// File : SPV3D_Prs.cxx
#include "SPV3D_Prs.h"
+#include "SPV3D_ViewWindow.h"
#include "vtkActor.h"
#include "vtkDataSet.h"
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
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()
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)
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;
void DisplayIn( SALOME_View* v ) const override;
+ void CopyInfo(SPV3D_EXPORTSPV3DData *info) const;
void SetPVRenderInfo(SPV3D_EXPORTSPV3DData *pvRendInfo) { _pvRendInfo = pvRendInfo; }
private:
SPV3D_EXPORTSPV3DData *_pvRendInfo = nullptr;
+ SPV3D_ViewWindow *_view = nullptr;
};
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)
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
*/