Isis 3 Programmer Reference
TargetBody.cpp
1 #include "TargetBody.h"
2 
3 #include <QDataStream>
4 #include <QDebug>
5 #include <QList>
6 #include <QUuid>
7 #include <QXmlStreamWriter>
8 
9 #include "Distance.h"
10 #include "IString.h"
11 #include "Project.h"
12 #include "PvlKeyword.h"
13 #include "PvlObject.h"
15 #include "XmlStackedHandlerReader.h"
16 
17 namespace Isis {
23 TargetBody::TargetBody(Target *target, QObject *parent) : QObject(parent) {
24  m_id = NULL;
25 
26  m_radii.resize(3, Distance());
28 
29  m_bodyCode = new SpiceInt;
30  m_systemCode = new SpiceInt;
31 
32  m_targetName = target->name();
33 
34  m_systemName = target->systemName();
35 
36  m_frametype = target->frameType();
37 
38  // TODO - initialize TargetBody members from target
39  *m_bodyCode = target->naifBodyCode();
41  m_radii[0] = target->radii().at(0);
42  m_radii[1] = target->radii().at(1);
43  m_radii[2] = target->radii().at(2);
44 
45  m_raPole = target->poleRaCoefs();
46  m_decPole = target->poleDecCoefs();
47  m_pm = target->pmCoefs();
48 
49  m_raNutPrec = target->poleRaNutPrecCoefs();
50  m_decNutPrec = target->poleDecNutPrecCoefs();
51  m_pmNutPrec = target->pmNutPrecCoefs();
52 
53  m_sysNutPrec0 = target->sysNutPrecConstants();
54  m_sysNutPrec1 = target->sysNutPrecCoefs();
55 
57  = new TargetBodyDisplayProperties(target->name(), this);
58 
59  m_id = new QUuid(QUuid::createUuid());
60  }
61 
62 
68 /*
69  TargetBody::TargetBody(BundleTargetBodyQsp bundleTargetBody, QObject *parent) : QObject(parent)
70  {
71  m_id = NULL;
72 
73  m_radii.resize(3, Distance());
74  m_sigmaRadii.resize(3, Distance(0.0, Distance::Kilometers));
75 
76  m_bodyCode = new SpiceInt;
77  m_systemCode = new SpiceInt;
78 
79 // m_systemName = bundleTargetBody->systemName();
80 
81  // TODO - initialize TargetBody members from bundleTargetBody
82 // *m_bodyCode = target->naifBodyCode();
83 // *m_systemCode = target->naifPlanetSystemCode();
84  m_radii = bundleTargetBody->radii();
85 // m_sigmaRadii = bundleTargetBody->
86 
87  m_raPole = bundleTargetBody->poleRaCoefs();
88  m_decPole = bundleTargetBody->poleDecCoefs();
89  m_pm = bundleTargetBody->pmCoefs();
90 
91 // m_raNutPrec = bundleTargetBody->poleRaNutPrecCoefs();
92 // m_decNutPrec = bundleTargetBody->poleDecNutPrecCoefs();
93 // m_pmNutPrec = bundleTargetBody->pmNutPrecCoefs();
94 
95 // m_sysNutPrec0 = bundleTargetBody->sysNutPrecConstants();
96 // m_sysNutPrec1 = bundleTargetBody->sysNutPrecCoefs();
97 
98 // m_displayProperties
99 // = new TargetBodyDisplayProperties(target->name(), this);
100 
101  m_id = new QUuid(QUuid::createUuid());
102  }
103 */
104 
105 // TargetBody::TargetBody(Project *project, XmlStackedHandlerReader *xmlReader,
106 // QObject *parent) : QObject(parent) {
107 // TODO: does xml stuff need project???
108 // m_id = NULL;
109 
110 // xmlReader->pushContentHandler(new XmlHandler(this, project));
111 // xmlReader->setErrorHandler(new XmlHandler(this, project));
112 // }
113 
114 
115 
116 // TargetBody::TargetBody(const TargetBody &src)
117 // : m_id(new QUuid(src.m_id->toString())) {
118 //
119 // m_bodyCode = new SpiceInt(*src.m_bodyCode);
120 //
121 // m_radii.resize(3, Distance());
122 // m_sigmaRadii.resize(3, Distance(3.0, Distance::Kilometers));
123 // TODO - radii sigma fudged for now
124 //
125 // for (int i = 0; i < 3; i++) {
126 // m_radii[i] = src.m_radii[i];
127 // m_sigmaRadii[i] = src.m_sigmaRadii[i];
128 // }
129 //
130 // m_displayProperties
131 // = new TargetBodyDisplayProperties(*src.m_displayProperties);
132 //
133 // int fred=1;
134 // m_bodyCode = src.m_bodyCode;
135 // }
136 
137 
142  delete m_id;
143  m_id = NULL;
144 
145  delete m_bodyCode;
146  m_bodyCode = NULL;
147 
148  delete m_systemCode;
149  m_systemCode = NULL;
150  }
151 
152 
153 // TargetBody &TargetBody::operator=(const TargetBody &src) {
154 
155 // if (&src != this) {
156 
157 // delete m_id;
158 // m_id = NULL;
159 // m_id = new QUuid(src.m_id->toString());
160 // }
161 
162 // return *this;
163 // }
164 
165 
173  bool TargetBody::operator==(const TargetBody &src) const {
174 
175  TargetBody *rtargetBody = (TargetBody *) &src;
176 
177  if (*m_bodyCode != rtargetBody->naifBodyCode())
178  return false;
179  if (m_radii[0] != rtargetBody->radiusA())
180  return false;
181  if (m_radii[1] != rtargetBody->radiusB())
182  return false;
183  if (m_radii[2] != rtargetBody->radiusC())
184  return false;
185 
186  return true;
187  }
188 
189 
196  return m_displayProperties;
197  }
198 
199 
206  return m_displayProperties;
207  }
208 
209 
215  return m_targetName;
216  }
217 
218 
224  return m_frametype;
225  }
226 
227 
232  std::vector<Angle> TargetBody::poleRaCoefs() {
233  return m_raPole;
234  }
235 
236 
241  std::vector<Angle> TargetBody::poleDecCoefs() {
242  return m_decPole;
243  }
244 
245 
250  std::vector<Angle> TargetBody::pmCoefs() {
251  return m_pm;
252  }
253 
254 
259  std::vector<double> TargetBody::poleRaNutPrecCoefs() {
260  return m_raNutPrec;
261  }
262 
263 
268  std::vector<double> TargetBody::poleDecNutPrecCoefs() {
269  return m_decNutPrec;
270  }
271 
272 
277  std::vector<double> TargetBody::pmNutPrecCoefs() {
278  return m_pmNutPrec;
279  }
280 
281 
286  std::vector<Angle> TargetBody::sysNutPrecConstants() {
287  return m_sysNutPrec0;
288  }
289 
294  std::vector<Angle> TargetBody::sysNutPrecCoefs() {
295  return m_sysNutPrec1;
296  }
297 
298 
305  SpiceInt TargetBody::naifBodyCode() const {
306  return *m_bodyCode;
307  }
308 
309 
317  return *m_systemCode;
318  }
319 
320 
328  return m_systemName;
329  }
330 
331 
338  return m_radii[0];
339  }
340 
341 
348  return m_sigmaRadii[0];
349  }
350 
351 
358  return m_radii[1];
359  }
360 
361 
368  return m_sigmaRadii[1];
369  }
370 
371 
378  return m_radii[2];
379  }
380 
381 
388  return m_sigmaRadii[2];
389  }
390 
391 
398  Distance meanRadius = m_radii[0] + m_radii[1] + m_radii[2];
399 
400  meanRadius = meanRadius/3.0;
401 
402  return meanRadius;
403  }
404 
405 
413 
415 
416  return sigmaMeanRadius;
417  }
418 
419 
430 // void TargetBody::save(QXmlStreamWriter &stream, const Project *project,
431 // FileName newProjectRoot) const {
432 
433 // stream.writeStartElement("TargetBody");
434 // // save ID, cnet file name, and run time to stream
435 // stream.writeStartElement("generalAttributes");
436 // stream.writeTextElement("id", m_id->toString());
437 // stream.writeTextElement("runTime", runTime());
438 // stream.writeTextElement("fileName", m_controlNetworkFileName->expanded());
439 // stream.writeEndElement(); // end general attributes
440 
441 // // save settings to stream
442 // m_settings->save(stream, project);
443 
444 // // save statistics to stream
445 // m_statisticsResults->save(stream, project);
446 
447 // // save image lists to stream
448 // if ( !m_images->isEmpty() ) {
449 // stream.writeStartElement("imageLists");
450 
451 // for (int i = 0; i < m_images->count(); i++) {
452 // m_images->at(i)->save(stream, project, "");
453 // }
454 
455 // stream.writeEndElement();
456 // }
457 // stream.writeEndElement(); //end TargetBody
458 // }
459 
460 
461 
462 // void TargetBody::save(QXmlStreamWriter &stream, const Project *project) const {
463 
464 // stream.writeStartElement("TargetBody");
465 
466 // // save ID, attributes, and run time to stream
467 // stream.writeStartElement("generalAttributes");
468 // stream.writeTextElement("id", m_id->toString());
469 // stream.writeTextElement("runTime", runTime());
470 // stream.writeEndElement(); // end general attributes
471 
472 // stream.writeEndElement(); //end TargetBody
473 // }
474 
475 
476 
484 // TargetBody::XmlHandler::XmlHandler(TargetBody *TargetBody, Project *project) {
485 // m_xmlHandlerTargetBody = TargetBody;
486 // m_xmlHandlerProject = NULL;
487 // m_xmlHandlerProject = project;
488 // m_xmlHandlerCharacters = "";
489 // }
490 
491 
492 
493 // TargetBody::XmlHandler::~XmlHandler() {
494  // TargetBody passed in is "this" delete+null will cause problems,no?
495 // delete m_xmlHandlerTargetBody;
496 // m_xmlHandlerTargetBody = NULL;
497 
498  // we do not delete this pointer since it was set to a passed in pointer in constructor and we
499  // don't own it... is that right???
500 // delete m_xmlHandlerProject;
501 // m_xmlHandlerProject = NULL;
502 // }
503 
504 
505 
511 // bool TargetBody::XmlHandler::startElement(const QString &namespaceURI, const QString &localName,
512 // const QString &qName, const QXmlAttributes &atts) {
513 // m_xmlHandlerCharacters = "";
514 //
515 // if (XmlStackedHandler::startElement(namespaceURI, localName, qName, atts)) {
516 //
517 // if (localName == "targetBody") {
518 // m_xmlHandlerTargetBody =
519 // BundleSettingsQsp(new TargetBody(m_xmlHandlerProject, reader()));
520 // }
521 // else if (localName == "bundleResults") {
522 // delete m_xmlHandlerBundleResults;
523 // m_xmlHandlerBundleResults = NULL;
524 // m_xmlHandlerBundleResults = new BundleResults(m_xmlHandlerProject, reader());
525 //TODO: need to add constructor for this???
526 // }
527 // else if (localName == "imageList") {
528 // m_xmlHandlerImages->append(new ImageList(m_xmlHandlerProject, reader()));
529 // }
530 // }
531 // return true;
532 // }
533 
534 
535 
536 // bool TargetBody::XmlHandler::characters(const QString &ch) {
537 // m_xmlHandlerCharacters += ch;
538 // return XmlStackedHandler::characters(ch);
539 // }
540 
541 
542 
543 // bool TargetBody::XmlHandler::endElement(const QString &namespaceURI, const QString &localName,
544 // const QString &qName) {
545 // if (localName == "id") {
546 // m_xmlHandlerTargetBody->m_id = NULL;
547 // m_xmlHandlerTargetBody->m_id = new QUuid(m_xmlHandlerCharacters);
548 // }
549 // else if (localName == "runTime") {
550 // m_xmlHandlerTargetBody->m_runTime = m_xmlHandlerCharacters;
551 // }
552 // else if (localName == "fileName") {
553 // m_xmlHandlerTargetBody->m_controlNetworkFileName = NULL;
554 // m_xmlHandlerTargetBody->m_controlNetworkFileName = new FileName(m_xmlHandlerCharacters);
555 // }
556 // else if (localName == "bundleSettings") {
557 // m_xmlHandlerTargetBody->m_settings =
558 // BundleSettingsQsp(new BundleSettings(*m_xmlHandlerBundleSettings));
559 // }
560 // else if (localName == "bundleResults") {
561 // m_xmlHandlerTargetBody->m_statisticsResults = new BundleResults(*m_xmlHandlerBundleResults);
562 // }
563 // if (localName == "imageLists") {
564 // for (int i = 0; i < m_xmlHandlerImages->size(); i++) {
565 // m_xmlHandlerTargetBody->m_images->append(m_xmlHandlerImages->at(i));
566 // }
567 // m_xmlHandlerImages->clear();
568 // }
569 // m_xmlHandlerCharacters = "";
570 // return XmlStackedHandler::endElement(namespaceURI, localName, qName);
571 // }
572 
573 
574 
580  QString TargetBody::id() const {
581  return m_id->toString().remove(QRegExp("[{}]"));
582  }
583 
584 
585 }
std::vector< double > m_pmNutPrec
Coefficients of prime meridian nut/prec terms.
Definition: TargetBody.h:224
std::vector< Angle > m_sysNutPrec0
Constants of planetary system nut/prec periods.
Definition: TargetBody.h:227
TargetBodyDisplayProperties * m_displayProperties
The GUI information for how this Target will be displayed.
Definition: TargetBody.h:210
Container class for TargetBody.
Definition: TargetBody.h:80
std::vector< Angle > sysNutPrecCoefs()
Returns Linear terms of planetary system nut/prec periods.
Definition: TargetBody.cpp:294
std::vector< Angle > sysNutPrecConstants()
Returns constants of planetary system nut/prec periods.
Definition: TargetBody.cpp:286
SpiceInt * m_systemCode
The NaifBodyCode system code.
Definition: TargetBody.h:190
int m_frametype
Fill this in when Debbie or Ken tell me what it is returning.
Definition: TargetBody.h:212
int frameType()
Returns the frame type.
Definition: TargetBody.cpp:223
bool operator==(const TargetBody &src) const
Compares two Target Body objects to see if they are equal.
Definition: TargetBody.cpp:173
~TargetBody()
The second constructor for this class.
Definition: TargetBody.cpp:141
std::vector< Angle > poleDecCoefs()
Returns coefficients of a quadratic polynomial fitting pole dec.
Definition: TargetBody.cpp:241
SpiceInt naifBodyCode() const
This returns the NAIF body code of the target.
Definition: TargetBody.cpp:305
This is the GUI communication mechanism for target body objects.
QString naifPlanetSystemName() const
This returns the body name of the target&#39;s planet system.
Definition: TargetBody.cpp:327
std::vector< Angle > m_raPole
Coefficients of a quadratic polynomial fitting pole ra.
Definition: TargetBody.h:215
SpiceInt naifPlanetSystemCode() const
This returns the NAIF body code of the target&#39;s planet system.
Definition: TargetBody.cpp:316
The distance is being specified in kilometers.
Definition: Distance.h:58
TargetBodyDisplayProperties * displayProperties()
Gets TargetBodyDisplayProperties.
Definition: TargetBody.cpp:195
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
std::vector< double > poleDecNutPrecCoefs()
TargetBody::poleDecNutPrecCoefs.
Definition: TargetBody.cpp:268
std::vector< double > poleRaNutPrecCoefs()
Returns coefficients of pole right ascension nut/prec terms.
Definition: TargetBody.cpp:259
Distance measurement, usually in meters.
Definition: Distance.h:47
std::vector< Angle > m_sysNutPrec1
Linear terms of planetary system nut/prec periods.
Definition: TargetBody.h:228
std::vector< Angle > m_pm
Coefficients of a quadratic polynomial fitting pole pm.
Definition: TargetBody.h:217
std::vector< Distance > m_sigmaRadii
target radii sigmas
Definition: TargetBody.h:205
Distance sigmaMeanRadius() const
Returns the mean radius sigma.
Definition: TargetBody.cpp:411
QString systemName() const
Return planet system name.
Definition: Target.cpp:512
SpiceInt * m_bodyCode
TODO - RETHINK MEMBER VARIABLES AND METHODS The NaifBodyCode value, if it exists in the cube labels...
Definition: TargetBody.h:185
Distance sigmaRadiusC() const
Returns the "c" radius sigma.
Definition: TargetBody.cpp:387
Distance meanRadius() const
Returns the mean radius.
Definition: TargetBody.cpp:397
TargetBody(Target *target, QObject *parent=0)
The first constructor for this class.
Definition: TargetBody.cpp:23
QString id() const
Output format:
Definition: TargetBody.cpp:580
SpiceInt naifPlanetSystemCode() const
This returns the NAIF planet system body code of the target.
Definition: Target.cpp:500
Distance sigmaRadiusB() const
Returns "b" radius sigma.
Definition: TargetBody.cpp:367
SpiceInt naifBodyCode() const
This returns the NAIF body code of the target.
Definition: Target.cpp:487
std::vector< double > pmNutPrecCoefs()
Returns coefficients of the prime meridian nut/prec terms.
Definition: TargetBody.cpp:277
QString name() const
Return target name.
Definition: Target.cpp:506
QString m_targetName
The TargetName as it appears in the original cube.
Definition: TargetBody.h:178
This class is used to create and store valid Isis3 targets.
Definition: Target.h:76
QUuid * m_id
A unique ID for this TargetBody object (useful for others to reference this object when saving to dis...
Definition: TargetBody.h:173
std::vector< Angle > poleRaCoefs()
TargetBody::poleRaCoefs.
Definition: TargetBody.cpp:232
Distance sigmaRadiusA() const
Returns "a" radius sigma.
Definition: TargetBody.cpp:347
Distance radiusA() const
Returns "a" radius.
Definition: TargetBody.cpp:337
std::vector< Distance > m_radii
target radii
Definition: TargetBody.h:200
std::vector< Angle > m_decPole
Coefficients of a quadratic polynomial fitting pole dec.
Definition: TargetBody.h:216
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
Distance radiusB() const
Returns "b" radius.
Definition: TargetBody.cpp:357
QString targetName()
Returns the value stored at TargetName in the original pvl label.
Definition: TargetBody.cpp:214
std::vector< double > m_decNutPrec
Coefficients of pole decliniation nut/prec terms.
Definition: TargetBody.h:223
QString m_systemName
The NaifBodyCode system name.
Definition: TargetBody.h:195
std::vector< double > m_raNutPrec
Coefficients of pole right ascension nut/prec terms.
Definition: TargetBody.h:222
std::vector< Angle > pmCoefs()
Returns coefficients of a quadratic polynomial fitting pole pm.
Definition: TargetBody.cpp:250
Distance radiusC() const
Returns the "c" radius.
Definition: TargetBody.cpp:377
std::vector< Distance > radii() const
Returns the radii of the body in km.
Definition: Target.cpp:522