Isis 3 Programmer Reference
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_signedInteger = new QRadioButton("&Signed Integer");
78  p_signedInteger->setToolTip("Signed 32-bit integer");
79  p_unsignedInteger = new QRadioButton("Unsigned Integer");
80  p_unsignedInteger->setToolTip("Unsigned 32-bit integer");
81  p_real = new QRadioButton("&Real");
82  p_real->setToolTip("Floating point 32-bit pixels");
83 
84  QButtonGroup *buttonGroup = new QButtonGroup();
85  buttonGroup->addButton(p_propagate);
86  buttonGroup->addButton(p_unsignedByte);
87  buttonGroup->addButton(p_signedWord);
88  buttonGroup->addButton(p_unsignedWord);
89  buttonGroup->addButton(p_unsignedInteger);
90  buttonGroup->addButton(p_signedInteger);
91  buttonGroup->addButton(p_real);
92  buttonGroup->setExclusive(true);
93 
94  p_minEdit = new QLineEdit();
95  p_maxEdit = new QLineEdit();
96  QLabel *minLabel = new QLabel("Minimum");
97  QLabel *maxLabel = new QLabel("Maximum");
98  connect(p_propagate, SIGNAL(toggled(bool)), p_minEdit, SLOT(setDisabled(bool)));
99  connect(p_propagate, SIGNAL(toggled(bool)), p_maxEdit, SLOT(setDisabled(bool)));
100  connect(p_unsignedByte, SIGNAL(toggled(bool)), p_minEdit, SLOT(setEnabled(bool)));
101  connect(p_unsignedByte, SIGNAL(toggled(bool)), p_maxEdit, SLOT(setEnabled(bool)));
102  connect(p_signedWord, SIGNAL(toggled(bool)), p_minEdit, SLOT(setEnabled(bool)));
103  connect(p_signedWord, SIGNAL(toggled(bool)), p_maxEdit, SLOT(setEnabled(bool)));
104  connect(p_unsignedWord, SIGNAL(toggled(bool)), p_minEdit, SLOT(setEnabled(bool)));
105  connect(p_unsignedWord, SIGNAL(toggled(bool)), p_maxEdit, SLOT(setEnabled(bool)));
106  connect(p_unsignedInteger, SIGNAL(toggled(bool)), p_minEdit, SLOT(setEnabled(bool)));
107  connect(p_unsignedInteger, SIGNAL(toggled(bool)), p_maxEdit, SLOT(setEnabled(bool)));
108  connect(p_signedInteger, SIGNAL(toggled(bool)), p_minEdit, SLOT(setEnabled(bool)));
109  connect(p_signedInteger, SIGNAL(toggled(bool)), p_maxEdit, SLOT(setEnabled(bool)));
110  connect(p_real, SIGNAL(toggled(bool)), p_minEdit, SLOT(setDisabled(bool)));
111  connect(p_real, SIGNAL(toggled(bool)), p_maxEdit, SLOT(setDisabled(bool)));
112  p_minEdit->setValidator(new QDoubleValidator(p_minEdit));
113  p_maxEdit->setValidator(new QDoubleValidator(p_maxEdit));
114 
115  QGridLayout *gridLayout = new QGridLayout();
116  gridLayout->addWidget(p_propagate, 0, 0);
117  gridLayout->addWidget(p_unsignedByte, 1, 0);
118  gridLayout->addWidget(p_signedWord, 2, 0);
119  gridLayout->addWidget(p_unsignedWord, 3, 0);
120  gridLayout->addWidget(p_signedInteger, 4, 0);
121  gridLayout->addWidget(p_unsignedInteger, 5, 0);
122  gridLayout->addWidget(p_real, 6, 0);
123  gridLayout->addWidget(minLabel, 0, 1);
124  gridLayout->addWidget(p_minEdit, 1, 1);
125  gridLayout->addWidget(maxLabel, 2, 1);
126  gridLayout->addWidget(p_maxEdit, 3, 1);
127 
128  QGroupBox *pixelTypeBox = new QGroupBox("Pixel Type");
129  pixelTypeBox->setLayout(gridLayout);
130 
131  // Create detached/attached stuff
132  p_attached = new QRadioButton("&Attached");
133  p_attached->setToolTip("Save labels and image data in one file");
134  p_detached = new QRadioButton("&Detached");
135  p_detached->setToolTip("Save labels and image data in separate files");
136  p_attached->setChecked(true);
137 
138  buttonGroup = new QButtonGroup();
139  buttonGroup->addButton(p_attached);
140  buttonGroup->addButton(p_detached);
141  buttonGroup->setExclusive(true);
142 
143  QVBoxLayout *layout = new QVBoxLayout();
144  layout->addWidget(p_attached);
145  layout->addWidget(p_detached);
146 
147  QGroupBox *labelFormatBox = new QGroupBox("Label Format");
148  labelFormatBox->setLayout(layout);
149 
150  // Create cube format stuff
151  p_tiled = new QRadioButton("&Tiled");
152  p_tiled->setToolTip("Save image data in tiled format");
153  p_bsq = new QRadioButton("&BSQ");
154  p_bsq->setToolTip("Save image data in band sequential format");
155 
156  buttonGroup = new QButtonGroup();
157  buttonGroup->addButton(p_tiled);
158  buttonGroup->addButton(p_bsq);
159  buttonGroup->setExclusive(true);
160 
161  layout = new QVBoxLayout();
162  layout->addWidget(p_tiled);
163  layout->addWidget(p_bsq);
164 
165  QGroupBox *cubeFormatBox = new QGroupBox("Cube Format");
166  cubeFormatBox->setLayout(layout);
167 
168  // Create cube format stuff
169  p_lsb = new QRadioButton("&LSB");
170  p_lsb->setToolTip("Save image data in little endian format");
171  p_msb = new QRadioButton("&MSB");
172  p_msb->setToolTip("Save image data in big endian format");
173 
174  buttonGroup = new QButtonGroup();
175  buttonGroup->addButton(p_lsb);
176  buttonGroup->addButton(p_msb);
177  buttonGroup->setExclusive(true);
178 
179  layout = new QVBoxLayout();
180  layout->addWidget(p_lsb);
181  layout->addWidget(p_msb);
182 
183  QGroupBox *byteOrderBox = new QGroupBox("Byte Order");
184  byteOrderBox->setLayout(layout);
185 
186  // Create the action buttons
187  QPushButton *okButton = new QPushButton("Ok");
188  connect(okButton, SIGNAL(clicked()), this, SLOT(accept()));
189 
190  QPushButton *cancelButton = new QPushButton("Cancel");
191  connect(cancelButton, SIGNAL(clicked()), this, SLOT(reject()));
192 
193  // Put the buttons in a horizontal orientation
194  QHBoxLayout *actionLayout = new QHBoxLayout();
195  actionLayout->addWidget(okButton);
196  actionLayout->addWidget(cancelButton);
197 
198  // Put the grid layout and action layout on the dialog
199  QVBoxLayout *dialogLayout = new QVBoxLayout(this);
200  dialogLayout->addWidget(pixelTypeBox);
201  dialogLayout->addWidget(labelFormatBox);
202  dialogLayout->addWidget(cubeFormatBox);
203  dialogLayout->addWidget(byteOrderBox);
204  dialogLayout->addLayout(actionLayout);
205  }
206 
207 
208  // Destructor
209  GuiOutputAttribute::~GuiOutputAttribute() {}
210 
211 
212  // Return the attributes in the dialog
213  QString GuiOutputAttribute::GetAttributes() {
214  QString att;
215  if(p_lsb->isChecked()) att += "+Lsb";
216  if(p_msb->isChecked()) att += "+Msb";
217 
218  if(p_tiled->isChecked()) att += "+Tile";
219  if(p_bsq->isChecked()) att += "+BandSequential";
220 
221  if(p_attached->isChecked()) att += "+Attached";
222  if(p_detached->isChecked()) att += "+Detached";
223 
224  if(p_real->isChecked()) att += "+Real";
225  if(p_unsignedByte->isChecked()) att += "+UnsignedByte";
226  if(p_signedWord->isChecked()) att += "+SignedWord";
227  if(p_unsignedWord->isChecked()) att += "+UnsignedWord";
228  if(p_signedInteger->isChecked()) att += "+SignedInteger";
229  if(p_unsignedInteger->isChecked()) att += "+UnsignedInteger";
230 
231  if(p_unsignedByte->isChecked() || p_signedWord->isChecked() || p_unsignedWord->isChecked()
232  || p_signedInteger->isChecked() || p_unsignedInteger->isChecked()) {
233  if((p_minEdit->text() != "") && (p_maxEdit->text() != "")) {
234  att += "+";
235  att += p_minEdit->text();
236  att += ":";
237  att += p_maxEdit->text();
238  }
239  }
240 
241  Isis::CubeAttributeOutput catt(att);
242  QString s = catt.toString();
243  return s;
244  }
245 
246  // Set the attributes in the dialog
247  void GuiOutputAttribute::SetAttributes(const QString &value) {
248  Isis::CubeAttributeOutput att(value);
249  if(att.fileFormat() == Cube::Tile) {
250  p_tiled->setChecked(true);
251  }
252  else {
253  p_bsq->setChecked(true);
254  }
255 
256  if(att.byteOrder() == Isis::Lsb) {
257  p_lsb->setChecked(true);
258  }
259  else {
260  p_msb->setChecked(true);
261  }
262 
263  if(att.labelAttachment() == AttachedLabel) {
264  p_attached->setChecked(true);
265  }
266  else {
267  p_detached->setChecked(true);
268  }
269 
270  if(att.propagatePixelType()) {
271  p_propagate->setChecked(true);
272  }
273  else if(att.pixelType() == Isis::UnsignedByte) {
274  p_unsignedByte->setChecked(true);
275  }
276  else if(att.pixelType() == Isis::SignedWord) {
277  p_signedWord->setChecked(true);
278  }
279  else if(att.pixelType() == Isis::UnsignedWord) {
280  p_unsignedWord->setChecked(true);
281  }
282  else if(att.pixelType() == Isis::SignedInteger) {
283  p_signedInteger->setChecked(true);
284  }
285  else if(att.pixelType() == Isis::UnsignedInteger) {
286  p_unsignedInteger->setChecked(true);
287  }
288  else {
289  p_real->setChecked(true);
290  }
291 
292  if(!att.propagateMinimumMaximum()) {
293  p_minEdit->setText(QString::number(att.minimum()));
294  p_maxEdit->setText(QString::number(att.maximum()));
295  }
296  }
297 
300  p_propagationEnabled = enabled;
301  p_propagate->setEnabled(enabled);
302  }
303 }
Cubes are stored in tile format, that is the order of the pixels in the file (on disk) is BSQ within ...
Definition: Cube.h:234
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.
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
GuiOutputAttribute(QWidget *parent=0)
Constuctor.