From: Léon Victor Date: Thu, 5 Sep 2024 13:16:41 +0000 (+0200) Subject: Client->Server selection communication X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=0007a1f17197c7f12ce4fdeb038fcf0f62f337d9;p=modules%2Fgui.git Client->Server selection communication --- 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(); +}