]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To implement more intellegent view handling
authorapo <apo@opencascade.com>
Mon, 27 Nov 2006 09:03:18 +0000 (09:03 +0000)
committerapo <apo@opencascade.com>
Mon, 27 Nov 2006 09:03:18 +0000 (09:03 +0000)
src/VISU_I/VISU_ColoredPrs3dCache_i.cc
src/VISU_I/VISU_ViewManager_i.hh

index 61c8c4a3d912ca870b428b6f3d0e0843ae30ae03..f3e61fa129cf76ed20cfc826454bd3db9fbb3c4e 100644 (file)
@@ -28,8 +28,8 @@
 
 #include "VISU_ColoredPrs3dHolder_i.hh"
 #include "VISU_ColoredPrs3dFactory.hh"
-#include "VISU_View_i.hh"
 #include "VISU_ViewManager_i.hh"
+#include "VISU_View_i.hh"
 
 #include "VISU_Convertor.hxx"
 #include "VISU_PipeLine.hxx"
 #include "VVTK_ViewWindow.h"
 #include "SUIT_ResourceMgr.h"
 
+#include "VTKViewer_Algorithm.h"
+#include "SVTK_Functor.h"
+
+#include <vtkActorCollection.h>
+#include <vtkRenderer.h>
+
 #ifdef _DEBUG_
 static int MYDEBUG = 0;
 #else
@@ -402,14 +408,32 @@ VISU::ColoredPrs3dCache_i
   aPrs3d->SetTimeStampNumber(theInput.myTimeStampNumber);
   aPrs3d->SameAs(thePrs);
   if(!CORBA::is_nil(theView3D)){
-    if(aPrs3d != aLastVisitedPrs3d){
-      VISU::ColoredPrs3d_var aColoredPrs3d = aLastVisitedPrs3d->_this();
-      theView3D->Erase(aColoredPrs3d);
-      aColoredPrs3d = aPrs3d->_this();
-      theView3D->Display(aColoredPrs3d);
-    }else
-      theView3D->Update();
-    return true;
+    PortableServer::ServantBase_var aServant = GetServant(theView3D);
+    if(VISU::View3D_i* aView3d = dynamic_cast<VISU::View3D_i*>(aServant.in())){
+      if(SUIT_ViewWindow* aView = aView3d->GetViewWindow()){
+       if(SVTK_ViewWindow* aViewWindow = dynamic_cast<SVTK_ViewWindow*>(aView)){
+         if(aPrs3d != aLastVisitedPrs3d){
+           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));
+           VISU_Actor* anActor = 
+             SVTK::Find<VISU_Actor>(anActors,
+                                    VISU::TIsSamePrs3d(aPrs3d));
+           if(!anActor){
+             anActor = aPrs3d->CreateActor();
+             aViewWindow->AddActor(anActor);
+           }else
+             anActor->SetVisibility(true);
+           anActor->UpdateFromFactory();
+         }
+         aViewWindow->Repaint();
+         return true;
+       }
+      }
+    }
   }
 
   return false;
index 2fc2255891c7b332c9c70c364e2cac40378fe238..ba4e7c4cd8d0788a6c959fe4e42265c57459b48c 100644 (file)
 #define VISU_ViewManager_i_HeaderFile
 
 #include "VISUConfig.hh"
+#include "VISU_Actor.h"
 
 class SalomeApp_Application;
 
-class VISU_Actor;
-
 class SUIT_ViewWindow;
 
 class SVTK_ViewWindow;
@@ -42,7 +41,8 @@ class vtkRenderer;
 class vtkCamera;
 
 
-namespace VISU {
+namespace VISU 
+{
   class Prs3d_i;
   class Curve_i;
 
@@ -73,10 +73,25 @@ namespace VISU {
   VISU_Actor* UpdateViewer (SUIT_ViewWindow* theViewWindow, int theDisplaing, Prs3d_i* thePrs = NULL);
   void UpdatePlot2d (Plot2d_ViewFrame *theView, int theDisplaying, Curve_i* theCurve);
 
-  VISU_Actor* GetActor (VISU::Prs3d_i* thePrs, SVTK_ViewWindow* theViewWindow);
-
   void DeleteActors (VISU::Prs3d_i* thePrs);
   void DeleteActors (VISU::Curve_i* thePrs);
+
+  VISU_Actor* GetActor (VISU::Prs3d_i* thePrs, SVTK_ViewWindow* theViewWindow);
+
+  struct TIsSamePrs3d
+  {
+    VISU::Prs3d_i* myPrs3d;
+
+    TIsSamePrs3d(VISU::Prs3d_i* thePrs3d):
+      myPrs3d(thePrs3d)
+    {}
+    
+    bool
+    operator()(VISU_Actor* theActor) 
+    {
+      return theActor->GetPrs3d() == myPrs3d;
+    }
+  };
 }
 
 #endif