USGS

Isis 3.0 Object Programmers' Reference

Home

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);
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 
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);
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 
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