]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Fix on Bug11663
authorapo <apo@opencascade.com>
Tue, 18 Apr 2006 08:47:04 +0000 (08:47 +0000)
committerapo <apo@opencascade.com>
Tue, 18 Apr 2006 08:47:04 +0000 (08:47 +0000)
   There is the same 3D popup for all VTK viewers in "Mesh".
(To redefine methods of the LightApp_VTKDataOwner to get result for the active VTK view, not where the LightApp_VTKDataOwner was created. So, we unify the way to find corresponding VTK actros, sub-selection indexes and selection mode)

src/LightApp/LightApp_VTKSelector.cxx
src/LightApp/LightApp_VTKSelector.h

index a81891b590abcd06cd2638900800ce50d8200808..2e800fec127a2ee88e175547c6aed73c6b96bb94 100644 (file)
@@ -21,6 +21,7 @@
 
 #ifndef DISABLE_VTKVIEWER
   #include "SVTK_ViewModelBase.h"
+  #include "SVTK_ViewManager.h"
   #include "SVTK_Selector.h"
   #include "SVTK_ViewWindow.h"
   #include "SVTK_Functor.h"
 */
 LightApp_SVTKDataOwner
 ::LightApp_SVTKDataOwner( const Handle(SALOME_InteractiveObject)& theIO,
-                         const TColStd_IndexedMapOfInteger& theIds,
-                         Selection_Mode theMode,
-                         SALOME_Actor* theActor):
+                         SUIT_Desktop* theDesktop ):
   LightApp_DataOwner( theIO ),
-  mySelectionMode(theMode),
-  myActor(theActor)
-{
-  myIds = theIds; // workaround - there is no constructor copy for the container
-}
+  myDesktop( theDesktop )
+{}
 #endif
 
 /*!
@@ -61,6 +57,48 @@ LightApp_SVTKDataOwner
 {
 }
 
+SVTK_ViewWindow* 
+LightApp_SVTKDataOwner
+::GetActiveViewWindow() const
+{
+  if(SUIT_ViewWindow* aViewWindow = myDesktop->activeWindow())
+    return dynamic_cast<SVTK_ViewWindow*>(aViewWindow);
+
+  return NULL;
+}
+
+/*!
+  Gets dataowners ids list.
+*/
+const TColStd_IndexedMapOfInteger& 
+LightApp_SVTKDataOwner
+::GetIds() const
+{
+  if(SVTK_ViewWindow* aViewWindow = GetActiveViewWindow()){
+    if(SVTK_Selector* aSelector = aViewWindow->GetSelector()){
+      aSelector->GetIndex(IO(),myIds);
+    }
+  }
+
+  return myIds;
+}
+
+/*!
+  Gets selection mode.
+*/
+Selection_Mode
+LightApp_SVTKDataOwner
+::GetMode() const
+{
+  if(SVTK_ViewWindow* aViewWindow = GetActiveViewWindow()){
+    if(SVTK_Selector* aSelector = aViewWindow->GetSelector()){
+      return aSelector->SelectionMode();
+    }
+  }
+  
+  return -1;
+}
+
 /*!
   Gets actor pointer.
 */
@@ -68,7 +106,12 @@ SALOME_Actor*
 LightApp_SVTKDataOwner
 ::GetActor() const
 {
-  return myActor.GetPointer();
+  if(SVTK_ViewWindow* aViewWindow = GetActiveViewWindow()){
+    using namespace SVTK;
+    return Find<SALOME_Actor>(aViewWindow->getRenderer()->GetActors(),TIsSameIObject<SALOME_Actor>(IO()));
+  }
+
+  return NULL;
 }
 
 #endif
