summaryrefslogtreecommitdiffstats
path: root/src/object-snapper.cpp
diff options
context:
space:
mode:
authorDiederik van Lierop <mail@diedenrezi.nl>2008-09-07 10:35:07 +0000
committerdvlierop2 <dvlierop2@users.sourceforge.net>2008-09-07 10:35:07 +0000
commitb9cd7f7ef85ede6010815c2cfbc79e136ffdf63d (patch)
tree1e709414830df8e592f13bb95db6f3b127028617 /src/object-snapper.cpp
parentfinally got the pattern transform right (diff)
downloadinkscape-b9cd7f7ef85ede6010815c2cfbc79e136ffdf63d.tar.gz
inkscape-b9cd7f7ef85ede6010815c2cfbc79e136ffdf63d.zip
Remove pointer to SPDesktop from ObjectSnapper
(bzr r6772)
Diffstat (limited to 'src/object-snapper.cpp')
-rw-r--r--src/object-snapper.cpp27
1 files changed, 14 insertions, 13 deletions
diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp
index 90acb7f29..c620e91cd 100644
--- a/src/object-snapper.cpp
+++ b/src/object-snapper.cpp
@@ -33,6 +33,7 @@
#include "sp-clippath.h"
#include "sp-mask.h"
#include "helper/geom-curves.h"
+#include "desktop.h"
Inkscape::SnapCandidate::SnapCandidate(SPItem* item, bool clip_or_mask, Geom::Matrix additional_affine)
: item(item), clip_or_mask(clip_or_mask), additional_affine(additional_affine)
@@ -97,8 +98,8 @@ void Inkscape::ObjectSnapper::_findCandidates(SPObject* parent,
bbox_to_snap_incl.expandBy(getSnapperTolerance()); // see?
for (SPObject* o = sp_object_first_child(parent); o != NULL; o = SP_OBJECT_NEXT(o)) {
- g_assert(_desktop != NULL);
- if (SP_IS_ITEM(o) && !SP_ITEM(o)->isLocked() && !(_desktop->itemIsHidden(SP_ITEM(o)) && !clip_or_mask)) {
+ g_assert(_named_view->snap_manager.getDesktop() != NULL);
+ if (SP_IS_ITEM(o) && !SP_ITEM(o)->isLocked() && !(_named_view->snap_manager.getDesktop()->itemIsHidden(SP_ITEM(o)) && !clip_or_mask)) {
// Don't snap to locked items, and
// don't snap to hidden objects, unless they're a clipped path or a mask
/* See if this item is on the ignore list */
@@ -412,8 +413,8 @@ void Inkscape::ObjectSnapper::_snapPaths(SnappedConstraints &sc,
_collectPaths(t, first_point);
// Now we can finally do the real snapping, using the paths collected above
- g_assert(_desktop != NULL);
- Geom::Point const p_doc = _desktop->dt2doc(p);
+ g_assert(_named_view->snap_manager.getDesktop() != NULL);
+ Geom::Point const p_doc = _named_view->snap_manager.getDesktop()->dt2doc(p);
bool const node_tool_active = _snap_to_itempath && selected_path != NULL;
@@ -462,13 +463,13 @@ void Inkscape::ObjectSnapper::_snapPaths(SnappedConstraints &sc,
* piece are unselected; if they are then this piece must be stationary
*/
g_assert(unselected_nodes != NULL);
- Geom::Point start_pt = _desktop->doc2dt(curve->pointAt(0));
- Geom::Point end_pt = _desktop->doc2dt(curve->pointAt(1));
+ Geom::Point start_pt = _named_view->snap_manager.getDesktop()->doc2dt(curve->pointAt(0));
+ Geom::Point end_pt = _named_view->snap_manager.getDesktop()->doc2dt(curve->pointAt(1));
c1 = isUnselectedNode(start_pt, unselected_nodes);
c2 = isUnselectedNode(end_pt, unselected_nodes);
}
- Geom::Point const sp_dt = _desktop->doc2dt(sp_doc);
+ Geom::Point const sp_dt = _named_view->snap_manager.getDesktop()->doc2dt(sp_doc);
if (!being_edited || (c1 && c2)) {
Geom::Coord const dist = Geom::distance(sp_doc, p_doc);
if (dist < getSnapperTolerance()) {
@@ -511,8 +512,8 @@ void Inkscape::ObjectSnapper::_snapPathsConstrained(SnappedConstraints &sc,
// Now we can finally do the real snapping, using the paths collected above
- g_assert(_desktop != NULL);
- Geom::Point const p_doc = _desktop->dt2doc(p);
+ g_assert(_named_view->snap_manager.getDesktop() != NULL);
+ Geom::Point const p_doc = _named_view->snap_manager.getDesktop()->dt2doc(p);
Geom::Point direction_vector = c.getDirection();
if (!is_zero(direction_vector)) {
@@ -526,8 +527,8 @@ void Inkscape::ObjectSnapper::_snapPathsConstrained(SnappedConstraints &sc,
// must lie within two points on the constraintline: p_min_on_cl and p_max_on_cl
// The distance between those points is twice the snapping tolerance
Geom::Point const p_proj_on_cl = project_on_linesegment(p, p1_on_cl, p2_on_cl);
- Geom::Point const p_min_on_cl = _desktop->dt2doc(p_proj_on_cl - getSnapperTolerance() * direction_vector);
- Geom::Point const p_max_on_cl = _desktop->dt2doc(p_proj_on_cl + getSnapperTolerance() * direction_vector);
+ Geom::Point const p_min_on_cl = _named_view->snap_manager.getDesktop()->dt2doc(p_proj_on_cl - getSnapperTolerance() * direction_vector);
+ Geom::Point const p_max_on_cl = _named_view->snap_manager.getDesktop()->dt2doc(p_proj_on_cl + getSnapperTolerance() * direction_vector);
Geom::Path cl;
std::vector<Geom::Path> clv;
@@ -547,8 +548,8 @@ void Inkscape::ObjectSnapper::_snapPathsConstrained(SnappedConstraints &sc,
Geom::Point p_inters = p_min_on_cl + ((*m).ta) * (p_max_on_cl - p_min_on_cl);
// When it's within snapping range, then return it
// (within snapping range == between p_min_on_cl and p_max_on_cl == 0 < ta < 1)
- Geom::Coord dist = Geom::L2(_desktop->dt2doc(p_proj_on_cl) - p_inters);
- SnappedPoint s(_desktop->doc2dt(p_inters), SNAPTARGET_PATH, dist, getSnapperTolerance(), getSnapperAlwaysSnap());
+ Geom::Coord dist = Geom::L2(_named_view->snap_manager.getDesktop()->dt2doc(p_proj_on_cl) - p_inters);
+ SnappedPoint s(_named_view->snap_manager.getDesktop()->doc2dt(p_inters), SNAPTARGET_PATH, dist, getSnapperTolerance(), getSnapperAlwaysSnap());
sc.points.push_back(s);
}
}