From cabc82c0ba19c7107464b294bf9f43ece0246494 Mon Sep 17 00:00:00 2001 From: Anthony Geay Date: Fri, 7 Apr 2023 18:10:02 +0200 Subject: [PATCH] Single entry in PV pipeline for a single entry in a single PV3D view --- src/SPV3D/SPV3D_Prs.cxx | 52 ++++++++++++++++++++++------------ src/SPV3D/SPV3D_Prs.h | 6 +++- src/SPV3D/SPV3D_ViewWindow.cxx | 13 ++++++++- src/SPV3D/SPV3D_ViewWindow.h | 2 ++ 4 files changed, 53 insertions(+), 20 deletions(-) diff --git a/src/SPV3D/SPV3D_Prs.cxx b/src/SPV3D/SPV3D_Prs.cxx index cf2e3a562..ed912665a 100644 --- a/src/SPV3D/SPV3D_Prs.cxx +++ b/src/SPV3D/SPV3D_Prs.cxx @@ -24,6 +24,7 @@ // File : SPV3D_Prs.cxx #include "SPV3D_Prs.h" +#include "SPV3D_ViewWindow.h" #include "vtkActor.h" #include "vtkDataSet.h" @@ -56,10 +57,8 @@ void SPV3D_EXPORTSPV3DData::Hide() const GetRepresentation()->setVisible(0); } -SPV3D_Prs::SPV3D_Prs( const char* entry ) : SALOME_PV3DPrs(entry) +SPV3D_Prs::SPV3D_Prs( const char* entry , SPV3D_ViewWindow *view) : SALOME_PV3DPrs(entry),_view(view) { - DBG_FUN(); - ARG(entry); } SPV3D_Prs *SPV3D_Prs::deepCopy() const @@ -70,21 +69,29 @@ SPV3D_Prs *SPV3D_Prs::deepCopy() const void SPV3D_Prs::FillUsingActor(vtkActor *actor) const { - actor->GetMapper()->Update(); - vtkDataObject *ds = actor->GetMapper()->GetInput();//GetOutputDataObject(0); - vtkDataSet *ds2 = vtkDataSet::SafeDownCast(ds); - // - pqServer *serv(pqApplicationCore::instance()->getServerManagerModel()->findServer(pqServerResource("builtin:"))); - pqObjectBuilder *builder(pqApplicationCore::instance()->getObjectBuilder()); - pqPipelineSource *mySourceProducer(builder->createSource("sources","PVTrivialProducer",serv)); - vtkSMProxy *producerBase = mySourceProducer->getProxy(); - vtkSMSourceProxy *producer(vtkSMSourceProxy::SafeDownCast(producerBase)); - vtkObjectBase *clientSideObject(producer->GetClientSideObject()); - vtkPVTrivialProducer *clientSideObjectCast = vtkPVTrivialProducer::SafeDownCast(clientSideObject); - clientSideObjectCast->SetOutput(ds2); - mySourceProducer->updatePipeline(); - // - this->SetSourceProducer( mySourceProducer ); + SPV3D_EXPORTSPV3DData *alreadyExistingSrc = nullptr; + alreadyExistingSrc = _view->isEntryAlreadyExist( GetEntry() ); + if(alreadyExistingSrc && !alreadyExistingSrc->GetSourceProducer()) + { + actor->GetMapper()->Update(); + vtkDataObject *ds = actor->GetMapper()->GetInput();//GetOutputDataObject(0); + vtkDataSet *ds2 = vtkDataSet::SafeDownCast(ds); + // + pqServer *serv(pqApplicationCore::instance()->getServerManagerModel()->findServer(pqServerResource("builtin:"))); + pqObjectBuilder *builder(pqApplicationCore::instance()->getObjectBuilder()); + pqPipelineSource *mySourceProducer(builder->createSource("sources","PVTrivialProducer",serv)); + vtkSMProxy *producerBase = mySourceProducer->getProxy(); + vtkSMSourceProxy *producer(vtkSMSourceProxy::SafeDownCast(producerBase)); + vtkObjectBase *clientSideObject(producer->GetClientSideObject()); + vtkPVTrivialProducer *clientSideObjectCast = vtkPVTrivialProducer::SafeDownCast(clientSideObject); + clientSideObjectCast->SetOutput(ds2); + mySourceProducer->updatePipeline(); + this->SetSourceProducer( mySourceProducer ); + } + else + { + this->CopyInfo( alreadyExistingSrc ); + } } SPV3D_Prs:: ~SPV3D_Prs() @@ -97,6 +104,15 @@ void SPV3D_Prs::DisplayIn( SALOME_View* v ) const SALOME_PV3DPrs::DisplayIn(v); } +void SPV3D_Prs::CopyInfo(SPV3D_EXPORTSPV3DData *info) const +{ + if(!_pvRendInfo || !info) + return ; + if(_pvRendInfo == info) + return ; + *_pvRendInfo = *info; +} + bool SPV3D_Prs::IsNull() const { if(_pvRendInfo) diff --git a/src/SPV3D/SPV3D_Prs.h b/src/SPV3D/SPV3D_Prs.h index 4ed52b0c3..89a012a5e 100644 --- a/src/SPV3D/SPV3D_Prs.h +++ b/src/SPV3D/SPV3D_Prs.h @@ -48,10 +48,12 @@ private: mutable pqDataRepresentation *_repr = nullptr; }; +class SPV3D_ViewWindow; + class SPV3D_EXPORT SPV3D_Prs : public SALOME_PV3DPrs { public: - explicit SPV3D_Prs( const char* entry ); + explicit SPV3D_Prs( const char* entry, SPV3D_ViewWindow *view); ~SPV3D_Prs(); SPV3D_Prs *deepCopy() const; @@ -60,6 +62,7 @@ public: void DisplayIn( SALOME_View* v ) const override; + void CopyInfo(SPV3D_EXPORTSPV3DData *info) const; void SetPVRenderInfo(SPV3D_EXPORTSPV3DData *pvRendInfo) { _pvRendInfo = pvRendInfo; } @@ -82,4 +85,5 @@ public: private: SPV3D_EXPORTSPV3DData *_pvRendInfo = nullptr; + SPV3D_ViewWindow *_view = nullptr; }; diff --git a/src/SPV3D/SPV3D_ViewWindow.cxx b/src/SPV3D/SPV3D_ViewWindow.cxx index d3e226c4d..c23fe69cd 100644 --- a/src/SPV3D/SPV3D_ViewWindow.cxx +++ b/src/SPV3D/SPV3D_ViewWindow.cxx @@ -95,7 +95,7 @@ void SPV3D_ViewWindow::init() SPV3D_Prs *SPV3D_ViewWindow::findOrCreatePrs( const char* entry ) { std::string entryCpp( entry ); - SPV3D_Prs *prsOut( new SPV3D_Prs( entry ) ); + SPV3D_Prs *prsOut( new SPV3D_Prs( entry, this ) ); for(auto& prs : myPrs) { if(entryCpp == prs.first) @@ -111,6 +111,17 @@ SPV3D_Prs *SPV3D_ViewWindow::findOrCreatePrs( const char* entry ) return prsOut; } +SPV3D_EXPORTSPV3DData *SPV3D_ViewWindow::isEntryAlreadyExist( const char* entry ) const +{ + std::string entryCpp( entry ); + for(const auto& prs : myPrs) + { + if(entryCpp == prs.first) + return prs.second.get(); + } + return nullptr; +} + /*! Destructor */ diff --git a/src/SPV3D/SPV3D_ViewWindow.h b/src/SPV3D/SPV3D_ViewWindow.h index 5a39d5bff..aa03d100b 100644 --- a/src/SPV3D/SPV3D_ViewWindow.h +++ b/src/SPV3D/SPV3D_ViewWindow.h @@ -91,6 +91,8 @@ class SPV3D_EXPORT SPV3D_ViewWindow : public PV3DViewer_ViewWindow //SUIT_ViewWi SPV3D_Prs *findOrCreatePrs( const char* entry ); + SPV3D_EXPORTSPV3DData *isEntryAlreadyExist( const char* entry ) const; + void init(); virtual ~SPV3D_ViewWindow(); -- 2.39.2