USGS

Isis 3.0 Object Programmers' Reference

Home

MosaicControlNetToolMovementConfigDialog.cpp
1 #include "MosaicControlNetToolMovementConfigDialog.h"
2 
3 #include <float.h>
4 
5 #include <QCheckBox>
6 #include <QDebug>
7 #include <QDialog>
8 #include <QDoubleValidator>
9 #include <QGridLayout>
10 #include <QLabel>
11 #include <QLineEdit>
12 #include <QMessageBox>
13 #include <QPushButton>
14 #include <QtGui>
15 #include <QElapsedTimer>
16 
17 #include "Angle.h"
18 #include "IException.h"
19 #include "Latitude.h"
20 #include "Longitude.h"
21 #include "MosaicControlNetTool.h"
22 #include "MosaicSceneWidget.h"
23 #include "Projection.h"
24 #include "PvlGroup.h"
25 #include "SpecialPixel.h"
26 
27 namespace Isis {
35  MosaicControlNetTool *tool, QWidget *parent) : QDialog(parent) {
36  m_tool = tool;
37 
38  setWindowTitle("Movement Options");
39 
40  QGridLayout *mainLayout = new QGridLayout;
41  setLayout(mainLayout);
42 
43  int row = 0;
44 
45  QString showMovementWhatsThis =
46  tr("Check or uncheck to draw or clear the movement arrows");
47  QLabel *showMovementLabel = new QLabel("&Show Movement");
48  showMovementLabel->setWhatsThis(showMovementWhatsThis);
49  mainLayout->addWidget(showMovementLabel, row, 0);
50 
51  m_showMovementCheckBox = new QCheckBox;
52  showMovementLabel->setBuddy(m_showMovementCheckBox);
53  m_showMovementCheckBox->setWhatsThis(showMovementWhatsThis);
54  connect(m_showMovementCheckBox, SIGNAL(toggled(bool)),
55  this, SLOT(refreshWidgetStates()));
56  mainLayout->addWidget(m_showMovementCheckBox, row, 1, 1, 1, Qt::AlignRight);
57  row++;
58 
59  QString colorSourceWhatsThis =
60  tr("Select criteria for arrow color");
61  QLabel *colorSourceLabel = new QLabel("&Color Criteria");
62  colorSourceLabel->setWhatsThis(colorSourceWhatsThis);
63  mainLayout->addWidget(colorSourceLabel, row, 0, 1, 1);
64 
66  m_colorSourceComboBox->addItem(tr("No Color"), MosaicControlNetTool::NoColor);
67  m_colorSourceComboBox->addItem(tr("Measure Count"), MosaicControlNetTool::MeasureCount);
68  m_colorSourceComboBox->addItem(tr("Residual Magnitude"),
70  m_colorSourceComboBox->setCurrentIndex(
72  connect(m_colorSourceComboBox, SIGNAL(currentIndexChanged(int)),
73  this, SLOT(refreshWidgetStates()));
74 
75  colorSourceLabel->setBuddy(m_colorSourceComboBox);
76  m_colorSourceComboBox->setWhatsThis(colorSourceWhatsThis);
77  mainLayout->addWidget(m_colorSourceComboBox, row, 1, 1, 1, Qt::AlignRight);
78  row++;
79 
80  QString brightestMeasureCountValueWhatsThis =
81  tr("Measure count of brightest color. Points with this measure count or greater will be "
82  "colored the brightest.");
83  m_brightestMeasureCountValueLabel = new QLabel("Min &measure count to color");
84  m_brightestMeasureCountValueLabel->setWhatsThis(brightestMeasureCountValueWhatsThis);
85  mainLayout->addWidget(m_brightestMeasureCountValueLabel, row, 0, 1, 1);
86 
88  m_brightestMeasureCountValueLineEdit->setValidator(new QIntValidator(1, INT_MAX, NULL));
89  connect(m_brightestMeasureCountValueLineEdit, SIGNAL(textChanged(const QString &)),
90  this, SLOT(refreshWidgetStates()));
91 
93  m_colorSourceComboBox->setWhatsThis(brightestMeasureCountValueWhatsThis);
94  mainLayout->addWidget(m_brightestMeasureCountValueLineEdit, row, 1, 1, 1, Qt::AlignRight);
95  row++;
96 
97  QString brightestResidualMagnitudeValueWhatsThis =
98  tr("Residual magnitude of brightest color. Points with this maximum residual magnitude or "
99  "greater will be colored the brightest.");
100  m_brightestResidualMagValueLabel = new QLabel("Min &residual magnitude to color");
101  m_brightestResidualMagValueLabel->setWhatsThis(brightestResidualMagnitudeValueWhatsThis);
102  mainLayout->addWidget(m_brightestResidualMagValueLabel, row, 0, 1, 1);
103 
104  m_brightestResidualMagValueLineEdit = new QLineEdit;
105  m_brightestResidualMagValueLineEdit->setValidator(new QDoubleValidator(0.0, DBL_MAX, 8, NULL));
106  connect(m_brightestResidualMagValueLineEdit, SIGNAL(textChanged(const QString &)),
107  this, SLOT(refreshWidgetStates()));
108 
110  m_colorSourceComboBox->setWhatsThis(brightestResidualMagnitudeValueWhatsThis);
111  mainLayout->addWidget(m_brightestResidualMagValueLineEdit, row, 1, 1, 1, Qt::AlignRight);
112  row++;
113 
114  mainLayout->setRowMinimumHeight(row, 10);
115  row++;
116 
117  QHBoxLayout *buttonsAreaLayout = new QHBoxLayout;
118  mainLayout->addLayout(buttonsAreaLayout, row, 0, 1, 2, Qt::AlignRight);
119 
120  buttonsAreaLayout->addStretch();
121 
122  m_okayButton = new QPushButton("&Ok");
123  m_okayButton->setIcon(QIcon::fromTheme("dialog-ok"));
124  connect(m_okayButton, SIGNAL(clicked()),
125  this, SLOT(applySettings()));
126  connect(m_okayButton, SIGNAL(clicked()),
127  this, SLOT(accept()));
128  buttonsAreaLayout->addWidget(m_okayButton);
129 
130  m_applyButton = new QPushButton("&Apply");
131  m_applyButton->setIcon(QIcon::fromTheme("dialog-ok-apply"));
132  connect(m_applyButton, SIGNAL(clicked()),
133  this, SLOT(applySettings()));
134  buttonsAreaLayout->addWidget(m_applyButton);
135 
136  QPushButton *cancelButton = new QPushButton("&Cancel");
137  cancelButton->setIcon(QIcon::fromTheme("dialog-cancel"));
138  connect(cancelButton, SIGNAL(clicked()),
139  this, SLOT(reject()));
140  buttonsAreaLayout->addWidget(cancelButton);
141 
142  readSettings();
143  }
144 
145 
150  }
151 
152 
157  bool haveMeasureCountBrightest = !m_brightestMeasureCountValueLineEdit->text().isEmpty();
158  bool haveResidualMagBrightest = !m_brightestResidualMagValueLineEdit->text().isEmpty();
159 
160  if (!m_showMovementCheckBox->isChecked()) {
161  m_tool->setMovementArrowColorSource(MosaicControlNetTool::NoMovement,
162  haveMeasureCountBrightest? toInt(m_brightestMeasureCountValueLineEdit->text()) : -1,
163  haveResidualMagBrightest? toDouble(m_brightestResidualMagValueLineEdit->text()) : Null);
164  }
165  else {
166 
167  m_tool->setMovementArrowColorSource((MosaicControlNetTool::MovementColorSource)
168  m_colorSourceComboBox->itemData(m_colorSourceComboBox->currentIndex()).toInt(),
169  haveMeasureCountBrightest? toInt(m_brightestMeasureCountValueLineEdit->text()) : -1,
170  haveResidualMagBrightest? toDouble(m_brightestResidualMagValueLineEdit->text()) : Null);
171  }
172 
173  // Now re-read to verify
174  readSettings();
175  }
176 
177 
182  MosaicControlNetTool::MovementColorSource currentSrc = m_tool->movementArrowColorSource();
183  m_showMovementCheckBox->setChecked(currentSrc != MosaicControlNetTool::NoMovement);
184 
185  if (currentSrc != MosaicControlNetTool::NoMovement) {
186  m_colorSourceComboBox->setCurrentIndex(m_colorSourceComboBox->findData(currentSrc));
187  }
188 
189  if (m_tool->maxMovementColorMeasureCount() != -1) {
191  toString(m_tool->maxMovementColorMeasureCount()));
192  }
193 
194  if (m_tool->maxMovementColorResidualMagnitude() != Null) {
196  toString(m_tool->maxMovementColorResidualMagnitude()));
197  }
198 
200  }
201 
202 
207 
208  bool movementEnabled = m_showMovementCheckBox->isChecked();
209  m_colorSourceComboBox->setEnabled(movementEnabled);
210 
211 
212  bool comboSelectedMeasureCount =
213  (m_colorSourceComboBox->itemData(m_colorSourceComboBox->currentIndex()).toInt() ==
215  bool movementIsMeasureCnt = movementEnabled && comboSelectedMeasureCount;
216  m_brightestMeasureCountValueLabel->setEnabled(movementIsMeasureCnt);
217  m_brightestMeasureCountValueLineEdit->setEnabled(movementIsMeasureCnt);
218 
219  bool comboSelectedResidualMagnitude =
220  (m_colorSourceComboBox->itemData(m_colorSourceComboBox->currentIndex()).toInt() ==
222  bool movementIsResidualMagnitude = movementEnabled && comboSelectedResidualMagnitude;
223  m_brightestResidualMagValueLabel->setEnabled(movementIsResidualMagnitude);
224  m_brightestResidualMagValueLineEdit->setEnabled(movementIsResidualMagnitude);
225 
226  bool comboSelectedNoColor =
227  (m_colorSourceComboBox->itemData(m_colorSourceComboBox->currentIndex()).toInt() ==
229 
230  bool validState = !movementEnabled ||
231  comboSelectedNoColor ||
232  (comboSelectedMeasureCount &&
233  !m_brightestMeasureCountValueLineEdit->text().isEmpty()) ||
234  (comboSelectedResidualMagnitude &&
235  !m_brightestResidualMagValueLineEdit->text().isEmpty());
236  m_okayButton->setEnabled(validState);
237  m_applyButton->setEnabled(validState);
238  }
239 }