diff options
| author | Johan B. C. Engelen <jbc.engelen@swissonline.ch> | 2008-07-04 23:36:25 +0000 |
|---|---|---|
| committer | johanengelen <johanengelen@users.sourceforge.net> | 2008-07-04 23:36:25 +0000 |
| commit | be2f7a2520b6aceca598afbaa16ed0b5971b48c0 (patch) | |
| tree | c31cbb674aaa46cb589be00c7f0062aa09faffbd /src | |
| parent | 2geomify calculation of number of markers on a path (diff) | |
| download | inkscape-be2f7a2520b6aceca598afbaa16ed0b5971b48c0.tar.gz inkscape-be2f7a2520b6aceca598afbaa16ed0b5971b48c0.zip | |
create pathvector_for_curve method.
(bzr r6160)
Diffstat (limited to 'src')
| -rw-r--r-- | src/object-snapper.cpp | 2 | ||||
| -rw-r--r-- | src/splivarot.cpp | 23 | ||||
| -rw-r--r-- | src/splivarot.h | 2 |
3 files changed, 25 insertions, 2 deletions
diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index 88e709b7f..ef6c5fce2 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -320,7 +320,7 @@ void Inkscape::ObjectSnapper::_collectPaths(Inkscape::Snapper::PointType const & if (!very_lenghty_prose && !very_complex_path) { SPCurve *curve = curve_for_item(root_item); if (curve) { - NArtBpath *bpath = bpath_for_curve(root_item, curve, true, true); + NArtBpath *bpath = bpath_for_curve(root_item, curve, true, true); // perhaps for speed, get a reference to the Geom::pathvector, and store the transformation besides it. apply transformation on the snap points, instead of generating whole new path _bpaths_to_snap_to->push_back(bpath); // we will get a dupe of the path, which must be freed at some point curve->unref(); } diff --git a/src/splivarot.cpp b/src/splivarot.cpp index 944c15f84..88daaa666 100644 --- a/src/splivarot.cpp +++ b/src/splivarot.cpp @@ -48,7 +48,7 @@ #include "libnr/nr-path.h" #include "xml/repr.h" #include "xml/repr-sorting.h" - +#include <2geom/pathvector.h> #include <libnr/nr-matrix-fns.h> #include <libnr/nr-matrix-ops.h> #include <libnr/nr-matrix-translate-ops.h> @@ -1764,6 +1764,27 @@ bpath_for_curve(SPItem *item, SPCurve *curve, bool doTransformation, bool transf return new_bpath; } +/* + * NOTE: Returns empty pathvector if curve == NULL + * TODO: see if calling this method can be optimized. All the pathvector copying might be slow. + */ +Geom::PathVector +pathvector_for_curve(SPItem *item, SPCurve *curve, bool doTransformation, bool transformFull) +{ + if (curve == NULL) + return Geom::PathVector(); + + if (doTransformation) { + if (transformFull) { + return (curve->get_pathvector()) * sp_item_i2doc_affine(item); + } else { + return (curve->get_pathvector()) * to_2geom(item->transform); + } + } else { + return curve->get_pathvector(); + } +} + SPCurve* curve_for_item(SPItem *item) { if (!item) diff --git a/src/splivarot.h b/src/splivarot.h index 2ac47135a..6e59d2cc5 100644 --- a/src/splivarot.h +++ b/src/splivarot.h @@ -8,6 +8,7 @@ */ #include "livarot/Path.h" +#include <2geom/forward.h> // boolean operations // work on the current selection @@ -45,6 +46,7 @@ void sp_selected_path_simplify (); Path *Path_for_item(SPItem *item, bool doTransformation, bool transformFull = true); NArtBpath *bpath_for_curve(SPItem *item, SPCurve *curve, bool doTransformation, bool transformFull); +Geom::PathVector pathvector_for_curve(SPItem *item, SPCurve *curve, bool doTransformation, bool transformFull); SPCurve *curve_for_item(SPItem *item); NR::Maybe<Path::cut_position> get_nearest_position_on_Path(Path *path, NR::Point p, unsigned seg = 0); NR::Point get_point_on_Path(Path *path, int piece, double t); |
