diff --git a/src/sp-spiral.cpp b/src/sp-spiral.cpp
index 9c04120e1e8dea67091c679d1e7185a93cba5697..3a37a8da278805f91880d93e5d48805f007fdf41 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 void sp_spiral_init (SPSpiral *spiral);
static void sp_spiral_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr);
-static Inkscape::XML::Node *sp_spiral_write (SPObject *object, Inkscape::XML::Node *repr, guint flags);
+static Inkscape::XML::Node *sp_spiral_write (SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
static void sp_spiral_set (SPObject *object, unsigned int key, const gchar *value);
static void sp_spiral_update (SPObject *object, SPCtx *ctx, guint flags);
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 (SPLPEItem *lpeitem, bool write);
static NR::Point sp_spiral_get_tangent (SPSpiral const *spiral, gdouble t);
GObjectClass * gobject_class;
SPObjectClass * sp_object_class;
SPItemClass * item_class;
+ SPLPEItemClass * lpe_item_class;
SPShapeClass *shape_class;
gobject_class = (GObjectClass *) klass;
sp_object_class = (SPObjectClass *) klass;
item_class = (SPItemClass *) klass;
+ lpe_item_class = (SPLPEItemClass *) klass;
shape_class = (SPShapeClass *) klass;
parent_class = (SPShapeClass *)g_type_class_ref (SP_TYPE_SHAPE);
item_class->description = sp_spiral_description;
item_class->snappoints = sp_spiral_snappoints;
- shape_class->set_shape = sp_spiral_set_shape;
+ lpe_item_class->update_patheffect = sp_spiral_update_patheffect;
+
+ shape_class->set_shape = sp_spiral_set_shape;
}
/**
@@ -134,12 +141,12 @@ sp_spiral_build (SPObject * object, SPDocument * document, Inkscape::XML::Node *
* Virtual write: write spiral attributes to corresponding repr.
*/
static Inkscape::XML::Node *
-sp_spiral_write (SPObject *object, Inkscape::XML::Node *repr, guint flags)
+sp_spiral_write (SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
{
SPSpiral *spiral = SP_SPIRAL (object);
if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) {
- repr = sp_repr_new ("svg:path");
+ repr = xml_doc->createElement("svg:path");
}
if (flags & SP_OBJECT_WRITE_EXT) {
// 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
- if ( !curve ) {
- //g_warning("sp_spiral_write(): No path to copy\n");
- return NULL;
- }
- NArtBpath *bpath = curve->bpath;
- if ( !bpath ) {
- //g_warning("sp_spiral_write(): No path to copy\n");
- return NULL;
- }
- char *d = sp_svg_write_path ( bpath );
- repr->setAttribute("d", d);
- g_free (d);
-
- if (((SPObjectClass *) (parent_class))->write)
- ((SPObjectClass *) (parent_class))->write (object, repr, flags | SP_SHAPE_WRITE_PATH);
-
- return repr;
+ //Duplicate the path
+ SPCurve *curve = ((SPShape *) spiral)->curve;
+ //Nulls might be possible if this called iteratively
+ if ( !curve ) {
+ //g_warning("sp_spiral_write(): No path to copy\n");
+ return NULL;
+ }
+ char *d = sp_svg_write_path ( curve->get_pathvector() );
+ repr->setAttribute("d", d);
+ g_free (d);
+
+ if (((SPObjectClass *) (parent_class))->write)
+ ((SPObjectClass *) (parent_class))->write (object, xml_doc, repr, flags | SP_SHAPE_WRITE_PATH);
+
+ return repr;
}
/**
((SPObjectClass *) parent_class)->update (object, ctx, flags);
}
+static void
+sp_spiral_update_patheffect(SPLPEItem *lpeitem, bool write)
+{
+ SPShape *shape = (SPShape *) lpeitem;
+ sp_spiral_set_shape(shape);
+
+ if (write) {
+ Inkscape::XML::Node *repr = SP_OBJECT_REPR(shape);
+ if ( shape->curve != NULL ) {
+ gchar *str = sp_svg_write_path(shape->curve->get_pathvector());
+ repr->setAttribute("d", str);
+ g_free(str);
+ } else {
+ repr->setAttribute("d", NULL);
+ }
+ }
+
+ ((SPObject *)shape)->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
+}
+
/**
* Return textual description of spiral.
*/
#endif
if (depth != -1) {
for (i = 0; i < 4*depth; i += 4) {
- sp_curve_curveto (c,
- bezier[i + 1],
+ c->curveto(bezier[i + 1],
bezier[i + 2],
bezier[i + 3]);
}
g_print ("cant_fit_cubic: t=%g\n", *t);
#endif
for (i = 1; i < SAMPLE_SIZE; i++)
- sp_curve_lineto (c, darray[i]);
+ c->lineto(darray[i]);
}
*t = next_t;
g_assert (is_unit_vector (hat2));
SP_OBJECT (spiral)->requestModified(SP_OBJECT_MODIFIED_FLAG);
- SPCurve *c = sp_curve_new ();
+ SPCurve *c = new SPCurve ();
#ifdef SPIRAL_VERBOSE
g_print ("cx=%g, cy=%g, exp=%g, revo=%g, rad=%g, arg=%g, t0=%g\n",
#endif
/* Initial moveto. */
- sp_curve_moveto(c, sp_spiral_get_xy(spiral, spiral->t0));
+ c->moveto(sp_spiral_get_xy(spiral, spiral->t0));
double const tstep = SAMPLE_STEP / spiral->revo;
double const dstep = tstep / (SAMPLE_SIZE - 1);
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_lpe_item_perform_path_effect(SP_LPE_ITEM (spiral), c);
+ sp_shape_set_curve_insync ((SPShape *) spiral, c, TRUE);
+ c->unref();
}
/**