From ae812cff3e19215314ee45c81a145a8401bee6a2 Mon Sep 17 00:00:00 2001 From: apo Date: Mon, 27 Nov 2006 09:47:20 +0000 Subject: [PATCH] To implement more intellegent view handling --- src/VISUGUI/VisuGUI_Slider.cxx | 16 ++++----- src/VISU_I/VISU_ColoredPrs3dCache_i.cc | 49 +++++++++++++++++++++----- 2 files changed, 46 insertions(+), 19 deletions(-) diff --git a/src/VISUGUI/VisuGUI_Slider.cxx b/src/VISUGUI/VisuGUI_Slider.cxx index 12682cbe..03a181e5 100644 --- a/src/VISUGUI/VisuGUI_Slider.cxx +++ b/src/VISUGUI/VisuGUI_Slider.cxx @@ -35,12 +35,6 @@ #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" @@ -49,11 +43,12 @@ #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 #include @@ -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 ); diff --git a/src/VISU_I/VISU_ColoredPrs3dCache_i.cc b/src/VISU_I/VISU_ColoredPrs3dCache_i.cc index f3e61fa1..80ee8d22 100644 --- a/src/VISU_I/VISU_ColoredPrs3dCache_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3dCache_i.cc @@ -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(aServant.in())){ if(SUIT_ViewWindow* aView = aView3d->GetViewWindow()){ if(SVTK_ViewWindow* aViewWindow = dynamic_cast(aView)){ + // Find actor that corresponds to the holder + vtkRenderer* aRenderer = aViewWindow->getRenderer(); + vtkActorCollection* anActors = aRenderer->GetActors(); + VISU_Actor* anActor = + SVTK::Find(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(anActors, SVTK::TIsSameIObject(anIO), SVTK::TSetVisibility(false)); - VISU_Actor* anActor = + // To find the new one that corresponds to fresh presentation + VISU_Actor* aNewActor = SVTK::Find(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; -- 2.39.2