41 #include "../TreeTemplateTools.h" 58 if (
getINode()->hasDistanceToFather())
71 getTree_()->setVoidBranchLengths(0.);
80 fireBeforeTreeEvent_(treeEvent);
81 unsigned int* tipCounter =
new unsigned int(0);
83 recursivePlot_(gDevice, *const_cast<INode*>(getTree_()->getRootNode()),
84 getHorizontalOrientation() == ORIENTATION_LEFT_TO_RIGHT ? 0 : getWidth() * getXUnit(),
86 getHorizontalOrientation() == ORIENTATION_LEFT_TO_RIGHT ? 1. : -1.,
87 getVerticalOrientation() == ORIENTATION_TOP_TO_BOTTOM ? 1. : -1.,
89 fireAfterTreeEvent_(treeEvent);
96 bool drawBranch =
true;
100 if (length < -10000000)
107 x2 = x + hDirection * length *
getXUnit();
116 auto_ptr<Cursor> cursor;
117 auto_ptr<DrawINodeEvent> nodeEvent;
118 auto_ptr<DrawIBranchEvent> branchEvent;
124 cursor.reset(
new Cursor(x2, y, 0, hpos));
125 nodeEvent.reset(
new DrawINodeEvent(
this, &gDevice, &node, *cursor));
128 else if (node.
getInfos().isCollapsed())
132 cursor.reset(
new Cursor(x2, y, 0, hpos));
133 nodeEvent.reset(
new DrawINodeEvent(
this, &gDevice, &node, *cursor));
139 double miny = 1000000;
145 if(yson < miny) miny = yson;
146 if(yson > maxy) maxy = yson;
148 y = (maxy + miny) / 2.;
149 cursor.reset(
new Cursor(x2, y, 0, hpos));
150 nodeEvent.reset(
new DrawINodeEvent(
this, &gDevice, &node, *cursor));
152 gDevice.drawLine(x2, miny, x2, maxy);
158 nodeEvent.reset(
new DrawINodeEvent(
this, &gDevice, &node, *cursor));
166 gDevice.drawLine(x, y, x2, y);
Basal interface for tree drawing classes.
void setTree(const Tree *tree)
const NodeTemplate< NodeInfos > * getSon(size_t i) const
Cursor getBranchCursor(double position) const
short getHorizontalOrientation() const
Event class that uses INode object (more efficient than relying on nodes id, but less generic)...
Cursor getTranslation(double x, double y) const
PhylogramDrawBranchEvent(const TreeDrawing *source, GraphicDevice *gd, const INode *node, const Cursor &cursor, short orientation)
void fireAfterNodeEvent_(const DrawINodeEvent &event) const
virtual bool hasDistanceToFather() const
Tell is this node has a distance to the father.
Interface for phylogenetic tree objects.
virtual bool isLeaf() const
void recursivePlot_(GraphicDevice &gDevice, INode &node, double x, double &y, double hDirection, double vDirection, unsigned int *tipCounter) const
virtual double getDistanceToFather() const
Get the distance to the father node is there is one, otherwise throw a NodeException.
virtual const TreeDrawing * getTreeDrawing() const
virtual const Cursor & getCursor() const
void fireBeforeBranchEvent_(const DrawIBranchEvent &event) const
void fireAfterBranchEvent_(const DrawIBranchEvent &event) const
void fireBeforeNodeEvent_(const DrawINodeEvent &event) const
static short ORIENTATION_LEFT_TO_RIGHT
Event class that uses INode object (more efficient than relying on nodes id, but less generic)...
virtual double getXUnit() const =0
static short ORIENTATION_TOP_TO_BOTTOM
const INode * getINode() const
virtual size_t getNumberOfSons() const
short getVerticalOrientation() const
TreeTemplate< INode > * getTree_()
void setTree(const Tree *tree=0)
virtual const NodeInfos & getInfos() const
void drawDendrogram_(GraphicDevice &gDevice) const
Data structure describing a plotting direction.
Event class used by TreeDrawing classes.