NCBI C++ ToolKit
phylo_circular_cladogram.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: phylo_circular_cladogram.cpp 45513 2020-08-20 19:05:56Z evgeniev $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Bob Falk
27  *
28  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
34 
36 #include <gui/utils/math.hpp>
37 #include <corelib/ncbi_limits.h>
38 
40 
41 //////////////////////////////////////////////////////////////////////
42 //
43 //////////////////////////////////////////////////////////////////////
44 
45 
47 : m_UseMinimalRotation(true)
48 {
49  SetRotatedLabels(true);
50 }
51 
53 : IPhyloTreeRender(w, h)
54 , m_UseMinimalRotation(true)
55 {
56  SetRotatedLabels(true);
57 }
58 
59 
61 {
62 }
63 
64 
66 {
67 #ifdef ATTRIB_MENU_SUPPORT
69 #endif
70 
71  Int4 leafs = ds.GetSize();
72  Int4 width = ds.GetWidth();
73 
74  if (width>0){
75  m_xStep = m_DimX / width;
76  }
77  else {
78  m_xStep = m_DimX / 2;
79  }
80 
81  if (leafs>1){
82  m_yStep = m_DimY / leafs;
83  }
84  else {
85  m_yStep = m_DimY / 2;
86  }
87 
88  if (float(m_DS->GetNormDistance()) > kMin_Float)
90  else
91  m_NormDistance = 1.0;
92 
96 
97  x_Calculate(ds.GetTree());
98 
99  TModelRect newRect = ds.GetBoundRect();
100 
101  m_RasterRect.Init(newRect.Left(),
102  newRect.Bottom(),
103  newRect.Right(),
104  newRect.Top());
105 
108 
111 }
112 
114 {
115  // Set drawing options that are specific to slanted cladogram
116  CGlVboNode* edge_node = ds.GetModel().FindGeomNode("TreeEdges");
117  CGlVboNode* narrow_edge_node = ds.GetModel().FindGeomNode("NarrowTreeEdges");
118 
119  CGlVboNode* sel_edge_node = ds.GetModel().FindGeomNode("SelectedTreeEdges");
120  CGlVboNode* sel_narrow_edge_node = ds.GetModel().FindGeomNode("SelectedNarrowTreeEdges");
121 
122  CGlVboNode* filler_points_node = m_DS->GetModel().FindGeomNode("FillerPoints");
123 
124  if (edge_node != NULL && narrow_edge_node != NULL &&
125  sel_edge_node != NULL && sel_narrow_edge_node != NULL) {
126  edge_node->GetState().Enable(GL_LINE_SMOOTH);
127  edge_node->GetState().Enable(GL_BLEND);
128  edge_node->GetState().BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
129 
130  sel_edge_node->GetState().Enable(GL_LINE_SMOOTH);
131  sel_edge_node->GetState().Enable(GL_BLEND);
132  sel_edge_node->GetState().BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
133 
134  narrow_edge_node->GetState().Enable(GL_LINE_SMOOTH);
135  narrow_edge_node->GetState().Enable(GL_BLEND);
136  narrow_edge_node->GetState().BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
137 
138  sel_narrow_edge_node->GetState().Enable(GL_LINE_SMOOTH);
139  sel_narrow_edge_node->GetState().Enable(GL_BLEND);
140  sel_narrow_edge_node->GetState().BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
141  }
142 
143  if (filler_points_node != NULL)
144  filler_points_node->SetVisible(false);
145 }
146 
148 {
149  // Enable circular label processing...
152  }
153 
154  CGlVboNode* edge_node = m_DS->GetModel().FindGeomNode("TreeEdges");
155  CGlVboNode* narrow_edge_node = m_DS->GetModel().FindGeomNode("NarrowTreeEdges");
156  CGlVboNode* sel_edge_node = ds.GetModel().FindGeomNode("SelectedTreeEdges");
157  CGlVboNode* point_node = m_DS->GetModel().FindGeomNode("NodePoints");
158  _ASSERT(edge_node != NULL &&
159  narrow_edge_node != NULL &&
160  sel_edge_node != NULL &&
161  point_node != NULL);
162 
163  GLsizei edge_count = (GLsizei)ds.GetNumEdges();
164  GLsizei node_count = (GLsizei)ds.GetNumNodes();
165 
166  int estimatedSize = edge_count * 155;
167 
168  if (edge_count > 0) {
169  vector<float> color_coords;
170  color_coords.reserve(node_count);
171 
172  vector<CVect2<float> > edge_node_coords, sel_edge_node_coords;
173  edge_node_coords.reserve(estimatedSize);
174  sel_edge_node_coords.reserve(estimatedSize);
175 
176  vector<CVect4<unsigned char> > edge_node_colors, sel_edge_node_colors;
177  edge_node_colors.reserve(estimatedSize);
178  sel_edge_node_colors.reserve(estimatedSize);
179 
180  x_DrawTree(ds.GetTree(), color_coords, edge_node_coords, edge_node_colors, sel_edge_node_coords, sel_edge_node_colors);
181  point_node->SetTexCoordBuffer1D(color_coords);
182 
183  point_node->ClearPositions();
184  point_node->SetVisible(true);
185 
186  edge_node->SetVertexBuffer2D(edge_node_coords);
187  edge_node->SetColorBufferUC(edge_node_colors);
188 
189  sel_edge_node->SetVertexBuffer2D(sel_edge_node_coords);
190  sel_edge_node->SetColorBufferUC(sel_edge_node_colors);
191  }
192  else if (node_count == 1) {
193  edge_node->SetVisible(false);
194  narrow_edge_node->SetVisible(false);
195 
196  vector<float> color_coords;
197  x_RenderNodeVbo(&ds.GetTree()->GetRoot(), ds.GetTree()->GetRootIdx(), color_coords);
198  point_node->SetTexCoordBuffer1D(color_coords);
199 
200  point_node->ClearPositions();
201  point_node->SetVisible(true);
202  }
203  else {
204  edge_node->SetVisible(false);
205  narrow_edge_node->SetVisible(false);
206  point_node->SetVisible(false);
207  }
208 }
209 
210 // Compute node distance for a fixed pixel offset using unproject
212  const CVect2<TModelUnit>& pixpos1,
213  const CVect2<TModelUnit>& pixpos2) const {
214  CVect2<TModelUnit> pt1 = pane.UnProjectEx(pixpos1);
215  CVect2<TModelUnit> pt2 = pane.UnProjectEx(pixpos2);
216 
217  // m_DimX is a factor used during layout to force
218  // the graph to project to a virtual window of width m_DimX (labels not
219  // included) so we divide it out here. GetNormDistance is the
220  // underlying graph width that gets scaled (at layout) to m_DimX.
221  double d = (pt2.X() - pt1.X())*(4.0*m_DS->GetNormDistance() / m_DimX);
222  return math::roundn(d);
223 }
224 
226 {
227 public:
229 
230 public:
233  const CVect2<float>& center)
234  : m_Clad(clad)
235  , m_DS(ds)
236  , m_ComputeBoundary(0)
237  , m_Center(center)
238  , m_LeafPixelsVisited(0.0f)
239  , m_LevelsFromRoot(0)
240  , m_DistFromRoot(0.0f)
241  , m_LastDist(0.0f)
242  {
244  m_Clad->InitExtents();
245 
246  m_MaxRadius = (float)(m_Clad->GetDimX() * 0.25);
247 
248  if (float(m_DS->GetNormDistance()) > kMin_Float)
249  m_NormDist = 1.0f / (float)m_DS->GetNormDistance();
250  else
251  m_NormDist = 1.0f;
252 
253  m_TotalLeaves = (ds->GetTree()->GetRoot()->GetNumLeavesEx() > 0) ? ds->GetTree()->GetRoot()->GetNumLeavesEx() : 1.0f;
254 
255  // Leave a small gap so top and bottom do not blend together.
256  m_TotalRadius = float(M_PI*2.0 - M_PI / 32.0);
257 
258  /// distance between adjacent nodes - this is both the y step and the xstep
259  /// at their maximum values (angle=0/180 and angle=90/270) (of course this is
260  /// radial distance along circle, not linear distance)
262  }
263 
265  TTreeIdx node_idx, int delta)
266  {
267  CPhyloTree::TNodeType& node = tree[node_idx];
268 
269  if (delta == 1) {
271  m_LevelsFromRoot += 1;
272  m_DistFromRoot += (*node).GetDistance();
273  }
274  else if (delta == 0 && node.HasParent()) {
276  node.GetValue().GetDistance();
277  }
278 
279  if (delta == 1 || delta == 0){
280 
282  m_ComputeBoundary += 1;
283 
284  // radius is current depth in tree/total depth * max-dimension
285  if (node.IsLeafEx()) {
286  float node_pixels = (float)m_Clad->GetNodeLayoutSize(&node);
287 
288  // add 1/2 of the pixels before the node and 1/2 after
289  m_LeafPixelsVisited += node_pixels;
290  float avg_angle = m_TotalRadius*(m_LeafPixelsVisited / m_Clad->GetTreeHeight());
291  node->SetAngle(avg_angle);
292  m_LeafPixelsVisited += node_pixels;
293 
294  // Push leaf nodes to the perimeter Except for collapsed nodes
295  float radius = m_MaxRadius;
296 
297  (*node).X() = m_Center.X() + (radius * cosf(avg_angle));
298  (*node).Y() = m_Center.Y() + (radius * sinf(avg_angle));
299 
300  m_Clad->InitLabel(&tree, node);
301  m_Clad->CalculateExtents(&tree, node);
302 
303  CBoundaryPoints node_boundary_pts;
304  m_Clad->x_ComputeNodeBoundary(&tree, node, node_boundary_pts, "CircularCladogram");
306  m_ComputeBoundary -= 1;
307 
308  if (m_ComputeBoundary > 0) {
309  m_BoundaryPoints.top().AddBoundedPoints(node_boundary_pts);
310  }
311  }
312  }
313  else if (delta == -1) {
314  // Compute the position of the node based on the average angle around
315  // the circle of its immediate children
316  m_LevelsFromRoot -= 1;
318 
319  float angle = 0.0f;
320  if (!node.HasParent()) { // root
321  (*node).XY() = m_Center;
322  }
323  else {
324  float num_children = 0.0f;
326  it != node.SubNodeEndEx(); it++) {
327  angle += tree[*it]->GetAngle();
328  ++num_children;
329  }
330 
331  angle /= num_children;
332  }
333  node->SetAngle(angle);
334 
335  float radius;
336  if (m_Clad->GetDistRendering())
338  else
339  radius = ((float)m_LevelsFromRoot) / ((float)m_DS->GetWidth()) * m_MaxRadius;
340 
341  (*node).X() = m_Center.X() + (radius * cosf(angle));
342  (*node).Y() = m_Center.Y() + (radius * sinf(angle));
343  if (!node.IsLeafEx())
344  m_Clad->InitLabel(&tree, node); // this needs the angle (node->SetAngle())
345  m_Clad->CalculateExtents(&tree, node);
346 
347  // Each node that computes a boundary has to add in the points (and text rectangles)
348  // for all nodes below it in the tree
349  CBoundaryPoints pts = m_BoundaryPoints.top();
350  m_BoundaryPoints.pop();
351  m_Clad->x_ComputeNodeBoundary(&tree, node, pts, "CircularCladogram");
352 
354  m_ComputeBoundary -= 1;
355  }
356 
357  if (m_ComputeBoundary > 0) {
358  m_BoundaryPoints.top().AddBoundedPoints(pts);
359  }
360  }
361 
362  m_LastDist = node.GetValue().GetDistance();
363  return eTreeTraverse;
364  }
365 
366  double GetYStep() const { return m_NodeDelta; }
367 
368 private:
372  stack<CBoundaryPoints> m_BoundaryPoints;
373  double m_NodeDelta;
374  float m_MaxRadius;
380  float m_NormDist;
381  float m_LastDist;
383 };
384 
386 {
387  m_Center.Set(((float)(GetDimX() / 2.0)), ((float)(GetDimY() / 2.0)));
388  CCalcCircularTree calc_tree(this, m_DS, m_Center);
389  TreeDepthFirstEx(*tree, calc_tree);
390 
391  m_yStep = calc_tree.GetYStep();
392  m_xStep = m_yStep;
393 }
394 
395 
396 
399 
400  bool operator()(const CPhyloTree::TTreeIdx& lhs, const CPhyloTree::TTreeIdx& rhs) {
401  // 4-way comparison
402  switch ((*m_Tree)[lhs]->GetSelectedState()) {
404  {{
405  return ((*m_Tree)[rhs]->GetSelectedState()!=CPhyloNodeData::eNotSelected);
406  }}
408  {{
409  return ((*m_Tree)[rhs]->GetSelectedState()!=CPhyloNodeData::eNotSelected);
410  }}
412  {{
413  return ((*m_Tree)[rhs]->GetSelectedState()==CPhyloNodeData::eSelected);
414  }}
416  {{
417  return false;
418  }}
419  default:
420  {{
421  return false;
422  }}
423  }
424  }
425 
426 protected:
428 };
429 
431 {
432 public:
434 
435 public:
438  vector<CVect2<float> >* trace_line_coords,
439  vector<CVect4<unsigned char> >* trace_line_colors,
440  vector<CVect2<float> >* trace_point_coords,
441  vector<CVect4<unsigned char> >* trace_point_colors,
442  vector<CVect2<float> >& edge_node_coords,
443  vector<CVect4<unsigned char> >& edge_node_colors,
444  vector<CVect2<float> >& sel_edge_node_coords,
445  vector<CVect4<unsigned char> >& sel_edge_node_colors,
446  vector<float>& color_coords)
447  : m_Clad(clad)
448  , m_SL(clad->GetScheme())
449  , m_DS(ds)
450  , m_EdgeNodeCoords(edge_node_coords)
451  , m_EdgeNodeColors(edge_node_colors)
452  , m_SelEdgeNodeCoords(sel_edge_node_coords)
453  , m_SelEdgeNodeColors(sel_edge_node_colors)
454  , m_ColorCoords(color_coords)
455  , m_TraceLineCoords(trace_line_coords)
456  , m_TraceLineColors(trace_line_colors)
457  , m_TracePointCoords(trace_point_coords)
458  , m_TracePointColors(trace_point_colors)
459  , m_NodeSingleSelection(clad->GetSingleSelection())
460  {
461  // When drawing arcs, the resolution determines the number
462  // of segments. For larger trees (more leaves) you can zoom
463  // in more so there are more segments. Overall, the circular
464  // cladogram draws the leaves around the circle, so the number
465  // of leaves is a good proxy for resolution.
466  if (m_DS->GetSize()/4 < 360)
467  m_Resolution = 360.0f;
468  else
469  m_Resolution = (float)m_DS->GetSize()/4;
470 
471  m_Center = m_DS->GetTree()->GetRoot()->XY();
472  m_MaxRadius = (float)(m_Clad->GetDimX() * 0.25);
473 
474  if (float(m_DS->GetNormDistance()) > kMin_Float)
475  m_NormDist = 1.0f / (float)m_DS->GetNormDistance();
476  else
477  m_NormDist = 1.0f;
478  }
479 
481  TTreeIdx node_idx, int delta)
482  {
483  if (delta==1 || delta==0) {
484  CPhyloTree::TNodeType& node = tree[node_idx];
485 
486  // Other than root, render node info when looping over children, since
487  // we use some selection info (computed there) of that node for edges too
488  if (node.GetParent() == CPhyloTreeNode::Null())
489  m_Clad->x_RenderNodeVbo(&node, node_idx, m_ColorCoords);
490 
491  if (!node.Expanded())
492  return eTreeTraverse;
493 
494  vector<CPhyloTree::TTreeIdx> sorted_nodes = node.GetChildren();
495  CompareBrightness cb(&tree);
496 
497  std::sort(sorted_nodes.begin(), sorted_nodes.end(), cb);
498 
499  float radius = 0.0f;
500  for (CPhyloTreeNode::TNodeList_I it = sorted_nodes.begin();
501  it!=sorted_nodes.end(); it++) {
502 
503  CPhyloTreeNode& sub_node = tree.GetNode(*it);
504 
505  // Only get radius once
506  if (radius==0.0f)
507  radius = (node->XY() - m_Center).Length();
508  float angle = sub_node->GetAngle();
509 
510  CVect2<float> delta(0.0f, 0.0f);
511  if (sub_node.IsLeafEx() && m_Clad->GetDistRendering()) {
512  float r = (*sub_node).GetDistance()*m_NormDist*m_MaxRadius + ((*node).XY() - m_Center).Length();
513 
514  CVect2<float> pt(m_Center.X() + (r * cosf(angle)),
515  m_Center.Y() + (r * sinf(angle)));
516  delta = ((*sub_node).XY() - pt);
517  }
518 
519  m_Clad->x_RenderNodeVbo(&sub_node, *it, m_ColorCoords, delta);
520 
521  m_Clad->x_RenderCircularVbo(*it, &sub_node, &node,
526  radius, m_Center, delta, m_Resolution);
527  }
528  }
529  return eTreeTraverse;
530  }
531 
532 private:
536  vector<CVect2<float> >& m_EdgeNodeCoords;
537  vector<CVect4<unsigned char> >& m_EdgeNodeColors;
538  vector<CVect2<float> >& m_SelEdgeNodeCoords;
539  vector<CVect4<unsigned char> >& m_SelEdgeNodeColors;
540  vector<float>& m_ColorCoords;
542 
543  float m_MaxRadius;
544  float m_NormDist;
546  vector<CVect2<float> >* m_TraceLineCoords;
547  vector<CVect4<unsigned char> >* m_TraceLineColors;
548  vector<CVect2<float> >* m_TracePointCoords;
549  vector<CVect4<unsigned char> >* m_TracePointColors;
550 
551  // When user only wants to display a single, current selection from
552  // the selection set (including traced and commmon nodes).
554 };
555 
556 
558  vector<float>& color_coords,
559  vector<CVect2<float> >& edge_node_coords,
560  vector<CVect4<unsigned char> >& edge_node_colors,
561  vector<CVect2<float> >& sel_edge_node_coords,
562  vector<CVect4<unsigned char> >& sel_edge_node_colors)
563 {
564  CGlVboNode* trace_lines = m_DS->GetModel().FindGeomNode("CircularTraces");
565  CGlVboNode* trace_points = m_DS->GetModel().FindGeomNode("CircularTracePoints");
566  int num_leaves = m_DS->GetTree()->GetRoot()->GetNumLeavesEx();
567 
568  // With distance rendering we still place nodes at perimeter. To do this we add
569  // extra thin lines from end of distance-based edge to node on perimiter (trace_lines)
570  // We also add individual points (trace_points) to the points where the main (thicker)
571  // edge and thin edge to perimeter intersect. These points 'cap off' the thicker
572  // edge (except in PDF mode where edges can have a cap-style).
573  if (GetDistRendering()) {
574  CMatrix4<float> m;
575  m.Identity();
576 
577  if (trace_lines == NULL) {
578  trace_lines = m_DS->GetModel().AddGeomNode(GL_LINES, "CircularTraces", 0, true);
579 
580  trace_lines->GetState().Enable(GL_BLEND);
581  trace_lines->GetState().Enable(GL_LINE_SMOOTH);
582  trace_lines->GetState().BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
583  trace_lines->GetState().Disable(GL_TEXTURE_2D);
584  trace_lines->GetState().Disable(GL_TEXTURE_1D);
585  trace_lines->GetState().LineWidth(1.0f);
586  }
587  trace_lines->SetPosition(m);
588 
589  if (trace_points == NULL) {
590  trace_points = m_DS->GetModel().AddGeomNode(GL_POINTS, "CircularTracePoints", true);
591  trace_points->GetState().Disable(GL_BLEND);
592  trace_points->GetState().Disable(GL_TEXTURE_2D);
593  trace_points->GetState().Disable(GL_TEXTURE_1D);
594  // Don't draw points in pdf mode (pdf fills line elbows differently)
595  trace_points->SkipTarget(eRenderPDF, true);
596  }
597  trace_points->SetPosition(m);
598 
599  vector<CVect2<float> > trace_line_coords, trace_point_coords;
600  trace_line_coords.reserve(num_leaves * 2);
601  trace_point_coords.reserve(num_leaves);
602 
603  vector<CVect4<unsigned char> > trace_line_colors, trace_point_colors;
604  trace_line_colors.reserve(num_leaves * 2);
605  trace_point_colors.reserve(num_leaves);
606 
607  CDrawCircularTreeVbo draw_tree(this, m_DS,
608  &trace_line_coords, &trace_line_colors,
609  &trace_point_coords, &trace_point_colors,
610  edge_node_coords,
611  edge_node_colors,
612  sel_edge_node_coords,
613  sel_edge_node_colors,
614  color_coords);
615 
616  TreeDepthFirstEx(*tree, draw_tree);
617 
618  trace_lines->SetVertexBuffer2D(trace_line_coords);
619  trace_lines->SetColorBufferUC(trace_line_colors);
620 
621  trace_points->SetVertexBuffer2D(trace_point_coords);
622  trace_points->SetColorBufferUC(trace_point_colors);
623 
624  trace_lines->SetVisible(true);
625  trace_points->SetVisible(true);
626  }
627  else {
628  CDrawCircularTreeVbo draw_tree(this, m_DS,
629  nullptr, nullptr,
630  nullptr, nullptr,
631  edge_node_coords,
632  edge_node_colors,
633  sel_edge_node_coords,
634  sel_edge_node_colors,
635  color_coords);
636  TreeDepthFirstEx(*tree, draw_tree);
637  }
638 }
639 
640 
642 {
643  return "Circular Cladogram";
644 }
645 
647 {
648  // Different if collapsed nodes are inside distance tree and therefore
649  // not "pushing" text out.
650  float d = 0;
651  if (!node->Expanded()) {
652  if (GetDistRendering()) {
653  d = ((node->GetValue().GetNodeWidthScaler(m_SL.GetPointer())) / 2.0f);
654  }
655  else {
656  d = (node->GetValue().GetNodeWidthScaler(m_SL.GetPointer())) - 2.0f;
657  }
658  }
659  else {
660  d = GetDefaultNodeSize(node);
661  }
662 
663  return d;
664 }
665 
667 {
668  TModelUnit line_width =
670 
671  // Require lines to be twice as far apart as normal. This means that lines
672  // until they are closer to the center of the circle
673  if (DistanceBetweenNodes() > line_width*4.0) {
674  return true;
675  }
676  return false;
677 }
678 
#define true
Definition: bool.h:35
static CAttribMenu & GetInstance()
Return a static instance of CAttribMenu.
Definition: attrib_menu.cpp:50
virtual void SynchToUserValue()
Recursively calls each menu item to set its menu value to the current user value (if not NULL).
CBoundaryPoints –.
CPhyloTreeDataSource * m_DS
CPhyloTree::TTreeIdx TTreeIdx
CCalcCircularTree(CPhyloCircularCladogram *clad, CPhyloTreeDataSource *ds, const CVect2< float > &center)
stack< CBoundaryPoints > m_BoundaryPoints
CPhyloCircularCladogram * m_Clad
ETreeTraverseCode operator()(CPhyloTree &tree, TTreeIdx node_idx, int delta)
vector< CVect2< float > > * m_TracePointCoords
const CPhyloTreeScheme & m_SL
vector< CVect4< unsigned char > > & m_SelEdgeNodeColors
CPhyloTreeDataSource * m_DS
vector< CVect2< float > > & m_EdgeNodeCoords
vector< CVect2< float > > * m_TraceLineCoords
CPhyloCircularCladogram * m_Clad
ETreeTraverseCode operator()(CPhyloTree &tree, TTreeIdx node_idx, int delta)
vector< CVect2< float > > & m_SelEdgeNodeCoords
vector< CVect4< unsigned char > > * m_TracePointColors
CPhyloTree::TSelState & m_NodeSingleSelection
vector< CVect4< unsigned char > > & m_EdgeNodeColors
CDrawCircularTreeVbo(CPhyloCircularCladogram *clad, CPhyloTreeDataSource *ds, vector< CVect2< float > > *trace_line_coords, vector< CVect4< unsigned char > > *trace_line_colors, vector< CVect2< float > > *trace_point_coords, vector< CVect4< unsigned char > > *trace_point_colors, vector< CVect2< float > > &edge_node_coords, vector< CVect4< unsigned char > > &edge_node_colors, vector< CVect2< float > > &sel_edge_node_coords, vector< CVect4< unsigned char > > &sel_edge_node_colors, vector< float > &color_coords)
vector< CVect4< unsigned char > > * m_TraceLineColors
class CGlPane
Definition: glpane.hpp:62
CGlVboNode A rendering node that holds a vertex buffer object.
Definition: glvbonode.hpp:64
virtual void x_SetGlRenderOptions(CPhyloTreeDataSource &ds)
Set OpenGL rendering options that depend on layout chosen.
CVect2< float > m_Center
Center of cladogram.
void x_Layout(CPhyloTreeDataSource &ds)
virtual float GetNodeLabelDist(const CPhyloTreeNode *node) const
bool x_WideLines()
Returns true if lines are separated enough to use the wider form of lines (more separation is require...
void x_RenderVbo(CPhyloTreeDataSource &ds)
void x_Calculate(CPhyloTree *tree)
void x_DrawTree(CPhyloTree *tree, vector< float > &color_coords, vector< CVect2< float > > &edge_node_coords, vector< CVect4< unsigned char > > &edge_node_colors, vector< CVect2< float > > &sel_edge_node_coords, vector< CVect4< unsigned char > > &sel_edge_node_colors)
bool m_UseMinimalRotation
If true, labels will only be rotated by amount required to avoid overlap when rotated labels are in u...
virtual double ComputeDistFromPixels(CGlPane &pane, const CVect2< TModelUnit > &pixpos1, const CVect2< TModelUnit > &pixpos2) const
TBoundingState GetBoundedDisplay() const
float GetNodeWidthScaler(const CPhyloTreeScheme *scheme) const
Get modified node width (length) for collapsed nodes. Default is 1.
TDistance GetDistance() const
CPhyloTree * GetTree()
unsigned int GetNumEdges(void)
unsigned int GetNumNodes(void)
double GetNormDistance(void)
CTreeGraphicsModel & GetModel()
Get model for rendering.
TModelRect GetBoundRect()
bool Expanded() const
Return true if node is currently not collapsed.
TNodeList_I SubNodeEndEx()
TNodeList_I SubNodeBeginEx()
Return the child nodes only if visible.
bool IsLeafEx() const
Return true if node is a leaf or is collapsed.
GLdouble & SetSize(TPhyloTreeSizes obj)
Tree subclass also has functions and data needed for rendering and selection.
Definition: phylo_tree.hpp:52
vector< TSelStateValue > TSelState
Definition: phylo_tree.hpp:57
void EnableCircularLabelTrimming(const CVect2< float > &cladogram_center)
Called for circular layout - enables trimming of non-rotated labels based on proximity to adjacent le...
TTreeIdx GetParent() const
Get node's parent.
Definition: tree_model.hpp:82
TNodeList & GetChildren()
Return the indices of this node's child nodes.
Definition: tree_model.hpp:126
TNodeList::iterator TNodeList_I
Definition: tree_model.hpp:63
TData & GetValue()
Return the value object for the node.
Definition: tree_model.hpp:159
bool HasParent() const
Check if the node has a parent.
Definition: tree_model.hpp:90
static TTreeIdx Null()
Static function that returns the null value.
Definition: tree_model.hpp:636
TNodeType & GetRoot()
Return a reference to the root node of the tree.
Definition: tree_model.hpp:254
TTreeIdx GetRootIdx() const
Return the index of the root node.
Definition: tree_model.hpp:267
float m_TreePixels
Sum of size (height) of all leaf nodes in pixels, without considering labels (accomodates nodes that ...
bool GetDistRendering(void) const
CRef< CPhyloTreeScheme > m_SL
virtual float GetNodeLayoutSize(const CPhyloTreeNode *node) const
This is the height of the node for layout purposes.
virtual void x_ComputeNodeBoundary(CPhyloTree *tree, CPhyloTree::TNodeType &node, CBoundaryPoints &boundary_pts, const string &layout_type)
void InitExtents()
Set extents to default values so CalculateExtents can be called.
void InitLabel(CPhyloTree *tree, CPhyloTree::TNodeType &node)
Initialize (for current layout) label text and extent (label rectangle)
void x_RenderCircularVbo(TTreeIdx child_node_idx, CPhyloTreeNode *child_node, CPhyloTreeNode *parent_node, vector< CVect2< float > > *trace_line_coords, vector< CVect4< unsigned char > > *trace_line_colors, vector< CVect2< float > > *trace_point_coords, vector< CVect4< unsigned char > > *trace_point_colors, vector< CVect2< float > > &edge_node_coords, vector< CVect4< unsigned char > > &edge_node_colors, vector< CVect2< float > > &sel_edge_node_coords, vector< CVect4< unsigned char > > &sel_edge_node_colors, float radius, const CVect2< float > &center, const CVect2< float > &offset, float resolution)
const double GetDimX(void)
float GetTreeHeight() const
Get sum of pixel size of all leaf nodes.
void x_RenderNodeVbo(CPhyloTreeNode *node, TTreeIdx node_idx, vector< float > &color_coords, const CVect2< float > delta=CVect2< float >(0.0f, 0.0f))
const double GetDimY(void)
virtual TVPUnit DistanceBetweenNodes(void) const
CGlPane * m_pPane
event handling
float m_LabelPixels
Height of tree in pixels when labels are displayed.
virtual float GetDefaultNodeSize(const CPhyloTreeNode *node) const
bool GetRotatedLabels(void) const
ELayoutStatus m_ValidLayout
void CalculateExtents(CPhyloTree *tree, CPhyloTree::TNodeType &node)
CPhyloTreeDataSource * m_DS
void SetRotatedLabels(bool flag)
void ComputeViewingLimits(CGlPane &pane, bool force_square=false, bool init_collision_info=true)
Compute the optimal viewing pane size so that the tree occupies the entire viewing area,...
#define NULL
Definition: ncbistd.hpp:225
double roundn(double num, unsigned dec=6)
Definition: math.cpp:41
void Set(T x, T y)
Definition: vect2.hpp:260
T & X()
Definition: vect2.hpp:107
void Identity()
Definition: matrix4.hpp:373
T & Y()
Definition: vect2.hpp:109
void ClearPositions()
void SkipTarget(ERenderTarget target, bool skip)
Turn off visibility for individual render targets.
GLdouble TModelUnit
Definition: gltypes.hpp:48
CGlVboNode * AddGeomNode(GLenum node_type, const string &name, bool visible=true)
Add a geometry (vertex buffer object) node.
Definition: glmodel2d.cpp:97
void SetModelLimitsRect(const TModelRect &R)
Definition: glpane.hpp:342
void SetTexCoordBuffer1D(const vector< float > &data)
Definition: glvbonode.cpp:131
void SetVertexBuffer2D(const vector< CVect2< float > > &data)
Definition: glvbonode.cpp:75
void Init()
Definition: glrect.hpp:62
T Top() const
Definition: glrect.hpp:84
T Bottom() const
Definition: glrect.hpp:82
T Right() const
Definition: glrect.hpp:83
virtual void Enable(GLenum glstate)
glEnable() all options in m_Enabled
Definition: glstate.cpp:356
CGlState & GetState()
virtual void LineWidth(GLfloat w)
Set line width for drawing: glLineWidth()
Definition: glstate.cpp:410
void SetPosition(const CMatrix4< float > &mat)
Set 1 transformation and have it be "mat".
T Left() const
Definition: glrect.hpp:81
virtual void Disable(GLenum glstate)
glDisable() all options in m_Disabled
Definition: glstate.cpp:380
void SetVisibleRect(const TModelRect &R)
Definition: glpane.cpp:113
void SetColorBufferUC(const vector< CVect4< unsigned char > > &data)
Definition: glvbonode.cpp:117
void SetVisible(bool b)
Set/get node visibility.
virtual void BlendFunc(GLenum sfactor, GLenum dfactor)
Options to be used when GL_BLEND is enabled.
Definition: glstate.cpp:562
CVect2< TModelUnit > UnProjectEx(const CVect2< TModelUnit > &pt)
Definition: glpane.cpp:797
CGlVboNode * FindGeomNode(const string &name)
Find a geometry (vertex buffer object) node by name.
Definition: glmodel2d.cpp:88
@ eRenderPDF
Definition: glstate.hpp:61
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:998
int32_t Int4
4-byte (32-bit) signed integer
Definition: ncbitype.h:102
#define kMin_Float
Definition: ncbi_limits.h:204
#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
@ eTreeTraverse
Keep traversal.
Definition: ncbi_tree.hpp:52
constexpr auto sort(_Init &&init)
Int4 delta(size_t dimension_, const Int4 *score_)
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
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
bool operator()(const CPhyloTree::TTreeIdx &lhs, const CPhyloTree::TTreeIdx &rhs)
CompareBrightness(CPhyloTree *tree)
#define _ASSERT
Fun TreeDepthFirst(TTreeModel &tree_model, typename TTreeModel::TTreeIdx node_idx, Fun func)
Depth-first tree traversal algorithm.
Definition: tree_model.hpp:355
Modified on Tue Nov 28 02:21:45 2023 by modify_doxy.py rev. 669887