Editor API
UnigineEditor public API
Editor::SelectorNodes Class Reference

This class is used to manage selected nodes along with their subobjects (such as surfaces, shapes, joints, billboards, etc.). More...

#include <Selector.h>

Inheritance diagram for Editor::SelectorNodes:
Editor::Selector

Classes

class  SubItemList
 This class represents a list of selected subitems of a selected node. When an object is selected, some of its surfaces or collision shapes can also be selected, the subitems list shall contain all of them. More...
 

Public Types

enum  SubType { INDEXED = 0, USER = 0x0100 }
 Subitem type. The first 256 types are reserved by UNIGINE, user subitem types start from USER + i (256 and higher). More...
 

Public Member Functions

 SelectorNodes ()
 
 SelectorNodes (const QVector< Unigine::NodePtr > &nodes)
 
 ~SelectorNodes () override
 
int type () const override
 Returns the current selector type. More...
 
bool equal (const Selector *selector) const override
 Checks whether the selector is equal to the specified target selector. More...
 
SelectorNodesclone () const override
 Clones the current nodes selector. More...
 
QVector< Unigine::NodePtr > getNodes () const
 Returns the list of all selected nodes. More...
 
int size () const
 Returns the number of selected nodes. More...
 
bool empty () const
 Checks whether the nodes selector is empty (no nodes are currently selected). More...
 
void extend (const Unigine::NodePtr &node)
 Extends the current selection by adding the specified node to it. More...
 
void extend (const QVector< Unigine::NodePtr > &nodes)
 Extends the current selection by adding the specified list of nodes to it. More...
 
void extend (const Unigine::NodePtr &node, SubItemList *subs)
 Extends the current selection by adding the specified node to it along with the list of selected subitems. More...
 
void exclude (const Unigine::NodePtr &node)
 Excludes the specified node from the current selection. More...
 
void exclude (const QVector< Unigine::NodePtr > &nodes)
 Excludes the specified list of nodes from the current selection. More...
 
void exclude (Constants::SubObjectType stype)
 Excludes the specified type of subitems from the current selection for all selected nodes (e.g., remove all joints from the selection for all selected nodes). More...
 
bool contains (const Unigine::NodePtr &node)
 Checks whether the current selection contains the specified node. More...
 
SubItemListgetSubItemList (int node_id) const
 Gets the list of subitems for the selected node with the specified ID. More...
 
SubItemListgetSubItemList (const Unigine::NodePtr &node) const
 Gets the list of subitems for the specified selected node. More...
 
IndexListgetIndexList (int node_id) const
 Gets the list of subitem indices for the the selected node with the specified ID. Some subitems (such as surfaces, shapes, joints, billboards, forces, noises, or deflectors) are referred to via indices, and unlike the getSubItemList() which returns the list of subitems, this method returns the list of indices for them. More...
 
IndexListgetIndexList (const Unigine::NodePtr &node) const
 Gets the list of subitem indices for the specified selected node. Some subitems (such as surfaces, shapes, joints, billboards, forces, noises, or deflectors) are referred to via indices, and unlike the getSubItemList() which returns the list of subitems, this method returns the list of indices for them. More...
 
QSet< int > getIntersectedIndexes (Constants::SubObjectType stype) const
 Gets the list of indices of the specified subitem type that are currently selected for all selected nodes (e.g., if surfaces 0, 1, 2, 3 of the first selected object and surfaces 1 and 3 of the second one are selected the result will be: {1, 3}). Some subitems (such as surfaces, shapes, joints, billboards, forces, noises, or deflectors) are referred to via indices, and unlike the getSubItemList() which returns the list of subitems, this method returns the list of indices for them. More...
 
void resetCache ()
 Resets nodes cache used for selection. Storing direct pointers to nodes is unsafe, so their IDs are stored instead. To optimize retrieval of nodes by their IDs the nodes cache is used. This method is used to reset this cache when it is no longer valid (e.g., in case of loading another world). More...
 
void setNeedExpand (bool value)
 
bool isNeedExpand () const
 
- Public Member Functions inherited from Editor::Selector
 Selector ()
 
virtual ~Selector ()
 

Static Public Member Functions

static SelectorNodescreateObjectsSelector (const QVector< Unigine::NodePtr > &nodes)
 Creates a new selection (SelectorNodes) combining all objects from the specified list of nodes. All surfaces of these objects shall also be included in the current selection. More...
 

Detailed Description

This class is used to manage selected nodes along with their subobjects (such as surfaces, shapes, joints, billboards, etc.).

Member Enumeration Documentation

◆ SubType

Subitem type. The first 256 types are reserved by UNIGINE, user subitem types start from USER + i (256 and higher).

Enumerator
INDEXED 

Subitems of nodes referred to via indices (such as surfaces, shapes, joints, billboards, forces, noises, or deflectors).

USER 

Beginning of the range of user-defined subitem types. Types are referred to as USER+0, USER+1...

Constructor & Destructor Documentation

◆ SelectorNodes() [1/2]

Editor::SelectorNodes::SelectorNodes ( )

◆ SelectorNodes() [2/2]

Editor::SelectorNodes::SelectorNodes ( const QVector< Unigine::NodePtr > &  nodes)
explicit

◆ ~SelectorNodes()

Editor::SelectorNodes::~SelectorNodes ( )
override

Member Function Documentation

◆ clone()

SelectorNodes* Editor::SelectorNodes::clone ( ) const
overridevirtual

Clones the current nodes selector.

Returns
Clone of the current nodes selector.

Implements Editor::Selector.

◆ contains()

bool Editor::SelectorNodes::contains ( const Unigine::NodePtr &  node)

Checks whether the current selection contains the specified node.

Parameters
nodeNode to be checked.
Returns
true if the current selection contains the specified node; otherwise, false.

◆ createObjectsSelector()

static SelectorNodes* Editor::SelectorNodes::createObjectsSelector ( const QVector< Unigine::NodePtr > &  nodes)
static

Creates a new selection (SelectorNodes) combining all objects from the specified list of nodes. All surfaces of these objects shall also be included in the current selection.

Returns
Selector of the nodes type including all objects from the specified list of nodes, or nullptr if there are no objects in the specified list.

◆ empty()

bool Editor::SelectorNodes::empty ( ) const

Checks whether the nodes selector is empty (no nodes are currently selected).

Returns
true if the selector is empty; otherwise, false.

◆ equal()

bool Editor::SelectorNodes::equal ( const Selector selector) const
overridevirtual

Checks whether the selector is equal to the specified target selector.

Parameters
selectorTarget selector.
Returns
true if selectors are equal; otherwise, false.

Implements Editor::Selector.

◆ exclude() [1/3]

void Editor::SelectorNodes::exclude ( const Unigine::NodePtr &  node)

Excludes the specified node from the current selection.

Parameters
nodeNode to be excluded from the current selection.

◆ exclude() [2/3]

void Editor::SelectorNodes::exclude ( const QVector< Unigine::NodePtr > &  nodes)

Excludes the specified list of nodes from the current selection.

Parameters
nodesVector containing nodes to be excluded from the current selection.

◆ exclude() [3/3]

void Editor::SelectorNodes::exclude ( Constants::SubObjectType  stype)

Excludes the specified type of subitems from the current selection for all selected nodes (e.g., remove all joints from the selection for all selected nodes).

Parameters
stypeType of subitems to be excluded from the current selection for all nodes (Constants::SubObjectType).

◆ extend() [1/3]

void Editor::SelectorNodes::extend ( const Unigine::NodePtr &  node)

Extends the current selection by adding the specified node to it.

Parameters
nodeNode to be added to the current selection.

◆ extend() [2/3]

void Editor::SelectorNodes::extend ( const QVector< Unigine::NodePtr > &  nodes)

Extends the current selection by adding the specified list of nodes to it.

