From 2566c299e475ce148c1b7f840d1bbe25b79096c1 Mon Sep 17 00:00:00 2001 From: buliabyak Date: Thu, 12 Apr 2007 07:22:09 +0000 Subject: [PATCH] add method to select objects picked by a vector of points --- src/document.cpp | 24 ++++++++++++++++++++++++ src/document.h | 4 +++- 2 files changed, 27 insertions(+), 1 deletion(-) 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) 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 #include "verbs.h" +#include 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 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); -- 2.30.2