00001 /****************************************************************************************************** 00002 * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released * 00003 * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file * 00004 * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. * 00005 ******************************************************************************************************/ 00006 00007 #ifndef CALLBACK_POINT_ORDINAL_H 00008 #define CALLBACK_POINT_ORDINAL_H 00009 00010 #include "CallbackSearchReturn.h" 00011 #include "LineStyle.h" 00012 #include <QPointF> 00013 #include <QString> 00014 #include "Transformation.h" 00015 00016 class Point; 00017 00019 class CallbackPointOrdinal 00020 { 00021 public: 00023 CallbackPointOrdinal(const LineStyle &lineStyle, 00024 const Transformation &transformation, 00025 const QPointF &posScreen); 00026 00028 CallbackSearchReturn callback (const Point &pointStart, 00029 const Point &pointStop); 00030 00032 double ordinal () const; 00033 00034 private: 00035 CallbackPointOrdinal(); 00036 00037 const LineStyle m_lineStyle; 00038 const Transformation m_transformation; 00039 const QPointF m_posScreen; 00040 00041 // Find the line segment using one or two steps: 00042 // 1) If the closest point to m_posScreen is between the endpoints of a line segment, then finding the minimum point-to-line distance 00043 // is sufficient to determine the closest line segment. There is no ambiguity, since only one line segment will have the 00044 // minimum point-to-line distance 00045 // 2) If case 1 does not apply, then there are two cases: 00046 // 2a) The point is just past one terminating line segment. There is no ambiguity, since only one line segment will have the 00047 // minimum point-to-line distance 00048 // 2b) The point is near a vertex between two line segments. There is ambiguity with the two line segments which is resolved 00049 // by comparing the minimum projected-distance-outside-line (minimum value wins) 00050 bool m_haveMinimumDistanceToLine; 00051 double m_minimumDistanceToLine; 00052 double m_minimumProjectedDistanceOutsideLine; 00053 double m_ordinal; // Valid when m_haveMinimumDistanceToLine is true 00054 }; 00055 00056 #endif // CALLBACK_POINT_ORDINAL_H