Isis 3 Programmer Reference
QnetSetAprioriDialog.cpp
1#include "QnetSetAprioriDialog.h"
2
3#include <QDialog>
4#include <QGridLayout>
5#include <QGroupBox>
6#include <QLabel>
7#include <QLineEdit>
8#include <QListWidget>
9#include <QListWidgetItem>
10#include <QMessageBox>
11#include <QPushButton>
12#include <QStackedWidget>
13#include <QString>
14#include <QStringList>
15#include <QtWidgets>
16#include <QVBoxLayout>
17
18#include "Camera.h"
19#include "CameraDistortionMap.h"
20#include "ControlMeasure.h"
21#include "ControlNet.h"
22#include "ControlPoint.h"
23#include "Distance.h"
24#include "Latitude.h"
25#include "Longitude.h"
26#include "QnetTool.h"
27#include "SerialNumberList.h"
28#include "SpecialPixel.h"
29
30using namespace std;
31
32namespace Isis {
33 QnetSetAprioriDialog::QnetSetAprioriDialog(QnetTool *qnetTool, QWidget *parent) : QDialog(parent) {
34 m_qnetTool = qnetTool;
35
36 m_aprioriDialog = NULL;
37 m_aprioriGridLayout = NULL;
38 m_okButton = NULL;
39 m_cancelButton = NULL;
40 m_applyButton = NULL;
41 m_pointInfoStack = NULL;
42
43 m_singlePointInfoGroup = NULL;
44 m_pointIDLabel = NULL;
45 m_pointTypeLabel = NULL;
46 m_pointMeasureNumber = NULL;
47 m_editLockedBoolLabel = NULL;
48 m_ignoredBoolLabel = NULL;
49
50 m_multiplePointsInfoGroup = NULL;
51 m_pointsCount = NULL;
52 m_pointsMeasuresCount = NULL;
53 m_constrainedPointsCount = NULL;
54 m_fixedPointsCount = NULL;
55 m_freePointsCount = NULL;
56 m_pointsEditLockedCount = NULL;
57 m_pointsIgnoredCount = NULL;
58
59 m_pointGroup = NULL;
60 m_aprioriLatLabel = NULL;
61 m_aprioriLonLabel = NULL;
62 m_aprioriRadiusLabel = NULL;
63 m_latLineEdit = NULL;
64 m_lonLineEdit = NULL;
65 m_radiusLineEdit = NULL;
66 m_currentAprioriButton = NULL;
67 m_referenceAprioriButton = NULL;
68 m_averageAprioriButton = NULL;
69
70 m_sigmaGroup = NULL;
71 m_sigmaWarningLabel = NULL;
72 m_currentSigmaButton = NULL;
73 m_latSigmaLabel = NULL;
74 m_lonSigmaLabel = NULL;
75 m_radiusSigmaLabel = NULL;
76 m_latSigmaLineEdit = NULL;
77 m_lonSigmaLineEdit = NULL;
78 m_radiusSigmaLineEdit = NULL;
79
80 m_multiPointsMeasureCount = 0;
81 m_multiPointsConstraintedCount = 0;
82 m_multiPointsFixedCount = 0;
83 m_multiPointsFreeCount = 0;
84 m_multiPointsEditLockedCount = 0;
85 m_multiPointsIgnoredCount = 0;
86
87 createSetAprioriDialog(parent);
88
89 connect(m_currentAprioriButton, SIGNAL(clicked()), this, SLOT(fillCurrentAprioriLineEdits()));
90 connect(m_referenceAprioriButton, SIGNAL(clicked()), this,
91 SLOT(fillReferenceAprioriLineEdits()));
92 connect(m_averageAprioriButton, SIGNAL(clicked()), this, SLOT(fillAverageAprioriLineEdits()));
93
94 //TODO create a ground button that retrieves the lat/lon/radius of the ground source if there
95 //is one. The basic connections are already done, just need to actually do it
96// connect(m_groundAprioriButton, SIGNAL(clicked()), this,
97// SLOT(fillGroundSourceAprioriLineEdits()));
98
99 connect(m_currentSigmaButton, SIGNAL(clicked()), this, SLOT(fillSigmaLineEdits()));
100 connect(m_currentSigmaButton, SIGNAL(clicked()), this, SLOT(fillSigmaLineEdits()));
101
102 connect(m_aprioriDialog, SIGNAL(rejected()), this, SLOT(reject()));
103
104 connect(m_okButton, SIGNAL(clicked()), this, SLOT(setApriori()));
105 connect(m_okButton, SIGNAL(clicked()), this, SLOT(closeEvent()));
106 connect(m_okButton, SIGNAL(clicked()), m_aprioriDialog, SLOT(close()));
107
108 connect(m_applyButton, SIGNAL(clicked()), this, SLOT(setApriori()));
109 connect(m_cancelButton, SIGNAL(clicked()), this, SLOT(closeEvent()));
110 connect(m_cancelButton, SIGNAL(clicked()), m_aprioriDialog, SLOT(close()));
111 }
112
113
122 void QnetSetAprioriDialog::createSetAprioriDialog(QWidget *parent) {
123
124 //Create all of the individual elements
125 m_pointIDLabel = new QLabel("Point ID: ");
126 m_pointTypeLabel = new QLabel("Point Type: ");
127 m_pointMeasureNumber = new QLabel("Number of Measures: ");
128 m_editLockedBoolLabel = new QLabel("EditLocked: ");
129 m_ignoredBoolLabel= new QLabel("Ignored: ");
130
131 m_pointsCount = new QLabel("Number of Points: ");
132 m_pointsMeasuresCount = new QLabel("Total Number of Measures: ");
133 m_constrainedPointsCount = new QLabel("Number of Constrained Points: ");
134 m_fixedPointsCount = new QLabel("Number of Fixed Points: ");
135 m_freePointsCount = new QLabel("Number of Free Points: ");
136 m_pointsEditLockedCount = new QLabel("Number of Edit Locked Points: ");
137 m_pointsIgnoredCount = new QLabel("Number of Ignored Points: ");
138
139 m_currentAprioriButton = new QPushButton("Current");
140 m_currentAprioriButton->setDefault(false);
141 m_currentAprioriButton->setToolTip("Populate with the current Apriori Position");
142
143 m_referenceAprioriButton = new QPushButton("Reference");
144 m_referenceAprioriButton->setToolTip("Populate with Apriori Position of the reference measure");
145
146 m_averageAprioriButton = new QPushButton("Average");
147 m_averageAprioriButton->setToolTip("Calculate and populate with the average Apriori Position");
148
149// m_groundAprioriButton = new QPushButton("Ground");
150// m_groundAprioriButton->setToolTip("Populate with the Ground Source position, if a Ground Source is loaded");
151
152 m_aprioriLatLabel = new QLabel(tr("Apriori Latitude"));
153 m_aprioriLonLabel = new QLabel(tr("Apriori Longitude"));
154 m_aprioriRadiusLabel = new QLabel(tr("Apriori Radius"));
155 m_latLineEdit = new QLineEdit();
156 m_lonLineEdit = new QLineEdit();
157 m_radiusLineEdit = new QLineEdit();
158
159 m_sigmaWarningLabel = new QLabel("");
160
161 m_currentSigmaButton = new QPushButton("Current");
162 m_currentSigmaButton->setToolTip("Populate the current sigma values");
163
164 m_latSigmaLabel = new QLabel(tr("Latitude Sigma"));
165 m_lonSigmaLabel = new QLabel(tr("Longitude Sigma"));
166 m_radiusSigmaLabel = new QLabel(tr("Radius Sigma"));
167 m_latSigmaLineEdit = new QLineEdit();
168 m_lonSigmaLineEdit = new QLineEdit();
169 m_radiusSigmaLineEdit = new QLineEdit();
170
171 m_okButton = new QPushButton("&OK");
172 m_okButton->setToolTip("Apply changes and close this dialog");
173
174 m_cancelButton = new QPushButton("&Cancel");
175 m_cancelButton->setToolTip("Discard changes and close this dialog");
176
177 m_applyButton = new QPushButton("&Apply");
178 m_applyButton->setAutoDefault(true);
179 m_applyButton->setDefault(true);
180 m_applyButton->setToolTip("Apply changes");
181
182 //Create the point group box and layout
183 m_pointGroup = new QGroupBox(tr("Apriori Point"));
184 m_pointGroup->setToolTip("Apriori Point Position");
185
186 QGridLayout *pointGridLayout = new QGridLayout(m_pointGroup);
187 pointGridLayout->addWidget(m_currentAprioriButton, 1, 1);
188 pointGridLayout->addWidget(m_referenceAprioriButton, 1, 2);
189 pointGridLayout->addWidget(m_averageAprioriButton, 1, 3);
190// pointGridLayout->addWidget(m_groundAprioriButton, 1, 4);
191 pointGridLayout->addWidget(m_aprioriLatLabel, 2, 1);
192 pointGridLayout->addWidget(m_aprioriLonLabel, 3, 1);
193 pointGridLayout->addWidget(m_aprioriRadiusLabel, 4, 1);
194 pointGridLayout->addWidget(m_latLineEdit, 2, 2, 1, -1);
195 pointGridLayout->addWidget(m_lonLineEdit, 3, 2, 1, -1);
196 pointGridLayout->addWidget(m_radiusLineEdit, 4, 2, 1, -1);
197 m_pointGroup->setLayout(pointGridLayout);
198
199 //Create the sigma group box and layout
200 m_sigmaGroup = new QGroupBox(tr("Apriori Constraints"));
201 QGridLayout *sigmaGridLayout = new QGridLayout(m_sigmaGroup);
202 sigmaGridLayout->addWidget(m_currentSigmaButton, 1, 1);
203 sigmaGridLayout->addWidget(m_latSigmaLabel, 2, 1);
204 sigmaGridLayout->addWidget(m_lonSigmaLabel, 3, 1);
205 sigmaGridLayout->addWidget(m_radiusSigmaLabel, 4, 1);
206 sigmaGridLayout->addWidget(m_latSigmaLineEdit, 2, 2, 1, 3);
207 sigmaGridLayout->addWidget(m_lonSigmaLineEdit, 3, 2, 1, 3);
208 sigmaGridLayout->addWidget(m_radiusSigmaLineEdit, 4, 2, 1, 3);
209 m_sigmaGroup->setLayout(sigmaGridLayout);
210
211 //Create group box for the single point information labels
212 m_singlePointInfoGroup = new QGroupBox(tr("Point Information"));
213 m_singlePointInfoGroup->setToolTip("Information on Point selected");
214
215 QVBoxLayout *m_singlePointInfoLayout = new QVBoxLayout(m_singlePointInfoGroup);
216 m_singlePointInfoLayout->addWidget(m_pointIDLabel);
217 m_singlePointInfoLayout->addWidget(m_pointTypeLabel);
218 m_singlePointInfoLayout->addWidget(m_pointMeasureNumber);
219 m_singlePointInfoLayout->addWidget(m_editLockedBoolLabel);
220 m_singlePointInfoLayout->addWidget(m_ignoredBoolLabel);
221 m_singlePointInfoGroup->setLayout(m_singlePointInfoLayout);
222
223 //Create group box for the multiple point information labels
224 m_multiplePointsInfoGroup = new QGroupBox(tr("Multiple Point Information"));
225 m_multiplePointsInfoGroup->setToolTip("Information on Points selected");
226 QVBoxLayout *m_multiplePointsInfoLayout = new QVBoxLayout(m_multiplePointsInfoGroup);
227 m_multiplePointsInfoLayout->addWidget(m_pointsCount);
228 m_multiplePointsInfoLayout->addWidget(m_pointsMeasuresCount);
229 m_multiplePointsInfoLayout->addWidget(m_constrainedPointsCount);
230 m_multiplePointsInfoLayout->addWidget(m_fixedPointsCount);
231 m_multiplePointsInfoLayout->addWidget(m_freePointsCount);
232 m_multiplePointsInfoLayout->addWidget(m_pointsEditLockedCount);
233 m_multiplePointsInfoLayout->addWidget(m_pointsIgnoredCount);
234 m_multiplePointsInfoGroup->setLayout(m_multiplePointsInfoLayout);
235
236 //Create a stacked widget to switch between the single point and multiple point labels
237 m_pointInfoStack = new QStackedWidget;
238 m_pointInfoStack->addWidget(m_singlePointInfoGroup);
239 m_pointInfoStack->addWidget(m_multiplePointsInfoGroup);
240
241 //Add all of the major widgets to the main dialog layout
242 m_aprioriGridLayout = new QGridLayout(m_aprioriDialog);
243 m_aprioriGridLayout->addWidget(m_pointInfoStack, 1, 1, 1, -1);
244 m_aprioriGridLayout->addWidget(m_pointGroup, 5, 1, 1, -1);
245 m_aprioriGridLayout->addWidget(m_sigmaGroup, 6, 1, 1, -1);
246 m_aprioriGridLayout->addWidget(m_sigmaWarningLabel, 7, 1, 1, -1);
247 m_aprioriGridLayout->addWidget(m_okButton, 8, 2);
248 m_aprioriGridLayout->addWidget(m_cancelButton, 8, 3);
249 m_aprioriGridLayout->addWidget(m_applyButton, 8, 4);
250
251
252 m_aprioriDialog = new QDialog(parent);
253 m_aprioriDialog->setWindowTitle("Set Apriori Point and Constraints");
254 m_aprioriDialog->setLayout(m_aprioriGridLayout);
255
256 setVisiblity();
257 }
258
259
267 void QnetSetAprioriDialog::reject() {
268 closeEvent();
269 QDialog::reject();
270 }
271
272
278 void QnetSetAprioriDialog::closeEvent() {
279
280 disconnect(m_currentAprioriButton, SIGNAL(clicked()), this,
281 SLOT(fillCurrentAprioriLineEdits()));
282 disconnect(m_referenceAprioriButton, SIGNAL(clicked()), this,
283 SLOT(fillReferenceAprioriLineEdits()));
284 disconnect(m_averageAprioriButton, SIGNAL(clicked()), this,
285 SLOT(fillAverageAprioriLineEdits()));
286
287 disconnect(m_currentSigmaButton, SIGNAL(clicked()), this, SLOT(fillSigmaLineEdits()));
288 disconnect(m_currentSigmaButton, SIGNAL(clicked()), this, SLOT(fillSigmaLineEdits()));
289
290 disconnect(m_okButton, SIGNAL(clicked()), this, SLOT(setApriori()));
291 disconnect(m_applyButton, SIGNAL(clicked()), this, SLOT(setApriori()));
292
293 emit aprioriDialogClosed();
294
295 }
296
297
304 void QnetSetAprioriDialog::setVisiblity() {
305 if (m_aprioriDialog != NULL) {
306 m_aprioriDialog->setVisible(true);
307 }
308 }
309
310
321 void QnetSetAprioriDialog::setPoints(QList<QListWidgetItem *> selectedPoints) {
322 m_points = selectedPoints;
323
324 checkPointInfoDisable(m_points);
325 resetInfoLabels();
326 clearLineEdits();
327
328 setInfoStack(m_points);
329
330 if (m_points.size() == 1) {
331 fillCurrentAprioriLineEdits();
332 fillSigmaLineEdits();
333 }
334 }
335
336
345 void QnetSetAprioriDialog::fillCurrentAprioriLineEdits() {
346 if (m_points.size() == 0) {
347 QString msg = "There are no Points selected. Please select a Point.";
348 QMessageBox::warning((QWidget *)parent(), "Warning", msg);
349 return;
350 }
351
352 //we can only populate the line edits if there is one point selected
353 if (m_points.size() == 1) {
354 QString id = m_points.at(0)->text();
355 ControlPoint *pt = m_qnetTool->controlNet()->GetPoint(id);
356 SurfacePoint sPt = pt->GetAprioriSurfacePoint();
357
358 if (sPt.GetLatitude().degrees() != Null) {
359 m_latLineEdit->setText(
360 QString::number(sPt.GetLatitude().degrees()));
361 }
362 else {
363 m_latLineEdit->clear();
364 }
365 if (sPt.GetLongitude().degrees() != Null) {
366 m_lonLineEdit->setText(
367 QString::number(sPt.GetLongitude().degrees()));
368 }
369 else {
370 m_lonLineEdit->clear();
371 }
372 //The 'f', 2 allows the radius to be displayed in meters rather than scientific notation
373 if (sPt.GetLocalRadius().meters() != Null) {
374 m_radiusLineEdit->setText(
375 QString::number(sPt.GetLocalRadius().meters(), 'f', 2));
376 }
377 else {
378 m_radiusLineEdit->clear();
379 }
380 m_aprioriSource = (Source) USER;
381 }
382 }
383
384
393 void QnetSetAprioriDialog::fillReferenceAprioriLineEdits() {
394 if (m_points.size() == 0) {
395 QString msg = "There are no Points selected. Please select a Point.";
396 QMessageBox::warning((QWidget *)parent(), "Warning", msg);
397 return;
398 }
399
400 //we can only populate the line edits if there is one point selected
401 if (m_points.size() == 1) {
402
403 QString id = m_points.at(0)->text();
404 ControlPoint *pt = m_qnetTool->controlNet()->GetPoint(id);
405 ControlMeasure *m = pt->GetRefMeasure();
406
407 // Find camera from network camera list
408 int camIndex = m_qnetTool->serialNumberList()->serialNumberIndex(
409 m->GetCubeSerialNumber());
410 Camera *cam = m_qnetTool->controlNet()->Camera(camIndex);
411 cam->SetImage(m->GetSample(),m->GetLine());
412 SurfacePoint refSPt = cam->GetSurfacePoint();
413 if (refSPt.GetLatitude().degrees() != Null) {
414 m_latLineEdit->setText(
415 QString::number(refSPt.GetLatitude().degrees()));
416 }
417 else {
418 m_latLineEdit->clear();
419 }
420 if (refSPt.GetLongitude().degrees() != Null) {
421 m_lonLineEdit->setText(
422 QString::number(refSPt.GetLongitude().degrees()));
423 }
424 else {
425 m_lonLineEdit->clear();
426 }
427 //The 'f', 2 allows the radius to be displayed in meters rather than scientific notation
428 if (refSPt.GetLocalRadius().meters() != Null) {
429 m_radiusLineEdit->setText(
430 QString::number(refSPt.GetLocalRadius().meters(), 'f', 2));
431 }
432 else {
433 m_radiusLineEdit->clear();
434 }
435
436 //If all of the line edits are empty something went wrong, tell the user, and return
437 if ((m_latLineEdit->text() == "") && (m_lonLineEdit->text() == "")
438 && (m_radiusLineEdit->text() == "")) {
439 QString msg = "Cannot retrieve the latitude, longitude, and radius from the reference";
440 msg = msg + "measure; this is the result of a known problem in our system. Please select ";
441 msg = msg + "Current, Average, or enter your own values.";
442 QMessageBox::warning((QWidget *)parent(), "Warning", msg);
443 return;
444 }
445 m_aprioriSource = (Source) REFERENCE;
446 }
447 }
448
449
465 void QnetSetAprioriDialog::fillAverageAprioriLineEdits() {
466 if (m_points.size() == 0) {
467 QString msg = "There are no Points selected. Please select a Point.";
468 QMessageBox::warning((QWidget *)parent(), "Warning", msg);
469 return;
470 }
471
472 //we can only populate the line edits if there is one point selected
473 if (m_points.size() == 1) {
474 double xB = 0.0;
475 double yB = 0.0;
476 double zB = 0.0;
477 double r2B = 0.0;
478 int goodMeasures = 0;
479 SurfacePoint aprioriSurfacePoint;
480
481 QString id = m_points.at(0)->text();
482 ControlPoint *pt = m_qnetTool->controlNet()->GetPoint(id);
483
484
485
486 //this code is copied from ControlPoint::ComputeApriori
487
488 for (int i = 0; i < pt->GetNumMeasures(); i++) {
489 ControlMeasure *m = pt->GetMeasure(i);
490 if (m->IsIgnored()) {
491 // TODO: How do we deal with ignored measures
492 }
493 else {
494 Camera *cam = m->Camera();
495 if (cam == NULL) {
496 QString msg = "The Camera must be set prior to calculating apriori";
497 throw IException(IException::Programmer, msg, _FILEINFO_);
498 }
499 if (cam->SetImage(m->GetSample(), m->GetLine())) {
500 goodMeasures++;
501 double pB[3];
502 cam->Coordinate(pB);
503 xB += pB[0];
504 yB += pB[1];
505 zB += pB[2];
506 r2B += pB[0]*pB[0] + pB[1]*pB[1] + pB[2]*pB[2];
507
508 //double x = cam->DistortionMap()->UndistortedFocalPlaneX();
509 //double y = cam->DistortionMap()->UndistortedFocalPlaneY();
510 //m->SetFocalPlaneMeasured(x, y);
511 }
512 else {
513 // JAA: Don't stop if we know the lat/lon. The SetImage may fail
514 // but the FocalPlane measures have been set
515 if (pt->GetPointTypeString() == "Fixed")
516 continue;
517 }
518 }
519 }
520
521 // Did we have any measures?
522 if (goodMeasures == 0) {
523 QString msg = "ControlPoint [" + id + "] has no measures which "
524 "project to lat/lon/radius (x/y/z)";
525 throw IException(IException::User, msg, _FILEINFO_);
526 }
527
528 // Compute the averages
529 //if (NumberOfConstrainedCoordinates() == 0) {
530 if (pt->GetPointTypeString() == "Free" || pt->NumberOfConstrainedCoordinates() == 0) {
531 double avgX = xB / goodMeasures;
532 double avgY = yB / goodMeasures;
533 double avgZ = zB / goodMeasures;
534 double avgR2 = r2B / goodMeasures;
535 double scale = sqrt(avgR2/(avgX*avgX+avgY*avgY+avgZ*avgZ));
536
537 aprioriSurfacePoint.SetRectangular(
538 Displacement((avgX*scale), Displacement::Kilometers),
539 Displacement((avgY*scale), Displacement::Kilometers),
540 Displacement((avgZ*scale), Displacement::Kilometers));
541 }
542 // Since we are not solving yet for x,y,and z in the bundle directly,
543 // longitude must be constrained. This constrains x and y as well.
544 else if (!(pt->GetPointTypeString() == "Fixed") &&
545 !(pt->NumberOfConstrainedCoordinates() == 3) &&
546 !pt->IsCoord1Constrained() &&
547 !pt->IsCoord2Constrained() &&
548 !pt->IsCoord3Constrained()){
549 aprioriSurfacePoint.SetRectangular(
550 Displacement(aprioriSurfacePoint.GetX().meters(), Displacement::Meters),
551 Displacement(aprioriSurfacePoint.GetY().meters(), Displacement::Meters),
552 Displacement((zB / goodMeasures), Displacement::Kilometers));
553 }
554
555 //End of copied code
556
557
558
559 SurfacePoint sPt = aprioriSurfacePoint;
560
561 if (sPt.GetLatitude().degrees() != Null) {
562 m_latLineEdit->setText(
563 QString::number(sPt.GetLatitude().degrees()));
564 }
565 else {
566 m_latLineEdit->clear();
567 }
568 if (sPt.GetLongitude().degrees() != Null) {
569 m_lonLineEdit->setText(
570 QString::number(sPt.GetLongitude().degrees()));
571 }
572 else {
573 m_lonLineEdit->clear();
574 }
575 //The 'f', 2 allows the radius to be displayed in meters rather than scientific notation
576 if (sPt.GetLocalRadius().meters() != Null) {
577 m_radiusLineEdit->setText(
578 QString::number(sPt.GetLocalRadius().meters(), 'f', 2));
579 }
580 else {
581 m_radiusLineEdit->clear();
582 }
583
584 //If all of the line edits are empty something went wrong
585 //tell the user that the average canot be computed and leave the apriori source alone
586 if ((m_latLineEdit->text() == "") && (m_lonLineEdit->text() == "")
587 && (m_radiusLineEdit->text() == "")) {
588 QString msg = "Average cannot be computed for this point [" + m_points.at(0)->text();
589 msg = msg + "]; this is the result of a known problem in our system. Please select ";
590 msg = msg + "Current, Reference, or enter your own values.";
591 QMessageBox::warning((QWidget *)parent(), "Warning", msg);
592 return;
593 }
594 m_aprioriSource = (Source) AVERAGE;
595 }
596 }
597
598// /**
599// This is the base for a new ticket that allows for a ground source button
600//
601// * Populates the apriori lat/lon/radius line edits with the ground source values, if there is a
602// * ground source. This only works on single points and is disabled for multiple points.
603// *
604// * @author 2016-08-05 Makayla Shepherd
605// *
606// */
607// void QnetSetAprioriDialog::fillGroundSourceAprioriLineEdits() {
608// if (m_points.size() == 0) {
609// QString msg = "There are no Points selected. Please select a Point.";
610// QMessageBox::warning((QWidget *)parent(), "Warning", msg);
611// return;
612// }
613// if (m_points.size() == 1) {
614//
615// }
616// }
617
618
627 void QnetSetAprioriDialog::fillSigmaLineEdits() {
628 if (m_points.size() == 0) {
629 QString msg = "There are no Points selected. Please select a Point.";
630 QMessageBox::warning((QWidget *)parent(), "Warning", msg);
631 return;
632 }
633
634 //we can only populate the sigma line edits if there is one point selected
635 if (m_points.size() == 1) {
636 QString id = m_points.at(0)->text();
637 ControlPoint *pt = m_qnetTool->controlNet()->GetPoint(id);
638 SurfacePoint sPt = pt->GetAprioriSurfacePoint();
639 if (sPt.GetLatSigmaDistance().meters() != Null) {
640 m_latSigmaLineEdit->setText(
641 QString::number(sPt.GetLatSigmaDistance().meters()));
642 }
643 if (sPt.GetLonSigmaDistance().meters() != Null) {
644 m_lonSigmaLineEdit->setText(
645 QString::number(sPt.GetLonSigmaDistance().meters()));
646 }
647 //The 'f', 2 allows the radius to be displayed in meters rather than scientific notation
648 if (sPt.GetLocalRadiusSigma().meters() != Null) {
649 m_radiusSigmaLineEdit->setText(
650 QString::number(sPt.GetLocalRadiusSigma().meters(), 'f', 2));
651 }
652 pt = NULL;
653 }
654 }
655
656
664 void QnetSetAprioriDialog::setInfoStack(QList<QListWidgetItem *> selectedPoints) {
665 if (selectedPoints.size() > 1) {
666 m_pointInfoStack->setCurrentWidget(m_multiplePointsInfoGroup);
667 }
668 else {
669 m_pointInfoStack->setCurrentWidget(m_singlePointInfoGroup);
670 }
671 }
672
673
682 void QnetSetAprioriDialog::checkPointInfoDisable(QList<QListWidgetItem *> selectedPoints) {
683 m_points = selectedPoints;
684 m_aprioriDialog->setEnabled(true);
685 m_sigmaGroup->setEnabled(true);
686 m_pointGroup->setEnabled(true);
687 m_currentSigmaButton->setEnabled(true);
688 m_sigmaWarningLabel->clear();
689
690 m_multiPointsMeasureCount = 0;
691 m_multiPointsConstraintedCount = 0;
692 m_multiPointsFixedCount = 0;
693 m_multiPointsFreeCount = 0;
694 m_multiPointsEditLockedCount = 0;
695 m_multiPointsIgnoredCount = 0;
696
697 //handle multiple points
698 if (m_points.size() > 1) {
699 for (int i = 0; i < m_points.size(); i++) {
700 QString id = m_points.at(i)->text();
701 ControlPoint *pt = m_qnetTool->controlNet()->GetPoint(id);
702 m_multiPointsMeasureCount += pt->GetNumMeasures();
703 if (pt->IsEditLocked()) {
704 m_multiPointsEditLockedCount++;
705 }
706 if (pt->IsIgnored()) {
707 m_multiPointsIgnoredCount++;
708 }
709 if (pt->GetPointTypeString() == "Constrained") {
710 m_multiPointsConstraintedCount++;
711 }
712 if (pt->GetPointTypeString() == "Fixed") {
713 m_multiPointsFixedCount++;
714 }
715 if (pt->GetPointTypeString() == "Free") {
716 m_multiPointsFreeCount++;
717 }
718 }
719 if (m_multiPointsEditLockedCount > 0) {
720 m_aprioriDialog->setDisabled(true);
721 QString msg = "There is an EditLocked point selected. To continue, unselect the";
722 msg = msg + " Editlocked point.";
723 QMessageBox::warning((QWidget *)parent(), "Warning", msg);
724 return;
725 }
726 if (m_multiPointsFixedCount > 0 || m_multiPointsFreeCount > 0) {
727 m_aprioriDialog->setDisabled(true);
728 QString msg = "Sigmas can only be set on Constrained points. Use Filters to filter by";
729 msg = msg + " Constrained points.";
730 QMessageBox::warning((QWidget *)parent(), "Warning", msg);
731 return;
732 }
733 m_pointGroup->setDisabled(true);
734 m_currentSigmaButton->setDisabled(true);
735 }
736 //handle a single point
737 else if (m_points.size() == 1) {
738 QString id = m_points.at(0)->text();
739 ControlPoint *pt = m_qnetTool->controlNet()->GetPoint(id);
740 if (pt->IsEditLocked()) {
741 m_aprioriDialog->setDisabled(true);
742 QString msg = "This control point is edit locked. The Apriori latitude, longitude and ";
743 msg += "radius cannot be updated. You must first unlock the point by clicking the ";
744 msg += "check box above labeled \"Edit Lock Point\".";
745 QMessageBox::warning((QWidget *)parent(), "Warning", msg);
746 return;
747 }
748 else if (pt->GetPointTypeString() == "Fixed" || pt->GetPointTypeString() == "Free") {
749 m_sigmaWarningLabel->setText("Change point type to Constrained to enter constraints (Apriori Sigmas).");
750 m_sigmaGroup->setDisabled(true);
751 }
752 else {
753 m_aprioriDialog->setEnabled(true);
754 m_sigmaGroup->setEnabled(true);
755 m_pointGroup->setEnabled(true);
756 m_currentSigmaButton->setEnabled(true);
757 }
758 }
759 }
760
761
770 void QnetSetAprioriDialog::clearLineEdits() {
771 m_latLineEdit->clear();
772 m_lonLineEdit->clear();
773 m_radiusLineEdit->clear();
774 m_latSigmaLineEdit->clear();
775 m_lonSigmaLineEdit->clear();
776 m_radiusSigmaLineEdit->clear();
777 }
778
779
786 void QnetSetAprioriDialog::resetInfoLabels() {
787
788 if (m_points.size() < 0) {
789 m_pointIDLabel->setText("Point ID: ");
790 m_pointTypeLabel->setText("Point Type: ");
791 m_pointMeasureNumber->setText("Number of Measures: ");
792 m_editLockedBoolLabel->setText("EditLocked: ");
793 m_ignoredBoolLabel->setText("Ignored: ");
794 }
795 //reset all the information needed for a single point
796 else if (m_points.size() == 1) {
797 QString id = m_points.at(0)->text();
798 ControlPoint *pt = m_qnetTool->controlNet()->GetPoint(id);
799 m_pointIDLabel->setText("Point ID: " + QString(id));
800 m_pointTypeLabel->setText("Point Type: " + QString(pt->GetPointTypeString()));
801 m_pointMeasureNumber->setText("Number of Measures: " + QString::number(pt->GetNumMeasures()));
802
803 if (pt->IsEditLocked()) {
804 m_editLockedBoolLabel->setText("EditLocked: True");
805 }
806 else {
807 m_editLockedBoolLabel->setText("EditLocked: False");
808 }
809 if (pt->IsIgnored()) {
810 m_ignoredBoolLabel->setText("Ignored: True");
811 }
812 else {
813 m_ignoredBoolLabel->setText("Ignored: False");
814 }
815 }
816 //reset all of the information needed for multiple points
817 else if (m_points.size() > 1) {
818 m_pointsCount->setText("Number of Points: " + QString::number(m_points.size()));
819 m_pointsMeasuresCount->setText("Total Number of Measures: " +
820 QString::number(m_multiPointsMeasureCount));
821 m_constrainedPointsCount->setText("Number of Constrained Points: " +
822 QString::number(m_multiPointsConstraintedCount));
823 m_fixedPointsCount->setText("Number of Fixed Points: " +
824 QString::number(m_multiPointsFixedCount));
825 m_freePointsCount->setText("Number of Free Points: " +
826 QString::number(m_multiPointsFreeCount));
827 m_pointsEditLockedCount->setText("Number of Edit Locked Points: " +
828 QString::number(m_multiPointsEditLockedCount));
829 m_pointsIgnoredCount->setText("Number of Ignored Points: " +
830 QString::number(m_multiPointsIgnoredCount));
831 }
832 }
833
834
859 void QnetSetAprioriDialog::setApriori() {
860
861 if (m_points.size() == 0) {
862 QString msg = "There are no Points selected. Please select a Point.";
863 QMessageBox::warning((QWidget *)parent(), "Warning", msg);
864 return;
865 }
866
867 double latSigma = Null;
868 double lat = Null;
869 double lonSigma = Null;
870 double lon = Null;
871 double radiusSigma = Null;
872 double radius = Null;
873 bool lineEditModified = false;
874
875 //retrieve all of the line edit values and check if the line edits have been modified
876 if (m_latLineEdit->text() != "") {
877 lat = m_latLineEdit->text().toDouble();
878 if (lat > 90 || lat < -90) {
879 QString msg = "Invalid latitude value. Please enter a latitude value between -90 and 90.";
880 QMessageBox::warning((QWidget *)parent(), "Warning", msg);
881 return;
882 }
883 if (m_latLineEdit->isModified()) {
884 lineEditModified = true;
885 }
886 }
887 if (m_lonLineEdit->text() != "") {
888 lon = m_lonLineEdit->text().toDouble();
889 if (m_lonLineEdit->isModified()) {
890 lineEditModified = true;
891 }
892 }
893 if (m_radiusLineEdit->text() != "") {
894 radius = m_radiusLineEdit->text().toDouble();
895 if (m_radiusLineEdit->isModified()) {
896 lineEditModified = true;
897 }
898 }
899 if (m_latSigmaLineEdit->text() != "") {
900 latSigma = m_latSigmaLineEdit->text().toDouble();
901 }
902 if (m_lonSigmaLineEdit->text() != "") {
903 lonSigma = m_lonSigmaLineEdit->text().toDouble();
904 }
905 if (m_radiusSigmaLineEdit->text() != "") {
906 radiusSigma = m_radiusSigmaLineEdit->text().toDouble();
907 }
908
909
910 //if any of the line edits have been modified then the AprioriSurfacePointSource and
911 //RadiusSource are the user
912 if (lineEditModified) {
913 m_aprioriSource = (Source) USER;
914 }
915
916 for (int i = 0; i < m_points.size(); i++) {
917 QString id = m_points.at(i)->text();
918 ControlPoint *pt = m_qnetTool->controlNet()->GetPoint(id);
919 if (m_points.size() == 1) {
921 Latitude(lat, Angle::Degrees),
922 Longitude(lon, Angle::Degrees),
923 Distance(radius,Distance::Meters)));
924 if (m_aprioriSource == (Source) REFERENCE) {
925 pt->SetAprioriSurfacePointSource(ControlPoint::SurfacePointSource::Reference);
926 }
927 else if (m_aprioriSource == (Source) AVERAGE) {
928 pt->SetAprioriSurfacePointSource(ControlPoint::SurfacePointSource::AverageOfMeasures);
929// pt->SetAprioriRadiusSource(ControlPoint::RadiusSource::AverageOfMeasures);
930 }
931 else if (m_aprioriSource == (Source) USER) {
932 pt->SetAprioriSurfacePointSource(ControlPoint::SurfacePointSource::User);
933// pt->SetAprioriRadiusSource(ControlPoint::RadiusSource::User);
934 }
935 }
936 if (!pt->HasAprioriCoordinates()) {
937 QString msg = "Point [" + id + "] does not have an Apriori coordinate. "
938 "Make sure to save the ground source measurement then the Point before "
939 "setting the sigmas. ";
940 if (m_points.size() > 1) {
941 msg += "The sigmas for all of the selected points will not be set.";
942 }
943 else {
944 msg += "The sigmas for this point will not be set.";
945 }
946 QMessageBox::warning((QWidget *)parent(), "Warning", msg);
947 return;
948 }
949
950 try {
951 // Read Surface point from the control point and set the sigmas,
952 // first set the target radii
953 SurfacePoint spt = pt->GetAprioriSurfacePoint();
954
955 spt.SetSphericalSigmasDistance(Distance(latSigma,Distance::Meters),
956 Distance(lonSigma,Distance::Meters),
957 Distance(radiusSigma,Distance::Meters));
958
959 // Write the surface point back out to the controlPoint
960 pt->SetAprioriSurfacePoint(spt);
961
962 // TODO: Is the following line necessary, should error be thrown
963 // for free or fixed pts?
964 //pt->SetType(ControlPoint::Constrained);
965 emit pointChanged(id);
966 emit netChanged();
967 }
968 catch (IException &e) {
969 QString message = "Error setting sigmas. \n";
970 message += e.toString();
971 QMessageBox::critical((QWidget *)parent(),"Error",message);
972 QApplication::restoreOverrideCursor();
973 // Sigmas failed, but surface pt coordinate was set
974 emit pointChanged(id);
975 emit netChanged();
976 return;
977 }
978 }
979 }
980}
Camera(Cube &cube)
Constructs the Camera object.
Definition Camera.cpp:56
a control measurement
A single control point.
Status SetAprioriSurfacePoint(SurfacePoint aprioriSP)
This updates the apriori surface point.
Displacement is a signed length, usually in meters.
double meters() const
Get the displacement in meters.
Distance measurement, usually in meters.
Definition Distance.h:34
Isis exception class.
Definition IException.h:91
This class is designed to encapsulate the concept of a Latitude.
Definition Latitude.h:51
This class is designed to encapsulate the concept of a Longitude.
Definition Longitude.h:40
This class defines a body-fixed surface point.
void SetSphericalSigmasDistance(const Distance &latSigma, const Distance &lonSigma, const Distance &radiusSigma)
Set the spherical sigmas (in Distance units) into the spherical variance/covariance matrix.
void SetRectangular(const Displacement &x, const Displacement &y, const Displacement &z, const Distance &xSigma=Distance(), const Distance &ySigma=Distance(), const Distance &zSigma=Distance())
Set surface point in rectangular body-fixed coordinates wtih optional sigmas.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
const double Null
Value for an Isis Null pixel.
Namespace for the standard library.