diff --git a/src/QtComponents/QtComponents.qrc b/src/QtComponents/QtComponents.qrc index 9a9fcaea..887e0a27 100644 --- a/src/QtComponents/QtComponents.qrc +++ b/src/QtComponents/QtComponents.qrc @@ -112,6 +112,7 @@ images/surfaces.png images/lookup_table.png images/lookup_table_editor.png + images/mode_2d.png images/reset_view.png images/landmark.png images/trihedron.png diff --git a/src/QtComponents/QtMgx3DMainWindow.cpp b/src/QtComponents/QtMgx3DMainWindow.cpp index 8596fbce..6eeea0b1 100644 --- a/src/QtComponents/QtMgx3DMainWindow.cpp +++ b/src/QtComponents/QtMgx3DMainWindow.cpp @@ -245,7 +245,7 @@ namespace QtComponents QtMgx3DMainWindow::WindowsActions::WindowsActions() : _preferencesAction(0), _editSettingsAction(0), _quitAction(0), - _print3DViewAction(0), _print3DViewToFileAction(0), + _2dModeAction (0), _print3DViewAction(0), _print3DViewToFileAction(0), _useGlobalDisplayPropertiesAction(0), _displayTrihedronAction(0), _displayLandmarkAction(0), _parametrizeLandmarkAction(0), _displayFocalPointAction(0), @@ -322,6 +322,7 @@ namespace QtComponents : _preferencesAction(wa._preferencesAction), _editSettingsAction(wa._editSettingsAction), _quitAction(wa._quitAction), + _2dModeAction (wa._2dModeAction), _print3DViewAction(wa._print3DViewAction), _print3DViewToFileAction(wa._print3DViewToFileAction), _useGlobalDisplayPropertiesAction(wa._useGlobalDisplayPropertiesAction), @@ -454,12 +455,13 @@ namespace QtComponents { if (&wa != this) { - _preferencesAction = wa._preferencesAction; - _editSettingsAction = wa._editSettingsAction; - _quitAction = wa._quitAction; - _print3DViewAction = wa._print3DViewAction; - _print3DViewToFileAction = wa._print3DViewToFileAction; - _useGlobalDisplayPropertiesAction = wa._useGlobalDisplayPropertiesAction; + _preferencesAction = wa._preferencesAction; + _editSettingsAction = wa._editSettingsAction; + _quitAction = wa._quitAction; + _2dModeAction = wa._2dModeAction; + _print3DViewAction = wa._print3DViewAction; + _print3DViewToFileAction = wa._print3DViewToFileAction; + _useGlobalDisplayPropertiesAction = wa._useGlobalDisplayPropertiesAction; _displayTrihedronAction = wa._displayTrihedronAction; _displayLandmarkAction = wa._displayLandmarkAction; _parametrizeLandmarkAction = wa._parametrizeLandmarkAction; @@ -1748,9 +1750,8 @@ void QtMgx3DMainWindow::showReady ( ) // Menu Vue : _viewMenu = new QMenu("&Vue", menubar); menubar->addMenu(_viewMenu); -#ifndef QT_4 _viewMenu->setToolTipsVisible(true); -#endif // QT_4 + _viewMenu->addAction(getActions()._2dModeAction); _viewMenu->addAction(getActions()._print3DViewAction); _viewMenu->addAction(getActions()._print3DViewToFileAction); _viewMenu->addAction(getActions()._useGlobalDisplayPropertiesAction); @@ -1780,9 +1781,7 @@ void QtMgx3DMainWindow::showReady ( ) // Menu Topologie : _topologyMenu = new QMenu("&Topologie", menubar); menubar->addMenu(_topologyMenu); -#ifndef QT_4 _topologyMenu->setToolTipsVisible(true); -#endif // QT_4 _topologyMenu->addAction(getActions()._topoSetDefaultNbMeshingEdgesAction); _topologyMenu->addAction(getActions()._topoRefineAction); #ifdef _DEBUG @@ -2036,6 +2035,7 @@ void QtMgx3DMainWindow::showReady ( ) _3dViewToolbar->addAction(getActions()._displayLandmarkAction); _3dViewToolbar->addAction(getActions()._displayFocalPointAction); _3dViewToolbar->addSeparator(); + _3dViewToolbar->addAction(getActions()._2dModeAction); _3dViewToolbar->addAction(getActions()._xOyViewAction); _3dViewToolbar->addAction(getActions()._xOzViewAction); _3dViewToolbar->addAction(getActions()._yOzViewAction); @@ -2230,6 +2230,13 @@ void QtMgx3DMainWindow::showReady ( ) connect(_actions._executePythonScriptAction, SIGNAL(triggered()), this, SLOT(executePythonScriptCallback()), defaultConnectionType); // La vue 3D : + _actions._2dModeAction = new QAction (QIcon(":/images/mode_2d.png"), QString ("Affichage 2D"), this); + _actions._2dModeAction->setCheckable (true); + _actions._2dModeAction->setChecked (false); + UTF8String tooltip (Charset::UTF_8); + tooltip << "Fige les interactions dans le plan courant. Pour basculer dans le plan xOy, presser préalablement la touche \'z\' dans la fenêtre graphique."; + _actions._2dModeAction->setToolTip (UTF8TOQSTRING (tooltip)); + connect(_actions._2dModeAction, SIGNAL(toggled(bool)), this, SLOT(mode2DCallback(bool)),defaultConnectionType); _actions._print3DViewAction = new QAction(QIcon(":/images/print.png"), "Imprimer ...", this); connect(_actions._print3DViewAction, SIGNAL(triggered()), this, SLOT(print3DViewCallback()), defaultConnectionType); _actions._print3DViewAction->setShortcut(QKeySequence(Qt::CTRL + Qt::Key_P)); @@ -6235,6 +6242,15 @@ void QtMgx3DMainWindow::executeRecentMgx3DScriptCallback ( ) } // QtMgx3DMainWindow::executeRecentMgx3DScriptCallback +void QtMgx3DMainWindow::mode2DCallback (bool enable2D) +{ + BEGIN_QT_TRY_CATCH_BLOCK + + throw Exception (UTF8String ("QtMgx3DMainWindow::mode2DCallback : méthode à surcharger.", Charset::UTF_8)); + + COMPLETE_QT_TRY_CATCH_BLOCK (true, this, getAppTitle ( )) +} // QtMgx3DMainWindow::mode2DCallback + void QtMgx3DMainWindow::print3DViewCallback ( ) { diff --git a/src/QtComponents/images/mode_2d.png b/src/QtComponents/images/mode_2d.png new file mode 100644 index 00000000..3ac883f3 Binary files /dev/null and b/src/QtComponents/images/mode_2d.png differ diff --git a/src/QtComponents/images/mode_2d.svg b/src/QtComponents/images/mode_2d.svg new file mode 100644 index 00000000..8a959db2 --- /dev/null +++ b/src/QtComponents/images/mode_2d.svg @@ -0,0 +1,58 @@ + + + + + + + + + + 2D + + diff --git a/src/QtComponents/protected/QtComponents/QtMgx3DMainWindow.h b/src/QtComponents/protected/QtComponents/QtMgx3DMainWindow.h index 9b3df57e..c39fd955 100644 --- a/src/QtComponents/protected/QtComponents/QtMgx3DMainWindow.h +++ b/src/QtComponents/protected/QtComponents/QtMgx3DMainWindow.h @@ -377,7 +377,7 @@ class QtMgx3DMainWindow : QAction *_longCommandAction, *_openCascadeLongCommandAction; QAction *_executePythonScriptAction; QAction *_preferencesAction, *_editSettingsAction, *_quitAction; - QAction *_print3DViewAction, *_print3DViewToFileAction; + QAction *_2dModeAction, *_print3DViewAction, *_print3DViewToFileAction; QAction *_useGlobalDisplayPropertiesAction; QAction *_displayTrihedronAction, *_displayLandmarkAction, *_parametrizeLandmarkAction, *_displayFocalPointAction, @@ -1006,6 +1006,11 @@ class QtMgx3DMainWindow : */ //@{ + /** + * Passe en mode d'interaction 2D/3D. + */ + virtual void mode2DCallback (bool enable2D); + /** * Affiche une boite de dialogue d'impression de la vue 3D. */ diff --git a/src/QtVtkComponents/QtVtkMgx3DMainWindow.cpp b/src/QtVtkComponents/QtVtkMgx3DMainWindow.cpp index d2795905..af561f4b 100644 --- a/src/QtVtkComponents/QtVtkMgx3DMainWindow.cpp +++ b/src/QtVtkComponents/QtVtkMgx3DMainWindow.cpp @@ -357,6 +357,19 @@ void QtVtkMgx3DMainWindow::preferencesCallback ( ) } // QtVtkMgx3DMainWindow::preferencesCallback +void QtVtkMgx3DMainWindow::mode2DCallback (bool enable2D) +{ + BEGIN_QT_TRY_CATCH_BLOCK + + QtVtkGraphicalWidget* vgw = dynamic_cast(&getGraphicalWidget ( )); + CHECK_NULL_PTR_ERROR (vgw) + CHECK_NULL_PTR_ERROR (vgw->getVTKRenderingManager ( ).getMgx3DInteractorStyle ( ).GetMgx3DPicker ( )) + vgw->getVTKRenderingManager ( ).getMgx3DInteractorStyle ( ).Set2DMode (enable2D); + + COMPLETE_QT_TRY_CATCH_BLOCK (true, this, getAppTitle ( )) +} // QtVtkMgx3DMainWindow::mode2DCallback + + void QtVtkMgx3DMainWindow::print3DViewCallback ( ) { BEGIN_QT_TRY_CATCH_BLOCK diff --git a/src/QtVtkComponents/protected/QtVtkComponents/QtVtkMgx3DMainWindow.h b/src/QtVtkComponents/protected/QtVtkComponents/QtVtkMgx3DMainWindow.h index d99c5420..d516a8f0 100644 --- a/src/QtVtkComponents/protected/QtVtkComponents/QtVtkMgx3DMainWindow.h +++ b/src/QtVtkComponents/protected/QtVtkComponents/QtVtkMgx3DMainWindow.h @@ -153,6 +153,11 @@ class QtVtkMgx3DMainWindow : public QtComponents::QtMgx3DMainWindow */ virtual void preferencesCallback ( ); + /** + * Passe en mode d'interaction 2D/3D. + */ + virtual void mode2DCallback (bool enable2D); + /** * Affiche une boite de dialogue d'impression de la vue 3D. */ diff --git a/src/QtVtkComponents/protected/QtVtkComponents/vtkUnifiedInteractorStyle.h b/src/QtVtkComponents/protected/QtVtkComponents/vtkUnifiedInteractorStyle.h index bdf20de8..8384df93 100644 --- a/src/QtVtkComponents/protected/QtVtkComponents/vtkUnifiedInteractorStyle.h +++ b/src/QtVtkComponents/protected/QtVtkComponents/vtkUnifiedInteractorStyle.h @@ -87,6 +87,13 @@ class vtkUnifiedInteractorStyle : public vtkInteractorStyleTrackballCamera virtual bool GetEnablePlaneKeys ( ) const { return _enablePlaneKeys; } + /** + * (Dés)Active le mode 2D, à savoir le plan de l'écran est le plan xOy, les rotations autour d'un axe sont interdites. + */ + virtual void Set2DMode (bool enable); + virtual bool Get2DMode ( ) const + { return _2dMode; } + /** *

Surcharge pour éviter de redéterminer le renderer ou se trouve l'interacteur à chaque mouvement de souris : cela permet dans le cas de * renderers multiples d'appliquer les mouvements au renderer où l'action a debuté.

@@ -271,6 +278,11 @@ class vtkUnifiedInteractorStyle : public vtkInteractorStyleTrackballCamera * true si le positionnement de la vue dans un plan sur touche x, X, ... est activé, false dans le cas contraire. */ bool _enablePlaneKeys; + + /** + * true si on est en mode 2D (plan de l'écran = xOy), false si on en mode 3D. + */ + bool _2dMode; }; // class vtkUnifiedInteractorStyle diff --git a/src/QtVtkComponents/vtkUnifiedInteractorStyle.cpp b/src/QtVtkComponents/vtkUnifiedInteractorStyle.cpp index 5c4019fd..a2879d19 100644 --- a/src/QtVtkComponents/vtkUnifiedInteractorStyle.cpp +++ b/src/QtVtkComponents/vtkUnifiedInteractorStyle.cpp @@ -26,13 +26,13 @@ double vtkUnifiedInteractorStyle::eyeAngleModifier = 0.25; // en degres bool vtkUnifiedInteractorStyle::upZoom = false; vtkUnifiedInteractorStyle::vtkUnifiedInteractorStyle ( ) - : vtkInteractorStyleTrackballCamera ( ), _motionRatio (0.1), _enablePlaneKeys (true) + : vtkInteractorStyleTrackballCamera ( ), _motionRatio (0.1), _enablePlaneKeys (true), _2dMode (false) { } // vtkUnifiedInteractorStyle::vtkUnifiedInteractorStyle vtkUnifiedInteractorStyle::vtkUnifiedInteractorStyle (const vtkUnifiedInteractorStyle&) - : vtkInteractorStyleTrackballCamera ( ), _motionRatio (0.1), _enablePlaneKeys (true) + : vtkInteractorStyleTrackballCamera ( ), _motionRatio (0.1), _enablePlaneKeys (true), _2dMode (false) { assert (0 && "vtkUnifiedInteractorStyle copy constructor is not allowed."); } // vtkUnifiedInteractorStyle copy constructor @@ -69,12 +69,12 @@ void vtkUnifiedInteractorStyle::OnChar ( ) break; case 'x' : // case 'X' : - if ((true == GetEnablePlaneKeys ( )) && (false == hasModifier ( ))) + if ((true != _2dMode) && (true == GetEnablePlaneKeys ( )) && (false == hasModifier ( ))) DisplayyOzViewPlane ( ); break; case 'y' : // case 'Y' : - if ((true == GetEnablePlaneKeys ( )) && (false == hasModifier ( ))) + if ((true != _2dMode) && (true == GetEnablePlaneKeys ( )) && (false == hasModifier ( ))) DisplayxOzViewPlane ( ); break; case 'z' : @@ -100,13 +100,33 @@ void vtkUnifiedInteractorStyle::OnChar ( ) } // vtkUnifiedInteractorStyle::OnChar +void vtkUnifiedInteractorStyle::Set2DMode (bool enable) +{ + if (enable != _2dMode) + { + _2dMode = enable; + +// Tel que c'est le plan courant qui est figé. Si on veut forcer d'emblée à ce que ce soit le plan +// xOy il convient de décommenter les lignes suivantes. +/* if (true == enable) + { + DisplayxOyViewPlane ( ); + ResetRoll ( ); + } // if (true == enable) */ + } // if (enable != _2dMode) +} // vtkUnifiedInteractorStyle::Set2DMode + + void vtkUnifiedInteractorStyle::OnMouseMove ( ) { switch (this->State) { case VTKIS_ROTATE : - this->Rotate ( ); - this->InvokeEvent (vtkCommand::InteractionEvent, NULL); + if (true != _2dMode) + { + this->Rotate ( ); + this->InvokeEvent (vtkCommand::InteractionEvent, NULL); + } break; case VTKIS_PAN : this->Pan ( ); @@ -117,8 +137,11 @@ void vtkUnifiedInteractorStyle::OnMouseMove ( ) this->InvokeEvent (vtkCommand::InteractionEvent, NULL); break; case VTKIS_SPIN : - this->Spin ( ); - this->InvokeEvent (vtkCommand::InteractionEvent, NULL); + if (true != _2dMode) + { + this->Spin ( ); + this->InvokeEvent (vtkCommand::InteractionEvent, NULL); + } break; } // switch (this->State) } // vtkUnifiedInteractorStyle::OnMouseMove