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

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 ISIS Support Center
File Modified: 07/12/2023 23:19:15