Code

Connector tool: make connectors avoid the convex hull of shapes.
[inkscape.git] / src / nodepath.cpp
index 5b2a738d3dc2c96e4d007a0bb0064b01a5149c8a..8f17ae0133122477bd60f9583553eed265fa15fb 100644 (file)
@@ -1201,7 +1201,9 @@ void sp_nodepath_convert_node_type(Inkscape::NodePath::Node *node, Inkscape::Nod
                 // pull opposite handle in line with the existing one
             }
         } else if (no_handles) {
-            if (both_segments_are_lines OR both_segments_are_curves) {
+            if (both_segments_are_lines 
+                  OR both_segments_are_curves 
+                  OR one_is_line_but_the_curveside_node_is_selected_and_has_two_handles) {
                 //pull both handles
             } else {
                 // pull the handle opposite to line segment, making node half-smooth
@@ -1213,6 +1215,8 @@ void sp_nodepath_convert_node_type(Inkscape::NodePath::Node *node, Inkscape::Nod
         bool p_is_line = sp_node_side_is_line(node, &node->p);
         bool n_is_line = sp_node_side_is_line(node, &node->n);
 
+#define NODE_HAS_BOTH_HANDLES(node) ((Geom::L2(node->pos  - node->n.pos) > 1e-6) && (Geom::L2(node->pos  - node->p.pos) > 1e-6))
+
         if (p_has_handle && n_has_handle) {
             // do nothing, adjust_handles will line them up
         } else if (p_has_handle || n_has_handle) {
@@ -1252,9 +1256,13 @@ void sp_nodepath_convert_node_type(Inkscape::NodePath::Node *node, Inkscape::Nod
                 node->p.pos = node->pos - (len / Geom::L2(node->n.pos - node->pos)) * (node->n.pos - node->pos);
             }
         } else if (!p_has_handle && !n_has_handle) {
-            if ((p_is_line && n_is_line) || (!p_is_line && node->p.other && !n_is_line && node->n.other)) {
-                // no handles, but both segments are either lnes or curves:
-                //pull both handles
+            if ((p_is_line && n_is_line) || (!p_is_line && node->p.other && !n_is_line && node->n.other) || 
+                (n_is_line && node->p.other && node->p.other->selected && NODE_HAS_BOTH_HANDLES(node->p.other)) ||
+                (p_is_line && node->n.other && node->n.other->selected && NODE_HAS_BOTH_HANDLES(node->n.other)) 
+            ) {
+                // no handles, but: both segments are either lines or curves; or: one is line and the
+                // node at the other side is selected (so it was just smoothed too!) and now has both
+                // handles: then pull both handles here
 
                 // convert both to curves:
                 node->code = NR_CURVETO;
@@ -1309,7 +1317,7 @@ void sp_node_moveto(Inkscape::NodePath::Node *node, Geom::Point p)
     Inkscape::NodePath::Node *node_n = NULL;
 
     if (node->p.other) {
-        if (node->code == NR_LINETO) {
+        if (sp_node_side_is_line(node, &node->p)) {
             sp_node_adjust_handle(node, 1);
             sp_node_adjust_handle(node->p.other, -1);
             node_p = node->p.other;
@@ -1320,7 +1328,7 @@ void sp_node_moveto(Inkscape::NodePath::Node *node, Geom::Point p)
         }
     }
     if (node->n.other) {
-        if (node->n.other->code == NR_LINETO) {
+        if (sp_node_side_is_line(node, &node->n)) {
             sp_node_adjust_handle(node, -1);
             sp_node_adjust_handle(node->n.other, 1);
             node_n = node->n.other;