Isis 3 Programmer Reference
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 
Manipulate and parse attributes of input cube filenames.
virtual void SelectFile()
Gets an input/output file from a GUI filechooser or typed in filename.
void ViewLabel()
Displays cube label in the GUI log.
File name manipulation and expansion.
Definition: FileName.h:116
QString Value()
Gets the value found in the line edit text box.
bool propagatePixelType() const
Return true if the pixel type is to be propagated from an input cube.
void GuiReportError(IException &e)
Loads the error message into the gui, but does not write it to the session log.
GuiCubeParameter(QGridLayout *grid, UserInterface &ui, int group, int param)
Constructs GuiCubeParameter object.
QString PixelType(const int &group, const int &param) const
Returns the default pixel type from the XML.
Definition: IsisAml.cpp:1759
static void RunSystemCommand(QString commandLine)
This runs arbitrary system commands.
static void GuiLog(const Pvl &results)
Writes the Pvl results to the sessionlog, but not to the printfile.
void SelectAttribute()
Select cube attributes.
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:40
Manipulate and parse attributes of output cube filenames.
A type of error that could only have occurred due to a mistake on the user&#39;s part (e...
Definition: IException.h:142
void close(bool remove=false)
Closes the cube and updates the labels.
Definition: Cube.cpp:177
void open(const QString &cfile, QString access="r")
This method will open an isis cube for reading or reading/writing.
Definition: Cube.cpp:544
virtual bool IsModified()
Return if the parameter value is different from the default value.
Container for cube-like labels.
Definition: Pvl.h:135
~GuiCubeParameter()
Destructor of GuiCubeParameter object.
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
Definition: Cube.cpp:1346
QString ParamFileMode(const int &group, const int &param) const
Returns the file mode for a parameter in a specified group.
Definition: IsisAml.cpp:1597
Isis exception class.
Definition: IException.h:107
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31
Command Line and Xml loader, validation, and access.
QString ParamName(const int &group, const int &param) const
Returns the parameter name.
Definition: IsisAml.cpp:1235
void ViewCube()
Opens cube in qview.
IO Handler for Isis Cubes.
Definition: Cube.h:170