Commit 6c991eac by Kai Westerkamp

Pfeiltasten wieder eingebaut

parent 5eb26b35
......@@ -35,7 +35,14 @@ void MainWidget::keyPressEvent(QKeyEvent *event){
}
else if (event->key() == Qt::Key_Plus){
cam->move(QVector3D(0.0,0.0,10));
} else{
}
else if(event->key() == Qt::Key_Right || event->key() == Qt::Key_D){
emit subdifChange(1);
}
else if(event->key() == Qt::Key_Left || event->key() == Qt::Key_A){
emit subdifChange(-1);
}
else{
QOpenGLWidget::keyPressEvent(event);
}
}
......@@ -146,7 +153,7 @@ void MainWidget::loadNewMesh(){
QString fn = QFileDialog::getOpenFileName(NULL, tr("Open Mesh..."),
QString("..\\Models"),
tr("*.md5mesh *.3ds *.md2 *.obj *.dae *.dxf *.mesh.xml *.blend *.b3d" ));
emit subdifChange(0);
loadNewMesh(fn);
}
......
......@@ -37,6 +37,9 @@ public slots:
void setWireframe(bool active);
void subdivide(int level);
signals:
void subdifChange(int value);
protected:
void initializeGL();
void paintGL();
......
......@@ -48,6 +48,7 @@ MainWindow::MainWindow(QWidget *parent) :
connect(subdivSlider, SIGNAL(valueChanged(int)),
this, SLOT(sliderfix(int)));
toolBar->addWidget(subdivSlider);
......@@ -55,9 +56,11 @@ MainWindow::MainWindow(QWidget *parent) :
m_centralWidget->setFocusPolicy(Qt::StrongFocus);
m_centralWidget->setFocus();
// showMaximized();
connect(m_centralWidget, SIGNAL(subdifChange(int)),this,SLOT(subdifChange(int)));
}
void MainWindow::sliderfix(int pos){
void MainWindow::sliderfix(int pos){
int move = pos -oldSliderpos;
move >0 ? move = 1 : move = -1;
int newPos = oldSliderpos+move;
......@@ -65,7 +68,15 @@ MainWindow::MainWindow(QWidget *parent) :
m_centralWidget->subdivide(newPos);
subdivSlider->setSliderPosition(newPos);
oldSliderpos = newPos;
}
void MainWindow::subdifChange(int change){
if(change == 0){
subdivSlider->setSliderPosition(0);
}
subdivSlider->setSliderPosition(subdivSlider->sliderPosition()+change);
m_centralWidget->subdivide(subdivSlider->sliderPosition());
}
MainWindow::~MainWindow()
{
......
......@@ -21,6 +21,7 @@ public:
public slots:
void sliderfix(int pos);
void subdifChange(int change);
private:
int oldSliderpos = 0;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment