From: DUC ANH HOANG Date: Tue, 4 Jun 2024 12:08:35 +0000 (+0200) Subject: Second integration of PV3D viewer: X-Git-Tag: V9_13_0b1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=f5aec67b0043ca23f3e893128514ecf904350295;p=modules%2Fgui.git Second integration of PV3D viewer: Correction of the Presentation pipeline updating Correction of the CAD selection(setup solid_id with entry) Get preselect solidID (entry) from client --- diff --git a/src/SPV3D/SPV3D_CADSelection.cxx b/src/SPV3D/SPV3D_CADSelection.cxx index cd7820cf9..2cf4d1751 100644 --- a/src/SPV3D/SPV3D_CADSelection.cxx +++ b/src/SPV3D/SPV3D_CADSelection.cxx @@ -38,6 +38,12 @@ #include #include +#include + +#include "SPV3D_Prs.h" + + + //----------------------------------------------------------------------------- SPV3D_CADSelection::SPV3D_CADSelection(QObject *parent, pqRenderView* view, SelectionMode mode):QObject(parent) @@ -275,6 +281,32 @@ void SPV3D_CADSelection::onMouseMove() { this->fastSelection(true); } + + // get preselected id here + vtkSMProxy* proxyRepresentation = this->Representation->getProxy(); + if (!proxyRepresentation) + { + qWarning()<< "There is no representation in the active view for the Geometry Source."; + return; + } + + + // Retrieve the wanted information property + vtkSMProperty* PreselectedIDProperty = + proxyRepresentation->GetProperty("PreSelectedID"); + if (!PreselectedIDProperty) + { + qWarning()<< "The representation named '" << proxyRepresentation->GetXMLName()<< "' didn't have a property named 'SelectedIDInfo'."; + return; + } + + // Force to update the information property + proxyRepresentation->UpdatePropertyInformation(PreselectedIDProperty); + + vtkIdType PreSelectedID = + vtkSMPropertyHelper(proxyRepresentation,"PreSelectedID").GetAsInt(0); + qInfo() << "entry from client: "<< SPV3D_Prs::FromVtkIdToEntry(PreSelectedID); + } //----------------------------------------------------------------------------- diff --git a/src/SPV3D/SPV3D_Prs.cxx b/src/SPV3D/SPV3D_Prs.cxx index 8e8637cc5..210d89a50 100644 --- a/src/SPV3D/SPV3D_Prs.cxx +++ b/src/SPV3D/SPV3D_Prs.cxx @@ -23,6 +23,7 @@ #include "SPV3D_Prs.h" #include "SPV3D_ViewWindow.h" +#include #include "vtkActor.h" #include "vtkPolyData.h" #include "vtkCellData.h" @@ -36,6 +37,99 @@ #include "vtkPVTrivialProducer.h" #include +#include + +vtkIdType SPV3D_Prs::cellid = 0; +vtkIdType SPV3D_Prs::nbsolid = 0; + +SPV3D_EXPORTSPV3DData::SPV3D_EXPORTSPV3DData() +{ + nbsolid = 0; + _multiGEOMData = vtkSmartPointer::New(); + pqServer *serv(pqApplicationCore::instance()->getServerManagerModel()->findServer(pqServerResource("builtin:"))); + pqObjectBuilder *builder(pqApplicationCore::instance()->getObjectBuilder()); + _sourceProducer = builder->createSource("sources","PVTrivialProducer",serv); +} +void SPV3D_EXPORTSPV3DData::SetPolyData(vtkPolyData* ds) +{ + _multiGEOMData->SetBlock(nbsolid , ds); + nbsolid++; +} + +void SPV3D_EXPORTSPV3DData::SetPrs(vtkPolyData* ds, const char* entry) +{ + unsigned int id; + if (havePrs(entry, id)) + return; + auto nbCells( ds->GetNumberOfCells() ); + + vtkNew solidIdArray; + qInfo() << "nb of cells: " << nbCells; + solidIdArray->SetNumberOfComponents(1); + solidIdArray->SetNumberOfTuples( nbCells ); + solidIdArray->SetName("Solid id"); + +// vtkNew cellIdArray; +// cellIdArray->SetNumberOfComponents(1); +// cellIdArray->SetNumberOfTuples( nbCells ); +// cellIdArray->SetName("Edge id"); + + vtkIdType *pt( solidIdArray->GetPointer(0) ); + vtkIdType solidid = SPV3D_Prs::FromEntryToVtkId(entry); + std::for_each(pt,pt+nbCells,[solidid](vtkIdType& elt) { elt = solidid;}); +// pt = cellIdArray->GetPointer(0); +// std::for_each(pt,pt+nbCells,[](vtkIdType& elt) { elt = SPV3D_Prs::cellid;SPV3D_Prs::cellid++; }); + + ds->GetCellData()->AddArray( solidIdArray ); +// ->GetCellData()->AddArray( cellIdArray ); + SetPolyData(ds); + updateSource_for_display(); +} + +void SPV3D_EXPORTSPV3DData::RemovePrs(const char* entry) +{ + unsigned int id; + if (!havePrs(entry, id)) + { + qWarning() << "Can not find solid with entry: " << entry; + return; + } + _multiGEOMData->RemoveBlock(id); + updateSource_for_display(); +} + +void SPV3D_EXPORTSPV3DData::updateSource_for_display() +{ + vtkNew appendFilter; + nbsolid = _multiGEOMData->GetNumberOfBlocks(); + qInfo() <<"number of block: " << nbsolid; + for (unsigned int i = 0; i < nbsolid; ++i) + { + vtkPolyData* polyData = vtkPolyData::SafeDownCast(_multiGEOMData->GetBlock(i)); + if (polyData) + { + vtkIdTypeArray* retrievedArray = vtkIdTypeArray::SafeDownCast(polyData->GetCellData()->GetArray("Solid id")); + if (retrievedArray) + appendFilter->AddInputData(polyData); + } + } + appendFilter->Update(); + vtkNew ds; + ds->ShallowCopy(appendFilter->GetOutput()); + + vtkSMProxy* producerBase = _sourceProducer->getProxy(); + vtkSMSourceProxy *producer(vtkSMSourceProxy::SafeDownCast(producerBase)); + vtkObjectBase *clientSideObject(producer->GetClientSideObject()); + vtkPVTrivialProducer *clientSideObjectCast = vtkPVTrivialProducer::SafeDownCast(clientSideObject); + clientSideObjectCast->SetOutput(ds); + _sourceProducer->updatePipeline(); + + //pqServerManagerModel* smmodel = pqApplicationCore::instance()->getServerManagerModel(); + //pqProxy *producerBase2( smmodel->findItem(producerBase) ); + //if(producerBase2 && !_name.empty()) + // producerBase2->rename( _name.c_str() ); +} + bool SPV3D_EXPORTSPV3DData::IsVisible() const { if( IsNull() ) @@ -43,6 +137,25 @@ bool SPV3D_EXPORTSPV3DData::IsVisible() const return GetRepresentation()->isVisible(); } +bool SPV3D_EXPORTSPV3DData::havePrs(const char* entry, unsigned int & id) +{ + vtkIdType solid_id = SPV3D_Prs::FromEntryToVtkId(entry); + id = 0; + while (id < _multiGEOMData->GetNumberOfBlocks()) + { + vtkPolyData* polyData = vtkPolyData::SafeDownCast(_multiGEOMData->GetBlock(id)); + if (polyData) + { + vtkIdTypeArray* retrievedArray = vtkIdTypeArray::SafeDownCast(polyData->GetCellData()->GetArray("Solid id")); + if (retrievedArray && retrievedArray->GetValue(0) == solid_id) + break; + } + id++; + } + + return id < _multiGEOMData->GetNumberOfBlocks(); +} + void SPV3D_EXPORTSPV3DData::Hide() const { if( GetRepresentation() ) @@ -53,6 +166,38 @@ SPV3D_Prs::SPV3D_Prs( const char* entry , SPV3D_ViewWindow *view) : SALOME_PV3DP { } +vtkIdType SPV3D_Prs::FromEntryToVtkId (const char* entry) +{ + char *str = new char[strlen(entry)+1]; + strcpy(str, entry); + + const char delimiter[2] = ":"; + + char* token; + token = strtok(str, delimiter); + + std::uint32_t ret(atoi(token)); + token = strtok(NULL, delimiter); + + while (token != NULL) { + ret <<=8; + ret |= atoi(token); + token = strtok(NULL, delimiter); + } + + return static_cast (ret); +} + +const char* SPV3D_Prs::FromVtkIdToEntry(vtkIdType id) +{ + int d = id & 0xFF; + std::uint32_t c_work = ( id & 0xFF00 ); int c = c_work >> 8; + std::uint32_t b_work = ( id & 0xFF0000 ); int b = b_work >> 16; + std::uint32_t a_work = ( id & 0xFF000000 ); int a = a_work >> 24; + std::string ret = std::to_string(a) + ":" + std::to_string(b) + ":" + std::to_string(c)+ ":" + std::to_string(d); + return ret.c_str(); +} + SPV3D_Prs *SPV3D_Prs::deepCopy() const { SPV3D_Prs *ret = new SPV3D_Prs( *this ); @@ -65,49 +210,6 @@ pqProxy *getPQProxy(vtkSMProxy *proxy) return smmodel->findItem(proxy); } -void SPV3D_Prs::FillUsingActor(vtkActor *actor) const -{ - SPV3D_EXPORTSPV3DData *alreadyExistingSrc = nullptr; - alreadyExistingSrc = _view->isEntryAlreadyExist( GetEntry() ); - if(alreadyExistingSrc && !alreadyExistingSrc->GetSourceProducer()) - { - actor->GetMapper()->Update(); - vtkDataObject *ds = actor->GetMapper()->GetInput(); - vtkPolyData *ds3 = vtkPolyData::SafeDownCast(ds); - vtkNew ds4; - if(ds3) - { - ds4->ShallowCopy( ds3 ); - vtkNew solidIdArray; - auto nbCells( ds4->GetNumberOfCells() ); - solidIdArray->SetNumberOfComponents(1); - solidIdArray->SetNumberOfTuples( nbCells ); - solidIdArray->SetName("Solid id"); - vtkIdType *pt( solidIdArray->GetPointer(0) ); - std::for_each(pt,pt+nbCells,[](vtkIdType& elt) { elt = 0; }); - ds4->GetCellData()->AddArray( solidIdArray ); - } - // - 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(ds4); - mySourceProducer->updatePipeline(); - pqProxy *producerBase2( getPQProxy(producerBase) ); - if(producerBase2 && !_name.empty()) - producerBase2->rename( _name.c_str() ); - this->SetSourceProducer( mySourceProducer ); - } - else - { - this->CopyInfo( alreadyExistingSrc ); - } -} - SPV3D_Prs:: ~SPV3D_Prs() { } @@ -117,20 +219,33 @@ 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) - return _pvRendInfo->IsNull(); + { + unsigned int id; + return !_pvRendInfo->havePrs(GetEntry(),id); + } return true; } +void SPV3D_Prs::FillUsingActor(vtkActor *actor) const +{ + std::cout << "Hello FillUsingActor"<isEntryAlreadyExist( GetEntry() ); + if(id == -1) // not exist + { + actor->GetMapper()->Update(); + vtkDataObject *ds = actor->GetMapper()->GetInput(); + vtkPolyData *ds2 = vtkPolyData::SafeDownCast(ds); + if(ds2) + { + _view->ExportToSPV3D(ds2, GetEntry()); + } + } + else + { + qWarning() << "Geometry Object is already in viewer window"; + } +} diff --git a/src/SPV3D/SPV3D_Prs.h b/src/SPV3D/SPV3D_Prs.h index 2cba496a0..191fd556b 100644 --- a/src/SPV3D/SPV3D_Prs.h +++ b/src/SPV3D/SPV3D_Prs.h @@ -22,6 +22,12 @@ #include "SPV3D.h" #include "SALOME_Prs.h" +#include "vtkPolyData.h" +#include "vtkCellData.h" +#include +#include + +#include class vtkActor; class pqPipelineSource; class pqDataRepresentation; @@ -29,21 +35,32 @@ class pqDataRepresentation; class SPV3D_EXPORTSPV3DData { public: - SPV3D_EXPORTSPV3DData() = default; + SPV3D_EXPORTSPV3DData(); SPV3D_EXPORTSPV3DData *deepCopy() { return new SPV3D_EXPORTSPV3DData(*this); } - void SetSourceProducer(pqPipelineSource *sourceProducer) const { _sourceProducer = sourceProducer; } + void SetPrs(vtkPolyData* ds, const char* entry); + void SetPolyData(vtkPolyData* ds); + void RemovePrs(const char* entry); + + // the source producer is initialized in the instantiation of SPV3D_EXPORTSPV3DData + // Normaly, we shouldn't copy another src in SPV3D_EXPORTSPV3DData + //void SetSourceProducer(pqPipelineSource *sourceProducer) const { _sourceProducer = sourceProducer; } pqPipelineSource *GetSourceProducer() const { return _sourceProducer; } void SetRepresentation(pqDataRepresentation *repr) const { _repr = repr; } pqDataRepresentation *GetRepresentation() const { return _repr; } + void updateSource_for_display(); bool IsNull() const { return !_sourceProducer && !_repr; } bool IsVisible() const; + bool havePrs(const char* entry, unsigned int & id); void Hide() const; + private: SPV3D_EXPORTSPV3DData(const SPV3D_EXPORTSPV3DData& other) = default; private: + vtkSmartPointer _multiGEOMData; + vtkIdType nbsolid; mutable pqPipelineSource *_sourceProducer = nullptr; mutable pqDataRepresentation *_repr = nullptr; }; @@ -64,24 +81,26 @@ public: void DisplayIn( SALOME_View* v ) const override; - void CopyInfo(SPV3D_EXPORTSPV3DData *info) const; - void SetPVRenderInfo(SPV3D_EXPORTSPV3DData *pvRendInfo) { _pvRendInfo = pvRendInfo; } - void SetSourceProducer(pqPipelineSource *sourceProducer) const { if(_pvRendInfo) _pvRendInfo->SetSourceProducer(sourceProducer); } + // the source producer is initialized in the instantiation of SPV3D_EXPORTSPV3DData + // Normaly, we shouldn't copy another src in SPV3D_EXPORTSPV3DData + //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 { if(_pvRendInfo) _pvRendInfo->SetRepresentation(repr); } pqDataRepresentation *GetRepresentation() const { if(_pvRendInfo) return _pvRendInfo->GetRepresentation(); return nullptr; } bool IsNull() const override; + static vtkIdType FromEntryToVtkId (const char*); + static const char* FromVtkIdToEntry (vtkIdType); private: SPV3D_Prs(const SPV3D_Prs& other) = default; public: - void hide() const { if(_pvRendInfo) return _pvRendInfo->Hide(); } + void hide() const { if(_pvRendInfo) return _pvRendInfo->RemovePrs(GetEntry()); } bool isVisible() const { if(_pvRendInfo) return _pvRendInfo->IsVisible(); return false; } private: @@ -90,4 +109,7 @@ private: SPV3D_ViewWindow *_view = nullptr; //! Name attached to the displayable object in the study std::string _name; + static vtkIdType cellid; + static vtkIdType nbsolid; + }; diff --git a/src/SPV3D/SPV3D_ViewModel.cxx b/src/SPV3D/SPV3D_ViewModel.cxx index 30b4f1e2e..90cae0b6a 100644 --- a/src/SPV3D/SPV3D_ViewModel.cxx +++ b/src/SPV3D/SPV3D_ViewModel.cxx @@ -21,12 +21,12 @@ #include #include #include +#include #include #include "SPV3D_ViewModel.h" #include "SPV3D_ViewWindow.h" -#include "SPV3D_Prs.h" #include "PVViewer_Core.h" #include @@ -196,6 +196,28 @@ pqView *SPV3D_ViewModel::getView() const return _view; } +void SPV3D_ViewModel::updatePVPrsPipeline(const SPV3D_Prs* aPrs) +{ + if (aPrs->GetRepresentation()) + { + aPrs->GetRepresentation()->setVisible(0); + delete(aPrs->GetRepresentation()); + } + pqObjectBuilder *builder(pqApplicationCore::instance()->getObjectBuilder()); + pqActiveObjects::instance().setActiveView(getView()); + pqPipelineSource *mySourceProducer = aPrs->GetSourceProducer(); + pqDataRepresentation* myRepr(builder->createDataRepresentation(mySourceProducer->getOutputPort(0),getView(),"CADRepresentation"));//"GeometryRepresentation" + vtkSMViewProxy::RepresentationVisibilityChanged(myRepr->getViewProxy(), myRepr->getProxy(), true); + aPrs->SetRepresentation(myRepr); + myRepr->setVisible(1); + vtkSMPVRepresentationProxy* proxy(dynamic_cast(myRepr->getProxy())); + if(proxy) + { + vtkSMPropertyHelper inputHelper(proxy, "Input"); + vtkSMSourceProxy* input = vtkSMSourceProxy::SafeDownCast(inputHelper.GetAsProxy()); + input->UpdatePipeline(); + } +} /*! Display presentation \param prs - presentation @@ -204,28 +226,14 @@ void SPV3D_ViewModel::Display( const SALOME_PV3DPrs* prs ) { if(const SPV3D_Prs* aPrs = dynamic_cast( prs )) { - if( !aPrs->GetRepresentation() ) - { - pqObjectBuilder *builder(pqApplicationCore::instance()->getObjectBuilder()); - pqActiveObjects::instance().setActiveView(getView()); - pqPipelineSource *mySourceProducer = aPrs->GetSourceProducer(); - aPrs->SetSourceProducer( mySourceProducer ); - pqDataRepresentation* myRepr(builder->createDataRepresentation(mySourceProducer->getOutputPort(0),getView(),"CADRepresentation"));//"GeometryRepresentation" - vtkSMViewProxy::RepresentationVisibilityChanged(myRepr->getViewProxy(), myRepr->getProxy(), true); - aPrs->SetRepresentation(myRepr); - } - pqDataRepresentation* myRepr = aPrs->GetRepresentation(); - myRepr->setVisible(1); - vtkSMPVRepresentationProxy* proxy(dynamic_cast(myRepr->getProxy())); - if(proxy) - { - vtkSMPropertyHelper inputHelper(proxy, "Input"); - vtkSMSourceProxy* input = vtkSMSourceProxy::SafeDownCast(inputHelper.GetAsProxy()); - input->UpdatePipeline(); - } + updatePVPrsPipeline(aPrs); getView()->resetDisplay(); getView()->render(); } + else + { + qWarning()<< "SPV3D_ViewModel::Display: Something wrong"; + } } /*! @@ -239,11 +247,10 @@ void SPV3D_ViewModel::Erase( const SALOME_PV3DPrs* prs, const bool /*forced*/ ) if(const SPV3D_Prs* aPrs = dynamic_cast( prs )){ if(aPrs->IsNull()) return; - aPrs->GetRepresentation()->setVisible(0); + aPrs->hide(); + updatePVPrsPipeline(aPrs); + getView()->resetDisplay(); getView()->render(); - //pqObjectBuilder* builder = pqApplicationCore::instance()->getObjectBuilder(); - //pqServer* activeServer = pqActiveObjects::instance().activeServer(); - //builder->destroySources(activeServer); } } diff --git a/src/SPV3D/SPV3D_ViewModel.h b/src/SPV3D/SPV3D_ViewModel.h index dc982345e..3daf72d7e 100644 --- a/src/SPV3D/SPV3D_ViewModel.h +++ b/src/SPV3D/SPV3D_ViewModel.h @@ -26,6 +26,9 @@ #include #include +#include "SPV3D_Prs.h" + + class QMouseEvent; class pqPipelineSource; class pqView; @@ -62,7 +65,7 @@ public: public: void enableSelection(bool isEnabled); bool isSelectionEnabled() const { return mySelectionEnabled; } - + void updatePVPrsPipeline( const SPV3D_Prs* aPrs); /* Reimplemented from SALOME_View */ //! See #SALOME_View::Display( const SALOME_Prs* ) diff --git a/src/SPV3D/SPV3D_ViewWindow.cxx b/src/SPV3D/SPV3D_ViewWindow.cxx index 5837461f2..b4e04f9b5 100644 --- a/src/SPV3D/SPV3D_ViewWindow.cxx +++ b/src/SPV3D/SPV3D_ViewWindow.cxx @@ -114,6 +114,9 @@ void SPV3D_ViewWindow::init() QAction *selectionAction = toolMgr()->toolBar(myToolBar)->addAction(SUIT_Session::session()->resourceMgr()->loadPixmap( "VTKViewer", tr( "ICON_SVTK_PRESELECTION_STANDARD" ) ), tr( "MNU_SVTK_PRESELECTION_STANDARD" ) ); selectionAction->setCheckable(true); QObject::connect(selectionAction, &QAction::toggled, this, &SPV3D_ViewWindow::goSelect); + + SPV3D_EXPORTSPV3DData* rawPtr = new SPV3D_EXPORTSPV3DData(); + myPrs.reset(rawPtr); } void SPV3D_ViewWindow::goSelect(bool val) @@ -125,15 +128,12 @@ void SPV3D_ViewWindow::goSelect(bool val) { return; } - for(const auto& elt : myPrs) + pqPipelineSource *geometrySource = myPrs->GetSourceProducer(); + if(geometrySource) { - pqPipelineSource *geometrySource = elt.second->GetSourceProducer(); - if(geometrySource) - { - vtkSMProxy* repr = activeView->getViewProxy()->FindRepresentation( - geometrySource->getSourceProxy(), 0); - repr->InvokeCommand("Reset"); - } + vtkSMProxy* repr = activeView->getViewProxy()->FindRepresentation( + geometrySource->getSourceProxy(), 0); + repr->InvokeCommand("Reset"); } activeView->forceRender(); activeView->render(); @@ -234,34 +234,26 @@ void SPV3D_ViewWindow::showCenterAxes(bool show_axes) renderView->render(); } + SPV3D_Prs *SPV3D_ViewWindow::findOrCreatePrs( const char* entry ) -{ - std::string entryCpp( entry ); +{//en cours SPV3D_Prs *prsOut( new SPV3D_Prs( entry, this ) ); - for(auto& prs : myPrs) - { - if(entryCpp == prs.first) - { - prsOut->SetPVRenderInfo( prs.second.get() ); - return prsOut; - } - } - std::unique_ptr data(new SPV3D_EXPORTSPV3DData); - prsOut->SetPVRenderInfo( data.get() ); - std::pair > p(entryCpp,std::move(data)); - myPrs.emplace_back( std::move(p) ); + prsOut->SetPVRenderInfo( myPrs.get() ); return prsOut; } -SPV3D_EXPORTSPV3DData *SPV3D_ViewWindow::isEntryAlreadyExist( const char* entry ) const +unsigned int 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; + unsigned int id; + if(myPrs->havePrs(entry, id)) + return id; + else + return -1; +} + +void SPV3D_ViewWindow::ExportToSPV3D(vtkPolyData* ds, const char* entry) +{ + myPrs->SetPrs(ds, entry); } /*! @@ -273,11 +265,11 @@ SPV3D_ViewWindow::~SPV3D_ViewWindow() bool SPV3D_ViewWindow::isVisible(const Handle(SALOME_InteractiveObject)& theIObject) { - std::string entryCpp( theIObject->getEntry() ); - for(auto& prs : myPrs) + auto entry = theIObject->getEntry(); + unsigned int id; + if (myPrs->havePrs(entry, id)) { - if(entryCpp == prs.first ) - return prs.second->IsVisible(); + return true; } return false; } @@ -323,10 +315,7 @@ void SPV3D_ViewWindow::DisplayAll() */ void SPV3D_ViewWindow::EraseAll() { - for(auto& prs : myPrs) - { - prs.second->Hide(); - } + myPrs->Hide(); if(myModel) myModel->render(); } diff --git a/src/SPV3D/SPV3D_ViewWindow.h b/src/SPV3D/SPV3D_ViewWindow.h index 084d4268b..fb546dc78 100644 --- a/src/SPV3D/SPV3D_ViewWindow.h +++ b/src/SPV3D/SPV3D_ViewWindow.h @@ -48,7 +48,9 @@ class SPV3D_EXPORT SPV3D_ViewWindow : public PV3DViewer_ViewWindow SPV3D_Prs *findOrCreatePrs( const char* entry ); - SPV3D_EXPORTSPV3DData *isEntryAlreadyExist( const char* entry ) const; + unsigned int isEntryAlreadyExist( const char* entry ) const; + + void ExportToSPV3D(vtkPolyData* ds, const char*); void init(); @@ -104,7 +106,9 @@ protected: SPV3D_CADSelection *mySelection = nullptr; int myToolBar = -1; SPV3D_ViewModel* myModel; - std::list< std::pair > > myPrs; + //std::list< std::pair > > myPrs; + std::list< std::pair > Prs; + std::unique_ptr myPrs; }; #ifdef WIN32