summaryrefslogtreecommitdiffstats
path: root/src/ui/tool/path-manipulator.cpp
diff options
context:
space:
mode:
authorLiam P. White <inkscapebrony@gmail.com>2014-09-27 14:17:45 +0000
committerLiam P. White <inkscapebrony@gmail.com>2014-09-27 14:17:45 +0000
commitfa9bd6393f316dab9303569b28f6b5d179fedd61 (patch)
tree33df00632f850a6f117978c36145feeac05f1a4c /src/ui/tool/path-manipulator.cpp
parentUpdate to experimental r13527 (diff)
downloadinkscape-fa9bd6393f316dab9303569b28f6b5d179fedd61.tar.gz
inkscape-fa9bd6393f316dab9303569b28f6b5d179fedd61.zip
Update to experimental r13565
(bzr r13341.5.16)
Diffstat (limited to 'src/ui/tool/path-manipulator.cpp')
-rw-r--r--src/ui/tool/path-manipulator.cpp50
1 files changed, 42 insertions, 8 deletions
diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp
index 5f20aece7..52ff5d42c 100644
--- a/src/ui/tool/path-manipulator.cpp
+++ b/src/ui/tool/path-manipulator.cpp
@@ -56,6 +56,10 @@ enum PathChange {
};
} // anonymous namespace
+const double handleCubicGap = 0.01;
+const double noPower = 0.0;
+const double defaultStartPower = 0.3334;
+const double defaultEndPower = 0.6667;
/**
* Notifies the path manipulator when something changes the path being edited
@@ -991,9 +995,37 @@ NodeList::iterator PathManipulator::subdivideSegment(NodeList::iterator first, d
// set new handle positions
Node *n = new Node(_multi_path_manipulator._path_data.node_data, seg2[0]);
- n->back()->setPosition(seg1[2]);
- n->front()->setPosition(seg2[1]);
- n->setType(NODE_SMOOTH, false);
+ if(!isBSpline()){
+ n->back()->setPosition(seg1[2]);
+ n->front()->setPosition(seg2[1]);
+ n->setType(NODE_SMOOTH, false);
+ } else {
+ const double handleCubicGap = 0.01;
+ Geom::D2< Geom::SBasis > SBasisInsideNodes;
+ SPCurve *lineInsideNodes = new SPCurve();
+ if(second->back()->isDegenerate()){
+ lineInsideNodes->moveto(n->position());
+ lineInsideNodes->lineto(second->position());
+ SBasisInsideNodes = lineInsideNodes->first_segment()->toSBasis();
+ Geom::Point next = SBasisInsideNodes.valueAt(defaultStartPower);
+ next = Geom::Point(next[Geom::X] + handleCubicGap,next[Geom::Y] + handleCubicGap);
+ lineInsideNodes->reset();
+ n->front()->setPosition(next);
+ }else{
+ n->front()->setPosition(seg2[1]);
+ }
+ if(first->front()->isDegenerate()){
+ lineInsideNodes->moveto(n->position());
+ lineInsideNodes->lineto(first->position());
+ SBasisInsideNodes = lineInsideNodes->first_segment()->toSBasis();
+ Geom::Point previous = SBasisInsideNodes.valueAt(defaultStartPower);
+ previous = Geom::Point(previous[Geom::X] + handleCubicGap,previous[Geom::Y] + handleCubicGap);
+ n->back()->setPosition(previous);
+ }else{
+ n->back()->setPosition(seg1[2]);
+ }
+ n->setType(NODE_CUSP, false);
+ }
inserted = list.insert(insert_at, n);
first->front()->move(seg1[1]);
@@ -1218,7 +1250,7 @@ double PathManipulator::BSplineHandlePosition(Handle *h, Handle *h2){
if(h2){
h = h2;
}
- double pos = 0.0000;
+ double pos = noPower;
const double handleCubicGap = 0.01;
Node *n = h->parent();
Node * nextNode = NULL;
@@ -1227,9 +1259,11 @@ double PathManipulator::BSplineHandlePosition(Handle *h, Handle *h2){
SPCurve *lineInsideNodes = new SPCurve();
lineInsideNodes->moveto(n->position());
lineInsideNodes->lineto(nextNode->position());
- pos = Geom::nearest_point(Geom::Point(h->position()[X] - handleCubicGap,h->position()[Y] - handleCubicGap),*lineInsideNodes->first_segment());
+ if(!are_near(h->position(), n->position())){
+ pos = Geom::nearest_point(Geom::Point(h->position()[X] - handleCubicGap, h->position()[Y] - handleCubicGap), *lineInsideNodes->first_segment());
+ }
}
- if (pos == 0.0000 && !h2){
+ if (pos == noPower && !h2){
return BSplineHandlePosition(h, h->other());
}
return pos;
@@ -1252,14 +1286,14 @@ Geom::Point PathManipulator::BSplineHandleReposition(Handle *h,double pos){
SPCurve *lineInsideNodes = new SPCurve();
Node * nextNode = NULL;
nextNode = n->nodeToward(h);
- if(nextNode && pos != 0.0000){
+ if(nextNode && pos != noPower){
lineInsideNodes->moveto(n->position());
lineInsideNodes->lineto(nextNode->position());
SBasisInsideNodes = lineInsideNodes->first_segment()->toSBasis();
ret = SBasisInsideNodes.valueAt(pos);
ret = Geom::Point(ret[X] + handleCubicGap,ret[Y] + handleCubicGap);
}else{
- if(pos == 0.0000){
+ if(pos == noPower){
ret = n->position();
}
}