Isis 3 Programmer Reference
MosaicGridToolConfigDialog.cpp
1 #include "MosaicGridToolConfigDialog.h"
2 
3 #include <QCheckBox>
4 #include <QComboBox>
5 #include <QDebug>
6 #include <QDialog>
7 #include <QDoubleValidator>
8 #include <QElapsedTimer>
9 #include <QGridLayout>
10 #include <QLabel>
11 #include <QLineEdit>
12 #include <QMessageBox>
13 #include <QPushButton>
14 #include <QSlider>
15 #include <QtWidgets>
16 
17 #include "Angle.h"
18 #include "IException.h"
19 #include "Latitude.h"
20 #include "Longitude.h"
21 #include "MosaicGridTool.h"
22 #include "MosaicGridToolConfigDialog.h"
23 #include "MosaicSceneWidget.h"
24 #include "Projection.h"
25 #include "PvlGroup.h"
26 
27 namespace Isis {
35  MosaicGridTool *tool, QWidget *parent) : QDialog(parent) {
36 
37  /*
38  * What's This' provided here were written by Tammy Becker (2011-12-05) with
39  * help from Steven Lambright.
40  */
41  m_tool = tool;
42 
43  setWindowTitle("Grid Options");
44 
45  QGridLayout *mainLayout = new QGridLayout;
46  setLayout(mainLayout);
47 
48  int row = 0;
49 
50  QString showGridWhatsThis =
51  "Check or uncheck to draw or clear the grid.";
52  QLabel *showGridLabel = new QLabel("&Show Grid");
53  showGridLabel->setWhatsThis(showGridWhatsThis);
54  mainLayout->addWidget(showGridLabel, row, 0, 1, 2);
55 
56  m_showGridCheckBox = new QCheckBox;
57  showGridLabel->setBuddy(m_showGridCheckBox);
58  m_showGridCheckBox->setWhatsThis(showGridWhatsThis);
59  connect(m_showGridCheckBox, SIGNAL(toggled(bool)),
60  this, SLOT(refreshWidgetStates()));
61  mainLayout->addWidget(m_showGridCheckBox, row, 3, 1, 2, Qt::AlignRight);
62  row++;
63 
64  QString autoGridWhatsThis =
65  "Draws a grid based on the current lat/lon extents (from the cubes, map, or user).";
66  QLabel *autoGridLabel = new QLabel("Auto &Grid");
67  autoGridLabel->setWhatsThis(autoGridWhatsThis);
68  mainLayout->addWidget(autoGridLabel, row, 0, 1, 2);
69 
70  m_autoGridCheckBox = new QCheckBox;
71  autoGridLabel->setBuddy(m_autoGridCheckBox);
72  m_autoGridCheckBox->setWhatsThis(autoGridWhatsThis);
73  connect(m_autoGridCheckBox, SIGNAL(toggled(bool)),
74  this, SLOT(refreshWidgetStates()));
75  mainLayout->addWidget(m_autoGridCheckBox, row, 3, 1, 2, Qt::AlignRight);
76  row++;
77 
78  QString baseLatWhatsThis =
79  "The origin for the first latitude line. The first line of the grid "
80  "will be drawn at the base latitude. Successive latitude lines will "
81  "then be drawn relative to base latitude at an increment defined by "
82  "the latitude increment. Base latitude can be outside the range of "
83  "the image data.";
84  m_baseLatLabel = new QLabel("Base Latitude");
85  m_baseLatLabel->setWhatsThis(baseLatWhatsThis);
86  mainLayout->addWidget(m_baseLatLabel, row, 0, 1, 2);
87 
88  m_baseLatSlider = new QSlider(Qt::Horizontal);
89  m_baseLatSlider->setRange(0, 100);
90  m_baseLatSlider->setWhatsThis(baseLatWhatsThis);
91  connect(m_baseLatSlider, SIGNAL(valueChanged(int)),
92  this, SLOT(onBaseLatSliderChanged()));
93  mainLayout->addWidget(m_baseLatSlider, row, 2, 1, 1);
94 
95  m_baseLatLineEdit = new QLineEdit("0");
96  m_baseLatLineEdit->setValidator(new QDoubleValidator(-90.0, 90.0, 99, this));
97  m_baseLatLineEdit->setWhatsThis(baseLatWhatsThis);
98  connect(m_baseLatLineEdit, SIGNAL(textChanged(const QString &)),
99  this, SLOT(refreshWidgetStates()));
100  mainLayout->addWidget(m_baseLatLineEdit, row, 3, 1, 1);
101 
102  m_baseLatTypeLabel = new QLabel("Degrees");
103  mainLayout->addWidget(m_baseLatTypeLabel, row, 4, 1, 1);
104  row++;
105 
106  QString baseLonWhatsThis =
107  "The origin for the first longitude line. The first line of the grid"
108  " will be drawn at the base longitude. Successive longitude lines will"
109  " then be drawn relative to base longitude at an increment defined by"
110  " the longitude increment. Base longitude can be outside the range of"
111  " the image data.";
112  m_baseLonLabel = new QLabel("Base Longitude");
113  m_baseLonLabel->setWhatsThis(baseLonWhatsThis);
114  mainLayout->addWidget(m_baseLonLabel, row, 0, 1, 2);
115 
116  m_baseLonSlider = new QSlider(Qt::Horizontal);
117  m_baseLonSlider->setRange(0, 100);
118  m_baseLonSlider->setWhatsThis(baseLonWhatsThis);
119  connect(m_baseLonSlider, SIGNAL(valueChanged(int)),
120  this, SLOT(onBaseLonSliderChanged()));
121  mainLayout->addWidget(m_baseLonSlider, row, 2, 1, 1);
122 
123  m_baseLonLineEdit = new QLineEdit("0");
124  m_baseLonLineEdit->setValidator(new QDoubleValidator(this));
125  m_baseLonLineEdit->setWhatsThis(baseLonWhatsThis);
126  connect(m_baseLonLineEdit, SIGNAL(textChanged(const QString &)),
127  this, SLOT(refreshWidgetStates()));
128  mainLayout->addWidget(m_baseLonLineEdit, row, 3, 1, 1);
129 
130  m_baseLonTypeLabel = new QLabel("Degrees");
131  mainLayout->addWidget(m_baseLonTypeLabel, row, 4, 1, 1);
132  row++;
133 
134  QString latIncWhatsThis =
135  "The latitude increment is how often a line is drawn as the latitude "
136  "values change. A latitude increment of 45 will result in a line at "
137  "latitude = -90, -45, 0, 45, 90 for the entire longitude range.";
138  m_latIncLabel = new QLabel("Latitude Increment");
139  m_latIncLabel->setWhatsThis(latIncWhatsThis);
140  mainLayout->addWidget(m_latIncLabel, row, 0, 1, 2);
141 
142  m_latIncSlider = new QSlider(Qt::Horizontal);
143  m_latIncSlider->setRange(1, 180);
144  m_latIncSlider->setWhatsThis(latIncWhatsThis);
145  connect(m_latIncSlider, SIGNAL(valueChanged(int)),
146  this, SLOT(onLatIncSliderChanged()));
147  mainLayout->addWidget(m_latIncSlider, row, 2, 1, 1);
148 
149  m_latIncLineEdit = new QLineEdit("45");
150  m_latIncLineEdit->setValidator(new QDoubleValidator(0, 180.0, 15, this));
151  m_latIncLineEdit->setWhatsThis(latIncWhatsThis);
152  connect(m_latIncLineEdit, SIGNAL(textChanged(const QString &)),
153  this, SLOT(refreshWidgetStates()));
154  mainLayout->addWidget(m_latIncLineEdit, row, 3, 1, 1);
155 
156  m_latIncTypeLabel = new QLabel("Degrees");
157  mainLayout->addWidget(m_latIncTypeLabel, row, 4, 1, 1);
158  row++;
159 
160  QString lonIncWhatsThis =
161  "The longitude increment is how often a line is drawn as the longitude "
162  "values change. A longitude increment of 180 will result in a line at "
163  "longitude = 0, 180, 360 for the entire latitude range.";
164  m_lonIncLabel = new QLabel("Longitude Increment");
165  m_lonIncLabel->setWhatsThis(lonIncWhatsThis);
166  mainLayout->addWidget(m_lonIncLabel, row, 0, 1, 2);
167 
168  m_lonIncSlider = new QSlider(Qt::Horizontal);
169  m_lonIncSlider->setRange(1, 360);
170  m_lonIncSlider->setWhatsThis(lonIncWhatsThis);
171  connect(m_lonIncSlider, SIGNAL(valueChanged(int)),
172  this, SLOT(onLonIncSliderChanged()));
173  mainLayout->addWidget(m_lonIncSlider, row, 2, 1, 1);
174 
175  m_lonIncLineEdit = new QLineEdit("45");
176  m_lonIncLineEdit->setValidator(new QDoubleValidator(this));
177  m_lonIncLineEdit->setWhatsThis(lonIncWhatsThis);
178  connect(m_lonIncLineEdit, SIGNAL(textChanged(const QString &)),
179  this, SLOT(refreshWidgetStates()));
180  mainLayout->addWidget(m_lonIncLineEdit, row, 3, 1, 1);
181 
182  m_lonIncTypeLabel = new QLabel("Degrees");
183  mainLayout->addWidget(m_lonIncTypeLabel, row, 4, 1, 1);
184  row++;
185  mainLayout->setRowMinimumHeight(row, 10);
186  row++;
187 
188  QString latExtentWhatsThis =
189  "The longitude range determines the extents of the grid. The \"Read Map File\" option will "
190  "derive the extents from the loaded map's projection. The \"Compute From Images\" option "
191  "will use the ranges covered by the open cubes. The \"Manual\" option allows you to enter "
192  "values of your choice.";
193  m_latExtentLabel = new QLabel("Latitude Range");
194  m_latExtentLabel->setWhatsThis(latExtentWhatsThis);
195  mainLayout->addWidget(m_latExtentLabel, row, 0, 1, 2);
196 
197  m_latExtentCombo = new QComboBox;
198  m_latExtentCombo->addItem("Read Map File", MosaicGridTool::Map);
199  m_latExtentCombo->addItem("Compute From Images", MosaicGridTool::Cubes);
200  m_latExtentCombo->addItem("Manual", MosaicGridTool::Manual);
201  m_latExtentCombo->setCurrentIndex(m_latExtentCombo->findData(m_tool->latExtents()));
202  m_latExtentCombo->setWhatsThis(latExtentWhatsThis);
203  connect(m_latExtentCombo, SIGNAL(currentIndexChanged(int)),
204  this, SLOT(onExtentTypeChanged()));
205  mainLayout->addWidget(m_latExtentCombo, row, 2, 1, 2);
206  m_latExtentTypeLabel = new QLabel(m_tool->latType());
207  mainLayout->addWidget(m_latExtentTypeLabel, row, 4, 1, 1);
208  row++;
209 
210 
211  QString minLatWhatsThis =
212  "The minimum latitude will be the lower edge of the grid. This parameter currently "
213  "expects degree input.";
214  m_minLatExtentLabel = new QLabel("Minimum Latitude");
215  m_minLatExtentLabel->setWhatsThis(minLatWhatsThis);
216  mainLayout->addWidget(m_minLatExtentLabel, row, 1, 1, 1);
217 
218  m_minLatExtentSlider = new QSlider(Qt::Horizontal);
219  m_minLatExtentSlider->setRange(-90, 90);
220  m_minLatExtentSlider->setWhatsThis(minLatWhatsThis);
221  connect(m_minLatExtentSlider, SIGNAL(valueChanged(int)),
222  this, SLOT(onMinLatExtentSliderChanged()));
223  mainLayout->addWidget(m_minLatExtentSlider, row, 2, 1, 1);
224 
225  m_minLatExtentLineEdit = new QLineEdit("0");
226  m_minLatExtentLineEdit->setValidator(new QDoubleValidator(this));
227  m_minLatExtentLineEdit->setWhatsThis(minLatWhatsThis);
228  connect(m_minLatExtentLineEdit, SIGNAL(textChanged(const QString &)),
229  this, SLOT(refreshWidgetStates()));
230  mainLayout->addWidget(m_minLatExtentLineEdit, row, 3, 1, 1);
231  m_minLatExtentTypeLabel = new QLabel("Degrees");
232  mainLayout->addWidget(m_minLatExtentTypeLabel, row, 4, 1, 1);
233  row++;
234 
235  QString maxLatWhatsThis =
236  "The maximum latitude will be the upper edge of the grid. This parameter currently "
237  "expects degree input.";
238  m_maxLatExtentLabel = new QLabel("Maximum Latitude");
239  m_maxLatExtentLabel->setWhatsThis(maxLatWhatsThis);
240  mainLayout->addWidget(m_maxLatExtentLabel, row, 1, 1, 1);
241 
242  m_maxLatExtentSlider = new QSlider(Qt::Horizontal);
243  m_maxLatExtentSlider->setRange(-90, 90);
244  m_maxLatExtentSlider->setWhatsThis(maxLatWhatsThis);
245  connect(m_maxLatExtentSlider, SIGNAL(valueChanged(int)),
246  this, SLOT(onMaxLatExtentSliderChanged()));
247  mainLayout->addWidget(m_maxLatExtentSlider, row, 2, 1, 1);
248 
249  m_maxLatExtentLineEdit = new QLineEdit("0");
250  m_maxLatExtentLineEdit->setValidator(new QDoubleValidator(this));
251  m_maxLatExtentLineEdit->setWhatsThis(maxLatWhatsThis);
252  connect(m_maxLatExtentLineEdit, SIGNAL(textChanged(const QString &)),
253  this, SLOT(refreshWidgetStates()));
254  mainLayout->addWidget(m_maxLatExtentLineEdit, row, 3, 1, 1);
255  m_maxLatExtentTypeLabel = new QLabel("Degrees");
256  mainLayout->addWidget(m_maxLatExtentTypeLabel, row, 4, 1, 1);
257  row++;
258  mainLayout->setRowMinimumHeight(row, 10);
259  row++;
260 
261  QString lonExtentWhatsThis =
262  "The longitude range determines the extents of the grid. The \"<b>Read Map File</b>\" "
263  "option will derive the extents from the loaded map's projection. The"
264  "\"Compute From Images\" option will use the ranges covered by the open cubes. The "
265  "\"Manual\" option allows you to enter "
266  "values of your choice. The domain is that of the map projection.";
267  m_lonExtentLabel = new QLabel("Longitude Range");
268  m_lonExtentLabel->setWhatsThis(lonExtentWhatsThis);
269  mainLayout->addWidget(m_lonExtentLabel, row, 0, 1, 2);
270 
271  m_lonExtentCombo = new QComboBox;
272  m_lonExtentCombo->addItem("Read Map File", MosaicGridTool::Map);
273  m_lonExtentCombo->addItem("Compute From Images", MosaicGridTool::Cubes);
274  m_lonExtentCombo->addItem("Manual", MosaicGridTool::Manual);
275 
276  m_lonExtentCombo->setCurrentIndex(m_lonExtentCombo->findData(m_tool->lonExtents()));
277  m_lonExtentCombo->setWhatsThis(lonExtentWhatsThis);
278  connect(m_lonExtentCombo, SIGNAL(currentIndexChanged(int)),
279  this, SLOT(onExtentTypeChanged()));
280  mainLayout->addWidget(m_lonExtentCombo, row, 2, 1, 2);
281 
282  m_lonDomainLabel = new QLabel(m_tool->lonDomain() + " Domain");
283  mainLayout->addWidget(m_lonDomainLabel, row, 4, 1, 1);
284  row++;
285 
286  QString minLonWhatsThis =
287  "The maximum longitude will be the left edge of the grid. This parameter currently "
288  "expects degree input.";
289  m_minLonExtentLabel = new QLabel("Minimum Longitude");
290  m_minLonExtentLabel->setWhatsThis(minLonWhatsThis);
291  mainLayout->addWidget(m_minLonExtentLabel, row, 1, 1, 1);
292 
293  m_minLonExtentSlider = new QSlider(Qt::Horizontal);
294  m_minLonExtentSlider->setRange(0, 360);
295  m_minLonExtentSlider->setWhatsThis(minLonWhatsThis);
296  connect(m_minLonExtentSlider, SIGNAL(valueChanged(int)),
297  this, SLOT(onMinLonExtentSliderChanged()));
298  mainLayout->addWidget(m_minLonExtentSlider, row, 2, 1, 1);
299 
300  m_minLonExtentLineEdit = new QLineEdit("0");
301  m_minLonExtentLineEdit->setValidator(new QDoubleValidator(this));
302  m_minLonExtentLineEdit->setWhatsThis(minLonWhatsThis);
303  connect(m_minLonExtentLineEdit, SIGNAL(textChanged(const QString &)),
304  this, SLOT(refreshWidgetStates()));
305  mainLayout->addWidget(m_minLonExtentLineEdit, row, 3, 1, 1);
306  m_minLonExtentTypeLabel = new QLabel("Degrees");
307  mainLayout->addWidget(m_minLonExtentTypeLabel, row, 4, 1, 1);
308  row++;
309 
310  QString maxLonWhatsThis =
311  "The maximum longitude will be the right edge of the grid. This parameter currently "
312  "expects degree input.";
313  m_maxLonExtentLabel = new QLabel("Maximum Longitude");
314  m_maxLonExtentLabel->setWhatsThis(maxLonWhatsThis);
315  mainLayout->addWidget(m_maxLonExtentLabel, row, 1, 1, 1);
316 
317  m_maxLonExtentSlider = new QSlider(Qt::Horizontal);
318  m_maxLonExtentSlider->setRange(0, 360);
319  m_maxLonExtentSlider->setWhatsThis(maxLonWhatsThis);
320  connect(m_maxLonExtentSlider, SIGNAL(valueChanged(int)),
321  this, SLOT(onMaxLonExtentSliderChanged()));
322  mainLayout->addWidget(m_maxLonExtentSlider, row, 2, 1, 1);
323 
324  m_maxLonExtentLineEdit = new QLineEdit("0");
325  m_maxLonExtentLineEdit->setValidator(new QDoubleValidator(this));
326  m_maxLonExtentLineEdit->setWhatsThis(maxLonWhatsThis);
327  connect(m_maxLonExtentLineEdit, SIGNAL(textChanged(const QString &)),
328  this, SLOT(refreshWidgetStates()));
329  mainLayout->addWidget(m_maxLonExtentLineEdit, row, 3, 1, 1);
330  m_maxLonExtentTypeLabel = new QLabel("Degrees");
331  mainLayout->addWidget(m_maxLonExtentTypeLabel, row, 4, 1, 1);
332  row++;
333  mainLayout->setRowMinimumHeight(row, 10);
334  row++;
335 
336  QString densityWhatsThis =
337  "The density is the estimated total number of straight lines used "
338  "to create the grid. Increasing this number will significantly slow "
339  "down the drawing of the grid while making curves more accurate. If "
340  "the grid does not look accurate then try increasing this number.";
341  m_densityLabel = new QLabel("Grid Line Density");
342  m_densityLabel->setWhatsThis(densityWhatsThis);
343  mainLayout->addWidget(m_densityLabel, row, 0, 1, 2);
344 
345  m_densityEdit = new QLineEdit("10000");
346  m_densityEdit->setValidator(new QIntValidator(1, INT_MAX, this));
347  m_densityEdit->setWhatsThis(densityWhatsThis);
348  connect(m_densityEdit, SIGNAL(textChanged(const QString &)),
349  this, SLOT(refreshWidgetStates()));
350  mainLayout->addWidget(m_densityEdit, row, 2, 1, 2);
351  row++;
352  mainLayout->setRowMinimumHeight(row, 10);
353  row++;
354 
355  QHBoxLayout *buttonsAreaLayout = new QHBoxLayout;
356  mainLayout->addLayout(buttonsAreaLayout, row, 0, 1, 4);
357 
358  QString autoApplyWhatsThis =
359  "Automatically updates the grid when parameters are changed.";
360  m_autoApplyCheckBox = new QCheckBox("Auto Apply");
361  m_autoApplyCheckBox->setChecked(true);
362  buttonsAreaLayout->addWidget(m_autoApplyCheckBox);
363 
364  buttonsAreaLayout->addStretch();
365 
366  QPushButton *okayButton = new QPushButton("&Ok");
367  okayButton->setIcon(QIcon::fromTheme("dialog-ok"));
368  connect(okayButton, SIGNAL(clicked()),
369  this, SLOT(applySettings()));
370  connect(okayButton, SIGNAL(clicked()),
371  this, SLOT(accept()));
372  buttonsAreaLayout->addWidget(okayButton);
373 
374  QPushButton *applyButton = new QPushButton("&Apply");
375  applyButton->setIcon(QIcon::fromTheme("dialog-ok-apply"));
376  connect(applyButton, SIGNAL(clicked()),
377  this, SLOT(applySettings()));
378  buttonsAreaLayout->addWidget(applyButton);
379 
380  QPushButton *cancelButton = new QPushButton("&Cancel");
381  cancelButton->setIcon(QIcon::fromTheme("dialog-cancel"));
382  connect(cancelButton, SIGNAL(clicked()),
383  this, SLOT(reject()));
384  buttonsAreaLayout->addWidget(cancelButton);
385 
386  connect(m_tool, SIGNAL(boundingRectChanged()), this, SLOT(readSettings()));
387 
388  readSettings();
389  }
390 
395  }
396 
397 
402  void MosaicGridToolConfigDialog::applySettings(bool shouldReadSettings) {
403 
404  int cursorPos = 0;
405 
406  // Validate base latitude value
407  QString baseLatitude = m_baseLatLineEdit->text();
408  if (m_baseLatLineEdit->isEnabled()) {
409  QValidator::State validBaseLat =
410  m_baseLatLineEdit->validator()->validate(baseLatitude, cursorPos);
411  if (validBaseLat != QValidator::Acceptable) {
413  "Base Latitude value must be in the range -90 to 90",
414  _FILEINFO_);
415  }
416  }
417 
418  // Validate base longitude value
419  QString baseLongitude = m_baseLonLineEdit->text();
420  QValidator::State validBaseLon =
421  m_baseLonLineEdit->validator()->validate(baseLongitude, cursorPos);
422  if (validBaseLon != QValidator::Acceptable) {
424  "Base Longitude value must be a double",
425  _FILEINFO_);
426  }
427 
428  // Validate latitudeInc value
429  QString latitudeInc = m_latIncLineEdit->text();
430  QValidator::State validLatInc = m_latIncLineEdit->validator()->validate(latitudeInc,
431  cursorPos);
432  if (validLatInc != QValidator::Acceptable) {
434  "Latitude increment must be in the range 0 to 180",
435  _FILEINFO_);
436  }
437 
438  // Validate longitudeInc value
439  QString longitudeInc = m_lonIncLineEdit->text();
440  QValidator::State validLonInc =
441  m_lonIncLineEdit->validator()->validate(longitudeInc, cursorPos);
442  if (validLonInc != QValidator::Acceptable) {
444  "Longitude increment must be a double",
445  _FILEINFO_);
446  }
447 
448  // Validate minLatExtent value
449  QString minLatExtent = m_minLatExtentLineEdit->text();
450  QValidator::State validMinLatExtent =
451  m_minLatExtentLineEdit->validator()->validate(minLatExtent, cursorPos);
452  if (validMinLatExtent != QValidator::Acceptable) {
454  "Minimum latitude extent must be a double",
455  _FILEINFO_);
456  }
457 
458  // Validate maxLatExtent value
459  QString maxLatExtent = m_maxLatExtentLineEdit->text();
460  QValidator::State validMaxLatExtent =
461  m_maxLatExtentLineEdit->validator()->validate(maxLatExtent, cursorPos);
462  if (validMaxLatExtent != QValidator::Acceptable) {
464  "Maximum latitude extent must be a double",
465  _FILEINFO_);
466  }
467 
468  // Validate minLonExtent value
469  QString minLonExtent = m_minLonExtentLineEdit->text();
470  QValidator::State validMinLonExtent =
471  m_minLonExtentLineEdit->validator()->validate(minLonExtent, cursorPos);
472  if (validMinLonExtent != QValidator::Acceptable) {
474  "Minimum longitude extent must be a double",
475  _FILEINFO_);
476  }
477 
478  // Validate maxLonExtent value
479  QString maxLonExtent = m_maxLonExtentLineEdit->text();
480  QValidator::State validMaxLonExtent =
481  m_maxLonExtentLineEdit->validator()->validate(maxLonExtent, cursorPos);
482  if (validMaxLonExtent != QValidator::Acceptable) {
484  "Maximum longitude extent must be a double",
485  _FILEINFO_);
486  }
487 
488  // Validate density value
489  QString density = m_densityEdit->text();
490  QValidator::State validDensity =
491  m_densityEdit->validator()->validate(density, cursorPos);
492  if (validDensity != QValidator::Acceptable) {
494  "Density must be a non-zero positive integer",
495  _FILEINFO_);
496  }
497 
498  if (m_tool->sceneWidget()->getProjection()) {
499  PvlGroup mapGroup(m_tool->sceneWidget()->getProjection()->Mapping());
500 
501  m_tool->setShowGrid(m_showGridCheckBox->isChecked());
502  m_tool->setAutoGridCheckBox(m_autoGridCheckBox->isChecked());
503 
504  m_tool->setBaseLat(Latitude(baseLatitude.toDouble(), mapGroup, Angle::Degrees));
505  m_tool->setBaseLon(Longitude(baseLongitude.toDouble(), Angle::Degrees));
506  m_tool->setLatInc(Angle(latitudeInc.toDouble(), Angle::Degrees));
507  m_tool->setLonInc(Angle(longitudeInc.toDouble(), Angle::Degrees));
508 
510  m_latExtentCombo->itemData(m_latExtentCombo->currentIndex()).toInt(),
511  Latitude(minLatExtent.toDouble(), mapGroup, Angle::Degrees),
512  Latitude(maxLatExtent.toDouble(), mapGroup, Angle::Degrees));
514  m_lonExtentCombo->itemData(m_lonExtentCombo->currentIndex()).toInt(),
515  Longitude(minLonExtent.toDouble(), Angle::Degrees),
516  Longitude(maxLonExtent.toDouble(), Angle::Degrees));
517 
518  m_tool->setDensity(density.toInt());
519 
520  if (m_showGridCheckBox->isChecked() && m_autoGridCheckBox->isChecked())
521  m_tool->autoGrid(m_autoGridCheckBox->isChecked());
522  else if (m_showGridCheckBox->isChecked())
523  m_tool->drawGrid();
524  else
525  m_tool->clearGrid();
526 
527  if (shouldReadSettings)
528  readSettings();
529  }
530  }
531 
532 
537  applySettings(true);
538  }
539 
540 
545 
546  if (m_tool->sceneWidget()->getProjection()) {
547  // Don't auto apply until we're done
548  bool autoApply = m_autoApplyCheckBox->isChecked();
549  m_autoApplyCheckBox->setChecked(false);
550 
551  m_showGridCheckBox->setChecked(m_tool->showGrid());
552  m_autoGridCheckBox->setChecked(m_tool->autoGridCheckBox());
553  m_baseLonLineEdit->setText(QString::number(m_tool->baseLon().degrees()));
554 
555  m_latIncLineEdit->setText(QString::number(m_tool->latInc().degrees()));
556  m_lonIncLineEdit->setText(QString::number(m_tool->lonInc().degrees()));
557 
558  Latitude minLat = m_tool->minLat();
559  Latitude maxLat = m_tool->maxLat();
560  m_latExtentCombo->setCurrentIndex(m_latExtentCombo->findData(m_tool->latExtents()));
561  if (m_tool->sceneWidget()->getProjection()->Mapping()["LatitudeType"][0] ==
562  "Planetocentric") {
563 
564  m_baseLatLineEdit->setText(QString::number(m_tool->baseLat().degrees()));
565  m_minLatExtentLineEdit->setText(QString::number(minLat.degrees()));
566  m_maxLatExtentLineEdit->setText(QString::number(maxLat.degrees()));
567  }
568  else {
569  m_baseLatLineEdit->setText(QString::number(
571  m_minLatExtentLineEdit->setText(QString::number(
572  minLat.planetographic(Angle::Degrees)));
573  m_maxLatExtentLineEdit->setText(QString::number(
574  maxLat.planetographic(Angle::Degrees)));
575  }
576 
577  Angle minLon = m_tool->minLon();
578  Angle maxLon = m_tool->maxLon();
579  m_lonExtentCombo->setCurrentIndex(m_lonExtentCombo->findData(m_tool->lonExtents()));
580  m_minLonExtentLineEdit->setText(QString::number(minLon.degrees()));
581  m_maxLonExtentLineEdit->setText(QString::number(maxLon.degrees()));
582 
583  m_densityEdit->setText(QString::number(m_tool->density()));
584 
585  // Now we can restore auto apply
586  m_autoApplyCheckBox->setChecked(autoApply);
587  }
588  else {
589  refreshWidgetStates(false);
590  }
591  }
592 
593 
599  refreshWidgetStates(true);
600  }
601 
602 
608 
609  QElapsedTimer timer;
610  timer.start();
611 
612  bool enabled = m_tool->sceneWidget()->getProjection();
613  bool showGrid = enabled && m_showGridCheckBox->isChecked();
614  bool autoGrid = enabled && m_autoGridCheckBox->isChecked();
615  bool enableLatExtents = ( (MosaicGridTool::GridExtentSource)
616  m_latExtentCombo->itemData(m_latExtentCombo->currentIndex()).toInt() ==
617  MosaicGridTool::Manual ) && showGrid;
618  bool enableLonExtents = ( (MosaicGridTool::GridExtentSource)
619  m_lonExtentCombo->itemData(m_lonExtentCombo->currentIndex()).toInt() ==
620  MosaicGridTool::Manual ) && showGrid;
621 
622  m_autoGridCheckBox->setEnabled(showGrid);
623 
624  m_baseLatLabel->setEnabled(showGrid);
625  m_baseLatSlider->setEnabled(showGrid);
626  m_baseLatSlider->blockSignals(true);
627  m_baseLatSlider->setValue(
628  qRound(100 * m_baseLatLineEdit->text().toDouble() / m_latIncLineEdit->text().toDouble()));
629  m_baseLatSlider->blockSignals(false);
630  m_baseLatLineEdit->setEnabled(showGrid);
631  m_baseLatTypeLabel->setEnabled(showGrid);
632 
633  m_baseLonLabel->setEnabled(showGrid);
634  m_baseLonSlider->setEnabled(showGrid);
635  m_baseLonSlider->blockSignals(true);
636  m_baseLonSlider->setValue(
637  qRound(100 * m_baseLonLineEdit->text().toDouble() / m_lonIncLineEdit->text().toDouble()));
638  m_baseLonSlider->blockSignals(false);
639  m_baseLonLineEdit->setEnabled(showGrid);
640  m_baseLonTypeLabel->setEnabled(showGrid);
641 
642  m_latIncLabel->setEnabled(showGrid && !autoGrid);
643  m_latIncLineEdit->setEnabled(!autoGrid && showGrid);
644  m_latIncSlider->blockSignals(true);
645  m_latIncSlider->setEnabled(showGrid && !autoGrid);
646  m_latIncSlider->setValue(m_latIncLineEdit->text().toDouble());
647  m_latIncSlider->blockSignals(false);
648  m_latIncTypeLabel->setEnabled(showGrid && !autoGrid);
649 
650  m_lonIncLabel->setEnabled(showGrid && !autoGrid);
651  m_lonIncLineEdit->setEnabled(showGrid && !autoGrid);
652  m_lonIncSlider->blockSignals(true);
653  m_lonIncSlider->setEnabled(!autoGrid);
654  m_lonIncSlider->setValue(m_lonIncLineEdit->text().toDouble());
655  m_lonIncSlider->blockSignals(false);
656  m_lonIncTypeLabel->setEnabled(showGrid && !autoGrid);
657 
658  m_latExtentLabel->setEnabled(showGrid);
659  m_latExtentCombo->setEnabled(showGrid);
660  m_latExtentTypeLabel->setEnabled(showGrid);
661 
662  m_minLatExtentLabel->setEnabled(enableLatExtents);
663  m_minLatExtentLabel->setEnabled(enableLatExtents);
664  m_minLatExtentSlider->blockSignals(true);
665  m_minLatExtentSlider->setValue(
666  qRound(m_minLatExtentLineEdit->text().toDouble()));
667  m_minLatExtentSlider->blockSignals(false);
668  m_minLatExtentLineEdit->setEnabled(enableLatExtents);
669  m_minLatExtentTypeLabel->setEnabled(enableLatExtents);
670 
671  m_maxLatExtentLabel->setEnabled(enableLatExtents);
672  m_maxLatExtentSlider->setEnabled(enableLatExtents);
673  m_maxLatExtentSlider->blockSignals(true);
674  m_maxLatExtentSlider->setValue(
675  qRound(m_maxLatExtentLineEdit->text().toDouble()));
676  m_maxLatExtentSlider->blockSignals(false);
677  m_maxLatExtentLineEdit->setEnabled(enableLatExtents);
678  m_maxLatExtentTypeLabel->setEnabled(enableLatExtents);
679 
680  m_lonExtentLabel->setEnabled(showGrid);
681  m_lonExtentCombo->setEnabled(showGrid);
682  m_lonDomainLabel->setEnabled(showGrid);
683 
684  m_minLonExtentLabel->setEnabled(enableLonExtents);
685  m_minLonExtentSlider->setRange(m_tool->domainMinLon().degrees(),
686  m_tool->domainMaxLon().degrees());
687  m_minLonExtentSlider->setEnabled(enableLonExtents);
688  m_minLonExtentSlider->blockSignals(true);
689  m_minLonExtentSlider->setValue(m_minLonExtentLineEdit->text().toDouble());
690  m_minLonExtentSlider->blockSignals(false);
691  m_minLonExtentLineEdit->setEnabled(enableLonExtents);
692  m_minLonExtentTypeLabel->setEnabled(enableLonExtents);
693 
694  m_maxLonExtentLabel->setEnabled(enableLonExtents);
695  m_maxLonExtentSlider->setRange(m_tool->domainMinLon().degrees(),
696  m_tool->domainMaxLon().degrees());
697  m_maxLonExtentSlider->setEnabled(enableLonExtents);
698  m_maxLonExtentSlider->blockSignals(true);
699  m_maxLonExtentSlider->setValue(m_maxLonExtentLineEdit->text().toDouble());
700  m_maxLonExtentSlider->blockSignals(false);
701  m_maxLonExtentLineEdit->setEnabled(enableLonExtents);
702  m_maxLonExtentTypeLabel->setEnabled(enableLonExtents);
703 
704  m_densityLabel->setEnabled(showGrid);
705  m_densityEdit->setEnabled(showGrid);
706 
707  if (m_autoApplyCheckBox->isChecked() && canAutoApply) {
708  try {
709  if(m_autoGridCheckBox->isChecked())
710  applySettings(true);
711  else
712  applySettings(false);
713  }
714  catch (IException &) {
715  }
716 
717  //Time in milliseconds
718  if (timer.elapsed() > 250) {
719  m_densityEdit->setText(QString::number(
720  qMax(1000, qRound(m_densityEdit->text().toInt() * 0.75))));
721  }
722  }
723  }
724 
729  m_baseLatLineEdit->setText(
730  QString::number( (m_baseLatSlider->value() / 100.0) * m_latIncLineEdit->text().toDouble() ));
731  }
732 
733 
738  m_baseLonLineEdit->setText(
739  QString::number( (m_baseLonSlider->value() / 100.0) * m_lonIncLineEdit->text().toDouble() ));
740  }
741 
742 
747  m_latIncLineEdit->setText(QString::number(m_latIncSlider->value()));
748  }
749 
750 
755  m_lonIncLineEdit->setText(QString::number(m_lonIncSlider->value()));
756  }
757 
758 
763  if (m_minLatExtentSlider->value() < m_maxLatExtentSlider->value()) {
764  m_minLatExtentLineEdit->setText(QString::number(m_minLatExtentSlider->value()));
765  }
766  else {
767  m_minLatExtentSlider->setValue(m_maxLatExtentSlider->value() - 1);
768  }
769  }
770 
771 
776  if (m_maxLatExtentSlider->value() > m_minLatExtentSlider->value()) {
777  m_maxLatExtentLineEdit->setText(QString::number(m_maxLatExtentSlider->value()));
778  }
779  else {
780  m_maxLatExtentSlider->setValue(m_minLatExtentSlider->value() + 1);
781  }
782  }
783 
784 
791  QElapsedTimer timer;
792  timer.start();
793  refreshWidgetStates(false);
794  applySettings(true);
795  //Time in milliseconds
796  if (timer.elapsed() > 250)
797  m_densityEdit->setText(QString::number(1000));
798  }
799 
800 
805  if (m_minLonExtentSlider->value() < m_maxLonExtentSlider->value()) {
806  m_minLonExtentLineEdit->setText(QString::number(m_minLonExtentSlider->value()));
807  }
808  else {
809  m_minLonExtentSlider->setValue(m_maxLonExtentSlider->value() - 1);
810  }
811  }
812 
813 
818  if (m_maxLonExtentSlider->value() > m_minLonExtentSlider->value()) {
819  m_maxLonExtentLineEdit->setText(QString::number(m_maxLonExtentSlider->value()));
820  }
821  else {
822  m_maxLonExtentSlider->setValue(m_minLonExtentSlider->value() + 1);
823  }
824  }
825 }
QPointer< QLineEdit > m_maxLonExtentLineEdit
Input for the maximum longitude.
QPointer< QLabel > m_baseLonLabel
Label for the base longitude.
QPointer< QLineEdit > m_lonIncLineEdit
Input for longitude increment.
QPointer< QLabel > m_latIncTypeLabel
Label for the increment type (degrees/radians)
Latitude maxLat()
The maximum latitude used to determine the grid&#39;s extents and increments.
QPointer< QSlider > m_baseLonSlider
Input for base longitude.
void autoGrid(bool draw)
Calculates the lat/lon increments from the bounding rectangle of the open cubes.
void onBaseLatSliderChanged()
Updates the corresponding line edit when the baseLatSlider changes.
QPointer< QSlider > m_maxLatExtentSlider
Input for the maximum latitude.
Latitude baseLat()
The base latitude.
double planetographic(Angle::Units units=Angle::Radians) const
Get the latitude in the planetographic coordinate system.
Definition: Latitude.cpp:328
QString lonDomain()
The longitude domain of the projection of the scene.
void setLonExtents(GridExtentSource source, Longitude minLon, Longitude maxLon)
Set the maximum and minimum longitude of the grid.
QPointer< QLabel > m_baseLatTypeLabel
Label for the baselat type (degrees/radians)
void setLatExtents(GridExtentSource source, Latitude minLat, Latitude maxLat)
Set the maximum and minimum latitude of the grid.
Longitude minLon()
The minimum longitude used to determine the grid&#39;s extents and increments.
void applySettings()
Slot that calls applySettings with true to call readSettings also.
void setBaseLon(Longitude baseLon)
Modify the base longitude.
void setLonInc(Angle lonInc)
Modify the longitude increment.
void refreshWidgetStates()
Calls the private method refreshWidgetStates with true as the argument in order to have refreshWidget...
QPointer< QLineEdit > m_maxLatExtentLineEdit
Input for the maximum latitude.
The grid will be drawn using the extents that the user specifies.
QPointer< QLabel > m_lonIncLabel
Label for the longitude increment.
int toInt(const QString &string)
Global function to convert from a string to an integer.
Definition: IString.cpp:108
MosaicSceneWidget * sceneWidget()
Longitude baseLon()
The base longitude.
This class is designed to encapsulate the concept of a Latitude.
Definition: Latitude.h:63
GridExtentSource lonExtents()
The extent type (Map, Cubes, Manual) for the longitude.
Angle lonInc()
The angle of the longitude increment.
void clearGrid()
Clears the grid from the scene.
QPointer< QSlider > m_baseLatSlider
Input for base latitude.
QPointer< QCheckBox > m_autoGridCheckBox
True if grid properties come form open cubes.
QPointer< QLabel > m_lonIncTypeLabel
Label for the increment type (degrees/radians)
QPointer< QLabel > m_lonExtentLabel
Label for the longitude range Selection for the longitude extent source (Map, Cube, Manual)
double degrees() const
Get the angle in units of Degrees.
Definition: Angle.h:249
void onMinLatExtentSliderChanged()
Updates the corresponding line edit when the minLatSlider changes.
void readSettings()
Read the tool&#39;s current settings and set the widget states to match.
QPointer< QLabel > m_lonDomainLabel
Label for the longitude domain.
This class is designed to encapsulate the concept of a Longitude.
Definition: Longitude.h:52
The grid will be drawn using the extents from the map projection.
void onMinLonExtentSliderChanged()
Updates the corresponding line edit when the minLonSlider changes.
QPointer< QLabel > m_maxLatExtentLabel
Label for the maximum latitude.
void onMaxLonExtentSliderChanged()
Updates the corresponding line edit when the maxLonSlider changes.
QPointer< QSlider > m_lonIncSlider
Input for longitude increment.
QString latType()
The latitude type (planetocentric/planetographic) of the projection of the scene. ...
Degrees are generally considered more human readable, 0-360 is one circle, however most math does not...
Definition: Angle.h:73
bool autoGridCheckBox()
True if checked.
Longitude maxLon()
The maximum longitude used to determine the grid&#39;s extents and increments.
void setAutoGridCheckBox(bool checked)
Modify the check state of the checkbox.
Latitude minLat()
The minimum latitude used to determine the grid&#39;s extents and increments.
QPointer< QLabel > m_minLonExtentLabel
Label for the minimum longitude.
Contains multiple PvlContainers.
Definition: PvlGroup.h:57
QPointer< QLineEdit > m_densityEdit
Input for grid density.
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:40
void setBaseLat(Latitude baseLat)
Modify the base latitude.
QPointer< QLineEdit > m_minLonExtentLineEdit
Input for the minimum longitude.
A type of error that cannot be classified as any of the other error types.
Definition: IException.h:134
QPointer< QLabel > m_densityLabel
Label for the grid density.
QPointer< QLabel > m_baseLonTypeLabel
Label for the baselon type (degrees/radians)
void setShowGrid(bool show)
Modify the check state of the checkbox.
QPointer< QLabel > m_maxLonExtentLabel
Label for the maximum longitude.
QPointer< QLineEdit > m_baseLonLineEdit
Input for base longitude.
QPointer< QLineEdit > m_latIncLineEdit
Input for latitude increment.
QPointer< QLabel > m_latIncLabel
Label for the latitude increment.
int density()
The density or resolution of the grid.
MosaicGridToolConfigDialog(MosaicGridTool *tool, QWidget *parent)
Create a config dialog that configures the given MosaicGridTool.
QPointer< QLabel > m_minLatExtentLabel
Label for the minimum latitude.
Defines an angle and provides unit conversions.
Definition: Angle.h:62
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
void onLatIncSliderChanged()
Updates the corresponding line edit when the latIncSlider changes.
QPointer< QSlider > m_maxLonExtentSlider
Input for the maximum longitude.
~MosaicGridToolConfigDialog()
Clean up allocated memory.
void onLonIncSliderChanged()
Updates the corresponding line edit when the lonIncSlider changes.
QPointer< QSlider > m_latIncSlider
Input for latitude increment.
The grid will be drawn using the extents from the bounding rectangle of the open cubes.
Isis exception class.
Definition: IException.h:107
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
void drawGrid()
Creates the GridGraphicsItem that will draw the grid.
void onMaxLatExtentSliderChanged()
Updates the corresponding line edit when the maxLatSlider changes.
QPointer< QSlider > m_minLatExtentSlider
Input for the minimum latitude.
GridExtentSource latExtents()
The extent type (Map, Cubes, Manual) for the latitude.
void onBaseLonSliderChanged()
Updates the corresponding line edit when the baseLonSlider changes.
QPointer< QCheckBox > m_showGridCheckBox
The tool we&#39;re configuring.
This controls the &#39;Grid&#39; abilities in the MosaicSceneWidget.
QPointer< QSlider > m_minLonExtentSlider
Input for the minimumlongitude.
QPointer< QLineEdit > m_baseLatLineEdit
Input for base latitude.
bool showGrid()
True if grid is displayed.
void setLatInc(Angle latInc)
Modify the latitude increment.
void setDensity(int density)
Modify the density.
QPointer< QLabel > m_baseLatLabel
Label for the base latitude.
QPointer< QLabel > m_latExtentLabel
Label for the latitude range Selection for the latitude extent source (Map, Cube, Manual) ...
QPointer< QLineEdit > m_minLatExtentLineEdit
Input for the minimum latitude.
void onExtentTypeChanged()
Updates the dialog when the lat or lon extent source is changed.
QPointer< QCheckBox > m_autoApplyCheckBox
True to applySettings on state change.
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
Angle latInc()
The angle of the latitude increment.