]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
in progress 1
authorDUC ANH HOANG <dh77501n@dsp1043837>
Thu, 13 Jun 2024 15:54:09 +0000 (17:54 +0200)
committerDUC ANH HOANG <dh77501n@dsp1043837>
Thu, 13 Jun 2024 15:54:09 +0000 (17:54 +0200)
src/SPV3D/SPV3D_Prs.cxx
src/SPV3D/SPV3D_Prs.h
src/SPV3D/SPV3D_ViewWindow.cxx

index cad22e9887b190c6816899ffea494f6bd33d4545..90d8a1b2a3dc5bd44d0599152e59cfbcad3ded1c 100644 (file)
@@ -40,7 +40,7 @@
 
 vtkIdType SPV3D_Prs::cellid = 0;
 vtkIdType SPV3D_Prs::nbsolid = 0;
-std::map<vtkIdType, const char*> SPV3D_Prs::vtkIdToEntry;
+//std::map<vtkIdType, const char*> SPV3D_Prs::vtkIdToEntry;
 vtkSmartPointer<vtkMultiBlockDataSet> SPV3D_Prs::multiGEOMData = vtkSmartPointer<vtkMultiBlockDataSet>::New();
 
 SPV3D_EXPORTSPV3DData::SPV3D_EXPORTSPV3DData()
@@ -50,6 +50,8 @@ SPV3D_EXPORTSPV3DData::SPV3D_EXPORTSPV3DData()
   pqServer *serv(pqApplicationCore::instance()->getServerManagerModel()->findServer(pqServerResource("builtin:")));
   pqObjectBuilder *builder(pqApplicationCore::instance()->getObjectBuilder());
   _sourceProducer = builder->createSource("sources","PVTrivialProducer",serv);
+  _repr = builder->createDataRepresentation(_sourceProducer->getOutputPort(0),getView(),"CADRepresentation");
+  vtkSMViewProxy::RepresentationVisibilityChanged(_repr->getViewProxy(), _repr->getProxy(), true);
 }
 void SPV3D_EXPORTSPV3DData::SetPolyData(vtkPolyData* ds)
 {
@@ -96,9 +98,10 @@ void SPV3D_EXPORTSPV3DData::RemovePrs(const char* entry)
   }
     return;
   _multiGEOMData->RemoveBlock(id);
+  Hide_list.erase(SPV3D_Prs::FromEntryToVtkId(entry));
 }
 
-void SPV3D_EXPORTSPV3DData::updateSource() const
+void SPV3D_EXPORTSPV3DData::updateSource_for_display() const
 {
   vtkNew<vtkAppendPolyData> appendFilter;
   std::cout <<"number of block: " << _multiGEOMData->GetNumberOfBlocks()<<std::endl;
@@ -107,7 +110,9 @@ void SPV3D_EXPORTSPV3DData::updateSource() const
       vtkPolyData* polyData = vtkPolyData::SafeDownCast(_multiGEOMData->GetBlock(i));
       if (polyData)
       {
-        appendFilter->AddInputData(polyData);
+        vtkIdTypeArray* retrievedArray = vtkIdTypeArray::SafeDownCast(polyData->GetCellData()->GetArray("Solid id"));
+        if (retrievedArray && !Hide_list.find(retrievedArray->GetValue(0)))
+          appendFilter->AddInputData(polyData);
       }
   }
   appendFilter->Update();
@@ -132,9 +137,9 @@ bool SPV3D_EXPORTSPV3DData::IsVisible() const
   return GetRepresentation()->isVisible();
 }
 
-bool SPV3D_EXPORTSPV3DData::SolidIsVisible(vtkidtype solid_id) const
+bool SPV3D_EXPORTSPV3DData::SolidIsVisible(vtkIdType solid_id) const
 {
-  if( std::find(Hide_list.begin(), Hide_list.end(), solid_id) )
+  if( Hide_list.find(solid_id) )
     return false;
   return true
 }
@@ -148,7 +153,7 @@ bool SPV3D_EXPORTSPV3DData::havePrs(const char* entry, unsigned int & id)
       vtkPolyData* polyData = vtkPolyData::SafeDownCast(_multiGEOMData->GetBlock(id));
       if (polyData)
       {
-        vtkIdTypeArray* retrievedArray = vtkIdTypeArray::SafeDownCast(toto->GetCellData()->GetArray("Solid id"));
+        vtkIdTypeArray* retrievedArray = vtkIdTypeArray::SafeDownCast(polyData->GetCellData()->GetArray("Solid id"));
         if (retrievedArray && retrievedArray->GetValue(0) == solid_id)
           break;
       }
@@ -161,9 +166,23 @@ bool SPV3D_EXPORTSPV3DData::havePrs(const char* entry, unsigned int & id)
     return false;
 }
 
