remove debug output and get logic correct to cause first render to always use the...
[ardour.git] / libs / canvas / poly_line.cc
index 08d611117f3bac05110f95dd6bb87d8e31d77922..3150907db6f17aec5fec9f16e362444bac54ff99 100644 (file)
 
 using namespace ArdourCanvas;
 
-PolyLine::PolyLine (Group* parent)
-       : Item (parent)
-       , PolyItem (parent)
+PolyLine::PolyLine (Canvas* c)
+       : PolyItem (c)
        , _threshold (1.0)
 {
+}
 
+PolyLine::PolyLine (Item* parent)
+       : PolyItem (parent)
+       , _threshold (1.0)
+{
 }
 
 void
@@ -43,6 +47,30 @@ PolyLine::render (Rect const & area, Cairo::RefPtr<Cairo::Context> context) cons
        }
 }
 
+void
+PolyLine::set_steps (Points const & points, bool stepped)
+{
+       if (!stepped) {
+               PolyItem::set(points);
+               return;
+       }
+
+       Points copy;
+       for (Points::const_iterator p = points.begin(); p != points.end();) {
+               Points::const_iterator next = p;
+               ++next;
+
+               copy.push_back(*p);
+               if (next != points.end() && next->x != p->x) {
+                       copy.push_back(Duple(next->x, p->y));
+               }
+
+               p = next;
+       }
+
+       PolyItem::set(copy);
+}
+
 bool
 PolyLine::covers (Duple const & point) const
 {