NCBI C++ ToolKit
Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
CTreeModel< TNode > Class Template Reference

Search Toolkit Book for CTreeModel

#include <gui/widgets/phylo_tree/tree_model.hpp>

+ Inheritance diagram for CTreeModel< TNode >:
+ Collaboration diagram for CTreeModel< TNode >:

Public Types

typedef TNode TNodeType
 
typedef std::vector< TNodeTypeTNodeVecType
 
typedef TNode::TValueType TValueType
 
typedef TNode::TTreeIdx TTreeIdx
 
typedef TNodeType::TNodeList TNodeList
 
typedef TNodeType::TNodeList_I TNodeList_I
 
typedef TNodeType::TNodeList_CI TNodeList_CI
 
typedef TNodeType::TNodeList_RI TNodeList_RI
 
typedef TNodeType::TNodeList_CRI TNodeList_CRI
 
- Public Types inherited from CObject
enum  EAllocFillMode { eAllocFillNone = 1 , eAllocFillZero , eAllocFillPattern }
 Control filling of newly allocated memory. More...
 
typedef CObjectCounterLocker TLockerType
 Default locker type for CRef. More...
 
typedef atomic< Uint8TCounter
 Counter type is CAtomiCounter. More...
 
typedef Uint8 TCount
 Alias for value type of counter. More...
 

Public Member Functions

 CTreeModel ()
 Create empty tree. Tree is not valid at this point (no nodes) More...
 
virtual ~CTreeModel ()
 
void Clear ()
 Remove all nodes (empty array) and set root index to Null. More...
 
TNodeTypeGetNode (TTreeIdx idx)
 Return a reference to the node at the given index. More...
 
const TNode & GetNode (TTreeIdx idx) const
 
TNodeTypeoperator[] (TTreeIdx idx)
 Use operator[] to return a reference to the node at 'idx'. More...
 
const TNode & operator[] (TTreeIdx idx) const
 
size_t GetSize () const
 Get the number of nodes currently in the array. More...
 
size_t GetNumNodes () const
 Get the number of displayed nodes in current tree layout. More...
 
void SetNumNodes (int count)
 Set the number of displayed nodes in current tree layout. More...
 
TNodeTypeGetParent (TNodeType &node)
 Return a reference to the parent node of the given node. More...
 
const TNodeTypeGetParent (TNodeType &node) const
 
TValueTypeGetNodeValue (TTreeIdx idx)
 Return a reference to the 'value' object of a node. More...
 
const TValueTypeGetNodeValue (TTreeIdx idx) const
 
TNodeTypeGetRoot ()
 Return a reference to the root node of the tree. More...
 
const TNode & GetRoot () const
 
void SetRootIdx (TTreeIdx idx)
 Set the index of the root node of the tree. More...
 
TTreeIdx GetRootIdx () const
 Return the index of the root node. More...
 
void RemoveChild (TTreeIdx parent_idx, TTreeIdx child_idx)
 Remove the node at 'child_idx' from its parent 'parent_idx' Nothing is done if the node 'child_idx' is not a child of that parent. More...
 
void AddChild (TTreeIdx parent_idx, TTreeIdx child_idx)
 Add the node at 'child_idx' to the children 'parent_idx'. More...
 
void ReRoot (TTreeIdx idx)
 Sets the root idx to be 'idx' and updates the tree so that all nodes above the new root become children of that node. More...
 
TTreeIdx AddNode ()
 Add a new default node to the tree and return its index. More...
 
TTreeIdx AddNode (const TNode &node)
 Add a copy of node 'node' to the tree and return its index. More...
 
void Reserve (size_t target_size)
 Allocate the memory in advance, if you know how big the tree will be. More...
 
- Public Member Functions inherited from CObject
 CObject (void)
 Constructor. More...
 
 CObject (const CObject &src)
 Copy constructor. More...
 
virtual ~CObject (void)
 Destructor. More...
 
CObjectoperator= (const CObject &src) THROWS_NONE
 Assignment operator. More...
 
bool CanBeDeleted (void) const THROWS_NONE
 Check if object can be deleted. More...
 
bool IsAllocatedInPool (void) const THROWS_NONE
 Check if object is allocated in memory pool (not system heap) More...
 
bool Referenced (void) const THROWS_NONE
 Check if object is referenced. More...
 
