USGS

Isis 3.0 Object Programmers' Reference

Home

ControlPointEdit.cpp
1 #include "ControlPointEdit.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 <QMessageBox>
14 #include <QPalette>
15 #include <QPushButton>
16 #include <QRadioButton>
17 #include <QScrollBar>
18 #include <QSize>
19 #include <QString>
20 #include <QTimer>
21 #include <QToolButton>
22 
23 #include "Application.h"
24 #include "AutoReg.h"
25 #include "AutoRegFactory.h"
26 #include "ChipViewport.h"
27 #include "ControlMeasure.h"
28 #include "ControlMeasureLogData.h"
29 #include "FileName.h"
30 #include "IString.h"
31 #include "ProgramLauncher.h"
32 #include "Pvl.h"
33 #include "UniversalGroundMap.h"
34 
35 namespace Isis {
36 
37  const int VIEWSIZE = 301;
38 
52  bool allowLeftMouse, bool useGeometry) : QWidget(parent) {
53 
54  p_rotation = 0;
55  p_timerOn = false;
56  p_autoRegFact = NULL;
57  p_allowLeftMouse = allowLeftMouse;
58  p_useGeometry = useGeometry;
59 
60  // Initialize some pointers
61  p_leftCube = 0;
62  p_rightCube = 0;
63  p_leftGroundMap = 0;
64  p_rightGroundMap = 0;
65 
66  try {
67  p_templateFileName = "$base/templates/autoreg/qnetReg.def";
68  Pvl pvl(p_templateFileName);
69  p_autoRegFact = AutoRegFactory::Create(pvl);
70  }
71  catch (IException &e) {
72  p_autoRegFact = NULL;
73  IException fullError(e, IException::Io,
74  "Cannot create AutoRegFactory. As a result, "
75  "sub-pixel registration will not work.",
76  _FILEINFO_);
77  QString message = fullError.toString();
78  QMessageBox::information((QWidget *)parent, "Error", message);
79  }
80 
81  createPointEditor(parent);
82  if (cnet != NULL) emit newControlNetwork(cnet);
83  }
84 
85 
86 
87  ControlPointEdit::~ControlPointEdit() {
88 
89  delete p_leftChip;
90  p_leftChip = NULL;
91  delete p_rightChip;
92  p_rightChip = NULL;
93  }
94 
95 
96 
118  // Place everything in a grid
119  QGridLayout *gridLayout = new QGridLayout();
120  gridLayout->setSizeConstraint(QLayout::SetFixedSize);
121  // grid row
122  int row = 0;
123 
124  QString tempFileName = FileName("$base/icons").expanded();
125  QString toolIconDir = tempFileName;
126 
127  QSize isize(27, 27);
128  // Add zoom buttons
129  QToolButton *leftZoomIn = new QToolButton();
130  leftZoomIn->setIcon(QPixmap(toolIconDir + "/viewmag+.png"));
131  leftZoomIn->setIconSize(isize);
132  leftZoomIn->setToolTip("Zoom In 2x");
133  leftZoomIn->setWhatsThis("Zoom In 2x on left measure.");
134 
135  QToolButton *leftZoomOut = new QToolButton();
136  leftZoomOut->setIcon(QPixmap(toolIconDir + "/viewmag-.png"));
137  leftZoomOut->setIconSize(isize);
138  leftZoomOut->setToolTip("Zoom Out 2x");
139  leftZoomOut->setWhatsThis("Zoom Out 2x on left measure.");
140 
141  QToolButton *leftZoom1 = new QToolButton();
142  leftZoom1->setIcon(QPixmap(toolIconDir + "/viewmag1.png"));
143  leftZoom1->setIconSize(isize);
144  leftZoom1->setToolTip("Zoom 1:1");
145  leftZoom1->setWhatsThis("Show left measure at full resolution.");
146 
147  QHBoxLayout *leftZoomPan = new QHBoxLayout;
148  leftZoomPan->addWidget(leftZoomIn);
149  leftZoomPan->addWidget(leftZoomOut);
150  leftZoomPan->addWidget(leftZoom1);
151 
152  // These buttons only used if allow mouse events in leftViewport
153  QToolButton *leftPanUp = 0;
154  QToolButton *leftPanDown = 0;
155  QToolButton *leftPanLeft = 0;
156  QToolButton *leftPanRight = 0;
157  if ( p_allowLeftMouse ) {
158  // Add arrows for panning
159  leftPanUp = new QToolButton(parent);
160  leftPanUp->setIcon(QIcon(FileName("$base/icons/up.png").
161  expanded()));
162  leftPanUp->setIconSize(isize);
163  leftPanUp->setToolTip("Move up 1 screen pixel");
164  leftPanUp->setStatusTip("Move up 1 screen pixel");
165  leftPanUp->setWhatsThis("Move the left measure up 1 screen pixel.");
166 
167  leftPanDown = new QToolButton(parent);
168  leftPanDown->setIcon(QIcon(FileName("$base/icons/down.png").
169  expanded()));
170  leftPanDown->setIconSize(isize);
171  leftPanDown->setToolTip("Move down 1 screen pixel");
172  leftPanDown->setStatusTip("Move down 1 screen pixel");
173  leftPanDown->setWhatsThis("Move the left measure down 1 screen pixel.");
174 
175  leftPanLeft = new QToolButton(parent);
176  leftPanLeft->setIcon(QIcon(FileName("$base/icons/back.png").
177  expanded()));
178  leftPanLeft->setIconSize(isize);
179  leftPanLeft->setToolTip("Move left 1 screen pixel");
180  leftPanLeft->setWhatsThis("Move the left measure to the left by 1 screen"
181  "pixel.");
182 
183  leftPanRight = new QToolButton(parent);
184  leftPanRight->setIcon(QIcon(FileName("$base/icons/forward.png").
185  expanded()));
186  leftPanRight->setIconSize(isize);
187  leftPanRight->setToolTip("Move right 1 screen pixel");
188  leftPanRight->setWhatsThis("Move the left measure to the right by 1"
189  "screen pixel.");
190 
191  leftZoomPan->addWidget(leftPanUp);
192  leftZoomPan->addWidget(leftPanDown);
193  leftZoomPan->addWidget(leftPanLeft);
194  leftZoomPan->addWidget(leftPanRight);
195  }
196 
197  leftZoomPan->addStretch();
198  gridLayout->addLayout(leftZoomPan, row, 0);
199 
200  p_rightZoomIn = new QToolButton();
201  p_rightZoomIn->setIcon(QPixmap(toolIconDir + "/viewmag+.png"));
202  p_rightZoomIn->setIconSize(isize);
203  p_rightZoomIn->setToolTip("Zoom In 2x");
204  p_rightZoomIn->setWhatsThis("Zoom In 2x on right measure.");
205 
206  p_rightZoomOut = new QToolButton();
207  p_rightZoomOut->setIcon(QIcon(FileName("$base/icons/viewmag-.png").
208  expanded()));
209  p_rightZoomOut->setIconSize(isize);
210  p_rightZoomOut->setToolTip("Zoom Out 2x");
211  p_rightZoomOut->setWhatsThis("Zoom Out 2x on right measure.");
212 
213  p_rightZoom1 = new QToolButton();
214  p_rightZoom1->setIcon(QPixmap(toolIconDir + "/viewmag1.png"));
215  p_rightZoom1->setIconSize(isize);
216  p_rightZoom1->setToolTip("Zoom 1:1");
217  p_rightZoom1->setWhatsThis("Show right measure at full resolution.");
218 
219  QHBoxLayout *rightZoomPan = new QHBoxLayout;
220  rightZoomPan->addWidget(p_rightZoomIn);
221  rightZoomPan->addWidget(p_rightZoomOut);
222  rightZoomPan->addWidget(p_rightZoom1);
223 
224  // Add arrows for panning
225  QToolButton *rightPanUp = new QToolButton(parent);
226  rightPanUp->setIcon(QIcon(FileName("$base/icons/up.png").
227  expanded()));
228  rightPanUp->setIconSize(isize);
229  rightPanUp->setToolTip("Move up 1 screen pixel");
230  rightPanUp->setWhatsThis("Move the right measure up 1 screen pixel.");
231 
232  QToolButton *rightPanDown = new QToolButton(parent);
233  rightPanDown->setIcon(QIcon(FileName("$base/icons/down.png").
234  expanded()));
235  rightPanDown->setIconSize(isize);
236  rightPanDown->setToolTip("Move down 1 screen pixel");
237  rightPanUp->setWhatsThis("Move the right measure down 1 screen pixel.");
238 
239  QToolButton *rightPanLeft = new QToolButton(parent);
240  rightPanLeft->setIcon(QIcon(FileName("$base/icons/back.png").
241  expanded()));
242  rightPanLeft->setIconSize(isize);
243  rightPanLeft->setToolTip("Move left 1 screen pixel");
244  rightPanLeft->setWhatsThis("Move the right measure to the left by 1 screen"
245  "pixel.");
246 
247  QToolButton *rightPanRight = new QToolButton(parent);
248  rightPanRight->setIcon(QIcon(FileName("$base/icons/forward.png").
249  expanded()));
250  rightPanRight->setIconSize(isize);
251  rightPanRight->setToolTip("Move right 1 screen pixel");
252  rightPanRight->setWhatsThis("Move the right measure to the right by 1"
253  "screen pixel.");
254 
255  rightZoomPan->addWidget(rightPanUp);
256  rightZoomPan->addWidget(rightPanDown);
257  rightZoomPan->addWidget(rightPanLeft);
258  rightZoomPan->addWidget(rightPanRight);
259  rightZoomPan->addStretch();
260 
261  gridLayout->addLayout(rightZoomPan, row++, 1);
262 
263  // Add zoom factor label and stretch locking checkbox
264  p_leftZoomFactor = new QLabel();
265  QCheckBox *leftLockStretch = new QCheckBox("lock stretch");
266  // there are two "lock stretch" checkboxes (left and right)
267  // use same whats this text for both
268  QString whatsThisTextForStretchLocking = "If checked then a new stretch "
269  "will NOT be calculated for each pan or zoom change. Note that stretch"
270  " changes made using the stretch tool will ALWAYS take effect, "
271  "regardless of the state of this checkbox.";
272  leftLockStretch->setWhatsThis(whatsThisTextForStretchLocking);
273  QHBoxLayout *leftzflsLayout = new QHBoxLayout;
274  leftzflsLayout->addWidget(p_leftZoomFactor);
275  leftzflsLayout->addWidget(leftLockStretch);
276  gridLayout->addLayout(leftzflsLayout, row, 0);
277 
278  p_rightZoomFactor = new QLabel();
279  QCheckBox *rightLockStretch = new QCheckBox("lock stretch");
280  rightLockStretch->setWhatsThis(whatsThisTextForStretchLocking);
281  QHBoxLayout *rightzflsLayout = new QHBoxLayout;
282  rightzflsLayout->addWidget(p_rightZoomFactor);
283  rightzflsLayout->addWidget(rightLockStretch);
284  gridLayout->addLayout(rightzflsLayout, row++, 1);
285 
286 
287  p_leftView = new ChipViewport(VIEWSIZE, VIEWSIZE, this);
288  // Do not want to accept mouse/keyboard events
289  if ( !p_allowLeftMouse ) p_leftView->setDisabled(true);
290 
291  gridLayout->addWidget(p_leftView, row, 0);
292 
293  connect(this, SIGNAL(newControlNetwork(ControlNet *)),
294  p_leftView, SLOT(setControlNet(ControlNet *)));
295 
296  connect(this,
297  SIGNAL(stretchChipViewport(Stretch *, CubeViewport *)),
298  p_leftView,
299  SLOT(stretchFromCubeViewport(Stretch *, CubeViewport *)));
300 
301  connect(leftLockStretch, SIGNAL(stateChanged(int)),
302  p_leftView,
303  SLOT(changeStretchLock(int)));
304  leftLockStretch->setChecked(false);
305 
306 
307  // Connect left zoom buttons to ChipViewport's zoom slots
308  connect(leftZoomIn, SIGNAL(clicked()), p_leftView, SLOT(zoomIn()));
309  connect(leftZoomOut, SIGNAL(clicked()), p_leftView, SLOT(zoomOut()));
310  connect(leftZoom1, SIGNAL(clicked()), p_leftView, SLOT(zoom1()));
311 
312  // If zoom on left, need to re-geom right
313  connect(leftZoomIn, SIGNAL(clicked()), this, SLOT(updateRightGeom()));
314  connect(leftZoomOut, SIGNAL(clicked()), this, SLOT(updateRightGeom()));
315  connect(leftZoom1, SIGNAL(clicked()), this, SLOT(updateRightGeom()));
316 
317  // Connect the ChipViewport tackPointChanged signal to
318  // the update sample/line label
319  connect(p_leftView, SIGNAL(tackPointChanged(double)),
320  this, SLOT(updateLeftPositionLabel(double)));
321 
322  // we want to allow this connection so that if a changed point is saved
323  // and the same image is showing in both viewports, the left will refresh.
324  connect(this, SIGNAL(updateLeftView(double, double)),
325  p_leftView, SLOT(refreshView(double, double)));
326 
327  connect (p_leftView, SIGNAL(userMovedTackPoint()),
328  this, SLOT(colorizeSaveButton()));
329 
330  if ( p_allowLeftMouse ) {
331  // Connect pan buttons to ChipViewport
332  connect(leftPanUp, SIGNAL(clicked()), p_leftView, SLOT(panUp()));
333  connect(leftPanDown, SIGNAL(clicked()), p_leftView, SLOT(panDown()));
334  connect(leftPanLeft, SIGNAL(clicked()), p_leftView, SLOT(panLeft()));
335  connect(leftPanRight, SIGNAL(clicked()), p_leftView, SLOT(panRight()));
336 
337  connect(leftPanUp, SIGNAL(clicked()), this, SLOT(colorizeSaveButton()));
338  connect(leftPanDown, SIGNAL(clicked()), this, SLOT(colorizeSaveButton()));
339  connect(leftPanLeft, SIGNAL(clicked()), this, SLOT(colorizeSaveButton()));
340  connect(leftPanRight, SIGNAL(clicked()), this, SLOT(colorizeSaveButton()));
341  }
342 
343  p_rightView = new ChipViewport(VIEWSIZE, VIEWSIZE, this);
344  gridLayout->addWidget(p_rightView, row, 1);
345 
346  connect(this, SIGNAL(newControlNetwork(ControlNet *)),
347  p_rightView, SLOT(setControlNet(ControlNet *)));
348  connect(this,
349  SIGNAL(stretchChipViewport(Stretch *, CubeViewport *)),
350  p_rightView,
351  SLOT(stretchFromCubeViewport(Stretch *, CubeViewport *)));
352  connect(rightLockStretch, SIGNAL(stateChanged(int)),
353  p_rightView,
354  SLOT(changeStretchLock(int)));
355  rightLockStretch->setChecked(false);
356 
357  // Connect the ChipViewport tackPointChanged signal to
358  // the update sample/line label
359  connect(p_rightView, SIGNAL(tackPointChanged(double)),
360  this, SLOT(updateRightPositionLabel(double)));
361  connect(this, SIGNAL(updateRightView(double, double)),
362  p_rightView, SLOT(refreshView(double, double)));
363 
364  connect (p_rightView, SIGNAL(userMovedTackPoint()),
365  this, SLOT(colorizeSaveButton()));
366 
367  connect(p_rightZoomIn, SIGNAL(clicked()), p_rightView, SLOT(zoomIn()));
368  connect(p_rightZoomOut, SIGNAL(clicked()), p_rightView, SLOT(zoomOut()));
369  connect(p_rightZoom1, SIGNAL(clicked()), p_rightView, SLOT(zoom1()));
370 
371  // Connect pan buttons to ChipViewport
372  connect(rightPanUp, SIGNAL(clicked()), p_rightView, SLOT(panUp()));
373  connect(rightPanDown, SIGNAL(clicked()), p_rightView, SLOT(panDown()));
374  connect(rightPanLeft, SIGNAL(clicked()), p_rightView, SLOT(panLeft()));
375  connect(rightPanRight, SIGNAL(clicked()), p_rightView, SLOT(panRight()));
376 
377  connect(rightPanUp, SIGNAL(clicked()), this, SLOT(colorizeSaveButton()));
378  connect(rightPanDown, SIGNAL(clicked()), this, SLOT(colorizeSaveButton()));
379  connect(rightPanLeft, SIGNAL(clicked()), this, SLOT(colorizeSaveButton()));
380  connect(rightPanRight, SIGNAL(clicked()), this, SLOT(colorizeSaveButton()));
381 
382  // Create chips for left and right
383  p_leftChip = new Chip(VIEWSIZE, VIEWSIZE);
384  p_rightChip = new Chip(VIEWSIZE, VIEWSIZE);
385 
386  QButtonGroup *bgroup = new QButtonGroup();
387  p_nogeom = new QRadioButton();
388  p_nogeom->setChecked(true);
389  connect(p_nogeom, SIGNAL(clicked()), this, SLOT(setNoGeom()));
390 
391  QCheckBox *linkZoom = NULL;
392  if (p_useGeometry) {
393  p_nogeom->setText("No geom/rotate");
394  p_nogeom->setToolTip("Reset right measure to it's native geometry.");
395  p_nogeom->setWhatsThis("Reset right measure to it's native geometry. "
396  "If measure was rotated, set rotation back to 0. "
397  "If measure was geomed to match the left measure, "
398  "reset the geometry back to it's native state.");
399  p_geom = new QRadioButton("Geom");
400  p_geom->setToolTip("Geom right measure to match geometry of left measure.");
401  p_geom->setWhatsThis("Using an affine transform, geom the right measure to match the "
402  "geometry of the left measure.");
403  bgroup->addButton(p_geom);
404  connect(p_geom, SIGNAL(clicked()), this, SLOT(setGeom()));
405  }
406  else {
407  linkZoom = new QCheckBox("Link Zoom");
408  linkZoom->setToolTip("Link zooming between the left and right views.");
409  linkZoom->setWhatsThis("When zooming in the left view, the right view will "
410  "be set to the same zoom factor as the left view.");
411  connect(linkZoom, SIGNAL(toggled(bool)), this, SLOT(setZoomLink(bool)));
412 
413  p_nogeom->setText("No rotate");
414  p_nogeom->setToolTip("Reset right measure to it's native geometry.");
415  p_nogeom->setWhatsThis("Reset right measure to it's native geometry. "
416  "If measure was rotated, set rotation back to 0.");
417  }
418  bgroup->addButton(p_nogeom);
419 
420  QRadioButton *rotate = new QRadioButton("Rotate");
421  bgroup->addButton(rotate);
422  // TODO: ?? Don't think we need this connection
423  connect(rotate, SIGNAL(clicked()), this, SLOT(setRotate()));
424 
425  // Set some defaults
426  p_geomIt = false;
427  p_rotation = 0;
428  p_linkZoom = false;
429 
430  p_dial = new QDial();
431  p_dial->setRange(0, 360);
432  p_dial->setWrapping(false);
433  p_dial->setNotchesVisible(true);
434  p_dial->setNotchTarget(5.);
435  p_dial->setEnabled(false);
436  p_dial->setToolTip("Rotate right measure");
437  p_dial->setWhatsThis("Rotate the right measure by degrees.");
438 
439  p_dialNumber = new QLCDNumber();
440  p_dialNumber->setEnabled(false);
441  p_dialNumber->setToolTip("Rotate right measure");
442  p_dialNumber->setWhatsThis("Rotate the right measure by given number"
443  " of degrees.");
444  connect(p_dial, SIGNAL(valueChanged(int)), p_dialNumber, SLOT(display(int)));
445  connect(p_dial, SIGNAL(valueChanged(int)), p_rightView, SLOT(rotateChip(int)));
446 
447  QCheckBox *showPoints = new QCheckBox("Show control points");
448  showPoints->setToolTip("Draw control point crosshairs");
449  showPoints->setWhatsThis("This will toggle whether crosshairs are drawn"
450  " for the control points located within the measure''s"
451  " view. For areas of dense measurements, turning this"
452  " off will allow easier viewing of features.");
453  connect(showPoints, SIGNAL(toggled(bool)), p_leftView, SLOT(setPoints(bool)));
454  connect(showPoints, SIGNAL(toggled(bool)), p_rightView, SLOT(setPoints(bool)));
455  showPoints->setChecked(true);
456 
457  QCheckBox *cross = new QCheckBox("Show crosshair");
458  connect(cross, SIGNAL(toggled(bool)), p_leftView, SLOT(setCross(bool)));
459  connect(cross, SIGNAL(toggled(bool)), p_rightView, SLOT(setCross(bool)));
460  cross->setChecked(true);
461  cross->setToolTip("Show the red crosshair across measure view");
462  cross->setWhatsThis("This will toggle whether the crosshair across the"
463  " measure view will be shown");
464 
465  QCheckBox *circle = new QCheckBox("Circle");
466  circle->setChecked(false);
467  circle->setToolTip("Draw circle");
468  circle->setWhatsThis("Draw circle on measure view. This can aid in"
469  " centering a crater under the crosshair.");
470  connect(circle, SIGNAL(toggled(bool)), this, SLOT(setCircle(bool)));
471 
472  p_slider = new QScrollBar(Qt::Horizontal);
473  p_slider->setRange(1, 100);
474  p_slider->setSingleStep(1);
475  connect(p_slider, SIGNAL(valueChanged(int)), p_leftView, SLOT(setCircleSize(int)));
476  connect(p_slider, SIGNAL(valueChanged(int)), p_rightView, SLOT(setCircleSize(int)));
477  p_slider->setValue(20);
478  p_slider->setDisabled(true);
479  p_slider->hide();
480  p_slider->setToolTip("Adjust circle size");
481  p_slider->setWhatsThis("This allows the cirle size to be adjusted.");
482 
483  QVBoxLayout *vlayout = new QVBoxLayout();
484  if (!p_useGeometry) {
485  vlayout->addWidget(linkZoom);
486  }
487  vlayout->addWidget(p_nogeom);
488  if (p_useGeometry) {
489  vlayout->addWidget(p_geom);
490  }
491  vlayout->addWidget(rotate);
492  vlayout->addWidget(p_dial);
493  vlayout->addWidget(p_dialNumber);
494  vlayout->addWidget(showPoints);
495  vlayout->addWidget(cross);
496  vlayout->addWidget(circle);
497  vlayout->addWidget(p_slider);
498  gridLayout->addLayout(vlayout, row++, 2);
499 
500  // Show sample / line for measure of chips shown
501  p_leftSampLinePosition = new QLabel();
502  p_leftSampLinePosition->setToolTip("Sample/Line under the crosshair");
503  gridLayout->addWidget(p_leftSampLinePosition, row, 0);
504  p_rightSampLinePosition = new QLabel();
505  p_rightSampLinePosition->setToolTip("Sample/Line under the crosshair");
506  gridLayout->addWidget(p_rightSampLinePosition, row++, 1);
507 
508  if (p_useGeometry) {
509  // Show lat / lon for measure of chips shown
510  p_leftLatLonPosition = new QLabel();
511  p_leftLatLonPosition->setToolTip("Latitude/Longitude under the crosshair");
512  gridLayout->addWidget(p_leftLatLonPosition, row, 0);
513  p_rightLatLonPosition = new QLabel();
514  p_rightLatLonPosition->setToolTip("Latitude/Longitude under the crosshair");
515  gridLayout->addWidget(p_rightLatLonPosition, row++, 1);
516  }
517 
518 
519  // Add auto registration extension
520  p_autoRegExtension = new QWidget;
521  p_oldPosition = new QLabel;
522  p_oldPosition->setToolTip("Measure Sample/Line before sub-pixel "
523  "registration");
524  p_oldPosition->setWhatsThis("Original Sample/Line of the right measure "
525  "before the sub-pixel registration. If you select the \"Undo\" "
526  "button, the measure will revert back to this Sample/Line.");
527  p_goodFit = new QLabel;
528  p_goodFit->setToolTip("Goodness of Fit result from sub-pixel registration.");
529  p_goodFit->setWhatsThis("Resulting Goodness of Fit from sub-pixel "
530  "registration.");
531  QVBoxLayout *autoRegLayout = new QVBoxLayout;
532  autoRegLayout->setMargin(0);
533  autoRegLayout->addWidget(p_oldPosition);
534  autoRegLayout->addWidget(p_goodFit);
535  p_autoRegExtension->setLayout(autoRegLayout);
536  p_autoRegShown = false;
537  p_autoRegAttempted = false;
538  gridLayout->addWidget(p_autoRegExtension, row++, 1);
539 
540 
541  QHBoxLayout *leftLayout = new QHBoxLayout();
542  QToolButton *stop = new QToolButton();
543  stop->setIcon(QPixmap(toolIconDir + "/blinkStop.png"));
544  stop->setIconSize(QSize(22, 22));
545  stop->setToolTip("Blink Stop");
546  QString text = "<b>Function:</b> Stop automatic timed blinking";
547  stop->setWhatsThis(text);
548  connect(stop, SIGNAL(released()), this, SLOT(blinkStop()));
549 
550  QToolButton *start = new QToolButton();
551  start->setIcon(QPixmap(toolIconDir + "/blinkStart.png"));
552  start->setIconSize(QSize(22, 22));
553  start->setToolTip("Blink Start");
554  text = "<b>Function:</b> Start automatic timed blinking. Cycles \
555  through linked viewports at variable rate";
556  start->setWhatsThis(text);
557  connect(start, SIGNAL(released()), this, SLOT(blinkStart()));
558 
559  p_blinkTimeBox = new QDoubleSpinBox();
560  p_blinkTimeBox->setMinimum(0.1);
561  p_blinkTimeBox->setMaximum(5.0);
562  p_blinkTimeBox->setDecimals(1);
563  p_blinkTimeBox->setSingleStep(0.1);
564  p_blinkTimeBox->setValue(0.5);
565  p_blinkTimeBox->setToolTip("Blink Time Delay");
566  text = "<b>Function:</b> Change automatic blink rate between " +
567  QString::number(p_blinkTimeBox->minimum()) + " and " +
568  QString::number(p_blinkTimeBox->maximum()) + " seconds";
569  p_blinkTimeBox->setWhatsThis(text);
570  connect(p_blinkTimeBox, SIGNAL(valueChanged(double)),
571  this, SLOT(changeBlinkTime(double)));
572 
573  leftLayout->addWidget(stop);
574  leftLayout->addWidget(start);
575  leftLayout->addWidget(p_blinkTimeBox);
576 
577  if (p_useGeometry) {
578  QPushButton *find = new QPushButton("Find");
579  find->setToolTip("Move right measure to same Latitude/Longitude as left.");
580  find->setWhatsThis("Find the Latitude/Longitude under the crosshair in the "
581  "left measure and move the right measure to the same "
582  "latitude/longitude.");
583  leftLayout->addWidget(find);
584  connect(find, SIGNAL(clicked()), this, SLOT(findPoint()));
585  }
586 
587  leftLayout->addStretch();
588  gridLayout->addLayout(leftLayout, row, 0);
589 
590  QHBoxLayout *rightLayout = new QHBoxLayout();
591  p_autoReg = new QPushButton("Register");
592  p_autoReg->setToolTip("Sub-pixel register the right measure to the left");
593  p_autoReg->setWhatsThis("Sub-pixel register the right measure to the left "
594  "and move the result under the crosshair. After "
595  "viewing the results, the option exists to move the "
596  "measure back to the original position by selecting "
597  "<strong>\"Undo Registration\"</strong>.");
598  if (p_allowLeftMouse) {
599  p_saveMeasure = new QPushButton("Save Measures");
600  p_saveMeasure->setToolTip("Save the both the left and right measure to the edit control "
601  "point (control point currently being edited). "
602  " <strong>Note: The edit control point "
603  "will not be saved to the network until you select "
604  "<strong>\"Save Point\"</strong>");
605  }
606  else {
607  p_saveMeasure = new QPushButton("Save Measure");
608  p_saveMeasure->setToolTip("Save the right measure to the edit control "
609  "point (control point currently being edited). "
610  " <strong>Note: The edit control point "
611  "will not be saved to the network until you select "
612  "<strong>\"Save Point\"</strong>");
613  }
614  p_saveDefaultPalette = p_saveMeasure->palette();
615 
616  rightLayout->addWidget(p_autoReg);
617  rightLayout->addWidget(p_saveMeasure);
618  rightLayout->addStretch();
619  gridLayout->addLayout(rightLayout, row, 1);
620 
621  connect(p_autoReg, SIGNAL(clicked()), this, SLOT(registerPoint()));
622  connect(p_saveMeasure, SIGNAL(clicked()), this, SLOT(saveMeasure()));
623 
624  setLayout(gridLayout);
625 
626  //p_pointEditor->setCentralWidget(cw);
627  p_autoRegExtension->hide();
628 
629  //p_pointEditor->setShown(true);
630  //p_pointEditor->raise();
631  }
632 
633 
634 
635 
658  Cube *leftCube, QString pointId) {
659 
660  // Make sure registration is turned off
661  if ( p_autoRegShown ) {
662  // Undo Registration
663  p_autoRegShown = false;
664  p_autoRegExtension->hide();
665  p_autoReg->setText("Register");
666  }
667 
668  p_leftMeasure = leftMeasure;
669 
670  if (p_useGeometry) {
671  // get new ground map
672  if ( p_leftGroundMap != 0 ) delete p_leftGroundMap;
673  p_leftGroundMap = new UniversalGroundMap(*leftCube);
674  }
675  p_leftCube = leftCube;
676 
677  p_leftChip->TackCube(p_leftMeasure->GetSample(), p_leftMeasure->GetLine());
678  p_leftChip->Load(*p_leftCube);
679 
680  // Dump into left chipViewport
681  p_leftView->setChip(p_leftChip, p_leftCube);
682 
683  // Only update right if not loading a new point. If it's a new point, right measure
684  // hasn't been loaded yet.
685  if (pointId == p_pointId && p_geomIt) updateRightGeom();
686  p_pointId = pointId;
687  }
688 
689 
716  Cube *rightCube, QString pointId) {
717 
718  // Make sure registration is turned off
719  if ( p_autoRegShown ) {
720  // Undo Registration
721  p_autoRegShown = false;
722  p_autoRegExtension->hide();
723  p_autoReg->setText("Register");
724  }
725  p_autoRegAttempted = false;
726 
727  p_rightMeasure = rightMeasure;
728  p_pointId = pointId;
729 
730  if (p_useGeometry) {
731  // get new ground map
732  if ( p_rightGroundMap != 0 ) delete p_rightGroundMap;
733  p_rightGroundMap = new UniversalGroundMap(*rightCube);
734  }
735  p_rightCube = rightCube;
736 
737  p_rightChip->TackCube(p_rightMeasure->GetSample(),
738  p_rightMeasure->GetLine());
739  if ( p_geomIt == false ) {
740  p_rightChip->Load(*p_rightCube);
741  }
742  else {
743  try {
744  p_rightChip->Load(*p_rightCube, *p_leftChip, *p_leftCube);
745 
746  }
747  catch (IException &e) {
748  IException fullError(e, IException::User, "Geom failed.", _FILEINFO_);
749  QString message = fullError.toString();
750  QMessageBox::information((QWidget *)parent(), "Error", message);
751  p_rightChip->Load(*p_rightCube);
752  p_geomIt = false;
753  p_nogeom->setChecked(true);
754  p_geom->setChecked(false);
755  }
756  }
757 
758  // Dump into left chipViewport
759  p_rightView->setChip(p_rightChip, p_rightCube);
760 
761  updateRightGeom();
762  //p_rightView->geomChip(p_leftChip,p_leftCube);
763 
764  // New right measure, make sure Save Measure Button text is default
765  p_saveMeasure->setPalette(p_saveDefaultPalette);
766 
767  }
768 
769 
783  QString pos = "Sample: " + QString::number(p_leftView->tackSample()) +
784  " Line: " + QString::number(p_leftView->tackLine());
785  p_leftSampLinePosition->setText(pos);
786 
787  if (p_useGeometry) {
788  // Get lat/lon from point in left
789  p_leftGroundMap->SetImage(p_leftView->tackSample(), p_leftView->tackLine());
790  double lat = p_leftGroundMap->UniversalLatitude();
791  double lon = p_leftGroundMap->UniversalLongitude();
792 
793  pos = "Latitude: " + QString::number(lat) +
794  " Longitude: " + QString::number(lon);
795  p_leftLatLonPosition->setText(pos);
796  }
797 
798  // Print zoom scale factor
799  pos = "Zoom Factor: " + QString::number(zoomFactor);
800  p_leftZoomFactor->setText(pos);
801 
802  // If zooms are linked, make right match left
803  if (p_linkZoom) {
804  p_rightView->zoom(p_leftView->zoomFactor());
805  }
806 
807  }
808 
809 
818 
819  // If registration Info is on, turn off
820  if ( p_autoRegShown ) {
821  // Undo Registration
822  p_autoRegShown = false;
823  p_autoRegExtension->hide();
824  p_autoReg->setText("Register");
825  }
826 
827  QString pos = "Sample: " + QString::number(p_rightView->tackSample()) +
828  " Line: " + QString::number(p_rightView->tackLine());
829  p_rightSampLinePosition->setText(pos);
830 
831  if (p_useGeometry) {
832  // Get lat/lon from point in right
833  p_rightGroundMap->SetImage(p_rightView->tackSample(), p_rightView->tackLine());
834  double lat = p_rightGroundMap->UniversalLatitude();
835  double lon = p_rightGroundMap->UniversalLongitude();
836 
837  pos = "Latitude: " + QString::number(lat) +
838  " Longitude: " + QString::number(lon);
839  p_rightLatLonPosition->setText(pos);
840  }
841 
842  // Print zoom scale factor
843  pos = "Zoom Factor: " + QString::number(zoomFactor);
844  p_rightZoomFactor->setText(pos);
845 
846  }
847 
848 
855 
856  QColor qc = Qt::red;
857  QPalette p = p_saveMeasure->palette();
858  p.setColor(QPalette::ButtonText,qc);
859  p_saveMeasure->setPalette(p);
860 
861  }
862 
863 
874 
875  // Get lat/lon from point in left
876  p_leftGroundMap->SetImage(p_leftView->tackSample(), p_leftView->tackLine());
877  double lat = p_leftGroundMap->UniversalLatitude();
878  double lon = p_leftGroundMap->UniversalLongitude();
879 
880  // Reload right chipViewport with this new tack point.
881  if ( p_rightGroundMap->SetUniversalGround(lat, lon) ) {
882  emit updateRightView(p_rightGroundMap->Sample(), p_rightGroundMap->Line());
883 
884  // If moving from saved measure, turn save button to red
885  if (p_rightGroundMap->Sample() != p_rightMeasure->GetSample() ||
886  p_rightGroundMap->Line() != p_rightMeasure->GetLine())
888  }
889  else {
890  QString message = "Latitude: " + QString::number(lat) + " Longitude: " +
891  QString::number(lon) + " is not on the right image. Right measure " +
892  "was not moved.";
893  QMessageBox::warning((QWidget *)parent(),"Warning",message);
894  }
895 
896  }
897 
898 
929 
930  if ( p_autoRegShown ) {
931  // Undo Registration
932  p_autoRegShown = false;
933  p_autoRegExtension->hide();
934  p_autoReg->setText("Register");
935 
936  // Reload chip with original measure
937  emit updateRightView(p_rightMeasure->GetSample(),
938  p_rightMeasure->GetLine());
939  // Since un-doing registration, make sure save button not red
940  p_saveMeasure->setPalette(p_saveDefaultPalette);
941  return;
942 
943  }
944  p_autoRegAttempted = true;
945 
946  try {
947  p_autoRegFact->PatternChip()->TackCube(
948  p_leftMeasure->GetSample(), p_leftMeasure->GetLine());
949  p_autoRegFact->PatternChip()->Load(*p_leftCube);
950  p_autoRegFact->SearchChip()->TackCube(
951  p_rightMeasure->GetSample(),
952  p_rightMeasure->GetLine());
953  if (p_useGeometry) {
954  p_autoRegFact->SearchChip()->Load(*p_rightCube,
955  *(p_autoRegFact->PatternChip()), *p_leftCube);
956  }
957  else {
958  p_autoRegFact->SearchChip()->Load(*p_rightCube);
959  }
960  }
961  catch (IException &e) {
962  QString msg = "Cannot register this point, unable to Load chips.\n";
963  msg += e.toString();
964  QMessageBox::information((QWidget *)parent(), "Error", msg);
965  return;
966  }
967 
968  try {
969  AutoReg::RegisterStatus status = p_autoRegFact->Register();
970  if ( !p_autoRegFact->Success() ) {
971  QString msg = "Cannot sub-pixel register this point.\n";
972  if ( status == AutoReg::PatternChipNotEnoughValidData ) {
973  msg += "\n\nNot enough valid data in Pattern Chip.\n";
974  msg += " PatternValidPercent = ";
975  msg += QString::number(p_autoRegFact->PatternValidPercent()) + "%";
976  }
977  else if ( status == AutoReg::FitChipNoData ) {
978  msg += "\n\nNo valid data in Fit Chip.";
979  }
980  else if ( status == AutoReg::FitChipToleranceNotMet ) {
981  msg += "\n\nGoodness of Fit Tolerance not met.\n";
982  msg += "\nGoodnessOfFit = " + QString::number(p_autoRegFact->GoodnessOfFit());
983  msg += "\nGoodnessOfFitTolerance = ";
984  msg += QString::number(p_autoRegFact->Tolerance());
985  }
986  else if ( status == AutoReg::SurfaceModelNotEnoughValidData ) {
987  msg += "\n\nNot enough valid points in the fit chip window for sub-pixel ";
988  msg += "accuracy. Probably too close to edge.\n";
989  }
990  else if ( status == AutoReg::SurfaceModelSolutionInvalid ) {
991  msg += "\n\nCould not model surface for sub-pixel accuracy.\n";
992  }
993  else if ( status == AutoReg::SurfaceModelDistanceInvalid ) {
994  double sampDist, lineDist;
995  p_autoRegFact->Distance(sampDist, lineDist);
996  msg += "\n\nSub pixel algorithm moves registration more than tolerance.\n";
997  msg += "\nSampleMovement = " + QString::number(sampDist) +
998  " LineMovement = " + QString::number(lineDist);
999  msg += "\nDistanceTolerance = " +
1000  QString::number(p_autoRegFact->DistanceTolerance());
1001  }
1002  else if ( status == AutoReg::PatternZScoreNotMet ) {
1003  double score1, score2;
1004  p_autoRegFact->ZScores(score1, score2);
1005  msg += "\n\nPattern data max or min does not pass z-score test.\n";
1006  msg += "\nMinimumZScore = " + QString::number(p_autoRegFact->MinimumZScore());
1007  msg += "\nCalculatedZscores = " + QString::number(score1) + ", " + QString::number(score2);
1008  }
1009  else if ( status == AutoReg::AdaptiveAlgorithmFailed ) {
1010  msg += "\n\nError occured in Adaptive algorithm.";
1011  }
1012  else {
1013  msg += "\n\nUnknown registration error.";
1014  }
1015 
1016  QMessageBox::information((QWidget *)parent(), "Error", msg);
1017  return;
1018  }
1019  }
1020  catch (IException &e) {
1021  QString msg = "Cannot register this point.\n";
1022  msg += e.toString();
1023  QMessageBox::information((QWidget *)parent(), "Error", msg);
1024  return;
1025  }
1026 
1027 
1028 
1029  // Load chip with new registered point
1030  emit updateRightView(p_autoRegFact->CubeSample(), p_autoRegFact->CubeLine());
1031  // If registered pt different from measure, colorize the save button
1032  if (p_autoRegFact->CubeSample() != p_rightMeasure->GetSample() ||
1033  p_autoRegFact->CubeLine() != p_rightMeasure->GetLine()) {
1035  }
1036 
1037  QString oldPos = "Original Sample: " +
1038  QString::number(p_rightMeasure->GetSample()) + " Original Line: " +
1039  QString::number(p_rightMeasure->GetLine());
1040  p_oldPosition->setText(oldPos);
1041 
1042  QString goodFit = "Goodness of Fit: " +
1043  QString::number(p_autoRegFact->GoodnessOfFit());
1044  p_goodFit->setText(goodFit);
1045 
1046  p_autoRegExtension->show();
1047  p_autoRegShown = true;
1048  p_autoReg->setText("Undo Registration");
1049  }
1050 
1051 
1087 
1088  if (p_rightMeasure != NULL) {
1089 
1090  if (p_rightMeasure->IsEditLocked()) {
1091  QString message = "The right measure is locked. You must first unlock the measure by ";
1092  message += "clicking the check box above labeled \"Edit Lock Measure\".";
1093  QMessageBox::warning((QWidget *)parent(),"Warning",message);
1094  return;
1095  }
1096 
1097  if (p_autoRegShown) {
1098  try {
1099  // Save autoreg parameters to the right measure log entry
1100  // Eccentricity may be invalid, check before writing.
1101  p_rightMeasure->SetLogData(ControlMeasureLogData(
1103  p_autoRegFact->GoodnessOfFit()));
1104  double minZScore, maxZScore;
1105  p_autoRegFact->ZScores(minZScore,maxZScore);
1106  p_rightMeasure->SetLogData(ControlMeasureLogData(
1108  minZScore));
1109  p_rightMeasure->SetLogData(ControlMeasureLogData(
1111  maxZScore));
1112  }
1113  // need to handle exception that SetLogData throws if our data is invalid -
1114  // unhandled exceptions thrown in Qt signal and slot connections produce undefined behavior
1115  catch (IException &e) {
1116  QString message = e.toString();
1117  QMessageBox::critical((QWidget *)parent(), "Error", message);
1118  return;
1119  }
1120 
1121  // Reset AprioriSample/Line to the current coordinate, before the
1122  // coordinate is updated with the registered coordinate.
1123  p_rightMeasure->SetAprioriSample(p_rightMeasure->GetSample());
1124  p_rightMeasure->SetAprioriLine(p_rightMeasure->GetLine());
1125 
1126  p_rightMeasure->SetChooserName("Application qnet");
1128 
1129  p_autoRegShown = false;
1130  p_autoRegExtension->hide();
1131  p_autoReg->setText("Register");
1132  }
1133  else {
1134  p_rightMeasure->SetChooserName(Application::UserName());
1135  p_rightMeasure->SetType(ControlMeasure::Manual);
1136  p_rightMeasure->DeleteLogData(
1138  p_rightMeasure->DeleteLogData(
1140  p_rightMeasure->DeleteLogData(
1142  }
1143 
1144  // Get cube position at right chipViewport crosshair
1145  p_rightMeasure->SetCoordinate(p_rightView->tackSample(),
1146  p_rightView->tackLine());
1147  p_rightMeasure->SetDateTime();
1148 
1149  }
1150 
1151  if (p_allowLeftMouse) {
1152  if (p_leftMeasure != NULL) {
1153  if (p_leftMeasure->IsEditLocked()) {
1154  QString message = "The left measure is locked. You must first unlock the measure by ";
1155  message += "clicking the check box above labeled \"Edit Lock Measure\".";
1156  QMessageBox::warning((QWidget *)parent(),"Warning",message);
1157  return;
1158  }
1159 
1160  p_leftMeasure->SetCoordinate(p_leftView->tackSample(), p_leftView->tackLine());
1161  p_leftMeasure->SetDateTime();
1162  p_leftMeasure->SetChooserName(Application::UserName());
1163  p_leftMeasure->SetType(ControlMeasure::Manual);
1164  }
1165  }
1166 
1167  // If the right chip is the same as the left chip, copy right into left and
1168  // re-load the left.
1169  if (p_rightMeasure->GetCubeSerialNumber() ==
1170  p_leftMeasure->GetCubeSerialNumber()) {
1171 
1172  *p_leftMeasure = *p_rightMeasure;
1173  setLeftMeasure(p_leftMeasure,p_leftCube,p_pointId);
1174  }
1175 
1176  // Change Save Measure button text back to default palette
1177  p_saveMeasure->setPalette(p_saveDefaultPalette);
1178 
1179  // Redraw measures on viewports
1180  emit measureSaved();
1181  }
1182 
1183 
1192 
1193  if (p_geomIt) {
1194  try {
1195  p_rightView->geomChip(p_leftChip, p_leftCube);
1196 
1197  }
1198  catch (IException &e) {
1199  IException fullError(e, IException::User, "Geom failed.", _FILEINFO_);
1200  QString message = fullError.toString();
1201  QMessageBox::information((QWidget *)parent(), "Error", message);
1202  p_geomIt = false;
1203  p_nogeom->setChecked(true);
1204  p_geom->setChecked(false);
1205  }
1206  }
1207  }
1208 
1209 
1210 
1212 // * Slot to update the right ChipViewport for zoom
1213 // * operations
1214 // *
1215 // * @author 2012-07-26 Tracie Sucharski
1216 // *
1217 // * @internal
1218 // */
1219 //void ControlPointEdit::updateRightZoom() {
1220 //
1221 // if ( p_linkZoom ) {
1222 // try {
1223 // p_rightView->geomChip(p_leftChip, p_leftCube);
1224 //
1225 // }
1226 // catch (IException &e) {
1227 // IException fullError(e, IException::User, "Geom failed.", _FILEINFO_);
1228 // QString message = fullError.toString();
1229 // QMessageBox::information((QWidget *)parent(), "Error", message);
1230 // p_geomIt = false;
1231 // p_nogeom->setChecked(true);
1232 // p_geom->setChecked(false);
1233 // }
1234 // }
1235 //}
1236 
1237 
1238 
1245  QApplication::setOverrideCursor(Qt::WaitCursor);
1246 
1247  // Text needs to be reset because it was changed to
1248  // indicate why it's greyed out
1249  QString text = "Zoom in 2X";
1250  p_rightZoomIn->setEnabled(true);
1251  p_rightZoomIn->setWhatsThis(text);
1252  p_rightZoomIn->setToolTip("Zoom In");
1253  text = "Zoom out 2X";
1254  p_rightZoomOut->setEnabled(true);
1255  p_rightZoomOut->setWhatsThis(text);
1256  p_rightZoomOut->setToolTip("Zoom Out");
1257  text = "Zoom 1:1";
1258  p_rightZoom1->setEnabled(true);
1259  p_rightZoom1->setWhatsThis(text);
1260  p_rightZoom1->setToolTip("Zoom 1:1");
1261 
1262  p_geomIt = false;
1263  p_rightView->nogeomChip();
1264 
1265  QApplication::restoreOverrideCursor();
1266 
1267  p_dial->setEnabled(true);
1268  p_dialNumber->setEnabled(true);
1269  p_dial->setNotchesVisible(true);
1270 
1271  }
1272 
1273 
1274 
1284 
1285  if (p_geomIt == true) return;
1286 
1287  QApplication::setOverrideCursor(Qt::WaitCursor);
1288 
1289  // Grey right view zoom buttons
1290  QString text = "Zoom functions disabled when Geom is set";
1291  p_rightZoomIn->setEnabled(false);
1292  p_rightZoomIn->setWhatsThis(text);
1293  p_rightZoomIn->setToolTip(text);
1294  p_rightZoomOut->setEnabled(false);
1295  p_rightZoomOut->setWhatsThis(text);
1296  p_rightZoomOut->setToolTip(text);
1297  p_rightZoom1->setEnabled(false);
1298  p_rightZoom1->setWhatsThis(text);
1299  p_rightZoom1->setToolTip(text);
1300 
1301 
1302  // Reset dial to 0 before disabling
1303  p_dial->setValue(0);
1304  p_dial->setEnabled(false);
1305  p_dialNumber->setEnabled(false);
1306 
1307  p_geomIt = true;
1308 
1309  try {
1310  p_rightView->geomChip(p_leftChip, p_leftCube);
1311 
1312  }
1313  catch (IException &e) {
1314  IException fullError(e, IException::User, "Geom failed.", _FILEINFO_);
1315  QString message = fullError.toString();
1316  QMessageBox::information((QWidget *)parent(), "Error", message);
1317  p_geomIt = false;
1318  p_nogeom->setChecked(true);
1319  p_geom->setChecked(false);
1320  }
1321 
1322  QApplication::restoreOverrideCursor();
1323  }
1324 
1325 
1332 
1333  QApplication::setOverrideCursor(Qt::WaitCursor);
1334 
1335  QString text = "Zoom in 2X";
1336  p_rightZoomIn->setEnabled(true);
1337  p_rightZoomIn->setWhatsThis(text);
1338  p_rightZoomIn->setToolTip("Zoom In");
1339  text = "Zoom out 2X";
1340  p_rightZoomOut->setEnabled(true);
1341  p_rightZoomOut->setWhatsThis(text);
1342  p_rightZoomOut->setToolTip("Zoom Out");
1343  text = "Zoom 1:1";
1344  p_rightZoom1->setEnabled(true);
1345  p_rightZoom1->setWhatsThis(text);
1346  p_rightZoom1->setToolTip("Zoom 1:1");
1347 
1348  // Reset dial to 0 before disabling
1349  p_dial->setValue(0);
1350  p_dial->setEnabled(false);
1351  p_dialNumber->setEnabled(false);
1352 
1353  p_geomIt = false;
1354  p_rightView->nogeomChip();
1355 
1356  QApplication::restoreOverrideCursor();
1357  }
1358 
1359 
1360 
1361 
1369  void ControlPointEdit::setCircle(bool checked) {
1370 
1371  if ( checked == p_circle ) return;
1372 
1373  p_circle = checked;
1374  if ( p_circle ) {
1375  // Turn on slider bar
1376  p_slider->setDisabled(false);
1377  p_slider->show();
1378  p_slider->setValue(20);
1379  p_leftView->setCircle(true);
1380  p_rightView->setCircle(true);
1381  }
1382  else {
1383  p_slider->setDisabled(true);
1384  p_slider->hide();
1385  p_leftView->setCircle(false);
1386  p_rightView->setCircle(false);
1387  }
1388 
1389 
1390  }
1391 
1392 
1393 
1401  void ControlPointEdit::setZoomLink(bool checked) {
1402 
1403  if ( checked == p_linkZoom ) return;
1404 
1405  p_linkZoom = checked;
1406  if ( p_linkZoom ) {
1407  p_rightView->zoom(p_leftView->zoomFactor());
1408  }
1409  }
1410 
1411 
1412 
1415  if ( p_timerOn ) return;
1416 
1417  // Set up blink list
1418  p_blinkList.push_back(p_leftView);
1419  p_blinkList.push_back(p_rightView);
1420  p_blinkIndex = 0;
1421 
1422  p_timerOn = true;
1423  int msec = (int)(p_blinkTimeBox->value() * 1000.0);
1424  p_timer = new QTimer(this);
1425  connect(p_timer, SIGNAL(timeout()), this, SLOT(updateBlink()));
1426  p_timer->start(msec);
1427  }
1428 
1429 
1432  p_timer->stop();
1433  p_timerOn = false;
1434  p_blinkList.clear();
1435 
1436  // Reload left chipViewport with original chip
1437  p_leftView->repaint();
1438 
1439  }
1440 
1441 
1442 
1449  void ControlPointEdit::changeBlinkTime(double interval) {
1450  if ( p_timerOn ) p_timer->setInterval((int)(interval * 1000.));
1451  }
1452 
1453 
1456 
1457  p_blinkIndex = !p_blinkIndex;
1458  p_leftView->loadView(*(p_blinkList)[p_blinkIndex]);
1459  }
1460 
1461 
1462 
1463 
1483 
1484  AutoReg *reg = NULL;
1485  // save original template filename
1486  QString temp = p_templateFileName;
1487  try {
1488  // set template filename to user chosen pvl file
1489  p_templateFileName = fn;
1490 
1491  // Create PVL object with this file
1492  Pvl pvl(fn);
1493 
1494  // try to register file
1495  reg = AutoRegFactory::Create(pvl);
1496  if ( p_autoRegFact != NULL )
1497  delete p_autoRegFact;
1498  p_autoRegFact = reg;
1499 
1500  p_templateFileName = fn;
1501 
1502  // undo registration if a point is already registered
1503  // this prevents the user from saving a measure with invalid data
1504  if (p_autoRegShown)
1505  registerPoint();
1506 
1507  return true;
1508  }
1509  catch (IException &e) {
1510  // set templateFileName back to its original value
1511  p_templateFileName = temp;
1512  IException fullError(e, IException::Io,
1513  "Cannot create AutoRegFactory for " +
1514  fn +
1515  ". As a result, current template file will remain set to " +
1516  p_templateFileName, _FILEINFO_);
1517  QString message = fullError.toString();
1518  QMessageBox::information((QWidget *)parent(), "Error", message);
1519  return false;
1520  }
1521  }
1522 
1523 
1530  void ControlPointEdit::allowLeftMouse(bool allowMouse) {
1531  p_allowLeftMouse = allowMouse;
1532 
1533  if (p_allowLeftMouse) {
1534  p_saveMeasure = new QPushButton("Save Measures");
1535  p_saveMeasure->setToolTip("Save the both the left and right measure to the edit control "
1536  "point (control point currently being edited). "
1537  " <strong>Note: The edit control point "
1538  "will not be saved to the network until you select "
1539  "<strong>\"Save Point\"</strong>");
1540  }
1541  else {
1542  p_saveMeasure = new QPushButton("Save Measure");
1543  p_saveMeasure->setToolTip("Save the right measure to the edit control "
1544  "point (control point currently being edited). "
1545  " <strong>Note: The edit control point "
1546  "will not be saved to the network until you select "
1547  "<strong>\"Save Point\"</strong>");
1548  }
1549  }
1550 
1551 
1552 
1553  void ControlPointEdit::refreshChips() {
1554  p_leftView->update();
1555  p_rightView->update();
1556  }
1557 
1558 
1559 
1569 
1570 // if (!p_autoRegShown) {
1571  if ( !p_autoRegAttempted ) {
1572  QString message = "Point must be Registered before chips can be saved.";
1573  QMessageBox::warning((QWidget *)parent(), "Warning", message);
1574  return;
1575  }
1576 
1577  // Save chips - pattern, search and fit
1578  QString baseFile = p_pointId.replace(" ", "_") + "_" +
1579  toString((int)(p_leftMeasure ->GetSample())) + "_" +
1580  toString((int)(p_leftMeasure ->GetLine())) + "_" +
1581  toString((int)(p_rightMeasure->GetSample())) + "_" +
1582  toString((int)(p_rightMeasure->GetLine())) + "_";
1583  QString fname = baseFile + "Search.cub";
1584  QString command = "$ISISROOT/bin/qview \'" + fname + "\'";
1585  p_autoRegFact->RegistrationSearchChip()->Write(fname);
1586  fname = baseFile + "Pattern.cub";
1587  command += " \'" + fname + "\'";
1588  p_autoRegFact->RegistrationPatternChip()->Write(fname);
1589  fname = baseFile + "Fit.cub";
1590  command += " \'" + fname + "\' &";
1591  p_autoRegFact->FitChip()->Write(fname);
1593  }
1594 }
1595