USGS

Isis 3.0 Object Programmers' Reference

Home

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