From a9e8c482f8ee8a43d15fb595992ef2c9ef826943 Mon Sep 17 00:00:00 2001 From: apo Date: Thu, 30 Nov 2006 09:08:11 +0000 Subject: [PATCH] To adjust Display/Erase popup functionality to the VISU Cache System --- src/OBJECT/VISU_ActorFactory.h | 5 ++ src/VISU_I/VISU_ColoredPrs3dCache_i.cc | 21 ++---- src/VISU_I/VISU_Prs3d_i.cc | 18 +++++ src/VISU_I/VISU_Prs3d_i.hh | 15 +++++ src/VVTK/VVTK_ViewModel.cxx | 91 ++++++++++++++++++++++++-- src/VVTK/VVTK_ViewModel.h | 33 ++++++++-- 6 files changed, 155 insertions(+), 28 deletions(-) diff --git a/src/OBJECT/VISU_ActorFactory.h b/src/OBJECT/VISU_ActorFactory.h index 72402370..ec7af383 100644 --- a/src/OBJECT/VISU_ActorFactory.h +++ b/src/OBJECT/VISU_ActorFactory.h @@ -53,6 +53,11 @@ namespace VISU ~TActorFactory() {} + //! Gets know whether the factory instance can be used for actor management or not + virtual + bool + GetActiveState() = 0; + //! Return modified time of the factory virtual unsigned long int diff --git a/src/VISU_I/VISU_ColoredPrs3dCache_i.cc b/src/VISU_I/VISU_ColoredPrs3dCache_i.cc index 122aaa33..2b5043e7 100644 --- a/src/VISU_I/VISU_ColoredPrs3dCache_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3dCache_i.cc @@ -33,17 +33,9 @@ #include "VISU_View_i.hh" #include "VISU_Actor.h" -#include "VTKViewer_Algorithm.h" -#include "SVTK_Functor.h" - -//#include "VISU_Convertor.hxx" -//#include "VISU_PipeLine.hxx" - #include "VVTK_ViewWindow.h" #include "SUIT_ResourceMgr.h" -#include - #ifdef _DEBUG_ static int MYDEBUG = 0; #else @@ -388,13 +380,9 @@ VISU::ColoredPrs3dCache_i return true; if(aPrs3d != aLastVisitedPrs3d){ - // To erase all actors that corresponds to the holder - vtkRenderer* aRenderer = aViewWindow->getRenderer(); - vtkActorCollection* anActors = aRenderer->GetActors(); - Handle(SALOME_InteractiveObject) anIO = aPrs3d->GetIO(); - SVTK::ForEachIf(anActors, - SVTK::TIsSameIObject(anIO), - SVTK::TSetVisibility(false)); + // To erase non active presentation + aLastVisitedPrs3d->SetActiveState(false); + anActor->SetVisibility(false); // To find the new one that corresponds to fresh presentation VISU_Actor* aNewActor = VISU::FindActor(aViewWindow, aPrs3d); if(!aNewActor){ @@ -404,6 +392,7 @@ VISU::ColoredPrs3dCache_i aNewActor->SetVisibility(true); //anActor->RemoveFromRender(); aNewActor->DeepCopy(anActor); + aPrs3d->SetActiveState(true); } aViewWindow->Repaint(); return true; @@ -433,6 +422,4 @@ VISU::ColoredPrs3dCache_i } } } - - } diff --git a/src/VISU_I/VISU_Prs3d_i.cc b/src/VISU_I/VISU_Prs3d_i.cc index 621b18de..651f2d8e 100644 --- a/src/VISU_I/VISU_Prs3d_i.cc +++ b/src/VISU_I/VISU_Prs3d_i.cc @@ -52,6 +52,7 @@ VISU::Prs3d_i PrsObject_i(SALOMEDS::Study::_nil()), myActorCollection(vtkActorCollection::New()), mySObject(SALOMEDS::SObject::_nil()), + myIsActiveSatate(true), myPipeLine(NULL), myResult(NULL) { @@ -68,6 +69,7 @@ VISU::Prs3d_i PrsObject_i(theSObject->GetStudy()), mySObject(theSObject), myActorCollection(vtkActorCollection::New()), + myIsActiveSatate(true), myResult(theResult), myPipeLine(NULL) { @@ -240,6 +242,22 @@ VISU::Prs3d_i return aTime; } +//---------------------------------------------------------------------------- +bool +VISU::Prs3d_i +::GetActiveState() +{ + return myIsActiveSatate; +} + +//---------------------------------------------------------------------------- +void +VISU::Prs3d_i +::SetActiveState(bool theState) +{ + myIsActiveSatate = theState; +} + //---------------------------------------------------------------------------- VISU::Storable* VISU::Prs3d_i diff --git a/src/VISU_I/VISU_Prs3d_i.hh b/src/VISU_I/VISU_Prs3d_i.hh index 07cdbd8a..9c357194 100644 --- a/src/VISU_I/VISU_Prs3d_i.hh +++ b/src/VISU_I/VISU_Prs3d_i.hh @@ -252,6 +252,12 @@ namespace VISU CORBA::Float GetMemorySize(); + //---------------------------------------------------------------------------- + //! Gets know whether the factory instance can be used for actor management or not + virtual + bool + GetActiveState(); + //---------------------------------------------------------------------------- //! Return modified time of the presentation virtual @@ -327,6 +333,15 @@ namespace VISU VISU_PipeLine *myPipeLine; Handle(SALOME_InteractiveObject) myIO; + + private: + //! Sets activity flag for the factory instance + void + SetActiveState(bool theState); + + bool myIsActiveSatate; + + friend class ColoredPrs3dCache_i; }; //---------------------------------------------------------------------------- diff --git a/src/VVTK/VVTK_ViewModel.cxx b/src/VVTK/VVTK_ViewModel.cxx index af6f65ed..b1b3ec4e 100644 --- a/src/VVTK/VVTK_ViewModel.cxx +++ b/src/VVTK/VVTK_ViewModel.cxx @@ -21,20 +21,31 @@ #include "VVTK_ViewWindow.h" -VVTK_Viewer:: -VVTK_Viewer() +#include "VTKViewer_Algorithm.h" +#include "SVTK_Functor.h" +#include "VISU_Actor.h" +#include "SVTK_View.h" +#include "SVTK_Prs.h" + +#include +#include + +//--------------------------------------------------------------- +VVTK_Viewer +::VVTK_Viewer() { } -VVTK_Viewer:: -~VVTK_Viewer() +//--------------------------------------------------------------- +VVTK_Viewer +::~VVTK_Viewer() { } -//========================================================== +//--------------------------------------------------------------- SUIT_ViewWindow* -VVTK_Viewer:: -createView( SUIT_Desktop* theDesktop ) +VVTK_Viewer +::createView( SUIT_Desktop* theDesktop ) { TViewWindow* aViewWindow = new TViewWindow (theDesktop); aViewWindow->Initialize(this); @@ -44,3 +55,69 @@ createView( SUIT_Desktop* theDesktop ) return aViewWindow; } + +//--------------------------------------------------------------- +void +VVTK_Viewer +::Display(const SALOME_VTKPrs* thePrs) +{ + // try do downcast object + if(const SVTK_Prs* aPrs = dynamic_cast(thePrs)){ + if(aPrs->IsNull()) + return; + if(vtkActorCollection* aCollection = aPrs->GetObjects()){ + aCollection->InitTraversal(); + while(VISU_Actor* anActor = dynamic_cast(aCollection->GetNextActor())){ + if(!anActor->GetFactory()->GetActiveState()) + continue; + QPtrVector aViews = myViewManager->getViews(); + for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){ + if(SVTK_ViewWindow* aViewWindow = dynamic_cast(aViews.at(i))){ + if(SVTK_View* aView = aViewWindow->getView()){ + aView->Display(anActor, false); + } + } + } + } + } + } +} + +//--------------------------------------------------------------- +namespace VVTK +{ + struct TIsOneActorVisibleAction + { + bool& myResult; + TIsOneActorVisibleAction(bool& theResult): + myResult(theResult) + { + myResult = false; + } + void + operator()(SALOME_Actor* theActor) + { + if(!myResult) + myResult = theActor->GetVisibility(); + } + }; +} + +//--------------------------------------------------------------- +bool +VVTK_Viewer +::isVisible( const Handle(SALOME_InteractiveObject)& theIO ) +{ + QPtrVector aViews = myViewManager->getViews(); + for(int i = 0, iEnd = aViews.size(); i < iEnd; i++) + if(SVTK_ViewWindow* aViewWindow = dynamic_cast(aViews.at(i))){ + bool aResult; + VVTK::TIsOneActorVisibleAction anAction(aResult); + SVTK::ForEachIf(aViewWindow->getRenderer()->GetActors(), + SVTK::TIsSameIObject(theIO), + anAction); + return anAction.myResult; + } + + return false; +} diff --git a/src/VVTK/VVTK_ViewModel.h b/src/VVTK/VVTK_ViewModel.h index fb7ca0dc..35fefc2b 100644 --- a/src/VVTK/VVTK_ViewModel.h +++ b/src/VVTK/VVTK_ViewModel.h @@ -34,16 +34,41 @@ class VVTK_EXPORT VVTK_Viewer : public SVTK_Viewer public: typedef VVTK_ViewWindow TViewWindow; - static QString Type() { return "VVTK"; } + + static + QString + Type() + { + return "VVTK"; + } VVTK_Viewer(); - virtual ~VVTK_Viewer(); + + virtual + ~VVTK_Viewer(); //! See #SUIT_ViewModel::createView - virtual SUIT_ViewWindow* createView(SUIT_Desktop*); + virtual + SUIT_ViewWindow* + createView(SUIT_Desktop*); //! See SUIT_ViewModel::getType - virtual QString getType() const { return Type(); } + virtual + QString + getType() const + { + return Type(); + } + + //! See #SALOME_View::Display( const SALOME_Prs* ) + virtual + void + Display(const SALOME_VTKPrs* thePrs); + + //! See #SALOME_View::isVisible( const Handle(SALOME_InteractiveObject)& ) + virtual + bool + isVisible(const Handle(SALOME_InteractiveObject)& theIO); }; #endif -- 2.39.2