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
GuiInputAttribute.cpp
1
5
6/* SPDX-License-Identifier: CC0-1.0 */
7
8#include <iostream>
9#include <string>
10
11#include <QDebug>
12#include <QRadioButton>
13#include <QRegularExpression>
14#include <QPushButton>
15#include <QButtonGroup>
16#include <QGridLayout>
17#include <QHBoxLayout>
18#include <QVBoxLayout>
19
20#include "CubeAttribute.h"
21#include "FileName.h"
22#include "GuiInputAttribute.h"
23
24namespace Isis {
26 int GuiInputAttribute::GetAttributes(const QString &defaultAttribute,
27 QString &newAttribute,
28 const QString &title,
29 QWidget *parent) {
30 // Construct dialog if necessary
31 static GuiInputAttribute *p_dialog = 0;
32 if(p_dialog == 0) {
33 p_dialog = new GuiInputAttribute(parent);
34 }
35 p_dialog->setWindowTitle(title);
36
37 // Load default attributes and then get the new ones
38 p_dialog->SetAttributes(defaultAttribute);
39 if(p_dialog->exec() == QDialog::Accepted) {
40 newAttribute = p_dialog->GetAttributes();
41 return 1;
42 }
43 newAttribute = defaultAttribute;
44 return 0;
45 }
46
49 // Create the two radio buttons
50 QRadioButton *allBands = new QRadioButton("&All Bands");
51 allBands->setToolTip("Select all bands from the input cube");
52
53 QRadioButton *listBands = new QRadioButton("&Band List");
54 listBands->setToolTip("Select any bands from the input cube");
55
56 // Create the button group for the radio buttons
57 p_buttonGroup = new QButtonGroup();
58 p_buttonGroup->addButton(allBands);
59 p_buttonGroup->addButton(listBands);
60 p_buttonGroup->setExclusive(true);
61
62 // Create the text field for list toggle button
63 p_lineEdit = new QLineEdit();
64 connect(allBands, SIGNAL(toggled(bool)), p_lineEdit, SLOT(setDisabled(bool)));
65 allBands->setChecked(true);
66
67 // Put the buttons and text field in a gridlayout
68 QGridLayout *gridLayout = new QGridLayout();
69 gridLayout->addWidget(allBands, 0, 0);
70 gridLayout->addWidget(listBands, 1, 0);
71 gridLayout->addWidget(p_lineEdit, 1, 1);
72
73 // Create the action buttons
74 QPushButton *okButton = new QPushButton("Ok");
75 connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
76
77 QPushButton *cancelButton = new QPushButton("Cancel");
78 connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
79
80#if 0
81 // Add them to a button group
82 QButtonGroup *actionGroup = new QButtonGroup();
83 actionGroup->addButton(okButton);
84 actionGroup->addButton(cancelButton);
85#endif
86
87 // Put the buttons in a horizontal orientation
88 QHBoxLayout *actionLayout = new QHBoxLayout();
89 actionLayout->addWidget(okButton);
90 actionLayout->addWidget(cancelButton);
91
92 // Put the grid layout and action layout on the dialog
93 QVBoxLayout *dialogLayout = new QVBoxLayout(this);
94 dialogLayout->addLayout(gridLayout);
95 dialogLayout->addLayout(actionLayout);
96 }
97
98
99 // Destructor
100 GuiInputAttribute::~GuiInputAttribute() {}
101
102
103 // Return the attributes in the dialog
104 QString GuiInputAttribute::GetAttributes() {
105 QString attStr("");
106 if(p_lineEdit->isEnabled()) {
107 attStr = p_lineEdit->text().simplified();
108 attStr = attStr.remove(QRegularExpression("^[+]*"));
109 if (attStr.length() > 0) {
110 if (attStr.left(1) != "+") attStr.prepend('+');
111 }
112 }
113 return attStr;
114 }
115
116
117 // Set the attributes in the dialog
118 void GuiInputAttribute::SetAttributes(const QString &value) {
119 Isis::CubeAttributeInput att(value);
120 std::vector<QString> bands = att.bands();
121 if(bands.size() == 0) {
122 p_buttonGroup->buttons()[0]->setChecked(true);
123 p_lineEdit->setText("");
124 }
125 else {
126 p_buttonGroup->buttons()[1]->setChecked(true);
127 p_lineEdit->setText(att.toString());
128 }
129 }
130}
131
GuiInputAttribute(QWidget *parent=0)
Constuctor.
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16