summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7cc06cc)
raw | patch | inline | side by side (parent: 7cc06cc)
author | johanengelen <johanengelen@users.sourceforge.net> | |
Thu, 26 Jun 2008 22:57:43 +0000 (22:57 +0000) | ||
committer | johanengelen <johanengelen@users.sourceforge.net> | |
Thu, 26 Jun 2008 22:57:43 +0000 (22:57 +0000) |
src/livarot/Path.h | patch | blob | history | |
src/livarot/PathCutting.cpp | patch | blob | history | |
src/nodepath.cpp | patch | blob | history | |
src/sp-offset.cpp | patch | blob | history |
diff --git a/src/livarot/Path.h b/src/livarot/Path.h
index d0bd2e9dd06852437c72d82193bc8755d313fa1a..adc26c169e425447e7254b44229980fc43e19ec3 100644 (file)
--- a/src/livarot/Path.h
+++ b/src/livarot/Path.h
//utilitaire pour inkscape
void LoadPath(Geom::Path const &path, Geom::Matrix const &tr, bool doTransformation, bool append = false);
void LoadPathVector(Geom::PathVector const &pv, Geom::Matrix const &tr, bool doTransformation);
+ void LoadPathVector(Geom::PathVector const &pv);
void* MakeArtBPath();
void Transform(const NR::Matrix &trans);
index c67fc9c97436752d98e72f51801ad239da272382..2987536c3e9ee1961146ec79b7ee9aa6eaac1d84 100644 (file)
if (path.empty())
return;
+ // TODO: this can be optimized by not generating a new path here, but doing the transform in AddCurve
+ // directly on the curve parameters
Geom::Path const pathtr = doTransformation ? path * tr : path;
MoveTo( from_2geom(pathtr.initialPoint()) );
@@ -465,6 +467,11 @@ void Path::LoadPath(Geom::Path const &path, Geom::Matrix const &tr, bool doTran
}
}
+void Path::LoadPathVector(Geom::PathVector const &pv)
+{
+ LoadPathVector(pv, Geom::Matrix(), false);
+}
+
void Path::LoadPathVector(Geom::PathVector const &pv, Geom::Matrix const &tr, bool doTransformation)
{
SetBackData (false);
diff --git a/src/nodepath.cpp b/src/nodepath.cpp
index f4be1c30c71dd7a9fcb2f738712e442374047613..b712539ab767f78f872a3fb550c54095ae7f1f9f 100644 (file)
--- a/src/nodepath.cpp
+++ b/src/nodepath.cpp
if (np && np->livarot_path == NULL) {
SPCurve *curve = create_curve(np);
np->livarot_path = new Path;
- np->livarot_path->LoadPathVector(curve->get_pathvector(), Geom::Matrix(), false);
+ np->livarot_path->LoadPathVector(curve->get_pathvector());
if (np->livarot_path)
np->livarot_path->ConvertWithBackData(0.01);
diff --git a/src/sp-offset.cpp b/src/sp-offset.cpp
index c11324ec5f9c23da60f0d18e3c579512acef9070..de4933821c3ed46f65e596b5da6950c24476cc92 100644 (file)
--- a/src/sp-offset.cpp
+++ b/src/sp-offset.cpp
static void sp_offset_snappoints(SPItem const *item, SnapPointsIter p);
static void sp_offset_set_shape (SPShape * shape);
-Path *bpath_to_liv_path (NArtBpath const * bpath);
-
static void refresh_offset_source(SPOffset* offset);
static void sp_offset_start_listening(SPOffset *offset,SPObject* to);
offset->original = strdup (value);
Geom::PathVector pv = sp_svg_read_pathv(offset->original);
- SPCurve *curve = new SPCurve(pv); // fixme: translate this: curve se chargera de detruire bpath
- g_assert (curve != NULL);
- offset->originalPath = bpath_to_liv_path (SP_CURVE_BPATH(curve));
- curve->unref();
+ offset->originalPath = new Path;
+ reinterpret_cast<Path *>(offset->originalPath)->LoadPathVector(pv);
offset->knotSet = false;
if ( offset->isUpdating == false ) object->requestDisplayUpdate(SP_OBJECT_MODIFIED_FLAG);
}
}
-/**
- * Converts an NArtBpath (like the one stored in a SPCurve) into a
- * livarot Path. Duplicate of splivarot.
- */
-Path *
-bpath_to_liv_path(NArtBpath const *bpath)
-{
- if (bpath == NULL)
- return NULL;
-
- Path *dest = new Path;
- dest->SetBackData (false);
- {
- int i;
- bool closed = false;
- float lastX = 0.0;
- float lastY = 0.0;
-
- for (i = 0; bpath[i].code != NR_END; i++)
- {
- switch (bpath[i].code)
- {
- case NR_LINETO:
- lastX = bpath[i].x3;
- lastY = bpath[i].y3;
- {
- NR::Point tmp(lastX,lastY);
- dest->LineTo (tmp);
- }
- break;
-
- case NR_CURVETO:
- {
- NR::Point tmp(bpath[i].x3, bpath[i].y3);
- NR::Point tms;
- tms[0]=3 * (bpath[i].x1 - lastX);
- tms[1]=3 * (bpath[i].y1 - lastY);
- NR::Point tme;
- tme[0]=3 * (bpath[i].x3 - bpath[i].x2);
- tme[1]= 3 * (bpath[i].y3 - bpath[i].y2);
- dest->CubicTo (tmp,tms,tme);
- }
- lastX = bpath[i].x3;
- lastY = bpath[i].y3;
- break;
-
- case NR_MOVETO_OPEN:
- case NR_MOVETO:
- if (closed)
- dest->Close ();
- closed = (bpath[i].code == NR_MOVETO);
- lastX = bpath[i].x3;
- lastY = bpath[i].y3;
- {
- NR::Point tmp(lastX,lastY);
- dest->MoveTo(tmp);
- }
- break;
- default:
- break;
- }
- }
- if (closed)
- dest->Close ();
- }
-
- return dest;
-}
-
/**
* Compute and set shape's offset.
*/
if (curve == NULL)
return;
}
-
- Path *finalPath = bpath_to_liv_path (SP_CURVE_BPATH(curve));
- if (finalPath == NULL)
+ if (curve->is_empty())
{
curve->unref();
return;
}
+ Path *finalPath = new Path;
+ finalPath->LoadPathVector(curve->get_pathvector());
+
Shape *theShape = new Shape;
finalPath->Convert (1.0);
{
if ( offset == NULL ) return;
offset->sourceDirty=false;
- Path *orig = NULL;
// le mauvais cas: pas d'attribut d => il faut verifier que c'est une SPShape puis prendre le contour
// The bad case: no d attribute. Must check that it's an SPShape and then take the outline.
if (SP_IS_TEXT (item)) {
curve = SP_TEXT (item)->getNormalizedBpath ();
if (curve == NULL)
- return;
+ return;
}
- orig = bpath_to_liv_path (SP_CURVE_BPATH(curve));
+ Path *orig = new Path;
+ orig->LoadPathVector(curve->get_pathvector());
curve->unref();