ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
cvSelectionToolController.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 // Qt - must be included before other headers for MOC to work correctly
11 #include <QtGlobal>
12 
13 // clang-format off
14 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
15 #include <QActionGroup>
16 #include <QMap>
17 #include <QObject>
18 #include <QPointer>
19 #else
20 #include <QtWidgets/QActionGroup>
21 #include <QtCore/QMap>
22 #include <QtCore/QObject>
23 #include <QtCore/QPointer>
24 #endif
25 // clang-format on
26 
27 #include "cvSelectionData.h" // Contains SelectionMode, SelectionModifier enums // For SelectionMode and SelectionModifier enums
28 #include "cvViewSelectionManager.h"
29 #include "qPCL.h"
30 
31 class QAction;
32 class QMenu;
33 class QToolBar;
35 class cvSelectionData;
37 class cvSelectionHistory;
38 class cvSelectionBookmarks;
40 
51  Q_OBJECT
52 
53 public:
56 
60  static cvSelectionToolController* instance();
61 
66  void initialize(QWidget* parent);
67 
71  void setVisualizer(ecvGenericVisualizer3D* viewer);
72 
93  template <typename UiType>
94  void setupActions(UiType* ui);
95 
99  static bool isPCLBackendAvailable();
100 
108  // Surface selection
109  QAction* selectSurfaceCells = nullptr;
110  QAction* selectSurfacePoints = nullptr;
111 
112  // Frustum selection
113  QAction* selectFrustumCells = nullptr;
114  QAction* selectFrustumPoints = nullptr;
115 
116  // Polygon selection
117  QAction* selectPolygonCells = nullptr;
118  QAction* selectPolygonPoints = nullptr;
119 
120  // Block selection
121  QAction* selectBlocks = nullptr;
122  QAction* selectFrustumBlocks = nullptr;
123 
124  // Interactive selection
125  QAction* interactiveSelectCells = nullptr;
126  QAction* interactiveSelectPoints = nullptr;
127 
128  // Hover/tooltip selection
129  QAction* hoverCells = nullptr;
130  QAction* hoverPoints = nullptr;
131 
132  // Selection modifiers
133  QAction* addSelection = nullptr;
134  QAction* subtractSelection = nullptr;
135  QAction* toggleSelection = nullptr;
136 
137  // Selection manipulation
138  QAction* growSelection = nullptr;
139  QAction* shrinkSelection = nullptr;
140  QAction* clearSelection = nullptr;
141 
142  // Zoom to box
143  QAction* zoomToBox = nullptr;
144  };
145 
150  void setupActions(const SelectionActions& actions);
151 
155  void connectHighlighter();
156 
160  QObject* getPropertiesDelegate() const { return m_propertiesDelegate; }
161 
165  void setPropertiesDelegate(QObject* delegate) {
166  m_propertiesDelegate = delegate;
167  }
168 
179  cvRenderViewSelectionReaction* registerAction(QAction* action,
180  SelectionMode mode);
181 
188  void registerModifierActions(QAction* addAction,
189  QAction* subtractAction,
190  QAction* toggleAction);
191 
195  void registerManipulationActions(QAction* growAction,
196  QAction* shrinkAction,
197  QAction* clearAction);
198 
203  void disableAllTools(cvRenderViewSelectionReaction* except = nullptr);
204 
208  bool isAnyToolActive() const;
209 
213  SelectionMode currentMode() const;
214 
219  bool handleEscapeKey();
220 
224  cvViewSelectionManager* manager() const { return m_manager; }
225 
229  cvSelectionHighlighter* highlighter() const;
230 
231  // history() removed - UI not implemented
232 
237  void setSelectionPropertiesActive(bool active);
238 
245  void invalidateCache();
246 
247 signals:
251  void selectionFinished(const cvSelectionData& selectionData);
252 
257  void selectionToolStateChanged(bool anyToolActive);
258 
263  void selectionPropertiesUpdateRequested(
264  const cvSelectionData& selectionData);
265 
269  void selectionHistoryChanged();
270 
274  void bookmarksChanged();
275 
279  void zoomToBoxRequested(int xmin, int ymin, int xmax, int ymax);
280 
281 public slots:
285  void onSelectionFinished(const cvSelectionData& selectionData);
286 
287  // undoSelection/redoSelection removed - UI not implemented
288 
292  void onModifierChanged(QAction* action);
293 
294  // Note: onTooltipSettingsChanged has been removed as tooltip settings
295  // are now managed through cvSelectionLabelPropertiesDialog
296 
297 private:
298  explicit cvSelectionToolController(QObject* parent = nullptr);
299  ~cvSelectionToolController() override;
300 
301  Q_DISABLE_COPY(cvSelectionToolController)
302 
303  // Core components
304  QPointer<QWidget> m_parentWidget;
305  cvViewSelectionManager* m_manager;
306  bool m_selectionToolsActive;
307  QPointer<QObject> m_propertiesDelegate;
308 
309  // Reactions for each selection mode
310  QMap<SelectionMode, QPointer<cvRenderViewSelectionReaction>> m_reactions;
311 
312  // Store actions for ESC handling
313  SelectionActions m_actions;
314 
315  // Modifier action group
316  QPointer<QActionGroup> m_modifierGroup;
317  QPointer<QAction> m_addAction;
318  QPointer<QAction> m_subtractAction;
319  QPointer<QAction> m_toggleAction;
320 
321  // Manipulation actions
322  QPointer<QAction> m_growAction;
323  QPointer<QAction> m_shrinkAction;
324  QPointer<QAction> m_clearAction;
325 };
cvViewSelectionManager::getHighlighter
cvSelectionHighlighter * getHighlighter()
Get the shared highlighter.
Definition: cvViewSelectionManager.h:238
cvSelectionToolController::SelectionModifier
::SelectionModifier SelectionModifier
Definition: cvSelectionToolController.h:55
SelectionModifier::SELECTION_SUBTRACTION
@ SELECTION_SUBTRACTION
Subtract from selection (Shift)
cvSelectionToolController::SelectionActions::selectSurfaceCells
QAction * selectSurfaceCells
Definition: cvSelectionToolController.h:109
cvSelectionToolController::setPropertiesDelegate
void setPropertiesDelegate(QObject *delegate)
Set the properties delegate for selection properties updates.
Definition: cvSelectionToolController.h:165
cvSelectionToolController::SelectionActions::subtractSelection
QAction * subtractSelection
Definition: cvSelectionToolController.h:134
cvViewSelectionManager::setSelectionModifier
void setSelectionModifier(SelectionModifier modifier)
Set the selection modifier.
Definition: cvViewSelectionManager.cpp:165
SelectionMode::SELECT_FRUSTUM_POINTS
@ SELECT_FRUSTUM_POINTS
Select points in frustum.
SelectionModifier
SelectionModifier
Selection modifiers for combining selections.
Definition: cvSelectionData.h:80
cvSelectionPipeline::invalidateCachedSelection
void invalidateCachedSelection()
Clear selection cache and invalidate cached buffers.
Definition: cvSelectionPipeline.cpp:491
SelectionMode::SELECT_SURFACE_CELLS_POLYGON
@ SELECT_SURFACE_CELLS_POLYGON
Select cells on surface (polygon)
data
GraphType data
Definition: graph_cut.cc:138
cvSelectionToolController::SelectionActions::interactiveSelectPoints
QAction * interactiveSelectPoints
Definition: cvSelectionToolController.h:126
CVLog::PrintVerbose
static bool PrintVerbose(const char *format,...)
Prints out a verbose formatted message in console.
Definition: CVLog.cpp:103
cvSelectionToolController::invalidateCache
void invalidateCache()
Invalidate cached selection data.
Definition: cvSelectionToolController.cpp:559
signals
#define signals
Definition: PythonPlugin.cpp:26
cvRenderViewSelectionReaction.h
Simplified selection reaction class aligned with ParaView architecture.
cvSelectionToolController::isPCLBackendAvailable
static bool isPCLBackendAvailable()
Check if PCL backend is available.
Definition: cvSelectionToolController.cpp:454
cvSelectionToolController::SelectionActions::selectFrustumBlocks
QAction * selectFrustumBlocks
Definition: cvSelectionToolController.h:122
cvSelectionToolController::highlighter
cvSelectionHighlighter * highlighter() const
Get the selection highlighter.
Definition: cvSelectionToolController.cpp:318
cvSelectionToolController::manager
cvViewSelectionManager * manager() const
Get the selection manager.
Definition: cvSelectionToolController.h:224
cvSelectionToolController::SelectionActions::toggleSelection
QAction * toggleSelection
Definition: cvSelectionToolController.h:135
CVLog.h
cvSelectionToolController::registerAction
cvRenderViewSelectionReaction * registerAction(QAction *action, SelectionMode mode)
Register an action for a selection mode.
Definition: cvSelectionToolController.cpp:96
cvSelectionToolController::SelectionActions::clearSelection
QAction * clearSelection
Definition: cvSelectionToolController.h:140
SelectionMode::SELECT_SURFACE_CELLS_INTERACTIVELY
@ SELECT_SURFACE_CELLS_INTERACTIVELY
SelectionMode::SHRINK_SELECTION
@ SHRINK_SELECTION
Shrink selection by one layer.
cvSelectionToolController::registerManipulationActions
void registerManipulationActions(QAction *growAction, QAction *shrinkAction, QAction *clearAction)
Register grow/shrink/clear actions.
Definition: cvSelectionToolController.cpp:215
cvSelectionToolController::selectionFinished
void selectionFinished(const cvSelectionData &selectionData)
Emitted when a selection operation is completed.
cvSelectionToolController::setVisualizer
void setVisualizer(ecvGenericVisualizer3D *viewer)
Set the visualizer for all selection operations.
Definition: cvSelectionToolController.cpp:75
cvSelectionToolController::zoomToBoxRequested
void zoomToBoxRequested(int xmin, int ymin, int xmax, int ymax)
Emitted for zoom to box requests.
SelectionModifier::SELECTION_ADDITION
@ SELECTION_ADDITION
Add to selection (Ctrl)
qPCL.h
slots
#define slots
Definition: PythonPlugin.cpp:25
cvViewSelectionManager::getCurrentMode
SelectionMode getCurrentMode() const
Get the current active selection mode.
Definition: cvViewSelectionManager.h:110
cvRenderViewSelectionReaction::isActive
bool isActive() const
Check if this reaction's selection is currently active.
Definition: cvRenderViewSelectionReaction.cpp:221
SelectionMode::ZOOM_TO_BOX
@ ZOOM_TO_BOX
Zoom to box region.
SelectionMode::SELECT_SURFACE_CELLS
@ SELECT_SURFACE_CELLS
Select cells on surface (rectangle)
cvSelectionToolController::initialize
void initialize(QWidget *parent)
Initialize the controller with UI elements.
Definition: cvSelectionToolController.cpp:67
cvSelectionToolController.h
cvSelectionData::isEmpty
bool isEmpty() const
Check if selection is empty.
Definition: cvSelectionData.cpp:114
SelectionModifier::SELECTION_DEFAULT
@ SELECTION_DEFAULT
Replace selection (default)
cvSelectionToolController::setupActions
void setupActions(UiType *ui)
Setup all selection actions from a UI struct.
cvSelectionToolController::SelectionActions::shrinkSelection
QAction * shrinkSelection
Definition: cvSelectionToolController.h:139
SelectionMode::HOVER_POINTS_TOOLTIP
@ HOVER_POINTS_TOOLTIP
Show point data tooltip on hover (read-only)
cvSelectionToolController::handleEscapeKey
bool handleEscapeKey()
Handle ESC key to exit selection tools.
Definition: cvSelectionToolController.cpp:280
cvSelectionToolController::SelectionActions::growSelection
QAction * growSelection
Definition: cvSelectionToolController.h:138
cvViewSelectionManager.h
cvSelectionPipeline
Selection pipeline abstraction layer.
Definition: cvSelectionPipeline.h:53
cvSelectionToolController::SelectionActions::selectPolygonCells
QAction * selectPolygonCells
Definition: cvSelectionToolController.h:117
cvViewSelectionManager
Central manager for all selection operations in the view.
Definition: cvViewSelectionManager.h:52
ecvGenericVisualizer3D
Generic visualizer 3D interface.
Definition: ecvGenericVisualizer3D.h:15
cvSelectionToolController::SelectionActions::selectPolygonPoints
QAction * selectPolygonPoints
Definition: cvSelectionToolController.h:118
cvSelectionData::count
int count() const
Get number of selected items.
Definition: cvSelectionData.cpp:119
cvViewSelectionManager::getPipeline
cvSelectionPipeline * getPipeline()
Get the selection pipeline.
Definition: cvViewSelectionManager.h:214
cvSelectionToolController::connectHighlighter
void connectHighlighter()
Connect highlighter for visual feedback.
Definition: cvSelectionToolController.cpp:550
cvRenderViewSelectionReaction::setVisualizer
void setVisualizer(ecvGenericVisualizer3D *viewer)
Set the visualizer for selection operations.
Definition: cvRenderViewSelectionReaction.cpp:193
cvRenderViewSelectionReaction::activeReaction
static cvRenderViewSelectionReaction * activeReaction()
Get the currently active reaction (static)
Definition: cvRenderViewSelectionReaction.h:142
cvRenderViewSelectionReaction::endActiveSelection
static void endActiveSelection()
Force end any active selection.
Definition: cvRenderViewSelectionReaction.cpp:226
cvSelectionToolController::SelectionActions::selectFrustumPoints
QAction * selectFrustumPoints
Definition: cvSelectionToolController.h:114
cvSelectionToolController::SelectionActions::selectFrustumCells
QAction * selectFrustumCells
Definition: cvSelectionToolController.h:113
cvSelectionToolController::SelectionActions::zoomToBox
QAction * zoomToBox
Definition: cvSelectionToolController.h:143
SelectionModifier::SELECTION_TOGGLE
@ SELECTION_TOGGLE
Toggle selection (Ctrl+Shift)
cvSelectionToolController::selectionToolStateChanged
void selectionToolStateChanged(bool anyToolActive)
Emitted when selection tool state changes Connect this to ecvPropertiesTreeDelegate::setSelectionTool...
cvSelectionToolController::currentMode
SelectionMode currentMode() const
Get the current active selection mode.
Definition: cvSelectionToolController.cpp:272
SelectionMode::SELECT_BLOCKS
@ SELECT_BLOCKS
Select blocks (rectangle)
cvRenderViewSelectionReaction::zoomToBoxCompleted
void zoomToBoxCompleted(int xmin, int ymin, int xmax, int ymax)
Emitted when zoom to box is completed.
cvSelectionData::fieldTypeString
QString fieldTypeString() const
Get human-readable field type string.
Definition: cvSelectionData.cpp:143
cvSelectionToolController::SelectionActions::selectBlocks
QAction * selectBlocks
Definition: cvSelectionToolController.h:121
cvRenderViewSelectionReaction
cvRenderViewSelectionReaction handles all selection modes in a single class
Definition: cvRenderViewSelectionReaction.h:89
cvSelectionToolController::SelectionMode
::SelectionMode SelectionMode
Definition: cvSelectionToolController.h:54
cvSelectionToolController::isAnyToolActive
bool isAnyToolActive() const
Check if any selection tool is active.
Definition: cvSelectionToolController.cpp:266
cvSelectionData
Encapsulates selection data without exposing VTK types.
Definition: cvSelectionData.h:136
SelectionMode::HOVER_CELLS_TOOLTIP
@ HOVER_CELLS_TOOLTIP
Show cell data tooltip on hover (read-only)
CVLog::Warning
static bool Warning(const char *format,...)
Prints out a formatted warning message in console.
Definition: CVLog.cpp:133
QPCL_ENGINE_LIB_API
#define QPCL_ENGINE_LIB_API
Definition: qPCL.h:15
cvRenderViewSelectionReaction::selectionFinished
void selectionFinished(const cvSelectionData &selectionData)
Emitted when selection is finished.
cvSelectionBase::getVisualizer
ecvGenericVisualizer3D * getVisualizer() const
Get the visualizer instance.
Definition: cvSelectionBase.h:64
cvSelectionHighlighter.h
cvSelectionToolController::onModifierChanged
void onModifierChanged(QAction *action)
Handle modifier action changes.
Definition: cvSelectionToolController.cpp:379
SelectionMode::SELECT_FRUSTUM_CELLS
@ SELECT_FRUSTUM_CELLS
Select cells in frustum.
cvViewSelectionManager::selectionChanged
void selectionChanged()
Emitted when the selection has changed (legacy - for backward compatibility)
SelectionMode
SelectionMode
Selection modes matching ParaView's SelectionMode enum.
Definition: cvSelectionData.h:36
cvSelectionToolController::registerModifierActions
void registerModifierActions(QAction *addAction, QAction *subtractAction, QAction *toggleAction)
Register the selection modifier action group.
Definition: cvSelectionToolController.cpp:172
cvSelectionToolController::disableAllTools
void disableAllTools(cvRenderViewSelectionReaction *except=nullptr)
Disable all selection tools.
Definition: cvSelectionToolController.cpp:240
SelectionMode::SELECT_FRUSTUM_BLOCKS
@ SELECT_FRUSTUM_BLOCKS
Select blocks in frustum.
cvSelectionToolController::SelectionActions
Structure to hold all selection action pointers.
Definition: cvSelectionToolController.h:107
cvSelectionToolController::setSelectionPropertiesActive
void setSelectionPropertiesActive(bool active)
Update selection properties widget state.
Definition: cvSelectionToolController.cpp:329
SelectionMode::SELECT_SURFACE_POINTS_INTERACTIVELY
@ SELECT_SURFACE_POINTS_INTERACTIVELY
cvSelectionData.h
cvViewSelectionManager::setCurrentSelection
void setCurrentSelection(const cvSelectionData &selectionData, bool resetLayers=true)
Set the current selection data.
Definition: cvViewSelectionManager.cpp:370
SelectionMode::CLEAR_SELECTION
@ CLEAR_SELECTION
Clear current selection.
cvSelectionToolController::SelectionActions::selectSurfacePoints
QAction * selectSurfacePoints
Definition: cvSelectionToolController.h:110
cvSelectionToolController::SelectionActions::hoverPoints
QAction * hoverPoints
Definition: cvSelectionToolController.h:130
cvSelectionToolController::instance
static cvSelectionToolController * instance()
Get the singleton instance.
Definition: cvSelectionToolController.cpp:25
cvSelectionToolController
Controller class that manages all selection tools and their UI.
Definition: cvSelectionToolController.h:50
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)
cvSelectionToolController::SelectionActions::hoverCells
QAction * hoverCells
Definition: cvSelectionToolController.h:129
SelectionMode::GROW_SELECTION
@ GROW_SELECTION
Expand selection by one layer.
cvSelectionToolController::SelectionActions::interactiveSelectCells
QAction * interactiveSelectCells
Definition: cvSelectionToolController.h:125
cvViewSelectionManager::setSourceObject
void setSourceObject(ccHObject *obj)
Set the source object for selection operations.
Definition: cvViewSelectionManager.cpp:631
cvSelectionHighlighter
Helper class for highlighting selected elements in the visualizer.
Definition: cvSelectionHighlighter.h:101
cvSelectionToolController::selectionPropertiesUpdateRequested
void selectionPropertiesUpdateRequested(const cvSelectionData &selectionData)
Emitted when selection properties should be updated Connect this to ecvPropertiesTreeDelegate::update...
cvSelectionToolController::selectionHistoryChanged
void selectionHistoryChanged()
Emitted when selection history changes.
cvSelectionToolController::onSelectionFinished
void onSelectionFinished(const cvSelectionData &selectionData)
Handle selection finished from any tool.
Definition: cvSelectionToolController.cpp:337
cvSelectionToolController::SelectionActions::addSelection
QAction * addSelection
Definition: cvSelectionToolController.h:133
cvSelectionToolController::getPropertiesDelegate
QObject * getPropertiesDelegate() const
Get db root delegate (if connected)
Definition: cvSelectionToolController.h:160
cvViewSelectionManager::setVisualizer
void setVisualizer(ecvGenericVisualizer3D *viewer) override
Set the visualizer for all selection operations.
Definition: cvViewSelectionManager.cpp:89
cvSelectionPipeline.h