NDEVR
API Documentation
SelectionController

Allows user to select data in a DesignObjectLookup. More...

Inheritance diagram for SelectionController:
[legend]
Collaboration diagram for SelectionController:
[legend]

Public Member Functions

 SelectionController (DesignObjectLookup *manager)
 Constructs a SelectionController for the given design object lookup.
virtual ~SelectionController ()
 Destructor.
uint04 addCurrentAsMask ()
 Converts the current selection into a mask and adds it.
uint04 addMask (const SelectionArea< 3, fltp08 > &mask)
 Adds a 3D selection area as a mask.
virtual void begin () override
 Begins the selection interaction session.
virtual void cancel () override
 Cancels the current selection operation without committing.
void clear (bool clear_selection, bool clear_masks)
 Clears the selection state and/or masks.
void clearMaskHighlight ()
 Clears any active mask highlight.
UUID currentSelection () const
 Returns the UUID of the currently selected object.
String currentSelectionHint () const
 Returns a hint string describing the current selection state.
void darkenMaskExclusion (bool darken)
 Sets whether mask-excluded geometry should be darkened.
bool darkensMaskExclusion () const
 Checks whether mask-excluded geometry is darkened rather than hidden.
TranslatedString defaultHint (const TranslatedString &action_hint) const
 Returns a default hint string combining the action hint with selection context.
virtual void finish () override
 Finishes and commits the current selection.
void highlightMask (uint04 mask_index)
 Visually highlights a specific mask.
bool isInvertedSelection () const
 Checks whether the selection logic is inverted (selecting outside rather than inside).
const Buffer< SelectionArea< 3, fltp08 > > & masks () const
 Returns a read-only reference to all current selection masks.
virtual bool processKeyEvent (const KeyEvent &event, DesignObjectLookup *lookup, Camera *camera) override
 Processes a keyboard event for selection interaction.
virtual bool processMouseEvent (MouseControllerEvent &event, SelectionInfo &info) override
 Processes a mouse event for selection interaction.
void removeMask (uint04 mask_index)
 Removes a mask by index.
bool selectionComplete () const
 Checks whether the user has completed the selection.
void setCameraShowEnvironment (bool show_grid)
 Sets whether the camera environment (skybox/background scene) is shown.
void setCameraShowGrid (bool show_grid)
 Sets whether the camera grid is shown.
void setHideMaskExclusion (bool is_hidden)
 Sets whether geometry excluded by masks should be hidden entirely.
void setInvertedSelection (bool is_inside)
 Sets whether selection is inverted.
void setIsEditSelection (bool is_edit_selection)
 Sets whether this selection controller is operating in edit-selection mode.
void setMaskEnabled (uint04 index, bool enabled)
 Enables or disables a specific mask by index.
void setPreGeometryFilter (const std::function< bool(const Model &, const Geometry &)> &pre_geometry_filter)
 Sets a filter applied before testing a geometry within a model for selection.
void setPreModelFilter (const std::function< bool(const Model &)> &pre_model_filter)
 Sets a filter applied before testing a model for selection.
void setSelectionFilter (const std::function< bool(const Model &)> &selection_filter)
 Sets a filter applied after a selection is made to resolve the appropriate parent.
void setSubSelectionMode (const SubSelectionMode &mode)
 Sets the sub-selection mode (single model, vertex rectangle, vertex polygon, etc.).
void setThemeCameraBackgroundColor (const RGBColor &color)
 Sets the fallback camera background color used when no theme default is available.
SubSelectionMode subSelectionMode () const
 Returns the current sub-selection mode.
void updateCameraBackgrounds ()
 Updates all camera backgrounds to reflect the current theme or mask state.
void updateSelectionInfo (SelectionInfo &info)
 Updates the provided SelectionInfo with the current selection state.
Public Member Functions inherited from SnapController
 SnapController (DesignObjectLookup *manager)
 Constructs a SnapController associated with the given DesignObjectLookup.
void clearSnapSelection ()
 Clears all currently accumulated snap selection points and resets the visual state.
Vertex< 3, fltp08currentLocation () const
 Returns the current snap location in 3D space.
