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