bool ReferencedOnlyOnce (void) const THROWS_NONE
 Check if object is referenced only once. More...
 
void AddReference (void) const
 Add reference to object. More...
 
void RemoveReference (void) const
 Remove reference to object. More...
 
void ReleaseReference (void) const
 Remove reference without deleting object. More...
 
virtual void DoNotDeleteThisObject (void)
 Mark this object as not allocated in heap – do not delete this object. More...
 
virtual void DoDeleteThisObject (void)
 Mark this object as allocated in heap – object can be deleted. More...
 
void * operator new (size_t size)
 Define new operator for memory allocation. More...
 
void * operator new[] (size_t size)
 Define new[] operator for 'array' memory allocation. More...
 
void operator delete (void *ptr)
 Define delete operator for memory deallocation. More...
 
void operator delete[] (void *ptr)
 Define delete[] operator for memory deallocation. More...
 
void * operator new (size_t size, void *place)
 Define new operator. More...
 
void operator delete (void *ptr, void *place)
 Define delete operator. More...
 
void * operator new (size_t size, CObjectMemoryPool *place)
 Define new operator using memory pool. More...
 
void operator delete (void *ptr, CObjectMemoryPool *place)
 Define delete operator. More...
 
virtual void DebugDump (CDebugDumpContext ddc, unsigned int depth) const
 Define method for dumping debug information. More...
 
- Public Member Functions inherited from CDebugDumpable
 CDebugDumpable (void)
 
virtual ~CDebugDumpable (void)
 
void DebugDumpText (ostream &out, const string &bundle, unsigned int depth) const
 
void DebugDumpFormat (CDebugDumpFormatter &ddf, const string &bundle, unsigned int depth) const
 
void DumpToConsole (void) const
 

Static Public Member Functions

static TTreeIdx Null ()
 Return the index value that represents a NULL node. More...
 
- Static Public Member Functions inherited from CObject
static NCBI_XNCBI_EXPORT void ThrowNullPointerException (void)
 Define method to throw null pointer exception. More...
 
static NCBI_XNCBI_EXPORT void ThrowNullPointerException (const type_info &type)
 
static EAllocFillMode GetAllocFillMode (void)
 
static void SetAllocFillMode (EAllocFillMode mode)
 
static void SetAllocFillMode (const string &value)
 Set mode from configuration parameter value. More...
 
- Static Public Member Functions inherited from CDebugDumpable
static void EnableDebugDump (bool on)
 

Protected Member Functions

virtual void x_ConvertUpstream (TTreeIdx node_idx)
 Convert parents of node_idx to be its children. More...
 
- Protected Member Functions inherited from CObject
virtual void DeleteThis (void)
 Virtual method "deleting" this object. More...
 

Protected Attributes

TNodeVecType m_Nodes
 The list of nodes in the tree. More...
 
int m_NumNodes
 Number of nodes in tree (not including collapsed/hidden nodes) More...
 
TTreeIdx m_RootIdx
 The index of the root node within the tree. More...
 

Additional Inherited Members

- Static Public Attributes inherited from CObject
static const TCount eCounterBitsCanBeDeleted = 1 << 0
 Define possible object states. More...
 
static const TCount eCounterBitsInPlainHeap = 1 << 1
 Heap signature was found. More...
 
static const TCount eCounterBitsPlaceMask
 Mask for 'in heap' state flags. More...
 
static const int eCounterStep = 1 << 2
 Skip over the "in heap" bits. More...
 
static const TCount eCounterValid = TCount(1) << (sizeof(TCount) * 8 - 2)
 Minimal value for valid objects (reference counter is zero) Must be a single bit value. More...
 
static const TCount eCounterStateMask
 Valid object, and object in heap. More...
 

Detailed Description

template<class TNode>
class CTreeModel< TNode >

Definition at line 180 of file tree_model.hpp.

Member Typedef Documentation

◆ TNodeList

template<class TNode >
typedef TNodeType::TNodeList CTreeModel< TNode >::TNodeList

Definition at line 188 of file tree_model.hpp.

◆ TNodeList_CI

template<class TNode >
typedef TNodeType::TNodeList_CI CTreeModel< TNode >::TNodeList_CI

Definition at line 190 of file tree_model.hpp.

◆ TNodeList_CRI

