Isis 3 Programmer Reference
AbstractPointItem.cpp
1
7/* SPDX-License-Identifier: CC0-1.0 */
8
9#include "AbstractPointItem.h"
10
11#include <QDateTime>
12#include <QMessageBox>
13#include <QString>
14#include <QVariant>
15
16#include "CnetDisplayProperties.h"
17#include "ControlMeasure.h"
18#include "ControlNet.h"
19#include "ControlPoint.h"
20#include "IException.h"
21#include "Latitude.h"
22#include "Longitude.h"
23#include "TableColumn.h"
24#include "TableColumnList.h"
25
26
27namespace Isis {
28 QString AbstractPointItem::getColumnName(Column col) {
29 CnetDisplayProperties *displayProperties = CnetDisplayProperties::getInstance();
30 bool latLonRadiusCoordDisplay = false;
31 if (displayProperties->coordinateDisplayType() == CnetDisplayProperties::LatLonRadius) {
32 latLonRadiusCoordDisplay = true;
33 }
34
35 switch (col) {
36 case Id:
37 return "Point ID";
38 case PointType:
39 return "Point Type";
40 case ChooserName:
41 return "Chooser Name";
42 case DateTime:
43 return "Date Time";
44 case EditLock:
45 return "Edit Lock";
46 case Ignored:
47 return "Ignored";
48 case Reference:
49 return "Reference";
50 case AdjustedSPCoord1:
51 if (latLonRadiusCoordDisplay) {
52 return "Adjusted SP Lat";
53 }
54 else {
55 return "Adjusted SP X";
56 }
57 case AdjustedSPCoord2:
58 if (latLonRadiusCoordDisplay) {
59 return "Adjusted SP Lon";
60 }
61 else {
62 return "Adjusted SP Y";
63 }
64 case AdjustedSPCoord3:
65 if (latLonRadiusCoordDisplay) {
66 return "Adjusted SP Radius";
67 }
68 else {
69 return "Adjusted SP Z";
70 }
71 case AdjustedSPCoord1Sigma:
72 if (latLonRadiusCoordDisplay) {
73 return "Adjusted SP Lat Sigma";
74 }
75 else {
76 return "Adjusted SP X Sigma";
77 }
78 case AdjustedSPCoord2Sigma:
79 if (latLonRadiusCoordDisplay) {
80 return "Adjusted SP Lon Sigma";
81 }
82 else {
83 return "Adjusted SP Y Sigma";
84 }
85 case AdjustedSPCoord3Sigma:
86 if (latLonRadiusCoordDisplay) {
87 return "Adjusted SP Radius Sigma";
88 }
89 else {
90 return "Adjusted SP Z Sigma";
91 }
92 case APrioriSPCoord1:
93 if (latLonRadiusCoordDisplay) {
94 return "A Priori SP Lat";
95 }
96 else {
97 return "A Priori SP X";
98 }
99 case APrioriSPCoord2:
100 if (latLonRadiusCoordDisplay) {
101 return "A Priori SP Lon";
102 }
103 else {
104 return "A Priori SP Y";
105 }
106 case APrioriSPCoord3:
107 if (latLonRadiusCoordDisplay) {
108 return "A Priori SP Radius";
109 }
110 else {
111 return "A Priori SP Z";
112 }
113 case APrioriSPCoord1Sigma:
114 if (latLonRadiusCoordDisplay) {
115 return "A Priori SP Lat Sigma";
116 }
117 else {
118 return "A Priori SP X Sigma";
119 }
120 case APrioriSPCoord2Sigma:
121 if (latLonRadiusCoordDisplay) {
122 return "A Priori SP Lon Sigma";
123 }
124 else {
125 return "A Priori SP Y Sigma";
126 }
127 case APrioriSPCoord3Sigma:
128 if (latLonRadiusCoordDisplay) {
129 return "A Priori SP Radius Sigma";
130 }
131 else {
132 return "A Priori SP Z Sigma";
133 }
134 case APrioriSPSource:
135 return "A Priori SP Source";
136 case APrioriSPSourceFile:
137 return "A Priori SP Source File";
138 case APrioriRadiusSource:
139 return "A Priori Radius Source";
140 case APrioriRadiusSourceFile:
141 return "A Priori Radius Source File";
142 case JigsawRejected:
143 return "Jigsaw Rejected";
144 }
145
146 return QString();
147 }
148
149
150 AbstractPointItem::Column AbstractPointItem::getColumn(QString columnTitle) {
151 for (int i = 0; i < COLS; i++) {
152 if (columnTitle == getColumnName((Column)i))
153 return (Column)i;
154 }
155
156 QString msg = "Column title [" + columnTitle + "] does not match any of "
157 "the defined column types";
158 throw IException(IException::Programmer, msg, _FILEINFO_);
159 }
160
161
162 TableColumnList *AbstractPointItem::createColumns() {
163 TableColumnList *columnList = new TableColumnList;
164
165 columnList->append(new TableColumn(getColumnName(Id), false, false));
166 columnList->append(
167 new TableColumn(getColumnName(PointType), false, false));
168 columnList->append(
169 new TableColumn(getColumnName(ChooserName), false, false));
170 columnList->append(
171 new TableColumn(getColumnName(DateTime), true, false));
172 columnList->append(
173 new TableColumn(getColumnName(EditLock), false, false));
174 columnList->append(
175 new TableColumn(getColumnName(Ignored), false, true));
176 columnList->append(
177 new TableColumn(getColumnName(Reference), false, false));
178 columnList->append(
179 new TableColumn(getColumnName(AdjustedSPCoord1), true, false));
180 columnList->append(
181 new TableColumn(getColumnName(AdjustedSPCoord2), true, false));
182 columnList->append(
183 new TableColumn(getColumnName(AdjustedSPCoord3), true, false));
184 columnList->append(
185 new TableColumn(getColumnName(AdjustedSPCoord1Sigma), true, false));
186 columnList->append(
187 new TableColumn(getColumnName(AdjustedSPCoord2Sigma), true, false));
188 columnList->append(
189 new TableColumn(getColumnName(AdjustedSPCoord3Sigma), true, false));
190 columnList->append(
191 new TableColumn(getColumnName(APrioriSPCoord1), false, false));
192 columnList->append(
193 new TableColumn(getColumnName(APrioriSPCoord2), false, false));
194 columnList->append(
195 new TableColumn(getColumnName(APrioriSPCoord3), false, false));
196 columnList->append(
197 new TableColumn(getColumnName(APrioriSPCoord1Sigma), false, false));
198 columnList->append(
199 new TableColumn(getColumnName(APrioriSPCoord2Sigma), false, false));
200 columnList->append(
201 new TableColumn(getColumnName(APrioriSPCoord3Sigma), false, false));
202 columnList->append(
203 new TableColumn(getColumnName(APrioriSPSource), false, false));
204 columnList->append(
205 new TableColumn(getColumnName(APrioriSPSourceFile), false, false));
206 columnList->append(
207 new TableColumn(getColumnName(APrioriRadiusSource), false, false));
208 columnList->append(new TableColumn(
209 getColumnName(APrioriRadiusSourceFile), false, false));
210 columnList->append(
211 new TableColumn(getColumnName(JigsawRejected), true, false));
212
213 return columnList;
214 }
215
216
217 AbstractPointItem::AbstractPointItem(ControlPoint *cp,
218 int avgCharWidth, AbstractTreeItem *parent)
219 : AbstractTreeItem(parent) {
220
221 m_point = cp;
222 calcDataWidth(avgCharWidth);
223
224 connect(m_point, SIGNAL(destroyed(QObject *)), this, SLOT(sourceDeleted()));
225 }
226
227
228 AbstractPointItem::~AbstractPointItem() {
229 m_point = NULL;
230 }
231
232
233 QVariant AbstractPointItem::getData() const {
234 return getData(getColumnName(Id));
235 }
236
237
243 void AbstractPointItem::resetColumnHeaders(TableColumnList *columns) {
244 TableColumn *col = (*columns)[8];
245 col->setTitle(getColumnName(AdjustedSPCoord1));
246 col = (*columns)[9];
247 col->setTitle(getColumnName(AdjustedSPCoord2));
248 col = (*columns)[10];
249 col->setTitle(getColumnName(AdjustedSPCoord3));
250
251 col = (*columns)[11];
252 col->setTitle(getColumnName(AdjustedSPCoord1Sigma));
253 col = (*columns)[12];
254 col->setTitle(getColumnName(AdjustedSPCoord2Sigma));
255 col = (*columns)[13];
256 col->setTitle(getColumnName(AdjustedSPCoord3Sigma));
257
258 col = (*columns)[14];
259 col->setTitle(getColumnName(APrioriSPCoord1));
260 col = (*columns)[15];
261 col->setTitle(getColumnName(APrioriSPCoord2));
262 col = (*columns)[16];
263 col->setTitle(getColumnName(APrioriSPCoord3));
264
265 col = (*columns)[17];
266 col->setTitle(getColumnName(APrioriSPCoord1Sigma));
267 col = (*columns)[18];
268 col->setTitle(getColumnName(APrioriSPCoord2Sigma));
269 col = (*columns)[19];
270 col->setTitle(getColumnName(APrioriSPCoord3Sigma));
271 }
272
273
274 QVariant AbstractPointItem::getData(QString columnTitle) const {
275 CnetDisplayProperties *displayProperties = CnetDisplayProperties::getInstance();
276
277 if (m_point) {
278 bool latLonRadiusCoordDisplay = false;
279 if (displayProperties->coordinateDisplayType() == CnetDisplayProperties::LatLonRadius) {
280 latLonRadiusCoordDisplay = true;
281 }
282
283 Column column = getColumn(columnTitle);
284
285 switch ((Column) column) {
286 case Id:
287 return QVariant((QString)m_point->GetId());
288 case PointType:
289 return QVariant((QString)m_point->GetPointTypeString());
290 case ChooserName:
291 return QVariant((QString)m_point->GetChooserName());
292 case DateTime:
293 // return QVariant(QDateTime::fromString(
294 // m_point->GetDateTime(), "yyyy-MM-ddTHH:mm:ss"));
295 return QVariant((QString)m_point->GetDateTime());
296 case EditLock:
297 if (m_point->IsEditLocked())
298 return QVariant("Yes");
299 else
300 return QVariant("No");
301 break;
302 case Ignored:
303 if (m_point->IsIgnored())
304 return QVariant("Yes");
305 else
306 return QVariant("No");
307 case Reference:
308 if (m_point->GetNumMeasures())
309 return QVariant(
310 CnetDisplayProperties::getInstance()->getImageName(
311 (QString) m_point->GetRefMeasure()->GetCubeSerialNumber()));
312 else
313 return QVariant();
314 case AdjustedSPCoord1:
315 if (latLonRadiusCoordDisplay) {
316 return QVariant(m_point->GetAdjustedSurfacePoint().GetLatitude().degrees());
317 }
318 else {
319 return QVariant(m_point->GetAdjustedSurfacePoint().GetX().meters());
320 }
321 case AdjustedSPCoord2:
322 if (latLonRadiusCoordDisplay) {
323 return QVariant(m_point->GetAdjustedSurfacePoint().GetLongitude().degrees());
324 }
325 else {
326 return QVariant(m_point->GetAdjustedSurfacePoint().GetY().meters());
327 }
328 case AdjustedSPCoord3:
329 if (latLonRadiusCoordDisplay) {
330 return QVariant(m_point->GetAdjustedSurfacePoint().GetLocalRadius().meters());
331 }
332 else {
333 return QVariant(m_point->GetAdjustedSurfacePoint().GetZ().meters());
334 }
335 case AdjustedSPCoord1Sigma:
336 if (latLonRadiusCoordDisplay) {
337 return QVariant(m_point->GetAdjustedSurfacePoint().GetLatSigmaDistance().meters());
338 }
339 else {
340 return QVariant(m_point->GetAdjustedSurfacePoint().GetXSigma().meters());
341 }
342 case AdjustedSPCoord2Sigma:
343 if (latLonRadiusCoordDisplay) {
344 return QVariant(m_point->GetAdjustedSurfacePoint().GetLonSigmaDistance().meters());
345 }
346 else {
347 return QVariant(m_point->GetAdjustedSurfacePoint().GetYSigma().meters());
348 }
349 case AdjustedSPCoord3Sigma:
350 if (latLonRadiusCoordDisplay) {
351 return QVariant(m_point->GetAdjustedSurfacePoint().GetLocalRadiusSigma().meters());
352 }
353 else {
354 return QVariant(m_point->GetAdjustedSurfacePoint().GetZSigma().meters());
355 }
356 case APrioriSPCoord1:
357 if (latLonRadiusCoordDisplay) {
358 return QVariant(m_point->GetAprioriSurfacePoint().GetLatitude().degrees());
359 }
360 else {
361 return QVariant(m_point->GetAprioriSurfacePoint().GetX().meters());
362 }
363 case APrioriSPCoord2:
364 if (latLonRadiusCoordDisplay) {
365 return QVariant(m_point->GetAprioriSurfacePoint().GetLongitude().degrees());
366 }
367 else {
368 return QVariant(m_point->GetAprioriSurfacePoint().GetY().meters());
369 }
370 case APrioriSPCoord3:
371 if (latLonRadiusCoordDisplay) {
372 return QVariant(m_point->GetAprioriSurfacePoint().GetLocalRadius().meters());
373 }
374 else {
375 return QVariant(m_point->GetAprioriSurfacePoint().GetZ().meters());
376 }
377 case APrioriSPCoord1Sigma:
378 if (latLonRadiusCoordDisplay) {
379 return QVariant(m_point->GetAprioriSurfacePoint().GetLatSigmaDistance().meters());
380 }
381 else {
382 return QVariant(m_point->GetAprioriSurfacePoint().GetXSigma().meters());
383 }
384 case APrioriSPCoord2Sigma:
385 if (latLonRadiusCoordDisplay) {
386 return QVariant(m_point->GetAprioriSurfacePoint().GetLonSigmaDistance().meters());
387 }
388 else {
389 return QVariant(m_point->GetAprioriSurfacePoint().GetYSigma().meters());
390 }
391 case APrioriSPCoord3Sigma:
392 if (latLonRadiusCoordDisplay) {
393 return QVariant(m_point->GetAprioriSurfacePoint().GetLocalRadiusSigma().meters());
394 }
395 else {
396 return QVariant(m_point->GetAprioriSurfacePoint().GetZSigma().meters());
397 }
398 case APrioriSPSource:
399 return QVariant((QString)m_point->GetSurfacePointSourceString());
400 case APrioriSPSourceFile:
401 return QVariant((QString)m_point->GetAprioriSurfacePointSourceFile());
402 case APrioriRadiusSource:
403 return QVariant((QString)m_point->GetRadiusSourceString());
404 case APrioriRadiusSourceFile:
405 return QVariant((QString)m_point->GetAprioriRadiusSourceFile());
406 case JigsawRejected:
407 if (m_point->IsRejected())
408 return QVariant("Yes");
409 else
410 return QVariant("No");
411 }
412 }
413
414 return QVariant();
415 }
416
417
418 void AbstractPointItem::setData(QString const &columnTitle,
419 QString const &newData) {
420
421 CnetDisplayProperties *displayProperties = CnetDisplayProperties::getInstance();
422 if (m_point) {
423 bool latLonRadiusCoordDisplay = false;
424 if (displayProperties->coordinateDisplayType() == CnetDisplayProperties::LatLonRadius) {
425 latLonRadiusCoordDisplay = true;
426 }
427
428 Column column = getColumn(columnTitle);
429
430 switch ((Column) column) {
431 case Id:
432 m_point->SetId(newData);
433 break;
434 case PointType:
435 m_point->SetType(m_point->StringToPointType(newData));
436 break;
437 case ChooserName:
438 m_point->SetChooserName(newData);
439 break;
440 case DateTime:
441 m_point->SetDateTime(newData);
442 break;
443 case EditLock:
444 if (newData == "Yes")
445 m_point->SetEditLock(true);
446 else
447 m_point->SetEditLock(false);
448 break;
449 case Ignored:
450 m_point->SetIgnored(newData == "Yes");
451 break;
452 case Reference:
453 m_point->SetRefMeasure(newData);
454 break;
455 case AdjustedSPCoord1:
456 if (latLonRadiusCoordDisplay) {
457 m_point->SetAdjustedSurfacePoint(SurfacePoint(
458 Latitude(catchNull(newData), Angle::Degrees),
459 m_point->GetAdjustedSurfacePoint().GetLongitude(),
460 m_point->GetAdjustedSurfacePoint().GetLocalRadius()));
461 }
462 else {
463 m_point->SetAdjustedSurfacePoint(SurfacePoint(
464 Distance(catchNull(newData), Distance::Meters),
465 m_point->GetAdjustedSurfacePoint().GetY(),
466 m_point->GetAdjustedSurfacePoint().GetZ()));
467 }
468 break;
469 case AdjustedSPCoord2:
470 if (latLonRadiusCoordDisplay) {
471 m_point->SetAdjustedSurfacePoint(SurfacePoint(
472 m_point->GetAdjustedSurfacePoint().GetLatitude(),
473 Longitude(catchNull(newData), Angle::Degrees),
474 m_point->GetAdjustedSurfacePoint().GetLocalRadius()));
475 }
476 else {
477 m_point->SetAdjustedSurfacePoint(SurfacePoint(
478 m_point->GetAdjustedSurfacePoint().GetX(),
479 Distance(catchNull(newData), Distance::Meters),
480 m_point->GetAdjustedSurfacePoint().GetZ()));
481 }
482 break;
483 case AdjustedSPCoord3:
484 if (latLonRadiusCoordDisplay) {
485 m_point->SetAdjustedSurfacePoint(SurfacePoint(
486 m_point->GetAdjustedSurfacePoint().GetLatitude(),
487 m_point->GetAdjustedSurfacePoint().GetLongitude(),
488 Distance(catchNull(newData), Distance::Meters)));
489 }
490 else {
491 m_point->SetAdjustedSurfacePoint(SurfacePoint(
492 m_point->GetAdjustedSurfacePoint().GetX(),
493 m_point->GetAdjustedSurfacePoint().GetY(),
494 Distance(catchNull(newData), Distance::Meters)));
495 }
496 break;
497 case AdjustedSPCoord1Sigma: {
498 QString msg;
499 if (latLonRadiusCoordDisplay) {
500 msg = "Cannot set adjusted surface point latitude sigma";
501 }
502 else {
503 msg = "Cannot set adjusted surface point X sigma";
504 }
505 throw IException(IException::Programmer, msg, _FILEINFO_);
506 break;
507 }
508 case AdjustedSPCoord2Sigma: {
509 QString msg;
510 if (latLonRadiusCoordDisplay) {
511 msg = "Cannot set adjusted surface point longitude sigma";
512 }
513 else {
514 msg = "Cannot set adjusted surface point Y sigma";
515 }
516 throw IException(IException::Programmer, msg, _FILEINFO_);
517 break;
518 }
519 case AdjustedSPCoord3Sigma: {
520 QString msg;
521 if (latLonRadiusCoordDisplay) {
522 msg = "Cannot set adjusted surface point radius sigma";
523 }
524 else {
525 msg = "Cannot set adjusted surface point Z sigma";
526 }
527 throw IException(IException::Programmer, msg, _FILEINFO_);
528 break;
529 }
530 case APrioriSPCoord1: {
531 if (latLonRadiusCoordDisplay) {
532 Latitude newLat(catchNull(newData), Angle::Degrees);
533 SurfacePoint newSurfacePoint(prepareSurfacePoint(newLat,
534 m_point->GetAprioriSurfacePoint()));
535
536 newSurfacePoint.SetSphericalCoordinates(newLat,
537 newSurfacePoint.GetLongitude(),
538 newSurfacePoint.GetLocalRadius());
539 m_point->SetAprioriSurfacePoint(newSurfacePoint);
540 }
541 else {
542 Distance newX(catchNull(newData), Distance::Meters);
543 SurfacePoint newSurfacePoint(prepareSurfacePoint(newX,
544 m_point->GetAprioriSurfacePoint()));
545
546 newSurfacePoint.SetRectangularCoordinates(newX,
547 newSurfacePoint.GetY(),
548 newSurfacePoint.GetZ());
549 m_point->SetAprioriSurfacePoint(newSurfacePoint);
550 }
551 break;
552 }
553 case APrioriSPCoord2: {
554 if (latLonRadiusCoordDisplay) {
555 Longitude newLon(catchNull(newData), Angle::Degrees);
556 SurfacePoint newSurfacePoint(prepareSurfacePoint(newLon,
557 m_point->GetAprioriSurfacePoint()));
558
559 newSurfacePoint.SetSphericalCoordinates(
560 newSurfacePoint.GetLatitude(),
561 newLon,
562 newSurfacePoint.GetLocalRadius());
563 m_point->SetAprioriSurfacePoint(newSurfacePoint);
564 }
565 else {
566 Distance newY(catchNull(newData), Distance::Meters);
567 SurfacePoint newSurfacePoint(prepareSurfacePoint(newY,
568 m_point->GetAprioriSurfacePoint()));
569
570 newSurfacePoint.SetRectangularCoordinates(newSurfacePoint.GetX(),
571 newY,
572 newSurfacePoint.GetZ());
573 m_point->SetAprioriSurfacePoint(newSurfacePoint);
574 }
575 break;
576 }
577 case APrioriSPCoord3: {
578 if (latLonRadiusCoordDisplay) {
579 Distance newRadius(catchNull(newData), Distance::Meters);
580 SurfacePoint newSurfacePoint(prepareSurfacePoint(newRadius,
581 m_point->GetAprioriSurfacePoint()));
582
583 newSurfacePoint.SetSphericalCoordinates(
584 newSurfacePoint.GetLatitude(),
585 newSurfacePoint.GetLongitude(),
586 newRadius);
587 m_point->SetAprioriSurfacePoint(newSurfacePoint);
588 }
589 else {
590 Distance newZ(catchNull(newData), Distance::Meters);
591 SurfacePoint newSurfacePoint(prepareSurfacePoint(newZ,
592 m_point->GetAprioriSurfacePoint()));
593
594 newSurfacePoint.SetRectangularCoordinates(newSurfacePoint.GetX(),
595 newSurfacePoint.GetY(),
596 newZ);
597 m_point->SetAprioriSurfacePoint(newSurfacePoint);
598 }
599 break;
600 }
601 case APrioriSPCoord1Sigma: {
602 if (latLonRadiusCoordDisplay) {
603 Distance newSigma(catchNull(newData), Distance::Meters);
604 SurfacePoint newSurfacePoint(prepareSigmas(newSigma,
605 m_point->GetAprioriSurfacePoint()));
606
607 newSurfacePoint.SetSphericalSigmasDistance(
608 newSigma, newSurfacePoint.GetLonSigmaDistance(),
609 newSurfacePoint.GetLocalRadiusSigma());
610
611 m_point->SetAprioriSurfacePoint(newSurfacePoint);
612 }
613 else {
614 Distance newSigma(catchNull(newData), Distance::Meters);
615 SurfacePoint newSurfacePoint(prepareXYZSigmas(newSigma,
616 m_point->GetAprioriSurfacePoint()));
617
618 newSurfacePoint.SetRectangularSigmas(
619 newSigma, newSurfacePoint.GetYSigma(),
620 newSurfacePoint.GetZSigma());
621
622 m_point->SetAprioriSurfacePoint(newSurfacePoint);
623 }
624 break;
625 }
626 case APrioriSPCoord2Sigma: {
627 if (latLonRadiusCoordDisplay) {
628 Distance newSigma(catchNull(newData), Distance::Meters);
629 SurfacePoint newSurfacePoint(prepareSigmas(newSigma,
630 m_point->GetAprioriSurfacePoint()));
631
632 newSurfacePoint.SetSphericalSigmasDistance(
633 newSurfacePoint.GetLatSigmaDistance(), newSigma,
634 newSurfacePoint.GetLocalRadiusSigma());
635
636 m_point->SetAprioriSurfacePoint(newSurfacePoint);
637 }
638 else {
639 Distance newSigma(catchNull(newData), Distance::Meters);
640 SurfacePoint newSurfacePoint(prepareXYZSigmas(newSigma,
641 m_point->GetAprioriSurfacePoint()));
642
643 newSurfacePoint.SetRectangularSigmas(
644 newSurfacePoint.GetXSigma(), newSigma,
645 newSurfacePoint.GetZSigma());
646
647 m_point->SetAprioriSurfacePoint(newSurfacePoint);
648 }
649 break;
650 }
651 case APrioriSPCoord3Sigma: {
652 if (latLonRadiusCoordDisplay) {
653 Distance newSigma(catchNull(newData), Distance::Meters);
654 SurfacePoint newSurfacePoint(prepareSigmas(newSigma,
655 m_point->GetAprioriSurfacePoint()));
656
657 newSurfacePoint.SetSphericalSigmasDistance(
658 newSurfacePoint.GetLatSigmaDistance(),
659 newSurfacePoint.GetLonSigmaDistance(),
660 newSigma);
661
662 m_point->SetAprioriSurfacePoint(newSurfacePoint);
663 }
664 else {
665 Distance newSigma(catchNull(newData), Distance::Meters);
666 SurfacePoint newSurfacePoint(prepareXYZSigmas(newSigma,
667 m_point->GetAprioriSurfacePoint()));
668
669 newSurfacePoint.SetRectangularSigmas(
670 newSurfacePoint.GetXSigma(),
671 newSurfacePoint.GetYSigma(),
672 newSigma);
673
674 m_point->SetAprioriSurfacePoint(newSurfacePoint);
675 }
676 break;
677 }
678 case APrioriSPSource:
679 m_point->SetAprioriSurfacePointSource(
680 m_point->StringToSurfacePointSource(newData));
681 break;
682 case APrioriSPSourceFile:
683 m_point->SetAprioriSurfacePointSourceFile(newData);
684 break;
685 case APrioriRadiusSource:
686 m_point->SetAprioriRadiusSource(
687 m_point->StringToRadiusSource(newData));
688 break;
689 case APrioriRadiusSourceFile:
690 m_point->SetAprioriRadiusSourceFile(newData);
691 break;
692 case JigsawRejected:
693 // jigsaw rejected is not editable!
694 break;
695 }
696 }
697 }
698
699
700 // Returns true if the data at the given column is locked (i.e.
701 // edit-locked). If the m_point is edit-locked, all columns except the edit
702 // lock column should be uneditable.
703 bool AbstractPointItem::isDataEditable(QString columnTitle) const {
704 bool locked = true;
705 if (m_point->IsEditLocked()) {
706 if (getColumn(columnTitle) == EditLock)
707 locked = false;
708 }
709 else {
710 locked = false;
711 }
712
713 return !locked;
714 }
715
716
717 void AbstractPointItem::deleteSource() {
718 if (m_point) {
719 if (m_point->IsEditLocked()) {
720 QString msg = "Point [" + getFormattedData() + "] is edit locked and "
721 "cannot be deleted";
722 throw IException(IException::User, msg, _FILEINFO_);
723 }
724 else if (m_point->GetNumLockedMeasures() > 0) {
725 QString msg = "Point [" + getFormattedData() + "] has at least one "
726 "edit locked measure and cannot be deleted";
727 throw IException(IException::User, msg, _FILEINFO_);
728 }
729
730 ControlPoint *tempPoint = m_point;
731 m_point = NULL;
732 tempPoint->Parent()->DeletePoint(tempPoint);
733 }
734 }
735
736
737 AbstractTreeItem::InternalPointerType AbstractPointItem::getPointerType() const {
738 return AbstractTreeItem::Point;
739 }
740
741
742 void *AbstractPointItem::getPointer() const {
743 return m_point;
744 }
745
746
747 bool AbstractPointItem::hasPoint(ControlPoint *p) const {
748 return m_point == p;
749 }
750
751 void AbstractPointItem::sourceDeleted() {
752 m_point = NULL;
753 }
754
755
756 SurfacePoint AbstractPointItem::prepareSigmas(Distance newSigma,
757 SurfacePoint surfacePoint) {
758 const Distance free(10000, Distance::Meters);
759 Distance latSigDist = surfacePoint.GetLatSigmaDistance();
760 Distance lonSigDist = surfacePoint.GetLonSigmaDistance();
761 Distance radiusSigDist = surfacePoint.GetLocalRadiusSigma();
762
763 if (newSigma.isValid()) {
764 if (!latSigDist.isValid())
765 latSigDist = free;
766 if (!lonSigDist.isValid())
767 lonSigDist = free;
768 if (!radiusSigDist.isValid())
769 radiusSigDist = free;
770 }
771 else {
772 latSigDist = Distance();
773 lonSigDist = Distance();
774 radiusSigDist = Distance();
775 }
776
777 surfacePoint.SetSphericalSigmasDistance(
778 latSigDist, lonSigDist, radiusSigDist);
779 return surfacePoint;
780 }
781
782
783 SurfacePoint AbstractPointItem::prepareXYZSigmas(Distance newSigma,
784 SurfacePoint surfacePoint) {
785 const Distance free(10000, Distance::Meters);
786 Distance xSigma = surfacePoint.GetXSigma();
787 Distance ySigma = surfacePoint.GetYSigma();
788 Distance zSigma = surfacePoint.GetZSigma();
789
790 if (newSigma.isValid()) {
791 if (!xSigma.isValid())
792 xSigma = free;
793 if (!ySigma.isValid())
794 ySigma = free;
795 if (!zSigma.isValid())
796 zSigma = free;
797 }
798 else {
799 xSigma = Distance();
800 ySigma = Distance();
801 zSigma = Distance();
802 }
803
804 surfacePoint.SetRectangularSigmas(xSigma, ySigma, zSigma);
805 return surfacePoint;
806 }
807
808
809 SurfacePoint AbstractPointItem::prepareSurfacePoint(Latitude newLat,
810 SurfacePoint surfacePoint) {
811 if (newLat.isValid()) {
812 surfacePoint = prepareSurfacePoint(surfacePoint);
813 }
814 else {
815 surfacePoint.SetSphericalCoordinates(Latitude(), Longitude(),
816 Distance());
817 }
818
819 return surfacePoint;
820 }
821
822
823 SurfacePoint AbstractPointItem::prepareSurfacePoint(Longitude newLon,
824 SurfacePoint surfacePoint) {
825 if (newLon.isValid()) {
826 surfacePoint = prepareSurfacePoint(surfacePoint);
827 }
828 else {
829 surfacePoint.SetSphericalCoordinates(Latitude(), Longitude(),
830 Distance());
831 }
832
833 return surfacePoint;
834 }
835
836
837 SurfacePoint AbstractPointItem::prepareSurfacePoint(
838 Distance newRadius, SurfacePoint surfacePoint) {
839 if (newRadius.isValid()) {
840 surfacePoint = prepareSurfacePoint(surfacePoint);
841 }
842 else {
843 surfacePoint.SetSphericalCoordinates(Latitude(), Longitude(),
844 Distance());
845 }
846
847 return surfacePoint;
848 }
849
850
851 SurfacePoint AbstractPointItem::prepareSurfacePoint(
852 SurfacePoint surfacePoint) {
853 Latitude lat = surfacePoint.GetLatitude();
854 Longitude lon = surfacePoint.GetLongitude();
855 Distance radius = surfacePoint.GetLocalRadius();
856
857 if (!lat.isValid())
858 lat = Latitude(0, Angle::Degrees);
859 if (!lon.isValid())
860 lon = Longitude(0, Angle::Degrees);
861 if (!radius.isValid())
862 radius = Distance(10000, Distance::Meters);
863
864 surfacePoint.SetSphericalCoordinates(lat, lon, radius);
865 return surfacePoint;
866 }
867}
Handles how control networks should be displayed to the user.
coordinateDisplayType
Returns coordinate display type (0 = LatLonRadius, 1 = XYZ).
@ Programmer
This error is for when a programmer made an API call that was illegal.
Definition IException.h:146
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16