summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--glview.cc15
-rw-r--r--mainwin.cc63
-rw-r--r--openscad.h10
3 files changed, 81 insertions, 7 deletions
diff --git a/glview.cc b/glview.cc
index f443de0..3d25f25 100644
--- a/glview.cc
+++ b/glview.cc
@@ -212,6 +212,20 @@ void GLView::paintGL()
renderfunc(renderfunc_vp);
}
+void GLView::keyPressEvent(QKeyEvent *event)
+{
+ if (event->key() == Qt::Key_Plus) {
+ viewer_distance *= 0.9;
+ updateGL();
+ return;
+ }
+ if (event->key() == Qt::Key_Minus) {
+ viewer_distance /= 0.9;
+ updateGL();
+ return;
+ }
+}
+
void GLView::wheelEvent(QWheelEvent *event)
{
viewer_distance *= pow(0.9, event->delta() / 120.0);
@@ -224,6 +238,7 @@ void GLView::mousePressEvent(QMouseEvent *event)
last_mouse_x = event->globalX();
last_mouse_y = event->globalY();
grabMouse();
+ setFocus();
}
void GLView::mouseMoveEvent(QMouseEvent *event)
diff --git a/mainwin.cc b/mainwin.cc
index 990ed6b..564a5a1 100644
--- a/mainwin.cc
+++ b/mainwin.cc
@@ -165,13 +165,13 @@ MainWindow::MainWindow(const char *filename)
actViewModeAnimate->setCheckable(true);
menu->addSeparator();
- menu->addAction("Top");
- menu->addAction("Bottom");
- menu->addAction("Left");
- menu->addAction("Right");
- menu->addAction("Front");
- menu->addAction("Back");
- menu->addAction("Diagonal");
+ menu->addAction("Top", this, SLOT(viewAngleTop()));
+ menu->addAction("Bottom", this, SLOT(viewAngleBottom()));
+ menu->addAction("Left", this, SLOT(viewAngleLeft()));
+ menu->addAction("Right", this, SLOT(viewAngleRight()));
+ menu->addAction("Front", this, SLOT(viewAngleFront()));
+ menu->addAction("Back", this, SLOT(viewAngleBack()));
+ menu->addAction("Diagonal", this, SLOT(viewAngleDiagonal()));
menu->addSeparator();
menu->addAction("Perspective");
menu->addAction("Orthogonal");
@@ -1124,3 +1124,52 @@ void MainWindow::viewModeAnimate()
}
}
+void MainWindow::viewAngleTop()
+{
+ screen->object_rot_y = 90;
+ screen->object_rot_z = 0;
+ screen->updateGL();
+}
+
+void MainWindow::viewAngleBottom()
+{
+ screen->object_rot_y = 270;
+ screen->object_rot_z = 0;
+ screen->updateGL();
+}
+
+void MainWindow::viewAngleLeft()
+{
+ screen->object_rot_y = 0;
+ screen->object_rot_z = 90;
+ screen->updateGL();
+}
+
+void MainWindow::viewAngleRight()
+{
+ screen->object_rot_y = 0;
+ screen->object_rot_z = 270;
+ screen->updateGL();
+}
+
+void MainWindow::viewAngleFront()
+{
+ screen->object_rot_y = 0;
+ screen->object_rot_z = 0;
+ screen->updateGL();
+}
+
+void MainWindow::viewAngleBack()
+{
+ screen->object_rot_y = 0;
+ screen->object_rot_z = 180;
+ screen->updateGL();
+}
+
+void MainWindow::viewAngleDiagonal()
+{
+ screen->object_rot_y = 35;
+ screen->object_rot_z = 25;
+ screen->updateGL();
+}
+
diff --git a/openscad.h b/openscad.h
index b6b0b47..0088723 100644
--- a/openscad.h
+++ b/openscad.h
@@ -658,6 +658,7 @@ protected:
int last_mouse_x;
int last_mouse_y;
+ void keyPressEvent(QKeyEvent *event);
void wheelEvent(QWheelEvent *event);
void mousePressEvent(QMouseEvent *event);
void mouseMoveEvent(QMouseEvent *event);
@@ -763,6 +764,15 @@ private slots:
void viewModeThrownTogether();
void viewModeShowEdges();
void viewModeAnimate();
+
+private slots:
+ void viewAngleTop();
+ void viewAngleBottom();
+ void viewAngleLeft();
+ void viewAngleRight();
+ void viewAngleFront();
+ void viewAngleBack();
+ void viewAngleDiagonal();
};
extern AbstractModule *parse(const char *text, int debug);
contact: Jan Huwald // Impressum