]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Single entry in PV pipeline for a single entry in a single PV3D view
authorAnthony Geay <anthony.geay@edf.fr>
Fri, 7 Apr 2023 16:10:02 +0000 (18:10 +0200)
committerAnthony Geay <anthony.geay@edf.fr>
Fri, 7 Apr 2023 16:10:02 +0000 (18:10 +0200)
src/SPV3D/SPV3D_Prs.cxx
src/SPV3D/SPV3D_Prs.h
src/SPV3D/SPV3D_ViewWindow.cxx
src/SPV3D/SPV3D_ViewWindow.h

index cf2e3a562f2187fe1e2951b96256ac3acf585ef2..ed912665afaa66b4e17f34cc4f1fe0b3a65e9d33 100644 (file)
@@ -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)
index 4ed52b0c36cebdeb9b718392282686e00fe385f2..89a012a5ed495711f1809921a186c48e410b5931 100644 (file)
@@ -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;
 };
index d3e226c4d4f9ebd4b4af40535e5ed5d37d92da90..c23fe69cd85c0d226c4ca52ebc6ce1166fe5bcea 100644 (file)
@@ -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
 */
index 5a39d5bffe2b4f79b26f77092c38d534bd5cb06b..aa03d100be28596e4e6d9466e03eb5fe5462e0f6 100644 (file)
@@ -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();