]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Second integration of PV3D viewer: duc/Viewerunique_integre1 V9_13_0b1
authorDUC ANH HOANG <dh77501n@dsp1043837>
Tue, 4 Jun 2024 12:08:35 +0000 (14:08 +0200)
committerDUC ANH HOANG <dh77501n@dsp1043837>
Thu, 20 Jun 2024 15:02:42 +0000 (17:02 +0200)
   Correction of the Presentation pipeline updating
   Correction of the CAD selection(setup solid_id with entry)
   Get preselect solidID (entry) from client

src/SPV3D/SPV3D_CADSelection.cxx
src/SPV3D/SPV3D_Prs.cxx
src/SPV3D/SPV3D_Prs.h
src/SPV3D/SPV3D_ViewModel.cxx
src/SPV3D/SPV3D_ViewModel.h
src/SPV3D/SPV3D_ViewWindow.cxx
src/SPV3D/SPV3D_ViewWindow.h

index cd7820cf90d17cc61375b08258e7f25ca775c3d2..2cf4d17515a86eaaf3c751bc9f1988c34a0904b1 100644 (file)
 #include <vtkSMRepresentationProxy.h>
 #include <vtkPVDataSetAttributesInformation.h>
 
+#include <QDebug>
+
+#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);
+  
 }
 
 //-----------------------------------------------------------------------------
index 8e8637cc5d9a03a2e370ffe6652aa68305e7d37b..210d89a502095f868d4fd2e8f3ccb5d22b4f505b 100644 (file)
@@ -23,6 +23,7 @@
 #include "SPV3D_Prs.h"
 #include "SPV3D_ViewWindow.h"
 
+#include <vtkAppendPolyData.h>
 #include "vtkActor.h"
 #include "vtkPolyData.h"
 #include "vtkCellData.h"
 #include "vtkPVTrivialProducer.h"
 #include <pqDataRepresentation.h>
 
+#include <QDebug>
+
+vtkIdType SPV3D_Prs::cellid = 0;
+vtkIdType SPV3D_Prs::nbsolid = 0;
+
+SPV3D_EXPORTSPV3DData::SPV3D_EXPORTSPV3DData()
+{
+  nbsolid = 0;
+  _multiGEOMData = vtkSmartPointer<vtkMultiBlockDataSet>::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<vtkIdTypeArray> solidIdArray;
+  qInfo() << "nb of cells: " << nbCells;
+  solidIdArray->SetNumberOfComponents(1);
+  solidIdArray->SetNumberOfTuples( nbCells );
+  solidIdArray->SetName("Solid id");
+
+//  vtkNew<vtkIdTypeArray> 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<vtkAppendPolyData> 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<vtkPolyData> 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<pqProxy*>(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<vtkIdType> (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<pqProxy*>(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<vtkPolyData> ds4;
-    if(ds3)
-    {
-      ds4->ShallowCopy( ds3 );
-      vtkNew<vtkIdTypeArray> 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"<<std::endl;
+  int id = _view->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";
+  }
+}
index 2cba496a03867a265d3316c5a1044fe3f4806f94..191fd556b839e2e69c38b8308ab46476db00f79e 100644 (file)
 #include "SPV3D.h"
 #include "SALOME_Prs.h"
 
+#include "vtkPolyData.h"
+#include "vtkCellData.h"
+#include <vtkMultiBlockDataSet.h>
+#include <vtkSmartPointer.h>
+
+#include <set>
 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<vtkMultiBlockDataSet> _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;
+
 };
index 30b4f1e2e87920270ec9efb5682979ecde6e76e5..90cae0b6a96f122486d227e3fde2391db441121b 100644 (file)
 #include <QColorDialog>
 #include <QToolBar>
 #include <QTimer>
+#include <QDebug>
 
 #include <vtkActorCollection.h>
 
 #include "SPV3D_ViewModel.h"
 #include "SPV3D_ViewWindow.h"
-#include "SPV3D_Prs.h"
 #include "PVViewer_Core.h"
 
 #include <pqActiveObjects.h>
@@ -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<vtkSMPVRepresentationProxy*>(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<const SPV3D_Prs*>( 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<vtkSMPVRepresentationProxy*>(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<const SPV3D_Prs*>( 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);
   }
 }
 
index dc982345e58fa6c12c6b44ab6b2cb534b645f5d8..3daf72d7ee320a4ee23b66f2a8e53ceccdb69ce4 100644 (file)
@@ -26,6 +26,9 @@
 #include <SALOME_InteractiveObject.hxx>
 #include <SALOME_ListIO.hxx>
 
+#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* )
index 5837461f2335ae716143a140118b7a41f0e4a28a..b4e04f9b55f94597d70517340a9bfa8670c6b71c 100644 (file)
@@ -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<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) );
+  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();
 }
index 084d4268b2134cca52ff18232b2f70ae9dc08f9a..fb546dc784a0e4bf644d93b4b7b6ba12532bd975 100644 (file)
@@ -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<std::string, std::unique_ptr<SPV3D_EXPORTSPV3DData> > > myPrs;
+  //std::list< std::pair<std::string, std::unique_ptr<SPV3D_EXPORTSPV3DData> > > myPrs;
+  std::list< std::pair<std::string, SPV3D_Prs* > > Prs;
+  std::unique_ptr<SPV3D_EXPORTSPV3DData> myPrs;
 };
 
 #ifdef WIN32