diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/connector-context.cpp | 10 | ||||
| -rw-r--r-- | src/draw-context.cpp | 2 | ||||
| -rw-r--r-- | src/flood-context.cpp | 8 | ||||
| -rw-r--r-- | src/live_effects/lpe-interpolate.cpp | 2 | ||||
| -rw-r--r-- | src/live_effects/lpe-knot.cpp | 2 | ||||
| -rw-r--r-- | src/live_effects/lpe-tangent_to_curve.cpp | 2 | ||||
| -rw-r--r-- | src/object-snapper.cpp | 2 | ||||
| -rw-r--r-- | src/path-chemistry.cpp | 6 | ||||
| -rw-r--r-- | src/sp-conn-end-pair.cpp | 4 | ||||
| -rw-r--r-- | src/sp-item-group.cpp | 2 | ||||
| -rw-r--r-- | src/sp-path.cpp | 73 | ||||
| -rw-r--r-- | src/sp-path.h | 31 | ||||
| -rw-r--r-- | src/sp-shape.cpp | 5 | ||||
| -rw-r--r-- | src/sp-shape.h | 4 | ||||
| -rw-r--r-- | src/splivarot.cpp | 2 | ||||
| -rw-r--r-- | src/ui/tool/path-manipulator.cpp | 4 |
16 files changed, 84 insertions, 75 deletions
diff --git a/src/connector-context.cpp b/src/connector-context.cpp index 7ab617094..395cf04ea 100644 --- a/src/connector-context.cpp +++ b/src/connector-context.cpp @@ -980,7 +980,7 @@ connector_handle_motion_notify(SPConnectorContext *const cc, GdkEventMotion cons Geom::Affine i2d ( (cc->clickeditem)->i2dt_affine() ); Geom::Affine d2i = i2d.inverse(); SPPath *path = SP_PATH(cc->clickeditem); - SPCurve *curve = sp_path_get_curve(path); + SPCurve *curve = path->get_curve(); if (cc->clickedhandle == cc->endpt_handle[0]) { Geom::Point o = cc->endpt_handle[1]->pos; curve->stretch_endpoints(p * d2i, o * d2i); @@ -992,7 +992,7 @@ connector_handle_motion_notify(SPConnectorContext *const cc, GdkEventMotion cons sp_conn_reroute_path_immediate(path); // Copy this to the temporary visible path - cc->red_curve = sp_path_get_curve_for_edit(path); + cc->red_curve = path->get_curve_for_edit(); cc->red_curve->transform(i2d); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(cc->red_bpath), cc->red_curve); @@ -1605,7 +1605,7 @@ endpt_handler(SPKnot */*knot*/, GdkEvent *event, SPConnectorContext *cc) } // Show the red path for dragging. - cc->red_curve = sp_path_get_curve_for_edit(SP_PATH(cc->clickeditem)); + cc->red_curve = SP_PATH(cc->clickeditem)->get_curve_for_edit(); Geom::Affine i2d = (cc->clickeditem)->i2dt_affine(); cc->red_curve->transform(i2d); sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(cc->red_bpath), cc->red_curve); @@ -1764,7 +1764,7 @@ cc_set_active_conn(SPConnectorContext *cc, SPItem *item) { g_assert( SP_IS_PATH(item) ); - const SPCurve *curve = sp_path_get_curve_reference(SP_PATH(item)); + const SPCurve *curve = SP_PATH(item)->get_curve_reference(); Geom::Affine i2dt = item->i2dt_affine(); if (cc->active_conn == item) @@ -1917,7 +1917,7 @@ static bool cc_item_is_shape(SPItem *item) bool cc_item_is_connector(SPItem *item) { if (SP_IS_PATH(item)) { - bool closed = sp_path_get_curve_reference(SP_PATH(item))->is_closed(); + bool closed = SP_PATH(item)->get_curve_reference()->is_closed(); if (SP_PATH(item)->connEndPair.isAutoRoutingConn() && !closed) { // To be considered a connector, an object must be a non-closed // path that is marked with a "inkscape:connector-type" attribute. diff --git a/src/draw-context.cpp b/src/draw-context.cpp index 29e38adc5..083587625 100644 --- a/src/draw-context.cpp +++ b/src/draw-context.cpp @@ -451,7 +451,7 @@ spdc_attach_selection(SPDrawContext *dc, Inkscape::Selection */*sel*/) dc->white_item = item; /* Curve list */ /* We keep it in desktop coordinates to eliminate calculation errors */ - SPCurve *norm = sp_path_get_curve_for_edit (SP_PATH(item)); + SPCurve *norm = SP_PATH(item)->get_curve_for_edit(); norm->transform((dc->white_item)->i2dt_affine()); g_return_if_fail( norm != NULL ); dc->white_curves = g_slist_reverse(norm->split()); diff --git a/src/flood-context.cpp b/src/flood-context.cpp index 9c527613e..4b16a5e10 100644 --- a/src/flood-context.cpp +++ b/src/flood-context.cpp @@ -511,11 +511,15 @@ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *deskto pathRepr->setPosition(-1); if (union_with_selection) { - desktop->messageStack()->flashF(Inkscape::WARNING_MESSAGE, ngettext("Area filled, path with <b>%d</b> node created and unioned with selection.","Area filled, path with <b>%d</b> nodes created and unioned with selection.",sp_nodes_in_path(SP_PATH(reprobj))), sp_nodes_in_path(SP_PATH(reprobj))); + desktop->messageStack()->flashF( Inkscape::WARNING_MESSAGE, + ngettext("Area filled, path with <b>%d</b> node created and unioned with selection.","Area filled, path with <b>%d</b> nodes created and unioned with selection.", + SP_PATH(reprobj)->nodesInPath()), SP_PATH(reprobj)->nodesInPath() ); selection->add(reprobj); sp_selected_path_union_skip_undo(desktop); } else { - desktop->messageStack()->flashF(Inkscape::WARNING_MESSAGE, ngettext("Area filled, path with <b>%d</b> node created.","Area filled, path with <b>%d</b> nodes created.",sp_nodes_in_path(SP_PATH(reprobj))), sp_nodes_in_path(SP_PATH(reprobj))); + desktop->messageStack()->flashF( Inkscape::WARNING_MESSAGE, + ngettext("Area filled, path with <b>%d</b> node created.","Area filled, path with <b>%d</b> nodes created.", + SP_PATH(reprobj)->nodesInPath()), SP_PATH(reprobj)->nodesInPath() ); selection->set(reprobj); } diff --git a/src/live_effects/lpe-interpolate.cpp b/src/live_effects/lpe-interpolate.cpp index 621823546..83c41d3e9 100644 --- a/src/live_effects/lpe-interpolate.cpp +++ b/src/live_effects/lpe-interpolate.cpp @@ -105,7 +105,7 @@ LPEInterpolate::resetDefaults(SPItem * item) if (!SP_IS_PATH(item)) return; - SPCurve const *crv = sp_path_get_curve_reference(SP_PATH(item)); + SPCurve const *crv = SP_PATH(item)->get_curve_reference(); Geom::PathVector const &pathv = crv->get_pathvector(); if ( (pathv.size() < 2) ) return; diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index 9decdea9b..58dc4bd75 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -509,7 +509,7 @@ void collectPathsAndWidths (SPLPEItem const *lpeitem, std::vector<Geom::Path> &p else if (SP_IS_SHAPE(lpeitem)) { SPCurve * c = NULL; if (SP_IS_PATH(lpeitem)) { - c = sp_path_get_curve_for_edit(SP_PATH(lpeitem)); + c = SP_PATH(lpeitem)->get_curve_for_edit(); } else { c = SP_SHAPE(lpeitem)->getCurve(); } diff --git a/src/live_effects/lpe-tangent_to_curve.cpp b/src/live_effects/lpe-tangent_to_curve.cpp index b43fd8b36..a2d3cd061 100644 --- a/src/live_effects/lpe-tangent_to_curve.cpp +++ b/src/live_effects/lpe-tangent_to_curve.cpp @@ -119,7 +119,7 @@ KnotHolderEntityAttachPt::knot_set(Geom::Point const &p, Geom::Point const &/*or Geom::Point const s = snap_knot_position(p); // FIXME: There must be a better way of converting the path's SPCurve* to pwd2. - SPCurve *curve = sp_path_get_curve_for_edit (SP_PATH(item)); + SPCurve *curve = SP_PATH(item)->get_curve_for_edit(); Geom::PathVector pathv = curve->get_pathvector(); Piecewise<D2<SBasis> > pwd2; for (unsigned int i=0; i < pathv.size(); i++) { diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index 3b1b327ee..1a4d79a7d 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -412,7 +412,7 @@ void Inkscape::ObjectSnapper::_collectPaths(Geom::Point /*p*/, // This also leads to a lag of approx. 500 msec (in my lousy test set-up). bool very_complex_path = false; if (SP_IS_PATH(root_item)) { - very_complex_path = sp_nodes_in_path(SP_PATH(root_item)) > 500; + very_complex_path = SP_PATH(root_item)->nodesInPath() > 500; } if (!very_complex_path && root_item && _snapmanager->snapprefs.isTargetSnappable(SNAPTARGET_PATH, SNAPTARGET_PATH_INTERSECTION)) { diff --git a/src/path-chemistry.cpp b/src/path-chemistry.cpp index b2680acce..3714f3531 100644 --- a/src/path-chemistry.cpp +++ b/src/path-chemistry.cpp @@ -104,7 +104,7 @@ sp_selected_path_combine(SPDesktop *desktop) did = true; } - SPCurve *c = sp_path_get_curve_for_edit(SP_PATH(item)); + SPCurve *c = SP_PATH(item)->get_curve_for_edit(); if (first == NULL) { // this is the topmost path first = item; parent = first->getRepr()->parent(); @@ -211,7 +211,7 @@ sp_selected_path_break_apart(SPDesktop *desktop) SPPath *path = SP_PATH(item); - SPCurve *curve = sp_path_get_curve_for_edit(path); + SPCurve *curve = path->get_curve_for_edit(); if (curve == NULL) { continue; } @@ -617,7 +617,7 @@ sp_selected_path_reverse(SPDesktop *desktop) did = true; SPPath *path = SP_PATH(i->data); - SPCurve *rcurve = sp_path_get_curve_reference(path)->create_reverse(); + SPCurve *rcurve = path->get_curve_reference()->create_reverse(); gchar *str = sp_svg_write_path(rcurve->get_pathvector()); if ( sp_lpe_item_has_path_effect_recursive(SP_LPE_ITEM(path)) ) { diff --git a/src/sp-conn-end-pair.cpp b/src/sp-conn-end-pair.cpp index fa01dc2d8..17e9e7397 100644 --- a/src/sp-conn-end-pair.cpp +++ b/src/sp-conn-end-pair.cpp @@ -214,7 +214,7 @@ SPConnEndPair::getAttachedItems(SPItem *h2attItem[2]) const { void SPConnEndPair::getEndpoints(Geom::Point endPts[]) const { - SPCurve const *curve = sp_path_get_curve_reference(_path); + SPCurve const *curve = _path->get_curve_reference(); SPItem *h2attItem[2] = {0}; getAttachedItems(h2attItem); Geom::Affine i2d = _path->i2doc_affine(); @@ -403,7 +403,7 @@ SPConnEndPair::reroutePathFromLibavoid(void) return false; } - SPCurve *curve = sp_path_get_curve(_path); + SPCurve *curve = _path->get_curve(); recreateCurve( curve, _connRef, _connCurvature ); diff --git a/src/sp-item-group.cpp b/src/sp-item-group.cpp index a733097d5..476564b8a 100644 --- a/src/sp-item-group.cpp +++ b/src/sp-item-group.cpp @@ -845,7 +845,7 @@ sp_group_perform_patheffect(SPGroup *group, SPGroup *topgroup, bool write) } else if (SP_IS_SHAPE(subitem)) { SPCurve * c = NULL; if (SP_IS_PATH(subitem)) { - c = sp_path_get_original_curve(SP_PATH(subitem)); + c = SP_PATH(subitem)->get_original_curve(); } else { c = SP_SHAPE(subitem)->getCurve(); } diff --git a/src/sp-path.cpp b/src/sp-path.cpp index 2cf09c4a1..3760ccd78 100644 --- a/src/sp-path.cpp +++ b/src/sp-path.cpp @@ -5,10 +5,12 @@ * Lauris Kaplinski <lauris@kaplinski.com> * David Turner <novalis@gnu.org> * Abhishek Sharma + * Johan Engelen * * Copyright (C) 2004 David Turner * Copyright (C) 1999-2002 Lauris Kaplinski * Copyright (C) 2000-2001 Ximian, Inc. + * Copyright (C) 1999-2012 Authors * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -122,19 +124,15 @@ sp_path_class_init(SPPathClass * klass) } -gint -sp_nodes_in_path(SPPath *path) +gint SPPath::nodesInPath() const { - SPCurve *curve = SP_SHAPE(path)->curve; - if (!curve) - return 0; - return curve->nodes_in_path(); + return curve ? curve->nodes_in_path() : 0; } static gchar * sp_path_description(SPItem * item) { - int count = sp_nodes_in_path(SP_PATH(item)); + int count = SP_PATH(item)->nodesInPath(); if (SP_IS_LPE_ITEM(item) && sp_lpe_item_has_path_effect(SP_LPE_ITEM(item))) { Glib::ustring s; @@ -258,11 +256,11 @@ sp_path_set(SPObject *object, unsigned int key, gchar const *value) Geom::PathVector pv = sp_svg_read_pathv(value); SPCurve *curve = new SPCurve(pv); if (curve) { - sp_path_set_original_curve(path, curve, TRUE, true); + path->set_original_curve(curve, TRUE, true); curve->unref(); } } else { - sp_path_set_original_curve(path, NULL, TRUE, true); + path->set_original_curve(NULL, TRUE, true); } object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); break; @@ -456,31 +454,29 @@ g_message("sp_path_update_patheffect writes 'd' attribute"); * and also triggers a request to update the display. Does not write * result to XML when write=false. */ -void -sp_path_set_original_curve (SPPath *path, SPCurve *curve, unsigned int owner, bool write) +void SPPath::set_original_curve (SPCurve *new_curve, unsigned int owner, bool write) { - if (path->curve_before_lpe) { - path->curve_before_lpe = path->curve_before_lpe->unref(); + if (curve_before_lpe) { + curve_before_lpe = curve_before_lpe->unref(); } - if (curve) { + if (new_curve) { if (owner) { - path->curve_before_lpe = curve->ref(); + curve_before_lpe = new_curve->ref(); } else { - path->curve_before_lpe = curve->copy(); + curve_before_lpe = new_curve->copy(); } } - sp_lpe_item_update_patheffect(path, true, write); - path->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); + sp_lpe_item_update_patheffect(this, true, write); + requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG); } /** * Return duplicate of curve_before_lpe (if any exists) or NULL if there is no curve */ -SPCurve * -sp_path_get_original_curve (SPPath *path) +SPCurve * SPPath::get_original_curve () const { - if (path->curve_before_lpe) { - return path->curve_before_lpe->copy(); + if (curve_before_lpe) { + return curve_before_lpe->copy(); } return NULL; } @@ -489,16 +485,15 @@ sp_path_get_original_curve (SPPath *path) * Return duplicate of edittable curve which is curve_before_lpe if it exists or * shape->curve if not. */ -SPCurve* -sp_path_get_curve_for_edit (SPPath *path) +SPCurve* SPPath::get_curve_for_edit () const { - if (!SP_IS_PATH(path)) { + if (!SP_IS_PATH(this)) { return NULL; } - if (path->curve_before_lpe && sp_lpe_item_has_path_effect_recursive(SP_LPE_ITEM(path))) { - return sp_path_get_original_curve(path); + if (curve_before_lpe && sp_lpe_item_has_path_effect_recursive(SP_LPE_ITEM(this))) { + return get_original_curve(); } else { - return path->getCurve(); + return getCurve(); } } @@ -506,16 +501,15 @@ sp_path_get_curve_for_edit (SPPath *path) * Returns \c curve_before_lpe if it is not NULL and a valid LPE is applied or * \c curve if not. */ -const SPCurve* -sp_path_get_curve_reference (SPPath *path) +const SPCurve* SPPath::get_curve_reference () const { - if (!SP_IS_PATH(path)) { + if (!SP_IS_PATH(this)) { return NULL; } - if (path->curve_before_lpe && sp_lpe_item_has_path_effect_recursive(SP_LPE_ITEM(path))) { - return path->curve_before_lpe; + if (curve_before_lpe && sp_lpe_item_has_path_effect_recursive(SP_LPE_ITEM(this))) { + return curve_before_lpe; } else { - return path->curve; + return curve; } } @@ -523,16 +517,15 @@ sp_path_get_curve_reference (SPPath *path) * Returns \c curve_before_lpe if it is not NULL and a valid LPE is applied or \c curve if not. * \todo should only be available to class friends! */ -SPCurve* -sp_path_get_curve (SPPath *path) +SPCurve* SPPath::get_curve () { - if (!SP_IS_PATH(path)) { + if (!SP_IS_PATH(this)) { return NULL; } - if (path->curve_before_lpe && sp_lpe_item_has_path_effect_recursive(SP_LPE_ITEM(path))) { - return path->curve_before_lpe; + if (curve_before_lpe && sp_lpe_item_has_path_effect_recursive(SP_LPE_ITEM(this))) { + return curve_before_lpe; } else { - return path->curve; + return curve; } } diff --git a/src/sp-path.h b/src/sp-path.h index 3d66794d1..5dd79212c 100644 --- a/src/sp-path.h +++ b/src/sp-path.h @@ -6,9 +6,12 @@ * * Authors: * Lauris Kaplinski <lauris@kaplinski.com> + * Ximian, Inc. + * Johan Engelen * * Copyright (C) 1999-2002 Lauris Kaplinski * Copyright (C) 2000-2001 Ximian, Inc. + * Copyright (C) 1999-2012 Authors * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -16,13 +19,30 @@ #include "sp-shape.h" #include "sp-conn-end-pair.h" -struct SPCurve; +class SPCurve; #define SP_TYPE_PATH (sp_path_get_type ()) #define SP_PATH(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), SP_TYPE_PATH, SPPath)) #define SP_IS_PATH(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), SP_TYPE_PATH)) -struct SPPath : public SPShape { +/** + * SVG <path> implementation + */ +class SPPath : public SPShape { +public: + gint nodesInPath() const; + + // still in lowercase because the names should be clearer on whether curve, curve->copy or curve-ref is returned. + void set_original_curve (SPCurve *curve, unsigned int owner, bool write); + SPCurve* get_original_curve () const; + SPCurve* get_curve_for_edit () const; + const SPCurve* get_curve_reference() const; + +public: // should be made protected + SPCurve* get_curve(); + friend class SPConnEndPair; + +public: SPConnEndPair connEndPair; }; @@ -31,13 +51,6 @@ struct SPPathClass { }; GType sp_path_get_type (void); -gint sp_nodes_in_path(SPPath *path); - -void sp_path_set_original_curve (SPPath *path, SPCurve *curve, unsigned int owner, bool write); -SPCurve* sp_path_get_original_curve (SPPath *path); -SPCurve* sp_path_get_curve_for_edit (SPPath *path); -const SPCurve* sp_path_get_curve_reference (SPPath *path); -SPCurve* sp_path_get_curve (SPPath *path); // should only be available for friends and not public! #endif // SEEN_SP_PATH_H diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp index 5fd33bef7..b946e52ce 100644 --- a/src/sp-shape.cpp +++ b/src/sp-shape.cpp @@ -1065,7 +1065,7 @@ SPShape::setCurveBeforeLPE (SPCurve *curve) /** * Return duplicate of curve (if any exists) or NULL if there is no curve */ -SPCurve * SPShape::getCurve() +SPCurve * SPShape::getCurve() const { if (this->curve) { return this->curve->copy(); @@ -1076,8 +1076,7 @@ SPCurve * SPShape::getCurve() /** * Return duplicate of curve *before* LPE (if any exists) or NULL if there is no curve */ -SPCurve * -SPShape::getCurveBeforeLPE() +SPCurve * SPShape::getCurveBeforeLPE() const { if (sp_lpe_item_has_path_effect(SP_LPE_ITEM(this))) { if (this->curve_before_lpe) { diff --git a/src/sp-shape.h b/src/sp-shape.h index bb7b6cf02..36fcef8e1 100644 --- a/src/sp-shape.h +++ b/src/sp-shape.h @@ -49,8 +49,8 @@ public: static GType getType (void); void setShape (); - SPCurve * getCurve (); - SPCurve * getCurveBeforeLPE (); + SPCurve * getCurve () const; + SPCurve * getCurveBeforeLPE () const; void setCurve (SPCurve *curve, unsigned int owner); void setCurveInsync (SPCurve *curve, unsigned int owner); void setCurveBeforeLPE (SPCurve *curve); diff --git a/src/splivarot.cpp b/src/splivarot.cpp index b46963b2f..87a1563db 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -2144,7 +2144,7 @@ SPCurve* curve_for_item(SPItem *item) SPCurve *curve = NULL; if (SP_IS_SHAPE(item)) { if (SP_IS_PATH(item)) { - curve = sp_path_get_curve_for_edit(SP_PATH(item)); + curve = SP_PATH(item)->get_curve_for_edit(); } else { curve = SP_SHAPE(item)->getCurve(); } diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 826c3d818..c2eca5f75 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -1295,7 +1295,7 @@ void PathManipulator::_getGeometry() } } else { _spcurve->unref(); - _spcurve = sp_path_get_curve_for_edit(_path); + _spcurve = _path->get_curve_for_edit(); } } @@ -1318,7 +1318,7 @@ void PathManipulator::_setGeometry() } else { //XML Tree being used here directly while it shouldn't be. if (_path->getRepr()->attribute("inkscape:original-d")) - sp_path_set_original_curve(_path, _spcurve, false, false); + _path->set_original_curve(_spcurve, false, false); else SP_SHAPE(_path)->setCurve(_spcurve, false); } |
