Isis 3.0 Object Programmers' Reference
Home
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
ExportDescription.cpp
1
#include "
ExportDescription.h
"
2
3
#include <float.h>
4
5
#include <QList>
6
7
#include "
CubeAttribute.h
"
8
#include "
FileName.h
"
9
#include "
IString.h
"
10
#include "
IException.h
"
11
#include "
PixelType.h
"
12
13
namespace
Isis {
17
ExportDescription::ExportDescription
() {
18
m_channels
= NULL;
19
m_channels
=
new
QList<ChannelDescription *>
;
20
21
m_type
= Isis::None;
22
23
m_outputPixelNull
= 0.0;
24
m_outputPixelValidMin
= 0.0;
25
m_outputPixelValidMax
= 255.0;
26
m_outputPixelAbsoluteMin
= 0.0;
27
m_outputPixelAbsoluteMax
= 255.0;
28
}
29
30
35
ExportDescription::ExportDescription
(
const
ExportDescription
&descriptionToCopy) {
36
m_channels
= NULL;
37
38
if
(descriptionToCopy.
m_channels
) {
39
m_channels
=
new
QList<ChannelDescription *>
();
40
for
(
int
i = 0; i < descriptionToCopy.
channelCount
(); i++) {
41
const
ExportDescription::ChannelDescription
&
channel
= descriptionToCopy.
channel
(i);
42
CubeAttributeInput
att = channel.
attributes
();
43
if
(channel.
hasCustomRange
()) {
44
addChannel
(channel.
filename
(), att, channel.
inputMinimum
(), channel.
inputMaximum
());
45
}
46
else
{
47
addChannel
(channel.
filename
(), att);
48
}
49
}
50
}
51
52
setPixelType
(descriptionToCopy.
m_type
);
53
}
54
61
ExportDescription
&
ExportDescription::operator=
(
const
ExportDescription
&descriptionToCopy) {
62
if
(
m_channels
) {
63
delete
m_channels
;
64
m_channels
= NULL;
65
}
66
67
if
(descriptionToCopy.
m_channels
) {
68
m_channels
=
new
QList<ChannelDescription *>
();
69
for
(
int
i = 0; i < descriptionToCopy.
channelCount
(); i++) {
70
const
ExportDescription::ChannelDescription
&
channel
= descriptionToCopy.
channel
(i);
71
CubeAttributeInput
att = channel.
attributes
();
72
if
(channel.
hasCustomRange
()) {
73
addChannel
(channel.
filename
(), att, channel.
inputMinimum
(), channel.
inputMaximum
());
74
}
75
else
{
76
addChannel
(channel.
filename
(), att);
77
}
78
}
79
}
80
81
setPixelType
(descriptionToCopy.
m_type
);
82
return
*
this
;
83
}
84
88
ExportDescription::~ExportDescription
() {
89
for
(
int
i = 0; i <
m_channels
->size(); i++)
delete
(*
m_channels
)[i];
90
delete
m_channels
;
91
m_channels
= NULL;
92
}
93
94
101
void
ExportDescription::setPixelType
(
PixelType
type) {
102
m_type
= type;
103
switch
(type) {
104
case
UnsignedByte:
105
m_outputPixelNull
= 0.0;
106
m_outputPixelValidMin
= 1.0;
107
m_outputPixelValidMax
= 255.0;
108
break
;
109
case
SignedWord:
110
m_outputPixelNull
= -32768.0;
111
m_outputPixelValidMin
= -32767.0;
// Changed from -32752.0 since this variable represents
112
// the smallest valid exported pixel value, not our
113
// special pixel min valid value
114
m_outputPixelValidMax
= 32767.0;
115
break
;
116
case
UnsignedWord:
117
m_outputPixelNull
= 0.0;
118
m_outputPixelValidMin
= 1.0;
// Changed from 3.0 since this variable is used to set the
119
// smallest valid exported pixel value, not our special pixel
120
// min valid value
121
m_outputPixelValidMax
= 65535.0;
// Changed from 65522.0 since this variable represents the
122
// largest valid exported pixel value, not our special
123
// pixel max valid value
124
break
;
125
default
:
126
throw
IException
(
IException::Programmer
,
127
"Invalid export pixel type ["
+
toString
(type) +
"]"
,
128
_FILEINFO_
);
129
}
130
// in each case above, the smallest possible output pixel value is the null value
131
m_outputPixelAbsoluteMin
=
m_outputPixelNull
;
132
// in each case above, the largest possible output pixel value is the maximum value
133
m_outputPixelAbsoluteMax
=
m_outputPixelValidMax
;
134
135
}
136
137
143
PixelType
ExportDescription::pixelType
()
const
{
144
return
m_type
;
145
}
146
147
153
double
ExportDescription::outputPixelNull
()
const
{
154
return
m_outputPixelNull
;
155
}
156
157
163
double
ExportDescription::outputPixelValidMin
()
const
{
164
return
m_outputPixelValidMin
;
165
}
166
167
173
double
ExportDescription::outputPixelValidMax
()
const
{
174
return
m_outputPixelValidMax
;
175
}
176
177
183
double
ExportDescription::outputPixelAbsoluteMin
()
const
{
184
return
m_outputPixelAbsoluteMin
;
185
}
186
187
193
double
ExportDescription::outputPixelAbsoluteMax
()
const
{
194
return
m_outputPixelAbsoluteMax
;
195
}
196
197
207
int
ExportDescription::addChannel
(
FileName
filename,
CubeAttributeInput
&att) {
208
209
m_channels
->append(
new
ChannelDescription
(filename, att));
210
return
m_channels
->size() - 1;
211
}
212
213
225
int
ExportDescription::addChannel
(
FileName
filename,
CubeAttributeInput
&att,
226
double
min,
double
max) {
227
228
ChannelDescription
*desc =
new
ChannelDescription
(filename, att);
229
desc->
setInputRange
(min, max);
230
m_channels
->append(desc);
231
return
m_channels
->size() - 1;
232
}
233
234
242
const
ExportDescription::ChannelDescription
&
ExportDescription::channel
(
int
i)
const
{
243
244
return
*(*m_channels)[i];
245
}
246
247
253
int
ExportDescription::channelCount
()
const
{
254
return
m_channels
->size();
255
}
256
257
264
ExportDescription::ChannelDescription::ChannelDescription
(
FileName
&filename,
265
CubeAttributeInput
&att) {
266
267
m_filename
=
filename
;
268
m_att
= att;
269
270
m_customRange
=
false
;
271
m_inputMin
= DBL_MIN;
272
m_inputMax
= DBL_MAX;
273
}
274
275
281
FileName
ExportDescription::ChannelDescription::filename
()
const
{
282
return
m_filename;
283
}
284
285
291
CubeAttributeInput
ExportDescription::ChannelDescription::attributes
()
const
{
292
return
m_att;
293
}
294
295
304
void
ExportDescription::ChannelDescription::setInputRange
(
double
min,
double
max) {
305
306
m_inputMin = min;
307
m_inputMax = max;
308
m_customRange =
true
;
309
}
310
311
318
double
ExportDescription::ChannelDescription::inputMinimum
()
const
{
319
return
m_inputMin;
320
}
321
322
329
double
ExportDescription::ChannelDescription::inputMaximum
()
const
{
330
return
m_inputMax;
331
}
332
333
340
bool
ExportDescription::ChannelDescription::hasCustomRange
()
const
{
341
return
m_customRange;
342
}
343
};
344