summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: fbce30b)
raw | patch | inline | side by side (parent: fbce30b)
author | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Sun, 7 Sep 2008 10:35:07 +0000 (10:35 +0000) | ||
committer | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Sun, 7 Sep 2008 10:35:07 +0000 (10:35 +0000) |
src/object-snapper.cpp | patch | blob | history | |
src/object-snapper.h | patch | blob | history | |
src/snap.cpp | patch | blob | history | |
src/snap.h | patch | blob | history |
diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp
index 90acb7f299b91f63c1de6c98eef9ada21e47a37d..c620e91cdf7e2a5c676fdde524a723de22fdf85c 100644 (file)
--- a/src/object-snapper.cpp
+++ b/src/object-snapper.cpp
#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)
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 */
_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;
* 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()) {
// 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)) {
// 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;
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);
}
}
diff --git a/src/object-snapper.h b/src/object-snapper.h
index 3e7222e23f0914d94ad2efdcc3e2c38db5a7813d..02b4b422b771cb70fd4708dcbe78300bbfb191f3 100644 (file)
--- a/src/object-snapper.h
+++ b/src/object-snapper.h
#include "snapper.h"
#include "sp-path.h"
#include "splivarot.h"
-#include "desktop.h"
struct SPNamedView;
struct SPItem;
void setIncludeItemCenter(bool s) {_include_item_center = s;}
bool getIncludeItemCenter() const {return _include_item_center;}
void setStrictSnapping(bool enabled) {_strict_snapping = enabled;}
- void setDesktop(SPDesktop const *desktop) {_desktop = desktop;}
void guideSnap(SnappedConstraints &sc,
Geom::Point const &p,
Geom::Point const &guide_normal) const;
//(snapping to grids and guides is not affected by this)
bool _strict_snapping;
bool _include_item_center;
- SPDesktop const *_desktop;
};
}
diff --git a/src/snap.cpp b/src/snap.cpp
index 54eb500e15437f310d846c26ca618972ec5190cf..15bc8658d4c56aa9dd0dfbc316a925004616d23a 100644 (file)
--- a/src/snap.cpp
+++ b/src/snap.cpp
@@ -886,8 +886,7 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(Geom::Point const &p, SnappedCo
void SnapManager::setup(SPDesktop const *desktop, bool snapindicator, SPItem const *item_to_ignore, std::vector<Geom::Point> *unselected_nodes)
{
g_assert(desktop != NULL);
- object.setDesktop(desktop);
- _item_to_ignore = item_to_ignore;
+ _item_to_ignore = item_to_ignore;
_items_to_ignore = NULL;
_desktop = desktop;
_snapindicator = snapindicator;
@@ -897,7 +896,6 @@ void SnapManager::setup(SPDesktop const *desktop, bool snapindicator, SPItem con
void SnapManager::setup(SPDesktop const *desktop, bool snapindicator, std::vector<SPItem const *> &items_to_ignore, std::vector<Geom::Point> *unselected_nodes)
{
g_assert(desktop != NULL);
- object.setDesktop(desktop);
_item_to_ignore = NULL;
_items_to_ignore = &items_to_ignore;
_desktop = desktop;
diff --git a/src/snap.h b/src/snap.h
index 02cee70ca867068734ddb264bd8c6f844dbade0d..480ca98691fdf9dc2045276d7865bc98f5f0b283 100644 (file)
--- a/src/snap.h
+++ b/src/snap.h
SnapperList getSnappers() const;
SnapperList getGridSnappers() const;
+ SPDesktop const *getDesktop() const {return _desktop;}
+
void setSnapModeBBox(bool enabled);
void setSnapModeNode(bool enabled);
void setSnapModeGuide(bool enabled);