ufe 5.5
Universal Front End is a DCC-agnostic component that will allow a DCC to browse and edit data in multiple data models
Ufe::Selection Class Reference

Selection list for objects in the scene. More...

#include <selection.h>

Inheritance diagram for Ufe::Selection:

Public Types

typedef SceneItemList::const_iterator const_iterator
 
typedef SceneItemList::const_reverse_iterator const_reverse_iterator
 

Public Member Functions

 Selection ()
 Constructors. More...
 
 Selection (std::initializer_list< SceneItem::Ptr > items)
 
 Selection (SceneItemList items)
 
 Selection (const SceneItem::Ptr &item)
 
 Selection (const Selection &)
 
virtual ~Selection ()
 Destructor. More...
 
Selectionoperator= (const Selection &)
 Syntactic convenience that calls replaceWith. More...
 
 Selection (Selection &&)
 Move construction. postClear is called on the argument. More...
 
Selectionoperator= (Selection &&rhs)
 Move assignment. postClear is first called on rhs, then postReplaceWith on this. More...
 
std::size_t size () const
 
bool empty () const
 
bool append (const SceneItem::Ptr &item)
 
bool remove (const SceneItem::Ptr &item)
 
bool insert (const SceneItem::Ptr &position, const SceneItem::Ptr &item)
 
void clear ()
 
void replaceWith (const Selection &selection)
 
bool contains (const Path &path) const
 
bool containsDescendant (const Path &path) const
 
bool containsDescendantInclusive (const Path &path) const
 
bool containsAncestor (const Path &path) const
 
bool containsAncestorInclusive (const Path &path) const
 
SceneItem::Ptr closestCommonAncestor () const
 
SceneItem::Ptr next (const SceneItem::Ptr &item) const
 
const SceneItem::Ptrfront () const
 Element access. More...
 
const SceneItem::Ptrback () const
 
const_iterator cbegin () const
 Iteration interface on SceneItems. More...
 
const_iterator begin () const
 
const_iterator cend () const
 
const_iterator end () const
 
const_reverse_iterator crbegin () const
 
const_reverse_iterator rbegin () const
 
const_reverse_iterator crend () const
 
const_reverse_iterator rend () const
 

Protected Member Functions

bool doAppend (const SceneItem::Ptr &item)
 
bool doRemove (const SceneItem::Ptr &item)
 
bool doInsert (const SceneItem::Ptr &position, const SceneItem::Ptr &item)
 
Selection doClear ()
 
Selection doReplaceWith (const Selection &selection)
 
virtual void postAppend (const SceneItem::Ptr &item)
 
virtual void postRemove (const SceneItem::Ptr &item)
 
virtual void postInsert (const SceneItem::Ptr &position, const SceneItem::Ptr &item)
 
virtual void postClear (const Selection &previous)
 
virtual void postReplaceWith (const Selection &previous)
 
SelectionTrietrie ()
 Trie-based acceleration structure access. More...
 
const SelectionTrietrie () const
 
SceneItemListlist ()
 

Private Member Functions

 Selection (SceneItemList &&list, SelectionTrie &&selectionTrie)
 Constructor used internally to build previous selection list. More...
 

Private Attributes

SceneItemList fList
 
void * fTrieStorage [2]
 

Detailed Description

Selection list for objects in the scene.

This class provides an ordered list composed of selection items. It uses a backing trie data structure so that on average, for a path with c components, addition, lookup, and removal from the selection can be done in O(c) time.

Definition at line 27 of file selection.h.

Member Typedef Documentation

◆ const_iterator

typedef SceneItemList::const_iterator Ufe::Selection::const_iterator

Definition at line 31 of file selection.h.

◆ const_reverse_iterator

typedef SceneItemList::const_reverse_iterator Ufe::Selection::const_reverse_iterator

Definition at line 32 of file selection.h.

Constructor & Destructor Documentation

◆ Selection() [1/7]

Ufe::Selection::Selection ( )

Constructors.

◆ Selection() [2/7]

Ufe::Selection::Selection ( std::initializer_list< SceneItem::Ptr items)

◆ Selection() [3/7]

Ufe::Selection::Selection ( SceneItemList  items)

◆ Selection() [4/7]

Ufe::Selection::Selection ( const SceneItem::Ptr item)

◆ Selection() [5/7]

