void QGCodeViewer::init() { setShortcut(DISPLAY_FPS, Qt::CTRL+Qt::Key_F); setShortcut(DRAW_GRID, 0); setManipulatedFrame(new ManipulatedFrame()); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); glEnable(GL_DEPTH_TEST); glDrawBuffer(GL_BACK); //glDisable(GL_CULL_FACE); //glLineStipple(2, 0xFFFF); glDisable(GL_LIGHTING); glClearColor(0.25,0.25,0.25,0); //glPixelStorei(GL_UNPACK_ALIGNMENT, 1); //glLineWidth(3); //setGridIsDrawn(); if (!restoreStateFromFile()) { showEntireScene(); } setMouseBinding(Qt::AltModifier, Qt::RightButton, SHOW_ENTIRE_SCENE, true, Qt::MidButton); clear(); //startAnimation(); }
Scene::Scene( QWidget * parent, const QGLWidget * shareWidget, Qt::WFlags flags) : QGLViewer(parent, shareWidget, flags) { activeMesh = NULL; activeFrame = new ManipulatedFrame(); setManipulatedFrame(activeFrame); // GLViewer options setGridIsDrawn(); // TEXT ON SCREEN timer = new QTimer(this); connect(timer, SIGNAL(timeout()), SLOT(dequeueLastMessage())); // Mouse selection window this->setSelectRegionHeight(10); this->setSelectRegionWidth(10); this->selectMode = CONTROLLER; // Take focus this->setFocus(); emit(gotFocus(this)); // Stacker stuff sp = NULL; activeDeformer = NULL; activeVoxelDeformer = NULL; isShowStacked = false; isDrawOffset = false; displayMessage(tr("New scene created.")); }
void View::linkMap(MapHandlerGen* map) { // RECORDING QTextStream* rec = m_schnapps->pythonStreamRecorder(); if (rec) *rec << this->getName() << ".linkMap(\"" << map->getName() << "\");" << endl; DEBUG_SLOT(); if(map && !l_maps.contains(map)) { l_maps.push_back(map); map->linkView(this); DEBUG_EMIT("mapLinked"); emit(mapLinked(map)); connect(map, SIGNAL(selectedCellsChanged(CellSelectorGen*)), this, SLOT(updateGL())); connect(map, SIGNAL(boundingBoxModified()), this, SLOT(updateBoundingBox())); if(map->isSelectedMap()) setManipulatedFrame(map->getFrame()); updateBoundingBox(); b_updatingUI = true; m_dialogMaps->check(map->getName(), Qt::Checked); b_updatingUI = false; }
void GL_widget_3::init() { setBackgroundColor(Qt::white); glEnable(GL_POINT_SMOOTH); glEnable(GL_LINE_SMOOTH); glEnable(GL_BLEND); // Enable Blending glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); // Type Of Blending To Use glHint(GL_POINT_SMOOTH_HINT, GL_NICEST); // Make round points, not square points // glHint(GL_LINE_SMOOTH_HINT, GL_NICEST); // Antialias the lines glDisable( GL_COLOR_MATERIAL ); glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER,GL_TRUE); glLightModeli( GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE ); // glShadeModel(GL_FLAT); glEnable(GL_NORMALIZE); setMouseBinding(Qt::LeftButton, ZOOM_ON_PIXEL, true); // setMouseBinding(Qt::LeftButton, RAP_FROM_PIXEL, true); setMouseBinding(Qt::RightButton, ZOOM_TO_FIT, true); setMouseBinding(Qt::ALT + Qt::LeftButton, ALIGN_CAMERA, true); // setMouseBinding(Qt::RightButton, RAP_IS_CENTER, true); glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 50); setManipulatedFrame(0); set_camera_projection(); create_sphere_display_list(); }
void Viewer::init() { if (bFirstInit) { // - init GLEW OpenGL::init(); fprintf(stdout, "Status: Using GLEW %s\n", glewGetString(GLEW_VERSION)); // Restore previous viewer state. //restoreStateFromFile(); // Set position of light's camera qgl_cam_light.setPosition( qglviewer::Vec(0, 50, 0) ); qgl_cam_light.fitBoundingBox( qglviewer::Vec(-1, -1, -1), qglviewer::Vec(+1, +1, +1) ); // Add a manipulated frame to the viewer. setManipulatedFrame( qgl_cam_light.frame() ); setAnimationPeriod(0.); setSceneCenter(qglviewer::Vec(0, 0, 0)); setSceneRadius(10.f); } initAll( !bFirstInit ); if (bFirstInit) { qgl_mf_vbo.setPosition( -qglviewer::Vec(ts->getCenter()) ); f_scale_vbo = 1.f / ( ts->getRadius() ); } bFirstInit = false; // On vérifie les erreurs MSG_CHECK_GL; }
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; }
void GLViewer::init() { oldZValue = 0.0; gravityForce = 1.6666; // restoreStateFromFile(); setMouseTracking(true); glLineWidth(3.0); glPointSize(10.1); camera()->setZClippingCoefficient (1.0f); camera()->setIODistance (20.0f); // m_camera_frame = new ManipulatedCameraFrame(); this->m_camera_constraint = new CameraConstraint(camera()); // m_camera_constraint->setTranslationConstraintType(AxisPlaneConstraint::PLANE); //m_camera_constraint->setTranslationConstraintDirection(Vec(1.0f, 1.0f, 1.0f)); m_camera_constraint->setRotationConstraintType(AxisPlaneConstraint::PLANE); m_camera_constraint->setRotationConstraintDirection(Vec(0.001f ,0.001f, 0.0f)); camera()->frame ()->setSpinningSensitivity (0.0); //camera()->frame ()->setSpinningSensitivity(0); camera()->frame ()->setRotationSensitivity(0.25f); camera()->frame ()->setTranslationSensitivity(0.25f); camera()->frame ()->setConstraint(m_camera_constraint); camera()->frame()->setOrientation (0.714989,-0.0573572,-0.00334217,-0.696771); camera()->frame()->setPosition (0.181669,6.60265,-1.25621); // camera()->setFrame(m_camera_frame); this->m_world_constraint = new WorldConstraint(); // m_world_constraint->setTranslationConstraintType(AxisPlaneConstraint::AXIS); // m_world_constraint->setTranslationConstraintDirection(Vec(1.0f, 0.0, 0.0)); m_world_constraint->setRotationConstraintType(AxisPlaneConstraint::AXIS); m_world_constraint->setRotationConstraintDirection(Vec(0.0, 0.0, 1.0f)); m_frame.setTranslationSensitivity(1.0f); //m_frame.setOrientation(0.312498, 0.0328202, -0.054013, 0.947813); m_frame.setOrientation (0.714989,-0.0573572,-0.00334217,-0.696771); m_frame.setRotationSensitivity(0.75f); m_frame.setSpinningSensitivity(0.75f); m_frame.setConstraint(m_world_constraint); //camera()->frame()->setOrientation(-0.308071, -0.774754, 0.510504, 0.21032 ); // camera()->frame()->setOrientation(0.0268112, -0.900378, 0.430649, 0.0560555); // m_camera_frame->setConstraint(m_camera_constraint); //m_camera_frame->setPosition(Vec(-1339.98, -2474.59, -2001.8 )); // camera()->setPosition(Vec(-1339.98, -1474.59, -2001.8 )); // camera()->setViewDirection(Vec(-0.0956168, 0.783527, 0.613957)); // camera()->setPosition(Vec(0, 0, 0)); // QWheelEvent* wheelevent = new QWheelEvent(QPoint(0, 0), 5, Qt::NoButton, Qt::NoModifier, Qt::Vertical); // QGLViewer::wheelEvent(wheelevent); //camera()->frame()->setSpinningSensitivity(0.0); // camera()->frame()->setOrientation(0.312498, 0.0328202, -0.054013, 0.947813); setManipulatedFrame(&m_frame); // this->camera()->frame()->setConstraint(m_world_constraint); // m_frame.setConstraint(m_world_constraint); setMouseBinding(Qt::NoModifier, Qt::LeftButton, CAMERA, ROTATE, false); //setMouseBinding(Qt::NoModifier, Qt::LeftButton, CAMERA, ROTATE, false); setMouseBinding(Qt::NoModifier, Qt::RightButton, CAMERA, TRANSLATE, false); /* setMouseBinding(Qt::RightButton, CAMERA, NO_MOUSE_ACTION); setWheelBinding(Qt::ControlModifier, CAMERA, NO_MOUSE_ACTION); setWheelBinding(Qt::ShiftModifier, CAMERA, NO_MOUSE_ACTION); setWheelBinding(Qt::AltModifier, CAMERA, NO_MOUSE_ACTION); setMouseBinding(Qt::LeftButton, FRAME, NO_MOUSE_ACTION); setMouseBinding(Qt::MidButton | Qt::LeftButton, CAMERA, NO_MOUSE_ACTION); setMouseBinding(Qt::MidButton, FRAME, NO_MOUSE_ACTION); */ // setMouseBinding(Qt::MidButton, CAMERA, true, NO_MOUSE_ACTION); //this->camera()->setViewDirection(qglviewer::Vec(1.0, 10.0, 8.0)); this->showEntireScene(); // this->update(); }