Vertex< 3, fltp08lastPoint () const
 Returns the most recent snap location.
const Buffer< SnapPoint > & lastSnapPoints () const
 Returns the buffer of snap points from the most recent snap calculation.
void lockAxis (uint01 axis, fltp08 lock)
 Locks a specific axis to a fixed coordinate value.
uint04 pointCount () const
 Returns the number of points currently recorded by the snap controller.
const Buffer< Vertex< 3, fltp08 > > & points () const
 Returns the buffer of all accumulated snap points.
SelectionMode selectionMode () const
 Returns the current selection mode.
void setCustomSnapManager (const ConstPointer< SnapsManager > &snap_manager)
 Sets a custom snap manager to override the default snapping behavior.
virtual void setFinishedCallback (const std::function< void(bool is_accepted)> &callback)
 Sets a callback invoked when the snap operation finishes.
void setLocation (const Vertex< 3, fltp08 > &location, bool is_click=false, Camera *camera=nullptr)
 Sets the current snap location, optionally registering it as a click.
void setLockLine (const LineSegment< 3, fltp08 > &line)
 Sets a line segment to constrain snap positions along.
void setLockMode (LockMode mode)
 Sets the lock mode that controls how axis/plane locking interacts with snapping.
void setLockPlane (const Plane< 3, fltp08 > &plane)
 Sets a plane to constrain snap positions onto.
void setPointsDrawMode (PointsDrawMode mode)
 Sets the visual draw mode for how accumulated points are rendered.
void setSelectionMode (SelectionMode mode)
 Sets the selection mode used during snap interaction.
void setShowLengthLabels (bool show)
 Sets whether length labels are displayed along guide lines.
void setShowPointLabels (bool show)
 Sets whether coordinate labels are displayed at snap points.
virtual void setUpdateCallback (const std::function< void()> &callback)
 Sets a callback invoked whenever the snap location or state is updated.

Protected Member Functions

void clearMasks ()
 Clears all selection masks.
void clearSelection ()
 Clears the active selection state.
void setSelectionMaskInfo (const SelectionInfo &info)
 Stores the selection mask info from the given SelectionInfo.
void updateSelectionMask ()
 Updates the visual representation of selection masks.
Protected Member Functions inherited from SnapController
void addGuideLineModel ()
 Adds a guide line model to the scene for visual feedback.
void addGuidePlaneModel ()
 Adds a guide plane model to the scene for visual feedback.
void addGuidePointModel ()
 Adds a guide point model to the scene for visual feedback.
virtual void addPoint (const SnapPoint &point)
 Adds a snap point (with snap metadata) to the accumulated points buffer.
virtual void addPoint (const Vertex< 3, fltp08 > &point)
 Adds a 3D point to the accumulated points buffer.
void calcLockLineLocation (SnapPoint &point, const SelectionInfo &info)
 Calculates the constrained snap point position along a lock line.
void calcLockPlaneLocation (SnapPoint &point, const SelectionInfo &info)
 Calculates the constrained snap point position on a lock plane.
SnapPoint calcSnapPoint (const SelectionInfo &info, DesignObjectLookup *lookup)
 Calculates the best snap point for the current selection context.
void drawDefaultGuideLines (const SnapPoint &point)
 Draws the default set of guide lines based on the current snap point context.
void drawDefaultGuidePlane (const SnapPoint &point)
 Draws the default guide plane based on the current snap point context.
UUID lineMaterial (const SnapPoint &point)
 Returns the material UUID appropriate for the given snap point's guide line type.
UUID pointMaterial (const SnapPoint &point)
 Returns the material UUID appropriate for the given snap point type.
bool processMouseSelection (MouseControllerEvent &event)
 Processes a mouse event for object selection (non-snap interaction).
bool processMouseSnap (MouseControllerEvent &event, SelectionInfo &info)
 Processes a mouse event specifically for snapping logic.
void processUserInput ()
 Processes any pending user text input for dimension locking.
void setGuideLine (uint04 index, const Vertex< 3, fltp08 > &p1, const Vector< 3, fltp08 > &p2, const UUID &material)
 Sets the start position, direction, and material of a guide line at the given index.
