NCBI C++ ToolKit
Public Types | Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Private Member Functions | List of all members
CPhyloTree Class Reference

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>

+ Inheritance diagram for CPhyloTree:
+ Collaboration diagram for CPhyloTree:

Public Types

typedef CPhyloNodeData::TClusterID TClusterID
 
typedef CPhyloNodeData::TID TID
 
typedef pair< TTreeIdx, CPhyloNodeData::TSelectedStateTSelStateValue
 
typedef vector< TSelStateValueTSelState
 
- Public Types inherited from CTreeModel< CPhyloTreeNode >
typedef CPhyloTreeNode 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

 CPhyloTree ()
 ctor - need to add nodes to make tree valid More...
 
void Clear ()
 Clear the tree nodes, graphics model and selected nodes. More...
 
CTreeGraphicsModelGetGraphicsModel ()
 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< CTreeGraphicsModelGetGraphicsModelRef ()
 
CRgbaGradColorTableGetColorTable ()
 
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< TTreeIdxGetAllCollapsed () 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...
 
CPhyloTreeNodeGetCurrentNode ()
 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...
 
CBioTreeFeatureDictionaryGetFeatureDict ()
 Return feature dictionary. More...
 
const CBioTreeFeatureDictionaryGetFeatureDict () const
 
CPhyloSelectionSetMgrGetSelectionSets ()
 
const CPhyloSelectionSetMgrGetSelectionSets () 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...
 
TNodeTypeGetNode (TTreeIdx idx)
 Return a reference to the node at the given index. More...
 
const CPhyloTreeNodeGetNode (TTreeIdx idx) const
 
TNodeTypeoperator[] (TTreeIdx idx)
 Use operator[] to return a reference to the node at 'idx'. More...
 
