summaryrefslogtreecommitdiffstats
path: root/src/object/algorithms/bboxsort.h
diff options
context:
space:
mode:
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 :