diff options
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/tool/node.cpp | 41 | ||||
| -rw-r--r-- | src/ui/tool/node.h | 2 | ||||
| -rw-r--r-- | src/ui/tool/path-manipulator.cpp | 26 | ||||
| -rw-r--r-- | src/ui/tool/path-manipulator.h | 1 |
4 files changed, 39 insertions, 31 deletions
diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index b4976bde5..dfa9c5d84 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -139,7 +139,6 @@ void Handle::move(Geom::Point const &new_pos) Handle *towards = node_towards ? node_towards->handleAwayFrom(_parent) : NULL; Handle *towards_second = node_towards ? node_towards->handleToward(_parent) : NULL; //BSpline - double pos = 0; Handle *h = NULL; Handle *h2 = NULL; if(_pm().isBSpline){ @@ -189,9 +188,9 @@ void Handle::move(Geom::Point const &new_pos) if(_pm().isBSpline){ h = this; setPosition(_pm().BSplineHandleReposition(h)); - pos = _pm().BSplineHandlePosition(h); + _parent->bsplineWeight = _pm().BSplineHandlePosition(h); h2 = this->other(); - this->other()->setPosition(_pm().BSplineHandleReposition(h2,pos)); + this->other()->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); } //BSpline End return; @@ -228,9 +227,9 @@ void Handle::move(Geom::Point const &new_pos) if(_pm().isBSpline){ h = this; setPosition(_pm().BSplineHandleReposition(h)); - pos = _pm().BSplineHandlePosition(h); + _parent->bsplineWeight = _pm().BSplineHandlePosition(h); h2 = this->other(); - this->other()->setPosition(_pm().BSplineHandleReposition(h2,pos)); + this->other()->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); } //BSpline End } @@ -325,12 +324,12 @@ void Handle::handle_2button_press(){ if(_pm().isBSpline){ Handle *h = NULL; Handle *h2 = NULL; - double pos = 0; + _parent->bsplineWeight = 0; h = this; setPosition(_pm().BSplineHandleReposition(h,0.3334)); - pos = _pm().BSplineHandlePosition(h); + _parent->bsplineWeight = _pm().BSplineHandlePosition(h); h2 = this->other(); - this->other()->setPosition(_pm().BSplineHandleReposition(h2,pos)); + this->other()->setPosition(_pm().BSplineHandleReposition(h2,_parent->bsplineWeight)); _pm().update(); } } @@ -386,12 +385,12 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) //BSpline if(_pm().isBSpline){ Handle *h = NULL; - double pos = 0; + _parent->bsplineWeight = 0; h = this; setPosition(new_pos); int steps = _pm().getSteps(); - pos = ceilf(_pm().BSplineHandlePosition(h)*steps)/steps; - new_pos=_pm().BSplineHandleReposition(h,pos); + _parent->bsplineWeight = ceilf(_pm().BSplineHandlePosition(h)*steps)/steps; + new_pos=_pm().BSplineHandleReposition(h,_parent->bsplineWeight); } //BSpline End } @@ -579,6 +578,7 @@ Node::Node(NodeSharedData const &data, Geom::Point const &initial_pos) : _handles_shown(false) { // NOTE we do not set type here, because the handles are still degenerate + this->bsplineWeight = 0.3334; } Node const *Node::_next() const @@ -619,7 +619,6 @@ void Node::move(Geom::Point const &new_pos) Geom::Point delta = new_pos - position(); //BSpline double prevPos = 0; - double pos = 0; double nextPos = 0; Node *n = this; Node * nextNode = n->nodeToward(n->front()); @@ -627,9 +626,9 @@ void Node::move(Geom::Point const &new_pos) if(_pm().isBSpline){ if(prevNode) prevPos = _pm().BSplineHandlePosition(prevNode->front()); - pos = _pm().BSplineHandlePosition(n->front()); - if(pos == 0) - pos = _pm().BSplineHandlePosition(n->back()); + n->bsplineWeight = _pm().BSplineHandlePosition(n->front()); + if(n->bsplineWeight == 0) + n->bsplineWeight = _pm().BSplineHandlePosition(n->back()); if(nextNode) nextPos = _pm().BSplineHandlePosition(nextNode->back()); } @@ -653,8 +652,8 @@ void Node::move(Geom::Point const &new_pos) if(_pm().isBSpline){ Handle* front = &_front; Handle* back = &_back; - _front.setPosition(_pm().BSplineHandleReposition(front,pos)); - _back.setPosition(_pm().BSplineHandleReposition(back,pos)); + _front.setPosition(_pm().BSplineHandleReposition(front,n->bsplineWeight)); + _back.setPosition(_pm().BSplineHandleReposition(back,n->bsplineWeight)); } } @@ -864,10 +863,10 @@ void Node::setType(NodeType type, bool update_handles) if(isBSpline){ Handle* front = &_front; Handle* back = &_back; - double pos = _pm().BSplineHandlePosition(front); - if(pos !=0) pos = 0.3334; - _front.setPosition(_pm().BSplineHandleReposition(front,pos)); - _back.setPosition(_pm().BSplineHandleReposition(back,pos)); + this->bsplineWeight = _pm().BSplineHandlePosition(front); + if(this->bsplineWeight !=0) this->bsplineWeight = 0.3334; + _front.setPosition(_pm().BSplineHandleReposition(front,this->bsplineWeight)); + _back.setPosition(_pm().BSplineHandleReposition(back,this->bsplineWeight)); } //BSpline End } diff --git a/src/ui/tool/node.h b/src/ui/tool/node.h index 2b547256b..f6d5beadc 100644 --- a/src/ui/tool/node.h +++ b/src/ui/tool/node.h @@ -180,7 +180,7 @@ public: bool isEndNode() const; Handle *front() { return &_front; } Handle *back() { return &_back; } - + double bsplineWeight; /** * Gets the handle that faces the given adjacent node. * Will abort with error if the given node is not adjacent. diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp index 1607585c5..be5514e1f 100644 --- a/src/ui/tool/path-manipulator.cpp +++ b/src/ui/tool/path-manipulator.cpp @@ -862,7 +862,6 @@ void PathManipulator::rotateHandle(Node *n, int which, int dir, bool pixel) int snaps = prefs->getIntLimited("/options/rotationsnapsperpi/value", 12, 1, 1000); angle = M_PI * dir / snaps; } - h->setRelativePos(h->relativePos() * Geom::Rotate(angle)); update(); @@ -1211,14 +1210,12 @@ double PathManipulator::BSplineHandlePosition(Handle *h){ Node * nextNode = NULL; if(!n->isEndNode()) 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(positionH,*lineInsideNodes->first_segment()); - } + 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(positionH,*lineInsideNodes->first_segment()); } return pos; } @@ -1250,6 +1247,11 @@ Geom::Point PathManipulator::BSplineHandleReposition(Handle *h,double pos){ return ret; } +void PathManipulator::BSplineNodeHandlesReposition(Node *n){ + n->front()->setPosition(BSplineHandleReposition(n->front(),n->bsplineWeight)); + n->back()->setPosition(BSplineHandleReposition(n->back(),n->bsplineWeight)); +} + /** Construct the geometric representation of nodes and handles, update the outline * and display * \param alert_LPE if true, first the LPE is warned what the new path is going to be before updating it @@ -1264,8 +1266,14 @@ void PathManipulator::_createGeometryFromControlPoints(bool alert_LPE) continue; } NodeList::iterator prev = subpath->begin(); + if(isBSpline){ + BSplineNodeHandlesReposition(prev.ptr()); + } builder.moveTo(prev->position()); for (NodeList::iterator i = ++subpath->begin(); i != subpath->end(); ++i) { + if(isBSpline){ + BSplineNodeHandlesReposition(i.ptr()); + } build_segment(builder, prev.ptr(), i.ptr()); prev = i; } diff --git a/src/ui/tool/path-manipulator.h b/src/ui/tool/path-manipulator.h index e68cabef1..743d70b96 100644 --- a/src/ui/tool/path-manipulator.h +++ b/src/ui/tool/path-manipulator.h @@ -115,6 +115,7 @@ private: double BSplineHandlePosition(Handle *h); Geom::Point BSplineHandleReposition(Handle *h); Geom::Point BSplineHandleReposition(Handle *h,double pos); + void BSplineNodeHandlesReposition(Node *n); //BSpline End void _createGeometryFromControlPoints(bool alert_LPE = false); unsigned _deleteStretch(NodeList::iterator first, NodeList::iterator last, bool keep_shape); |
