From a24b5812eb45231a9cf93820ed08ad93798c9aab Mon Sep 17 00:00:00 2001 From: bulia byak Date: Thu, 12 Apr 2007 07:22:09 +0000 Subject: add method to select objects picked by a vector of points (bzr r2864) --- src/document.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/document.cpp') 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 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) -- cgit v1.2.3