diff options
| author | Diederik van Lierop <mail@diedenrezi.nl> | 2007-04-17 21:26:43 +0000 |
|---|---|---|
| committer | dvlierop2 <dvlierop2@users.sourceforge.net> | 2007-04-17 21:26:43 +0000 |
| commit | f12da8471875838ac6cf1f8c8db16637cb97c200 (patch) | |
| tree | b5da97b8edbc054dcadf5589e04b9bb744f0b303 /src/object-snapper.cpp | |
| parent | flipping patch by maximilian albert (diff) | |
| download | inkscape-f12da8471875838ac6cf1f8c8db16637cb97c200.tar.gz inkscape-f12da8471875838ac6cf1f8c8db16637cb97c200.zip | |
Improve snapper performance (mainly in by editting WillSnapSomething())
(bzr r2917)
Diffstat (limited to 'src/object-snapper.cpp')
| -rw-r--r-- | src/object-snapper.cpp | 49 |
1 files changed, 30 insertions, 19 deletions
diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp index 5492fc439..e39d398b1 100644 --- a/src/object-snapper.cpp +++ b/src/object-snapper.cpp @@ -38,28 +38,30 @@ void Inkscape::ObjectSnapper::_findCandidates(std::list<SPItem*>& c, std::list<SPItem const *> const &it, NR::Point const &p) const { - SPDesktop const *desktop = SP_ACTIVE_DESKTOP; - for (SPObject* o = sp_object_first_child(r); o != NULL; o = SP_OBJECT_NEXT(o)) { - if (SP_IS_ITEM(o) && !SP_ITEM(o)->isLocked() && !desktop->itemIsHidden(SP_ITEM(o))) { - - /* See if this item is on the ignore list */ - std::list<SPItem const *>::const_iterator i = it.begin(); - while (i != it.end() && *i != o) { - i++; - } - - if (i == it.end()) { - /* See if the item is within range */ - if (SP_IS_GROUP(o)) { - _findCandidates(c, o, it, p); - } else { - NR::Maybe<NR::Rect> b = sp_item_bbox_desktop(SP_ITEM(o)); - if ( b && NR::expand(*b, -getDistance()).contains(p) ) { - c.push_back(SP_ITEM(o)); + if (willSnapSomething()) { + SPDesktop const *desktop = SP_ACTIVE_DESKTOP; + for (SPObject* o = sp_object_first_child(r); o != NULL; o = SP_OBJECT_NEXT(o)) { + if (SP_IS_ITEM(o) && !SP_ITEM(o)->isLocked() && !desktop->itemIsHidden(SP_ITEM(o))) { + + /* See if this item is on the ignore list */ + std::list<SPItem const *>::const_iterator i = it.begin(); + while (i != it.end() && *i != o) { + i++; + } + + if (i == it.end()) { + /* See if the item is within range */ + if (SP_IS_GROUP(o)) { + _findCandidates(c, o, it, p); + } else { + NR::Maybe<NR::Rect> b = sp_item_bbox_desktop(SP_ITEM(o)); + if ( b && NR::expand(*b, -getDistance()).contains(p) ) { + c.push_back(SP_ITEM(o)); + } } } + } - } } } @@ -181,6 +183,15 @@ Inkscape::SnappedPoint Inkscape::ObjectSnapper::_doConstrainedSnap(NR::Point con return _doFreeSnap(p, it); } +/** + * \return true if this Snapper will snap at least one kind of point. + */ +bool Inkscape::ObjectSnapper::willSnapSomething() const +{ + return (_enabled && _snap_to != 0 && (_snap_to_paths || _snap_to_nodes)); +} + + /* Local Variables: mode:c++ |
