]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To provide save / restore Gauss Points configuration functionality
authorapo <apo@opencascade.com>
Wed, 28 Dec 2005 16:00:15 +0000 (16:00 +0000)
committerapo <apo@opencascade.com>
Wed, 28 Dec 2005 16:00:15 +0000 (16:00 +0000)
src/VISUGUI/VisuGUI_Module.cxx
src/VISUGUI/VisuGUI_Module.h
src/VVTK/VVTK_MainWindow.cxx
src/VVTK/VVTK_MainWindow.h

index 76dce4482830e598d6eb5277c6839538e030618c..21bd9ca294c01a490b1c0e68b5a726547a171745 100644 (file)
@@ -38,6 +38,7 @@
 
 #include "CAM_Module.h"
 
+#include "SALOME_Event.hxx"
 #include "SalomeApp_Application.h"
 #include "LightApp_SelectionMgr.h"
 #include "LightApp_VTKSelector.h"
@@ -50,6 +51,7 @@
 #include "SVTK_ViewModel.h"
 #include "SVTK_ViewManager.h"
 #include "SVTK_MainWindow.h"
+#include "SVTK_RenderWindowInteractor.h"
 #include "VISU_Event.h"
 
 #include "VisuGUI_Prs3dTools.h"
@@ -100,8 +102,7 @@ static int MYDEBUG = 0;
 #define GAUSS_SAVE_CONFIGURATION       5700
 #define GAUSS_OVERWRITE_CONFIGURATION  5701
 #define GAUSS_RESTORE_CONFIGURATION    5702
-
-int VisuGUI_Module::myNbConfigs = 0;
+#define GAUSS_RENAME_CONFIGURATION     5703
 
 void
 CreateCurves( SalomeApp_Module* theModule,
@@ -298,6 +299,12 @@ VisuGUI_Module
   mgr->setRule( action( GAUSS_DISPLAY_ONLY_PRS ), 
                aRule, true );
 
+  createAction( GAUSS_RENAME_CONFIGURATION, tr("MEN_RENAME"), QIconSet(), 
+               tr("MEN_RENAME"), "", 0, this, false,
+                this, SLOT(OnRename()));
+  mgr->insert( action( GAUSS_RENAME_CONFIGURATION ), -1, -1, -1 );
+  mgr->setRule( action( GAUSS_RENAME_CONFIGURATION ), "selcount=1 and type='VISU::TGAUSSVIEW'", true );
+
   createAction( GAUSS_SAVE_CONFIGURATION, tr("MEN_SAVE_CONFIGURATION"), QIconSet(),
                 tr("MEN_SAVE_CONFIGURATION"), "", 0, this, false,
                 this, SLOT(OnSaveConfiguration()));
@@ -316,7 +323,7 @@ VisuGUI_Module
                 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 );
+               "selcount=1 and type='VISU::TGAUSSVIEW'", true );
 }
 
 //---------------------------------------------------------------
@@ -1170,34 +1177,42 @@ namespace
     GetViewParams(theViewWindow,"1",theStr);
 
     VISU_WidgetCtrl* aWidgetCtrl = theViewWindow->GetWidgetCtrl();
