1 #include "ControlPointEdit.h"
6 #include <QApplication>
7 #include <QButtonGroup>
11 #include <QDoubleSpinBox>
12 #include <QFileDialog>
13 #include <QGridLayout>
14 #include <QHBoxLayout>
16 #include <QMessageBox>
18 #include <QPushButton>
19 #include <QRadioButton>
24 #include <QToolButton>
55 bool allowLeftMouse,
bool useGeometry) :
QWidget(parent) {
61 p_useGeometry = useGeometry;
70 p_templateFileName =
"$base/templates/autoreg/qnetReg.def";
71 Pvl pvl(p_templateFileName);
77 "Cannot create AutoRegFactory. As a result, "
78 "sub-pixel registration will not work.",
80 QString message = fullError.
toString();
81 QMessageBox::information((
QWidget *)parent,
"Error", message);
85 if (cnet != NULL) emit newControlNetwork(cnet);
90 ControlPointEdit::~ControlPointEdit() {
125 QGridLayout *gridLayout =
new QGridLayout();
126 gridLayout->setSizeConstraint(QLayout::SetFixedSize);
130 QString tempFileName =
FileName(
"$base/icons").expanded();
131 QString toolIconDir = tempFileName;
135 QToolButton *leftZoomIn =
new QToolButton();
136 leftZoomIn->setIcon(QPixmap(toolIconDir +
"/viewmag+.png"));
137 leftZoomIn->setIconSize(isize);
138 leftZoomIn->setToolTip(
"Zoom In 2x");
139 leftZoomIn->setWhatsThis(
"Zoom In 2x on left measure.");
141 QToolButton *leftZoomOut =
new QToolButton();
142 leftZoomOut->setIcon(QPixmap(toolIconDir +
"/viewmag-.png"));
143 leftZoomOut->setIconSize(isize);
144 leftZoomOut->setToolTip(
"Zoom Out 2x");
145 leftZoomOut->setWhatsThis(
"Zoom Out 2x on left measure.");
147 QToolButton *leftZoom1 =
new QToolButton();
148 leftZoom1->setIcon(QPixmap(toolIconDir +
"/viewmag1.png"));
149 leftZoom1->setIconSize(isize);
150 leftZoom1->setToolTip(
"Zoom 1:1");
151 leftZoom1->setWhatsThis(
"Show left measure at full resolution.");
153 QHBoxLayout *leftZoomPan =
new QHBoxLayout;
154 leftZoomPan->addWidget(leftZoomIn);
155 leftZoomPan->addWidget(leftZoomOut);
156 leftZoomPan->addWidget(leftZoom1);
159 QToolButton *leftPanUp = 0;
160 QToolButton *leftPanDown = 0;
161 QToolButton *leftPanLeft = 0;
162 QToolButton *leftPanRight = 0;
163 if ( p_allowLeftMouse ) {
165 leftPanUp =
new QToolButton(parent);
166 leftPanUp->setIcon(QIcon(
FileName(
"$base/icons/up.png").
168 leftPanUp->setIconSize(isize);
169 leftPanUp->setToolTip(
"Move up 1 screen pixel");
170 leftPanUp->setStatusTip(
"Move up 1 screen pixel");
171 leftPanUp->setWhatsThis(
"Move the left measure up 1 screen pixel.");
173 leftPanDown =
new QToolButton(parent);
174 leftPanDown->setIcon(QIcon(
FileName(
"$base/icons/down.png").
176 leftPanDown->setIconSize(isize);
177 leftPanDown->setToolTip(
"Move down 1 screen pixel");
178 leftPanDown->setStatusTip(
"Move down 1 screen pixel");
179 leftPanDown->setWhatsThis(
"Move the left measure down 1 screen pixel.");
181 leftPanLeft =
new QToolButton(parent);
182 leftPanLeft->setIcon(QIcon(
FileName(
"$base/icons/back.png").
184 leftPanLeft->setIconSize(isize);
185 leftPanLeft->setToolTip(
"Move left 1 screen pixel");
186 leftPanLeft->setWhatsThis(
"Move the left measure to the left by 1 screen"
189 leftPanRight =
new QToolButton(parent);
190 leftPanRight->setIcon(QIcon(
FileName(
"$base/icons/forward.png").
192 leftPanRight->setIconSize(isize);
193 leftPanRight->setToolTip(
"Move right 1 screen pixel");
194 leftPanRight->setWhatsThis(
"Move the left measure to the right by 1"
197 leftZoomPan->addWidget(leftPanUp);
198 leftZoomPan->addWidget(leftPanDown);
199 leftZoomPan->addWidget(leftPanLeft);
200 leftZoomPan->addWidget(leftPanRight);
203 leftZoomPan->addStretch();
204 gridLayout->addLayout(leftZoomPan, row, 0);
206 p_rightZoomIn =
new QToolButton();
207 p_rightZoomIn->setIcon(QPixmap(toolIconDir +
"/viewmag+.png"));
208 p_rightZoomIn->setIconSize(isize);
209 p_rightZoomIn->setToolTip(
"Zoom In 2x");
210 p_rightZoomIn->setWhatsThis(
"Zoom In 2x on right measure.");
212 p_rightZoomOut =
new QToolButton();
213 p_rightZoomOut->setIcon(QIcon(
FileName(
"$base/icons/viewmag-.png").
215 p_rightZoomOut->setIconSize(isize);
216 p_rightZoomOut->setToolTip(
"Zoom Out 2x");
217 p_rightZoomOut->setWhatsThis(
"Zoom Out 2x on right measure.");
219 p_rightZoom1 =
new QToolButton();
220 p_rightZoom1->setIcon(QPixmap(toolIconDir +
"/viewmag1.png"));
221 p_rightZoom1->setIconSize(isize);
222 p_rightZoom1->setToolTip(
"Zoom 1:1");
223 p_rightZoom1->setWhatsThis(
"Show right measure at full resolution.");
225 QHBoxLayout *rightZoomPan =
new QHBoxLayout;
226 rightZoomPan->addWidget(p_rightZoomIn);
227 rightZoomPan->addWidget(p_rightZoomOut);
228 rightZoomPan->addWidget(p_rightZoom1);
231 QToolButton *rightPanUp =
new QToolButton(parent);
232 rightPanUp->setIcon(QIcon(
FileName(
"$base/icons/up.png").
234 rightPanUp->setIconSize(isize);
235 rightPanUp->setToolTip(
"Move up 1 screen pixel");
236 rightPanUp->setWhatsThis(
"Move the right measure up 1 screen pixel.");
238 QToolButton *rightPanDown =
new QToolButton(parent);
239 rightPanDown->setIcon(QIcon(
FileName(
"$base/icons/down.png").
241 rightPanDown->setIconSize(isize);
242 rightPanDown->setToolTip(
"Move down 1 screen pixel");
243 rightPanUp->setWhatsThis(
"Move the right measure down 1 screen pixel.");
245 QToolButton *rightPanLeft =
new QToolButton(parent);
246 rightPanLeft->setIcon(QIcon(
FileName(
"$base/icons/back.png").
248 rightPanLeft->setIconSize(isize);
249 rightPanLeft->setToolTip(
"Move left 1 screen pixel");
250 rightPanLeft->setWhatsThis(
"Move the right measure to the left by 1 screen"
253 QToolButton *rightPanRight =
new QToolButton(parent);
254 rightPanRight->setIcon(QIcon(
FileName(
"$base/icons/forward.png").
256 rightPanRight->setIconSize(isize);
257 rightPanRight->setToolTip(
"Move right 1 screen pixel");
258 rightPanRight->setWhatsThis(
"Move the right measure to the right by 1"
261 rightZoomPan->addWidget(rightPanUp);
262 rightZoomPan->addWidget(rightPanDown);
263 rightZoomPan->addWidget(rightPanLeft);
264 rightZoomPan->addWidget(rightPanRight);
265 rightZoomPan->addStretch();
267 gridLayout->addLayout(rightZoomPan, row++, 1);
270 p_leftZoomFactor =
new QLabel();
271 QCheckBox *leftLockStretch =
new QCheckBox(
"lock stretch");
274 QString whatsThisTextForStretchLocking =
"If checked then a new stretch "
275 "will NOT be calculated for each pan or zoom change. Note that stretch"
276 " changes made using the stretch tool will ALWAYS take effect, "
277 "regardless of the state of this checkbox.";
278 leftLockStretch->setWhatsThis(whatsThisTextForStretchLocking);
279 QHBoxLayout *leftzflsLayout =
new QHBoxLayout;
280 leftzflsLayout->addWidget(p_leftZoomFactor);
281 leftzflsLayout->addWidget(leftLockStretch);
282 gridLayout->addLayout(leftzflsLayout, row, 0);
284 p_rightZoomFactor =
new QLabel();
285 QCheckBox *rightLockStretch =
new QCheckBox(
"lock stretch");
286 rightLockStretch->setWhatsThis(whatsThisTextForStretchLocking);
287 QHBoxLayout *rightzflsLayout =
new QHBoxLayout;
288 rightzflsLayout->addWidget(p_rightZoomFactor);
289 rightzflsLayout->addWidget(rightLockStretch);
290 gridLayout->addLayout(rightzflsLayout, row++, 1);
295 if ( !p_allowLeftMouse ) p_leftView->setDisabled(
true);
297 gridLayout->addWidget(p_leftView, row, 0);
299 connect(
this, SIGNAL(newControlNetwork(
ControlNet *)),
300 p_leftView, SLOT(setControlNet(
ControlNet *)));
307 connect(leftLockStretch, SIGNAL(stateChanged(
int)),
309 SLOT(changeStretchLock(
int)));
310 leftLockStretch->setChecked(
false);
314 connect(leftZoomIn, SIGNAL(clicked()), p_leftView, SLOT(zoomIn()));
315 connect(leftZoomOut, SIGNAL(clicked()), p_leftView, SLOT(zoomOut()));
316 connect(leftZoom1, SIGNAL(clicked()), p_leftView, SLOT(zoom1()));
320 connect(leftZoomOut, SIGNAL(clicked()),
this, SLOT(
updateRightGeom()));
325 connect(p_leftView, SIGNAL(tackPointChanged(
double)),
330 connect(
this, SIGNAL(updateLeftView(
double,
double)),
331 p_leftView, SLOT(refreshView(
double,
double)));
333 connect (p_leftView, SIGNAL(userMovedTackPoint()),
336 if ( p_allowLeftMouse ) {
338 connect(leftPanUp, SIGNAL(clicked()), p_leftView, SLOT(panUp()));
339 connect(leftPanDown, SIGNAL(clicked()), p_leftView, SLOT(panDown()));
340 connect(leftPanLeft, SIGNAL(clicked()), p_leftView, SLOT(panLeft()));
341 connect(leftPanRight, SIGNAL(clicked()), p_leftView, SLOT(panRight()));
350 gridLayout->addWidget(p_rightView, row, 1);
352 connect(
this, SIGNAL(newControlNetwork(
ControlNet *)),
353 p_rightView, SLOT(setControlNet(
ControlNet *)));
358 connect(rightLockStretch, SIGNAL(stateChanged(
int)),
360 SLOT(changeStretchLock(
int)));
361 rightLockStretch->setChecked(
false);
365 connect(p_rightView, SIGNAL(tackPointChanged(
double)),
367 connect(
this, SIGNAL(updateRightView(
double,
double)),
368 p_rightView, SLOT(refreshView(
double,
double)));
370 connect (p_rightView, SIGNAL(userMovedTackPoint()),
373 connect(p_rightZoomIn, SIGNAL(clicked()), p_rightView, SLOT(zoomIn()));
374 connect(p_rightZoomOut, SIGNAL(clicked()), p_rightView, SLOT(zoomOut()));
375 connect(p_rightZoom1, SIGNAL(clicked()), p_rightView, SLOT(zoom1()));
378 connect(rightPanUp, SIGNAL(clicked()), p_rightView, SLOT(panUp()));
379 connect(rightPanDown, SIGNAL(clicked()), p_rightView, SLOT(panDown()));
380 connect(rightPanLeft, SIGNAL(clicked()), p_rightView, SLOT(panLeft()));
381 connect(rightPanRight, SIGNAL(clicked()), p_rightView, SLOT(panRight()));
392 QButtonGroup *bgroup =
new QButtonGroup();
393 p_nogeom =
new QRadioButton();
394 p_nogeom->setChecked(
true);
395 connect(p_nogeom, SIGNAL(clicked()),
this, SLOT(
setNoGeom()));
397 QCheckBox *linkZoom = NULL;
399 p_nogeom->setText(
"No geom/rotate");
400 p_nogeom->setToolTip(
"Reset right measure to it's native geometry.");
401 p_nogeom->setWhatsThis(
"Reset right measure to it's native geometry. "
402 "If measure was rotated, set rotation back to 0. "
403 "If measure was geomed to match the left measure, "
404 "reset the geometry back to it's native state.");
405 p_geom =
new QRadioButton(
"Geom");
406 p_geom->setToolTip(
"Geom right measure to match geometry of left measure.");
407 p_geom->setWhatsThis(
"Using an affine transform, geom the right measure to match the "
408 "geometry of the left measure.");
409 bgroup->addButton(p_geom);
410 connect(p_geom, SIGNAL(clicked()),
this, SLOT(
setGeom()));
413 linkZoom =
new QCheckBox(
"Link Zoom");
414 linkZoom->setToolTip(
"Link zooming between the left and right views.");
415 linkZoom->setWhatsThis(
"When zooming in the left view, the right view will "
416 "be set to the same zoom factor as the left view.");
417 connect(linkZoom, SIGNAL(toggled(
bool)),
this, SLOT(
setZoomLink(
bool)));
419 p_nogeom->setText(
"No rotate");
420 p_nogeom->setToolTip(
"Reset right measure to it's native geometry.");
421 p_nogeom->setWhatsThis(
"Reset right measure to it's native geometry. "
422 "If measure was rotated, set rotation back to 0.");
424 bgroup->addButton(p_nogeom);
426 QRadioButton *rotate =
new QRadioButton(
"Rotate");
427 bgroup->addButton(rotate);
429 connect(rotate, SIGNAL(clicked()),
this, SLOT(
setRotate()));
436 p_dial =
new QDial();
437 p_dial->setRange(0, 360);
438 p_dial->setWrapping(
false);
439 p_dial->setNotchesVisible(
true);
440 p_dial->setNotchTarget(5.);
441 p_dial->setEnabled(
false);
442 p_dial->setToolTip(
"Rotate right measure");
443 p_dial->setWhatsThis(
"Rotate the right measure by degrees.");
445 p_dialNumber =
new QLCDNumber();
446 p_dialNumber->setEnabled(
false);
447 p_dialNumber->setToolTip(
"Rotate right measure");
448 p_dialNumber->setWhatsThis(
"Rotate the right measure by given number"
450 connect(p_dial, SIGNAL(valueChanged(
int)), p_dialNumber, SLOT(display(
int)));
451 connect(p_dial, SIGNAL(valueChanged(
int)), p_rightView, SLOT(rotateChip(
int)));
453 QCheckBox *showPoints =
new QCheckBox(
"Show control points");
454 showPoints->setToolTip(
"Draw control point crosshairs");
455 showPoints->setWhatsThis(
"This will toggle whether crosshairs are drawn"
456 " for the control points located within the measure''s"
457 " view. For areas of dense measurements, turning this"
458 " off will allow easier viewing of features.");
459 connect(showPoints, SIGNAL(toggled(
bool)), p_leftView, SLOT(setPoints(
bool)));
460 connect(showPoints, SIGNAL(toggled(
bool)), p_rightView, SLOT(setPoints(
bool)));
461 showPoints->setChecked(
true);
463 QCheckBox *cross =
new QCheckBox(
"Show crosshair");
464 connect(cross, SIGNAL(toggled(
bool)), p_leftView, SLOT(setCross(
bool)));
465 connect(cross, SIGNAL(toggled(
bool)), p_rightView, SLOT(setCross(
bool)));
466 cross->setChecked(
true);
467 cross->setToolTip(
"Show the red crosshair across measure view");
468 cross->setWhatsThis(
"This will toggle whether the crosshair across the"
469 " measure view will be shown");
471 QCheckBox *circle =
new QCheckBox(
"Circle");
472 circle->setChecked(
false);
473 circle->setToolTip(
"Draw circle");
474 circle->setWhatsThis(
"Draw circle on measure view. This can aid in"
475 " centering a crater under the crosshair.");
476 connect(circle, SIGNAL(toggled(
bool)),
this, SLOT(
setCircle(
bool)));
478 p_slider =
new QScrollBar(Qt::Horizontal);
479 p_slider->setRange(1, 100);
480 p_slider->setSingleStep(1);
481 connect(p_slider, SIGNAL(valueChanged(
int)), p_leftView, SLOT(setCircleSize(
int)));
482 connect(p_slider, SIGNAL(valueChanged(
int)), p_rightView, SLOT(setCircleSize(
int)));
483 p_slider->setValue(20);
484 p_slider->setDisabled(
true);
486 p_slider->setToolTip(
"Adjust circle size");
487 p_slider->setWhatsThis(
"This allows the cirle size to be adjusted.");
489 QVBoxLayout *vlayout =
new QVBoxLayout();
490 if (!p_useGeometry) {
491 vlayout->addWidget(linkZoom);
493 vlayout->addWidget(p_nogeom);
495 vlayout->addWidget(p_geom);
497 vlayout->addWidget(rotate);
498 vlayout->addWidget(p_dial);
499 vlayout->addWidget(p_dialNumber);
500 vlayout->addWidget(showPoints);
501 vlayout->addWidget(cross);
502 vlayout->addWidget(circle);
503 vlayout->addWidget(p_slider);
504 gridLayout->addLayout(vlayout, row++, 2);
507 p_leftSampLinePosition =
new QLabel();
508 p_leftSampLinePosition->setToolTip(
"Sample/Line under the crosshair");
509 gridLayout->addWidget(p_leftSampLinePosition, row, 0);
510 p_rightSampLinePosition =
new QLabel();
511 p_rightSampLinePosition->setToolTip(
"Sample/Line under the crosshair");
512 gridLayout->addWidget(p_rightSampLinePosition, row++, 1);
516 p_leftLatLonPosition =
new QLabel();
517 p_leftLatLonPosition->setToolTip(
"Latitude/Longitude under the crosshair");
518 gridLayout->addWidget(p_leftLatLonPosition, row, 0);
519 p_rightLatLonPosition =
new QLabel();
520 p_rightLatLonPosition->setToolTip(
"Latitude/Longitude under the crosshair");
521 gridLayout->addWidget(p_rightLatLonPosition, row++, 1);
526 p_autoRegExtension =
new QWidget;
527 p_oldPosition =
new QLabel;
528 p_oldPosition->setToolTip(
"Measure Sample/Line before sub-pixel "
530 p_oldPosition->setWhatsThis(
"Original Sample/Line of the right measure "
531 "before the sub-pixel registration. If you select the \"Undo\" "
532 "button, the measure will revert back to this Sample/Line.");
533 p_goodFit =
new QLabel;
534 p_goodFit->setToolTip(
"Goodness of Fit result from sub-pixel registration.");
535 p_goodFit->setWhatsThis(
"Resulting Goodness of Fit from sub-pixel "
537 QVBoxLayout *autoRegLayout =
new QVBoxLayout;
538 autoRegLayout->setMargin(0);
539 autoRegLayout->addWidget(p_oldPosition);
540 autoRegLayout->addWidget(p_goodFit);
541 p_autoRegExtension->setLayout(autoRegLayout);
542 p_autoRegShown =
false;
543 p_autoRegAttempted =
false;
544 gridLayout->addWidget(p_autoRegExtension, row++, 1);
547 QHBoxLayout *leftLayout =
new QHBoxLayout();
548 QToolButton *stop =
new QToolButton();
549 stop->setIcon(QPixmap(toolIconDir +
"/blinkStop.png"));
550 stop->setIconSize(QSize(22, 22));
551 stop->setToolTip(
"Blink Stop");
552 QString text =
"<b>Function:</b> Stop automatic timed blinking";
553 stop->setWhatsThis(text);
554 connect(stop, SIGNAL(released()),
this, SLOT(
blinkStop()));
556 QToolButton *start =
new QToolButton();
557 start->setIcon(QPixmap(toolIconDir +
"/blinkStart.png"));
558 start->setIconSize(QSize(22, 22));
559 start->setToolTip(
"Blink Start");
560 text =
"<b>Function:</b> Start automatic timed blinking. Cycles \
561 through linked viewports at variable rate";
562 start->setWhatsThis(text);
563 connect(start, SIGNAL(released()),
this, SLOT(
blinkStart()));
565 p_blinkTimeBox =
new QDoubleSpinBox();
566 p_blinkTimeBox->setMinimum(0.1);
567 p_blinkTimeBox->setMaximum(5.0);
568 p_blinkTimeBox->setDecimals(1);
569 p_blinkTimeBox->setSingleStep(0.1);
570 p_blinkTimeBox->setValue(0.5);
571 p_blinkTimeBox->setToolTip(
"Blink Time Delay");
572 text =
"<b>Function:</b> Change automatic blink rate between " +
573 QString::number(p_blinkTimeBox->minimum()) +
" and " +
574 QString::number(p_blinkTimeBox->maximum()) +
" seconds";
575 p_blinkTimeBox->setWhatsThis(text);
576 connect(p_blinkTimeBox, SIGNAL(valueChanged(
double)),
579 leftLayout->addWidget(stop);
580 leftLayout->addWidget(start);
581 leftLayout->addWidget(p_blinkTimeBox);
584 QPushButton *find =
new QPushButton(
"Find");
585 find->setShortcut(Qt::Key_F);
586 find->setToolTip(
"Move right measure to same Latitude/Longitude as left. "
587 "<strong>Shortcut: F</strong>");
588 find->setWhatsThis(
"Find the Latitude/Longitude under the crosshair in the "
589 "left measure and move the right measure to the same "
590 "latitude/longitude.");
591 leftLayout->addWidget(find);
592 connect(find, SIGNAL(clicked()),
this, SLOT(
findPoint()));
595 leftLayout->addStretch();
596 gridLayout->addLayout(leftLayout, row, 0);
598 QHBoxLayout *rightLayout =
new QHBoxLayout();
599 p_autoReg =
new QPushButton(
"Register");
600 p_autoReg->setShortcut(Qt::Key_R);
601 p_autoReg->setToolTip(
"Sub-pixel register the right measure to the left. "
602 "<strong>Shortcut: R</strong>");
603 p_autoReg->setWhatsThis(
"Sub-pixel register the right measure to the left "
604 "and move the result under the crosshair. After "
605 "viewing the results, the option exists to move the "
606 "measure back to the original position by selecting "
607 "<strong>\"Undo Registration\"</strong>.");
608 if (p_allowLeftMouse) {
609 p_saveMeasure =
new QPushButton(
"Save Measures");
610 p_saveMeasure->setToolTip(
"Save the both the left and right measure to the edit control "
611 "point (control point currently being edited). "
612 "<strong>Shortcut: M</strong>. "
613 " <strong>Note: The edit control point "
614 "will not be saved to the network until you select "
615 "<strong>\"Save Point\"</strong>");
618 p_saveMeasure =
new QPushButton(
"Save Measure");
619 p_saveMeasure->setToolTip(
"Save the right measure to the edit control "
620 "point (control point currently being edited). "
621 "<strong>Shortcut: M</strong>. "
622 " <strong>Note: The edit control point "
623 "will not be saved to the network until you select "
624 "<strong>\"Save Point\"</strong>");
626 p_saveMeasure->setShortcut(Qt::Key_M);
627 p_saveDefaultPalette = p_saveMeasure->palette();
629 rightLayout->addWidget(p_autoReg);
630 rightLayout->addWidget(p_saveMeasure);
631 rightLayout->addStretch();
632 gridLayout->addLayout(rightLayout, row, 1);
634 connect(p_autoReg, SIGNAL(clicked()),
this, SLOT(
registerPoint()));
635 connect(p_saveMeasure, SIGNAL(clicked()),
this, SLOT(
saveMeasure()));
637 setLayout(gridLayout);
640 p_autoRegExtension->hide();
671 Cube *leftCube, QString pointId) {
674 if ( p_autoRegShown ) {
676 p_autoRegShown =
false;
677 p_autoRegExtension->hide();
678 p_autoReg->setText(
"Register");
679 p_autoReg->setToolTip(
"Sub-pixel register the right measure to the left."
680 "<strong>Shortcut: R</strong>");
681 p_autoReg->setShortcut(Qt::Key_R);
684 p_leftMeasure = leftMeasure;
688 if ( p_leftGroundMap != 0 )
delete p_leftGroundMap;
691 p_leftCube = leftCube;
693 p_leftChip->
TackCube(p_leftMeasure->GetSample(), p_leftMeasure->GetLine());
694 p_leftChip->
Load(*p_leftCube);
697 p_leftView->
setChip(p_leftChip, p_leftCube);
732 Cube *rightCube, QString pointId) {
735 if ( p_autoRegShown ) {
737 p_autoRegShown =
false;
738 p_autoRegExtension->hide();
739 p_autoReg->setText(
"Register");
740 p_autoReg->setShortcut(Qt::Key_R);
742 p_autoRegAttempted =
false;
744 p_rightMeasure = rightMeasure;
749 if ( p_rightGroundMap != 0 )
delete p_rightGroundMap;
752 p_rightCube = rightCube;
754 p_rightChip->
TackCube(p_rightMeasure->GetSample(),
755 p_rightMeasure->GetLine());
756 if ( p_geomIt ==
false ) {
757 p_rightChip->
Load(*p_rightCube);
761 p_rightChip->
Load(*p_rightCube, *p_leftChip, *p_leftCube);
766 QString message = fullError.
toString();
767 QMessageBox::information((
QWidget *)parent(),
"Error", message);
768 p_rightChip->
Load(*p_rightCube);
770 p_nogeom->setChecked(
true);
771 p_geom->setChecked(
false);
776 p_rightView->
setChip(p_rightChip, p_rightCube);
782 p_saveMeasure->setPalette(p_saveDefaultPalette);
800 QString pos =
"Sample: " + QString::number(p_leftView->
tackSample()) +
801 " Line: " + QString::number(p_leftView->
tackLine());
802 p_leftSampLinePosition->setText(pos);
810 pos =
"Latitude: " + QString::number(lat) +
811 " Longitude: " + QString::number(lon);
812 p_leftLatLonPosition->setText(pos);
816 pos =
"Zoom Factor: " + QString::number(zoomFactor);
817 p_leftZoomFactor->setText(pos);
837 if ( p_autoRegShown ) {
839 p_autoRegShown =
false;
840 p_autoRegExtension->hide();
841 p_autoReg->setText(
"Register");
842 p_autoReg->setToolTip(
"Sub-pixel register the right measure to the left. "
843 "<strong>Shortcut: R</strong>");
844 p_autoReg->setShortcut(Qt::Key_R);
847 QString pos =
"Sample: " + QString::number(p_rightView->
tackSample()) +
848 " Line: " + QString::number(p_rightView->
tackLine());
849 p_rightSampLinePosition->setText(pos);
857 pos =
"Latitude: " + QString::number(lat) +
858 " Longitude: " + QString::number(lon);
859 p_rightLatLonPosition->setText(pos);
863 pos =
"Zoom Factor: " + QString::number(zoomFactor);
864 p_rightZoomFactor->setText(pos);
877 QPalette p = p_saveMeasure->palette();
878 p.setColor(QPalette::ButtonText,qc);
879 p_saveMeasure->setPalette(p);
902 emit updateRightView(p_rightGroundMap->
Sample(), p_rightGroundMap->
Line());
905 if (p_rightGroundMap->
Sample() != p_rightMeasure->GetSample() ||
906 p_rightGroundMap->
Line() != p_rightMeasure->GetLine())
910 QString message =
"Latitude: " + QString::number(lat) +
" Longitude: " +
911 QString::number(lon) +
" is not on the right image. Right measure " +
913 QMessageBox::warning((
QWidget *)parent(),
"Warning",message);
950 if ( p_autoRegShown ) {
952 p_autoRegShown =
false;
953 p_autoRegExtension->hide();
954 p_autoReg->setText(
"Register");
955 p_autoReg->setToolTip(
"Sub-pixel register the right measure to the left. "
956 "<strong>Shortcut: R</strong>");
957 p_autoReg->setShortcut(Qt::Key_R);
960 emit updateRightView(p_rightMeasure->GetSample(),
961 p_rightMeasure->GetLine());
963 p_saveMeasure->setPalette(p_saveDefaultPalette);
967 p_autoRegAttempted =
true;
971 p_leftMeasure->GetSample(), p_leftMeasure->GetLine());
974 p_rightMeasure->GetSample(),
975 p_rightMeasure->GetLine());
985 QString msg =
"Cannot register this point, unable to Load chips.\n";
987 QMessageBox::information((
QWidget *)parent(),
"Error", msg);
993 if ( !p_autoRegFact->
Success() ) {
994 QString msg =
"Cannot sub-pixel register this point.\n";
996 msg +=
"\n\nNot enough valid data in Pattern Chip.\n";
997 msg +=
" PatternValidPercent = ";
1001 msg +=
"\n\nNo valid data in Fit Chip.";
1004 msg +=
"\n\nGoodness of Fit Tolerance not met.\n";
1005 msg +=
"\nGoodnessOfFit = " + QString::number(p_autoRegFact->
GoodnessOfFit());
1006 msg +=
"\nGoodnessOfFitTolerance = ";
1007 msg += QString::number(p_autoRegFact->
Tolerance());
1010 msg +=
"\n\nNot enough valid points in the fit chip window for sub-pixel ";
1011 msg +=
"accuracy. Probably too close to edge.\n";
1014 msg +=
"\n\nCould not model surface for sub-pixel accuracy.\n";
1017 double sampDist, lineDist;
1018 p_autoRegFact->
Distance(sampDist, lineDist);
1019 msg +=
"\n\nSub pixel algorithm moves registration more than tolerance.\n";
1020 msg +=
"\nSampleMovement = " + QString::number(sampDist) +
1021 " LineMovement = " + QString::number(lineDist);
1022 msg +=
"\nDistanceTolerance = " +
1026 double score1, score2;
1027 p_autoRegFact->
ZScores(score1, score2);
1028 msg +=
"\n\nPattern data max or min does not pass z-score test.\n";
1029 msg +=
"\nMinimumZScore = " + QString::number(p_autoRegFact->
MinimumZScore());
1030 msg +=
"\nCalculatedZscores = " + QString::number(score1) +
", " + QString::number(score2);
1033 msg +=
"\n\nError occured in Adaptive algorithm.";
1036 msg +=
"\n\nUnknown registration error.";
1039 QMessageBox::information((
QWidget *)parent(),
"Error", msg);
1044 QString msg =
"Cannot register this point.\n";
1046 QMessageBox::information((
QWidget *)parent(),
"Error", msg);
1055 if (p_autoRegFact->
CubeSample() != p_rightMeasure->GetSample() ||
1056 p_autoRegFact->
CubeLine() != p_rightMeasure->GetLine()) {
1060 QString oldPos =
"Original Sample: " +
1061 QString::number(p_rightMeasure->GetSample()) +
" Original Line: " +
1062 QString::number(p_rightMeasure->GetLine());
1063 p_oldPosition->setText(oldPos);
1065 QString goodFit =
"Goodness of Fit: " +
1067 p_goodFit->setText(goodFit);
1069 p_autoRegExtension->show();
1070 p_autoRegShown =
true;
1071 p_autoReg->setText(
"Undo Registration");
1072 p_autoReg->setToolTip(
"Undo sub-pixel registration. "
1073 "<strong>Shortcut: U</strong>");
1074 p_autoReg->setShortcut(Qt::Key_U);
1114 if (p_rightMeasure != NULL) {
1117 QString message =
"The right measure is locked. You must first unlock the measure by ";
1118 message +=
"clicking the check box above labeled \"Edit Lock Measure\".";
1119 QMessageBox::warning((
QWidget *)parent(),
"Warning",message);
1123 if (p_autoRegShown) {
1130 double minZScore, maxZScore;
1131 p_autoRegFact->
ZScores(minZScore,maxZScore);
1143 QMessageBox::critical((
QWidget *)parent(),
"Error", message);
1149 p_rightMeasure->SetAprioriSample(p_rightMeasure->GetSample());
1150 p_rightMeasure->SetAprioriLine(p_rightMeasure->GetLine());
1155 p_autoRegShown =
false;
1156 p_autoRegExtension->hide();
1157 p_autoReg->setText(
"Register");
1158 p_autoReg->setToolTip(
"Sub-pixel register the right measure to the left. "
1159 "<strong>Shortcut: R</strong>");
1160 p_autoReg->setShortcut(Qt::Key_R);
1180 if (p_allowLeftMouse) {
1181 if (p_leftMeasure != NULL) {
1183 QString message =
"The left measure is locked. You must first unlock the measure by ";
1184 message +=
"clicking the check box above labeled \"Edit Lock Measure\".";
1185 QMessageBox::warning((
QWidget *)parent(),
"Warning",message);
1201 *p_leftMeasure = *p_rightMeasure;
1206 p_saveMeasure->setPalette(p_saveDefaultPalette);
1209 emit measureSaved();
1224 p_rightView->
geomChip(p_leftChip, p_leftCube);
1229 QString message = fullError.
toString();
1230 QMessageBox::information((
QWidget *)parent(),
"Error", message);
1232 p_nogeom->setChecked(
true);
1233 p_geom->setChecked(
false);
1274 QApplication::setOverrideCursor(Qt::WaitCursor);
1278 QString text =
"Zoom in 2X";
1279 p_rightZoomIn->setEnabled(
true);
1280 p_rightZoomIn->setWhatsThis(text);
1281 p_rightZoomIn->setToolTip(
"Zoom In");
1282 text =
"Zoom out 2X";
1283 p_rightZoomOut->setEnabled(
true);
1284 p_rightZoomOut->setWhatsThis(text);
1285 p_rightZoomOut->setToolTip(
"Zoom Out");
1287 p_rightZoom1->setEnabled(
true);
1288 p_rightZoom1->setWhatsThis(text);
1289 p_rightZoom1->setToolTip(
"Zoom 1:1");
1294 QApplication::restoreOverrideCursor();
1296 p_dial->setEnabled(
true);
1297 p_dialNumber->setEnabled(
true);
1298 p_dial->setNotchesVisible(
true);
1314 if (p_geomIt ==
true)
return;
1316 QApplication::setOverrideCursor(Qt::WaitCursor);
1319 QString text =
"Zoom functions disabled when Geom is set";
1320 p_rightZoomIn->setEnabled(
false);
1321 p_rightZoomIn->setWhatsThis(text);
1322 p_rightZoomIn->setToolTip(text);
1323 p_rightZoomOut->setEnabled(
false);
1324 p_rightZoomOut->setWhatsThis(text);
1325 p_rightZoomOut->setToolTip(text);
1326 p_rightZoom1->setEnabled(
false);
1327 p_rightZoom1->setWhatsThis(text);
1328 p_rightZoom1->setToolTip(text);
1332 p_dial->setValue(0);
1333 p_dial->setEnabled(
false);
1334 p_dialNumber->setEnabled(
false);
1339 p_rightView->
geomChip(p_leftChip, p_leftCube);
1344 QString message = fullError.
toString();
1345 QMessageBox::information((
QWidget *)parent(),
"Error", message);
1347 p_nogeom->setChecked(
true);
1348 p_geom->setChecked(
false);
1351 QApplication::restoreOverrideCursor();
1362 QApplication::setOverrideCursor(Qt::WaitCursor);
1364 QString text =
"Zoom in 2X";
1365 p_rightZoomIn->setEnabled(
true);
1366 p_rightZoomIn->setWhatsThis(text);
1367 p_rightZoomIn->setToolTip(
"Zoom In");
1368 text =
"Zoom out 2X";
1369 p_rightZoomOut->setEnabled(
true);
1370 p_rightZoomOut->setWhatsThis(text);
1371 p_rightZoomOut->setToolTip(
"Zoom Out");
1373 p_rightZoom1->setEnabled(
true);
1374 p_rightZoom1->setWhatsThis(text);
1375 p_rightZoom1->setToolTip(
"Zoom 1:1");
1378 p_dial->setValue(0);
1379 p_dial->setEnabled(
false);
1380 p_dialNumber->setEnabled(
false);
1385 QApplication::restoreOverrideCursor();
1400 if ( checked == p_circle )
return;
1405 p_slider->setDisabled(
false);
1407 p_slider->setValue(20);
1412 p_slider->setDisabled(
true);
1432 if ( checked == p_linkZoom )
return;
1434 p_linkZoom = checked;
1444 if ( p_timerOn )
return;
1447 p_blinkList.push_back(p_leftView);
1448 p_blinkList.push_back(p_rightView);
1452 int msec = (int)(p_blinkTimeBox->value() * 1000.0);
1453 p_timer =
new QTimer(
this);
1454 connect(p_timer, SIGNAL(timeout()),
this, SLOT(
updateBlink()));
1455 p_timer->start(msec);
1463 p_blinkList.clear();
1466 p_leftView->repaint();
1479 if ( p_timerOn ) p_timer->setInterval((
int)(interval * 1000.));
1486 p_blinkIndex = !p_blinkIndex;
1487 p_leftView->
loadView(*(p_blinkList)[p_blinkIndex]);
1515 QString temp = p_templateFileName;
1518 p_templateFileName = fn;
1525 if ( p_autoRegFact != NULL )
1526 delete p_autoRegFact;
1527 p_autoRegFact = reg;
1529 p_templateFileName = fn;
1540 p_templateFileName = temp;
1542 "Cannot create AutoRegFactory for " +
1544 ". As a result, current template file will remain set to " +
1546 QString message = fullError.
toString();
1547 QMessageBox::information((
QWidget *)parent(),
"Error", message);
1560 p_allowLeftMouse = allowMouse;
1562 if (p_allowLeftMouse) {
1563 p_saveMeasure =
new QPushButton(
"Save Measures");
1564 p_saveMeasure->setToolTip(
"Save the both the left and right measure to the edit control "
1565 "point (control point currently being edited). "
1566 " <strong>Note: The edit control point "
1567 "will not be saved to the network until you select "
1568 "<strong>\"Save Point\"</strong>");
1571 p_saveMeasure =
new QPushButton(
"Save Measure");
1572 p_saveMeasure->setToolTip(
"Save the right measure to the edit control "
1573 "point (control point currently being edited). "
1574 " <strong>Note: The edit control point "
1575 "will not be saved to the network until you select "
1576 "<strong>\"Save Point\"</strong>");
1582 void ControlPointEdit::refreshChips() {
1583 p_leftView->update();
1584 p_rightView->update();
1600 if ( !p_autoRegAttempted ) {
1601 QString message =
"Point must be Registered before chips can be saved.";
1602 QMessageBox::warning((
QWidget *)parent(),
"Warning", message);
1607 QString baseFile = p_pointId.replace(
" ",
"_") +
"_" +
1608 toString((
int)(p_leftMeasure ->GetSample())) +
"_" +
1609 toString((
int)(p_leftMeasure ->GetLine())) +
"_" +
1610 toString((
int)(p_rightMeasure->GetSample())) +
"_" +
1611 toString((
int)(p_rightMeasure->GetLine())) +
"_";
1612 QString fname = baseFile +
"Search.cub";
1613 QString command =
"$ISISROOT/bin/qview \'" + fname +
"\'";
1615 fname = baseFile +
"Pattern.cub";
1616 command +=
" \'" + fname +
"\'";
1618 fname = baseFile +
"Fit.cub";
1619 command +=
" \'" + fname +
"\' &";
Status SetType(MeasureType type)
Set how the coordinate was obtained.
void allowLeftMouse(bool allowMouse)
Set the option that allows mouse movements in the left ChipViewport.
Error occured in Adaptive algorithm.
void zoom(double zoomFactor)
Zoom by a specified factor.
void ZScores(double &score1, double &score2) const
Return the ZScores of the pattern chip.
void findPoint()
Find point from left ChipViewport in the right ChipViewport.
double DistanceTolerance() const
Return distance tolerance.
double Sample() const
Returns the current line value of the camera model or projection.
File name manipulation and expansion.
double Tolerance() const
Return match algorithm tolerance.
A small chip of data used for pattern matching.
void setNoGeom()
Slot to turn off geom.
Chip * RegistrationSearchChip()
Return pointer to search chip used in registration.
Not enough valid data in pattern chip.
void updateRightPositionLabel(double zoomFactor)
Update sample/line, lat/lon and zoom factor of right measure.
Not enough points to fit a surface model for sub-pixel accuracy.
Chip * RegistrationPatternChip()
Return pointer to pattern chip used in registration.
Surface model moves registration more than one pixel.
Statistical and similar ControlMeasure associated information.
void registerPoint()
Sub-pixel register point in right chipViewport with point in left.
void TackCube(const double cubeSample, const double cubeLine)
This sets which cube position will be located at the chip tack position.
void updateLeftPositionLabel(double zoomFactor)
Update sample/line, lat/lon and zoom factor of left measure.
AutoReg::RegisterStatus Register()
Walk the pattern chip through the search chip to find the best registration.
Chip * SearchChip()
Return pointer to search chip.
void saveChips()
Slot to save registration chips to files and fire off qview.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
double UniversalLatitude() const
Returns the universal latitude of the camera model or projection.
Widget to display Isis cubes for qt apps.
Registered to sub-pixel (e.g., pointreg)
double Line() const
Returns the current line value of the camera model or projection.
A type of error that occurred when performing an actual I/O operation.
double tackLine()
Returns tack line.
void colorizeSaveButton()
Turn "Save Measure" button text to red.
double tackSample()
Return the position of cube under cross hair.
Control measures store z-scores in pairs.
void setRightMeasure(ControlMeasure *rightMeasure, Cube *rightCube, QString pointId)
Set the measure displayed in the right ChipViewport.
static void RunSystemCommand(QString commandLine)
This runs arbitrary system commands.
double PatternValidPercent() const
Return pattern chip valid percent. The default value is.
ControlPointEdit(ControlNet *cnet, QWidget *parent=0, bool allowLeftMouse=false, bool useGeometry=true)
Constructs a ControlPointEdit widget.
double CubeSample() const
Return the search chip cube sample that best matched.
bool setTemplateFile(QString)
Allows user to choose a new template file by opening a window from which to select a filename...
double GoodnessOfFit() const
Return the goodness of fit of the match algorithm.
Hand Measured (e.g., qnet)
Chip * PatternChip()
Return pointer to pattern chip.
void Write(const QString &filename)
Writes the contents of the Chip to a cube.
void setGeom()
Turn geom on.
void changeBlinkTime(double interval)
Set blink rate.
bool Success() const
Return whether the match algorithm succeeded or not.
#define _FILEINFO_
Macro for the filename and line number.
void blinkStart()
Slot to start blink function.
void SetLogData(ControlMeasureLogData)
This adds or updates the log data information associated with data's type.
A type of error that could only have occurred due to a mistake on the user's part (e...
void saveMeasure()
Save control measure under the crosshair in right ChipViewport.
void updateBlink()
Slot to cause the blink to happen coinciding with the timer.
double UniversalLongitude() const
Returns the universal longitude of the camera model or projection.
void geomChip(Chip *matchChip, Cube *matchChipCube)
Slot to geom chip (apply geometry transformation)
double zoomFactor()
Return the zoom factor.
Fit chip did not have any valid data.
Container for cube-like labels.
void Load(Cube &cube, const double rotation=0.0, const double scale=1.0, const int band=1)
Load cube data into the Chip.
bool IsEditLocked() const
Return value for p_editLock or implicit lock on reference measure.
void updateRightGeom()
Slot to update the geomed right ChipViewport for zoom operations.
void blinkStop()
Slot to stop blink function.
bool SetImage(double sample, double line)
Returns whether the sample/line postion was set successfully in the camera model or projection...
static AutoReg * Create(Pvl &pvl)
Create an AutoReg object using a PVL specification.
GoodnessOfFit is pointreg information for reference measures.
Goodness of fit tolerance not satisfied.
void createPointEditor(QWidget *parent)
Design the PointEdit widget.
void setRotate()
Slot to update the right ChipViewport for zoom operations.
RegisterStatus
Enumeration of the Register() method's return status.
void Distance(double &sampDistance, double &lineDistance)
Return the distance point moved.
void setChip(Chip *chip, Cube *chipCube)
Set chip.
QString toString() const
Returns a string representation of this exception.
static QString UserName()
Returns the user name.
Status SetChooserName()
Set chooser name to a user who last changed the coordinate.
bool SetUniversalGround(double lat, double lon)
Returns whether the lat/lon position was set successfully in the camera model or projection.
QString GetCubeSerialNumber() const
Return the serial number of the cube containing the coordinate.
Status SetCoordinate(double sample, double line)
Set the coordinate of the measurement.
Chip * FitChip()
Return pointer to fit chip.
void DeleteLogData(long dataType)
This deletes log data of the specified type.
Status SetDateTime()
Date Time - Creation Time.
Could not model surface for sub-pixel accuracy.
Pattern data max or min does not pass the z-score test.
void setCircle(bool checked)
Slot to change state of circle.
double MinimumZScore() const
Return minimumPatternZScore.
const int VIEWSIZE
Constant representing the length and width of the chip viewports.
void setZoomLink(bool)
Turn linking of zoom on or off.
double CubeLine() const
Return the search chip cube line that best matched.
void loadView(ChipViewport &newView)
Load with another ChipViewport, used for blinking.
void setCircle(bool)
Turn circle widgets on/off.
void nogeomChip()
Slot to un-geom chip (revert geometry transformation)
void setLeftMeasure(ControlMeasure *leftMeasure, Cube *leftCube, QString pointId)
Set the measure displayed in the left ChipViewport.
IO Handler for Isis Cubes.