]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
Selection is improved
authorouv <ouv@opencascade.com>
Thu, 9 Nov 2006 11:59:37 +0000 (11:59 +0000)
committerouv <ouv@opencascade.com>
Thu, 9 Nov 2006 11:59:37 +0000 (11:59 +0000)
src/VISUGUI/VisuGUI.cxx
src/VISUGUI/VisuGUI_Prs3dTools.h
src/VISUGUI/VisuGUI_Tools.cxx
src/VISUGUI/VisuGUI_Tools.h
src/VISU_I/VISU_Prs3d_i.cc
src/VISU_I/VISU_Prs3d_i.hh

index 8d67b6812610398ae41ee19803c87baa2b894012..b64fd5fb76da86599ab1466e9c77e5b7bb3b70e8 100644 (file)
@@ -3318,7 +3318,7 @@ void VisuGUI::OnPlot3dFromCutPlane()
          aDlg->setPlane(aOrient, aRotX, aRotY, aPlanePos);
            
          if (!(runAndWait(aDlg, 0) && (aDlg->storeToPrsObject(aPrs3d)))) {
-           DeletePrs3d(this, aPrs3d, anIO);
+           DeletePrs3d(this, aPrs3d);
            delete aDlg;
            return;
          }
index 2738c1587759d32f944cdb1d17aaa9e49f4aeb93..4de653448ca64d0879eb0e01a5d56512d186a42f 100644 (file)
@@ -39,17 +39,6 @@ namespace VISU
   class ColoredPrs3d_i;
   class CutLines_i;
 
-  //---------------------------------------------------------------
-  inline
-  void
-  RestoreSelection(VisuGUI* theModule)
-  {
-    SALOME_ListIO aList;
-    theModule->selectedObjects(aList);
-    LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(theModule);
-    aSelectionMgr->setSelectedObjects(aList);
-  }
-
   //---------------------------------------------------------------
   inline
   int
@@ -103,10 +92,8 @@ namespace VISU
                      aDlg,
                      false ); // in edition mode
        QApplication::restoreOverrideCursor();
-
-       RestoreSelection(theModule);
-       
       }
+      RestoreSelection(theModule, thePrs3d);
       delete aDlg;
     }
   }
@@ -161,10 +148,9 @@ namespace VISU
   //---------------------------------------------------------------
   template<class TPrs3d_i, class TViewer, class TDlg, int IsDlgModal>
   inline
-  bool
+  TPrs3d_i*
   CreateAndEditPrs3d(VisuGUI* theModule,
                     _PTR(SObject) theTimeStamp,
-                    const Handle(SALOME_InteractiveObject)& theIO,
                     ColoredPrs3d_i::EPublishInStudyMode thePublishInStudyMode)
   {
     Storable::TRestoringMap aMap = getMapOfValue(theTimeStamp);
@@ -172,7 +158,7 @@ namespace VISU
     bool isExist;
     QString aType = Storable::FindValue(aMap,"myType",&isExist);
     if (!isExist || aType.toInt() != TTIMESTAMP )
-      return false;
+      return NULL;
 
     QString aMeshName = Storable::FindValue(aMap,"myMeshName",&isExist).latin1();
     QString anEntity = Storable::FindValue(aMap,"myEntityId",&isExist).latin1();
@@ -217,10 +203,10 @@ namespace VISU
              QApplication::restoreOverrideCursor();
              delete aDlg;
            } else {
-             DeletePrs3d(theModule,aPrs3d,theIO);
+             DeletePrs3d(theModule,aPrs3d);
              QApplication::restoreOverrideCursor();
              delete aDlg;
-             return false;
+             return NULL;
            }
        }
       }
@@ -233,10 +219,10 @@ namespace VISU
        AddScalarBarPosition(theModule, aViewWindow, aPrs3d, aPos);
       }
 
-      return true;
+      return aPrs3d;
     }
 
-    return false;
+    return NULL;
   }
 
 