-
-    VISU_PlanesWidget *aPlanesWidget = aWidgetCtrl->GetPlanesWidget();
-
-    float anOrigin[3];
-    aPlanesWidget->GetOrigin(anOrigin);
-    Storable::DataToStream(theStr,"myCursorOrigin[0]",anOrigin[0]);
-    Storable::DataToStream(theStr,"myCursorOrigin[1]",anOrigin[1]);
-    Storable::DataToStream(theStr,"myCursorOrigin[2]",anOrigin[2]);
-
-    float aNormal[3];
-    aPlanesWidget->GetNormal(aNormal);
-    Storable::DataToStream(theStr,"myCursorNormal[0]",aNormal[0]);
-    Storable::DataToStream(theStr,"myCursorNormal[1]",aNormal[1]);
-    Storable::DataToStream(theStr,"myCursorNormal[2]",aNormal[2]);
-
-    float aDepth = aPlanesWidget->Distance();
-    Storable::DataToStream(theStr,"myCursorDepth",aDepth);
-
-
-    VISU_SphereWidget *aSphereWidget = aWidgetCtrl->GetSphereWidget();
-    float aCenter[3];
-    aSphereWidget->GetCenter(aCenter);
-    Storable::DataToStream(theStr,"mySphereCursorCenter[0]",aCenter[0]);
-    Storable::DataToStream(theStr,"mySphereCursorCenter[1]",aCenter[1]);
-    Storable::DataToStream(theStr,"mySphereCursorCenter[2]",aCenter[2]);
-
-    float aRadius = aSphereWidget->GetRadius();
-    Storable::DataToStream(theStr,"mySphereCursorRaduis",aRadius);
+    if(aWidgetCtrl->GetEnabled()){
+      std::string aSegmentationMode;
+      if(aWidgetCtrl->IsPlanesActive()){
+       VISU_PlanesWidget *aPlanesWidget = aWidgetCtrl->GetPlanesWidget();
+       float anOrigin[3];
+       aPlanesWidget->GetOrigin(anOrigin);
+       Storable::DataToStream(theStr,"myCursorOrigin[0]",anOrigin[0]);
+       Storable::DataToStream(theStr,"myCursorOrigin[1]",anOrigin[1]);
+       Storable::DataToStream(theStr,"myCursorOrigin[2]",anOrigin[2]);
+       
+       float aNormal[3];
+       aPlanesWidget->GetNormal(aNormal);
+       Storable::DataToStream(theStr,"myCursorNormal[0]",aNormal[0]);
+       Storable::DataToStream(theStr,"myCursorNormal[1]",aNormal[1]);
+       Storable::DataToStream(theStr,"myCursorNormal[2]",aNormal[2]);
+       
+       float aDepth = aPlanesWidget->Distance();
+       Storable::DataToStream(theStr,"myCursorDepth",aDepth);
+       
+       aSegmentationMode = "Planes";
+      }else if(aWidgetCtrl->IsSphereActive()){
+       VISU_SphereWidget *aSphereWidget = aWidgetCtrl->GetSphereWidget();
+       float aCenter[3];
+       aSphereWidget->GetCenter(aCenter);
+       Storable::DataToStream(theStr,"mySphereCursorCenter[0]",aCenter[0]);
+       Storable::DataToStream(theStr,"mySphereCursorCenter[1]",aCenter[1]);
+       Storable::DataToStream(theStr,"mySphereCursorCenter[2]",aCenter[2]);
+       
+       float aRadius = aSphereWidget->GetRadius();
+       Storable::DataToStream(theStr,"mySphereCursorRaduis",aRadius);
+       
+       aSegmentationMode = "Sphere";
+      }
+      
+      Storable::DataToStream(theStr,"mySegmentationMode",aSegmentationMode);
+    }
   }
 
   //---------------------------------------------------------------
@@ -1206,35 +1221,6 @@ namespace
                const Storable::TRestoringMap& theMap)
   {
     SetViewParams(theViewWindow,"1",theMap);
-
-    VISU_WidgetCtrl* aWidgetCtrl = theViewWindow->GetWidgetCtrl();
-
-    VISU_PlanesWidget *aPlanesWidget = aWidgetCtrl->GetPlanesWidget();
-    float anOrigin[3];
-    anOrigin[0] = Storable::FindValue(theMap,"myCursorOrigin[0]").toDouble();
-    anOrigin[1] = Storable::FindValue(theMap,"myCursorOrigin[1]").toDouble();
-    anOrigin[2] = Storable::FindValue(theMap,"myCursorOrigin[2]").toDouble();
-    aPlanesWidget->SetOrigin(anOrigin);
-
-    float aNormal[3];
-    aNormal[0] = Storable::FindValue(theMap,"myCursorNormal[0]").toDouble();
-    aNormal[1] = Storable::FindValue(theMap,"myCursorNormal[1]").toDouble();
-    aNormal[2] = Storable::FindValue(theMap,"myCursorNormal[2]").toDouble();
-    aPlanesWidget->SetNormal(aNormal);
-
-    float aDepth = Storable::FindValue(theMap,"myCursorDepth").toDouble();
-    aPlanesWidget->SetDistance(aDepth);
-
-
-    VISU_SphereWidget *aSphereWidget = aWidgetCtrl->GetSphereWidget();
-    float aCenter[3];
-    aCenter[0] = Storable::FindValue(theMap,"mySphereCursorCenter[0]").toDouble();
-    aCenter[1] = Storable::FindValue(theMap,"mySphereCursorCenter[1]").toDouble();
-    aCenter[2] = Storable::FindValue(theMap,"mySphereCursorCenter[2]").toDouble();
-    aSphereWidget->SetCenter(aCenter);
-
-    float aRadius = Storable::FindValue(theMap,"mySphereCursorRaduis").toDouble();
-    aSphereWidget->SetRadius(aRadius);
   }
 
 
