]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Managing configurations.
authorouv <ouv@opencascade.com>
Mon, 26 Dec 2005 13:12:39 +0000 (13:12 +0000)
committerouv <ouv@opencascade.com>
Mon, 26 Dec 2005 13:12:39 +0000 (13:12 +0000)
src/VISUGUI/VISUM_msg_en.po
src/VISUGUI/VisuGUI.cxx
src/VISUGUI/VisuGUI_Module.cxx
src/VISUGUI/VisuGUI_Module.h

index 6aa0d0fd45bd91fdeedc408e3d9bcee332e78318..ff3533b7aece8c3433b90189881d7df7ed1c902e 100644 (file)
@@ -18,6 +18,15 @@ msgstr "Visualization"
 msgid "VisuGUI_Module::TOOL_VISUALISATION"
 msgstr "Visualization Toolbar"
 
+msgid "VisuGUI_Module::MEN_SAVE_CONFIGURATION"
+msgstr "Store current configuration"
+
+msgid "VisuGUI_Module::MEN_OVERWRITE_CONFIGURATION"
+msgstr "Overwrite current configuration"
+
+msgid "VisuGUI_Module::MEN_RESTORE_CONFIGURATION"
+msgstr "Restore current configuration"
+
 msgid "VisuGUI_Module::MEN_GAUSS"
 msgstr "Gauss"
 
index 4c18c6e708e5aa0515fa63bc5fc5277f29207327..1da83dacb52c12a87179710116f8849ad2aa7c23 100644 (file)
@@ -2430,10 +2430,10 @@ createPopupMenus()
   mgr->setRule( action( VISU_FREE_SCALAR_BARS ), aRule, true );
 
   // view parameters
-  aRule = "selcount=1 and type='VISU::TVIEW3D'";
+  aRule = "selcount=1 and type='VISU::TVIEW3D' and activeView='VTKViewer'";
   mgr->setRule( action( VISU_SAVE_VIEW_PARAMS_1 ), aRule, true );
-  mgr->setRule( action( VISU_SAVE_VIEW_PARAMS ), "client='VTKViewer' and selcount=0", true );
-  mgr->setRule( action( VISU_RESTORE_VIEW_PARAMS ), "selcount=1 and type='VISU::TVIEW3D'", true );
+  mgr->setRule( action( VISU_SAVE_VIEW_PARAMS ), "client='VTKViewer' and selcount=0 and activeView='VTKViewer'", true );
+  mgr->setRule( action( VISU_RESTORE_VIEW_PARAMS ), "selcount=1 and type='VISU::TVIEW3D' and activeView='VTKViewer'", true );
   //mgr->setRule( action( VISU_DELETE_VIEW_PARAMS ), "selcount=1 and type='VISU::TVIEW3D'", true );
 
   mgr->setRule( action( VISU_ARRANGE_ACTORS ), "client='VTKViewer' and selcount=0", true );
index ecabc032cfcd6c9bd9fd6cf164628f99043f8f04..bbbfaa3d0034365285c4476337204ff096dea47b 100644 (file)
@@ -55,6 +55,7 @@
 #include "VisuGUI_Prs3dTools.h"
 
 #include "VISU_GaussPoints_i.hh"
+#include "VISU_GaussPtsAct.h"
 #include "VisuGUI_GaussPointsDlg.h"
 
 #include "VISU_Gen_i.hh"
@@ -96,6 +97,12 @@ static int MYDEBUG = 0;
 #define GAUSS_DISPLAY_PRS        5500
 #define GAUSS_DISPLAY_ONLY_PRS   5600
 
