Engauge Digitizer
2
Toggle main menu visibility
Loading...
Searching...
No Matches
Callback
CallbackDocumentHash.cpp
Go to the documentation of this file.
1
/******************************************************************************************************
2
* (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3
* under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4
* LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5
******************************************************************************************************/
6
7
#include "
CallbackDocumentHash.h
"
8
#include "
EngaugeAssert.h
"
9
#include "
Logger.h
"
10
#include "
Point.h
"
11
#include <QCryptographicHash>
12
#include "
QtToString.h
"
13
#include "
Transformation.h
"
14
15
CallbackDocumentHash::CallbackDocumentHash
(
DocumentAxesPointsRequired
documentAxesPointsRequired) :
16
m_documentAxesPointsRequired (documentAxesPointsRequired),
17
m_documentHash (QCryptographicHash::Md5)
18
{
19
}
20
21
CallbackDocumentHash::~CallbackDocumentHash
()
22
{
23
}
24
25
CallbackSearchReturn
CallbackDocumentHash::callback
(
const
QString &curveName,
26
const
Point
&point)
27
{
28
// LOG4CPP_DEBUG_S is below
29
30
// Capture all important information about the point into the hash. A single string representing all of the point's details is
31
// created, which can be logged, and then that string is added to the hash
32
33
QString details;
34
35
details += curveName.toLatin1();
36
details +=
" "
+ point.
identifier
();
37
details +=
" "
+
QPointFToString
(point.
posScreen
());
38
39
if
(point.
hasOrdinal
()) {
40
details +=
" "
+ QString::number (point.
ordinal
());
41
}
42
43
if
(point.
isAxisPoint
()) {
44
45
switch
(m_documentAxesPointsRequired) {
46
case
DOCUMENT_AXES_POINTS_REQUIRED_2
:
47
// Axis point has same value for both coordinates so we chose one coordinate
48
details +=
" "
+ QString::number (point.
posGraph
().x());
49
break
;
50
51
case
DOCUMENT_AXES_POINTS_REQUIRED_3
:
52
// Axis point has two coordinates
53
details +=
" "
+
QPointFToString
(point.
posGraph
());
54
break
;
55
56
case
DOCUMENT_AXES_POINTS_REQUIRED_4
:
57
// Axis point has one coordinate
58
if
(point.
isXOnly
()) {
59
60
details +=
" "
+ QString::number (point.
posGraph
().x());
61
62
}
else
{
63
64
details +=
" "
+ QString::number (point.
posGraph
().y());
65
66
}
67
break
;
68
}
69
}
70
71
qCDebug(ENGAUGE_LOG) <<
"CallbackDocumentHash::callback details="
<< details.toLatin1().data();
72
73
// Add details to hash
74
m_documentHash.addData (details.toLatin1());
75
76
return
CALLBACK_SEARCH_RETURN_CONTINUE
;
77
}
78
79
DocumentHash
CallbackDocumentHash::hash
()
const
80
{
81
return
m_documentHash.result ();
82
}
CallbackDocumentHash.h
CallbackSearchReturn
CallbackSearchReturn
Return values for search callback methods.
Definition
CallbackSearchReturn.h:18
CALLBACK_SEARCH_RETURN_CONTINUE
@ CALLBACK_SEARCH_RETURN_CONTINUE
Continue normal execution of the search.
Definition
CallbackSearchReturn.h:19
DocumentAxesPointsRequired
DocumentAxesPointsRequired
Definition
DocumentAxesPointsRequired.h:10
DOCUMENT_AXES_POINTS_REQUIRED_3
@ DOCUMENT_AXES_POINTS_REQUIRED_3
Definition
DocumentAxesPointsRequired.h:11
DOCUMENT_AXES_POINTS_REQUIRED_4
@ DOCUMENT_AXES_POINTS_REQUIRED_4
Definition
DocumentAxesPointsRequired.h:12
DOCUMENT_AXES_POINTS_REQUIRED_2
@ DOCUMENT_AXES_POINTS_REQUIRED_2
Definition
DocumentAxesPointsRequired.h:13
DocumentHash
QByteArray DocumentHash
Definition
DocumentHash.h:12
EngaugeAssert.h
Logger.h
Point.h
QPointFToString
QString QPointFToString(const QPointF &pos)
Definition
QtToString.cpp:17
QtToString.h
Transformation.h
CallbackDocumentHash::callback
CallbackSearchReturn callback(const QString &curveName, const Point &point)
Callback method.
Definition
CallbackDocumentHash.cpp:25
CallbackDocumentHash::CallbackDocumentHash
CallbackDocumentHash(DocumentAxesPointsRequired documentAxesPointsRequired)
Single constructor.
Definition
CallbackDocumentHash.cpp:15
CallbackDocumentHash::~CallbackDocumentHash
virtual ~CallbackDocumentHash()
Definition
CallbackDocumentHash.cpp:21
CallbackDocumentHash::hash
DocumentHash hash() const
Computed hash value.
Definition
CallbackDocumentHash.cpp:79
Point
Class that represents one digitized point. The screen-to-graph coordinate transformation is always ex...
Definition
Point.h:26
Point::posGraph
QPointF posGraph(ApplyHasCheck applyHasCheck=KEEP_HAS_CHECK) const
Accessor for graph position. Skip check if copying one instance to another.
Definition
Point.cpp:395
Point::posScreen
QPointF posScreen() const
Accessor for screen position.
Definition
Point.cpp:404
Point::identifier
QString identifier() const
Unique identifier for a specific Point.
Definition
Point.cpp:268
Point::ordinal
double ordinal(ApplyHasCheck applyHasCheck=KEEP_HAS_CHECK) const
Get method for ordinal. Skip check if copying one instance to another.
Definition
Point.cpp:386
Point::hasOrdinal
bool hasOrdinal() const
True if ordinal is defined.
Definition
Point.cpp:258
Point::isAxisPoint
bool isAxisPoint() const
True if point is an axis point. This is used only for sanity checks.
Definition
Point.cpp:281
Point::isXOnly
bool isXOnly() const
In DOCUMENT_AXES_POINTS_REQUIRED_4 modes, this is true/false if y/x coordinate is undefined.
Definition
Point.cpp:286
Generated on
for Engauge Digitizer by
1.17.0