template<class TNode >
typedef TNodeType::TNodeList_CRI CTreeModel< TNode >::TNodeList_CRI

Definition at line 192 of file tree_model.hpp.

◆ TNodeList_I

template<class TNode >
typedef TNodeType::TNodeList_I CTreeModel< TNode >::TNodeList_I

Definition at line 189 of file tree_model.hpp.

◆ TNodeList_RI

template<class TNode >
typedef TNodeType::TNodeList_RI CTreeModel< TNode >::TNodeList_RI

Definition at line 191 of file tree_model.hpp.

◆ TNodeType

template<class TNode >
typedef TNode CTreeModel< TNode >::TNodeType

Definition at line 183 of file tree_model.hpp.

◆ TNodeVecType

template<class TNode >
typedef std::vector<TNodeType> CTreeModel< TNode >::TNodeVecType

Definition at line 184 of file tree_model.hpp.

◆ TTreeIdx

template<class TNode >
typedef TNode::TTreeIdx CTreeModel< TNode >::TTreeIdx

Definition at line 186 of file tree_model.hpp.

◆ TValueType

template<class TNode >
typedef TNode::TValueType CTreeModel< TNode >::TValueType

Definition at line 185 of file tree_model.hpp.

Constructor & Destructor Documentation

◆ CTreeModel()

template<class TNode >
CTreeModel< TNode >::CTreeModel ( )
inline

Create empty tree. Tree is not valid at this point (no nodes)

Definition at line 196 of file tree_model.hpp.

◆ ~CTreeModel()

template<class TNode >
virtual CTreeModel< TNode >::~CTreeModel ( )
inlinevirtual

Definition at line 197 of file tree_model.hpp.

Member Function Documentation

◆ AddChild()

template<class TNode >
void CTreeModel< TNode >::AddChild ( TTreeIdx  parent_idx,
TTreeIdx  child_idx 
)

Add the node at 'child_idx' to the children 'parent_idx'.

This does not check to see if the node is already a child.

Parameters
parent_idx- the index of the parent node child_idx - the index of the child node

Definition at line 715 of file tree_model.hpp.

Referenced by CPhyloTreeDataSource::NewNode(), visitor_copy_subtree::operator()(), visitor_paste_subtree::operator()(), and CPhyloTreeDataSource::Remove().

◆ AddNode() [1/2]

template<class TNode >
CTreeModel< TNode >::TTreeIdx CTreeModel< TNode >::AddNode

Add a new default node to the tree and return its index.

Returns
- the index of the new node

Definition at line 749 of file tree_model.hpp.

Referenced by CPhyloTreeDataSource::NewNode(), visitor_copy_subtree::operator()(), and visitor_paste_subtree::operator()().

◆ AddNode() [2/2]

template<class TNode >
CTreeModel< TNode >::TTreeIdx CTreeModel< TNode >::AddNode ( const TNode &  node)

Add a copy of node 'node' to the tree and return its index.

Parameters
node- the node from which to copy the new node
Returns
- the index of the new node

Definition at line 758 of file tree_model.hpp.

◆ Clear()

template<class TNode >
void CTreeModel< TNode >::Clear ( void  )

Remove all nodes (empty array) and set root index to Null.

Definition at line 681 of file tree_model.hpp.

Referenced by CPhyloTree::Clear().

◆ GetNode() [1/2]

template<class TNode >
TNodeType& CTreeModel< TNode >::GetNode ( TTreeIdx  idx)
inline

Return a reference to the node at the given index.

Parameters
idxindex of the node to be returned
Returns
reference to the node at index 'idx'

Definition at line 207 of file tree_model.hpp.

