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
11
12namespace bpp
13{
15 public DrawIBranchEvent
16{
17private:
19 double length_;
20
21public:
22 CladogramDrawBranchEvent(const TreeDrawing* source, GraphicDevice* gd, const INode* node, double length_, const Cursor& cursor, short orientation);
23
24public:
25 Cursor getBranchCursor(double position) const;
26};
27
28
36{
37private:
40
41public:
44 {}
45
46 virtual ~CladogramPlot() {}
47
48 CladogramPlot* clone() const override { return new CladogramPlot(*this); }
49
50public:
51 std::string getName() const override { return "Cladogram"; }
52
53 void setTree(const Tree& tree) override;
54
55 double getWidth() const override { return totalDepth_; }
56 double getHeight() const override { return numberOfLeaves_; }
57
58 void treeHasChanged() override
59 {
60 if (hasTree())
61 {
62 totalDepth_ = static_cast<double>(TreeTemplateTools::getDepth(*tree_->getRootNode()));
63 numberOfLeaves_ = static_cast<double>(tree_->getNumberOfLeaves());
64 }
65 }
66
67private:
68 void drawDendrogram_(GraphicDevice& gDevice) const override;
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.
const Tree & tree() const override
std::unique_ptr< TreeTemplate< INode > > tree_
bool hasTree() const override
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
void treeHasChanged() override
Method to implement to deal with redrawing when the underlying tree has been modified.
Definition: CladogramPlot.h:58
std::string getName() const override
Definition: CladogramPlot.h:51
double getWidth() const override
Definition: CladogramPlot.h:55
double getHeight() const override
Definition: CladogramPlot.h:56
CladogramPlot * clone() const override
Definition: CladogramPlot.h:48
void drawDendrogram_(GraphicDevice &gDevice) const override
void setTree(const Tree &tree) override
Data structure describing a plotting direction.
Definition: TreeDrawing.h:54
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.