const CPhyloTreeNodeoperator[] (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 CPhyloTreeNodeGetRoot () 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...
 
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
 

Protected Types

typedef set< TTreeIdxTTreeIdxSet
 Indices of all the nodes with selection state eSelected. More...
 
typedef map< TID, TTreeIdxTTIDPhyloTreeNodeMap
 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< CTreeGraphicsModelm_GraphicsModel
 Model for rendering (updated from current tree state) More...
 
CRef< CRgbaGradColorTablem_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...
 
CPhyloTreeoperator= (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...
 

Detailed Description

Tree subclass also has functions and data needed for rendering and selection.

Definition at line 51 of file phylo_tree.hpp.

Member Typedef Documentation

◆ TClusterID

Definition at line 54 of file phylo_tree.hpp.

◆ TID

Definition at line 55 of file phylo_tree.hpp.

◆ TSelState

Definition at line 57 of file phylo_tree.hpp.

◆ TSelStateValue

Definition at line 56 of file phylo_tree.hpp.

◆ TTIDPhyloTreeNodeMap

Node ID to tree index map.

Definition at line 370 of file phylo_tree.hpp.

◆ TTreeIdxSet

typedef set<TTreeIdx> CPhyloTree::TTreeIdxSet
protected

Indices of all the nodes with selection state eSelected.

Definition at line 360 of file phylo_tree.hpp.

Constructor & Destructor Documentation

◆ CPhyloTree() [1/2]

CPhyloTree::CPhyloTree ( )

ctor - need to add nodes to make tree valid

Definition at line 42 of file phylo_tree.cpp.

References Clear().

◆ CPhyloTree() [2/2]

CPhyloTree::CPhyloTree ( const CPhyloTree )
private

Disable copy.

Member Function Documentation

◆ Clear()

void CPhyloTree::Clear ( void  )

◆ ClearSelection()

void CPhyloTree::ClearSelection ( )

◆ FindNodeById()

TTreeIdx CPhyloTree::FindNodeById ( TID  id) const
inline

◆ GetAllCollapsed()

vector< CPhyloTree::TTreeIdx > CPhyloTree::GetAllCollapsed ( ) const

Returns indices of nodes thate are currently collapsed.

Returns
- vector of all collapsed nodes

Definition at line 368 of file phylo_tree.cpp.

References CPhyloNodeData::eHideChildren, i, IsUnused(), and CTreeModel< CPhyloTreeNode >::m_Nodes.

Referenced by CPhyloTreeWidget::OnShowAll().

◆ GetCollapsedParentIdx()

TTreeIdx CPhyloTree::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.

Parameters
node_idx- the node to check
Returns
- Index of the node itself or of the collapsed parent node, if any, closest to the root.

Definition at line 382 of file phylo_tree.cpp.

References CTreeModel< CPhyloTreeNode >::GetNode(), CTreeModelNode< TData >::GetParent(), CTreeModelNode< CPhyloNodeData >::Null(), and result.

◆ GetColorTable()

CRgbaGradColorTable * CPhyloTree::GetColorTable ( )

◆ GetCurrentEdge()

void CPhyloTree::GetCurrentEdge ( TTreeIdx child_idx,
TTreeIdx parent_idx 
) const

Definition at line 448 of file phylo_tree.cpp.

References m_CurrentEdgeChild, and m_CurrentEdgeParent.

Referenced by CPhyloTreeWidget::OnRerootTreeAtEdge().

◆ GetCurrentNode()

CPhyloTreeNode & CPhyloTree::GetCurrentNode ( )

◆ GetCurrentNodeIdx()

TTreeIdx CPhyloTree::GetCurrentNodeIdx ( ) const
inline

◆ GetExplicitlySelected()

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(...)

Returns
- vector of all explicitly selected nodes

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().

◆ GetExplicitlySelectedAndNotCollapsed()

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.

Returns
- vector of all explicitly selected nodes

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().

◆ GetExplicitlySelectedIDs()

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(...)

Returns
- vector of ids of all explictly selected nodes

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().

◆ GetFeatureDict() [1/2]

CBioTreeFeatureDictionary& CPhyloTree::GetFeatureDict ( )
inline

◆ GetFeatureDict() [2/2]

const CBioTreeFeatureDictionary& CPhyloTree::GetFeatureDict ( ) const
inline

Definition at line 324 of file phylo_tree.hpp.

References m_FeatureDict.

◆ GetGraphicsModel()

CTreeGraphicsModel & CPhyloTree::GetGraphicsModel ( )

◆ GetGraphicsModelRef()

CRef<CTreeGraphicsModel> CPhyloTree::GetGraphicsModelRef ( )
inline

Definition at line 74 of file phylo_tree.hpp.

References m_GraphicsModel.

◆ GetNumSelected()

size_t CPhyloTree::GetNumSelected ( ) const
inline

Returns the number of selected nodes.

Returns
- number of selected nodes with state eSelected

Definition at line 151 of file phylo_tree.hpp.

References m_Selected, and set< Key, Compare >::size().

Referenced by CPhyTreeView::OnCreateSelectedSubtree(), and CPhyloTreeWidget::OnUpdateSubtreeFromSelection().

◆ GetSelected()

void CPhyloTree::GetSelected ( vector< TTreeIdx > &  sel) const

Returns indices of selected nodes.

Returns
- vector of all nodes with state eSelected

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().

◆ GetSelectedBoundary()

bool CPhyloTree::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.

Parameters
ll- min x and y coordinates for selected set ur - max x and y coordinates for selected set
Returns
- true if one or more nodes are selected, false otherwise

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().

◆ GetSelectedIDs()

void CPhyloTree::GetSelectedIDs ( vector< TID > &  sel) const

Returns the node ids of selected nodes.

Returns
- vector of all nodes with state eSelected

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().

◆ GetSelectionSets() [1/2]

CPhyloSelectionSetMgr& CPhyloTree::GetSelectionSets ( )
inline

◆ GetSelectionSets() [2/2]

const CPhyloSelectionSetMgr& CPhyloTree::GetSelectionSets ( ) const
inline

Definition at line 327 of file phylo_tree.hpp.

References m_SelectionSets.

◆ GetSelState()

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.

Parameters
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().

◆ HasCurrentEdge()

bool CPhyloTree::HasCurrentEdge ( ) const

◆ HasCurrentNode()

bool CPhyloTree::HasCurrentNode ( ) const
inline

◆ HasSelection()

bool CPhyloTree::HasSelection ( ) const
inline

◆ IsUnused()

bool CPhyloTree::IsUnused ( TTreeIdx  idx) const
inline

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

Parameters
idx- the index to check
Returns
- true if the position is empty

Definition at line 320 of file phylo_tree.hpp.

References CTreeModel< CPhyloTreeNode >::m_Nodes.

Referenced by GetAllCollapsed().

◆ IsVisible()

bool CPhyloTree::IsVisible ( TTreeIdx  node_idx)

Determine if the node at node_idx is within a collapsed subtree or not.

Parameters
node_idx- the node to check
Returns
- true if no parents (recursively) of node_idx are collapsed

Definition at line 469 of file phylo_tree.cpp.

References CPhyloNodeData::eHideChildren, CTreeModelNode< TData >::GetParent(), CTreeModel< CPhyloTreeNode >::m_Nodes, NULL, and CTreeModelNode< CPhyloNodeData >::Null().

◆ operator=()

CPhyloTree& CPhyloTree::operator= ( const CPhyloTree )
private

◆ SelectByPoint()

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

Parameters
pt- the selection position sel - if true we are doing normal (vs. incremental) selection toggle - if true we should toggle node's selection state
Returns
- true if a node's selections state was updated

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().

◆ SelectByRect()

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.

Parameters
ll- lower left corner of selection rectangle ur - upper right corner of selection rectangle toggle - if true we should toggle node's selection state
Returns
- true if one or more node's selection state was updated

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().

◆ SetCurrentEdge()

void CPhyloTree::SetCurrentEdge ( TTreeIdx  child_idx,
TTreeIdx  parent_idx 
)

Set/Get the edge between the two specified nodes as current.

May be Null (but if one value is null, both are)

Parameters
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().

◆ SetCurrentNode() [1/2]

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.

Parameters
node_idx- index of the active node within the tree (may be Null())
Returns
-true if a node was selected (even if it was already current)

Definition at line 420 of file phylo_tree.cpp.

References m_CurrentNode, CTreeModel< CPhyloTreeNode >::Null(), and TestForNode().

◆ SetCurrentNode() [2/2]

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.

Parameters
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().

◆ SetExplicitlySelected()

void CPhyloTree::SetExplicitlySelected ( const vector< TID > &  esel)

Reset explicitly selected nodes to those currently selected nodes that are also found in the vector 'esel'.

Parameters
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().

◆ SetGraphicsModelRef()

void CPhyloTree::SetGraphicsModelRef ( CRef< CTreeGraphicsModel gm)
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.

◆ SetLeavesExplicitlySelected()

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().

◆ SetSelection() [1/2]

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.

Parameters
sel- the set of nodes to be selected

Definition at line 357 of file phylo_tree.cpp.

References SetSelection().

◆ SetSelection() [2/2]

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.

Parameters
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().

◆ SetSelectionIDs()

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.

Parameters
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()

void CPhyloTree::Sort ( TTreeIdx  idx,
bool  order 
)

Sort the children of a node based on the number of children they have.

Parameters
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().

◆ SortLabel()

void CPhyloTree::SortLabel ( TTreeIdx  idx,
bool  order 
)

Sort the children of a node based on label comparison (alphabetical order)

Parameters
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().

◆ SortLabelRange()

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.

Parameters
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().

◆ SortSubtreeDist()

void CPhyloTree::SortSubtreeDist ( TTreeIdx  idx,
const vector< float > &  distances,
bool  order 
)

Sort the children of a node based on length of longest subtree.

Parameters
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().

◆ TestForNode()

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)

Parameters
pt- the position against which we are testing
Returns
- index of the closest node within selection distance or Null()

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().

◆ UpdateNodesMapping()

void CPhyloTree::UpdateNodesMapping ( )

◆ x_CommonNodeSearch()

CPhyloTree::TTreeIdx CPhyloTree::x_CommonNodeSearch ( TTreeIdx  idx)
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().

◆ x_ConvertUpstream()

void CPhyloTree::x_ConvertUpstream ( TTreeIdx  node_idx)
protectedvirtual

◆ x_GetChildState()

void CPhyloTree::x_GetChildState ( TSelState sel_state,
TTreeIdx  idx 
) const
protected

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().

◆ x_GetParentState()

void CPhyloTree::x_GetParentState ( TSelState sel_state,
TTreeIdx  idx 
) const
protected

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().

◆ x_PropagateCommonState()

void CPhyloTree::x_PropagateCommonState ( CPhyloTreeNode node)
protected

◆ x_SelectChildren()

void CPhyloTree::x_SelectChildren ( CPhyloTreeNode node,
bool  sel 
)
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().

◆ x_SelectParents()

void CPhyloTree::x_SelectParents ( CPhyloTreeNode node,
bool  sel,
bool  children_selected = true 
)
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().

◆ x_SetSelState()

void CPhyloTree::x_SetSelState ( TTreeIdx  idx,
CPhyloNodeData::TSelectedState  state,
bool  override_explicit = true 
)
protected

Member Data Documentation

◆ m_ColorTable

CRef<CRgbaGradColorTable> CPhyloTree::m_ColorTable
protected

Color table to store colors by index.

Definition at line 384 of file phylo_tree.hpp.

Referenced by GetColorTable().

◆ m_CurrentEdgeChild

TTreeIdx CPhyloTree::m_CurrentEdgeChild
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().

◆ m_CurrentEdgeParent

TTreeIdx CPhyloTree::m_CurrentEdgeParent
protected

Definition at line 379 of file phylo_tree.hpp.

Referenced by ClearSelection(), GetCurrentEdge(), HasCurrentEdge(), and SetCurrentEdge().

◆ m_CurrentNode

TTreeIdx CPhyloTree::m_CurrentNode
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().

◆ m_ExplicitlySelected

TTreeIdxSet CPhyloTree::m_ExplicitlySelected
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().

◆ m_FeatureDict

CBioTreeFeatureDictionary CPhyloTree::m_FeatureDict
protected

Feature dictionary.

Definition at line 387 of file phylo_tree.hpp.

Referenced by GetFeatureDict(), and x_ConvertUpstream().

◆ m_GraphicsModel

CRef<CTreeGraphicsModel> CPhyloTree::m_GraphicsModel
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().

◆ m_NodesMap

TTIDPhyloTreeNodeMap CPhyloTree::m_NodesMap
protected

Definition at line 371 of file phylo_tree.hpp.

Referenced by FindNodeById(), and UpdateNodesMapping().

◆ m_Selected

TTreeIdxSet CPhyloTree::m_Selected
protected

◆ m_SelectionSets

CPhyloSelectionSetMgr CPhyloTree::m_SelectionSets
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().


The documentation for this class was generated from the following files:
Modified on Mon Jul 15 05:31:26 2024 by modify_doxy.py rev. 669887