ACloudViewer  3.9.4
A Modern Library for 3D Data Processing
cvGenericSelectionTool Class Reference

Base class for selection tools with picking capabilities. More...

#include <cvGenericSelectionTool.h>

Inheritance diagram for cvGenericSelectionTool:
Collaboration diagram for cvGenericSelectionTool:

Public Types

using SelectionMode = ::SelectionMode
 Selection mode Now using global SelectionMode enum from cvSelectionTypes.h. More...
 
using SelectionModifier = ::SelectionModifier
 Selection modifier (for multi-selection) Now using global SelectionModifier enum from cvSelectionTypes.h. More...
 

Public Member Functions

 cvGenericSelectionTool ()
 
 ~cvGenericSelectionTool () override=default
 
void setSelectionManager (cvViewSelectionManager *manager)
 Set the selection manager (to access pipeline) More...
 
cvViewSelectionManagergetSelectionManager () const
 Get the selection manager. More...
 
cvSelectionPipelinegetSelectionPipeline () const
 Get the selection pipeline from manager. More...
 
vtkPolyData * getPolyDataForSelection (const cvSelectionData *selectionData=nullptr) override
 Get polyData for a selection using ParaView-style priority (override) More...
 
- Public Member Functions inherited from cvSelectionBase
 cvSelectionBase ()
 
virtual ~cvSelectionBase ()=default
 
virtual void setVisualizer (ecvGenericVisualizer3D *viewer)
 Set the visualizer instance. More...
 
ecvGenericVisualizer3DgetVisualizer () const
 Get the visualizer instance. More...
 

Protected Member Functions

cvSelectionData hardwareSelectAtPoint (int x, int y, SelectionMode mode=SelectionMode::SELECT_SURFACE_CELLS, SelectionModifier modifier=SelectionModifier::SELECTION_DEFAULT)
 Hardware-accelerated selection (ParaView-aligned) More...
 
cvSelectionData hardwareSelectInRegion (const int region[4], SelectionMode mode=SelectionMode::SELECT_SURFACE_CELLS, SelectionModifier modifier=SelectionModifier::SELECTION_DEFAULT)
 Perform hardware selection in a region. More...
 
QVector< cvActorSelectionInfogetActorsAtPoint (int x, int y)
 Get all actors at a screen location (without full selection) More...
 
void setUseHardwareSelection (bool enable)
 Hardware selection configuration. More...
 
bool useHardwareSelection () const
 Check if hardware selection is enabled. More...
 
void setCaptureZValues (bool capture)
 Set whether to capture Z-buffer values. More...
 
void setMultipleSelectionMode (bool enable)
 Enable/disable multi-selection mode. More...
 
bool multipleSelectionMode () const
 Check if multi-selection is enabled. More...
 
void initializePickers ()
 Software picking methods (unified from subclasses) More...
 
vtkIdType pickAtPosition (int x, int y, bool selectCells)
 Pick element at screen position. More...
 
vtkIdType pickAtCursor (bool selectCells)
 Pick element at current cursor position. More...
 
void setInteractor (vtkRenderWindowInteractor *interactor)
 Set the interactor for picking. More...
 
vtkRenderWindowInteractor * getInteractor () const
 Get the interactor. More...
 
void setRenderer (vtkRenderer *renderer)
 Set the renderer for picking. More...
 
vtkRenderer * getPickingRenderer () const
 Get the renderer (for picking) More...
 
void setPickerTolerance (double cellTolerance, double pointTolerance)
 Set picker tolerance. More...
 
vtkActor * getPickedActor (bool selectCells)
 Get the last picked actor. More...
 
vtkPolyData * getPickedPolyData (bool selectCells)
 Get the last picked polyData. More...
 
bool getPickedPosition (bool selectCells, double position[3])
 Get pick position in world coordinates. More...
 
cvSelectionData createSelectionFromPick (vtkIdType pickedId, bool selectCells)
 Create cvSelectionData from software picking result. More...
 
cvSelectionData applySelectionModifierUnified (const cvSelectionData &newSelection, const cvSelectionData &currentSelection, int modifier, int fieldAssociation)
 Apply selection modifier to combine selections. More...
 
- Protected Member Functions inherited from cvSelectionBase
PclUtils::PCLVisgetPCLVis () const
 Get PCLVis instance (for VTK-specific operations) More...
 