@@ -137,23 +180,16 @@ LightApp_VTKSelector
 ::getSelection( SUIT_DataOwnerPtrList& aList ) const
 {
   if(myViewer){
-    if(SUIT_ViewManager* aViewMgr = myViewer->getViewManager()){
-      if(SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewMgr->getActiveView())){
-       if(SVTK_Selector* aSelector = aView->GetSelector()){
-         Selection_Mode aMode = aSelector->SelectionMode();
-         const SALOME_ListIO& aListIO = aSelector->StoredIObjects();
-         SALOME_ListIteratorOfListIO anIter(aListIO);
-         for(; anIter.More(); anIter.Next()){
-           Handle(SALOME_InteractiveObject) anIO = anIter.Value();
-           if(anIO->hasEntry()){
-             TColStd_IndexedMapOfInteger anIds;
-             aSelector->GetIndex(anIO,anIds);
-             SALOME_Actor* anActor = aSelector->GetActor(anIO);
-             if( !anActor ){
-               using namespace SVTK;
-               anActor = Find<SALOME_Actor>(aView->getRenderer()->GetActors(),TIsSameIObject<SALOME_Actor>(anIO));
-             }
-             aList.append(new LightApp_SVTKDataOwner(anIO,anIds,aMode,anActor));
+    if(SUIT_ViewManager* aViewManager = myViewer->getViewManager()){
+      if(SVTK_ViewManager* aViewMgr = dynamic_cast<SVTK_ViewManager*>(aViewManager)){
+       if(SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewMgr->getActiveView())){
+         if(SVTK_Selector* aSelector = aView->GetSelector()){
+           const SALOME_ListIO& aListIO = aSelector->StoredIObjects();
+           SALOME_ListIteratorOfListIO anIter(aListIO);
+           for(; anIter.More(); anIter.Next()){
+             Handle(SALOME_InteractiveObject) anIO = anIter.Value();
+             if(anIO->hasEntry())
+               aList.append(new LightApp_SVTKDataOwner(anIO,aViewMgr->getDesktop()));
            }
          }
        }
@@ -182,10 +218,7 @@ LightApp_VTKSelector
              aSelector->SetSelectionMode(anOwner->GetMode());
              Handle(SALOME_InteractiveObject) anIO = anOwner->IO();
 
-             if( anOwner->GetActor() )
-               aSelector->AddIObject( anOwner->GetActor() );
-             else
-               aSelector->AddIObject(anIO);
+             aSelector->AddIObject(anIO);
 
              anAppendList.Append(anIO);
              aSelector->AddOrRemoveIndex(anIO,anOwner->GetIds(),false);
index 7c5dca73f6fb63700994c38434bc661ce3c91ca6..fd4247b7ff52b8ab4ee446dd6da9586005e9ef80 100644 (file)
@@ -23,6 +23,8 @@
 #include "LightApp.h"
 #include "LightApp_DataOwner.h"
 
+class SUIT_Desktop;
+
 #ifndef DISABLE_VTKVIEWER
   #include <vtkSmartPointer.h>
   #include <TColStd_IndexedMapOfInteger.hxx>
@@ -31,6 +33,7 @@
   #include "SALOME_InteractiveObject.hxx"
 #endif
   class SALOME_Actor;
+  class SVTK_ViewWindow;
   class SVTK_ViewModelBase;
 #endif
 
@@ -43,30 +46,25 @@ class LIGHTAPP_EXPORT LightApp_SVTKDataOwner : public LightApp_DataOwner
 #ifndef DISABLE_VTKVIEWER
    #ifndef DISABLE_SALOMEOBJECT
     LightApp_SVTKDataOwner( const Handle(SALOME_InteractiveObject)& theIO,
-                            const TColStd_IndexedMapOfInteger& theIds,
-                            Selection_Mode theMode = ActorSelection,
-                            SALOME_Actor* theActor = NULL);
+                           SUIT_Desktop* theDesktop );
    #endif
     virtual ~LightApp_SVTKDataOwner();
 
     /*!Gets dataowners ids list.*/
-    const TColStd_IndexedMapOfInteger& GetIds() const
-    {
-      return myIds;
-    }
+    const TColStd_IndexedMapOfInteger& GetIds() const;
 
     /*!Gets selection mode.*/
-    Selection_Mode GetMode() const 
-    { 
-      return mySelectionMode; 
-    }
+    Selection_Mode GetMode() const;
 
+    /*!Finds corresponding actor in the active viewer.*/
     SALOME_Actor* GetActor() const;
 
  protected:
-    TColStd_IndexedMapOfInteger myIds;
-    Selection_Mode mySelectionMode;
-    vtkSmartPointer<SALOME_Actor> myActor;
+    mutable TColStd_IndexedMapOfInteger myIds;
+
+    SVTK_ViewWindow* GetActiveViewWindow() const;
+    SUIT_Desktop* myDesktop;
+    
 #else
   LightApp_SVTKDataOwner( const QString& );
 #endif