Isis 3 Programmer Reference
ExportDescription.cpp
1
6/* SPDX-License-Identifier: CC0-1.0 */
7#include "ExportDescription.h"
8
9#include <float.h>
10#include <QList>
11
12#include "CubeAttribute.h"
13#include "FileName.h"
14#include "IString.h"
15#include "IException.h"
16#include "PixelType.h"
17
18namespace Isis {
23 m_channels = NULL;
24 m_channels = new QList<ChannelDescription *>;
25
26 m_type = Isis::None;
27
33 }
34
35
41 m_channels = NULL;
42
43 if(descriptionToCopy.m_channels) {
44 m_channels = new QList<ChannelDescription *>();
45 for (int i = 0; i < descriptionToCopy.channelCount(); i++) {
46 const ExportDescription::ChannelDescription &channel = descriptionToCopy.channel(i);
47 CubeAttributeInput att = channel.attributes();
48 if (channel.hasCustomRange()) {
49 addChannel(channel.filename(), att, channel.inputMinimum(), channel.inputMaximum());
50 }
51 else {
52 addChannel(channel.filename(), att);
53 }
54 }
55 }
56
57 setPixelType(descriptionToCopy.m_type);
58 }
59
67 if (m_channels) {
68 delete m_channels;
69 m_channels = NULL;
70 }
71
72 if(descriptionToCopy.m_channels) {
73 m_channels = new QList<ChannelDescription *>();
74 for (int i = 0; i < descriptionToCopy.channelCount(); i++) {
75 const ExportDescription::ChannelDescription &channel = descriptionToCopy.channel(i);
76 CubeAttributeInput att = channel.attributes();
77 if (channel.hasCustomRange()) {
78 addChannel(channel.filename(), att, channel.inputMinimum(), channel.inputMaximum());
79 }
80 else {
81 addChannel(channel.filename(), att);
82 }
83 }
84 }
85
86 setPixelType(descriptionToCopy.m_type);
87 return *this;
88 }
89
94 for (int i = 0; i < m_channels->size(); i++) delete (*m_channels)[i];
95 delete m_channels;
96 m_channels = NULL;
97 }
98
99
107 m_type = type;
108 switch (type) {
109 case UnsignedByte:
110 m_outputPixelNull = 0.0;
112 m_outputPixelValidMax = 255.0;
113 break;
114 case SignedWord:
115 m_outputPixelNull = -32768.0;
116 m_outputPixelValidMin = -32767.0; // Changed from -32752.0 since this variable represents
117 // the smallest valid exported pixel value, not our
118 // special pixel min valid value
119 m_outputPixelValidMax = 32767.0;
120 break;
121 case UnsignedWord:
122 m_outputPixelNull = 0.0;
123 m_outputPixelValidMin = 1.0; // Changed from 3.0 since this variable is used to set the
124 // smallest valid exported pixel value, not our special pixel
125 // min valid value
126 m_outputPixelValidMax = 65535.0; // Changed from 65522.0 since this variable represents the
127 // largest valid exported pixel value, not our special
128 // pixel max valid value
129 break;
130 default:
132 "Invalid export pixel type [" + toString(type) + "]",
133 _FILEINFO_);
134 }
135 // in each case above, the smallest possible output pixel value is the null value
137 // in each case above, the largest possible output pixel value is the maximum value
139
140 }
141
142
149 return m_type;
150 }
151
152
159 return m_outputPixelNull;
160 }
161
162
171
172
181
182
191
192
201
202
213
214 m_channels->append(new ChannelDescription(filename, att));
215 return m_channels->size() - 1;
216 }
217
218
231 double min, double max) {
232
233 ChannelDescription *desc = new ChannelDescription(filename, att);
234 desc->setInputRange(min, max);
235 m_channels->append(desc);
236 return m_channels->size() - 1;
237 }
238
239
248
249 return *(*m_channels)[i];
250 }
251
252
259 return m_channels->size();
260 }
261
262
270 CubeAttributeInput &att) {
271
273 m_att = att;
274
275 m_customRange = false;
276 m_inputMin = DBL_MIN;
277 m_inputMax = DBL_MAX;
278 }
279
280
287 return m_filename;
288 }
289
290
299
300
310
311 m_inputMin = min;
312 m_inputMax = max;
313 m_customRange = true;
314 }
315
316
324 return m_inputMin;
325 }
326
327
335 return m_inputMax;
336 }
337
338
346 return m_customRange;
347 }
348};
349
Manipulate and parse attributes of input cube filenames.
Describes how a cube as a single color channel to be exported.
double inputMinimum() const
Returns the input minimum for this channel.
CubeAttributeInput m_att
Attributes like which band to use from the input cube.
void setInputRange(double min, double max)
Sets the input range for this channel.
bool m_customRange
Whether or not the user has specified a custom input DN range.
double m_inputMin
Minimum DN in the input, defaults to DBL_MIN.
double inputMaximum() const
Returns the input maximum for this channel.
FileName m_filename
Input filename of the cube to be treated as a color channel.
ChannelDescription(FileName &filename, CubeAttributeInput &att)
Construct the channel description with the given input name and attributes.
bool hasCustomRange() const
Returns true if the user of this instance has set a custom input range for this channel.
FileName filename() const
Returns a copy of the filename associated with this channel.
double m_inputMax
Maximum DN in the input, defaults to DBL_MAX.
CubeAttributeInput attributes() const
Returns a copy of the input attributes associated with this channel.
Describes how a series of cubes should be exported.
ExportDescription()
Construct the export description.
PixelType m_type
Pixel type to export the data to, defaults to None.
double m_outputPixelNull
Value to which Null DNs will be mapped in the exported image file, defaults to 0.0.
int addChannel(FileName filename, CubeAttributeInput &att)
Add an export color channel for the given input cube and attributes (typically band number).
QList< ChannelDescription * > * m_channels
List of color channels to be exported into the output image.
const ChannelDescription & channel(int i) const
Return the channels description at the given index.
double outputPixelAbsoluteMax() const
Returns the absolute maximum value for output pixels.
double outputPixelValidMin() const
Returns the output pixel value for the valid minimum.
double outputPixelAbsoluteMin() const
Returns the absolute minimum value for output pixels.
double m_outputPixelAbsoluteMin
The smallest allowed pixel value in the exported image file.
double m_outputPixelAbsoluteMax
The largest allowed pixel value in the exported image file.
PixelType pixelType() const
Returns the pixel type.
int channelCount() const
Count of the number of channels in the description.
double outputPixelNull() const
Returns the output pixel value for Null DNs.
void setPixelType(PixelType type)
Set the pixel type for the output image.
ExportDescription & operator=(const ExportDescription &descriptionToCopy)
Assignment operator for the export description.
double outputPixelValidMax() const
Returns the output pixel value for the valid maximum.
double m_outputPixelValidMin
Value to which minimum valid DNs will be mapped in the exported image file, defaults to 0....
virtual ~ExportDescription()
Destruct the export description.
double m_outputPixelValidMax
Value to which maximum valid DNs will be mapped in the exported image file, defaults to 255....
File name manipulation and expansion.
Definition FileName.h:100
Isis exception class.
Definition IException.h:91
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition IException.h:146
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition IString.cpp:211
PixelType
Enumerations for Isis Pixel Types.
Definition PixelType.h:27