+#define GAUSS_SAVE_CONFIGURATION       5700
+#define GAUSS_OVERWRITE_CONFIGURATION  5701
+#define GAUSS_RESTORE_CONFIGURATION    5702
+
+int VisuGUI_Module::myNbConfigs = 0;
+
 void
 CreateCurves( SalomeApp_Module* theModule,
               VISU::CutLines_i* thePrs,
@@ -290,13 +297,35 @@ VisuGUI_Module
   mgr->insert( action( GAUSS_DISPLAY_ONLY_PRS ), -1, -1, -1 ); // display only
   mgr->setRule( action( GAUSS_DISPLAY_ONLY_PRS ), 
                aRule, true );
-
-  mgr->setRule( action( VISU_SAVE_VIEW_PARAMS ), "selcount=1 and $type in {'VISU::TVIEW3D' VISU::TGAUSSVIEW}", true );
-  mgr->setRule( action( VISU_SAVE_VIEW_PARAMS_1 ), "$client in {'VTKViewer' 'SVTK'} and selcount=0", true );
-  aRule = "selcount=1 and "
+  /*
+  mgr->setRule( action( VISU_SAVE_VIEW_PARAMS ), "selcount=1 and $type in {VISU::TGAUSSVIEW}", true );
+  mgr->setRule( action( VISU_SAVE_VIEW_PARAMS_1 ), "$client in {'VVTK'} and selcount=0", true );
+  //mgr->setRule( action( VISU_SAVE_VIEW_PARAMS ), "$type in {'VISU::TVIEW3D' VISU::TGAUSSVIEW}", true );
+  //mgr->setRule( action( VISU_SAVE_VIEW_PARAMS_1 ), "$client in {'VTKViewer' 'SVTK'}", true );
+  aRule = //"selcount=1 and "
     "((type='VISU::TVIEW3D' and activeView='VTKViewer') or "
     "(type='VISU::TGAUSSVIEW' and activeView='VVTK'))";
   mgr->setRule( action( VISU_RESTORE_VIEW_PARAMS ), aRule, true );
+  */
+  createAction( GAUSS_SAVE_CONFIGURATION, tr("MEN_SAVE_CONFIGURATION"), QIconSet(),
+                tr("MEN_SAVE_CONFIGURATION"), "", 0, this, false,
+                this, SLOT(OnSaveConfiguration()));
+  mgr->insert( action( GAUSS_SAVE_CONFIGURATION ), -1, -1, -1 );
+  mgr->setRule( action( GAUSS_SAVE_CONFIGURATION ), "selcount>=0 and client='VVTK' and activeView='VVTK'", true );
+
+  createAction( GAUSS_OVERWRITE_CONFIGURATION, tr("MEN_OVERWRITE_CONFIGURATION"), QIconSet(),
+                tr("MEN_OVERWRITE_CONFIGURATION"), "", 0, this, false,
+                this, SLOT(OnOverwriteConfiguration()));
+  mgr->insert( action( GAUSS_OVERWRITE_CONFIGURATION ), -1, -1, -1 );
+  mgr->setRule( action( GAUSS_OVERWRITE_CONFIGURATION ),
+               "selcount=1 and client='ObjectBrowser' and type='VISU::TGAUSSVIEW' and activeView='VVTK'", true );
+
+  createAction( GAUSS_RESTORE_CONFIGURATION, tr("MEN_RESTORE_CONFIGURATION"), QIconSet(),
+                tr("MEN_RESTORE_CONFIGURATION"), "", 0, this, false,
+                this, SLOT(OnRestoreConfiguration()));
+  mgr->insert( action( GAUSS_RESTORE_CONFIGURATION ), -1, -1, -1 );
+  mgr->setRule( action( GAUSS_RESTORE_CONFIGURATION ),
+               "selcount=1 and type='VISU::TGAUSSVIEW' and activeView='VVTK'", true );
 }
 
 //---------------------------------------------------------------
@@ -1098,6 +1127,50 @@ namespace
     Storable::DataToStream(theStr,std::string("myScaleFactor") + theSuffix + "[0]",aScaleFactor[0]);
     Storable::DataToStream(theStr,std::string("myScaleFactor") + theSuffix + "[1]",aScaleFactor[1]);
     Storable::DataToStream(theStr,std::string("myScaleFactor") + theSuffix + "[2]",aScaleFactor[2]);
