122 void QnetSetAprioriDialog::createSetAprioriDialog(
QWidget *parent) {
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: ");
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: ");
139 m_currentAprioriButton =
new QPushButton(
"Current");
140 m_currentAprioriButton->setDefault(
false);
141 m_currentAprioriButton->setToolTip(
"Populate with the current Apriori Position");
143 m_referenceAprioriButton =
new QPushButton(
"Reference");
144 m_referenceAprioriButton->setToolTip(
"Populate with Apriori Position of the reference measure");
146 m_averageAprioriButton =
new QPushButton(
"Average");
147 m_averageAprioriButton->setToolTip(
"Calculate and populate with the average Apriori Position");
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();
159 m_sigmaWarningLabel =
new QLabel(
"");
161 m_currentSigmaButton =
new QPushButton(
"Current");
162 m_currentSigmaButton->setToolTip(
"Populate the current sigma values");
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();
171 m_okButton =
new QPushButton(
"&OK");
172 m_okButton->setToolTip(
"Apply changes and close this dialog");
174 m_cancelButton =
new QPushButton(
"&Cancel");
175 m_cancelButton->setToolTip(
"Discard changes and close this dialog");
177 m_applyButton =
new QPushButton(
"&Apply");
178 m_applyButton->setAutoDefault(
true);
179 m_applyButton->setDefault(
true);
180 m_applyButton->setToolTip(
"Apply changes");
183 m_pointGroup =
new QGroupBox(tr(
"Apriori Point"));
184 m_pointGroup->setToolTip(
"Apriori Point Position");
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);
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);
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);
212 m_singlePointInfoGroup =
new QGroupBox(tr(
"Point Information"));
213 m_singlePointInfoGroup->setToolTip(
"Information on Point selected");
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);
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);
237 m_pointInfoStack =
new QStackedWidget;
238 m_pointInfoStack->addWidget(m_singlePointInfoGroup);
239 m_pointInfoStack->addWidget(m_multiplePointsInfoGroup);
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);
252 m_aprioriDialog =
new QDialog(parent);
253 m_aprioriDialog->setWindowTitle(
"Set Apriori Point and Constraints");
254 m_aprioriDialog->setLayout(m_aprioriGridLayout);
278 void QnetSetAprioriDialog::closeEvent() {
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()));
287 disconnect(m_currentSigmaButton, SIGNAL(clicked()),
this, SLOT(fillSigmaLineEdits()));
288 disconnect(m_currentSigmaButton, SIGNAL(clicked()),
this, SLOT(fillSigmaLineEdits()));
290 disconnect(m_okButton, SIGNAL(clicked()),
this, SLOT(setApriori()));
291 disconnect(m_applyButton, SIGNAL(clicked()),
this, SLOT(setApriori()));
293 emit aprioriDialogClosed();
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);
401 if (m_points.size() == 1) {
403 QString
id = m_points.at(0)->text();
404 ControlPoint *pt = m_qnetTool->controlNet()->GetPoint(
id);
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());
413 if (refSPt.GetLatitude().degrees() !=
Null) {
414 m_latLineEdit->setText(
415 QString::number(refSPt.GetLatitude().degrees()));
418 m_latLineEdit->clear();
420 if (refSPt.GetLongitude().degrees() !=
Null) {
421 m_lonLineEdit->setText(
422 QString::number(refSPt.GetLongitude().degrees()));
425 m_lonLineEdit->clear();
428 if (refSPt.GetLocalRadius().meters() !=
Null) {
429 m_radiusLineEdit->setText(
430 QString::number(refSPt.GetLocalRadius().meters(),
'f', 2));
433 m_radiusLineEdit->clear();
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);
445 m_aprioriSource = (Source) REFERENCE;
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);
473 if (m_points.size() == 1) {
478 int goodMeasures = 0;
481 QString
id = m_points.at(0)->text();
482 ControlPoint *pt = m_qnetTool->controlNet()->GetPoint(
id);
488 for (
int i = 0; i < pt->GetNumMeasures(); i++) {
490 if (m->IsIgnored()) {
496 QString msg =
"The Camera must be set prior to calculating apriori";
497 throw IException(IException::Programmer, msg, _FILEINFO_);
499 if (cam->SetImage(m->GetSample(), m->GetLine())) {
506 r2B += pB[0]*pB[0] + pB[1]*pB[1] + pB[2]*pB[2];
515 if (pt->GetPointTypeString() ==
"Fixed")
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_);
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));
544 else if (!(pt->GetPointTypeString() ==
"Fixed") &&
545 !(pt->NumberOfConstrainedCoordinates() == 3) &&
546 !pt->IsCoord1Constrained() &&
547 !pt->IsCoord2Constrained() &&
548 !pt->IsCoord3Constrained()){
552 Displacement((zB / goodMeasures), Displacement::Kilometers));
561 if (sPt.GetLatitude().degrees() !=
Null) {
562 m_latLineEdit->setText(
563 QString::number(sPt.GetLatitude().degrees()));
566 m_latLineEdit->clear();
568 if (sPt.GetLongitude().degrees() !=
Null) {
569 m_lonLineEdit->setText(
570 QString::number(sPt.GetLongitude().degrees()));
573 m_lonLineEdit->clear();
576 if (sPt.GetLocalRadius().meters() !=
Null) {
577 m_radiusLineEdit->setText(
578 QString::number(sPt.GetLocalRadius().meters(),
'f', 2));
581 m_radiusLineEdit->clear();
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);
594 m_aprioriSource = (Source) AVERAGE;
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();
690 m_multiPointsMeasureCount = 0;
691 m_multiPointsConstraintedCount = 0;
692 m_multiPointsFixedCount = 0;
693 m_multiPointsFreeCount = 0;
694 m_multiPointsEditLockedCount = 0;
695 m_multiPointsIgnoredCount = 0;
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++;
706 if (pt->IsIgnored()) {
707 m_multiPointsIgnoredCount++;
709 if (pt->GetPointTypeString() ==
"Constrained") {
710 m_multiPointsConstraintedCount++;
712 if (pt->GetPointTypeString() ==
"Fixed") {
713 m_multiPointsFixedCount++;
715 if (pt->GetPointTypeString() ==
"Free") {
716 m_multiPointsFreeCount++;
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);
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);
733 m_pointGroup->setDisabled(
true);
734 m_currentSigmaButton->setDisabled(
true);
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);
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);
753 m_aprioriDialog->setEnabled(
true);
754 m_sigmaGroup->setEnabled(
true);
755 m_pointGroup->setEnabled(
true);
756 m_currentSigmaButton->setEnabled(
true);
786 void QnetSetAprioriDialog::resetInfoLabels() {
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: ");
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()));
803 if (pt->IsEditLocked()) {
804 m_editLockedBoolLabel->setText(
"EditLocked: True");
807 m_editLockedBoolLabel->setText(
"EditLocked: False");
809 if (pt->IsIgnored()) {
810 m_ignoredBoolLabel->setText(
"Ignored: True");
813 m_ignoredBoolLabel->setText(
"Ignored: False");
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));
859 void QnetSetAprioriDialog::setApriori() {
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);
867 double latSigma =
Null;
869 double lonSigma =
Null;
871 double radiusSigma =
Null;
872 double radius =
Null;
873 bool lineEditModified =
false;
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);
883 if (m_latLineEdit->isModified()) {
884 lineEditModified =
true;
887 if (m_lonLineEdit->text() !=
"") {
888 lon = m_lonLineEdit->text().toDouble();
889 if (m_lonLineEdit->isModified()) {
890 lineEditModified =
true;
893 if (m_radiusLineEdit->text() !=
"") {
894 radius = m_radiusLineEdit->text().toDouble();
895 if (m_radiusLineEdit->isModified()) {
896 lineEditModified =
true;
899 if (m_latSigmaLineEdit->text() !=
"") {
900 latSigma = m_latSigmaLineEdit->text().toDouble();
902 if (m_lonSigmaLineEdit->text() !=
"") {
903 lonSigma = m_lonSigmaLineEdit->text().toDouble();
905 if (m_radiusSigmaLineEdit->text() !=
"") {
906 radiusSigma = m_radiusSigmaLineEdit->text().toDouble();
912 if (lineEditModified) {
913 m_aprioriSource = (Source) USER;
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) {
923 Distance(radius,Distance::Meters)));
924 if (m_aprioriSource == (Source) REFERENCE) {
925 pt->SetAprioriSurfacePointSource(ControlPoint::SurfacePointSource::Reference);
927 else if (m_aprioriSource == (Source) AVERAGE) {
928 pt->SetAprioriSurfacePointSource(ControlPoint::SurfacePointSource::AverageOfMeasures);
931 else if (m_aprioriSource == (Source) USER) {
932 pt->SetAprioriSurfacePointSource(ControlPoint::SurfacePointSource::User);
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.";
944 msg +=
"The sigmas for this point will not be set.";
946 QMessageBox::warning((
QWidget *)parent(),
"Warning", msg);
956 Distance(lonSigma,Distance::Meters),
957 Distance(radiusSigma,Distance::Meters));
960 pt->SetAprioriSurfacePoint(spt);
965 emit pointChanged(
id);
969 QString message =
"Error setting sigmas. \n";
970 message += e.toString();
971 QMessageBox::critical((
QWidget *)parent(),
"Error",message);
972 QApplication::restoreOverrideCursor();
974 emit pointChanged(
id);