ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
cvSelectionData.h
Go to the documentation of this file.
1 // ----------------------------------------------------------------------------
2 // - CloudViewer: www.cloudViewer.org -
3 // ----------------------------------------------------------------------------
4 // Copyright (c) 2018-2024 www.cloudViewer.org
5 // SPDX-License-Identifier: MIT
6 // ----------------------------------------------------------------------------
7 
8 #pragma once
9 
10 // LOCAL
11 #include "qPCL.h"
12 
13 // QT
14 #include <QtCore/QHashFunctions>
15 #include <QtCore/QSharedPointer>
16 #include <QtCore/QString>
17 #include <QtCore/QVector>
18 
19 // VTK
20 #include <vtkSmartPointer.h>
21 
22 // Forward declarations (VTK types - not exposed in public API)
23 class vtkIdTypeArray;
24 class vtkPolyData;
25 class vtkActor;
26 
27 //=============================================================================
28 // Selection Types and Enums (merged from cvSelectionTypes.h)
29 //=============================================================================
30 
36 enum class SelectionMode {
37  // Surface selection
42 
43  // Frustum selection
46 
47  // Block selection
50 
51  // Interactive selection
58 
59  // Tooltip selection (Hovering mode)
62 
63  // Custom selection (emit signals with selection region)
65 
66  // Zoom mode (ParaView-aligned)
67  ZOOM_TO_BOX,
68 
69  // Selection management
73 };
74 
80 enum class SelectionModifier {
85 };
86 
87 // Provide qHash function for SelectionMode to support QSet<SelectionMode>
88 inline uint qHash(SelectionMode key, uint seed = 0) noexcept {
89  return qHash(static_cast<int>(key), seed);
90 }
91 
92 // Provide qHash function for SelectionModifier to support
93 // QSet<SelectionModifier>
94 inline uint qHash(SelectionModifier key, uint seed = 0) noexcept {
95  return qHash(static_cast<int>(key), seed);
96 }
97 
98 //=============================================================================
99 // Selection Data Classes
100 //=============================================================================
101 
110  vtkActor* actor;
111  vtkPolyData* polyData;
112  double zValue;
113  int propId;
114  unsigned int blockIndex;
115  QString actorName;
116 
118  : actor(nullptr),
119  polyData(nullptr),
120  zValue(1.0),
121  propId(-1),
122  blockIndex(0),
123  actorName("") {}
124 };
125 
137 public:
142  CELLS = 0,
143  POINTS = 1
144  };
145 
149  cvSelectionData();
150 
156  cvSelectionData(vtkIdTypeArray* vtkArray, int association);
157 
163  cvSelectionData(const QVector<qint64>& ids, FieldAssociation association);
164 
168  cvSelectionData(const cvSelectionData& other);
169 
173  cvSelectionData& operator=(const cvSelectionData& other);
174 
178  ~cvSelectionData();
179 
183  bool isEmpty() const;
184 
188  int count() const;
189 
193  FieldAssociation fieldAssociation() const { return m_fieldAssociation; }
194 
198  QVector<qint64> ids() const;
199 
204  vtkSmartPointer<vtkIdTypeArray> vtkArray() const { return m_vtkArray; }
205 
209  void clear();
210 
214  QString fieldTypeString() const;
215 
217 
232  void addActorInfo(const cvActorSelectionInfo& info);
233 
240  void setActorInfo(vtkActor* actor,
241  vtkPolyData* polyData,
242  double zValue = 1.0);
243 
248  int actorCount() const { return m_actorInfos.size(); }
249 
253  bool hasActorInfo() const { return !m_actorInfos.isEmpty(); }
254 
262  cvActorSelectionInfo actorInfo(int index = 0) const;
263 
268  QVector<cvActorSelectionInfo> actorInfos() const { return m_actorInfos; }
269 
276  vtkActor* primaryActor() const;
277 
282  vtkPolyData* primaryPolyData() const;
283 
287  void clearActorInfo();
288 
290 
291 private:
293  m_vtkArray;
294  FieldAssociation m_fieldAssociation;
295 
298  QVector<cvActorSelectionInfo> m_actorInfos;
299 };
300 
304 using cvSelectionDataPtr = QSharedPointer<cvSelectionData>;
int count
Encapsulates selection data without exposing VTK types.
FieldAssociation fieldAssociation() const
Get field association.
vtkSmartPointer< vtkIdTypeArray > vtkArray() const
Get the underlying VTK array (for internal use only)
FieldAssociation
Field association for selection.
QVector< cvActorSelectionInfo > actorInfos() const
Get all actor infos.
bool hasActorInfo() const
Check if actor information is available.
int actorCount() const
Get number of actors in this selection.
SelectionMode
Selection modes matching ParaView's SelectionMode enum.
@ SELECT_BLOCKS
Select blocks (rectangle)
@ SELECT_FRUSTUM_BLOCKS
Select blocks in frustum.
@ SELECT_FRUSTUM_POINTS
Select points in frustum.
@ SELECT_SURFACE_POINTS
Select points on surface (rectangle)
@ HOVER_CELLS_TOOLTIP
Show cell data tooltip on hover (read-only)
@ SELECT_SURFACE_POINTS_POLYGON
Select points on surface (polygon)
@ GROW_SELECTION
Expand selection by one layer.
@ SELECT_CUSTOM_POLYGON
Custom polygon selection (signal only)
@ SHRINK_SELECTION
Shrink selection by one layer.
@ SELECT_SURFACE_POINTS_INTERACTIVELY
@ SELECT_SURFACE_CELLS
Select cells on surface (rectangle)
@ SELECT_SURFACE_CELLS_INTERACTIVELY
@ HOVER_POINTS_TOOLTIP
Show point data tooltip on hover (read-only)
@ SELECT_SURFACE_CELLDATA_INTERACTIVELY
Hover highlight cell data.
@ SELECT_SURFACE_POINTDATA_INTERACTIVELY
Hover highlight point data.
@ ZOOM_TO_BOX
Zoom to box region.
@ SELECT_SURFACE_CELLS_POLYGON
Select cells on surface (polygon)
@ SELECT_FRUSTUM_CELLS
Select cells in frustum.
@ CLEAR_SELECTION
Clear current selection.
uint qHash(SelectionMode key, uint seed=0) noexcept
SelectionModifier
Selection modifiers for combining selections.
@ SELECTION_TOGGLE
Toggle selection (Ctrl+Shift)
@ SELECTION_DEFAULT
Replace selection (default)
@ SELECTION_ADDITION
Add to selection (Ctrl)
@ SELECTION_SUBTRACTION
Subtract from selection (Shift)
QSharedPointer< cvSelectionData > cvSelectionDataPtr
Shared pointer to selection data.
#define QPCL_ENGINE_LIB_API
Definition: qPCL.h:15
Information about a selected actor/representation.
double zValue
Z-buffer depth value (for front-to-back ordering)
unsigned int blockIndex
Block index for composite datasets.
int propId
Unique prop ID (from hardware selector)
vtkPolyData * polyData
The associated polyData (weak pointer)
vtkActor * actor
The selected actor (weak pointer)
QString actorName
Optional actor name/description.