From 87503ee9c1d50fe3fcb8bf0bf4ab863ee211b8d0 Mon Sep 17 00:00:00 2001 From: nkv Date: Mon, 9 Jun 2008 06:58:46 +0000 Subject: [PATCH] VTK Viewer Preferences --- src/LightApp/LightApp_Application.cxx | 196 ++++++++++++- src/LightApp/resources/LightApp.xml | 9 +- src/LightApp/resources/LightApp_msg_en.ts | 100 +++++++ src/SVTK/SVTK_InteractorStyle.cxx | 18 +- src/SVTK/SVTK_InteractorStyle.h | 59 ++-- src/SVTK/SVTK_MainWindow.cxx | 26 ++ src/SVTK/SVTK_MainWindow.h | 6 + src/SVTK/SVTK_ViewModel.cxx | 205 ++++++++++---- src/SVTK/SVTK_ViewModel.h | 32 +++ src/SVTK/SVTK_ViewWindow.cxx | 319 ++++++++-------------- src/SVTK/SVTK_ViewWindow.h | 247 ++++++----------- 11 files changed, 748 insertions(+), 469 deletions(-) diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index fa4d8498e..3bdc1cb19 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -1294,9 +1294,16 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType SVTK_Viewer* vm = dynamic_cast( viewMgr->getViewModel() ); if( vm ) { + vm->setProjectionMode( resMgr->integerValue( "VTKViewer", "projection_mode", vm->projectionMode() ) ); vm->setBackgroundColor( resMgr->colorValue( "VTKViewer", "background", vm->backgroundColor() ) ); vm->setTrihedronSize( resMgr->doubleValue( "VTKViewer", "trihedron_size", vm->trihedronSize() ), resMgr->booleanValue( "VTKViewer", "relative_size", vm->trihedronRelative() ) ); + vm->setInteractionStyle( resMgr->integerValue( "VTKViewer", "navigation_mode", vm->interactionStyle() ) ); + vm->setIncrementalSpeed( resMgr->integerValue( "VTKViewer", "speed_value", vm->incrementalSpeed() ), + resMgr->integerValue( "VTKViewer", "speed_mode", vm->incrementalSpeedMode() ) ); + vm->setSpacemouseButtons( resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", vm->spacemouseBtn(1) ), + resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", vm->spacemouseBtn(2) ), + resMgr->integerValue( "VTKViewer", "spacemouse_func3_btn", vm->spacemouseBtn(3) ) ); new LightApp_VTKSelector( vm, mySelMgr ); vm->connectToApplication(this); } @@ -1757,9 +1764,10 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) int supervGroup = pref->addPreference( tr( "PREF_GROUP_SUPERV" ), viewTab ); pref->setItemProperty( "columns", 4, occGroup ); - pref->setItemProperty( "columns", 4, vtkGroup ); + pref->setItemProperty( "columns", 1, vtkGroup ); pref->setItemProperty( "columns", 4, plot2dGroup ); + // OCC Viewer int occTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), occGroup, LightApp_Preferences::DblSpin, "OCCViewer", "trihedron_size" ); pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), occGroup, @@ -1779,15 +1787,104 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) pref->setItemProperty( "min", 0, isoV ); pref->setItemProperty( "max", 100000, isoV ); - int vtkTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), vtkGroup, - LightApp_Preferences::DblSpin, "VTKViewer", "trihedron_size" ); - pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), vtkGroup, + // VTK Viewer + int vtkGen = pref->addPreference( "", vtkGroup, LightApp_Preferences::Frame ); + pref->setItemProperty( "columns", 2, vtkGen ); + + int vtkProjMode = pref->addPreference( tr( "PREF_PROJECTION_MODE" ), vtkGen, + LightApp_Preferences::Selector, "VTKViewer", "projection_mode" ); + QStringList aProjModeList; + aProjModeList.append( tr("PREF_ORTHOGRAPHIC") ); + aProjModeList.append( tr("PREF_PERSPECTIVE") ); + + QList aModeIndexesList; + aModeIndexesList.append(0); + aModeIndexesList.append(1); + + pref->setItemProperty( "strings", aProjModeList, vtkProjMode ); + pref->setItemProperty( "indexes", aModeIndexesList, vtkProjMode ); + + pref->addPreference( tr( "PREF_VIEWER_BACKGROUND" ), vtkGen, LightApp_Preferences::Color, "VTKViewer", "background" ); - pref->addPreference( tr( "PREF_RELATIVE_SIZE" ), vtkGroup, LightApp_Preferences::Bool, "VTKViewer", "relative_size" ); + + int vtkTS = pref->addPreference( tr( "PREF_TRIHEDRON_SIZE" ), vtkGen, + LightApp_Preferences::DblSpin, "VTKViewer", "trihedron_size" ); pref->setItemProperty( "min", 1.0E-06, vtkTS ); pref->setItemProperty( "max", 150, vtkTS ); + pref->addPreference( tr( "PREF_RELATIVE_SIZE" ), vtkGen, LightApp_Preferences::Bool, "VTKViewer", "relative_size" ); + + int vtkStyleMode = pref->addPreference( tr( "PREF_NAVIGATION" ), vtkGen, + LightApp_Preferences::Selector, "VTKViewer", "navigation_mode" ); + QStringList aStyleModeList; + aStyleModeList.append( tr("PREF_STANDARD_STYLE") ); + aStyleModeList.append( tr("PREF_KEYFREE_STYLE") ); + + pref->setItemProperty( "strings", aStyleModeList, vtkStyleMode ); + pref->setItemProperty( "indexes", aModeIndexesList, vtkStyleMode ); + + pref->addPreference( "", vtkGroup, LightApp_Preferences::Space ); + + int vtkSpeed = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED" ), vtkGen, + LightApp_Preferences::IntSpin, "VTKViewer", "speed_value" ); + + pref->setItemProperty( "min", 1, vtkSpeed ); + pref->setItemProperty( "max", 1000, vtkSpeed ); + + int vtkSpeedMode = pref->addPreference( tr( "PREF_INCREMENTAL_SPEED_MODE" ), vtkGen, + LightApp_Preferences::Selector, "VTKViewer", "speed_mode" ); + QStringList aSpeedModeList; + aSpeedModeList.append( tr("PREF_ARITHMETIC") ); + aSpeedModeList.append( tr("PREF_GEOMETRICAL") ); + + pref->setItemProperty( "strings", aSpeedModeList, vtkSpeedMode ); + pref->setItemProperty( "indexes", aModeIndexesList, vtkSpeedMode ); + + int vtkSM = pref->addPreference( tr( "PREF_FRAME_SPACEMOUSE" ), vtkGroup, LightApp_Preferences::GroupBox ); + pref->setItemProperty( "columns", 2, vtkSM ); + int spacemousePref1 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_1" ), vtkSM, + LightApp_Preferences::Selector, "VTKViewer", + "spacemouse_func1_btn" ); //decrease_speed_increment + int spacemousePref2 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_2" ), vtkSM, + LightApp_Preferences::Selector, "VTKViewer", + "spacemouse_func2_btn" ); //increase_speed_increment + int spacemousePref3 = pref->addPreference( tr( "PREF_SPACEMOUSE_FUNC_3" ), vtkSM, + LightApp_Preferences::Selector, "VTKViewer", + "spacemouse_func3_btn" ); //dominant_combined_switch + + QStringList values; + values.append( tr( "PREF_SPACEMOUSE_BTN_1" ) ); + values.append( tr( "PREF_SPACEMOUSE_BTN_2" ) ); + values.append( tr( "PREF_SPACEMOUSE_BTN_3" ) ); + values.append( tr( "PREF_SPACEMOUSE_BTN_4" ) ); + values.append( tr( "PREF_SPACEMOUSE_BTN_5" ) ); + values.append( tr( "PREF_SPACEMOUSE_BTN_6" ) ); + values.append( tr( "PREF_SPACEMOUSE_BTN_7" ) ); + values.append( tr( "PREF_SPACEMOUSE_BTN_8" ) ); + values.append( tr( "PREF_SPACEMOUSE_BTN_*" ) ); + values.append( tr( "PREF_SPACEMOUSE_BTN_10" ) ); + values.append( tr( "PREF_SPACEMOUSE_BTN_11" ) ); + QList indices; + indices.append( 1 ); + indices.append( 2 ); + indices.append( 3 ); + indices.append( 4 ); + indices.append( 5 ); + indices.append( 6 ); + indices.append( 7 ); + indices.append( 8 ); + indices.append( 9 ); // == button_* + indices.append( 10 ); + indices.append( 11 ); + pref->setItemProperty( "strings", values, spacemousePref1 ); + pref->setItemProperty( "indexes", indices, spacemousePref1 ); + pref->setItemProperty( "strings", values, spacemousePref2 ); + pref->setItemProperty( "indexes", indices, spacemousePref2 ); + pref->setItemProperty( "strings", values, spacemousePref3 ); + pref->setItemProperty( "indexes", indices, spacemousePref3 ); + + // Plot2d pref->addPreference( tr( "PREF_SHOW_LEGEND" ), plot2dGroup, LightApp_Preferences::Bool, "Plot2d", "ShowLegend" ); @@ -1997,6 +2094,95 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString } #endif +#ifndef DISABLE_VTKVIEWER + if ( sec == QString( "VTKViewer" ) && (param == QString( "speed_value" ) || param == QString( "speed_mode" )) ) + { + int speed = resMgr->integerValue( "VTKViewer", "speed_value", 10 ); + int mode = resMgr->integerValue( "VTKViewer", "speed_mode", 0 ); + QList lst; +#ifndef DISABLE_SALOMEOBJECT + viewManagers( SVTK_Viewer::Type(), lst ); + QListIterator it( lst ); + while ( it.hasNext() ) + { + SUIT_ViewModel* vm = it.next()->getViewModel(); + if ( !vm || !vm->inherits( "SVTK_Viewer" ) ) + continue; + + SVTK_Viewer* vtkVM = dynamic_cast( vm ); + if( vtkVM ) vtkVM->setIncrementalSpeed( speed, mode ); + } +#endif + } +#endif + +#ifndef DISABLE_VTKVIEWER + if ( sec == QString( "VTKViewer" ) && param == QString( "projection_mode" ) ) + { + int mode = resMgr->integerValue( "VTKViewer", "projection_mode", 0 ); + QList lst; +#ifndef DISABLE_SALOMEOBJECT + viewManagers( SVTK_Viewer::Type(), lst ); + QListIterator it( lst ); + while ( it.hasNext() ) + { + SUIT_ViewModel* vm = it.next()->getViewModel(); + if ( !vm || !vm->inherits( "SVTK_Viewer" ) ) + continue; + + SVTK_Viewer* vtkVM = dynamic_cast( vm ); + if( vtkVM ) vtkVM->setProjectionMode( mode ); + } +#endif + } +#endif + +#ifndef DISABLE_VTKVIEWER + if ( sec == QString( "VTKViewer" ) && param == QString( "navigation_mode" ) ) + { + int mode = resMgr->integerValue( "VTKViewer", "navigation_mode", 0 ); + QList lst; +#ifndef DISABLE_SALOMEOBJECT + viewManagers( SVTK_Viewer::Type(), lst ); + QListIterator it( lst ); + while ( it.hasNext() ) + { + SUIT_ViewModel* vm = it.next()->getViewModel(); + if ( !vm || !vm->inherits( "SVTK_Viewer" ) ) + continue; + + SVTK_Viewer* vtkVM = dynamic_cast( vm ); + if( vtkVM ) vtkVM->setInteractionStyle( mode ); + } +#endif + } +#endif + +#ifndef DISABLE_VTKVIEWER + if ( sec == QString( "VTKViewer" ) && (param == QString( "spacemouse_func1_btn" ) || + param == QString( "spacemouse_func2_btn" ) || + param == QString( "spacemouse_func3_btn" ) ) ) + { + int btn1 = resMgr->integerValue( "VTKViewer", "spacemouse_func1_btn", 1 ); + int btn2 = resMgr->integerValue( "VTKViewer", "spacemouse_func2_btn", 2 ); + int btn3 = resMgr->integerValue( "VTKViewer", "spacemouse_func3_btn", 9 ); + QList lst; +#ifndef DISABLE_SALOMEOBJECT + viewManagers( SVTK_Viewer::Type(), lst ); + QListIterator it( lst ); + while ( it.hasNext() ) + { + SUIT_ViewModel* vm = it.next()->getViewModel(); + if ( !vm || !vm->inherits( "SVTK_Viewer" ) ) + continue; + + SVTK_Viewer* vtkVM = dynamic_cast( vm ); + if( vtkVM ) vtkVM->setSpacemouseButtons( btn1, btn2, btn3 ); + } +#endif + } +#endif + #ifndef DISABLE_OCCVIEWER if ( sec == QString( "OCCViewer" ) && ( param == QString( "iso_number_u" ) || param == QString( "iso_number_v" ) ) ) { diff --git a/src/LightApp/resources/LightApp.xml b/src/LightApp/resources/LightApp.xml index 9fe7a3b57..e4e5ab0a3 100644 --- a/src/LightApp/resources/LightApp.xml +++ b/src/LightApp/resources/LightApp.xml @@ -80,9 +80,16 @@
- + + + + + + + +
diff --git a/src/LightApp/resources/LightApp_msg_en.ts b/src/LightApp/resources/LightApp_msg_en.ts index e9df1e199..1812cbc5f 100644 --- a/src/LightApp/resources/LightApp_msg_en.ts +++ b/src/LightApp/resources/LightApp_msg_en.ts @@ -81,6 +81,106 @@ CEA/DEN, CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITASPREF_STORE_POS Store positions of windows + + PREF_PROJECTION_MODE + Projection mode: + + + PREF_ORTHOGRAPHIC + Orthogonal + + + PREF_PERSPECTIVE + Perspective + + + PREF_NAVIGATION + Navigation: + + + PREF_STANDARD_STYLE + Salome standard controls + + + PREF_KEYFREE_STYLE + Keyboard free style + + + PREF_INCREMENTAL_SPEED + Speed increment: + + + PREF_INCREMENTAL_SPEED_MODE + Modification mode: + + + PREF_ARITHMETIC + Arithmetic progression + + + PREF_GEOMETRICAL + Geometrical progression + + + PREF_FRAME_SPACEMOUSE + Spacemouse + + + PREF_SPACEMOUSE_FUNC_1 + Decrease speed increment + + + PREF_SPACEMOUSE_FUNC_2 + Increase speed increment + + + PREF_SPACEMOUSE_FUNC_3 + Dominant / combined switch + + + PREF_SPACEMOUSE_BTN_1 + Button 1 + + + PREF_SPACEMOUSE_BTN_2 + Button 2 + + + PREF_SPACEMOUSE_BTN_3 + Button 3 + + + PREF_SPACEMOUSE_BTN_4 + Button 4 + + + PREF_SPACEMOUSE_BTN_5 + Button 5 + + + PREF_SPACEMOUSE_BTN_6 + Button 6 + + + PREF_SPACEMOUSE_BTN_7 + Button 7 + + + PREF_SPACEMOUSE_BTN_8 + Button 8 + + + PREF_SPACEMOUSE_BTN_* + Button * + + + PREF_SPACEMOUSE_BTN_10 + Button 10 + + + PREF_SPACEMOUSE_BTN_11 + Button 11 + PREF_BOTTOM Bottom diff --git a/src/SVTK/SVTK_InteractorStyle.cxx b/src/SVTK/SVTK_InteractorStyle.cxx index 06870d12f..0ec193589 100644 --- a/src/SVTK/SVTK_InteractorStyle.cxx +++ b/src/SVTK/SVTK_InteractorStyle.cxx @@ -1642,13 +1642,29 @@ SVTK_ControllerOnKeyDown* SVTK_InteractorStyle::ControllerOnKeyDown() } /*! - To get current increment controller + To set current increment controller */ void SVTK_InteractorStyle::SetControllerIncrement(SVTK_ControllerIncrement* theController) { myControllerIncrement=theController; } +/*! + To modify current increment controller +*/ +void SVTK_InteractorStyle::SetIncrementSpeed(const int theValue, const int theMode) +{ + SVTK_ControllerIncrement* c = 0; + switch (theMode) { + case 0: c = SVTK_ControllerIncrement::New(); break; + case 1: c = SVTK_GeomControllerIncrement::New(); break; + } + c->SetStartValue(theValue); + + SetControllerIncrement(c); + c->Delete(); +} + /*! To get current increment controller */ diff --git a/src/SVTK/SVTK_InteractorStyle.h b/src/SVTK/SVTK_InteractorStyle.h index ddf067bee..969531065 100644 --- a/src/SVTK/SVTK_InteractorStyle.h +++ b/src/SVTK/SVTK_InteractorStyle.h @@ -162,78 +162,53 @@ class SVTK_EXPORT SVTK_InteractorStyle: public vtkInteractorStyle //! Generate special #SVTK_SelectionEvent - virtual - SVTK_SelectionEvent* - GetSelectionEvent(); + virtual SVTK_SelectionEvent* GetSelectionEvent(); //! Generate special #SVTK_SelectionEvent with flipped Y coordinate - virtual - SVTK_SelectionEvent* - GetSelectionEventFlipY(); + virtual SVTK_SelectionEvent* GetSelectionEventFlipY(); //! Redefined in order to add an observer (callback) for custom event (space mouse event) - virtual - void - SetInteractor( vtkRenderWindowInteractor* ); + virtual void SetInteractor( vtkRenderWindowInteractor* ); //! To invoke #vtkRenderWindowInteractor::CreateTimer - virtual - void - Render(); + virtual void Render(); //! To implement cached rendering - virtual - void - OnTimer(); + virtual void OnTimer(); //! To reset reset view - virtual - void - OnConfigure(); + virtual void OnConfigure(); //! To handle mouse move event - virtual - void - OnMouseMove(); + virtual void OnMouseMove(); //! To handle left mouse button down event (reimplemented from #vtkInteractorStyle) - virtual - void - OnLeftButtonDown(); + virtual void OnLeftButtonDown(); //! To handle left mouse button up event (reimplemented from #vtkInteractorStyle) - virtual - void - OnLeftButtonUp(); + virtual void OnLeftButtonUp(); //! To handle middle mouse button down event (reimplemented from #vtkInteractorStyle) - virtual - void - OnMiddleButtonDown(); + virtual void OnMiddleButtonDown(); //! To handle middle mouse button up event (reimplemented from #vtkInteractorStyle) - virtual - void - OnMiddleButtonUp(); + virtual void OnMiddleButtonUp(); //! To handle right mouse button down event (reimplemented from #vtkInteractorStyle) - virtual - void - OnRightButtonDown(); + virtual void OnRightButtonDown(); //! To handle right mouse button up event (reimplemented from #vtkInteractorStyle) - virtual - void - OnRightButtonUp(); + virtual void OnRightButtonUp(); //! To handle keyboard event (reimplemented from #vtkInteractorStyle) - virtual - void - OnChar(); + virtual void OnChar(); //! To set current increment controller void SetControllerIncrement(SVTK_ControllerIncrement*); + //! To modify current increment controller + void SetIncrementSpeed(const int, const int = 0); + //! To get current increment controller SVTK_ControllerIncrement* ControllerIncrement(); diff --git a/src/SVTK/SVTK_MainWindow.cxx b/src/SVTK/SVTK_MainWindow.cxx index 2865b4b0a..da9e4b5ae 100644 --- a/src/SVTK/SVTK_MainWindow.cxx +++ b/src/SVTK/SVTK_MainWindow.cxx @@ -293,6 +293,29 @@ void SVTK_MainWindow::RemoveActor(VTKViewer_Actor* theActor, Repaint(); } +/*! + Redirect the request to SVTK_InteractorStyle::SetTrihedronSize +*/ +void SVTK_MainWindow::SetIncrementalSpeed( const int theValue, const int theMode ) +{ + if ( (SVTK_InteractorStyle*)GetInteractorStyle() ) + ((SVTK_InteractorStyle*)GetInteractorStyle())->SetIncrementSpeed(theValue, theMode); +} + +/*! + Redirect the request to SVTK_InteractorStyle +*/ +void SVTK_MainWindow::SetSMButtons( const int theBtn1, const int theBtn2, const int theBtn3 ) +{ + int val = theBtn1; + myEventDispatcher->InvokeEvent(SVTK::SetSMDecreaseSpeedEvent, &val); + val = theBtn2; + myEventDispatcher->InvokeEvent(SVTK::SetSMIncreaseSpeedEvent, &val); + val = theBtn3; + myEventDispatcher->InvokeEvent(SVTK::SetSMDominantCombinedSwitchEvent, &val); +} + + /*! Redirect the request to SVTK_Renderer::GetTrihedronSize */ @@ -770,6 +793,9 @@ void SVTK_MainWindow::onSwitchInteractionStyle(bool theOn) else { PopInteractorStyle(); } + + // update action state if method is called outside + action(SwitchInteractionStyleId)->setChecked( theOn ); } /*! diff --git a/src/SVTK/SVTK_MainWindow.h b/src/SVTK/SVTK_MainWindow.h index ae9983009..6f4ec2ce0 100644 --- a/src/SVTK/SVTK_MainWindow.h +++ b/src/SVTK/SVTK_MainWindow.h @@ -139,6 +139,12 @@ public: virtual void RemoveActor(VTKViewer_Actor* theActor, bool theIsUpdate = false); + //! Redirect the request to #SVTK_InteractorStyle::SetIncrementalSpeed + void SetIncrementalSpeed( const int, const int = 0 ); + + //! Redirect the request to #SVTK_InteractorStyle::SetIncrementalSpeed + void SetSMButtons( const int, const int, const int ); + //! Redirect the request to #SVTK_Renderer::GetTrihedronSize vtkFloatingPointType GetTrihedronSize(); diff --git a/src/SVTK/SVTK_ViewModel.cxx b/src/SVTK/SVTK_ViewModel.cxx index 8c146841d..7ccffe623 100644 --- a/src/SVTK/SVTK_ViewModel.cxx +++ b/src/SVTK/SVTK_ViewModel.cxx @@ -75,6 +75,13 @@ SVTK_Viewer::SVTK_Viewer() myActiveModule = 0; myTrihedronSize = 105; myTrihedronRelative = true; + myIncrementSpeed = 10; + myIncrementMode = 0; + myProjMode = 0; + myStyle = 0; + mySpaceBtn[0] = 1; + mySpaceBtn[1] = 2; + mySpaceBtn[2] = 9; } /*! @@ -87,9 +94,7 @@ SVTK_Viewer::~SVTK_Viewer() /*! \return background color */ -QColor -SVTK_Viewer -::backgroundColor() const +QColor SVTK_Viewer::backgroundColor() const { return myBgColor; } @@ -98,9 +103,7 @@ SVTK_Viewer Changes background color \param theColor - new background color */ -void -SVTK_Viewer -::setBackgroundColor( const QColor& theColor ) +void SVTK_Viewer::setBackgroundColor( const QColor& theColor ) { if ( !theColor.isValid() ) return; @@ -120,9 +123,7 @@ SVTK_Viewer /*!Create new instance of view window on desktop \a theDesktop. *\retval SUIT_ViewWindow* - created view window pointer. */ -SUIT_ViewWindow* -SVTK_Viewer:: -createView( SUIT_Desktop* theDesktop ) +SUIT_ViewWindow* SVTK_Viewer::createView( SUIT_Desktop* theDesktop ) { TViewWindow* aViewWindow = new TViewWindow(theDesktop); aViewWindow->Initialize(this); @@ -181,6 +182,129 @@ void SVTK_Viewer::setTrihedronSize( const vtkFloatingPointType theSize, const bo } } + +/*! + \return projection mode +*/ +int SVTK_Viewer::projectionMode() const +{ + return myProjMode; +} + + +/*! + Sets projection mode: 0 - orthogonal, 1 - perspective projection + \param theMode - new projection mode +*/ +void SVTK_Viewer::setProjectionMode( const int theMode ) +{ + if ( myProjMode != theMode ) { + myProjMode = theMode; + + if (SUIT_ViewManager* aViewManager = getViewManager()) { + QVector aViews = aViewManager->getViews(); + for ( uint i = 0; i < aViews.count(); i++ ) + { + if ( TViewWindow* aView = dynamic_cast(aViews.at( i )) ) + aView->SetProjectionMode( theMode ); + } + } + } +} + +/*! + \return interaction style +*/ +int SVTK_Viewer::interactionStyle() const +{ + return myStyle; +} + +/*! + Sets interaction style: 0 - standard, 1 - keyboard free interaction + \param theStyle - new interaction style +*/ +void SVTK_Viewer::setInteractionStyle( const int theStyle ) +{ + myStyle = theStyle; + + if (SUIT_ViewManager* aViewManager = getViewManager()) { + QVector aViews = aViewManager->getViews(); + for ( uint i = 0; i < aViews.count(); i++ ) + { + if ( TViewWindow* aView = dynamic_cast(aViews.at( i )) ) + aView->SetInteractionStyle( theStyle ); + } + } +} + +/*! + \return incremental speed value +*/ +int SVTK_Viewer::incrementalSpeed() const +{ + return myIncrementSpeed; +} + +/*! + \return modification mode of the incremental speed +*/ +int SVTK_Viewer::incrementalSpeedMode() const +{ + return myIncrementMode; +} + +/*! + Set the incremental speed value and modification mode + \param theValue - new value + \param theMode - new mode: 0 - arithmetic, 1 - geometrical progression +*/ +void SVTK_Viewer::setIncrementalSpeed( const int theValue, const int theMode ) +{ + myIncrementSpeed = theValue; + myIncrementMode = theMode; + + if (SUIT_ViewManager* aViewManager = getViewManager()) { + QVector aViews = aViewManager->getViews(); + for ( uint i = 0; i < aViews.count(); i++ ) + { + if ( TViewWindow* aView = dynamic_cast(aViews.at( i )) ) + aView->SetIncrementalSpeed( theValue, theMode ); + } + } +} + +/*! + \return spacemouse button assigned to the specified function + \param theIndex - function by number (from 1 to 3) +*/ +int SVTK_Viewer::spacemouseBtn( const int theIndex ) const +{ + if ( theIndex < 1 || theIndex > 3 ) + return -1; + return mySpaceBtn[theIndex-1]; +} + +/*! + Set the spacemouse buttons + \param theBtn1, theBtn2, theBtn3 - new buttons +*/ +void SVTK_Viewer::setSpacemouseButtons( const int theBtn1, const int theBtn2, const int theBtn3 ) +{ + mySpaceBtn[0] = theBtn1; + mySpaceBtn[1] = theBtn2; + mySpaceBtn[2] = theBtn3; + + if (SUIT_ViewManager* aViewManager = getViewManager()) { + QVector aViews = aViewManager->getViews(); + for ( uint i = 0; i < aViews.count(); i++ ) + { + if ( TViewWindow* aView = dynamic_cast(aViews.at( i )) ) + aView->SetSpacemouseButtons( theBtn1, theBtn2, theBtn3 ); + } + } +} + /*! Sets new view manager \param theViewManager - new view manager @@ -205,9 +329,7 @@ void SVTK_Viewer::setViewManager(SUIT_ViewManager* theViewManager) /*! Builds popup for vtk viewer */ -void -SVTK_Viewer -::contextMenuPopup( QMenu* thePopup ) +void SVTK_Viewer::contextMenuPopup( QMenu* thePopup ) { thePopup->addAction( VTKViewer_Viewer::tr( "MEN_DUMP_VIEW" ), this, SLOT( onDumpView() ) ); thePopup->addAction( VTKViewer_Viewer::tr( "MEN_CHANGE_BACKGROUD" ), this, SLOT( onChangeBgColor() ) ); @@ -233,34 +355,26 @@ SVTK_Viewer /*! SLOT: called on mouse button press, empty implementation */ -void -SVTK_Viewer -::onMousePress(SUIT_ViewWindow* vw, QMouseEvent* event) +void SVTK_Viewer::onMousePress(SUIT_ViewWindow* vw, QMouseEvent* event) {} /*! SLOT: called on mouse move, empty implementation */ -void -SVTK_Viewer -::onMouseMove(SUIT_ViewWindow* vw, QMouseEvent* event) +void SVTK_Viewer::onMouseMove(SUIT_ViewWindow* vw, QMouseEvent* event) {} /*! SLOT: called on mouse button release, empty implementation */ -void -SVTK_Viewer -::onMouseRelease(SUIT_ViewWindow* vw, QMouseEvent* event) +void SVTK_Viewer::onMouseRelease(SUIT_ViewWindow* vw, QMouseEvent* event) {} /*! Enables/disables selection \param isEnabled - new state */ -void -SVTK_Viewer -::enableSelection(bool isEnabled) +void SVTK_Viewer::enableSelection(bool isEnabled) { mySelectionEnabled = isEnabled; //!! To be done for view windows @@ -270,9 +384,7 @@ SVTK_Viewer Enables/disables selection of many object \param isEnabled - new state */ -void -SVTK_Viewer -::enableMultiselection(bool isEnable) +void SVTK_Viewer::enableMultiselection(bool isEnable) { myMultiSelectionEnabled = isEnable; //!! To be done for view windows @@ -281,9 +393,7 @@ SVTK_Viewer /*! SLOT: called on dump view operation is activated, stores scene to raster file */ -void -SVTK_Viewer -::onDumpView() +void SVTK_Viewer::onDumpView() { if(SUIT_ViewWindow* aView = myViewManager->getActiveView()) aView->onDumpView(); @@ -292,9 +402,7 @@ SVTK_Viewer /*! SLOT: called if background color is to be changed changed, passes new color to view port */ -void -SVTK_Viewer -::onChangeBgColor() +void SVTK_Viewer::onChangeBgColor() { if(SUIT_ViewWindow* aView = myViewManager->getActiveView()){ QColor aColor = QColorDialog::getColor( backgroundColor(), aView); @@ -306,9 +414,7 @@ SVTK_Viewer Display presentation \param prs - presentation */ -void -SVTK_Viewer -::Display( const SALOME_VTKPrs* prs ) +void SVTK_Viewer::Display( const SALOME_VTKPrs* prs ) { // try do downcast object if(const SVTK_Prs* aPrs = dynamic_cast( prs )){ @@ -355,9 +461,7 @@ SVTK_Viewer \param prs - presentation \param forced - removes object from view */ -void -SVTK_Viewer -::Erase( const SALOME_VTKPrs* prs, const bool forced ) +void SVTK_Viewer::Erase( const SALOME_VTKPrs* prs, const bool forced ) { // try do downcast object if(const SVTK_Prs* aPrs = dynamic_cast( prs )){ @@ -399,9 +503,7 @@ SVTK_Viewer Erase all presentations \param forced - removes all objects from view */ -void -SVTK_Viewer -::EraseAll( const bool forced ) +void SVTK_Viewer::EraseAll( const bool forced ) { // Temporarily commented to avoid awful dependecy on SALOMEDS // TODO: better mechanism of storing display/erse status in a study @@ -447,9 +549,7 @@ SVTK_Viewer Create presentation corresponding to the entry \param entry - entry */ -SALOME_Prs* -SVTK_Viewer -::CreatePrs( const char* entry ) +SALOME_Prs* SVTK_Viewer::CreatePrs( const char* entry ) { SVTK_Prs* prs = new SVTK_Prs(); if ( entry ) { @@ -473,9 +573,7 @@ SVTK_Viewer /*! Auxiliary method called before displaying of objects */ -void -SVTK_Viewer -::BeforeDisplay( SALOME_Displayer* d ) +void SVTK_Viewer::BeforeDisplay( SALOME_Displayer* d ) { d->BeforeDisplay( this, SALOME_VTKViewType() ); } @@ -483,8 +581,7 @@ SVTK_Viewer /*! Auxiliary method called after displaying of objects */ -void -SVTK_Viewer::AfterDisplay( SALOME_Displayer* d ) +void SVTK_Viewer::AfterDisplay( SALOME_Displayer* d ) { d->AfterDisplay( this, SALOME_VTKViewType() ); } @@ -493,9 +590,7 @@ SVTK_Viewer::AfterDisplay( SALOME_Displayer* d ) \return true if object is displayed in viewer \param obj - object to be checked */ -bool -SVTK_Viewer -::isVisible( const Handle(SALOME_InteractiveObject)& io ) +bool SVTK_Viewer::isVisible( const Handle(SALOME_InteractiveObject)& io ) { QVector aViews = myViewManager->getViews(); for(int i = 0, iEnd = aViews.size(); i < iEnd; i++) @@ -511,9 +606,7 @@ SVTK_Viewer /*! Updates current viewer */ -void -SVTK_Viewer -::Repaint() +void SVTK_Viewer::Repaint() { // if (theUpdateTrihedron) onAdjustTrihedron(); QVector aViews = myViewManager->getViews(); diff --git a/src/SVTK/SVTK_ViewModel.h b/src/SVTK/SVTK_ViewModel.h index 9b36f63f0..d09391c5a 100644 --- a/src/SVTK/SVTK_ViewModel.h +++ b/src/SVTK/SVTK_ViewModel.h @@ -77,6 +77,33 @@ public: //! Set size of trihedron of the viewer (see #SVTK_Renderer::SetTrihedronSize) void setTrihedronSize( const vtkFloatingPointType, const bool = true ); + //! Gets projection mode + int projectionMode() const; + + //! Sets projection mode + void setProjectionMode( const int ); + + //! Gets interaction style + int interactionStyle() const; + + //! Sets interaction style + void setInteractionStyle( const int ); + + //! Get incremental speed (see #SVTK_InteractorStyle::ControllerIncrement) + int incrementalSpeed() const; + + //! Returns modification mode of incremental speed (see #SVTK_InteractorStyle::ControllerIncrement) + int incrementalSpeedMode() const; + + //! Set the incremental speed for view operation (see #SVTK_InteractorStyle::ControllerIncrement) + void setIncrementalSpeed( const int, const int = 0 ); + + //! Gets spacemouse button for specified function + int spacemouseBtn( const int ) const; + + //! Sets spacemouse buttons + void setSpacemouseButtons( const int, const int, const int ); + public: void enableSelection(bool isEnabled); bool isSelectionEnabled() const { return mySelectionEnabled; } @@ -140,6 +167,11 @@ private: bool myTrihedronRelative; bool mySelectionEnabled; bool myMultiSelectionEnabled; + int myIncrementSpeed; + int myIncrementMode; + int myProjMode; + int myStyle; + int mySpaceBtn[3]; CAM_Module* myActiveModule; int myExtToolBarId; diff --git a/src/SVTK/SVTK_ViewWindow.cxx b/src/SVTK/SVTK_ViewWindow.cxx index c89b4fb4a..c42c42596 100755 --- a/src/SVTK/SVTK_ViewWindow.cxx +++ b/src/SVTK/SVTK_ViewWindow.cxx @@ -89,8 +89,7 @@ namespace SVTK /*! Constructor */ -SVTK_ViewWindow -::SVTK_ViewWindow(SUIT_Desktop* theDesktop): +SVTK_ViewWindow::SVTK_ViewWindow(SUIT_Desktop* theDesktop): SUIT_ViewWindow(theDesktop), myMainWindow(0), myView(NULL), @@ -100,9 +99,7 @@ SVTK_ViewWindow /*! To initialize #SVTK_ViewWindow instance */ -void -SVTK_ViewWindow -::Initialize(SVTK_ViewModelBase* theModel) +void SVTK_ViewWindow::Initialize(SVTK_ViewModelBase* theModel) { if(SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr()){ myMainWindow = new SVTK_MainWindow(this,"SVTK_MainWindow",aResourceMgr,this); @@ -145,10 +142,8 @@ SVTK_ViewWindow /*! To initialize #SVTK_ViewWindow instance */ -void -SVTK_ViewWindow -::Initialize(SVTK_View* theView, - SVTK_ViewModelBase* theModel) +void SVTK_ViewWindow::Initialize(SVTK_View* theView, + SVTK_ViewModelBase* theModel) { connect(theView,SIGNAL(KeyPressed(QKeyEvent*)), this,SLOT(onKeyPressed(QKeyEvent*)) ); @@ -171,17 +166,14 @@ SVTK_ViewWindow /*! Destructor */ -SVTK_ViewWindow -::~SVTK_ViewWindow() +SVTK_ViewWindow::~SVTK_ViewWindow() {} /*! \return corresponding view */ -SVTK_View* -SVTK_ViewWindow -::getView() +SVTK_View* SVTK_ViewWindow::getView() { return myView; } @@ -189,9 +181,7 @@ SVTK_ViewWindow /*! \return corresponding vtk main window */ -SVTK_MainWindow* -SVTK_ViewWindow -::getMainWindow() +SVTK_MainWindow* SVTK_ViewWindow::getMainWindow() { return myMainWindow; } @@ -199,9 +189,7 @@ SVTK_ViewWindow /*! \return corresponding vtk render window */ -vtkRenderWindow* -SVTK_ViewWindow -::getRenderWindow() +vtkRenderWindow* SVTK_ViewWindow::getRenderWindow() { return getMainWindow()->getRenderWindow(); } @@ -209,9 +197,7 @@ SVTK_ViewWindow /*! \return corresponding vtk render window interactor */ -vtkRenderWindowInteractor* -SVTK_ViewWindow -::getInteractor() +vtkRenderWindowInteractor* SVTK_ViewWindow::getInteractor() { return getMainWindow()->getInteractor(); } @@ -219,9 +205,7 @@ SVTK_ViewWindow /*! \return corresponding vtk renderer */ -vtkRenderer* -SVTK_ViewWindow -::getRenderer() +vtkRenderer* SVTK_ViewWindow::getRenderer() { return myMainWindow->getRenderer(); } @@ -229,9 +213,7 @@ SVTK_ViewWindow /*! \return corresponding vtk selector */ -SVTK_Selector* -SVTK_ViewWindow -::GetSelector() +SVTK_Selector* SVTK_ViewWindow::GetSelector() { return myMainWindow->GetSelector(); } @@ -239,9 +221,7 @@ SVTK_ViewWindow /*! Processes transformation "front view" */ -void -SVTK_ViewWindow -::onFrontView() +void SVTK_ViewWindow::onFrontView() { myMainWindow->onFrontView(); } @@ -249,9 +229,7 @@ SVTK_ViewWindow /*! Processes transformation "back view" */ -void -SVTK_ViewWindow -::onBackView() +void SVTK_ViewWindow::onBackView() { myMainWindow->onBackView(); } @@ -259,9 +237,7 @@ SVTK_ViewWindow /*! Processes transformation "top view" */ -void -SVTK_ViewWindow -::onTopView() +void SVTK_ViewWindow::onTopView() { myMainWindow->onTopView(); } @@ -269,9 +245,7 @@ SVTK_ViewWindow /*! Processes transformation "bottom view" */ -void -SVTK_ViewWindow -::onBottomView() +void SVTK_ViewWindow::onBottomView() { myMainWindow->onBottomView(); } @@ -279,9 +253,7 @@ SVTK_ViewWindow /*! Processes transformation "left view" */ -void -SVTK_ViewWindow -::onLeftView() +void SVTK_ViewWindow::onLeftView() { myMainWindow->onLeftView(); } @@ -289,9 +261,7 @@ SVTK_ViewWindow /*! Processes transformation "right view" */ -void -SVTK_ViewWindow -::onRightView() +void SVTK_ViewWindow::onRightView() { myMainWindow->onRightView(); } @@ -299,9 +269,7 @@ SVTK_ViewWindow /*! Processes transformation "reset view": sets default orientation of viewport camera */ -void -SVTK_ViewWindow -::onResetView() +void SVTK_ViewWindow::onResetView() { myMainWindow->onResetView(); } @@ -309,9 +277,7 @@ SVTK_ViewWindow /*! Processes transformation "fit all" */ -void -SVTK_ViewWindow -::onFitAll() +void SVTK_ViewWindow::onFitAll() { myMainWindow->onFitAll(); } @@ -319,9 +285,7 @@ SVTK_ViewWindow /*! SLOT: called if selection is changed */ -void -SVTK_ViewWindow -::onSelectionChanged() +void SVTK_ViewWindow::onSelectionChanged() { myView->onSelectionChanged(); } @@ -330,9 +294,7 @@ SVTK_ViewWindow Change selection mode \param theMode - new selection mode */ -void -SVTK_ViewWindow -::SetSelectionMode(Selection_Mode theMode) +void SVTK_ViewWindow::SetSelectionMode(Selection_Mode theMode) { myMainWindow->SetSelectionMode( theMode ); } @@ -340,9 +302,7 @@ SVTK_ViewWindow /*! \return selection mode */ -Selection_Mode -SVTK_ViewWindow -::SelectionMode() const +Selection_Mode SVTK_ViewWindow::SelectionMode() const { return myMainWindow->SelectionMode(); } @@ -350,9 +310,7 @@ SVTK_ViewWindow /*! Unhilights all objects in viewer */ -void -SVTK_ViewWindow -::unHighlightAll() +void SVTK_ViewWindow::unHighlightAll() { myView->unHighlightAll(); } @@ -363,11 +321,9 @@ SVTK_ViewWindow \param theIsHighlight - if it is true, object will be hilighted, otherwise it will be unhilighted \param theIsUpdate - update current viewer */ -void -SVTK_ViewWindow -::highlight(const Handle(SALOME_InteractiveObject)& theIO, - bool theIsHighlight, - bool theIsUpdate ) +void SVTK_ViewWindow::highlight(const Handle(SALOME_InteractiveObject)& theIO, + bool theIsHighlight, + bool theIsUpdate ) { myView->highlight( theIO, theIsHighlight, theIsUpdate ); } @@ -376,9 +332,7 @@ SVTK_ViewWindow \return true if object is in viewer or in collector \param theIO - object to be checked */ -bool -SVTK_ViewWindow -::isInViewer( const Handle(SALOME_InteractiveObject)& theIO ) +bool SVTK_ViewWindow::isInViewer( const Handle(SALOME_InteractiveObject)& theIO ) { return myView->isInViewer( theIO ); } @@ -387,9 +341,7 @@ SVTK_ViewWindow \return true if object is displayed in viewer \param theIO - object to be checked */ -bool -SVTK_ViewWindow -::isVisible( const Handle(SALOME_InteractiveObject)& theIO ) +bool SVTK_ViewWindow::isVisible( const Handle(SALOME_InteractiveObject)& theIO ) { return myView->isVisible( theIO ); } @@ -398,9 +350,7 @@ SVTK_ViewWindow Display object \param theEntry - entry that corresponds to intractive objects */ -Handle(SALOME_InteractiveObject) -SVTK_ViewWindow -::FindIObject(const char* theEntry) +Handle(SALOME_InteractiveObject) SVTK_ViewWindow::FindIObject(const char* theEntry) { return myView->FindIObject(theEntry); } @@ -410,10 +360,8 @@ SVTK_ViewWindow \param theIO - object \param theImmediatly - update viewer */ -void -SVTK_ViewWindow -::Display(const Handle(SALOME_InteractiveObject)& theIO, - bool theImmediatly) +void SVTK_ViewWindow::Display(const Handle(SALOME_InteractiveObject)& theIO, + bool theImmediatly) { myView->Display(theIO,theImmediatly); } @@ -423,10 +371,8 @@ SVTK_ViewWindow \param theIO - object \param theImmediatly - update viewer */ -void -SVTK_ViewWindow -::Erase(const Handle(SALOME_InteractiveObject)& theIO, - bool theImmediatly) +void SVTK_ViewWindow::Erase(const Handle(SALOME_InteractiveObject)& theIO, + bool theImmediatly) { myView->Erase(theIO,theImmediatly); } @@ -435,9 +381,7 @@ SVTK_ViewWindow Display only passed object \param theIO - object */ -void -SVTK_ViewWindow -::DisplayOnly(const Handle(SALOME_InteractiveObject)& theIO) +void SVTK_ViewWindow::DisplayOnly(const Handle(SALOME_InteractiveObject)& theIO) { myView->DisplayOnly(theIO); } @@ -445,9 +389,7 @@ SVTK_ViewWindow /*! Display all objects in view */ -void -SVTK_ViewWindow -::DisplayAll() +void SVTK_ViewWindow::DisplayAll() { myView->DisplayAll(); } @@ -455,9 +397,7 @@ SVTK_ViewWindow /*! Erase all objects in view */ -void -SVTK_ViewWindow -::EraseAll() +void SVTK_ViewWindow::EraseAll() { myView->EraseAll(); } @@ -466,9 +406,7 @@ SVTK_ViewWindow Sets background color \param color - new background color */ -void -SVTK_ViewWindow -::setBackgroundColor( const QColor& color ) +void SVTK_ViewWindow::setBackgroundColor( const QColor& color ) { myMainWindow->SetBackgroundColor( color ); } @@ -476,9 +414,7 @@ SVTK_ViewWindow /*! \return background color of viewer */ -QColor -SVTK_ViewWindow -::backgroundColor() const +QColor SVTK_ViewWindow::backgroundColor() const { return myMainWindow->BackgroundColor(); } @@ -486,9 +422,7 @@ SVTK_ViewWindow /*! Updates current viewer */ -void -SVTK_ViewWindow -::Repaint(bool theUpdateTrihedron) +void SVTK_ViewWindow::Repaint(bool theUpdateTrihedron) { myMainWindow->Repaint( theUpdateTrihedron ); } @@ -496,9 +430,7 @@ SVTK_ViewWindow /*! Redirect the request to #SVTK_Renderer::GetScale */ -void -SVTK_ViewWindow -::GetScale( double theScale[3] ) +void SVTK_ViewWindow::GetScale( double theScale[3] ) { myMainWindow->GetScale( theScale ); } @@ -506,9 +438,7 @@ SVTK_ViewWindow /*! Redirect the request to #SVTK_Renderer::SetScale */ -void -SVTK_ViewWindow -::SetScale( double theScale[3] ) +void SVTK_ViewWindow::SetScale( double theScale[3] ) { myMainWindow->SetScale( theScale ); } @@ -516,9 +446,7 @@ SVTK_ViewWindow /*! Redirect the request to #SVTK_Renderer::IsTrihedronDisplayed */ -bool -SVTK_ViewWindow -::isTrihedronDisplayed() +bool SVTK_ViewWindow::isTrihedronDisplayed() { return myMainWindow->IsTrihedronDisplayed(); } @@ -526,9 +454,7 @@ SVTK_ViewWindow /*! Redirect the request to #SVTK_Renderer::IsCubeAxesDisplayed */ -bool -SVTK_ViewWindow -::isCubeAxesDisplayed() +bool SVTK_ViewWindow::isCubeAxesDisplayed() { return myMainWindow->IsCubeAxesDisplayed(); } @@ -536,9 +462,7 @@ SVTK_ViewWindow /*! Redirect the request to #SVTK_Renderer::OnViewTrihedron */ -void -SVTK_ViewWindow -::onViewTrihedron() +void SVTK_ViewWindow::onViewTrihedron() { myMainWindow->onViewTrihedron(); } @@ -546,9 +470,7 @@ SVTK_ViewWindow /*! Redirect the request to #SVTK_Renderer::OnViewCubeAxes */ -void -SVTK_ViewWindow -::onViewCubeAxes() +void SVTK_ViewWindow::onViewCubeAxes() { myMainWindow->onViewCubeAxes(); } @@ -556,9 +478,7 @@ SVTK_ViewWindow /*! Redirect the request to #SVTK_Renderer::GetTrihedron */ -VTKViewer_Trihedron* -SVTK_ViewWindow:: -GetTrihedron() +VTKViewer_Trihedron* SVTK_ViewWindow::GetTrihedron() { return myMainWindow->GetTrihedron(); } @@ -566,9 +486,7 @@ GetTrihedron() /*! Redirect the request to #SVTK_Renderer::GetCubeAxes */ -SVTK_CubeAxesActor2D* -SVTK_ViewWindow -::GetCubeAxes() +SVTK_CubeAxesActor2D* SVTK_ViewWindow::GetCubeAxes() { return myMainWindow->GetCubeAxes(); } @@ -576,21 +494,58 @@ SVTK_ViewWindow /*! \return trihedron size */ -vtkFloatingPointType -SVTK_ViewWindow -::GetTrihedronSize() const +vtkFloatingPointType SVTK_ViewWindow::GetTrihedronSize() const { return myMainWindow->GetTrihedronSize(); } +/*! + Sets projection mode + \param theMode - projection mode ( 0 - orthogonal, 1 - perspective ) +*/ +void SVTK_ViewWindow::SetProjectionMode(const int theMode) +{ + myMainWindow->activateProjectionMode( theMode ); +} + +/*! + Sets actual interaction style + \param theStyle - type of interaction style ( 0 - standard, 1 - keyboard free ) +*/ +void SVTK_ViewWindow::SetInteractionStyle(const int theStyle) +{ + myMainWindow->onSwitchInteractionStyle( theStyle==1 ); +} + +/*! + Sets incremental speed + \param theValue - new incremental speed + \param theMode - modification mode +*/ +void SVTK_ViewWindow::SetIncrementalSpeed(const int theValue, const int theMode) +{ + myMainWindow->SetIncrementalSpeed(theValue, theMode); +} + +/*! + Sets spacemouse buttons for the functions + \param theBtn1 - spacemouse button for the "decrease speed increment" + \param theBtn2 - spacemouse button for the "increase speed increment" + \param theBtn3 - spacemouse button for the "dominant combined switch" +*/ +void SVTK_ViewWindow::SetSpacemouseButtons(const int theBtn1, + const int theBtn2, + const int theBtn3) +{ + myMainWindow->SetSMButtons(theBtn1, theBtn2, theBtn3); +} + /*! Sets trihedron size \param theSize - new trihedron size \param theRelative - trihedron relativeness */ -void -SVTK_ViewWindow -::SetTrihedronSize(const vtkFloatingPointType theSize, const bool theRelative) +void SVTK_ViewWindow::SetTrihedronSize(const vtkFloatingPointType theSize, const bool theRelative) { myMainWindow->SetTrihedronSize(theSize, theRelative); } @@ -598,9 +553,7 @@ SVTK_ViewWindow /*! If parameter theIsForcedUpdate is true, recalculate parameters for * trihedron and cube axes, even if trihedron and cube axes is invisible. */ -void -SVTK_ViewWindow -::AdjustTrihedrons(const bool theIsForcedUpdate) +void SVTK_ViewWindow::AdjustTrihedrons(const bool theIsForcedUpdate) { myMainWindow->AdjustActors(); } @@ -608,9 +561,7 @@ SVTK_ViewWindow /*! Redirect the request to #SVTK_Renderer::OnAdjustTrihedron */ -void -SVTK_ViewWindow -::onAdjustTrihedron() +void SVTK_ViewWindow::onAdjustTrihedron() { myMainWindow->onAdjustTrihedron(); } @@ -618,9 +569,7 @@ SVTK_ViewWindow /*! Redirect the request to #SVTK_Renderer::OnAdjustCubeAxes */ -void -SVTK_ViewWindow -::onAdjustCubeAxes() +void SVTK_ViewWindow::onAdjustCubeAxes() { myMainWindow->onAdjustCubeAxes(); } @@ -628,9 +577,7 @@ SVTK_ViewWindow /*! Emits key pressed */ -void -SVTK_ViewWindow -::onKeyPressed(QKeyEvent* event) +void SVTK_ViewWindow::onKeyPressed(QKeyEvent* event) { emit keyPressed( this, event ); } @@ -638,9 +585,7 @@ SVTK_ViewWindow /*! Emits key released */ -void -SVTK_ViewWindow -::onKeyReleased(QKeyEvent* event) +void SVTK_ViewWindow::onKeyReleased(QKeyEvent* event) { emit keyReleased( this, event ); } @@ -648,9 +593,7 @@ SVTK_ViewWindow /*! Emits mouse pressed */ -void -SVTK_ViewWindow -::onMousePressed(QMouseEvent* event) +void SVTK_ViewWindow::onMousePressed(QMouseEvent* event) { emit mousePressed(this, event); } @@ -658,9 +601,7 @@ SVTK_ViewWindow /*! Emits mouse released */ -void -SVTK_ViewWindow -::onMouseReleased(QMouseEvent* event) +void SVTK_ViewWindow::onMouseReleased(QMouseEvent* event) { emit mouseReleased( this, event ); } @@ -668,9 +609,7 @@ SVTK_ViewWindow /*! Emits mouse moving */ -void -SVTK_ViewWindow -::onMouseMoving(QMouseEvent* event) +void SVTK_ViewWindow::onMouseMoving(QMouseEvent* event) { emit mouseMoving( this, event ); } @@ -678,9 +617,7 @@ SVTK_ViewWindow /*! Emits mouse double clicked */ -void -SVTK_ViewWindow -::onMouseDoubleClicked( QMouseEvent* event ) +void SVTK_ViewWindow::onMouseDoubleClicked( QMouseEvent* event ) { emit mouseDoubleClicked( this, event ); } @@ -689,7 +626,7 @@ SVTK_ViewWindow Redirect the request to #SVTK_Renderer::AddActor */ void SVTK_ViewWindow::AddActor( VTKViewer_Actor* theActor, - bool theUpdate ) + bool theUpdate ) { myMainWindow->AddActor( theActor, theUpdate ); emit actorAdded(theActor); @@ -698,10 +635,8 @@ void SVTK_ViewWindow::AddActor( VTKViewer_Actor* theActor, /*! Redirect the request to #SVTK_Renderer::RemoveActor */ -void -SVTK_ViewWindow -::RemoveActor( VTKViewer_Actor* theActor, - bool theUpdate ) +void SVTK_ViewWindow::RemoveActor( VTKViewer_Actor* theActor, + bool theUpdate ) { myMainWindow->RemoveActor( theActor, theUpdate ); emit actorRemoved(theActor); @@ -710,9 +645,7 @@ SVTK_ViewWindow /*! \return QImage, containing all scene rendering in window */ -QImage -SVTK_ViewWindow -::dumpView() +QImage SVTK_ViewWindow::dumpView() { if ( myMainWindow->getToolBar()->testAttribute(Qt::WA_UnderMouse) || myDumpImage.isNull() ) return myMainWindow->dumpView(); @@ -770,12 +703,10 @@ void SVTK_ViewWindow::RefreshDumpImage() /*! Redirect the request to #SVTK_Renderer::SetSelectionProp */ -void -SVTK_ViewWindow -::SetSelectionProp(const double& theRed, - const double& theGreen, - const double& theBlue, - const int& theWidth) +void SVTK_ViewWindow::SetSelectionProp(const double& theRed, + const double& theGreen, + const double& theBlue, + const int& theWidth) { myView->SetSelectionProp(theRed,theGreen,theBlue,theWidth); } @@ -783,12 +714,10 @@ SVTK_ViewWindow /*! Redirect the request to #SVTK_Renderer::SetSelectionProp */ -void -SVTK_ViewWindow -::SetPreselectionProp(const double& theRed, - const double& theGreen, - const double& theBlue, - const int& theWidth) +void SVTK_ViewWindow::SetPreselectionProp(const double& theRed, + const double& theGreen, + const double& theBlue, + const int& theWidth) { myView->SetPreselectionProp(theRed,theGreen,theBlue,theWidth); } @@ -796,11 +725,9 @@ SVTK_ViewWindow /*! Redirect the request to #SVTK_Renderer::SetSelectionTolerance */ -void -SVTK_ViewWindow -::SetSelectionTolerance(const double& theTolNodes, - const double& theTolItems, - const double& theTolObjects) +void SVTK_ViewWindow::SetSelectionTolerance(const double& theTolNodes, + const double& theTolItems, + const double& theTolObjects) { myView->SetSelectionTolerance(theTolNodes, theTolItems, theTolObjects); } @@ -809,9 +736,7 @@ SVTK_ViewWindow Performs action \param accelAction - action */ -bool -SVTK_ViewWindow -::action( const int accelAction ) +bool SVTK_ViewWindow::action( const int accelAction ) { if ( !myMainWindow->hasFocus() ) return false; @@ -958,9 +883,7 @@ void setGradAxisVisualParams( vtkAxisActor2D* actor, const QString& params ) /*! The method returns the visual parameters of this view as a formated string */ -QString -SVTK_ViewWindow -::getVisualParameters() +QString SVTK_ViewWindow::getVisualParameters() { double pos[3], focalPnt[3], viewUp[3], parScale, scale[3]; @@ -993,10 +916,8 @@ SVTK_ViewWindow /*! The method restores visual parameters of this view or postpones it untill the view is shown -*/ -void -SVTK_ViewWindow -::setVisualParameters( const QString& parameters ) +*/ +void SVTK_ViewWindow::setVisualParameters( const QString& parameters ) { SVTK_RenderWindowInteractor* anInteractor = getMainWindow()->GetInteractor(); if ( anInteractor->isVisible() ) { @@ -1011,9 +932,7 @@ SVTK_ViewWindow /*! The method restores visual parameters of this view from a formated string */ -void -SVTK_ViewWindow -::doSetVisualParameters( const QString& parameters ) +void SVTK_ViewWindow::doSetVisualParameters( const QString& parameters ) { QStringList paramsLst = parameters.split( '*' ); if ( paramsLst.size() >= nNormalParams ) { diff --git a/src/SVTK/SVTK_ViewWindow.h b/src/SVTK/SVTK_ViewWindow.h index 75f7acf48..ab4e876a6 100755 --- a/src/SVTK/SVTK_ViewWindow.h +++ b/src/SVTK/SVTK_ViewWindow.h @@ -62,215 +62,161 @@ class SVTK_EXPORT SVTK_ViewWindow : public SUIT_ViewWindow //! To construct #SVTK_ViewWindow instance SVTK_ViewWindow(SUIT_Desktop* theDesktop); - virtual - ~SVTK_ViewWindow(); + virtual ~SVTK_ViewWindow(); virtual QImage dumpView(); //! To initialize #SVTK_ViewWindow instance - virtual - void - Initialize(SVTK_ViewModelBase* theModel); + virtual void Initialize(SVTK_ViewModelBase* theModel); //! Get #SVTK_View - SVTK_View* - getView(); + SVTK_View* getView(); //! Get #SVTK_MainWindow - SVTK_MainWindow* - getMainWindow(); + SVTK_MainWindow* getMainWindow(); //! Redirect the request to #SVTK_MainWindow::getRenderWindow - vtkRenderWindow* - getRenderWindow(); + vtkRenderWindow* getRenderWindow(); //! Redirect the request to #SVTK_MainWindow::getInteractor - vtkRenderWindowInteractor* - getInteractor(); + vtkRenderWindowInteractor* getInteractor(); //! Redirect the request to #SVTK_MainWindow::getRenderer - vtkRenderer* - getRenderer(); + vtkRenderer* getRenderer(); //! Redirect the request to #SVTK_MainWindow::GetSelector - SVTK_Selector* - GetSelector(); + SVTK_Selector* GetSelector(); //! Redirect the request to #SVTK_Selector::SelectionMode - Selection_Mode - SelectionMode() const; + Selection_Mode SelectionMode() const; //! Change selection mode - virtual - void - SetSelectionMode(Selection_Mode theMode); + virtual void SetSelectionMode(Selection_Mode theMode); //! Redirect the request to #SVTK_MainWindow::SetBackgroundColor - virtual - void - setBackgroundColor( const QColor& ); + virtual void setBackgroundColor( const QColor& ); //! Redirect the request to #SVTK_MainWindow::SetBackgroundColor - QColor - backgroundColor() const; + QColor backgroundColor() const; //! Redirect the request to #SVTK_Renderer::IsTrihedronDisplayed - bool - isTrihedronDisplayed(); + bool isTrihedronDisplayed(); //! Redirect the request to #SVTK_Renderer::IsCubeAxesDisplayed - bool - isCubeAxesDisplayed(); + bool isCubeAxesDisplayed(); /* interactive object management */ //! Redirect the request to #SVTK_View::highlight (to support old code) - virtual - void - highlight(const Handle(SALOME_InteractiveObject)& theIO, - bool theIsHighlight = true, - bool theIsUpdate = true); + virtual void highlight(const Handle(SALOME_InteractiveObject)& theIO, + bool theIsHighlight = true, + bool theIsUpdate = true); //! Redirect the request to #SVTK_View::unHighlightAll (to support old code) - virtual - void - unHighlightAll(); + virtual void unHighlightAll(); //! Redirect the request to #SVTK_View::isInViewer (to support old code) - bool - isInViewer(const Handle(SALOME_InteractiveObject)& theIObject); + bool isInViewer(const Handle(SALOME_InteractiveObject)& theIObject); //! Redirect the request to #SVTK_View::isVisible (to support old code) - bool - isVisible(const Handle(SALOME_InteractiveObject)& theIObject); + bool isVisible(const Handle(SALOME_InteractiveObject)& theIObject); //! Redirect the request to #SVTK_View::FindIObject (to support old code) //---------------------------------------------------------------------------- - Handle(SALOME_InteractiveObject) - FindIObject(const char* theEntry); + Handle(SALOME_InteractiveObject) FindIObject(const char* theEntry); /* display */ //---------------------------------------------------------------------------- //! Redirect the request to #SVTK_View::Display (to support old code) - virtual - void - Display(const Handle(SALOME_InteractiveObject)& theIObject, - bool theImmediatly = true); + virtual void Display(const Handle(SALOME_InteractiveObject)& theIObject, + bool theImmediatly = true); //! Redirect the request to #SVTK_View::DisplayOnly (to support old code) - virtual - void - DisplayOnly(const Handle(SALOME_InteractiveObject)& theIObject); + virtual void DisplayOnly(const Handle(SALOME_InteractiveObject)& theIObject); //! Redirect the request to #SVTK_View::Erase (to support old code) - virtual - void - Erase(const Handle(SALOME_InteractiveObject)& theIObject, - bool theImmediatly = true); + virtual void Erase(const Handle(SALOME_InteractiveObject)& theIObject, + bool theImmediatly = true); //! Redirect the request to #SVTK_View::DisplayAll (to support old code) - virtual - void - DisplayAll(); + virtual void DisplayAll(); //! Redirect the request to #SVTK_View::EraseAll (to support old code) - virtual - void - EraseAll(); + virtual void EraseAll(); //! To repaint the viewer - virtual - void - Repaint(bool theUpdateTrihedron = true); + virtual void Repaint(bool theUpdateTrihedron = true); //---------------------------------------------------------------------------- //! Redirect the request to #SVTK_Renderer::SetScale - virtual - void - SetScale( double theScale[3] ); + virtual void SetScale( double theScale[3] ); //! Redirect the request to #SVTK_Renderer::GetScale - virtual - void - GetScale( double theScale[3] ); + virtual void GetScale( double theScale[3] ); //! Redirect the request to #SVTK_Renderer::AddActor - virtual - void - AddActor(VTKViewer_Actor* theActor, - bool theIsUpdate = false); + virtual void AddActor(VTKViewer_Actor* theActor, + bool theIsUpdate = false); //! Redirect the request to #SVTK_Renderer::RemoveActor - virtual - void - RemoveActor(VTKViewer_Actor* theActor, - bool theIsUpdate = false); + virtual void RemoveActor(VTKViewer_Actor* theActor, + bool theIsUpdate = false); //---------------------------------------------------------------------------- //! Redirect the request to #SVTK_Renderer::AdjustActors - virtual - void - AdjustTrihedrons(const bool theIsForced); + virtual void AdjustTrihedrons(const bool theIsForced); //! Redirect the request to #SVTK_Renderer::GetTrihedron - VTKViewer_Trihedron* - GetTrihedron(); + VTKViewer_Trihedron* GetTrihedron(); //! Redirect the request to #SVTK_Renderer::GetCubeAxes - SVTK_CubeAxesActor2D* - GetCubeAxes(); + SVTK_CubeAxesActor2D* GetCubeAxes(); //! Redirect the request to #SVTK_Renderer::GetTrihedronSize - vtkFloatingPointType - GetTrihedronSize() const; + vtkFloatingPointType GetTrihedronSize() const; //! Redirect the request to #SVTK_Renderer::SetTrihedronSize - virtual - void - SetTrihedronSize( const vtkFloatingPointType, const bool = true ); + virtual void SetTrihedronSize( const vtkFloatingPointType, const bool = true ); + + //! Redirect the request to #SVTK_MainWindow::SetIncrementalSpeed + virtual void SetIncrementalSpeed( const int, const int = 0 ); + + //! Redirect the request to #SVTK_MainWindow::SetProjectionMode + virtual void SetProjectionMode( const int ); + + //! Redirect the request to #SVTK_MainWindow::SetInteractionStyle + virtual void SetInteractionStyle( const int ); + + //! Redirect the request to #SVTK_MainWindow::SetSpacemouseButtons + virtual void SetSpacemouseButtons( const int, const int, const int ); //! Redirect the request to #SVTK_Renderer::SetSelectionProp - virtual - void - SetSelectionProp(const double& theRed = 1, - const double& theGreen = 1, - const double& theBlue = 0, - const int& theWidth = 5); + virtual void SetSelectionProp(const double& theRed = 1, + const double& theGreen = 1, + const double& theBlue = 0, + const int& theWidth = 5); //! Redirect the request to #SVTK_Renderer::SetPreselectionProp - virtual - void - SetPreselectionProp(const double& theRed = 0, - const double& theGreen = 1, - const double& theBlue = 1, - const int& theWidth = 5); + virtual void SetPreselectionProp(const double& theRed = 0, + const double& theGreen = 1, + const double& theBlue = 1, + const int& theWidth = 5); //! Redirect the request to #SVTK_Renderer::SetSelectionTolerance - virtual - void - SetSelectionTolerance(const double& theTolNodes = 0.025, - const double& theTolCell = 0.001, - const double& theTolObjects = 0.025); + virtual void SetSelectionTolerance(const double& theTolNodes = 0.025, + const double& theTolCell = 0.001, + const double& theTolObjects = 0.025); //! Methods to save/restore visual parameters of a view (pan, zoom, etc.) - virtual - QString - getVisualParameters(); + virtual QString getVisualParameters(); - virtual - void - setVisualParameters( const QString& parameters ); + virtual void setVisualParameters( const QString& parameters ); - virtual - bool - eventFilter( QObject*, QEvent* ); + virtual bool eventFilter( QObject*, QEvent* ); - virtual - void RefreshDumpImage(); + virtual void RefreshDumpImage(); public slots: - virtual - void - onSelectionChanged(); + virtual void onSelectionChanged(); signals: void selectionChanged(); @@ -279,64 +225,40 @@ signals: public slots: //! Redirect the request to #SVTK_Renderer::OnFrontView - virtual - void - onFrontView(); + virtual void onFrontView(); //! Redirect the request to #SVTK_Renderer::OnBackView - virtual - void - onBackView(); + virtual void onBackView(); //! Redirect the request to #SVTK_Renderer::OnTopView - virtual - void - onTopView(); + virtual void onTopView(); //! Redirect the request to #SVTK_Renderer::OnBottomView - virtual - void - onBottomView(); + virtual void onBottomView(); //! Redirect the request to #SVTK_Renderer::OnRightView - virtual - void - onRightView(); + virtual void onRightView(); //! Redirect the request to #SVTK_Renderer::OnLeftView - virtual - void - onLeftView(); + virtual void onLeftView(); //! Redirect the request to #SVTK_Renderer::OnResetView - virtual - void - onResetView(); + virtual void onResetView(); //! Redirect the request to #SVTK_Renderer::OnFitAll - virtual - void - onFitAll(); + virtual void onFitAll(); //! Redirect the request to #SVTK_Renderer::OnViewTrihedron - virtual - void - onViewTrihedron(); + virtual void onViewTrihedron(); //! Redirect the request to #SVTK_Renderer::OnViewCubeAxes - virtual - void - onViewCubeAxes(); + virtual void onViewCubeAxes(); //! Redirect the request to #SVTK_Renderer::OnAdjustTrihedron - virtual - void - onAdjustTrihedron(); + virtual void onAdjustTrihedron(); //! Redirect the request to #SVTK_Renderer::OnAdjustCubeAxes - virtual - void - onAdjustCubeAxes(); + virtual void onAdjustCubeAxes(); protected slots: void onKeyPressed(QKeyEvent* event); @@ -347,13 +269,10 @@ protected slots: void onMouseMoving(QMouseEvent* event); protected: - virtual - void - Initialize(SVTK_View* theView, - SVTK_ViewModelBase* theModel); + virtual void Initialize(SVTK_View* theView, + SVTK_ViewModelBase* theModel); - void - doSetVisualParameters( const QString& ); + void doSetVisualParameters( const QString& ); virtual QString filter() const; virtual bool dumpViewToFormat( const QImage& img, const QString& fileName, const QString& format ); -- 2.39.2