From: Léon Victor Date: Mon, 9 Sep 2024 11:58:40 +0000 (+0200) Subject: WIP: better selection X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=b5ae770f0f397918c1121d7ceb06ee9a56a508a0;p=modules%2Fgui.git WIP: better selection --- diff --git a/src/SPV3D/SPV3D_CADSelection.cxx b/src/SPV3D/SPV3D_CADSelection.cxx index 5d999ff60..85c0e8375 100644 --- a/src/SPV3D/SPV3D_CADSelection.cxx +++ b/src/SPV3D/SPV3D_CADSelection.cxx @@ -37,8 +37,14 @@ #include #include #include - +#include +#include #include +#include +#include +#include +#include +#include #include "SPV3D_Prs.h" @@ -540,6 +546,17 @@ void SPV3D_CADSelection::SetSelectionFromEntrySet(std::set 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 selectionSource; + selectionSource->SetFieldType(vtkSelectionNode::CELL); + selectionSource->SetContentType(vtkSelectionNode::BLOCKS); + selectionSource->SetArrayName("name"); // TODO + // Retrieve entry ids and put them in a vector std::vector selectedIds; selectedIds.reserve(EntryList.size()); @@ -548,8 +565,38 @@ void SPV3D_CADSelection::SetSelectionFromEntrySet(std::set 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(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();