bool hasValidPCLVis () const
 Check if visualizer is valid and is PCLVis. More...
 
vtkDataSet * getDataFromActor (vtkActor *actor)
 Get data object from a specific actor (ParaView-style) More...
 
QList< vtkActor * > getDataActors () const
 Get all visible data actors from visualizer. More...
 
std::vector< vtkPolyData * > getAllPolyDataFromVisualizer ()
 Get all polyData from the visualizer. More...
 

Protected Attributes

cvViewSelectionManagerm_manager
 Manager reference (for pipeline access) More...
 
vtkSmartPointer< vtkCellPicker > m_cellPicker
 Software picking components (unified from subclasses) More...
 
vtkSmartPointer< vtkPointPicker > m_pointPicker
 Point picker. More...
 
vtkRenderWindowInteractor * m_interactor
 Interactor (weak pointer) More...
 
vtkRenderer * m_renderer
 Renderer (weak pointer) More...
 
bool m_useHardwareSelection
 Hardware selection components (reused for performance) More...
 
bool m_captureZValues
 Capture Z-buffer values. More...
 
bool m_multipleSelectionMode
 Allow multiple selections. More...
 
cvSelectionData m_currentSelection
 Current selection (for modifiers) More...
 
vtkSmartPointer< vtkHardwareSelector > m_hardwareSelector
 Hardware selector (reused) More...
 
- Protected Attributes inherited from cvSelectionBase
ecvGenericVisualizer3Dm_viewer
 Visualizer instance (abstract interface) More...
 

Detailed Description

Base class for selection tools with picking capabilities.

Inherits from cvSelectionBase and adds:

  • Software picking (cell/point pickers)
  • Hardware selection (vtkHardwareSelector)
  • Selection modifiers

Use this class when you need picking/selection functionality. For components that only need visualizer access, use cvSelectionBase instead.

ParaView-Aligned Features:

  • Hardware-accelerated selection using vtkHardwareSelector
  • Multi-actor support with Z-value ordering
  • Selection modifiers (Add/Subtract/Toggle)
  • Unified API for both software and hardware selection

Definition at line 47 of file cvGenericSelectionTool.h.

Member Typedef Documentation

◆ SelectionMode

Selection mode Now using global SelectionMode enum from cvSelectionTypes.h.

Definition at line 53 of file cvGenericSelectionTool.h.

◆ SelectionModifier

Selection modifier (for multi-selection) Now using global SelectionModifier enum from cvSelectionTypes.h.

Definition at line 59 of file cvGenericSelectionTool.h.

Constructor & Destructor Documentation

◆ cvGenericSelectionTool()

cvGenericSelectionTool::cvGenericSelectionTool ( )
inline

Definition at line 61 of file cvGenericSelectionTool.h.

◆ ~cvGenericSelectionTool()

cvGenericSelectionTool::~cvGenericSelectionTool ( )
overridedefault

Member Function Documentation

◆ applySelectionModifierUnified()

cvSelectionData cvGenericSelectionTool::applySelectionModifierUnified ( const cvSelectionData newSelection,
const cvSelectionData currentSelection,
int  modifier,
int  fieldAssociation 
)
protected

Apply selection modifier to combine selections.

Parameters
newSelectionNew selection to combine
currentSelectionCurrent selection (or empty for replace)
modifierModifier defining combination operation
fieldAssociationField association (0=cells, 1=points)
Returns
Combined selection result

ParaView-aligned: Uses cvSelectionPipeline::combineSelections() Reference: pqRenderViewSelectionReaction selection modifier handling

Definition at line 746 of file cvGenericSelectionTool.cpp.

References cvSelectionPipeline::combineSelections(), cvSelectionPipeline::OPERATION_ADDITION, cvSelectionPipeline::OPERATION_DEFAULT, cvSelectionPipeline::OPERATION_SUBTRACTION, cvSelectionPipeline::OPERATION_TOGGLE, CVLog::PrintVerbose(), and CVLog::Warning().

◆ createSelectionFromPick()

cvSelectionData cvGenericSelectionTool::createSelectionFromPick ( vtkIdType  pickedId,
bool  selectCells 
)
protected

Create cvSelectionData from software picking result.

Parameters
pickedIdThe picked element ID
selectCellsIf true, selecting cells; if false, selecting points
Returns
Selection data with actor information