@@ -246,7 +232,6 @@ namespace VISU
   void
   CreatePrs3dInViewer(VisuGUI* theModule,
                      _PTR(SObject) theTimeStampSObj,
-                     const Handle(SALOME_InteractiveObject)& theIO,
                      ColoredPrs3d_i::EPublishInStudyMode thePublishInStudyMode)
   {
     // Create new TViewWindow instance, if it does not exist.
@@ -254,10 +239,10 @@ namespace VISU
     if (!GetViewWindow<TViewer>(theModule))
       return;
 
-    if (!CreateAndEditPrs3d<TPrs3d_i,TViewer,TDlg,IsDlgModal>(theModule,theTimeStampSObj,theIO,thePublishInStudyMode))
-      return;
+    TPrs3d_i* aPrs3d = CreateAndEditPrs3d<TPrs3d_i,TViewer,TDlg,IsDlgModal>
+      (theModule,theTimeStampSObj,thePublishInStudyMode);
 
-    RestoreSelection(theModule);
+    RestoreSelection(theModule, aPrs3d);
 
     theModule->application()->putInfo(QObject::tr("INF_DONE"));
   }
@@ -279,25 +264,25 @@ namespace VISU
 
     if(aPublishInStudyMode == VISU::ColoredPrs3d_i::EPublishIndependently){
       CreatePrs3dInViewer<TPrs3d_i,VVTK_Viewer,TDlg,0>
-       (theModule,aTimeStampSObj,anIO,aPublishInStudyMode);
+       (theModule,aTimeStampSObj,aPublishInStudyMode);
       return;
     }else{
       if(theDesiredViewerType.isNull()){
        if (SUIT_ViewManager* aViewManager = theModule->getApp()->activeViewManager())
          if (aViewManager->getType() == VVTK_Viewer::Type()){ 
            CreatePrs3dInViewer<TPrs3d_i,VVTK_Viewer,TDlg,IsDlgModal>
-             (theModule,aTimeStampSObj,anIO,aPublishInStudyMode);
+             (theModule,aTimeStampSObj,aPublishInStudyMode);
            return;
          }
        CreatePrs3dInViewer<TPrs3d_i,SVTK_Viewer,TDlg,IsDlgModal>
-         (theModule,aTimeStampSObj,anIO,aPublishInStudyMode);
+         (theModule,aTimeStampSObj,aPublishInStudyMode);
       }else{
        if(theDesiredViewerType == VVTK_Viewer::Type())
          CreatePrs3dInViewer<TPrs3d_i,VVTK_Viewer,TDlg,IsDlgModal>
-           (theModule,aTimeStampSObj,anIO,aPublishInStudyMode);
+           (theModule,aTimeStampSObj,aPublishInStudyMode);
        else
          CreatePrs3dInViewer<TPrs3d_i,SVTK_Viewer,TDlg,IsDlgModal>
-           (theModule,aTimeStampSObj,anIO,aPublishInStudyMode);
+           (theModule,aTimeStampSObj,aPublishInStudyMode);
       }
     }
   }
index 212654c11daf399e1c3028744611f147ff013121..1b307d201bd115e0635ab48cccfc9e64894e426e 100644 (file)
@@ -333,6 +333,25 @@ namespace VISU
     theSelectionMgr->setSelectedObjects(aNewListIO);
   }
 
