 |
ACloudViewer
3.9.4
A Modern Library for 3D Data Processing
|
Go to the documentation of this file.
30 #if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
38 #include <QtWidgets/QAction>
39 #include <QtGui/QCursor>
40 #include <QtCore/QObject>
41 #include <QtCore/QPointer>
42 #include <QtWidgets/QShortcut>
43 #include <QtCore/QTimer>
52 #include <vtkSmartPointer.h>
53 #include <vtkWeakPointer.h>
61 class vtkRenderWindowInteractor;
63 class vtkInteractorStyle;
104 QActionGroup* modifierGroup =
nullptr);
134 bool isActive()
const;
143 return ActiveReaction;
152 static void endActiveSelection();
162 void handleSelectionChanged(vtkObject* caller,
163 unsigned long eventId,
169 Q_INVOKABLE
void handleMouseMove();
174 Q_INVOKABLE
void handleLeftButtonPress();
179 Q_INVOKABLE
void handleLeftButtonRelease();
184 Q_INVOKABLE
void handleWheelRotate();
189 Q_INVOKABLE
void handleRightButtonPressed();
194 Q_INVOKABLE
void handleRightButtonRelease();
207 void vtkOnSelectionChanged(vtkObject* caller,
208 unsigned long eventId,
210 void vtkOnMouseMove(vtkObject* caller,
211 unsigned long eventId,
213 void vtkOnLeftButtonPress(vtkObject* caller,
214 unsigned long eventId,
216 void vtkOnLeftButtonRelease(vtkObject* caller,
217 unsigned long eventId,
219 void vtkOnWheelRotate(vtkObject* caller,
220 unsigned long eventId,
222 void vtkOnRightButtonPressed(vtkObject* caller,
223 unsigned long eventId,
225 void vtkOnRightButtonRelease(vtkObject* caller,
226 unsigned long eventId,
228 void vtkOnMiddleButtonPressed(vtkObject* caller,
229 unsigned long eventId,
231 void vtkOnMiddleButtonRelease(vtkObject* caller,
232 unsigned long eventId,
247 void selectedCustomBox(
int xmin,
int ymin,
int xmax,
int ymax);
248 void selectedCustomBox(
const int region[4]);
254 void selectedCustomPolygon(vtkIntArray*
polygon);
259 void zoomToBoxCompleted(
int xmin,
int ymin,
int xmax,
int ymax);
270 virtual void actionTriggered(
bool val);
280 virtual void updateEnableState();
296 virtual void beginSelection();
310 virtual void endSelection();
317 virtual void onMouseStop();
324 virtual void clearSelectionCache();
338 virtual void selectionChanged(vtkObject* caller,
339 unsigned long eventId,
347 virtual void onMouseMove();
352 virtual void onLeftButtonPress();
359 virtual void onLeftButtonRelease();
366 virtual void onWheelRotate();
371 virtual void onRightButtonPressed();
376 virtual void onRightButtonRelease();
381 virtual void onMiddleButtonPressed();
387 virtual void onMiddleButtonRelease();
394 virtual void preSelection();
401 virtual void fastPreSelection();
408 virtual void updateTooltip();
418 virtual int getSelectionModifier();
434 virtual void cleanupObservers();
439 void uncheckSelectionModifiers();
450 void selectCellsOnSurface(
int region[4],
int selectionModifier);
457 void selectPointsOnSurface(
int region[4],
int selectionModifier);
464 void selectFrustumCells(
int region[4],
int selectionModifier);
471 void selectFrustumPoints(
int region[4],
int selectionModifier);
482 int selectionModifier,
483 const QString& description);
490 void selectPolygonCells(vtkIntArray*
polygon,
int selectionModifier);
497 void selectPolygonPoints(vtkIntArray*
polygon,
int selectionModifier);
504 void selectBlock(
int region[4],
int selectionModifier);
528 bool isSelectingCells()
const;
533 bool isInteractiveMode()
const;
538 bool isTooltipMode()
const;
543 void setCursor(
const QCursor& cursor);
553 void storeCurrentStyle();
563 void setupInteractorStyle();
568 void setupObservers();
577 void addCameraMovementObservers(
int startIndex);
585 void setRubberBand3DStyle(
bool renderOnMouseMove);
590 void showInstructionDialog();
594 QPointer<QAction> m_parentAction;
595 QPointer<QActionGroup> m_modifierGroup;
604 vtkRenderWindowInteractor* m_interactor =
nullptr;
605 vtkRenderer* m_renderer =
nullptr;
610 int m_previousRenderViewMode = -1;
613 unsigned long m_observerIds[8] = {0, 0, 0, 0, 0, 0, 0, 0};
614 vtkWeakPointer<vtkObject> m_observedObject;
617 unsigned long m_styleObserverId = 0;
620 QCursor m_zoomCursor;
623 QTimer m_mouseMovingTimer;
624 bool m_mouseMoving =
false;
625 int m_mousePosition[2] = {0, 0};
628 int m_zoomStartPosition[2] = {0, 0};
629 bool m_zoomTracking =
false;
632 bool m_disablePreSelection =
false;
635 QString m_plainTooltipText;
636 QShortcut* m_copyTooltipShortcut =
nullptr;
639 vtkIdType m_hoveredId = -1;
640 vtkPolyData* m_currentPolyData =
nullptr;
647 static QPointer<cvRenderViewSelectionReaction> ActiveReaction;
650 static const int TOOLTIP_WAITING_TIME = 400;
cvSelectionHighlighter * getHighlighter()
Get the shared highlighter.
Definition: cvViewSelectionManager.h:238
const cvSelectionData & currentSelection() const
Get the current selection data (VTK-independent)
Definition: cvViewSelectionManager.cpp:356
virtual void selectionChanged(vtkObject *caller, unsigned long eventId, void *callData)
Callback for selection changed event from VTK.
Definition: cvRenderViewSelectionReaction.cpp:638
@ SELECTION_SUBTRACTION
Subtract from selection (Shift)
PclUtils::PCLVis * getPCLVis() const
Get the PCLVis instance.
Definition: cvRenderViewSelectionReaction.cpp:1676
cvRenderViewSelectionReaction(QAction *parentAction, SelectionMode mode, QActionGroup *modifierGroup=nullptr)
Constructor.
Definition: cvRenderViewSelectionReaction.cpp:86
void showInstructionDialog()
Show instruction dialog for interactive modes.
Definition: cvRenderViewSelectionReaction.cpp:1978
virtual void onMiddleButtonPressed()
Handle middle button press (disable pre-selection during pan)
Definition: cvRenderViewSelectionReaction.cpp:958
normal_z x
Definition: my_point_types.h:165
~cvRenderViewSelectionReaction() override
Definition: cvRenderViewSelectionReaction.cpp:177
@ SELECT_FRUSTUM_POINTS
Select points in frustum.
void finalizeSelection(const cvSelectionData &newSelection, int selectionModifier, const QString &description)
Unified selection finalization (ParaView-style) Combines new selection with existing,...
Definition: cvRenderViewSelectionReaction.cpp:1556
QAction * parentAction() const
Get the parent action.
Definition: cvRenderViewSelectionReaction.h:111
bool hasActorInfo() const
Check if actor information is available.
Definition: cvSelectionData.h:253
void selectPolygonCells(vtkIntArray *polygon, int selectionModifier)
Select cells in polygon.
Definition: cvRenderViewSelectionReaction.cpp:1624
void growSelection()
Grow the current selection by one layer.
Definition: cvViewSelectionManager.cpp:188
virtual void updateTooltip()
Update tooltip display.
Definition: cvRenderViewSelectionReaction.cpp:1058
SelectionModifier
Selection modifiers for combining selections.
Definition: cvSelectionData.h:80
void invalidateCachedSelection()
Clear selection cache and invalidate cached buffers.
Definition: cvSelectionPipeline.cpp:491
bool highlightSelection(const vtkSmartPointer< vtkIdTypeArray > &selection, int fieldAssociation, HighlightMode mode=SELECTED)
Highlight selected elements (automatically gets polyData from visualizer)
Definition: cvSelectionHighlighter.cpp:268
cvSelectionData selectCellsInPolygon(vtkIntArray *polygon)
Select cells in polygon region.
Definition: cvSelectionPipeline.cpp:942
@ SELECT_SURFACE_CELLS_POLYGON
Select cells on surface (polygon)
void selectFrustumPoints(int region[4], int selectionModifier)
Select points in frustum.
Definition: cvRenderViewSelectionReaction.cpp:1545
static bool PrintVerbose(const char *format,...)
Prints out a verbose formatted message in console.
Definition: CVLog.cpp:103
virtual void onRightButtonRelease()
Handle right button release (re-enable pre-selection)
Definition: cvRenderViewSelectionReaction.cpp:944
bool valid
Definition: cvSelectionPipeline.h:290
vtkRenderer * getCurrentRenderer(int viewport=0)
Definition: PCLVis.cpp:2924
#define signals
Definition: PythonPlugin.cpp:26
Simplified selection reaction class aligned with ParaView architecture.
bool isInteractiveMode() const
Check if this is an interactive selection mode.
Definition: cvRenderViewSelectionReaction.cpp:1715
@ SELECTED
Definition: cvSelectionHighlighter.h:120
void clearHoverHighlight()
Clear only hover highlight (keep selected/preselected)
Definition: cvSelectionHighlighter.cpp:452
ccHObject * getSourceObject(const std::string &viewID) const
Get the source object for a given viewID.
Definition: PCLVis.cpp:2425
void vtkOnMiddleButtonRelease(vtkObject *caller, unsigned long eventId, void *callData)
Definition: cvRenderViewSelectionReaction.cpp:314
@ SELECT_SURFACE_POINTDATA_INTERACTIVELY
Hover highlight point data.
virtual int getSelectionModifier()
Get the selection modifier from keyboard state.
Definition: cvRenderViewSelectionReaction.cpp:1353
void shrinkSelection()
Shrink the current selection by one layer.
Definition: cvViewSelectionManager.cpp:194
Definition: WidgetMap.h:20
Definition: CustomContextItem.cpp:18
bool isSelectingCells() const
Check if currently selecting cells (vs points)
Definition: cvRenderViewSelectionReaction.cpp:1698
void uncheckSelectionModifiers()
Uncheck selection modifier buttons.
Definition: cvRenderViewSelectionReaction.cpp:1464
cvSelectionHighlighter * getSelectionHighlighter() const
Get the selection highlighter.
Definition: cvRenderViewSelectionReaction.cpp:1691
@ SELECT_SURFACE_CELLS_INTERACTIVELY
@ SHRINK_SELECTION
Shrink selection by one layer.
virtual bool isCompatible(SelectionMode mode)
Check if this selection is compatible with another mode.
Definition: cvRenderViewSelectionReaction.cpp:1402
void selectBlock(int region[4], int selectionModifier)
Select blocks.
Definition: cvRenderViewSelectionReaction.cpp:1666
void vtkOnLeftButtonRelease(vtkObject *caller, unsigned long eventId, void *callData)
Definition: cvRenderViewSelectionReaction.cpp:284
@ SELECT_SURFACE_CELLDATA_INTERACTIVELY
Hover highlight cell data.
static bool promptUser(const QString &settingsKey, const QString &title, const QString &message, QWidget *parent=nullptr)
Shows instruction dialog if not disabled by user (ParaView-style)
Definition: cvSelectionPipeline.cpp:1289
virtual void onLeftButtonRelease()
Handle left button release (for interactive selection)
Definition: cvRenderViewSelectionReaction.cpp:851
Q_INVOKABLE void handleRightButtonRelease()
Handle right button release (public for callback access)
Definition: cvRenderViewSelectionReaction.cpp:257
void vtkOnSelectionChanged(vtkObject *caller, unsigned long eventId, void *callData)
VTK callback functions for observer pattern.
Definition: cvRenderViewSelectionReaction.cpp:266
void unsetCursor()
Restore default cursor.
Definition: cvRenderViewSelectionReaction.cpp:1742
bool hasSelection() const
Check if there is a current selection.
Definition: cvViewSelectionManager.cpp:510
virtual void clearSelectionCache()
Clear selection cache when data changes.
Definition: cvRenderViewSelectionReaction.cpp:623
bool Copy(const std::string &from, const std::string &to, bool include_parent_dir=false, const std::string &extname="")
Copy a file or directory.
Definition: FileSystem.cpp:249
core::Tensor result
Definition: VtkUtils.cpp:76
virtual void onMouseMove()
Handle mouse move events (for interactive selection)
Definition: cvRenderViewSelectionReaction.cpp:789
constexpr QRegularExpression::PatternOption CaseInsensitive
Definition: QtCompat.h:174
@ SELECTION_ADDITION
Add to selection (Ctrl)
SelectionMode mode() const
Get the selection mode.
Definition: cvRenderViewSelectionReaction.h:116
Q_INVOKABLE void handleLeftButtonRelease()
Handle left button release (public for callback access)
Definition: cvRenderViewSelectionReaction.cpp:247
#define slots
Definition: PythonPlugin.cpp:25
CombineOperation
Selection combination methods (ParaView-style)
Definition: cvSelectionPipeline.h:389
int size
Definition: FileIOFactory.cpp:130
void setupObservers()
Set up event observers for this selection mode.
Definition: cvRenderViewSelectionReaction.cpp:1888
cvSelectionPipeline * getSelectionPipeline() const
Get the selection pipeline.
Definition: cvRenderViewSelectionReaction.cpp:1684
bool isActive() const
Check if this reaction's selection is currently active.
Definition: cvRenderViewSelectionReaction.cpp:221
@ ZOOM_TO_BOX
Zoom to box region.
normal_z y
Definition: my_point_types.h:168
void restoreStyle()
Restore previous interactor style.
Definition: cvRenderViewSelectionReaction.cpp:1783
bool isPointPickingEnabled()
Definition: PCLVis.h:667
Fast Pre-Selection API (ParaView-aligned)
Definition: cvSelectionPipeline.h:289
@ SELECT_SURFACE_CELLS
Select cells on surface (rectangle)
Q_INVOKABLE void handleRightButtonPressed()
Handle right button press (public for callback access)
Definition: cvRenderViewSelectionReaction.cpp:253
bool highlightElement(vtkPolyData *polyData, vtkIdType elementId, int fieldAssociation)
Highlight a single element (for hover preview)
Definition: cvSelectionHighlighter.cpp:394
std::string getIdByActor(vtkProp *actor)
Definition: PCLVis.cpp:3079
void vtkOnRightButtonPressed(vtkObject *caller, unsigned long eventId, void *callData)
Definition: cvRenderViewSelectionReaction.cpp:296
bool isEmpty() const
Check if selection is empty.
Definition: cvSelectionData.cpp:114
@ SELECTION_DEFAULT
Replace selection (default)
void selectCellsOnSurface(int region[4], int selectionModifier)
Select cells on surface.
Definition: cvRenderViewSelectionReaction.cpp:1477
PixelSelectionInfo getPixelSelectionInfo(int x, int y, bool selectCells)
Get complete pixel selection information at a screen position.
Definition: cvSelectionPipeline.cpp:394
void addCameraMovementObservers(int startIndex)
Add camera movement observers for cache invalidation.
Definition: cvRenderViewSelectionReaction.cpp:1951
Definition: MainWindow.h:117
@ HOVER_POINTS_TOOLTIP
Show point data tooltip on hover (read-only)
void clearHighlights()
Clear all highlights.
Definition: cvSelectionHighlighter.cpp:430
void exitSelectionMode()
Exit selection mode and release cached buffers.
Definition: cvSelectionPipeline.cpp:473
vtkSmartPointer< vtkRenderWindowInteractor > getRenderWindowInteractor()
Get a pointer to the current interactor style used.
Definition: PCLVis.h:148
Selection pipeline abstraction layer.
Definition: cvSelectionPipeline.h:53
void setCursor(const QCursor &cursor)
Set cursor on the view.
Definition: cvRenderViewSelectionReaction.cpp:1734
Central manager for all selection operations in the view.
Definition: cvViewSelectionManager.h:52
Generic visualizer 3D interface.
Definition: ecvGenericVisualizer3D.h:15
vtkActor * primaryActor() const
Get the primary (front-most) actor.
Definition: cvSelectionData.cpp:181
static cvSelectionData combineSelections(const cvSelectionData &sel1, const cvSelectionData &sel2, CombineOperation operation)
Combine two selections.
Definition: cvSelectionPipeline.cpp:983
virtual void preSelection()
Perform pre-selection highlighting.
Definition: cvRenderViewSelectionReaction.cpp:977
cvSelectionPipeline * getPipeline()
Get the selection pipeline.
Definition: cvViewSelectionManager.h:214
void storeCurrentStyle()
Store current interactor style.
Definition: cvRenderViewSelectionReaction.cpp:1751
void setRubberBand3DStyle(bool renderOnMouseMove)
Set vtkInteractorStyleRubberBand3D as the interactor style.
Definition: cvRenderViewSelectionReaction.cpp:1805
vtkPolyData * polyData
Definition: cvSelectionPipeline.h:293
void setVisualizer(ecvGenericVisualizer3D *viewer)
Set the visualizer for selection operations.
Definition: cvRenderViewSelectionReaction.cpp:193
static cvRenderViewSelectionReaction * activeReaction()
Get the currently active reaction (static)
Definition: cvRenderViewSelectionReaction.h:142
static void endActiveSelection()
Force end any active selection.
Definition: cvRenderViewSelectionReaction.cpp:226
@ SELECTION_TOGGLE
Toggle selection (Ctrl+Shift)
int points
Definition: FileIOFactory.cpp:144
virtual void onLeftButtonPress()
Handle left button press (for zoom tracking)
Definition: cvRenderViewSelectionReaction.cpp:829
@ SELECT_BLOCKS
Select blocks (rectangle)
virtual void onMiddleButtonRelease()
Handle middle button release (re-enable pre-selection, invalidate cache)
Definition: cvRenderViewSelectionReaction.cpp:964
void zoomToBoxCompleted(int xmin, int ymin, int xmax, int ymax)
Emitted when zoom to box is completed.
Q_INVOKABLE void handleWheelRotate()
Handle wheel rotation (public for callback access)
Definition: cvRenderViewSelectionReaction.cpp:251
vtkIdType attributeID
Definition: cvSelectionPipeline.h:291
virtual void onWheelRotate()
Handle wheel rotation events.
Definition: cvRenderViewSelectionReaction.cpp:922
::SelectionModifier SelectionModifier
Definition: cvRenderViewSelectionReaction.h:94
virtual void updateEnableState()
Updates the enabled state of the action.
Definition: cvRenderViewSelectionReaction.cpp:349
cvRenderViewSelectionReaction handles all selection modes in a single class
Definition: cvRenderViewSelectionReaction.h:89
@ SELECT_CUSTOM_POLYGON
Custom polygon selection (signal only)
void clearSelection()
Clear all selections.
Definition: cvViewSelectionManager.cpp:175
void vtkOnWheelRotate(vtkObject *caller, unsigned long eventId, void *callData)
Definition: cvRenderViewSelectionReaction.cpp:290
virtual void onMouseStop()
Handle mouse stop event (for tooltip display)
Definition: cvRenderViewSelectionReaction.cpp:615
Encapsulates selection data without exposing VTK types.
Definition: cvSelectionData.h:136
@ HOVER_CELLS_TOOLTIP
Show cell data tooltip on hover (read-only)
virtual void beginSelection()
Starts the selection mode.
Definition: cvRenderViewSelectionReaction.cpp:404
static bool Warning(const char *format,...)
Prints out a formatted warning message in console.
Definition: CVLog.cpp:133
#define QPCL_ENGINE_LIB_API
Definition: qPCL.h:15
void selectionFinished(const cvSelectionData &selectionData)
Emitted when selection is finished.
cvSelectionData selectCellsOnSurface(const int region[4])
High-level selection API (ParaView-style)
Definition: cvSelectionPipeline.cpp:923
void vtkOnLeftButtonPress(vtkObject *caller, unsigned long eventId, void *callData)
Definition: cvRenderViewSelectionReaction.cpp:278
@ SELECT_FRUSTUM_CELLS
Select cells in frustum.
void selectionChanged()
Emitted when the selection has changed (legacy - for backward compatibility)
void handleSelectionChanged(vtkObject *caller, unsigned long eventId, void *callData)
Handle selection changed event from VTK (public for callback access)
Definition: cvRenderViewSelectionReaction.cpp:236
SelectionMode
Selection modes matching ParaView's SelectionMode enum.
Definition: cvSelectionData.h:36
boost::geometry::model::polygon< point_xy > polygon
Definition: TreeIso.cpp:37
::SelectionMode SelectionMode
Definition: cvRenderViewSelectionReaction.h:93
bool canShrinkSelection() const
Check if the selection can be shrunk.
Definition: cvViewSelectionManager.h:368
virtual void onRightButtonPressed()
Handle right button press (disable pre-selection)
Definition: cvRenderViewSelectionReaction.cpp:937
@ SELECT_FRUSTUM_BLOCKS
Select blocks in frustum.
static cvViewSelectionManager * instance()
Get the singleton instance.
Definition: cvViewSelectionManager.cpp:38
void selectedCustomPolygon(vtkIntArray *polygon)
Emitted for custom polygon selection.
void vtkOnMouseMove(vtkObject *caller, unsigned long eventId, void *callData)
Definition: cvRenderViewSelectionReaction.cpp:272
virtual void endSelection()
Ends the selection mode.
Definition: cvRenderViewSelectionReaction.cpp:518
Hierarchical CLOUDVIEWER Object.
Definition: ecvHObject.h:25
@ SELECT_SURFACE_POINTS_INTERACTIVELY
bool isTooltipMode() const
Check if this is a tooltip mode.
Definition: cvRenderViewSelectionReaction.cpp:1728
void setHighlightsVisible(bool visible)
Set visibility of all highlight actors.
Definition: cvSelectionHighlighter.cpp:460
void setCurrentSelection(const cvSelectionData &selectionData, bool resetLayers=true)
Set the current selection data.
Definition: cvViewSelectionManager.cpp:370
void selectFrustumCells(int region[4], int selectionModifier)
Select cells in frustum.
Definition: cvRenderViewSelectionReaction.cpp:1537
Q_INVOKABLE void handleLeftButtonPress()
Handle left button press (public for callback access)
Definition: cvRenderViewSelectionReaction.cpp:243
void vtkOnMiddleButtonPressed(vtkObject *caller, unsigned long eventId, void *callData)
Definition: cvRenderViewSelectionReaction.cpp:308
@ CLEAR_SELECTION
Clear current selection.
void setupInteractorStyle()
Set up interactor style for this selection mode.
Definition: cvRenderViewSelectionReaction.cpp:1821
virtual void fastPreSelection()
Perform fast pre-selection using cached buffers.
Definition: cvRenderViewSelectionReaction.cpp:1048
Q_INVOKABLE void handleMouseMove()
Handle mouse move event (public for callback access)
Definition: cvRenderViewSelectionReaction.cpp:241
ecvGenericVisualizer3D * getVisualizer() const
Get the current visualizer.
Definition: cvRenderViewSelectionReaction.h:129
@ SELECT_SURFACE_POINTS_POLYGON
Select points on surface (polygon)
@ SELECT_SURFACE_POINTS
Select points on surface (rectangle)
cvSelectionData selectPointsOnSurface(const int region[4])
Select points on surface in a rectangular region.
Definition: cvSelectionPipeline.cpp:932
void vtkOnRightButtonRelease(vtkObject *caller, unsigned long eventId, void *callData)
Definition: cvRenderViewSelectionReaction.cpp:302
@ GROW_SELECTION
Expand selection by one layer.
void setPointPickingEnabled(bool state)
Definition: PCLVis.h:668
void setSourceObject(ccHObject *obj)
Set the source object for selection operations.
Definition: cvViewSelectionManager.cpp:631
Helper class for highlighting selected elements in the visualizer.
Definition: cvSelectionHighlighter.h:101
virtual void actionTriggered(bool val)
Called when the action is triggered.
Definition: cvRenderViewSelectionReaction.cpp:324
void selectPointsOnSurface(int region[4], int selectionModifier)
Select points on surface.
Definition: cvRenderViewSelectionReaction.cpp:1507
void selectPolygonPoints(vtkIntArray *polygon, int selectionModifier)
Select points in polygon.
Definition: cvRenderViewSelectionReaction.cpp:1645
cvSelectionData selectPointsInPolygon(vtkIntArray *polygon)
Select points in polygon region.
Definition: cvSelectionPipeline.cpp:961
std::string name
Definition: FileIOFactory.cpp:129
virtual void cleanupObservers()
Clean up event observers.
Definition: cvRenderViewSelectionReaction.cpp:1438