Isis 3 Programmer Reference
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 "Camera.h"
11 #include "IString.h"
12 #include "Project.h"
13 #include "PvlKeyword.h"
14 #include "PvlObject.h"
15 #include "XmlStackedHandlerReader.h"
16 
17 namespace Isis {
18 
19 
25  GuiCamera::GuiCamera(Camera *camera, QObject *parent) : QObject(parent) {
26  m_id = NULL;
27 
28 // m_camera = camera;
29 
30  // TODO - initialize GuiCamera members from target
31 // *m_bodyCode = target->naifBodyCode();
32 // m_radii[0] = target->radii().at(0);
33 // m_radii[1] = target->radii().at(1);
34 // m_radii[2] = target->radii().at(2);
35 
36  m_instrumentId = camera->instrumentId();
37 
42 
43  QString displayStr = m_spacecraftNameShort + "/" + m_instrumentNameShort;
44 
45  m_displayProperties = new GuiCameraDisplayProperties(displayStr, this);
46 
47  m_id = new QUuid(QUuid::createUuid());
48  }
49 
50 
51 
52 // GuiCamera::GuiCamera(Project *project, XmlStackedHandlerReader *xmlReader,
53 // QObject *parent) : QObject(parent) {
54 // TODO: does xml stuff need project???
55 // m_id = NULL;
56 // xmlReader->pushContentHandler(new XmlHandler(this, project));
57 // xmlReader->setErrorHandler(new XmlHandler(this, project));
58 // }
59 
60 
61 
62 // GuiCamera::GuiCamera(const GuiCamera &src)
63 // : m_id(new QUuid(src.m_id->toString())) {
64 //
65 // m_bodyCode = new SpiceInt(*src.m_bodyCode);
66 //
67 // m_radii.resize(3, Distance());
68 // m_sigmaRadii.resize(3, Distance(3.0, Distance::Kilometers));
69 // TODO - radii sigma fudged for now
70 //
71 // for (int i = 0; i < 3; i++) {
72 // m_radii[i] = src.m_radii[i];
73 // m_sigmaRadii[i] = src.m_sigmaRadii[i];
74 // }
75 //
76 // m_displayProperties
77 // = new GuiCameraDisplayProperties(*src.m_displayProperties);
78 //
79 // int fred=1;
80 // m_bodyCode = src.m_bodyCode;
81 // }
82 
83 
84 
90  delete m_id;
91  m_id = NULL;
92  }
93 
94 
95 // GuiCamera &GuiCamera::operator=(const GuiCamera &src) {
96 // if (&src != this) {
97 // delete m_id;
98 // m_id = NULL;
99 // m_id = new QUuid(src.m_id->toString());
100 // }
101 // return *this;
102 // }
103 // Camera *GuiCamera::camera() {
104 // return m_camera;
105 // }
106 
107 
113  bool GuiCamera::operator== (const GuiCamera &srcGuiCamera) const {
114 
115  if (m_displayProperties->displayName() != srcGuiCamera.displayProperties()->displayName())
116  return false;
117 
118  return true;
119  }
120 
121 
122 
123  /*
124  GuiCameraDisplayProperties *GuiCamera::displayProperties() {
125  return m_displayProperties;
126  }
127  */
128 
134  return m_displayProperties;
135  }
136 
137 
138 
139 
150 // void GuiCamera::save(QXmlStreamWriter &stream, const Project *project,
151 // FileName newProjectRoot) const {
152 
153 // stream.writeStartElement("GuiCamera");
154 // // save ID, cnet file name, and run time to stream
155 // stream.writeStartElement("generalAttributes");
156 // stream.writeTextElement("id", m_id->toString());
157 // stream.writeTextElement("runTime", runTime());
158 // stream.writeTextElement("fileName", m_controlNetworkFileName->expanded());
159 // stream.writeEndElement(); // end general attributes
160 
161 // // save settings to stream
162 // m_settings->save(stream, project);
163 
164 // // save statistics to stream
165 // m_statisticsResults->save(stream, project);
166 
167 // // save image lists to stream
168 // if ( !m_images->isEmpty() ) {
169 // stream.writeStartElement("imageLists");
170 
171 // for (int i = 0; i < m_images->count(); i++) {
172 // m_images->at(i)->save(stream, project, "");
173 // }
174 
175 // stream.writeEndElement();
176 // }
177 // stream.writeEndElement(); //end GuiCamera
178 // }
179 
180 
181 
182 // void GuiCamera::save(QXmlStreamWriter &stream, const Project *project) const {
183 
184 // stream.writeStartElement("GuiCamera");
185 
186 // // save ID, attributes, and run time to stream
187 // stream.writeStartElement("generalAttributes");
188 // stream.writeTextElement("id", m_id->toString());
189 // stream.writeTextElement("runTime", runTime());
190 // stream.writeEndElement(); // end general attributes
191 
192 // stream.writeEndElement(); //end GuiCamera
193 // }
194 
195 
196 
204 // GuiCamera::XmlHandler::XmlHandler(GuiCamera *GuiCamera, Project *project) {
205 // m_xmlHandlerGuiCamera = GuiCamera;
206 // m_xmlHandlerProject = NULL;
207 // m_xmlHandlerProject = project;
208 // m_xmlHandlerCharacters = "";
209 // }
210 
211 
212 
213 // GuiCamera::XmlHandler::~XmlHandler() {
214  // GuiCamera passed in is "this" delete+null will cause problems,no?
215 // delete m_xmlHandlerGuiCamera;
216 // m_xmlHandlerGuiCamera = NULL;
217 
218  // we do not delete this pointer since it was set to a passed in pointer in constructor and we
219  // don't own it... is that right???
220 // delete m_xmlHandlerProject;
221 // m_xmlHandlerProject = NULL;
222 // }
223 
224 
225 
231 // bool GuiCamera::XmlHandler::startElement(const QString &namespaceURI, const QString &localName,
232 // const QString &qName, const QXmlAttributes &atts) {
233 // m_xmlHandlerCharacters = "";
234 //
235 // if (XmlStackedHandler::startElement(namespaceURI, localName, qName, atts)) {
236 //
237 // if (localName == "GuiCamera") {
238 // m_xmlHandlerGuiCamera =
239 // BundleSettingsQsp(new GuiCamera(m_xmlHandlerProject, reader()));
240 // }
241 // else if (localName == "bundleResults") {
242 // delete m_xmlHandlerBundleResults;
243 // m_xmlHandlerBundleResults = NULL;
244 // m_xmlHandlerBundleResults = new BundleResults(m_xmlHandlerProject, reader());
245 //TODO: need to add constructor for this???
246 // }
247 // else if (localName == "imageList") {
248 // m_xmlHandlerImages->append(new ImageList(m_xmlHandlerProject, reader()));
249 // }
250 // }
251 // return true;
252 // }
253 
254 
255 
256 // bool GuiCamera::XmlHandler::characters(const QString &ch) {
257 // m_xmlHandlerCharacters += ch;
258 // return XmlStackedHandler::characters(ch);
259 // }
260 
261 
262 
263 // bool GuiCamera::XmlHandler::endElement(const QString &namespaceURI, const QString &localName,
264 // const QString &qName) {
265 // if (localName == "id") {
266 // m_xmlHandlerGuiCamera->m_id = NULL;
267 // m_xmlHandlerGuiCamera->m_id = new QUuid(m_xmlHandlerCharacters);
268 // }
269 // else if (localName == "runTime") {
270 // m_xmlHandlerGuiCamera->m_runTime = m_xmlHandlerCharacters;
271 // }
272 // else if (localName == "fileName") {
273 // m_xmlHandlerGuiCamera->m_controlNetworkFileName = NULL;
274 // m_xmlHandlerGuiCamera->m_controlNetworkFileName = new FileName(m_xmlHandlerCharacters);
275 // }
276 // else if (localName == "bundleSettings") {
277 // m_xmlHandlerGuiCamera->m_settings =
278 // BundleSettingsQsp(new BundleSettings(*m_xmlHandlerBundleSettings));
279 // }
280 // else if (localName == "bundleResults") {
281 // m_xmlHandlerGuiCamera->m_statisticsResults = new BundleResults(*m_xmlHandlerBundleResults);
282 // }
283 // if (localName == "imageLists") {
284 // for (int i = 0; i < m_xmlHandlerImages->size(); i++) {
285 // m_xmlHandlerGuiCamera->m_images->append(m_xmlHandlerImages->at(i));
286 // }
287 // m_xmlHandlerImages->clear();
288 // }
289 // m_xmlHandlerCharacters = "";
290 // return XmlStackedHandler::endElement(namespaceURI, localName, qName);
291 // }
292 
293 
298  QString GuiCamera::id() const {
299  return m_id->toString().remove(QRegExp("[{}]"));
300  }
301 
302 
308  return m_instrumentId;
309  }
310 
311 
317  return m_instrumentNameShort;
318  }
319 
320 
326  return m_instrumentNameLong;
327  }
328 
329 
335  return m_spacecraftNameShort;
336  }
337 
338 
344  return m_spacecraftNameLong;
345  }
346 
347 
348 
349 }
QString instrumentNameShort() const
This method returns the shortened instrument name.
Definition: Camera.cpp:2908
QString m_spacecraftNameLong
The full spacecraft name.
Definition: GuiCamera.h:172
QString spacecraftNameLong()
Retrieves the full name of the spacecraft.
Definition: GuiCamera.cpp:343
QString m_spacecraftNameShort
An abbreviated name for the spacecraft.
Definition: GuiCamera.h:170
QString displayName() const
Returns the display name.
QString m_instrumentNameShort
The abbreviated instrument name.
Definition: GuiCamera.h:174
QString instrumentNameLong() const
This method returns the full instrument name.
Definition: Camera.cpp:2898
QString instrumentId()
Retrieve the InstrumentId as appears in the original cube label.
Definition: GuiCamera.cpp:307
Container class for GuiCamera.
Definition: GuiCamera.h:72
QString spacecraftNameShort()
Retrieves an abbbreviated name for the spacecraft.
Definition: GuiCamera.cpp:334
~GuiCamera()
The Destructor.
Definition: GuiCamera.cpp:89
QUuid * m_id
A unique ID for this GuiCamera object (useful for others to reference this object when saving to disk...
Definition: GuiCamera.h:151
QString id() const
Output format:
Definition: GuiCamera.cpp:298
QString instrumentId()
This method returns the InstrumentId as it appears in the cube.
Definition: Camera.cpp:2888
QString m_instrumentId
The InstrumentId as it appears on the cube.
Definition: GuiCamera.h:168
GuiCamera(Camera *camera, QObject *parent=0)
The constructor for this class.
Definition: GuiCamera.cpp:25
QString spacecraftNameLong() const
This method returns the full spacecraft name.
Definition: Camera.cpp:2918
bool operator==(const GuiCamera &srcGuiCamera) const
Compares two Target Body objects to see if they are equal.
Definition: GuiCamera.cpp:113
QString instrumentNameShort()
Retrieves an abbreviated version for the name of the instrument.
Definition: GuiCamera.cpp:316
The GUI communication mechanism for target body objects.
QString spacecraftNameShort() const
This method returns the shortened spacecraft name.
Definition: Camera.cpp:2928
QString instrumentNameLong()
Retrieves a long version for the name of the instrument.
Definition: GuiCamera.cpp:325
QString m_instrumentNameLong
The full instrument name.
Definition: GuiCamera.h:176
const GuiCameraDisplayProperties * displayProperties() const
Retrieves the display properties of the camera.
Definition: GuiCamera.cpp:133
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
GuiCameraDisplayProperties * m_displayProperties
Camera.
Definition: GuiCamera.h:166