Ufe::Selection::Selection ( const Selection )

◆ ~Selection()

virtual Ufe::Selection::~Selection ( )
virtual

Destructor.

◆ Selection() [6/7]

Ufe::Selection::Selection ( Selection &&  )

Move construction. postClear is called on the argument.

◆ Selection() [7/7]

Ufe::Selection::Selection ( SceneItemList &&  list,
SelectionTrie &&  selectionTrie 
)
private

Constructor used internally to build previous selection list.

Member Function Documentation

◆ append()

bool Ufe::Selection::append ( const SceneItem::Ptr item)

If the item is not on the selection list, append it at the end and return true. If the item is already in the list, do nothing and return false.

Parameters
itemSceneItem to append to the selection list.
Returns
True if the item was added to selection list.
Exceptions
std::invalid_argumentif the argument is a null pointer.
Complexity
Amortized O(m) for an item with a path of m components.

◆ back()

const SceneItem::Ptr & Ufe::Selection::back ( ) const

◆ begin()

const_iterator Ufe::Selection::begin ( ) const

◆ cbegin()

const_iterator Ufe::Selection::cbegin ( ) const

Iteration interface on SceneItems.

◆ cend()

const_iterator Ufe::Selection::cend ( ) const

◆ clear()

void Ufe::Selection::clear ( )

Remove all SceneItems from the selection list.

Complexity
O(n) for a selection with n items.

◆ closestCommonAncestor()

SceneItem::Ptr Ufe::Selection::closestCommonAncestor ( ) const

Finds the single common parent of the existing selection.

Returns
Common parent SceneItem if it exists, null pointer if not.
Exceptions
std::invalid_argumentif the selection is empty.
Complexity
Amortized O(m) for a selection with m components.

◆ contains()

bool Ufe::Selection::contains ( const Path path) const
Parameters
pathPath to verify if is in selection list.
Returns
True if the given Path is in the selection list.
Complexity
Amortized O(m) for a path of m components.

◆ containsAncestor()

bool Ufe::Selection::containsAncestor ( const Path path) const

Query whether the selection contains an ancestor of the argument path. Must be a strict ancestor: if the selection contains only the argument itself, returns false. If the argument path is empty, returns false.

Parameters
pathdescendant Path
Returns
True if an ancestor of the argument Path is in the selection
Complexity
Amortized O(m) for an argument path of m components.

◆ containsAncestorInclusive()

bool Ufe::Selection::containsAncestorInclusive ( const Path path) const

Query whether the selection contains the argument path or an ancestor of the argument path. If the argument path is empty, returns false.

Parameters
pathdescendant Path
Returns
True if the argument Path or an ancestor of the argument Path is in the selection
Complexity
Amortized O(m) for an argument path of m components.

◆ containsDescendant()

bool Ufe::Selection::containsDescendant ( const Path path) const

Query whether the selection contains a descendant of the argument path. Must be a strict descendant: if the selection contains only the argument itself, returns false. If the argument path is empty, returns false.

Parameters
pathancestor Path
Returns
True if a descendant of the argument Path is in the selection
Complexity
Amortized O(m) for an argument path of m components.

◆ containsDescendantInclusive()

bool Ufe::Selection::containsDescendantInclusive ( const Path path) const

Query whether the selection contains the argument path or a descendant of the argument path. If the argument path is empty, returns false.

Parameters
pathancestor Path
Returns
True if the argument Path or a descendant of the argument Path is in the selection
Complexity
Amortized O(m) for an argument path of m components.

◆ crbegin()

const_reverse_iterator Ufe::Selection::crbegin ( ) const

◆ crend()

const_reverse_iterator Ufe::Selection::crend ( ) const

◆ doAppend()

bool Ufe::Selection::doAppend ( const SceneItem::Ptr item)
protected

Engine methods for append, remove, insert, clear, and replaceWith, to implement the Template Method design pattern. See

https://en.wikipedia.org/wiki/Template_method_pattern

◆ doClear()

Selection Ufe::Selection::doClear ( )
protected

◆ doInsert()

bool Ufe::Selection::doInsert ( const SceneItem::Ptr position,
const SceneItem::Ptr item 
)
protected

◆ doRemove()

bool Ufe::Selection::doRemove ( const SceneItem::Ptr item)
protected

◆ doReplaceWith()

