Commit 6c991eac by Kai Westerkamp

Pfeiltasten wieder eingebaut

parent 5eb26b35
...@@ -35,7 +35,14 @@ void MainWidget::keyPressEvent(QKeyEvent *event){ ...@@ -35,7 +35,14 @@ void MainWidget::keyPressEvent(QKeyEvent *event){
} }
else if (event->key() == Qt::Key_Plus){ else if (event->key() == Qt::Key_Plus){
cam->move(QVector3D(0.0,0.0,10)); 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); QOpenGLWidget::keyPressEvent(event);
} }
} }
...@@ -146,7 +153,7 @@ void MainWidget::loadNewMesh(){ ...@@ -146,7 +153,7 @@ void MainWidget::loadNewMesh(){
QString fn = QFileDialog::getOpenFileName(NULL, tr("Open Mesh..."), QString fn = QFileDialog::getOpenFileName(NULL, tr("Open Mesh..."),
QString("..\\Models"), QString("..\\Models"),
tr("*.md5mesh *.3ds *.md2 *.obj *.dae *.dxf *.mesh.xml *.blend *.b3d" )); tr("*.md5mesh *.3ds *.md2 *.obj *.dae *.dxf *.mesh.xml *.blend *.b3d" ));
emit subdifChange(0);
loadNewMesh(fn); loadNewMesh(fn);
} }
......
...@@ -37,6 +37,9 @@ public slots: ...@@ -37,6 +37,9 @@ public slots:
void setWireframe(bool active); void setWireframe(bool active);
void subdivide(int level); void subdivide(int level);
signals:
void subdifChange(int value);
protected: protected:
void initializeGL(); void initializeGL();
void paintGL(); void paintGL();
......
...@@ -48,6 +48,7 @@ MainWindow::MainWindow(QWidget *parent) : ...@@ -48,6 +48,7 @@ MainWindow::MainWindow(QWidget *parent) :
connect(subdivSlider, SIGNAL(valueChanged(int)), connect(subdivSlider, SIGNAL(valueChanged(int)),
this, SLOT(sliderfix(int))); this, SLOT(sliderfix(int)));
toolBar->addWidget(subdivSlider); toolBar->addWidget(subdivSlider);
...@@ -55,9 +56,11 @@ MainWindow::MainWindow(QWidget *parent) : ...@@ -55,9 +56,11 @@ MainWindow::MainWindow(QWidget *parent) :
m_centralWidget->setFocusPolicy(Qt::StrongFocus); m_centralWidget->setFocusPolicy(Qt::StrongFocus);
m_centralWidget->setFocus(); m_centralWidget->setFocus();
// showMaximized(); // 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; int move = pos -oldSliderpos;
move >0 ? move = 1 : move = -1; move >0 ? move = 1 : move = -1;
int newPos = oldSliderpos+move; int newPos = oldSliderpos+move;
...@@ -65,7 +68,15 @@ MainWindow::MainWindow(QWidget *parent) : ...@@ -65,7 +68,15 @@ MainWindow::MainWindow(QWidget *parent) :
m_centralWidget->subdivide(newPos); m_centralWidget->subdivide(newPos);
subdivSlider->setSliderPosition(newPos); subdivSlider->setSliderPosition(newPos);
oldSliderpos = 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() MainWindow::~MainWindow()
{ {
......
...@@ -21,6 +21,7 @@ public: ...@@ -21,6 +21,7 @@ public:
public slots: public slots:
void sliderfix(int pos); void sliderfix(int pos);
void subdifChange(int change);
private: private:
int oldSliderpos = 0; 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