@@ -1272,20 +1258,6 @@ namespace
     return aStream.str();
   }
 
-  //---------------------------------------------------------------
-  void
-  SetViewParams(VVTK_ViewWindow* theViewWindow,
-               const Storable::TRestoringMap& theMap)
-  {
-    Selection_Mode aSelectionMode = Storable::FindValue(theMap,"mySelectionMode").toInt();
-    SVTK_Selector* aSelector = theViewWindow->GetSelector();
-    aSelector->SetSelectionMode(aSelectionMode);
-
-    SetViewParams(theViewWindow->getMainWindow1(),theMap);
-    SetViewParams(theViewWindow->getMainWindow2(),theMap);
-  }
-
-
   //---------------------------------------------------------------
   struct TSelection
   {
@@ -1338,13 +1310,16 @@ namespace
     for(; anIter.More(); anIter.Next()){
       Handle(SALOME_InteractiveObject) anIO = anIter.Value();
       std::string anEntry = anIO->getEntry();
-      TSelection& aSelection = theVisibleEntries[anEntry];
-      aSelection.myIsSelected = true;
-      TColStd_IndexedMapOfInteger anIndexes;
-      aSelector->GetIndex(anIO,anIndexes);
-      if(anIndexes.Extent() > 0){
-       aSelection.myHasSubId = true;
-       aSelection.mySubId = anIndexes(1);
+      TVisibleEntries::iterator anEntriesIter = theVisibleEntries.find(anEntry);
+      if(anEntriesIter != theVisibleEntries.end()){
+       TSelection& aSelection = anEntriesIter->second;
+       aSelection.myIsSelected = true;
+       TColStd_IndexedMapOfInteger anIndexes;
+       aSelector->GetIndex(anIO,anIndexes);
+       if(anIndexes.Extent() > 0){
+         aSelection.myHasSubId = true;
+         aSelection.mySubId = anIndexes(1);
+       }
       }
     }
   }
@@ -1425,62 +1400,116 @@ namespace
 
     aSelector->EndPickCallback(); // To invoke selection changed signal
   }
-}
-
 
