00001
00002
00003
00004
00005
00006
00007 #include "CallbackDocumentHash.h"
00008 #include "EngaugeAssert.h"
00009 #include "Logger.h"
00010 #include "Point.h"
00011 #include <QCryptographicHash>
00012 #include "QtToString.h"
00013 #include "Transformation.h"
00014
00015 CallbackDocumentHash::CallbackDocumentHash(DocumentAxesPointsRequired documentAxesPointsRequired) :
00016 m_documentAxesPointsRequired (documentAxesPointsRequired),
00017 m_documentHash (QCryptographicHash::Md5)
00018 {
00019 }
00020
00021 CallbackSearchReturn CallbackDocumentHash::callback (const QString &curveName,
00022 const Point &point)
00023 {
00024
00025
00026
00027
00028
00029 QString details;
00030
00031 details += curveName.toLatin1();
00032 details += " " + point.identifier ();
00033 details += " " + QPointFToString (point.posScreen());
00034
00035 if (point.hasOrdinal ()) {
00036 details += " " + QString::number (point.ordinal ());
00037 }
00038
00039 if (point.isAxisPoint()) {
00040
00041 switch (m_documentAxesPointsRequired) {
00042 case DOCUMENT_AXES_POINTS_REQUIRED_2:
00043
00044 details += " " + QString::number (point.posGraph().x());
00045 break;
00046
00047 case DOCUMENT_AXES_POINTS_REQUIRED_3:
00048
00049 details += " " + QPointFToString (point.posGraph());
00050 break;
00051
00052 case DOCUMENT_AXES_POINTS_REQUIRED_4:
00053
00054 if (point.isXOnly()) {
00055
00056 details += " " + QString::number (point.posGraph().x());
00057
00058 } else {
00059
00060 details += " " + QString::number (point.posGraph().y());
00061
00062 }
00063 break;
00064
00065 default:
00066 ENGAUGE_ASSERT (false);
00067 }
00068 }
00069
00070 LOG4CPP_DEBUG_S ((*mainCat)) << "CallbackDocumentHash::callback details=" << details.toLatin1().data();
00071
00072
00073 m_documentHash.addData (details.toLatin1());
00074
00075 return CALLBACK_SEARCH_RETURN_CONTINUE;
00076 }
00077
00078 DocumentHash CallbackDocumentHash::hash () const
00079 {
00080 return m_documentHash.result ();
00081 }