Isis 3.0 Object Programmers' Reference
Home
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
ControlMeasureLogData.cpp
1
#include "
ControlMeasureLogData.h
"
2
3
#include <QVariant>
4
5
#include "ControlNetFileV0001.pb.h"
6
#include "ControlNetFileV0002.pb.h"
7
#include "
PvlKeyword.h
"
8
#include "
SpecialPixel.h
"
9
10
namespace
Isis {
14
ControlMeasureLogData::ControlMeasureLogData
() {
15
Init
();
16
}
17
18
25
ControlMeasureLogData::ControlMeasureLogData
(
NumericLogDataType
dataType,
26
double
value) {
27
p_dataType
= dataType;
28
p_numericalValue
= value;
29
}
30
31
38
ControlMeasureLogData::ControlMeasureLogData
(
NumericLogDataType
dataType) {
39
Init
();
40
p_dataType
= dataType;
41
}
42
43
51
ControlMeasureLogData::ControlMeasureLogData
(
PvlKeyword
keywordRep) {
52
Init
();
53
54
QString name = keywordRep.
name
();
55
p_dataType
=
NameToDataType
(name);
56
if
(
p_dataType
!=
InvalidNumericLogDataType
)
57
p_numericalValue
=
toDouble
(keywordRep[0]);
58
}
59
60
67
ControlMeasureLogData::ControlMeasureLogData
(
68
const
ControlNetLogDataProtoV0001_Point_Measure_DataEntry
&protoBuf) {
69
p_dataType
= (
NumericLogDataType
)protoBuf.datatype();
70
p_numericalValue
= protoBuf.datavalue();
71
}
72
73
80
ControlMeasureLogData::ControlMeasureLogData
(
81
const
ControlPointFileEntryV0002_Measure_MeasureLogData
&protoBuf) {
82
if
(protoBuf.has_doubledatatype()) {
83
p_dataType
= (
NumericLogDataType
)protoBuf.doubledatatype();
84
p_numericalValue
= protoBuf.doubledatavalue();
85
}
86
}
87
88
94
ControlMeasureLogData::ControlMeasureLogData
(
const
ControlMeasureLogData
&
95
other) {
96
p_dataType
= other.
p_dataType
;
97
p_numericalValue
= other.
p_numericalValue
;
98
}
99
100
104
ControlMeasureLogData::~ControlMeasureLogData
() {
105
}
106
107
112
void
ControlMeasureLogData::Init
() {
113
p_dataType
=
InvalidNumericLogDataType
;
114
p_numericalValue
=
Null
;
115
}
116
117
123
void
ControlMeasureLogData::SetNumericalValue
(
double
value) {
124
p_numericalValue
= value;
125
}
126
127
134
void
ControlMeasureLogData::SetDataType
(
NumericLogDataType
newDataType) {
135
Init
();
136
p_dataType
= newDataType;
137
}
138
139
146
double
ControlMeasureLogData::GetNumericalValue
()
const
{
147
return
p_numericalValue
;
148
}
149
150
157
ControlMeasureLogData::NumericLogDataType
158
ControlMeasureLogData::GetDataType
()
const
{
159
return
p_dataType
;
160
}
161
162
167
QVariant
ControlMeasureLogData::GetValue
()
const
{
168
return
QVariant(
p_numericalValue
);
169
}
170
171
177
bool
ControlMeasureLogData::IsValid
()
const
{
178
return
(
p_numericalValue
!=
Null
) &&
179
(
p_dataType
!=
InvalidNumericLogDataType
);
180
}
181
182
189
PvlKeyword
ControlMeasureLogData::ToKeyword
()
const
{
190
if
(
IsValid
())
191
return
PvlKeyword
(
DataTypeToName
(
p_dataType
),
toString
(
p_numericalValue
));
192
else
193
return
PvlKeyword
();
194
}
195
196
203
ControlPointFileEntryV0002_Measure_MeasureLogData
204
ControlMeasureLogData::ToProtocolBuffer
()
const
{
205
if
(!
IsValid
()) {
206
IString
msg =
"Cannot write an invalid log data entry to binary format"
;
207
throw
IException
(
IException::Programmer
, msg,
_FILEINFO_
);
208
}
209
210
ControlPointFileEntryV0002_Measure_MeasureLogData
protoBufDataEntry;
211
212
protoBufDataEntry.set_doubledatatype(
p_dataType
);
213
protoBufDataEntry.set_doubledatavalue(
p_numericalValue
);
214
215
return
protoBufDataEntry;
216
}
217
218
226
ControlMeasureLogData::NumericLogDataType
ControlMeasureLogData::NameToDataType
(
227
QString name)
const
{
228
for
(
int
i =
InvalidNumericLogDataType
+ 1;
229
i <
MaximumNumericLogDataType
; i++) {
230
try
{
231
QString thisTypeName =
DataTypeToName
((
NumericLogDataType
) i);
232
233
if
(name == thisTypeName) {
234
return
(
NumericLogDataType
) i;
235
}
236
}
237
catch
(
IException
&) {
238
}
239
}
240
241
return
InvalidNumericLogDataType
;
242
}
243
244
252
QString
ControlMeasureLogData::DataTypeToName
(
NumericLogDataType
type)
const
{
253
switch
(type) {
254
case
InvalidNumericLogDataType
: {
255
IString
msg =
"Cannot convert an invalid data type to a string"
;
256
throw
IException
(
IException::Programmer
, msg,
_FILEINFO_
);
257
}
258
259
case
Obsolete_Eccentricity
:
260
return
"Obsolete_Eccentricity"
;
261
262
case
GoodnessOfFit
:
263
return
"GoodnessOfFit"
;
264
265
case
MinimumPixelZScore
:
266
return
"MinimumPixelZScore"
;
267
268
case
MaximumPixelZScore
:
269
return
"MaximumPixelZScore"
;
270
271
case
PixelShift
:
272
return
"PixelShift"
;
273
274
case
WholePixelCorrelation
:
275
return
"WholePixelCorrelation"
;
276
277
case
SubPixelCorrelation
:
278
return
"SubPixelCorrelation"
;
279
280
case
Obsolete_AverageResidual
:
281
return
"Obsolete_AverageResidual"
;
282
}
283
284
QString msg =
"Unknown data type ["
+
toString
(type) +
"]"
;
285
throw
IException
(
IException::Programmer
, msg,
_FILEINFO_
);
286
}
287
}