3 #include "pbd/compose.h"
5 #include "canvas/poly_item.h"
6 #include "canvas/canvas.h"
9 using namespace ArdourCanvas;
11 PolyItem::PolyItem (Group* parent)
19 PolyItem::compute_bounding_box () const
21 bool have_one = false;
25 for (Points::const_iterator i = _points.begin(); i != _points.end(); ++i) {
27 bbox.x0 = min (bbox.x0, i->x);
28 bbox.y0 = min (bbox.y0, i->y);
29 bbox.x1 = max (bbox.x1, i->x);
30 bbox.y1 = max (bbox.y1, i->y);
32 bbox.x0 = bbox.x1 = i->x;
33 bbox.y0 = bbox.y1 = i->y;
40 _bounding_box = boost::optional<Rect> ();
42 _bounding_box = bbox.expand (_outline_width / 2);
45 _bounding_box_dirty = false;
49 PolyItem::render_path (Rect const & /*area*/, Cairo::RefPtr<Cairo::Context> context) const
51 bool done_first = false;
52 for (Points::const_iterator i = _points.begin(); i != _points.end(); ++i) {
54 context->line_to (i->x, i->y);
56 context->move_to (i->x, i->y);
63 PolyItem::render_curve (Rect const & area, Cairo::RefPtr<Cairo::Context> context, Points const & first_control_points, Points const & second_control_points) const
65 bool done_first = false;
67 if (_points.size() <= 2) {
68 render_path (area, context);
72 Points::const_iterator cp1 = first_control_points.begin();
73 Points::const_iterator cp2 = second_control_points.begin();
75 for (Points::const_iterator i = _points.begin(); i != _points.end(); ++i) {
79 context->curve_to (cp1->x, cp1->y,
88 context->move_to (i->x, i->y);
95 PolyItem::set (Points const & points)
101 _bounding_box_dirty = true;
106 PolyItem::get () const
112 PolyItem::dump (ostream& o) const
116 o << _canvas->indent() << '\t' << _points.size() << " points" << endl;
117 for (Points::const_iterator i = _points.begin(); i != _points.end(); ++i) {
118 o << _canvas->indent() << "\t\t" << i->x << ", " << i->y << endl;