void Osg3dView::setMouseMode() { QAction *a = dynamic_cast<QAction *>(sender()); if (!a) return; MouseMode mode = static_cast<MouseMode>(a->data().toUInt()); setMouseMode(mode); }
// -------------------------------------------------------------------------------------------------------- void KikiController::handleMouseButtonEvent ( SDL_MouseButtonEvent & event) { KEventHandler::handleMouseButtonEvent(event); if (event.state == SDL_RELEASED) { setMouseMode(KDL_MOUSE_MODE_ROTATE); } }
void OSGWidget::popState() { if (m_stashState.size() < 1) return; stashState state = m_stashState.last(); m_stashState.pop_back(); m_viewingCore->setViewingCoreMode(state.vcm); setMouseMode(state.mm); }
void OSGWidget::mousePressEvent( QMouseEvent* event ) { m_animateTimer.stop(); m_mouseReleaseJustHappened = false; m_lastMouseEventNDCoords = getNormalized(event->x(), event->y()); m_mouseButtons |= event->buttons(); m_mouseModifiers = event->modifiers(); // handle overrides if (m_mouseButtons == Qt::LeftButton) { if (m_mouseModifiers == Qt::ShiftModifier) { pushState(); m_viewingCore->setViewingCoreMode(ViewingCore::THIRD_PERSON); setMouseMode(MM_PAN); } else if (m_mouseModifiers == Qt::ControlModifier) { pushState(); m_viewingCore->setViewingCoreMode(ViewingCore::THIRD_PERSON); setMouseMode(MM_ORBIT); } else if ((unsigned)m_mouseModifiers == (unsigned)(Qt::ControlModifier | Qt::ShiftModifier) ) { pushState(); m_viewingCore->setViewingCoreMode(ViewingCore::THIRD_PERSON); setMouseMode(MM_ZOOM); } } else if (m_mouseButtons == Qt::RightButton) { m_viewingCore->pickCenter(m_lastMouseEventNDCoords.x(), m_lastMouseEventNDCoords.y() ); } // Do the job asked if (m_mouseMode & (MM_PAN|MM_ROTATE|MM_ORBIT|MM_ZOOM) ) m_viewingCore->setPanStart( m_lastMouseEventNDCoords.x(), m_lastMouseEventNDCoords.y() ); else if (m_mouseMode & MM_PICK_CENTER) { m_viewingCore->pickCenter(m_lastMouseEventNDCoords.x(), m_lastMouseEventNDCoords.y() ); } m_lastMouseEventTime.start(); }
ImageView::ImageView(QWidget *parent) : QLabel(parent) { setMouseTracking(true); m_minMaxLens = new QRubberBand(QRubberBand::Rectangle, this); m_rubberBand = new QRubberBand(QRubberBand::Rectangle, this); m_zoomLevel = 1.0f; setMouseMode(MM_PICK); //setFocusPolicy(Qt::StrongFocus); //setFocus(); }
void RGLView::setMouseCallbacks(int button, userControlPtr begin, userControlPtr update, userControlEndPtr end, userCleanupPtr cleanup, void** user) { int ind = button - 1; if (cleanupCallback[ind]) (*cleanupCallback[ind])(userData + 3*ind); beginCallback[ind] = begin; updateCallback[ind] = update; endCallback[ind] = end; cleanupCallback[ind] = cleanup; userData[3*ind + 0] = *(user++); userData[3*ind + 1] = *(user++); userData[3*ind + 2] = *user; setMouseMode(button, mmUSER); }
void Osg3dView::buildPopupMenu() { QAction *a; QMenu *sub = m_popupMenu.addMenu("MouseMode..."); a = sub->addAction("Orbit", this, SLOT(setMouseMode()), QKeySequence(Qt::Key_O)); a->setData(QVariant(MM_ORBIT)); a = sub->addAction("Pan", this, SLOT(setMouseMode()), QKeySequence(Qt::Key_P)); a->setData(QVariant(MM_PAN)); a = sub->addAction("Rotate", this, SLOT(setMouseMode()), QKeySequence(Qt::Key_R)); a->setData(QVariant(MM_ROTATE)); a = sub->addAction("Zoom", this, SLOT(setMouseMode()), QKeySequence(Qt::Key_Z)); a->setData(QVariant(MM_ZOOM)); a = sub->addAction("Pick Center", this, SLOT(setMouseMode()), QKeySequence(Qt::Key_C)); a->setData(QVariant(MM_PICK_CENTER)); a = sub->addAction("Select Object", this, SLOT(setMouseMode()), QKeySequence(Qt::Key_S)); a->setData(QVariant(MM_SELECT)); sub = m_popupMenu.addMenu("Std View..."); a = sub->addAction("Top", this, SLOT(setStandardView()), QKeySequence(Qt::SHIFT + Qt::Key_T)); a->setData(V_TOP); a = sub->addAction("Underside", this, SLOT(setStandardView()), QKeySequence(Qt::SHIFT + Qt::Key_U)); a->setData(V_BOTTOM); a = sub->addAction("Front", this, SLOT(setStandardView()), QKeySequence(Qt::SHIFT + Qt::Key_F)); a->setData(V_FRONT); a = sub->addAction("Back", this, SLOT(setStandardView()), QKeySequence(Qt::SHIFT + Qt::Key_B)); a->setData(V_BACK); a = sub->addAction("Right", this, SLOT(setStandardView()), QKeySequence(Qt::SHIFT + Qt::Key_R)); a->setData(V_RIGHT); a = sub->addAction("Left", this, SLOT(setStandardView()), QKeySequence(Qt::SHIFT + Qt::Key_L)); a->setData(V_LEFT); sub = m_popupMenu.addMenu("Projection..."); a = sub->addAction("Orthographic", this, SLOT(setProjection())); a->setData(P_ORTHO); a = sub->addAction("Perspective", this, SLOT(setProjection())); a->setData(P_PERSP); sub = m_popupMenu.addMenu("DrawMode..."); a = sub->addAction("Facets", this, SLOT(setDrawMode()), QKeySequence(Qt::Key_F)); a->setData(osg::PolygonMode::FILL); a = sub->addAction("Wireframe", this, SLOT(setDrawMode()), QKeySequence(Qt::Key_W)); a->setData(osg::PolygonMode::LINE); a = sub->addAction("Verticies", this, SLOT(setDrawMode()), QKeySequence(Qt::Key_V)); a->setData(osg::PolygonMode::POINT); sub = m_popupMenu.addMenu("Toggle..."); a = sub->addAction("MenuBar", this, SIGNAL(toggleMenuBar()), QKeySequence(Qt::CTRL+ Qt::Key_M)); a = sub->addAction("ToolBar", this, SIGNAL(toggleToolBar()), QKeySequence(Qt::CTRL+ Qt::Key_T)); }
void Osg3dView::keyPressEvent(QKeyEvent *event) { int key = event->key(); bool isShifted = event->modifiers() & Qt::ShiftModifier; switch (key) { case Qt::Key_M: if (event->modifiers() & Qt::ControlModifier) emit toggleMenuBar(); break; case Qt::Key_W: setDrawMode(osg::PolygonMode::LINE); update(); break; case Qt::Key_V: setDrawMode(osg::PolygonMode::POINT); update(); break; case Qt::Key_T: if (isShifted) { m_viewingCore->viewTop(); update(); } else if (event->modifiers() & Qt::ControlModifier) { emit toggleToolBar(); } break; case Qt::Key_L: if (isShifted) m_viewingCore->viewLeft(); update(); break; case Qt::Key_B: if (isShifted) m_viewingCore->viewBack(); update(); break; case Qt::Key_F: if (isShifted) { m_viewingCore->viewFront(); } else { setDrawMode(osg::PolygonMode::FILL); } update(); break; case Qt::Key_U: if (isShifted) m_viewingCore->viewBottom(); update(); break; case Qt::Key_O: setMouseMode(MM_ORBIT); break; case Qt::Key_P: setMouseMode(MM_PAN); break; case Qt::Key_Z: setMouseMode(MM_ZOOM); break; case Qt::Key_R: if (isShifted) { m_viewingCore->viewRight(); update(); }else setMouseMode(MM_ROTATE); break; case Qt::Key_C: setMouseMode(MM_PICK_CENTER); break; case Qt::Key_S: setMouseMode(MM_SELECT); break; } }
void RGLView::setDefaultMouseFunc() { setMouseMode(1, mmPOLAR); setMouseMode(2, mmFOV); setMouseMode(3, mmZOOM); }