From b7dadf34e82775b4b25b0f812bdf1848853bdef9 Mon Sep 17 00:00:00 2001 From: apo Date: Tue, 18 Apr 2006 08:47:04 +0000 Subject: [PATCH] Fix on Bug11663 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 | 93 ++++++++++++++++++--------- src/LightApp/LightApp_VTKSelector.h | 26 ++++---- 2 files changed, 75 insertions(+), 44 deletions(-) diff --git a/src/LightApp/LightApp_VTKSelector.cxx b/src/LightApp/LightApp_VTKSelector.cxx index a81891b59..2e800fec1 100644 --- a/src/LightApp/LightApp_VTKSelector.cxx +++ b/src/LightApp/LightApp_VTKSelector.cxx @@ -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" @@ -42,15 +43,10 @@ */ 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(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(aViewWindow->getRenderer()->GetActors(),TIsSameIObject(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(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(aView->getRenderer()->GetActors(),TIsSameIObject(anIO)); - } - aList.append(new LightApp_SVTKDataOwner(anIO,anIds,aMode,anActor)); + if(SUIT_ViewManager* aViewManager = myViewer->getViewManager()){ + if(SVTK_ViewManager* aViewMgr = dynamic_cast(aViewManager)){ + if(SVTK_ViewWindow* aView = dynamic_cast(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); diff --git a/src/LightApp/LightApp_VTKSelector.h b/src/LightApp/LightApp_VTKSelector.h index 7c5dca73f..fd4247b7f 100644 --- a/src/LightApp/LightApp_VTKSelector.h +++ b/src/LightApp/LightApp_VTKSelector.h @@ -23,6 +23,8 @@ #include "LightApp.h" #include "LightApp_DataOwner.h" +class SUIT_Desktop; + #ifndef DISABLE_VTKVIEWER #include #include @@ -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 myActor; + mutable TColStd_IndexedMapOfInteger myIds; + + SVTK_ViewWindow* GetActiveViewWindow() const; + SUIT_Desktop* myDesktop; + #else LightApp_SVTKDataOwner( const QString& ); #endif -- 2.39.2