Referenced by CTreeQueryExec::CallFunction(), CPhyloTreeDataSource::CollapseByDistance(), CPhyloTreeDataSource::CollapseSelected(), CPhyloTreeDataSource::ComputeLengthsFromRoot(), CTreeQueryExec::EvalNext(), CPhyloTreeDataSource::ExecuteStringQuery(), IPhyloTreeRender::GetHoverNode(), CPhyTreeView::GetSelection(), CPhyloTreeWidget::IterateSelection(), CPhyloTreeDataSource::MoveNode(), CPhyloTreeDataSource::NewNode(), CPhyloTreeWidget::OnCollapseChildren(), CPhyloTreeWidget::OnExpandChildren(), CPhyloTreeWidget::OnInfoTip(), IPhyloTreeRender::OnLeftDblClick(), CPhyloTreeWidget::OnSearchTip(), CPhyloTreeWidget::OnUpdateCollapseChildren(), CPhyloTreeWidget::OnUpdateCollapseSelected(), CPhyloTreeWidget::OnUpdateExpandChildren(), CPhyloTreeWidget::OnUpdateZoomToSubtree(), CPhyloTreeWidget::OnZoomTip(), CPhyloTreeWidget::OnZoomToSubtree(), CChangePhyloPropertyCmd::PerformEdit(), CChangePhyloExpandCollapseCmd::PerformEdit(), CPhyloTreeWidget::RedrawDataSource(), CPhyloTreeDataSource::Remove(), CPhyloTreeDataSource::RemoveSelected(), CPhyloTreeDataSource::ReRoot(), CPhyloTreeDataSource::ReRootEdge(), CPhyloTreeDataSource::ReRootMidpoint(), CTreeQueryExec::ResolveIdentifier(), CPhyloTreeDataSource::SetCollapsedLabel(), CPhyloTreeDataSource::SetCollapsedLabels(), CPhyloSelectionSetMgr::SetSelectionSetProperty(), CwxPhyloSettingsDlg::UpdateSample(), CPhyloTreeFilter_Export::x_Allowed(), CTreeQueryExec::x_EvalAdvance(), IPhyloTreeRender::x_RenderNodeHighlight(), IPhyloTreeRender::x_RenderSelection(), and IPhyloTreeRender::x_RenderTooltipHints().

◆ GetNode() [2/2]

template<class TNode >
const TNode& CTreeModel< TNode >::GetNode ( TTreeIdx  idx) const
inline

Definition at line 208 of file tree_model.hpp.

◆ GetNodeValue() [1/2]

template<class TNode >
TValueType& CTreeModel< TNode >::GetNodeValue ( TTreeIdx  idx)
inline

Return a reference to the 'value' object of a node.

Parameters
idx- index of the node
Returns
- reference to the value object held by the node at 'idx'

Definition at line 246 of file tree_model.hpp.

◆ GetNodeValue() [2/2]

template<class TNode >
const TValueType& CTreeModel< TNode >::GetNodeValue ( TTreeIdx  idx) const
inline

Definition at line 248 of file tree_model.hpp.

◆ GetNumNodes()

template<class TNode >
size_t CTreeModel< TNode >::GetNumNodes ( ) const
inline

Get the number of displayed nodes in current tree layout.

Returns
- the number of displayed (active) nodes

Definition at line 223 of file tree_model.hpp.

Referenced by CPhyloTreeWidget::OnUpdateSetMidpointRoot().

◆ GetParent() [1/2]

template<class TNode >
CTreeModel< TNode >::TNodeType & CTreeModel< TNode >::GetParent ( TNodeType node)

Return a reference to the parent node of the given node.

Throws exception if the given node is root

Parameters
node- the node whose parent is to be returned
Returns
- reference to node's parent, if node is not root

Definition at line 690 of file tree_model.hpp.

References eUnknown, and NCBI_THROW.

Referenced by CPhyloTreeDataSource::Clusterize(), and IPhyloTreeFilter::x_OnStep().

◆ GetParent() [2/2]

template<class TNode >
const CTreeModel< TNode >::TNodeType & CTreeModel< TNode >::GetParent ( TNodeType node) const

Definition at line 699 of file tree_model.hpp.

References eUnknown, and NCBI_THROW.

◆ GetRoot() [1/2]

template<class TNode >
TNodeType& CTreeModel< TNode >::GetRoot ( void  )
inline

◆ GetRoot() [2/2]

template<class TNode >
const TNode& CTreeModel< TNode >::GetRoot ( void  ) const
inline

Definition at line 255 of file tree_model.hpp.

◆ GetRootIdx()

template<class TNode >
TTreeIdx CTreeModel< TNode >::GetRootIdx ( ) const
inline

◆ GetSize()

template<class TNode >
size_t CTreeModel< TNode >::GetSize ( void  ) const
inline

Get the number of nodes currently in the array.

Returns
- the number of nodes (but some may be collapsed)

Definition at line 218 of file tree_model.hpp.

