From cca66b9ec4e494c1d919bff0f71a820d8afab1fa Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 20:24:48 +0200 Subject: Adding upstream version 1.2.2. Signed-off-by: Daniel Baumann --- src/object/algorithms/bboxsort.h | 54 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 src/object/algorithms/bboxsort.h (limited to 'src/object/algorithms/bboxsort.h') 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 : -- cgit v1.2.3