Parameters
nodesVector containing nodes to be added to the current selection.

◆ extend() [3/3]

void Editor::SelectorNodes::extend ( const Unigine::NodePtr &  node,
SubItemList subs 
)

Extends the current selection by adding the specified node to it along with the list of selected subitems.

Parameters
nodeNode to be added to the current selection.
subsList of subitems to be added to the current selection.

◆ getIndexList() [1/2]

IndexList* Editor::SelectorNodes::getIndexList ( int  node_id) const

Gets the list of subitem indices for the the selected node with the specified ID. Some subitems (such as surfaces, shapes, joints, billboards, forces, noises, or deflectors) are referred to via indices, and unlike the getSubItemList() which returns the list of subitems, this method returns the list of indices for them.

Parameters
node_idID of the selected node for which the list of indices of selected subitems is to be obtained.
Returns
List of indices of selected subitems for the selected node with the specified ID (if any); otherwise, nullptr.

◆ getIndexList() [2/2]

IndexList* Editor::SelectorNodes::getIndexList ( const Unigine::NodePtr &  node) const

Gets the list of subitem indices for the specified selected node. Some subitems (such as surfaces, shapes, joints, billboards, forces, noises, or deflectors) are referred to via indices, and unlike the getSubItemList() which returns the list of subitems, this method returns the list of indices for them.

Parameters
nodeSelected node for which the list of indices of selected subitems is to be obtained.
Returns
List of indices of selected subitems for the specified selected node (if any); otherwise, nullptr.

◆ getIntersectedIndexes()

QSet<int> Editor::SelectorNodes::getIntersectedIndexes ( Constants::SubObjectType  stype) const

Gets the list of indices of the specified subitem type that are currently selected for all selected nodes (e.g., if surfaces 0, 1, 2, 3 of the first selected object and surfaces 1 and 3 of the second one are selected the result will be: {1, 3}). Some subitems (such as surfaces, shapes, joints, billboards, forces, noises, or deflectors) are referred to via indices, and unlike the getSubItemList() which returns the list of subitems, this method returns the list of indices for them.

Parameters
stypeSelected node for which the list of indices of selected subitems is to be obtained.
Returns
List of indices of selected subitems for the specified selected node (if any); otherwise, nullptr.

◆ getNodes()

QVector<Unigine::NodePtr> Editor::SelectorNodes::getNodes ( ) const

Returns the list of all selected nodes.

Returns
Vector containing all selected.

◆ getSubItemList() [1/2]

SubItemList* Editor::SelectorNodes::getSubItemList ( int  node_id) const

Gets the list of subitems for the selected node with the specified ID.

Parameters
node_idID of the selected node.
Returns
List of subitems for the selected node with the specified ID (if any); otherwise, nullptr.

◆ getSubItemList() [2/2]

SubItemList* Editor::SelectorNodes::getSubItemList ( const Unigine::NodePtr &  node) const

Gets the list of subitems for the specified selected node.

Parameters
nodeSelected node for which the list of selected subitems is to be obtained.
Returns
List of subitems for the specified selected node (if any); otherwise, nullptr.

◆ isNeedExpand()

bool Editor::SelectorNodes::isNeedExpand ( ) const

◆ resetCache()

void Editor::SelectorNodes::resetCache ( )

Resets nodes cache used for selection. Storing direct pointers to nodes is unsafe, so their IDs are stored instead. To optimize retrieval of nodes by their IDs the nodes cache is used. This method is used to reset this cache when it is no longer valid (e.g., in case of loading another world).

◆ setNeedExpand()

void Editor::SelectorNodes::setNeedExpand ( bool  value)

◆ size()

int Editor::SelectorNodes::size ( ) const

Returns the number of selected nodes.

Returns
Number of selected nodes.

◆ type()

int Editor::SelectorNodes::type ( ) const
overridevirtual

Returns the current selector type.

Returns
Current selector type: one of the SelectorType enum values.

Implements Editor::Selector.