]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
last clean duc/Viewerunique
authorDUC ANH HOANG <dh77501n@dsp1043837>
Thu, 20 Jun 2024 14:07:52 +0000 (16:07 +0200)
committerDUC ANH HOANG <dh77501n@dsp1043837>
Thu, 20 Jun 2024 14:07:52 +0000 (16:07 +0200)
src/SPV3D/SPV3D_Prs.cxx
src/SPV3D/SPV3D_Prs.h
src/SPV3D/SPV3D_ViewModel.cxx
src/SPV3D/SPV3D_ViewWindow.cxx
src/SPV3D/SPV3D_ViewWindow.h

index d6fd8c6febbad8b8d1c4ac5fa991d4c14947b3c6..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 <vtkAppendPolyData.h>
+#include <QDebug>
 
 vtkIdType SPV3D_Prs::cellid = 0;
 vtkIdType SPV3D_Prs::nbsolid = 0;
-//std::map<vtkIdType, const char*> SPV3D_Prs::vtkIdToEntry;
-//vtkSmartPointer<vtkMultiBlockDataSet> SPV3D_Prs::multiGEOMData = vtkSmartPointer<vtkMultiBlockDataSet>::New();
 
 SPV3D_EXPORTSPV3DData::SPV3D_EXPORTSPV3DData()
 {
   nbsolid = 0;
   _multiGEOMData = vtkSmartPointer<vtkMultiBlockDataSet>::New();
-  std::cout << "DDDDDDDDDDDDDDDDDDDDDD" << std::endl;
   pqServer *serv(pqApplicationCore::instance()->getServerManagerModel()->findServer(pqServerResource("builtin:")));
-  std::cout << "AAAAAAAAAAAAAAAAAAAAAa" << std::endl;
   pqObjectBuilder *builder(pqApplicationCore::instance()->getObjectBuilder());
-  std::cout << "BBBBBBBBBBBBBBBBBBBBBB" << std::endl;
   _sourceProducer = builder->createSource("sources","PVTrivialProducer",serv);
-  std::cout << "CCCCCCCCCCCCCCCCCCCCC" << std::endl;
 }
 void SPV3D_EXPORTSPV3DData::SetPolyData(vtkPolyData* ds)
 {
@@ -69,7 +64,7 @@ void SPV3D_EXPORTSPV3DData::SetPrs(vtkPolyData* ds, const char* entry)
   auto nbCells( ds->GetNumberOfCells() );
 
   vtkNew<vtkIdTypeArray> solidIdArray;
-  std::cout << "nb of cells: " <<nbCells <<std::endl;
+  qInfo() << "nb of cells: " << nbCells;
   solidIdArray->SetNumberOfComponents(1);
   solidIdArray->SetNumberOfTuples( nbCells );
   solidIdArray->SetName("Solid id");
@@ -81,7 +76,6 @@ void SPV3D_EXPORTSPV3DData::SetPrs(vtkPolyData* ds, const char* entry)
 
   vtkIdType *pt( solidIdArray->GetPointer(0) );
   vtkIdType solidid = SPV3D_Prs::FromEntryToVtkId(entry);
-  std::cout <<"Presolidid_from_src: " <<solidid << std::endl;
   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++; });
@@ -97,26 +91,25 @@ void SPV3D_EXPORTSPV3DData::RemovePrs(const char* entry)
   unsigned int id;
   if (!havePrs(entry, id))
   {
-    std::cout << "Can not find solid " << entry<< std::endl;
+    qWarning() << "Can not find solid with entry: " << entry;
     return;
   }
   _multiGEOMData->RemoveBlock(id);
   updateSource_for_display();
-  //Hide_list.erase(SPV3D_Prs::FromEntryToVtkId(entry));
 }
 
 void SPV3D_EXPORTSPV3DData::updateSource_for_display()
 {
   vtkNew<vtkAppendPolyData> appendFilter;
   nbsolid = _multiGEOMData->GetNumberOfBlocks();
-  std::cout <<"number of block: " << nbsolid<<std::endl;
+  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 && Hide_list.find(retrievedArray->GetValue(0)) == Hide_list.end())
+        if (retrievedArray)
           appendFilter->AddInputData(polyData);
       }
   }
