diff options
| author | Diederik van Lierop <mail@diedenrezi.nl> | 2012-02-14 20:56:34 +0000 |
|---|---|---|
| committer | Diederik van Lierop <mail@diedenrezi.nl> | 2012-02-14 20:56:34 +0000 |
| commit | e182d3546498c8c865fb155481890c5571430c6f (patch) | |
| tree | 3ea9d416ab9610220a3e11fbdae0f62c1ba91741 /src/snap.cpp | |
| parent | Update Authors & Translators lists in About dialog (diff) | |
| download | inkscape-e182d3546498c8c865fb155481890c5571430c6f.tar.gz inkscape-e182d3546498c8c865fb155481890c5571430c6f.zip | |
1) Add checkboxes for perpendicular and tangential snapping to the document properties dialog (on the snap tab)
2) Newly created guides (dragged off the ruler) will take on the angle of the curve that's being snapped to (either perpendicularly or tangentialy, depending of the settings in the document properties dialog)
(bzr r10975)
Diffstat (limited to 'src/snap.cpp')
| -rw-r--r-- | src/snap.cpp | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/src/snap.cpp b/src/snap.cpp index f1197155b..4ca1ec476 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -10,7 +10,7 @@ * * Copyright (C) 2006-2007 Johan Engelen <johan@shouraizou.nl> * Copyrigth (C) 2004 Nathan Hurst - * Copyright (C) 1999-2010 Authors + * Copyright (C) 1999-2012 Authors * * Released under GNU GPL, read the file 'COPYING' for more information */ @@ -391,22 +391,23 @@ Inkscape::SnappedPoint SnapManager::constrainedAngularSnap(Inkscape::SnapCandida return sp; } -void SnapManager::guideFreeSnap(Geom::Point &p, SPGuideDragType drag_type, boost::optional<Geom::Point> origin_or_vector) const +void SnapManager::guideFreeSnap(Geom::Point &p, Geom::Point &origin_or_vector, bool origin, bool freeze_angle) const { + if (freeze_angle && origin) { + g_warning("Dear developer, when snapping guides you shouldn't ask me to freeze the guide's vector when you haven't specified one"); + // You've supplied me with an origin instead of a vector + } + if (!snapprefs.getSnapEnabledGlobally() || snapprefs.getSnapPostponedGlobally() || !snapprefs.isTargetSnappable(Inkscape::SNAPTARGET_GUIDE)) { return; } - Inkscape::SnapCandidatePoint candidate(p, Inkscape::SNAPSOURCE_GUIDE_ORIGIN); - if (drag_type == SP_DRAG_ROTATE) { - candidate = Inkscape::SnapCandidatePoint(p, Inkscape::SNAPSOURCE_GUIDE); - if (origin_or_vector) { - candidate.addOrigin(*origin_or_vector); - } + Inkscape::SnapCandidatePoint candidate(p, Inkscape::SNAPSOURCE_GUIDE); + if (origin) { + candidate.addOrigin(origin_or_vector); } else { - if (origin_or_vector) { - candidate.addVector(*origin_or_vector); - } + candidate = Inkscape::SnapCandidatePoint(p, Inkscape::SNAPSOURCE_GUIDE_ORIGIN); + candidate.addVector(Geom::rot90(origin_or_vector)); } IntermSnapResults isr; @@ -418,6 +419,13 @@ void SnapManager::guideFreeSnap(Geom::Point &p, SPGuideDragType drag_type, boost Inkscape::SnappedPoint const s = findBestSnap(candidate, isr, false); s.getPointIfSnapped(p); + + if (!freeze_angle && s.getSnapped()) { + if (!Geom::are_near(s.getTangent(), Geom::Point(0,0))) { // If the tangent has been set ... + origin_or_vector = Geom::rot90(s.getTangent()); // then use it to update the normal of the guide + // PS: The tangent might not have been set if we snapped for example to a node + } + } } void SnapManager::guideConstrainedSnap(Geom::Point &p, SPGuide const &guideline) const |
