5 #ifndef BPP_PHYL_GRAPHICS_ABSTRACTTREEDRAWING_H
6 #define BPP_PHYL_GRAPHICS_ABSTRACTTREEDRAWING_H
9 #include "../Tree/NodeTemplate.h"
10 #include "../Tree/TreeTemplate.h"
119 std::unique_ptr<TreeTemplate<INode>>
tree_;
135 for (
unsigned int i = 0; i <
listeners_.size(); ++i)
153 for (
unsigned int i = 0; i <
listeners_.size(); ++i)
165 for (
unsigned int i = 0; i <
listeners_.size(); i++)
181 if (!tree)
tree_.reset();
217 double xOffset = 0,
double yOffset = 0,
252 if (!
tree_.get())
throw Exception(
"AbstractTreeDrawing::collapseNode. No tree is associated to the drawing.");
253 tree_->getNode(nodeId)->getInfos().collapse(yn);
258 if (!
tree_.get())
throw Exception(
"AbstractTreeDrawing::isNodeCollapsed. No tree is associated to the drawing.");
259 return tree_->getNode(nodeId)->getInfos().isCollapsed();
265 throw Exception(
"AbstractTreeDrawing::addTreeDrawingListener. Listener is already associated to this drawing.");
271 std::vector<TreeDrawingListener*>::iterator it = std::find(
listeners_.begin(),
listeners_.end(), listener);
273 throw Exception(
"AbstractTreeDrawing::addTreeDrawingListener. Listener is not associated to this drawing, and therefore can't be removed.");
290 for (
unsigned int i = 0; i <
listeners_.size(); i++)
299 for (
unsigned int i = 0; i <
listeners_.size(); i++)
308 for (
unsigned int i = 0; i <
listeners_.size(); i++)
317 for (
unsigned int i = 0; i <
listeners_.size(); i++)
326 for (
unsigned int i = 0; i <
listeners_.size(); i++)
335 for (
unsigned int i = 0; i <
listeners_.size(); i++)
Partial implementation of the TreeDrawing interface.
const TreeTemplate< INode > * getTree() const
void addTreeDrawingListener(TreeDrawingListener *listener)
Add a drawing listener to this instance.
void fireBeforeBranchEvent_(const DrawIBranchEvent &event) const
TreeTemplate< INode > * getTree_()
std::vector< TreeDrawingListener * > listeners_
Point2D< double > getNodePosition(int nodeId) const
Get the position of a node.
const TreeDrawingSettings & getDisplaySettings() const
AbstractTreeDrawing(const AbstractTreeDrawing &atd)
void setDisplaySettings(const TreeDrawingSettings *tds)
Global drawing settings.
bool isNodeCollapsed(int nodeId) const
void collapseNode(int nodeId, bool yn)
Properties to draw.
bool belongsTo(const Point2D< double > &p1, const Point2D< double > &p2) const
Utilitary function, telling if a point belongs to a specified area.
void setYUnit(double yu)
Set the 'vertical' expansion unit.
int getNodeAt(const Point2D< double > &position) const
Get the node corresponding to a position on the device.
const TreeDrawingSettings * settings_
std::unique_ptr< TreeTemplate< INode > > tree_
virtual void drawAtBranch(GraphicDevice &gDevice, const INode &node, const std::string &text, double xOffset=0, double yOffset=0, short hpos=GraphicDevice::TEXT_HORIZONTAL_LEFT, short vpos=GraphicDevice::TEXT_VERTICAL_CENTER, double angle=0) const
Draw some text at a particular branch position.
const TreeTemplate< INode > * getTree_() const
void fireAfterTreeEvent_(const DrawTreeEvent &event) const
void fireBeforeNodeEvent_(const DrawINodeEvent &event) const
void setTree(const Tree *tree)
virtual void drawAtNode(GraphicDevice &gDevice, const INode &node, const std::string &text, double xOffset=0, double yOffset=0, short hpos=GraphicDevice::TEXT_HORIZONTAL_LEFT, short vpos=GraphicDevice::TEXT_VERTICAL_CENTER, double angle=0) const
Draw some text at a particular node position.
virtual void treeHasChanged()=0
Method to implement to deal with redrawing when the underlying tree has been modified.
void removeTreeDrawingListener(TreeDrawingListener *listener)
Remove a drawing listener from this instance.
void fireAfterNodeEvent_(const DrawINodeEvent &event) const
static const TreeDrawingSettings DEFAULT_SETTINGS
AbstractTreeDrawing & operator=(const AbstractTreeDrawing &atd)
virtual ~AbstractTreeDrawing()
void fireBeforeTreeEvent_(const DrawTreeEvent &event) const
void setXUnit(double xu)
Set the 'horizontal' expansion unit.
void fireAfterBranchEvent_(const DrawIBranchEvent &event) const
Data structure describing a plotting direction.
Event class used by TreeDrawing classes.
DrawBranchEvent & operator=(const DrawBranchEvent &dne)
Event class that uses INode object (more efficient than relying on nodes id, but less generic).
const INode * getINode() const
DrawIBranchEvent(const TreeDrawing *source, GraphicDevice *gd, const INode *node, const Cursor &cursor)
DrawIBranchEvent & operator=(const DrawIBranchEvent &dne)
DrawIBranchEvent(const DrawIBranchEvent &dne)
Event class that uses INode object (more efficient than relying on nodes id, but less generic).
DrawINodeEvent & operator=(const DrawINodeEvent &dne)
DrawINodeEvent(const TreeDrawing *source, GraphicDevice *gd, const INode *node, const Cursor &cursor)
const INode * getINode() const
DrawINodeEvent(const DrawINodeEvent &dne)
Event class used by TreeDrawing classes.
DrawNodeEvent & operator=(const DrawNodeEvent &dne)
Event class used by TreeDrawing classes.
static short TEXT_HORIZONTAL_LEFT
static short TEXT_VERTICAL_CENTER
Interface allowing to capture drawing events.
virtual bool isAutonomous() const =0
Tells if the listener is autonomous. If so, it will never be hard-copied or deleted.
Point2D< double > & getPosition()
virtual ~TreeDrawingNodeInfo()
void setPosition(const Point2D< double > &position)
const Point2D< double > & getPosition() const
A set of options to tune the display of a TreeDrawing object.
Basal interface for tree drawing classes.
TreeDrawing * clone() const =0
The phylogenetic tree class.
Interface for phylogenetic tree objects.
Defines the basic types of data flow nodes.
NodeTemplate< TreeDrawingNodeInfo > INode