File failed to load: https://isis.astrogeology.usgs.gov/6.0.0/Object/assets/jax/output/NativeMML/config.js
Isis 3 Programmer Reference
GuiOutputAttribute.cpp
1 
6 /* SPDX-License-Identifier: CC0-1.0 */
7 
8 #include <iostream>
9 #include <string>
10 
11 #include <QRadioButton>
12 #include <QPushButton>
13 #include <QButtonGroup>
14 #include <QGridLayout>
15 #include <QHBoxLayout>
16 #include <QVBoxLayout>
17 #include <QLabel>
18 #include <QGroupBox>
19 #include <QDoubleValidator>
20 
21 #include "CubeAttribute.h"
22 #include "FileName.h"
23 #include "GuiOutputAttribute.h"
24 
25 namespace Isis {
27  int GuiOutputAttribute::GetAttributes(const QString &defaultAttribute,
28  QString &newAttribute,
29  const QString &title,
30  bool allowProp,
31  QWidget *parent) {
32  // Construct dialog if necessary
33  static GuiOutputAttribute *p_dialog = 0;
34  if(p_dialog == 0) {
35  p_dialog = new GuiOutputAttribute(parent);
36  }
37  p_dialog->setWindowTitle(title);
38  p_dialog->SetPropagation(allowProp);
39 
40  // Load default attributes and then get the new ones
41  p_dialog->SetAttributes(defaultAttribute);
42  if(p_dialog->exec() == QDialog::Accepted) {
43  newAttribute = p_dialog->GetAttributes();
44  return 1;
45  }
46  newAttribute = defaultAttribute;
47  return 0;
48  }
49 
52  // Create the pixel type group
53  p_propagate = new QRadioButton("&Propagate");
54  p_propagate->setToolTip("Propagate pixel type from input cube");
55  p_unsignedByte = new QRadioButton("&Unsigned Byte");
56  p_unsignedByte->setToolTip("Unsigned 8-bit pixels");
57  p_signedWord = new QRadioButton("&Signed Word");
58  p_signedWord->setToolTip("Signed 16-bit pixels");
59  p_unsignedWord = new QRadioButton("Unsigned Word");
60  p_unsignedWord->setToolTip("Unsigned 16-bit pixels");
61  p_signedInteger = new QRadioButton("&Signed Integer");
62  p_signedInteger->setToolTip("Signed 32-bit integer");
63  p_unsignedInteger = new QRadioButton("Unsigned Integer");
64  p_unsignedInteger->setToolTip("Unsigned 32-bit integer");
65  p_real = new QRadioButton("&Real");
66  p_real->setToolTip("Floating point 32-bit pixels");
67 
68  QButtonGroup *buttonGroup = new QButtonGroup();
69  buttonGroup->addButton(p_propagate);
70  buttonGroup->addButton(p_unsignedByte);
71  buttonGroup->addButton(p_signedWord);
72  buttonGroup->addButton(p_unsignedWord);
73  buttonGroup->addButton(p_unsignedInteger);
74  buttonGroup->addButton(p_signedInteger);
75  buttonGroup->addButton(p_real);
76  buttonGroup->setExclusive(true);
77 
78  p_minEdit = new QLineEdit();
79  p_maxEdit = new QLineEdit();
80  QLabel *minLabel = new QLabel("Minimum");
81  QLabel *maxLabel = new QLabel("Maximum");
82  connect(p_propagate, SIGNAL(toggled(bool)), p_minEdit, SLOT(setDisabled(bool)));
83  connect(p_propagate, SIGNAL(toggled(bool)), p_maxEdit, SLOT(setDisabled(bool)));
84  connect(p_unsignedByte, SIGNAL(toggled(bool)), p_minEdit, SLOT(setEnabled(bool)));
85  connect(p_unsignedByte, SIGNAL(toggled(bool)), p_maxEdit, SLOT(setEnabled(bool)));
86  connect(p_signedWord, SIGNAL(toggled(bool)), p_minEdit, SLOT(setEnabled(bool)));
87  connect(p_signedWord, SIGNAL(toggled(bool)), p_maxEdit, SLOT(setEnabled(bool)));
88  connect(p_unsignedWord, SIGNAL(toggled(bool)), p_minEdit, SLOT(setEnabled(bool)));
89  connect(p_unsignedWord, SIGNAL(toggled(bool)), p_maxEdit, SLOT(setEnabled(bool)));
90  connect(p_unsignedInteger, SIGNAL(toggled(bool)), p_minEdit, SLOT(setEnabled(bool)));
91  connect(p_unsignedInteger, SIGNAL(toggled(bool)), p_maxEdit, SLOT(setEnabled(bool)));
92  connect(p_signedInteger, SIGNAL(toggled(bool)), p_minEdit, SLOT(setEnabled(bool)));
93  connect(p_signedInteger, SIGNAL(toggled(bool)), p_maxEdit, SLOT(setEnabled(bool)));
94  connect(p_real, SIGNAL(toggled(bool)), p_minEdit, SLOT(setDisabled(bool)));
95  connect(p_real, SIGNAL(toggled(bool)), p_maxEdit, SLOT(setDisabled(bool)));
96  p_minEdit->setValidator(new QDoubleValidator(p_minEdit));
97  p_maxEdit->setValidator(new QDoubleValidator(p_maxEdit));
98 
99  QGridLayout *gridLayout = new QGridLayout();
100  gridLayout->addWidget(p_propagate, 0, 0);
101  gridLayout->addWidget(p_unsignedByte, 1, 0);
102  gridLayout->addWidget(p_signedWord, 2, 0);
103  gridLayout->addWidget(p_unsignedWord, 3, 0);
104  gridLayout->addWidget(p_signedInteger, 4, 0);
105  gridLayout->addWidget(p_unsignedInteger, 5, 0);
106  gridLayout->addWidget(p_real, 6, 0);
107  gridLayout->addWidget(minLabel, 0, 1);
108  gridLayout->addWidget(p_minEdit, 1, 1);
109  gridLayout->addWidget(maxLabel, 2, 1);
110  gridLayout->addWidget(p_maxEdit, 3, 1);
111 
112  QGroupBox *pixelTypeBox = new QGroupBox("Pixel Type");
113  pixelTypeBox->setLayout(gridLayout);
114 
115  // Create detached/attached stuff
116  p_attached = new QRadioButton("&Attached");
117  p_attached->setToolTip("Save labels and image data in one file");
118  p_detached = new QRadioButton("&Detached");
119  p_detached->setToolTip("Save labels and image data in separate files");
120  p_attached->setChecked(true);
121 
122  buttonGroup = new QButtonGroup();
123  buttonGroup->addButton(p_attached);
124  buttonGroup->addButton(p_detached);
125  buttonGroup->setExclusive(true);
126 
127  QVBoxLayout *layout = new QVBoxLayout();
128  layout->addWidget(p_attached);
129  layout->addWidget(p_detached);
130 
131  QGroupBox *labelFormatBox = new QGroupBox("Label Format");
132  labelFormatBox->setLayout(layout);
133 
134  // Create cube format stuff
135  p_tiled = new QRadioButton("&Tiled");
136  p_tiled->setToolTip("Save image data in tiled format");
137  p_bsq = new QRadioButton("&BSQ");
138  p_bsq->setToolTip("Save image data in band sequential format");
139 
140  buttonGroup = new QButtonGroup();
141  buttonGroup->addButton(p_tiled);
142  buttonGroup->addButton(p_bsq);
143  buttonGroup->setExclusive(true);
144 
145  layout = new QVBoxLayout();
146  layout->addWidget(p_tiled);
147  layout->addWidget(p_bsq);
148 
149  QGroupBox *cubeFormatBox = new QGroupBox("Cube Format");
150  cubeFormatBox->setLayout(layout);
151 
152  // Create cube format stuff
153  p_lsb = new QRadioButton("&LSB");
154  p_lsb->setToolTip("Save image data in little endian format");
155  p_msb = new QRadioButton("&MSB");
156  p_msb->setToolTip("Save image data in big endian format");
157 
158  buttonGroup = new QButtonGroup();
159  buttonGroup->addButton(p_lsb);
160  buttonGroup->addButton(p_msb);
161  buttonGroup->setExclusive(true);
162 
163  layout = new QVBoxLayout();
164  layout->addWidget(p_lsb);
165  layout->addWidget(p_msb);
166 
167  QGroupBox *byteOrderBox = new QGroupBox("Byte Order");
168  byteOrderBox->setLayout(layout);
169 
170  // Create the action buttons
171  QPushButton *okButton = new QPushButton("Ok");
172  connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
173 
174  QPushButton *cancelButton = new QPushButton("Cancel");
175  connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
176 
177  // Put the buttons in a horizontal orientation
178  QHBoxLayout *actionLayout = new QHBoxLayout();
179  actionLayout->addWidget(okButton);
180  actionLayout->addWidget(cancelButton);
181 
182  // Put the grid layout and action layout on the dialog
183  QVBoxLayout *dialogLayout = new QVBoxLayout(this);
184  dialogLayout->addWidget(pixelTypeBox);
185  dialogLayout->addWidget(labelFormatBox);
186  dialogLayout->addWidget(cubeFormatBox);
187  dialogLayout->addWidget(byteOrderBox);
188  dialogLayout->addLayout(actionLayout);
189  }
190 
191 
192  // Destructor
193  GuiOutputAttribute::~GuiOutputAttribute() {}
194 
195 
196  // Return the attributes in the dialog
197  QString GuiOutputAttribute::GetAttributes() {
198  QString att;
199  if(p_lsb->isChecked()) att += "+Lsb";
200  if(p_msb->isChecked()) att += "+Msb";
201 
202  if(p_tiled->isChecked()) att += "+Tile";
203  if(p_bsq->isChecked()) att += "+BandSequential";
204 
205  if(p_attached->isChecked()) att += "+Attached";
206  if(p_detached->isChecked()) att += "+Detached";
207 
208  if(p_real->isChecked()) att += "+Real";
209  if(p_unsignedByte->isChecked()) att += "+UnsignedByte";
210  if(p_signedWord->isChecked()) att += "+SignedWord";
211  if(p_unsignedWord->isChecked()) att += "+UnsignedWord";
212  if(p_signedInteger->isChecked()) att += "+SignedInteger";
213  if(p_unsignedInteger->isChecked()) att += "+UnsignedInteger";
214 
215  if(p_unsignedByte->isChecked() || p_signedWord->isChecked() || p_unsignedWord->isChecked()
216  || p_signedInteger->isChecked() || p_unsignedInteger->isChecked()) {
217  if((p_minEdit->text() != "") && (p_maxEdit->text() != "")) {
218  att += "+";
219  att += p_minEdit->text();
220  att += ":";
221  att += p_maxEdit->text();
222  }
223  }
224 
225  Isis::CubeAttributeOutput catt(att);
226  QString s = catt.toString();
227  return s;
228  }
229 
230  // Set the attributes in the dialog
231  void GuiOutputAttribute::SetAttributes(const QString &value) {
232  Isis::CubeAttributeOutput att(value);
233  if(att.fileFormat() == Cube::Tile) {
234  p_tiled->setChecked(true);
235  }
236  else {
237  p_bsq->setChecked(true);
238  }
239 
240  if(att.byteOrder() == Isis::Lsb) {
241  p_lsb->setChecked(true);
242  }
243  else {
244  p_msb->setChecked(true);
245  }
246 
247  if(att.labelAttachment() == AttachedLabel) {
248  p_attached->setChecked(true);
249  }
250  else {
251  p_detached->setChecked(true);
252  }
253 
254  if(att.propagatePixelType()) {
255  p_propagate->setChecked(true);
256  }
257  else if(att.pixelType() == Isis::UnsignedByte) {
258  p_unsignedByte->setChecked(true);
259  }
260  else if(att.pixelType() == Isis::SignedWord) {
261  p_signedWord->setChecked(true);
262  }
263  else if(att.pixelType() == Isis::UnsignedWord) {
264  p_unsignedWord->setChecked(true);
265  }
266  else if(att.pixelType() == Isis::SignedInteger) {
267  p_signedInteger->setChecked(true);
268  }
269  else if(att.pixelType() == Isis::UnsignedInteger) {
270  p_unsignedInteger->setChecked(true);
271  }
272  else {
273  p_real->setChecked(true);
274  }
275 
276  if(!att.propagateMinimumMaximum()) {
277  p_minEdit->setText(QString::number(att.minimum()));
278  p_maxEdit->setText(QString::number(att.maximum()));
279  }
280  }
281 
284  p_propagationEnabled = enabled;
285  p_propagate->setEnabled(enabled);
286  }
287 }
QWidget
Isis::CubeAttributeOutput
Manipulate and parse attributes of output cube filenames.
Definition: CubeAttribute.h:473
Isis::GuiOutputAttribute::SetPropagation
void SetPropagation(bool enabled)
Do we allow propagation.
Definition: GuiOutputAttribute.cpp:283
Isis::AttachedLabel
@ AttachedLabel
The input label is embedded in the image file.
Definition: CubeAttribute.h:32
Isis::Cube::Tile
@ Tile
Cubes are stored in tile format, that is the order of the pixels in the file (on disk) is BSQ within ...
Definition: Cube.h:232
Isis::GuiOutputAttribute
Definition: GuiOutputAttribute.h:29
Isis::GuiOutputAttribute::GuiOutputAttribute
GuiOutputAttribute(QWidget *parent=0)
Constuctor.
Definition: GuiOutputAttribute.cpp:51
QDialog
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16

U.S. Department of the Interior | U.S. Geological Survey
ISIS | Privacy & Disclaimers | Astrogeology Research Program
To contact us, please post comments and questions on the USGS Astrogeology Discussion Board
To report a bug, or suggest a feature go to: ISIS Github
File Modified: 07/13/2023 15:16:32