52   UserInterface::UserInterface(
const QString &xmlfile, 
int &argc,
 
   65       FileName setup = 
"$HOME/.Isis/history";
 
   67       if ( !setup.fileExists() ) {
 
   68         setup.dir().mkpath(
".");
 
   81       p_gui = Gui::Create(*
this, argc, argv);
 
  135     for (
unsigned int currArgument = 1; currArgument < 
p_cmdline.size(); currArgument ++) {
 
  137       vector<QString> paramValue;
 
  143         if (paramName[0] == 
'-')
 
  146         for (
unsigned int value = 0; value < paramValue.size(); value++) {
 
  147           IString thisValue = paramValue[value];
 
  148           QString token = thisValue.
Token(
"$").
ToQt();
 
  152           while (thisValue != 
"") {
 
  155               int j = 
toInt( thisValue.substr(0, 1).c_str() ) - 1;
 
  157               thisValue.replace(0, 1, 
"");
 
  170           paramValue[value] = newValue;
 
  182       if(paramValue.size() == 1) {
 
  183         cout << 
"=" << paramValue[0] << 
" ";
 
  185       else if (paramValue.size() > 1) {
 
  188         for (
unsigned int value = 0; value < paramValue.size(); value++) {
 
  192           cout << paramValue[value] << endl;
 
  219       os.open(fileName.toLatin1().data(), std::ios::app);
 
  223         QString msg = 
"Unable to create error list [" + 
p_errList 
  224                       + 
"] Disk may be full or directory permissions not writeable";
 
  228       for (
int j = 0; j < (int) 
p_batchList[i].size(); j++) {
 
  247     if (grp[
"HistoryRecording"][0] == 
"Off")
 
  267       if ( histFile.fileExists() ) {
 
  268         hist.
read( histFile.expanded() );
 
  278     while( hist.
groups() > 
toInt(grp[
"HistoryLength"][0]) ) {
 
  284       hist.
write( histFile.expanded() );
 
  311       QString msg = 
"The batchlist file [" + file + 
"] could not be opened";
 
  317     for (
int i = 0; i < temp.
LineCount(); i++) {
 
  334       foreach (QString token, tokens) {
 
  336         token = token.remove( QRegExp(
"[\"']") );
 
  346         QString msg = 
"The number of columns must be constant in batchlist";
 
  352       QString msg = 
"The list file [" + file + 
"] does not contain any data";
 
  379     if ( (argc == 1) && (file.name() != 
"unitTest") ) {
 
  384     for (
int i = 0; i < argc; i++) {
 
  389     vector<QString> options;
 
  390     options.push_back(
"-GUI");
 
  391     options.push_back(
"-NOGUI");
 
  392     options.push_back(
"-BATCHLIST");
 
  393     options.push_back(
"-LAST");
 
  394     options.push_back(
"-RESTORE");
 
  395     options.push_back(
"-WEBHELP");
 
  396     options.push_back(
"-HELP");
 
  397     options.push_back(
"-ERRLIST");
 
  398     options.push_back(
"-ONERROR");
 
  399     options.push_back(
"-SAVE");
 
  400     options.push_back(
"-INFO");
 
  401     options.push_back(
"-PREFERENCE");
 
  402     options.push_back(
"-LOG");
 
  403     options.push_back(
"-VERBOSE");
 
  404     options.push_back(
"-PID");
 
  406     bool usedDashLast = 
false;
 
  407     bool usedDashRestore = 
false; 
 
  416     for (
unsigned int currArgument = 1; currArgument < (unsigned)argc; currArgument++) {
 
  418       vector<QString> paramValue;
 
  423       if (paramName[0] == 
'-') {
 
  424         paramName = paramName.toUpper();
 
  428         if (paramValue.size() > 1) {
 
  429           QString msg = 
"Invalid value for reserve parameter [" 
  439         if (paramName == 
"-LAST") {
 
  446         if (paramName == 
"-RESTORE") {
 
  447           usedDashRestore = 
true;
 
  451         QString realValue = 
"";
 
  453         if ( paramValue.size() ) {
 
  454           realValue = paramValue[0];
 
  472                                   || usedDashRestore) ) {
 
  473       QString msg = 
"-BATCHLIST cannot be used with -GUI, -SAVE, -RESTORE, ";
 
  480       QString msg = 
"-ERRLIST and -ONERROR=continue cannot be used without ";
 
  481       msg += 
" the -BATCHLIST option";
 
  500     if ( hist.fileExists() ) {
 
  505         if (g >= 0 && lab.group(g).isNamed(
"UserParameters") ) {
 
  507           for (
int k = 0; k < up.
keywords(); k++) {
 
  508             QString keyword = up[k].
name();
 
  510             vector<QString> values;
 
  512             for (
int i = 0; i < up[k].size(); i++) {
 
  513               values.push_back(up[k][i]);
 
  518             bool matchesDefault = 
false;
 
  519             if (values.size() == 1 && paramData->internalDefault == values[0])
 
  520               matchesDefault = 
true;
 
  522             if (!matchesDefault) {
 
  524                   (values.size() == paramData->defaultValues.size());
 
  526               for (
int i = 0; matchesDefault && i < (int)values.size(); i++) {
 
  527                 matchesDefault = matchesDefault &&
 
  528                                  values[i] == paramData->defaultValues[i];
 
  538         for (
int o = lab.objects() - 1; o >= 0; o--) {
 
  541             for (
int g = obj.
groups() - 1; g >= 0; g--) {
 
  543               if ( up.
isNamed(
"UserParameters") ) {
 
  544                 for (
int k = 0; k < up.
keywords(); k++) {
 
  545                   QString keyword = up[k].
name();
 
  546                   QString value = up[k][0];
 
  560         QString msg = 
"The history file [" + file + 
"] is for a different application or corrupt, "\
 
  561                       "please fix or delete this file";
 
  566       QString msg = 
"The history file [" + file + 
"] does not exist";
 
  587                                      const QString value) {
 
  589     bool unitTest = 
false;
 
  595     if (name == 
"-GUI") {
 
  598     else if (name == 
"-NOGUI") {
 
  601     else if (name == 
"-BATCHLIST") {
 
  604     else if (name == 
"-LAST") {
 
  617     else if(name == 
"-RESTORE") {
 
  620     else if(name == 
"-WEBHELP") {
 
  622       QString command = pref[
"GuiHelpBrowser"];
 
  623       command += 
" $ISISROOT/doc/Application/presentation/Tabbed/";
 
  628                          "Evaluating -WEBHELP should only throw this exception during a unitTest",
 
  637     else if (name == 
"-INFO") {
 
  641       if (value.size() != 0) {
 
  645     else if (name == 
"-HELP") {
 
  646       if (value.size() == 0) {
 
  789                          "Evaluating -HELP should only throw this exception during a unitTest",
 
  797     else if (name == 
"-PID") {
 
  800     else if (name == 
"-ERRLIST") {
 
  804         QString msg = 
"-ERRLIST expects a file name";
 
  812     else if (name == 
"-ONERROR") {
 
  813       if (value.toUpper() == 
"CONTINUE") {
 
  817       else if (value.toUpper() == 
"ABORT") {
 
  822         QString msg = 
"[" + value
 
  823                       + 
"] is an invalid value for -ONERROR, options are ABORT or CONTINUE";
 
  827     else if (name == 
"-SAVE") {
 
  828       if (value.size() == 0) {
 
  835     else if (name == 
"-PREFERENCE") {
 
  838     else if (name == 
"-LOG") {
 
  839       if( value.isEmpty() ) {
 
  840         p.
findGroup(
"SessionLog")[
"FileOutput"].setValue(
"On");
 
  843         p.
findGroup(
"SessionLog")[
"FileOutput"].setValue(
"On");
 
  844         p.
findGroup(
"SessionLog")[
"FileName"].setValue(value);
 
  848     else if (name == 
"-VERBOSE") {
 
  849       p.
findGroup(
"SessionLog")[
"TerminalOutput"].setValue(
"On");
 
  854       QString msg = 
"-GUI and -PID are incompatible arguments";
 
  873                                        std::vector<QString> &value) {
 
  875     QString paramValue = 
"";
 
  880     if ( !paramName.contains(
"=") ) {
 
  885         if (QString(
p_cmdline[curPos + 1]).compare(
"=") == 0) {
 
  894     else if ( paramName.endsWith(
"=") ) {
 
  895       paramName = paramName.mid(0, paramName.size() - 1);
 
  905     else if (paramName.indexOf(
"=") > 0) {
 
  906       QString parameterLiteral = 
p_cmdline[curPos];
 
  907       paramName = parameterLiteral.mid( 0, parameterLiteral.indexOf(
"=") );
 
  908       paramValue = parameterLiteral.mid(parameterLiteral.indexOf(
"=") + 1);
 
  913       QString msg = 
"Unknown parameter [" + QString(
p_cmdline[curPos])
 
  922     paramValue = paramValue.trimmed();
 
  924     if (paramValue.length() > 0 && paramValue[0] != 
'(') {
 
  929       if (paramValue.length() > 1 && paramValue.mid(0, 2) ==
"\\(") {
 
  930         paramValue = paramValue.mid(1);
 
  933       else if (paramValue.length() > 2 && paramValue.mid(0, 3) == 
"\\\\(") {
 
  934         paramValue = paramValue.mid(1);
 
  937       value.push_back(paramValue);
 
  939     else if ( paramValue.length() ) {
 
  959                                  std::vector<QString> &reservedParams) {
 
  960     for (
unsigned int currArgument = 1; currArgument < (unsigned)
p_cmdline.size(); 
 
  963       QString paramName = 
p_cmdline[currArgument];
 
  964       QString trueParamValue = 
"";
 
  965       vector<QString> paramValue;
 
  968       if (paramName[0] == 
'-') {
 
  972         paramName = paramName.toUpper();
 
  975         if ( paramValue.size() ) {
 
  976           trueParamValue = paramValue[0].toUpper();
 
  983         if (fullReservedName == paramName) {
 
 1005     std::vector<QString> values;
 
 1007     bool inDoubleQuotes = 
false;
 
 1008     bool inSingleQuotes = 
false;
 
 1009     bool arrayClosed = 
false;
 
 1010     bool nextElementStarted = 
false;
 
 1011     QString currElement = 
"";
 
 1013     for (
int strPos = 0; strPos < arrayString.size(); strPos++) {
 
 1015         if (arrayString[strPos] != 
'(') {
 
 1016           QString msg = 
"Invalid array format [" + arrayString + 
"]";
 
 1024       if ( arrayString[strPos] == 
'\\' && strPos + 1 < (
int)arrayString.size() ) {
 
 1025         currElement += arrayString[strPos+1];
 
 1030       else if (arrayString[strPos] == 
'\\') {
 
 1031         QString msg = 
"Invalid array format [" + arrayString + 
"]";
 
 1036       if (!inDoubleQuotes && !inSingleQuotes) {
 
 1038           QString msg = 
"Invalid array format [" + arrayString + 
"]";
 
 1042         nextElementStarted = (nextElementStarted || arrayString[strPos] != 
' ');
 
 1044         if (!nextElementStarted) {
 
 1048         if (arrayString[strPos] == 
'"') {
 
 1049           inDoubleQuotes = 
true;
 
 1051         else if (arrayString[strPos] == 
'\'') {
 
 1052           inSingleQuotes = 
true;
 
 1054         else if (arrayString[strPos] == 
',') {
 
 1055           values.push_back(currElement);
 
 1057           nextElementStarted = 
false;
 
 1059         else if (arrayString[strPos] == 
')') {
 
 1060           values.push_back(currElement);
 
 1063           nextElementStarted = 
false;
 
 1065         else if (nextElementStarted && arrayString[strPos] == 
' ') {
 
 1067           bool onlyWhite = 
true;
 
 1068           int closingPos = strPos + 1;
 
 1070           for( 
int pos = strPos;
 
 1071                onlyWhite && arrayString[pos] != 
',' && arrayString[pos] != 
')' &&
 
 1072                pos < arrayString.size(); pos++) {
 
 1074             onlyWhite &= (arrayString[pos] == 
' ');
 
 1078             currElement += arrayString[strPos];
 
 1081         else if (nextElementStarted) {
 
 1082           currElement += arrayString[strPos];
 
 1085       else if (inSingleQuotes) {
 
 1086         if(arrayString[strPos] == 
'\'') {
 
 1087           inSingleQuotes = 
false;
 
 1090           currElement += arrayString[strPos];
 
 1095         if (arrayString[strPos] == 
'"') {
 
 1096           inDoubleQuotes = 
false;
 
 1099           currElement += arrayString[strPos];
 
 1104     if (!arrayClosed || currElement != 
"") {
 
 1105       QString msg = 
"Invalid array format [" + arrayString + 
"]";
 
 1132                                           std::vector<QString> &reservedParams, 
 
 1133                                           bool handleNoMatches) {
 
 1135     int matchOption = -1;
 
 1137     for (
int option = 0; option < (int)reservedParams.size(); option++) {
 
 1140       if ( reservedParams[option].startsWith(unresolvedParam) ) {
 
 1141         if (matchOption >= 0) {
 
 1142           QString msg = 
"Ambiguous Reserve Parameter [" 
 1143           + unresolvedParam + 
"]. Please clarify.";
 
 1147         matchOption = option;
 
 1151     if (handleNoMatches) {
 
 1153       if (matchOption < 0) {
 
 1154         QString msg = 
"Invalid Reserve Parameter Option [" 
 1155         + unresolvedParam + 
"]. Choices are ";
 
 1158         for (
int option = 0; option < (int)reservedParams.size(); option++) {
 
 1160           if (reservedParams[option].compare(
"-PID") == 0) {
 
 1164           msgOptions += reservedParams[option];
 
 1177         msg += 
" [" + msgOptions + 
"]";
 
 1182     if (matchOption < 0) {
 
 1186       return reservedParams[matchOption];
 
PvlObject & object(const int index)
Return the object at the specified index. 
 
int NumParams(const int &) const 
Returns the number of parameters in a group. 
 
int ParamIncludeSize(const int &group, const int ¶m) const 
Returns the number of parameters included in this parameter's inclusions. 
 
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes. 
 
QString ToQt() const 
Retuns the object string as a QString. 
 
QString ParamDefault(const int &group, const int ¶m) const 
Returns the default for a parameter in a specified group. 
 
File name manipulation and expansion. 
 
QString ParamMinimum(const int &group, const int ¶m) const 
Returns the minimum value of a parameter in a specified group. 
 
const IsisParameterData * ReturnParam(const QString ¶mName) const 
Returns a pointer to a parameter whose name starts with paramName. 
 
QString resolveParameter(QString &name, std::vector< QString > &reservedParams, bool handleNoMatches=true)
This resolves a reserved parameter token on the command line to its fullname. 
 
QString ParamListBrief(const int &group, const int ¶m, const int &option) const 
Returns the brief description for a specific option to a parameter. 
 
static void checkX11()
check to see if X is available 
 
void Open(const QString &filename, const char *openmode="input", const char *extension="")
Opens a text file. 
 
void loadHistory(const QString file)
Loads the previous history for the program. 
 
QString ParamMaximum(const int &group, const int ¶m) const 
Returns the maximum value of a parameter in a specified group. 
 
int ParamGreaterThanOrEqualSize(const int &group, const int ¶m) const 
Returns the number of values in the parameters greater than or equal list. 
 
int ParamNotEqualSize(const int &group, const int ¶m) const 
Returns the number of values in the not equal list. 
 
int keywords() const 
Returns the number of keywords contained in the PvlContainer. 
 
int ParamExcludeSize(const int &group, const int ¶m) const 
Returns the number of parameters excluded in this parameter's exclusions. 
 
void addGroup(const Isis::PvlGroup &group)
Add a group to the object. 
 
int toInt(const QString &string)
Global function to convert from a string to an integer. 
 
void PutAsString(const QString ¶mName, const QString &value)
Allows the insertion of a value for any parameter. 
 
int BatchListSize()
Returns the size of the batchlist. 
 
int p_parentId
This is a status to indicate if the GUI is running or not. 
 
int ParamListIncludeSize(const int &group, const int ¶m, const int &option) const 
Returns the number of items in a parameters list include section. 
 
Gui * p_gui
Pointer to the gui object. 
 
QString GetInfoFileName()
This method returns the filename where the debugging info is stored when the "-info" tag is used...
 
This error is for when a programmer made an API call that was illegal. 
 
QString p_saveFile
FileName to save last history to. 
 
std::vector< char * > p_cmdline
This variable will contain argv. 
 
void deleteGroup(const QString &name)
Remove a group from the current PvlObject. 
 
int ParamListExcludeSize(const int &group, const int ¶m, const int &option) const 
Returns the number of items in a parameters list exclude section. 
 
void SaveHistory()
Saves the user parameter information in the history of the program for later use. ...
 
void setTerminator(const QString &term)
Sets the terminator used to signify the end of the PVL informationDefaults to "END". 
 
static void RunSystemCommand(QString commandLine)
This runs arbitrary system commands. 
 
QString ParamLessThan(const int &group, const int ¶m, const int &great) const 
Returns the name of the specified lessThan parameter. 
 
IString Compress(bool force=false)
Collapses multiple spaces into single spaces. 
 
QString ParamListExclude(const int &group, const int ¶m, const int &option, const int &exclude) const 
Returns the parameter name to be excluded if this option is selected. 
 
QString ParamMinimumInclusive(const int &group, const int ¶m) const 
Returns whether the minimum value is inclusive or not. 
 
IString Token(const IString &separator)
Returns the first token in the IString. 
 
QString ParamInclude(const int &group, const int ¶m, const int &include) const 
Returns the name of the specified included parameter. 
 
QString ParamType(const int &group, const int ¶m) const 
Returns the parameter type of a parameter in a specified group. 
 
int ParamLessThanOrEqualSize(const int &group, const int ¶m) const 
Returns the number of values in the parameters less than or equal list. 
 
Contains multiple PvlContainers. 
 
void evaluateOption(const QString name, const QString value)
This interprets the "-" options for reserved parameters. 
 
#define _FILEINFO_
Macro for the filename and line number. 
 
QString ParamExclude(const int &group, const int ¶m, const int &exclude) const 
Returns the name of the specified excluded parameter. 
 
A type of error that could only have occurred due to a mistake on the user's part (e...
 
A single keyword-value pair. 
 
QString p_infoFileName
FileName to save debugging info. 
 
void loadBatchList(const QString file)
Loads the user entered batchlist file into a private variable for later use. 
 
int ParamLessThanSize(const int &group, const int ¶m) const 
Returns the number of values in the parameters less than list. 
 
A type of error that cannot be classified as any of the other error types. 
 
QString ParamGreaterThan(const int &group, const int ¶m, const int &great) const 
Returns the name of the specified greaterThan parameter. 
 
int LineCount(const int &maxLinesToRead=0)
Counts number of lines in file. 
 
bool GetLine(QString &line, const bool skipComments=true)
Gets next line from file. 
 
QString ParamName(const int &group, const int ¶m) const 
Returns the parameter name. 
 
bool GetInfoFlag()
This method returns the flag state of info. 
 
void Clear(const QString ¶mName)
Clears the value(s) in the named parameter. 
 
std::vector< std::vector< QString > > p_batchList
Vector of batchlist data. 
 
QString PixelType(const int &group, const int ¶m) const 
Returns the default pixel type from the XML. 
 
Container for cube-like labels. 
 
~UserInterface()
Destroys the UserInterface object. 
 
bool p_interactive
Boolean value representing whether the program is interactive or not. 
 
QString ParamListValue(const int &group, const int ¶m, const int &option) const 
Returns the option value for a specific option to a parameter. 
 
void loadCommandLine(int argc, char *argv[])
This is used to load the command line into p_cmdline and the Aml object using information contained i...
 
QString p_progName
Name of program to run. 
 
QString ParamOdd(const int &group, const int ¶m) const 
Returns whether the selected parameter has a restriction on odd values or not. 
 
Application program XML file parameter manager. 
 
QString p_errList
FileName to write batchlist line that caused error on. 
 
Provides access to sequential ASCII stream I/O. 
 
QString ParamBrief(const int &group, const int ¶m) const 
Returns the brief description of a parameter in a specified group. 
 
int groups() const 
Returns the number of groups contained. 
 
PvlGroup & group(const int index)
Return the group at the specified index. 
 
QString ProgramName() const 
Returns the Program name. 
 
int NumGroups() const 
Returns the number of groups found in the XML. 
 
IString Replace(const std::string &from, const std::string &to, int maxReplaceCount=20)
Replaces all instances of the first input string with the second input string. 
 
Adds specific functionality to C++ strings. 
 
QString ParamNotEqual(const int &group, const int ¶m, const int ¬Eq) const 
Returns the name of the specified notEqual parameter. 
 
void VerifyAll()
Verify all parameters. 
 
bool p_info
Boolean value representing if it's in debug mode. 
 
QString ParamGreaterThanOrEqual(const int &group, const int ¶m, const int &great) const 
Returns the name of the specified greaterThanOrEqual parameter. 
 
bool isNamed(const QString &match) const 
Returns whether the given string is equal to the container name or not. 
 
QString ParamInternalDefault(const int &group, const int ¶m) const 
Returns the internal default for a parameter in a specified group. 
 
std::vector< QString > readArray(QString arrayString)
This interprets an array value from the command line. 
 
void SetBatchList(int i)
Clears the gui parameters and sets the batch list information at line i as the new parameters...
 
void CommandLine(Isis::Pvl &lab) const 
Creates a QString which could be used as a command line. 
 
void write(const QString &file)
Opens and writes PVL information to a file and handles the end of line sequence. 
 
int ParamListSize(const int &group, const int ¶m) const 
Returns the number of options in the specified parameter's list. 
 
QString ParamListInclude(const int &group, const int ¶m, const int &option, const int &include) const 
Returns the parameter name to be included if this option is selected. 
 
QString ParamLessThanOrEqual(const int &group, const int ¶m, const int &les) const 
Returns the name of the specified lessThanOrEqual parameter. 
 
void SetErrorList(int i)
This method adds the line specified in the BatchList that the error occured on. 
 
Contains Pvl Groups and Pvl Objects. 
 
void read(const QString &file)
Loads PVL information from a stream. 
 
void getNextParameter(unsigned int &curPos, QString &unresolvedParam, std::vector< QString > &value)
This gets the next parameter in the list of arguments. 
 
int ParamGreaterThanSize(const int &group, const int ¶m) const 
Returns the number of values in the parameters greater than list. 
 
QString name() const 
Returns the container name. 
 
void preProcess(QString fullReservedName, std::vector< QString > &reservedParams)
This parses the command line and looks for the specified reserved parameter name passed. 
 
bool p_abortOnError
Boolean value representing whether to abort or continue on error. 
 
Reads user preferences from a data file. 
 
QString ParamMaximumInclusive(const int &group, const int ¶m) const 
Returns whether the maximum value is inclusive or not. 
 
void addValue(QString value, QString unit="")
Adds a value with units.