Skip to content

Class SelectionManager

template <class _Base>

ClassList > SelectionManager

Generic selection state manager supporting single and multi-selection. More...

  • #include <SelectionManager.h>

Public Functions

Type Name
void Deselect (_Base * obj, bool increment)
Deselects an object.
_Base * GetActiveObject () const
Returns the active (last selected) object.
_Base * GetSelectedObjects () const
Returns the first selected object.
bool IsSelected (_Base * obj) const
Checks if an object is selected.
void Select (_Base * obj, bool increment)
Selects an object.

Detailed Description

SelectionManager maintains a list of selected objects with fast lookup. It distinguishes between: * Selected objects: All objects in the selection set * Active object: The last selected object (primary selection) * Hovered object: Object under mouse cursor (not selected yet)

Usage Examples: * Scene object selection in Outliner/Viewport * Material selection in MaterialViewer * Node selection in node editor

Selection Modes: * increment=false: Single selection (replace existing) * increment=true: Multi-selection (add to set)

Performance: * Select: O(1) lookup + O(1) append * IsSelected: O(1) hash lookup * GetSelected: O(1) vector access

Template parameters:

  • _Base Base type of selectable objects (must support pointer semantics)

Note:

Active object is always the last selected object in the list

Note:

Duplicate selections are prevented via _selection_cache

Public Functions Documentation

function Deselect

Deselects an object.

inline void SelectionManager::Deselect (
    _Base * obj,
    bool increment
) 

Removes obj from selection set. If obj was active, the previous object becomes active.

Parameters:

  • obj Pointer to object to deselect (nullptr ignored)
  • increment Unused parameter (kept for API consistency)

Note:

No-op if obj is not selected


function GetActiveObject

Returns the active (last selected) object.

inline _Base * SelectionManager::GetActiveObject () const

The active object is the primary selection, typically used for displaying properties or applying operations.

Returns:

Pointer to active object, or nullptr if no selection


function GetSelectedObjects

Returns the first selected object.

inline _Base * SelectionManager::GetSelectedObjects () const

Returns:

Pointer to first selected object, or nullptr if no selection

Note:

TODO: Clarify difference from GetActiveObject() or unify API


function IsSelected

Checks if an object is selected.

inline bool SelectionManager::IsSelected (
    _Base * obj
) const

Fast O(1) lookup using internal hash set.

Parameters:

  • obj Pointer to object to check

Returns:

true if obj is in the selection set


function Select

Selects an object.

inline void SelectionManager::Select (
    _Base * obj,
    bool increment
) 

If increment=false (single selection): * Clears existing selection * Adds obj as the only selected object

If increment=true (multi-selection): * If obj not in selection: adds to end (becomes active) * If obj already selected: moves to end (becomes active)

Parameters:

  • obj Pointer to object to select (nullptr ignored)
  • increment Whether to add to selection (true) or replace (false)

Note:

Active object is always selected_objects.back()



The documentation for this class was generated from the following file src/editor/SelectionManager.h