bpp-phyl  2.2.0
CladogramPlot.h
Go to the documentation of this file.
1 //
2 // File: CladogramPlot.h
3 // Created by: Julien Dutheil
4 // Created on: Tue Oct 9 17:22 2006
5 //
6 
7 /*
8 Copyright or © or Copr. Bio++ Development Team, (November 16, 2004)
9 
10 This software is a computer program whose purpose is to provide
11 graphic components to develop bioinformatics applications.
12 
13 This software is governed by the CeCILL license under French law and
14 abiding by the rules of distribution of free software. You can use,
15 modify and/ or redistribute the software under the terms of the CeCILL
16 license as circulated by CEA, CNRS and INRIA at the following URL
17 "http://www.cecill.info".
18 
19 As a counterpart to the access to the source code and rights to copy,
20 modify and redistribute granted by the license, users are provided only
21 with a limited warranty and the software's author, the holder of the
22 economic rights, and the successive licensors have only limited
23 liability.
24 
25 In this respect, the user's attention is drawn to the risks associated
26 with loading, using, modifying and/or developing or reproducing the
27 software by the user in light of its specific status of free software,
28 that may mean that it is complicated to manipulate, and that also
29 therefore means that it is reserved for developers and experienced
30 professionals having in-depth computer knowledge. Users are therefore
31 encouraged to load and test the software's suitability as regards their
32 requirements in conditions enabling the security of their systems and/or
33 data to be ensured and, more generally, to use and operate it in the
34 same conditions as regards security.
35 
36 The fact that you are presently reading this means that you have had
37 knowledge of the CeCILL license and that you accept its terms.
38 */
39 
40 #ifndef _CLADOGRAMPLOT_H_
41 #define _CLADOGRAMPLOT_H_
42 
43 #include <Bpp/Exceptions.h>
44 
45 #include "AbstractDendrogramPlot.h"
46 
47 namespace bpp
48 {
49 
51  public DrawIBranchEvent
52 {
53  private:
54  double orientation_;
55  double length_;
56 
57  public:
58  CladogramDrawBranchEvent(const TreeDrawing* source, GraphicDevice* gd, const INode* node, double length_, const Cursor& cursor, short orientation);
59 
60  public:
61  Cursor getBranchCursor(double position) const;
62 
63 };
64 
65 
66 
74 {
75  private:
76  double totalDepth_;
78 
79  public:
82  {}
83 
84  virtual ~CladogramPlot() {}
85 
86  CladogramPlot* clone() const { return new CladogramPlot(*this); }
87 
88  public:
89  std::string getName() const { return "Cladogram"; }
90 
91  void setTree(const Tree* tree = 0);
92 
93  double getWidth() const { return totalDepth_; }
94  double getHeight() const { return numberOfLeaves_; }
95 
97  {
98  if (hasTree())
99  {
100  totalDepth_ = static_cast<double>(TreeTemplateTools::getDepth(*getTree_()->getRootNode()));
101  numberOfLeaves_ = static_cast<double>(getTree_()->getNumberOfLeaves());
102  }
103  }
104 
105 
106  private:
107  void drawDendrogram_(GraphicDevice& gDevice) const throw (Exception);
108  void recursivePlot_(GraphicDevice& gDevice, INode& node, double x, double& y, double hDirection, double vDirection, unsigned int* tipCounter) const;
109 
110 };
111 
112 } //end of namespace bpp.
113 
114 #endif //_CLADOGRAMPLOT_H_
115 
Basal interface for tree drawing classes.
Definition: TreeDrawing.h:264
CladogramPlot * clone() const
Definition: CladogramPlot.h:86
static unsigned int getDepth(const Node &node)
Get the depth of the subtree defined by node &#39;node&#39;, i.e. the maximum number of sons &#39;generations&#39;...
void setTree(const Tree *tree=0)
Cursor getBranchCursor(double position) const
Cladogram representation of trees.
Definition: CladogramPlot.h:72
Basic implementation of dendrogram plots.
std::string getName() const
Definition: CladogramPlot.h:89
Interface for phylogenetic tree objects.
Definition: Tree.h:148
CladogramDrawBranchEvent(const TreeDrawing *source, GraphicDevice *gd, const INode *node, double length_, const Cursor &cursor, short orientation)
virtual ~CladogramPlot()
Definition: CladogramPlot.h:84
Event class that uses INode object (more efficient than relying on nodes id, but less generic)...
double getWidth() const
Definition: CladogramPlot.h:93
void drawDendrogram_(GraphicDevice &gDevice) const
TreeTemplate< INode > * getTree_()
void treeHasChanged()
Method to implement to deal with redrawing when the underlying tree has been modified.
Definition: CladogramPlot.h:96
The NodeTemplate class.
Definition: NodeTemplate.h:73
double getHeight() const
Definition: CladogramPlot.h:94
Data structure describing a plotting direction.
Definition: TreeDrawing.h:87
void recursivePlot_(GraphicDevice &gDevice, INode &node, double x, double &y, double hDirection, double vDirection, unsigned int *tipCounter) const