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 
264  const cvSelectionData& selectionData);
265 
270 
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 };
#define slots
#define signals
cvRenderViewSelectionReaction handles all selection modes in a single class
Encapsulates selection data without exposing VTK types.
Helper class for highlighting selected elements in the visualizer.
Controller class that manages all selection tools and their UI.
void selectionPropertiesUpdateRequested(const cvSelectionData &selectionData)
Emitted when selection properties should be updated Connect this to ecvPropertiesTreeDelegate::update...
QObject * getPropertiesDelegate() const
Get db root delegate (if connected)
void setupActions(UiType *ui)
Setup all selection actions from a UI struct.
void setPropertiesDelegate(QObject *delegate)
Set the properties delegate for selection properties updates.
void zoomToBoxRequested(int xmin, int ymin, int xmax, int ymax)
Emitted for zoom to box requests.
void bookmarksChanged()
Emitted when bookmarks change.
void selectionHistoryChanged()
Emitted when selection history changes.
void selectionFinished(const cvSelectionData &selectionData)
Emitted when a selection operation is completed.
cvViewSelectionManager * manager() const
Get the selection manager.
void selectionToolStateChanged(bool anyToolActive)
Emitted when selection tool state changes Connect this to ecvPropertiesTreeDelegate::setSelectionTool...
Central manager for all selection operations in the view.
Generic visualizer 3D interface.
SelectionMode
Selection modes matching ParaView's SelectionMode enum.
SelectionModifier
Selection modifiers for combining selections.
#define QPCL_ENGINE_LIB_API
Definition: qPCL.h:15
Structure to hold all selection action pointers.