void setGuideLineVisible (bool visible)
 Sets the visibility of all guide lines.
void setGuideLineVisible (uint04 index, bool visible)
 Sets the visibility of a specific guide line by index.
void setGuidePlane (uint04 index, const Vector< 3, fltp08 > &normal, const Vertex< 3, fltp08 > &location, fltp08 radius)
 Sets the orientation, position, and size of a guide plane at the given index.
void setGuidePlaneVisible (bool visible)
 Sets the visibility of all guide planes.
void setGuidePlaneVisible (uint04 index, bool visible)
 Sets the visibility of a specific guide plane by index.
void setGuidePoint (uint04 index, const Vertex< 3, fltp08 > &p1, const UUID &material)
 Sets the position and material of a guide point at the given index.
void setGuidePointVisible (bool visible)
 Sets the visibility of all guide points.
void setGuidePointVisible (uint04 index, bool visible)
 Sets the visibility of a specific guide point by index.
Model setupGuideModel ()
 Creates and returns a Model configured as a guide visual element.
virtual void setupSelectionInfo (const MouseEvent &event, Camera *camera, SelectionInfo &info)
 Populates a SelectionInfo from the given mouse event and camera.
virtual void updateLocation (const Vertex< 3, fltp08 > &location, bool is_click, Camera *camera)
 Called when the snap location is updated.
void updateRecentGeometry (const SnapPoint &point)
 Updates the recent geometry cache with the latest snap point for extending/snapping to nearby geometry in future operations.

Protected Attributes

UUID m_current_selection
 UUID of the currently selected object.
bool m_darken_mask_exclusion
 Whether to darken geometry excluded by masks instead of hiding.
bool m_hide_mask_exclusion
 Whether to hide geometry excluded by masks.
uint04 m_highlighted_mask
 Index of the currently highlighted mask, or invalid if none.
bool m_inverted_selection
 Whether selection logic is inverted (select outside).
bool m_is_edit_selection
 Whether the controller is in edit-selection mode.
Buffer< UUIDm_last_mask_geometries
 UUIDs of geometries created for the last set of masks.
Buffer< UUIDm_last_selection_geometries
 UUIDs of geometries created for the last selection.
UUID m_original_camera = Constant<UUID>::Invalid
 UUID of the camera state before selection began.
bool m_selection_complete
 Whether the user has finished making a selection.
SelectionInfo m_selection_highlight_info
 Saved selection info for restoring previous highlight state.
SelectionInfo m_selection_info
 The active selection info for the current interaction.
SelectionInfo m_selection_mask_info
 Selection info used only when selecting mask objects.
SubSelectionMode m_sub_selection_mode
 The current sub-selection mode.
bool m_temp_inverted
 Temporary inversion state (e.g., while holding a modifier key).
Protected Attributes inherited from SnapController
UUID m_blue_line_material = Constant<UUID>::Invalid
 Material for Z-axis (blue) guide lines.
UUID m_center_point_material = Constant<UUID>::Invalid
 Material for snap points at center points.
UUID m_current_line_material = Constant<UUID>::Invalid
 Material UUID for the current guide line being drawn.
ConstPointer< SnapsManagerm_custom_snap_manager
 Optional custom snap manager overriding default snap behavior.
UUID m_edge_point_material = Constant<UUID>::Invalid
 Material for snap points on edges.
UUID m_end_point_material = Constant<UUID>::Invalid
 Material for snap points at endpoints.
UUID m_extend_line_material = Constant<UUID>::Invalid
 Material for extension guide lines.
std::function< void(bool is_accepted)> m_finished_callback
 Callback invoked when the snap operation finishes.
UUID m_free_line_material = Constant<UUID>::Invalid
 Material for free (unconstrained) guide lines.
UUID m_free_point_material = Constant<UUID>::Invalid
 Material for free (unconstrained) snap points.
UUID m_green_line_material = Constant<UUID>::Invalid
 Material for Y-axis (green) guide lines.
Buffer< UUIDm_guide_line_material
 Materials assigned to each guide line.
Buffer< UUIDm_guide_line_model
 UUIDs of individual guide line models.
UUID m_guide_model = Constant<UUID>::Invalid
 UUID of the root guide model in the scene.
