Isis 3 Programmer Reference
PushFrameCameraCcdLayout.cpp
Go to the documentation of this file.
1 
23 #include <iostream>
24 #include <sstream>
25 
26 #include <SpiceUsr.h>
27 #include <SpiceZfc.h>
28 #include <SpiceZmc.h>
29 
30 #include "FileName.h"
31 #include "IString.h"
33 #include "NaifStatus.h"
34 
35 namespace Isis {
41  m_ccdId = 1;
42  }
43 
44 
51  m_ccdId = ccdId;
52  }
53 
54 
59  }
60 
61 
72  bool PushFrameCameraCcdLayout::addKernel(const QString &kernel) {
73  FileName kern(kernel);
74  if ( kern.isVersioned()) {
75  kern = kern.highestVersion();
76  }
77  m_kernels.Add(kern.expanded());
78  int nloaded = m_kernels.Load();
79  return (nloaded > 0);
80  }
81 
82 
90  QString var = "INS" + toString(m_ccdId) + "_FILTER_SAMPLES";
91  return (getSpiceInt(var));
92  }
93 
94 
102  QString var = "INS" + toString(m_ccdId) + "_FILTER_LINES";
103  return (getSpiceInt(var));
104  }
105 
106 
117  const int &frameId,
118  const QString &name) const {
119  FrameletInfo finfo(frameId);
120  finfo.m_filterName = name;
121 
122  QString base = "INS" + toString(frameId);
123  try {
124  finfo.m_samples = getSpiceInt(base + "_FILTER_SAMPLES");
125  finfo.m_lines = getSpiceInt(base + "_FILTER_LINES");
126  finfo.m_startLine = getSpiceInt(base + "_FILTER_OFFSET");
127  }
128  catch (IException &e) {
129  QString msg = "Could not find layout information for framelet ["
130  + toString(frameId) + "].";
131  throw IException(e, IException::Io, msg, _FILEINFO_);
132  }
133  finfo.m_startSample = 1;
134 
135  if ( finfo.m_filterName.isEmpty()) {
136  try {
137  finfo.m_filterName = getSpiceString(base + "_FILTER_NAME");
138  } catch (IException &ie) {
139  // noop - leave name empty
140  }
141  }
142 
143  return (finfo);
144  }
145 
146 
157  int PushFrameCameraCcdLayout::getSpiceInt(const QString &var,
158  const int index) const {
159  SpiceBoolean found = false;
160  SpiceInt numValuesRead;
161  SpiceInt kernelValue;
162  gipool_c(var.toLatin1().data(), (SpiceInt) index, 1, &numValuesRead,
163  &kernelValue, &found);
164 
165  // Gotta throw an error here if not found
166  if (!found) {
168  QString msg = "Can not find [" + var + "] in text kernels";
169  throw IException(IException::Io, msg, _FILEINFO_);
170  }
171 
172  return ( (int) kernelValue );
173  }
174 
175 
186  double PushFrameCameraCcdLayout::getSpiceDouble(const QString &var,
187  const int index) const {
188  SpiceBoolean found = false;
189  SpiceInt numValuesRead;
190  SpiceDouble kernelValue;
191  gdpool_c(var.toLatin1().data(), (SpiceInt) index, 1, &numValuesRead,
192  &kernelValue, &found);
193 
194  // Gotta throw an error here if not found
195  if (!found) {
197  QString msg = "Can not find [" + var + "] in text kernels";
198  throw IException(IException::Io, msg, _FILEINFO_);
199  }
200 
201  return ( (double) kernelValue );
202  }
203 
204 
215  QString PushFrameCameraCcdLayout::getSpiceString(const QString &var,
216  const int index) const {
217  SpiceBoolean found = false;
218  SpiceInt numValuesRead;
219  char kernelValue[512];
220  gcpool_c(var.toLatin1().data(), (SpiceInt) index, 1, sizeof(kernelValue),
221  &numValuesRead, kernelValue, &found);
222 
223  // Gotta throw an error here if not found
224  if (!found) {
226  QString msg = "Can not find [" + var + "] in text kernels";
227  throw IException(IException::Io, msg, _FILEINFO_);
228  }
229 
230  return ( QString(kernelValue) );
231  }
232 
233 };
FrameletInfo getFrameInfo(const int &frameId, const QString &name="") const
Get the layout information for a framelet.
int ccdLines() const
Return the number of lines in the CCD.
File name manipulation and expansion.
Definition: FileName.h:116
bool addKernel(const QString &kernel)
Add a NAIF kernel to the set of kernels that values will be pulled from.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition: IString.cpp:226
A type of error that occurred when performing an actual I/O operation.
Definition: IException.h:171
QString m_filterName
The name of the framelet.
QString getSpiceString(const QString &var, const int index=0) const
Query the loaded kernels for a string valued keyword.
int ccdSamples() const
Return the number of samples in the CCD.
int getSpiceInt(const QString &var, const int index=0) const
Query the loaded kernels for an integer valued keyword.
Container for the layout of a specific framelet on the detector.
int m_lines
The number of lines in the framelet.
bool Add(const QString &kfile)
Add a new kernel to the list.
Definition: Kernels.cpp:195
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:40
int m_startSample
The first sample of the framelet on the detector.
double getSpiceDouble(const QString &var, const int index=0) const
Query the loaded kernels for a double valued keyword.
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
Definition: FileName.cpp:212
int m_samples
The number of samples in the framelet.
int m_startLine
The first line of the framelet on the detector.
static void CheckErrors(bool resetNaif=true)
This method looks for any naif errors that might have occurred.
Definition: NaifStatus.cpp:43
FileName highestVersion() const
Searches the directory specified in the file name for the highest version of the file name...
Definition: FileName.cpp:329
Isis exception class.
Definition: IException.h:107
virtual ~PushFrameCameraCcdLayout()
Destructor.
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
int Load(const QString &ktype)
Load all kernels with one more types.
Definition: Kernels.cpp:381
bool isVersioned() const
Checks to see if a file name is versioned by date or numerically.
Definition: FileName.cpp:297
PushFrameCameraCcdLayout()
Push frame full CCD layout class.
Kernels m_kernels
NAIF kernel manager.