Isis 3 Programmer Reference
MosaicControlNetToolMovementConfigDialog.cpp
1#include "MosaicControlNetToolMovementConfigDialog.h"
2
3#include <float.h>
4
5#include <QCheckBox>
6#include <QComboBox>
7#include <QDebug>
8#include <QDialog>
9#include <QDoubleValidator>
10#include <QGridLayout>
11#include <QLabel>
12#include <QLineEdit>
13#include <QMessageBox>
14#include <QPushButton>
15#include <QtWidgets>
16#include <QElapsedTimer>
17
18#include "Angle.h"
19#include "IException.h"
20#include "Latitude.h"
21#include "Longitude.h"
22#include "MosaicControlNetTool.h"
23#include "MosaicSceneWidget.h"
24#include "Projection.h"
25#include "PvlGroup.h"
26#include "SpecialPixel.h"
27
28namespace Isis {
36 MosaicControlNetTool *tool, QWidget *parent) : QDialog(parent) {
37 m_tool = tool;
38
39 setWindowTitle("Movement Options");
40
41 QGridLayout *mainLayout = new QGridLayout;
42 setLayout(mainLayout);
43
44 int row = 0;
45
46 QString showMovementWhatsThis =
47 tr("Check or uncheck to draw or clear the movement arrows");
48 QLabel *showMovementLabel = new QLabel("&Show Movement");
49 showMovementLabel->setWhatsThis(showMovementWhatsThis);
50 mainLayout->addWidget(showMovementLabel, row, 0);
51
52 m_showMovementCheckBox = new QCheckBox;
53 showMovementLabel->setBuddy(m_showMovementCheckBox);
54 m_showMovementCheckBox->setWhatsThis(showMovementWhatsThis);
55 connect(m_showMovementCheckBox, SIGNAL(toggled(bool)),
56 this, SLOT(refreshWidgetStates()));
57 mainLayout->addWidget(m_showMovementCheckBox, row, 1, 1, 1, Qt::AlignRight);
58 row++;
59
60 QString colorSourceWhatsThis =
61 tr("Select criteria for arrow color");
62 QLabel *colorSourceLabel = new QLabel("&Color Criteria");
63 colorSourceLabel->setWhatsThis(colorSourceWhatsThis);
64 mainLayout->addWidget(colorSourceLabel, row, 0, 1, 1);
65
68 m_colorSourceComboBox->addItem(tr("Measure Count"), MosaicControlNetTool::MeasureCount);
69 m_colorSourceComboBox->addItem(tr("Residual Magnitude"),
71 m_colorSourceComboBox->setCurrentIndex(
73 connect(m_colorSourceComboBox, SIGNAL(currentIndexChanged(int)),
74 this, SLOT(refreshWidgetStates()));
75
76 colorSourceLabel->setBuddy(m_colorSourceComboBox);
77 m_colorSourceComboBox->setWhatsThis(colorSourceWhatsThis);
78 mainLayout->addWidget(m_colorSourceComboBox, row, 1, 1, 1, Qt::AlignRight);
79 row++;
80
81 QString brightestMeasureCountValueWhatsThis =
82 tr("Measure count of brightest color. Points with this measure count or greater will be "
83 "colored the brightest.");
84 m_brightestMeasureCountValueLabel = new QLabel("Min &measure count to color");
85 m_brightestMeasureCountValueLabel->setWhatsThis(brightestMeasureCountValueWhatsThis);
86 mainLayout->addWidget(m_brightestMeasureCountValueLabel, row, 0, 1, 1);
87
89 m_brightestMeasureCountValueLineEdit->setValidator(new QIntValidator(1, INT_MAX, NULL));
90 connect(m_brightestMeasureCountValueLineEdit, SIGNAL(textChanged(const QString &)),
91 this, SLOT(refreshWidgetStates()));
92
94 m_colorSourceComboBox->setWhatsThis(brightestMeasureCountValueWhatsThis);
95 mainLayout->addWidget(m_brightestMeasureCountValueLineEdit, row, 1, 1, 1, Qt::AlignRight);
96 row++;
97
98 QString brightestResidualMagnitudeValueWhatsThis =
99 tr("Residual magnitude of brightest color. Points with this maximum residual magnitude or "
100 "greater will be colored the brightest.");
101 m_brightestResidualMagValueLabel = new QLabel("Min &residual magnitude to color");
102 m_brightestResidualMagValueLabel->setWhatsThis(brightestResidualMagnitudeValueWhatsThis);
103 mainLayout->addWidget(m_brightestResidualMagValueLabel, row, 0, 1, 1);
104
106 m_brightestResidualMagValueLineEdit->setValidator(new QDoubleValidator(0.0, DBL_MAX, 8, NULL));
107 connect(m_brightestResidualMagValueLineEdit, SIGNAL(textChanged(const QString &)),
108 this, SLOT(refreshWidgetStates()));
109
111 m_colorSourceComboBox->setWhatsThis(brightestResidualMagnitudeValueWhatsThis);
112 mainLayout->addWidget(m_brightestResidualMagValueLineEdit, row, 1, 1, 1, Qt::AlignRight);
113 row++;
114
115 mainLayout->setRowMinimumHeight(row, 10);
116 row++;
117
118 QHBoxLayout *buttonsAreaLayout = new QHBoxLayout;
119 mainLayout->addLayout(buttonsAreaLayout, row, 0, 1, 2, Qt::AlignRight);
120
121 buttonsAreaLayout->addStretch();
122
123 m_okayButton = new QPushButton("&Ok");
124 m_okayButton->setIcon(QIcon::fromTheme("dialog-ok"));
125 connect(m_okayButton, SIGNAL(clicked()),
126 this, SLOT(applySettings()));
127 connect(m_okayButton, SIGNAL(clicked()),
128 this, SLOT(accept()));
129 buttonsAreaLayout->addWidget(m_okayButton);
130
131 m_applyButton = new QPushButton("&Apply");
132 m_applyButton->setIcon(QIcon::fromTheme("dialog-ok-apply"));
133 connect(m_applyButton, SIGNAL(clicked()),
134 this, SLOT(applySettings()));
135 buttonsAreaLayout->addWidget(m_applyButton);
136
137 QPushButton *cancelButton = new QPushButton("&Cancel");
138 cancelButton->setIcon(QIcon::fromTheme("dialog-cancel"));
139 connect(cancelButton, SIGNAL(clicked()),
140 this, SLOT(reject()));
141 buttonsAreaLayout->addWidget(cancelButton);
142
143 readSettings();
144 }
145
146
152
153
158 bool haveMeasureCountBrightest = !m_brightestMeasureCountValueLineEdit->text().isEmpty();
159 bool haveResidualMagBrightest = !m_brightestResidualMagValueLineEdit->text().isEmpty();
160
161 if (!m_showMovementCheckBox->isChecked()) {
162 m_tool->setMovementArrowColorSource(MosaicControlNetTool::NoMovement,
163 haveMeasureCountBrightest? toInt(m_brightestMeasureCountValueLineEdit->text()) : -1,
164 haveResidualMagBrightest? toDouble(m_brightestResidualMagValueLineEdit->text()) : Null);
165 }
166 else {
167
168 m_tool->setMovementArrowColorSource((MosaicControlNetTool::MovementColorSource)
169 m_colorSourceComboBox->itemData(m_colorSourceComboBox->currentIndex()).toInt(),
170 haveMeasureCountBrightest? toInt(m_brightestMeasureCountValueLineEdit->text()) : -1,
171 haveResidualMagBrightest? toDouble(m_brightestResidualMagValueLineEdit->text()) : Null);
172 }
173
174 // Now re-read to verify
175 readSettings();
176 }
177
178
183 MosaicControlNetTool::MovementColorSource currentSrc = m_tool->movementArrowColorSource();
185
186 if (currentSrc != MosaicControlNetTool::NoMovement) {
187 m_colorSourceComboBox->setCurrentIndex(m_colorSourceComboBox->findData(currentSrc));
188 }
189
190 if (m_tool->maxMovementColorMeasureCount() != -1) {
192 toString(m_tool->maxMovementColorMeasureCount()));
193 }
194
195 if (m_tool->maxMovementColorResidualMagnitude() != Null) {
197 toString(m_tool->maxMovementColorResidualMagnitude()));
198 }
199
201 }
202
203
208
209 bool movementEnabled = m_showMovementCheckBox->isChecked();
210 m_colorSourceComboBox->setEnabled(movementEnabled);
211
212
213 bool comboSelectedMeasureCount =
214 (m_colorSourceComboBox->itemData(m_colorSourceComboBox->currentIndex()).toInt() ==
216 bool movementIsMeasureCnt = movementEnabled && comboSelectedMeasureCount;
217 m_brightestMeasureCountValueLabel->setEnabled(movementIsMeasureCnt);
218 m_brightestMeasureCountValueLineEdit->setEnabled(movementIsMeasureCnt);
219
220 bool comboSelectedResidualMagnitude =
221 (m_colorSourceComboBox->itemData(m_colorSourceComboBox->currentIndex()).toInt() ==
223 bool movementIsResidualMagnitude = movementEnabled && comboSelectedResidualMagnitude;
224 m_brightestResidualMagValueLabel->setEnabled(movementIsResidualMagnitude);
225 m_brightestResidualMagValueLineEdit->setEnabled(movementIsResidualMagnitude);
226
227 bool comboSelectedNoColor =
228 (m_colorSourceComboBox->itemData(m_colorSourceComboBox->currentIndex()).toInt() ==
230
231 bool validState = !movementEnabled ||
232 comboSelectedNoColor ||
233 (comboSelectedMeasureCount &&
234 !m_brightestMeasureCountValueLineEdit->text().isEmpty()) ||
235 (comboSelectedResidualMagnitude &&
236 !m_brightestResidualMagValueLineEdit->text().isEmpty());
237 m_okayButton->setEnabled(validState);
238 m_applyButton->setEnabled(validState);
239 }
240}
//TODO: Remove debug printout & comment // 2016-08-25 Tracie Sucharski - Checking Directory pointer f...
MovementColorSource
This enum defines how to draw the movement arrows (arrows from CP A Priori location to adjusted locat...
@ ResidualMagnitude
Show movement arrows colored by residual magnitude.
@ NoColor
Show black movement arrows.
@ NoMovement
Do not show movement arrows.
@ MeasureCount
Show movement arrows colored by measure count.
QPointer< QLineEdit > m_brightestMeasureCountValueLineEdit
Max measure count input.
QPointer< MosaicControlNetTool > m_tool
The MosaicControlNetTool that we're configuring.
void applySettings()
Apply the user's current settings to the tool.
void refreshWidgetStates()
Enables or disables widgets depending on the state of the tool.
QPointer< QPushButton > m_applyButton
Apply button at bottom of dialog.
QPointer< QLabel > m_brightestMeasureCountValueLabel
Label of max measure count input.
QPointer< QPushButton > m_okayButton
OK button at bottom of dialog.
QPointer< QLineEdit > m_brightestResidualMagValueLineEdit
Max residual magnitude input.
QPointer< QLabel > m_brightestResidualMagValueLabel
Label of max residual magnitude input.
MosaicControlNetToolMovementConfigDialog(MosaicControlNetTool *tool, QWidget *parent)
Create a config dialog that configures the given MosaicControlNetTool.
void readSettings()
Read the tool's current settings and set the widget states to match.
QPointer< QCheckBox > m_showMovementCheckBox
Check box for enabling/disabling arrows entirely.
QPointer< QComboBox > m_colorSourceComboBox
Combo box for all coloring possibilities.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
Definition IString.cpp:211
int toInt(const QString &string)
Global function to convert from a string to an integer.
Definition IString.cpp:93
const double Null
Value for an Isis Null pixel.
double toDouble(const QString &string)
Global function to convert from a string to a double.
Definition IString.cpp:149