void Gource::mouseClick(SDL_MouseButtonEvent *e) { if(e->type != SDL_MOUSEBUTTONDOWN || commitlog==0) return; //wheel up if(e->button == SDL_BUTTON_WHEELUP) { zoom(true); return; } //wheel down if(e->button == SDL_BUTTON_WHEELDOWN) { zoom(false); return; } if(e->button == SDL_BUTTON_RIGHT) { toggleCameraMode(); return; } if(e->button == SDL_BUTTON_LEFT) { mousepos = vec2f(e->x, e->y); mouseclicked=true; if(canSeek()) { float position; if(slider.click(mousepos, &position)) { seekTo(position); } } } }
void gameKeypressCallback(int key, int action) { if (action) { if (key == GLFW_KEY_ESC) { Quit = true; } #ifdef DEVEL_FREECAMERA_KEY else if (key == 'G') { toggleCameraMode(); } #endif } }
int QGLViewer::qt_metacall(QMetaObject::Call _c, int _id, void **_a) { _id = QGLWidget::qt_metacall(_c, _id, _a); if (_id < 0) return _id; if (_c == QMetaObject::InvokeMetaMethod) { switch (_id) { case 0: viewerInitialized(); break; case 1: drawNeeded(); break; case 2: drawFinished((*reinterpret_cast< bool(*)>(_a[1]))); break; case 3: animateNeeded(); break; case 4: helpRequired(); break; case 5: axisIsDrawnChanged((*reinterpret_cast< bool(*)>(_a[1]))); break; case 6: gridIsDrawnChanged((*reinterpret_cast< bool(*)>(_a[1]))); break; case 7: FPSIsDisplayedChanged((*reinterpret_cast< bool(*)>(_a[1]))); break; case 8: textIsEnabledChanged((*reinterpret_cast< bool(*)>(_a[1]))); break; case 9: cameraIsEditedChanged((*reinterpret_cast< bool(*)>(_a[1]))); break; case 10: stereoChanged((*reinterpret_cast< bool(*)>(_a[1]))); break; case 11: pointSelected((*reinterpret_cast< const QMouseEvent*(*)>(_a[1]))); break; case 12: mouseGrabberChanged((*reinterpret_cast< qglviewer::MouseGrabber*(*)>(_a[1]))); break; case 13: setAxisIsDrawn((*reinterpret_cast< bool(*)>(_a[1]))); break; case 14: setAxisIsDrawn(); break; case 15: setGridIsDrawn((*reinterpret_cast< bool(*)>(_a[1]))); break; case 16: setGridIsDrawn(); break; case 17: setFPSIsDisplayed((*reinterpret_cast< bool(*)>(_a[1]))); break; case 18: setFPSIsDisplayed(); break; case 19: setTextIsEnabled((*reinterpret_cast< bool(*)>(_a[1]))); break; case 20: setTextIsEnabled(); break; case 21: setCameraIsEdited((*reinterpret_cast< bool(*)>(_a[1]))); break; case 22: setCameraIsEdited(); break; case 23: toggleAxisIsDrawn(); break; case 24: toggleGridIsDrawn(); break; case 25: toggleFPSIsDisplayed(); break; case 26: toggleTextIsEnabled(); break; case 27: toggleCameraIsEdited(); break; case 28: setBackgroundColor((*reinterpret_cast< const QColor(*)>(_a[1]))); break; case 29: setForegroundColor((*reinterpret_cast< const QColor(*)>(_a[1]))); break; case 30: setSceneRadius((*reinterpret_cast< float(*)>(_a[1]))); break; case 31: setSceneCenter((*reinterpret_cast< const qglviewer::Vec(*)>(_a[1]))); break; case 32: setSceneBoundingBox((*reinterpret_cast< const qglviewer::Vec(*)>(_a[1])),(*reinterpret_cast< const qglviewer::Vec(*)>(_a[2]))); break; case 33: showEntireScene(); break; case 34: setCamera((*reinterpret_cast< qglviewer::Camera*const(*)>(_a[1]))); break; case 35: setManipulatedFrame((*reinterpret_cast< qglviewer::ManipulatedFrame*(*)>(_a[1]))); break; case 36: setMouseGrabber((*reinterpret_cast< qglviewer::MouseGrabber*(*)>(_a[1]))); break; case 37: setFullScreen((*reinterpret_cast< bool(*)>(_a[1]))); break; case 38: setFullScreen(); break; case 39: setStereoDisplay((*reinterpret_cast< bool(*)>(_a[1]))); break; case 40: setStereoDisplay(); break; case 41: toggleFullScreen(); break; case 42: toggleStereoDisplay(); break; case 43: toggleCameraMode(); break; case 44: saveSnapshot((*reinterpret_cast< bool(*)>(_a[1])),(*reinterpret_cast< bool(*)>(_a[2]))); break; case 45: saveSnapshot((*reinterpret_cast< bool(*)>(_a[1]))); break; case 46: saveSnapshot(); break; case 47: saveSnapshot((*reinterpret_cast< const QString(*)>(_a[1])),(*reinterpret_cast< bool(*)>(_a[2]))); break; case 48: saveSnapshot((*reinterpret_cast< const QString(*)>(_a[1]))); break; case 49: setSnapshotFileName((*reinterpret_cast< const QString(*)>(_a[1]))); break; case 50: setSnapshotFormat((*reinterpret_cast< const QString(*)>(_a[1]))); break; case 51: setSnapshotCounter((*reinterpret_cast< int(*)>(_a[1]))); break; case 52: setSnapshotQuality((*reinterpret_cast< int(*)>(_a[1]))); break; case 53: { bool _r = openSnapshotFormatDialog(); if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; } break; case 54: snapshotToClipboard(); break; case 55: copyBufferToTexture((*reinterpret_cast< GLint(*)>(_a[1])),(*reinterpret_cast< GLenum(*)>(_a[2]))); break; case 56: copyBufferToTexture((*reinterpret_cast< GLint(*)>(_a[1]))); break; case 57: setAnimationPeriod((*reinterpret_cast< int(*)>(_a[1]))); break; case 58: startAnimation(); break; case 59: stopAnimation(); break; case 60: animate(); break; case 61: toggleAnimation(); break; case 62: help(); break; case 63: aboutQGLViewer(); break; case 64: select((*reinterpret_cast< const QMouseEvent*(*)>(_a[1]))); break; case 65: select((*reinterpret_cast< const QPoint(*)>(_a[1]))); break; case 66: setSelectBufferSize((*reinterpret_cast< int(*)>(_a[1]))); break; case 67: setSelectRegionWidth((*reinterpret_cast< int(*)>(_a[1]))); break; case 68: setSelectRegionHeight((*reinterpret_cast< int(*)>(_a[1]))); break; case 69: setSelectedName((*reinterpret_cast< int(*)>(_a[1]))); break; case 70: setShortcut((*reinterpret_cast< KeyboardAction(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 71: setKeyboardAccelerator((*reinterpret_cast< KeyboardAction(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 72: setKeyDescription((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< QString(*)>(_a[2]))); break; case 73: setKeyFrameKey((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 74: setPlayKeyFramePathStateKey((*reinterpret_cast< int(*)>(_a[1]))); break; case 75: setPlayPathStateKey((*reinterpret_cast< int(*)>(_a[1]))); break; case 76: setAddKeyFrameStateKey((*reinterpret_cast< int(*)>(_a[1]))); break; case 77: setPathKey((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 78: setPathKey((*reinterpret_cast< int(*)>(_a[1]))); break; case 79: setPlayPathKeyboardModifiers((*reinterpret_cast< QtKeyboardModifiers(*)>(_a[1]))); break; case 80: setAddKeyFrameKeyboardModifiers((*reinterpret_cast< QtKeyboardModifiers(*)>(_a[1]))); break; case 81: setMouseBinding((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< MouseHandler(*)>(_a[2])),(*reinterpret_cast< MouseAction(*)>(_a[3])),(*reinterpret_cast< bool(*)>(_a[4]))); break; case 82: setMouseBinding((*reinterpret_cast< int(*)>(_a[1])),(*reinterpret_cast< MouseHandler(*)>(_a[2])),(*reinterpret_cast< MouseAction(*)>(_a[3]))); break; case 83: setWheelBinding((*reinterpret_cast< QtKeyboardModifiers(*)>(_a[1])),(*reinterpret_cast< MouseHandler(*)>(_a[2])),(*reinterpret_cast< MouseAction(*)>(_a[3])),(*reinterpret_cast< bool(*)>(_a[4]))); break; case 84: setWheelBinding((*reinterpret_cast< QtKeyboardModifiers(*)>(_a[1])),(*reinterpret_cast< MouseHandler(*)>(_a[2])),(*reinterpret_cast< MouseAction(*)>(_a[3]))); break; case 85: setHandlerKeyboardModifiers((*reinterpret_cast< MouseHandler(*)>(_a[1])),(*reinterpret_cast< QtKeyboardModifiers(*)>(_a[2]))); break; case 86: setHandlerStateKey((*reinterpret_cast< MouseHandler(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 87: setMouseStateKey((*reinterpret_cast< MouseHandler(*)>(_a[1])),(*reinterpret_cast< int(*)>(_a[2]))); break; case 88: initFromDOMElement((*reinterpret_cast< const QDomElement(*)>(_a[1]))); break; case 89: saveStateToFile(); break; case 90: { bool _r = restoreStateFromFile(); if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; } break; case 91: setStateFileName((*reinterpret_cast< const QString(*)>(_a[1]))); break; case 92: saveToFile((*reinterpret_cast< const QString(*)>(_a[1]))); break; case 93: saveToFile(); break; case 94: { bool _r = restoreFromFile((*reinterpret_cast< const QString(*)>(_a[1]))); if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; } break; case 95: { bool _r = restoreFromFile(); if (_a[0]) *reinterpret_cast< bool*>(_a[0]) = _r; } break; case 96: resetVisualHints(); break; case 97: delayedFullScreen(); break; case 98: hideMessage(); break; default: ; } _id -= 99; } return _id; }
QMenu* SimObjectWidget::createUserMenu() const { QMenu* menu = new QMenu(tr(&object == Simulation::simulation->scene ? "S&cene" : "&Object")); QSignalMapper* flagsSignalMapper = new QSignalMapper(menu); connect(flagsSignalMapper, SIGNAL(mapped(int)), SLOT(toggleRenderFlag(int))); { QMenu* subMenu = menu->addMenu(tr("&Drag and Drop")); QAction* action = subMenu->menuAction(); action->setIcon(QIcon(":/Icons/DragPlane.png")); action->setStatusTip(tr("Select the drag and drop dynamics mode and plane along which operations are performed")); QActionGroup* actionGroup = new QActionGroup(subMenu); QSignalMapper* signalMapper = new QSignalMapper(subMenu); connect(signalMapper, SIGNAL(mapped(int)), SLOT(setDragPlane(int))); action = subMenu->addAction(tr("X/Y Plane")); actionGroup->addAction(action); signalMapper->setMapping(action, SimRobotCore2::Renderer::xyPlane); action->setShortcut(QKeySequence(Qt::Key_Z)); action->setCheckable(true); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("X/Z Plane")); actionGroup->addAction(action); signalMapper->setMapping(action, SimRobotCore2::Renderer::xzPlane); action->setShortcut(QKeySequence(Qt::Key_Y)); action->setCheckable(true); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("Y/Z Plane")); actionGroup->addAction(action); signalMapper->setMapping(action, SimRobotCore2::Renderer::yzPlane); action->setShortcut(QKeySequence(Qt::Key_X)); action->setCheckable(true); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); qobject_cast<QAction*>(signalMapper->mapping(objectRenderer.getDragPlane()))->setChecked(true); subMenu->addSeparator(); actionGroup = new QActionGroup(subMenu); signalMapper = new QSignalMapper(subMenu); connect(signalMapper, SIGNAL(mapped(int)), SLOT(setDragMode(int))); action = subMenu->addAction(tr("&Keep Dynamics")); actionGroup->addAction(action); signalMapper->setMapping(action, SimRobotCore2::Renderer::keepDynamics); action->setShortcut(QKeySequence(Qt::Key_7)); action->setCheckable(true); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("&Reset Dynamics")); actionGroup->addAction(action); signalMapper->setMapping(action, SimRobotCore2::Renderer::resetDynamics); action->setShortcut(QKeySequence(Qt::Key_8)); action->setCheckable(true); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("A&dopt Dynamics")); actionGroup->addAction(action); signalMapper->setMapping(action, SimRobotCore2::Renderer::adoptDynamics); action->setShortcut(QKeySequence(Qt::Key_9)); action->setCheckable(true); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("&Apply Dynamics")); actionGroup->addAction(action); signalMapper->setMapping(action, SimRobotCore2::Renderer::applyDynamics); action->setShortcut(QKeySequence(Qt::Key_0)); action->setCheckable(true); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); qobject_cast<QAction*>(signalMapper->mapping(objectRenderer.getDragMode()))->setChecked(true); } menu->addSeparator(); { QMenu* subMenu = menu->addMenu(tr("&Camera")); QAction* action = subMenu->menuAction(); action->setIcon(QIcon(":/Icons/camera.png")); action->setStatusTip(tr("Select different camera modes for displaying the scene")); QActionGroup* actionGroup = new QActionGroup(subMenu); QSignalMapper* signalMapper = new QSignalMapper(subMenu); connect(signalMapper, SIGNAL(mapped(int)), SLOT(setCameraMode(int))); action = subMenu->addAction(tr("&Target Mode")); action->setCheckable(true); actionGroup->addAction(action); signalMapper->setMapping(action, SimRobotCore2::Renderer::targetCam); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("&Free Mode")); action->setCheckable(true); actionGroup->addAction(action); signalMapper->setMapping(action, SimRobotCore2::Renderer::freeCam); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); qobject_cast<QAction*>(signalMapper->mapping(objectRenderer.getCameraMode()))->setChecked(true); subMenu->addSeparator(); action = subMenu->addAction(tr("&Reset")); action->setShortcut(QKeySequence(Qt::Key_R)); connect(action, SIGNAL(triggered()), this, SLOT(resetCamera())); action = subMenu->addAction(tr("&Toggle")); action->setShortcut(QKeySequence(Qt::Key_T)); connect(action, SIGNAL(triggered()), this, SLOT(toggleCameraMode())); /* action = subMenu->addAction(tr("&Fit")); action->setShortcut(QKeySequence(Qt::Key_F)); connect(action, SIGNAL(triggered()), this, SLOT(fitCamera())); subMenu->addSeparator(); */ } { QMenu* subMenu = menu->addMenu(tr("&Vertical Opening Angle")); QAction* action = subMenu->menuAction(); action->setIcon(QIcon(":/Icons/opening_angle.png")); QActionGroup* actionGroup = new QActionGroup(subMenu); QSignalMapper* signalMapper = new QSignalMapper(subMenu); connect(signalMapper, SIGNAL(mapped(int)), SLOT(setFovY(int))); action = subMenu->addAction(tr("&20°")); actionGroup->addAction(action); signalMapper->setMapping(action, 20); action->setShortcut(QKeySequence(Qt::Key_1)); action->setCheckable(true); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("&40°")); actionGroup->addAction(action); signalMapper->setMapping(action, 40); action->setShortcut(QKeySequence(Qt::Key_2)); action->setCheckable(true); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("&60°")); actionGroup->addAction(action); signalMapper->setMapping(action, 60); action->setShortcut(QKeySequence(Qt::Key_3)); action->setCheckable(true); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("&80°")); actionGroup->addAction(action); signalMapper->setMapping(action, 80); action->setShortcut(QKeySequence(Qt::Key_4)); action->setCheckable(true); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("100°")); actionGroup->addAction(action); signalMapper->setMapping(action, 100); action->setShortcut(QKeySequence(Qt::Key_5)); action->setCheckable(true); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("120°")); actionGroup->addAction(action); signalMapper->setMapping(action, 120); action->setShortcut(QKeySequence(Qt::Key_6)); action->setCheckable(true); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); qobject_cast<QAction*>(signalMapper->mapping(objectRenderer.getFovY()))->setChecked(true); } menu->addSeparator(); { QMenu* subMenu = menu->addMenu(tr("&Appearances Rendering")); QActionGroup* actionGroup = new QActionGroup(subMenu); QSignalMapper* signalMapper = new QSignalMapper(subMenu); connect(signalMapper, SIGNAL(mapped(int)), SLOT(setSurfaceShadeMode(int))); QAction* action = subMenu->menuAction(); action->setIcon(QIcon(":/Icons/layers.png")); action->setStatusTip(tr("Select different shading techniques for displaying the scene")); action = subMenu->addAction(tr("&Off")); actionGroup->addAction(action); //action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_W)); action->setCheckable(true); signalMapper->setMapping(action, SimRobotCore2::Renderer::noShading); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("&Wire Frame")); actionGroup->addAction(action); action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_W)); action->setCheckable(true); signalMapper->setMapping(action, SimRobotCore2::Renderer::wireframeShading); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("&Flat Shading")); actionGroup->addAction(action); action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_F)); action->setCheckable(true); signalMapper->setMapping(action, SimRobotCore2::Renderer::flatShading); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("&Smooth Shading")); actionGroup->addAction(action); action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); action->setCheckable(true); signalMapper->setMapping(action, SimRobotCore2::Renderer::smoothShading); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); qobject_cast<QAction*>(signalMapper->mapping(objectRenderer.getSurfaceShadeMode()))->setChecked(true); } { QMenu* subMenu = menu->addMenu(tr("&Physics Rendering")); QActionGroup* actionGroup = new QActionGroup(subMenu); QSignalMapper* signalMapper = new QSignalMapper(subMenu); connect(signalMapper, SIGNAL(mapped(int)), SLOT(setPhysicsShadeMode(int))); QAction* action = subMenu->menuAction(); //action->setIcon(QIcon(":/Icons/layers.png")); action->setStatusTip(tr("Select different shading techniques for displaying the physical representation of objects")); action = subMenu->addAction(tr("&Off")); actionGroup->addAction(action); //action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_W)); action->setCheckable(true); signalMapper->setMapping(action, SimRobotCore2::Renderer::noShading); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("&Wire Frame")); actionGroup->addAction(action); //action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_W)); action->setCheckable(true); signalMapper->setMapping(action, SimRobotCore2::Renderer::wireframeShading); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("&Flat Shading")); actionGroup->addAction(action); //action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_F)); action->setCheckable(true); signalMapper->setMapping(action, SimRobotCore2::Renderer::flatShading); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("&Smooth Shading")); actionGroup->addAction(action); //action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); action->setCheckable(true); signalMapper->setMapping(action, SimRobotCore2::Renderer::smoothShading); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); qobject_cast<QAction*>(signalMapper->mapping(objectRenderer.getPhysicsShadeMode()))->setChecked(true); } { QMenu* subMenu = menu->addMenu(tr("&Drawings Rendering")); QActionGroup* actionGroup = new QActionGroup(subMenu); QSignalMapper* signalMapper = new QSignalMapper(subMenu); connect(signalMapper, SIGNAL(mapped(int)), SLOT(setDrawingsShadeMode(int))); QAction* action = subMenu->menuAction(); action->setIcon(QIcon(":/Icons/chart_line.png")); action->setStatusTip(tr("Select different shading techniques for displaying controller drawings")); action = subMenu->addAction(tr("&Off")); actionGroup->addAction(action); //action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_W)); action->setCheckable(true); signalMapper->setMapping(action, SimRobotCore2::Renderer::noShading); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("&Wire Frame")); actionGroup->addAction(action); //action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_W)); action->setCheckable(true); signalMapper->setMapping(action, SimRobotCore2::Renderer::wireframeShading); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("&Flat Shading")); actionGroup->addAction(action); //action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_F)); action->setCheckable(true); signalMapper->setMapping(action, SimRobotCore2::Renderer::flatShading); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("&Smooth Shading")); actionGroup->addAction(action); //action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); action->setCheckable(true); signalMapper->setMapping(action, SimRobotCore2::Renderer::smoothShading); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); qobject_cast<QAction*>(signalMapper->mapping(objectRenderer.getDrawingsShadeMode()))->setChecked(true); subMenu->addSeparator(); subMenu = subMenu->addMenu(tr("&Occlusion")); actionGroup = new QActionGroup(subMenu); signalMapper = new QSignalMapper(subMenu); connect(signalMapper, SIGNAL(mapped(int)), SLOT(setDrawingsOcclusion(int))); action = subMenu->menuAction(); action->setStatusTip(tr("Select different drawings occlusion modes")); action = subMenu->addAction(tr("&On")); actionGroup->addAction(action); action->setCheckable(true); signalMapper->setMapping(action, SimRobotCore2::Renderer::enableDrawingsOcclusion); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("O&ff")); actionGroup->addAction(action); action->setCheckable(true); signalMapper->setMapping(action, 0); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("&Transparent")); actionGroup->addAction(action); action->setCheckable(true); signalMapper->setMapping(action, SimRobotCore2::Renderer::enableDrawingsTransparentOcclusion); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); qobject_cast<QAction*>(signalMapper->mapping(objectRenderer.getRenderFlags() & (SimRobotCore2::Renderer::enableDrawingsOcclusion | SimRobotCore2::Renderer::enableDrawingsTransparentOcclusion)))->setChecked(true); } menu->addSeparator(); QAction* action = menu->addAction(tr("Enable &Lights")); action->setStatusTip(tr("Enable lightning")); action->setCheckable(true); action->setChecked(objectRenderer.getRenderFlags() & SimRobotCore2::Renderer::enableLights); flagsSignalMapper->setMapping(action, SimRobotCore2::Renderer::enableLights); connect(action, SIGNAL(triggered()), flagsSignalMapper, SLOT(map())); action = menu->addAction(tr("Enable &Textures")); action->setStatusTip(tr("Enable textures")); action->setCheckable(true); action->setChecked(objectRenderer.getRenderFlags() & SimRobotCore2::Renderer::enableTextures); flagsSignalMapper->setMapping(action, SimRobotCore2::Renderer::enableTextures); connect(action, SIGNAL(triggered()), flagsSignalMapper, SLOT(map())); action = menu->addAction(tr("Enable &Multisample")); action->setStatusTip(tr("Enable multisampling")); action->setCheckable(true); action->setChecked(objectRenderer.getRenderFlags() & SimRobotCore2::Renderer::enableMultisample); flagsSignalMapper->setMapping(action, SimRobotCore2::Renderer::enableMultisample); connect(action, SIGNAL(triggered()), flagsSignalMapper, SLOT(map())); menu->addSeparator(); action = menu->addAction(tr("Show &Coordinate System")); action->setStatusTip(tr("Show the coordinate system of the displayed object")); action->setCheckable(true); action->setChecked(objectRenderer.getRenderFlags() & SimRobotCore2::Renderer::showCoordinateSystem); flagsSignalMapper->setMapping(action, SimRobotCore2::Renderer::showCoordinateSystem); connect(action, SIGNAL(triggered()), flagsSignalMapper, SLOT(map())); action = menu->addAction(QIcon(":/Icons/transmit_go.png"), tr("Show &Sensors")); action->setStatusTip(tr("Show the values of the sensors in the scene view")); action->setCheckable(true); action->setChecked(objectRenderer.getRenderFlags() & SimRobotCore2::Renderer::showSensors); flagsSignalMapper->setMapping(action, SimRobotCore2::Renderer::showSensors); connect(action, SIGNAL(triggered()), flagsSignalMapper, SLOT(map())); menu->addSeparator(); { QMenu* subMenu = menu->addMenu(tr("Export as Image...")); QSignalMapper* signalMapper = new QSignalMapper(subMenu); connect(signalMapper, SIGNAL(mapped(int)), SLOT(exportAsImage(int))); action = subMenu->addAction(tr("3840x2160")); signalMapper->setMapping(action, (3840 << 16) | 2160); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("2880x1620")); signalMapper->setMapping(action, (2880 << 16) | 1620); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("1920x1080")); signalMapper->setMapping(action, (1920 << 16) | 1080); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("1280x1024")); signalMapper->setMapping(action, (1280 << 16) | 1024); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); } return menu; }
QMenu* ObjectWidget::createPopupMenu() { QMenu* menu = new QMenu(tr("&Object")); QAction* action; action = menu->addAction(QIcon(":/icons/page_copy.png"), tr("&Copy")); action->setShortcut(QKeySequence(QKeySequence::Copy)); action->setStatusTip(tr("Copy the current selection's contents or view to the clipboard")); connect(action, SIGNAL(triggered()), this, SLOT(copy())); menu->addSeparator(); QMenu* subMenu = menu->addMenu(tr("&Drag and Drop")); action = subMenu->menuAction(); action->setIcon(QIcon(":/icons/DragPlane.png")); action->setStatusTip(tr("Select the drag and drop dynamics mode and plane along which operations are performed")); QActionGroup* actionGroup = new QActionGroup(subMenu); QSignalMapper* signalMapper = new QSignalMapper(subMenu); connect(signalMapper, SIGNAL(mapped(int)), SLOT(setDragPlane(int))); action = subMenu->addAction(tr("X/Y Plane")); actionGroup->addAction(action); signalMapper->setMapping(action, XY_PLANE); action->setShortcut(QKeySequence(Qt::Key_Z)); action->setCheckable(true); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("X/Z Plane")); actionGroup->addAction(action); signalMapper->setMapping(action, XZ_PLANE); action->setShortcut(QKeySequence(Qt::Key_Y)); action->setCheckable(true); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("Y/Z Plane")); actionGroup->addAction(action); signalMapper->setMapping(action, YZ_PLANE); action->setShortcut(QKeySequence(Qt::Key_X)); action->setCheckable(true); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); qobject_cast<QAction*>(signalMapper->mapping(objectRenderer.getDragPlane()))->setChecked(true); subMenu->addSeparator(); actionGroup = new QActionGroup(subMenu); signalMapper = new QSignalMapper(subMenu); connect(signalMapper, SIGNAL(mapped(int)), SLOT(setDragMode(int))); action = subMenu->addAction(tr("&Keep Dynamics")); actionGroup->addAction(action); signalMapper->setMapping(action, KEEP_DYNAMICS); action->setShortcut(QKeySequence(Qt::Key_8)); action->setCheckable(true); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("&Reset Dynamics")); actionGroup->addAction(action); signalMapper->setMapping(action, RESET_DYNAMICS); action->setShortcut(QKeySequence(Qt::Key_9)); action->setCheckable(true); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("&Apply Dynamics")); actionGroup->addAction(action); signalMapper->setMapping(action, APPLY_DYNAMICS); action->setShortcut(QKeySequence(Qt::Key_0)); action->setCheckable(true); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); qobject_cast<QAction*>(signalMapper->mapping(objectRenderer.getDragMode()))->setChecked(true); menu->addSeparator(); subMenu = menu->addMenu(tr("&Camera")); action = subMenu->menuAction(); action->setIcon(QIcon(":/icons/camera.png")); action->setStatusTip(tr("Select different camera modes for displaying the scene")); actionGroup = new QActionGroup(subMenu); signalMapper = new QSignalMapper(subMenu); connect(signalMapper, SIGNAL(mapped(int)), SLOT(setCameraMode(int))); action = subMenu->addAction(tr("&Target Mode")); action->setCheckable(true); actionGroup->addAction(action); signalMapper->setMapping(action, VisualizationParameterSet::TARGETCAM); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("&Free Mode")); action->setCheckable(true); actionGroup->addAction(action); signalMapper->setMapping(action, VisualizationParameterSet::FREECAM); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("&Presentation Mode")); action->setCheckable(true); actionGroup->addAction(action); signalMapper->setMapping(action, VisualizationParameterSet::PRESENTATION); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); qobject_cast<QAction*>(signalMapper->mapping(objectRenderer.getCameraMode()))->setChecked(true); subMenu->addSeparator(); action = subMenu->addAction(tr("&Reset")); action->setShortcut(QKeySequence(Qt::Key_R)); connect(action, SIGNAL(triggered()), this, SLOT(resetCamera())); action = subMenu->addAction(tr("&Toggle")); action->setShortcut(QKeySequence(Qt::Key_T)); connect(action, SIGNAL(triggered()), this, SLOT(toggleCameraMode())); action = subMenu->addAction(tr("&Fit")); action->setShortcut(QKeySequence(Qt::Key_F)); connect(action, SIGNAL(triggered()), this, SLOT(fitCamera())); subMenu->addSeparator(); action = subMenu->addAction(tr("&Snap To Root")); action->setCheckable(true); action->setChecked(objectRenderer.hasSnapToRoot()); connect(action, SIGNAL(triggered()), this, SLOT(snapToRoot())); subMenu = menu->addMenu(tr("&Vertical Opening Angle")); action = subMenu->menuAction(); action->setIcon(QIcon(":/icons/opening_angle.png")); actionGroup = new QActionGroup(subMenu); signalMapper = new QSignalMapper(subMenu); connect(signalMapper, SIGNAL(mapped(int)), SLOT(setFovY(int))); action = subMenu->addAction(tr("&20°")); actionGroup->addAction(action); signalMapper->setMapping(action, 20); action->setShortcut(QKeySequence(Qt::Key_1)); action->setCheckable(true); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("&40°")); actionGroup->addAction(action); signalMapper->setMapping(action, 40); action->setShortcut(QKeySequence(Qt::Key_2)); action->setCheckable(true); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("&60°")); actionGroup->addAction(action); signalMapper->setMapping(action, 60); action->setShortcut(QKeySequence(Qt::Key_3)); action->setCheckable(true); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("&80°")); actionGroup->addAction(action); signalMapper->setMapping(action, 80); action->setShortcut(QKeySequence(Qt::Key_4)); action->setCheckable(true); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("100°")); actionGroup->addAction(action); signalMapper->setMapping(action, 100); action->setShortcut(QKeySequence(Qt::Key_5)); action->setCheckable(true); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("120°")); actionGroup->addAction(action); signalMapper->setMapping(action, 120); action->setShortcut(QKeySequence(Qt::Key_6)); action->setCheckable(true); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); qobject_cast<QAction*>(signalMapper->mapping(objectRenderer.getFovY()))->setChecked(true); subMenu = menu->addMenu(tr("&Surface Rendering")); actionGroup = new QActionGroup(subMenu); signalMapper = new QSignalMapper(subMenu); connect(signalMapper, SIGNAL(mapped(int)), SLOT(setSurfaceStyle(int))); action = subMenu->menuAction(); action->setIcon(QIcon(":/icons/layers.png")); action->setStatusTip(tr("Select different rendering techniques for displaying the scene")); action = subMenu->addAction(tr("Appearance &Wire Frame")); actionGroup->addAction(action); action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_W)); action->setCheckable(true); signalMapper->setMapping(action, VisualizationParameterSet::WIREFRAME); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("Appearance &Flat Shading")); actionGroup->addAction(action); action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_F)); action->setCheckable(true); signalMapper->setMapping(action, VisualizationParameterSet::FLAT_SHADING); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("Appearance &Smooth Shading")); actionGroup->addAction(action); action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_M)); action->setCheckable(true); signalMapper->setMapping(action, VisualizationParameterSet::SMOOTH_SHADING); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("Appearance &Texture Shading")); actionGroup->addAction(action); action->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_T)); action->setCheckable(true); signalMapper->setMapping(action, VisualizationParameterSet::TEXTURE_SHADING); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("Appearance &Camera Simulation")); actionGroup->addAction(action); action->setCheckable(true); signalMapper->setMapping(action, VisualizationParameterSet::CAMERA_SIMULATION); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); subMenu->addSeparator(); action = subMenu->addAction(tr("Physics &Wire Frame")); actionGroup->addAction(action); action->setCheckable(true); signalMapper->setMapping(action, VisualizationParameterSet::PHYSICS_WIREFRAME); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("Physics &Flat Shading")); actionGroup->addAction(action); action->setCheckable(true); signalMapper->setMapping(action, VisualizationParameterSet::PHYSICS_FLAT); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("Physics &Smooth Shading")); actionGroup->addAction(action); action->setCheckable(true); signalMapper->setMapping(action, VisualizationParameterSet::PHYSICS_SMOOTH); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); subMenu->addSeparator(); action = subMenu->addAction(tr("Mixed Mode &1 (Shaded Physics)")); actionGroup->addAction(action); action->setCheckable(true); signalMapper->setMapping(action, VisualizationParameterSet::MIXED_PHYSICS); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); action = subMenu->addAction(tr("Mixed Mode &2 (Shaded Appearance)")); actionGroup->addAction(action); action->setCheckable(true); signalMapper->setMapping(action, VisualizationParameterSet::MIXED_APPEARANCE); connect(action, SIGNAL(triggered()), signalMapper, SLOT(map())); qobject_cast<QAction*>(signalMapper->mapping(objectRenderer.getSurfaceStyle()))->setChecked(true); menu->addSeparator(); if(!showSensorsAct) { showSensorsAct = new QAction(QIcon(":/icons/transmit_go.png"), tr("Show &Sensors"), this); showSensorsAct->setStatusTip(tr("Show the values of the sensors in the scene view")); showSensorsAct->setCheckable(true); showSensorsAct->setChecked(objectRenderer.hasShowDetailSensors()); connect(showSensorsAct, SIGNAL(triggered()), this, SLOT(showDetailSensors())); } menu->addAction(showSensorsAct); if(!showDrawingsAct) { showDrawingsAct = new QAction(QIcon(":/icons/chart_line.png"), tr("Show Controller &Drawings"), this); showDrawingsAct->setStatusTip(tr("Show the controller 3D drawings in the scene view")); showDrawingsAct->setCheckable(true); showDrawingsAct->setChecked(objectRenderer.hasShowControllerDrawings()); connect(showDrawingsAct, SIGNAL(triggered()), this, SLOT(showControllerDrawings())); } menu->addAction(showDrawingsAct); return menu; }
void Gource::keyPress(SDL_KeyboardEvent *e) { if (e->type == SDL_KEYUP) return; if (e->type == SDL_KEYDOWN) { if (e->keysym.sym == SDLK_ESCAPE) { appFinished=true; } if(commitlog==0) return; if (e->keysym.sym == SDLK_q) { debug = !debug; } if (e->keysym.sym == SDLK_w) { trace_debug = !trace_debug; } if (e->keysym.sym == SDLK_n) { idle_time = gGourceAutoSkipSeconds; } if (e->keysym.sym == SDLK_t) { gGourceQuadTreeDebug = !gGourceQuadTreeDebug; } if (e->keysym.sym == SDLK_g) { gGourceHideUsers = !gGourceHideUsers; } if (e->keysym.sym == SDLK_u) { gGourceHideUsernames = !gGourceHideUsernames; } if (e->keysym.sym == SDLK_d) { gGourceDrawDirName = !gGourceDrawDirName; } if (e->keysym.sym == SDLK_f) { gGourceHideFilenames = !gGourceHideFilenames; } if(e->keysym.sym == SDLK_c) { splash = 15.0f; } if (e->keysym.sym == SDLK_v) { toggleCameraMode(); } if (e->keysym.sym == SDLK_z) { gGourceGravity = !gGourceGravity; } if(e->keysym.sym == SDLK_TAB) { selectNextUser(); } if (e->keysym.sym == SDLK_SPACE) { paused = !paused; } if (e->keysym.sym == SDLK_EQUALS) { if(gGourceDaysPerSecond>=1.0) { gGourceDaysPerSecond = std::min(30.0f, floorf(gGourceDaysPerSecond) + 1.0f); } else { gGourceDaysPerSecond = std::min(1.0f, gGourceDaysPerSecond * 2.0f); } } if (e->keysym.sym == SDLK_MINUS) { if(gGourceDaysPerSecond>1.0) { gGourceDaysPerSecond = std::max(0.0f, floorf(gGourceDaysPerSecond) - 1.0f); } else { gGourceDaysPerSecond = std::max(0.0f, gGourceDaysPerSecond * 0.5f); } } if(e->keysym.sym == SDLK_UP) { zoom(true); } if(e->keysym.sym == SDLK_DOWN) { zoom(false); } if(e->keysym.sym == SDLK_LEFTBRACKET) { gGourceForceGravity /= 1.1; } if(e->keysym.sym == SDLK_RIGHTBRACKET) { gGourceForceGravity *= 1.1; } if(e->keysym.sym == SDLK_PERIOD) { if(time_scale>=1.0) { time_scale = std::min(4.0f, floorf(time_scale) + 1.0f); } else { time_scale = std::min(1.0f, time_scale * 2.0f); } } if(e->keysym.sym == SDLK_COMMA) { if(time_scale>1.0) { time_scale = std::max(0.0f, floorf(time_scale) - 1.0f); } else { time_scale = std::max(0.25f, time_scale * 0.5f); } } if(e->keysym.sym == SDLK_SLASH) { time_scale = 1.0f; } } }
PointViewerMainWindow::PointViewerMainWindow(const QGLFormat& format) : m_progressBar(0), m_pointView(0), m_shaderEditor(0), m_helpDialog(0), m_logTextView(0), m_maxPointCount(200*1000*1000), // 200 million m_geometries(0), m_ipcServer(0), m_hookManager(0) { #ifndef _WIN32 setWindowIcon(QIcon(":resource/icons/hicolor/256x256/apps/displaz.png")); #else // On windows, application icon is set via windows resource file #endif setWindowTitle("Displaz"); setAcceptDrops(true); m_helpDialog = new HelpDialog(this); m_geometries = new GeometryCollection(this); connect(m_geometries, SIGNAL(layoutChanged()), this, SLOT(updateTitle())); connect(m_geometries, SIGNAL(dataChanged(QModelIndex,QModelIndex)), this, SLOT(updateTitle())); connect(m_geometries, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(updateTitle())); connect(m_geometries, SIGNAL(rowsRemoved(QModelIndex,int,int)), this, SLOT(updateTitle())); //-------------------------------------------------- // Set up file loader in a separate thread // // Some subtleties regarding qt thread usage are discussed here: // http://mayaposch.wordpress.com/2011/11/01/how-to-really-truly-use-qthreads-the-full-explanation // // Main point: each QObject has a thread affinity which determines which // thread its slots will execute on, when called via a connected signal. QThread* loaderThread = new QThread(); m_fileLoader = new FileLoader(m_maxPointCount); m_fileLoader->moveToThread(loaderThread); connect(loaderThread, SIGNAL(finished()), m_fileLoader, SLOT(deleteLater())); connect(loaderThread, SIGNAL(finished()), loaderThread, SLOT(deleteLater())); //connect(m_fileLoader, SIGNAL(finished()), this, SIGNAL(fileLoadFinished())); connect(m_fileLoader, SIGNAL(geometryLoaded(std::shared_ptr<Geometry>, bool, bool)), m_geometries, SLOT(addGeometry(std::shared_ptr<Geometry>, bool, bool))); connect(m_fileLoader, SIGNAL(geometryMutatorLoaded(std::shared_ptr<GeometryMutator>)), m_geometries, SLOT(mutateGeometry(std::shared_ptr<GeometryMutator>))); loaderThread->start(); //-------------------------------------------------- // Menus menuBar()->setNativeMenuBar(false); // OS X doesn't activate the native menu bar under Qt5 // File menu QMenu* fileMenu = menuBar()->addMenu(tr("&File")); QAction* openAct = fileMenu->addAction(tr("&Open")); openAct->setToolTip(tr("Open a data set")); openAct->setShortcuts(QKeySequence::Open); connect(openAct, SIGNAL(triggered()), this, SLOT(openFiles())); QAction* addAct = fileMenu->addAction(tr("&Add")); addAct->setToolTip(tr("Add a data set")); connect(addAct, SIGNAL(triggered()), this, SLOT(addFiles())); QAction* reloadAct = fileMenu->addAction(tr("&Reload")); reloadAct->setStatusTip(tr("Reload point files from disk")); reloadAct->setShortcut(Qt::Key_F5); connect(reloadAct, SIGNAL(triggered()), this, SLOT(reloadFiles())); fileMenu->addSeparator(); QAction* screenShotAct = fileMenu->addAction(tr("Scree&nshot")); screenShotAct->setStatusTip(tr("Save screen shot of 3D window")); screenShotAct->setShortcut(Qt::Key_F9); connect(screenShotAct, SIGNAL(triggered()), this, SLOT(screenShot())); fileMenu->addSeparator(); QAction* quitAct = fileMenu->addAction(tr("&Quit")); quitAct->setStatusTip(tr("Exit the application")); quitAct->setShortcuts(QKeySequence::Quit); connect(quitAct, SIGNAL(triggered()), this, SLOT(close())); // View menu QMenu* viewMenu = menuBar()->addMenu(tr("&View")); QAction* trackballMode = viewMenu->addAction(tr("Use &Trackball camera")); trackballMode->setCheckable(true); trackballMode->setChecked(false); // Background sub-menu QMenu* backMenu = viewMenu->addMenu(tr("Set &Background")); QSignalMapper* mapper = new QSignalMapper(this); // Selectable backgrounds (svg_names from SVG standard - see QColor docs) const char* backgroundNames[] = {/* "Display Name", "svg_name", */ "Default", "#3C3232", "Black", "black", "Dark Grey", "dimgrey", "Slate Grey", "#858C93", "Light Grey", "lightgrey", "White", "white" }; for(size_t i = 0; i < sizeof(backgroundNames)/sizeof(const char*); i+=2) { QAction* backgroundAct = backMenu->addAction(tr(backgroundNames[i])); QPixmap pixmap(50,50); QString colName = backgroundNames[i+1]; pixmap.fill(QColor(colName)); QIcon icon(pixmap); backgroundAct->setIcon(icon); mapper->setMapping(backgroundAct, colName); connect(backgroundAct, SIGNAL(triggered()), mapper, SLOT(map())); } connect(mapper, SIGNAL(mapped(QString)), this, SLOT(setBackground(QString))); backMenu->addSeparator(); QAction* backgroundCustom = backMenu->addAction(tr("&Custom")); connect(backgroundCustom, SIGNAL(triggered()), this, SLOT(chooseBackground())); // Check boxes for drawing various scene elements by category viewMenu->addSeparator(); QAction* drawBoundingBoxes = viewMenu->addAction(tr("Draw Bounding bo&xes")); drawBoundingBoxes->setCheckable(true); drawBoundingBoxes->setChecked(false); QAction* drawCursor = viewMenu->addAction(tr("Draw 3D &Cursor")); drawCursor->setCheckable(true); drawCursor->setChecked(true); QAction* drawAxes = viewMenu->addAction(tr("Draw &Axes")); drawAxes->setCheckable(true); drawAxes->setChecked(true); QAction* drawGrid = viewMenu->addAction(tr("Draw &Grid")); drawGrid->setCheckable(true); drawGrid->setChecked(false); QAction* drawAnnotations = viewMenu->addAction(tr("Draw A&nnotations")); drawAnnotations->setCheckable(true); drawAnnotations->setChecked(true); // Shader menu QMenu* shaderMenu = menuBar()->addMenu(tr("&Shader")); QAction* openShaderAct = shaderMenu->addAction(tr("&Open")); openShaderAct->setToolTip(tr("Open a shader file")); connect(openShaderAct, SIGNAL(triggered()), this, SLOT(openShaderFile())); QAction* editShaderAct = shaderMenu->addAction(tr("&Edit")); editShaderAct->setToolTip(tr("Open shader editor window")); QAction* saveShaderAct = shaderMenu->addAction(tr("&Save")); saveShaderAct->setToolTip(tr("Save current shader file")); connect(saveShaderAct, SIGNAL(triggered()), this, SLOT(saveShaderFile())); shaderMenu->addSeparator(); // Help menu QMenu* helpMenu = menuBar()->addMenu(tr("&Help")); QAction* helpAct = helpMenu->addAction(tr("User &Guide")); connect(helpAct, SIGNAL(triggered()), this, SLOT(helpDialog())); helpMenu->addSeparator(); QAction* aboutAct = helpMenu->addAction(tr("&About")); connect(aboutAct, SIGNAL(triggered()), this, SLOT(aboutDialog())); //-------------------------------------------------- // Point viewer m_pointView = new View3D(m_geometries, format, this); setCentralWidget(m_pointView); connect(drawBoundingBoxes, SIGNAL(triggered()), m_pointView, SLOT(toggleDrawBoundingBoxes())); connect(drawCursor, SIGNAL(triggered()), m_pointView, SLOT(toggleDrawCursor())); connect(drawAxes, SIGNAL(triggered()), m_pointView, SLOT(toggleDrawAxes())); connect(drawGrid, SIGNAL(triggered()), m_pointView, SLOT(toggleDrawGrid())); connect(drawAnnotations, SIGNAL(triggered()), m_pointView, SLOT(toggleDrawAnnotations())); connect(trackballMode, SIGNAL(triggered()), m_pointView, SLOT(toggleCameraMode())); connect(m_geometries, SIGNAL(rowsInserted(QModelIndex,int,int)), this, SLOT(geometryRowsInserted(QModelIndex,int,int))); //-------------------------------------------------- // Docked widgets // Shader parameters UI QDockWidget* shaderParamsDock = new QDockWidget(tr("Shader Parameters"), this); shaderParamsDock->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable); QWidget* shaderParamsUI = new QWidget(shaderParamsDock); shaderParamsDock->setWidget(shaderParamsUI); m_pointView->setShaderParamsUIWidget(shaderParamsUI); // Shader editor UI QDockWidget* shaderEditorDock = new QDockWidget(tr("Shader Editor"), this); shaderEditorDock->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetFloatable); QWidget* shaderEditorUI = new QWidget(shaderEditorDock); m_shaderEditor = new ShaderEditor(shaderEditorUI); QGridLayout* shaderEditorLayout = new QGridLayout(shaderEditorUI); shaderEditorLayout->setContentsMargins(2,2,2,2); shaderEditorLayout->addWidget(m_shaderEditor, 0, 0, 1, 1); connect(editShaderAct, SIGNAL(triggered()), shaderEditorDock, SLOT(show())); shaderEditorDock->setWidget(shaderEditorUI); shaderMenu->addAction(m_shaderEditor->compileAction()); connect(m_shaderEditor->compileAction(), SIGNAL(triggered()), this, SLOT(compileShaderFile())); // TODO: check if this is needed - test shader update functionality //connect(m_shaderEditor, SIGNAL(sendShader(QString)), // &m_pointView->shaderProgram(), SLOT(setShader(QString))); // Log viewer UI QDockWidget* logDock = new QDockWidget(tr("Log"), this); logDock->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable); QWidget* logUI = new QWidget(logDock); m_logTextView = new LogViewer(logUI); m_logTextView->setReadOnly(true); m_logTextView->setTextInteractionFlags(Qt::TextSelectableByKeyboard | Qt::TextSelectableByMouse); m_logTextView->connectLogger(&g_logger); // connect to global logger m_progressBar = new QProgressBar(logUI); m_progressBar->setRange(0,100); m_progressBar->setValue(0); m_progressBar->hide(); connect(m_fileLoader, SIGNAL(loadStepStarted(QString)), this, SLOT(setProgressBarText(QString))); connect(m_fileLoader, SIGNAL(loadProgress(int)), m_progressBar, SLOT(setValue(int))); connect(m_fileLoader, SIGNAL(resetProgress()), m_progressBar, SLOT(hide())); QVBoxLayout* logUILayout = new QVBoxLayout(logUI); //logUILayout->setContentsMargins(2,2,2,2); logUILayout->addWidget(m_logTextView); logUILayout->addWidget(m_progressBar); //m_logTextView->setLineWrapMode(QPlainTextEdit::NoWrap); logDock->setWidget(logUI); // Data set list UI QDockWidget* dataSetDock = new QDockWidget(tr("Data Sets"), this); dataSetDock->setFeatures(QDockWidget::DockWidgetMovable | QDockWidget::DockWidgetClosable | QDockWidget::DockWidgetFloatable); DataSetUI* dataSetUI = new DataSetUI(this); dataSetDock->setWidget(dataSetUI); QAbstractItemView* dataSetOverview = dataSetUI->view(); dataSetOverview->setModel(m_geometries); connect(dataSetOverview, SIGNAL(doubleClicked(const QModelIndex&)), m_pointView, SLOT(centerOnGeometry(const QModelIndex&))); m_pointView->setSelectionModel(dataSetOverview->selectionModel()); // Set up docked widgets addDockWidget(Qt::RightDockWidgetArea, shaderParamsDock); addDockWidget(Qt::LeftDockWidgetArea, shaderEditorDock); addDockWidget(Qt::RightDockWidgetArea, logDock); addDockWidget(Qt::RightDockWidgetArea, dataSetDock); tabifyDockWidget(logDock, dataSetDock); logDock->raise(); shaderEditorDock->setVisible(false); // Add dock widget toggles to view menu viewMenu->addSeparator(); viewMenu->addAction(shaderParamsDock->toggleViewAction()); viewMenu->addAction(logDock->toggleViewAction()); viewMenu->addAction(dataSetDock->toggleViewAction()); // Create custom hook events from CLI at runtime m_hookManager = new HookManager(this); }
void Gource::keyPress(SDL_KeyboardEvent *e) { if (e->type == SDL_KEYUP) return; if (e->type == SDL_KEYDOWN) { if (e->keysym.unicode == SDLK_ESCAPE) { appFinished=true; } if(commitlog==0) return; if(e->keysym.sym == SDLK_F12) { screenshot(); } if (e->keysym.sym == SDLK_q) { debug = !debug; } if (e->keysym.sym == SDLK_w) { trace_debug = !trace_debug; } if (e->keysym.sym == SDLK_m) { //toggle mouse visiblity unless mouse clicked/pressed/dragged if(!(mousedragged || mouseclicked || cursor.leftButtonPressed() )) { if(!cursor.isHidden()) { cursor.showCursor(false); gGourceSettings.hide_mouse = true; } else { cursor.showCursor(true); gGourceSettings.hide_mouse = false; } } } if (e->keysym.sym == SDLK_n) { idle_time = gGourceSettings.auto_skip_seconds; } if (e->keysym.sym == SDLK_t) { gGourceQuadTreeDebug = !gGourceQuadTreeDebug; } if (e->keysym.sym == SDLK_g) { gGourceSettings.hide_users = !gGourceSettings.hide_users; } if (e->keysym.sym == SDLK_u) { gGourceSettings.hide_usernames = !gGourceSettings.hide_usernames; } if (e->keysym.sym == SDLK_d) { gGourceSettings.hide_dirnames = ! gGourceSettings.hide_dirnames; } if (e->keysym.sym == SDLK_f) { gGourceSettings.hide_filenames = !gGourceSettings.hide_filenames; } if(e->keysym.sym == SDLK_c) { splash = 15.0f; } if (e->keysym.sym == SDLK_v) { toggleCameraMode(); } if (e->keysym.sym == SDLK_z) { gGourceGravity = !gGourceGravity; } if(e->keysym.unicode == SDLK_TAB) { selectNextUser(); } if (e->keysym.unicode == SDLK_SPACE) { paused = !paused; } if (e->keysym.unicode == SDLK_EQUALS || e->keysym.unicode == SDLK_PLUS) { if(gGourceSettings.days_per_second>=1.0) { gGourceSettings.days_per_second = std::min(30.0f, floorf(gGourceSettings.days_per_second) + 1.0f); } else { gGourceSettings.days_per_second = std::min(1.0f, gGourceSettings.days_per_second * 2.0f); } } if (e->keysym.unicode == SDLK_MINUS) { if(gGourceSettings.days_per_second>1.0) { gGourceSettings.days_per_second = std::max(0.0f, floorf(gGourceSettings.days_per_second) - 1.0f); } else { gGourceSettings.days_per_second = std::max(0.0f, gGourceSettings.days_per_second * 0.5f); } } if(e->keysym.sym == SDLK_UP) { zoom(true); } if(e->keysym.sym == SDLK_DOWN) { zoom(false); } if(e->keysym.unicode == SDLK_LEFTBRACKET) { gGourceForceGravity /= 1.1; } if(e->keysym.unicode == SDLK_RIGHTBRACKET) { gGourceForceGravity *= 1.1; } if(e->keysym.unicode == SDLK_PERIOD) { if(time_scale>=1.0) { time_scale = std::min(4.0f, floorf(time_scale) + 1.0f); } else { time_scale = std::min(1.0f, time_scale * 2.0f); } } if(e->keysym.unicode == SDLK_COMMA) { if(time_scale>1.0) { time_scale = std::max(0.0f, floorf(time_scale) - 1.0f); } else { time_scale = std::max(0.25f, time_scale * 0.5f); } } if(e->keysym.unicode == SDLK_SLASH) { time_scale = 1.0f; } } }
void Gource::mouseClick(SDL_MouseButtonEvent *e) { if(commitlog==0) return; if(gGourceSettings.hide_mouse) return; //mouse click should stop the cursor being idle cursor.updatePos(mousepos); if(e->type == SDL_MOUSEBUTTONUP) { if(e->button == SDL_BUTTON_LEFT) { //stop dragging mouse, return the mouse to where //the user started dragging. mousedragged=false; } if(e->button == SDL_BUTTON_LEFT || e->button == SDL_BUTTON_RIGHT) { if(!cursor.buttonPressed()) { cursor.showCursor(true); grab_mouse=false; SDL_WarpMouse(mousepos.x, mousepos.y); } } } if(e->type != SDL_MOUSEBUTTONDOWN) return; //wheel up if(e->button == SDL_BUTTON_WHEELUP) { zoom(true); return; } //wheel down if(e->button == SDL_BUTTON_WHEELDOWN) { zoom(false); return; } if(e->button == SDL_BUTTON_MIDDLE) { toggleCameraMode(); return; } if(e->button == SDL_BUTTON_RIGHT) { cursor.showCursor(false); grab_mouse=true; return; } if(e->button == SDL_BUTTON_LEFT) { //mousepos = vec2f(e->x, e->y); mouseclicked=true; if(canSeek()) { float position; if(slider.click(mousepos, &position)) { seekTo(position); } } } }
void Gource::keyPress(SDL_KeyboardEvent *e) { if (e->type == SDL_KEYUP) return; if (e->type == SDL_KEYDOWN) { if (e->keysym.sym == SDLK_ESCAPE) { appFinished=true; } if(commitlog==0) return; if (e->keysym.sym == SDLK_q) { debug = !debug; } if (e->keysym.sym == SDLK_w) { trace_debug = !trace_debug; } if (e->keysym.sym == SDLK_n) { idle_time = gGourceAutoSkipSeconds; } if (e->keysym.sym == SDLK_t) { gGourceQuadTreeDebug = !gGourceQuadTreeDebug; } if (e->keysym.sym == SDLK_g) { gGourceHideUsers = !gGourceHideUsers; } if (e->keysym.sym == SDLK_u) { gGourceHideUsernames = !gGourceHideUsernames; } if (e->keysym.sym == SDLK_d) { gGourceDrawDirName = !gGourceDrawDirName; } if (e->keysym.sym == SDLK_f) { gGourceHideFilenames = !gGourceHideFilenames; } if(e->keysym.sym == SDLK_c) { splash = 15.0f; } if (e->keysym.sym == SDLK_v) { toggleCameraMode(); } if (e->keysym.sym == SDLK_z) { gGourceGravity = !gGourceGravity; } if(e->keysym.sym == SDLK_TAB) { selectNextUser(); } if (e->keysym.sym == SDLK_SPACE) { paused = !paused; } if (e->keysym.sym == SDLK_EQUALS) { gGourceDaysPerSecond *= 2.0; } if (e->keysym.sym == SDLK_MINUS) { if(gGourceDaysPerSecond>0.0) gGourceDaysPerSecond *= 0.5; } if(e->keysym.sym == SDLK_UP) { zoom(true); } if(e->keysym.sym == SDLK_DOWN) { zoom(false); } if(e->keysym.sym == SDLK_LEFTBRACKET) { gGourceForceGravity /= 1.1; } if(e->keysym.sym == SDLK_RIGHTBRACKET) { gGourceForceGravity *= 1.1; } } }
void Gource::mouseClick(SDL_MouseButtonEvent *e) { if(commitlog==0) return; if(gGourceSettings.hide_mouse) return; if(e->type == SDL_MOUSEBUTTONUP) { if(e->button == SDL_BUTTON_LEFT) { //stop dragging mouse, return the mouse to where //the user started dragging. mousedragged=false; } Uint8 ms = SDL_GetMouseState(0,0); if(e->button == SDL_BUTTON_LEFT || e->button == SDL_BUTTON_RIGHT) { if(!(ms & SDL_BUTTON(SDL_BUTTON_RIGHT) || ms & SDL_BUTTON(SDL_BUTTON_LEFT))) { SDL_WM_GrabInput(SDL_GRAB_OFF); SDL_ShowCursor(true); SDL_WarpMouse(mousepos.x, mousepos.y); } } } if(e->type != SDL_MOUSEBUTTONDOWN) return; //wheel up if(e->button == SDL_BUTTON_WHEELUP) { zoom(true); return; } //wheel down if(e->button == SDL_BUTTON_WHEELDOWN) { zoom(false); return; } if(e->button == SDL_BUTTON_MIDDLE) { toggleCameraMode(); return; } if(e->button == SDL_BUTTON_RIGHT) { SDL_WM_GrabInput(SDL_GRAB_ON); SDL_ShowCursor(false); return; } if(e->button == SDL_BUTTON_LEFT) { //mousepos = vec2f(e->x, e->y); mouseclicked=true; if(canSeek()) { float position; if(slider.click(mousepos, &position)) { seekTo(position); } } } }