Isis 3.0 Programmer Reference
Back | Home
GuiCamera.cpp
1 #include "GuiCamera.h"
2 
3 #include <QDataStream>
4 #include <QDebug>
5 #include <QList>
6 #include <QUuid>
7 #include <QXmlStreamWriter>
8 
9 #include <hdf5.h>
10 #include <hdf5_hl.h> // in the hdf5 library
11 
12 
13 #include "Camera.h"
15 #include "IString.h"
16 #include "Project.h"
17 #include "PvlKeyword.h"
18 #include "PvlObject.h"
19 #include "XmlStackedHandlerReader.h"
20 
21 namespace Isis {
22 
23 
29  GuiCamera::GuiCamera(Camera *camera, QObject *parent) : QObject(parent) {
30  m_id = NULL;
31 
32 // m_camera = camera;
33 
34  // TODO - initialize GuiCamera members from target
35 // *m_bodyCode = target->naifBodyCode();
36 // m_radii[0] = target->radii().at(0);
37 // m_radii[1] = target->radii().at(1);
38 // m_radii[2] = target->radii().at(2);
39 
44 
45  QString displayStr = m_spacecraftNameShort + "/" + m_instrumentNameShort;
46 
47  m_displayProperties = new GuiCameraDisplayProperties(displayStr, this);
48 
49  m_id = new QUuid(QUuid::createUuid());
50  }
51 
52 
53 
54 // GuiCamera::GuiCamera(Project *project, XmlStackedHandlerReader *xmlReader,
55 // QObject *parent) : QObject(parent) {
56 // TODO: does xml stuff need project???
57 // m_id = NULL;
58 // xmlReader->pushContentHandler(new XmlHandler(this, project));
59 // xmlReader->setErrorHandler(new XmlHandler(this, project));
60 // }
61 
62 
63 
64 // GuiCamera::GuiCamera(const GuiCamera &src)
65 // : m_id(new QUuid(src.m_id->toString())) {
66 //
67 // m_bodyCode = new SpiceInt(*src.m_bodyCode);
68 //
69 // m_radii.resize(3, Distance());
70 // m_sigmaRadii.resize(3, Distance(3.0, Distance::Kilometers));
71 // TODO - radii sigma fudged for now
72 //
73 // for (int i = 0; i < 3; i++) {
74 // m_radii[i] = src.m_radii[i];
75 // m_sigmaRadii[i] = src.m_sigmaRadii[i];
76 // }
77 //
78 // m_displayProperties
79 // = new GuiCameraDisplayProperties(*src.m_displayProperties);
80 //
81 // int fred=1;
82 // m_bodyCode = src.m_bodyCode;
83 // }
84 
85 
86 
92  delete m_id;
93  m_id = NULL;
94  }
95 
96 
97 // GuiCamera &GuiCamera::operator=(const GuiCamera &src) {
98 // if (&src != this) {
99 // delete m_id;
100 // m_id = NULL;
101 // m_id = new QUuid(src.m_id->toString());
102 // }
103 // return *this;
104 // }
105 // Camera *GuiCamera::camera() {
106 // return m_camera;
107 // }
108 
109 
115  bool GuiCamera::operator== (const GuiCamera &srcGuiCamera) const {
116 
117  if (m_displayProperties->displayName() != srcGuiCamera.displayProperties()->displayName())
118  return false;
119 
120  return true;
121  }
122 
123 
124 
125  /*
126  GuiCameraDisplayProperties *GuiCamera::displayProperties() {
127  return m_displayProperties;
128  }
129  */
130 
136  return m_displayProperties;
137  }
138 
139 
140 // PvlObject GuiCamera::pvlObject(QString resultsName, QString settingsName,
141 // QString statisticsName) {
142 
143 // PvlObject pvl(resultsName);
144 // pvl += PvlKeyword("RunTime", runTime());
145 // if (m_controlNetworkFileName->expanded() != "") {
146 // pvl += PvlKeyword("OutputControlNetwork", controlNetworkFileName());
147 // }
148 // pvl += bundleSettings()->pvlObject(settingsName);
149 // pvl += bundleResults()->pvlObject(statisticsName);
150 // return pvl;
151 
152 // }
153 
154 
161 // SpiceInt GuiCamera::naifBodyCode() const {
162 // return *m_bodyCode;
163 // }
164 
165 
171 // Distance GuiCamera::radiusA() const {
172 // return m_radii[0];
173 // }
174 
175 
181 // Distance GuiCamera::sigmaRadiusA() const {
182 // return m_sigmaRadii[0];
183 // }
184 
190 // Distance GuiCamera::radiusB() const {
191 // return m_radii[1];
192 // }
193 
194 
200 // Distance GuiCamera::sigmaRadiusB() const {
201 // return m_sigmaRadii[1];
202 // }
203 
204 
210 // Distance GuiCamera::radiusC() const {
211 // return m_radii[2];
212 // }
213 
214 
220 // Distance GuiCamera::sigmaRadiusC() const {
221 // return m_sigmaRadii[2];
222 // }
223 
224 
230 // Distance GuiCamera::meanRadius() const {
231 // Distance meanRadius = m_radii[0] + m_radii[1] + m_radii[2];
232 
233 // meanRadius = meanRadius/3.0;
234 
235 // return meanRadius;
236 // }
237 
238 
244 // Distance GuiCamera::sigmaMeanRadius() const {
245 // Distance sigmaMeanRadius = m_sigmaRadii[0] + m_sigmaRadii[1] + m_sigmaRadii[2];
246 
247 // sigmaMeanRadius = sigmaMeanRadius/3.0;
248 
249 // return sigmaMeanRadius;
250 // }
251 
252 
263 // void GuiCamera::save(QXmlStreamWriter &stream, const Project *project,
264 // FileName newProjectRoot) const {
265 
266 // stream.writeStartElement("GuiCamera");
267 // // save ID, cnet file name, and run time to stream
268 // stream.writeStartElement("generalAttributes");
269 // stream.writeTextElement("id", m_id->toString());
270 // stream.writeTextElement("runTime", runTime());
271 // stream.writeTextElement("fileName", m_controlNetworkFileName->expanded());
272 // stream.writeEndElement(); // end general attributes
273 
274 // // save settings to stream
275 // m_settings->save(stream, project);
276 
277 // // save statistics to stream
278 // m_statisticsResults->save(stream, project);
279 
280 // // save image lists to stream
281 // if ( !m_images->isEmpty() ) {
282 // stream.writeStartElement("imageLists");
283 
284 // for (int i = 0; i < m_images->count(); i++) {
285 // m_images->at(i)->save(stream, project, "");
286 // }
287 
288 // stream.writeEndElement();
289 // }
290 // stream.writeEndElement(); //end GuiCamera
291 // }
292 
293 
294 
295 // void GuiCamera::save(QXmlStreamWriter &stream, const Project *project) const {
296 
297 // stream.writeStartElement("GuiCamera");
298 
299 // // save ID, attributes, and run time to stream
300 // stream.writeStartElement("generalAttributes");
301 // stream.writeTextElement("id", m_id->toString());
302 // stream.writeTextElement("runTime", runTime());
303 // stream.writeEndElement(); // end general attributes
304 
305 // stream.writeEndElement(); //end GuiCamera
306 // }
307 
308 
309 
317 // GuiCamera::XmlHandler::XmlHandler(GuiCamera *GuiCamera, Project *project) {
318 // m_xmlHandlerGuiCamera = GuiCamera;
319 // m_xmlHandlerProject = NULL;
320 // m_xmlHandlerProject = project;
321 // m_xmlHandlerCharacters = "";
322 // }
323 
324 
325 
326 // GuiCamera::XmlHandler::~XmlHandler() {
327  // GuiCamera passed in is "this" delete+null will cause problems,no?
328 // delete m_xmlHandlerGuiCamera;
329 // m_xmlHandlerGuiCamera = NULL;
330 
331  // we do not delete this pointer since it was set to a passed in pointer in constructor and we
332  // don't own it... is that right???
333 // delete m_xmlHandlerProject;
334 // m_xmlHandlerProject = NULL;
335 // }
336 
337 
338 
344 // bool GuiCamera::XmlHandler::startElement(const QString &namespaceURI, const QString &localName,
345 // const QString &qName, const QXmlAttributes &atts) {
346 // m_xmlHandlerCharacters = "";
347 //
348 // if (XmlStackedHandler::startElement(namespaceURI, localName, qName, atts)) {
349 //
350 // if (localName == "GuiCamera") {
351 // m_xmlHandlerGuiCamera =
352 // BundleSettingsQsp(new GuiCamera(m_xmlHandlerProject, reader()));
353 // }
354 // else if (localName == "bundleResults") {
355 // delete m_xmlHandlerBundleResults;
356 // m_xmlHandlerBundleResults = NULL;
357 // m_xmlHandlerBundleResults = new BundleResults(m_xmlHandlerProject, reader());
358 //TODO: need to add constructor for this???
359 // }
360 // else if (localName == "imageList") {
361 // m_xmlHandlerImages->append(new ImageList(m_xmlHandlerProject, reader()));
362 // }
363 // }
364 // return true;
365 // }
366 
367 
368 
369 // bool GuiCamera::XmlHandler::characters(const QString &ch) {
370 // m_xmlHandlerCharacters += ch;
371 // return XmlStackedHandler::characters(ch);
372 // }
373 
374 
375 
376 // bool GuiCamera::XmlHandler::endElement(const QString &namespaceURI, const QString &localName,
377 // const QString &qName) {
378 // if (localName == "id") {
379 // m_xmlHandlerGuiCamera->m_id = NULL;
380 // m_xmlHandlerGuiCamera->m_id = new QUuid(m_xmlHandlerCharacters);
381 // }
382 // else if (localName == "runTime") {
383 // m_xmlHandlerGuiCamera->m_runTime = m_xmlHandlerCharacters;
384 // }
385 // else if (localName == "fileName") {
386 // m_xmlHandlerGuiCamera->m_controlNetworkFileName = NULL;
387 // m_xmlHandlerGuiCamera->m_controlNetworkFileName = new FileName(m_xmlHandlerCharacters);
388 // }
389 // else if (localName == "bundleSettings") {
390 // m_xmlHandlerGuiCamera->m_settings =
391 // BundleSettingsQsp(new BundleSettings(*m_xmlHandlerBundleSettings));
392 // }
393 // else if (localName == "bundleResults") {
394 // m_xmlHandlerGuiCamera->m_statisticsResults = new BundleResults(*m_xmlHandlerBundleResults);
395 // }
396 // if (localName == "imageLists") {
397 // for (int i = 0; i < m_xmlHandlerImages->size(); i++) {
398 // m_xmlHandlerGuiCamera->m_images->append(m_xmlHandlerImages->at(i));
399 // }
400 // m_xmlHandlerImages->clear();
401 // }
402 // m_xmlHandlerCharacters = "";
403 // return XmlStackedHandler::endElement(namespaceURI, localName, qName);
404 // }
405 
406 
411  QString GuiCamera::id() const {
412  return m_id->toString().remove(QRegExp("[{}]"));
413  }
414 
420  return m_instrumentNameShort;
421  }
422 
428  return m_instrumentNameLong;
429  }
430 
436  return m_spacecraftNameShort;
437  }
438 
444  return m_spacecraftNameLong;
445  }
446 
447 
448 // QDataStream &GuiCamera::write(QDataStream &stream) const {
449 // stream << m_id->toString()
450 // << m_runTime;
451 
452 // return stream;
453 // }
454 
455 
456 
457 // QDataStream &GuiCamera::read(QDataStream &stream) {
458 
459 // QString id;
460 // stream >> id;
461 // delete m_id;
462 // m_id = NULL;
463 // m_id = new QUuid(id);
464 
465 // stream >> m_runTime;
466 
467 // return stream;
468 // }
469 
470 
471 
472 // QDataStream &operator<<(QDataStream &stream, const GuiCamera &GuiCamera) {
473 // return GuiCamera.write(stream);
474 // }
475 
476 
477 
478 // QDataStream &operator>>(QDataStream &stream, GuiCamera &GuiCamera) {
479 // return GuiCamera.read(stream);
480 // }
481 
482 
483 
484 // void GuiCamera::savehdf5(FileName outputfilename) const {
485 // const H5std_string hdfFileName(outputfilename.expanded().toStdString());
486 //Is this the right way to have a dynamic file name? What about PATH?
487 // // Try block to detect exceptions raised by any of the calls inside it
488 // try {
489 // /*
490 // * Turn off the auto-printing when failure occurs so that we can
491 // * handle the errors appropriately
492 // */
493 // H5::Exception::dontPrint();
494 // /*
495 // * Create a new file using H5F_ACC_TRUNC access,
496 // * default file creation properties, and default file
497 // * access properties.
498 // */
499 // H5::H5File hdfFile = H5::H5File( hdfFileName, H5F_ACC_EXCL );
500 // hid_t fileId = hdfFile.getId();
501 
502 // QString objectName = "/GuiCamera";
503 // H5LTset_attribute_string(fileId, objectName.toLatin1(), "runTime", m_runTime.toAscii());
504 // H5LTset_attribute_string(fileId, objectName.toLatin1(), "controlNetworkFileName",
505 // m_controlNetworkFileName->expanded().toLatin1());
506 
507 // //??? H5::Group settingsGroup = H5::Group(hdfFile.createGroup("/GuiCamera/BundleSettings"));
508 // ???
509 // //???H5::Group settingsGroup = hdfFile.createGroup("/GuiCamera/BundleSettings");
510 // QString groupName = objectName + "/BundleSettings";
511 // hid_t groupId = H5Gcreate(fileId, groupName.toLatin1(), H5P_DEFAULT, H5P_DEFAULT,
512 // H5P_DEFAULT);
513 // m_settings->savehdf5(groupId, groupName.toLatin1());
514 // groupName = objectName + "/BundleResults";
515 // H5::Group resultsGroup = H5::Group(hdfFile.createGroup(groupName.toLatin1()));
516 // m_statisticsResults->savehdf5(fileId, resultsGroup);
517 
518 // }
519 // catch (H5::FileIException error) {
520 // QString msg = QString(error.getCDetailMsg());
521 // IException hpfError(IException::Unknown, msg, _FILEINFO_);
522 // msg = "Unable to save GuiCamera to hpf5 file. "
523 // "H5 exception handler has detected a file error.";
524 // throw IException(hpfError, IException::Unknown, msg, _FILEINFO_);
525 // }
526 // }
527 }
QString id() const
This returns the NAIF body code of the target.
Definition: GuiCamera.cpp:411
QString m_spacecraftNameLong
The full spacecraft name.
Definition: GuiCamera.h:172
bool operator==(const GuiCamera &srcGuiCamera) const
Compares two Target Body objects to see if they are equal.
Definition: GuiCamera.cpp:115
QString spacecraftNameShort() const
This method returns the shortened spacecraft name.
Definition: Camera.cpp:2966
QString spacecraftNameLong()
Retrieves the full name of the spacecraft.
Definition: GuiCamera.cpp:443
QString spacecraftNameLong() const
This method returns the full spacecraft name.
Definition: Camera.cpp:2956
QString m_spacecraftNameShort
An abbreviated name for the spacecraft.
Definition: GuiCamera.h:169
QString m_instrumentNameShort
The abbreviated instrument name.
Definition: GuiCamera.h:175
Container class for GuiCamera.
Definition: GuiCamera.h:70
QString spacecraftNameShort()
Retrieves an abbbreviated name for the spacecraft.
Definition: GuiCamera.cpp:435
~GuiCamera()
The Destructor.
Definition: GuiCamera.cpp:91
QUuid * m_id
A unique ID for this GuiCamera object (useful for others to reference this object when saving to disk...
Definition: GuiCamera.h:150
QString instrumentNameLong() const
This method returns the full instrument name.
Definition: Camera.cpp:2936
const GuiCameraDisplayProperties * displayProperties() const
Retrieves the display properties of the camera.
Definition: GuiCamera.cpp:135
QString displayName() const
Returns the display name.
GuiCamera(Camera *camera, QObject *parent=0)
The constructor for this class.
Definition: GuiCamera.cpp:29
QString instrumentNameShort() const
This method returns the shortened instrument name.
Definition: Camera.cpp:2946
QString instrumentNameShort()
Retrieves an abbreviated version for the name of the instrument.
Definition: GuiCamera.cpp:419
This is the GUI communication mechanism for target body objects.
QString instrumentNameLong()
Retrieves a long version for the name of the instrument.
Definition: GuiCamera.cpp:427
QString m_instrumentNameLong
The full instrument name.
Definition: GuiCamera.h:178
GuiCameraDisplayProperties * m_displayProperties
Camera.
Definition: GuiCamera.h:165

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the ISIS Support Center
File Modified: 07/12/2023 23:18:58