diff options
| author | bulia byak <buliabyak@gmail.com> | 2007-04-12 07:22:09 +0000 |
|---|---|---|
| committer | buliabyak <buliabyak@users.sourceforge.net> | 2007-04-12 07:22:09 +0000 |
| commit | a24b5812eb45231a9cf93820ed08ad93798c9aab (patch) | |
| tree | 1361a81f9b0ba41a844cdbf0da40c1a477055374 /src | |
| parent | add touchpath mode (diff) | |
| download | inkscape-a24b5812eb45231a9cf93820ed08ad93798c9aab.tar.gz inkscape-a24b5812eb45231a9cf93820ed08ad93798c9aab.zip | |
add method to select objects picked by a vector of points
(bzr r2864)
Diffstat (limited to 'src')
| -rw-r--r-- | src/document.cpp | 24 | ||||
| -rw-r--r-- | src/document.h | 4 |
2 files changed, 27 insertions, 1 deletions
diff --git a/src/document.cpp b/src/document.cpp index 4dd0f3d21..a61dffc0b 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -996,6 +996,30 @@ GSList *sp_document_partial_items_in_box(SPDocument *document, unsigned int dkey return find_items_in_area(NULL, SP_GROUP(document->root), dkey, box, overlaps); } +GSList * +sp_document_items_at_points(SPDocument *document, unsigned const key, std::vector<NR::Point> points) +{ + GSList *items = NULL; + + // When picking along the path, we don't want small objects close together + // (such as hatching strokes) to obscure each other by their deltas, + // so we temporarily set delta to a small value + gdouble saved_delta = prefs_get_double_attribute ("options.cursortolerance", "value", 1.0); + prefs_set_double_attribute ("options.cursortolerance", "value", 0.25); + + for(unsigned int i = 0; i < points.size(); i++) { + SPItem *item = sp_document_item_at_point(document, key, points[i], + false, NULL); + if (item && !g_slist_find(items, item)) + items = g_slist_prepend (items, item); + } + + // and now we restore it back + prefs_set_double_attribute ("options.cursortolerance", "value", saved_delta); + + return items; +} + SPItem * sp_document_item_at_point(SPDocument *document, unsigned const key, NR::Point const p, gboolean const into_groups, SPItem *upto) diff --git a/src/document.h b/src/document.h index 6e4bd8d6c..a3377f398 100644 --- a/src/document.h +++ b/src/document.h @@ -28,6 +28,7 @@ #include "gc-anchored.h" #include <glibmm/ustring.h> #include "verbs.h" +#include <vector> namespace Avoid { class Router; @@ -233,7 +234,8 @@ GSList * sp_document_items_in_box(SPDocument *document, unsigned int dkey, NR::R GSList * sp_document_partial_items_in_box(SPDocument *document, unsigned int dkey, NR::Rect const &box); SPItem* sp_document_item_from_list_at_point_bottom (unsigned int dkey, SPGroup *group, const GSList *list, NR::Point const p, bool take_insensitive = false); SPItem * sp_document_item_at_point (SPDocument *document, unsigned int key, NR::Point const p, gboolean into_groups, SPItem *upto = NULL); -SPItem * sp_document_group_at_point (SPDocument *document, unsigned int key, NR::Point const p); +GSList *sp_document_items_at_points(SPDocument *document, unsigned const key, std::vector<NR::Point> points); +SPItem *sp_document_group_at_point (SPDocument *document, unsigned int key, NR::Point const p); void sp_document_set_uri (SPDocument *document, const gchar *uri); void sp_document_resized_signal_emit (SPDocument *doc, gdouble width, gdouble height); |
