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
33namespace 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
static void GuiLog(const Pvl &results)
Writes the Pvl results to the sessionlog, but not to the printfile.
void GuiReportError(IException &e)
Loads the error message into the gui, but does not write it to the session log.
Manipulate and parse attributes of input cube filenames.
Manipulate and parse attributes of output cube filenames.
IO Handler for Isis Cubes.
Definition Cube.h:168
void open(const QString &cfile, QString access="r")
This method will open an existing isis cube for reading or reading/writing.
Definition Cube.cpp:622
File name manipulation and expansion.
Definition FileName.h:100
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
Definition FileName.cpp:196
void SelectAttribute()
Select cube attributes.
~GuiCubeParameter()
Destructor of GuiCubeParameter object.
GuiCubeParameter(QGridLayout *grid, UserInterface &ui, int group, int param)
Constructs GuiCubeParameter object.
void ViewCube()
Opens cube in qview.
void ViewLabel()
Displays cube label in the GUI log.
virtual void SelectFile()
Gets an input/output file from a GUI filechooser or typed in filename.
QString Value()
Gets the value found in the line edit text box.
virtual bool IsModified()
Return if the parameter value is different from the default value.
Isis exception class.
Definition IException.h:91
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
Definition IException.h:126
static void RunSystemCommand(QString commandLine)
This runs arbitrary system commands.
Container for cube-like labels.
Definition Pvl.h:119
Command Line and Xml loader, validation, and access.
QString PixelType(const int &group, const int &param) const
Returns the default pixel type from the XML.
Definition IsisAml.cpp:1920
QString ParamFileMode(const int &group, const int &param) const
Returns the file mode for a parameter in a specified group.
Definition IsisAml.cpp:1748
QString ParamName(const int &group, const int &param) const
Returns the parameter name.
Definition IsisAml.cpp:1362
This is free and unencumbered software released into the public domain.
Definition Apollo.h:16