Isis 3.0 Programmer Reference
Back | Home
ControlMeasureEditWidget.cpp
1 #include "ControlMeasureEditWidget.h"
2 
3 #include <QApplication>
4 #include <QButtonGroup>
5 #include <QCheckBox>
6 #include <QColor>
7 #include <QDial>
8 #include <QDoubleSpinBox>
9 #include <QFileDialog>
10 #include <QGridLayout>
11 #include <QHBoxLayout>
12 #include <QLCDNumber>
13 #include <QListWidget>
14 #include <QMessageBox>
15 #include <QPalette>
16 #include <QPushButton>
17 #include <QRadioButton>
18 #include <QScrollBar>
19 #include <QSize>
20 #include <QString>
21 #include <QTimer>
22 #include <QToolButton>
23 
24 #include "Application.h"
25 #include "AutoReg.h"
26 #include "AutoRegFactory.h"
27 #include "ChipViewport.h"
28 #include "ControlMeasure.h"
29 #include "ControlMeasureLogData.h"
30 #include "ControlPoint.h"
31 #include "FileName.h"
32 #include "IString.h"
33 #include "ProgramLauncher.h"
34 #include "Pvl.h"
35 #include "SerialNumberList.h"
36 #include "UniversalGroundMap.h"
37 
38 namespace Isis {
39 
41  const int VIEWSIZE = 301;
42 
59  bool allowLeftMouse,
60  bool useGeometry) : QWidget(parent) {
61 
62  m_rotation = 0;
63  m_timerOn = false;
64  m_timerOnRight = false;
65  m_autoRegFact = NULL;
67  m_useGeometry = useGeometry;
68 
69  // Initialize some pointers
70  m_leftCube = 0;
71  m_rightCube = 0;
72  m_leftGroundMap = 0;
73  m_rightGroundMap = 0;
74 
75  try {
76  m_templateFileName = "$base/templates/autoreg/qnetReg.def";
79  }
80  catch (IException &e) {
81  m_autoRegFact = NULL;
82  IException fullError(e, IException::Io,
83  "Cannot create AutoRegFactory. As a result, "
84  "sub-pixel registration will not work.",
85  _FILEINFO_);
86  QString message = fullError.toString();
87  QMessageBox::information((QWidget *)parent, "Error", message);
88  }
89 
90  createMeasureEditor(parent);
91  }
92 
93 
98 
99  delete m_leftChip;
100  m_leftChip = NULL;
101  delete m_rightChip;
102  m_rightChip = NULL;
103  }
104 
105 
129  // Place everything in a grid
130  QGridLayout *gridLayout = new QGridLayout();
131  gridLayout->setSizeConstraint(QLayout::SetFixedSize);
132  // grid row
133  int row = 0;
134 
135  QString tempFileName = FileName("$base/icons").expanded();
136  QString toolIconDir = tempFileName;
137 
138  QSize isize(27, 27);
139  // Add zoom buttons
140  QToolButton *leftZoomIn = new QToolButton();
141  leftZoomIn->setIcon(QPixmap(toolIconDir + "/viewmag+.png"));
142  leftZoomIn->setIconSize(isize);
143  leftZoomIn->setToolTip("Zoom In 2x");
144  leftZoomIn->setWhatsThis("Zoom In 2x on left measure.");
145  leftZoomIn->setShortcut(Qt::Key_Plus);
146 
147  QToolButton *leftZoomOut = new QToolButton();
148  leftZoomOut->setIcon(QPixmap(toolIconDir + "/viewmag-.png"));
149  leftZoomOut->setIconSize(isize);
150  leftZoomOut->setToolTip("Zoom Out 2x");
151  leftZoomOut->setWhatsThis("Zoom Out 2x on left measure.");
152  leftZoomOut->setShortcut(Qt::Key_Minus);
153 
154  QToolButton *leftZoom1 = new QToolButton();
155  leftZoom1->setIcon(QPixmap(toolIconDir + "/viewmag1.png"));
156  leftZoom1->setIconSize(isize);
157  leftZoom1->setToolTip("Zoom 1:1");
158  leftZoom1->setWhatsThis("Show left measure at full resolution.");
159  leftZoom1->setShortcut(Qt::Key_Slash);
160 
161  QHBoxLayout *leftZoomPan = new QHBoxLayout;
162  leftZoomPan->addWidget(leftZoomIn);
163  leftZoomPan->addWidget(leftZoomOut);
164  leftZoomPan->addWidget(leftZoom1);
165 
166  // These buttons only used if allow mouse events in leftViewport
167  QToolButton *leftPanUp = 0;
168  QToolButton *leftPanDown = 0;
169  QToolButton *leftPanLeft = 0;
170  QToolButton *leftPanRight = 0;
171  if ( m_allowLeftMouse ) {
172  // Add arrows for panning
173  leftPanUp = new QToolButton(parent);
174  leftPanUp->setIcon(QIcon(FileName("$base/icons/up.png").
175  expanded()));
176  leftPanUp->setIconSize(isize);
177  leftPanUp->setToolTip("Move up 1 screen pixel");
178  leftPanUp->setStatusTip("Move up 1 screen pixel");
179  leftPanUp->setWhatsThis("Move the left measure up 1 screen pixel.");
180 
181  leftPanDown = new QToolButton(parent);
182  leftPanDown->setIcon(QIcon(FileName("$base/icons/down.png").
183  expanded()));
184  leftPanDown->setIconSize(isize);
185  leftPanDown->setToolTip("Move down 1 screen pixel");
186  leftPanDown->setStatusTip("Move down 1 screen pixel");
187  leftPanDown->setWhatsThis("Move the left measure down 1 screen pixel.");
188 
189  leftPanLeft = new QToolButton(parent);
190  leftPanLeft->setIcon(QIcon(FileName("$base/icons/back.png").
191  expanded()));
192  leftPanLeft->setIconSize(isize);
193  leftPanLeft->setToolTip("Move left 1 screen pixel");
194  leftPanLeft->setWhatsThis("Move the left measure to the left by 1 screen"
195  "pixel.");
196 
197  leftPanRight = new QToolButton(parent);
198  leftPanRight->setIcon(QIcon(FileName("$base/icons/forward.png").
199  expanded()));
200  leftPanRight->setIconSize(isize);
201  leftPanRight->setToolTip("Move right 1 screen pixel");
202  leftPanRight->setWhatsThis("Move the left measure to the right by 1"
203  "screen pixel.");
204 
205  leftZoomPan->addWidget(leftPanUp);
206  leftZoomPan->addWidget(leftPanDown);
207  leftZoomPan->addWidget(leftPanLeft);
208  leftZoomPan->addWidget(leftPanRight);
209  }
210 
211  leftZoomPan->addStretch();
212  gridLayout->addLayout(leftZoomPan, row, 0);
213 
214  m_rightZoomIn = new QToolButton();
215  m_rightZoomIn->setIcon(QPixmap(toolIconDir + "/viewmag+.png"));
216  m_rightZoomIn->setIconSize(isize);
217  m_rightZoomIn->setToolTip("Zoom In 2x");
218  m_rightZoomIn->setWhatsThis("Zoom In 2x on right measure.");
219  m_rightZoomIn->setShortcut(Qt::Key_Plus);
220 
221  m_rightZoomOut = new QToolButton();
222  m_rightZoomOut->setIcon(QIcon(FileName("$base/icons/viewmag-.png").
223  expanded()));
224  m_rightZoomOut->setIconSize(isize);
225  m_rightZoomOut->setToolTip("Zoom Out 2x");
226  m_rightZoomOut->setWhatsThis("Zoom Out 2x on right measure.");
227  m_rightZoomOut->setShortcut(Qt::Key_Minus);
228 
229  m_rightZoom1 = new QToolButton();
230  m_rightZoom1->setIcon(QPixmap(toolIconDir + "/viewmag1.png"));
231  m_rightZoom1->setIconSize(isize);
232  m_rightZoom1->setToolTip("Zoom 1:1");
233  m_rightZoom1->setWhatsThis("Show right measure at full resolution.");
234  m_rightZoom1->setShortcut(Qt::Key_Slash);
235 
236  QHBoxLayout *rightZoomPan = new QHBoxLayout;
237  rightZoomPan->addWidget(m_rightZoomIn);
238  rightZoomPan->addWidget(m_rightZoomOut);
239  rightZoomPan->addWidget(m_rightZoom1);
240 
241  // Add arrows for panning
242  QToolButton *rightPanUp = new QToolButton(parent);
243  rightPanUp->setIcon(QIcon(FileName("$base/icons/up.png").
244  expanded()));
245  rightPanUp->setIconSize(isize);
246  rightPanUp->setToolTip("Move up 1 screen pixel");
247  rightPanUp->setWhatsThis("Move the right measure up 1 screen pixel.");
248 
249  QToolButton *rightPanDown = new QToolButton(parent);
250  rightPanDown->setIcon(QIcon(FileName("$base/icons/down.png").
251  expanded()));
252  rightPanDown->setIconSize(isize);
253  rightPanDown->setToolTip("Move down 1 screen pixel");
254  rightPanUp->setWhatsThis("Move the right measure down 1 screen pixel.");
255 
256  QToolButton *rightPanLeft = new QToolButton(parent);
257  rightPanLeft->setIcon(QIcon(FileName("$base/icons/back.png").
258  expanded()));
259  rightPanLeft->setIconSize(isize);
260  rightPanLeft->setToolTip("Move left 1 screen pixel");
261  rightPanLeft->setWhatsThis("Move the right measure to the left by 1 screen"
262  "pixel.");
263 
264  QToolButton *rightPanRight = new QToolButton(parent);
265  rightPanRight->setIcon(QIcon(FileName("$base/icons/forward.png").
266  expanded()));
267  rightPanRight->setIconSize(isize);
268  rightPanRight->setToolTip("Move right 1 screen pixel");
269  rightPanRight->setWhatsThis("Move the right measure to the right by 1"
270  "screen pixel.");
271 
272  rightZoomPan->addWidget(rightPanUp);
273  rightZoomPan->addWidget(rightPanDown);
274  rightZoomPan->addWidget(rightPanLeft);
275  rightZoomPan->addWidget(rightPanRight);
276  rightZoomPan->addStretch();
277 
278  gridLayout->addLayout(rightZoomPan, row++, 1);
279 
280  // Add zoom factor label and stretch locking checkbox
281  m_leftZoomFactor = new QLabel();
282  QCheckBox *leftLockStretch = new QCheckBox("lock stretch");
283  // there are two "lock stretch" checkboxes (left and right)
284  // use same whats this text for both
285  QString whatsThisTextForStretchLocking = "If checked then a new stretch "
286  "will NOT be calculated for each pan or zoom change. Note that stretch"
287  " changes made using the stretch tool will ALWAYS take effect, "
288  "regardless of the state of this checkbox.";
289  leftLockStretch->setWhatsThis(whatsThisTextForStretchLocking);
290  QHBoxLayout *leftzflsLayout = new QHBoxLayout;
291  leftzflsLayout->addWidget(m_leftZoomFactor);
292  leftzflsLayout->addWidget(leftLockStretch);
293  gridLayout->addLayout(leftzflsLayout, row, 0);
294 
295  m_rightZoomFactor = new QLabel();
296  QCheckBox *rightLockStretch = new QCheckBox("lock stretch");
297  rightLockStretch->setWhatsThis(whatsThisTextForStretchLocking);
298  QHBoxLayout *rightzflsLayout = new QHBoxLayout;
299  rightzflsLayout->addWidget(m_rightZoomFactor);
300  rightzflsLayout->addWidget(rightLockStretch);
301  gridLayout->addLayout(rightzflsLayout, row++, 1);
302 
303 
305  // Do not want to accept mouse/keyboard events
306  if ( !m_allowLeftMouse ) m_leftView->setDisabled(true);
307 
308  gridLayout->addWidget(m_leftView, row, 0);
309 
310  connect(this, SIGNAL(newControlNetwork(ControlNet *)),
311  m_leftView, SLOT(setControlNet(ControlNet *)));
312 
313  connect(this,
314  SIGNAL(stretchChipViewport(Stretch *, CubeViewport *)),
315  m_leftView,
316  SLOT(stretchFromCubeViewport(Stretch *, CubeViewport *)));
317 
318  connect(leftLockStretch, SIGNAL(stateChanged(int)),
319  m_leftView,
320  SLOT(changeStretchLock(int)));
321  leftLockStretch->setChecked(false);
322 
323 
324  // Connect left zoom buttons to ChipViewport's zoom slots
325  connect(leftZoomIn, SIGNAL(clicked()), m_leftView, SLOT(zoomIn()));
326  connect(leftZoomOut, SIGNAL(clicked()), m_leftView, SLOT(zoomOut()));
327  connect(leftZoom1, SIGNAL(clicked()), m_leftView, SLOT(zoom1()));
328 
329  // If zoom on left, need to re-geom right
330  connect(leftZoomIn, SIGNAL(clicked()), this, SLOT(updateRightGeom()));
331  connect(leftZoomOut, SIGNAL(clicked()), this, SLOT(updateRightGeom()));
332  connect(leftZoom1, SIGNAL(clicked()), this, SLOT(updateRightGeom()));
333 
334  // Connect the ChipViewport tackPointChanged signal to
335  // the update sample/line label
336  connect(m_leftView, SIGNAL(tackPointChanged(double)),
337  this, SLOT(updateLeftPositionLabel(double)));
338 
339  // we want to allow this connection so that if a changed point is saved
340  // and the same image is showing in both viewports, the left will refresh.
341  connect(this, SIGNAL(updateLeftView(double, double)),
342  m_leftView, SLOT(refreshView(double, double)));
343 
344  connect (m_leftView, SIGNAL(userMovedTackPoint()),
345  this, SLOT(colorizeSaveButton()));
346 
347  if ( m_allowLeftMouse ) {
348  // Connect pan buttons to ChipViewport
349  connect(leftPanUp, SIGNAL(clicked()), m_leftView, SLOT(panUp()));
350  connect(leftPanDown, SIGNAL(clicked()), m_leftView, SLOT(panDown()));
351  connect(leftPanLeft, SIGNAL(clicked()), m_leftView, SLOT(panLeft()));
352  connect(leftPanRight, SIGNAL(clicked()), m_leftView, SLOT(panRight()));
353 
354  connect(leftPanUp, SIGNAL(clicked()), this, SLOT(colorizeSaveButton()));
355  connect(leftPanDown, SIGNAL(clicked()), this, SLOT(colorizeSaveButton()));
356  connect(leftPanLeft, SIGNAL(clicked()), this, SLOT(colorizeSaveButton()));
357  connect(leftPanRight, SIGNAL(clicked()), this, SLOT(colorizeSaveButton()));
358  }
359 
361  gridLayout->addWidget(m_rightView, row, 1);
362 
363  connect(this, SIGNAL(newControlNetwork(ControlNet *)),
364  m_rightView, SLOT(setControlNet(ControlNet *)));
365  connect(this,
366  SIGNAL(stretchChipViewport(Stretch *, CubeViewport *)),
367  m_rightView,
368  SLOT(stretchFromCubeViewport(Stretch *, CubeViewport *)));
369  connect(rightLockStretch, SIGNAL(stateChanged(int)),
370  m_rightView,
371  SLOT(changeStretchLock(int)));
372  rightLockStretch->setChecked(false);
373 
374  // Connect the ChipViewport tackPointChanged signal to
375  // the update sample/line label
376  connect(m_rightView, SIGNAL(tackPointChanged(double)),
377  this, SLOT(updateRightPositionLabel(double)));
378  connect(this, SIGNAL(updateRightView(double, double)),
379  m_rightView, SLOT(refreshView(double, double)));
380 
381  connect (m_rightView, SIGNAL(userMovedTackPoint()),
382  this, SLOT(colorizeSaveButton()));
383 
384  connect(m_rightZoomIn, SIGNAL(clicked()), m_rightView, SLOT(zoomIn()));
385  connect(m_rightZoomOut, SIGNAL(clicked()), m_rightView, SLOT(zoomOut()));
386  connect(m_rightZoom1, SIGNAL(clicked()), m_rightView, SLOT(zoom1()));
387 
388  // Connect pan buttons to ChipViewport
389  connect(rightPanUp, SIGNAL(clicked()), m_rightView, SLOT(panUp()));
390  connect(rightPanDown, SIGNAL(clicked()), m_rightView, SLOT(panDown()));
391  connect(rightPanLeft, SIGNAL(clicked()), m_rightView, SLOT(panLeft()));
392  connect(rightPanRight, SIGNAL(clicked()), m_rightView, SLOT(panRight()));
393 
394  connect(rightPanUp, SIGNAL(clicked()), this, SLOT(colorizeSaveButton()));
395  connect(rightPanDown, SIGNAL(clicked()), this, SLOT(colorizeSaveButton()));
396  connect(rightPanLeft, SIGNAL(clicked()), this, SLOT(colorizeSaveButton()));
397  connect(rightPanRight, SIGNAL(clicked()), this, SLOT(colorizeSaveButton()));
398 
399  // Create chips for left and right
402 
403  QButtonGroup *bgroup = new QButtonGroup();
404  m_nogeom = new QRadioButton();
405  m_nogeom->setChecked(true);
406  connect(m_nogeom, SIGNAL(clicked()), this, SLOT(setNoGeom()));
407 
408  QCheckBox *linkZoom = NULL;
409  if (m_useGeometry) {
410  m_nogeom->setText("No geom/rotate");
411  m_nogeom->setToolTip("Reset right measure to it's native geometry.");
412  m_nogeom->setWhatsThis("Reset right measure to it's native geometry. "
413  "If measure was rotated, set rotation back to 0. "
414  "If measure was geomed to match the left measure, "
415  "reset the geometry back to it's native state.");
416  m_geom = new QRadioButton("Geom");
417  m_geom->setToolTip("Geom right measure to match geometry of left measure.");
418  m_geom->setWhatsThis("Using an affine transform, geom the right measure to match the "
419  "geometry of the left measure.");
420  bgroup->addButton(m_geom);
421  connect(m_geom, SIGNAL(clicked()), this, SLOT(setGeom()));
422  }
423  else {
424  linkZoom = new QCheckBox("Link Zoom");
425  linkZoom->setToolTip("Link zooming between the left and right views.");
426  linkZoom->setWhatsThis("When zooming in the left view, the right view will "
427  "be set to the same zoom factor as the left view.");
428  connect(linkZoom, SIGNAL(toggled(bool)), this, SLOT(setZoomLink(bool)));
429 
430  m_nogeom->setText("No rotate");
431  m_nogeom->setToolTip("Reset right measure to it's native geometry.");
432  m_nogeom->setWhatsThis("Reset right measure to it's native geometry. "
433  "If measure was rotated, set rotation back to 0.");
434  }
435  bgroup->addButton(m_nogeom);
436 
437  QRadioButton *rotate = new QRadioButton("Rotate");
438  bgroup->addButton(rotate);
439  // TODO: ?? Don't think we need this connection
440  connect(rotate, SIGNAL(clicked()), this, SLOT(setRotate()));
441 
442  // Set some defaults
443  m_geomIt = false;
444  m_rotation = 0;
445  m_linkZoom = false;
446 
447  m_dial = new QDial();
448  m_dial->setRange(0, 360);
449  m_dial->setWrapping(false);
450  m_dial->setNotchesVisible(true);
451  m_dial->setNotchTarget(5.);
452  m_dial->setEnabled(false);
453  m_dial->setToolTip("Rotate right measure");
454  m_dial->setWhatsThis("Rotate the right measure by degrees.");
455 
456  m_dialNumber = new QLCDNumber();
457  m_dialNumber->setEnabled(false);
458  m_dialNumber->setToolTip("Rotate right measure");
459  m_dialNumber->setWhatsThis("Rotate the right measure by given number"
460  " of degrees.");
461  connect(m_dial, SIGNAL(valueChanged(int)), m_dialNumber, SLOT(display(int)));
462  connect(m_dial, SIGNAL(valueChanged(int)), m_rightView, SLOT(rotateChip(int)));
463 
464  QCheckBox *showPoints = new QCheckBox("Show control points");
465  showPoints->setToolTip("Draw control point crosshairs");
466  showPoints->setWhatsThis("This will toggle whether crosshairs are drawn"
467  " for the control points located within the measure''s"
468  " view. For areas of dense measurements, turning this"
469  " off will allow easier viewing of features.");
470  connect(showPoints, SIGNAL(toggled(bool)), m_leftView, SLOT(setPoints(bool)));
471  connect(showPoints, SIGNAL(toggled(bool)), m_rightView, SLOT(setPoints(bool)));
472  showPoints->setChecked(true);
473 
474  QCheckBox *cross = new QCheckBox("Show crosshair");
475  connect(cross, SIGNAL(toggled(bool)), m_leftView, SLOT(setCross(bool)));
476  connect(cross, SIGNAL(toggled(bool)), m_rightView, SLOT(setCross(bool)));
477  cross->setChecked(true);
478  cross->setToolTip("Show the red crosshair across measure view");
479  cross->setWhatsThis("This will toggle whether the crosshair across the"
480  " measure view will be shown");
481 
482  QCheckBox *circle = new QCheckBox("Circle");
483  circle->setChecked(false);
484  circle->setToolTip("Draw circle");
485  circle->setWhatsThis("Draw circle on measure view. This can aid in"
486  " centering a crater under the crosshair.");
487  connect(circle, SIGNAL(toggled(bool)), this, SLOT(setCircle(bool)));
488 
489  m_slider = new QScrollBar(Qt::Horizontal);
490  m_slider->setRange(1, 100);
491  m_slider->setSingleStep(1);
492  connect(m_slider, SIGNAL(valueChanged(int)), m_leftView, SLOT(setCircleSize(int)));
493  connect(m_slider, SIGNAL(valueChanged(int)), m_rightView, SLOT(setCircleSize(int)));
494  m_slider->setValue(20);
495  m_slider->setDisabled(true);
496  m_slider->hide();
497  m_slider->setToolTip("Adjust circle size");
498  m_slider->setWhatsThis("This allows the cirle size to be adjusted.");
499 
500  QVBoxLayout *vlayout = new QVBoxLayout();
501  if (!m_useGeometry) {
502  vlayout->addWidget(linkZoom);
503  }
504  vlayout->addWidget(m_nogeom);
505  if (m_useGeometry) {
506  vlayout->addWidget(m_geom);
507  }
508  vlayout->addWidget(rotate);
509  vlayout->addWidget(m_dial);
510  vlayout->addWidget(m_dialNumber);
511  vlayout->addWidget(showPoints);
512  vlayout->addWidget(cross);
513  vlayout->addWidget(circle);
514  vlayout->addWidget(m_slider);
515  gridLayout->addLayout(vlayout, row++, 2);
516 
517  // Add auto registration extension
519  m_oldPosition = new QLabel;
520  m_oldPosition->setToolTip("Measure Sample/Line before sub-pixel "
521  "registration");
522  m_oldPosition->setWhatsThis("Original Sample/Line of the right measure "
523  "before the sub-pixel registration. If you select the \"Undo\" "
524  "button, the measure will revert back to this Sample/Line.");
525  m_goodFit = new QLabel;
526  m_goodFit->setToolTip("Goodness of Fit result from sub-pixel registration.");
527  m_goodFit->setWhatsThis("Resulting Goodness of Fit from sub-pixel "
528  "registration.");
529  QVBoxLayout *autoRegLayout = new QVBoxLayout;
530  autoRegLayout->setMargin(0);
531  autoRegLayout->addWidget(m_oldPosition);
532  autoRegLayout->addWidget(m_goodFit);
533  m_autoRegExtension->setLayout(autoRegLayout);
534  m_autoRegShown = false;
535  m_autoRegAttempted = false;
536  gridLayout->addWidget(m_autoRegExtension, row++, 1);
537 
538 
539  QHBoxLayout *leftLayout = new QHBoxLayout();
540  QToolButton *stop = new QToolButton();
541  stop->setIcon(QPixmap(toolIconDir + "/blinkStop.png"));
542  stop->setIconSize(QSize(22, 22));
543  stop->setToolTip("Blink Stop");
544  QString text = "<b>Function:</b> Stop automatic timed blinking";
545  stop->setWhatsThis(text);
546  connect(stop, SIGNAL(released()), this, SLOT(blinkStop()));
547 
548  QToolButton *start = new QToolButton();
549  start->setIcon(QPixmap(toolIconDir + "/blinkStart.png"));
550  start->setIconSize(QSize(22, 22));
551  start->setToolTip("Blink Start");
552  text = "<b>Function:</b> Start automatic timed blinking. Cycles \
553  through linked viewports at variable rate";
554  start->setWhatsThis(text);
555  connect(start, SIGNAL(released()), this, SLOT(blinkStart()));
556 
557  m_blinkTimeBox = new QDoubleSpinBox();
558  m_blinkTimeBox->setMinimum(0.1);
559  m_blinkTimeBox->setMaximum(5.0);
560  m_blinkTimeBox->setDecimals(1);
561  m_blinkTimeBox->setSingleStep(0.1);
562  m_blinkTimeBox->setValue(0.5);
563  m_blinkTimeBox->setToolTip("Blink Time Delay");
564  text = "<b>Function:</b> Change automatic blink rate between " +
565  QString::number(m_blinkTimeBox->minimum()) + " and " +
566  QString::number(m_blinkTimeBox->maximum()) + " seconds";
567  m_blinkTimeBox->setWhatsThis(text);
568  connect(m_blinkTimeBox, SIGNAL(valueChanged(double)),
569  this, SLOT(changeBlinkTime(double)));
570 
571  leftLayout->addWidget(stop);
572  leftLayout->addWidget(start);
573  leftLayout->addWidget(m_blinkTimeBox);
574 
575  if (m_useGeometry) {
576  QPushButton *find = new QPushButton("Find");
577  find->setToolTip("Move right measure to same Latitude/Longitude as left.");
578  find->setWhatsThis("Find the Latitude/Longitude under the crosshair in the "
579  "left measure and move the right measure to the same "
580  "latitude/longitude.");
581  leftLayout->addWidget(find);
582  connect(find, SIGNAL(clicked()), this, SLOT(findPoint()));
583  }
584 
585  leftLayout->addStretch();
586  gridLayout->addLayout(leftLayout, row, 0);
587 
588  QHBoxLayout *rightLayout = new QHBoxLayout();
589  m_autoReg = new QPushButton("Register");
590  m_autoReg->setToolTip("Sub-pixel register the right measure to the left");
591  m_autoReg->setWhatsThis("Sub-pixel register the right measure to the left "
592  "and move the result under the crosshair. After "
593  "viewing the results, the option exists to move the "
594  "measure back to the original position by selecting "
595  "<strong>\"Undo Registration\"</strong>.");
596  if (m_allowLeftMouse) {
597  m_saveMeasure = new QPushButton("Save Measures");
598  m_saveMeasure->setToolTip("Save the both the left and right measure to the edit control "
599  "point (control point currently being edited). "
600  " <strong>Note: The edit control point "
601  "will not be saved to the network until you select "
602  "<strong>\"Save Point\"</strong>");
603  }
604  else {
605  m_saveMeasure = new QPushButton("Save Measure");
606  m_saveMeasure->setToolTip("Save the right measure to the edit control "
607  "point (control point currently being edited). "
608  " <strong>Note: The edit control point "
609  "will not be saved to the network until you select "
610  "<strong>\"Save Point\"</strong>");
611  }
612  m_saveDefaultPalette = m_saveMeasure->palette();
613 
614  m_blinkExtension = new QWidget;
615 
616  QPushButton *blinkButton = new QPushButton("Blink");
617  blinkButton->setCheckable(true);
618  connect(blinkButton, &QAbstractButton::toggled, m_blinkExtension, &QWidget::setVisible);
619  connect(blinkButton, SIGNAL(clicked()), this, SLOT(showBlinkExtension()));
620 
621  QHBoxLayout *rightBlinkLayout = new QHBoxLayout();
622  QToolButton *stopRight = new QToolButton();
623  stopRight->setIcon(QPixmap(toolIconDir + "/blinkStop.png"));
624  stopRight->setIconSize(QSize(22, 22));
625  stopRight->setToolTip("Blink Stop");
626  text = "<b>Function:</b> Stop automatic timed blinking";
627  stopRight->setWhatsThis(text);
628  connect(stopRight, SIGNAL(released()), this, SLOT(blinkStopRight()));
629 
630  QToolButton *startRight = new QToolButton();
631  startRight->setIcon(QPixmap(toolIconDir + "/blinkStart.png"));
632  startRight->setIconSize(QSize(22, 22));
633  startRight->setToolTip("Blink Start");
634  text = "<b>Function:</b> Start automatic timed blinking. Cycles \
635  through linked viewports at variable rate";
636  startRight->setWhatsThis(text);
637  connect(startRight, SIGNAL(released()), this, SLOT(blinkStartRight()));
638 
639  m_blinkTimeBoxRight = new QDoubleSpinBox();
640  m_blinkTimeBoxRight->setMinimum(0.1);
641  m_blinkTimeBoxRight->setMaximum(5.0);
642  m_blinkTimeBoxRight->setDecimals(1);
643  m_blinkTimeBoxRight->setSingleStep(0.1);
644  m_blinkTimeBoxRight->setValue(0.5);
645  m_blinkTimeBoxRight->setToolTip("Blink Time Delay");
646  text = "<b>Function:</b> Change automatic blink rate between " +
647  QString::number(m_blinkTimeBox->minimum()) + " and " +
648  QString::number(m_blinkTimeBox->maximum()) + " seconds";
649  m_blinkTimeBoxRight->setWhatsThis(text);
650  connect(m_blinkTimeBoxRight, SIGNAL(valueChanged(double)),
651  this, SLOT(changeBlinkTimeRight(double)));
652 
653  rightBlinkLayout->addWidget(stopRight);
654  rightBlinkLayout->addWidget(startRight);
655  rightBlinkLayout->addWidget(m_blinkTimeBoxRight);
656 
657  m_blinkListWidget = new QListWidget(m_blinkExtension);
658  m_blinkListWidget->setMinimumHeight(100);
659  m_blinkListWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);
660  m_blinkListWidget->setDragEnabled(true);
661  m_blinkListWidget->setAcceptDrops(true);
662  m_blinkListWidget->setDropIndicatorShown(true);
663  m_blinkListWidget->setDragDropMode(QAbstractItemView::InternalMove);
664 // connect(m_blinkListWidget, SIGNAL(itemActivated(QListWidgetItem *)),
665 // this, SLOT(toggleBlink(QListWidgetItem *)));
666 // connect(m_blinkListWidget, SIGNAL(currentRowChanged(int)),
667 // this, SLOT(updateWindow()));
668 
669  rightBlinkLayout->addWidget(m_blinkListWidget);
670 
671  m_blinkExtension->setLayout(rightBlinkLayout);
672 
673 
674 
675 
676 
677 
678  rightLayout->addWidget(m_autoReg);
679  rightLayout->addWidget(m_saveMeasure);
680  rightLayout->addWidget(blinkButton);
681  rightLayout->addStretch();
682  gridLayout->addLayout(rightLayout, row++, 1);
683  gridLayout->addWidget(m_blinkExtension, row, 1);
684  connect(m_autoReg, SIGNAL(clicked()), this, SLOT(registerPoint()));
685  connect(m_saveMeasure, SIGNAL(clicked()), this, SLOT(saveMeasure()));
686 
687  setLayout(gridLayout);
688 
689  //m_pointEditor->setCentralWidget(cw);
690  m_autoRegExtension->hide();
691  m_blinkExtension->hide();
692 
693  //m_pointEditor->setVisible(true);
694  //m_pointEditor->raise();
695  }
696 
697 
721  Cube *leftCube, QString pointId) {
722 
723  // Make sure registration is turned off
724  if ( m_autoRegShown ) {
725  // Undo Registration
726  m_autoRegShown = false;
727  m_autoRegExtension->hide();
728  m_autoReg->setText("Register");
729  }
730 
731  m_leftMeasure = leftMeasure;
732 
733  if (m_useGeometry) {
734  // get new ground map
735  if ( m_leftGroundMap != 0 ) delete m_leftGroundMap;
736  m_leftGroundMap = new UniversalGroundMap(*leftCube);
737  }
738  m_leftCube = leftCube;
739 
740  m_leftChip->TackCube(m_leftMeasure->GetSample(), m_leftMeasure->GetLine());
742 
743  // Dump into left chipViewport
745 
746  // Only update right if not loading a new point. If it's a new point, right measure
747  // hasn't been loaded yet.
748  if (pointId == m_pointId && m_geomIt) updateRightGeom();
749  m_pointId = pointId;
750  }
751 
752 
780  Cube *rightCube, QString pointId) {
781 
782  // Make sure registration is turned off
783  if ( m_autoRegShown ) {
784  // Undo Registration
785  m_autoRegShown = false;
786  m_autoRegExtension->hide();
787  m_autoReg->setText("Register");
788  }
789  m_autoRegAttempted = false;
790 
791  m_rightMeasure = rightMeasure;
792  m_pointId = pointId;
793 
794  if (m_useGeometry) {
795  // get new ground map
796  if ( m_rightGroundMap != 0 ) delete m_rightGroundMap;
797  m_rightGroundMap = new UniversalGroundMap(*rightCube);
798  }
799  m_rightCube = rightCube;
800 
801  m_rightChip->TackCube(m_rightMeasure->GetSample(),
802  m_rightMeasure->GetLine());
803  if ( m_geomIt == false ) {
805  }
806  else {
807  try {
809 
810  }
811  catch (IException &e) {
812  IException fullError(e, IException::User, "Geom failed.", _FILEINFO_);
813  QString message = fullError.toString();
814  QMessageBox::information((QWidget *)parent(), "Error", message);
816  m_geomIt = false;
817  m_nogeom->setChecked(true);
818  m_geom->setChecked(false);
819  }
820  }
821 
822  // Dump into left chipViewport
824 
825  updateRightGeom();
826  //m_rightView->geomChip(m_leftChip,m_leftCube);
827 
828  // New right measure, make sure Save Measure Button text is default
829  m_saveMeasure->setPalette(m_saveDefaultPalette);
830 
831  }
832 
833 
847 
848  // Print zoom scale factor
849  QString pos = "Zoom Factor: " + QString::number(zoomFactor);
850  m_leftZoomFactor->setText(pos);
851 
852  // If zooms are linked, make right match left
853  if (m_linkZoom) {
855  }
856  }
857 
858 
867 
868  // If registration Info is on, turn off
869  if ( m_autoRegShown ) {
870  // Undo Registration
871  m_autoRegShown = false;
872  m_autoRegExtension->hide();
873  m_autoReg->setText("Register");
874  }
875 
876  // Print zoom scale factor
877  QString pos = "Zoom Factor: " + QString::number(zoomFactor);
878  m_rightZoomFactor->setText(pos);
879 
880  }
881 
882 
889 
890  QColor qc = Qt::red;
891  QPalette p = m_saveMeasure->palette();
892  p.setColor(QPalette::ButtonText,qc);
893  m_saveMeasure->setPalette(p);
894 
895  }
896 
897 
908 
909  // Get lat/lon from point in left
911  double lat = m_leftGroundMap->UniversalLatitude();
912  double lon = m_leftGroundMap->UniversalLongitude();
913 
914  // Reload right chipViewport with this new tack point.
915  if ( m_rightGroundMap->SetUniversalGround(lat, lon) ) {
916  emit updateRightView(m_rightGroundMap->Sample(), m_rightGroundMap->Line());
917 
918  // If moving from saved measure, turn save button to red
919  if (m_rightGroundMap->Sample() != m_rightMeasure->GetSample() ||
920  m_rightGroundMap->Line() != m_rightMeasure->GetLine())
922  }
923  else {
924  QString message = "Latitude: " + QString::number(lat) + " Longitude: " +
925  QString::number(lon) + " is not on the right image. Right measure " +
926  "was not moved.";
927  QMessageBox::warning((QWidget *)parent(),"Warning",message);
928  }
929 
930  }
931 
932 
962 
963  if ( m_autoRegShown ) {
964  // Undo Registration
965  m_autoRegShown = false;
966  m_autoRegExtension->hide();
967  m_autoReg->setText("Register");
968 
969  // Reload chip with original measure
970  emit updateRightView(m_rightMeasure->GetSample(),
971  m_rightMeasure->GetLine());
972  // Since un-doing registration, make sure save button not red
973  m_saveMeasure->setPalette(m_saveDefaultPalette);
974  return;
975 
976  }
977  m_autoRegAttempted = true;
978 
979  try {
981  m_leftMeasure->GetSample(), m_leftMeasure->GetLine());
984  m_rightMeasure->GetSample(),
985  m_rightMeasure->GetLine());
986  if (m_useGeometry) {
989  }
990  else {
992  }
993  }
994  catch (IException &e) {
995  QString msg = "Cannot register this point, unable to Load chips.\n";
996  msg += e.toString();
997  QMessageBox::information((QWidget *)parent(), "Error", msg);
998  return;
999  }
1000 
1001  try {
1003  if ( !m_autoRegFact->Success() ) {
1004  QString msg = "Cannot sub-pixel register this point.\n";
1005  if ( status == AutoReg::PatternChipNotEnoughValidData ) {
1006  msg += "\n\nNot enough valid data in Pattern Chip.\n";
1007  msg += " PatternValidPercent = ";
1008  msg += QString::number(m_autoRegFact->PatternValidPercent()) + "%";
1009  }
1010  else if ( status == AutoReg::FitChipNoData ) {
1011  msg += "\n\nNo valid data in Fit Chip.";
1012  }
1013  else if ( status == AutoReg::FitChipToleranceNotMet ) {
1014  msg += "\n\nGoodness of Fit Tolerance not met.\n";
1015  msg += "\nGoodnessOfFit = " + QString::number(m_autoRegFact->GoodnessOfFit());
1016  msg += "\nGoodnessOfFitTolerance = ";
1017  msg += QString::number(m_autoRegFact->Tolerance());
1018  }
1019  else if ( status == AutoReg::SurfaceModelNotEnoughValidData ) {
1020  msg += "\n\nNot enough valid points in the fit chip window for sub-pixel ";
1021  msg += "accuracy. Probably too close to edge.\n";
1022  }
1023  else if ( status == AutoReg::SurfaceModelSolutionInvalid ) {
1024  msg += "\n\nCould not model surface for sub-pixel accuracy.\n";
1025  }
1026  else if ( status == AutoReg::SurfaceModelDistanceInvalid ) {
1027  double sampDist, lineDist;
1028  m_autoRegFact->Distance(sampDist, lineDist);
1029  msg += "\n\nSub pixel algorithm moves registration more than tolerance.\n";
1030  msg += "\nSampleMovement = " + QString::number(sampDist) +
1031  " LineMovement = " + QString::number(lineDist);
1032  msg += "\nDistanceTolerance = " +
1033  QString::number(m_autoRegFact->DistanceTolerance());
1034  }
1035  else if ( status == AutoReg::PatternZScoreNotMet ) {
1036  double score1, score2;
1037  m_autoRegFact->ZScores(score1, score2);
1038  msg += "\n\nPattern data max or min does not pass z-score test.\n";
1039  msg += "\nMinimumZScore = " + QString::number(m_autoRegFact->MinimumZScore());
1040  msg += "\nCalculatedZscores = " + QString::number(score1) + ", " + QString::number(score2);
1041  }
1042  else if ( status == AutoReg::AdaptiveAlgorithmFailed ) {
1043  msg += "\n\nError occured in Adaptive algorithm.";
1044  }
1045  else {
1046  msg += "\n\nUnknown registration error.";
1047  }
1048 
1049  QMessageBox::information((QWidget *)parent(), "Error", msg);
1050  return;
1051  }
1052  }
1053  catch (IException &e) {
1054  QString msg = "Cannot register this point.\n";
1055  msg += e.toString();
1056  QMessageBox::information((QWidget *)parent(), "Error", msg);
1057  return;
1058  }
1059 
1060 
1061 
1062  // Load chip with new registered point
1063  emit updateRightView(m_autoRegFact->CubeSample(), m_autoRegFact->CubeLine());
1064  // If registered pt different from measure, colorize the save button
1065  if (m_autoRegFact->CubeSample() != m_rightMeasure->GetSample() ||
1066  m_autoRegFact->CubeLine() != m_rightMeasure->GetLine()) {
1068  }
1069 
1070  QString oldPos = "Original Sample: " +
1071  QString::number(m_rightMeasure->GetSample()) + " Original Line: " +
1072  QString::number(m_rightMeasure->GetLine());
1073  m_oldPosition->setText(oldPos);
1074 
1075  QString goodFit = "Goodness of Fit: " +
1076  QString::number(m_autoRegFact->GoodnessOfFit());
1077  m_goodFit->setText(goodFit);
1078 
1079  m_autoRegExtension->show();
1080  m_autoRegShown = true;
1081  m_autoReg->setText("Undo Registration");
1082  }
1083 
1084 
1118 
1119  if ( m_rightMeasure != NULL ) {
1120 
1121  if (m_rightMeasure->IsEditLocked()) {
1122  QString message = "The right measure is locked. You must first unlock the measure by ";
1123  message += "clicking the check box above labeled \"Edit Lock Measure\".";
1124  QMessageBox::warning((QWidget *)parent(),"Warning",message);
1125  return;
1126  }
1127 
1128  if ( m_autoRegShown ) {
1129  // Reset AprioriSample/Line to the current coordinate, before the
1130  // coordinate is updated with the registered coordinate.
1131  m_rightMeasure->SetAprioriSample(m_rightMeasure->GetSample());
1132  m_rightMeasure->SetAprioriLine(m_rightMeasure->GetLine());
1133 
1134  m_rightMeasure->SetChooserName("Application qnet");
1136  // Save autoreg parameters to the right measure log entry
1137  // Eccentricity may be invalid, check before writing.
1141  double minZScore, maxZScore;
1142  m_autoRegFact->ZScores(minZScore,maxZScore);
1145  minZScore));
1148  maxZScore));
1149 
1150  m_autoRegShown = false;
1151  m_autoRegExtension->hide();
1152  m_autoReg->setText("Register");
1153  }
1154  else {
1163  }
1164 
1165  // Get cube position at right chipViewport crosshair
1167  m_rightView->tackLine());
1169 
1170  }
1171 
1172  if ( m_allowLeftMouse ) {
1173  if ( m_leftMeasure != NULL ) {
1174  if (m_leftMeasure->IsEditLocked()) {
1175  QString message = "The left measure is locked. You must first unlock the measure by ";
1176  message += "clicking the check box above labeled \"Edit Lock Measure\".";
1177  QMessageBox::warning((QWidget *)parent(),"Warning",message);
1178  return;
1179  }
1180 
1185  }
1186  }
1187 
1188  // If the right chip is the same as the left chip, copy right into left and
1189  // re-load the left.
1192 
1195  }
1196 
1197  // Change Save Measure button text back to default palette
1198  m_saveMeasure->setPalette(m_saveDefaultPalette);
1199 
1200  // Redraw measures on viewports
1201  emit measureSaved();
1202  }
1203 
1204 
1214 
1215  if ( m_geomIt ) {
1216  try {
1218 
1219  }
1220  catch (IException &e) {
1221  IException fullError(e, IException::User, "Geom failed.", _FILEINFO_);
1222  QString message = fullError.toString();
1223  QMessageBox::information((QWidget *)parent(), "Error", message);
1224  m_geomIt = false;
1225  m_nogeom->setChecked(true);
1226  m_geom->setChecked(false);
1227  }
1228  }
1229  }
1230 
1231 
1232 
1234 // * Slot to update the right ChipViewport for zoom
1235 // * operations
1236 // *
1237 // * @author 2012-07-26 Tracie Sucharski
1238 // *
1239 // * @internal
1240 // */
1241 //void ControlMeasureEditWidget::updateRightZoom() {
1242 //
1243 // if ( m_linkZoom ) {
1244 // try {
1245 // m_rightView->geomChip(m_leftChip, m_leftCube);
1246 //
1247 // }
1248 // catch (IException &e) {
1249 // IException fullError(e, IException::User, "Geom failed.", _FILEINFO_);
1250 // QString message = fullError.toString();
1251 // QMessageBox::information((QWidget *)parent(), "Error", message);
1252 // m_geomIt = false;
1253 // m_nogeom->setChecked(true);
1254 // m_geom->setChecked(false);
1255 // }
1256 // }
1257 //}
1258 
1259 
1267  QApplication::setOverrideCursor(Qt::WaitCursor);
1268 
1269  // Text needs to be reset because it was changed to
1270  // indicate why it's greyed out
1271  QString text = "Zoom in 2X";
1272  m_rightZoomIn->setEnabled(true);
1273  m_rightZoomIn->setWhatsThis(text);
1274  m_rightZoomIn->setToolTip("Zoom In");
1275  text = "Zoom out 2X";
1276  m_rightZoomOut->setEnabled(true);
1277  m_rightZoomOut->setWhatsThis(text);
1278  m_rightZoomOut->setToolTip("Zoom Out");
1279  text = "Zoom 1:1";
1280  m_rightZoom1->setEnabled(true);
1281  m_rightZoom1->setWhatsThis(text);
1282  m_rightZoom1->setToolTip("Zoom 1:1");
1283 
1284  m_geomIt = false;
1286 
1287  QApplication::restoreOverrideCursor();
1288 
1289  m_dial->setEnabled(true);
1290  m_dialNumber->setEnabled(true);
1291  m_dial->setNotchesVisible(true);
1292 
1293  }
1294 
1295 
1306 
1307  if ( m_geomIt == true ) return;
1308 
1309  QApplication::setOverrideCursor(Qt::WaitCursor);
1310 
1311  // Grey right view zoom buttons
1312  QString text = "Zoom functions disabled when Geom is set";
1313  m_rightZoomIn->setEnabled(false);
1314  m_rightZoomIn->setWhatsThis(text);
1315  m_rightZoomIn->setToolTip(text);
1316  m_rightZoomOut->setEnabled(false);
1317  m_rightZoomOut->setWhatsThis(text);
1318  m_rightZoomOut->setToolTip(text);
1319  m_rightZoom1->setEnabled(false);
1320  m_rightZoom1->setWhatsThis(text);
1321  m_rightZoom1->setToolTip(text);
1322 
1323 
1324  // Reset dial to 0 before disabling
1325  m_dial->setValue(0);
1326  m_dial->setEnabled(false);
1327  m_dialNumber->setEnabled(false);
1328 
1329  m_geomIt = true;
1330 
1331  try {
1333 
1334  }
1335  catch (IException &e) {
1336  IException fullError(e, IException::User, "Geom failed.", _FILEINFO_);
1337  QString message = fullError.toString();
1338  QMessageBox::information((QWidget *)parent(), "Error", message);
1339  m_geomIt = false;
1340  m_nogeom->setChecked(true);
1341  m_geom->setChecked(false);
1342  }
1343 
1344  QApplication::restoreOverrideCursor();
1345  }
1346 
1347 
1355 
1356  QApplication::setOverrideCursor(Qt::WaitCursor);
1357 
1358  QString text = "Zoom in 2X";
1359  m_rightZoomIn->setEnabled(true);
1360  m_rightZoomIn->setWhatsThis(text);
1361  m_rightZoomIn->setToolTip("Zoom In");
1362  text = "Zoom out 2X";
1363  m_rightZoomOut->setEnabled(true);
1364  m_rightZoomOut->setWhatsThis(text);
1365  m_rightZoomOut->setToolTip("Zoom Out");
1366  text = "Zoom 1:1";
1367  m_rightZoom1->setEnabled(true);
1368  m_rightZoom1->setWhatsThis(text);
1369  m_rightZoom1->setToolTip("Zoom 1:1");
1370 
1371  // Reset dial to 0 before disabling
1372  m_dial->setValue(0);
1373  m_dial->setEnabled(false);
1374  m_dialNumber->setEnabled(false);
1375 
1376  m_geomIt = false;
1378 
1379  QApplication::restoreOverrideCursor();
1380  }
1381 
1382 
1391 
1392  if ( checked == m_circle ) return;
1393 
1394  m_circle = checked;
1395  if ( m_circle ) {
1396  // Turn on slider bar
1397  m_slider->setDisabled(false);
1398  m_slider->show();
1399  m_slider->setValue(20);
1400  m_leftView->setCircle(true);
1401  m_rightView->setCircle(true);
1402  }
1403  else {
1404  m_slider->setDisabled(true);
1405  m_slider->hide();
1406  m_leftView->setCircle(false);
1407  m_rightView->setCircle(false);
1408  }
1409  }
1410 
1411 
1420 
1421  if ( checked == m_linkZoom ) return;
1422 
1423  m_linkZoom = checked;
1424  if ( m_linkZoom ) {
1426  }
1427  }
1428 
1429 
1434  if ( m_timerOn ) return;
1435 
1436  // Set up blink list
1437  m_blinkList.push_back(m_leftView);
1438  m_blinkList.push_back(m_rightView);
1439  m_blinkIndex = 0;
1440 
1441  m_timerOn = true;
1442  int msec = (int)(m_blinkTimeBox->value() * 1000.0);
1443  m_timer = new QTimer(this);
1444  connect(m_timer, SIGNAL(timeout()), this, SLOT(updateBlink()));
1445  m_timer->start(msec);
1446  }
1447 
1448 
1453  m_timer->stop();
1454  m_timerOn = false;
1455  m_blinkList.clear();
1456 
1457  // Reload left chipViewport with original chip
1458  m_leftView->repaint();
1459 
1460  }
1461 
1462 
1470  if ( m_timerOn ) m_timer->setInterval((int)(interval * 1000.));
1471  }
1472 
1473 
1478 
1481  }
1482 
1483 
1503 
1504  AutoReg *reg = NULL;
1505  // save original template filename
1506  QString temp = m_templateFileName;
1507  try {
1508  // set template filename to user chosen pvl file
1509  m_templateFileName = fn;
1510 
1511  // Create PVL object with this file
1512  Pvl pvl(fn);
1513 
1514  // try to register file
1515  reg = AutoRegFactory::Create(pvl);
1516  if ( m_autoRegFact != NULL )
1517  delete m_autoRegFact;
1518  m_autoRegFact = reg;
1519 
1520  m_templateFileName = fn;
1521  return true;
1522  }
1523  catch (IException &e) {
1524  // set templateFileName back to its original value
1525  m_templateFileName = temp;
1526  IException fullError(e, IException::Io,
1527  "Cannot create AutoRegFactory for " +
1528  fn +
1529  ". As a result, current template file will remain set to " +
1531  QString message = fullError.toString();
1532  QMessageBox::information((QWidget *)parent(), "Error", message);
1533  return false;
1534  }
1535  }
1536 
1537 
1546  m_allowLeftMouse = allowMouse;
1547 
1548  if (m_allowLeftMouse) {
1549  m_saveMeasure = new QPushButton("Save Measures");
1550  m_saveMeasure->setToolTip("Save the both the left and right measure to the edit control "
1551  "point (control point currently being edited). "
1552  " <strong>Note: The edit control point "
1553  "will not be saved to the network until you select "
1554  "<strong>\"Save Point\"</strong>");
1555  }
1556  else {
1557  m_saveMeasure = new QPushButton("Save Measure");
1558  m_saveMeasure->setToolTip("Save the right measure to the edit control "
1559  "point (control point currently being edited). "
1560  " <strong>Note: The edit control point "
1561  "will not be saved to the network until you select "
1562  "<strong>\"Save Point\"</strong>");
1563  }
1564  }
1565 
1566 
1567  void ControlMeasureEditWidget::refreshChips() {
1568  m_leftView->update();
1569  m_rightView->update();
1570  }
1571 
1572 
1583 
1584 // if (!m_autoRegShown) {
1585  if ( !m_autoRegAttempted ) {
1586  QString message = "Point must be Registered before chips can be saved.";
1587  QMessageBox::warning((QWidget *)parent(), "Warning", message);
1588  return;
1589  }
1590 
1591  // Save chips - pattern, search and fit
1592  QString baseFile = m_pointId.replace(" ", "_") + "_" +
1593  toString((int)(m_leftMeasure ->GetSample())) + "_" +
1594  toString((int)(m_leftMeasure ->GetLine())) + "_" +
1595  toString((int)(m_rightMeasure->GetSample())) + "_" +
1596  toString((int)(m_rightMeasure->GetLine())) + "_";
1597  QString fname = baseFile + "Search.cub";
1598  QString command = "$ISISROOT/bin/qview \'" + fname + "\'";
1600  fname = baseFile + "Pattern.cub";
1601  command += " \'" + fname + "\'";
1603  fname = baseFile + "Fit.cub";
1604  command += " \'" + fname + "\' &";
1605  m_autoRegFact->FitChip()->Write(fname);
1607  }
1608 
1609 
1610 
1611 
1612 
1613 
1614 
1615 // TODO IPCE 2016-06-13 ALL CODE BELOW HERE IS TEMPORARY PROTOTYPE CODE NEEDS MUCH CLEANUP, LEAKY MEMORY, ETC
1616 
1617 
1618 
1619 
1620  void ControlMeasureEditWidget::setPoint(ControlPoint *editPoint, SerialNumberList *snList) {
1621 
1622  m_editPoint = editPoint;
1623  m_serialNumberList = snList;
1624 
1625 
1626  m_blinkListWidget->clear();
1627  }
1628 
1629 
1630  void ControlMeasureEditWidget::showBlinkExtension() {
1631  m_blinkListWidget->clear();
1632  // Get all measure filenames for ListWidget
1633  for (int i=0; i<m_editPoint->GetNumMeasures(); i++) {
1634  ControlMeasure &m = *(*m_editPoint)[i];
1635  QString file = m_serialNumberList->fileName(m.GetCubeSerialNumber());
1636  // TODO Ipce TLS Look at QnetNavTool for how selectedItems is used so don't need map
1637  // between full cubename and base name.
1638 // QString tempFileName = FileName(file).name();
1639  m_blinkListWidget->addItem(file);
1640 
1641 
1642 
1643 // if (m_editPoint->IsReferenceExplicit() &&
1644 // (QString)m.GetCubeSerialNumber() == m_editPoint->GetReferenceSN()) {
1645 // m_blinkListWidget->setItemData(i,QFont("DejaVu Sans", 12, QFont::Bold), Qt::FontRole);
1646 // }
1647  }
1648  }
1649 
1650 
1653 
1654  if ( m_timerOnRight ) return;
1655 
1656  // Set up blink list. Create ChipViewport for each cube active in the ListWidget
1657  QList<QListWidgetItem *> selected = m_blinkListWidget->selectedItems();
1658  if (selected.size() < 1) {
1659  QMessageBox::information((QWidget *)parent(), "Error", "No files selected for blinking.");
1660  return;
1661  }
1662 
1663  // Find measure for each selected file, create cube, chip and chipViewport
1664  for (int i=0; i<selected.size(); i++) {
1665  QString file = selected.at(i)->text();
1666  QString serial = m_serialNumberList->serialNumber(file);
1667  Cube *blinkCube = new Cube(selected.at(i)->text());
1668  Chip *blinkChip = new Chip(VIEWSIZE, VIEWSIZE);
1669  ControlMeasure *blinkMeasure = m_editPoint->GetMeasure(serial);
1670  blinkChip->TackCube(blinkMeasure->GetSample(), blinkMeasure->GetLine());
1671  blinkChip->Load(*blinkCube);
1672  ChipViewport *blinkViewport = new ChipViewport(VIEWSIZE, VIEWSIZE, this);
1673  blinkViewport->setChip(blinkChip, blinkCube);
1674  m_blinkChipViewportListRight.append(blinkViewport);
1675  }
1676 
1677  m_blinkIndexRight = 0;
1678 
1679  m_timerOnRight = true;
1680  int msec = (int)(m_blinkTimeBoxRight->value() * 1000.0);
1681  m_timerRight = new QTimer(this);
1682  connect(m_timerRight, SIGNAL(timeout()), this, SLOT(updateBlinkRight()));
1683  m_timerRight->start(msec);
1684  }
1685 
1686 
1689 
1690  m_timerRight->stop();
1691  m_timerOnRight = false;
1692  m_blinkChipViewportListRight.clear();
1693  // Reload left chipViewport with original chip
1694  m_rightView->repaint();
1695  }
1696 
1697 
1705  if ( m_timerOnRight ) m_timerRight->setInterval((int)(interval * 1000.));
1706  }
1707 
1708 
1711 
1712  m_blinkIndexRight++;
1713  if (m_blinkIndexRight > m_blinkChipViewportListRight.size()-1) {
1714  m_blinkIndexRight = 0;
1715  }
1716  m_rightView->loadView(*(m_blinkChipViewportListRight)[m_blinkIndexRight]);
1717  }
1718 }
1719 
Status SetType(MeasureType type)
Set how the coordinate was obtained.
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 blinkStartRight()
Slot to start blink function.
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
void setCircle(bool)
Turn circle widgets on/off.
void updateBlinkRight()
Slot to cause the blink to happen coinciding with the timer.
void blinkStart()
Slot to start blink function.
A small chip of data used for pattern matching.
Definition: Chip.h:101
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
Not enough points to fit a surface model for sub-pixel accuracy.
Definition: AutoReg.h:195
void updateRightPositionLabel(double zoomFactor)
Update sample/line, lat/lon and zoom factor of right measure.
QString serialNumber(const QString &filename)
Return a serial number given a filename.
Chip * RegistrationPatternChip()
Return pointer to pattern chip used in registration.
Definition: AutoReg.h:227
QTimer * m_timer
Timer on the blinking.
Surface model moves registration more than one pixel.
Definition: AutoReg.h:197
Statistical and similar ControlMeasure associated information.
QLabel * m_leftZoomFactor
Label for left chip viewport&#39;s zoom factor.
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
QPushButton * m_autoReg
Button to auto-register the measure.
AutoReg::RegisterStatus Register()
Walk the pattern chip through the search chip to find the best registration.
Definition: AutoReg.cpp:600
bool m_linkZoom
Link zoom factors between chip viewports.
Chip * SearchChip()
Return pointer to search chip.
Definition: AutoReg.h:217
ChipViewport * m_leftView
Left ChipViewport.
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
ControlMeasureEditWidget(QWidget *parent=0, bool allowLeftMouse=false, bool useGeometry=true)
Constructs a ControlMeasureEditWidget widget.
Registered to sub-pixel (e.g., pointreg)
double Line() const
Returns the current line value of the camera model or projection.
void setNoGeom()
Slot to turn off geom.
QLabel * m_rightZoomFactor
Label for right chip viewport&#39;s zoom factor.
A type of error that occurred when performing an actual I/O operation.
Definition: IException.h:163
double tackLine()
Returns tack line.
void changeBlinkTime(double interval)
Set blink rate.
void colorizeSaveButton()
Turn &quot;Save Measure&quot; button text to red.
bool m_circle
Whether or not to draw circle in center of the right chip viewport.
double tackSample()
Return the position of cube under cross hair.
Control measures store z-scores in pairs.
bool m_useGeometry
Whether or not to allow geometry/rotation on right chip viewport.
QString fileName(const QString &sn)
Return a filename given a serial number.
QLCDNumber * m_dialNumber
The current amount of rotation (in degrees)
static void RunSystemCommand(QString commandLine)
This runs arbitrary system commands.
void saveChips()
Slot to save registration chips to files and fire off qview.
void updateBlink()
Slot to cause the blink to happen coinciding with the timer.
void updateLeftPositionLabel(double zoomFactor)
Update sample/line, lat/lon and zoom factor of left measure.
UniversalGroundMap * m_leftGroundMap
UniversalGroundMap for left cube.
double PatternValidPercent() const
Return pattern chip valid percent. The default value is.
Definition: AutoReg.h:290
void saveMeasure()
Save control measure under the crosshair in right ChipViewport.
void setRotate()
Slot to update the right ChipViewport for zoom operations.
void findPoint()
Find point from left ChipViewport in the right ChipViewport.
a control network
Definition: ControlNet.h:207
double CubeSample() const
Return the search chip cube sample that best matched.
Definition: AutoReg.h:350
double GoodnessOfFit() const
Return the goodness of fit of the match algorithm.
Definition: AutoReg.h:333
Hand Measured (e.g., qnet)
bool m_geomIt
Apply geometry to the right chip viewport.
void blinkStop()
Slot to stop blink function.
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
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 changeBlinkTimeRight(double interval)
Set blink rate.
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
QScrollBar * m_slider
Slider that controls the size of the center circle.
double UniversalLongitude() const
Returns the universal longitude of the camera model or projection.
AutoReg * m_autoRegFact
Created AutoReg.
bool m_allowLeftMouse
Whether or not to allow mouse events on left chip viewport.
void geomChip(Chip *matchChip, Cube *matchChipCube)
Slot to geom chip (apply geometry transformation)
A single control point.
Definition: ControlPoint.h:339
QRadioButton * m_geom
Radio button to apply geometry/rotation to right chip viewport.
bool m_autoRegAttempted
Whether or not auto-registration has been attempted.
void setLeftMeasure(ControlMeasure *leftMeasure, Cube *leftCube, QString pointId)
Set the measure displayed in the left ChipViewport.
QRadioButton * m_nogeom
Radio button to remove geometry/rotation for right chip viewport.
double zoomFactor()
Return the zoom factor.
ControlMeasure * m_rightMeasure
Right ControlMeasure.
Fit chip did not have any valid data.
Definition: AutoReg.h:193
void setRightMeasure(ControlMeasure *rightMeasure, Cube *rightCube, QString pointId)
Set the measure displayed in the right ChipViewport.
QString m_templateFileName
Registration template filename.
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.
QLabel * m_goodFit
The goodness of fit value after registering.
QToolButton * m_rightZoomOut
Button for zooming out right chip viewport.
void createMeasureEditor(QWidget *parent)
Design the MeasureEdit widget.
Auto Registration class.
Definition: AutoReg.h:177
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.
int m_rotation
Amount to rotate right chip viewport TODO Is this used??
QToolButton * m_rightZoomIn
Button for zooming in right chip viewport.
Goodness of fit tolerance not satisfied.
Definition: AutoReg.h:194
Viewport for Isis Chips.
Definition: ChipViewport.h:85
void registerPoint()
Sub-pixel register point in right chipViewport with point in left.
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
Cube * m_leftCube
Left chip viewport&#39;s Cube.
QDoubleSpinBox * m_blinkTimeBox
The current blink step (in seconds)
void setChip(Chip *chip, Cube *chipCube)
Set chip.
QString toString() const
Returns a string representation of this exception.
Definition: IException.cpp:553
ChipViewport * m_rightView
Right ChipViewport.
static QString UserName()
Returns the user name.
Isis exception class.
Definition: IException.h:99
ControlMeasure * m_leftMeasure
Left ControlMeasure.
QLabel * m_oldPosition
The old sample and line before registering.
Status SetChooserName()
Set chooser name to a user who last changed the coordinate.
QPalette m_saveDefaultPalette
Default color palette for the Save button.
QList< ChipViewport * > m_blinkList
List of chip viewports to blink.
void updateRightGeom()
Slot to update the geomed right ChipViewport for zoom operations.
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.
bool m_timerOn
Indicates if the blink timer is on.
QString m_pointId
Associated control point id of the right measure.
QPushButton * m_saveMeasure
Button to save the current measure.
Chip * FitChip()
Return pointer to fit chip.
Definition: AutoReg.h:222
bool m_autoRegShown
Whether or not the auto-reg extension is shown.
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
Cube * m_rightCube
Right chip viewport&#39;s Cube.
void setCircle(bool checked)
Slot to change state of circle.
QToolButton * m_rightZoom1
Button for 1:1 zoom on right chip viewport.
double MinimumZScore() const
Return minimumPatternZScore.
Definition: AutoReg.h:360
const int VIEWSIZE
Constant representing the length and width of the chip viewports.
Serial Number list generator.
QWidget * m_autoRegExtension
Widget that shows after registering a measure.
void allowLeftMouse(bool allowMouse)
Set the option that allows mouse movements in the left ChipViewport.
const ControlMeasure * GetMeasure(QString serialNumber) const
Get a control measure based on its cube&#39;s serial number.
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.
unsigned char m_blinkIndex
Index of the chip to load in the left chip viewport.
UniversalGroundMap * m_rightGroundMap
UniversalGroundMap for right cube.
bool setTemplateFile(QString)
Allows user to choose a new template file by opening a window from which to select a filename...
void nogeomChip()
Slot to un-geom chip (revert geometry transformation)
void setZoomLink(bool)
Turn linking of zoom on or off.
void blinkStopRight()
Slot to stop blink function.
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:22