From: DUC ANH HOANG Date: Thu, 13 Jun 2024 15:54:09 +0000 (+0200) Subject: in progress 1 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=9e6f08f0a67594934313d65f89bb225653d3b065;p=modules%2Fgui.git in progress 1 --- diff --git a/src/SPV3D/SPV3D_Prs.cxx b/src/SPV3D/SPV3D_Prs.cxx index cad22e988..90d8a1b2a 100644 --- a/src/SPV3D/SPV3D_Prs.cxx +++ b/src/SPV3D/SPV3D_Prs.cxx @@ -40,7 +40,7 @@ vtkIdType SPV3D_Prs::cellid = 0; vtkIdType SPV3D_Prs::nbsolid = 0; -std::map SPV3D_Prs::vtkIdToEntry; +//std::map SPV3D_Prs::vtkIdToEntry; vtkSmartPointer SPV3D_Prs::multiGEOMData = vtkSmartPointer::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 appendFilter; std::cout <<"number of block: " << _multiGEOMData->GetNumberOfBlocks()<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(proxy); } -void SPV3D_Prs::FillUsingActor(vtkActor *actor) const +void SPV3D_Prs::FillUsingActor_init(vtkActor *actor) const { std::cout << "Hello FillUsingActor"<isEntryAlreadyExist( GetEntry() ); + + if(alreadyExisting) // hide but it exist in SPV3D_EXPORTSPV3DData + { + + } + else + { + this->CopyInfo( alreadyExistingSrc ); + } +} \ No newline at end of file diff --git a/src/SPV3D/SPV3D_Prs.h b/src/SPV3D/SPV3D_Prs.h index a4acfcb93..8c5cecd28 100644 --- a/src/SPV3D/SPV3D_Prs.h +++ b/src/SPV3D/SPV3D_Prs.h @@ -33,7 +33,7 @@ class pqDataRepresentation; class SPV3D_EXPORTSPV3DData { public: - SPV3D_EXPORTSPV3DData():nbsolid(0),_multiGEOMData( vtkSmartPointer::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 _multiGEOMData; vtkIdType nbsolid; - std::list Hide_list; + std::set 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 vtkIdToEntry; + //static std::map vtkIdToEntry; static vtkSmartPointer multiGEOMData; }; diff --git a/src/SPV3D/SPV3D_ViewWindow.cxx b/src/SPV3D/SPV3D_ViewWindow.cxx index ba1eef990..191044a43 100644 --- a/src/SPV3D/SPV3D_ViewWindow.cxx +++ b/src/SPV3D/SPV3D_ViewWindow.cxx @@ -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; } /*!