phylo_tree_slated_cladogram.cpp
来自「ncbi源码」· C++ 代码 · 共 176 行
CPP
176 行
/* * =========================================================================== * PRODUCTION $Log: phylo_tree_slated_cladogram.cpp,v $ * PRODUCTION Revision 1000.1 2004/06/01 21:11:55 gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.7 * PRODUCTION * =========================================================================== *//* $Id: phylo_tree_slated_cladogram.cpp,v 1000.1 2004/06/01 21:11:55 gouriano Exp $ * =========================================================================== * * 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: Vladimir Tereshkov * * File Description: * */#include <ncbi_pch.hpp>#include <corelib/ncbistl.hpp>#include <gui/opengl/glhelpers.hpp>#include <gui/graph/igraph_utils.hpp>#include <gui/widgets/phylo_tree/phylo_tree_render.hpp>#include <gui/widgets/phylo_tree/phylo_tree_slated_cladogram.hpp>#include <FL/Fl.H>#include <math.h>BEGIN_NCBI_SCOPECPhyloSlatedCladogram::CPhyloSlatedCladogram(){ }CPhyloSlatedCladogram::~CPhyloSlatedCladogram(){}void CPhyloSlatedCladogram::x_Layout(CPhyloTreeDataSource& ds){ m_Leafs = ds.GetSize(); m_Width = ds.GetWidth(); //m_xStep = (m_DimX - m_LeftMargin - m_RightMargin) / width; m_yStep = (m_DimY - m_TopMargin - m_BottomMargin) / (m_Leafs-1); m_xStep = m_yStep; x_Calculate(ds.GetTree()); // changing raster - x_Calculate for shure changed size in unpredictable way TModelRect newRect = ds.GetBoundRect(); m_RasterRect.Init(newRect.Left() - m_LeftMargin, newRect.Top() - m_TopMargin, newRect.Right() + m_RightMargin, newRect.Bottom() + m_BottomMargin); }void CPhyloSlatedCladogram::x_Render(CGlPane& pane, CPhyloTreeDataSource& ds){ pane.OpenOrtho(); x_DrawTree(ds.GetTree()); pane.Close(); }void CPhyloSlatedCladogram:: x_Calculate(CPhyloTreeNode * node){ if (node->IsLeaf()) { node->XY().first = (m_DimX - m_RightMargin); // all leafs on the right node->XY().second = (m_DimY - m_TopMargin - node->IDX().second * m_yStep); // y coordinate node->SetAngle(0); // for correct labeling } else { Int4 childLeafs = 0; x_CountLeafs(node, childLeafs); node->XY().first = (m_DimX - m_RightMargin - (childLeafs-1) * m_xStep); node->XY().second = (m_DimY - m_TopMargin - node->IDX().second * m_yStep - ((childLeafs-1)*m_yStep)/2.0); for(CPhyloTreeNode::TNodeList_I it = node->SubNodeBegin(); it != node->SubNodeEnd(); it++ ) x_Calculate((*it)->GetValue()); } }void CPhyloSlatedCladogram :: x_DrawTree(CPhyloTreeNode * node){ // label if (m_pLabelFont && node->IsLeaf()) { // x_RenderText(node->GetValue()->XY().first, node->GetValue()->XY().second, node->GetLabel()); CGlPoint<int> labelPos(node->GetValue()->XY().first, node->GetValue()->XY().second); m_Label.Render(*m_pPane, labelPos, node->GetLabel(), node->GetSelected()); } // drawing leaf node if (node->GetParent()){ x_RenderLine(node->GetParent()->GetValue()->XY().first + m_LineWidth, node->GetParent()->GetValue()->XY().second, node->GetValue()->XY().first, node->GetValue()->XY().second, m_LineWidth, node->GetSelected()?m_LineSelColor:m_LineColor, node->GetSelected()?m_LineSelHiColor:m_LineHiColor); //x_RenderSpline(node->GetParent()->GetValue()->XY().first + m_LineWidth, node->GetParent()->GetValue()->XY().second, // node->GetValue()->XY().first, node->GetValue()->XY().second); } for(CPhyloTreeNode::TNodeList_I it = node->SubNodeBegin(); it != node->SubNodeEnd(); it++ ) x_DrawTree((*it)->GetValue()); x_RenderNode(node->GetValue()->XY().first, node->GetValue()->XY().second, m_NodeSize, node->GetSelected()?m_NodeSelColor:m_NodeColor);} void CPhyloSlatedCladogram :: x_CountLeafs(CPhyloTreeNode * node, Int4 & lfCount){ if (node->IsLeaf()) lfCount++; for (CPhyloTreeNode::TNodeList_I it = node->SubNodeBegin(); it != node->SubNodeEnd(); it++) x_CountLeafs((*it)->GetValue(), lfCount); }string CPhyloSlatedCladogram::GetDescription(void){ return "Slated Cladogram";}END_NCBI_SCOPE/* * =========================================================================== * $Log: phylo_tree_slated_cladogram.cpp,v $ * Revision 1000.1 2004/06/01 21:11:55 gouriano * PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.7 * * Revision 1.7 2004/05/21 22:27:54 gorelenk * Added PCH ncbi_pch.hpp * * Revision 1.6 2004/04/20 21:57:19 tereshko * Major rendering, labeling and performance improvements * * Revision 1.5 2004/04/13 20:28:53 tereshko * Numerous renderers improvements * * Revision 1.4 2004/04/01 21:47:25 tereshko * Code clean-up * * Revision 1.3 2004/02/23 22:52:27 tereshko * Rendering Improvements * * Revision 1.2 2004/02/23 15:40:30 tereshko * Layout improvements * * Revision 1.1 2004/02/13 17:05:14 tereshko * Phylogenetic Tree Widget initial revision * * =========================================================================== */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?