00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00024
00025 #include <QMap>
00026 #include <QList>
00027 #include <QPointF>
00028
00029 #ifndef QV2DMAP_H
00030 #define QV2DMAP_H
00031
00032 #define SIGNATURE(Point) (Point.x())
00033
00060 #define SIGNATURE(Point) (Point.x())
00061 class QV2DMap: public QMap<double, QPointF>
00062 {
00063 private:
00064 #ifndef DOXYGEN_IGNORE_THIS
00065 QList<QPointF> getClosestPoints2(const QPointF &point, const int n) const;
00066 #endif
00067
00068 public:
00072 void add(const QPointF &point);
00073
00077 QV2DMap(const QList<QPointF> & points = QList<QPointF>());
00078
00082 QPointF getClosestPoint(const QPointF &point) const
00083 {
00084 if (size() == 0)
00085 return QPointF();
00086 else
00087 return getClosestPoints(point, 1).first();
00088 }
00089
00094 QList<QPointF> getClosestPoints(const QPointF &point, const int n) const;
00095
00096 #ifndef DOXYGEN_IGNORE_THIS
00097 static void test();
00098 #endif
00099 };
00100 #endif