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>;
cvSelectionData::addActorInfo
void addActorInfo(const cvActorSelectionInfo &info)
Actor/Representation information (ParaView-style)
Definition: cvSelectionData.cpp:148
SelectionModifier::SELECTION_SUBTRACTION
@ SELECTION_SUBTRACTION
Subtract from selection (Shift)
cvSelectionData::operator=
cvSelectionData & operator=(const cvSelectionData &other)
Assignment operator.
Definition: cvSelectionData.cpp:81
cvSelectionData::actorCount
int actorCount() const
Get number of actors in this selection.
Definition: cvSelectionData.h:248
SelectionMode::SELECT_FRUSTUM_POINTS
@ SELECT_FRUSTUM_POINTS
Select points in frustum.
cvSelectionData::hasActorInfo
bool hasActorInfo() const
Check if actor information is available.
Definition: cvSelectionData.h:253
SelectionModifier
SelectionModifier
Selection modifiers for combining selections.
Definition: cvSelectionData.h:80
cvSelectionData::fieldAssociation
FieldAssociation fieldAssociation() const
Get field association.
Definition: cvSelectionData.h:193
SelectionMode::SELECT_SURFACE_CELLS_POLYGON
@ SELECT_SURFACE_CELLS_POLYGON
Select cells on surface (polygon)
cvActorSelectionInfo::blockIndex
unsigned int blockIndex
Block index for composite datasets.
Definition: cvSelectionData.h:114
cvSelectionData::clear
void clear()
Clear the selection.
Definition: cvSelectionData.cpp:137
SelectionMode::SELECT_SURFACE_POINTDATA_INTERACTIVELY
@ SELECT_SURFACE_POINTDATA_INTERACTIVELY
Hover highlight point data.
vtkSmartPointer
Definition: WidgetMap.h:20
SelectionMode::SELECT_SURFACE_CELLS_INTERACTIVELY
@ SELECT_SURFACE_CELLS_INTERACTIVELY
SelectionMode::SHRINK_SELECTION
@ SHRINK_SELECTION
Shrink selection by one layer.
cvSelectionData::~cvSelectionData
~cvSelectionData()
Destructor.
Definition: cvSelectionData.cpp:109
SelectionMode::SELECT_SURFACE_CELLDATA_INTERACTIVELY
@ SELECT_SURFACE_CELLDATA_INTERACTIVELY
Hover highlight cell data.
cvActorSelectionInfo::actorName
QString actorName
Optional actor name/description.
Definition: cvSelectionData.h:115
result
core::Tensor result
Definition: VtkUtils.cpp:76
SelectionModifier::SELECTION_ADDITION
@ SELECTION_ADDITION
Add to selection (Ctrl)
qPCL.h
SelectionMode::ZOOM_TO_BOX
@ ZOOM_TO_BOX
Zoom to box region.
cvActorSelectionInfo::zValue
double zValue
Z-buffer depth value (for front-to-back ordering)
Definition: cvSelectionData.h:112
cvActorSelectionInfo::propId
int propId
Unique prop ID (from hardware selector)
Definition: cvSelectionData.h:113
SelectionMode::SELECT_SURFACE_CELLS
@ SELECT_SURFACE_CELLS
Select cells on surface (rectangle)
cvSelectionData::isEmpty
bool isEmpty() const
Check if selection is empty.
Definition: cvSelectionData.cpp:114
SelectionModifier::SELECTION_DEFAULT
@ SELECTION_DEFAULT
Replace selection (default)
SelectionMode::HOVER_POINTS_TOOLTIP
@ HOVER_POINTS_TOOLTIP
Show point data tooltip on hover (read-only)
cvSelectionData::actorInfo
cvActorSelectionInfo actorInfo(int index=0) const
Get actor info at index.
Definition: cvSelectionData.cpp:173
cvSelectionData::CELLS
@ CELLS
Selection applies to cells.
Definition: cvSelectionData.h:142
cvSelectionData::primaryActor
vtkActor * primaryActor() const
Get the primary (front-most) actor.
Definition: cvSelectionData.cpp:181
cvSelectionData::count
int count() const
Get number of selected items.
Definition: cvSelectionData.cpp:119
cvActorSelectionInfo::polyData
vtkPolyData * polyData
The associated polyData (weak pointer)
Definition: cvSelectionData.h:111
cvSelectionDataPtr
QSharedPointer< cvSelectionData > cvSelectionDataPtr
Shared pointer to selection data.
Definition: cvSelectionData.h:304
a
a[190]
Definition: essential_matrix_poly.h:19
SelectionModifier::SELECTION_TOGGLE
@ SELECTION_TOGGLE
Toggle selection (Ctrl+Shift)
cvSelectionData::ids
QVector< qint64 > ids() const
Get selected IDs as a vector (copy)
Definition: cvSelectionData.cpp:124
SelectionMode::SELECT_BLOCKS
@ SELECT_BLOCKS
Select blocks (rectangle)
cvActorSelectionInfo::cvActorSelectionInfo
cvActorSelectionInfo()
Definition: cvSelectionData.h:117
cvSelectionData::fieldTypeString
QString fieldTypeString() const
Get human-readable field type string.
Definition: cvSelectionData.cpp:143
SelectionMode::SELECT_CUSTOM_POLYGON
@ SELECT_CUSTOM_POLYGON
Custom polygon selection (signal only)
cvSelectionData::clearActorInfo
void clearActorInfo()
Clear actor information.
Definition: cvSelectionData.cpp:191
cvSelectionData
Encapsulates selection data without exposing VTK types.
Definition: cvSelectionData.h:136
count
int count
Definition: FileIOFactory.cpp:132
SelectionMode::HOVER_CELLS_TOOLTIP
@ HOVER_CELLS_TOOLTIP
Show cell data tooltip on hover (read-only)
QPCL_ENGINE_LIB_API
#define QPCL_ENGINE_LIB_API
Definition: qPCL.h:15
SelectionMode::SELECT_FRUSTUM_CELLS
@ SELECT_FRUSTUM_CELLS
Select cells in frustum.
qHash
uint qHash(SelectionMode key, uint seed=0) noexcept
Definition: cvSelectionData.h:88
SelectionMode
SelectionMode
Selection modes matching ParaView's SelectionMode enum.
Definition: cvSelectionData.h:36
SelectionMode::SELECT_FRUSTUM_BLOCKS
@ SELECT_FRUSTUM_BLOCKS
Select blocks in frustum.
SelectionMode::SELECT_SURFACE_POINTS_INTERACTIVELY
@ SELECT_SURFACE_POINTS_INTERACTIVELY
cvSelectionData::vtkArray
vtkSmartPointer< vtkIdTypeArray > vtkArray() const
Get the underlying VTK array (for internal use only)
Definition: cvSelectionData.h:204
cvSelectionData.h
SelectionMode::CLEAR_SELECTION
@ CLEAR_SELECTION
Clear current selection.
cvSelectionData::FieldAssociation
FieldAssociation
Field association for selection.
Definition: cvSelectionData.h:141
SelectionMode::SELECT_SURFACE_POINTS_POLYGON
@ SELECT_SURFACE_POINTS_POLYGON
Select points on surface (polygon)
SelectionMode::SELECT_SURFACE_POINTS
@ SELECT_SURFACE_POINTS
Select points on surface (rectangle)
cvSelectionData::primaryPolyData
vtkPolyData * primaryPolyData() const
Get the primary (front-most) polyData.
Definition: cvSelectionData.cpp:186
SelectionMode::GROW_SELECTION
@ GROW_SELECTION
Expand selection by one layer.
cvSelectionData::setActorInfo
void setActorInfo(vtkActor *actor, vtkPolyData *polyData, double zValue=1.0)
Set actor information (single actor case)
Definition: cvSelectionData.cpp:159
cvActorSelectionInfo
Information about a selected actor/representation.
Definition: cvSelectionData.h:109
cvActorSelectionInfo::actor
vtkActor * actor
The selected actor (weak pointer)
Definition: cvSelectionData.h:110
cvSelectionData::cvSelectionData
cvSelectionData()
Construct empty selection data.
Definition: cvSelectionData.cpp:19
cvSelectionData::actorInfos
QVector< cvActorSelectionInfo > actorInfos() const
Get all actor infos.
Definition: cvSelectionData.h:268