diff --git a/src/pen-context.cpp b/src/pen-context.cpp
index 6e545be9d77cfcbaa5ace9b4019f8c151394a580..607bdaedc2fc9df9279e87d201b3f5c1d077ca78 100644 (file)
--- a/src/pen-context.cpp
+++ b/src/pen-context.cpp
#include "message-context.h"
#include "preferences.h"
#include "sp-path.h"
+#include "display/sp-canvas.h"
#include "display/curve.h"
#include "pixmaps/cursor-pen.xpm"
#include "display/canvas-bpath.h"
@@ -476,6 +477,7 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop);
m.freeSnapReturnByRef(p, Inkscape::SNAPSOURCE_NODE_HANDLE);
+ m.unSetup();
}
spdc_create_single_dot(event_context, p, "/tools/freehand/pen", bevent.state);
ret = TRUE;
SnapManager &m = dt->namedview->snap_manager;
m.setup(dt);
m.preSnap(Inkscape::SnapCandidatePoint(p, Inkscape::SNAPSOURCE_NODE_HANDLE));
+ m.unSetup();
}
break;
case SP_PEN_CONTEXT_CONTROL:
@@ -657,10 +660,11 @@ pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion const &mevent)
if (!anchor) { /* Snap node only if not hitting anchor */
spdc_endpoint_snap(pc, p, mevent.state);
+ spdc_pen_set_subsequent_point(pc, p, true, mevent.state);
+ } else {
+ spdc_pen_set_subsequent_point(pc, anchor->dp, false, mevent.state);
}
- spdc_pen_set_subsequent_point(pc, p, !anchor, mevent.state);
-
if (anchor && !pc->anchor_statusbar) {
pc->_message_context->set(Inkscape::NORMAL_MESSAGE, _("<b>Click</b> or <b>click and drag</b> to close and finish the path."));
pc->anchor_statusbar = true;
SnapManager &m = dt->namedview->snap_manager;
m.setup(dt);
m.preSnap(Inkscape::SnapCandidatePoint(p, Inkscape::SNAPSOURCE_NODE_HANDLE));
+ m.unSetup();
}
}
break;
SnapManager &m = dt->namedview->snap_manager;
m.setup(dt);
m.preSnap(Inkscape::SnapCandidatePoint(p, Inkscape::SNAPSOURCE_NODE_HANDLE));
+ m.unSetup();
}
break;
}
sp_canvas_item_hide(pc->cl1);
pc->state = SP_PEN_CONTEXT_POINT;
spdc_pen_set_subsequent_point(pc, pt, true);
+ pen_last_paraxial_dir = !pen_last_paraxial_dir;
ret = TRUE;
}
break;
@@ -1254,16 +1261,20 @@ spdc_pen_set_subsequent_point(SPPenContext *const pc, Geom::Point const p, bool
bool is_curve;
pc->red_curve->moveto(pc->p[0]);
if (pc->polylines_paraxial && !statusbar) {
- // we are drawing horizontal/vertical lines and hit an anchor; draw an L-shaped path
- Geom::Point intermed = p;
- pen_set_to_nearest_horiz_vert(pc, intermed, status, false);
- pc->red_curve->lineto(intermed);
+ // we are drawing horizontal/vertical lines and hit an anchor;
+ Geom::Point const origin = pc->p[0];
+ // if the previous point and the anchor are not aligned either horizontally or vertically...
+ if ((abs(p[Geom::X] - origin[Geom::X]) > 1e-9) && (abs(p[Geom::Y] - origin[Geom::Y]) > 1e-9)) {
+ // ...then we should draw an L-shaped path, consisting of two paraxial segments
+ Geom::Point intermed = p;
+ pen_set_to_nearest_horiz_vert(pc, intermed, status, false);
+ pc->red_curve->lineto(intermed);
+ }
pc->red_curve->lineto(p);
is_curve = false;
} else {
// one of the 'regular' modes
- if (pc->p[1] != pc->p[0])
- {
+ if (pc->p[1] != pc->p[0]) {
pc->red_curve->curveto(pc->p[1], p, p);
is_curve = true;
} else {
void pen_set_to_nearest_horiz_vert(const SPPenContext *const pc, Geom::Point &pt, guint const state, bool snap)
{
- Geom::Point const &origin = pc->p[0];
+ Geom::Point const origin = pc->p[0];
int next_dir = pen_next_paraxial_direction(pc, pt, origin, state);
@@ -1464,7 +1475,7 @@ void pen_set_to_nearest_horiz_vert(const SPPenContext *const pc, Geom::Point &pt
}
} else {
// Create a horizontal or vertical constraint line
- Inkscape::Snapper::ConstraintLine cl(origin, next_dir ? Geom::Point(0, 1) : Geom::Point(1, 0));
+ Inkscape::Snapper::SnapConstraint cl(origin, next_dir ? Geom::Point(0, 1) : Geom::Point(1, 0));
// Snap along the constraint line; if we didn't snap then still the constraint will be applied
SnapManager &m = pc->desktop->namedview->snap_manager;
@@ -1475,6 +1486,7 @@ void pen_set_to_nearest_horiz_vert(const SPPenContext *const pc, Geom::Point &pt
m.setup(pc->desktop, true, selection->singleItem());
m.constrainedSnapReturnByRef(pt, Inkscape::SNAPSOURCE_NODE_HANDLE, cl);
+ m.unSetup();
}
}
@@ -1487,4 +1499,4 @@ void pen_set_to_nearest_horiz_vert(const SPPenContext *const pc, Geom::Point &pt
fill-column:99
End:
*/
-// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :