NCBI C++ ToolKit
|
Search Toolkit Book for CTreeModel
#include <gui/widgets/phylo_tree/tree_model.hpp>
Public Types | |
typedef TNode | TNodeType |
typedef std::vector< TNodeType > | TNodeVecType |
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 |
![]() | |
enum | EAllocFillMode { eAllocFillNone = 1 , eAllocFillZero , eAllocFillPattern } |
Control filling of newly allocated memory. More... | |
typedef CObjectCounterLocker | TLockerType |
Default locker type for CRef. More... | |
typedef atomic< Uint8 > | TCounter |
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... | |
TNodeType & | GetNode (TTreeIdx idx) |
Return a reference to the node at the given index. More... | |
const TNode & | GetNode (TTreeIdx idx) const |
TNodeType & | operator[] (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... | |
TNodeType & | GetParent (TNodeType &node) |
Return a reference to the parent node of the given node. More... | |
const TNodeType & | GetParent (TNodeType &node) const |
TValueType & | GetNodeValue (TTreeIdx idx) |
Return a reference to the 'value' object of a node. More... | |
const TValueType & | GetNodeValue (TTreeIdx idx) const |
TNodeType & | GetRoot () |
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... | |
![]() | |
CObject (void) | |
Constructor. More... | |
CObject (const CObject &src) | |
Copy constructor. More... | |
virtual | ~CObject (void) |
Destructor. More... | |
CObject & | operator= (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... | |
![]() | |
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 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 void | EnableDebugDump (bool on) |
Protected Member Functions | |
virtual void | x_ConvertUpstream (TTreeIdx node_idx) |
Convert parents of node_idx to be its children. More... | |
![]() | |
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 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... | |
Definition at line 180 of file tree_model.hpp.
typedef TNodeType::TNodeList CTreeModel< TNode >::TNodeList |
Definition at line 188 of file tree_model.hpp.
typedef TNodeType::TNodeList_CI CTreeModel< TNode >::TNodeList_CI |
Definition at line 190 of file tree_model.hpp.
typedef TNodeType::TNodeList_CRI CTreeModel< TNode >::TNodeList_CRI |
Definition at line 192 of file tree_model.hpp.
typedef TNodeType::TNodeList_I CTreeModel< TNode >::TNodeList_I |
Definition at line 189 of file tree_model.hpp.
typedef TNodeType::TNodeList_RI CTreeModel< TNode >::TNodeList_RI |
Definition at line 191 of file tree_model.hpp.
typedef TNode CTreeModel< TNode >::TNodeType |
Definition at line 183 of file tree_model.hpp.
typedef std::vector<TNodeType> CTreeModel< TNode >::TNodeVecType |
Definition at line 184 of file tree_model.hpp.
typedef TNode::TTreeIdx CTreeModel< TNode >::TTreeIdx |
Definition at line 186 of file tree_model.hpp.
typedef TNode::TValueType CTreeModel< TNode >::TValueType |
Definition at line 185 of file tree_model.hpp.
|
inline |
Create empty tree. Tree is not valid at this point (no nodes)
Definition at line 196 of file tree_model.hpp.
|
inlinevirtual |
Definition at line 197 of file tree_model.hpp.
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.
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().
CTreeModel< TNode >::TTreeIdx CTreeModel< TNode >::AddNode |
Add a new default node to the tree and return its index.
Definition at line 749 of file tree_model.hpp.
Referenced by CPhyloTreeDataSource::NewNode(), visitor_copy_subtree::operator()(), and visitor_paste_subtree::operator()().
CTreeModel< TNode >::TTreeIdx CTreeModel< TNode >::AddNode | ( | const TNode & | node | ) |
Add a copy of node 'node' to the tree and return its index.
node | - the node from which to copy the new node |
Definition at line 758 of file tree_model.hpp.
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().
|
inline |
Return a reference to the node at the given index.
idx | index of the node to be returned |
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().
|
inline |
Definition at line 208 of file tree_model.hpp.
|
inline |
Return a reference to the 'value' object of a node.
idx | - index of the node |
Definition at line 246 of file tree_model.hpp.
|
inline |
Definition at line 248 of file tree_model.hpp.
|
inline |
Get the number of displayed nodes in current tree layout.
Definition at line 223 of file tree_model.hpp.
Referenced by CPhyloTreeWidget::OnUpdateSetMidpointRoot().
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
node | - the node whose parent is to be returned |
Definition at line 690 of file tree_model.hpp.
References eUnknown, and NCBI_THROW.
Referenced by CPhyloTreeDataSource::Clusterize(), and IPhyloTreeFilter::x_OnStep().
const CTreeModel< TNode >::TNodeType & CTreeModel< TNode >::GetParent | ( | TNodeType & | node | ) | const |
Definition at line 699 of file tree_model.hpp.
References eUnknown, and NCBI_THROW.
|
inline |
Return a reference to the root node of the tree.
Definition at line 254 of file tree_model.hpp.
Referenced by CCalcCircularTree::CCalcCircularTree(), CDrawCircularTreeVbo::CDrawCircularTreeVbo(), CPhyloTreeDataSource::CollapseByDistance(), CTreeGraphicsModel::EnableCircularLabelTrimming(), CTreeQueryExec::EvalStart(), CPhyloCircularCladogram::x_DrawTree(), CPhyloForce::x_Layout(), CPhyloCircularCladogram::x_RenderVbo(), CPhyloRadial::x_RenderVbo(), CPhyloSlantedCladogram::x_RenderVbo(), CPhyloRectCladogram::x_RenderVboPseudoSplines(), and CPhyloRectCladogram::x_RenderVboSplines().
|
inline |
Definition at line 255 of file tree_model.hpp.
|
inline |
Return the index of the root node.
Definition at line 267 of file tree_model.hpp.
Referenced by CPhyloTreeDataSource::ApplyAttributes(), CPhyloTreeDataSource::ClipboardEmpty(), CPhyloTreeDataSource::CollapseByDistance(), CPhyloTreeDataSource::CollapseSelected(), CPhyloTreeDataSource::ComputeLengthsFromRoot(), CPhyloTreeDataSource::Cut(), CTreeQueryExec::EvalStart(), CPhyloTreeDataSource::Filter(), CPhyloTreeDataSource::FilterDistances(), CPhyloTreeDataSource::GetBoundRect(), CPhyloTreeDataSource::IterateOverSelNodes(), CPhyloTreeDataSource::MeasureTree(), CPhyTreeView::OnCreateSelectedSubtree(), CPhyloTreeWidget::OnSelectAll(), CPhyloTreeWidget::OnUpdateCollapseSelected(), CPhyloTreeWidget::OnUpdateRerootTree(), CPhyloTreeWidget::OnUpdateZoomToSubtree(), CPhyloTreeDataSource::Paste(), CPhyloTreeDataSource::Relabel(), CPhyloTreeDataSource::ReRootMidpoint(), CPhyloTreeDataSource::Sort(), CPhyloTreeDataSource::SortDist(), CPhyloTreeDataSource::SortLabel(), CPhyloTreeDataSource::SortLabelRange(), CPhyloTreePane::Update(), CPhyloTreePane::x_Render(), CPhyloCircularCladogram::x_RenderVbo(), CPhyloRadial::x_RenderVbo(), CPhyloSlantedCladogram::x_RenderVbo(), CPhyloRectCladogram::x_RenderVboPseudoSplines(), and CPhyloRectCladogram::x_RenderVboSplines().
|
inline |
Get the number of nodes currently in the array.
Definition at line 218 of file tree_model.hpp.
Referenced by CCalcRadialTree::CCalcRadialTree(), CCalcSlantedTree::CCalcSlantedTree(), and CPhyloSelectionSetMgr::SetSelectionSetProperty().
|
static |
Return the index value that represents a NULL node.
Definition at line 678 of file tree_model.hpp.
References NULL_TREE_IDX.
|
inline |
Use operator[] to return a reference to the node at 'idx'.
Definition at line 211 of file tree_model.hpp.
|
inline |
Definition at line 212 of file tree_model.hpp.
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.
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().
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.
idx | - the new root node |
Definition at line 722 of file tree_model.hpp.
Referenced by CPhyloTreeDataSource::ReRoot().
void CTreeModel< TNode >::Reserve | ( | size_t | target_size | ) |
Allocate the memory in advance, if you know how big the tree will be.
target_size | - the number of nodes that will be in the tree |
Definition at line 767 of file tree_model.hpp.
|
inline |
Set the number of displayed nodes in current tree layout.
count | - number of nodes |
Definition at line 229 of file tree_model.hpp.
Referenced by CPhyloTreeDataSource::Relabel().
|
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.
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().
|
protectedvirtual |
Convert parents of node_idx to be its children.
Definition at line 736 of file tree_model.hpp.
|
protected |
The list of nodes in the tree.
Definition at line 318 of file tree_model.hpp.
Referenced by CTreeModel< CPhyloTreeNode >::GetNode(), CTreeModel< CPhyloTreeNode >::GetNodeValue(), CTreeModel< CPhyloTreeNode >::GetRoot(), CTreeModel< CPhyloTreeNode >::GetSize(), and CTreeModel< CPhyloTreeNode >::operator[]().
|
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().
|
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().