From 2b3cabe179b4499adc82f3834ea498b4a52cbe0d Mon Sep 17 00:00:00 2001 From: johanengelen Date: Tue, 8 Jul 2008 20:18:44 +0000 Subject: [PATCH] 2geomify SPCurve::new_from_rect --- src/display/curve.cpp | 9 ++++----- src/display/curve.h | 3 +-- src/object-snapper.cpp | 6 ++++-- src/sp-image.cpp | 6 ++++-- 4 files changed, 13 insertions(+), 11 deletions(-) diff --git a/src/display/curve.cpp b/src/display/curve.cpp index 68cb1c900..c229ec28a 100644 --- a/src/display/curve.cpp +++ b/src/display/curve.cpp @@ -34,6 +34,7 @@ #include <2geom/sbasis-geometric.h> #include <2geom/sbasis-to-bezier.h> #include "svg/svg.h" +#include <2geom/point.h> static unsigned sp_bpath_length(NArtBpath const bpath[]); static bool sp_bpath_closed(NArtBpath const bpath[]); @@ -143,17 +144,15 @@ SPCurve::new_from_bpath(NArtBpath *bpath) // * 2GEOMproof SPCurve * -SPCurve::new_from_rect(NR::Maybe const &rect) +SPCurve::new_from_rect(Geom::Rect const &rect) { - g_return_val_if_fail(rect, NULL); - SPCurve *c = new SPCurve(); - NR::Point p = rect->corner(0); + NR::Point p = rect.corner(0); c->moveto(p); for (int i=3; i>=0; i--) { - c->lineto(rect->corner(i)); + c->lineto(rect.corner(i)); } c->closepath_current(); diff --git a/src/display/curve.h b/src/display/curve.h index 39720e401..6697987ca 100644 --- a/src/display/curve.h +++ b/src/display/curve.h @@ -19,7 +19,6 @@ #include #include <2geom/forward.h> -#include <2geom/point.h> #include "libnr/nr-forward.h" #include "libnr/nr-rect.h" @@ -36,7 +35,7 @@ public: SPCurve(Geom::PathVector const& pathv); static SPCurve * new_from_bpath(NArtBpath *bpath); static SPCurve * new_from_foreign_bpath(NArtBpath const *bpath); - static SPCurve * new_from_rect(NR::Maybe const &rect); + static SPCurve * new_from_rect(Geom::Rect const &rect); virtual ~SPCurve(); diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index ef6c5fce2..c928d43d3 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -16,7 +16,9 @@ #include "libnr/nr-rect-ops.h" #include "libnr/nr-point-fns.h" #include "libnr/n-art-bpath-2geom.h" -#include "2geom/path-intersection.h" +#include <2geom/path-intersection.h> +#include <2geom/point.h> +#include <2geom/rect.h> #include "document.h" #include "sp-namedview.h" #include "sp-image.h" @@ -706,7 +708,7 @@ void Inkscape::ObjectSnapper::_clear_paths() const NArtBpath const* Inkscape::ObjectSnapper::_getBorderBPath() const { NArtBpath const *border_bpath = NULL; - NR::Rect const border_rect = NR::Rect(NR::Point(0,0), NR::Point(sp_document_width(_named_view->document),sp_document_height(_named_view->document))); + Geom::Rect const border_rect = Geom::Rect(Geom::Point(0,0), Geom::Point(sp_document_width(_named_view->document),sp_document_height(_named_view->document))); SPCurve const *border_curve = SPCurve::new_from_rect(border_rect); if (border_curve) { border_bpath = SP_CURVE_BPATH(border_curve); diff --git a/src/sp-image.cpp b/src/sp-image.cpp index f2f2265ea..2dc3bfb27 100644 --- a/src/sp-image.cpp +++ b/src/sp-image.cpp @@ -23,6 +23,8 @@ #include #include #include +#include +#include <2geom/rect.h> //#define GDK_PIXBUF_ENABLE_BACKEND 1 //#include #include "display/nr-arena-image.h" @@ -1518,8 +1520,8 @@ sp_image_set_curve(SPImage *image) NRRect rect; sp_image_bbox(image, &rect, NR::identity(), 0); - NR::Maybe rect2 = rect.upgrade(); - SPCurve *c = SPCurve::new_from_rect(rect2); + Geom::Rect rect2 = to_2geom(*rect.upgrade()); + SPCurve *c = SPCurve::new_from_rect(rect2); if (image->curve) { image->curve = image->curve->unref(); -- 2.30.2