summaryrefslogtreecommitdiffstats
path: root/src/sp-polygon.cpp
diff options
context:
space:
mode:
authorJohan B. C. Engelen <jbc.engelen@swissonline.ch>2008-07-08 17:55:15 +0000
committerjohanengelen <johanengelen@users.sourceforge.net>2008-07-08 17:55:15 +0000
commitcfb555a0a5fe43e44b9f9725fe64d68b9a2f5eef (patch)
tree63c3f6a7da12fbe8564789cf616422c80ee16c32 /src/sp-polygon.cpp
parentpatch by FreqMod for bug 246389 (diff)
downloadinkscape-cfb555a0a5fe43e44b9f9725fe64d68b9a2f5eef.tar.gz
inkscape-cfb555a0a5fe43e44b9f9725fe64d68b9a2f5eef.zip
* 2geomify polygon svg writing
* 2geomify caligraphy and erasertool svg writing (bzr r6228)
Diffstat (limited to 'src/sp-polygon.cpp')
-rw-r--r--src/sp-polygon.cpp33
1 files changed, 14 insertions, 19 deletions
diff --git a/src/sp-polygon.cpp b/src/sp-polygon.cpp
index 88b155e8e..04046a47d 100644
--- a/src/sp-polygon.cpp
+++ b/src/sp-polygon.cpp
@@ -18,7 +18,7 @@
#include "sp-polygon.h"
#include "display/curve.h"
#include <glibmm/i18n.h>
-#include "libnr/n-art-bpath.h"
+#include <2geom/pathvector.h>
#include "svg/stringstream.h"
#include "xml/repr.h"
#include "document.h"
@@ -87,27 +87,23 @@ static void sp_polygon_build(SPObject *object, SPDocument *document, Inkscape::X
/*
* sp_svg_write_polygon: Write points attribute for polygon tag.
- * @bpath:
- *
+ * pathv may only contain paths with only straight line segments
* Return value: points attribute string.
*/
-static gchar *sp_svg_write_polygon(const NArtBpath *bpath)
+static gchar *sp_svg_write_polygon(Geom::PathVector const & pathv)
{
- g_return_val_if_fail(bpath != NULL, NULL);
-
Inkscape::SVGOStringStream os;
- for (int i = 0; bpath[i].code != NR_END; i++) {
- switch (bpath [i].code) {
- case NR_LINETO:
- case NR_MOVETO:
- case NR_MOVETO_OPEN:
- os << bpath [i].x3 << "," << bpath [i].y3 << " ";
- break;
-
- case NR_CURVETO:
- default:
- g_assert_not_reached();
+ for (Geom::PathVector::const_iterator pit = pathv.begin(); pit != pathv.end(); ++pit) {
+ for (Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_default(); ++cit) {
+ if ( dynamic_cast<Geom::LineSegment const *>(&*cit) ||
+ dynamic_cast<Geom::HLineSegment const *>(&*cit) ||
+ dynamic_cast<Geom::VLineSegment const *>(&*cit) )
+ {
+ os << cit->finalPoint()[0] << "," << cit->finalPoint()[1] << " ";
+ } else {
+ g_error("sp_svg_write_polygon: polygon path contains non-straight line segments");
+ }
}
}
@@ -126,8 +122,7 @@ static Inkscape::XML::Node *sp_polygon_write(SPObject *object, Inkscape::XML::Do
}
/* We can safely write points here, because all subclasses require it too (Lauris) */
- NArtBpath const * abp = shape->curve->get_bpath();
- gchar *str = sp_svg_write_polygon(abp);
+ gchar *str = sp_svg_write_polygon(shape->curve->get_pathvector());
repr->setAttribute("points", str);
g_free(str);