summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 1f203f5)
raw | patch | inline | side by side (parent: 1f203f5)
author | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Sun, 25 Jan 2009 20:02:13 +0000 (20:02 +0000) | ||
committer | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Sun, 25 Jan 2009 20:02:13 +0000 (20:02 +0000) |
src/desktop.h | patch | blob | history | |
src/snap.cpp | patch | blob | history | |
src/snapped-curve.cpp | patch | blob | history | |
src/snapped-curve.h | patch | blob | history |
diff --git a/src/desktop.h b/src/desktop.h
index 50041543c2a2e7e98663faeb83fff56ba91e7f77..e1479d8573fd429768fd71e55edc0b3f4c717d1a 100644 (file)
--- a/src/desktop.h
+++ b/src/desktop.h
void toggleGrids();
void toggleSnapGlobal();
- bool gridsEnabled() { return grids_visible; }
+ bool gridsEnabled() const { return grids_visible; };
void showGrids(bool show, bool dirty_document = true);
bool is_iconified();
diff --git a/src/snap.cpp b/src/snap.cpp
index 7404ed12b8eaea62a60476e40fec1e3837a01f06..04521f07fc64ad4b99cdb1ec18ecbedb0ce21a2a 100644 (file)
--- a/src/snap.cpp
+++ b/src/snap.cpp
SnapperList s;
//FIXME: this code should actually do this: add new grid snappers that are active for this desktop. now it just adds all gridsnappers
- SPDesktop* desktop = SP_ACTIVE_DESKTOP;
- if (desktop && desktop->gridsEnabled()) {
+ if (_desktop && _desktop->gridsEnabled()) {
for ( GSList const *l = _named_view->grids; l != NULL; l = l->next) {
Inkscape::CanvasGrid *grid = (Inkscape::CanvasGrid*) l->data;
s.push_back(grid->snapper);
return t;
//FIXME: this code should actually do this: add new grid snappers that are active for this desktop. now it just adds all gridsnappers
- SPDesktop* desktop = SP_ACTIVE_DESKTOP;
- if (desktop && desktop->gridsEnabled()) {
+ if (_desktop && _desktop->gridsEnabled()) {
bool success = false;
Geom::Point nearest_multiple;
Geom::Coord nearest_distance = NR_HUGE;
// this, so when using multiple grids one can get unexpected results
// Cannot use getGridSnappers() because we need both the grids AND their snappers
- // Therefor we iterate through all grids manually
+ // Therefore we iterate through all grids manually
for (GSList const *l = _named_view->grids; l != NULL; l = l->next) {
Inkscape::CanvasGrid *grid = (Inkscape::CanvasGrid*) l->data;
const Inkscape::Snapper* snapper = grid->snapper;
@@ -787,7 +785,7 @@ Inkscape::SnappedPoint SnapManager::findBestSnap(Geom::Point const &p, SnappedCo
if (snapprefs.getSnapIntersectionCS()) {
// search for the closest snapped intersection of curves
Inkscape::SnappedPoint closestCurvesIntersection;
- if (getClosestIntersectionCS(sc.curves, p, closestCurvesIntersection)) {
+ if (getClosestIntersectionCS(sc.curves, p, closestCurvesIntersection, _desktop->dt2doc())) {
sp_list.push_back(closestCurvesIntersection);
}
}
diff --git a/src/snapped-curve.cpp b/src/snapped-curve.cpp
index 50bc8364879d23c358f64ec61ec66b87f960542b..20d7aea33ccd680bb6e4ff8562c6e29aacd5ce5a 100644 (file)
--- a/src/snapped-curve.cpp
+++ b/src/snapped-curve.cpp
#include <2geom/path-intersection.h>
#include <libnr/nr-convert2geom.h>
-// These two are needed for SP_ACTIVE_DESKTOP; this is a dirty hack
-#include "desktop.h"
-#include "inkscape.h"
-
Inkscape::SnappedCurve::SnappedCurve(Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, Geom::Coord const &snapped_tolerance, bool const &always_snap, bool const &fully_constrained, Geom::Curve const *curve)
{
_distance = snapped_distance;
{
}
-Inkscape::SnappedPoint Inkscape::SnappedCurve::intersect(SnappedCurve const &curve, Geom::Point const &p) const
+Inkscape::SnappedPoint Inkscape::SnappedCurve::intersect(SnappedCurve const &curve, Geom::Point const &p, Geom::Matrix dt2doc) const
{
// Calculate the intersections of two curves, which are both within snapping range, and
// return only the closest intersection
bool const use_this_as_primary = _distance < curve.getSnapDistance();
Inkscape::SnappedCurve const *primaryC = use_this_as_primary ? this : &curve;
Inkscape::SnappedCurve const *secondaryC = use_this_as_primary ? &curve : this;
- // The intersection should in fact be returned in desktop coordinates, but for this
- // we need a desktop: this is a dirty hack
- SPDesktop const *desktop = SP_ACTIVE_DESKTOP;
- best_p = desktop->dt2doc(best_p);
+
+ // The intersection should in fact be returned in desktop coordinates
+ best_p = best_p * dt2doc;
Geom::Coord primaryDist = use_this_as_primary ? Geom::L2(best_p - this->getPoint()) : Geom::L2(best_p - curve.getPoint());
Geom::Coord secondaryDist = use_this_as_primary ? Geom::L2(best_p - curve.getPoint()) : Geom::L2(best_p - this->getPoint());
@@ -110,7 +105,7 @@ bool getClosestCurve(std::list<Inkscape::SnappedCurve> const &list, Inkscape::Sn
}
// search for the closest intersection of two snapped curves, which are both member of the same collection
-bool getClosestIntersectionCS(std::list<Inkscape::SnappedCurve> const &list, Geom::Point const &p, Inkscape::SnappedPoint &result)
+bool getClosestIntersectionCS(std::list<Inkscape::SnappedCurve> const &list, Geom::Point const &p, Inkscape::SnappedPoint &result, Geom::Matrix dt2doc)
{
bool success = false;
@@ -118,7 +113,7 @@ bool getClosestIntersectionCS(std::list<Inkscape::SnappedCurve> const &list, Geo
std::list<Inkscape::SnappedCurve>::const_iterator j = i;
j++;
for (; j != list.end(); j++) {
- Inkscape::SnappedPoint sp = (*i).intersect(*j, p);
+ Inkscape::SnappedPoint sp = (*i).intersect(*j, p, dt2doc);
if (sp.getAtIntersection()) {
// if it's the first point
bool const c1 = !success;
diff --git a/src/snapped-curve.h b/src/snapped-curve.h
index 814777b68953c2f97470e37fb1282552ea9d4190..8414c10eb8839889159816787351637d909e5622 100644 (file)
--- a/src/snapped-curve.h
+++ b/src/snapped-curve.h
SnappedCurve();\r
SnappedCurve(Geom::Point const &snapped_point, Geom::Coord const &snapped_distance, Geom::Coord const &snapped_tolerance, bool const &always_snap, bool const &fully_constrained, Geom::Curve const *curve);\r
~SnappedCurve();\r
- Inkscape::SnappedPoint intersect(SnappedCurve const &curve, Geom::Point const &p) const; //intersect with another SnappedCurve\r
- \r
+ Inkscape::SnappedPoint intersect(SnappedCurve const &curve, Geom::Point const &p, Geom::Matrix dt2doc) const; //intersect with another SnappedCurve\r
+\r
private:\r
Geom::Curve const *_curve;\r
};\r
}\r
\r
bool getClosestCurve(std::list<Inkscape::SnappedCurve> const &list, Inkscape::SnappedCurve &result);\r
-bool getClosestIntersectionCS(std::list<Inkscape::SnappedCurve> const &list, Geom::Point const &p, Inkscape::SnappedPoint &result);\r
+bool getClosestIntersectionCS(std::list<Inkscape::SnappedCurve> const &list, Geom::Point const &p, Inkscape::SnappedPoint &result, Geom::Matrix dt2doc);\r
\r
\r
#endif /* !SEEN_SNAPPEDCURVE_H */\r