Isis 3 Programmer Reference
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 {
18  m_channels = NULL;
20 
21  m_type = Isis::None;
22 
23  m_outputPixelNull = 0.0;
25  m_outputPixelValidMax = 255.0;
28  }
29 
30 
36  m_channels = NULL;
37 
38  if(descriptionToCopy.m_channels) {
40  for (int i = 0; i < descriptionToCopy.channelCount(); i++) {
41  const ExportDescription::ChannelDescription &channel = descriptionToCopy.channel(i);
43  if (channel.hasCustomRange()) {
45  }
46  else {
47  addChannel(channel.filename(), att);
48  }
49  }
50  }
51 
52  setPixelType(descriptionToCopy.m_type);
53  }
54 
62  if (m_channels) {
63  delete m_channels;
64  m_channels = NULL;
65  }
66 
67  if(descriptionToCopy.m_channels) {
69  for (int i = 0; i < descriptionToCopy.channelCount(); i++) {
70  const ExportDescription::ChannelDescription &channel = descriptionToCopy.channel(i);
72  if (channel.hasCustomRange()) {
74  }
75  else {
76  addChannel(channel.filename(), att);
77  }
78  }
79  }
80 
81  setPixelType(descriptionToCopy.m_type);
82  return *this;
83  }
84 
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 
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:
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
132  // in each case above, the largest possible output pixel value is the maximum value
134 
135  }
136 
137 
144  return m_type;
145  }
146 
147 
154  return m_outputPixelNull;
155  }
156 
157 
164  return m_outputPixelValidMin;
165  }
166 
167 
174  return m_outputPixelValidMax;
175  }
176 
177 
185  }
186 
187 
195  }
196 
197 
208 
209  m_channels->append(new ChannelDescription(filename, att));
210  return m_channels->size() - 1;
211  }
212 
213 
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 
243 
244  return *(*m_channels)[i];
245  }
246 
247 
254  return m_channels->size();
255  }
256 
257 
265  CubeAttributeInput &att) {
266 
268  m_att = att;
269 
270  m_customRange = false;
271  m_inputMin = DBL_MIN;
272  m_inputMax = DBL_MAX;
273  }
274 
275 
282  return m_filename;
283  }
284 
285 
292  return m_att;
293  }
294 
295 
305 
306  m_inputMin = min;
307  m_inputMax = max;
308  m_customRange = true;
309  }
310 
311 
319  return m_inputMin;
320  }
321 
322 
330  return m_inputMax;
331  }
332 
333 
341  return m_customRange;
342  }
343 };
344 
double inputMaximum() const
Returns the input maximum for this channel.
Manipulate and parse attributes of input cube filenames.
virtual ~ExportDescription()
Destruct the export description.
double outputPixelValidMax() const
Returns the output pixel value for the valid maximum.
CubeAttributeInput m_att
Attributes like which band to use from the input cube.
double m_outputPixelValidMin
Value to which minimum valid DNs will be mapped in the exported image file, defaults to 0...
File name manipulation and expansion.
Definition: FileName.h:116
double m_inputMax
Maximum DN in the input, defaults to DBL_MAX.
double m_outputPixelAbsoluteMin
The smallest allowed pixel value in the exported image file.
bool m_customRange
Whether or not the user has specified a custom input DN range.
ChannelDescription(FileName &filename, CubeAttributeInput &att)
Construct the channel description with the given input name and attributes.
double inputMinimum() const
Returns the input minimum for this channel.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:226
PixelType m_type
Pixel type to export the data to, defaults to None.
double outputPixelNull() const
Returns the output pixel value for Null DNs.
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:162
PixelType
Enumerations for Isis Pixel Types.
Definition: PixelType.h:43
FileName m_filename
Input filename of the cube to be treated as a color channel.
double outputPixelAbsoluteMin() const
Returns the absolute minimum value for output pixels.
int addChannel(FileName filename, CubeAttributeInput &att)
Add an export color channel for the given input cube and attributes (typically band number)...
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:40
QList< ChannelDescription * > * m_channels
List of color channels to be exported into the output image.
double m_outputPixelValidMax
Value to which maximum valid DNs will be mapped in the exported image file, defaults to 255...
void setInputRange(double min, double max)
Sets the input range for this channel.
Describes how a series of cubes should be exported.
ExportDescription & operator=(const ExportDescription &descriptionToCopy)
Assignment operator for the export description.
Describes how a cube as a single color channel to be exported.
double m_outputPixelNull
Value to which Null DNs will be mapped in the exported image file, defaults to 0.0.
FileName filename() const
Returns a copy of the filename associated with this channel.
ExportDescription()
Construct the export description.
PixelType pixelType() const
Returns the pixel type.
int channelCount() const
Count of the number of channels in the description.
void setPixelType(PixelType type)
Set the pixel type for the output image.
Isis exception class.
Definition: IException.h:107
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
bool hasCustomRange() const
Returns true if the user of this instance has set a custom input range for this channel.
const ChannelDescription & channel(int i) const
Return the channels description at the given index.
double m_outputPixelAbsoluteMax
The largest allowed pixel value in the exported image file.
double outputPixelAbsoluteMax() const
Returns the absolute maximum value for output pixels.
CubeAttributeInput attributes() const
Returns a copy of the input attributes associated with this channel.
double m_inputMin
Minimum DN in the input, defaults to DBL_MIN.
double outputPixelValidMin() const
Returns the output pixel value for the valid minimum.