summaryrefslogtreecommitdiffstats
path: root/src/libnr
diff options
context:
space:
mode:
Diffstat (limited to 'src/libnr')
-rw-r--r--src/libnr/nr-convert2geom.h6
-rw-r--r--src/libnr/nr-rect.cpp19
-rw-r--r--src/libnr/nr-rect.h4
3 files changed, 23 insertions, 6 deletions
diff --git a/src/libnr/nr-convert2geom.h b/src/libnr/nr-convert2geom.h
index c8a139aa2..7b501cddc 100644
--- a/src/libnr/nr-convert2geom.h
+++ b/src/libnr/nr-convert2geom.h
@@ -61,12 +61,6 @@ inline Geom::Scale to_2geom(NR::scale const & in) {
return Geom::Scale(in[NR::X], in[NR::Y]);
}
-inline void to_2geom(std::vector<NR::Point> const &in_NR, std::vector<Geom::Point> &out_2geom) {
- for (std::vector<NR::Point>::const_iterator it = in_NR.begin(); it != in_NR.end(); it++) {
- out_2geom.push_back(to_2geom(*it));
- }
-}
-
#endif
/*
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.
diff --git a/src/libnr/nr-rect.h b/src/libnr/nr-rect.h
index 7d130fd18..83f780efd 100644
--- a/src/libnr/nr-rect.h
+++ b/src/libnr/nr-rect.h
@@ -25,6 +25,7 @@
#include <boost/optional.hpp>
#include <libnr/nr-point-matrix-ops.h>
#include <libnr/nr-forward.h>
+#include <2geom/rect.h>
namespace NR {
@@ -243,6 +244,9 @@ struct NRRect {
explicit NRRect(boost::optional<NR::Rect> const &rect);
operator boost::optional<NR::Rect>() const { return upgrade(); }
boost::optional<NR::Rect> upgrade() const;
+ explicit NRRect(boost::optional<Geom::Rect> const &rect);
+ operator boost::optional<Geom::Rect>() const { return upgrade_2geom(); }
+ boost::optional<Geom::Rect> upgrade_2geom() const;
NR::Coord x0, y0, x1, y1;
};