40 #ifndef _ABSTRACTTREEDRAWING_H_ 41 #define _ABSTRACTTREEDRAWING_H_ 43 #include "../TreeTemplate.h" 44 #include "../NodeTemplate.h" 159 std::auto_ptr<TreeTemplate<INode> >
tree_;
175 for (
unsigned int i = 0; i <
listeners_.size(); ++i)
193 for (
unsigned int i = 0; i <
listeners_.size(); ++i)
205 for (
unsigned int i = 0; i <
listeners_.size(); i++)
214 #ifdef NO_VIRTUAL_COV 225 if (!tree)
tree_.reset();
246 bool belongsTo(
const Point2D<double>& p1,
const Point2D<double>& p2)
const;
260 virtual void drawAtNode(GraphicDevice& gDevice,
const INode& node,
const std::string& text,
261 double xOffset = 0,
double yOffset = 0,
262 short hpos = GraphicDevice::TEXT_HORIZONTAL_LEFT,
short vpos = GraphicDevice::TEXT_VERTICAL_CENTER,
double angle = 0)
const;
276 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;
280 throw NullPointerException(
"AbstractTreeDrawing::setDisplaySettings. Null pointer provided.");
295 if(!
tree_.get())
throw Exception(
"AbstractTreeDrawing::collapseNode. No tree is associated to the drawing.");
296 tree_->getNode(nodeId)->getInfos().collapse(yn);
301 if(!
tree_.get())
throw Exception(
"AbstractTreeDrawing::isNodeCollapsed. No tree is associated to the drawing.");
302 return tree_->getNode(nodeId)->getInfos().isCollapsed();
308 throw Exception(
"AbstractTreeDrawing::addTreeDrawingListener. Listener is already associated to this drawing.");
314 std::vector<TreeDrawingListener*>::iterator it = std::find(
listeners_.begin(),
listeners_.end(), listener);
316 throw Exception(
"AbstractTreeDrawing::addTreeDrawingListener. Listener is not associated to this drawing, and therefore can't be removed.");
318 if (!listener->isAutonomous())
333 for (
unsigned int i = 0; i <
listeners_.size(); i++)
340 for (
unsigned int i = 0; i <
listeners_.size(); i++)
347 for (
unsigned int i = 0; i <
listeners_.size(); i++)
354 for (
unsigned int i = 0; i <
listeners_.size(); i++)
361 for (
unsigned int i = 0; i <
listeners_.size(); i++)
368 for (
unsigned int i = 0; i <
listeners_.size(); i++)
378 #endif //_ABSTRACTTREEDRAWING_H_ const Point2D< double > & getPosition() const
Basal interface for tree drawing classes.
const TreeTemplate< INode > * getTree() const
DrawINodeEvent(const DrawINodeEvent &dne)
const TreeDrawingSettings & getDisplaySettings() const
void setTree(const Tree *tree)
void fireBeforeTreeEvent_(const DrawTreeEvent &event) const
void setDisplaySettings(const TreeDrawingSettings *tds)
Global drawing settings.
DrawBranchEvent & operator=(const DrawBranchEvent &dne)
virtual ~AbstractTreeDrawing()
void removeTreeDrawingListener(TreeDrawingListener *listener)
Remove a drawing listener from this instance.
DrawIBranchEvent(const DrawIBranchEvent &dne)
AbstractTreeDrawing & operator=(const AbstractTreeDrawing &atd)
Partial implementation of the TreeDrawing interface.
DrawINodeEvent & operator=(const DrawINodeEvent &dne)
Event class that uses INode object (more efficient than relying on nodes id, but less generic)...
void setXUnit(double xu)
Set the 'horizontal' expansion unit.
TreeDrawing * clone() const =0
void setPosition(const Point2D< double > &position)
void fireAfterNodeEvent_(const DrawINodeEvent &event) const
Point2D< double > getNodePosition(int nodeId) const
Get the position of a node.
void fireAfterTreeEvent_(const DrawTreeEvent &event) const
The phylogenetic tree class.
DrawIBranchEvent(const TreeDrawing *source, GraphicDevice *gd, const INode *node, const Cursor &cursor)
Interface for phylogenetic tree objects.
virtual void treeHasChanged()=0
Method to implement to deal with redrawing when the underlying tree has been modified.
NodeTemplate< TreeDrawingNodeInfo > INode
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.
std::auto_ptr< TreeTemplate< INode > > tree_
AbstractTreeDrawing(const AbstractTreeDrawing &atd)
const TreeTemplate< INode > * getTree_() const
void fireBeforeBranchEvent_(const DrawIBranchEvent &event) const
void fireAfterBranchEvent_(const DrawIBranchEvent &event) const
const TreeDrawingSettings * settings_
void fireBeforeNodeEvent_(const DrawINodeEvent &event) const
A set of options to tune the display of a TreeDrawing object.
void setYUnit(double yu)
Set the 'vertical' expansion unit.
Exception thrown when something is wrong with a particular node.
Event class used by TreeDrawing classes.
DrawIBranchEvent & operator=(const DrawIBranchEvent &dne)
std::vector< TreeDrawingListener * > listeners_
Event class that uses INode object (more efficient than relying on nodes id, but less generic)...
Interface allowing to capture drawing events.
DrawNodeEvent & operator=(const DrawNodeEvent &dne)
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.
Point2D< double > & getPosition()
Event class used by TreeDrawing classes.
bool belongsTo(const Point2D< double > &p1, const Point2D< double > &p2) const
Utilitary function, telling if a point belongs to a specified area.
DrawINodeEvent(const TreeDrawing *source, GraphicDevice *gd, const INode *node, const Cursor &cursor)
const INode * getINode() const
bool isNodeCollapsed(int nodeId) const
int getNodeAt(const Point2D< double > &position) const
Get the node corresponding to a position on the device.
TreeTemplate< INode > * getTree_()
virtual ~TreeDrawingNodeInfo()
void addTreeDrawingListener(TreeDrawingListener *listener)
Add a drawing listener to this instance.
static const TreeDrawingSettings DEFAULT_SETTINGS
const INode * getINode() const
void collapseNode(int nodeId, bool yn)
Properties to draw.
Data structure describing a plotting direction.
Event class used by TreeDrawing classes.