@@ -144,13 +137,6 @@ bool SPV3D_EXPORTSPV3DData::IsVisible() const
   return GetRepresentation()->isVisible();
 }
 
-bool SPV3D_EXPORTSPV3DData::SolidIsVisible(vtkIdType solid_id) const
-{
-  if( Hide_list.find(solid_id) != Hide_list.end() )
-    return false;
-  return true;
-}
-
 bool SPV3D_EXPORTSPV3DData::havePrs(const char* entry, unsigned int & id)
 {
   vtkIdType solid_id = SPV3D_Prs::FromEntryToVtkId(entry);
@@ -167,34 +153,7 @@ bool SPV3D_EXPORTSPV3DData::havePrs(const char* entry, unsigned int & id)
     id++;
   }
 
-  if (id < _multiGEOMData->GetNumberOfBlocks())
-    return true;
-  else
-    return false;
-}
-
-void SPV3D_EXPORTSPV3DData::HideSolid(vtkIdType 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;
-  const char* entry = SPV3D_Prs::FromVtkIdToEntry(solid_id);
-  std::cout << "entry from vtkidtoentry: "<< entry << std::endl;
-  RemovePrs(entry);
-  updateSource_for_display();
-}
-
-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;
-  }
-  updateSource_for_display();
+  return id < _multiGEOMData->GetNumberOfBlocks();
 }
 
 void SPV3D_EXPORTSPV3DData::Hide() const
@@ -260,48 +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;
-  std::cout << "entry: " <<GetEntry()<< std::endl;
-  //SPV3D_EXPORTSPV3DData *alreadyExistingSrc = nullptr;
   int id = _view->isEntryAlreadyExist( GetEntry() );
 
   if(id == -1) // not exist
   {
-    std::cout << "FillUsingActor111111111111111"<<std::endl;
     actor->GetMapper()->Update();
     vtkDataObject *ds = actor->GetMapper()->GetInput();
     vtkPolyData *ds2 = vtkPolyData::SafeDownCast(ds);
     if(ds2)
     {
-      std::cout << "FillUsingActor2222222222222222éé"<<std::endl;
       _view->ExportToSPV3D(ds2, GetEntry());
     }
   }
-  else //exist but hide
+  else
   {
-    std::cout << "FillUsingActor33333333333333é"<<std::endl;
-    _view->DisplayObj_withEntry( GetEntry() );
+    qWarning() << "Geometry Object is already in viewer window";
   }
-}
\ No newline at end of file
+}
index a320387d84c3eb3a62385c915f83ec7f8da4e6ee..191fd556b839e2e69c38b8308ab46476db00f79e 100644 (file)
@@ -40,7 +40,10 @@ public:
   void SetPrs(vtkPolyData* ds, const char* entry);
   void SetPolyData(vtkPolyData* ds);
   void RemovePrs(const char* entry);
-  void SetSourceProducer(pqPipelineSource *sourceProducer) const { _sourceProducer = 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 { _sourceProducer = sourceProducer; }
   pqPipelineSource *GetSourceProducer() const { return _sourceProducer; }
   
   void SetRepresentation(pqDataRepresentation *repr) const { _repr = repr; }
@@ -52,16 +55,12 @@ public:
   bool IsVisible() const;
   bool havePrs(const char* entry, unsigned int & id);
   void Hide() const;
-  void HideSolid(vtkIdType solid_id);
-  void DisplaySolid(vtkIdType solid_id);
-  bool SolidIsVisible(vtkIdType solid_id) const;
 
 private:
   SPV3D_EXPORTSPV3DData(const SPV3D_EXPORTSPV3DData& other) = default;
 private:
   vtkSmartPointer<vtkMultiBlockDataSet> _multiGEOMData;
   vtkIdType nbsolid;
-  std::set<vtkIdType> Hide_list;
   mutable pqPipelineSource *_sourceProducer = nullptr;
   mutable pqDataRepresentation *_repr = nullptr;
 };
@@ -82,11 +81,11 @@ 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); }
@@ -112,7 +111,5 @@ private:
   std::string _name;
   static vtkIdType cellid;
   static vtkIdType nbsolid;
