NCBI C++ ToolKit
phylo_tree.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 #ifndef GUI_WIDGETS_PHY_TREE___PHYLO_RENDER_MODEL__HPP
2 #define GUI_WIDGETS_PHY_TREE___PHYLO_RENDER_MODEL__HPP
3 
4 /* $Id: phylo_tree.hpp 47464 2023-04-20 00:19:10Z evgeniev $
5  * ===========================================================================
6  *
7  * PUBLIC DOMAIN NOTICE
8  * National Center for Biotechnology Information
9  *
10  * This software/database is a "United States Government Work" under the
11  * terms of the United States Copyright Act. It was written as part of
12  * the author's official duties as a United States Government employee and
13  * thus cannot be copyrighted. This software/database is freely available
14  * to the public for use. The National Library of Medicine and the U.S.
15  * Government have not placed any restriction on its use or reproduction.
16  *
17  * Although all reasonable efforts have been taken to ensure the accuracy
18  * and reliability of the software and data, the NLM and the U.S.
19  * Government do not and cannot warrant the performance or results that
20  * may be obtained by using this software or data. The NLM and the U.S.
21  * Government disclaim all warranties, express or implied, including
22  * warranties of performance, merchantability or fitness for any particular
23  * purpose.
24  *
25  * Please cite the author in any work or product based on this material.
26  *
27  * ===========================================================================
28  *
29  * Authors: Bob Falk
30  *
31  * File Description:
32  *
33  */
34 
35 #include <corelib/ncbistd.hpp>
36 #include <corelib/ncbiobj.hpp>
37 #include <gui/utils/vect2.hpp>
38 #include <gui/opengl/glrect.hpp>
43 
45 
46 /////////////////////////////////////////////////////////////////////////////
47 ///
48 /// Tree subclass also has functions and data needed for rendering and
49 /// selection.
50 ///
52 {
53 public:
56  typedef pair<TTreeIdx, CPhyloNodeData::TSelectedState> TSelStateValue;
57  typedef vector<TSelStateValue> TSelState;
58 
59 public:
60 
61  /// ctor - need to add nodes to make tree valid
62  CPhyloTree();
63 
64  /// Clear the tree nodes, graphics model and selected nodes
65  void Clear();
66 
67  /// Get model for rendering
68  CTreeGraphicsModel& GetGraphicsModel();
69 
70  /// Set graphics model - may be needed if we want to render
71  /// to different graphics contexts since graphics model
72  /// has context-specific data (e.g. OpenGL buffer Ids)
73  void SetGraphicsModelRef(CRef<CTreeGraphicsModel> gm) { m_GraphicsModel = gm; }
74  CRef<CTreeGraphicsModel> GetGraphicsModelRef() { return m_GraphicsModel; }
75  CRgbaGradColorTable* GetColorTable();
76 
77  /// Sort the children of a node based on the number of children they have
78  ///
79  /// @param
80  /// idx - index of the node whose children will be sorted
81  /// order - if true order nodes in descending order of subtree size
82  void Sort(TTreeIdx idx, bool order);
83 
84  /// Sort the children of a node based on length of longest subtree
85  ///
86  /// @param
87  /// idx - index of the node whose children will be sorted
88  /// order - if true order nodes in descending order of distance
89  void SortSubtreeDist(TTreeIdx idx, const vector<float>& distances, bool order);
90 
91  /// Sort the children of a node based on label comparison (alphabetical order)
92  ///
93  /// @param
94  /// idx - index of the node whose children will be sorted
95  /// order - if true order nodes in descending alphabetical order
96  void SortLabel(TTreeIdx idx, bool order);
97 
98  /// Sort the children of a node based on the alphanumeric range of
99  /// their child nodes.
100  ///
101  /// @param
102  /// idx - index of the node whose children will be sorted
103  /// order - if true order nodes in descending alphabeitcal label range
104  void SortLabelRange(TTreeIdx idx,
105  const vector<pair<string,string> >& subtree_labels,
106  bool order);
107 
108  /// Select or deselect the node at the specified index and, optionally, its
109  /// parents and children as well. Parent selection state is eTraced or eShared.
110  ///
111  /// @param
112  /// idx - the node to be selected or unselected (eSelected or eNotSelected)
113  /// sel - if true the node should be selected, false - deselected
114  /// sel_children - if true, all chidren recursively are selected/deselected
115  /// sel_parents - if true all ancestors are selected/deselected
116  void SetSelection(TTreeIdx idx,
117  bool sel,
118  bool sel_children = true,
119  bool sel_parents = true);
120 
121  /// Given the selection of node 'idx', store the selection state
122  /// (selected, traced, shared) of that node and its parents. This
123  /// function does Not update selection state of the actual nodes.
124  ///
125  /// @param
126  /// sel_state - vector to return the selection info
127  /// idx - the node whose selection state we are retrieving
128  /// sel_children - if true, all chidren recursively are added to sel state
129  /// sel_parents - if true all ancestors are added to sel state
130  void GetSelState(TSelState& sel_state,
131  TTreeIdx idx,
132  bool sel_children = true,
133  bool sel_parents = true) const;
134 
135  /// Sets selection state of all nodes to eNotSelected and clears m_Selected
136  void ClearSelection();
137 
138  /// Returns indices of selected nodes
139  ///
140  /// @return - vector of all nodes with state eSelected
141  void GetSelected(vector<TTreeIdx>& sel) const;
142 
143  /// Returns the node ids of selected nodes
144  ///
145  /// @return - vector of all nodes with state eSelected
146  void GetSelectedIDs(vector<TID>& sel) const;
147 
148  /// Returns the number of selected nodes
149  ///
150  /// @return - number of selected nodes with state eSelected
151  size_t GetNumSelected() const { return m_Selected.size(); }
152 
153  /// Returns only indices of nodes explicitly selected, not their parents
154  /// or children, i.e. nodes passed as first parameter to SetSelection(...)
155  ///
156  /// @return - vector of all explicitly selected nodes
157  void GetExplicitlySelected(vector<TTreeIdx>& esel) const;
158 
159  /// Returns only indices of nodes explicitly selected, but when a node
160  /// is underneath a collapsed node, the collapsed parent is returned
161  ///
162  /// @return - vector of all explicitly selected nodes
163  void GetExplicitlySelectedAndNotCollapsed(vector<TTreeIdx>& esel) const;
164 
165  /// Returns only ids of nodes explicitly selected, not their parents
166  /// or children, i.e. nodes passed as first parameter to SetSelection(...)
167  ///
168  /// @return - vector of ids of all explictly selected nodes
169  void GetExplicitlySelectedIDs(vector<TID>& esel) const;
170 
171  /// Reset explicitly selected nodes to those currently selected
172  /// nodes that are also found in the vector 'esel'
173  ///
174  /// @param
175  /// esel - vector of node indices which, if they are Also in the current
176  /// selection set, will marked as explicitly selected.
177  void SetExplicitlySelected(const vector<TID>& esel);
178 
179  /// Set the nodes used for iteration to default to the leaf nodes. This
180  /// is used when we set the selection via broadcasting from another
181  /// tree such that we don't know which nodes were explicitly selected in
182  /// the other tree.
183  void SetLeavesExplicitlySelected();
184 
185  /// Select a set of nodes - equivalent to calling
186  /// SetSelection(idx, true, true, true) on each of the nodes.
187  ///
188  /// @param
189  /// sel - the set of nodes to be selected
190  void SetSelection(const vector<TTreeIdx>& sel,
191  bool sel_children = true,
192  bool sel_parents = true);
193 
194  /// Select a set of nodes - equivalent to calling
195  /// SetSelection(idx, true, true, true) on each of the nodes.
196  ///
197  /// @param
198  /// sel - the set of node IDs to be selected
199  void SetSelectionIDs(const vector<TID>& ids, bool sel=true, bool sel_children=true);
200 
201  bool HasSelection() const { return (m_Selected.size() > 0 ? true : false); }
202 
203  /// Return bounding rectangle from lower-left to upper-right of selected
204  /// nodes (eSelected) and false if no nodes are currently selected.
205  ///
206  /// @param
207  /// ll - min x and y coordinates for selected set
208  /// ur - max x and y coordinates for selected set
209  /// @return - true if one or more nodes are selected, false otherwise
210  bool GetSelectedBoundary(CVect2<float>& ll, CVect2<float>& ur);
211 
212  /// Determine if the point pt is close enough to a node to select or
213  /// deselect it. If it is, select or deselect according to sel and toggle
214  ///
215  /// @param
216  /// pt - the selection position
217  /// sel - if true we are doing normal (vs. incremental) selection
218  /// toggle - if true we should toggle node's selection state
219  // labels_visible - if true node labels are currently displayed
220  // rotated_lables - if true labels are drawn rotated as needed
221  /// @return - true if a node's selections state was updated
222  bool SelectByPoint(const CVect2<float>& pt, bool sel, bool toggle,
223  bool labels_visible, bool rotated_labels=false);
224 
225  /// Select or deselect all nodes in the rectangle bounded by ll and ur
226  ///
227  /// @param
228  /// ll - lower left corner of selection rectangle
229  /// ur - upper right corner of selection rectangle
230  /// toggle - if true we should toggle node's selection state
231  /// @return - true if one or more node's selection state was updated
232  bool SelectByRect(const CVect2<float>& ll,
233  const CVect2<float>& ur,
234  bool toggle);
235 
236  /// Returns indices of nodes thate are currently collapsed
237  ///
238  /// @return - vector of all collapsed nodes
239  vector<TTreeIdx> GetAllCollapsed() const;
240 
241  /// Return the index of the given node (node_idx) if none of its parent
242  /// nodes up to the root are collapsed, otherwise return the node index
243  /// of the collapsed parent node closest to the root
244  ///
245  /// @param
246  /// node_idx - the node to check
247  /// @return - Index of the node itself or of the collapsed parent node, if
248  /// any, closest to the root.
249  TTreeIdx GetCollapsedParentIdx(TTreeIdx node_idx) const;
250 
251  /// Set the index of the currently active node. Active nodes may have
252  /// edits or property updates applied to them.
253  ///
254  /// @param
255  /// node_idx - index of the active node within the tree (may be Null())
256  void SetCurrentNode(TTreeIdx node_idx);
257 
258  /// If a node is close enough to the given position, set it to be the
259  /// currently active node.
260  ///
261  /// @param
262  /// node_idx - index of the active node within the tree (may be Null())
263  /// @return -true if a node was selected (even if it was already current)
264  bool SetCurrentNode(const CVect2<float>& pt, bool labels_visible, bool rotated_labels,
265  bool unselect=true);
266 
267  /// Return the index of the currently active node (may be Null()).
268  TTreeIdx GetCurrentNodeIdx() const { return m_CurrentNode; }
269 
270  /// Get reference to currently active node. Throws exception if it's Null()
271  CPhyloTreeNode& GetCurrentNode();
272 
273  /// Return true if the currently active node is not Null()
274  bool HasCurrentNode() const { return m_CurrentNode != Null(); }
275 
276  /// Set/Get the edge between the two specified nodes as current. May
277  /// be Null (but if one value is null, both are)
278  ///
279  /// @param
280  /// child_idx - index of the child node of the edge (may be Null())
281  /// parent_idx - index of the parent node of the edge (may be NULL())
282  void SetCurrentEdge(TTreeIdx child_idx, TTreeIdx parent_idx);
283  void GetCurrentEdge(TTreeIdx& child_idx, TTreeIdx& parent_idx) const;
284  bool HasCurrentEdge() const;
285 
286  /// Search nodes to find and return closest node to 'pt' that is
287  /// within the max. selection distance (used for clicking on nodes)
288  ///
289  /// @param
290  /// pt - the position against which we are testing
291  // rotated_lables - true if lables are rotated (since we also test against the label)
292  /// @return - index of the closest node within selection distance or Null()
293  TTreeIdx TestForNode(const CVect2<float>& pt, bool labels_visible, bool rotated_labels=false);
294 
295  /// Determine if the node at node_idx is within a collapsed subtree or not
296  ///
297  /// @param
298  /// node_idx - the node to check
299  /// @return - true if no parents (recursively) of node_idx are collapsed
300  bool IsVisible(TTreeIdx node_idx);
301 
302  /// Return index of the node with the given id or Null(). ID's are unique.
303  ///
304  /// @param
305  /// id - the id to search for
306  /// @return - the node with the given ID or Null().
308  {
309  TTIDPhyloTreeNodeMap::const_iterator itNode = m_NodesMap.find(id);
310  return (itNode != m_NodesMap.end()) ? itNode->second : Null();
311  }
312 
313  /// Return true if the given position in the array is not currently
314  /// included as a node in the tree. Can happen if nodes are deleted, for
315  /// example
316  ///
317  /// @param
318  /// idx - the index to check
319  /// @return - true if the position is empty
320  bool IsUnused(TTreeIdx idx) const { return m_Nodes[idx].IsUnused(); }
321 
322  /// Return feature dictionary
323  CBioTreeFeatureDictionary& GetFeatureDict() { return m_FeatureDict; }
324  const CBioTreeFeatureDictionary& GetFeatureDict() const { return m_FeatureDict; }
325 
326  CPhyloSelectionSetMgr& GetSelectionSets() { return m_SelectionSets; }
327  const CPhyloSelectionSetMgr& GetSelectionSets() const { return m_SelectionSets; }
328 
329  void UpdateNodesMapping();
330 protected:
331 
332  /// Set selected state of anode and add/remove it from m_Selected as needed
333  void x_SetSelState(TTreeIdx idx,
335  bool override_explicit=true);
336  /// Propogate selection operation (selecte/deselect) to a nodes children
337  void x_SelectChildren(CPhyloTreeNode& node, bool sel);
338  /// Propogate selection (eTraced) to a nodes parents and if children
339  /// aren't be selected, don't override explicit parent selection
340  void x_SelectParents(CPhyloTreeNode& node, bool sel, bool children_selected = true);
341 
342  /// Check recursively parents of node and set selection state to eShared if
343  /// all of their children are selected
344  TTreeIdx x_CommonNodeSearch(TTreeIdx idx);
345  void x_PropagateCommonState(CPhyloTreeNode& node);
346 
347  /// Get (and return) selection state for parents of a given node
348  void x_GetParentState(TSelState& sel_state,
349  TTreeIdx idx) const;
350  /// Get (and return) selection state for children of a given node
351  void x_GetChildState(TSelState& sel_state,
352  TTreeIdx idx) const;
353 
354  /// Convert parents of node_idx to be its children. Also moves edge data
355  /// associated with node children to parents when parent/child role is reversed.
356  virtual void x_ConvertUpstream(TTreeIdx node_idx);
357 
358 
359  /// Indices of all the nodes with selection state eSelected
362 
363  /// Often when you select a node, it's children or parents may also
364  /// join the selection set. But in case of queries, user may want to
365  /// only see (or iterate over) nodes actually meeting query criteria
366  /// or explictly clicked on.
368 
369  /// Node ID to tree index map
372 
373  /// Currently active node (for operations like edit), or Null()
375 
376  /// Currently active edge (to allow re-rooting by edge). Since we do not
377  /// explicitly store edges, save it as the edges parent and child nodes.
380 
381  /// Model for rendering (updated from current tree state)
383  /// Color table to store colors by index
385 
386  /// Feature dictionary
388 
389  /// Selection sets - sets of selected nodes, which are saved in the
390  /// biotreecontainer in user data (visualized kind of like clusters)
392 
393 private:
394 
395  /// Disable copy
398 };
399 
400 /////////////////////////////////////////////////////////////////////////////
401 //
402 // Tree traversal
403 //
404 
405 /// Depth-first tree traversal that skips collapsed nodes.
406 ///
407 /// Identical to TreeDepthFirst except for the skipping of collapsed nodes.
408 ///
409 /// Takes tree and visitor function and calls function for every
410 /// node in the subtree rooted at node_idx
411 ///
412 /// Functor should have the next prototype:
413 /// ETreeTraverseCode Func(TTreeType& tree, TTreeType::TTreeIdx node, int delta)
414 /// where node is a reference to the visited node index and delta_level
415 /// reflects the current traverse direction(depth wise) in the tree,
416 /// 0 - algorithm stays is on the same level
417 /// 1 - we are going one level deep into the tree (from the root)
418 /// -1 - we are traveling back by one level (getting close to the root)
419 ///
420 /// The specificts of the algorithm is that it calls visitor both on the
421 /// way from the root to leafs and on the way back
422 /// Using this template we can implement both variants of tree
423 /// traversal (pre-order and post-order)
424 /// Visitor controls the traversal by returning ETreeTraverseCode
425 ///
426 /// @sa ETreeTraverseCode
427 ///
428 template<class TTreeModel, class Fun>
429 void TreeDepthFirstEx(TTreeModel& tree_model, typename TTreeModel::TTreeIdx node_idx, Fun& func)
430 {
431  typedef typename TTreeModel::TNodeType TNodeType;
432 
433  int delta_level = 0;
434  ETreeTraverseCode stop_scan;
435 
436  stop_scan = func(tree_model, node_idx, delta_level);
437  switch (stop_scan) {
438  case eTreeTraverseStop:
440  return;
441  case eTreeTraverse:
442  break;
443  }
444 
445  delta_level = 1;
446  TNodeType* tr = &tree_model[node_idx];
447 
448  typedef typename TNodeType::TNodeList_I TTreeNodeIterator;
449 
450  TTreeNodeIterator it = tr->SubNodeBeginEx();
451  TTreeNodeIterator it_end = tr->SubNodeEndEx();
452 
453  if (it == it_end)
454  return;
455 
456  stack<TTreeNodeIterator> tree_stack;
457 
458  while (true) {
459  tr = &tree_model[*it];
460  stop_scan = func(tree_model, *it, delta_level);
461  switch (stop_scan) {
462  case eTreeTraverseStop:
463  return;
464  case eTreeTraverse:
466  break;
467  }
468  if ( (stop_scan != eTreeTraverseStepOver) &&
469  (delta_level >= 0) &&
470  (!tr->IsLeafEx())) { // sub-node, going down
471  tree_stack.push(it);
472  it = tr->SubNodeBeginEx();
473  it_end = tr->SubNodeEndEx();
474  delta_level = 1;
475  continue;
476  }
477  ++it;
478  if (it == it_end) { // end of level, going up
479  if (tree_stack.empty()) {
480  break;
481  }
482  it = tree_stack.top();
483  tree_stack.pop();
484  tr = &tree_model[*it];
485  it_end = tree_model[tr->GetParent()].SubNodeEndEx();
486  delta_level = -1;
487  continue;
488  }
489  // same level
490  delta_level = 0;
491 
492  } // while
493 
494  func(tree_model, node_idx, -1);
495 }
496 
497 /// Calls TreeDepthFirst with the root node of 'tree_model'
498 ///
499 template<class TTreeModel, class Fun>
500 void TreeDepthFirstEx(TTreeModel& tree_model, Fun& func)
501 {
502  TreeDepthFirstEx(tree_model, tree_model.GetRootIdx(), func);
503 }
504 
505 ///////////////////////////////////////////////////////////////////////////////
506 /// Breadth-first tree traversal that skips collapsed nodes.
507 ///
508 /// Traverse the tree in breadth-first order, skipping
509 /// collapsed nodes.
510 ///
511 /// Takes tree and visitor function and calls function for every
512 /// node in the subtree rooted at node_idx
513 ///
514 /// Functor should have the next prototype:
515 /// ETreeTraverseCode Func(TTreeType& tree, TTreeType::TTreeIdx node, int delta)
516 /// where node is a reference to the visited node index and delta_level
517 /// reflects the current traverse direction(depth wise) in the tree,
518 /// 0 - algorithm stays on the same level
519 /// 1 - we are going one level deep into the tree (from the root)
520 ///
521 ///
522 /// @sa ETreeTraverseCode
523 ///
524 template<class TTreeModel, class Fun>
525 void TreeBreadthFirstEx(TTreeModel& tree_model, typename TTreeModel::TTreeIdx node_idx, Fun& func)
526 {
527  typedef typename TTreeModel::TNodeType TNodeType;
528  typedef typename TTreeModel::TTreeIdx TTreeIdx;
529 
530  int delta_level = 0;
531  ETreeTraverseCode stop_scan;
532 
533  stop_scan = func(tree_model, node_idx, delta_level);
534  switch (stop_scan) {
535  case eTreeTraverseStop:
537  return;
538  case eTreeTraverse:
539  break;
540  }
541 
542  typedef typename TNodeType::TNodeList_I TTreeNodeIterator;
543 
544  queue<TTreeIdx> node_queue;
545  node_queue.push(node_idx);
546  int level_count = 1;
547  delta_level = 1;
548 
549  while (!node_queue.empty()) {
550  TTreeIdx node_idx = node_queue.front();
551  node_queue.pop();
552 
553  TNodeType* tr = &tree_model[node_idx];
554 
555  TTreeNodeIterator it = tr->SubNodeBeginEx();
556  TTreeNodeIterator it_end = tr->SubNodeEndEx();
557  for (; it != it_end; ++it) {
558  stop_scan = func(tree_model, *it, delta_level);
559  switch (stop_scan) {
560  case eTreeTraverseStop:
561  return;
562  case eTreeTraverse:
564  break;
565  }
566  if ( (stop_scan != eTreeTraverseStepOver) &&
567  (!tr->IsLeafEx())) { // sub-node, que for next pass
568  node_queue.push(*it);
569  }
570  // same level
571  delta_level = 0;
572  }
573 
574  // track current level so that we can set delta_level correctly
575  if (--level_count == 0) {
576  level_count = static_cast<int>(node_queue.size());
577  delta_level = 1;
578  }
579 
580  } // while
581 
582  func(tree_model, node_idx, -1);
583 }
584 
585 /// Calls TreeBreadthFirstEx with the root node of 'tree_model'
586 ///
587 template<class TTreeModel, class Fun>
588 void TreeBreadthFirstEx(TTreeModel& tree_model, Fun& func)
589 {
590  TreeBreadthFirstEx(tree_model, tree_model.GetRootIdx(), func);
591 }
592 
594 
595 #endif
Feature dictionary.
Definition: bio_tree.hpp:176
objects::CNode::TId TID
Tree subclass also has functions and data needed for rendering and selection.
Definition: phylo_tree.hpp:52
CRef< CTreeGraphicsModel > m_GraphicsModel
Model for rendering (updated from current tree state)
Definition: phylo_tree.hpp:382
bool IsUnused(TTreeIdx idx) const
Return true if the given position in the array is not currently included as a node in the tree.
Definition: phylo_tree.hpp:320
TTIDPhyloTreeNodeMap m_NodesMap
Definition: phylo_tree.hpp:371
CRef< CTreeGraphicsModel > GetGraphicsModelRef()
Definition: phylo_tree.hpp:74
CPhyloTree & operator=(const CPhyloTree &)
TTreeIdx m_CurrentEdgeChild
Currently active edge (to allow re-rooting by edge).
Definition: phylo_tree.hpp:378
map< TID, TTreeIdx > TTIDPhyloTreeNodeMap
Node ID to tree index map.
Definition: phylo_tree.hpp:370
TTreeIdxSet m_Selected
Definition: phylo_tree.hpp:361
TTreeIdx m_CurrentNode
Currently active node (for operations like edit), or Null()
Definition: phylo_tree.hpp:374
TTreeIdxSet m_ExplicitlySelected
Often when you select a node, it's children or parents may also join the selection set.
Definition: phylo_tree.hpp:367
CPhyloNodeData::TClusterID TClusterID
Definition: phylo_tree.hpp:54
bool HasSelection() const
Definition: phylo_tree.hpp:201
CPhyloSelectionSetMgr & GetSelectionSets()
Definition: phylo_tree.hpp:326
const CBioTreeFeatureDictionary & GetFeatureDict() const
Definition: phylo_tree.hpp:324
TTreeIdx GetCurrentNodeIdx() const
Return the index of the currently active node (may be Null()).
Definition: phylo_tree.hpp:268
CRef< CRgbaGradColorTable > m_ColorTable
Color table to store colors by index.
Definition: phylo_tree.hpp:384
vector< TSelStateValue > TSelState
Definition: phylo_tree.hpp:57
CPhyloTree(const CPhyloTree &)
Disable copy.
TTreeIdx m_CurrentEdgeParent
Definition: phylo_tree.hpp:379
CPhyloSelectionSetMgr m_SelectionSets
Selection sets - sets of selected nodes, which are saved in the biotreecontainer in user data (visual...
Definition: phylo_tree.hpp:391
const CPhyloSelectionSetMgr & GetSelectionSets() const
Definition: phylo_tree.hpp:327
bool HasCurrentNode() const
Return true if the currently active node is not Null()
Definition: phylo_tree.hpp:274
TTreeIdx FindNodeById(TID id) const
Return index of the node with the given id or Null().
Definition: phylo_tree.hpp:307
set< TTreeIdx > TTreeIdxSet
Indices of all the nodes with selection state eSelected.
Definition: phylo_tree.hpp:360
CBioTreeFeatureDictionary & GetFeatureDict()
Return feature dictionary.
Definition: phylo_tree.hpp:323
pair< TTreeIdx, CPhyloNodeData::TSelectedState > TSelStateValue
Definition: phylo_tree.hpp:56
size_t GetNumSelected() const
Returns the number of selected nodes.
Definition: phylo_tree.hpp:151
CPhyloNodeData::TID TID
Definition: phylo_tree.hpp:55
CBioTreeFeatureDictionary m_FeatureDict
Feature dictionary.
Definition: phylo_tree.hpp:387
void SetGraphicsModelRef(CRef< CTreeGraphicsModel > gm)
Set graphics model - may be needed if we want to render to different graphics contexts since graphics...
Definition: phylo_tree.hpp:73
CRgbaGradColorTable Provides a storage for colors (to eliminate color creation overhead) and Function...
class CTreeGraphicsModel Model for rendering tree graphics data.
virtual void x_ConvertUpstream(TTreeIdx node_idx)
Convert parents of node_idx to be its children.
Definition: tree_model.hpp:736
static TTreeIdx Null()
Return the index value that represents a NULL node.
Definition: tree_model.hpp:678
void Clear()
Remove all nodes (empty array) and set root index to Null.
Definition: tree_model.hpp:681
container_type::const_iterator const_iterator
Definition: map.hpp:53
Include a standard set of the NCBI C++ Toolkit most basic headers.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
ETreeTraverseCode
Tree traverse code returned by the traverse predicate function.
Definition: ncbi_tree.hpp:51
@ eTreeTraverseStop
Stop traversal (return form algorithm)
Definition: ncbi_tree.hpp:53
@ eTreeTraverse
Keep traversal.
Definition: ncbi_tree.hpp:52
@ eTreeTraverseStepOver
Do not traverse current node (pick the next one)
Definition: ncbi_tree.hpp:54
#define NCBI_GUIWIDGETS_PHYLO_TREE_EXPORT
Definition: gui_export.h:535
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
void TreeBreadthFirstEx(TTreeModel &tree_model, typename TTreeModel::TTreeIdx node_idx, Fun &func)
Breadth-first tree traversal that skips collapsed nodes.
Definition: phylo_tree.hpp:525
void TreeDepthFirstEx(TTreeModel &tree_model, typename TTreeModel::TTreeIdx node_idx, Fun &func)
Depth-first tree traversal that skips collapsed nodes.
Definition: phylo_tree.hpp:429
size_t TTreeIdx
Bi-directionaly linked N way tree allocated in a contiguous memory block.
Definition: tree_model.hpp:48
Modified on Fri Sep 20 14:57:36 2024 by modify_doxy.py rev. 669887