void Base3DView::keyPressEvent(QKeyEvent *e) { if(e->key() == Qt::Key_O) { if(getCamera()->isOrthographic()) { fCamera = m_perspCamera; fCamera->copyTransformFrom(m_orthoCamera); updatePerspProjection(); m_hud->setCamera(fCamera); } else { fCamera = m_orthoCamera; fCamera->copyTransformFrom(m_perspCamera); updateOrthoProjection(); m_hud->setCamera(fCamera); } } switch (e->key()) { case Qt::Key_Space: clearSelection(); break; case Qt::Key_H: resetView(); break; case Qt::Key_BracketRight: growSelection(); break; case Qt::Key_BracketLeft: shrinkSelection(); break; case Qt::Key_Up: getCamera()->moveForward(23); break; case Qt::Key_Down: getCamera()->moveForward(-23); break; case Qt::Key_G: frameAll(); break; default: break; } QWidget::keyPressEvent(e); }
Viewport::Viewport(QWidget* parent) : QWidget(parent) { QVBoxLayout* layout = new QVBoxLayout(this); layout->setMargin(0); layout->setSpacing(0); m_gl_widget = MainWindow::instance().createGL<GLWidget>(this); layout->addWidget(m_gl_widget); QToolBar* tb = new QToolBar(this); tb->setFloatable(false); tb->setMovable(false); tb->setIconSize(QSize(16, 16)); layout->addWidget(tb); m_new_object = tb->addAction(QIcon(":/icons/new_object.png"), "New object", this, SLOT(newObject())); m_new_light = tb->addAction(QIcon(":/icons/new_light.png"), "New light", this, SLOT(newLight())); m_new_light->setEnabled(false); tb->addSeparator(); m_translate = tb->addAction(QIcon(":/icons/translate.png"), "Translate (W)", this, SLOT(translateGizmo())); m_translate->setCheckable(true); m_translate->setChecked(true); m_rotate = tb->addAction(QIcon(":/icons/rotate.png"), "Rotate (E)", this, SLOT(rotateGizmo())); m_rotate->setCheckable(true); m_rotate->setChecked(false); m_scale = tb->addAction(QIcon(":/icons/scale.png"), "Scale (R)", this, SLOT(scaleGizmo())); m_scale->setCheckable(true); m_scale->setChecked(false); m_scale->setEnabled(false); tb->addSeparator(); m_frame_selection = tb->addAction(QIcon(":/icons/frame.png"), "Frame selection (F)", this, SLOT(frameSelection())); m_frame_selection->setEnabled(false); m_frame_all = tb->addAction(QIcon(":/icons/frame_all.png"), "Frame all (A)", this, SLOT(frameAll())); m_frame_all->setEnabled(false); tb->addSeparator(); m_scene_mode = tb->addAction(QIcon(":/icons/blueprint.png"), "Blueprint mode (B)", this, SLOT(sceneMode())); m_scene_mode->setChecked(true); m_scene_mode->setEnabled(false); m_render_mode = tb->addAction(QIcon(":/icons/shader.png"), "Render mode (G)", this, SLOT(renderMode())); m_render_mode->setEnabled(false); tb->addSeparator(); m_delete_object = tb->addAction(QIcon(":/icons/delete.png"), "Delete object", this, SLOT(deleteObject())); translateGizmo(); }