sp-spiral.cpp revision 113c1da23be452320f54194502cbfe284547058d
79ec30eb098ea1053718e7b5b0e92b8ff59488a2buliabyak * <sodipodi:spiral> implementation
79ec30eb098ea1053718e7b5b0e92b8ff59488a2buliabyak * Mitsuru Oka <oka326@parkcity.ne.jp>
79ec30eb098ea1053718e7b5b0e92b8ff59488a2buliabyak * Lauris Kaplinski <lauris@kaplinski.com>
79ec30eb098ea1053718e7b5b0e92b8ff59488a2buliabyak * Abhishek Sharma
79ec30eb098ea1053718e7b5b0e92b8ff59488a2buliabyak * Jon A. Cruz <jon@joncruz.org>
79ec30eb098ea1053718e7b5b0e92b8ff59488a2buliabyak * Copyright (C) 1999-2002 Lauris Kaplinski
79ec30eb098ea1053718e7b5b0e92b8ff59488a2buliabyak * Copyright (C) 2000-2001 Ximian, Inc.
79ec30eb098ea1053718e7b5b0e92b8ff59488a2buliabyak * Released under GNU GPL, read the file 'COPYING' for more information
79ec30eb098ea1053718e7b5b0e92b8ff59488a2buliabyak return new SPSpiral();
79ec30eb098ea1053718e7b5b0e92b8ff59488a2buliabyak bool spiralRegistered = SPFactory::instance().registerObject("spiral", createSpiral);
8db8b3d85d2f91e5429d9bb407d0babcfe44518bpjrm this->cobject = this;
79ec30eb098ea1053718e7b5b0e92b8ff59488a2buliabyakvoid SPSpiral::build(SPDocument * document, Inkscape::XML::Node * repr) {
79ec30eb098ea1053718e7b5b0e92b8ff59488a2buliabyakInkscape::XML::Node* SPSpiral::write(Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags) {
60bbcba041e80a4b29118269c0897df5c068563eacspike /* Fixme: we may replace these attributes by
8db8b3d85d2f91e5429d9bb407d0babcfe44518bpjrm * sodipodi:spiral="cx cy exp revo rad arg t0"
79ec30eb098ea1053718e7b5b0e92b8ff59488a2buliabyak sp_repr_set_svg_double(repr, "sodipodi:cy", this->cy);
79ec30eb098ea1053718e7b5b0e92b8ff59488a2buliabyak sp_repr_set_svg_double(repr, "sodipodi:expansion", this->exp);
79ec30eb098ea1053718e7b5b0e92b8ff59488a2buliabyak sp_repr_set_svg_double(repr, "sodipodi:revolution", this->revo);
8db8b3d85d2f91e5429d9bb407d0babcfe44518bpjrm sp_repr_set_svg_double(repr, "sodipodi:radius", this->rad);
79ec30eb098ea1053718e7b5b0e92b8ff59488a2buliabyak sp_repr_set_svg_double(repr, "sodipodi:argument", this->arg);
79ec30eb098ea1053718e7b5b0e92b8ff59488a2buliabyak sp_repr_set_svg_double(repr, "sodipodi:t0", this->t0);
79ec30eb098ea1053718e7b5b0e92b8ff59488a2buliabyak // make sure the curve is rebuilt with all up-to-date parameters
79ec30eb098ea1053718e7b5b0e92b8ff59488a2buliabyak //Nulls might be possible if this called iteratively
79ec30eb098ea1053718e7b5b0e92b8ff59488a2buliabyak if (!this->_curve) {
79ec30eb098ea1053718e7b5b0e92b8ff59488a2buliabyak //g_warning("sp_spiral_write(): No path to copy\n");
79ec30eb098ea1053718e7b5b0e92b8ff59488a2buliabyak char *d = sp_svg_write_path(this->_curve->get_pathvector());
8db8b3d85d2f91e5429d9bb407d0babcfe44518bpjrm SPShape::write(xml_doc, repr, flags | SP_SHAPE_WRITE_PATH);
79ec30eb098ea1053718e7b5b0e92b8ff59488a2buliabyakvoid SPSpiral::set(unsigned int key, gchar const* value) {
79ec30eb098ea1053718e7b5b0e92b8ff59488a2buliabyak /// \todo fixme: we should really collect updates
8db8b3d85d2f91e5429d9bb407d0babcfe44518bpjrm if (!sp_svg_length_read_computed_absolute (value, &this->cx)) {
79ec30eb098ea1053718e7b5b0e92b8ff59488a2buliabyak this->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
79ec30eb098ea1053718e7b5b0e92b8ff59488a2buliabyak if (!sp_svg_length_read_computed_absolute (value, &this->cy)) {
if (value) {
if (value) {
case SP_ATTR_SODIPODI_RADIUS:
if (value) {
case SP_ATTR_SODIPODI_T0:
if (value) {
if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
this->set_shape();
if (write) {
void SPSpiral::fitAndDraw(SPCurve* c, double dstep, Geom::Point darray[], Geom::Point const& hat1, Geom::Point& hat2, double* t) const {
int depth, i;
d += dstep;
#ifdef SPIRAL_DEBUG
#ifdef SPIRAL_VERBOSE
*t = next_t;
g_warning ("The spiral shape has unknown LPE on it! Convert to path to make it editable preserving the appearance; editing it as spiral will remove the bad LPE");
#ifdef SPIRAL_VERBOSE
* This is very important for LPEs to work properly! (the bbox might be recalculated depending on the curve in shape)*/
if (sp_lpe_item_has_path_effect(SP_LPE_ITEM(shape)) && sp_lpe_item_path_effects_enabled(SP_LPE_ITEM(shape))) {
if (success) {
c->unref();
void SPSpiral::setPosition(gdouble cx, gdouble cy, gdouble exp, gdouble revo, gdouble rad, gdouble arg, gdouble t0) {
void SPSpiral::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) {
p.push_back(Inkscape::SnapCandidatePoint(Geom::Point(this->cx, this->cy) * i2dt, Inkscape::SNAPSOURCE_OBJECT_MIDPOINT, Inkscape::SNAPTARGET_OBJECT_MIDPOINT));
// This point is the start-point of the spiral, which is also returned when _snap_to_itemnode has been set
return ret;
if (rad) {
if (arg) {
return TRUE;
return TRUE;
return FALSE;