-void SPV3D_EXPORTSPV3DData::Hide(vtkditype solid_id)
+void SPV3D_EXPORTSPV3DData::HideSolid(vtkIdType solid_id)
 {
-  Hide_list.push_back(solid_id);
+  auto ret = Hide_list.emplace(solid_id);
+  if (!ret.second)
+    std::cout << SPV3D_Prs::FromVtkIdToEntry(solid_id) << " already exists in Hide_list\n" << std::endl;
+}
+
+void SPV3D_EXPORTSPV3DData::DisplaySolid(vtkIdType solid_id)
+{
+  if (SolidIsVisible(solid_id))
+  {
+    Hide_list.erase(solid_id);
+  }
+  else
+  {
+    std::cout << SPV3D_Prs::FromVtkIdToEntry(solid_id) << " is not in Hide_list\n" << std::endl;
+  }
 }
 
 void SPV3D_EXPORTSPV3DData::Hide() const
@@ -220,7 +239,7 @@ pqProxy *getPQProxy(vtkSMProxy *proxy)
   return smmodel->findItem<pqProxy*>(proxy);
 }
 
-void SPV3D_Prs::FillUsingActor(vtkActor *actor) const
+void SPV3D_Prs::FillUsingActor_init(vtkActor *actor) const
 {
   std::cout << "Hello FillUsingActor"<<std::endl;
 
@@ -325,3 +344,22 @@ bool SPV3D_Prs::IsNull() const
 }
 
 
+
+
+
+void SPV3D_Prs::FillUsingActor(vtkActor *actor) const
+{
+  std::cout << "Hello FillUsingActor"<<std::endl;
+
+  //SPV3D_EXPORTSPV3DData *alreadyExistingSrc = nullptr;
+  alreadyExisting = _view->isEntryAlreadyExist( GetEntry() );
+
+  if(alreadyExisting) // hide but it exist in SPV3D_EXPORTSPV3DData
+  {
+
+  }
+  else
+  {
+    this->CopyInfo( alreadyExistingSrc );
+  }
+}
\ No newline at end of file
index a4acfcb93cc621750f977408f0152420a05b59b0..8c5cecd288bc951b5b98280ac25cbdacb8a3e6d3 100644 (file)
@@ -33,7 +33,7 @@ class pqDataRepresentation;
 class SPV3D_EXPORTSPV3DData
 {
 public:
-  SPV3D_EXPORTSPV3DData():nbsolid(0),_multiGEOMData( vtkSmartPointer<vtkMultiBlockDataSet>::New()){};
+  SPV3D_EXPORTSPV3DData();
   SPV3D_EXPORTSPV3DData *deepCopy() { return new SPV3D_EXPORTSPV3DData(*this); }
   void SetPrs(vtkPolyData* ds, const char* entry);
   void SetPolyData(vtkPolyData* ds);
@@ -44,13 +44,14 @@ public:
   void SetRepresentation(pqDataRepresentation *repr) const { _repr = repr; }
   pqDataRepresentation *GetRepresentation() const { return _repr; }
   
-  void updateSource();
+  void updateSource_for_display();
   bool IsNull() const { return !_sourceProducer && !_repr; }
 
   bool IsVisible() const;
   bool havePrs(const char* entry, unsigned int & id);
   void Hide() const;
-  void Hide(vtkIdType solid_id);
+  void HideSolid(vtkIdType solid_id);
+  void DisplaySolid(vtkIdType solid_id);
   bool SolidIsVisible(vtkIdType solid_id) const;
 
 private:
@@ -58,7 +59,7 @@ private:
 private:
   vtkSmartPointer<vtkMultiBlockDataSet> _multiGEOMData;
   vtkIdType nbsolid;
-  std::list<vtkIdType> Hide_list;
+  std::set<vtkIdType> Hide_list;
   mutable pqPipelineSource *_sourceProducer = nullptr;
   mutable pqDataRepresentation *_repr = nullptr;
 };
@@ -109,7 +110,7 @@ private:
   std::string _name;
   static vtkIdType cellid;
   static vtkIdType nbsolid;
-  static std::map<vtkIdType,const char*> vtkIdToEntry;
+  //static std::map<vtkIdType,const char*> vtkIdToEntry;
   static vtkSmartPointer<vtkMultiBlockDataSet> multiGEOMData;
 
 };
index ba1eef9900a84f6cb2b66d459ebbe7a80b037fd0..191044a43eac4d025302ad37cbf118fc790e8f55 100644 (file)
@@ -253,13 +253,22 @@ SPV3D_Prs *SPV3D_ViewWindow::findOrCreatePrs( const char* entry )
 
 SPV3D_EXPORTSPV3DData *SPV3D_ViewWindow::isEntryAlreadyExist( const char* entry ) const
 {
-  std::string entryCpp( entry );
-  for(const auto& prs : myPrs)
+  //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))
   {
-    if(entryCpp == prs.first)
-      return prs.second.get();
+
+  }
+  else
+  {
+    return nullptr;
   }
-  return nullptr;
 }
 
 /*!