Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/QtComponents/QtComponents.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@
<file>images/surfaces.png</file>
<file>images/lookup_table.png</file>
<file>images/lookup_table_editor.png</file>
<file>images/mode_2d.png</file>
<file>images/reset_view.png</file>
<file>images/landmark.png</file>
<file>images/trihedron.png</file>
Expand Down
38 changes: 27 additions & 11 deletions src/QtComponents/QtMgx3DMainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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 ( )
{
Expand Down
Binary file added src/QtComponents/images/mode_2d.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 58 additions & 0 deletions src/QtComponents/images/mode_2d.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 6 additions & 1 deletion src/QtComponents/protected/QtComponents/QtMgx3DMainWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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.
*/
Expand Down
13 changes: 13 additions & 0 deletions src/QtVtkComponents/QtVtkMgx3DMainWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,6 +357,19 @@ void QtVtkMgx3DMainWindow::preferencesCallback ( )
} // QtVtkMgx3DMainWindow::preferencesCallback


void QtVtkMgx3DMainWindow::mode2DCallback (bool enable2D)
{
BEGIN_QT_TRY_CATCH_BLOCK

QtVtkGraphicalWidget* vgw = dynamic_cast<QtVtkGraphicalWidget*>(&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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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; }

/**
* <P>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é.</P>
Expand Down Expand Up @@ -271,6 +278,11 @@ class vtkUnifiedInteractorStyle : public vtkInteractorStyleTrackballCamera
* <I>true</I> si le positionnement de la vue dans un plan sur touche <I>x</I>, <I>X</I>, ... est activé, <I>false</I> dans le cas contraire.
*/
bool _enablePlaneKeys;

/**
* <I>true</I> si on est en mode 2D (plan de l'écran = xOy), <I>false</I> si on en mode 3D.
*/
bool _2dMode;
}; // class vtkUnifiedInteractorStyle


Expand Down
39 changes: 31 additions & 8 deletions src/QtVtkComponents/vtkUnifiedInteractorStyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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' :
Expand All @@ -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 ( );
Expand All @@ -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
Expand Down