From 143a47bf142b84ed31f0048c628732d71e1b9c15 Mon Sep 17 00:00:00 2001 From: apo Date: Mon, 27 Nov 2006 09:03:18 +0000 Subject: [PATCH] To implement more intellegent view handling --- src/VISU_I/VISU_ColoredPrs3dCache_i.cc | 42 ++++++++++++++++++++------ src/VISU_I/VISU_ViewManager_i.hh | 25 ++++++++++++--- 2 files changed, 53 insertions(+), 14 deletions(-) diff --git a/src/VISU_I/VISU_ColoredPrs3dCache_i.cc b/src/VISU_I/VISU_ColoredPrs3dCache_i.cc index 61c8c4a3..f3e61fa1 100644 --- a/src/VISU_I/VISU_ColoredPrs3dCache_i.cc +++ b/src/VISU_I/VISU_ColoredPrs3dCache_i.cc @@ -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" @@ -37,6 +37,12 @@ #include "VVTK_ViewWindow.h" #include "SUIT_ResourceMgr.h" +#include "VTKViewer_Algorithm.h" +#include "SVTK_Functor.h" + +#include +#include + #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(aServant.in())){ + if(SUIT_ViewWindow* aView = aView3d->GetViewWindow()){ + if(SVTK_ViewWindow* aViewWindow = dynamic_cast(aView)){ + if(aPrs3d != aLastVisitedPrs3d){ + vtkRenderer* aRenderer = aViewWindow->getRenderer(); + vtkActorCollection* anActors = aRenderer->GetActors(); + Handle(SALOME_InteractiveObject) anIO = aPrs3d->GetIO(); + SVTK::ForEachIf(anActors, + SVTK::TIsSameIObject(anIO), + SVTK::TSetVisibility(false)); + VISU_Actor* anActor = + SVTK::Find(anActors, + VISU::TIsSamePrs3d(aPrs3d)); + if(!anActor){ + anActor = aPrs3d->CreateActor(); + aViewWindow->AddActor(anActor); + }else + anActor->SetVisibility(true); + anActor->UpdateFromFactory(); + } + aViewWindow->Repaint(); + return true; + } + } + } } return false; diff --git a/src/VISU_I/VISU_ViewManager_i.hh b/src/VISU_I/VISU_ViewManager_i.hh index 2fc22558..ba4e7c4c 100644 --- a/src/VISU_I/VISU_ViewManager_i.hh +++ b/src/VISU_I/VISU_ViewManager_i.hh @@ -28,11 +28,10 @@ #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 -- 2.39.2