Geom::Point ArcKnotHolderEntityRY::knot_get() const { SPGenericEllipse const *ge = SP_GENERICELLIPSE(item); return (Geom::Point(ge->cx.computed, ge->cy.computed) - Geom::Point(0, ge->ry.computed)); }
static void sp_circle_set (SPObject *object, unsigned int key, const gchar *value) { SPGenericEllipse *ge; ge = SP_GENERICELLIPSE (object); switch (key) { case SP_ATTR_CX: if (!sp_svg_length_read (value, &ge->cx)) { sp_svg_length_unset (&ge->cx, SP_SVG_UNIT_NONE, 0.0, 0.0); } sp_object_request_update (object, SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_CY: if (!sp_svg_length_read (value, &ge->cy)) { sp_svg_length_unset (&ge->cy, SP_SVG_UNIT_NONE, 0.0, 0.0); } sp_object_request_update (object, SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_R: if (!sp_svg_length_read (value, &ge->rx) || (ge->rx.value <= 0.0)) { sp_svg_length_unset (&ge->rx, SP_SVG_UNIT_NONE, 0.0, 0.0); } ge->ry = ge->rx; sp_object_request_update (object, SP_OBJECT_MODIFIED_FLAG); break; default: if (((SPObjectClass *) circle_parent_class)->set) ((SPObjectClass *) circle_parent_class)->set (object, key, value); break; } }
Geom::Point ArcKnotHolderEntityEnd::knot_get() const { SPGenericEllipse const *ge = SP_GENERICELLIPSE(item); return ge->getPointAtAngle(ge->end); }
/** * If keep_path == true, the item should not be updated, effectively 'flattening' the LPE. */ void SPLPEItem::removeCurrentPathEffect(bool keep_paths) { Inkscape::LivePathEffect::LPEObjectReference* lperef = this->getCurrentLPEReference(); if (!lperef) return; if (Inkscape::LivePathEffect::Effect* effect_ = this->getCurrentLPE()) { effect_->doOnRemove(this); } PathEffectList new_list = *this->path_effect_list; new_list.remove(lperef); //current lpe ref is always our 'own' pointer from the path_effect_list std::string r = patheffectlist_write_svg(new_list); if (!r.empty()) { this->getRepr()->setAttribute("inkscape:path-effect", r.c_str()); } else { this->getRepr()->setAttribute("inkscape:path-effect", NULL); } if (!keep_paths) { // Make sure that ellipse is stored as <svg:circle> or <svg:ellipse> if possible. if( SP_IS_GENERICELLIPSE(this)) { SP_GENERICELLIPSE(this)->write( this->getRepr()->document(), this->getRepr(), SP_OBJECT_WRITE_EXT ); } sp_lpe_item_cleanup_original_path_recursive(this); } }
void SPLPEItem::addPathEffect(gchar *value, bool reset) { if (value) { // Apply the path effects here because in the casse of a group, lpe->resetDefaults // needs that all the subitems have their effects applied sp_lpe_item_update_patheffect(this, false, true); // Disable the path effects while preparing the new lpe sp_lpe_item_enable_path_effects(this, false); // Add the new reference to the list of LPE references HRefList hreflist; for (PathEffectList::const_iterator it = this->path_effect_list->begin(); it != this->path_effect_list->end(); ++it) { hreflist.push_back( std::string((*it)->lpeobject_href) ); } hreflist.push_back( std::string(value) ); std::string hrefs = hreflist_write_svg(hreflist); this->getRepr()->setAttribute("inkscape:path-effect", hrefs.c_str()); // Make sure that ellipse is stored as <svg:path> if( SP_IS_GENERICELLIPSE(this)) { SP_GENERICELLIPSE(this)->write( this->getRepr()->document(), this->getRepr(), SP_OBJECT_WRITE_EXT ); } // make sure there is an original-d for paths!!! sp_lpe_item_create_original_path_recursive(this); LivePathEffectObject *lpeobj = this->path_effect_list->back()->lpeobject; if (lpeobj && lpeobj->get_lpe()) { Inkscape::LivePathEffect::Effect *lpe = lpeobj->get_lpe(); // Ask the path effect to reset itself if it doesn't have parameters yet if (reset) { // has to be called when all the subitems have their lpes applied lpe->resetDefaults(this); } // perform this once when the effect is applied lpe->doOnApply(this); // indicate that all necessary preparations are done and the effect can be performed lpe->setReady(); } //Enable the path effects now that everything is ready to apply the new path effect sp_lpe_item_enable_path_effects(this, true); // Apply the path effect sp_lpe_item_update_patheffect(this, true, true); //fix bug 1219324 if (SP_ACTIVE_DESKTOP ) { Inkscape::UI::Tools::ToolBase *ec = SP_ACTIVE_DESKTOP->event_context; if (INK_IS_NODE_TOOL(ec)) { tools_switch(SP_ACTIVE_DESKTOP, TOOLS_LPETOOL); //mhh tools_switch(SP_ACTIVE_DESKTOP, TOOLS_NODES); } } } }
void ArcKnotHolderEntityRY::knot_click(guint state) { SPGenericEllipse *ge = SP_GENERICELLIPSE(item); if (state & GDK_CONTROL_MASK) { ge->rx.computed = ge->ry.computed; (static_cast<SPObject *>(ge))->updateRepr(); } }
void ArcKnotHolderEntityEnd::knot_click(guint state) { SPGenericEllipse *ge = SP_GENERICELLIPSE(item); if (state & GDK_SHIFT_MASK) { ge->end = ge->start = 0; (static_cast<SPObject *>(ge))->updateRepr(); } }
void sp_arc_get_xy (SPArc *arc, gdouble arg, NRPointF *p) { SPGenericEllipse *ge; ge = SP_GENERICELLIPSE (arc); p->x = ge->rx.computed * cos(arg) + ge->cx.computed; p->y = ge->ry.computed * sin(arg) + ge->cy.computed; }
/** * If keep_path == true, the item should not be updated, effectively 'flattening' the LPE. */ void SPLPEItem::removeAllPathEffects(bool keep_paths) { this->getRepr()->setAttribute("inkscape:path-effect", NULL); if (!keep_paths) { // Make sure that ellipse is stored as <svg:circle> or <svg:ellipse> if possible. if (SP_IS_GENERICELLIPSE(this)) { SP_GENERICELLIPSE(this)->write(this->getRepr()->document(), this->getRepr(), SP_OBJECT_WRITE_EXT); } sp_lpe_item_cleanup_original_path_recursive(this); } }
/* * sp_arc_set_elliptical_path_attribute: * * Convert center to endpoint parameterization and set it to repr. * * See SVG 1.0 Specification W3C Recommendation * ``F.6 Ellptical arc implementation notes'' for more detail. */ static gboolean sp_arc_set_elliptical_path_attribute (SPArc *arc, SPRepr *repr) { #define ARC_BUFSIZE 256 SPGenericEllipse *ge; NRPointF p1, p2; gint fa, fs; gdouble dt; gchar c[ARC_BUFSIZE]; ge = SP_GENERICELLIPSE (arc); sp_arc_get_xy (arc, ge->start, &p1); sp_arc_get_xy (arc, ge->end, &p2); dt = fmod (ge->end - ge->start, SP_2PI); if (fabs (dt) < 1e-6) { NRPointF ph; sp_arc_get_xy (arc, (ge->start + ge->end) / 2.0, &ph); g_snprintf (c, ARC_BUFSIZE, "M %f %f A %f %f 0 %d %d %f,%f A %g %g 0 %d %d %g %g L %f %f z", p1.x, p1.y, ge->rx.computed, ge->ry.computed, 1, (dt > 0), ph.x, ph.y, ge->rx.computed, ge->ry.computed, 1, (dt > 0), p2.x, p2.y, ge->cx.computed, ge->cy.computed); } else { fa = (fabs (dt) > M_PI) ? 1 : 0; fs = (dt > 0) ? 1 : 0; #ifdef ARC_VERBOSE g_print ("start:%g end:%g fa=%d fs=%d\n", ge->start, ge->end, fa, fs); #endif if (ge->closed) { g_snprintf (c, ARC_BUFSIZE, "M %f,%f A %f,%f 0 %d %d %f,%f L %f,%f z", p1.x, p1.y, ge->rx.computed, ge->ry.computed, fa, fs, p2.x, p2.y, ge->cx.computed, ge->cy.computed); } else { g_snprintf (c, ARC_BUFSIZE, "M %f,%f A %f,%f 0 %d %d %f,%f", p1.x, p1.y, ge->rx.computed, ge->ry.computed, fa, fs, p2.x, p2.y); } } return sp_repr_set_attr (repr, "d", c); }
void ArcKnotHolderEntityRY::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) { SPGenericEllipse *ge = SP_GENERICELLIPSE(item); Geom::Point const s = snap_knot_position(p, state); ge->ry.computed = fabs( ge->cy.computed - s[Geom::Y] ); if ( state & GDK_CONTROL_MASK ) { ge->rx.computed = ge->ry.computed; } (static_cast<SPObject *>(item))->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); }
static SPRepr * sp_arc_write (SPObject *object, SPRepr *repr, guint flags) { SPGenericEllipse *ge; SPArc *arc; ge = SP_GENERICELLIPSE (object); arc = SP_ARC (object); if (flags & SP_OBJECT_WRITE_EXT) { if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { repr = sp_repr_new ("path"); } sp_repr_set_attr (repr, "sodipodi:type", "arc"); sp_repr_set_double_attribute (repr, "sodipodi:cx", ge->cx.computed); sp_repr_set_double_attribute (repr, "sodipodi:cy", ge->cy.computed); sp_repr_set_double_attribute (repr, "sodipodi:rx", ge->rx.computed); sp_repr_set_double_attribute (repr, "sodipodi:ry", ge->ry.computed); sp_repr_set_double_attribute (repr, "sodipodi:start", ge->start); sp_repr_set_double_attribute (repr, "sodipodi:end", ge->end); sp_repr_set_attr (repr, "sodipodi:open", (!ge->closed) ? "true" : NULL); sp_arc_set_elliptical_path_attribute (arc, repr); } else { gdouble dt; dt = fmod (ge->end - ge->start, SP_2PI); if (fabs (dt) < 1e-6) { if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { repr = sp_repr_new ("ellipse"); } sp_repr_set_double_attribute (repr, "cx", ge->cx.computed); sp_repr_set_double_attribute (repr, "cy", ge->cy.computed); sp_repr_set_double_attribute (repr, "rx", ge->rx.computed); sp_repr_set_double_attribute (repr, "ry", ge->ry.computed); } else { if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { repr = sp_repr_new ("path"); } sp_arc_set_elliptical_path_attribute (arc, repr); } } if (((SPObjectClass *) arc_parent_class)->write) ((SPObjectClass *) arc_parent_class)->write (object, repr, flags); return repr; }
void sp_ellipse_position_set (SPEllipse *ellipse, gdouble x, gdouble y, gdouble rx, gdouble ry) { SPGenericEllipse *ge; g_return_if_fail (ellipse != NULL); g_return_if_fail (SP_IS_ELLIPSE (ellipse)); ge = SP_GENERICELLIPSE (ellipse); ge->cx.computed = x; ge->cy.computed = y; ge->rx.computed = rx; ge->ry.computed = ry; sp_object_request_update ((SPObject *) ge, SP_OBJECT_MODIFIED_FLAG); }
void sp_arc_position_set (SPArc *arc, gdouble x, gdouble y, gdouble rx, gdouble ry) { SPGenericEllipse *ge; g_return_if_fail (arc != NULL); g_return_if_fail (SP_IS_ARC (arc)); ge = SP_GENERICELLIPSE (arc); ge->cx.computed = x; ge->cy.computed = y; ge->rx.computed = rx; ge->ry.computed = ry; sp_object_request_update ((SPObject *) arc, SP_OBJECT_MODIFIED_FLAG); }
static SPRepr * sp_circle_write (SPObject *object, SPRepr *repr, guint flags) { SPGenericEllipse *ellipse; ellipse = SP_GENERICELLIPSE (object); if ((flags & SP_OBJECT_WRITE_BUILD) && !repr) { repr = sp_repr_new ("circle"); } sp_repr_set_double_attribute (repr, "cx", ellipse->cx.computed); sp_repr_set_double_attribute (repr, "cy", ellipse->cy.computed); sp_repr_set_double_attribute (repr, "r", ellipse->rx.computed); if (((SPObjectClass *) circle_parent_class)->write) ((SPObjectClass *) circle_parent_class)->write (object, repr, flags); return repr; }
void ArcKnotHolderEntityEnd::knot_set(Geom::Point const &p, Geom::Point const &/*origin*/, guint state) { int snaps = Inkscape::Preferences::get()->getInt("/options/rotationsnapsperpi/value", 12); SPGenericEllipse *arc = SP_GENERICELLIPSE(item); arc->setClosed(sp_genericellipse_side(arc, p) == -1); Geom::Point delta = p - Geom::Point(arc->cx.computed, arc->cy.computed); Geom::Scale sc(arc->rx.computed, arc->ry.computed); arc->end = atan2(delta * sc.inverse()); if ((state & GDK_CONTROL_MASK) && snaps) { arc->end = sp_round(arc->end, M_PI/snaps); } arc->normalize(); arc->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); }
static int sp_genericellipse_snappoints (SPItem *item, NRPointF *p, int size) { SPGenericEllipse *ge; NRMatrixF i2d; int pos; ge = SP_GENERICELLIPSE (item); /* we use corners of item and center of ellipse */ pos = 0; if (((SPItemClass *) ge_parent_class)->snappoints) pos = ((SPItemClass *) ge_parent_class)->snappoints (item, p, size); if (pos < size) { sp_item_i2d_affine (item, &i2d); p[pos].x = NR_MATRIX_DF_TRANSFORM_X (&i2d, ge->cx.computed, ge->cy.computed); p[pos].y = NR_MATRIX_DF_TRANSFORM_Y (&i2d, ge->cx.computed, ge->cy.computed); } return pos; }
static void sp_arc_set (SPObject *object, unsigned int key, const gchar *value) { SPGenericEllipse *ge; SPVersion version; ge = SP_GENERICELLIPSE (object); version = sp_object_get_sodipodi_version (object); if (sp_version_inside_range (version, 0, 0, 0, 25)) { switch (key) { case SP_ATTR_CX: key = SP_ATTR_SODIPODI_CX; break; case SP_ATTR_CY: key = SP_ATTR_SODIPODI_CY; break; case SP_ATTR_RX: key = SP_ATTR_SODIPODI_RX; break; case SP_ATTR_RY: key = SP_ATTR_SODIPODI_RY; break; } } switch (key) { case SP_ATTR_SODIPODI_CX: if (!sp_svg_length_read (value, &ge->cx)) { sp_svg_length_unset (&ge->cx, SP_SVG_UNIT_NONE, 0.0, 0.0); } sp_object_request_update (object, SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_SODIPODI_CY: if (!sp_svg_length_read (value, &ge->cy)) { sp_svg_length_unset (&ge->cy, SP_SVG_UNIT_NONE, 0.0, 0.0); } sp_object_request_update (object, SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_SODIPODI_RX: if (!sp_svg_length_read (value, &ge->rx) || (ge->rx.computed <= 0.0)) { sp_svg_length_unset (&ge->rx, SP_SVG_UNIT_NONE, 0.0, 0.0); } sp_object_request_update (object, SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_SODIPODI_RY: if (!sp_svg_length_read (value, &ge->ry) || (ge->ry.computed <= 0.0)) { sp_svg_length_unset (&ge->ry, SP_SVG_UNIT_NONE, 0.0, 0.0); } sp_object_request_update (object, SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_SODIPODI_START: sp_svg_number_read_d (value, &ge->start); sp_object_request_update (object, SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_SODIPODI_END: sp_svg_number_read_d (value, &ge->end); sp_object_request_update (object, SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_SODIPODI_OPEN: ge->closed = (!value); sp_object_request_update (object, SP_OBJECT_MODIFIED_FLAG); break; default: if (((SPObjectClass *) arc_parent_class)->set) ((SPObjectClass *) arc_parent_class)->set (object, key, value); break; } }