summaryrefslogtreecommitdiffstats
path: root/src/object/algorithms/bboxsort.h
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:24:48 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 18:24:48 +0000
commitcca66b9ec4e494c1d919bff0f71a820d8afab1fa (patch)
tree146f39ded1c938019e1ed42d30923c2ac9e86789 /src/object/algorithms/bboxsort.h
parentInitial commit. (diff)
downloadinkscape-upstream.tar.xz
inkscape-upstream.zip
Adding upstream version 1.2.2.upstream/1.2.2upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/object/algorithms/bboxsort.h')
-rw-r--r--src/object/algorithms/bboxsort.h54
1 files changed, 54 insertions, 0 deletions
diff --git a/src/object/algorithms/bboxsort.h b/src/object/algorithms/bboxsort.h
new file mode 100644
index 0000000..6d15c12
--- /dev/null
+++ b/src/object/algorithms/bboxsort.h
@@ -0,0 +1,54 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+#ifndef SEEN_BBOXSORT_H
+#define SEEN_BBOXSORT_H
+
+/** @file
+ * @brief Simple helper class for sorting objects based on their bounding boxes.
+ */
+/* Authors:
+ * MenTaLguY
+ * Dmitry Kirsanov
+ * Krzysztof KosiƄski
+ *
+ * Copyright (C) 2007-2012 Authors
+ *
+ * Released under GNU GPL v2+, read the file 'COPYING' for more information.
+ */
+/*
+ * Previously part of the Align and Distribute dialog.
+ */
+
+class BBoxSort {
+
+public:
+ BBoxSort(SPItem *item, Geom::Rect const &bounds, Geom::Dim2 orientation, double begin, double end)
+ : item(item)
+ , bbox(bounds)
+ {
+ anchor = begin * bbox.min()[orientation] + end * bbox.max()[orientation];
+ }
+
+ BBoxSort(const BBoxSort &rhs) = default; // Should really be vector of pointers to avoid copying class when sorting.
+ ~BBoxSort() = default;
+
+ double anchor = 0.0;
+ SPItem* item = nullptr;
+ Geom::Rect bbox;
+};
+
+static bool operator< (const BBoxSort &a, const BBoxSort &b) {
+ return a.anchor < b.anchor;
+}
+
+#endif // SEEN_BBOXSORT_H
+
+/*
+ Local Variables:
+ mode:c++
+ c-file-style:"stroustrup"
+ c-file-offsets:((innamespace . 0)(inline-open . 0))
+ indent-tabs-mode:nil
+ fill-column:99
+ End:
+*/
+// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :