]> 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:47:20 +0000 (09:47 +0000)
committerapo <apo@opencascade.com>
Mon, 27 Nov 2006 09:47:20 +0000 (09:47 +0000)
src/VISUGUI/VisuGUI_Slider.cxx
src/VISU_I/VISU_ColoredPrs3dCache_i.cc

index 12682cbea354689a0d801ef58261edddb6d87a19..03a181e581404c90b955a6178b6ecf506520b8e7 100644 (file)
 
 #include "LightApp_SelectionMgr.h"
 
-#include "SVTK_Functor.h"
-#include "SVTK_Renderer.h"
-#include "SVTK_RenderWindowInteractor.h"
-
-#include "VTKViewer_Algorithm.h"
-
 #include "SALOME_ListIteratorOfListIO.hxx"
 
 #include "VISU_Actor.h"
 #include "VVTK_ViewWindow.h"
 
 #include "VISU_Gen_i.hh"
-#include "VISU_ColoredPrs3d_i.hh"
-#include "VISU_ColoredPrs3dHolder_i.hh"
-
 #include "VisuGUI_Module.h"
 #include "VisuGUI_Tools.h"
+#include "VisuGUI_Prs3dTools.h"
+
+#include "VTKViewer_Algorithm.h"
+#include "SVTK_Functor.h"
 
 #include <vtkActorCollection.h>
 #include <vtkRenderer.h>
@@ -382,10 +377,11 @@ void VisuGUI_Slider::onValueChanged( int value )
     if( CORBA::is_nil( aHolder.in() ) )
       continue;
 
+    VISU::ColoredPrs3d_var aPrs3d = aHolder->GetDevice();
     VISU::ColoredPrs3dHolder::BasicInput_var anInput = aHolder->GetBasicInput();
     anInput->myTimeStampNumber = aNumber;
 
-    aHolder->Apply( aHolder->GetDevice(), anInput, myView3D );
+    aHolder->Apply( aPrs3d, anInput, myView3D );
   }
 
   myTimeStampStrings->setCurrentItem( value );
index f3e61fa129cf76ed20cfc826454bd3db9fbb3c4e..80ee8d224d708751f61e9e5742e51e7bdb15d54a 100644 (file)
@@ -28,8 +28,6 @@
 
 #include "VISU_ColoredPrs3dHolder_i.hh"
 #include "VISU_ColoredPrs3dFactory.hh"
-#include "VISU_ViewManager_i.hh"
-#include "VISU_View_i.hh"
 
 #include "VISU_Convertor.hxx"
 #include "VISU_PipeLine.hxx"
@@ -37,6 +35,9 @@
 #include "VVTK_ViewWindow.h"
 #include "SUIT_ResourceMgr.h"
 
+#include "VISU_Actor.h"
+#include "VISU_View_i.hh"
+
 #include "VTKViewer_Algorithm.h"
 #include "SVTK_Functor.h"
 
@@ -374,6 +375,26 @@ VISU::ColoredPrs3dCache_i
 }
 
 
+//----------------------------------------------------------------------------
+namespace VISU
+{
+  struct TIsSamePrs3d
+  {
+    VISU::Prs3d_i* myPrs3d;
+
+    TIsSamePrs3d(VISU::Prs3d_i* thePrs3d):
+      myPrs3d(thePrs3d)
+    {}
+    
+    bool
+    operator()(VISU_Actor* theActor) 
+    {
+      return theActor->GetPrs3d() == myPrs3d;
+    }
+  };
+}
+
+
 //----------------------------------------------------------------------------
 bool
 VISU::ColoredPrs3dCache_i
@@ -407,27 +428,37 @@ VISU::ColoredPrs3dCache_i
   aPrs3d->SetFieldName(theInput.myFieldName);
   aPrs3d->SetTimeStampNumber(theInput.myTimeStampNumber);
   aPrs3d->SameAs(thePrs);
+  aPrs3d->UpdateActors();
   if(!CORBA::is_nil(theView3D)){
     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)){
+         // Find actor that corresponds to the holder
+         vtkRenderer* aRenderer = aViewWindow->getRenderer();
+         vtkActorCollection* anActors = aRenderer->GetActors();
+         VISU_Actor* anActor = 
+           SVTK::Find<VISU_Actor>(anActors,
+                                  VISU::TIsSamePrs3d(aLastVisitedPrs3d));
+         // If the holder was erased from view then do nothing
+         if(!anActor->GetVisibility())
+           return true;
+
          if(aPrs3d != aLastVisitedPrs3d){
-           vtkRenderer* aRenderer = aViewWindow->getRenderer();
-           vtkActorCollection* anActors = aRenderer->GetActors();
+           // To erase all actors that corresponds to the holder
            Handle(SALOME_InteractiveObject) anIO = aPrs3d->GetIO();
            SVTK::ForEachIf<VISU_Actor>(anActors,
                                        SVTK::TIsSameIObject<SALOME_Actor>(anIO),
                                        SVTK::TSetVisibility<VISU_Actor>(false));
-           VISU_Actor* anActor = 
+           // To find the new one that corresponds to fresh presentation
+           VISU_Actor* aNewActor = 
              SVTK::Find<VISU_Actor>(anActors,
                                     VISU::TIsSamePrs3d(aPrs3d));
-           if(!anActor){
+           if(!aNewActor){
              anActor = aPrs3d->CreateActor();
-             aViewWindow->AddActor(anActor);
+             aViewWindow->AddActor(aNewActor);
            }else
-             anActor->SetVisibility(true);
-           anActor->UpdateFromFactory();
+             aNewActor->SetVisibility(true);
          }
          aViewWindow->Repaint();
          return true;