Referenced by CCalcRadialTree::CCalcRadialTree(), CCalcSlantedTree::CCalcSlantedTree(), and CPhyloSelectionSetMgr::SetSelectionSetProperty().

◆ Null()

template<class TNode >
CTreeModel< TNode >::TTreeIdx CTreeModel< TNode >::Null
static

Return the index value that represents a NULL node.

Definition at line 678 of file tree_model.hpp.

References NULL_TREE_IDX.

◆ operator[]() [1/2]

template<class TNode >
TNodeType& CTreeModel< TNode >::operator[] ( TTreeIdx  idx)
inline

Use operator[] to return a reference to the node at 'idx'.

Definition at line 211 of file tree_model.hpp.

◆ operator[]() [2/2]

template<class TNode >
const TNode& CTreeModel< TNode >::operator[] ( TTreeIdx  idx) const
inline

Definition at line 212 of file tree_model.hpp.

◆ RemoveChild()

template<class TNode >
void CTreeModel< TNode >::RemoveChild ( TTreeIdx  parent_idx,
TTreeIdx  child_idx 
)

Remove the node at 'child_idx' from its parent 'parent_idx' Nothing is done if the node 'child_idx' is not a child of that parent.

Parameters
parent_idx- the index of the parent node child_idx - the index of the child node

Definition at line 708 of file tree_model.hpp.

Referenced by CPhyloTreeDataSource::Cut(), CPhyloTreeDataSource::NewNode(), CPhyloTreeDataSource::Remove(), and CPhyloTreeDataSource::RemoveSelected().

◆ ReRoot()

template<class TNode >
void CTreeModel< TNode >::ReRoot ( TTreeIdx  idx)

Sets the root idx to be 'idx' and updates the tree so that all nodes above the new root become children of that node.

Parameters
idx- the new root node

Definition at line 722 of file tree_model.hpp.

Referenced by CPhyloTreeDataSource::ReRoot().

◆ Reserve()

template<class TNode >
void CTreeModel< TNode >::Reserve ( size_t  target_size)

Allocate the memory in advance, if you know how big the tree will be.

Parameters
target_size- the number of nodes that will be in the tree

Definition at line 767 of file tree_model.hpp.

◆ SetNumNodes()

template<class TNode >
void CTreeModel< TNode >::SetNumNodes ( int  count)
inline

Set the number of displayed nodes in current tree layout.

Parameters
count- number of nodes

Definition at line 229 of file tree_model.hpp.

Referenced by CPhyloTreeDataSource::Relabel().

◆ SetRootIdx()

template<class TNode >
void CTreeModel< TNode >::SetRootIdx ( TTreeIdx  idx)
inline

Set the index of the root node of the tree.

This is initially 0 but the root index can move around with sorting, edits etc.

Parameters
idx- the index for the tree's root node

Definition at line 262 of file tree_model.hpp.

Referenced by visitor_copy_subtree::visitor_copy_subtree(), and IPhyloTreeFilter::x_OnStep().

◆ x_ConvertUpstream()

template<class TNode >
void CTreeModel< TNode >::x_ConvertUpstream ( TTreeIdx  node_idx)
protectedvirtual

Convert parents of node_idx to be its children.

Definition at line 736 of file tree_model.hpp.

Member Data Documentation

◆ m_Nodes

template<class TNode >
TNodeVecType CTreeModel< TNode >::m_Nodes
protected

◆ m_NumNodes

template<class TNode >
int CTreeModel< TNode >::m_NumNodes
protected

Number of nodes in tree (not including collapsed/hidden nodes)

Definition at line 321 of file tree_model.hpp.

Referenced by CTreeModel< CPhyloTreeNode >::GetNumNodes(), and CTreeModel< CPhyloTreeNode >::SetNumNodes().

◆ m_RootIdx

template<class TNode >
TTreeIdx CTreeModel< TNode >::m_RootIdx
protected

The index of the root node within the tree.

Definition at line 324 of file tree_model.hpp.

Referenced by CTreeModel< CPhyloTreeNode >::GetRoot(), CTreeModel< CPhyloTreeNode >::GetRootIdx(), and CTreeModel< CPhyloTreeNode >::SetRootIdx().


The documentation for this class was generated from the following file:
Modified on Thu Jun 13 17:33:17 2024 by modify_doxy.py rev. 669887