Convenience method to convert software picking result to cvSelectionData with full actor information. This bridges software and hardware selection.

Definition at line 700 of file cvGenericSelectionTool.cpp.

References cvActorSelectionInfo::actor, cvSelectionData::addActorInfo(), cvSelectionData::CELLS, getPickedActor(), getPickedPolyData(), getPickedPosition(), cvSelectionData::POINTS, cvActorSelectionInfo::polyData, CVLog::PrintVerbose(), and cvActorSelectionInfo::zValue.

◆ getActorsAtPoint()

QVector< cvActorSelectionInfo > cvGenericSelectionTool::getActorsAtPoint ( int  x,
int  y 
)
protected

Get all actors at a screen location (without full selection)

Parameters
xX coordinate
yY coordinate
Returns
Vector of actor info, sorted by depth (front to back)

Fast query to find what actors are at a given screen position. Useful for tooltips and hover highlighting.

Definition at line 245 of file cvGenericSelectionTool.cpp.

References cvSelectionBase::hasValidPCLVis(), x, and y.

◆ getInteractor()

vtkRenderWindowInteractor* cvGenericSelectionTool::getInteractor ( ) const
inlineprotected

Get the interactor.

Definition at line 266 of file cvGenericSelectionTool.h.

◆ getPickedActor()

vtkActor * cvGenericSelectionTool::getPickedActor ( bool  selectCells)
protected

Get the last picked actor.

Parameters
selectCellsIf true, get from cell picker; if false, from point picker
Returns
Picked actor, or nullptr if no pick was made

Call this after pickAtPosition/pickAtCursor to get the actor that was picked. Useful for multi-actor scenarios to identify which actor was clicked.

Definition at line 649 of file cvGenericSelectionTool.cpp.

References m_cellPicker, and m_pointPicker.

Referenced by createSelectionFromPick(), and getPickedPolyData().

◆ getPickedPolyData()

vtkPolyData * cvGenericSelectionTool::getPickedPolyData ( bool  selectCells)
protected

Get the last picked polyData.

Parameters
selectCellsIf true, get from cell picker; if false, from point picker
Returns
Picked polyData, or nullptr if no pick was made

Convenience method to get the polyData from the picked actor's mapper.

Definition at line 659 of file cvGenericSelectionTool.cpp.

References getPickedActor().

Referenced by createSelectionFromPick().

◆ getPickedPosition()

bool cvGenericSelectionTool::getPickedPosition ( bool  selectCells,
double  position[3] 
)
protected

Get pick position in world coordinates.

Parameters
selectCellsIf true, get from cell picker; if false, from point picker
positionOutput: world position [x, y, z]
Returns
true if position is valid

Definition at line 687 of file cvGenericSelectionTool.cpp.

References m_cellPicker, m_pointPicker, and position.

Referenced by createSelectionFromPick().

◆ getPickingRenderer()

vtkRenderer* cvGenericSelectionTool::getPickingRenderer ( ) const
inlineprotected

Get the renderer (for picking)

Definition at line 277 of file cvGenericSelectionTool.h.

◆ getPolyDataForSelection()

vtkPolyData * cvGenericSelectionTool::getPolyDataForSelection ( const cvSelectionData selectionData = nullptr)
overridevirtual

Get polyData for a selection using ParaView-style priority (override)

Parameters
selectionDataOptional selection data to extract from (highest priority)
Returns
PolyData pointer, or nullptr if not available

This method extends cvSelectionBase::getPolyDataForSelection() by adding: Priority 2: From current selection's actor info (m_currentSelection)

Full priority order: Priority 1: From selectionData's actor info (if provided and has actor info) Priority 2: From current selection's actor info (m_currentSelection) [NEW] Priority 3: From selection manager's getPolyData() (uses last selection) Priority 4: From first data actor (fallback for non-selection operations)

This override provides enhanced functionality for selection tools.

Reimplemented from cvSelectionBase.

Definition at line 64 of file cvGenericSelectionTool.cpp.

References cvSelectionBase::getPolyDataForSelection(), cvSelectionData::hasActorInfo(), m_currentSelection, cvSelectionData::primaryPolyData(), and CVLog::PrintVerbose().

Referenced by cvSelectionHighlighter::highlightSelection().

◆ getSelectionManager()

cvViewSelectionManager* cvGenericSelectionTool::getSelectionManager ( ) const
inline