Selection Ufe::Selection::doReplaceWith ( const Selection selection)
protected

◆ empty()

bool Ufe::Selection::empty ( ) const
Returns
True if size() == 0.

◆ end()

const_iterator Ufe::Selection::end ( ) const

◆ front()

const SceneItem::Ptr & Ufe::Selection::front ( ) const

Element access.

◆ insert()

bool Ufe::Selection::insert ( const SceneItem::Ptr position,
const SceneItem::Ptr item 
)

Insert item just before the position item. If the item is already in the list, do nothing and return false. If position is the null pointer, append. Will throw an exception if the position argument is not found.

Parameters
positionSceneItem before which to insert into selection list.
itemSceneItem to insert into selection list.
Returns
True if the item was inserted into selection list.
Exceptions
std::invalid_argumentif item is a null pointer, or if position is not found.
Complexity
Amortized O(m) for an item with a path of m components.

◆ list()

SceneItemList & Ufe::Selection::list ( )
inlineprotected

Internal SceneItem list structure access. Do not change the order of this list as the internal trie saves iterators into fList.

Definition at line 223 of file selection.h.

◆ next()

SceneItem::Ptr Ufe::Selection::next ( const SceneItem::Ptr item) const

Finds the item which follows the argument item. This can be used to undo the effect of remove, by using insert.

Parameters
itemSceneItem whose successor must be found.
Returns
Successor SceneItem, or null pointer if the argument is the last item in the selection.
Exceptions
std::invalid_argumentif the argument item is not found.
Complexity
Amortized O(m) for a selection with m components.

◆ operator=() [1/2]

Selection & Ufe::Selection::operator= ( const Selection )

Syntactic convenience that calls replaceWith.

◆ operator=() [2/2]

Selection & Ufe::Selection::operator= ( Selection &&  rhs)

Move assignment. postClear is first called on rhs, then postReplaceWith on this.

◆ postAppend()

virtual void Ufe::Selection::postAppend ( const SceneItem::Ptr item)
protectedvirtual

Reimplemented in Ufe::ObservableSelection.

◆ postClear()

virtual void Ufe::Selection::postClear ( const Selection previous)
protectedvirtual

Reimplemented in Ufe::ObservableSelection.

◆ postInsert()

virtual void Ufe::Selection::postInsert ( const SceneItem::Ptr position,
const SceneItem::Ptr item 
)
protectedvirtual

Reimplemented in Ufe::ObservableSelection.

◆ postRemove()

virtual void Ufe::Selection::postRemove ( const SceneItem::Ptr item)
protectedvirtual

Reimplemented in Ufe::ObservableSelection.

◆ postReplaceWith()

virtual void Ufe::Selection::postReplaceWith ( const Selection previous)
protectedvirtual

Reimplemented in Ufe::ObservableSelection.

◆ rbegin()

const_reverse_iterator Ufe::Selection::rbegin ( ) const

◆ remove()

bool Ufe::Selection::remove ( const SceneItem::Ptr item)

Remove the item from the selection list, if present, and return true. If no such item is on the list, return false.

Parameters
itemSceneItem to remove from selection list.
Returns
True if the item was removed from selection list.
Exceptions
std::invalid_argumentif the argument is a null pointer.
Complexity
Amortized O(m) for an item with a path of m components.

◆ rend()

const_reverse_iterator Ufe::Selection::rend ( ) const

◆ replaceWith()

void Ufe::Selection::replaceWith ( const Selection selection)

Replace all SceneItems in the selection list with those from the argument selection list. The items are shared between both lists (shallow copy).

Parameters
selectionSelection to replace with.
Complexity
O(n) for an existing selection and argument selection of n items.

◆ size()

std::size_t Ufe::Selection::size ( ) const
Returns
Size of scene items in the selection.

◆ trie() [1/2]

SelectionTrie & Ufe::Selection::trie ( )
protected

Trie-based acceleration structure access.

◆ trie() [2/2]

const SelectionTrie & Ufe::Selection::trie ( ) const
protected

Member Data Documentation

◆ fList

SceneItemList Ufe::Selection::fList
private

Definition at line 229 of file selection.h.

◆ fTrieStorage

void* Ufe::Selection::fTrieStorage[2]
private

Hidden trie-based untyped storage. The untyped storage avoids a dynamic memory allocation.

Definition at line 233 of file selection.h.


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