]> SALOME platform Git repositories - modules/gui.git/commitdiff
Salome HOME
WIP: better selection
authorLéon Victor <leon.victor@kitware.com>
Mon, 9 Sep 2024 11:58:40 +0000 (13:58 +0200)
committerLéon Victor <leon.victor@kitware.com>
Mon, 9 Sep 2024 11:58:40 +0000 (13:58 +0200)
src/SPV3D/SPV3D_CADSelection.cxx

index 5d999ff60a1788ad6f2d4e23f23343caafb888b8..85c0e837595a650108cc2fe725e2135dc5dc3cb5 100644 (file)
 #include <vtkSMStringVectorProperty.h>
 #include <vtkSMRepresentationProxy.h>
 #include <vtkPVDataSetAttributesInformation.h>
-
+#include <vtkSMSelectionHelper.h>
+#include <vtkSMOutputPort.h>
 #include <QDebug>
+#include <vtkSelectionSource.h>
+#include <vtkSelectionNode.h>
+#include <pqPVApplicationCore.h>
+#include <pqSelectionManager.h>
+#include <pqServerManagerModel.h>
 
 #include "SPV3D_Prs.h"
 
@@ -540,6 +546,17 @@ void SPV3D_CADSelection::SetSelectionFromEntrySet(std::set<std::string> EntryLis
 
   std::cout << "(Client) Sending selected entries to server:" << std::endl;
 
+  auto producerPort = vtkSMPropertyHelper(proxyRepresentation, "Input").GetAsOutputPort();
+  if (producerPort)
+  {
+    std::cout << producerPort->GetDataClassName() << std::endl;
+  }
+
+  vtkNew<vtkSelectionSource> selectionSource;
+  selectionSource->SetFieldType(vtkSelectionNode::CELL);
+  selectionSource->SetContentType(vtkSelectionNode::BLOCKS);
+  selectionSource->SetArrayName("name"); // TODO 
+
   // Retrieve entry ids and put them in a vector
   std::vector<int> selectedIds;
   selectedIds.reserve(EntryList.size());
@@ -548,8 +565,38 @@ void SPV3D_CADSelection::SetSelectionFromEntrySet(std::set<std::string> EntryLis
     vtkIdType id = SPV3D_Prs::FromEntryToVtkId(entryName.c_str());
     std::cout << "(Client) " << id << std::endl;
     selectedIds.push_back(id);
+
+    // TODO: I'm not sure what ids reference
+    selectionSource->AddBlock(id);
+
+
   }
 
+  selectionSource->Update();
+
+  auto producer = producerPort->GetSourceProxy();
+  
+  auto selectionSourceProxy = vtk::TakeSmartPointer(
+    vtkSMSourceProxy::SafeDownCast(vtkSMSelectionHelper::NewSelectionSourceFromSelection(
+      producer->GetSession(), selectionSource->GetOutput())));
+  // create append selection proxy from selection source proxy
+  auto appendSelections = vtk::TakeSmartPointer(vtkSMSourceProxy::SafeDownCast(
+    vtkSMSelectionHelper::NewAppendSelectionsFromSelectionSource(selectionSourceProxy)));
+  if (appendSelections)
+  {
+    producer->SetSelectionInput(producerPort->GetPortIndex(), appendSelections, 0);
+
+    auto smmodel = pqApplicationCore::instance()->getServerManagerModel();
+    auto selManager = pqPVApplicationCore::instance()->selectionManager();
+    selManager->select(smmodel->findItem<pqOutputPort*>(producerPort));
+  }
+
+
+
+  // vtkSMSelectionHelper::NewSelectionSourceFromSelection(, vtkSelection *selection);
+  vtkSMProperty* selectionProperty = proxyRepresentation->GetProperty("Selection");
+  // vtkSMPropertyHelper(selectionProperty)
+
   vtkSMProperty* selectedIDsProperty = proxyRepresentation->GetProperty("SelectedIDs");
   vtkSMPropertyHelper(selectedIDsProperty).Set(selectedIds.data(), selectedIds.size());
   proxyRepresentation->UpdateVTKObjects();