-  //static std::map<vtkIdType,const char*> vtkIdToEntry;
-  //static vtkSmartPointer<vtkMultiBlockDataSet> multiGEOMData;
 
 };
index 8471c2663925f5c7b9ada83fd48258ec6193316e..90cae0b6a96f122486d227e3fde2391db441121b 100644 (file)
@@ -21,6 +21,7 @@
 #include <QColorDialog>
 #include <QToolBar>
 #include <QTimer>
+#include <QDebug>
 
 #include <vtkActorCollection.h>
 
@@ -205,7 +206,6 @@ void SPV3D_ViewModel::updatePVPrsPipeline(const SPV3D_Prs* aPrs)
   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);
@@ -224,7 +224,6 @@ void SPV3D_ViewModel::updatePVPrsPipeline(const SPV3D_Prs* aPrs)
 */
 void SPV3D_ViewModel::Display( const SALOME_PV3DPrs* prs )
 {
-  std::cout << "SPV3D_ViewModel::Display" << std::endl;
   if(const SPV3D_Prs* aPrs = dynamic_cast<const SPV3D_Prs*>( prs ))
   {
     updatePVPrsPipeline(aPrs);
@@ -233,7 +232,7 @@ void SPV3D_ViewModel::Display( const SALOME_PV3DPrs* prs )
   }
   else
   {
-    std::cout<< "Can't update PV presentation pipeline"<< std::endl;
+    qWarning()<< "SPV3D_ViewModel::Display: Something wrong";
   }
 }
 
index 7f4f302439d95ddd6c7c27d63689293086f39420..b4e04f9b55f94597d70517340a9bfa8670c6b71c 100644 (file)
@@ -244,13 +244,6 @@ SPV3D_Prs *SPV3D_ViewWindow::findOrCreatePrs( const char* entry )
 
 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;
@@ -273,15 +266,10 @@ SPV3D_ViewWindow::~SPV3D_ViewWindow()
 bool SPV3D_ViewWindow::isVisible(const Handle(SALOME_InteractiveObject)& theIObject)
 {
   auto entry =  theIObject->getEntry();
-  //for(auto& prs : myPrs)
-  //{
-  //  if(entryCpp == prs.first )
-  //    return prs.second->IsVisible();
-  //}
   unsigned int id;
   if (myPrs->havePrs(entry, id))
   {
-    return myPrs->SolidIsVisible(SPV3D_Prs::FromEntryToVtkId(entry));
+    return true;
   }
   return false;
 }
@@ -327,10 +315,6 @@ void SPV3D_ViewWindow::DisplayAll()
 */
 void SPV3D_ViewWindow::EraseAll() 
 {
-  //for(auto& prs : myPrs)
-  //{
-  //  prs.second->Hide();
-  //}
   myPrs->Hide();
   if(myModel)
     myModel->render();
@@ -416,13 +400,3 @@ void SPV3D_ViewWindow::hideEvent( QHideEvent * theEvent )
 {
   emit Hide( theEvent );
 }
-
-void SPV3D_ViewWindow::DisplayObj_withEntry(const char* entry)
-{
-  myPrs->DisplaySolid(SPV3D_Prs::FromEntryToVtkId(entry));
-}
-
-void SPV3D_ViewWindow::HideObj_withEntry(const char* entry)
-{
-  myPrs->HideSolid(SPV3D_Prs::FromEntryToVtkId(entry));
-}
\ No newline at end of file
index a0d20b514e6dc39d263a68f95da8290aeccad7b9..fb546dc784a0e4bf644d93b4b7b6ba12532bd975 100644 (file)
@@ -60,8 +60,6 @@ class SPV3D_EXPORT SPV3D_ViewWindow : public PV3DViewer_ViewWindow
 
   /* display */         
   //----------------------------------------------------------------------------
-  void DisplayObj_withEntry(const char* entry);
-  void HideObj_withEntry(const char* entry);
   //! Redirect the request to #SPV3D_View::Display (to support old code)
   virtual void Display(const Handle(SALOME_InteractiveObject)& theIObject,
                        bool theImmediatly = true);