diff options
Diffstat (limited to 'src/libnr/nr-rect.cpp')
| -rw-r--r-- | src/libnr/nr-rect.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/libnr/nr-rect.cpp b/src/libnr/nr-rect.cpp index 77af27417..620782996 100644 --- a/src/libnr/nr-rect.cpp +++ b/src/libnr/nr-rect.cpp @@ -28,6 +28,17 @@ NRRect::NRRect(boost::optional<NR::Rect> const &rect) { } } +NRRect::NRRect(boost::optional<Geom::Rect> const &rect) { + if (rect) { + x0 = rect->min()[Geom::X]; + y0 = rect->min()[Geom::Y]; + x1 = rect->max()[Geom::X]; + y1 = rect->max()[Geom::Y]; + } else { + nr_rect_d_set_empty(this); + } +} + boost::optional<NR::Rect> NRRect::upgrade() const { if (nr_rect_d_test_empty_ptr(this)) { return boost::optional<NR::Rect>(); @@ -36,6 +47,14 @@ boost::optional<NR::Rect> NRRect::upgrade() const { } } +boost::optional<Geom::Rect> NRRect::upgrade_2geom() const { + if (nr_rect_d_test_empty_ptr(this)) { + return boost::optional<Geom::Rect>(); + } else { + return Geom::Rect(Geom::Point(x0, y0), Geom::Point(x1, y1)); + } +} + /** * \param r0 Rectangle. * \param r1 Another rectangle. |
