Isis 3 Programmer Reference
MeasureValidationResults.cpp
1 
7 /* SPDX-License-Identifier: CC0-1.0 */
8 
9 #include "MeasureValidationResults.h"
10 
11 #include <QString>
12 #include <QVector>
13 
14 namespace Isis {
15 
16  MeasureValidationResults::MeasureValidationResults() {
17  failures = NULL;
18  errorMsg = NULL;
19 
20  failures = new QVector<Option>();
21  errorMsg = new QString();
22  }
23 
24 
25  MeasureValidationResults::~MeasureValidationResults() {
26  if (failures != NULL) {
27  delete failures;
28  failures = NULL;
29  }
30  if (errorMsg != NULL) {
31  delete errorMsg;
32  errorMsg = NULL;
33  }
34  }
35 
36 
37  bool MeasureValidationResults::isValid() {
38  return failures->size() == 0;
39  }
40 
41 
42  bool MeasureValidationResults::getValidStatus(Option opt) {
43  return !failures->contains(opt);
44  }
45 
46 
47  QString MeasureValidationResults::toString() {
48  return ((errorMsg->isEmpty()) ? "succeeded" : (*errorMsg));
49  }
50 
51 
52  QString MeasureValidationResults::toString(QString serialNumber, QString pointID) {
53  return "Control Measure with Serial Number " + serialNumber +
54  " in Control Point " + pointID + " " +
55  ((errorMsg->isEmpty()) ? "succeeded" : (*errorMsg));
56  }
57 
58 
59  QString MeasureValidationResults::toString(QString sample, QString line,
60  QString serialNumber, QString pointID) {
61  return "Control Measure with position (" + sample + ", " + line +
62  ") of Serial Number " + serialNumber +
63  " in Control Point " + pointID + " " +
64  ((errorMsg->isEmpty()) ? "succeeded" : (*errorMsg));
65  }
66 
67 
68  void MeasureValidationResults::addFailure(Option opt, double tolerance, const char* compare) {
69  failures->push_back(opt);
70 
71  QString failureReason = getFailurePrefix(opt) + "is " + compare + " than tolerance " +
72  QString::number(tolerance);
73  errorMsg->append(failureReason);
74  }
75 
76 
77  void MeasureValidationResults::addFailure(Option opt, double computed, double min, double max) {
78  failures->push_back(opt);
79 
80  QString failureReason = getFailurePrefix(opt) + QString::number(computed) +
81  " is outside range [" + QString::number(min) + ", " +
82  QString::number(max) + "]";
83  errorMsg->append(failureReason);
84  }
85 
86 
87  QString MeasureValidationResults::getFailurePrefix(Option opt) {
88  QString optString = "\n ";
89  switch (opt) {
90  case EmissionAngle:
91  optString += "Emission Angle";
92  break;
93  case IncidenceAngle:
94  optString += "Incidence Angle";
95  break;
96  case DNValue:
97  optString += "DN Value";
98  break;
99  case Resolution:
100  optString += "Resolution";
101  break;
102  case PixelsFromEdge:
103  optString += "Pixels From Edge";
104  break;
105  case MetersFromEdge:
106  optString += "Meters From Edge";
107  break;
108  case SampleResidual:
109  optString += "Sample Residual";
110  break;
111  case LineResidual:
112  optString += "Line Residual";
113  break;
114  case ResidualMagnitude:
115  optString += "Residual Magnitude";
116  break;
117  case SampleShift:
118  optString += "Sample Shift";
119  break;
120  case LineShift:
121  optString += "Line Shift";
122  break;
123  case PixelShift:
124  optString += "Pixel Shift";
125  break;
126  }
127  optString += " ";
128 
129  return ((errorMsg->isEmpty()) ? "failed: " : "") + optString;
130  }
131 };
QVector< Option >
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16