+
+    // Store displayed Gauss Points
+    int index = 0;
+    QString aPrsList;
+    vtkActor* anActor;
+    vtkActorCollection* anActColl = aRenderer->GetActors();
+    for( anActColl->InitTraversal(); ( anActor = anActColl->GetNextActor() ) != NULL; )
+    {
+      if( VISU_GaussPtsAct* aGaussActor = VISU_GaussPtsAct::SafeDownCast( anActor ) )
+      {
+       if( aGaussActor->GetVisibility() && aGaussActor->hasIO() )
+       {
+         const char* entry = aGaussActor->getIO()->getEntry();
+         Storable::DataToStream( theStr,
+                                 std::string("myDisplayedPrs") + theSuffix + "[" + QString::number( index ) + "]",
+                                 entry );
+         index++;
+       }
+      }
+    }
+    /*
+    TColStd_IndexedMapOfInteger anIndex;
+
+    // Store current selected Gauss Point
+    SVTK_Selector* aSelector = theViewWindow->GetSelector();
+    for( anActColl->InitTraversal(); ( anActor = anActColl->GetNextActor() ) != NULL; )
+    {
+      if( VISU_GaussPtsAct* aGaussActor = VISU_GaussPtsAct::SafeDownCast( anActor ) )
+      {
+       if( aGaussActor->hasIO() )
+       {
+         Handle(SALOME_InteractiveObject) anIO = aGaussActor->getIO();
+         if( aSelector->IsSelected( anIO ) )
+         {
+           aSelector->GetIndex( anIO, anIndex );
+           cout << anIO->getEntry() << endl;
+           if( anIndex.Extent() > 0 )
+             cout << anIndex(1) << endl;
+         }
+
+       }
+      }
+    }
+    */
   }
 
   //---------------------------------------------------------------
@@ -1140,6 +1213,29 @@ namespace
     aScaleFactor[1] = Storable::FindValue(theMap,std::string("myScaleFactor") + theSuffix + "[1]").toDouble();
     aScaleFactor[2] = Storable::FindValue(theMap,std::string("myScaleFactor") + theSuffix + "[2]").toDouble();
     theViewWindow->SetScale(aScaleFactor);
+
+    // Restore displayed Gauss Points
+    vtkActor* anActor;
+    VISU_GaussPtsAct* aGaussActor;
+    vtkActorCollection* anActColl = aRenderer->GetActors();
+    for( anActColl->InitTraversal(); ( anActor = anActColl->GetNextActor() ) != NULL; )
+    {
+      if( aGaussActor = VISU_GaussPtsAct::SafeDownCast( anActor ) )
+       anActor->SetVisibility( false );
+    }
+
+    for( int index = 0; ; index++ )
+    {
+      QString aPrs = Storable::FindValue( theMap, std::string("myDisplayedPrs") + theSuffix +
+                                         "[" + QString::number( index ) + "]" );
+      if( aPrs == "NULL" )
+       break;
+
+      using namespace SVTK;
+      if( aGaussActor = Find<VISU_GaussPtsAct>( anActColl, TIsSameEntry<VISU_GaussPtsAct>( aPrs.latin1() ) ) )
+       aGaussActor->SetVisibility( true );
+    }
+
   }
 
   //---------------------------------------------------------------
@@ -1250,9 +1346,65 @@ namespace
 
 }
 
+
+//---------------------------------------------------------------
 void
 VisuGUI_Module::
