summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: abbe3f5)
raw | patch | inline | side by side (parent: abbe3f5)
author | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Thu, 24 Jul 2008 21:02:18 +0000 (21:02 +0000) | ||
committer | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Thu, 24 Jul 2008 21:02:18 +0000 (21:02 +0000) |
src/object-snapper.cpp | patch | blob | history | |
src/object-snapper.h | patch | blob | history |
diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp
index 2e9f1b8de4702d038024c2cdd051387c5a20b843..a9f13c8aba288f2ea32074c7d6f78c417e11195c 100644 (file)
--- a/src/object-snapper.cpp
+++ b/src/object-snapper.cpp
@@ -193,6 +193,11 @@ void Inkscape::ObjectSnapper::_collectNodes(Inkscape::Snapper::PointType const &
bbox_type = (prefs_bbox == 0)?
SPItem::APPROXIMATE_BBOX : SPItem::GEOMETRIC_BBOX;
}
+
+ // Consider the page border for snapping
+ if (_snap_to_page_border) {
+ _getBorderNodes(_points_to_snap_to);
+ }
for (std::vector<SnapCandidate>::const_iterator i = _candidates->begin(); i != _candidates->end(); i++) {
//NR::Matrix i2doc(NR::identity());
}
void Inkscape::ObjectSnapper::_collectPaths(Inkscape::Snapper::PointType const &t,
- bool const &first_point,
- NArtBpath const *border_bpath) const
+ bool const &first_point) const
{
// Now, let's first collect all paths to snap to. If we have a whole bunch of points to snap,
// e.g. when translating an item using the selector tool, then we will only do this for the
@@ -323,14 +327,17 @@ void Inkscape::ObjectSnapper::_collectPaths(Inkscape::Snapper::PointType const &
}
// Consider the page border for snapping
- if (border_bpath != NULL) {
- // make our own copy of the const*
- NArtBpath *new_bpath;
- unsigned const len = sp_bpath_length(border_bpath);
- new_bpath = g_new(NArtBpath, len);
- memcpy(new_bpath, border_bpath, len * sizeof(NArtBpath));
-
- _bpaths_to_snap_to->push_back(new_bpath);
+ if (_snap_to_page_border) {
+ NArtBpath const *border_bpath = _getBorderBPath();
+ if (border_bpath != NULL) {
+ // make our own copy of the const*
+ NArtBpath *new_bpath;
+ unsigned const len = sp_bpath_length(border_bpath);
+ new_bpath = g_new(NArtBpath, len);
+ memcpy(new_bpath, border_bpath, len * sizeof(NArtBpath));
+
+ _bpaths_to_snap_to->push_back(new_bpath);
+ }
}
for (std::vector<SnapCandidate>::const_iterator i = _candidates->begin(); i != _candidates->end(); i++) {
NR::Point const &p,
bool const &first_point,
std::vector<NR::Point> *unselected_nodes,
- SPPath const *selected_path,
- NArtBpath const *border_bpath) const
+ SPPath const *selected_path) const
{
- _collectPaths(t, first_point, border_bpath);
+ _collectPaths(t, first_point);
// Now we can finally do the real snapping, using the paths collected above
SnappedPoint s;
bool success = false;
ConstraintLine const &c) const
{
- // Consider the page's border for snapping to
- NArtBpath const *border_bpath = _snap_to_page_border ? _getBorderBPath() : NULL;
-
- _collectPaths(t, first_point, border_bpath);
+ _collectPaths(t, first_point);
// Now we can finally do the real snapping, using the paths collected above
_findCandidates(sp_document_root(_named_view->document), it, first_point, local_bbox_to_snap, TRANSL_SNAP_XY, false, NR::identity());
}
- if (_snap_to_itemnode || _snap_to_bboxnode) {
+ if (_snap_to_itemnode || _snap_to_bboxnode || _snap_to_page_border) {
_snapNodes(sc, t, p, first_point, unselected_nodes);
}
- // Consider the page's border for snapping to
- NArtBpath const *border_bpath = _snap_to_page_border ? _getBorderBPath() : NULL;
-
if (_snap_to_itempath || _snap_to_bboxpath || _snap_to_page_border) {
unsigned n = (unselected_nodes == NULL) ? 0 : unselected_nodes->size();
if (n > 0) {
g_assert(it->size() == 1);
path = SP_PATH(*it->begin());
}
- _snapPaths(sc, t, p, first_point, unselected_nodes, path, border_bpath);
+ _snapPaths(sc, t, p, first_point, unselected_nodes, path);
} else {
- _snapPaths(sc, t, p, first_point, NULL, NULL, border_bpath);
+ _snapPaths(sc, t, p, first_point, NULL, NULL);
}
}
}
_findCandidates(sp_document_root(_named_view->document), &it, true, NR::Rect(p, p), snap_dim, false, NR::identity());
_snapTranslatingGuideToNodes(sc, Inkscape::Snapper::SNAPPOINT_GUIDE, p, guide_normal);
-
// _snapRotatingGuideToNodes has not been implemented yet.
}
return border_bpath;
}
+
+void Inkscape::ObjectSnapper::_getBorderNodes(std::vector<NR::Point> *points) const
+{
+ Geom::Coord w = sp_document_width(_named_view->document);
+ Geom::Coord h = sp_document_height(_named_view->document);
+ points->push_back(from_2geom(Geom::Point(0,0)));
+ points->push_back(from_2geom(Geom::Point(0,h)));
+ points->push_back(from_2geom(Geom::Point(w,h)));
+ points->push_back(from_2geom(Geom::Point(w,0)));
+}
/*
Local Variables:
mode:c++
diff --git a/src/object-snapper.h b/src/object-snapper.h
index 5d09930c05559b4a27fcf3937b00a3f6972b5ec6..7f6221f8b3be3659e2cc0293c4436feb22fd7c58 100644 (file)
--- a/src/object-snapper.h
+++ b/src/object-snapper.h
NR::Point const &p,
bool const &first_point,
std::vector<NR::Point> *unselected_nodes,
- SPPath const *selected_path,
- NArtBpath const *border_bpath) const;
+ SPPath const *selected_path) const;
void _snapPathsConstrained(SnappedConstraints &sc,
Inkscape::Snapper::PointType const &t,
bool isUnselectedNode(NR::Point const &point, std::vector<NR::Point> const *unselected_nodes) const;
void _collectPaths(Inkscape::Snapper::PointType const &t,
- bool const &first_point,
- NArtBpath const *border_bpath = NULL) const;
+ bool const &first_point) const;
void _clear_paths() const;
NArtBpath const* _getBorderBPath() const;
+ void _getBorderNodes(std::vector<NR::Point> *points) const;
bool _snap_to_itemnode;
bool _snap_to_itempath;