bpp-phyl3  3.0.0
CladogramPlot.h
Go to the documentation of this file.
1 // SPDX-FileCopyrightText: The Bio++ Development Group
2 //
3 // SPDX-License-Identifier: CECILL-2.1
4 
5 #ifndef BPP_PHYL_GRAPHICS_CLADOGRAMPLOT_H
6 #define BPP_PHYL_GRAPHICS_CLADOGRAMPLOT_H
7 
8 #include <Bpp/Exceptions.h>
9 
10 #include "AbstractDendrogramPlot.h"
11 
12 namespace bpp
13 {
15  public DrawIBranchEvent
16 {
17 private:
18  double orientation_;
19  double length_;
20 
21 public:
22  CladogramDrawBranchEvent(const TreeDrawing* source, GraphicDevice* gd, const INode* node, double length_, const Cursor& cursor, short orientation);
23 
24 public:
25  Cursor getBranchCursor(double position) const;
26 };
27 
28 
36 {
37 private:
38  double totalDepth_;
40 
41 public:
44  {}
45 
46  virtual ~CladogramPlot() {}
47 
48  CladogramPlot* clone() const { return new CladogramPlot(*this); }
49 
50 public:
51  std::string getName() const { return "Cladogram"; }
52 
53  void setTree(const Tree* tree = 0);
54 
55  double getWidth() const { return totalDepth_; }
56  double getHeight() const { return numberOfLeaves_; }
57 
59  {
60  if (hasTree())
61  {
62  totalDepth_ = static_cast<double>(TreeTemplateTools::getDepth(*getTree_()->getRootNode()));
63  numberOfLeaves_ = static_cast<double>(getTree_()->getNumberOfLeaves());
64  }
65  }
66 
67 private:
68  void drawDendrogram_(GraphicDevice& gDevice) const;
69  void recursivePlot_(GraphicDevice& gDevice, INode& node, double x, double& y, double hDirection, double vDirection, unsigned int& tipCounter) const;
70 };
71 } // end of namespace bpp.
72 #endif // BPP_PHYL_GRAPHICS_CLADOGRAMPLOT_H
Basic implementation of dendrogram plots.
TreeTemplate< INode > * getTree_()
CladogramDrawBranchEvent(const TreeDrawing *source, GraphicDevice *gd, const INode *node, double length_, const Cursor &cursor, short orientation)
Cursor getBranchCursor(double position) const
Cladogram representation of trees.
Definition: CladogramPlot.h:36
virtual ~CladogramPlot()
Definition: CladogramPlot.h:46
void recursivePlot_(GraphicDevice &gDevice, INode &node, double x, double &y, double hDirection, double vDirection, unsigned int &tipCounter) const
double getHeight() const
Definition: CladogramPlot.h:56
std::string getName() const
Definition: CladogramPlot.h:51
void treeHasChanged()
Method to implement to deal with redrawing when the underlying tree has been modified.
Definition: CladogramPlot.h:58
void drawDendrogram_(GraphicDevice &gDevice) const
void setTree(const Tree *tree=0)
double getWidth() const
Definition: CladogramPlot.h:55
CladogramPlot * clone() const
Definition: CladogramPlot.h:48
Data structure describing a plotting direction.
Definition: TreeDrawing.h:53
Event class that uses INode object (more efficient than relying on nodes id, but less generic).
The NodeTemplate class.
Definition: NodeTemplate.h:39
Basal interface for tree drawing classes.
Definition: TreeDrawing.h:223
static unsigned int getDepth(const Node &node)
Get the depth of the subtree defined by node 'node', i.e. the maximum number of sons 'generations'.
Interface for phylogenetic tree objects.
Definition: Tree.h:115
Defines the basic types of data flow nodes.