From 0007a1f17197c7f12ce4fdeb038fcf0f62f337d9 Mon Sep 17 00:00:00 2001 From: =?utf8?q?L=C3=A9on=20Victor?= Date: Thu, 5 Sep 2024 15:16:41 +0200 Subject: [PATCH] Client->Server selection communication --- src/SPV3D/SPV3D_CADSelection.cxx | 42 +++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/src/SPV3D/SPV3D_CADSelection.cxx b/src/SPV3D/SPV3D_CADSelection.cxx index a4278490d..5d999ff60 100644 --- a/src/SPV3D/SPV3D_CADSelection.cxx +++ b/src/SPV3D/SPV3D_CADSelection.cxx @@ -505,6 +505,8 @@ std::set SPV3D_CADSelection::GetSelectedObEntry() std::vector selectedIdx = vtkSMPropertyHelper(proxyRepresentation,"SelectedIDInfo").GetIntArray(); + std::cout << "(Client) Received selected entries from server:" << std::endl; + if (selectedIdx.empty()) { qWarning() << "There is no selected id for now."; @@ -513,7 +515,10 @@ std::set SPV3D_CADSelection::GetSelectedObEntry() { // Convert all selectedId from Representation in entry type and insert them in set for(std::size_t i = 0; i < selectedIdx.size(); i++) + { + std::cout << selectedIdx[i] << std::endl; EntryList.insert( SPV3D_Prs::FromVtkIdToEntry(static_cast(selectedIdx[i])) ); + } } return EntryList; @@ -521,22 +526,31 @@ std::set SPV3D_CADSelection::GetSelectedObEntry() void SPV3D_CADSelection::SetSelectionFromEntrySet(std::set EntryList) { - // Solid Ids list to be provided to server - std::vector SolidIds; - for (std::string entry : EntryList) - SolidIds.push_back( SPV3D_Prs::FromEntryToVtkId(entry.c_str()) ); - - if (this->Representation == nullptr) - { + if (this->Representation == nullptr) { qWarning() << "There is no pqDataRepresentation"; + return; } - return ; + vtkSMProxy* proxyRepresentation = this->Representation->getProxy(); - if (!proxyRepresentation) + if (!proxyRepresentation) + { + qWarning() << "There is no representation"; + return; + } + + std::cout << "(Client) Sending selected entries to server:" << std::endl; + + // Retrieve entry ids and put them in a vector + std::vector selectedIds; + selectedIds.reserve(EntryList.size()); + for (const std::string& entryName: EntryList) { - qWarning()<< "There is no representation"; + vtkIdType id = SPV3D_Prs::FromEntryToVtkId(entryName.c_str()); + std::cout << "(Client) " << id << std::endl; + selectedIds.push_back(id); } - //TODO: - // Send SolidIds vector to server - // On server update the Selection with this SolidIds -} \ No newline at end of file + + vtkSMProperty* selectedIDsProperty = proxyRepresentation->GetProperty("SelectedIDs"); + vtkSMPropertyHelper(selectedIDsProperty).Set(selectedIds.data(), selectedIds.size()); + proxyRepresentation->UpdateVTKObjects(); +} -- 2.39.2