From: vsr Date: Sat, 24 Sep 2011 17:24:50 +0000 (+0000) Subject: Issue 0021329: EDF 1922 SMESH: Performance issue of VTK viewer with big meshes X-Git-Tag: V6_4_0a1~62 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=08b5c317b6d9070cc97a315290c612076647dd6e;p=modules%2Fgui.git Issue 0021329: EDF 1922 SMESH: Performance issue of VTK viewer with big meshes --- diff --git a/src/LightApp/LightApp_Application.cxx b/src/LightApp/LightApp_Application.cxx index db79e0ded..f79040d06 100644 --- a/src/LightApp/LightApp_Application.cxx +++ b/src/LightApp/LightApp_Application.cxx @@ -1404,6 +1404,7 @@ SUIT_ViewManager* LightApp_Application::createViewManager( const QString& vmType vm->setStaticTrihedronVisible( resMgr->booleanValue( "VTKViewer", "show_static_trihedron", vm->isStaticTrihedronVisible() ) ); vm->setInteractionStyle( resMgr->integerValue( "VTKViewer", "navigation_mode", vm->interactionStyle() ) ); vm->setZoomingStyle( resMgr->integerValue( "VTKViewer", "zooming_mode", vm->zoomingStyle() ) ); + vm->setDynamicPreSelection( resMgr->booleanValue( "VTKViewer", "dynamic_preselection", vm->dynamicPreSelection() ) ); 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) ), @@ -2095,6 +2096,7 @@ void LightApp_Application::createPreferences( LightApp_Preferences* pref ) pref->setItemProperty( "indexes", aModeIndexesList, vtkSpeedMode ); pref->addPreference( tr( "PREF_SHOW_STATIC_TRIHEDRON" ), vtkGen, LightApp_Preferences::Bool, "VTKViewer", "show_static_trihedron" ); + pref->addPreference( tr( "PREF_DYNAMIC_PRESELECTION" ), vtkGen, LightApp_Preferences::Bool, "VTKViewer", "dynamic_preselection" ); int vtkSM = pref->addPreference( tr( "PREF_FRAME_SPACEMOUSE" ), vtkGroup, LightApp_Preferences::GroupBox ); pref->setItemProperty( "columns", 2, vtkSM ); @@ -2482,6 +2484,27 @@ void LightApp_Application::preferencesChanged( const QString& sec, const QString } #endif +#ifndef DISABLE_VTKVIEWER + if ( sec == QString( "VTKViewer" ) && param == QString( "dynamic_preselection" ) ) + { + bool mode = resMgr->booleanValue( "VTKViewer", "dynamic_preselection", true ); + 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->setDynamicPreSelection( mode ); + } +#endif + } +#endif + #ifndef DISABLE_VTKVIEWER if ( sec == QString( "VTKViewer" ) && param == QString( "show_static_trihedron" ) ) { diff --git a/src/LightApp/resources/LightApp.xml b/src/LightApp/resources/LightApp.xml index a2e7e17a6..58aed5a52 100644 --- a/src/LightApp/resources/LightApp.xml +++ b/src/LightApp/resources/LightApp.xml @@ -146,7 +146,7 @@ - + diff --git a/src/LightApp/resources/LightApp_msg_en.ts b/src/LightApp/resources/LightApp_msg_en.ts index 33ab5ac95..e8c917a33 100644 --- a/src/LightApp/resources/LightApp_msg_en.ts +++ b/src/LightApp/resources/LightApp_msg_en.ts @@ -627,8 +627,8 @@ The changes will be applied on the next application session. Python Console - PREF_USE_ADVANCED_SELECTION_ALGORITHM - Use Advanced Selection Algorithm + PREF_DYNAMIC_PRESELECTION + Dynamic pre-selection TOT_CLOSE diff --git a/src/LightApp/resources/LightApp_msg_fr.ts b/src/LightApp/resources/LightApp_msg_fr.ts index daffd4a83..d0818b919 100755 --- a/src/LightApp/resources/LightApp_msg_fr.ts +++ b/src/LightApp/resources/LightApp_msg_fr.ts @@ -627,7 +627,7 @@ Les modifications seront appliquées à la prochaine session. Console Python - PREF_USE_ADVANCED_SELECTION_ALGORITHM + PREF_DYNAMIC_PRESELECTION Utiliser l'algorithme de sélection avancée diff --git a/src/SVTK/Makefile.am b/src/SVTK/Makefile.am index f7f57dccd..57556cdf7 100755 --- a/src/SVTK/Makefile.am +++ b/src/SVTK/Makefile.am @@ -133,7 +133,8 @@ dist_salomeres_DATA=\ resources/vtk_view_recording_play.png \ resources/vtk_view_recording_pause.png \ resources/vtk_view_recording_stop.png \ - resources/vtk_view_sync.png + resources/vtk_view_sync.png \ + resources/vtk_view_highlight.png nodist_salomeres_DATA = \ SVTK_msg_en.qm \ diff --git a/src/SVTK/SVTK_Selector.cxx b/src/SVTK/SVTK_Selector.cxx index ea681eccc..c5b039a51 100644 --- a/src/SVTK/SVTK_Selector.cxx +++ b/src/SVTK/SVTK_Selector.cxx @@ -62,6 +62,7 @@ SVTK_SelectorDef myCellPicker(vtkCellPicker::New()) { mySelectionMode = ActorSelection; + myDynamicPreselection = true; myPicker->Delete(); myCellPicker->Delete(); @@ -531,13 +532,9 @@ vtkActorCollection* SVTK_SelectorDef ::Pick(const SVTK_SelectionEvent* theEvent, vtkRenderer* theRenderer) const { - bool anAdvancedSelectionAlgorithm = true; - SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr(); - if ( aResourceMgr ) - anAdvancedSelectionAlgorithm = aResourceMgr->booleanValue( "VTKViewer", "use_advanced_selection_algorithm", true ); - vtkActorCollection* aListActors = NULL; - if ( anAdvancedSelectionAlgorithm ) { + + if ( GetDynamicPreSelection() ) { myCellPicker->Pick(theEvent->myX, theEvent->myY, 0.0, @@ -564,3 +561,17 @@ SVTK_SelectorDef myPicker->SetTolerance(theTolerance); myCellPicker->SetTolerance(theTolerance); } + +void +SVTK_SelectorDef +::SetDynamicPreSelection( bool theIsDynPreselect ) +{ + myDynamicPreselection = theIsDynPreselect; +} + +bool +SVTK_SelectorDef +::GetDynamicPreSelection() const +{ + return myDynamicPreselection; +} diff --git a/src/SVTK/SVTK_Selector.h b/src/SVTK/SVTK_Selector.h index 4e1114b8b..15b1678fc 100644 --- a/src/SVTK/SVTK_Selector.h +++ b/src/SVTK/SVTK_Selector.h @@ -218,6 +218,14 @@ public: virtual void SetTolerance(const double& theTolerance) = 0; + + virtual + void + SetDynamicPreSelection( bool theIsDynPreselect ) = 0; + + virtual + bool + GetDynamicPreSelection() const = 0; }; diff --git a/src/SVTK/SVTK_SelectorDef.h b/src/SVTK/SVTK_SelectorDef.h index b4768e74f..bb78d3f89 100644 --- a/src/SVTK/SVTK_SelectorDef.h +++ b/src/SVTK/SVTK_SelectorDef.h @@ -178,9 +178,19 @@ public: void SetTolerance(const double& theTolerance); + virtual + void + SetDynamicPreSelection( bool theIsDynPreselect ); + + virtual + bool + GetDynamicPreSelection() const; + private: int mySelectionMode; + bool myDynamicPreselection; + struct TIOLessThan { bool diff --git a/src/SVTK/SVTK_ViewModel.cxx b/src/SVTK/SVTK_ViewModel.cxx index aa9edc2a8..10ac9944c 100644 --- a/src/SVTK/SVTK_ViewModel.cxx +++ b/src/SVTK/SVTK_ViewModel.cxx @@ -81,6 +81,7 @@ SVTK_Viewer::SVTK_Viewer() myProjMode = 0; myStyle = 0; myZoomingStyle = 0; + myDynamicPreSelection = false; mySpaceBtn[0] = 1; mySpaceBtn[1] = 2; mySpaceBtn[2] = 9; @@ -136,6 +137,7 @@ SUIT_ViewWindow* SVTK_Viewer::createView( SUIT_Desktop* theDesktop ) aViewWindow->SetProjectionMode( projectionMode() ); aViewWindow->SetInteractionStyle( interactionStyle() ); aViewWindow->SetZoomingStyle( zoomingStyle() ); + aViewWindow->SetDynamicPreSelection( dynamicPreSelection() ); aViewWindow->SetIncrementalSpeed( incrementalSpeed(), incrementalSpeedMode() ); aViewWindow->SetSpacemouseButtons( spacemouseBtn(1), spacemouseBtn(2), spacemouseBtn(3) ); @@ -290,6 +292,32 @@ void SVTK_Viewer::setZoomingStyle( const int theStyle ) } } +/*! + \return dynamic preselection +*/ +bool SVTK_Viewer::dynamicPreSelection() const +{ + return myDynamicPreSelection; +} + +/*! + Sets dynamic preselection + \param theMode - new dynamic preselection mode +*/ +void SVTK_Viewer::setDynamicPreSelection( const bool theMode ) +{ + myDynamicPreSelection = 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->SetDynamicPreSelection( theMode ); + } + } +} + /*! \return incremental speed value */ diff --git a/src/SVTK/SVTK_ViewModel.h b/src/SVTK/SVTK_ViewModel.h index a3755764c..c0313279e 100644 --- a/src/SVTK/SVTK_ViewModel.h +++ b/src/SVTK/SVTK_ViewModel.h @@ -103,6 +103,12 @@ public: //! Sets zooming style void setZoomingStyle( const int ); + //! Gets dynamic preselection + bool dynamicPreSelection() const; + + //! Sets dynamic preselection + void setDynamicPreSelection( const bool ); + //! Get incremental speed (see #SVTK_InteractorStyle::ControllerIncrement) int incrementalSpeed() const; @@ -180,6 +186,7 @@ private: int myProjMode; int myStyle; int myZoomingStyle; + bool myDynamicPreSelection; int mySpaceBtn[3]; }; diff --git a/src/SVTK/SVTK_ViewWindow.cxx b/src/SVTK/SVTK_ViewWindow.cxx index 1a853416b..c682aefaa 100755 --- a/src/SVTK/SVTK_ViewWindow.cxx +++ b/src/SVTK/SVTK_ViewWindow.cxx @@ -137,7 +137,9 @@ void SVTK_ViewWindow::Initialize(SVTK_ViewModelBase* theModel) { myInteractor = new SVTK_RenderWindowInteractor(this,"SVTK_RenderWindowInteractor"); - SVTK_Selector* aSelector = SVTK_Selector::New(); + SVTK_Selector* aSelector = SVTK_Selector::New(); + aSelector->SetDynamicPreSelection( SUIT_Session::session()->resourceMgr()-> + booleanValue( "VTKViewer", "dynamic_preselection", true ) ); SVTK_GenericRenderWindowInteractor* aDevice = SVTK_GenericRenderWindowInteractor::New(); aDevice->SetRenderWidget(myInteractor); @@ -155,7 +157,7 @@ void SVTK_ViewWindow::Initialize(SVTK_ViewModelBase* theModel) myToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_LABEL"), false, Qt::AllToolBarAreas, -1, this ); myRecordingToolBar = toolMgr()->createToolBar( tr("LBL_TOOLBAR_RECORD_LABEL"), false, Qt::AllToolBarAreas, -1, this ); - createActions( SUIT_Session::session()->activeApplication()->resourceMgr() ); + createActions( SUIT_Session::session()->resourceMgr() ); createToolBar(); SetEventDispatcher(myInteractor->GetDevice()); @@ -710,6 +712,15 @@ void SVTK_ViewWindow::SetZoomingStyle(const int theStyle) onSwitchZoomingStyle( theStyle==1 ); } +/*! + Switch dynamic preselection on / off + \param theDynPreselection - dynamic pre-selection mode +*/ +void SVTK_ViewWindow::SetDynamicPreSelection( bool theDynPreselection ) +{ + onSwitchDynamicPreSelection( theDynPreselection ); +} + /*! Switches "keyboard free" interaction style on/off */ @@ -756,6 +767,19 @@ void SVTK_ViewWindow::onSwitchZoomingStyle( bool theOn ) a->setChecked( theOn ); } +/*! + Toogles dynamic preselection on/off +*/ +void SVTK_ViewWindow::onSwitchDynamicPreSelection( bool theOn ) +{ + GetSelector()->SetDynamicPreSelection( theOn ); + + // update action state if method is called outside + QtxAction* a = getAction( SwitchDynamicPreselectionId ); + if ( a->isChecked() != theOn ) + a->setChecked( theOn ); +} + /*! Sets incremental speed \param theValue - new incremental speed @@ -1859,7 +1883,7 @@ void SVTK_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr) connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchInteractionStyle(bool))); mgr->registerAction( anAction, SwitchInteractionStyleId ); - // Switch between zomming styles + // Switch between zooming styles anAction = new QtxAction(tr("MNU_SVTK_ZOOMING_STYLE_SWITCH"), theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_ZOOMING_STYLE_SWITCH" ) ), tr( "MNU_SVTK_ZOOMING_STYLE_SWITCH" ), 0, this); @@ -1868,6 +1892,15 @@ void SVTK_ViewWindow::createActions(SUIT_ResourceMgr* theResourceMgr) connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchZoomingStyle(bool))); mgr->registerAction( anAction, SwitchZoomingStyleId ); + // Turn on/off dynamic pre-selection + anAction = new QtxAction(tr("MNU_SVTK_DYNAMIC_PRESLECTION_SWITCH"), + theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_DYNAMIC_PRESLECTION_SWITCH" ) ), + tr( "MNU_SVTK_DYNAMIC_PRESLECTION_SWITCH" ), 0, this); + anAction->setStatusTip(tr("DSC_SVTK_DYNAMIC_PRESLECTION_SWITCH")); + anAction->setCheckable(true); + connect(anAction, SIGNAL(toggled(bool)), this, SLOT(onSwitchDynamicPreSelection(bool))); + mgr->registerAction( anAction, SwitchDynamicPreselectionId ); + // Start recording myStartAction = new QtxAction(tr("MNU_SVTK_RECORDING_START"), theResourceMgr->loadPixmap( "VTKViewer", tr( "ICON_SVTK_RECORDING_START" ) ), @@ -1914,6 +1947,7 @@ void SVTK_ViewWindow::createToolBar() mgr->append( DumpId, myToolBar ); mgr->append( SwitchInteractionStyleId, myToolBar ); mgr->append( SwitchZoomingStyleId, myToolBar ); + mgr->append( SwitchDynamicPreselectionId, myToolBar ); mgr->append( ViewTrihedronId, myToolBar ); QtxMultiAction* aScaleAction = new QtxMultiAction( this ); diff --git a/src/SVTK/SVTK_ViewWindow.h b/src/SVTK/SVTK_ViewWindow.h index 24f29d9aa..5555b06d3 100755 --- a/src/SVTK/SVTK_ViewWindow.h +++ b/src/SVTK/SVTK_ViewWindow.h @@ -226,6 +226,8 @@ class SVTK_EXPORT SVTK_ViewWindow : public SUIT_ViewWindow //! Redirect the request to #SVTK_MainWindow::SetZoomingStyle virtual void SetZoomingStyle( const int ); + virtual void SetDynamicPreSelection( bool ); + //! Redirect the request to #SVTK_MainWindow::SetSpacemouseButtons virtual void SetSpacemouseButtons( const int, const int, const int ); @@ -301,6 +303,7 @@ public slots: void onSwitchInteractionStyle(bool theOn); void onSwitchZoomingStyle(bool theOn); + void onSwitchDynamicPreSelection(bool theOn); void onStartRecording(); void onPlayRecording(); @@ -389,10 +392,9 @@ protected: FrontId, BackId, TopId, BottomId, LeftId, RightId, ClockWiseId, AntiClockWiseId, ResetId, ViewTrihedronId, NonIsometric, GraduatedAxes, UpdateRate, ParallelModeId, ProjectionModeId, ViewParametersId, SynchronizeId, SwitchInteractionStyleId, - SwitchZoomingStyleId, + SwitchZoomingStyleId,SwitchDynamicPreselectionId, StartRecordingId, PlayRecordingId, PauseRecordingId, StopRecordingId }; - SVTK_View* myView; //SVTK_MainWindow* myMainWindow; SVTK_ViewModelBase* myModel; diff --git a/src/SVTK/resources/SVTK_images.ts b/src/SVTK/resources/SVTK_images.ts index c2afa1b8e..362ffef6e 100644 --- a/src/SVTK/resources/SVTK_images.ts +++ b/src/SVTK/resources/SVTK_images.ts @@ -59,5 +59,9 @@ ICON_SVTK_SYNCHRONIZE vtk_view_sync.png + + ICON_SVTK_DYNAMIC_PRESLECTION_SWITCH + vtk_view_highlight.png + diff --git a/src/SVTK/resources/SVTK_msg_en.ts b/src/SVTK/resources/SVTK_msg_en.ts index d5ef2af33..ad4d257bf 100644 --- a/src/SVTK/resources/SVTK_msg_en.ts +++ b/src/SVTK/resources/SVTK_msg_en.ts @@ -223,6 +223,14 @@ MNU_SVTK_ZOOMING_STYLE_SWITCH Zomming style switch + + DSC_SVTK_DYNAMIC_PRESLECTION_SWITCH + Dynamic preselection switch + + + MNU_SVTK_DYNAMIC_PRESLECTION_SWITCH + Dynamic preselection switch + SVTK_FontWidget diff --git a/src/SVTK/resources/vtk_view_highlight.png b/src/SVTK/resources/vtk_view_highlight.png new file mode 100755 index 000000000..0aa1d6f9c Binary files /dev/null and b/src/SVTK/resources/vtk_view_highlight.png differ