summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2009-04-22 15:36:23 -0400
committerBen Boeckel <MathStuf@gmail.com>2009-04-22 15:36:23 -0400
commit26719dc73ef8a87dd3da032532d890e805bce4bb (patch)
tree4f8310791cb65e9b8181c082ec7f1b1b1f131935
parent214ac803ab9fbfa562d29c3e2e7fa1e5c075e873 (diff)
downloadsigen-26719dc73ef8a87dd3da032532d890e805bce4bb.tar.gz
sigen-26719dc73ef8a87dd3da032532d890e805bce4bb.tar.xz
sigen-26719dc73ef8a87dd3da032532d890e805bce4bb.zip
Move clser method out of WorldPlacement
-rw-r--r--sigmodr/widgets/mapeditor/WorldMapPlacement.cpp22
-rw-r--r--sigmodr/widgets/mapeditor/WorldMapPlacement.h1
2 files changed, 11 insertions, 12 deletions
diff --git a/sigmodr/widgets/mapeditor/WorldMapPlacement.cpp b/sigmodr/widgets/mapeditor/WorldMapPlacement.cpp
index 977b17e1..edd6912a 100644
--- a/sigmodr/widgets/mapeditor/WorldMapPlacement.cpp
+++ b/sigmodr/widgets/mapeditor/WorldMapPlacement.cpp
@@ -41,6 +41,17 @@ static bool touches(const QPolygon& polygon1, const QPolygon& polygon2)
return false;
}
+static const QRect& closer(const QRect& rect1, const QRect& rect2, const QPoint& point)
+{
+ if (rect1.isNull())
+ return rect2;
+ const QPoint rect1Point = rect1.center() - point;
+ const QPoint rect2Point = rect2.center() - point;
+ const int rect1Dist = pow(rect1Point.x(), 2) + pow(rect1Point.y(), 2);
+ const int rect2Dist = pow(rect2Point.x(), 2) + pow(rect2Point.y(), 2);
+ return (rect1Dist < rect2Dist) ? rect1 : rect2;
+}
+
bool WorldMapPlacement::m_cacheGood = false;
QSize WorldMapPlacement::m_size;
QList<QPolygon> WorldMapPlacement::m_polygons;
@@ -192,14 +203,3 @@ QPolygon WorldMapPlacement::mergePolygons(const QPolygon& polygon1, const QPolyg
// TODO: merge the polygons
return polygon1;
}
-
-QRect WorldMapPlacement::closer(const QRect& rect1, const QRect& rect2, const QPoint& point)
-{
- if (rect1.isNull())
- return rect2;
- const QPoint rect1Point = rect1.center() - point;
- const QPoint rect2Point = rect2.center() - point;
- const int rect1Dist = pow(rect1Point.x(), 2) + pow(rect1Point.y(), 2);
- const int rect2Dist = pow(rect2Point.x(), 2) + pow(rect2Point.y(), 2);
- return (rect1Dist < rect2Dist) ? rect1 : rect2;
-}
diff --git a/sigmodr/widgets/mapeditor/WorldMapPlacement.h b/sigmodr/widgets/mapeditor/WorldMapPlacement.h
index 13e4daca..6627c33e 100644
--- a/sigmodr/widgets/mapeditor/WorldMapPlacement.h
+++ b/sigmodr/widgets/mapeditor/WorldMapPlacement.h
@@ -52,7 +52,6 @@ class SIGMODRWIDGETS_NO_EXPORT WorldMapPlacement
void finalize();
QPolygon mergePolygons(const QPolygon& polygon1, const QPolygon& polygon2);
- QRect closer(const QRect& rect1, const QRect& rect2, const QPoint& point);
static bool m_cacheGood;
static QSize m_size;