+  /*!
+   * Restores selection after presentation creating and editing
+   */
+  void
+  RestoreSelection(VisuGUI* theModule, VISU::Prs3d_i* thePrs3d)
+  {
+    SALOME_ListIO aList;
+    theModule->selectedObjects(aList);
+
+    if( thePrs3d )
+    {
+      Handle(SALOME_InteractiveObject) anIO = thePrs3d->GetIO();
+      aList.Append(anIO);
+    }
+
+    LightApp_SelectionMgr* aSelectionMgr = GetSelectionMgr(theModule);
+    aSelectionMgr->setSelectedObjects(aList);
+  }
+
   /*!
    * \brief Check, if "Delete" popup-menu can be put on current selection
    *
@@ -459,8 +478,7 @@ namespace VISU
 
   void
   DeletePrs3d(VisuGUI* theModule,
-              VISU::Prs3d_i* thePrs,
-              const Handle(SALOME_InteractiveObject)& theIO)
+              VISU::Prs3d_i* thePrs)
   {
     if (!thePrs)
       return;
@@ -549,14 +567,13 @@ namespace VISU
   bool
   CheckTimeStamp(const SalomeApp_Module* theModule,
                  _PTR(SObject)&          theSObject,
-                 const Handle(SALOME_InteractiveObject)& theIO,
+                 Handle(SALOME_InteractiveObject)& theIO,
                 ColoredPrs3d_i::EPublishInStudyMode& thePublishInStudyMode)
   {
-    Handle(SALOME_InteractiveObject) anIO = theIO;
-    CORBA::Object_var anObject = GetSelectedObj(theModule, &anIO);
-    if (!anIO.IsNull() && anIO->hasEntry()){
+    CORBA::Object_var anObject = GetSelectedObj(theModule, &theIO);
+    if (!theIO.IsNull() && theIO->hasEntry()){
       _PTR(Study) aStudy = GetCStudy(GetAppStudy(theModule));
-      theSObject = aStudy->FindObjectID(anIO->getEntry());
+      theSObject = aStudy->FindObjectID(theIO->getEntry());
       QString aValue = getValue(theSObject,"myType");
       if (aValue.toInt() == int(VISU::TTIMESTAMP)){
        thePublishInStudyMode = ColoredPrs3d_i::EPublishUnderTimeStamp;
index fc53c2c248d79d0b9f8432144e779d7e2787652b..c68ffffcc3be8ceffad31f5d9da92e65e61925eb 100644 (file)
@@ -98,14 +98,15 @@ namespace VISU
   void                                 Remove(LightApp_SelectionMgr* theSelectionMgr,
                                              const Handle(SALOME_InteractiveObject)& theIO);
 
+  void                                 RestoreSelection(VisuGUI* theModule, VISU::Prs3d_i* thePrs3d);
+
   bool                                 IsRemovableSelected(const SalomeApp_Module* theModule);
 
   void                                 DeleteSObject(VisuGUI* theModule,
                                                     _PTR(Study)       theStudy,
                                                     _PTR(SObject)     theSObject);
   void                                 DeletePrs3d(VisuGUI* theModule,
-                                                  VISU::Prs3d_i* thePrs,
-                                                  const Handle(SALOME_InteractiveObject)& theIO);
+                                                  VISU::Prs3d_i* thePrs);
 
   // Presentation management
   void ChangeRepresentation (const SalomeApp_Module* theModule,
@@ -116,7 +117,7 @@ namespace VISU
   // SObject type
   bool                                 CheckTimeStamp(const SalomeApp_Module* theModule,
                                                      _PTR(SObject)&          theSObject,
-                                                     const Handle(SALOME_InteractiveObject)& theIO,
+                                                     Handle(SALOME_InteractiveObject)& theIO,
                                                      ColoredPrs3d_i::EPublishInStudyMode& thePublishInStudyMode);
   VISU::Result_i*                      CheckResult(const SalomeApp_Module* theModule,
                                                   _PTR(SObject) theSource,
index 75a0b42f75a9be696f4230588b3bd21f3628d850..1f13d04f5ce1ed2feac053f01c8b2fd4744bd6de 100644 (file)
@@ -372,6 +372,15 @@ GetInput()
   return GetPipeLine()->GetInput();
 }
 
+Handle(SALOME_InteractiveObject)
+VISU::Prs3d_i::
+GetIO()
+{
+  if( myIO.IsNull() )
+    myIO = new SALOME_InteractiveObject(GetEntry(),"VISU",GetName());
+
+  return myIO;
+}
 
 //----------------------------------------------------------------------------
 void
@@ -382,7 +391,7 @@ VISU::Prs3d_i
   try{
     Handle(SALOME_InteractiveObject) anIO = theIO;
     if(anIO.IsNull() && (!mySObject->_is_nil())){
-      anIO = new SALOME_InteractiveObject(mySObject->GetID(),"VISU",GetName());
+      anIO = GetIO();
       theActor->setIO(anIO);
     }
 
index 1852c1c7a89486e472bd6d6f1d31f1d5e784ec3e..28fac17313db76c1cdc8f5c57fad4fb40b6ff0fd 100644 (file)
@@ -242,6 +242,12 @@ namespace VISU
     unsigned long int 
     GetMTime();
 
+    //----------------------------------------------------------------------------
+    //! Create and return the interactive object
+    virtual
+    Handle(SALOME_InteractiveObject)
+    GetIO();
+
   protected:
     virtual 
     bool 
@@ -283,6 +289,8 @@ namespace VISU
     vtkSmartPointer<vtkActorCollection> myActorCollection;
 
     VISU_PipeLine *myPipeLine;
+
+    Handle(SALOME_InteractiveObject) myIO;
   };
 
   //----------------------------------------------------------------------------