Code

2geomify SPCurve::new_from_rect
authorjohanengelen <johanengelen@users.sourceforge.net>
Tue, 8 Jul 2008 20:18:44 +0000 (20:18 +0000)
committerjohanengelen <johanengelen@users.sourceforge.net>
Tue, 8 Jul 2008 20:18:44 +0000 (20:18 +0000)
src/display/curve.cpp
src/display/curve.h
src/object-snapper.cpp
src/sp-image.cpp

index 68cb1c900a1c5294ea2760b41c6453ad0712ed12..c229ec28a533ebc5b9b2ff28c7a4b366d50bead3 100644 (file)
@@ -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<NR::Rect> 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();
 
index 39720e40195157e00e51630e75d57c79fc0167ef..6697987cafe9fd2cc48a7e41486f8a66cad05bf7 100644 (file)
@@ -19,7 +19,6 @@
 #include <glib/gslist.h>
 
 #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<NR::Rect> const &rect);
+    static SPCurve * new_from_rect(Geom::Rect const &rect);
 
     virtual ~SPCurve();
 
index ef6c5fce26c55be8d1ad802037b488574670ace2..c928d43d37fba450a3a25276aa36ee4b031ea651 100644 (file)
@@ -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); 
index f2f2265ea5b54d754b241e284321f8e5639aa8f1..2dc3bfb278a02c0f8009f5711239dd305cd9de3b 100644 (file)
@@ -23,6 +23,8 @@
 #include <libnr/nr-matrix-ops.h>
 #include <libnr/nr-translate-matrix-ops.h>
 #include <libnr/nr-scale-translate-ops.h>
+#include <libnr/nr-convert2geom.h>
+#include <2geom/rect.h>
 //#define GDK_PIXBUF_ENABLE_BACKEND 1
 //#include <gdk-pixbuf/gdk-pixbuf-io.h>
 #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<NR::Rect> 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();