From 307c46cfba6007781e4c9914797ae41488c9ed72 Mon Sep 17 00:00:00 2001 From: buliabyak Date: Tue, 6 May 2008 05:33:58 +0000 Subject: [PATCH] export bbox sorting machinery --- src/ui/dialog/align-and-distribute.cpp | 20 ++++++++------------ src/ui/dialog/align-and-distribute.h | 11 +++++++++++ 2 files changed, 19 insertions(+), 12 deletions(-) diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp index 9b16320f3..68c083c6f 100644 --- a/src/ui/dialog/align-and-distribute.cpp +++ b/src/ui/dialog/align-and-distribute.cpp @@ -255,24 +255,20 @@ ActionAlign::Coeffs const ActionAlign::_allCoeffs[10] = { {0., 0., 1., 0., 0., 0., 0., 1.} }; -struct BBoxSort -{ - SPItem *item; - float anchor; - NR::Rect bbox; - BBoxSort(SPItem *pItem, NR::Rect bounds, NR::Dim2 orientation, double kBegin, double kEnd) : +BBoxSort::BBoxSort(SPItem *pItem, NR::Rect bounds, NR::Dim2 orientation, double kBegin, double kEnd) : item(pItem), bbox (bounds) - { +{ anchor = kBegin * bbox.min()[orientation] + kEnd * bbox.max()[orientation]; - } - BBoxSort(const BBoxSort &rhs): +} +BBoxSort::BBoxSort(const BBoxSort &rhs) : //NOTE : this copy ctor is called O(sort) when sorting the vector //this is bad. The vector should be a vector of pointers. //But I'll wait the bohem GC before doing that - item(rhs.item), anchor(rhs.anchor), bbox(rhs.bbox) { - } -}; + item(rhs.item), anchor(rhs.anchor), bbox(rhs.bbox) +{ +} + bool operator< (const BBoxSort &a, const BBoxSort &b) { return (a.anchor < b.anchor); diff --git a/src/ui/dialog/align-and-distribute.h b/src/ui/dialog/align-and-distribute.h index a54ac781e..d6cbd377f 100644 --- a/src/ui/dialog/align-and-distribute.h +++ b/src/ui/dialog/align-and-distribute.h @@ -104,6 +104,17 @@ private: AlignAndDistribute& operator=(AlignAndDistribute const &d); }; + +struct BBoxSort +{ + SPItem *item; + float anchor; + NR::Rect bbox; + BBoxSort(SPItem *pItem, NR::Rect bounds, NR::Dim2 orientation, double kBegin, double kEnd); + BBoxSort(const BBoxSort &rhs); +}; +bool operator< (const BBoxSort &a, const BBoxSort &b); + } // namespace Dialog } // namespace UI } // namespace Inkscape -- 2.30.2