Buffer< UUIDm_guide_plane_material
 Materials assigned to each guide plane.
Buffer< UUIDm_guide_plane_model
 UUIDs of individual guide plane models.
Buffer< UUIDm_guide_point_material
 Materials assigned to each guide point.
Buffer< UUIDm_guide_point_model
 UUIDs of individual guide point models.
bool m_is_active
 Whether the snap controller is currently active.
bool m_is_horizontal_locked = false
 Whether horizontal axis locking is currently active.
bool m_is_using_lock_plane = false
 Whether a lock plane is currently in use for constraining.
bool m_is_vertical_locked = false
 Whether vertical axis locking is currently active.
Cameram_last_camera = nullptr
 The camera used in the last event processing.
Buffer< std::pair< UUID, uint04 > > m_last_lines
 Recently snapped line geometry (UUID and vertex index pairs).
DesignObjectLookupm_last_lookup = nullptr
 The DesignObjectLookup used in the last event processing.
Buffer< std::pair< UUID, uint04 > > m_last_meshes
 Recently snapped mesh geometry (UUID and face index pairs).
MouseEvent m_last_mouse_event
 The most recently processed mouse event.
Buffer< std::pair< UUID, uint04 > > m_last_points
 Recently snapped point geometry (UUID and vertex index pairs).
UUID m_last_selection_camera = Constant<UUID>::Invalid
 UUID of the camera used in the last selection operation.
Buffer< SnapPointm_last_snap_points
 The most recently computed set of candidate snap points.
Buffer< UUIDm_line_guide_text
 UUIDs of text labels attached to guide lines.
UUID m_line_mesh = Constant<UUID>::Invalid
 UUID of the mesh used for guide lines.
Vertex< 3, fltp08m_location
 The current snap location in 3D space.
Vertex< 3, fltp08m_lock_axis
 Per-axis lock values (NaN or invalid means unlocked).
LineSegment< 3, fltp08m_lock_line
 The line segment used for line-lock constraining.
Vertex< 3, fltp08m_lock_location
 The reference location used for lock calculations.
LockMode m_lock_mode
 The active lock mode controlling snap-lock interaction.
Plane< 3, fltp08m_lock_plane
 The plane used for plane-lock constraining.
UUID m_locked_line_material = Constant<UUID>::Invalid
 Material for locked/constrained guide lines.
DesignObjectLookupm_manager
 The DesignObjectLookup this controller operates on.
UUID m_mid_point_material = Constant<UUID>::Invalid
 Material for snap points at midpoints.
UUID m_on_face_point_material = Constant<UUID>::Invalid
 Material for snap points on faces.
SnapPoint m_original_snap
 The original snap point before lock adjustments.
UUID m_perpendicular_line_material = Constant<UUID>::Invalid
 Material for perpendicular guide lines.
UUID m_plane_mesh = Constant<UUID>::Invalid
 UUID of the mesh used for guide planes.
PointsDrawMode m_point_draw_mode
 The current draw mode for accumulated points.
Buffer< UUIDm_point_guide_text
 UUIDs of text labels attached to guide points.
UUID m_point_material = Constant<UUID>::Invalid
 Material for generic snap points.
UUID m_point_mesh = Constant<UUID>::Invalid
 UUID of the mesh used for guide points.
Buffer< Vertex< 3, fltp08 > > m_points
 Accumulated 3D snap points from user clicks.
UUID m_red_line_material = Constant<UUID>::Invalid
 Material for X-axis (red) guide lines.
SelectionMode m_selection_mode
 The current selection mode used during interaction.
bool m_show_length_label
 Whether length labels are displayed on guide lines.
bool m_show_location_label
 Whether coordinate labels are displayed at snap points.
UUID m_tangent_line_material = Constant<UUID>::Invalid
 Material for tangent guide lines.
std::function< void()> m_update_callback
 Callback invoked when the snap state is updated.
EditDimensionLockInformation m_user_edit
 Current user dimension lock edit state.

Additional Inherited Members

Public Types inherited from SnapController
enum  LockMode {
  e_lock_ignore_snap , e_lock_to_nearest_snap , e_lock_if_no_snap , e_only_allow_snap ,
  e_ignore
}
 Controls how axis/plane locking interacts with snapping behavior. More...