-OnSaveViewParams()
+OnSaveConfiguration()
+{
+  _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
+  if (CheckLock(aCStudy))
+    return;
+
+  LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
+
+  std::string aName = VISU::GenerateName("Config.", ++myNbConfigs).latin1();
+
+  SUIT_ViewManager* aViewManager = getApp()->activeViewManager();
+  if(aViewManager->getType() == VVTK_Viewer::Type()){
+    SUIT_ViewWindow* aWindow = aViewManager->getActiveView();
+    VVTK_ViewWindow* aViewWindow = dynamic_cast<VVTK_ViewWindow*>(aWindow);
+    std::string aValue = GetViewParams(aViewWindow);
+
+    SUIT_Study* aSStudy = aViewManager->study();
+    SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy);
+    _PTR(Study) aCStudy = aStudy->studyDS();
+    std::vector<_PTR(SObject)> aList = aCStudy->FindObjectByName(aName,"VISU");
+    _PTR(GenericAttribute) anAttr;
+    int iEnd = aList.size();
+    for(int i = 0; i < iEnd; i++){
+      _PTR(SObject) anObj = aList[i];
+      std::string anEntry = anObj->GetID();
+      if(anObj->FindAttribute(anAttr,"AttributeComment")){
+       _PTR(AttributeComment) aCmnt (anAttr);
+       std::string aComm (aCmnt->Value());
+       if(aComm.compare(View3D_i::myComment) >= 0){
+         aCmnt->SetValue(aValue.c_str());
+         return;
+       }
+      }
+    }
+    
+    _PTR(SComponent) aSComponent = ClientFindOrCreateVisuComponent(aCStudy);
+    std::string aSComponentEntry = aSComponent->GetID();
+    std::string anEntry = CreateAttributes(aCStudy, 
+                                          aSComponentEntry.c_str(), 
+                                          "", 
+                                          "", 
+                                           aName.c_str(),
+                                          "",
+                                          aValue.c_str());
+  }else
+    return;
+
+  UpdateObjBrowser(this);
+}
+
+
+//---------------------------------------------------------------
+void
+VisuGUI_Module::
+OnOverwriteConfiguration()
 {
   _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
   if (CheckLock(aCStudy))
@@ -1262,21 +1414,13 @@ OnSaveViewParams()
 
   SALOME_ListIO aListIO;
   aSelectionMgr->selectedObjects(aListIO);
-  if(aListIO.Extent() > 1)
+  if(aListIO.Extent() != 1)
     return;
 
-  std::string aName;
-  if(aListIO.Extent() == 0){
-    aName = VISU::View3D_i::GenerateViewParamsName().latin1();
-  }else{
-    const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
-    aName = anIO->getName();
-  }
+  std::string aName = aListIO.First()->getName();
 
   SUIT_ViewManager* aViewManager = getApp()->activeViewManager();
-  if(aViewManager->getType() == SVTK_Viewer::Type())
-    VISU::View3D_i::SaveViewParams(aViewManager,aName.c_str());
-  else if(aViewManager->getType() == VVTK_Viewer::Type()){
+  if(aViewManager->getType() == VVTK_Viewer::Type()){
     SUIT_ViewWindow* aWindow = aViewManager->getActiveView();
     VVTK_ViewWindow* aViewWindow = dynamic_cast<VVTK_ViewWindow*>(aWindow);
     std::string aValue = GetViewParams(aViewWindow);
@@ -1319,7 +1463,7 @@ OnSaveViewParams()
 //---------------------------------------------------------------
 void
 VisuGUI_Module::
-OnRestoreViewParams()
+OnRestoreConfiguration()
 {
   LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
 
index 0075937b671225a9e35ed56f7a724ab2f606e8fb..7a4f622ad0a33f7df0d4b735bdd4df0f90198aeb 100644 (file)
@@ -161,19 +161,26 @@ protected slots:
   void
   OnErasePrs();
 
-  //! Reimplemented method of saving view parameters.
+  //! Virtual method of saving configuration.
   virtual
   void
-  OnSaveViewParams();
+  OnSaveConfiguration();
 
-  //! Reimplemented method of restoring view parameters.
+  //! Virtual method of overwriting configuration.
   virtual
   void
-  OnRestoreViewParams();
+  OnOverwriteConfiguration();
+
+  //! Virtual method of restoring configuration.
+  virtual
+  void
+  OnRestoreConfiguration();
 
 protected:
   VISU::TViewerMap myViewerMap;
 
+  static int myNbConfigs;
+
   void setProperty( SVTK_ViewWindow*, const QString& );  // set a property (speed_increment, etc ) for SVTK ViewWindow
   void setProperty( SVTK_ViewManager*, const QString& ); // set a property for SVTK ViewWindow // set only 1 property for all ViewWindows of given view manager
 };