-//---------------------------------------------------------------
-void
-VisuGUI_Module::
-OnSaveConfiguration()
-{
-  _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
-  if (CheckLock(aCStudy,GetDesktop(this)))
-    return;
 
-  LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
-
-  SUIT_ViewManager* aViewManager = getApp()->activeViewManager();
-  if(aViewManager->getType() == VVTK_Viewer::Type()){
-    SUIT_ViewWindow* aWindow = aViewManager->getActiveView();
-    VVTK_ViewWindow* aViewWindow = dynamic_cast<VVTK_ViewWindow*>(aWindow);
-
-    SUIT_Study* aSStudy = aViewManager->study();
-    SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy);
-    _PTR(Study) aCStudy = aStudy->studyDS();
+  //---------------------------------------------------------------
+  void
+  OnStoreConfiguration(SalomeApp_Module* theModule,
+                      bool theIsNew)
+  {
+    _PTR(Study) aCStudy = GetCStudy(GetAppStudy(theModule));
+    if (CheckLock(aCStudy,GetDesktop(theModule)))
+      return;
     
-    _PTR(SComponent) aSComponent = ClientFindOrCreateVisuComponent(aCStudy);
-
-    std::string aName = VISU::GenerateName("Config.", ++myNbConfigs).latin1();
-    std::string aValue = GetViewParams(aViewWindow);
-
-    std::string aSComponentEntry = aSComponent->GetID();
-    std::string anEntry = CreateAttributes(aCStudy, 
-                                          aSComponentEntry.c_str(), 
-                                          "", 
-                                          "", 
-                                           aName.c_str(),
-                                          "",
-                                          aValue.c_str());
-
-    ::TVisibleEntries aVisibleEntries;
-    ::GetGaussPointsSelection(aViewWindow,
-                             aVisibleEntries);
+    LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(theModule);
     
-    _PTR(SObject) aSObject = aCStudy->FindObjectID(anEntry);
-    _PTR(StudyBuilder) aStudyBuilder = aCStudy->NewBuilder();
-    ::TVisibleEntries::const_iterator anIter =  aVisibleEntries.begin();
-    for(; anIter != aVisibleEntries.end(); anIter++){
-      const std::string& anEntry = anIter->first;
-      const TSelection& aSelection = anIter->second;
-
-      ::CreateReference(aCStudy,
-                       aStudyBuilder,
-                       aSObject, 
-                       anEntry,
-                       aSelection);
+    SUIT_ViewManager* aViewManager = theModule->getApp()->activeViewManager();
+    if(aViewManager->getType() == VVTK_Viewer::Type()){
+      SUIT_ViewWindow* aWindow = aViewManager->getActiveView();
+      VVTK_ViewWindow* aViewWindow = dynamic_cast<VVTK_ViewWindow*>(aWindow);
+      
+      SUIT_Study* aSStudy = aViewManager->study();
+      SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(aSStudy);
+      _PTR(Study) aCStudy = aStudy->studyDS();
+      _PTR(StudyBuilder) aStudyBuilder = aCStudy->NewBuilder();
+
+      std::string anEntry;
+      std::string aValue = GetViewParams(aViewWindow);
+
+      if(theIsNew){
+       _PTR(SComponent) aSComponent = ClientFindOrCreateVisuComponent(aCStudy);
+       
+       static int myNbConfigs = 0;
+       std::string aName = VISU::GenerateName("Config.", ++myNbConfigs).latin1();
+      
+       std::string aSComponentEntry = aSComponent->GetID();
+       anEntry = CreateAttributes(aCStudy, 
+                                  aSComponentEntry.c_str(), 
+                                  "", 
+                                  "", 
+                                  aName.c_str(),
+                                  "",
+                                  aValue.c_str());
+      }else{
+       SALOME_ListIO aListIO;
+       aSelectionMgr->selectedObjects(aListIO);
+       SALOME_ListIteratorOfListIO aListIter( aListIO );
+       for(; aListIter.More(); aListIter.Next()){
+         Handle(SALOME_InteractiveObject) anIO = aListIter.Value();
+         _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
+         _PTR(GenericAttribute) anAttr;
+         if(aSObject->FindAttribute(anAttr,"AttributeComment")){
+           _PTR(AttributeComment) aComment(anAttr);
+           std::string aCommentValue(aComment->Value());
+           if(aCommentValue.compare("myComment=GAUSSVIEW") >= 0){
+             aComment->SetValue(aValue.c_str());
+             anEntry = aSObject->GetID();
+             
+             _PTR(ChildIterator) aChildIter = aCStudy->NewChildIterator(aSObject);
+             for (; aChildIter->More(); aChildIter->Next()) {
+               _PTR(SObject) aChildSObject = aChildIter->Value();
+               aStudyBuilder->RemoveObject(aChildSObject);
+             }
+             break;
+           }
+         }
+       }
+      }
+
+      if(anEntry != ""){
+       TVisibleEntries aVisibleEntries;
+       GetGaussPointsSelection(aViewWindow,
+                               aVisibleEntries);
+       
+       _PTR(SObject) aSObject = aCStudy->FindObjectID(anEntry);
+       _PTR(StudyBuilder) aStudyBuilder = aCStudy->NewBuilder();
+       TVisibleEntries::const_iterator anIter =  aVisibleEntries.begin();
+       for(; anIter != aVisibleEntries.end(); anIter++){
+         const std::string& anEntry = anIter->first;
+         const TSelection& aSelection = anIter->second;
+         
+         CreateReference(aCStudy,
+                         aStudyBuilder,
+                         aSObject, 
+                         anEntry,
+                         aSelection);
+       }
+      
+       //UpdateObjBrowser(theModule,true,aSObject);
+       UpdateObjBrowser(theModule,true);
+      }
     }
+  }
 
-    UpdateObjBrowser(this,true,aSObject);
+
+  //---------------------------------------------------------------
+  template<class TMainWindow>
+  void
+  SetMainWindowParams(VisuGUI* theModule,
+                     _PTR(SObject) theSObject,
+                     VVTK_ViewWindow* theViewWindow,
+                     TMainWindow* theMainWindow)
+  {
+    _PTR(Study) aCStudy = GetCStudy(GetAppStudy(theModule));
+
+    _PTR(GenericAttribute) anAttr;
+    if(theSObject->FindAttribute(anAttr,"AttributeComment")){
+      _PTR(AttributeComment) aComment(anAttr);
+      QString aStream(aComment->Value().c_str());
+      Storable::TRestoringMap aMap;
+      Storable::StrToMap(aStream,aMap);
+      SetViewParams(theMainWindow,aMap);
+    }
   }
 }
 
@@ -1488,59 +1517,18 @@ OnSaveConfiguration()
 //---------------------------------------------------------------
 void
 VisuGUI_Module::
-OnOverwriteConfiguration()
+OnSaveConfiguration()
 {
-  _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
-  if (CheckLock(aCStudy,GetDesktop(this)))
-    return;
-
-  LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(this);
-
-  SALOME_ListIO aListIO;
-  aSelectionMgr->selectedObjects(aListIO);
-  if(aListIO.Extent() != 1)
-    return;
-
-  std::string aName = aListIO.First()->getName();
+  ::OnStoreConfiguration(this,true);
+}
 
-  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()
+{
+  ::OnStoreConfiguration(this,false);
 }
 
 
@@ -1556,25 +1544,113 @@ OnRestoreConfiguration()
   if(aListIO.Extent() > 1)
     return;
 
-  const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
-  _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
-  _PTR(SObject) aSObj = aCStudy->FindObjectID(anIO->getEntry());
-  std::string aName = aSObj->GetName();
-
   if(SUIT_ViewManager* aViewManager = getViewManager(VVTK_Viewer::Type(),true)){
+    const Handle(SALOME_InteractiveObject)& anIO = aListIO.First();
+    _PTR(Study) aCStudy = GetCStudy(GetAppStudy(this));
+    _PTR(SObject) aSObject = aCStudy->FindObjectID(anIO->getEntry());
+    myConfigSObject = aSObject;
     _PTR(GenericAttribute) anAttr;
-    if(aSObj->FindAttribute(anAttr,"AttributeComment")){
-      _PTR(AttributeComment) aCmnt(anAttr);
-      QString aStream(aCmnt->Value().c_str());
+    if(aSObject->FindAttribute(anAttr,"AttributeComment")){
+      _PTR(AttributeComment) aComment(anAttr);
+      QString aStream(aComment->Value().c_str());
       Storable::TRestoringMap aMap;
       Storable::StrToMap(aStream,aMap);
       SUIT_ViewWindow* aWindow = aViewManager->getActiveView();
       VVTK_ViewWindow* aViewWindow = dynamic_cast<VVTK_ViewWindow*>(aWindow);
+      
+      Selection_Mode aSelectionMode = Storable::FindValue(aMap,"mySelectionMode").toInt();
+      SVTK_Selector* aSelector = aViewWindow->GetSelector();
+      aSelector->SetSelectionMode(aSelectionMode);
+      
+      std::string aSegmentationMode;
+      if(VVTK_MainWindow1* aMainWindow = aViewWindow->getMainWindow1()){
+       aMainWindow->SetPlanesSegementation(false);
+       aMainWindow->SetSphereSegementation(false);
+       VISU_WidgetCtrl* aWidgetCtrl = aMainWindow->GetWidgetCtrl();
+       aSegmentationMode = Storable::FindValue(aMap,"mySegmentationMode").latin1();
+       
+       if(aSegmentationMode == "Planes"){
+         VISU_PlanesWidget *aPlanesWidget = aWidgetCtrl->GetPlanesWidget();
+         float anOrigin[3];
+         anOrigin[0] = Storable::FindValue(aMap,"myCursorOrigin[0]").toDouble();
+         anOrigin[1] = Storable::FindValue(aMap,"myCursorOrigin[1]").toDouble();
+         anOrigin[2] = Storable::FindValue(aMap,"myCursorOrigin[2]").toDouble();
+         aPlanesWidget->SetOrigin(anOrigin);
+         
+         float aNormal[3];
+         aNormal[0] = Storable::FindValue(aMap,"myCursorNormal[0]").toDouble();
+         aNormal[1] = Storable::FindValue(aMap,"myCursorNormal[1]").toDouble();
+         aNormal[2] = Storable::FindValue(aMap,"myCursorNormal[2]").toDouble();
+         aPlanesWidget->SetNormal(aNormal);
+         
+         float aDepth = Storable::FindValue(aMap,"myCursorDepth").toDouble();
+         aPlanesWidget->SetDistance(aDepth);
+         
+         aMainWindow->SetPlanesSegementation(true);
+       }else if(aSegmentationMode == "Sphere"){
+         VISU_SphereWidget *aSphereWidget = aWidgetCtrl->GetSphereWidget();
+         float aCenter[3];
+         aCenter[0] = Storable::FindValue(aMap,"mySphereCursorCenter[0]").toDouble();
+         aCenter[1] = Storable::FindValue(aMap,"mySphereCursorCenter[1]").toDouble();
+         aCenter[2] = Storable::FindValue(aMap,"mySphereCursorCenter[2]").toDouble();
+         aSphereWidget->SetCenter(aCenter);
+         
+         float aRadius = Storable::FindValue(aMap,"mySphereCursorRaduis").toDouble();
+         aSphereWidget->SetRadius(aRadius);
+         
+         aMainWindow->SetSphereSegementation(true);
+       }
+      }
 
-      SetViewParams(aViewWindow,aMap);
+      if(VVTK_MainWindow1* aMainWindow = aViewWindow->getMainWindow1()){
+       SVTK_RenderWindowInteractor* anInteractor = aMainWindow->GetInteractor();
+       if(anInteractor->isVisible()){
+         SetMainWindowParams(this,myConfigSObject,aViewWindow,aMainWindow);
+       }else
+         anInteractor->installEventFilter(this);
+      }
+
+      if(aSegmentationMode != ""){
+       if(VVTK_MainWindow2* aMainWindow = aViewWindow->getMainWindow2()){
+         SVTK_RenderWindowInteractor* anInteractor = aMainWindow->GetInteractor();
+         if(anInteractor->isVisible())
+           SetMainWindowParams(this,myConfigSObject,aViewWindow,aMainWindow);
+         else
+           anInteractor->installEventFilter(this);
+       }
+      }
 
-      SetGaussPointsSelection(this,aViewWindow,aCStudy,aSObj);
+      SetGaussPointsSelection(this,aViewWindow,aCStudy,aSObject);
     }
   }
 }
 
+
+//---------------------------------------------------------------
+bool
+VisuGUI_Module::
+eventFilter( QObject * theWatched, QEvent * theEvent )
+{
+  bool aRet = VisuGUI::eventFilter(theWatched,theEvent);
+  if(theEvent->type() == QEvent::Show){
+    if(SUIT_ViewManager* aViewManager = getViewManager(VVTK_Viewer::Type(),false)){
+      SUIT_ViewWindow* aWindow = aViewManager->getActiveView();
+      VVTK_ViewWindow* aViewWindow = dynamic_cast<VVTK_ViewWindow*>(aWindow);
+      if(VVTK_MainWindow1* aMainWindow = aViewWindow->getMainWindow1()){
+       SVTK_RenderWindowInteractor* anInteractor = aMainWindow->GetInteractor();
+       if(theWatched == anInteractor){
+         SetMainWindowParams(this,myConfigSObject,aViewWindow,aMainWindow);
+         anInteractor->removeEventFilter(this);
+       }
+      }
+      if(VVTK_MainWindow2* aMainWindow = aViewWindow->getMainWindow2()){
+       SVTK_RenderWindowInteractor* anInteractor = aMainWindow->GetInteractor();
+       if(theWatched == aMainWindow->GetInteractor()){
+         SetMainWindowParams(this,myConfigSObject,aViewWindow,aMainWindow);
+         anInteractor->removeEventFilter(this);
+       }
+      }
+    }
+  }
+  return aRet;
+}
index 7a4f622ad0a33f7df0d4b735bdd4df0f90198aeb..c13c8235d997885cca1298ba144abd19b50da748 100644 (file)
@@ -31,6 +31,7 @@
 
 #include "VisuGUI.h"
 #include "STD_Application.h"
+#include "SALOMEDSClient_SObject.hxx"
 
 class SUIT_ViewManager;
 class SVTK_ViewManager;
@@ -60,6 +61,10 @@ public:
   virtual
   ~VisuGUI_Module();
 
+  virtual
+  bool
+  eventFilter( QObject * theWatched, QEvent * theEvent );
+
   //! Redifined method of the module initializing.
   virtual
   void
@@ -178,8 +183,7 @@ protected slots:
 
 protected:
   VISU::TViewerMap myViewerMap;
-
-  static int myNbConfigs;
+  _PTR(SObject) myConfigSObject;
 
   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
index 8bb20dffbc537bbdba7cd1e772db453ef79c533a..6eb73563d9f0f8a0e8034e9acbd0e0ac3985370f 100644 (file)
@@ -405,33 +405,49 @@ VVTK_MainWindow1
 }
 
 //----------------------------------------------------------------------------
