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 #include "PointMatchTriplet.h" 00008 00009 PointMatchTriplet::PointMatchTriplet(int x, 00010 int y, 00011 double correlation) : 00012 m_x (x), 00013 m_y (y), 00014 m_correlation (correlation) 00015 { 00016 } 00017 00018 double PointMatchTriplet::correlation () const 00019 { 00020 return m_correlation; 00021 } 00022 00023 bool PointMatchTriplet::operator<(const PointMatchTriplet &other) const 00024 { 00025 // qSort wants to sort by ascending correlation, but we want to sort by descending correlation. We 00026 // compensate by comparing correlations numerically and flipping the result 00027 00028 bool isLess = false; 00029 00030 if (m_correlation == other.correlation ()) { 00031 00032 // To reduce jumping around, we prefer points on the left when the correlations are equal 00033 isLess = (m_x < other.x()); 00034 00035 } else { 00036 00037 isLess = !(m_correlation < other.correlation ()); 00038 00039 } 00040 00041 return isLess; 00042 } 00043 00044 QPoint PointMatchTriplet::point() const 00045 { 00046 return QPoint (m_x, 00047 m_y); 00048 } 00049 00050 int PointMatchTriplet::x() const 00051 { 00052 return m_x; 00053 } 00054 00055 int PointMatchTriplet::y() const 00056 { 00057 return m_y; 00058 }