Isis 3.0 Programmer Reference
Back | Home
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 
30 using namespace std;
31 
32 namespace 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 
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 
268  closeEvent();
269  QDialog::reject();
270  }
271 
272 
279 
280  disconnect(m_currentAprioriButton, SIGNAL(clicked()), this,
282  disconnect(m_referenceAprioriButton, SIGNAL(clicked()), this,
284  disconnect(m_averageAprioriButton, SIGNAL(clicked()), this,
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 
305  if (m_aprioriDialog != NULL) {
306  m_aprioriDialog->setVisible(true);
307  }
308  }
309 
310 
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) {
333  }
334  }
335 
336 
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  vector<Distance> targetRadii = m_qnetTool->controlNet()->GetTargetRadii();
358 
359  sPt.SetRadii(Distance(targetRadii[0]),
360  Distance(targetRadii[1]),
361  Distance(targetRadii[2]));
362  if (sPt.GetLatitude().degrees() != Null) {
363  m_latLineEdit->setText(
364  QString::number(sPt.GetLatitude().degrees()));
365  }
366  else {
367  m_latLineEdit->clear();
368  }
369  if (sPt.GetLongitude().degrees() != Null) {
370  m_lonLineEdit->setText(
371  QString::number(sPt.GetLongitude().degrees()));
372  }
373  else {
374  m_lonLineEdit->clear();
375  }
376  //The 'f', 2 allows the radius to be displayed in meters rather than scientific notation
377  if (sPt.GetLocalRadius().meters() != Null) {
378  m_radiusLineEdit->setText(
379  QString::number(sPt.GetLocalRadius().meters(), 'f', 2));
380  }
381  else {
382  m_radiusLineEdit->clear();
383  }
384  m_aprioriSource = (Source) USER;
385  }
386  }
387 
388 
398  if (m_points.size() == 0) {
399  QString msg = "There are no Points selected. Please select a Point.";
400  QMessageBox::warning((QWidget *)parent(), "Warning", msg);
401  return;
402  }
403 
404  //we can only populate the line edits if there is one point selected
405  if (m_points.size() == 1) {
406 
407  QString id = m_points.at(0)->text();
408  ControlPoint *pt = m_qnetTool->controlNet()->GetPoint(id);
409  ControlMeasure *m = pt->GetRefMeasure();
410  vector<Distance> targetRadii = m_qnetTool->controlNet()->GetTargetRadii();
411 
412  // Find camera from network camera list
413  int camIndex = m_qnetTool->serialNumberList()->serialNumberIndex(
414  m->GetCubeSerialNumber());
415  Camera *cam = m_qnetTool->controlNet()->Camera(camIndex);
416  cam->SetImage(m->GetSample(),m->GetLine());
417  SurfacePoint refSPt = cam->GetSurfacePoint();
418  refSPt.SetRadii(Distance(targetRadii[0]),
419  Distance(targetRadii[1]),
420  Distance(targetRadii[2]));
421  if (refSPt.GetLatitude().degrees() != Null) {
422  m_latLineEdit->setText(
423  QString::number(refSPt.GetLatitude().degrees()));
424  }
425  else {
426  m_latLineEdit->clear();
427  }
428  if (refSPt.GetLongitude().degrees() != Null) {
429  m_lonLineEdit->setText(
430  QString::number(refSPt.GetLongitude().degrees()));
431  }
432  else {
433  m_lonLineEdit->clear();
434  }
435  //The 'f', 2 allows the radius to be displayed in meters rather than scientific notation
436  if (refSPt.GetLocalRadius().meters() != Null) {
437  m_radiusLineEdit->setText(
438  QString::number(refSPt.GetLocalRadius().meters(), 'f', 2));
439  }
440  else {
441  m_radiusLineEdit->clear();
442  }
443 
444  //If all of the line edits are empty something went wrong, tell the user, and return
445  if ((m_latLineEdit->text() == "") && (m_lonLineEdit->text() == "")
446  && (m_radiusLineEdit->text() == "")) {
447  QString msg = "Cannot retrieve the latitude, longitude, and radius from the reference";
448  msg = msg + "measure; this is the result of a known problem in our system. Please select ";
449  msg = msg + "Current, Average, or enter your own values.";
450  QMessageBox::warning((QWidget *)parent(), "Warning", msg);
451  return;
452  }
453  m_aprioriSource = (Source) REFERENCE;
454  }
455  }
456 
457 
474  if (m_points.size() == 0) {
475  QString msg = "There are no Points selected. Please select a Point.";
476  QMessageBox::warning((QWidget *)parent(), "Warning", msg);
477  return;
478  }
479 
480  //we can only populate the line edits if there is one point selected
481  if (m_points.size() == 1) {
482  double xB = 0.0;
483  double yB = 0.0;
484  double zB = 0.0;
485  double r2B = 0.0;
486  int goodMeasures = 0;
487  SurfacePoint aprioriSurfacePoint;
488 
489  QString id = m_points.at(0)->text();
490  ControlPoint *pt = m_qnetTool->controlNet()->GetPoint(id);
491 
492 
493 
494  //this code is copied from ControlPoint::ComputeApriori
495 
496  for (int i = 0; i < pt->GetNumMeasures(); i++) {
497  ControlMeasure *m = pt->GetMeasure(i);
498  if (m->IsIgnored()) {
499  // TODO: How do we deal with ignored measures
500  }
501  else {
502  Camera *cam = m->Camera();
503  if (cam == NULL) {
504  QString msg = "The Camera must be set prior to calculating apriori";
506  }
507  if (cam->SetImage(m->GetSample(), m->GetLine())) {
508  goodMeasures++;
509  double pB[3];
510  cam->Coordinate(pB);
511  xB += pB[0];
512  yB += pB[1];
513  zB += pB[2];
514  r2B += pB[0]*pB[0] + pB[1]*pB[1] + pB[2]*pB[2];
515 
516  //double x = cam->DistortionMap()->UndistortedFocalPlaneX();
517  //double y = cam->DistortionMap()->UndistortedFocalPlaneY();
518  //m->SetFocalPlaneMeasured(x, y);
519  }
520  else {
521  // JAA: Don't stop if we know the lat/lon. The SetImage may fail
522  // but the FocalPlane measures have been set
523  if (pt->GetPointTypeString() == "Fixed")
524  continue;
525  }
526  }
527  }
528 
529  // Did we have any measures?
530  if (goodMeasures == 0) {
531  QString msg = "ControlPoint [" + id + "] has no measures which "
532  "project to lat/lon/radius (x/y/z)";
534  }
535 
536  // Compute the averages
537  //if (NumberOfConstrainedCoordinates() == 0) {
538  if (pt->GetPointTypeString() == "Free" || pt->NumberOfConstrainedCoordinates() == 0) {
539  double avgX = xB / goodMeasures;
540  double avgY = yB / goodMeasures;
541  double avgZ = zB / goodMeasures;
542  double avgR2 = r2B / goodMeasures;
543  double scale = sqrt(avgR2/(avgX*avgX+avgY*avgY+avgZ*avgZ));
544 
545  aprioriSurfacePoint.SetRectangular(
546  Displacement((avgX*scale), Displacement::Kilometers),
547  Displacement((avgY*scale), Displacement::Kilometers),
548  Displacement((avgZ*scale), Displacement::Kilometers));
549  }
550  // Since we are not solving yet for x,y,and z in the bundle directly,
551  // longitude must be constrained. This constrains x and y as well.
552  else if (!(pt->GetPointTypeString() == "Fixed") &&
553  !(pt->NumberOfConstrainedCoordinates() == 3) &&
554  !pt->IsLatitudeConstrained() &&
555  !pt->IsLongitudeConstrained() &&
556  !pt->IsRadiusConstrained()){
557 
558  aprioriSurfacePoint.SetRectangular(
559  Displacement(aprioriSurfacePoint.GetX().meters(), Displacement::Meters),
560  Displacement(aprioriSurfacePoint.GetY().meters(), Displacement::Meters),
561  Displacement((zB / goodMeasures), Displacement::Kilometers));
562  }
563 
564  //End of copied code
565 
566 
567 
568  SurfacePoint sPt = aprioriSurfacePoint;
569  vector<Distance> targetRadii = m_qnetTool->controlNet()->GetTargetRadii();
570 
571  sPt.SetRadii(Distance(targetRadii[0]),
572  Distance(targetRadii[1]),
573  Distance(targetRadii[2]));
574  if (sPt.GetLatitude().degrees() != Null) {
575  m_latLineEdit->setText(
576  QString::number(sPt.GetLatitude().degrees()));
577  }
578  else {
579  m_latLineEdit->clear();
580  }
581  if (sPt.GetLongitude().degrees() != Null) {
582  m_lonLineEdit->setText(
583  QString::number(sPt.GetLongitude().degrees()));
584  }
585  else {
586  m_lonLineEdit->clear();
587  }
588  //The 'f', 2 allows the radius to be displayed in meters rather than scientific notation
589  if (sPt.GetLocalRadius().meters() != Null) {
590  m_radiusLineEdit->setText(
591  QString::number(sPt.GetLocalRadius().meters(), 'f', 2));
592  }
593  else {
594  m_radiusLineEdit->clear();
595  }
596 
597  //If all of the line edits are empty something went wrong
598  //tell the user that the average canot be computed and leave the apriori source alone
599  if ((m_latLineEdit->text() == "") && (m_lonLineEdit->text() == "")
600  && (m_radiusLineEdit->text() == "")) {
601  QString msg = "Average cannot be computed for this point [" + m_points.at(0)->text();
602  msg = msg + "]; this is the result of a known problem in our system. Please select ";
603  msg = msg + "Current, Reference, or enter your own values.";
604  QMessageBox::warning((QWidget *)parent(), "Warning", msg);
605  return;
606  }
607  m_aprioriSource = (Source) AVERAGE;
608  }
609  }
610 
611 // /**
612 // This is the base for a new ticket that allows for a ground source button
613 //
614 // * Populates the apriori lat/lon/radius line edits with the ground source values, if there is a
615 // * ground source. This only works on single points and is disabled for multiple points.
616 // *
617 // * @author 2016-08-05 Makayla Shepherd
618 // *
619 // */
620 // void QnetSetAprioriDialog::fillGroundSourceAprioriLineEdits() {
621 // if (m_points.size() == 0) {
622 // QString msg = "There are no Points selected. Please select a Point.";
623 // QMessageBox::warning((QWidget *)parent(), "Warning", msg);
624 // return;
625 // }
626 // if (m_points.size() == 1) {
627 //
628 // }
629 // }
630 
631 
641  if (m_points.size() == 0) {
642  QString msg = "There are no Points selected. Please select a Point.";
643  QMessageBox::warning((QWidget *)parent(), "Warning", msg);
644  return;
645  }
646 
647  //we can only populate the sigma line edits if there is one point selected
648  if (m_points.size() == 1) {
649  QString id = m_points.at(0)->text();
650  ControlPoint *pt = m_qnetTool->controlNet()->GetPoint(id);
651  SurfacePoint sPt = pt->GetAprioriSurfacePoint();
652  vector<Distance> targetRadii = m_qnetTool->controlNet()->GetTargetRadii();
653  sPt.SetRadii(Distance(targetRadii[0]),
654  Distance(targetRadii[1]),
655  Distance(targetRadii[2]));
656  if (sPt.GetLatSigmaDistance().meters() != Null) {
657  m_latSigmaLineEdit->setText(
658  QString::number(sPt.GetLatSigmaDistance().meters()));
659  }
660  if (sPt.GetLonSigmaDistance().meters() != Null) {
661  m_lonSigmaLineEdit->setText(
662  QString::number(sPt.GetLonSigmaDistance().meters()));
663  }
664  //The 'f', 2 allows the radius to be displayed in meters rather than scientific notation
665  if (sPt.GetLocalRadiusSigma().meters() != Null) {
666  m_radiusSigmaLineEdit->setText(
667  QString::number(sPt.GetLocalRadiusSigma().meters(), 'f', 2));
668  }
669  pt = NULL;
670  }
671  }
672 
673 
682  if (selectedPoints.size() > 1) {
683  m_pointInfoStack->setCurrentWidget(m_multiplePointsInfoGroup);
684  }
685  else {
686  m_pointInfoStack->setCurrentWidget(m_singlePointInfoGroup);
687  }
688  }
689 
690 
700  m_points = selectedPoints;
701  m_aprioriDialog->setEnabled(true);
702  m_sigmaGroup->setEnabled(true);
703  m_pointGroup->setEnabled(true);
704  m_currentSigmaButton->setEnabled(true);
705  m_sigmaWarningLabel->clear();
706 
707  m_multiPointsMeasureCount = 0;
708  m_multiPointsConstraintedCount = 0;
709  m_multiPointsFixedCount = 0;
710  m_multiPointsFreeCount = 0;
711  m_multiPointsEditLockedCount = 0;
712  m_multiPointsIgnoredCount = 0;
713 
714  //handle multiple points
715  if (m_points.size() > 1) {
716  for (int i = 0; i < m_points.size(); i++) {
717  QString id = m_points.at(i)->text();
718  ControlPoint *pt = m_qnetTool->controlNet()->GetPoint(id);
719  m_multiPointsMeasureCount += pt->GetNumMeasures();
720  if (pt->IsEditLocked()) {
721  m_multiPointsEditLockedCount++;
722  }
723  if (pt->IsIgnored()) {
724  m_multiPointsIgnoredCount++;
725  }
726  if (pt->GetPointTypeString() == "Constrained") {
727  m_multiPointsConstraintedCount++;
728  }
729  if (pt->GetPointTypeString() == "Fixed") {
730  m_multiPointsFixedCount++;
731  }
732  if (pt->GetPointTypeString() == "Free") {
733  m_multiPointsFreeCount++;
734  }
735  }
736  if (m_multiPointsEditLockedCount > 0) {
737  m_aprioriDialog->setDisabled(true);
738  QString msg = "There is an EditLocked point selected. To continue, unselect the";
739  msg = msg + " Editlocked point.";
740  QMessageBox::warning((QWidget *)parent(), "Warning", msg);
741  return;
742  }
743  if (m_multiPointsFixedCount > 0 || m_multiPointsFreeCount > 0) {
744  m_aprioriDialog->setDisabled(true);
745  QString msg = "Sigmas can only be set on Constrained points. Use Filters to filter by";
746  msg = msg + " Constrained points.";
747  QMessageBox::warning((QWidget *)parent(), "Warning", msg);
748  return;
749  }
750  m_pointGroup->setDisabled(true);
751  m_currentSigmaButton->setDisabled(true);
752  }
753  //handle a single point
754  else if (m_points.size() == 1) {
755  QString id = m_points.at(0)->text();
756  ControlPoint *pt = m_qnetTool->controlNet()->GetPoint(id);
757  if (pt->IsEditLocked()) {
758  m_aprioriDialog->setDisabled(true);
759  QString msg = "This control point is edit locked. The Apriori latitude, longitude and ";
760  msg += "radius cannot be updated. You must first unlock the point by clicking the ";
761  msg += "check box above labeled \"Edit Lock Point\".";
762  QMessageBox::warning((QWidget *)parent(), "Warning", msg);
763  return;
764  }
765  else if (pt->GetPointTypeString() == "Fixed" || pt->GetPointTypeString() == "Free") {
766  m_sigmaWarningLabel->setText("Change point type to Constrained to enter constraints (Apriori Sigmas).");
767  m_sigmaGroup->setDisabled(true);
768  }
769  else {
770  m_aprioriDialog->setEnabled(true);
771  m_sigmaGroup->setEnabled(true);
772  m_pointGroup->setEnabled(true);
773  m_currentSigmaButton->setEnabled(true);
774  }
775  }
776  }
777 
778 
788  m_latLineEdit->clear();
789  m_lonLineEdit->clear();
790  m_radiusLineEdit->clear();
791  m_latSigmaLineEdit->clear();
792  m_lonSigmaLineEdit->clear();
793  m_radiusSigmaLineEdit->clear();
794  }
795 
796 
804 
805  if (m_points.size() < 0) {
806  m_pointIDLabel->setText("Point ID: ");
807  m_pointTypeLabel->setText("Point Type: ");
808  m_pointMeasureNumber->setText("Number of Measures: ");
809  m_editLockedBoolLabel->setText("EditLocked: ");
810  m_ignoredBoolLabel->setText("Ignored: ");
811  }
812  //reset all the information needed for a single point
813  else if (m_points.size() == 1) {
814  QString id = m_points.at(0)->text();
815  ControlPoint *pt = m_qnetTool->controlNet()->GetPoint(id);
816  m_pointIDLabel->setText("Point ID: " + QString(id));
817  m_pointTypeLabel->setText("Point Type: " + QString(pt->GetPointTypeString()));
818  m_pointMeasureNumber->setText("Number of Measures: " + QString::number(pt->GetNumMeasures()));
819 
820  if (pt->IsEditLocked()) {
821  m_editLockedBoolLabel->setText("EditLocked: True");
822  }
823  else {
824  m_editLockedBoolLabel->setText("EditLocked: False");
825  }
826  if (pt->IsIgnored()) {
827  m_ignoredBoolLabel->setText("Ignored: True");
828  }
829  else {
830  m_ignoredBoolLabel->setText("Ignored: False");
831  }
832  }
833  //reset all of the information needed for multiple points
834  else if (m_points.size() > 1) {
835  m_pointsCount->setText("Number of Points: " + QString::number(m_points.size()));
836  m_pointsMeasuresCount->setText("Total Number of Measures: " +
837  QString::number(m_multiPointsMeasureCount));
838  m_constrainedPointsCount->setText("Number of Constrained Points: " +
839  QString::number(m_multiPointsConstraintedCount));
840  m_fixedPointsCount->setText("Number of Fixed Points: " +
841  QString::number(m_multiPointsFixedCount));
842  m_freePointsCount->setText("Number of Free Points: " +
843  QString::number(m_multiPointsFreeCount));
844  m_pointsEditLockedCount->setText("Number of Edit Locked Points: " +
845  QString::number(m_multiPointsEditLockedCount));
846  m_pointsIgnoredCount->setText("Number of Ignored Points: " +
847  QString::number(m_multiPointsIgnoredCount));
848  }
849  }
850 
851 
877 
878  if (m_points.size() == 0) {
879  QString msg = "There are no Points selected. Please select a Point.";
880  QMessageBox::warning((QWidget *)parent(), "Warning", msg);
881  return;
882  }
883 
884  double latSigma = Null;
885  double lat = Null;
886  double lonSigma = Null;
887  double lon = Null;
888  double radiusSigma = Null;
889  double radius = Null;
890  bool lineEditModified = false;
891 
892  //retrieve all of the line edit values and check if the line edits have been modified
893  if (m_latLineEdit->text() != "") {
894  lat = m_latLineEdit->text().toDouble();
895  if (lat > 90 || lat < -90) {
896  QString msg = "Invalid latitude value. Please enter a latitude value between -90 and 90.";
897  QMessageBox::warning((QWidget *)parent(), "Warning", msg);
898  return;
899  }
900  if (m_latLineEdit->isModified()) {
901  lineEditModified = true;
902  }
903  }
904  if (m_lonLineEdit->text() != "") {
905  lon = m_lonLineEdit->text().toDouble();
906  if (m_lonLineEdit->isModified()) {
907  lineEditModified = true;
908  }
909  }
910  if (m_radiusLineEdit->text() != "") {
911  radius = m_radiusLineEdit->text().toDouble();
912  if (m_radiusLineEdit->isModified()) {
913  lineEditModified = true;
914  }
915  }
916  if (m_latSigmaLineEdit->text() != "") {
917  latSigma = m_latSigmaLineEdit->text().toDouble();
918  }
919  if (m_lonSigmaLineEdit->text() != "") {
920  lonSigma = m_lonSigmaLineEdit->text().toDouble();
921  }
922  if (m_radiusSigmaLineEdit->text() != "") {
923  radiusSigma = m_radiusSigmaLineEdit->text().toDouble();
924  }
925 
926 
927  //if any of the line edits have been modified then the AprioriSurfacePointSource and
928  //RadiusSource are the user
929  if (lineEditModified) {
930  m_aprioriSource = (Source) USER;
931  }
932 
933  for (int i = 0; i < m_points.size(); i++) {
934  QString id = m_points.at(i)->text();
935  ControlPoint *pt = m_qnetTool->controlNet()->GetPoint(id);
936  if (m_points.size() == 1) {
938  Latitude(lat, Angle::Degrees),
940  Distance(radius,Distance::Meters)));
941  if (m_aprioriSource == (Source) REFERENCE) {
942  pt->SetAprioriSurfacePointSource(ControlPoint::SurfacePointSource::Reference);
943  }
944  else if (m_aprioriSource == (Source) AVERAGE) {
945  pt->SetAprioriSurfacePointSource(ControlPoint::SurfacePointSource::AverageOfMeasures);
946 // pt->SetAprioriRadiusSource(ControlPoint::RadiusSource::AverageOfMeasures);
947  }
948  else if (m_aprioriSource == (Source) USER) {
949  pt->SetAprioriSurfacePointSource(ControlPoint::SurfacePointSource::User);
950 // pt->SetAprioriRadiusSource(ControlPoint::RadiusSource::User);
951  }
952  }
953  if (!pt->HasAprioriCoordinates()) {
954  QString msg = "Point [" + id + "] does not have an Apriori coordinate. "
955  "Make sure to save the ground source measurement then the Point before "
956  "setting the sigmas. ";
957  if (m_points.size() > 1) {
958  msg += "The sigmas for all of the selected points will not be set.";
959  }
960  else {
961  msg += "The sigmas for this point will not be set.";
962  }
963  QMessageBox::warning((QWidget *)parent(), "Warning", msg);
964  return;
965  }
966 
967  try {
968  // Read Surface point from the control point and set the sigmas,
969  // first set the target radii
970  SurfacePoint spt = pt->GetAprioriSurfacePoint();
971  vector<Distance> targetRadii = m_qnetTool->controlNet()->GetTargetRadii();
972  spt.SetRadii(Distance(targetRadii[0]),
973  Distance(targetRadii[1]),
974  Distance(targetRadii[2]));
975 
977  Distance(lonSigma,Distance::Meters),
978  Distance(radiusSigma,Distance::Meters));
979 
980  // Write the surface point back out to the controlPoint
981  pt->SetAprioriSurfacePoint(spt);
982 
983  // TODO: Is the following line necessary, should error be thrown
984  // for free or fixed pts?
985  //pt->SetType(ControlPoint::Constrained);
986  emit pointChanged(id);
987  emit netChanged();
988  }
989  catch (IException &e) {
990  QString message = "Error setting sigmas. \n";
991  message += e.toString();
992  QMessageBox::critical((QWidget *)parent(),"Error",message);
993  QApplication::restoreOverrideCursor();
994  // Sigmas failed, but surface pt coordinate was set
995  emit pointChanged(id);
996  emit netChanged();
997  return;
998  }
999  }
1000  }
1001 }
This class defines a body-fixed surface point.
Definition: SurfacePoint.h:86
Status SetAprioriSurfacePointSource(SurfacePointSource::Source source)
This updates the source of the surface point.
void fillReferenceAprioriLineEdits()
Populates the apriori lat/lon/radius line edits with the reference measure values.
int serialNumberIndex(const QString &sn)
Return a list index given a serial number.
void clearLineEdits()
Clears the line edits.
const double Null
Value for an Isis Null pixel.
Definition: SpecialPixel.h:109
The distance is being specified in kilometers.
Definition: Displacement.h:54
std::vector< Distance > GetTargetRadii()
Get the target radii.
void setVisiblity()
Shows the dialog box.
double degrees() const
Get the angle in units of Degrees.
Definition: Angle.h:245
void resetInfoLabels()
Resets and populates the information stack labels.
Distance GetLocalRadius() const
Return the radius of the surface point.
double meters() const
Get the displacement in meters.
QString GetPointTypeString() const
Obtain a string representation of the PointType.
void fillAverageAprioriLineEdits()
Populates the apriori lat/lon/radius line edits with the average measure values.
This class is designed to encapsulate the concept of a Latitude.
Definition: Latitude.h:59
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:154
virtual void reject()
This is called when the user selects the X button on the top right or they hit ESC.
The distance is being specified in meters.
Definition: Displacement.h:52
const ControlMeasure * GetRefMeasure() const
Get the reference control measure.
Distance measurement, usually in meters.
Definition: Distance.h:47
void fillSigmaLineEdits()
This is the base for a new ticket that allows for a ground source button.
void createSetAprioriDialog(QWidget *parent)
Creates the dialog box for the set apriori tool.
Longitude GetLongitude() const
Return the body-fixed longitude for the surface point.
void SetRadii(const Distance &majorRadius, const Distance &minorRadius, const Distance &polarRadius)
Reset the radii of the surface body of the surface point.
Distance GetLonSigmaDistance() const
Return the longiitude sigma in meters.
bool SetImage(const double sample, const double line)
Sets the sample/line values of the image to get the lat/lon values.
Definition: Camera.cpp:166
This class is designed to encapsulate the concept of a Longitude.
Definition: Longitude.h:52
double meters() const
Get the distance in meters.
Definition: Distance.cpp:97
Degrees are generally considered more human readable, 0-360 is one circle, however most math does not...
Definition: Angle.h:69
void setPoints(QList< QListWidgetItem * > selectedPoints)
Set control points in the dialog.
Latitude GetLatitude() const
Return the body-fixed latitude for the surface point.
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:38
A type of error that could only have occurred due to a mistake on the user&#39;s part (e...
Definition: IException.h:134
Status SetAprioriSurfacePoint(SurfacePoint aprioriSP)
This updates the apriori surface point.
void checkPointInfoDisable(QList< QListWidgetItem * > selectedPoints)
Enables/Disables features based on if there are multiple points selected or not.
A single control point.
Definition: ControlPoint.h:339
SurfacePoint GetSurfacePoint() const
Returns the surface point (most efficient accessor).
Definition: Sensor.cpp:270
void setInfoStack(QList< QListWidgetItem * > selectedPoints)
Switches what information is visible based on how many points are selected.
void Coordinate(double p[3]) const
Returns the x,y,z of the surface intersection in BodyFixed km.
Definition: Sensor.cpp:211
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
void closeEvent()
Disconnect all of the slots on a close event.
void fillCurrentAprioriLineEdits()
Populates the apriori lat/lon/radius line edits with the current values.
Displacement is a signed length, usually in meters.
Definition: Displacement.h:43
QString toString() const
Returns a string representation of this exception.
Definition: IException.cpp:553
Distance GetLatSigmaDistance() const
Return the latitude sigma in meters.
Isis exception class.
Definition: IException.h:99
a control measurement
QString GetCubeSerialNumber() const
Return the serial number of the cube containing the coordinate.
Isis::Camera * Camera(int index)
Returns the camera list from the given image number.
void SetSphericalSigmasDistance(const Distance &latSigma, const Distance &lonSigma, const Distance &radiusSigma)
Set the spherical sigmas (in meters) into the spherical variance/covariance matrix.
The distance is being specified in meters.
Definition: Distance.h:56
void setApriori()
Slot to set apriori on selected Points from Navigator list box.
const ControlMeasure * GetMeasure(QString serialNumber) const
Get a control measure based on its cube&#39;s serial number.
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.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.

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:27:50