diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2013-03-21 01:32:40 +0000 |
|---|---|---|
| committer | Jabiertxo Arraiza Zenotz <jtx@jtx.marker.es> | 2013-03-21 01:32:40 +0000 |
| commit | 27c65a6e91a8e79ae5b31e0a62869e3ec0e336c2 (patch) | |
| tree | 42723c2a30a65ad191a1103ed2ec4e124660e045 /src/ui/tool/node.cpp | |
| parent | For testing, widget added, regression fixed (diff) | |
| parent | Fixing node fault (diff) | |
| download | inkscape-27c65a6e91a8e79ae5b31e0a62869e3ec0e336c2.tar.gz inkscape-27c65a6e91a8e79ae5b31e0a62869e3ec0e336c2.zip | |
Inserting nodes fixed, cleanup
(bzr r11950.1.63)
Diffstat (limited to 'src/ui/tool/node.cpp')
| -rw-r--r-- | src/ui/tool/node.cpp | 61 |
1 files changed, 27 insertions, 34 deletions
diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index a1fa4e55b..3e4fbd508 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -110,7 +110,7 @@ Handle::Handle(NodeSharedData const &data, Geom::Point const &initial_pos, Node _handle_colors, data.handle_group), _parent(parent), _handle_line(ControlManager::getManager().createControlLine(data.handle_line_group)), - _degenerate(true),controlBsplineSteps(2) + _degenerate(true) { setVisible(false); } @@ -139,12 +139,10 @@ 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 - bool isBSpline = false; double pos = 0; Handle *h = NULL; Handle *h2 = NULL; - if(_pm().isBSpline()){ - isBSpline = true; + if(_pm().isBSpline){ typedef ControlPointSelection::Set Set; Set &nodes = _parent->_selection.allPoints(); for (Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { @@ -188,7 +186,7 @@ void Handle::move(Geom::Point const &new_pos) } setPosition(new_pos); //BSpline - if(isBSpline){ + if(_pm().isBSpline){ h = this; setPosition(_pm().BSplineHandleReposition(h)); pos = _pm().BSplineHandlePosition(h); @@ -227,7 +225,7 @@ void Handle::move(Geom::Point const &new_pos) } setPosition(new_pos); //BSpline - if(isBSpline){ + if(_pm().isBSpline){ h = this; setPosition(_pm().BSplineHandleReposition(h)); pos = _pm().BSplineHandlePosition(h); @@ -324,7 +322,7 @@ bool Handle::_eventHandler(SPEventContext *event_context, GdkEvent *event) //BSpline void Handle::handle_2button_press(){ - if(_pm().isBSpline()){ + if(_pm().isBSpline){ Handle *h = NULL; Handle *h2 = NULL; double pos = 0; @@ -386,19 +384,19 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) } new_pos = result; //BSpline - if(_pm().isBSpline()){ + if(_pm().isBSpline){ Handle *h = NULL; double pos = 0; h = this; setPosition(new_pos); - pos = ceilf(_pm().BSplineHandlePosition(h)*_pm().getControlBsplineSteps())/_pm().getControlBsplineSteps(); + pos = ceilf(_pm().BSplineHandlePosition(h)*_pm().controlBSplineSteps)/_pm().controlBSplineSteps; new_pos=_pm().BSplineHandleReposition(h,pos); } //BSpline End } std::vector<Inkscape::SnapCandidatePoint> unselected; - if (snap && ( (!held_control(*event) && _pm().isBSpline()) || !_pm().isBSpline())) { + if (snap && ( (!held_control(*event) && _pm().isBSpline) || !_pm().isBSpline)) { ControlPointSelection::Set &nodes = _parent->_selection.allPoints(); for (ControlPointSelection::Set::iterator i = nodes.begin(); i != nodes.end(); ++i) { Node *n = static_cast<Node*>(*i); @@ -625,7 +623,7 @@ void Node::move(Geom::Point const &new_pos) Node *n = this; Node * nextNode = n->nodeToward(n->front()); Node * prevNode = n->nodeToward(n->back()); - if(_pm().isBSpline()){ + if(_pm().isBSpline){ if(prevNode) prevPos = _pm().BSplineHandlePosition(prevNode->front()); pos = _pm().BSplineHandlePosition(n->front()); @@ -637,7 +635,7 @@ void Node::move(Geom::Point const &new_pos) //BSpline End setPosition(new_pos); //BSpline - if(_pm().isBSpline()){ + if(_pm().isBSpline){ if(prevNode) prevNode->front()->setPosition(_pm().BSplineHandleReposition(prevNode->front(),prevPos)); if(nextNode) @@ -651,7 +649,7 @@ void Node::move(Geom::Point const &new_pos) // with the segment _fixNeighbors(old_pos, new_pos); //BSpline - if(_pm().isBSpline()){ + if(_pm().isBSpline){ Handle* front = &_front; Handle* back = &_back; _front.setPosition(_pm().BSplineHandleReposition(front,pos)); @@ -773,27 +771,6 @@ void Node::setType(NodeType type, bool update_handles) return; } - //BSpline - if(_pm().isBSpline()){ - if (isEndNode()) return; - Handle* front = &_front; - Handle* back = &_back; - double pos = 0.3334; - switch (type) { - case NODE_CUSP: - if(update_handles) - pos = 0; - else - pos = _pm().BSplineHandlePosition(front);; - break; - default: break; - } - type = NODE_CUSP; - _front.setPosition(_pm().BSplineHandleReposition(front,pos)); - _back.setPosition(_pm().BSplineHandleReposition(back,pos)); - } - //BSpline End - // if update_handles is true, adjust handle positions to match the node type // handle degenerate handles appropriately if (update_handles) { @@ -876,12 +853,28 @@ void Node::setType(NodeType type, bool update_handles) break; default: break; } + //BSpline + bool isBSpline = false; + try { + isBSpline = nodeList().subpathList().pm().isBSpline; + } + catch( char * str ) { + } + if(isBSpline){ + Handle* front = &_front; + Handle* back = &_back; + double pos = _pm().BSplineHandlePosition(front); + _front.setPosition(_pm().BSplineHandleReposition(front,pos)); + _back.setPosition(_pm().BSplineHandleReposition(back,pos)); + } + //BSpline End } _type = type; _setControlType(nodeTypeToCtrlType(_type)); updateState(); + } void Node::pickBestType() |
