summaryrefslogtreecommitdiffstats
path: root/src/livarot/PathCutting.cpp
diff options
context:
space:
mode:
authorMartin Owens <doctormo@gmail.com>2014-03-27 01:33:44 +0000
committerMartin Owens <doctormo@gmail.com>2014-03-27 01:33:44 +0000
commit5a4fb2325f60d292b47330f540b26a3279341c90 (patch)
treed2aa7967be25450b83e625025366c618101ae49f /src/livarot/PathCutting.cpp
parentThe Polar Arrange Tab of the Arrange Dialog now hides the parametric (diff)
parentRemove Snap menu item and improve grid menu item text (diff)
downloadinkscape-5a4fb2325f60d292b47330f540b26a3279341c90.tar.gz
inkscape-5a4fb2325f60d292b47330f540b26a3279341c90.zip
Commit a merge to trunk, with probabal errors
(bzr r11073.1.36)
Diffstat (limited to 'src/livarot/PathCutting.cpp')
-rw-r--r--src/livarot/PathCutting.cpp62
1 files changed, 34 insertions, 28 deletions
diff --git a/src/livarot/PathCutting.cpp b/src/livarot/PathCutting.cpp
index e47ed8916..49b2c5a78 100644
--- a/src/livarot/PathCutting.cpp
+++ b/src/livarot/PathCutting.cpp
@@ -25,7 +25,6 @@
#include <2geom/affine.h>
#include <2geom/sbasis-to-bezier.h>
#include <2geom/curves.h>
-#include "../display/canvas-bpath.h"
#include "helper/geom-curves.h"
#include "helper/geom.h"
@@ -59,31 +58,36 @@ void Path::DashPolyline(float head,float tail,float body,int nbD,float *dashs,b
void Path::DashPolylineFromStyle(SPStyle *style, float scale, float min_len)
{
- if (style->stroke_dash.n_dash) {
+ if (!style->stroke_dasharray.values.empty()) {
double dlen = 0.0;
- for (int i = 0; i < style->stroke_dash.n_dash; i++) {
- dlen += style->stroke_dash.dash[i] * scale;
+ // Find total length
+ for (unsigned i = 0; i < style->stroke_dasharray.values.size(); i++) {
+ dlen += style->stroke_dasharray.values[i] * scale;
}
if (dlen >= min_len) {
- NRVpathDash dash;
- dash.offset = style->stroke_dash.offset * scale;
- dash.n_dash = style->stroke_dash.n_dash;
- dash.dash = g_new(double, dash.n_dash);
- for (int i = 0; i < dash.n_dash; i++) {
- dash.dash[i] = style->stroke_dash.dash[i] * scale;
+ // Extract out dash pattern (relative positions)
+ double dash_offset = style->stroke_dashoffset.value * scale;
+ size_t n_dash = style->stroke_dasharray.values.size();
+ double *dash = g_new(double, n_dash);
+ for (unsigned i = 0; i < n_dash; i++) {
+ dash[i] = style->stroke_dasharray.values[i] * scale;
}
- int nbD=dash.n_dash;
+
+ // Convert relative positions to absolute postions
+ int nbD = n_dash;
float *dashs=(float*)malloc((nbD+1)*sizeof(float));
- while ( dash.offset >= dlen ) dash.offset-=dlen;
- dashs[0]=dash.dash[0];
+ while ( dash_offset >= dlen ) dash_offset-=dlen;
+ dashs[0]=dash[0];
for (int i=1; i<nbD; i++) {
- dashs[i]=dashs[i-1]+dash.dash[i];
+ dashs[i]=dashs[i-1]+dash[i];
}
+
// modulo dlen
- this->DashPolyline(0.0, 0.0, dlen, nbD, dashs, true, dash.offset);
+ this->DashPolyline(0.0, 0.0, dlen, nbD, dashs, true, dash_offset);
+
free(dashs);
- g_free(dash.dash);
+ g_free(dash);
}
}
}
@@ -304,7 +308,7 @@ Path::MakePathVector()
{
/* TODO: add testcase for this descr_arcto case */
PathDescrArcTo *nData = dynamic_cast<PathDescrArcTo *>(descr_cmd[i]);
- currentpath->appendNew<Geom::SVGEllipticalArc>( nData->rx, nData->ry, nData->angle, nData->large, !nData->clockwise, nData->p );
+ currentpath->appendNew<Geom::SVGEllipticalArc>( nData->rx, nData->ry, nData->angle*M_PI/180.0, nData->large, !nData->clockwise, nData->p );
lastP = nData->p;
}
break;
@@ -399,7 +403,7 @@ void Path::AddCurve(Geom::Curve const &c)
else if(Geom::SVGEllipticalArc const *svg_elliptical_arc = dynamic_cast<Geom::SVGEllipticalArc const *>(&c)) {
ArcTo( svg_elliptical_arc->finalPoint(),
svg_elliptical_arc->ray(Geom::X), svg_elliptical_arc->ray(Geom::Y),
- svg_elliptical_arc->rotationAngle(), /// \todo check that this parameter is in radians (rotation_angle returns the angle in radians!)
+ svg_elliptical_arc->rotationAngle()*180.0/M_PI, // convert from radians to degrees
svg_elliptical_arc->largeArc(), !svg_elliptical_arc->sweep() );
} else {
//this case handles sbasis as well as all other curve types
@@ -483,7 +487,7 @@ double Path::Length()
Geom::Point lastP = pts[0].p;
double len = 0;
- for (std::vector<path_lineto>::const_iterator i = pts.begin(); i != pts.end(); i++) {
+ for (std::vector<path_lineto>::const_iterator i = pts.begin(); i != pts.end(); ++i) {
if ( i->isMoveTo != polyline_moveto ) {
len += Geom::L2(i->p - lastP);
@@ -506,7 +510,7 @@ double Path::Surface()
Geom::Point lastP = lastM;
double surf = 0;
- for (std::vector<path_lineto>::const_iterator i = pts.begin(); i != pts.end(); i++) {
+ for (std::vector<path_lineto>::const_iterator i = pts.begin(); i != pts.end(); ++i) {
if ( i->isMoveTo == polyline_moveto ) {
surf += Geom::cross(lastM - lastP, lastM);
@@ -642,21 +646,21 @@ Path** Path::SubPathsWithNesting(int &outNb,bool killNoSurf,int nbNest,int*
}
curAdd=NULL;
}
- Path* hasDad=NULL;
+ Path* hasParent=NULL;
for (int j=0;j<nbNest;j++) {
if ( conts[j] == i && nesting[j] >= 0 ) {
- int dadMvt=conts[nesting[j]];
+ int parentMvt=conts[nesting[j]];
for (int k=0;k<nbRes;k++) {
- if ( res[k] && res[k]->descr_cmd.empty() == false && res[k]->descr_cmd[0]->associated == dadMvt ) {
- hasDad=res[k];
+ if ( res[k] && res[k]->descr_cmd.empty() == false && res[k]->descr_cmd[0]->associated == parentMvt ) {
+ hasParent=res[k];
break;
}
}
}
if ( conts[j] > i ) break;
}
- if ( hasDad ) {
- curAdd=hasDad;
+ if ( hasParent ) {
+ curAdd=hasParent;
increment=true;
} else {
curAdd=new Path;
@@ -901,7 +905,7 @@ Path::cut_position* Path::CurvilignToPosition(int nbCv, double *cvAbs, int &nbCu
Geom::Point lastM = pts[0].p;
Geom::Point lastP = lastM;
- for (std::vector<path_lineto>::const_iterator i = pts.begin(); i != pts.end(); i++) {
+ for (std::vector<path_lineto>::const_iterator i = pts.begin(); i != pts.end(); ++i) {
if ( i->isMoveTo == polyline_moveto ) {
@@ -1127,6 +1131,8 @@ void Path::ConvertPositionsToForced(int nbPos, cut_position *poss)
}
}
}
+ if (descr_cmd[0]->getType() == descr_moveto)
+ descr_flags |= descr_doing_subpath; // see LP Bug 166302
qsort(poss, nbPos, sizeof(cut_position), CmpPosition);
@@ -1216,7 +1222,7 @@ void Path::ConvertPositionsToForced(int nbPos, cut_position *poss)
}
{
double sang,eang;
- ArcAngles(startP,endP,rx,ry,angle,large,clockw,sang,eang);
+ ArcAngles(startP,endP,rx,ry,angle*M_PI/180.0,large,clockw,sang,eang);
if (clockw) {
if ( sang < eang ) sang += 2*M_PI;