USGS

Isis 3.0 Object Programmers' Reference

Home

GuiCubeParameter.cpp
Go to the documentation of this file.
1 
24 #include <sstream>
25 
26 #include <QDialog>
27 #include <QDir>
28 #include <QFileDialog>
29 #include <QHBoxLayout>
30 #include <QLineEdit>
31 #include <QMenu>
32 #include <QString>
33 #include <QTextEdit>
34 #include <QToolButton>
35 
36 
37 #include "Application.h"
38 #include "Cube.h"
39 #include "FileName.h"
40 #include "GuiCubeParameter.h"
41 #include "GuiInputAttribute.h"
42 #include "GuiOutputAttribute.h"
43 #include "IException.h"
44 #include "ProgramLauncher.h"
45 #include "Pvl.h"
46 #include "UserInterface.h"
47 
48 
49 namespace Isis {
50 
60  int group, int param) :
61  GuiFileNameParameter(grid, ui, group, param) {
62  p_menu = new QMenu();
63 
64  QAction *fileAction = new QAction(this);
65  fileAction->setText("Select Cube");
66  connect(fileAction, SIGNAL(triggered(bool)), this, SLOT(SelectFile()));
67  p_menu->addAction(fileAction);
68 
69  QAction *attAction = new QAction(this);
70  attAction->setText("Change Attributes ...");
71  connect(attAction, SIGNAL(triggered(bool)), this, SLOT(SelectAttribute()));
72  p_menu->addAction(attAction);
73 
74  QAction *viewAction = new QAction(this);
75  viewAction->setText("View cube");
76  connect(viewAction, SIGNAL(triggered(bool)), this, SLOT(ViewCube()));
77  p_menu->addAction(viewAction);
78 
79  QAction *labAction = new QAction(this);
80  labAction->setText("View labels");
81  connect(labAction, SIGNAL(triggered(bool)), this, SLOT(ViewLabel()));
82  p_menu->addAction(labAction);
83 
84  p_fileButton->setMenu(p_menu);
85  p_fileButton->setPopupMode(QToolButton::MenuButtonPopup);
86  QString optButtonWhatsThisText = "<p><b>Function:</b> \
87  Opens a file chooser window to select a file from</p> <p>\
88  <b>Hint: </b> Click the arrow for more cube parameter options</p>";
89  p_fileButton->setWhatsThis(optButtonWhatsThisText);
90 
91  p_type = CubeWidget;
92  }
93 
94 
99  delete p_menu;
100  }
101 
102 
107  if(p_ui->ParamFileMode(p_group, p_param) == "input") {
108  Isis::CubeAttributeInput att(p_lineEdit->text());
109  QString curAtt = att.toString();
110  QString newAtt;
111  int status = GuiInputAttribute::GetAttributes(curAtt, newAtt,
112  p_ui->ParamName(p_group, p_param),
113  p_fileButton);
114  if((status == 1) && (curAtt != newAtt)) {
115  Isis::FileName f(p_lineEdit->text());
116  p_lineEdit->setText(f.expanded() + newAtt);
117  }
118  }
119  else {
120  Isis::CubeAttributeOutput att("+" + p_ui->PixelType(p_group, p_param));
121  bool allowProp = att.propagatePixelType();
122  att.addAttributes(FileName(p_lineEdit->text()));
123 
124  QString curAtt = att.toString();
125  QString newAtt;
126  int status = GuiOutputAttribute::GetAttributes(curAtt, newAtt,
127  p_ui->ParamName(p_group, p_param),
128  allowProp,
129  p_fileButton);
130  if((status == 1) && (curAtt != newAtt)) {
131  Isis::FileName f(p_lineEdit->text());
132  p_lineEdit->setText(f.expanded() + newAtt);
133  }
134  }
135 
136  return;
137  }
138 
144  try {
145  // Make sure the user entered a value
146  if(IsModified()) {
147  QString cubeName = Value();
148 
149  // Check to make sure the cube can be opened
150  Isis::Cube temp;
151  temp.open(cubeName);
152  temp.close();
153 
154  // Open the cube in Qview
155  QString command = "$ISISROOT/bin/qview " + cubeName + " &";
157  }
158  // Throw an error if no cube name was entered
159  else {
160  QString msg = "You must enter a cube name to open";
162  }
163  }
164  catch(IException &e) {
165  Isis::iApp->GuiReportError(e);
166  }
167  }
168 
174  try {
175  // Make sure the user entered a value
176  if(IsModified()) {
177  QString cubeName = Value();
178 
179  // Check to make sure the cube can be opened
180  Isis::Cube temp;
181  temp.open(cubeName);
182 
183  // Get the label and write it out to the log
184  Isis::Pvl *label = temp.label();
186 
187  // Close the cube
188  temp.close();
189 
190  }
191  else {
192  QString msg = "You must enter a cube name to open";
194  }
195  }
196  catch(IException &e) {
197  Isis::iApp->GuiReportError(e);
198  }
199 
200  }
201 }
202