Get the selection manager.

Returns
Pointer to selection manager, or nullptr

Definition at line 84 of file cvGenericSelectionTool.h.

◆ getSelectionPipeline()

cvSelectionPipeline * cvGenericSelectionTool::getSelectionPipeline ( ) const

Get the selection pipeline from manager.

Returns
Pointer to pipeline, or nullptr

Definition at line 56 of file cvGenericSelectionTool.cpp.

References cvViewSelectionManager::getPipeline(), and m_manager.

Referenced by hardwareSelectInRegion().

◆ hardwareSelectAtPoint()

cvSelectionData cvGenericSelectionTool::hardwareSelectAtPoint ( int  x,
int  y,
SelectionMode  mode = SelectionMode::SELECT_SURFACE_CELLS,
SelectionModifier  modifier = SelectionModifier::SELECTION_DEFAULT 
)
protected

Hardware-accelerated selection (ParaView-aligned)

These methods provide GPU-accelerated selection using vtkHardwareSelector. They return cvSelectionData with full actor information and Z-value ordering.

Perform hardware selection at a point

Parameters
xX coordinate in window space
yY coordinate in window space
modeSelection mode (cells/points)
modifierSelection modifier (replace/add/subtract/toggle)
Returns
Selection data with all actors at that location

Uses vtkHardwareSelector for precise, GPU-accelerated selection. Returns selection with actor information sorted by Z-value.

Definition at line 97 of file cvGenericSelectionTool.cpp.

References hardwareSelectInRegion(), x, and y.

◆ hardwareSelectInRegion()

◆ initializePickers()

void cvGenericSelectionTool::initializePickers ( )
protected

Software picking methods (unified from subclasses)

These methods provide software-based picking using VTK pickers. All selection tools can use these methods without duplicating code.

Initialize cell and point pickers

Creates and configures vtkCellPicker and vtkPointPicker with default tolerances. Call this before using pickAtPosition.

Tolerance defaults:

  • Cell picker: 0.005
  • Point picker: 0.01

Definition at line 553 of file cvGenericSelectionTool.cpp.

References m_cellPicker, m_pointPicker, and CVLog::PrintVerbose().

Referenced by pickAtPosition(), and setPickerTolerance().

◆ multipleSelectionMode()

bool cvGenericSelectionTool::multipleSelectionMode ( ) const
inlineprotected

Check if multi-selection is enabled.

Definition at line 209 of file cvGenericSelectionTool.h.

◆ pickAtCursor()

vtkIdType cvGenericSelectionTool::pickAtCursor ( bool  selectCells)
protected

Pick element at current cursor position.

Parameters
selectCellsIf true, pick cells; if false, pick points
Returns
Picked element ID, or -1 if nothing was picked

Convenience method that gets the current cursor position from the interactor and calls pickAtPosition.

Definition at line 619 of file cvGenericSelectionTool.cpp.

References m_interactor, pickAtPosition(), and CVLog::Warning().

◆ pickAtPosition()

vtkIdType cvGenericSelectionTool::pickAtPosition ( int  x,
int  y,
bool  selectCells 
)
protected

Pick element at screen position.

Parameters
xX coordinate in screen space
yY coordinate in screen space
selectCellsIf true, pick cells; if false, pick points
Returns
Picked element ID, or -1 if nothing was picked

This method uses vtkCellPicker or vtkPointPicker based on selectCells. The interactor and renderer must be set before calling this method.

Definition at line 568 of file cvGenericSelectionTool.cpp.

References initializePickers(), m_cellPicker, m_pointPicker, m_renderer, CVLog::PrintVerbose(), CVLog::Warning(), x, and y.

Referenced by pickAtCursor().

◆ setCaptureZValues()

void cvGenericSelectionTool::setCaptureZValues ( bool  capture)
inlineprotected

Set whether to capture Z-buffer values.

Parameters
captureIf true, capture Z values for depth sorting

Definition at line 196 of file cvGenericSelectionTool.h.

◆ setInteractor()

void cvGenericSelectionTool::setInteractor ( vtkRenderWindowInteractor *  interactor)
inlineprotected

Set the interactor for picking.

Parameters
interactorThe render window interactor

Definition at line 259 of file cvGenericSelectionTool.h.

◆ setMultipleSelectionMode()