enum  PointsDrawMode {
  e_points , e_triangle , e_lines , e_line_fan ,
  e_polyline
}
 Determines how snapped points are drawn or connected visually in the viewport. More...
Public Attributes inherited from SnapController
Resource< SnapPointcurrent_snap_point
 The currently active snap point resource, updated as the mouse moves.

Detailed Description

Allows user to select data in a DesignObjectLookup.


Extends SnapController to provide interactive selection of models, vertices, and regions within a 3D viewport. Supports selection masks, inverted selection, sub-selection modes (single model, rectangle, polygon), and filtering callbacks.

See also
SelectionInfo, DesignSelection, SnapsManager, SelectionEffect

Definition at line 59 of file SelectionController.h.

Constructor & Destructor Documentation

◆ SelectionController()

SelectionController::SelectionController ( DesignObjectLookup * manager)
explicit

Constructs a SelectionController for the given design object lookup.

Parameters
[in]managerThe DesignObjectLookup that this controller operates on.

Member Function Documentation

◆ addCurrentAsMask()

uint04 SelectionController::addCurrentAsMask ( )

Converts the current selection into a mask and adds it.

Returns
The index of the newly added mask.

◆ addMask()

uint04 SelectionController::addMask ( const SelectionArea< 3, fltp08 > & mask)

Adds a 3D selection area as a mask.

Parameters
[in]maskThe selection area to add as a mask.
Returns
The index of the newly added mask.

◆ clear()

void SelectionController::clear ( bool clear_selection,
bool clear_masks )

Clears the selection state and/or masks.

Parameters
[in]clear_selectionTrue to clear the active selection.
[in]clear_masksTrue to clear all masks.

◆ currentSelection()

UUID SelectionController::currentSelection ( ) const

Returns the UUID of the currently selected object.

Returns
The UUID of the current selection, or an invalid UUID if nothing is selected.

◆ currentSelectionHint()

String SelectionController::currentSelectionHint ( ) const

Returns a hint string describing the current selection state.

Returns
A string describing the current selection for user display.

◆ darkenMaskExclusion()

void SelectionController::darkenMaskExclusion ( bool darken)

Sets whether mask-excluded geometry should be darkened.

Parameters
[in]darkenTrue to darken excluded geometry.

◆ darkensMaskExclusion()

bool SelectionController::darkensMaskExclusion ( ) const
inline

Checks whether mask-excluded geometry is darkened rather than hidden.

Returns
True if exclusion darkening is active.

Definition at line 183 of file SelectionController.h.

References m_darken_mask_exclusion.

◆ defaultHint()

TranslatedString SelectionController::defaultHint ( const TranslatedString & action_hint) const

Returns a default hint string combining the action hint with selection context.

Parameters
[in]action_hintThe action-specific hint text to incorporate.
Returns
A translated hint string for user display.

◆ highlightMask()

void SelectionController::highlightMask ( uint04 mask_index)

Visually highlights a specific mask.

Parameters
[in]mask_indexThe index of the mask to highlight.

◆ isInvertedSelection()

bool SelectionController::isInvertedSelection ( ) const

Checks whether the selection logic is inverted (selecting outside rather than inside).

Returns
True if the selection is inverted.

◆ masks()

const Buffer< SelectionArea< 3, fltp08 > > & SelectionController::masks ( ) const

Returns a read-only reference to all current selection masks.

Returns
A buffer of 3D selection areas used as masks.

◆ processKeyEvent()

virtual bool SelectionController::processKeyEvent ( const KeyEvent & event,
DesignObjectLookup * lookup,
Camera * camera )
overridevirtual

Processes a keyboard event for selection interaction.

Parameters
[in]eventThe key event to process.
[in]lookupThe design object lookup for context.
[in]cameraThe active camera.
Returns
True if the event was handled.

Reimplemented from SnapController.

◆ processMouseEvent()

virtual bool SelectionController::processMouseEvent ( MouseControllerEvent & event,
SelectionInfo & info )
overridevirtual

Processes a mouse event for selection interaction.

