]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To adjust Display/Erase popup functionality to the VISU Cache System
authorapo <apo@opencascade.com>
Thu, 30 Nov 2006 09:08:11 +0000 (09:08 +0000)
committerapo <apo@opencascade.com>
Thu, 30 Nov 2006 09:08:11 +0000 (09:08 +0000)
src/OBJECT/VISU_ActorFactory.h
src/VISU_I/VISU_ColoredPrs3dCache_i.cc
src/VISU_I/VISU_Prs3d_i.cc
src/VISU_I/VISU_Prs3d_i.hh
src/VVTK/VVTK_ViewModel.cxx
src/VVTK/VVTK_ViewModel.h

index 7240237040f2370b47b3e16bd9e88067624962d2..ec7af383883ded8345678438bf241d8fe1c8d2f6 100644 (file)
@@ -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 
index 122aaa33b13ed64bb42703fcc63cbba082d70403..2b5043e7608be77a3588c8d14e71af448664eaca 100644 (file)
 #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 <vtkRenderer.h>
-
 #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<VISU_Actor>(anActors,
-                                       SVTK::TIsSameIObject<SALOME_Actor>(anIO),
-                                       SVTK::TSetVisibility<VISU_Actor>(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
       }
     }
   }
-
-
 }
index 621b18dec7749e7decb77db9b476bb2f5221fb8e..651f2d8e7f03356b8cc68a367cd20a09fe4c0405 100644 (file)
@@ -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
index 07cdbd8a3d0a8a79609605bb08b1dabffe13abe8..9c3571948706532b32426a23fade17aeee5b00d5 100644 (file)
@@ -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;
   };
 
   //----------------------------------------------------------------------------
index af6f65ed3c64c79544a322719643adde544aa733..b1b3ec4e82cd8d9160f535d620cba7d624660d5c 100644 (file)
 
 #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 <vtkActorCollection.h>
+#include <vtkRenderer.h>
+
+//---------------------------------------------------------------
+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<const SVTK_Prs*>(thePrs)){
+    if(aPrs->IsNull())
+      return;
+    if(vtkActorCollection* aCollection = aPrs->GetObjects()){
+      aCollection->InitTraversal();
+      while(VISU_Actor* anActor = dynamic_cast<VISU_Actor*>(aCollection->GetNextActor())){
+       if(!anActor->GetFactory()->GetActiveState())
+         continue;
+       QPtrVector<SUIT_ViewWindow> aViews = myViewManager->getViews();
+       for(int i = 0, iEnd = aViews.size(); i < iEnd; i++){
+         if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(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<SUIT_ViewWindow> aViews = myViewManager->getViews();
+  for(int i = 0, iEnd = aViews.size(); i < iEnd; i++)
+    if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(aViews.at(i))){
+      bool aResult;
+      VVTK::TIsOneActorVisibleAction anAction(aResult);
+      SVTK::ForEachIf<SALOME_Actor>(aViewWindow->getRenderer()->GetActors(),
+                                   SVTK::TIsSameIObject<SALOME_Actor>(theIO),
+                                   anAction);
+      return anAction.myResult;
+    }
+  
+  return false;
+}
index fb7ca0dc850002571d25c3100473aa69e2c50dad..35fefc2b43277b33863bdc668008ad8a7390b90b 100644 (file)
@@ -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