sp-path.cpp revision 1a32c2168b3c9c2150ffe55b7ec8e2c52805fb3a
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * SVG <path> implementation
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Authors:
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Lauris Kaplinski <lauris@kaplinski.com>
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * David Turner <novalis@gnu.org>
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Copyright (C) 2004 David Turner
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Copyright (C) 1999-2002 Lauris Kaplinski
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Copyright (C) 2000-2001 Ximian, Inc.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Released under GNU GPL, read the file 'COPYING' for more information
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwstatic void sp_path_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwstatic void sp_path_set(SPObject *object, unsigned key, gchar const *value);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwstatic Inkscape::XML::Node *sp_path_write(SPObject *object, Inkscape::XML::Document *doc, Inkscape::XML::Node *repr, guint flags);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwstatic NR::Matrix sp_path_set_transform(SPItem *item, NR::Matrix const &xform);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwstatic void sp_path_update(SPObject *object, SPCtx *ctx, guint flags);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwstatic void sp_path_update_patheffect(SPLPEItem *lpeitem, bool write);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Gets the GType object for SPPathClass
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw type = g_type_register_static(SP_TYPE_SHAPE, "SPPath", &info, (GTypeFlags)0);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Does the object-oriented work of initializing the class structure
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * including parent class, and registers function pointers for
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * the functions build, set, write, and set_transform.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwstatic void
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw SPObjectClass *sp_object_class = (SPObjectClass *) klass;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw SPLPEItemClass *lpe_item_class = (SPLPEItemClass *) klass;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw parent_class = (SPShapeClass *)g_type_class_peek_parent(klass);
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw item_class->convert_to_guides = sp_path_convert_to_guides;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw lpe_item_class->update_patheffect = sp_path_update_patheffect;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return g_strdup_printf(ngettext("<b>Path</b> (%i node, path effect)",
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw return g_strdup_printf(ngettext("<b>Path</b> (%i node)",
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwstatic void
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross if (!curve) return;
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross std::list<std::pair<Geom::Point, Geom::Point> > pts;
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw Geom::Matrix const i2d (sp_item_i2d_affine(SP_ITEM(path)));
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw for(Geom::PathVector::const_iterator pit = pv.begin(); pit != pv.end(); ++pit) {
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross for(Geom::Path::const_iterator cit = pit->begin(); cit != pit->end_default(); ++cit) {
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross // only add curves for straight line segments
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross if( dynamic_cast<Geom::LineSegment const *>(&*cit) ||
a90cf9f29973990687fa61de9f1f6ea22e924e40Gordon Ross dynamic_cast<Geom::HLineSegment const *>(&*cit) ||
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw pts.push_back(std::make_pair(cit->initialPoint() * i2d, cit->finalPoint() * i2d));
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Initializes an SPPath.
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwstatic void
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwstatic void
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * Given a repr, this sets the data items in the path object such as
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw * fill & style attributes, markers, and CSS properties.
dc20a3024900c47dd2ee44b9707e6df38f7d62a5asstatic void
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amwsp_path_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr)
da6c28aaf62fa55f0fdb8004aa40f88f23bf53f0amw /* Are these calls actually necessary? */
if (d == NULL) {
switch (key) {
if (value) {
if (curve) {
case SP_ATTR_D:
if (value) {
if (curve) {
case SP_PROP_MARKER:
case SP_PROP_MARKER_START:
case SP_PROP_MARKER_MID:
case SP_PROP_MARKER_END:
case SP_ATTR_CONNECTOR_TYPE:
case SP_ATTR_CONNECTION_START:
case SP_ATTR_CONNECTION_END:
sp_path_write(SPObject *object, Inkscape::XML::Document *xml_doc, Inkscape::XML::Node *repr, guint flags)
return repr;
if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
flags &= ~SP_OBJECT_USER_MODIFIED_FLAG_B; // since we change the description, it's not a "just translation" anymore
if (write) {
if (curve) {
if (owner) {
SPCurve *
return NULL;
const SPCurve*
void freehand_create_single_dot(SPEventContext *ec, NR::Point const &pt, char const *tool, guint event_state) {
if (style_str) {
str = g_strdup_printf("fill:#%06x;stroke:none;", sp_desktop_get_color_tool(desktop, tool, false) >> 8);