#include "MBDebug.h"
//---------------------------------------------------------
-/*!
- Default constructor
-*/
+bool SPV3D_EXPORTSPV3DData::IsVisible() const
+{
+ if( IsNull() )
+ return false;
+ return GetRepresentation()->isVisible();
+}
+
+void SPV3D_EXPORTSPV3DData::Hide() const
+{
+ if( GetRepresentation() )
+ GetRepresentation()->setVisible(0);
+}
+
SPV3D_Prs::SPV3D_Prs( const char* entry ) : SALOME_PV3DPrs(entry)
{
DBG_FUN();
ARG(entry);
}
-/*!
- Destructor
-*/
+SPV3D_Prs *SPV3D_Prs::deepCopy() const
+{
+ SPV3D_Prs *ret = new SPV3D_Prs( *this );
+ return ret;
+}
+
SPV3D_Prs:: ~SPV3D_Prs()
{
DBG_FUN();
bool SPV3D_Prs::IsNull() const
{
- return !_sourceProducer && !_repr;
+ if(_pvRendInfo)
+ return _pvRendInfo->IsNull();
+ return true;
}
-bool SPV3D_Prs::isVisible() const
-{
- if( IsNull() )
- return false;
- return _repr->isVisible();
-}
-void SPV3D_Prs::hide() const
-{
- if( _repr )
- _repr->setVisible(0);
-}
class pqPipelineSource;
class pqDataRepresentation;
+class SPV3D_EXPORTSPV3DData
+{
+public:
+ SPV3D_EXPORTSPV3DData() = default;
+ SPV3D_EXPORTSPV3DData *deepCopy() { return new SPV3D_EXPORTSPV3DData(*this); }
+ void SetSourceProducer(pqPipelineSource *sourceProducer) const { _sourceProducer = sourceProducer; }
+ pqPipelineSource *GetSourceProducer() const { return _sourceProducer; }
+
+ void SetRepresentation(pqDataRepresentation *repr) const { _repr = repr; }
+ pqDataRepresentation *GetRepresentation() const { return _repr; }
+
+ bool IsNull() const { return !_sourceProducer && !_repr; }
+
+ bool IsVisible() const;
+ void Hide() const;
+private:
+ SPV3D_EXPORTSPV3DData(const SPV3D_EXPORTSPV3DData& other) = default;
+private:
+ mutable pqPipelineSource *_sourceProducer = nullptr;
+ mutable pqDataRepresentation *_repr = nullptr;
+};
+
class SPV3D_EXPORT SPV3D_Prs : public SALOME_PV3DPrs
{
public:
explicit SPV3D_Prs( const char* entry );
~SPV3D_Prs();
+ SPV3D_Prs *deepCopy() const;
+
void DisplayIn( SALOME_View* v ) const override;
- void SetSourceProducer(pqPipelineSource *sourceProducer) { _sourceProducer = sourceProducer; }
- pqPipelineSource *GetSourceProducer() const { return _sourceProducer; }
+ void SetPVRenderInfo(SPV3D_EXPORTSPV3DData *pvRendInfo) { _pvRendInfo = pvRendInfo; }
+
+ void SetSourceProducer(pqPipelineSource *sourceProducer) const { if(_pvRendInfo) _pvRendInfo->SetSourceProducer(sourceProducer); }
+ pqPipelineSource *GetSourceProducer() const { if(_pvRendInfo) return _pvRendInfo->GetSourceProducer(); return nullptr; }
- void SetRepresentation(pqDataRepresentation *repr) const { _repr = repr; }
- pqDataRepresentation *GetRepresentation() const { return _repr; }
+ void SetRepresentation(pqDataRepresentation *repr) const { if(_pvRendInfo) _pvRendInfo->SetRepresentation(repr); }
+ pqDataRepresentation *GetRepresentation() const { if(_pvRendInfo) return _pvRendInfo->GetRepresentation(); return nullptr; }
bool IsNull() const override;
+private:
+
+ SPV3D_Prs(const SPV3D_Prs& other) = default;
+
public:
- void hide() const;
- bool isVisible() const;
+ void hide() const { if(_pvRendInfo) return _pvRendInfo->Hide(); }
+ bool isVisible() const { if(_pvRendInfo) return _pvRendInfo->IsVisible(); return false; }
private:
- pqPipelineSource *_sourceProducer = nullptr;
- mutable pqDataRepresentation *_repr = nullptr;
+
+ SPV3D_EXPORTSPV3DData *_pvRendInfo = nullptr;
};
pqObjectBuilder *builder(pqApplicationCore::instance()->getObjectBuilder());
pqActiveObjects::instance().setActiveView(getView());
pqPipelineSource *mySourceProducer = aPrs->GetSourceProducer();
+ aPrs->SetSourceProducer( mySourceProducer );
pqDataRepresentation* myRepr(builder->createDataRepresentation(mySourceProducer->getOutputPort(0),getView(),"GeometryRepresentation"));
vtkSMViewProxy::RepresentationVisibilityChanged(myRepr->getViewProxy(), myRepr->getProxy(), true);
aPrs->SetRepresentation(myRepr);
{
DBG_FUN();
ARG(entry);
- SPV3D_Prs* prs = new SPV3D_Prs( entry );
- if ( entry ) {
- if(SPV3D_ViewWindow* aViewWindow = dynamic_cast<SPV3D_ViewWindow*>(getViewManager()->getActiveView()))
- {
- aViewWindow->appendPrs( prs );
- }
+ if(SPV3D_ViewWindow* aViewWindow = dynamic_cast<SPV3D_ViewWindow*>(getViewManager()->getActiveView()))
+ {
+ return aViewWindow->findOrCreatePrs( entry );
}
- return prs;
+ return nullptr;
}
/*!
setCentralWidget( myModel->getView()->widget() );
}
-void SPV3D_ViewWindow::appendPrs( SPV3D_Prs* prs )
+SPV3D_Prs *SPV3D_ViewWindow::findOrCreatePrs( const char* entry )
{
- myPrs.push_back(prs);
+ std::string entryCpp( entry );
+ SPV3D_Prs *prsOut( new SPV3D_Prs( entry ) );
+ for(auto& prs : myPrs)
+ {
+ if(entryCpp == prs.first)
+ {
+ prsOut->SetPVRenderInfo( prs.second.get() );
+ return prsOut;
+ }
+ }
+ std::unique_ptr<SPV3D_EXPORTSPV3DData> data(new SPV3D_EXPORTSPV3DData);
+ prsOut->SetPVRenderInfo( data.get() );
+ std::pair<std::string, std::unique_ptr<SPV3D_EXPORTSPV3DData> > p(entryCpp,std::move(data));
+ myPrs.emplace_back( std::move(p) );
+ return prsOut;
}
/*!
bool SPV3D_ViewWindow::isVisible(const Handle(SALOME_InteractiveObject)& theIObject)
{
- std::string ior( theIObject->getEntry() );
- for(auto prs : myPrs)
+ std::string entryCpp( theIObject->getEntry() );
+ for(auto& prs : myPrs)
{
- if(ior == prs->GetEntry() )
- return prs->isVisible();
+ if(entryCpp == prs.first )
+ return prs.second->IsVisible();
}
return false;
}
void SPV3D_ViewWindow::EraseAll()
{
DBG_FUN();
- for(auto prs : myPrs)
+ for(auto& prs : myPrs)
{
- prs->hide();
+ prs.second->Hide();
}
if(myModel)
myModel->render();
#include "SPV3D.h"
#include "Qtx.h"
#include "PV3DViewer_ViewWindow.h"
+#include "SPV3D_Prs.h"
#include "SALOME_InteractiveObject.hxx"
#include "SALOME_ListIO.hxx"
#include <vtkSmartPointer.h>
#include <list>
+#include <memory>
class SUIT_Desktop;
class SUIT_ResourceMgr;
//! To construct #SPV3D_ViewWindow instance
SPV3D_ViewWindow(SUIT_Desktop* theDesktop, SPV3D_ViewModel* theModel);
- void appendPrs( SPV3D_Prs* prs );
+ SPV3D_Prs *findOrCreatePrs( const char* entry );
void init();
protected:
SPV3D_ViewModel* myModel;
- std::list< SPV3D_Prs* > myPrs;
+ std::list< std::pair<std::string, std::unique_ptr<SPV3D_EXPORTSPV3DData> > > myPrs;
};
#ifdef WIN32