]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Issue 0021329: EDF 1922 SMESH: Performance issue of VTK viewer with big meshes
authorvsr <vsr@opencascade.com>
Sat, 24 Sep 2011 17:24:50 +0000 (17:24 +0000)
committervsr <vsr@opencascade.com>
Sat, 24 Sep 2011 17:24:50 +0000 (17:24 +0000)
15 files changed:
src/LightApp/LightApp_Application.cxx
src/LightApp/resources/LightApp.xml
src/LightApp/resources/LightApp_msg_en.ts
src/LightApp/resources/LightApp_msg_fr.ts
src/SVTK/Makefile.am
src/SVTK/SVTK_Selector.cxx
src/SVTK/SVTK_Selector.h
src/SVTK/SVTK_SelectorDef.h
src/SVTK/SVTK_ViewModel.cxx
src/SVTK/SVTK_ViewModel.h
src/SVTK/SVTK_ViewWindow.cxx
src/SVTK/SVTK_ViewWindow.h
src/SVTK/resources/SVTK_images.ts
src/SVTK/resources/SVTK_msg_en.ts
src/SVTK/resources/vtk_view_highlight.png [new file with mode: 0755]

index db79e0dedb7ca8e4afef3fef456d56bc3bc9189d..f79040d064c132b279b319cd46fdb41c9a665b85 100644 (file)
@@ -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<SUIT_ViewManager*> lst;
+#ifndef DISABLE_SALOMEOBJECT
+    viewManagers( SVTK_Viewer::Type(), lst );
+    QListIterator<SUIT_ViewManager*> it( lst );
+    while ( it.hasNext() )
+    {
+      SUIT_ViewModel* vm = it.next()->getViewModel();
+      if ( !vm || !vm->inherits( "SVTK_Viewer" ) )
+        continue;
+
+      SVTK_Viewer* vtkVM = dynamic_cast<SVTK_Viewer*>( vm );
+      if( vtkVM ) vtkVM->setDynamicPreSelection( mode );
+    }
+#endif
+  }
+#endif
+
 #ifndef DISABLE_VTKVIEWER
   if ( sec == QString( "VTKViewer" ) && param == QString( "show_static_trihedron" ) )
   {
index a2e7e17a6240d3ff9c0cd1c067aa9d930aa9ffac..58aed5a52dc972c605a6b1f0479d5e2fe79a7068 100644 (file)
     <parameter name="projection_mode"                  value="0"/>
     <parameter name="trihedron_size"                   value="105"/>
     <parameter name="relative_size"                    value="true"/>
-    <parameter name="use_advanced_selection_algorithm" value="true"/>
+    <parameter name="dynamic_preselection"             value="true"/>
     <parameter name="navigation_mode"                  value="0"/>
     <parameter name="zooming_mode"                     value="0"/>
     <parameter name="speed_value"                      value="10"/>
index 33ab5ac95d070dbeea9dcf0a94c81fbfe9e4082c..e8c917a331b4bf0a130298efcd6d30a3fe70dfab 100644 (file)
@@ -627,8 +627,8 @@ The changes will be applied on the next application session.</translation>
         <translation>Python Console</translation>
     </message>
     <message>
-        <source>PREF_USE_ADVANCED_SELECTION_ALGORITHM</source>
-        <translation>Use Advanced Selection Algorithm</translation>
+        <source>PREF_DYNAMIC_PRESELECTION</source>
+        <translation>Dynamic pre-selection</translation>
     </message>
     <message>
         <source>TOT_CLOSE</source>
index daffd4a83d86f4ec6b0dde769629db858a30c934..d0818b919ebdfd0ca6324d34a878669a9177c70c 100755 (executable)
@@ -627,7 +627,7 @@ Les modifications seront appliquées à la prochaine session.</translation>
         <translation>Console Python</translation>
     </message>
     <message>
-        <source>PREF_USE_ADVANCED_SELECTION_ALGORITHM</source>
+        <source>PREF_DYNAMIC_PRESELECTION</source>
         <translation>Utiliser l&apos;algorithme de sélection avancée</translation>
     </message>
     <message>
index f7f57dccd342392bef85b8d959ac1002a8068f0d..57556cdf7fb8c7d54dbdb70637c37256fd8ce18b 100755 (executable)
@@ -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  \
index ea681eccc4782bfa6a459bde1524534a49f48478..c5b039a5137f64f20157ea3088a56ac9d61f3180 100644 (file)
@@ -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;
+}
index 4e1114b8b438ffb0bc7f3ed0aa27040c5280c5f3..15b1678fc301a600b43dfad2a8dc96f09ddd75ec 100644 (file)
@@ -218,6 +218,14 @@ public:
   virtual
   void
   SetTolerance(const double& theTolerance) = 0;
