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();
......
...@@ -34,11 +34,11 @@ MainWindow::MainWindow(QWidget *parent) : ...@@ -34,11 +34,11 @@ MainWindow::MainWindow(QWidget *parent) :
connect(CamHome, SIGNAL(triggered()), cam, SLOT(home())); connect(CamHome, SIGNAL(triggered()), cam, SLOT(home()));
toolBar->addAction(CamHome); toolBar->addAction(CamHome);
// debugOutput = new QAction("DebugOutput",this); // debugOutput = new QAction("DebugOutput",this);
// debugOutput->setCheckable(true); // debugOutput->setCheckable(true);
// debugOutput->setChecked(false); // debugOutput->setChecked(false);
// connect(debugOutput, SIGNAL(triggered(bool)), m_centralWidget, SLOT(setdebugOutput(bool))); // connect(debugOutput, SIGNAL(triggered(bool)), m_centralWidget, SLOT(setdebugOutput(bool)));
// toolBar->addAction(debugOutput); // toolBar->addAction(debugOutput);
subdivSlider = new QSlider(Qt::Horizontal); subdivSlider = new QSlider(Qt::Horizontal);
subdivSlider->setMinimum(0); subdivSlider->setMinimum(0);
...@@ -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,17 +56,27 @@ MainWindow::MainWindow(QWidget *parent) : ...@@ -55,17 +56,27 @@ 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;
// qDebug()<<"SliderPos"<<oldSliderpos<<move<<newPos; // qDebug()<<"SliderPos"<<oldSliderpos<<move<<newPos;
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