NCBI C++ ToolKit
|
Search Toolkit Book for CPhyloTree
Tree subclass also has functions and data needed for rendering and selection. More...
#include <gui/widgets/phylo_tree/phylo_tree.hpp>
Public Member Functions | |
CPhyloTree () | |
ctor - need to add nodes to make tree valid More... | |
void | Clear () |
Clear the tree nodes, graphics model and selected nodes. More... | |
CTreeGraphicsModel & | GetGraphicsModel () |
Get model for rendering. More... | |
void | SetGraphicsModelRef (CRef< CTreeGraphicsModel > gm) |
Set graphics model - may be needed if we want to render to different graphics contexts since graphics model has context-specific data (e.g. More... | |
CRef< CTreeGraphicsModel > | GetGraphicsModelRef () |
CRgbaGradColorTable * | GetColorTable () |
void | Sort (TTreeIdx idx, bool order) |
Sort the children of a node based on the number of children they have. More... | |
void | SortSubtreeDist (TTreeIdx idx, const vector< float > &distances, bool order) |
Sort the children of a node based on length of longest subtree. More... | |
void | SortLabel (TTreeIdx idx, bool order) |
Sort the children of a node based on label comparison (alphabetical order) More... | |
void | SortLabelRange (TTreeIdx idx, const vector< pair< string, string > > &subtree_labels, bool order) |
Sort the children of a node based on the alphanumeric range of their child nodes. More... | |
void | SetSelection (TTreeIdx idx, bool sel, bool sel_children=true, bool sel_parents=true) |
Select or deselect the node at the specified index and, optionally, its parents and children as well. More... | |
void | GetSelState (TSelState &sel_state, TTreeIdx idx, bool sel_children=true, bool sel_parents=true) const |
Given the selection of node 'idx', store the selection state (selected, traced, shared) of that node and its parents. More... | |
void | ClearSelection () |
Sets selection state of all nodes to eNotSelected and clears m_Selected. More... | |
void | GetSelected (vector< TTreeIdx > &sel) const |
Returns indices of selected nodes. More... | |
void | GetSelectedIDs (vector< TID > &sel) const |
Returns the node ids of selected nodes. More... | |
size_t | GetNumSelected () const |
Returns the number of selected nodes. More... | |
void | GetExplicitlySelected (vector< TTreeIdx > &esel) const |
Returns only indices of nodes explicitly selected, not their parents or children, i.e. More... | |
void | GetExplicitlySelectedAndNotCollapsed (vector< TTreeIdx > &esel) const |
Returns only indices of nodes explicitly selected, but when a node is underneath a collapsed node, the collapsed parent is returned. More... | |
void | GetExplicitlySelectedIDs (vector< TID > &esel) const |
Returns only ids of nodes explicitly selected, not their parents or children, i.e. More... | |
void | SetExplicitlySelected (const vector< TID > &esel) |
Reset explicitly selected nodes to those currently selected nodes that are also found in the vector 'esel'. More... | |
void | SetLeavesExplicitlySelected () |
Set the nodes used for iteration to default to the leaf nodes. More... | |
void | SetSelection (const vector< TTreeIdx > &sel, bool sel_children=true, bool sel_parents=true) |
Select a set of nodes - equivalent to calling SetSelection(idx, true, true, true) on each of the nodes. More... | |
void | SetSelectionIDs (const vector< TID > &ids, bool sel=true, bool sel_children=true) |
Select a set of nodes - equivalent to calling SetSelection(idx, true, true, true) on each of the nodes. More... | |
bool | HasSelection () const |
bool | GetSelectedBoundary (CVect2< float > &ll, CVect2< float > &ur) |
Return bounding rectangle from lower-left to upper-right of selected nodes (eSelected) and false if no nodes are currently selected. More... | |
bool | SelectByPoint (const CVect2< float > &pt, bool sel, bool toggle, bool labels_visible, bool rotated_labels=false) |
Determine if the point pt is close enough to a node to select or deselect it. More... | |
bool | SelectByRect (const CVect2< float > &ll, const CVect2< float > &ur, bool toggle) |
Select or deselect all nodes in the rectangle bounded by ll and ur. More... | |
vector< TTreeIdx > | GetAllCollapsed () const |
Returns indices of nodes thate are currently collapsed. More... | |
TTreeIdx | GetCollapsedParentIdx (TTreeIdx node_idx) const |
Return the index of the given node (node_idx) if none of its parent nodes up to the root are collapsed, otherwise return the node index of the collapsed parent node closest to the root. More... | |
void | SetCurrentNode (TTreeIdx node_idx) |
Set the index of the currently active node. More... | |
bool | SetCurrentNode (const CVect2< float > &pt, bool labels_visible, bool rotated_labels, bool unselect=true) |
If a node is close enough to the given position, set it to be the currently active node. More... | |
TTreeIdx | GetCurrentNodeIdx () const |
Return the index of the currently active node (may be Null()). More... | |
CPhyloTreeNode & | GetCurrentNode () |
Get reference to currently active node. Throws exception if it's Null() More... | |
bool | HasCurrentNode () const |
Return true if the currently active node is not Null() More... | |
void | SetCurrentEdge (TTreeIdx child_idx, TTreeIdx parent_idx) |
Set/Get the edge between the two specified nodes as current. More... | |
void | GetCurrentEdge (TTreeIdx &child_idx, TTreeIdx &parent_idx) const |
bool | HasCurrentEdge () const |
TTreeIdx | TestForNode (const CVect2< float > &pt, bool labels_visible, bool rotated_labels=false) |
Search nodes to find and return closest node to 'pt' that is within the max. More... | |
bool | IsVisible (TTreeIdx node_idx) |
Determine if the node at node_idx is within a collapsed subtree or not. More... | |
TTreeIdx | FindNodeById (TID id) const |
Return index of the node with the given id or Null(). More... | |
bool | IsUnused (TTreeIdx idx) const |
Return true if the given position in the array is not currently included as a node in the tree. More... | |
CBioTreeFeatureDictionary & | GetFeatureDict () |
Return feature dictionary. More... | |
const CBioTreeFeatureDictionary & | GetFeatureDict () const |
CPhyloSelectionSetMgr & | GetSelectionSets () |
const CPhyloSelectionSetMgr & | GetSelectionSets () const |
void | UpdateNodesMapping () |
Public Member Functions inherited from CTreeModel< CPhyloTreeNode > | |
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 CPhyloTreeNode & | GetNode (TTreeIdx idx) const |
TNodeType & | operator[] (TTreeIdx idx) |
Use operator[] to return a reference to the node at 'idx'. More... | |
const CPhyloTreeNode & | 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 CPhyloTreeNode & | 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 CPhyloTreeNode &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... | |
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... | |
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 |
Protected Types | |
typedef set< TTreeIdx > | TTreeIdxSet |
Indices of all the nodes with selection state eSelected. More... | |
typedef map< TID, TTreeIdx > | TTIDPhyloTreeNodeMap |
Node ID to tree index map. More... | |
Protected Member Functions | |
void | x_SetSelState (TTreeIdx idx, CPhyloNodeData::TSelectedState state, bool override_explicit=true) |
Set selected state of anode and add/remove it from m_Selected as needed. More... | |
void | x_SelectChildren (CPhyloTreeNode &node, bool sel) |
Propogate selection operation (selecte/deselect) to a nodes children. More... | |
void | x_SelectParents (CPhyloTreeNode &node, bool sel, bool children_selected=true) |
Propogate selection (eTraced) to a nodes parents and if children aren't be selected, don't override explicit parent selection. More... | |
TTreeIdx | x_CommonNodeSearch (TTreeIdx idx) |
Check recursively parents of node and set selection state to eShared if all of their children are selected. More... | |
void | x_PropagateCommonState (CPhyloTreeNode &node) |
void | x_GetParentState (TSelState &sel_state, TTreeIdx idx) const |
Get (and return) selection state for parents of a given node. More... | |
void | x_GetChildState (TSelState &sel_state, TTreeIdx idx) const |
Get (and return) selection state for children of a given node. More... | |
virtual void | x_ConvertUpstream (TTreeIdx node_idx) |
Convert parents of node_idx to be its children. More... | |
Protected Member Functions inherited from CTreeModel< CPhyloTreeNode > | |
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 | |
TTreeIdxSet | m_Selected |
TTreeIdxSet | m_ExplicitlySelected |
Often when you select a node, it's children or parents may also join the selection set. More... | |
TTIDPhyloTreeNodeMap | m_NodesMap |
TTreeIdx | m_CurrentNode |
Currently active node (for operations like edit), or Null() More... | |
TTreeIdx | m_CurrentEdgeChild |
Currently active edge (to allow re-rooting by edge). More... | |
TTreeIdx | m_CurrentEdgeParent |
CRef< CTreeGraphicsModel > | m_GraphicsModel |
Model for rendering (updated from current tree state) More... | |
CRef< CRgbaGradColorTable > | m_ColorTable |
Color table to store colors by index. More... | |
CBioTreeFeatureDictionary | m_FeatureDict |
Feature dictionary. More... | |
CPhyloSelectionSetMgr | m_SelectionSets |
Selection sets - sets of selected nodes, which are saved in the biotreecontainer in user data (visualized kind of like clusters) More... | |
Protected Attributes inherited from CTreeModel< CPhyloTreeNode > | |
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... | |
Private Member Functions | |
CPhyloTree (const CPhyloTree &) | |
Disable copy. More... | |
CPhyloTree & | operator= (const CPhyloTree &) |
Additional Inherited Members | |
Static Public Member Functions inherited from CTreeModel< CPhyloTreeNode > | |
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) |
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... | |
Tree subclass also has functions and data needed for rendering and selection.
Definition at line 51 of file phylo_tree.hpp.
Definition at line 54 of file phylo_tree.hpp.
typedef CPhyloNodeData::TID CPhyloTree::TID |
Definition at line 55 of file phylo_tree.hpp.
typedef vector<TSelStateValue> CPhyloTree::TSelState |
Definition at line 57 of file phylo_tree.hpp.
typedef pair<TTreeIdx, CPhyloNodeData::TSelectedState> CPhyloTree::TSelStateValue |
Definition at line 56 of file phylo_tree.hpp.
|
protected |
Node ID to tree index map.
Definition at line 370 of file phylo_tree.hpp.
|
protected |
Indices of all the nodes with selection state eSelected.
Definition at line 360 of file phylo_tree.hpp.
CPhyloTree::CPhyloTree | ( | ) |
ctor - need to add nodes to make tree valid
Definition at line 42 of file phylo_tree.cpp.
References Clear().
|
private |
Disable copy.
void CPhyloTree::Clear | ( | void | ) |
Clear the tree nodes, graphics model and selected nodes.
Definition at line 48 of file phylo_tree.cpp.
References CTreeModel< TNode >::Clear(), CGlModel2D::ClearAll(), ClearSelection(), CTreeGraphicsModel::Init(), CRef< C, Locker >::IsNull(), and m_GraphicsModel.
Referenced by CPhyloTreeDataSource::Clear(), CPhyloTree(), CPhyloTreeDataSource::Cut(), and CPhyloTreeDataSource::Init().
void CPhyloTree::ClearSelection | ( | ) |
Sets selection state of all nodes to eNotSelected and clears m_Selected.
Definition at line 242 of file phylo_tree.cpp.
References set< Key, Compare >::clear(), CPhyloNodeData::eNotSelected, m_CurrentEdgeChild, m_CurrentEdgeParent, m_CurrentNode, m_ExplicitlySelected, CTreeModel< CPhyloTreeNode >::m_Nodes, m_Selected, and CTreeModel< CPhyloTreeNode >::Null().
Referenced by Clear(), CPhyloTreeDataSource::Cut(), CPhyloTreeDataSource::ExecuteStringQuery(), CPhyloTreeWidget::OnClearSelection(), CPhyloTreeWidget::OnRerootTree(), CPhyloTreeWidget::OnRerootTreeAtEdge(), CPhyloTreeWidget::OnSetMidpointRoot(), IPhyloTreeRender::OnTimerLeftUp(), CPhyloTreeWidget::OnZoomToSubtree(), CPhyloTreeWidget::QueryEnd(), CPhyloTreeDataSource::Remove(), CPhyloTreeDataSource::RemoveSelected(), SelectByPoint(), CPhyloTreeDataSource::SetQueryResults(), CPhyloSaveSelectiondlg::SetSelections(), and CPhyTreeView::x_OnSetSelection().
Return index of the node with the given id or Null().
ID's are unique.
id | - the id to search for |
Definition at line 307 of file phylo_tree.hpp.
References map_checker< Container >::end(), map_checker< Container >::find(), m_NodesMap, and CTreeModel< CPhyloTreeNode >::Null().
Referenced by CPhyloTreeWidget::OnInfoTip(), CPhyloTreeWidget::OnSearchTip(), CPhyloTreeWidget::OnZoomTip(), visitor_copy_subtree::operator()(), visitor_paste_subtree::operator()(), CChangePhyloPropertyCmd::PerformEdit(), CChangePhyloExpandCollapseCmd::PerformEdit(), IPhyloTreeRender::PointToNode(), CPhyloTreeDataSource::RemoveSelected(), IPhyloTreeRender::SetActiveTooltipNode(), CPhyloTreeDataSource::SetCollapsedLabels(), SetExplicitlySelected(), SetSelectionIDs(), CPhyloSelectionSetMgr::SetSelectionSetProperty(), CTreeQueryExec::x_EvalAdvance(), and CPhyloSelectionSetMgr::x_SyncSelectionSets().
vector< CPhyloTree::TTreeIdx > CPhyloTree::GetAllCollapsed | ( | ) | const |
Returns indices of nodes thate are currently collapsed.
Definition at line 368 of file phylo_tree.cpp.
References CPhyloNodeData::eHideChildren, i, IsUnused(), and CTreeModel< CPhyloTreeNode >::m_Nodes.
Referenced by CPhyloTreeWidget::OnShowAll().
Return the index of the given node (node_idx) if none of its parent nodes up to the root are collapsed, otherwise return the node index of the collapsed parent node closest to the root.
node_idx | - the node to check |
Definition at line 382 of file phylo_tree.cpp.
References CTreeModel< CPhyloTreeNode >::GetNode(), CTreeModelNode< TData >::GetParent(), CTreeModelNode< CPhyloNodeData >::Null(), and result.
CRgbaGradColorTable * CPhyloTree::GetColorTable | ( | ) |
Definition at line 64 of file phylo_tree.cpp.
References CRef< C, Locker >::GetPointer(), CRef< C, Locker >::IsNull(), m_ColorTable, and CRef< C, Locker >::Reset().
Referenced by CPhyloTreeDataSource::ApplyAttributes(), CPhyloTreeDataSource::Clusterize(), CPhyloTreeDataSource::Init(), CPhyloTreeDataSource::MeasureTree(), CPhyloTreeDataSource::NewNode(), CPhyloTreeDataSource::Relabel(), and CPhyloTreeDataSource::SetColorIndices().
Definition at line 448 of file phylo_tree.cpp.
References m_CurrentEdgeChild, and m_CurrentEdgeParent.
Referenced by CPhyloTreeWidget::OnRerootTreeAtEdge().
CPhyloTreeNode & CPhyloTree::GetCurrentNode | ( | ) |
Get reference to currently active node. Throws exception if it's Null()
Definition at line 434 of file phylo_tree.cpp.
References eUnknown, HasCurrentNode(), m_CurrentNode, CTreeModel< CPhyloTreeNode >::m_Nodes, and NCBI_THROW.
Referenced by CPhyloTreeDataSource::Cut(), CPhyloTreeWidget::EditLabel(), CPhyloTreeDataSource::NewNode(), CPhyloTreeWidget::OnEditNode(), CPhyloTreeWidget::OnUpdateEdit(), and CPhyloTreeWidget::SendEditEvent().
|
inline |
Return the index of the currently active node (may be Null()).
Definition at line 268 of file phylo_tree.hpp.
References m_CurrentNode.
Referenced by IPhyloTreeRender::BufferedRender(), CPhyloTreeDataSource::Cut(), CPhyloTreeWidget::EditLabel(), CPhyTreeView::GetSelection(), CPhyloTreeDataSource::MoveNode(), CPhyloTreeDataSource::NewNode(), CPhyloTreeWidget::OnCollapseChildren(), CPhyTreeView::OnCreateSelectedSubtree(), CPhyloTreeWidget::OnEditNode(), CPhyloTreeWidget::OnExpandChildren(), IPhyloTreeRender::OnLeftDblClick(), CPhyloTreeWidget::OnRerootTree(), IPhyloTreeRender::OnTimerLeftUp(), CPhyloTreeWidget::OnUpdateCollapseChildren(), CPhyloTreeWidget::OnUpdateExpandChildren(), CPhyloTreeWidget::OnUpdateRerootTree(), CPhyloTreeWidget::OnUpdateSubtreeFromSelection(), CPhyloTreeWidget::OnUpdateZoomToSubtree(), CPhyloTreeWidget::OnZoomToSubtree(), CPhyloTreeDataSource::Paste(), CPhyloTreeWidget::RedrawDataSource(), CPhyloTreeDataSource::Remove(), CPhyloTreeWidget::SendEditEvent(), and IPhyloTreeRender::x_RenderSelection().
void CPhyloTree::GetExplicitlySelected | ( | vector< TTreeIdx > & | esel | ) | const |
Returns only indices of nodes explicitly selected, not their parents or children, i.e.
nodes passed as first parameter to SetSelection(...)
Definition at line 273 of file phylo_tree.cpp.
References set< Key, Compare >::begin(), copy(), set< Key, Compare >::end(), m_ExplicitlySelected, and set< Key, Compare >::size().
Referenced by CPhyloTreeDataSource::CollapseSelected(), and CPhyloSaveSelectiondlg::SetSelections().
void CPhyloTree::GetExplicitlySelectedAndNotCollapsed | ( | vector< TTreeIdx > & | esel | ) | const |
Returns only indices of nodes explicitly selected, but when a node is underneath a collapsed node, the collapsed parent is returned.
Definition at line 279 of file phylo_tree.cpp.
References set< Key, Compare >::begin(), set< Key, Compare >::end(), CPhyloTreeNode::Expanded(), CTreeModelNode< TData >::GetParent(), m_ExplicitlySelected, CTreeModel< CPhyloTreeNode >::m_Nodes, n, CTreeModelNode< CPhyloNodeData >::Null(), and set< Key, Compare >::size().
Referenced by CPhyloTreeDataSource::IterateOverSelNodes(), and CPhyloTreeWidget::OnUpdateSelChanged().
void CPhyloTree::GetExplicitlySelectedIDs | ( | vector< TID > & | esel | ) | const |
Returns only ids of nodes explicitly selected, not their parents or children, i.e.
nodes passed as first parameter to SetSelection(...)
Definition at line 313 of file phylo_tree.cpp.
References GetId(), ITERATE, m_ExplicitlySelected, CTreeModel< CPhyloTreeNode >::m_Nodes, and set< Key, Compare >::size().
Referenced by CPhyTreeView::GetSelection(), and CPhyloTreeDataSource::RemoveSelected().
|
inline |
Return feature dictionary.
Definition at line 323 of file phylo_tree.hpp.
References m_FeatureDict.
Referenced by CPhyloTreeDataSource::CollapseByDistance(), CPhyloTreeDataSource::CollapseSelected(), CPhyloTreeDataSource::ComputeLengthsFromRoot(), CPhyloTreeWidget::EditLabel(), CChangePhyloPropertyCmd::Execute(), CPhyloTreeDataSource::GenerateTooltipFormat(), CPhyloTreeDataSource::GetColsCount(), CPhyloTreeDataSource::GetColumnLabel(), CPhyloTreeDataSource::GetDictionary(), CPhyloTreeDataSource::Init(), CPhyloTreeDataSource::NewNode(), CPhyTreeView::OnBioTreeChanged(), CPhyloTreeWidget::OnZoomToSubtree(), visitor_paste_subtree::operator()(), CChangePhyloExpandCollapseCmd::PerformEdit(), CPhyloTreeDataSource::ReRoot(), CPhyloTreeDataSource::ReRootEdge(), CPhyloTreeDataSource::ReRootMidpoint(), CTreeQueryExec::ResolveIdentifier(), CPhyloTreeCalculator::SetAttrTable(), CPhyloTreeDataSource::SetCollapsedLabel(), CwxPhyloEditDlg::SetParams(), CPhyloSelectionSetMgr::SetSelectionSetProperty(), CPhyloTreeDataSource::SortDist(), SPriorityCollapse::SPriorityCollapse(), CChangePhyloPropertyCmd::Unexecute(), visitor_copy_subtree::visitor_copy_subtree(), CPhyTreeView::x_OnSetSelection(), CPhyloTreeMaxDirectChildDist::x_OnStep(), and CPhyloTreeCalculator::x_UpdateProperties().
|
inline |
Definition at line 324 of file phylo_tree.hpp.
References m_FeatureDict.
CTreeGraphicsModel & CPhyloTree::GetGraphicsModel | ( | ) |
Get model for rendering.
Definition at line 74 of file phylo_tree.cpp.
References CRef< C, Locker >::GetObject(), CTreeGraphicsModel::Init(), CRef< C, Locker >::IsNull(), m_GraphicsModel, and CRef< C, Locker >::Reset().
Referenced by CPhyloTreeDataSource::GetModel(), CPhyloTreePane::RenderPdf(), SelectByRect(), and TestForNode().
|
inline |
Definition at line 74 of file phylo_tree.hpp.
References m_GraphicsModel.
|
inline |
Returns the number of selected nodes.
Definition at line 151 of file phylo_tree.hpp.
References m_Selected, and set< Key, Compare >::size().
Referenced by CPhyTreeView::OnCreateSelectedSubtree(), and CPhyloTreeWidget::OnUpdateSubtreeFromSelection().
void CPhyloTree::GetSelected | ( | vector< TTreeIdx > & | sel | ) | const |
Returns indices of selected nodes.
Definition at line 259 of file phylo_tree.cpp.
References set< Key, Compare >::begin(), copy(), set< Key, Compare >::end(), m_Selected, and set< Key, Compare >::size().
Referenced by CPhyTreeView::GetSelection(), CPhyloTreeWidget::OnUpdateCollapseSelected(), and CPhyloSaveSelectiondlg::SetSelections().
Return bounding rectangle from lower-left to upper-right of selected nodes (eSelected) and false if no nodes are currently selected.
ll | - min x and y coordinates for selected set ur - max x and y coordinates for selected set |
Definition at line 397 of file phylo_tree.cpp.
References ITERATE, CTreeModel< CPhyloTreeNode >::m_Nodes, m_Selected, max(), min(), set< Key, Compare >::size(), CVect2< T >::X(), and CVect2< T >::Y().
Referenced by CPhyloTreeWidget::OnZoomToSelection().
void CPhyloTree::GetSelectedIDs | ( | vector< TID > & | sel | ) | const |
Returns the node ids of selected nodes.
Definition at line 265 of file phylo_tree.cpp.
References GetId(), ITERATE, CTreeModel< CPhyloTreeNode >::m_Nodes, m_Selected, and set< Key, Compare >::size().
Referenced by CPhyTreeView::GetSelection(), CPhyloSaveSelectiondlg::OnAddCurrentSelBtnClick(), and CPhyloSaveSelectiondlg::SetSelections().
|
inline |
Definition at line 326 of file phylo_tree.hpp.
References m_SelectionSets.
Referenced by CPhyloTreeDataSource::Clusterize(), CTreeQueryExec::EvalStart(), CChangePhyloSelectionSetCmd::Execute(), CPhyloTreeDataSource::GetSelectionSets(), CPhyloTreeDataSource::Init(), CPhyloTreeWidget::OnAddSelectionSet(), CChangePhyloSelectionSetCmd::PerformEdit(), CPhyloTreeWidget::QueryEnd(), CChangePhyloSelectionSetCmd::Unexecute(), and CPhyloTreeDataSource::UpdateSelectionSets().
|
inline |
Definition at line 327 of file phylo_tree.hpp.
References m_SelectionSets.
void CPhyloTree::GetSelState | ( | TSelState & | sel_state, |
TTreeIdx | idx, | ||
bool | sel_children = true , |
||
bool | sel_parents = true |
||
) | const |
Given the selection of node 'idx', store the selection state (selected, traced, shared) of that node and its parents.
This function does Not update selection state of the actual nodes.
sel_state | - vector to return the selection info idx - the node whose selection state we are retrieving sel_children - if true, all chidren recursively are added to sel state sel_parents - if true all ancestors are added to sel state |
Definition at line 613 of file phylo_tree.cpp.
References set< Key, Compare >::end(), CPhyloNodeData::eSelected, set< Key, Compare >::find(), CTreeModelNode< TData >::GetParent(), CTreeModelNode< TData >::HasParent(), CTreeModelNode< TData >::IsLeaf(), m_ExplicitlySelected, CTreeModel< CPhyloTreeNode >::m_Nodes, x_GetChildState(), and x_GetParentState().
Referenced by IPhyloTreeRender::BufferedRender().
bool CPhyloTree::HasCurrentEdge | ( | ) | const |
Definition at line 454 of file phylo_tree.cpp.
References m_CurrentEdgeChild, m_CurrentEdgeParent, and CTreeModel< CPhyloTreeNode >::Null().
Referenced by CPhyloTreeWidget::OnRerootTreeAtEdge(), and CPhyloTreeWidget::OnUpdateRerootTreeAtEdge().
|
inline |
Return true if the currently active node is not Null()
Definition at line 274 of file phylo_tree.hpp.
References m_CurrentNode, and CTreeModel< CPhyloTreeNode >::Null().
Referenced by CPhyloTreeWidget::EditLabel(), GetCurrentNode(), CPhyTreeView::GetSelection(), CPhyloTreeWidget::OnEditNode(), CPhyloTreeWidget::OnUpdateEdit(), CPhyloTreeWidget::OnUpdateEditLabel(), CPhyloTreeWidget::OnUpdateEditNode(), and CPhyloTreeWidget::SendEditEvent().
|
inline |
Definition at line 201 of file phylo_tree.hpp.
References m_Selected, and set< Key, Compare >::size().
Referenced by CPhyloTreeWidget::OnUpdateEdit(), CPhyloTreeWidget::OnUpdateSelChanged(), and CPhyloTreeWidget::OnUpdateZoomSel().
Return true if the given position in the array is not currently included as a node in the tree.
Can happen if nodes are deleted, for example
idx | - the index to check |
Definition at line 320 of file phylo_tree.hpp.
References CTreeModel< CPhyloTreeNode >::m_Nodes.
Referenced by GetAllCollapsed().
Determine if the node at node_idx is within a collapsed subtree or not.
node_idx | - the node to check |
Definition at line 469 of file phylo_tree.cpp.
References CPhyloNodeData::eHideChildren, CTreeModelNode< TData >::GetParent(), CTreeModel< CPhyloTreeNode >::m_Nodes, NULL, and CTreeModelNode< CPhyloNodeData >::Null().
|
private |
bool CPhyloTree::SelectByPoint | ( | const CVect2< float > & | pt, |
bool | sel, | ||
bool | toggle, | ||
bool | labels_visible, | ||
bool | rotated_labels = false |
||
) |
Determine if the point pt is close enough to a node to select or deselect it.
If it is, select or deselect according to sel and toggle
pt | - the selection position sel - if true we are doing normal (vs. incremental) selection toggle - if true we should toggle node's selection state |
Definition at line 486 of file phylo_tree.cpp.
References ClearSelection(), CPhyloNodeData::eSelected, m_CurrentNode, CTreeModel< CPhyloTreeNode >::m_Nodes, CTreeModel< CPhyloTreeNode >::Null(), SetSelection(), and TestForNode().
Referenced by IPhyloTreeRender::OnTimerLeftUp().
bool CPhyloTree::SelectByRect | ( | const CVect2< float > & | ll, |
const CVect2< float > & | ur, | ||
bool | toggle | ||
) |
Select or deselect all nodes in the rectangle bounded by ll and ur.
ll | - lower left corner of selection rectangle ur - upper right corner of selection rectangle toggle - if true we should toggle node's selection state |
Definition at line 512 of file phylo_tree.cpp.
References CPhyloNodeData::eSelected, CTreeGraphicsModel::GetCollisionData(), GetGraphicsModel(), i, CTreeModel< CPhyloTreeNode >::m_Nodes, CTreeCollisionModel2D::SelectNodes(), SetSelection(), CVect2< T >::X(), and CVect2< T >::Y().
Referenced by IPhyloTreeRender::x_SelectByRect().
Set/Get the edge between the two specified nodes as current.
May be Null (but if one value is null, both are)
child_idx | - index of the child node of the edge (may be Null()) parent_idx - index of the parent node of the edge (may be NULL()) |
Definition at line 442 of file phylo_tree.cpp.
References m_CurrentEdgeChild, and m_CurrentEdgeParent.
Referenced by IPhyloTreeRender::BufferedRender(), IPhyloTreeRender::x_RenderCircularVbo(), IPhyloTreeRender::x_RenderLineVbo(), IPhyloTreeRender::x_RenderPseudoSplineVbo(), and IPhyloTreeRender::x_RenderSplineVbo().
bool CPhyloTree::SetCurrentNode | ( | const CVect2< float > & | pt, |
bool | labels_visible, | ||
bool | rotated_labels, | ||
bool | unselect = true |
||
) |
If a node is close enough to the given position, set it to be the currently active node.
node_idx | - index of the active node within the tree (may be Null()) |
Definition at line 420 of file phylo_tree.cpp.
References m_CurrentNode, CTreeModel< CPhyloTreeNode >::Null(), and TestForNode().
void CPhyloTree::SetCurrentNode | ( | TTreeIdx | node_idx | ) |
Set the index of the currently active node.
Active nodes may have edits or property updates applied to them.
node_idx | - index of the active node within the tree (may be Null()) |
Definition at line 415 of file phylo_tree.cpp.
References m_CurrentNode.
Referenced by CPhyloTreeDataSource::IterateOverSelNodes(), IPhyloTreeRender::OnLeftDblClick(), IPhyloTreeRender::OnLeftDown(), IPhyloTreeRender::OnRightDown(), CPhyloTreeDataSource::ReRootEdge(), and CPhyloTreeDataSource::ReRootMidpoint().
Reset explicitly selected nodes to those currently selected nodes that are also found in the vector 'esel'.
esel | - vector of node indices which, if they are Also in the current selection set, will marked as explicitly selected. |
Definition at line 321 of file phylo_tree.cpp.
References set< Key, Compare >::clear(), set< Key, Compare >::end(), set< Key, Compare >::find(), FindNodeById(), set< Key, Compare >::insert(), ITERATE, m_ExplicitlySelected, and m_Selected.
Referenced by CPhyTreeView::x_OnSetSelection().
|
inline |
Set graphics model - may be needed if we want to render to different graphics contexts since graphics model has context-specific data (e.g.
OpenGL buffer Ids)
Definition at line 73 of file phylo_tree.hpp.
References m_GraphicsModel.
void CPhyloTree::SetLeavesExplicitlySelected | ( | ) |
Set the nodes used for iteration to default to the leaf nodes.
This is used when we set the selection via broadcasting from another tree such that we don't know which nodes were explicitly selected in the other tree.
Definition at line 337 of file phylo_tree.cpp.
References set< Key, Compare >::clear(), set< Key, Compare >::insert(), ITERATE, m_ExplicitlySelected, CTreeModel< CPhyloTreeNode >::m_Nodes, and m_Selected.
Referenced by CPhyTreeView::x_OnSetSelection().
void CPhyloTree::SetSelection | ( | const vector< TTreeIdx > & | sel, |
bool | sel_children = true , |
||
bool | sel_parents = true |
||
) |
Select a set of nodes - equivalent to calling SetSelection(idx, true, true, true) on each of the nodes.
sel | - the set of nodes to be selected |
Definition at line 357 of file phylo_tree.cpp.
References SetSelection().
void CPhyloTree::SetSelection | ( | TTreeIdx | idx, |
bool | sel, | ||
bool | sel_children = true , |
||
bool | sel_parents = true |
||
) |
Select or deselect the node at the specified index and, optionally, its parents and children as well.
Parent selection state is eTraced or eShared.
idx | - the node to be selected or unselected (eSelected or eNotSelected) sel - if true the node should be selected, false - deselected sel_children - if true, all chidren recursively are selected/deselected sel_parents - if true all ancestors are selected/deselected |
Definition at line 577 of file phylo_tree.cpp.
References set< Key, Compare >::end(), CPhyloNodeData::eNotSelected, set< Key, Compare >::erase(), CPhyloNodeData::eSelected, set< Key, Compare >::find(), set< Key, Compare >::insert(), m_ExplicitlySelected, CTreeModel< CPhyloTreeNode >::m_Nodes, CTreeModel< CPhyloTreeNode >::Null(), x_CommonNodeSearch(), x_PropagateCommonState(), x_SelectChildren(), x_SelectParents(), and x_SetSelState().
Referenced by CPhyloTreeDataSource::Cut(), CPhyloTreeDataSource::ExecuteStringQuery(), CPhyloTreeWidget::OnSelectAll(), SelectByPoint(), SelectByRect(), CPhyloTreeDataSource::SetQueryResults(), SetSelection(), SetSelectionIDs(), CPhyloSaveSelectiondlg::SetSelections(), and CPhyTreeView::x_OnSetSelection().
void CPhyloTree::SetSelectionIDs | ( | const vector< TID > & | ids, |
bool | sel = true , |
||
bool | sel_children = true |
||
) |
Select a set of nodes - equivalent to calling SetSelection(idx, true, true, true) on each of the nodes.
sel | - the set of node IDs to be selected |
Definition at line 346 of file phylo_tree.cpp.
References FindNodeById(), ITERATE, CTreeModel< CPhyloTreeNode >::Null(), and SetSelection().
Referenced by CPhyTreeView::x_OnSetSelection().
Sort the children of a node based on the number of children they have.
idx | - index of the node whose children will be sorted order - if true order nodes in descending order of subtree size |
Definition at line 208 of file phylo_tree.cpp.
References CTreeModel< CPhyloTreeNode >::m_Nodes, and ct::sort().
Referenced by CPhyloTreeSorter::x_OnStep().
Sort the children of a node based on label comparison (alphabetical order)
idx | - index of the node whose children will be sorted order - if true order nodes in descending alphabetical order |
Definition at line 224 of file phylo_tree.cpp.
References CTreeModel< CPhyloTreeNode >::m_Nodes, and ct::sort().
Referenced by CPhyloTreeSorterLabel::x_OnStep().
void CPhyloTree::SortLabelRange | ( | TTreeIdx | idx, |
const vector< pair< string, string > > & | subtree_labels, | ||
bool | order | ||
) |
Sort the children of a node based on the alphanumeric range of their child nodes.
idx | - index of the node whose children will be sorted order - if true order nodes in descending alphabeitcal label range |
Definition at line 232 of file phylo_tree.cpp.
References CTreeModel< CPhyloTreeNode >::m_Nodes, and ct::sort().
Referenced by CPhyloTreeSorterLabelRange::x_OnStep().
Sort the children of a node based on length of longest subtree.
idx | - index of the node whose children will be sorted order - if true order nodes in descending order of distance |
Definition at line 216 of file phylo_tree.cpp.
References CTreeModel< CPhyloTreeNode >::m_Nodes, and ct::sort().
Referenced by CPhyloTreeSorterSubtreeDist::x_OnStep().
CPhyloTree::TTreeIdx CPhyloTree::TestForNode | ( | const CVect2< float > & | pt, |
bool | labels_visible, | ||
bool | rotated_labels = false |
||
) |
Search nodes to find and return closest node to 'pt' that is within the max.
selection distance (used for clicking on nodes)
pt | - the position against which we are testing |
Definition at line 460 of file phylo_tree.cpp.
References CTreeGraphicsModel::GetCollisionData(), GetGraphicsModel(), CTreeModelNode< CPhyloNodeData >::Null(), CTreeCollisionModel2D::TestForNode(), CVect2< T >::X(), and CVect2< T >::Y().
Referenced by IPhyloTreeRender::GetHoverNode(), IPhyloTreeRender::GetHoverNodeIdx(), IPhyloTreeRender::OnLeftDown(), IPhyloTreeRender::OnTimerLeftUp(), SelectByPoint(), and SetCurrentNode().
void CPhyloTree::UpdateNodesMapping | ( | ) |
Definition at line 535 of file phylo_tree.cpp.
References map_checker< Container >::clear(), ITERATE, CTreeModel< CPhyloTreeNode >::m_Nodes, and m_NodesMap.
Referenced by CPhyloTreeDataSource::Cut(), CPhyloTreeDataSource::Init(), CPhyloTreeDataSource::NewNode(), CPhyloTreeDataSource::Paste(), CPhyloTreeDataSource::Remove(), and CPhyloTreeDataSource::RemoveSelected().
|
protected |
Check recursively parents of node and set selection state to eShared if all of their children are selected.
Definition at line 689 of file phylo_tree.cpp.
References CPhyloNodeData::eNotSelected, CTreeModelNode< TData >::GetParent(), CTreeModel< CPhyloTreeNode >::m_Nodes, CTreeModel< CPhyloTreeNode >::Null(), CTreeModelNode< TData >::SubNodeBegin(), and CTreeModelNode< TData >::SubNodeEnd().
Referenced by SetSelection().
|
protectedvirtual |
Convert parents of node_idx to be its children.
Also moves edge data associated with node children to parents when parent/child role is reversed.
Definition at line 758 of file phylo_tree.cpp.
References CTreeModel< CPhyloTreeNode >::AddChild(), CTreeModel< CPhyloTreeNode >::GetNode(), CTreeModelNode< TData >::GetValue(), m_FeatureDict, CTreeModel< CPhyloTreeNode >::m_Nodes, CTreeModel< CPhyloTreeNode >::Null(), CTreeModel< CPhyloTreeNode >::RemoveChild(), CPhyloNodeData::SetDistance(), and CPhyloNodeData::Sync().
Get (and return) selection state for children of a given node.
Definition at line 743 of file phylo_tree.cpp.
References CPhyloNodeData::eNotSelected, CTreeModel< CPhyloTreeNode >::m_Nodes, n, CTreeModelNode< TData >::SubNodeBegin(), and CTreeModelNode< TData >::SubNodeEnd().
Referenced by GetSelState().
Get (and return) selection state for parents of a given node.
Definition at line 730 of file phylo_tree.cpp.
References CPhyloNodeData::eNotSelected, CTreeModelNode< TData >::GetParent(), CTreeModelNode< TData >::HasParent(), and CTreeModel< CPhyloTreeNode >::m_Nodes.
Referenced by GetSelState().
|
protected |
Definition at line 718 of file phylo_tree.cpp.
References CPhyloNodeData::eShared, CPhyloNodeData::eTraced, CTreeModel< CPhyloTreeNode >::m_Nodes, CTreeModelNode< TData >::SubNodeBegin(), and CTreeModelNode< TData >::SubNodeEnd().
Referenced by SetSelection().
|
protected |
Propogate selection operation (selecte/deselect) to a nodes children.
Definition at line 642 of file phylo_tree.cpp.
References CPhyloNodeData::eNotSelected, CPhyloNodeData::eSelected, CTreeModel< CPhyloTreeNode >::m_Nodes, CTreeModelNode< TData >::SubNodeBegin(), CTreeModelNode< TData >::SubNodeEnd(), and x_SetSelState().
Referenced by SetSelection().
|
protected |
Propogate selection (eTraced) to a nodes parents and if children aren't be selected, don't override explicit parent selection.
Definition at line 655 of file phylo_tree.cpp.
References CPhyloNodeData::eNotSelected, CPhyloNodeData::eSelected, CPhyloNodeData::eTraced, CTreeModelNode< TData >::GetParent(), CTreeModelNode< TData >::HasParent(), CTreeModel< CPhyloTreeNode >::m_Nodes, CTreeModelNode< TData >::SubNodeBegin(), CTreeModelNode< TData >::SubNodeEnd(), and x_SetSelState().
Referenced by SetSelection().
|
protected |
Set selected state of anode and add/remove it from m_Selected as needed.
Definition at line 543 of file phylo_tree.cpp.
References set< Key, Compare >::end(), set< Key, Compare >::erase(), CPhyloNodeData::eSelected, set< Key, Compare >::find(), set< Key, Compare >::insert(), m_ExplicitlySelected, CTreeModel< CPhyloTreeNode >::m_Nodes, and m_Selected.
Referenced by SetSelection(), x_SelectChildren(), and x_SelectParents().
|
protected |
Color table to store colors by index.
Definition at line 384 of file phylo_tree.hpp.
Referenced by GetColorTable().
|
protected |
Currently active edge (to allow re-rooting by edge).
Since we do not explicitly store edges, save it as the edges parent and child nodes.
Definition at line 378 of file phylo_tree.hpp.
Referenced by ClearSelection(), GetCurrentEdge(), HasCurrentEdge(), and SetCurrentEdge().
|
protected |
Definition at line 379 of file phylo_tree.hpp.
Referenced by ClearSelection(), GetCurrentEdge(), HasCurrentEdge(), and SetCurrentEdge().
|
protected |
Currently active node (for operations like edit), or Null()
Definition at line 374 of file phylo_tree.hpp.
Referenced by ClearSelection(), GetCurrentNode(), GetCurrentNodeIdx(), HasCurrentNode(), SelectByPoint(), and SetCurrentNode().
|
protected |
Often when you select a node, it's children or parents may also join the selection set.
But in case of queries, user may want to only see (or iterate over) nodes actually meeting query criteria or explictly clicked on.
Definition at line 367 of file phylo_tree.hpp.
Referenced by ClearSelection(), GetExplicitlySelected(), GetExplicitlySelectedAndNotCollapsed(), GetExplicitlySelectedIDs(), GetSelState(), SetExplicitlySelected(), SetLeavesExplicitlySelected(), SetSelection(), and x_SetSelState().
|
protected |
Feature dictionary.
Definition at line 387 of file phylo_tree.hpp.
Referenced by GetFeatureDict(), and x_ConvertUpstream().
|
protected |
Model for rendering (updated from current tree state)
Definition at line 382 of file phylo_tree.hpp.
Referenced by Clear(), GetGraphicsModel(), GetGraphicsModelRef(), and SetGraphicsModelRef().
|
protected |
Definition at line 371 of file phylo_tree.hpp.
Referenced by FindNodeById(), and UpdateNodesMapping().
|
protected |
Definition at line 361 of file phylo_tree.hpp.
Referenced by ClearSelection(), GetNumSelected(), GetSelected(), GetSelectedBoundary(), GetSelectedIDs(), HasSelection(), SetExplicitlySelected(), SetLeavesExplicitlySelected(), and x_SetSelState().
|
protected |
Selection sets - sets of selected nodes, which are saved in the biotreecontainer in user data (visualized kind of like clusters)
Definition at line 391 of file phylo_tree.hpp.
Referenced by GetSelectionSets().