From: DUC ANH HOANG Date: Tue, 4 Jun 2024 12:08:35 +0000 (+0200) Subject: Mouseover fix X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=5ab0e9b97be406bfa65e02e8f8e3152080e17c0c;p=modules%2Fgui.git Mouseover fix --- diff --git a/src/SPV3D/SPV3D_Prs.cxx b/src/SPV3D/SPV3D_Prs.cxx index 8e8637cc5..a3b1db7f4 100644 --- a/src/SPV3D/SPV3D_Prs.cxx +++ b/src/SPV3D/SPV3D_Prs.cxx @@ -36,6 +36,33 @@ #include "vtkPVTrivialProducer.h" #include +#include + +vtkIdType SPV3D_Prs::cellid = 0; +vtkIdType SPV3D_Prs::solidid = 0; +vtkSmartPointer SPV3D_Prs::multiGEOMData = vtkSmartPointer::New(); + +static 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(0); + + while (token != NULL) { + ret |= atoi(token); + token = strtok(NULL, delimiter); + } + + return static_cast (ret); +} + + bool SPV3D_EXPORTSPV3DData::IsVisible() const { if( IsNull() ) @@ -67,8 +94,12 @@ pqProxy *getPQProxy(vtkSMProxy *proxy) void SPV3D_Prs::FillUsingActor(vtkActor *actor) const { + std::cout << "Hello FillUsingActor"<isEntryAlreadyExist( GetEntry() ); + std::cout <<"ENtry: " <GetSourceProducer()) { actor->GetMapper()->Update(); @@ -78,24 +109,56 @@ void SPV3D_Prs::FillUsingActor(vtkActor *actor) const if(ds3) { ds4->ShallowCopy( ds3 ); - vtkNew solidIdArray; auto nbCells( ds4->GetNumberOfCells() ); + + vtkNew solidIdArray; + std::cout << "nb of cells: " <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) ); - std::for_each(pt,pt+nbCells,[](vtkIdType& elt) { elt = 0; }); + std::for_each(pt,pt+nbCells,[](vtkIdType& elt) { elt = SPV3D_Prs::solidid;}); + // pt = cellIdArray->GetPointer(0); + // std::for_each(pt,pt+nbCells,[](vtkIdType& elt) { elt = SPV3D_Prs::cellid;SPV3D_Prs::cellid++; }); + ds4->GetCellData()->AddArray( solidIdArray ); + // ds4->GetCellData()->AddArray( cellIdArray ); + ////Add dataset to multiblock +// + SPV3D_Prs::multiGEOMData->SetBlock(SPV3D_Prs::solidid, ds4); +// + SPV3D_Prs::solidid++; + } + + vtkNew appendFilter; + std::cout <<"number of block" << SPV3D_Prs::multiGEOMData->GetNumberOfBlocks()<GetNumberOfBlocks(); ++i) + { + vtkPolyData* polyData = vtkPolyData::SafeDownCast(SPV3D_Prs::multiGEOMData->GetBlock(i)); + if (polyData) + { + appendFilter->AddInputData(polyData); + } } - // + appendFilter->Update(); + vtkNew ds5; + ds5->ShallowCopy(appendFilter->GetOutput()); + pqServer *serv(pqApplicationCore::instance()->getServerManagerModel()->findServer(pqServerResource("builtin:"))); pqObjectBuilder *builder(pqApplicationCore::instance()->getObjectBuilder()); pqPipelineSource *mySourceProducer(builder->createSource("sources","PVTrivialProducer",serv)); - vtkSMProxy *producerBase = mySourceProducer->getProxy(); + vtkSMProxy* producerBase = mySourceProducer->getProxy(); vtkSMSourceProxy *producer(vtkSMSourceProxy::SafeDownCast(producerBase)); + //producer->SetInput(ds4, 0); vtkObjectBase *clientSideObject(producer->GetClientSideObject()); vtkPVTrivialProducer *clientSideObjectCast = vtkPVTrivialProducer::SafeDownCast(clientSideObject); - clientSideObjectCast->SetOutput(ds4); + clientSideObjectCast->SetOutput(ds5); mySourceProducer->updatePipeline(); pqProxy *producerBase2( getPQProxy(producerBase) ); if(producerBase2 && !_name.empty()) diff --git a/src/SPV3D/SPV3D_Prs.h b/src/SPV3D/SPV3D_Prs.h index 2cba496a0..1f7fcaae5 100644 --- a/src/SPV3D/SPV3D_Prs.h +++ b/src/SPV3D/SPV3D_Prs.h @@ -22,6 +22,10 @@ #include "SPV3D.h" #include "SALOME_Prs.h" +#include "vtkPolyData.h" +#include "vtkCellData.h" +#include +#include class vtkActor; class pqPipelineSource; class pqDataRepresentation; @@ -75,6 +79,8 @@ public: 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: @@ -90,4 +96,8 @@ private: SPV3D_ViewWindow *_view = nullptr; //! Name attached to the displayable object in the study std::string _name; + static vtkIdType cellid; + static vtkIdType solidid; + static vtkSmartPointer multiGEOMData; + };