+
+  virtual
+  void
+  SetDynamicPreSelection( bool theIsDynPreselect ) = 0;
+
+  virtual
+  bool
+  GetDynamicPreSelection() const = 0;
 };
 
 
index b4768e74f792e6e61cd5f8996363776ada592576..bb78d3f89b516d9413504f5cc9c2957859258615 100644 (file)
@@ -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 
index aa9edc2a81a99c514ac5d2f8242fc1933a2a5589..10ac9944c27ee0856859c7e42de838c1989f3253 100644 (file)
@@ -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<SUIT_ViewWindow*> aViews = aViewManager->getViews();
+    for ( uint i = 0; i < aViews.count(); i++ )
+    {
+      if ( TViewWindow* aView = dynamic_cast<TViewWindow*>(aViews.at( i )) )
+        aView->SetDynamicPreSelection( theMode );
+    }
+  }
+}
+
 /*!
   \return incremental speed value
 */
index a3755764c1c11260c5cb417c5175dc703d0b5fa5..c0313279ef90eb7bdae1abeb5c08401649f8c689 100644 (file)
@@ -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];
 };
 
index 1a853416bc7a685206e72fbbaa7602adfa3ccdb7..c682aefaa45806f13075c7ac34031a08d829a107 100755 (executable)
@@ -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 );
index 24f29d9aa61fb29eb4a515c2dd31bde1348b70e3..5555b06d3d440e9583bb4faff9215aa953a8746f 100755 (executable)
@@ -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;
index c2afa1b8e0c135cce56aae37e0507e6a161aa727..362ffef6e05bce95d7672a7ea037e7b622a830a7 100644 (file)
@@ -59,5 +59,9 @@
         <source>ICON_SVTK_SYNCHRONIZE</source>
         <translation>vtk_view_sync.png</translation>
     </message>
+    <message>
+        <source>ICON_SVTK_DYNAMIC_PRESLECTION_SWITCH</source>
+        <translation>vtk_view_highlight.png</translation>
+    </message>
 </context>
 </TS>
index d5ef2af33ae97225bef817278d2ff0ea0608b92e..ad4d257bffe66077bd56220ccf12cccaed476ac8 100644 (file)
         <source>MNU_SVTK_ZOOMING_STYLE_SWITCH</source>
         <translation>Zomming style switch</translation>
     </message>
+    <message>
+        <source>DSC_SVTK_DYNAMIC_PRESLECTION_SWITCH</source>
+        <translation>Dynamic preselection switch</translation>
+    </message>
+    <message>
+        <source>MNU_SVTK_DYNAMIC_PRESLECTION_SWITCH</source>
+        <translation>Dynamic preselection switch</translation>
+    </message>
 </context>
 <context>
     <name>SVTK_FontWidget</name>
diff --git a/src/SVTK/resources/vtk_view_highlight.png b/src/SVTK/resources/vtk_view_highlight.png
new file mode 100755 (executable)
index 0000000..0aa1d6f
Binary files /dev/null and b/src/SVTK/resources/vtk_view_highlight.png differ