-void VVTK_MainWindow1::OnSegmentationSwitch()
+void
+VVTK_MainWindow1
+::SetPlanesSegementation(bool theIsOn)
+{
+  myPlaneSegmentationAction->setOn( theIsOn );
+  OnSegmentationSwitch(myPlaneSegmentationAction);
+}
+
+void
+VVTK_MainWindow1
+::SetSphereSegementation(bool theIsOn)
 {
-  bool theIsSegmentationOn = myPlaneSegmentationAction->isOn() ||
+  mySphereSegmentationAction->setOn( theIsOn );
+  OnSegmentationSwitch(mySphereSegmentationAction);
+}
+
+void
+VVTK_MainWindow1
+::OnSegmentationSwitch(QtxAction* theAction)
+{
+  bool anIsSegmentationOn = myPlaneSegmentationAction->isOn() ||
     mySphereSegmentationAction->isOn();
 
-  QtxAction* anAction = ( QtxAction* )sender();
-  if( !anAction )
+  if( !theAction )
     return;
   
-  VISU_WidgetCtrl *pWidgetCtrl=myRenderer->GetWidgetCtrl();
-  //printf(" \n*OnSegmentationSwitch(%d)\n", theIsSegmentationOn);
+  VISU_WidgetCtrl *aWidgetCtrl = myRenderer->GetWidgetCtrl();
   
-  if (theIsSegmentationOn) {
-    int anIndex= (anAction == myPlaneSegmentationAction) ? 0 : 1;
-    pWidgetCtrl->SetActiveIndex(anIndex);
+  if (anIsSegmentationOn) {
+    int anIndex = (theAction == myPlaneSegmentationAction) ? 0 : 1;
+    aWidgetCtrl->SetActiveIndex(anIndex);
   }
-  pWidgetCtrl->SetEnabled(theIsSegmentationOn);
+  aWidgetCtrl->SetEnabled(anIsSegmentationOn);
 
-  if( anAction == myPlaneSegmentationAction && theIsSegmentationOn )
+  if( theAction == myPlaneSegmentationAction && anIsSegmentationOn )
     mySphereSegmentationAction->setOn( false );
-  else if( anAction == mySphereSegmentationAction && theIsSegmentationOn )
+  else if( theAction == mySphereSegmentationAction && anIsSegmentationOn )
     myPlaneSegmentationAction->setOn( false );
 
-  if( theIsSegmentationOn )
+  if( anIsSegmentationOn )
   {
     myMainWindow2->show();
-    mySegmentationCursorDlg->SetIsPlaneSegmentation( anAction == myPlaneSegmentationAction );
+    mySegmentationCursorDlg->SetIsPlaneSegmentation( theAction == myPlaneSegmentationAction );
     mySegmentationCursorDlg->UpdateSegmentation();
     mySegmentationCursorDlg->UpdateInsideGaussPoints();
     mySegmentationCursorDlg->UpdateOutsideGaussPoints();
@@ -444,6 +460,14 @@ void VVTK_MainWindow1::OnSegmentationSwitch()
   }
 }
 
+void
+VVTK_MainWindow1
+::OnSegmentationSwitch()
+{
+  QtxAction* anAction = ( QtxAction* )sender();
+  OnSegmentationSwitch(anAction);
+}
+
 
 //----------------------------------------------------------------------------
 VVTK_MainWindow2
index f93678d7ea261b8cc1c6163a096bb73a06d18d32..20a2f7198409348f05f89507fa039d1c9cae9f53 100644 (file)
@@ -120,6 +120,12 @@ public:
 
   VISU_WidgetCtrl*  GetWidgetCtrl();
 
+  void
+  SetPlanesSegementation(bool theIsOn);
+
+  void
+  SetSphereSegementation(bool theIsOn);
+
   VISU_InsideCursorSettings*
   GetInsideCursorSettings();
 
@@ -136,6 +142,9 @@ public:
   void
   OnSegmentationSwitch();//bool theIsSegmentationOn); 
 
+  void
+  OnSegmentationSwitch(QtxAction* theAction);//bool theIsSegmentationOn); 
+
    //! To change active selection mode at run-time
   virtual
   void