Parameters
[in]eventThe mouse controller event to process.
[in]infoThe current selection info context.
Returns
True if the event was handled.

Reimplemented from SnapController.

◆ removeMask()

void SelectionController::removeMask ( uint04 mask_index)

Removes a mask by index.

Parameters
[in]mask_indexThe index of the mask to remove.

◆ selectionComplete()

bool SelectionController::selectionComplete ( ) const
inline

Checks whether the user has completed the selection.

Returns
True if the selection is complete.

Definition at line 166 of file SelectionController.h.

References m_selection_complete.

◆ setCameraShowEnvironment()

void SelectionController::setCameraShowEnvironment ( bool show_grid)

Sets whether the camera environment (skybox/background scene) is shown.

Parameters
[in]show_gridTrue to show the environment.

◆ setCameraShowGrid()

void SelectionController::setCameraShowGrid ( bool show_grid)

Sets whether the camera grid is shown.

Parameters
[in]show_gridTrue to show the grid.

◆ setHideMaskExclusion()

void SelectionController::setHideMaskExclusion ( bool is_hidden)

Sets whether geometry excluded by masks should be hidden entirely.

Parameters
[in]is_hiddenTrue to hide mask-excluded geometry.

◆ setInvertedSelection()

void SelectionController::setInvertedSelection ( bool is_inside)

Sets whether selection is inverted.

Parameters
[in]is_insideTrue to invert selection (select outside the region).

◆ setIsEditSelection()

void SelectionController::setIsEditSelection ( bool is_edit_selection)

Sets whether this selection controller is operating in edit-selection mode.

Parameters
[in]is_edit_selectionTrue to enable edit-selection mode.

◆ setMaskEnabled()

void SelectionController::setMaskEnabled ( uint04 index,
bool enabled )

Enables or disables a specific mask by index.

Parameters
[in]indexThe index of the mask to modify.
[in]enabledTrue to enable the mask, false to disable it.

◆ setPreGeometryFilter()

void SelectionController::setPreGeometryFilter ( const std::function< bool(const Model &, const Geometry &)> & pre_geometry_filter)

Sets a filter applied before testing a geometry within a model for selection.

The callback should return true if the geometry should be tested for selection, false to skip it.

Parameters
[in]pre_geometry_filterThe filter function to apply.

◆ setPreModelFilter()

void SelectionController::setPreModelFilter ( const std::function< bool(const Model &)> & pre_model_filter)

Sets a filter applied before testing a model for selection.

The callback should return true if the model should be tested for selection, false to skip it entirely.

Parameters
[in]pre_model_filterThe filter function to apply.

◆ setSelectionFilter()

void SelectionController::setSelectionFilter ( const std::function< bool(const Model &)> & selection_filter)

Sets a filter applied after a selection is made to resolve the appropriate parent.

The callback should return true if the model is selectable, false to reject it.

Parameters
[in]selection_filterThe filter function to apply.

◆ setSelectionMaskInfo()

void SelectionController::setSelectionMaskInfo ( const SelectionInfo & info)
protected

Stores the selection mask info from the given SelectionInfo.

Parameters
[in]infoThe SelectionInfo to copy mask data from.

◆ setSubSelectionMode()

void SelectionController::setSubSelectionMode ( const SubSelectionMode & mode)

Sets the sub-selection mode (single model, vertex rectangle, vertex polygon, etc.).

Parameters
[in]modeThe SubSelectionMode to apply.

◆ setThemeCameraBackgroundColor()

void SelectionController::setThemeCameraBackgroundColor ( const RGBColor & color)

Sets the fallback camera background color used when no theme default is available.

Parameters
[in]colorThe background color to use.

◆ subSelectionMode()

SubSelectionMode SelectionController::subSelectionMode ( ) const
inline

Returns the current sub-selection mode.

Returns
The active SubSelectionMode.

Definition at line 140 of file SelectionController.h.

References m_sub_selection_mode.

◆ updateSelectionInfo()

void SelectionController::updateSelectionInfo ( SelectionInfo & info)

Updates the provided SelectionInfo with the current selection state.

Parameters
[in]infoThe SelectionInfo to update.

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