Isis 3.0 Programmer Reference
Back | Home
ControlPointEdit.cpp
1 #include "ControlPointEdit.h"
2 
3 //TEST
4 #include <QDebug>
5 
6 #include <QApplication>
7 #include <QButtonGroup>
8 #include <QCheckBox>
9 #include <QColor>
10 #include <QDial>
11 #include <QDoubleSpinBox>
12 #include <QFileDialog>
13 #include <QGridLayout>
14 #include <QHBoxLayout>
15 #include <QLCDNumber>
16 #include <QMessageBox>
17 #include <QPalette>
18 #include <QPushButton>
19 #include <QRadioButton>
20 #include <QScrollBar>
21 #include <QSize>
22 #include <QString>
23 #include <QTimer>
24 #include <QToolButton>
25 
26 #include "Application.h"
27 #include "AutoReg.h"
28 #include "AutoRegFactory.h"
29 #include "ChipViewport.h"
30 #include "ControlMeasure.h"
31 #include "ControlMeasureLogData.h"
32 #include "FileName.h"
33 #include "IString.h"
34 #include "ProgramLauncher.h"
35 #include "Pvl.h"
36 #include "UniversalGroundMap.h"
37 
38 namespace Isis {
39 
40  const int VIEWSIZE = 301;
41 
55  bool allowLeftMouse, bool useGeometry) : QWidget(parent) {
56 
57  p_rotation = 0;
58  p_timerOn = false;
59  p_autoRegFact = NULL;
60  p_allowLeftMouse = allowLeftMouse;
61  p_useGeometry = useGeometry;
62 
63  // Initialize some pointers
64  p_leftCube = 0;
65  p_rightCube = 0;
66  p_leftGroundMap = 0;
67  p_rightGroundMap = 0;
68 
69  try {
70  p_templateFileName = "$base/templates/autoreg/qnetReg.def";
71  Pvl pvl(p_templateFileName);
72  p_autoRegFact = AutoRegFactory::Create(pvl);
73  }
74  catch (IException &e) {
75  p_autoRegFact = NULL;
76  IException fullError(e, IException::Io,
77  "Cannot create AutoRegFactory. As a result, "
78  "sub-pixel registration will not work.",
79  _FILEINFO_);
80  QString message = fullError.toString();
81  QMessageBox::information((QWidget *)parent, "Error", message);
82  }
83 
84  createPointEditor(parent);
85  if (cnet != NULL) emit newControlNetwork(cnet);
86  }
87 
88 
89 
90  ControlPointEdit::~ControlPointEdit() {
91 
92  delete p_leftChip;
93  p_leftChip = NULL;
94  delete p_rightChip;
95  p_rightChip = NULL;
96  }
97 
98 
99 
124  // Place everything in a grid
125  QGridLayout *gridLayout = new QGridLayout();
126  gridLayout->setSizeConstraint(QLayout::SetFixedSize);
127  // grid row
128  int row = 0;
129 
130  QString tempFileName = FileName("$base/icons").expanded();
131  QString toolIconDir = tempFileName;
132 
133  QSize isize(27, 27);
134  // Add zoom buttons
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.");
140 
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.");
146 
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.");
152 
153  QHBoxLayout *leftZoomPan = new QHBoxLayout;
154  leftZoomPan->addWidget(leftZoomIn);
155  leftZoomPan->addWidget(leftZoomOut);
156  leftZoomPan->addWidget(leftZoom1);
157 
158  // These buttons only used if allow mouse events in leftViewport
159  QToolButton *leftPanUp = 0;
160  QToolButton *leftPanDown = 0;
161  QToolButton *leftPanLeft = 0;
162  QToolButton *leftPanRight = 0;
163  if ( p_allowLeftMouse ) {
164  // Add arrows for panning
165  leftPanUp = new QToolButton(parent);
166  leftPanUp->setIcon(QIcon(FileName("$base/icons/up.png").
167  expanded()));
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.");
172 
173  leftPanDown = new QToolButton(parent);
174  leftPanDown->setIcon(QIcon(FileName("$base/icons/down.png").
175  expanded()));
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.");
180 
181  leftPanLeft = new QToolButton(parent);
182  leftPanLeft->setIcon(QIcon(FileName("$base/icons/back.png").
183  expanded()));
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"
187  "pixel.");
188 
189  leftPanRight = new QToolButton(parent);
190  leftPanRight->setIcon(QIcon(FileName("$base/icons/forward.png").
191  expanded()));
192  leftPanRight->setIconSize(isize);
193  leftPanRight->setToolTip("Move right 1 screen pixel");
194  leftPanRight->setWhatsThis("Move the left measure to the right by 1"
195  "screen pixel.");
196 
197  leftZoomPan->addWidget(leftPanUp);
198  leftZoomPan->addWidget(leftPanDown);
199  leftZoomPan->addWidget(leftPanLeft);
200  leftZoomPan->addWidget(leftPanRight);
201  }
202 
203  leftZoomPan->addStretch();
204  gridLayout->addLayout(leftZoomPan, row, 0);
205 
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.");
211 
212  p_rightZoomOut = new QToolButton();
213  p_rightZoomOut->setIcon(QIcon(FileName("$base/icons/viewmag-.png").
214  expanded()));
215  p_rightZoomOut->setIconSize(isize);
216  p_rightZoomOut->setToolTip("Zoom Out 2x");
217  p_rightZoomOut->setWhatsThis("Zoom Out 2x on right measure.");
218 
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.");
224 
225  QHBoxLayout *rightZoomPan = new QHBoxLayout;
226  rightZoomPan->addWidget(p_rightZoomIn);
227  rightZoomPan->addWidget(p_rightZoomOut);
228  rightZoomPan->addWidget(p_rightZoom1);
229 
230  // Add arrows for panning
231  QToolButton *rightPanUp = new QToolButton(parent);
232  rightPanUp->setIcon(QIcon(FileName("$base/icons/up.png").
233  expanded()));
234  rightPanUp->setIconSize(isize);
235  rightPanUp->setToolTip("Move up 1 screen pixel");
236  rightPanUp->setWhatsThis("Move the right measure up 1 screen pixel.");
237 
238  QToolButton *rightPanDown = new QToolButton(parent);
239  rightPanDown->setIcon(QIcon(FileName("$base/icons/down.png").
240  expanded()));
241  rightPanDown->setIconSize(isize);
242  rightPanDown->setToolTip("Move down 1 screen pixel");
243  rightPanUp->setWhatsThis("Move the right measure down 1 screen pixel.");
244 
245  QToolButton *rightPanLeft = new QToolButton(parent);
246  rightPanLeft->setIcon(QIcon(FileName("$base/icons/back.png").
247  expanded()));
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"
251  "pixel.");
252 
253  QToolButton *rightPanRight = new QToolButton(parent);
254  rightPanRight->setIcon(QIcon(FileName("$base/icons/forward.png").
255  expanded()));
256  rightPanRight->setIconSize(isize);
257  rightPanRight->setToolTip("Move right 1 screen pixel");
258  rightPanRight->setWhatsThis("Move the right measure to the right by 1"
259  "screen pixel.");
260 
261  rightZoomPan->addWidget(rightPanUp);
262  rightZoomPan->addWidget(rightPanDown);
263  rightZoomPan->addWidget(rightPanLeft);
264  rightZoomPan->addWidget(rightPanRight);
265  rightZoomPan->addStretch();
266 
267  gridLayout->addLayout(rightZoomPan, row++, 1);
268 
269  // Add zoom factor label and stretch locking checkbox
270  p_leftZoomFactor = new QLabel();
271  QCheckBox *leftLockStretch = new QCheckBox("lock stretch");
272  // there are two "lock stretch" checkboxes (left and right)
273  // use same whats this text for both
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);
283 
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);
291 
292 
293  p_leftView = new ChipViewport(VIEWSIZE, VIEWSIZE, this);
294  // Do not want to accept mouse/keyboard events
295  if ( !p_allowLeftMouse ) p_leftView->setDisabled(true);
296 
297  gridLayout->addWidget(p_leftView, row, 0);
298 
299  connect(this, SIGNAL(newControlNetwork(ControlNet *)),
300  p_leftView, SLOT(setControlNet(ControlNet *)));
301 
302  connect(this,
303  SIGNAL(stretchChipViewport(Stretch *, CubeViewport *)),
304  p_leftView,
305  SLOT(stretchFromCubeViewport(Stretch *, CubeViewport *)));
306 
307  connect(leftLockStretch, SIGNAL(stateChanged(int)),
308  p_leftView,
309  SLOT(changeStretchLock(int)));
310  leftLockStretch->setChecked(false);
311 
312 
313  // Connect left zoom buttons to ChipViewport's zoom slots
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()));
317 
318  // If zoom on left, need to re-geom right
319  connect(leftZoomIn, SIGNAL(clicked()), this, SLOT(updateRightGeom()));
320  connect(leftZoomOut, SIGNAL(clicked()), this, SLOT(updateRightGeom()));
321  connect(leftZoom1, SIGNAL(clicked()), this, SLOT(updateRightGeom()));
322 
323  // Connect the ChipViewport tackPointChanged signal to
324  // the update sample/line label
325  connect(p_leftView, SIGNAL(tackPointChanged(double)),
326  this, SLOT(updateLeftPositionLabel(double)));
327 
328  // we want to allow this connection so that if a changed point is saved
329  // and the same image is showing in both viewports, the left will refresh.
330  connect(this, SIGNAL(updateLeftView(double, double)),
331  p_leftView, SLOT(refreshView(double, double)));
332 
333  connect (p_leftView, SIGNAL(userMovedTackPoint()),
334  this, SLOT(colorizeSaveButton()));
335 
336  if ( p_allowLeftMouse ) {
337  // Connect pan buttons to ChipViewport
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()));
342 
343  connect(leftPanUp, SIGNAL(clicked()), this, SLOT(colorizeSaveButton()));
344  connect(leftPanDown, SIGNAL(clicked()), this, SLOT(colorizeSaveButton()));
345  connect(leftPanLeft, SIGNAL(clicked()), this, SLOT(colorizeSaveButton()));
346  connect(leftPanRight, SIGNAL(clicked()), this, SLOT(colorizeSaveButton()));
347  }
348 
349  p_rightView = new ChipViewport(VIEWSIZE, VIEWSIZE, this);
350  gridLayout->addWidget(p_rightView, row, 1);
351 
352  connect(this, SIGNAL(newControlNetwork(ControlNet *)),
353  p_rightView, SLOT(setControlNet(ControlNet *)));
354  connect(this,
355  SIGNAL(stretchChipViewport(Stretch *, CubeViewport *)),
356  p_rightView,
357  SLOT(stretchFromCubeViewport(Stretch *, CubeViewport *)));
358  connect(rightLockStretch, SIGNAL(stateChanged(int)),
359  p_rightView,
360  SLOT(changeStretchLock(int)));
361  rightLockStretch->setChecked(false);
362 
363  // Connect the ChipViewport tackPointChanged signal to
364  // the update sample/line label
365  connect(p_rightView, SIGNAL(tackPointChanged(double)),
366  this, SLOT(updateRightPositionLabel(double)));
367  connect(this, SIGNAL(updateRightView(double, double)),
368  p_rightView, SLOT(refreshView(double, double)));
369 
370  connect (p_rightView, SIGNAL(userMovedTackPoint()),
371  this, SLOT(colorizeSaveButton()));
372 
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()));
376 
377  // Connect pan buttons to ChipViewport
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()));
382 
383  connect(rightPanUp, SIGNAL(clicked()), this, SLOT(colorizeSaveButton()));
384  connect(rightPanDown, SIGNAL(clicked()), this, SLOT(colorizeSaveButton()));
385  connect(rightPanLeft, SIGNAL(clicked()), this, SLOT(colorizeSaveButton()));
386  connect(rightPanRight, SIGNAL(clicked()), this, SLOT(colorizeSaveButton()));
387 
388  // Create chips for left and right
389  p_leftChip = new Chip(VIEWSIZE, VIEWSIZE);
390  p_rightChip = new Chip(VIEWSIZE, VIEWSIZE);
391 
392  QButtonGroup *bgroup = new QButtonGroup();
393  p_nogeom = new QRadioButton();
394  p_nogeom->setChecked(true);
395  connect(p_nogeom, SIGNAL(clicked()), this, SLOT(setNoGeom()));
396 
397  QCheckBox *linkZoom = NULL;
398  if (p_useGeometry) {
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()));
411  }
412  else {
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)));
418 
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.");
423  }
424  bgroup->addButton(p_nogeom);
425 
426  QRadioButton *rotate = new QRadioButton("Rotate");
427  bgroup->addButton(rotate);
428  // TODO: ?? Don't think we need this connection
429  connect(rotate, SIGNAL(clicked()), this, SLOT(setRotate()));
430 
431  // Set some defaults
432  p_geomIt = false;
433  p_rotation = 0;
434  p_linkZoom = false;
435 
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.");
444 
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"
449  " of degrees.");
450  connect(p_dial, SIGNAL(valueChanged(int)), p_dialNumber, SLOT(display(int)));
451  connect(p_dial, SIGNAL(valueChanged(int)), p_rightView, SLOT(rotateChip(int)));
452 
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);
462 
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");
470 
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)));
477 
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);
485  p_slider->hide();
486  p_slider->setToolTip("Adjust circle size");
487  p_slider->setWhatsThis("This allows the cirle size to be adjusted.");
488 
489  QVBoxLayout *vlayout = new QVBoxLayout();
490  if (!p_useGeometry) {
491  vlayout->addWidget(linkZoom);
492  }
493  vlayout->addWidget(p_nogeom);
494  if (p_useGeometry) {
495  vlayout->addWidget(p_geom);
496  }
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);
505 
506  // Show sample / line for measure of chips shown
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);
513 
514  if (p_useGeometry) {
515  // Show lat / lon for measure of chips shown
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);
522  }
523 
524 
525  // Add auto registration extension
526  p_autoRegExtension = new QWidget;
527  p_oldPosition = new QLabel;
528  p_oldPosition->setToolTip("Measure Sample/Line before sub-pixel "
529  "registration");
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 "
536  "registration.");
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);
545 
546 
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()));
555 
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()));
564 
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)),
577  this, SLOT(changeBlinkTime(double)));
578 
579  leftLayout->addWidget(stop);
580  leftLayout->addWidget(start);
581  leftLayout->addWidget(p_blinkTimeBox);
582 
583  if (p_useGeometry) {
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()));
593  }
594 
595  leftLayout->addStretch();
596  gridLayout->addLayout(leftLayout, row, 0);
597 
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>");
616  }
617  else {
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>");
625  }
626  p_saveMeasure->setShortcut(Qt::Key_M);
627  p_saveDefaultPalette = p_saveMeasure->palette();
628 
629  rightLayout->addWidget(p_autoReg);
630  rightLayout->addWidget(p_saveMeasure);
631  rightLayout->addStretch();
632  gridLayout->addLayout(rightLayout, row, 1);
633 
634  connect(p_autoReg, SIGNAL(clicked()), this, SLOT(registerPoint()));
635  connect(p_saveMeasure, SIGNAL(clicked()), this, SLOT(saveMeasure()));
636 
637  setLayout(gridLayout);
638 
639  //p_pointEditor->setCentralWidget(cw);
640  p_autoRegExtension->hide();
641 
642  //p_pointEditor->setVisible(true);
643  //p_pointEditor->raise();
644  }
645 
646 
647 
648 
671  Cube *leftCube, QString pointId) {
672 
673  // Make sure registration is turned off
674  if ( p_autoRegShown ) {
675  // Undo Registration
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);
682  }
683 
684  p_leftMeasure = leftMeasure;
685 
686  if (p_useGeometry) {
687  // get new ground map
688  if ( p_leftGroundMap != 0 ) delete p_leftGroundMap;
689  p_leftGroundMap = new UniversalGroundMap(*leftCube);
690  }
691  p_leftCube = leftCube;
692 
693  p_leftChip->TackCube(p_leftMeasure->GetSample(), p_leftMeasure->GetLine());
694  p_leftChip->Load(*p_leftCube);
695 
696  // Dump into left chipViewport
697  p_leftView->setChip(p_leftChip, p_leftCube);
698 
699  // Only update right if not loading a new point. If it's a new point, right measure
700  // hasn't been loaded yet.
701  if (pointId == p_pointId && p_geomIt) updateRightGeom();
702  p_pointId = pointId;
703  }
704 
705 
732  Cube *rightCube, QString pointId) {
733 
734  // Make sure registration is turned off
735  if ( p_autoRegShown ) {
736  // Undo Registration
737  p_autoRegShown = false;
738  p_autoRegExtension->hide();
739  p_autoReg->setText("Register");
740  p_autoReg->setShortcut(Qt::Key_R);
741  }
742  p_autoRegAttempted = false;
743 
744  p_rightMeasure = rightMeasure;
745  p_pointId = pointId;
746 
747  if (p_useGeometry) {
748  // get new ground map
749  if ( p_rightGroundMap != 0 ) delete p_rightGroundMap;
750  p_rightGroundMap = new UniversalGroundMap(*rightCube);
751  }
752  p_rightCube = rightCube;
753 
754  p_rightChip->TackCube(p_rightMeasure->GetSample(),
755  p_rightMeasure->GetLine());
756  if ( p_geomIt == false ) {
757  p_rightChip->Load(*p_rightCube);
758  }
759  else {
760  try {
761  p_rightChip->Load(*p_rightCube, *p_leftChip, *p_leftCube);
762 
763  }
764  catch (IException &e) {
765  IException fullError(e, IException::User, "Geom failed.", _FILEINFO_);
766  QString message = fullError.toString();
767  QMessageBox::information((QWidget *)parent(), "Error", message);
768  p_rightChip->Load(*p_rightCube);
769  p_geomIt = false;
770  p_nogeom->setChecked(true);
771  p_geom->setChecked(false);
772  }
773  }
774 
775  // Dump into right chipViewport
776  p_rightView->setChip(p_rightChip, p_rightCube);
777 
778  updateRightGeom();
779  //p_rightView->geomChip(p_leftChip,p_leftCube);
780 
781  // New right measure, make sure Save Measure Button text is default
782  p_saveMeasure->setPalette(p_saveDefaultPalette);
783 
784  }
785 
786 
800  QString pos = "Sample: " + QString::number(p_leftView->tackSample()) +
801  " Line: " + QString::number(p_leftView->tackLine());
802  p_leftSampLinePosition->setText(pos);
803 
804  if (p_useGeometry) {
805  // Get lat/lon from point in left
806  p_leftGroundMap->SetImage(p_leftView->tackSample(), p_leftView->tackLine());
807  double lat = p_leftGroundMap->UniversalLatitude();
808  double lon = p_leftGroundMap->UniversalLongitude();
809 
810  pos = "Latitude: " + QString::number(lat) +
811  " Longitude: " + QString::number(lon);
812  p_leftLatLonPosition->setText(pos);
813  }
814 
815  // Print zoom scale factor
816  pos = "Zoom Factor: " + QString::number(zoomFactor);
817  p_leftZoomFactor->setText(pos);
818 
819  // If zooms are linked, make right match left
820  if (p_linkZoom) {
821  p_rightView->zoom(p_leftView->zoomFactor());
822  }
823 
824  }
825 
826 
835 
836  // If registration Info is on, turn off
837  if ( p_autoRegShown ) {
838  // Undo Registration
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);
845  }
846 
847  QString pos = "Sample: " + QString::number(p_rightView->tackSample()) +
848  " Line: " + QString::number(p_rightView->tackLine());
849  p_rightSampLinePosition->setText(pos);
850 
851  if (p_useGeometry) {
852  // Get lat/lon from point in right
853  p_rightGroundMap->SetImage(p_rightView->tackSample(), p_rightView->tackLine());
854  double lat = p_rightGroundMap->UniversalLatitude();
855  double lon = p_rightGroundMap->UniversalLongitude();
856 
857  pos = "Latitude: " + QString::number(lat) +
858  " Longitude: " + QString::number(lon);
859  p_rightLatLonPosition->setText(pos);
860  }
861 
862  // Print zoom scale factor
863  pos = "Zoom Factor: " + QString::number(zoomFactor);
864  p_rightZoomFactor->setText(pos);
865 
866  }
867 
868 
875 
876  QColor qc = Qt::red;
877  QPalette p = p_saveMeasure->palette();
878  p.setColor(QPalette::ButtonText,qc);
879  p_saveMeasure->setPalette(p);
880 
881  }
882 
883 
894 
895  // Get lat/lon from point in left
896  p_leftGroundMap->SetImage(p_leftView->tackSample(), p_leftView->tackLine());
897  double lat = p_leftGroundMap->UniversalLatitude();
898  double lon = p_leftGroundMap->UniversalLongitude();
899 
900  // Reload right chipViewport with this new tack point.
901  if ( p_rightGroundMap->SetUniversalGround(lat, lon) ) {
902  emit updateRightView(p_rightGroundMap->Sample(), p_rightGroundMap->Line());
903 
904  // If moving from saved measure, turn save button to red
905  if (p_rightGroundMap->Sample() != p_rightMeasure->GetSample() ||
906  p_rightGroundMap->Line() != p_rightMeasure->GetLine())
908  }
909  else {
910  QString message = "Latitude: " + QString::number(lat) + " Longitude: " +
911  QString::number(lon) + " is not on the right image. Right measure " +
912  "was not moved.";
913  QMessageBox::warning((QWidget *)parent(),"Warning",message);
914  }
915 
916  }
917 
918 
949 
950  if ( p_autoRegShown ) {
951  // Undo Registration
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);
958 
959  // Reload chip with original measure
960  emit updateRightView(p_rightMeasure->GetSample(),
961  p_rightMeasure->GetLine());
962  // Since un-doing registration, make sure save button not red
963  p_saveMeasure->setPalette(p_saveDefaultPalette);
964  return;
965 
966  }
967  p_autoRegAttempted = true;
968 
969  try {
970  p_autoRegFact->PatternChip()->TackCube(
971  p_leftMeasure->GetSample(), p_leftMeasure->GetLine());
972  p_autoRegFact->PatternChip()->Load(*p_leftCube);
973  p_autoRegFact->SearchChip()->TackCube(
974  p_rightMeasure->GetSample(),
975  p_rightMeasure->GetLine());
976  if (p_useGeometry) {
977  p_autoRegFact->SearchChip()->Load(*p_rightCube,
978  *(p_autoRegFact->PatternChip()), *p_leftCube);
979  }
980  else {
981  p_autoRegFact->SearchChip()->Load(*p_rightCube);
982  }
983  }
984  catch (IException &e) {
985  QString msg = "Cannot register this point, unable to Load chips.\n";
986  msg += e.toString();
987  QMessageBox::information((QWidget *)parent(), "Error", msg);
988  return;
989  }
990 
991  try {
992  AutoReg::RegisterStatus status = p_autoRegFact->Register();
993  if ( !p_autoRegFact->Success() ) {
994  QString msg = "Cannot sub-pixel register this point.\n";
995  if ( status == AutoReg::PatternChipNotEnoughValidData ) {
996  msg += "\n\nNot enough valid data in Pattern Chip.\n";
997  msg += " PatternValidPercent = ";
998  msg += QString::number(p_autoRegFact->PatternValidPercent()) + "%";
999  }
1000  else if ( status == AutoReg::FitChipNoData ) {
1001  msg += "\n\nNo valid data in Fit Chip.";
1002  }
1003  else if ( status == AutoReg::FitChipToleranceNotMet ) {
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());
1008  }
1009  else if ( status == AutoReg::SurfaceModelNotEnoughValidData ) {
1010  msg += "\n\nNot enough valid points in the fit chip window for sub-pixel ";
1011  msg += "accuracy. Probably too close to edge.\n";
1012  }
1013  else if ( status == AutoReg::SurfaceModelSolutionInvalid ) {
1014  msg += "\n\nCould not model surface for sub-pixel accuracy.\n";
1015  }
1016  else if ( status == AutoReg::SurfaceModelDistanceInvalid ) {
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 = " +
1023  QString::number(p_autoRegFact->DistanceTolerance());
1024  }
1025  else if ( status == AutoReg::PatternZScoreNotMet ) {
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);
1031  }
1032  else if ( status == AutoReg::AdaptiveAlgorithmFailed ) {
1033  msg += "\n\nError occured in Adaptive algorithm.";
1034  }
1035  else {
1036  msg += "\n\nUnknown registration error.";
1037  }
1038 
1039  QMessageBox::information((QWidget *)parent(), "Error", msg);
1040  return;
1041  }
1042  }
1043  catch (IException &e) {
1044  QString msg = "Cannot register this point.\n";
1045  msg += e.toString();
1046  QMessageBox::information((QWidget *)parent(), "Error", msg);
1047  return;
1048  }
1049 
1050 
1051 
1052  // Load chip with new registered point
1053  emit updateRightView(p_autoRegFact->CubeSample(), p_autoRegFact->CubeLine());
1054  // If registered pt different from measure, colorize the save button
1055  if (p_autoRegFact->CubeSample() != p_rightMeasure->GetSample() ||
1056  p_autoRegFact->CubeLine() != p_rightMeasure->GetLine()) {
1058  }
1059 
1060  QString oldPos = "Original Sample: " +
1061  QString::number(p_rightMeasure->GetSample()) + " Original Line: " +
1062  QString::number(p_rightMeasure->GetLine());
1063  p_oldPosition->setText(oldPos);
1064 
1065  QString goodFit = "Goodness of Fit: " +
1066  QString::number(p_autoRegFact->GoodnessOfFit());
1067  p_goodFit->setText(goodFit);
1068 
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);
1075  }
1076 
1077 
1113 
1114  if (p_rightMeasure != NULL) {
1115 
1116  if (p_rightMeasure->IsEditLocked()) {
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);
1120  return;
1121  }
1122 
1123  if (p_autoRegShown) {
1124  try {
1125  // Save autoreg parameters to the right measure log entry
1126  // Eccentricity may be invalid, check before writing.
1127  p_rightMeasure->SetLogData(ControlMeasureLogData(
1129  p_autoRegFact->GoodnessOfFit()));
1130  double minZScore, maxZScore;
1131  p_autoRegFact->ZScores(minZScore,maxZScore);
1132  p_rightMeasure->SetLogData(ControlMeasureLogData(
1134  minZScore));
1135  p_rightMeasure->SetLogData(ControlMeasureLogData(
1137  maxZScore));
1138  }
1139  // need to handle exception that SetLogData throws if our data is invalid -
1140  // unhandled exceptions thrown in Qt signal and slot connections produce undefined behavior
1141  catch (IException &e) {
1142  QString message = e.toString();
1143  QMessageBox::critical((QWidget *)parent(), "Error", message);
1144  return;
1145  }
1146 
1147  // Reset AprioriSample/Line to the current coordinate, before the
1148  // coordinate is updated with the registered coordinate.
1149  p_rightMeasure->SetAprioriSample(p_rightMeasure->GetSample());
1150  p_rightMeasure->SetAprioriLine(p_rightMeasure->GetLine());
1151 
1152  p_rightMeasure->SetChooserName("Application qnet");
1154 
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);
1161  }
1162  else {
1163  p_rightMeasure->SetChooserName(Application::UserName());
1164  p_rightMeasure->SetType(ControlMeasure::Manual);
1165  p_rightMeasure->DeleteLogData(
1167  p_rightMeasure->DeleteLogData(
1169  p_rightMeasure->DeleteLogData(
1171  }
1172 
1173  // Get cube position at right chipViewport crosshair
1174  p_rightMeasure->SetCoordinate(p_rightView->tackSample(),
1175  p_rightView->tackLine());
1176  p_rightMeasure->SetDateTime();
1177 
1178  }
1179 
1180  if (p_allowLeftMouse) {
1181  if (p_leftMeasure != NULL) {
1182  if (p_leftMeasure->IsEditLocked()) {
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);
1186  return;
1187  }
1188 
1189  p_leftMeasure->SetCoordinate(p_leftView->tackSample(), p_leftView->tackLine());
1190  p_leftMeasure->SetDateTime();
1191  p_leftMeasure->SetChooserName(Application::UserName());
1192  p_leftMeasure->SetType(ControlMeasure::Manual);
1193  }
1194  }
1195 
1196  // If the right chip is the same as the left chip, copy right into left and
1197  // re-load the left.
1198  if (p_rightMeasure->GetCubeSerialNumber() ==
1199  p_leftMeasure->GetCubeSerialNumber()) {
1200 
1201  *p_leftMeasure = *p_rightMeasure;
1202  setLeftMeasure(p_leftMeasure,p_leftCube,p_pointId);
1203  }
1204 
1205  // Change Save Measure button text back to default palette
1206  p_saveMeasure->setPalette(p_saveDefaultPalette);
1207 
1208  // Redraw measures on viewports
1209  emit measureSaved();
1210  }
1211 
1212 
1221 
1222  if (p_geomIt) {
1223  try {
1224  p_rightView->geomChip(p_leftChip, p_leftCube);
1225 
1226  }
1227  catch (IException &e) {
1228  IException fullError(e, IException::User, "Geom failed.", _FILEINFO_);
1229  QString message = fullError.toString();
1230  QMessageBox::information((QWidget *)parent(), "Error", message);
1231  p_geomIt = false;
1232  p_nogeom->setChecked(true);
1233  p_geom->setChecked(false);
1234  }
1235  }
1236  }
1237 
1238 
1239 
1241 // * Slot to update the right ChipViewport for zoom
1242 // * operations
1243 // *
1244 // * @author 2012-07-26 Tracie Sucharski
1245 // *
1246 // * @internal
1247 // */
1248 //void ControlPointEdit::updateRightZoom() {
1249 //
1250 // if ( p_linkZoom ) {
1251 // try {
1252 // p_rightView->geomChip(p_leftChip, p_leftCube);
1253 //
1254 // }
1255 // catch (IException &e) {
1256 // IException fullError(e, IException::User, "Geom failed.", _FILEINFO_);
1257 // QString message = fullError.toString();
1258 // QMessageBox::information((QWidget *)parent(), "Error", message);
1259 // p_geomIt = false;
1260 // p_nogeom->setChecked(true);
1261 // p_geom->setChecked(false);
1262 // }
1263 // }
1264 //}
1265 
1266 
1267 
1274  QApplication::setOverrideCursor(Qt::WaitCursor);
1275 
1276  // Text needs to be reset because it was changed to
1277  // indicate why it's greyed out
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");
1286  text = "Zoom 1:1";
1287  p_rightZoom1->setEnabled(true);
1288  p_rightZoom1->setWhatsThis(text);
1289  p_rightZoom1->setToolTip("Zoom 1:1");
1290 
1291  p_geomIt = false;
1292  p_rightView->nogeomChip();
1293 
1294  QApplication::restoreOverrideCursor();
1295 
1296  p_dial->setEnabled(true);
1297  p_dialNumber->setEnabled(true);
1298  p_dial->setNotchesVisible(true);
1299 
1300  }
1301 
1302 
1303 
1313 
1314  if (p_geomIt == true) return;
1315 
1316  QApplication::setOverrideCursor(Qt::WaitCursor);
1317 
1318  // Grey right view zoom buttons
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);
1329 
1330 
1331  // Reset dial to 0 before disabling
1332  p_dial->setValue(0);
1333  p_dial->setEnabled(false);
1334  p_dialNumber->setEnabled(false);
1335 
1336  p_geomIt = true;
1337 
1338  try {
1339  p_rightView->geomChip(p_leftChip, p_leftCube);
1340 
1341  }
1342  catch (IException &e) {
1343  IException fullError(e, IException::User, "Geom failed.", _FILEINFO_);
1344  QString message = fullError.toString();
1345  QMessageBox::information((QWidget *)parent(), "Error", message);
1346  p_geomIt = false;
1347  p_nogeom->setChecked(true);
1348  p_geom->setChecked(false);
1349  }
1350 
1351  QApplication::restoreOverrideCursor();
1352  }
1353 
1354 
1361 
1362  QApplication::setOverrideCursor(Qt::WaitCursor);
1363 
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");
1372  text = "Zoom 1:1";
1373  p_rightZoom1->setEnabled(true);
1374  p_rightZoom1->setWhatsThis(text);
1375  p_rightZoom1->setToolTip("Zoom 1:1");
1376 
1377  // Reset dial to 0 before disabling
1378  p_dial->setValue(0);
1379  p_dial->setEnabled(false);
1380  p_dialNumber->setEnabled(false);
1381 
1382  p_geomIt = false;
1383  p_rightView->nogeomChip();
1384 
1385  QApplication::restoreOverrideCursor();
1386  }
1387 
1388 
1389 
1390 
1398  void ControlPointEdit::setCircle(bool checked) {
1399 
1400  if ( checked == p_circle ) return;
1401 
1402  p_circle = checked;
1403  if ( p_circle ) {
1404  // Turn on slider bar
1405  p_slider->setDisabled(false);
1406  p_slider->show();
1407  p_slider->setValue(20);
1408  p_leftView->setCircle(true);
1409  p_rightView->setCircle(true);
1410  }
1411  else {
1412  p_slider->setDisabled(true);
1413  p_slider->hide();
1414  p_leftView->setCircle(false);
1415  p_rightView->setCircle(false);
1416  }
1417 
1418 
1419  }
1420 
1421 
1422 
1430  void ControlPointEdit::setZoomLink(bool checked) {
1431 
1432  if ( checked == p_linkZoom ) return;
1433 
1434  p_linkZoom = checked;
1435  if ( p_linkZoom ) {
1436  p_rightView->zoom(p_leftView->zoomFactor());
1437  }
1438  }
1439 
1440 
1441 
1444  if ( p_timerOn ) return;
1445 
1446  // Set up blink list
1447  p_blinkList.push_back(p_leftView);
1448  p_blinkList.push_back(p_rightView);
1449  p_blinkIndex = 0;
1450 
1451  p_timerOn = true;
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);
1456  }
1457 
1458 
1461  p_timer->stop();
1462  p_timerOn = false;
1463  p_blinkList.clear();
1464 
1465  // Reload left chipViewport with original chip
1466  p_leftView->repaint();
1467 
1468  }
1469 
1470 
1471 
1478  void ControlPointEdit::changeBlinkTime(double interval) {
1479  if ( p_timerOn ) p_timer->setInterval((int)(interval * 1000.));
1480  }
1481 
1482 
1485 
1486  p_blinkIndex = !p_blinkIndex;
1487  p_leftView->loadView(*(p_blinkList)[p_blinkIndex]);
1488  }
1489 
1490 
1491 
1492 
1512 
1513  AutoReg *reg = NULL;
1514  // save original template filename
1515  QString temp = p_templateFileName;
1516  try {
1517  // set template filename to user chosen pvl file
1518  p_templateFileName = fn;
1519 
1520  // Create PVL object with this file
1521  Pvl pvl(fn);
1522 
1523  // try to register file
1524  reg = AutoRegFactory::Create(pvl);
1525  if ( p_autoRegFact != NULL )
1526  delete p_autoRegFact;
1527  p_autoRegFact = reg;
1528 
1529  p_templateFileName = fn;
1530 
1531  // undo registration if a point is already registered
1532  // this prevents the user from saving a measure with invalid data
1533  if (p_autoRegShown)
1534  registerPoint();
1535 
1536  return true;
1537  }
1538  catch (IException &e) {
1539  // set templateFileName back to its original value
1540  p_templateFileName = temp;
1541  IException fullError(e, IException::Io,
1542  "Cannot create AutoRegFactory for " +
1543  fn +
1544  ". As a result, current template file will remain set to " +
1545  p_templateFileName, _FILEINFO_);
1546  QString message = fullError.toString();
1547  QMessageBox::information((QWidget *)parent(), "Error", message);
1548  return false;
1549  }
1550  }
1551 
1552 
1559  void ControlPointEdit::allowLeftMouse(bool allowMouse) {
1560  p_allowLeftMouse = allowMouse;
1561 
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>");
1569  }
1570  else {
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>");
1577  }
1578  }
1579 
1580 
1581 
1582  void ControlPointEdit::refreshChips() {
1583  p_leftView->update();
1584  p_rightView->update();
1585  }
1586 
1587 
1588 
1598 
1599 // if (!p_autoRegShown) {
1600  if ( !p_autoRegAttempted ) {
1601  QString message = "Point must be Registered before chips can be saved.";
1602  QMessageBox::warning((QWidget *)parent(), "Warning", message);
1603  return;
1604  }
1605 
1606  // Save chips - pattern, search and fit
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 + "\'";
1614  p_autoRegFact->RegistrationSearchChip()->Write(fname);
1615  fname = baseFile + "Pattern.cub";
1616  command += " \'" + fname + "\'";
1617  p_autoRegFact->RegistrationPatternChip()->Write(fname);
1618  fname = baseFile + "Fit.cub";
1619  command += " \'" + fname + "\' &";
1620  p_autoRegFact->FitChip()->Write(fname);
1622  }
1623 }
1624 
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.
Definition: AutoReg.h:199
void zoom(double zoomFactor)
Zoom by a specified factor.
void ZScores(double &score1, double &score2) const
Return the ZScores of the pattern chip.
Definition: AutoReg.h:370
void findPoint()
Find point from left ChipViewport in the right ChipViewport.
double DistanceTolerance() const
Return distance tolerance.
Definition: AutoReg.h:310
double Sample() const
Returns the current line value of the camera model or projection.
File name manipulation and expansion.
Definition: FileName.h:111
Universal Ground Map.
double Tolerance() const
Return match algorithm tolerance.
Definition: AutoReg.h:300
A small chip of data used for pattern matching.
Definition: Chip.h:101
void setNoGeom()
Slot to turn off geom.
Chip * RegistrationSearchChip()
Return pointer to search chip used in registration.
Definition: AutoReg.h:237
Not enough valid data in pattern chip.
Definition: AutoReg.h:192
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.
Definition: AutoReg.h:195
Chip * RegistrationPatternChip()
Return pointer to pattern chip used in registration.
Definition: AutoReg.h:227
Surface model moves registration more than one pixel.
Definition: AutoReg.h:197
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.
Definition: Chip.cpp:204
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.
Definition: AutoReg.cpp:600
Chip * SearchChip()
Return pointer to search chip.
Definition: AutoReg.h:217
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.
Definition: IString.cpp:226
double UniversalLatitude() const
Returns the universal latitude of the camera model or projection.
Widget to display Isis cubes for qt apps.
Definition: CubeViewport.h:121
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.
Definition: IException.h:163
double tackLine()
Returns tack line.
void colorizeSaveButton()
Turn &quot;Save Measure&quot; 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.
Definition: AutoReg.h:290
ControlPointEdit(ControlNet *cnet, QWidget *parent=0, bool allowLeftMouse=false, bool useGeometry=true)
Constructs a ControlPointEdit widget.
a control network
Definition: ControlNet.h:207
double CubeSample() const
Return the search chip cube sample that best matched.
Definition: AutoReg.h:350
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.
Definition: AutoReg.h:333
Hand Measured (e.g., qnet)
Pixel value mapper.
Definition: Stretch.h:72
Chip * PatternChip()
Return pointer to pattern chip.
Definition: AutoReg.h:212
void Write(const QString &filename)
Writes the contents of the Chip to a cube.
Definition: Chip.cpp:1023
void setGeom()
Turn geom on.
void changeBlinkTime(double interval)
Set blink rate.
bool Success() const
Return whether the match algorithm succeeded or not.
Definition: AutoReg.h:328
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:38
void blinkStart()
Slot to start blink function.
void SetLogData(ControlMeasureLogData)
This adds or updates the log data information associated with data&#39;s type.
A type of error that could only have occurred due to a mistake on the user&#39;s part (e...
Definition: IException.h:134
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.
Definition: AutoReg.h:193
Container for cube-like labels.
Definition: Pvl.h:135
void Load(Cube &cube, const double rotation=0.0, const double scale=1.0, const int band=1)
Load cube data into the Chip.
Definition: Chip.cpp:225
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.
Auto Registration class.
Definition: AutoReg.h:177
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.
Definition: AutoReg.h:194
void createPointEditor(QWidget *parent)
Design the PointEdit widget.
Viewport for Isis Chips.
Definition: ChipViewport.h:85
void setRotate()
Slot to update the right ChipViewport for zoom operations.
RegisterStatus
Enumeration of the Register() method&#39;s return status.
Definition: AutoReg.h:189
void Distance(double &sampDistance, double &lineDistance)
Return the distance point moved.
Definition: AutoReg.h:320
void setChip(Chip *chip, Cube *chipCube)
Set chip.
QString toString() const
Returns a string representation of this exception.
Definition: IException.cpp:553
static QString UserName()
Returns the user name.
Isis exception class.
Definition: IException.h:99
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.
a control measurement
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.
Definition: AutoReg.h:222
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.
Definition: AutoReg.h:196
Pattern data max or min does not pass the z-score test.
Definition: AutoReg.h:198
void setCircle(bool checked)
Slot to change state of circle.
double MinimumZScore() const
Return minimumPatternZScore.
Definition: AutoReg.h:360
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.
Definition: AutoReg.h:355
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.
Definition: Cube.h:158

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:16:41