Engauge Digitizer 2
Loading...
Searching...
No Matches
CallbackDocumentScrub.cpp
Go to the documentation of this file.
1/******************************************************************************************************
2 * (C) 2018 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
9#include "Point.h"
10#include <QStringList>
11
12extern const QString AXIS_CURVE_NAME;
13
15 m_success (true)
16{
17}
18
20{
21 return m_badPointName;
22}
23
25 const Point &point)
26{
27 QString identifier = point.identifier ();
28
29 QStringList fields = identifier.split (POINT_IDENTIFIER_DELIMITER_SAFE);
30
31 bool successBefore = m_success;
32
33 // Required format is defined by Point::temporaryPointIdentifier and Point::uniqueIdentifierGenerator
34 if (fields.size () == 2) {
35
36 // Temporary point
37 bool isLastNumeric = true;
38 fields [1].toInt (&isLastNumeric);
39 if (fields [0] != AXIS_CURVE_NAME ||
40 !isLastNumeric) {
41
42 m_success = false;
43
44 }
45
46 } else if (fields.size () == 3) {
47
48 // Regular point
49 bool isLastNumeric = true;
50 fields [2].toInt (&isLastNumeric);
51 if (!isLastNumeric) {
52
53 m_success = false;
54
55 }
56
57 } else {
58
59 // Unexpected number of arguments
60 m_success = false;
61
62 }
63
64 if (!m_success && successBefore) {
65 m_badPointName = point.identifier ();
66 }
67
68 return (m_success ? CALLBACK_SEARCH_RETURN_CONTINUE :
70}
71
73{
74 return m_success;
75}
const QString AXIS_CURVE_NAME
CallbackSearchReturn
Return values for search callback methods.
@ CALLBACK_SEARCH_RETURN_CONTINUE
Continue normal execution of the search.
@ CALLBACK_SEARCH_RETURN_INTERRUPT
Immediately terminate the current search.
const QString POINT_IDENTIFIER_DELIMITER_SAFE
CallbackSearchReturn callback(const QString &curveName, const Point &point)
Callback method.
CallbackDocumentScrub()
Single constructor.
bool success() const
Scrub overall result.
QString badPointName() const
Scrub result details. Applies when unsuccessful.
Class that represents one digitized point. The screen-to-graph coordinate transformation is always ex...
Definition Point.h:26
QString identifier() const
Unique identifier for a specific Point.
Definition Point.cpp:268