23 #include "visdisplay.h"
25 #include <interfaces/VisualDisplay2DInterface.h>
45 for (sit_ = shapes_.begin(); sit_ != shapes_.end(); ++sit_) {
57 interface_ = interface;
67 while (!interface_->msgq_empty()) {
71 shapes_[m->
id()] =
new Line(m->
x(0),
115 shapes_[m->
id()] =
new Text(m->
x(),
128 for (sit_ = shapes_.begin(); sit_ != shapes_.end(); ++sit_) {
134 interface_->msgq_pop();
146 for (sit_ = shapes_.begin(); sit_ != shapes_.end(); ++sit_) {
148 sit_->second->color(r, g, b, a);
149 sit_->second->apply_style(cr);
150 sit_->second->draw(cr);
214 _line_style = line_style;
215 _color_r = r / 255.f;
216 _color_g = g / 255.f;
217 _color_b = b / 255.f;
218 _color_a = a / 255.f;
256 :
Shape(id, owner, line_style, r, g, b, a)
267 cr->move_to(x1_, y1_);
268 cr->line_to(x2_, y2_);
303 :
Shape(id, owner, line_style, r, g, b, a)
314 cr->rectangle(x_, y_, width_, height_);
345 :
Shape(id, owner, line_style, r, g, b, a)
355 cr->arc(x_, y_, radius_, 0, 2 * M_PI);
380 const std::string & text,
403 cr->rotate(-0.5 * M_PI);
404 cr->set_font_size(1.36 * size_);
406 Cairo::TextExtents te;
407 cr->get_text_extents(text_, te);
409 float x = x_, y = y_;
411 case VisualDisplay2DInterface::CENTERED:
412 x = x_ - te.width / 2.;
413 y = y_ + te.height / 2.;
415 case VisualDisplay2DInterface::NORTH:
416 x = x_ - te.width / 2.;
419 case VisualDisplay2DInterface::EAST:
421 y = y_ + te.height / 2.;
423 case VisualDisplay2DInterface::SOUTH: x = x_ - te.width / 2.;
break;
424 case VisualDisplay2DInterface::WEST: y = y_ + te.height / 2.;
break;
425 case VisualDisplay2DInterface::NORTH_EAST:
429 case VisualDisplay2DInterface::SOUTH_EAST: x = x_ - te.width;
break;
430 case VisualDisplay2DInterface::SOUTH_WEST:
break;
431 case VisualDisplay2DInterface::NORTH_WEST: y = y_ + te.height;
break;
435 cr->show_text(text_);
Class representing a circle Line represented by its center point and radius.
Circle(float x, float y, float radius, unsigned int id, fawkes::Uuid owner, fawkes::VisualDisplay2DInterface::LineStyle line_style=fawkes::VisualDisplay2DInterface::LS_SOLID, unsigned char r=0, unsigned char g=0, unsigned char b=0, unsigned char a=0)
Constructor.
void draw(Cairo::RefPtr< Cairo::Context > &cr)
Draw shape to Cairo context.
Class representing a line.
void draw(Cairo::RefPtr< Cairo::Context > &cr)
Draw shape to Cairo context.
Line(float x1, float y1, float x2, float y2, unsigned int id, fawkes::Uuid owner, fawkes::VisualDisplay2DInterface::LineStyle line_style=fawkes::VisualDisplay2DInterface::LS_SOLID, unsigned char r=0, unsigned char g=0, unsigned char b=0, unsigned char a=0)
Constructor.
Class representing a rectangle.
Rectangle(float x, float y, float width, float height, unsigned int id, fawkes::Uuid owner, fawkes::VisualDisplay2DInterface::LineStyle line_style=fawkes::VisualDisplay2DInterface::LS_SOLID, unsigned char r=0, unsigned char g=0, unsigned char b=0, unsigned char a=0)
Constructor.
void draw(Cairo::RefPtr< Cairo::Context > &cr)
Draw shape to Cairo context.
Class representing a shape.
Shape(unsigned int id, fawkes::Uuid owner, fawkes::VisualDisplay2DInterface::LineStyle line_style=fawkes::VisualDisplay2DInterface::LS_SOLID, unsigned char r=0, unsigned char g=0, unsigned char b=0, unsigned char a=0)
Constructor.
virtual ~Shape()
Virtual empty destructor.
Class representing a text object.
void draw(Cairo::RefPtr< Cairo::Context > &cr)
Draw shape to Cairo context.
Text(float x, float y, const std::string &text, fawkes::VisualDisplay2DInterface::Anchor anchor, float size, unsigned int id, fawkes::Uuid owner, unsigned char r=0, unsigned char g=0, unsigned char b=0, unsigned char a=0)
Constructor.
VisualDisplay2D()
Constructor.
void set_interface(fawkes::VisualDisplay2DInterface *interface)
Set interface.
void draw(Cairo::RefPtr< Cairo::Context > cr)
Draw objects.
~VisualDisplay2D()
Destructor.
void process_messages()
Process messages.
Uuid sender_id() const
Get ID of the immediate sender, not necessarily the creator of the message.
unsigned int id() const
Get message ID.
A convenience class for universally unique identifiers (UUIDs).
AddCartCircleMessage Fawkes BlackBoard Interface Message.
float y() const
Get y value.
float x() const
Get x value.
float radius() const
Get radius value.
uint8_t * color() const
Get color value.
LineStyle style() const
Get style value.
AddCartLineMessage Fawkes BlackBoard Interface Message.
float * x() const
Get x value.
uint8_t * color() const
Get color value.
float * y() const
Get y value.
LineStyle style() const
Get style value.
AddCartRectMessage Fawkes BlackBoard Interface Message.
float height() const
Get height value.
float y() const
Get y value.
uint8_t * color() const
Get color value.
float width() const
Get width value.
LineStyle style() const
Get style value.
float x() const
Get x value.
AddCartTextMessage Fawkes BlackBoard Interface Message.
float x() const
Get x value.
float y() const
Get y value.
char * text() const
Get text value.
Anchor anchor() const
Get anchor value.
uint8_t * color() const
Get color value.
float size() const
Get size value.
DeleteAllMessage Fawkes BlackBoard Interface Message.
VisualDisplay2DInterface Fawkes BlackBoard Interface.
Anchor
Enumeration defining the possible anchor points.
LineStyle
Enumeration defining the possible line styles.
Fawkes library namespace.