1 #include "MosaicGridToolConfigDialog.h"
6 #include <QDoubleValidator>
10 #include <QMessageBox>
11 #include <QPushButton>
13 #include <QElapsedTimer>
19 #include "MosaicGridTool.h"
20 #include "MosaicGridToolConfigDialog.h"
21 #include "MosaicSceneWidget.h"
41 setWindowTitle(
"Grid Options");
43 QGridLayout *mainLayout =
new QGridLayout;
44 setLayout(mainLayout);
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);
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);
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 "
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"
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.";
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.";
183 mainLayout->setRowMinimumHeight(row, 10);
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.";
199 m_latExtentCombo->setCurrentIndex(m_latExtentCombo->findData(m_tool->
latExtents()));
200 m_latExtentCombo->setWhatsThis(latExtentWhatsThis);
201 connect(m_latExtentCombo, SIGNAL(currentIndexChanged(
int)),
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);
209 QString minLatWhatsThis =
210 "The minimum latitude will be the lower edge of the grid. This parameter currently "
211 "expects degree input.";
229 m_minLatExtentTypeLabel =
new QLabel(
"Degrees");
230 mainLayout->addWidget(m_minLatExtentTypeLabel, row, 4, 1, 1);
233 QString maxLatWhatsThis =
234 "The maximum latitude will be the upper edge of the grid. This parameter currently "
235 "expects degree input.";
253 m_maxLatExtentTypeLabel =
new QLabel(
"Degrees");
254 mainLayout->addWidget(m_maxLatExtentTypeLabel, row, 4, 1, 1);
256 mainLayout->setRowMinimumHeight(row, 10);
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.";
274 m_lonExtentCombo->setCurrentIndex(m_lonExtentCombo->findData(m_tool->
lonExtents()));
275 m_lonExtentCombo->setWhatsThis(lonExtentWhatsThis);
276 connect(m_lonExtentCombo, SIGNAL(currentIndexChanged(
int)),
278 mainLayout->addWidget(m_lonExtentCombo, row, 2, 1, 2);
284 QString minLonWhatsThis =
285 "The maximum longitude will be the left edge of the grid. This parameter currently "
286 "expects degree input.";
304 m_minLonExtentTypeLabel =
new QLabel(
"Degrees");
305 mainLayout->addWidget(m_minLonExtentTypeLabel, row, 4, 1, 1);
308 QString maxLonWhatsThis =
309 "The maximum longitude will be the right edge of the grid. This parameter currently "
310 "expects degree input.";
328 m_maxLonExtentTypeLabel =
new QLabel(
"Degrees");
329 mainLayout->addWidget(m_maxLonExtentTypeLabel, row, 4, 1, 1);
331 mainLayout->setRowMinimumHeight(row, 10);
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.";
344 m_densityEdit->setValidator(
new QIntValidator(1, INT_MAX,
this));
350 mainLayout->setRowMinimumHeight(row, 10);
353 QHBoxLayout *buttonsAreaLayout =
new QHBoxLayout;
354 mainLayout->addLayout(buttonsAreaLayout, row, 0, 1, 4);
356 QString autoApplyWhatsThis =
357 "Automatically updates the grid when parameters are changed.";
362 buttonsAreaLayout->addStretch();
364 QPushButton *okayButton =
new QPushButton(
"&Ok");
365 okayButton->setIcon(QIcon::fromTheme(
"dialog-ok"));
366 connect(okayButton, SIGNAL(clicked()),
368 connect(okayButton, SIGNAL(clicked()),
369 this, SLOT(accept()));
370 buttonsAreaLayout->addWidget(okayButton);
372 QPushButton *applyButton =
new QPushButton(
"&Apply");
373 applyButton->setIcon(QIcon::fromTheme(
"dialog-ok-apply"));
374 connect(applyButton, SIGNAL(clicked()),
376 buttonsAreaLayout->addWidget(applyButton);
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);
384 connect(m_tool, SIGNAL(boundingRectChanged()),
this, SLOT(
readSettings()));
407 QValidator::State validBaseLat =
409 if (validBaseLat != QValidator::Acceptable) {
411 "Base Latitude value must be in the range -90 to 90",
418 QValidator::State validBaseLon =
420 if (validBaseLon != QValidator::Acceptable) {
422 "Base Longitude value must be a double",
428 QValidator::State validLatInc =
m_latIncLineEdit->validator()->validate(latitudeInc,
430 if (validLatInc != QValidator::Acceptable) {
432 "Latitude increment must be in the range 0 to 180",
438 QValidator::State validLonInc =
440 if (validLonInc != QValidator::Acceptable) {
442 "Longitude increment must be a double",
448 QValidator::State validMinLatExtent =
450 if (validMinLatExtent != QValidator::Acceptable) {
452 "Minimum latitude extent must be a double",
458 QValidator::State validMaxLatExtent =
460 if (validMaxLatExtent != QValidator::Acceptable) {
462 "Maximum latitude extent must be a double",
468 QValidator::State validMinLonExtent =
470 if (validMinLonExtent != QValidator::Acceptable) {
472 "Minimum longitude extent must be a double",
478 QValidator::State validMaxLonExtent =
480 if (validMaxLonExtent != QValidator::Acceptable) {
482 "Maximum longitude extent must be a double",
488 QValidator::State validDensity =
490 if (validDensity != QValidator::Acceptable) {
492 "Density must be a non-zero positive integer",
508 m_latExtentCombo->itemData(m_latExtentCombo->currentIndex()).
toInt(),
512 m_lonExtentCombo->itemData(m_lonExtentCombo->currentIndex()).
toInt(),
525 if (shouldReadSettings)
558 m_latExtentCombo->setCurrentIndex(m_latExtentCombo->findData(m_tool->
latExtents()));
559 if (m_tool->
sceneWidget()->getProjection()->Mapping()[
"LatitudeType"][0] ==
577 m_lonExtentCombo->setCurrentIndex(m_lonExtentCombo->findData(m_tool->
lonExtents()));
610 bool enabled = m_tool->
sceneWidget()->getProjection();
614 m_latExtentCombo->itemData(m_latExtentCombo->currentIndex()).
toInt() ==
617 m_lonExtentCombo->itemData(m_lonExtentCombo->currentIndex()).
toInt() ==
657 m_latExtentCombo->setEnabled(showGrid);
658 m_latExtentTypeLabel->setEnabled(showGrid);
667 m_minLatExtentTypeLabel->setEnabled(enableLatExtents);
676 m_maxLatExtentTypeLabel->setEnabled(enableLatExtents);
679 m_lonExtentCombo->setEnabled(showGrid);
684 m_tool->domainMaxLon().
degrees());
690 m_minLonExtentTypeLabel->setEnabled(enableLonExtents);
694 m_tool->domainMaxLon().
degrees());
700 m_maxLonExtentTypeLabel->setEnabled(enableLonExtents);
716 if (timer.elapsed() > 250) {
794 if (timer.elapsed() > 250)