Isis 3 Programmer Reference
GuiCubeParameter.cpp
1 
6 /* SPDX-License-Identifier: CC0-1.0 */
7 
8 #include <sstream>
9 
10 #include <QDialog>
11 #include <QDir>
12 #include <QFileDialog>
13 #include <QHBoxLayout>
14 #include <QLineEdit>
15 #include <QMenu>
16 #include <QString>
17 #include <QTextEdit>
18 #include <QToolButton>
19 
20 
21 #include "Application.h"
22 #include "Cube.h"
23 #include "FileName.h"
24 #include "GuiCubeParameter.h"
25 #include "GuiInputAttribute.h"
26 #include "GuiOutputAttribute.h"
27 #include "IException.h"
28 #include "ProgramLauncher.h"
29 #include "Pvl.h"
30 #include "UserInterface.h"
31 
32 
33 namespace Isis {
34 
44  int group, int param) :
45  GuiFileNameParameter(grid, ui, group, param) {
46  p_menu = new QMenu();
47 
48  QAction *fileAction = new QAction(this);
49  fileAction->setText("Select Cube");
50  connect(fileAction, SIGNAL(triggered(bool)), this, SLOT(SelectFile()));
51  p_menu->addAction(fileAction);
52 
53  QAction *attAction = new QAction(this);
54  attAction->setText("Change Attributes ...");
55  connect(attAction, SIGNAL(triggered(bool)), this, SLOT(SelectAttribute()));
56  p_menu->addAction(attAction);
57 
58  QAction *viewAction = new QAction(this);
59  viewAction->setText("View cube");
60  connect(viewAction, SIGNAL(triggered(bool)), this, SLOT(ViewCube()));
61  p_menu->addAction(viewAction);
62 
63  QAction *labAction = new QAction(this);
64  labAction->setText("View labels");
65  connect(labAction, SIGNAL(triggered(bool)), this, SLOT(ViewLabel()));
66  p_menu->addAction(labAction);
67 
68  p_fileButton->setMenu(p_menu);
69  p_fileButton->setPopupMode(QToolButton::MenuButtonPopup);
70  QString optButtonWhatsThisText = "<p><b>Function:</b> \
71  Opens a file chooser window to select a file from</p> <p>\
72  <b>Hint: </b> Click the arrow for more cube parameter options</p>";
73  p_fileButton->setWhatsThis(optButtonWhatsThisText);
74 
75  p_type = CubeWidget;
76  }
77 
78 
83  delete p_menu;
84  }
85 
86 
91  if(p_ui->ParamFileMode(p_group, p_param) == "input") {
92  Isis::CubeAttributeInput att(p_lineEdit->text());
93  QString curAtt = att.toString();
94  QString newAtt;
95  int status = GuiInputAttribute::GetAttributes(curAtt, newAtt,
96  p_ui->ParamName(p_group, p_param),
97  p_fileButton);
98  if((status == 1) && (curAtt != newAtt)) {
99  Isis::FileName f(p_lineEdit->text());
100  p_lineEdit->setText(f.expanded() + newAtt);
101  }
102  }
103  else {
104  Isis::CubeAttributeOutput att("+" + p_ui->PixelType(p_group, p_param));
105  bool allowProp = att.propagatePixelType();
106  att.addAttributes(FileName(p_lineEdit->text()));
107 
108  QString curAtt = att.toString();
109  QString newAtt;
110  int status = GuiOutputAttribute::GetAttributes(curAtt, newAtt,
111  p_ui->ParamName(p_group, p_param),
112  allowProp,
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 
120  return;
121  }
122 
128  try {
129  // Make sure the user entered a value
130  if(IsModified()) {
131  QString cubeName = Value();
132 
133  // Check to make sure the cube can be opened
134  Isis::Cube temp;
135  temp.open(cubeName);
136  temp.close();
137 
138  // Open the cube in Qview
139  QString command = "$ISISROOT/bin/qview " + cubeName + " &";
141  }
142  // Throw an error if no cube name was entered
143  else {
144  QString msg = "You must enter a cube name to open";
145  throw IException(IException::User, msg, _FILEINFO_);
146  }
147  }
148  catch(IException &e) {
149  Isis::iApp->GuiReportError(e);
150  }
151  }
152 
158  try {
159  // Make sure the user entered a value
160  if(IsModified()) {
161  QString cubeName = Value();
162 
163  // Check to make sure the cube can be opened
164  Isis::Cube temp;
165  temp.open(cubeName);
166 
167  // Get the label and write it out to the log
168  Isis::Pvl *label = temp.label();
170 
171  // Close the cube
172  temp.close();
173 
174  }
175  else {
176  QString msg = "You must enter a cube name to open";
177  throw IException(IException::User, msg, _FILEINFO_);
178  }
179  }
180  catch(IException &e) {
181  Isis::iApp->GuiReportError(e);
182  }
183 
184  }
185 }
186 
Isis::Application::GuiLog
static void GuiLog(const Pvl &results)
Writes the Pvl results to the sessionlog, but not to the printfile.
Definition: Application.cpp:395
Isis::GuiCubeParameter::SelectAttribute
void SelectAttribute()
Select cube attributes.
Definition: GuiCubeParameter.cpp:90
Isis::ProgramLauncher::RunSystemCommand
static void RunSystemCommand(QString commandLine)
This runs arbitrary system commands.
Definition: ProgramLauncher.cpp:207
Isis::FileName
File name manipulation and expansion.
Definition: FileName.h:100
Isis::GuiCubeParameter::ViewCube
void ViewCube()
Opens cube in qview.
Definition: GuiCubeParameter.cpp:127
QMenu
Isis::Cube::close
void close(bool remove=false)
Closes the cube and updates the labels.
Definition: Cube.cpp:260
Isis::Pvl
Container for cube-like labels.
Definition: Pvl.h:119
Isis::CubeAttributeOutput
Manipulate and parse attributes of output cube filenames.
Definition: CubeAttribute.h:473
Isis::GuiParameter::IsModified
virtual bool IsModified()
Return if the parameter value is different from the default value.
Definition: GuiParameter.cpp:181
Isis::CubeAttribute::addAttributes
void addAttributes(const FileName &fileNameWithAtts)
Append the attributes found in the filename to these cube attributes.
Definition: CubeAttribute.h:222
Isis::GuiFileNameParameter::Value
QString Value()
Gets the value found in the line edit text box.
Definition: GuiFilenameParameter.cpp:82
Isis::FileName::expanded
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
Definition: FileName.cpp:196
Isis::GuiFileNameParameter
Definition: GuiFilenameParameter.h:32
Isis::Application::GuiReportError
void GuiReportError(IException &e)
Loads the error message into the gui, but does not write it to the session log.
Definition: Application.cpp:708
IsisAml::ParamFileMode
QString ParamFileMode(const int &group, const int &param) const
Returns the file mode for a parameter in a specified group.
Definition: IsisAml.cpp:1581
Isis::GuiFileNameParameter::SelectFile
virtual void SelectFile()
Gets an input/output file from a GUI filechooser or typed in filename.
Definition: GuiFilenameParameter.cpp:105
Isis::Cube
IO Handler for Isis Cubes.
Definition: Cube.h:167
Isis::IException
Isis exception class.
Definition: IException.h:91
IsisAml::PixelType
QString PixelType(const int &group, const int &param) const
Returns the default pixel type from the XML.
Definition: IsisAml.cpp:1743
Isis::GuiCubeParameter::GuiCubeParameter
GuiCubeParameter(QGridLayout *grid, UserInterface &ui, int group, int param)
Constructs GuiCubeParameter object.
Definition: GuiCubeParameter.cpp:43
Isis::UserInterface
Command Line and Xml loader, validation, and access.
Definition: UserInterface.h:140
Isis::Cube::label
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
Definition: Cube.cpp:1701
Isis::CubeAttributeInput
Manipulate and parse attributes of input cube filenames.
Definition: CubeAttribute.h:381
Isis::GuiCubeParameter::ViewLabel
void ViewLabel()
Displays cube label in the GUI log.
Definition: GuiCubeParameter.cpp:157
Isis::Cube::open
void open(const QString &cfile, QString access="r")
This method will open an isis cube for reading or reading/writing.
Definition: Cube.cpp:627
QAction
Isis::CubeAttributeOutput::propagatePixelType
bool propagatePixelType() const
Return true if the pixel type is to be propagated from an input cube.
Definition: CubeAttribute.cpp:165
IsisAml::ParamName
QString ParamName(const int &group, const int &param) const
Returns the parameter name.
Definition: IsisAml.cpp:1219
Isis::GuiCubeParameter::~GuiCubeParameter
~GuiCubeParameter()
Destructor of GuiCubeParameter object.
Definition: GuiCubeParameter.cpp:82
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16
Isis::IException::User
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
Definition: IException.h:126