summaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2013-02-28 03:43:21 +0000
committerJabiertxo Arraiza Zenotz <jtx@jtx.marker.es>2013-02-28 03:43:21 +0000
commitecc57932f1e7d157950ada2901f6ea6f3acc8aad (patch)
treea709f96bc323c5e7b69d09ece12aefebfb0e14d8 /src/ui
parentBSpline refactor (diff)
downloadinkscape-ecc57932f1e7d157950ada2901f6ea6f3acc8aad.tar.gz
inkscape-ecc57932f1e7d157950ada2901f6ea6f3acc8aad.zip
Fixed closed pc->ea
(bzr r11950.1.40)
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/tool/node.cpp38
-rw-r--r--src/ui/tool/path-manipulator.cpp45
2 files changed, 34 insertions, 49 deletions
diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp
index fef904006..4cac0e543 100644
--- a/src/ui/tool/node.cpp
+++ b/src/ui/tool/node.cpp
@@ -138,12 +138,14 @@ void Handle::move(Geom::Point const &new_pos)
//BSpline
bool isBSpline = false;
double pos = 0;
- Handle *h = this;
+ Handle *h = NULL;
+ Handle *h2 = NULL;
if(_pm().isBSpline()){
isBSpline = true;
- _parent->_selection.insert(_parent);
- //BSpline End
+ if(!_parent->selected())
+ _parent->_selection.insert(_parent);
}
+ //BSpline End
if (Geom::are_near(new_pos, _parent->position())) {
// The handle becomes degenerate.
@@ -177,12 +179,11 @@ void Handle::move(Geom::Point const &new_pos)
setPosition(new_pos);
//BSpline
if(isBSpline){
+ h = this;
setPosition(_pm().BSplineHandleReposition(h));
pos = _pm().BSplineHandlePosition(h);
- other->setPosition(_pm().BSplineHandleReposition(other,pos));
- if(pos == 0){
- _parent->setPosition(h->position());
- }
+ h2 = this->other();
+ this->other()->setPosition(_pm().BSplineHandleReposition(h2,pos));
}
//BSpline End
return;
@@ -217,12 +218,11 @@ void Handle::move(Geom::Point const &new_pos)
setPosition(new_pos);
//BSpline
if(isBSpline){
+ h = this;
setPosition(_pm().BSplineHandleReposition(h));
pos = _pm().BSplineHandlePosition(h);
- other->setPosition(_pm().BSplineHandleReposition(other,pos));
- if(pos == 0){
- _parent->setPosition(h->position());
- }
+ h2 = this->other();
+ this->other()->setPosition(_pm().BSplineHandleReposition(h2,pos));
}
//BSpline End
}
@@ -588,21 +588,25 @@ void Node::move(Geom::Point const &new_pos)
if(prevNode)
prevPos = _pm().BSplineHandlePosition(prevNode->front());
pos = _pm().BSplineHandlePosition(n->front());
+ if(pos == 0)
+ pos = _pm().BSplineHandlePosition(n->back());
if(nextNode)
nextPos = _pm().BSplineHandlePosition(nextNode->back());
}
//BSpline End
setPosition(new_pos);
//BSpline
- if(prevNode){
+ if(prevNode)
prevNode->front()->setPosition(_pm().BSplineHandleReposition(prevNode->front(),prevPos));
- }
- if(nextNode){
+ if(nextNode)
nextNode->back()->setPosition(_pm().BSplineHandleReposition(nextNode->back(),nextPos));
- }
//BSpline End
_front.setPosition(_front.position() + delta);
_back.setPosition(_back.position() + delta);
+ //BSpline End
+ // if the node has a smooth handle after a line segment, it should be kept colinear
+ // with the segment
+ _fixNeighbors(old_pos, new_pos);
//BSpline
if(_pm().isBSpline()){
Handle* front = &_front;
@@ -610,10 +614,6 @@ void Node::move(Geom::Point const &new_pos)
_front.setPosition(_pm().BSplineHandleReposition(front,pos));
_back.setPosition(_pm().BSplineHandleReposition(back,pos));
}
- //BSpline End
- // if the node has a smooth handle after a line segment, it should be kept colinear
- // with the segment
- _fixNeighbors(old_pos, new_pos);
}
void Node::transform(Geom::Affine const &m)
diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp
index ecb8abcf4..7c23ee153 100644
--- a/src/ui/tool/path-manipulator.cpp
+++ b/src/ui/tool/path-manipulator.cpp
@@ -1182,15 +1182,20 @@ bool PathManipulator::isBSpline(){
}
return false;
}
+
double PathManipulator::BSplineHandlePosition(Handle *h){
+ using Geom::X;
+ using Geom::Y;
double pos = 0;
Node *n = h->parent();
SPCurve *lineInsideNodes = new SPCurve();
Node * nextNode = n->nodeToward(h);
- if(nextNode){
+ Geom::Point positionH = h->position();
+ positionH = Geom::Point(positionH[X] - 0.0625,positionH[Y] - 0.0625);
+ if(nextNode && n->position() != h->position()){
lineInsideNodes->moveto(n->position());
lineInsideNodes->lineto(nextNode->position());
- pos = Geom::nearest_point(h->position(),*lineInsideNodes->first_segment());
+ pos = Geom::nearest_point(positionH,*lineInsideNodes->first_segment());
}
return pos;
}
@@ -1201,18 +1206,23 @@ Geom::Point PathManipulator::BSplineHandleReposition(Handle *h){
}
Geom::Point PathManipulator::BSplineHandleReposition(Handle *h,double pos){
+ using Geom::X;
+ using Geom::Y;
+ Geom::Point ret(0,0);
Node *n = h->parent();
Geom::D2< Geom::SBasis > SBasisInsideNodes;
SPCurve *lineInsideNodes = new SPCurve();
Node * nextNode = n->nodeToward(h);
- if(nextNode){
+ if(nextNode && pos != 0){
lineInsideNodes->moveto(n->position());
lineInsideNodes->lineto(nextNode->position());
SBasisInsideNodes = lineInsideNodes->first_segment()->toSBasis();
+ ret = SBasisInsideNodes.valueAt(pos);
+ ret = Geom::Point(ret[X] + 0.0625,ret[Y] + 0.0625);
}else{
- return n->position();
+ ret = n->position();
}
- return SBasisInsideNodes.valueAt(pos);
+ return ret;
}
/** Construct the geometric representation of nodes and handles, update the outline
@@ -1229,26 +1239,8 @@ void PathManipulator::_createGeometryFromControlPoints(bool alert_LPE)
continue;
}
NodeList::iterator prev = subpath->begin();
- //BSpline
- double pos =0;
- bool isBSpline = false;
- if(this->isBSpline())
- isBSpline = true;
- if(isBSpline){
- pos = BSplineHandlePosition(prev.ptr()->front());
- prev->front()->setPosition(BSplineHandleReposition(prev->front(),pos));
- }
- //BSpline End
builder.moveTo(prev->position());
for (NodeList::iterator i = ++subpath->begin(); i != subpath->end(); ++i) {
- //BSpline
- if (isBSpline) {
- pos = BSplineHandlePosition(i->back());
- i->front()->setPosition(BSplineHandleReposition(i->front(),pos));
- i->back()->setPosition(BSplineHandleReposition(i->back(),pos));
- }
-
- //BSpline End
build_segment(builder, prev.ptr(), i.ptr());
prev = i;
}
@@ -1256,13 +1248,6 @@ void PathManipulator::_createGeometryFromControlPoints(bool alert_LPE)
if (subpath->closed()) {
// Here we link the last and first node if the path is closed.
// If the last segment is Bezier, we add it.
- //BSpline
- if (isBSpline) {
- pos = BSplineHandlePosition(prev.next()->back());
- subpath->begin()->front()->setPosition(BSplineHandleReposition(subpath->begin()->front(),pos));
- prev.next()->back()->setPosition(BSplineHandleReposition(prev.next()->back(),pos));
- }
- //BSpline End
if (!prev->front()->isDegenerate() || !subpath->begin()->back()->isDegenerate()) {
build_segment(builder, prev.ptr(), subpath->begin().ptr());
}