From: ouv Date: Wed, 19 Mar 2014 13:10:13 +0000 (+0400) Subject: GUITHARE external issue 0020696: 2D 3D surfaces X-Git-Tag: CTH_1_10_a~17 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=67ffaa0aac1e370ff8230498c7d5f7b4f38e46e6;p=modules%2Fgui.git GUITHARE external issue 0020696: 2D 3D surfaces --- diff --git a/src/SVTK/SVTK_CubeAxesDlg.cxx b/src/SVTK/SVTK_CubeAxesDlg.cxx index c8f46c7b9..bf0eaf83f 100644 --- a/src/SVTK/SVTK_CubeAxesDlg.cxx +++ b/src/SVTK/SVTK_CubeAxesDlg.cxx @@ -474,6 +474,22 @@ void SVTK_CubeAxesDlg::Update() myIsVisible->setChecked(myActor->GetVisibility() ? true : false); } +/*! + Show/hide tab with X-dimension controls +*/ +void SVTK_CubeAxesDlg::SetDimensionXEnabled( const bool theIsEnabled ) +{ + myTabWg->setTabEnabled( 0, theIsEnabled ); +} + +/*! + Show/hide tab with Y-dimension controls +*/ +void SVTK_CubeAxesDlg::SetDimensionYEnabled( const bool theIsEnabled ) +{ + myTabWg->setTabEnabled( 1, theIsEnabled ); +} + /*! Show/hide tab with Z-dimension controls */ diff --git a/src/SVTK/SVTK_CubeAxesDlg.h b/src/SVTK/SVTK_CubeAxesDlg.h index e43cb6d5c..41be79735 100644 --- a/src/SVTK/SVTK_CubeAxesDlg.h +++ b/src/SVTK/SVTK_CubeAxesDlg.h @@ -59,6 +59,8 @@ public: void Update(); + void SetDimensionXEnabled( const bool theIsEnabled ); + void SetDimensionYEnabled( const bool theIsEnabled ); void SetDimensionZEnabled( const bool theIsEnabled ); private slots: diff --git a/src/SVTK/SVTK_ViewWindow.cxx b/src/SVTK/SVTK_ViewWindow.cxx index 06c666c9c..7cc026065 100755 --- a/src/SVTK/SVTK_ViewWindow.cxx +++ b/src/SVTK/SVTK_ViewWindow.cxx @@ -117,7 +117,8 @@ SVTK_ViewWindow::SVTK_ViewWindow(SUIT_Desktop* theDesktop): myStandardInteractorStyle(SVTK_InteractorStyle::New()), myKeyFreeInteractorStyle(SVTK_KeyFreeInteractorStyle::New()), myViewsAction( NULL ), - myMode2D( false ) + myMode2D( false ), + myMode2DNormalAxis( AxisZ ) { setWindowFlags( windowFlags() & ~Qt::Window ); // specific of vtkSmartPointer @@ -730,6 +731,7 @@ void SVTK_ViewWindow::onSwitchInteractionStyle(bool theOn) */ void SVTK_ViewWindow::onMode2D( bool theOn ) { + bool anIsModeChanged = theOn != myMode2D; myMode2D = theOn; if( getAction( ViewTrihedronId ) ) @@ -749,24 +751,44 @@ void SVTK_ViewWindow::onMode2D( bool theOn ) if( theOn ) { - myCubeAxesDlg->SetDimensionZEnabled( false ); + myCubeAxesDlg->SetDimensionXEnabled( myMode2DNormalAxis != AxisX ); + myCubeAxesDlg->SetDimensionYEnabled( myMode2DNormalAxis != AxisY ); + myCubeAxesDlg->SetDimensionZEnabled( myMode2DNormalAxis != AxisZ ); if( SVTK_CubeAxesActor2D* aCubeAxes = GetRenderer()->GetCubeAxes() ) { aCubeAxes->SetIsInvertedGrid( true ); + if( vtkAxisActor2D* aXAxis = aCubeAxes->GetXAxisActor2D() ) + { + aXAxis->SetTitleVisibility( myMode2DNormalAxis != AxisX ); + aXAxis->SetLabelVisibility( myMode2DNormalAxis != AxisX ); + aXAxis->SetTickVisibility( myMode2DNormalAxis != AxisX ); + } + if( vtkAxisActor2D* aYAxis = aCubeAxes->GetYAxisActor2D() ) + { + aYAxis->SetTitleVisibility( myMode2DNormalAxis != AxisY ); + aYAxis->SetLabelVisibility( myMode2DNormalAxis != AxisY ); + aYAxis->SetTickVisibility( myMode2DNormalAxis != AxisY ); + } if( vtkAxisActor2D* aZAxis = aCubeAxes->GetZAxisActor2D() ) { - aZAxis->SetTitleVisibility( 0 ); - aZAxis->SetLabelVisibility( 0 ); - aZAxis->SetTickVisibility( 0 ); + aZAxis->SetTitleVisibility( myMode2DNormalAxis != AxisZ ); + aZAxis->SetLabelVisibility( myMode2DNormalAxis != AxisZ ); + aZAxis->SetTickVisibility( myMode2DNormalAxis != AxisZ ); } } - storeViewState( myStored3DViewState ); + if( anIsModeChanged ) + storeViewState( myStored3DViewState ); if( !restoreViewState( myStored2DViewState ) ) { // first time the action is toggled GetRenderer()->SetTrihedronDisplayed( false ); - onTopView(); + switch( myMode2DNormalAxis ) + { + case AxisX: onFrontView(); break; + case AxisY: onLeftView(); break; + case AxisZ: onTopView(); break; + } onFitAll(); } @@ -775,10 +797,24 @@ void SVTK_ViewWindow::onMode2D( bool theOn ) } else { + myCubeAxesDlg->SetDimensionXEnabled( true ); + myCubeAxesDlg->SetDimensionYEnabled( true ); myCubeAxesDlg->SetDimensionZEnabled( true ); if( SVTK_CubeAxesActor2D* aCubeAxes = GetRenderer()->GetCubeAxes() ) { aCubeAxes->SetIsInvertedGrid( false ); + if( vtkAxisActor2D* aXAxis = aCubeAxes->GetXAxisActor2D() ) + { + aXAxis->SetTitleVisibility( 1 ); + aXAxis->SetLabelVisibility( 1 ); + aXAxis->SetTickVisibility( 1 ); + } + if( vtkAxisActor2D* aYAxis = aCubeAxes->GetYAxisActor2D() ) + { + aYAxis->SetTitleVisibility( 1 ); + aYAxis->SetLabelVisibility( 1 ); + aYAxis->SetTickVisibility( 1 ); + } if( vtkAxisActor2D* aZAxis = aCubeAxes->GetZAxisActor2D() ) { aZAxis->SetTitleVisibility( 1 ); @@ -795,6 +831,15 @@ void SVTK_ViewWindow::onMode2D( bool theOn ) } } +/*! + Check that 2D mode is active + \return true if 2D mode is active +*/ +bool SVTK_ViewWindow::isMode2D() const +{ + return myMode2D; +} + /*! Store 2D/3D view state \param theViewState - view state to be stored @@ -836,6 +881,18 @@ bool SVTK_ViewWindow::restoreViewState( ViewState theViewState ) return false; } +/*! + Clear 2D/3D view state + \param theIs2D flag used to indicate which state has to be cleared +*/ +void SVTK_ViewWindow::clearViewState( const bool theIs2D ) +{ + if( theIs2D ) + myStored2DViewState.IsInitialized = false; + else + myStored3DViewState.IsInitialized = false; +} + /*! Sets incremental speed \param theValue - new incremental speed @@ -2157,3 +2214,11 @@ void SVTK_ViewWindow::SetMode2DEnabled( const bool theIsEnabled ) { getAction( Mode2DId )->setVisible( theIsEnabled ); } + +/*! + Set the normal axis for the Mode2D +*/ +void SVTK_ViewWindow::SetMode2DNormalAxis( const int theAxis ) +{ + myMode2DNormalAxis = theAxis; +} diff --git a/src/SVTK/SVTK_ViewWindow.h b/src/SVTK/SVTK_ViewWindow.h index f3c86f980..83553fdde 100755 --- a/src/SVTK/SVTK_ViewWindow.h +++ b/src/SVTK/SVTK_ViewWindow.h @@ -75,6 +75,9 @@ class SVTK_EXPORT SVTK_ViewWindow : public SUIT_ViewWindow { Q_OBJECT; + public: + enum Axis { AxisX = 0, AxisY, AxisZ }; + public: //! To construct #SVTK_ViewWindow instance SVTK_ViewWindow(SUIT_Desktop* theDesktop); @@ -251,6 +254,15 @@ class SVTK_EXPORT SVTK_ViewWindow : public SUIT_ViewWindow //! Show/hide the Mode2D action void SetMode2DEnabled( const bool theIsEnabled ); + //! Set the normal axis for the 2D mode + void SetMode2DNormalAxis( const int theAxis ); + + //! Check that 2D mode is active + bool isMode2D() const; + + //! Clear 2D/3D view state + void clearViewState( const bool theIs2D ); + signals: void Show( QShowEvent * ); void Hide( QHideEvent * ); @@ -422,6 +434,7 @@ protected: int myRecordingToolBar; bool myMode2D; + int myMode2DNormalAxis; ViewState myStored2DViewState; ViewState myStored3DViewState;