From 4c6918c72721a35e0347e9e087396238e72eb62e Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Cenoz Date: Mon, 30 Dec 2013 20:41:32 +0100 Subject: Refactorizing (bzr r11950.1.212) --- src/ui/tool/node.cpp | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'src/ui/tool/node.cpp') diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp index 70e374424..7266c85bb 100644 --- a/src/ui/tool/node.cpp +++ b/src/ui/tool/node.cpp @@ -28,9 +28,7 @@ #include "ui/tool/node.h" #include "ui/tool/path-manipulator.h" #include - #include -; namespace { @@ -137,7 +135,7 @@ void Handle::move(Geom::Point const &new_pos) Node *node_away = _parent->nodeAwayFrom(this); // node in the opposite direction Handle *towards = node_towards ? node_towards->handleAwayFrom(_parent) : NULL; Handle *towards_second = node_towards ? node_towards->handleToward(_parent) : NULL; - + if (Geom::are_near(new_pos, _parent->position())) { // The handle becomes degenerate. // Adjust node type as necessary. @@ -308,7 +306,6 @@ bool Handle::_eventHandler(Inkscape::UI::Tools::ToolBase *event_context, GdkEven return ControlPoint::_eventHandler(event_context, event); } - void Handle::handle_2button_press(){ if(_pm().isBSpline){ setPosition(_pm().BSplineHandleReposition(this,0.3334)); @@ -318,7 +315,6 @@ void Handle::handle_2button_press(){ } } - bool Handle::grabbed(GdkEventMotion *) { _saved_other_pos = other()->position(); @@ -335,6 +331,7 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) SnapManager &sm = _desktop->namedview->snap_manager; bool snap = held_shift(*event) ? false : sm.someSnapperMightSnap(); boost::optional ctrl_constraint; + // with Alt, preserve length if (held_alt(*event)) { new_pos = parent_pos + Geom::unit_vector(new_pos - parent_pos) * _saved_length; @@ -366,14 +363,13 @@ void Handle::dragged(Geom::Point &new_pos, GdkEventMotion *event) ctrl_constraint = Inkscape::Snapper::SnapConstraint(parent_pos, parent_pos - perp_pos); } new_pos = result; - + if(_pm().isBSpline){ setPosition(new_pos); int steps = _pm().BSplineGetSteps(); _parent->bsplineWeight = ceilf(_pm().BSplineHandlePosition(this)*steps)/steps; new_pos=_pm().BSplineHandleReposition(this,_parent->bsplineWeight); } - } std::vector unselected; @@ -627,22 +623,22 @@ void Node::move(Geom::Point const &new_pos) // move handles when the node moves. Geom::Point old_pos = position(); Geom::Point delta = new_pos - position(); - + double oldPos = 0.0000; Node *n = this; if(_pm().isBSpline){ oldPos = n->bsplineWeight; } - + setPosition(new_pos); _front.setPosition(_front.position() + delta); _back.setPosition(_back.position() + delta); - + // if the node has a smooth handle after a line segment, it should be kept colinear // with the segment _fixNeighbors(old_pos, new_pos); - + if(_pm().isBSpline){ _front.setPosition(_pm().BSplineHandleReposition(this->front(),oldPos)); _back.setPosition(_pm().BSplineHandleReposition(this->back(),oldPos)); @@ -774,6 +770,7 @@ void Node::setType(NodeType type, bool update_handles) updateState(); // The size of the control might have changed return; } + // if update_handles is true, adjust handle positions to match the node type // handle degenerate handles appropriately if (update_handles) { @@ -861,7 +858,6 @@ void Node::setType(NodeType type, bool update_handles) _front.setPosition(_pm().BSplineHandleReposition(this->front(),this->bsplineWeight)); _back.setPosition(_pm().BSplineHandleReposition(this->back(),this->bsplineWeight)); } - } _type = type; _setControlType(nodeTypeToCtrlType(_type)); @@ -1124,7 +1120,6 @@ void Node::_setState(State state) this->back()->setPosition(_pm().BSplineHandleReposition(this->back(),this->bsplineWeight)); } } - break; } SelectableControlPoint::_setState(state); -- cgit v1.2.3