]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
Client->Server selection communication
authorLéon Victor <leon.victor@kitware.com>
Thu, 5 Sep 2024 13:16:41 +0000 (15:16 +0200)
committerLéon Victor <leon.victor@kitware.com>
Thu, 5 Sep 2024 13:16:41 +0000 (15:16 +0200)
src/SPV3D/SPV3D_CADSelection.cxx

index a4278490dcaa4362d0a6f4fc3eac89c036ce97f5..5d999ff60a1788ad6f2d4e23f23343caafb888b8 100644 (file)
@@ -505,6 +505,8 @@ std::set<std::string> SPV3D_CADSelection::GetSelectedObEntry()
   std::vector<int> 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<std::string> 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<vtkIdType>(selectedIdx[i])) );
+    }
   }
   return EntryList;
 
@@ -521,22 +526,31 @@ std::set<std::string> SPV3D_CADSelection::GetSelectedObEntry()
 
 void SPV3D_CADSelection::SetSelectionFromEntrySet(std::set<std::string> EntryList)
 {
-  // Solid Ids list to be provided to server
-  std::vector<vtkIdType> 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<int> 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<vtkIdType> 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();
+}