/** * Sets a value in the path object given by 'key', to 'value'. This is used * for setting attributes and markers on a path object. */ static void sp_path_set (SPObject *object, unsigned int key, const gchar *value) { SPPath *path; int marker_type; path = (SPPath *) object; switch (key) { case SP_ATTR_D: if (value) { ArtBpath *bpath; SPCurve *curve; bpath = sp_svg_read_path (value); curve = sp_curve_new_from_bpath (bpath); sp_shape_set_curve ((SPShape *) path, curve, TRUE); sp_curve_unref (curve); } else { sp_shape_set_curve ((SPShape *) path, NULL, TRUE); } break; case SP_PROP_MARKER: case SP_PROP_MARKER_START: case SP_PROP_MARKER_MID: case SP_PROP_MARKER_END: sp_shape_set_marker (object, key, value); break; default: if (((SPObjectClass *) parent_class)->set) { ((SPObjectClass *) parent_class)->set (object, key, value); } break; } }
void SPShape::build(SPDocument *document, Inkscape::XML::Node *repr) { SPLPEItem::build(document, repr); for (int i = 0 ; i < SP_MARKER_LOC_QTY ; i++) { sp_shape_set_marker (this, i, this->style->marker_ptrs[i]->value); } }
Inkscape::DrawingItem* SPShape::show(Inkscape::Drawing &drawing, unsigned int /*key*/, unsigned int /*flags*/) { Inkscape::DrawingShape *s = new Inkscape::DrawingShape(drawing); s->setStyle(this->style); s->setPath(this->_curve); /* This stanza checks that an object's marker style agrees with * the marker objects it has allocated. sp_shape_set_marker ensures * that the appropriate marker objects are present (or absent) to * match the style. */ for (int i = 0 ; i < SP_MARKER_LOC_QTY ; i++) { sp_shape_set_marker (this, i, this->style->marker_ptrs[i]->value); } if (this->hasMarkers ()) { /* provide key and dimension the marker views */ if (!s->key()) { s->setKey(SPItem::display_key_new (SP_MARKER_LOC_QTY)); } for (int i = 0; i < SP_MARKER_LOC_QTY; i++) { if (_marker[i]) { sp_marker_show_dimension(_marker[i], s->key() + i, numberOfMarkers(i)); } } /* Update marker views */ sp_shape_update_marker_view (this, s); } return s; }
void SPShape::update(SPCtx* ctx, guint flags) { SPLPEItem::update(ctx, flags); /* This stanza checks that an object's marker style agrees with * the marker objects it has allocated. sp_shape_set_marker ensures * that the appropriate marker objects are present (or absent) to * match the style. */ for (int i = 0 ; i < SP_MARKER_LOC_QTY ; i++) { sp_shape_set_marker (this, i, this->style->marker_ptrs[i]->value); } if (flags & (SP_OBJECT_STYLE_MODIFIED_FLAG | SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) { if (this->style->stroke_width.unit == SP_CSS_UNIT_PERCENT) { SPItemCtx *ictx = (SPItemCtx *) ctx; double const aw = 1.0 / ictx->i2vp.descrim(); this->style->stroke_width.computed = this->style->stroke_width.value * aw; for (SPItemView *v = ((SPItem *) (this))->display; v != NULL; v = v->next) { Inkscape::DrawingShape *sh = dynamic_cast<Inkscape::DrawingShape *>(v->arenaitem); sh->setStyle(this->style); } } } if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_PARENT_MODIFIED_FLAG)) { /* This is suboptimal, because changing parent style schedules recalculation */ /* But on the other hand - how can we know that parent does not tie style and transform */ for (SPItemView *v = this->display; v != NULL; v = v->next) { Inkscape::DrawingShape *sh = dynamic_cast<Inkscape::DrawingShape *>(v->arenaitem); if (flags & SP_OBJECT_MODIFIED_FLAG) { sh->setPath(this->_curve); } } } if (this->hasMarkers ()) { /* Dimension marker views */ for (SPItemView *v = this->display; v != NULL; v = v->next) { if (!v->arenaitem->key()) { v->arenaitem->setKey(SPItem::display_key_new (SP_MARKER_LOC_QTY)); } for (int i = 0 ; i < SP_MARKER_LOC_QTY ; i++) { if (_marker[i]) { sp_marker_show_dimension(_marker[i], v->arenaitem->key() + i, numberOfMarkers(i)); } } } /* Update marker views */ for (SPItemView *v = this->display; v != NULL; v = v->next) { sp_shape_update_marker_view (this, v->arenaitem); } } }
/** * Sets a value in the path object given by 'key', to 'value'. This is used * for setting attributes and markers on a path object. */ static void sp_path_set(SPObject *object, unsigned int key, gchar const *value) { SPPath *path = (SPPath *) object; switch (key) { case SP_ATTR_INKSCAPE_ORIGINAL_D: if (value) { Geom::PathVector pv = sp_svg_read_pathv(value); SPCurve *curve = new SPCurve(pv); if (curve) { path->set_original_curve(curve, TRUE, true); curve->unref(); } } else { path->set_original_curve(NULL, TRUE, true); } object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_D: if (value) { Geom::PathVector pv = sp_svg_read_pathv(value); SPCurve *curve = new SPCurve(pv); if (curve) { ((SPShape *) path)->setCurve(curve, TRUE); curve->unref(); } } else { ((SPShape *) path)->setCurve(NULL, TRUE); } object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); break; case SP_PROP_MARKER: case SP_PROP_MARKER_START: case SP_PROP_MARKER_MID: case SP_PROP_MARKER_END: sp_shape_set_marker(object, key, value); object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); break; case SP_ATTR_CONNECTOR_TYPE: case SP_ATTR_CONNECTOR_CURVATURE: case SP_ATTR_CONNECTION_START: case SP_ATTR_CONNECTION_END: case SP_ATTR_CONNECTION_START_POINT: case SP_ATTR_CONNECTION_END_POINT: path->connEndPair.setAttr(key, value); break; default: if (((SPObjectClass *) parent_class)->set) { ((SPObjectClass *) parent_class)->set(object, key, value); } break; } }