diff --git a/src/sp-spiral.cpp b/src/sp-spiral.cpp
index d7b703d1adbc70269657cf795f5a61ba6ce7a5fc..3e8ce49973afa41e2b830f018b8e1cff40d73b41 100644 (file)
--- a/src/sp-spiral.cpp
+++ b/src/sp-spiral.cpp
#include "display/curve.h"
#include <glibmm/i18n.h>
#include "xml/repr.h"
+#include "document.h"
#include "sp-spiral.h"
static gchar * sp_spiral_description (SPItem * item);
static void sp_spiral_snappoints(SPItem const *item, SnapPointsIter p);
+
static void sp_spiral_set_shape (SPShape *shape);
+static void sp_spiral_update_patheffect (SPShape *shape, bool write);
static NR::Point sp_spiral_get_tangent (SPSpiral const *spiral, gdouble t);
item_class->description = sp_spiral_description;
item_class->snappoints = sp_spiral_snappoints;
- shape_class->set_shape = sp_spiral_set_shape;
+ shape_class->set_shape = sp_spiral_set_shape;
+ shape_class->update_patheffect = sp_spiral_update_patheffect;
}
/**
SPSpiral *spiral = SP_SPIRAL (object);
if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
- repr = sp_repr_new ("svg:path");
+ Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_OBJECT_DOCUMENT(object));
+ repr = xml_doc->createElement("svg:path");
}
if (flags & SP_OBJECT_WRITE_EXT) {
sp_repr_set_svg_double(repr, "sodipodi:t0", spiral->t0);
}
+ // make sure the curve is rebuilt with all up-to-date parameters
+ sp_spiral_set_shape ((SPShape *) spiral);
+
//Duplicate the path
SPCurve *curve = ((SPShape *) spiral)->curve;
//Nulls might be possible if this called iteratively
//g_warning("sp_spiral_write(): No path to copy\n");
return NULL;
}
- NArtBpath *bpath = curve->bpath;
+ NArtBpath *bpath = SP_CURVE_BPATH(curve);
if ( !bpath ) {
//g_warning("sp_spiral_write(): No path to copy\n");
return NULL;
((SPObjectClass *) parent_class)->update (object, ctx, flags);
}
+static void
+sp_spiral_update_patheffect(SPShape *shape, bool write)
+{
+ sp_spiral_set_shape(shape);
+
+ if (write) {
+ Inkscape::XML::Node *repr = SP_OBJECT_REPR(shape);
+ if ( shape->curve != NULL ) {
+ NArtBpath *abp = sp_curve_first_bpath(shape->curve);
+ if (abp) {
+ gchar *str = sp_svg_write_path(abp);
+ repr->setAttribute("d", str);
+ g_free(str);
+ } else {
+ repr->setAttribute("d", "");
+ }
+ } else {
+ repr->setAttribute("d", NULL);
+ }
+ }
+
+ ((SPObject *)shape)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+}
+
/**
* Return textual description of spiral.
*/
sp_spiral_fit_and_draw (spiral, c, (1.0 - t)/(SAMPLE_SIZE - 1.0),
darray, hat1, hat2, &t);
- sp_shape_set_curve_insync ((SPShape *) spiral, c, TRUE);
- sp_curve_unref (c);
+ sp_shape_perform_path_effect(c, SP_SHAPE (spiral));
+ sp_shape_set_curve_insync ((SPShape *) spiral, c, TRUE);
+ sp_curve_unref (c);
}
/**