NCBI C++ Toolkit Cross Reference

  C++/src/gui/widgets/phylo_tree/phylo_circular_cladogram.cpp


1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650
/* $Id: phylo_circular_cladogram.cpp 38024 2017-03-15 19:07:01Z falkrb $ * =========================================================================== * * PUBLIC DOMAIN NOTICE * National Center for Biotechnology Information * * This software/database is a "United States Government Work" under the * terms of the United States Copyright Act. It was written as part of * the author's official duties as a United States Government employee and * thus cannot be copyrighted. This software/database is freely available * to the public for use. The National Library of Medicine and the U.S. * Government have not placed any restriction on its use or reproduction. * * Although all reasonable efforts have been taken to ensure the accuracy * and reliability of the software and data, the NLM and the U.S. * Government do not and cannot warrant the performance or results that * may be obtained by using this software or data. The NLM and the U.S. * Government disclaim all warranties, express or implied, including * warranties of performance, merchantability or fitness for any particular * purpose. * * Please cite the author in any work or product based on this material. * * =========================================================================== * * Authors: Bob Falk * * File Description: * */ #include <ncbi_pch.hpp> #include <gui/widgets/phylo_tree/phylo_circular_cladogram.hpp> #include <gui/widgets/gl/attrib_menu.hpp> #include <corelib/ncbi_limits.h> BEGIN_NCBI_SCOPE ////////////////////////////////////////////////////////////////////// // ////////////////////////////////////////////////////////////////////// CPhyloCircularCladogram::CPhyloCircularCladogram() : m_UseMinimalRotation(true) { SetRotatedLabels(true); } CPhyloCircularCladogram::CPhyloCircularCladogram(double w, double h) : IPhyloTreeRender(w, h) , m_UseMinimalRotation(true) { SetRotatedLabels(true); } CPhyloCircularCladogram::~CPhyloCircularCladogram() { } void CPhyloCircularCladogram::x_Layout(CPhyloTreeDataSource& ds) { #ifdef ATTRIB_MENU_SUPPORT CAttribMenuInstance::GetInstance().SynchToUserValue(); #endif Int4 leafs = ds.GetSize(); Int4 width = ds.GetWidth(); if (width>0){ m_xStep = m_DimX / width; } else { m_xStep = m_DimX / 2; } if (leafs>1){ m_yStep = m_DimY / leafs; } else { m_yStep = m_DimY / 2; } if (float(m_DS->GetNormDistance()) > kMin_Float) m_NormDistance = m_DimX / ds.GetNormDistance(); else m_NormDistance = 1.0; ComputePixelHeight ph = TreeDepthFirst(*ds.GetTree(), ComputePixelHeight(this)); m_TreePixels = ph.m_PixelHeight; m_LabelPixels = ph.m_TotalHeight; CBoundaryPoints boundary_pts; x_Calculate(ds.GetTree()); TModelRect newRect = ds.GetBoundRect(); m_RasterRect.Init(newRect.Left(), newRect.Bottom(), newRect.Right(), newRect.Top()); m_pPane->SetModelLimitsRect(m_RasterRect); m_pPane->SetVisibleRect(m_RasterRect); m_ValidLayout = eValidLayout; ComputeViewingLimits(*m_pPane, m_ForceSquare); } void CPhyloCircularCladogram::x_SetGlRenderOptions(CPhyloTreeDataSource& ds) { // Set drawing options that are specific to slanted cladogram CGlVboNode* edge_node = ds.GetModel().FindGeomNode("TreeEdges"); CGlVboNode* narrow_edge_node = ds.GetModel().FindGeomNode("NarrowTreeEdges"); CGlVboNode* sel_edge_node = ds.GetModel().FindGeomNode("SelectedTreeEdges"); CGlVboNode* sel_narrow_edge_node = ds.GetModel().FindGeomNode("SelectedNarrowTreeEdges"); CGlVboNode* filler_points_node = m_DS->GetModel().FindGeomNode("FillerPoints"); if (edge_node != NULL && narrow_edge_node != NULL && sel_edge_node != NULL && sel_narrow_edge_node != NULL) { edge_node->GetState().Enable(GL_LINE_SMOOTH); edge_node->GetState().Enable(GL_BLEND); edge_node->GetState().BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); sel_edge_node->GetState().Enable(GL_LINE_SMOOTH); sel_edge_node->GetState().Enable(GL_BLEND); sel_edge_node->GetState().BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); narrow_edge_node->GetState().Enable(GL_LINE_SMOOTH); narrow_edge_node->GetState().Enable(GL_BLEND); narrow_edge_node->GetState().BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); sel_narrow_edge_node->GetState().Enable(GL_LINE_SMOOTH); sel_narrow_edge_node->GetState().Enable(GL_BLEND); sel_narrow_edge_node->GetState().BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); } if (filler_points_node != NULL) filler_points_node->SetVisible(false); } void CPhyloCircularCladogram::x_RenderVbo(CPhyloTreeDataSource& ds) { // Enable circular label processing... if (m_UseMinimalRotation || !GetRotatedLabels()) { m_DS->GetModel().EnableCircularLabelTrimming(m_Center); } CGlVboNode* edge_node = m_DS->GetModel().FindGeomNode("TreeEdges"); CGlVboNode* narrow_edge_node = m_DS->GetModel().FindGeomNode("NarrowTreeEdges"); CGlVboNode* sel_edge_node = ds.GetModel().FindGeomNode("SelectedTreeEdges"); CGlVboNode* point_node = m_DS->GetModel().FindGeomNode("NodePoints"); _ASSERT(edge_node != NULL && narrow_edge_node != NULL && sel_edge_node != NULL && point_node != NULL); GLsizei edge_count = (GLsizei)ds.GetNumEdges(); GLsizei node_count = (GLsizei)ds.GetNumNodes(); point_node->GetTexCoordBuffer1D().BufferDataResize(node_count, NULL, GL_DYNAMIC_DRAW); if (edge_count > 0) { point_node->GetTexCoordBuffer1D().BufferDataResize(node_count, NULL, GL_DYNAMIC_DRAW); point_node->GetTexCoordBuffer1D().MapBuffer(GL_WRITE_ONLY); vector<CVect4<unsigned char> > edge_colors; vector<CVect4<unsigned char> > selected_edge_colors; x_DrawTree(ds.GetTree(), edge_colors, selected_edge_colors, point_node, edge_node); point_node->GetTexCoordBuffer1D().UnmapBuffer(); point_node->ClearPositions(); point_node->SetVisible(true); if (edge_colors.size() > 0) edge_node->GetColorBufferUC().BufferData(edge_colors.size(), &edge_colors[0], GL_DYNAMIC_DRAW); if (selected_edge_colors.size() > 0) sel_edge_node->GetColorBufferUC().BufferData(selected_edge_colors.size(), &selected_edge_colors[0], GL_DYNAMIC_DRAW); } else if (node_count == 1) { edge_node->SetVisible(false); narrow_edge_node->SetVisible(false); GLsizei node_count = (GLsizei)ds.GetNumNodes(); point_node->GetTexCoordBuffer1D().BufferDataResize(node_count, NULL, GL_DYNAMIC_DRAW); point_node->GetTexCoordBuffer1D().MapBuffer(GL_WRITE_ONLY); x_RenderNodeVbo(&ds.GetTree()->GetRoot(), ds.GetTree()->GetRootIdx(), point_node); point_node->GetTexCoordBuffer1D().UnmapBuffer(); point_node->ClearPositions(); point_node->SetVisible(true); } else { edge_node->SetVisible(false); narrow_edge_node->SetVisible(false); point_node->SetVisible(false); } } // Compute node distance for a fixed pixel offset using unproject double CPhyloCircularCladogram::ComputeDistFromPixels(CGlPane& pane, const CVect2<TModelUnit>& pixpos1, const CVect2<TModelUnit>& pixpos2) const { CVect2<TModelUnit> pt1 = pane.UnProjectEx(pixpos1); CVect2<TModelUnit> pt2 = pane.UnProjectEx(pixpos2); // m_DimX is a factor used during layout to force // the graph to project to a virtual window of width m_DimX (labels not // included) so we divide it out here. GetNormDistance is the // underlying graph width that gets scaled (at layout) to m_DimX. return (pt2.X() - pt1.X())*(4.0*m_DS->GetNormDistance() / m_DimX); } class CCalcCircularTree { public: typedef CPhyloTree::TTreeIdx TTreeIdx; public: CCalcCircularTree(CPhyloCircularCladogram* clad, CPhyloTreeDataSource* ds, const CVect2<float>& center) : m_Clad(clad) , m_DS(ds) , m_ComputeBoundary(0) , m_Center(center) , m_LeafPixelsVisited(0.0f) , m_LevelsFromRoot(0) , m_DistFromRoot(0.0f) , m_LastDist(0.0f) { m_BoundaryPoints.push(CBoundaryPoints()); m_Clad->InitExtents(); m_MaxRadius = (float)(m_Clad->GetDimX() * 0.25); if (float(m_DS->GetNormDistance()) > kMin_Float) m_NormDist = 1.0f / (float)m_DS->GetNormDistance(); else m_NormDist = 1.0f; m_TotalLeaves = (ds->GetTree()->GetRoot()->GetNumLeavesEx() > 0) ? ds->GetTree()->GetRoot()->GetNumLeavesEx() : 1.0f; // Leave a small gap so top and bottom do not blend together. m_TotalRadius = float(M_PI*2.0 - M_PI / 32.0); /// distance between adjacent nodes - this is both the y step and the xstep /// at their maximum values (angle=0/180 and angle=90/270) (of course this is /// radial distance along circle, not linear distance) m_NodeDelta = (m_TotalRadius*m_MaxRadius) / m_TotalLeaves; } ETreeTraverseCode operator()(CPhyloTree& tree, TTreeIdx node_idx, int delta) { CPhyloTree::TNodeType& node = tree[node_idx]; if (delta == 1) { m_BoundaryPoints.push(CBoundaryPoints()); m_LevelsFromRoot += 1; m_DistFromRoot += (*node).GetDistance(); } else if (delta == 0 && node.HasParent()) { m_DistFromRoot = m_DistFromRoot - m_LastDist + node.GetValue().GetDistance(); } if (delta == 1 || delta == 0){ if (node.GetValue().GetBoundedDisplay() == CPhyloNodeData::eBounded) m_ComputeBoundary += 1; // radius is current depth in tree/total depth * max-dimension if (node.IsLeafEx()) { float node_pixels = (float)m_Clad->GetDefaultNodeSize(&node); // add 1/2 of the pixels before the node and 1/2 after m_LeafPixelsVisited += node_pixels; float avg_angle = m_TotalRadius*(m_LeafPixelsVisited / m_Clad->GetTreeHeight()); node->SetAngle(avg_angle); m_LeafPixelsVisited += node_pixels; // Push leaf nodes to the perimeter Except for collapsed nodes float radius = m_MaxRadius; //if (m_Clad->GetDistRendering() && !node.Expanded()) { // radius = m_NormDist * m_DistFromRoot * m_MaxRadius; //} (*node).X() = m_Center.X() + (radius * cosf(avg_angle)); (*node).Y() = m_Center.Y() + (radius * sinf(avg_angle)); m_Clad->InitLabel(&tree, node); m_Clad->CalculateExtents(&tree, node); CBoundaryPoints node_boundary_pts; m_Clad->x_ComputeNodeBoundary(&tree, node, node_boundary_pts, "CircularCladogram"); if (node.GetValue().GetBoundedDisplay() == CPhyloNodeData::eBounded) m_ComputeBoundary -= 1; if (m_ComputeBoundary > 0) { m_BoundaryPoints.top().AddBoundedPoints(node_boundary_pts); } } } else if (delta == -1) { // Compute the position of the node based on the average angle around // the circle of its immediate children m_LevelsFromRoot -= 1; m_DistFromRoot -= m_LastDist; float angle = 0.0f; if (!node.HasParent()) { // root (*node).XY() = m_Center; } else { float num_children = 0.0f; for (CPhyloTreeNode::TNodeList_I it = node.SubNodeBeginEx(); it != node.SubNodeEndEx(); it++) { angle += tree[*it]->GetAngle(); ++num_children; } angle /= num_children; } node->SetAngle(angle); float radius; if (m_Clad->GetDistRendering()) radius = m_NormDist * m_DistFromRoot * m_MaxRadius; else radius = ((float)m_LevelsFromRoot) / ((float)m_DS->GetWidth()) * m_MaxRadius; (*node).X() = m_Center.X() + (radius * cosf(angle)); (*node).Y() = m_Center.Y() + (radius * sinf(angle)); if (!node.IsLeafEx()) m_Clad->InitLabel(&tree, node); // this needs the angle (node->SetAngle()) m_Clad->CalculateExtents(&tree, node); // Each node that computes a boundary has to add in the points (and text rectangles) // for all nodes below it in the tree CBoundaryPoints pts = m_BoundaryPoints.top(); m_BoundaryPoints.pop(); m_Clad->x_ComputeNodeBoundary(&tree, node, pts, "CircularCladogram"); if (node.GetValue().GetBoundedDisplay() == CPhyloNodeData::eBounded) { m_ComputeBoundary -= 1; } if (m_ComputeBoundary > 0) { m_BoundaryPoints.top().AddBoundedPoints(pts); } } m_LastDist = node.GetValue().GetDistance(); return eTreeTraverse; } double GetYStep() const { return m_NodeDelta; } private: CPhyloCircularCladogram* m_Clad; CPhyloTreeDataSource* m_DS; int m_ComputeBoundary; stack<CBoundaryPoints> m_BoundaryPoints; double m_NodeDelta; float m_MaxRadius; CVect2<float> m_Center; float m_LeafPixelsVisited; float m_TotalLeaves; int m_LevelsFromRoot; float m_DistFromRoot; float m_NormDist; float m_LastDist; float m_TotalRadius; }; void CPhyloCircularCladogram::x_Calculate(CPhyloTree* tree) { m_Center.Set(((float)(GetDimX() / 2.0)), ((float)(GetDimY() / 2.0))); CCalcCircularTree calc_tree(this, m_DS, m_Center); calc_tree = TreeDepthFirstEx(*tree, calc_tree); m_yStep = calc_tree.GetYStep(); m_xStep = m_yStep; } struct CompareBrightness { CompareBrightness(CPhyloTree* tree) : m_Tree(tree) {} bool operator()(const CPhyloTree::TTreeIdx& lhs, const CPhyloTree::TTreeIdx& rhs) { // 4-way comparison switch ((*m_Tree)[lhs]->GetSelectedState()) { case CPhyloNodeData::eNotSelected: {{ return ((*m_Tree)[rhs]->GetSelectedState()!=CPhyloNodeData::eNotSelected); }} case CPhyloNodeData::eTraced: {{ return ((*m_Tree)[rhs]->GetSelectedState()!=CPhyloNodeData::eNotSelected); }} case CPhyloNodeData::eShared: {{ return ((*m_Tree)[rhs]->GetSelectedState()==CPhyloNodeData::eSelected); }} case CPhyloNodeData::eSelected: {{ return false; }} default: {{ return false; }} } } protected: CPhyloTree* m_Tree; }; class CDrawCircularTreeVbo { public: typedef CPhyloTree::TTreeIdx TTreeIdx; public: CDrawCircularTreeVbo(CPhyloCircularCladogram* clad, CPhyloTreeDataSource* ds, CGlVboNode* trace_lines, CGlVboNode* trace_points, vector<CVect4<unsigned char> >& edge_colors, vector<CVect4<unsigned char> >& selected_edge_colors, CGlVboNode* point_node) : m_Clad(clad) , m_SL(clad->GetScheme()) , m_DS(ds) , m_EdgeColors(edge_colors) , m_SelectedEdgeColors(selected_edge_colors) , m_PointNode(point_node) , m_TraceLines(trace_lines) , m_TracePoints(trace_points) , m_NodeSingleSelection(clad->GetSingleSelection()) { // When drawing arcs, the resolution determines the number // of segments. For larger trees (more leaves) you can zoom // in more so there are more segments. Overall, the circular // cladogram draws the leaves around the circle, so the number // of leaves is a good proxy for resolution. if (m_DS->GetSize()/4 < 360) m_Resolution = 360.0f; else m_Resolution = (float)m_DS->GetSize()/4; m_Center = m_DS->GetTree()->GetRoot()->XY(); m_MaxRadius = (float)(m_Clad->GetDimX() * 0.25); if (float(m_DS->GetNormDistance()) > kMin_Float) m_NormDist = 1.0f / (float)m_DS->GetNormDistance(); else m_NormDist = 1.0f; } ETreeTraverseCode operator()(CPhyloTree& tree, TTreeIdx node_idx, int delta) { if (delta==1 || delta==0) { CPhyloTree::TNodeType& node = tree[node_idx]; // Other than root, render node info when looping over children, since // we use some selection info (computed there) of that node for edges too if (node.GetParent() == CPhyloTreeNode::Null()) m_Clad->x_RenderNodeVbo(&node, node_idx, m_PointNode); if (!node.Expanded()) return eTreeTraverse; vector<CPhyloTree::TTreeIdx> sorted_nodes = node.GetChildren(); CompareBrightness cb(&tree); std::sort(sorted_nodes.begin(), sorted_nodes.end(), cb); float radius = 0.0f; for (CPhyloTreeNode::TNodeList_I it = sorted_nodes.begin(); it!=sorted_nodes.end(); it++) { CPhyloTreeNode& sub_node = tree.GetNode(*it); // Only get radius once if (radius==0.0f) radius = (node->XY() - m_Center).Length(); float angle = sub_node->GetAngle(); CVect2<float> delta(0.0f, 0.0f); if (sub_node.IsLeafEx() && m_Clad->GetDistRendering()) { float r = (*sub_node).GetDistance()*m_NormDist*m_MaxRadius + ((*node).XY() - m_Center).Length(); CVect2<float> pt(m_Center.X() + (r * cosf(angle)), m_Center.Y() + (r * sinf(angle))); delta = ((*sub_node).XY() - pt); } m_Clad->x_RenderNodeVbo(&sub_node, *it, m_PointNode, delta); m_Clad->x_RenderCircularVbo(*it, &sub_node, &node, m_TraceLines, m_TracePoints, m_EdgeColors, m_SelectedEdgeColors, radius, m_Center, delta, m_Resolution); } } return eTreeTraverse; } private: CPhyloCircularCladogram* m_Clad; const CPhyloTreeScheme& m_SL; CPhyloTreeDataSource* m_DS; vector<CVect4<unsigned char> >& m_EdgeColors; vector<CVect4<unsigned char> >& m_SelectedEdgeColors; CGlVboNode* m_PointNode; float m_Resolution; float m_MaxRadius; float m_NormDist; CVect2<float> m_Center; CGlVboNode* m_TraceLines; CGlVboNode* m_TracePoints; // When user only wants to display a single, current selection from // the selection set (including traced and commmon nodes). CPhyloTree::TSelState& m_NodeSingleSelection; }; void CPhyloCircularCladogram::x_DrawTree(CPhyloTree* tree, vector<CVect4<unsigned char> >& edge_colors, vector<CVect4<unsigned char> >& selected_edge_colors, CGlVboNode* point_node, CGlVboNode* edge_node) { CGlVboNode* trace_lines = m_DS->GetModel().FindGeomNode("CircularTraces"); CGlVboNode* trace_points = m_DS->GetModel().FindGeomNode("CircularTracePoints"); int num_leaves = m_DS->GetTree()->GetRoot()->GetNumLeavesEx(); // With distance rendering we still place nodes at perimeter. To do this we add // extra thin lines from end of distance-based edge to node on perimiter (trace_lines) // We also add individual points (trace_points) to the points where the main (thicker) // edge and thin edge to perimeter intersect. These points 'cap off' the thicker // edge (except in PDF mode where edges can have a cap-style). if (GetDistRendering()) { CMatrix4<float> m; m.Identity(); if (trace_lines == NULL) { trace_lines = m_DS->GetModel().AddGeomNode(GL_LINES, "CircularTraces", 0, true); trace_lines->GetState().Enable(GL_BLEND); trace_lines->GetState().Enable(GL_LINE_SMOOTH); trace_lines->GetState().BlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); trace_lines->GetState().Disable(GL_TEXTURE_2D); trace_lines->GetState().Disable(GL_TEXTURE_1D); trace_lines->GetState().LineWidth(1.0f); } trace_lines->SetPosition(m); trace_lines->GetVertexBuffer2D().BufferDataResize(num_leaves * 2, NULL, GL_DYNAMIC_DRAW); trace_lines->GetVertexBuffer2D().MapBuffer(GL_WRITE_ONLY); trace_lines->GetColorBufferUC().BufferDataResize(num_leaves * 2, NULL, GL_DYNAMIC_DRAW); trace_lines->GetColorBufferUC().MapBuffer(GL_WRITE_ONLY); if (trace_points == NULL) { trace_points = m_DS->GetModel().AddGeomNode(GL_POINTS, "CircularTracePoints", true); trace_points->GetState().Disable(GL_BLEND); trace_points->GetState().Disable(GL_TEXTURE_2D); trace_points->GetState().Disable(GL_TEXTURE_1D); // Don't draw points in pdf mode (pdf fills line elbows differently) trace_points->SkipTarget(eRenderPDF, true); } trace_points->SetPosition(m); trace_points->GetVertexBuffer2D().BufferDataResize(num_leaves, NULL, GL_DYNAMIC_DRAW); trace_points->GetVertexBuffer2D().MapBuffer(GL_WRITE_ONLY); trace_points->GetColorBufferUC().BufferDataResize(num_leaves, NULL, GL_DYNAMIC_DRAW); trace_points->GetColorBufferUC().MapBuffer(GL_WRITE_ONLY); } CDrawCircularTreeVbo draw_tree(this, m_DS, trace_lines, trace_points, edge_colors, selected_edge_colors, point_node); TreeDepthFirstEx(*tree, draw_tree); // Unmap the (trace) buffers. if (GetDistRendering()) { trace_lines->GetVertexBuffer2D().SetActiveBufferSize(trace_lines->GetVertexBuffer2D().GetCurrentIdx()); trace_lines->GetColorBufferUC().SetActiveBufferSize(trace_lines->GetColorBufferUC().GetCurrentIdx()); trace_lines->GetColorBufferUC().UnmapBuffer(); trace_lines->GetVertexBuffer2D().UnmapBuffer(); trace_lines->SetVisible(true); trace_points->GetVertexBuffer2D().SetActiveBufferSize(trace_points->GetVertexBuffer2D().GetCurrentIdx()); trace_points->GetColorBufferUC().SetActiveBufferSize(trace_points->GetColorBufferUC().GetCurrentIdx()); trace_points->GetColorBufferUC().UnmapBuffer(); trace_points->GetVertexBuffer2D().UnmapBuffer(); trace_points->SetVisible(true); } } string CPhyloCircularCladogram::GetDescription(void) { return "Circular Cladogram"; } TVPUnit CPhyloCircularCladogram::GetNodeLabelDist(CPhyloTreeNode * node) { // Different if collapsed nodes are inside distance tree and therefore // not "pushing" text out. if (GetDistRendering()) { if (node->Expanded()) return GetDefaultNodeSize(node); else return (TVPUnit)m_SL->GetNodeSize(); } else { return IPhyloTreeRender::GetNodeLabelDist(node); } } bool CPhyloCircularCladogram::x_WideLines() { TModelUnit line_width = m_SL->SetSize(CPhyloTreeScheme::eLineWidth); // Require lines to be twice as far apart as normal. This means that lines // until they are closer to the center of the circle if (DistanceBetweenNodes() > line_width*4.0) { return true; } return false; } END_NCBI_SCOPE

source navigation ]   [ diff markup ]   [ identifier search ]   [ freetext search ]   [ file search ]  

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.