Official websites use .gov
A .gov website belongs to an official government organization in the United States.

Secure .gov websites use HTTPS
A lock ( ) or https:// means you’ve safely connected to the .gov website. Share sensitive information only on official, secure websites.

Isis 3 Programmer Reference
GuiParameter.cpp
1
5
6/* SPDX-License-Identifier: CC0-1.0 */
7
8#include <QFileDialog>
9#include <QHBoxLayout>
10#include <QLabel>
11#include <QLineEdit>
12#include <QToolButton>
13
14#include "GuiParameter.h"
15
16#include "Application.h"
17#include "FileName.h"
18#include "GuiHelperAction.h"
19#include "UserInterface.h"
20
21#include "GuiFilenameParameter.h"
22#include "GuiCubeParameter.h"
23
24namespace Isis {
27 int group, int param) : QObject() {
28 p_ui = &ui;
29 p_group = group;
30 p_param = param;
31
32 p_name = ui.ParamName(group, param);
33 p_fileButton = new QToolButton();
34 p_lineEdit = new QLineEdit();
35
36 p_label = new QLabel(p_name);
37 p_label->setAlignment(Qt::AlignRight | Qt::AlignVCenter);
38 p_label->setToolTip(p_ui->ParamBrief(group, param));
39 grid->addWidget(p_label, param, 0, Qt::AlignTop);
40
41 QString whatsThis;
42 whatsThis = (QString)("<b>Parameter:</b> " + p_ui->ParamName(group, param));
43 whatsThis += (QString)("<p><b>Type:</b> " + p_ui->ParamType(group, param) + "</p>");
44 whatsThis += (QString)("<p><b>Brief:</b> " + p_ui->ParamBrief(group, param) + "</p>");
45 QString def = p_ui->ParamDefault(group, param);
46 if(def == "") def = "None";
47 whatsThis += "<p><b>Default: </b>" + QString(def) + "</p>";
48 QString intdef = p_ui->ParamInternalDefault(group, param);
49 if(intdef != "") {
50 whatsThis += "<p><b>Internal Default: </b> " + QString(intdef) + "</p>";
51 }
52 QString pixtype = p_ui->PixelType(group, param);
53 if(pixtype != "") {
54 whatsThis += "<p><b>Pixel Type: </b> " + QString(pixtype) + "</p>";
55 }
56 QString pmin = p_ui->ParamMinimum(group, param);
57 if(pmin != "") {
58 if(p_ui->ParamMinimumInclusive(group, param) == "YES") {
59 whatsThis += "<p><b>Greater Than Or Equal To: </b>" +
60 QString(pmin) + "</p>";
61 }
62 else {
63 whatsThis += "<p><b>Greater Than: </b>" + QString(pmin) + "</p>";
64 }
65 }
66 QString pmax = p_ui->ParamMaximum(group, param);
67 if(pmax != "") {
68 if(p_ui->ParamMaximumInclusive(group, param) == "YES") {
69 whatsThis += "<p><b>Less Than Or Equal To: </b>" +
70 QString(pmax) + "</p>";
71 }
72 else {
73 whatsThis += "<p><b>Less Than: </b>" + QString(pmax) + "</p>";
74 }
75 }
76 if(p_ui->ParamLessThanSize(group, param) > 0) {
77 whatsThis += "<p><b>Less Than: </b>" +
78 QString(p_ui->ParamLessThan(group, param, 0));
79 for(int l = 1; l < p_ui->ParamLessThanSize(group, param); l++) {
80 whatsThis += ", " + QString(p_ui->ParamLessThan(group, param, l));
81 }
82 whatsThis += "</p>";
83 }
84 if(p_ui->ParamLessThanOrEqualSize(group, param) > 0) {
85 whatsThis += "<p><b>Less Than Or Equal: </b>" +
86 QString(p_ui->ParamLessThanOrEqual(group, param, 0));
87 for(int l = 1; l < p_ui->ParamLessThanOrEqualSize(group, param); l++) {
88 whatsThis += ", " +
89 QString(p_ui->ParamLessThanOrEqual(group, param, l));
90 }
91 whatsThis += "</p>";
92 }
93 if(p_ui->ParamNotEqualSize(group, param) > 0) {
94 whatsThis += "<p><b>Not Equal: </b>" +
95 QString(p_ui->ParamNotEqual(group, param, 0));
96 for(int l = 1; l < p_ui->ParamNotEqualSize(group, param); l++) {
97 whatsThis += ", " + QString(p_ui->ParamNotEqual(group, param, l));
98 }
99 whatsThis += "</p>";
100 }
101 if(p_ui->ParamGreaterThanSize(group, param) > 0) {
102 whatsThis += "<p><b>Greater Than: </b>" +
103 QString(p_ui->ParamGreaterThan(group, param, 0));
104 for(int l = 1; l < p_ui->ParamGreaterThanSize(group, param); l++) {
105 whatsThis += ", " +
106 QString(p_ui->ParamGreaterThan(group, param, l));
107 }
108 whatsThis += "</p>";
109 }
110 if(p_ui->ParamGreaterThanOrEqualSize(group, param) > 0) {
111 whatsThis += "<p><b>Greater Than Or Equal: </b>" +
112 QString(p_ui->ParamGreaterThanOrEqual(group, param, 0));
113 for(int l = 1; l < p_ui->ParamGreaterThanOrEqualSize(group, param); l++) {
114 whatsThis += ", " +
115 QString(p_ui->ParamGreaterThanOrEqual(group, param, l));
116 }
117 whatsThis += "</p>";
118 }
119 if(p_ui->ParamIncludeSize(group, param) > 0) {
120 whatsThis += "<p><b>Inclusions: </b>" +
121 QString(p_ui->ParamInclude(group, param, 0));
122 for(int l = 1; l < p_ui->ParamIncludeSize(group, param); l++) {
123 whatsThis += ", " +
124 QString(p_ui->ParamInclude(group, param, l));
125 }
126 whatsThis += "</p>";
127 }
128 if(p_ui->ParamExcludeSize(group, param) > 0) {
129 whatsThis += "<p><b>Exclusions: </b>" +
130 QString(p_ui->ParamExclude(group, param, 0));
131 for(int l = 1; l < p_ui->ParamExcludeSize(group, param); l++) {
132 whatsThis += ", " +
133 QString(p_ui->ParamExclude(group, param, l));
134 }
135 whatsThis += "</p>";
136 }
137 if(p_ui->ParamOdd(group, param) != "") {
138 whatsThis += "<p><b>Odd: </b>" +
139 QString(p_ui->ParamOdd(group, param)) + "</p>";
140 }
141 p_label->setWhatsThis(whatsThis);
142
143 p_helperMenu = NULL;
144 }
145
146
149 if(p_helperMenu) {
150 delete p_helperMenu;
151 p_helperMenu = NULL;
152 }
153
154 p_widgetList.clear();
155 }
156
159 if(p_ui->ParamDefault(p_group, p_param).size() > 0) {
160 Set(p_ui->ParamDefault(p_group, p_param));
161 }
162 else if(p_ui->ParamInternalDefault(p_group, p_param).size() > 0) {
163 Set(p_ui->ParamInternalDefault(p_group, p_param));
164 }
165 else {
166 Set("");
167 }
168 }
169
172 if(p_ui->WasEntered(p_name)) {
173 Set(p_ui->GetAsString(p_name));
174 }
175 else {
176 SetToDefault();
177 }
178 }
179
182 if(!IsEnabled()) return false;
183 if(p_ui->ParamDefault(p_group, p_param).size() > 0) {
184 if(Value() == p_ui->ParamDefault(p_group, p_param)) return false;
185 }
186 else if(p_ui->ParamInternalDefault(p_group, p_param).size() > 0) {
187 if(Value() == p_ui->ParamInternalDefault(p_group, p_param)) return false;
188 }
189 else {
190 if(Value() == "") return false;
191 }
192 return true;
193 }
194
197 if(p_ui->WasEntered(p_name)) {
198 Set(p_ui->GetAsString(p_name));
199 }
200 else if(p_ui->ParamDefault(p_group, p_param).size() > 0) {
201 Set(p_ui->ParamDefault(p_group, p_param));
202 }
203 else if(p_ui->ParamInternalDefault(p_group, p_param).size() > 0) {
204 Set(p_ui->ParamInternalDefault(p_group, p_param));
205 }
206 else {
207 Set("");
208 }
209 }
210
213 p_widgetList.push_back(w);
214 }
215
217 void GuiParameter::SetEnabledOption(bool enabled, QString option, bool isParentCombo) {
218 for(int i = 0; i < p_widgetList.size(); i++) {
219 QString objectName = p_widgetList[i]->objectName();
220 if (objectName == option) {
221 p_widgetList[i]->setEnabled(enabled);
222 p_widgetList[i]->setVisible(true);
223 if(isParentCombo && !enabled) {
224 p_widgetList[i]->setVisible(false);
225 }
226 }
227 }
228 }
229
231 void GuiParameter::SetEnabled(bool enabled, bool isParentCombo) {
232 if(p_type != ComboWidget) {
233 p_label->setEnabled(enabled);
234 p_label->setVisible(true);
235 if(isParentCombo && !enabled) {
236 p_label->setVisible(false);
237 }
238 for(int i = 0; i < p_widgetList.size(); i++) {
239 p_widgetList[i]->setEnabled(enabled);
240 p_widgetList[i]->setVisible(true);
241 if(isParentCombo && !enabled) {
242 p_widgetList[i]->setVisible(false);
243 }
244 }
245 }
246 else {
247 p_label->setEnabled(enabled);
248 p_widgetList[0]->setEnabled(enabled);
249 }
250 }
251
253 std::vector<QString> GuiParameter::Exclusions() {
254 std::vector<QString> list;
255 return list;
256 }
257
260 // Just make one single helper button
261 if(p_ui->HelpersSize(p_group, p_param) == 1) {
262 GuiHelperAction *action =
263 new GuiHelperAction(lo, p_ui->HelperFunction(p_group, p_param, 0));
264 if(p_ui->HelperIcon(p_group, p_param, 0) != "") {
265 QString file = FileName(
266 p_ui->HelperIcon(p_group, p_param, 0)).expanded();
267 action->setIcon(QIcon(QPixmap(file)));
268 }
269 else {
270 action->setText(p_ui->HelperButtonName(p_group, p_param, 0));
271 }
272 action->setToolTip(p_ui->HelperBrief(p_group, p_param, 0));
273 QString helperText = "<p><b>Function:</b> " +
274 QString(p_ui->HelperDescription(p_group, p_param, 0)) + "</p>";
275 action->setWhatsThis(helperText);
276 connect(action, SIGNAL(trigger(const QString &)), this,
277 SIGNAL(HelperTrigger(const QString &)));
278
279 QToolButton *helper = new QToolButton();
280 helper->setText(p_ui->HelperButtonName(p_group, p_param, 0));
281 helper->setDefaultAction(action);
282
283 if(p_ui->HelperIcon(p_group, p_param, 0) != "") {
284 helper->setText("");
285 QString file = FileName(
286 p_ui->HelperIcon(p_group, p_param, 0)).expanded();
287 helper->setIconSize(QSize(22, 22));
288 helper->setIcon(QIcon(QPixmap(file)));
289 }
290 else {
291 helper->setFixedWidth(helper->fontMetrics().horizontalAdvance(
292 " " + helper->text() + " "));
293 }
294 RememberWidget(helper);
295 return helper;
296 }
297
298 // Make a drop down menu of helper buttons
299 else {
300 if(p_helperMenu) {
301 throw IException(IException::Programmer,
302 "Can not call GuiParameter::AddHelpers twice",
303 _FILEINFO_);
304 }
305
306 p_helperMenu = new QMenu();
307
308 // Create default action item
309 GuiHelperAction *action =
310 new GuiHelperAction(lo, p_ui->HelperFunction(p_group, p_param, 0));
311 if(p_ui->HelperIcon(p_group, p_param, 0) != "") {
312 QString file = FileName(
313 p_ui->HelperIcon(p_group, p_param, 0)).expanded();
314 action->setIcon(QIcon(QPixmap(file)));
315 }
316 else {
317 action->setText(p_ui->HelperButtonName(p_group, p_param, 0));
318 }
319 connect(action, SIGNAL(trigger(const QString &)), this,
320 SIGNAL(HelperTrigger(const QString &)));
321
322 // Set up helper button
323 QToolButton *helper = new QToolButton();
324 helper->setText(p_ui->HelperButtonName(p_group, p_param, 0));
325
326 helper->setMenu(p_helperMenu);
327 helper->setPopupMode(QToolButton::MenuButtonPopup);
328 helper->setDefaultAction(action);
329 helper->setToolTip(p_ui->HelperBrief(p_group, p_param, 0));
330 QString text = "<p><b>Function:</b> " +
331 QString(p_ui->HelperDescription(p_group, p_param, 0)) + "</p>" +
332 "<p><b>Hint: </b> Click on the arrow to see more helper functions</p>";
333 helper->setWhatsThis(text);
334
335 if(p_ui->HelperIcon(p_group, p_param, 0) != "") {
336 helper->setText("");
337 QString file = FileName(
338 p_ui->HelperIcon(p_group, p_param, 0)).expanded();
339 helper->setIconSize(QSize(22, 22));
340 helper->setIcon(QIcon(QPixmap(file)));
341 }
342 else {
343 helper->setFixedWidth(helper->fontMetrics().horizontalAdvance(
344 " " + helper->text() + " "));
345 }
346
347 // Set up default action item in menu list
348 GuiHelperAction *action2 =
349 new GuiHelperAction(lo, p_ui->HelperFunction(p_group, p_param, 0));
350 action2->setText(p_ui->HelperBrief(p_group, p_param, 0));
351 action2->setToolTip(p_ui->HelperBrief(p_group, p_param, 0));
352 QString helperText = "<p><b>Function:</b> " +
353 QString(p_ui->HelperDescription(p_group, p_param, 0)) + "</p>";
354 action2->setWhatsThis(helperText);
355 connect(action2, SIGNAL(trigger(const QString &)), this,
356 SIGNAL(HelperTrigger(const QString &)));
357 p_helperMenu->addAction(action2);
358
359
360 // Add each additional helper button to the menu list
361 for(int i = 1; i < p_ui->HelpersSize(p_group, p_param); i++) {
362 GuiHelperAction *helperAction =
363 new GuiHelperAction(lo, p_ui->HelperFunction(p_group, p_param, i));
364 helperAction->setText(p_ui->HelperBrief(p_group, p_param, i));
365 helperAction->setToolTip(p_ui->HelperBrief(p_group, p_param, i));
366 QString helperText = "<p><b>Function:</b> " +
367 QString(p_ui->HelperDescription(p_group, p_param, i)) + "</p>";
368 helperAction->setWhatsThis(helperText);
369 connect(helperAction, SIGNAL(trigger(const QString &)), this,
370 SIGNAL(HelperTrigger(const QString &)));
371 p_helperMenu->addAction(helperAction);
372 }
373 RememberWidget(helper);
374 return helper;
375 }
376 }
377}
void Update()
Update the value on the GUI with the value in the UI.
bool IsEnabled() const
Is the parameter enabled.
virtual bool IsModified()
Return if the parameter value is different from the default value.
void SetEnabledOption(bool enabled, QString option, bool isParentCombo)
Enable or disable individual radio/combo options.
void RememberWidget(QWidget *w)
Add widgets to a list for enabling/disabling.
void SetToDefault()
Change the parameter to the default value.
virtual std::vector< QString > Exclusions()
Return list of current exclusions.
void SetEnabled(bool enabled, bool isParentCombo=false)
Enable or disable the parameter.
GuiParameter(QGridLayout *grid, UserInterface &ui, int group, int param)
Constructor.
void SetToCurrent()
Change the parameter to the current user interface value.
QWidget * AddHelpers(QObject *lo)
Sets up helper button.
virtual ~GuiParameter()
Destructor.
Command Line and Xml loader, validation, and access.
QString ParamName(const int &group, const int &param) const
Returns the parameter name.
Definition IsisAml.cpp:1360
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16