From cd99fed7cd3a49df337ff82401c17d97e091718d Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 30 Sep 2023 10:53:52 -0600 Subject: [PATCH] canvas: add PolyItem::clear() --- libs/canvas/canvas/poly_item.h | 1 + libs/canvas/poly_item.cc | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/libs/canvas/canvas/poly_item.h b/libs/canvas/canvas/poly_item.h index 7ad13485ff..79dcd876da 100644 --- a/libs/canvas/canvas/poly_item.h +++ b/libs/canvas/canvas/poly_item.h @@ -37,6 +37,7 @@ public: virtual void set (Points const&); virtual void add_point (Duple const &); + virtual void clear (); void pop_back(); Points const& get () const; diff --git a/libs/canvas/poly_item.cc b/libs/canvas/poly_item.cc index 3fa227250f..1ab75867f5 100644 --- a/libs/canvas/poly_item.cc +++ b/libs/canvas/poly_item.cc @@ -158,6 +158,17 @@ PolyItem::pop_back () end_change (); } +void +PolyItem::clear () +{ + if (!_points.empty()) { + begin_change (); + _points.clear (); + set_bbox_dirty (); + end_change (); + } +} + Points const& PolyItem::get () const {