void cvGenericSelectionTool::setMultipleSelectionMode ( bool  enable)
inlineprotected

Enable/disable multi-selection mode.

Parameters
enableIf true, allow multiple selections

Definition at line 202 of file cvGenericSelectionTool.h.

◆ setPickerTolerance()

void cvGenericSelectionTool::setPickerTolerance ( double  cellTolerance,
double  pointTolerance 
)
protected

Set picker tolerance.

Parameters
cellToleranceTolerance for cell picker
pointToleranceTolerance for point picker

Definition at line 631 of file cvGenericSelectionTool.cpp.

References initializePickers(), m_cellPicker, m_pointPicker, and CVLog::PrintVerbose().

◆ setRenderer()

void cvGenericSelectionTool::setRenderer ( vtkRenderer *  renderer)
inlineprotected

Set the renderer for picking.

Parameters
rendererThe renderer

Definition at line 272 of file cvGenericSelectionTool.h.

◆ setSelectionManager()

void cvGenericSelectionTool::setSelectionManager ( cvViewSelectionManager manager)
inline

Set the selection manager (to access pipeline)

Parameters
managerThe view selection manager

Definition at line 76 of file cvGenericSelectionTool.h.

◆ setUseHardwareSelection()

void cvGenericSelectionTool::setUseHardwareSelection ( bool  enable)
inlineprotected

Hardware selection configuration.

Enable/disable hardware selection

Parameters
enableIf true, use vtkHardwareSelector; if false, use software methods

When enabled, selection tools will use GPU-accelerated hardware selection for better accuracy and multi-actor support.

Definition at line 183 of file cvGenericSelectionTool.h.

◆ useHardwareSelection()

bool cvGenericSelectionTool::useHardwareSelection ( ) const
inlineprotected

Check if hardware selection is enabled.

Definition at line 190 of file cvGenericSelectionTool.h.

Member Data Documentation

◆ m_captureZValues

bool cvGenericSelectionTool::m_captureZValues
protected

Capture Z-buffer values.

Definition at line 404 of file cvGenericSelectionTool.h.

◆ m_cellPicker

vtkSmartPointer<vtkCellPicker> cvGenericSelectionTool::m_cellPicker
protected

Software picking components (unified from subclasses)

Cell picker

Definition at line 397 of file cvGenericSelectionTool.h.

Referenced by getPickedActor(), getPickedPosition(), initializePickers(), pickAtPosition(), and setPickerTolerance().

◆ m_currentSelection

cvSelectionData cvGenericSelectionTool::m_currentSelection
protected

Current selection (for modifiers)

Definition at line 406 of file cvGenericSelectionTool.h.

Referenced by getPolyDataForSelection(), and hardwareSelectInRegion().

◆ m_hardwareSelector

vtkSmartPointer<vtkHardwareSelector> cvGenericSelectionTool::m_hardwareSelector
protected

Hardware selector (reused)

Definition at line 408 of file cvGenericSelectionTool.h.

◆ m_interactor

vtkRenderWindowInteractor* cvGenericSelectionTool::m_interactor
protected

Interactor (weak pointer)

Definition at line 399 of file cvGenericSelectionTool.h.

Referenced by pickAtCursor().

◆ m_manager

cvViewSelectionManager* cvGenericSelectionTool::m_manager
protected

Manager reference (for pipeline access)

Selection manager (weak pointer)

Definition at line 394 of file cvGenericSelectionTool.h.

Referenced by getSelectionPipeline().

◆ m_multipleSelectionMode

bool cvGenericSelectionTool::m_multipleSelectionMode
protected

Allow multiple selections.

Definition at line 405 of file cvGenericSelectionTool.h.

Referenced by hardwareSelectInRegion().

◆ m_pointPicker

vtkSmartPointer<vtkPointPicker> cvGenericSelectionTool::m_pointPicker
protected

◆ m_renderer

vtkRenderer* cvGenericSelectionTool::m_renderer
protected

Renderer (weak pointer)

Definition at line 400 of file cvGenericSelectionTool.h.

Referenced by pickAtPosition().

◆ m_useHardwareSelection

bool cvGenericSelectionTool::m_useHardwareSelection
protected

Hardware selection components (reused for performance)

Use hardware selection

Definition at line 403 of file cvGenericSelectionTool.h.


The documentation for this class was generated from the following files: