USGS

Isis 3.0 Object Programmers' Reference

Home

IsisAml.cpp

Go to the documentation of this file.
00001 
00024 #include <sstream>
00025 #include <xercesc/util/PlatformUtils.hpp>
00026 #include <xercesc/util/TransService.hpp>
00027 #include <xercesc/sax2/XMLReaderFactory.hpp>
00028 
00029 #include "FileName.h"
00030 #include "IException.h"
00031 #include "IsisAml.h"
00032 #include "IsisXMLChTrans.h"
00033 #include "IString.h"
00034 #include "Preference.h"
00035 #include "Pvl.h"
00036 #include "PvlGroup.h"
00037 #include "PvlKeyword.h"
00038 #include "PvlObject.h"
00039 
00040 using namespace std;
00041 
00046 namespace XERCES = XERCES_CPP_NAMESPACE;
00047 
00054 IsisAml::IsisAml(const QString &xmlfile) {
00055   StartParser(xmlfile.toAscii().data());
00056 }
00057 
00061 IsisAml::~IsisAml() {
00062 }
00063 
00081 void IsisAml::PutAsString(const QString &paramName,
00082                           const QString &value) {
00083 
00084   IsisParameterData *param = const_cast <IsisParameterData *>(ReturnParam(paramName));
00085 
00086   if(param->values.size() > 0) {
00087     QString message = "A value for this parameter [" + paramName + "] has "
00088                      "already been entered.";
00089     throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
00090   }
00091 
00092   param->values.clear();
00093   param->values.push_back(value);
00094 
00095 }
00096 
00109 void IsisAml::PutAsString(const QString &paramName,
00110                           const vector<QString> &value) {
00111 
00112   IsisParameterData *param = const_cast <IsisParameterData *>(ReturnParam(paramName));
00113 
00114   if(param->values.size() > 0) {
00115     QString message = "A value for this parameter [" + paramName + "] has "
00116                      "already been entered.";
00117     throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
00118   }
00119 
00120   param->values.resize(value.size());
00121   param->values = value;
00122 
00123 }
00124 
00125 
00126 // Public: Sets the value member of a parameter of type QString whose name
00127 // starts with paramName
00128 
00144 void IsisAml::PutString(const QString &paramName, const QString &value) {
00145 
00146   IsisParameterData *param = const_cast <IsisParameterData *>(ReturnParam(paramName));
00147 
00148   if(param->type != "string" && param->type != "combo") {
00149     QString message = "Parameter [" + paramName + "] is not a string.";
00150     throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
00151   }
00152 
00153   if(param->values.size() > 0) {
00154     QString message = "A value for this parameter [" + paramName + "] has "
00155                      "already been saved (possibly by IsisGui). If you need to "
00156                      "change the value use \"Clear\" before the Put.";
00157     throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
00158   }
00159 
00160   param->values.clear();
00161   param->values.push_back(value);
00162 
00163   Verify(param);
00164 }
00165 
00166 
00167 // Public: Sets the value member of a parameter of type QString whose name
00168 // starts with paramName
00176 void IsisAml::PutString(const QString &paramName,
00177                         const vector<QString> &value) {
00178 
00179   IsisParameterData *param = const_cast <IsisParameterData *>(ReturnParam(paramName));
00180 
00181   if(param->type != "string" && param->type != "combo") {
00182     QString message = "Parameter [" + paramName + "] is not a string.";
00183     throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
00184   }
00185 
00186   if(param->values.size() > 0) {
00187     QString message = "A value for this parameter [" + paramName + "] has "
00188                      "already been saved (possibly by IsisGui). If you need to "
00189                      "change the value use \"Clear\" before the Put.";
00190     throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
00191   }
00192 
00193   param->values.resize(value.size());
00194   param->values = value;
00195 
00196   Verify(param);
00197 }
00198 
00199 
00200 // Public: Sets the value member of a parameter of type filename whose name
00201 // starts with paramName
00202 
00211 void IsisAml::PutFileName(const QString &paramName,
00212                           const QString &value) {
00213 
00214   IsisParameterData *param = const_cast <IsisParameterData *>(ReturnParam(paramName));
00215 
00216   if((param->type != "filename") && (param->type != "cube")) {
00217     QString message = "Parameter [" + paramName + "] is not a filename.";
00218     throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
00219   }
00220 
00221   if(param->values.size() > 0) {
00222     QString message = "A value for this parameter [" + paramName + "] has "
00223                      "already been saved (possibly by IsisGui). If you need to "
00224                      "change the value use \"Clear\" before the Put.";
00225     throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
00226   }
00227 
00228   param->values.clear();
00229   param->values.push_back(value);
00230 
00231   Verify(param);
00232 }
00233 
00234 
00235 // Public: Sets the value member of a parameter of type filename whose name
00236 // starts with paramName
00237 
00253 void IsisAml::PutFileName(const QString &paramName,
00254                           const vector<QString> &value) {
00255 
00256   IsisParameterData *param = const_cast <IsisParameterData *>(ReturnParam(paramName));
00257 
00258   if((param->type != "filename") && (param->type != "cube")) {
00259     QString message = "Parameter [" + paramName + "] is not a filename.";
00260     throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
00261   }
00262 
00263   if(param->values.size() > 0) {
00264     QString message = "A value for this parameter [" + paramName + "] has "
00265                      "already been saved (possibly by IsisGui). If you need to "
00266                      "change the value use \"Clear\" before the Put.";
00267     throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
00268   }
00269 
00270   param->values.resize(value.size());
00271   param->values = value;
00272 
00273   Verify(param);
00274 }
00275 
00276 
00277 // Public: Sets the value member of a parameter of type integer whose name
00278 // starts with paramName
00279 
00291 void IsisAml::PutInteger(const QString &paramName,
00292                          const int &value) {
00293 
00294   IsisParameterData *param = const_cast <IsisParameterData *>(ReturnParam(paramName));
00295 
00296   if(param->type != "integer") {
00297     QString message = "Parameter [" + paramName + "] is not an integer.";
00298     throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
00299   }
00300 
00301   if(param->values.size() > 0) {
00302     QString message = "A value for this parameter [" + paramName + "] has "
00303                      "already been saved (possibly by IsisGui). If you need to "
00304                      "change the value use \"Clear\" before the Put.";
00305     throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
00306   }
00307 
00308   param->values.clear();
00309   param->values.push_back(Isis::toString(value));
00310 
00311   Verify(param);
00312 }
00313 
00314 
00315 // Public: Sets the value member of a parameter of type integer whose name
00316 // starts with paramName
00317 
00332 void IsisAml::PutInteger(const QString &paramName,
00333                          const vector<int> &value) {
00334 
00335   IsisParameterData *param = const_cast <IsisParameterData *>(ReturnParam(paramName));
00336 
00337   if(param->type != "integer") {
00338     QString message = "Parameter [" + paramName + "] is not an integer.";
00339     throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
00340   }
00341 
00342   if(param->values.size() > 0) {
00343     QString message = "A value for this parameter [" + paramName + "] has "
00344                      "already been saved (possibly by IsisGui). If you need to "
00345                      "change the value use \"Clear\" before the Put.";
00346     throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
00347   }
00348 
00349   param->values.resize(value.size());
00350   for(unsigned int i = 0; i < value.size(); i++) {
00351     param->values[i] = Isis::toString(value[i]);
00352   }
00353 
00354   Verify(param);
00355 }
00356 
00357 
00358 
00359 
00360 // Public: Sets the value member of a parameter of type double whose name
00361 // starts with paramName
00377 void IsisAml::PutDouble(const QString &paramName,
00378                         const double &value) {
00379 
00380   IsisParameterData *param = const_cast <IsisParameterData *>(ReturnParam(paramName));
00381 
00382   if(param->type != "double") {
00383     QString message = "Parameter [" + paramName + "] is not a double.";
00384     throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
00385   }
00386 
00387   if(param->values.size() > 0) {
00388     QString message = "A value for this parameter [" + paramName + "] has "
00389                      "already been saved (possibly by IsisGui). If you need to "
00390                      "change the value use \"Clear\" before the Put.";
00391     throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
00392   }
00393 
00394   param->values.clear();
00395   param->values.push_back(Isis::toString(value));
00396 
00397   Verify(param);
00398 }
00399 
00400 
00401 // Public: Sets the value member of a parameter of type double whose name
00402 // starts with paramName
00418 void IsisAml::PutDouble(const QString &paramName,
00419                         const vector<double> &value) {
00420 
00421   IsisParameterData *param = const_cast <IsisParameterData *>(ReturnParam(paramName));
00422 
00423   if(param->type != "double") {
00424     QString message = "Parameter [" + paramName + "] is not a double.";
00425     throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
00426   }
00427 
00428   if(param->values.size() > 0) {
00429     QString message = "A value for this parameter [" + paramName + "] has "
00430                      "already been saved (possibly by IsisGui). If you need to "
00431                      "change the value use \"Clear\" before the Put.";
00432     throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
00433   }
00434 
00435   param->values.resize(value.size());
00436   for(unsigned int i = 0; i < value.size(); i++) {
00437     param->values[i] = Isis::toString(value[i]);
00438   }
00439 
00440   Verify(param);
00441 }
00442 
00443 
00444 
00445 // Public: Sets the value member of a parameter of type boolean whose name
00446 // starts with paramName
00462 void IsisAml::PutBoolean(const QString &paramName,
00463                          const bool &value) {
00464 
00465   IsisParameterData *param = const_cast <IsisParameterData *>(ReturnParam(paramName));
00466 
00467   if(param->type != "boolean") {
00468     QString message = "Parameter [" + paramName + "] is not a boolean.";
00469     throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
00470   }
00471 
00472   if(param->values.size() > 0) {
00473     QString message = "A value for this parameter [" + paramName + "] has "
00474                      "already been saved (possibly by IsisGui). If you need to "
00475                      "change the value use \"Clear\" before the Put.";
00476     throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
00477   }
00478 
00479   param->values.clear();
00480   if(value) {
00481     param->values.push_back("YES");
00482   }
00483   else {
00484     param->values.push_back("NO");
00485   }
00486 
00487   Verify(param);
00488 }
00489 
00490 
00491 // Public: Sets the value member of a parameter of type boolean whose name
00492 // starts with paramName
00508 void IsisAml::PutBoolean(const QString &paramName,
00509                          const vector<bool> &value) {
00510 
00511   IsisParameterData *param = const_cast <IsisParameterData *>(ReturnParam(paramName));
00512 
00513   if(param->type != "boolean") {
00514     QString message = "Parameter [" + paramName + "] is not a boolean.";
00515     throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
00516   }
00517 
00518   if(param->values.size() > 0) {
00519     QString message = "A value for this parameter [" + paramName + "] has "
00520                      "already been saved (possibly by IsisGui). If you need to "
00521                      "change the value use \"Clear\" before the Put.";
00522     throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
00523   }
00524 
00525   param->values.resize(value.size());
00526   for(unsigned int i = 0; i < value.size(); i++) {
00527     if(value[i]) {
00528       param->values.push_back("YES");
00529     }
00530     else {
00531       param->values.push_back("NO");
00532     }
00533   }
00534 
00535   Verify(param);
00536 }
00537 
00538 
00539 // Accessor methods for getting the value(s) of a parameter
00540 
00541 // Public: Returns the first element of the value member of a parameter whos
00542 // name starts with paramName as a QString. Any type can be retrieve with this member.
00553 QString IsisAml::GetAsString(const QString &paramName) const {
00554 
00555   const IsisParameterData *param = ReturnParam(paramName);
00556   QString value;
00557   if(param->values.size() == 0) {
00558     if(param->defaultValues.size() == 0) {
00559       QString message = "Parameter [" + paramName + "] has no value.";
00560       throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
00561     }
00562     else {
00563       value = param->defaultValues[0];
00564     }
00565   }
00566   else {
00567     value = param->values[0];
00568   }
00569 
00570   return value;
00571 }
00572 
00573 // Public: Returns the value member of a parameter whose name starts with paramName
00574 // as a vector<QString>
00585 void IsisAml::GetAsString(const QString &paramName,
00586                           vector<QString> &values) const {
00587 
00588   const IsisParameterData *param = ReturnParam(paramName);
00589 
00590   values.clear();
00591   QString value;
00592   if(param->values.size() == 0) {
00593     if(param->defaultValues.size() == 0) {
00594       QString message = "Parameter [" + paramName + "] has no value.";
00595       throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
00596     }
00597     else {
00598       for(unsigned int i = 0; i < param->defaultValues.size(); i++)
00599         values.push_back(param->defaultValues[i]);
00600     }
00601   }
00602   else {
00603     for(unsigned int i = 0; i < param->values.size(); i++)
00604       values.push_back(param->values[i]);
00605   }
00606 
00607   return;
00608 }
00609 
00610 
00611 // Public: Returns the first element of the value member of a parameter whose
00612 // name starts with paramName as a QString/filename
00623 QString IsisAml::GetFileName(const QString &paramName, QString extension) const {
00624 
00625   const IsisParameterData *param = ReturnParam(paramName);
00626 
00627   if((param->type != "filename") && (param->type != "cube")) {
00628     QString message = "Parameter [" + paramName + "] is not a filename.";
00629     throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
00630   }
00631 
00632   QString value;
00633   if(param->values.size() == 0) {
00634     if(param->defaultValues.size() == 0) {
00635       QString message = "Parameter [" + paramName + "] has no value.";
00636       throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
00637     }
00638     else {
00639       value = param->defaultValues[0];
00640     }
00641   }
00642   else {
00643     value = param->values[0];
00644   }
00645 
00646   Isis::FileName name(value);
00647   if(extension != "") name = name.addExtension(extension);
00648   value = name.expanded();
00649 
00650   return value;
00651 }
00652 
00653 
00654 // Public: Returns the value member of a parameter whose name starts with paramName
00655 // as a vector<QString/filename>
00663 void IsisAml::GetFileName(const QString &paramName,
00664                           vector<QString> &values) const {
00665 
00666   const IsisParameterData *param = ReturnParam(paramName);
00667 
00668   if((param->type != "filename") && (param->type != "cube")) {
00669     QString message = "Parameter [" + paramName + "] is not a filename.";
00670     throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
00671   }
00672 
00673   values.clear();
00674   if(param->values.size() == 0) {
00675     if(param->defaultValues.size() == 0) {
00676       QString message = "Parameter [" + paramName + "] has no value.";
00677       throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
00678     }
00679     else {
00680       for(unsigned int i = 0; i < param->defaultValues.size(); i++) {
00681         Isis::FileName name(param->defaultValues[i]);
00682         values.push_back(name.expanded());
00683       }
00684     }
00685   }
00686   else {
00687     for(unsigned int i = 0; i < param->values.size(); i++) {
00688       Isis::FileName name(param->values[i]);
00689       values.push_back(name.expanded());
00690     }
00691   }
00692 
00693   return;
00694 }
00695 
00696 
00697 // Public: Returns the first element of the value member of a parameter whos
00698 // name starts with paramName as a QString
00708 QString IsisAml::GetString(const QString &paramName) const {
00709 
00710   const IsisParameterData *param = ReturnParam(paramName);
00711   QString value;
00712 
00713   if(param->type != "string" && param->type != "combo") {
00714     QString message = "Parameter [" + paramName + "] is not a string.";
00715     throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
00716   }
00717 
00718   if(param->values.size() == 0) {
00719     if(param->defaultValues.size() == 0) {
00720       QString message = "Parameter [" + paramName + "] has no value.";
00721       throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
00722     }
00723     else {
00724       value = param->defaultValues[0];
00725     }
00726   }
00727   else {
00728     value = param->values[0];
00729     // If there is a list of legal values return the list option that matches
00730     // or begins with what was entered rather than exactly what was entered
00731     if(param->listOptions.size() > 0) {
00732       value = value.toUpper();
00733       int found = -1;
00734       int foundcount = 0;
00735       for(unsigned int p = 0; p < param->listOptions.size(); p++) {
00736         QString option = param->listOptions[p].value;
00737         option = option.toUpper();
00738         if(value == option) {
00739           return value;
00740         }
00741         else if(value.startsWith(option) || option.startsWith(value)) {
00742           found = p;
00743           foundcount = foundcount + 1;
00744         }
00745       }
00746       if(foundcount == 0) {
00747         QString message = "Value [" + value + "] for parameter [" +
00748                           paramName + "] is not a valid value.";
00749         throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
00750       }
00751       if(foundcount > 1) {
00752         QString message = "Value [" + value + "] for parameter [" +
00753                           paramName + "] is not unique.";
00754         throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
00755       }
00756       return param->listOptions[found].value;
00757     }
00758 
00759     // Just return what is in the value
00760     else {
00761       value = param->values[0];
00762     }
00763   }
00764   return value;
00765 }
00766 
00767 
00768 // Public: Returns the value member of a parameter whose name starts with paramName
00769 // as a vector<QString>
00780 void IsisAml::GetString(const QString &paramName,
00781                         vector<QString> &values) const {
00782 
00783   const IsisParameterData *param = ReturnParam(paramName);
00784 
00785   if(param->type != "string" && param->type != "combo") {
00786     QString message = "Parameter [" + paramName + "] is not a string.";
00787     throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
00788   }
00789 
00790   values.clear();
00791   QString value;
00792   if(param->values.size() == 0) {
00793     if(param->defaultValues.size() == 0) {
00794       QString message = "Parameter [" + paramName + "] has no value.";
00795       throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
00796     }
00797     else {
00798       for(unsigned int i = 0; i < param->defaultValues.size(); i++)
00799         values.push_back(param->defaultValues[i]);
00800     }
00801   }
00802   else {
00803     for(unsigned int i = 0; i < param->values.size(); i++)
00804       values.push_back(param->values[i]);
00805   }
00806 
00807   return;
00808 }
00809 
00810 
00811 
00812 // Public: Returns the first element of the value member of a parameter whos
00813 // name starts with paramName as an integer
00823 int IsisAml::GetInteger(const QString &paramName) const {
00824 
00825   const IsisParameterData *param = ReturnParam(paramName);
00826 
00827   if(param->type != "integer") {
00828     QString message = "Parameter [" + paramName + "] is not an integer.";
00829     throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
00830   }
00831 
00832   Isis::IString value;
00833   if(param->values.size() == 0) {
00834     if(param->defaultValues.size() == 0) {
00835       QString message = "Parameter [" + paramName + "] has no value.";
00836       throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
00837     }
00838     else {
00839       value = param->defaultValues[0];
00840     }
00841   }
00842   else {
00843     value = param->values[0];
00844   }
00845 
00846   return value.ToInteger();
00847 }
00848 
00849 
00850 // Public: Returns the value member of a parameter whose name starts with paramName
00851 // as a vector<int>
00862 void IsisAml::GetInteger(const QString &paramName,
00863                          vector<int> &values) const {
00864 
00865   const IsisParameterData *param = ReturnParam(paramName);
00866 
00867   if(param->type != "integer") {
00868     QString message = "Parameter [" + paramName + "] is not an integer.";
00869     throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
00870   }
00871 
00872   values.clear();
00873   Isis::IString value;
00874   if(param->values.size() == 0) {
00875     if(param->defaultValues.size() == 0) {
00876       QString message = "Parameter [" + paramName + "] has no value.";
00877       throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
00878     }
00879     else {
00880       for(unsigned int i = 0; i < param->defaultValues.size(); i++)
00881         value = param->defaultValues[i];
00882       values.push_back(value.ToInteger());
00883     }
00884   }
00885   else {
00886     for(unsigned int i = 0; i < param->values.size(); i++)
00887       value = param->values[i];
00888     values.push_back(value.ToInteger());
00889   }
00890 
00891   return;
00892 }
00893 
00894 
00895 
00896 // Public: Returns the first element of the value member of a parameter whos
00897 // name starts with paramName as a doubble
00907 double IsisAml::GetDouble(const QString &paramName) const {
00908 
00909   const IsisParameterData *param = ReturnParam(paramName);
00910 
00911   if(param->type != "double") {
00912     QString message = "Parameter [" + paramName + "] is not a double.";
00913     throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
00914   }
00915 
00916   Isis::IString value;
00917   if(param->values.size() == 0) {
00918     if(param->defaultValues.size() == 0) {
00919       QString message = "Parameter [" + paramName + "] has no value.";
00920       throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
00921     }
00922     else {
00923       value = param->defaultValues[0];
00924     }
00925   }
00926   else {
00927     value = param->values[0];
00928   }
00929 
00930   return value.ToDouble();
00931 }
00932 
00933 // Public: Returns the value member of a parameter whose name starts with paramName
00934 // as a vector<doubble>
00945 void IsisAml::GetDouble(const QString &paramName,
00946                         vector<double> &values) const {
00947 
00948   const IsisParameterData *param = ReturnParam(paramName);
00949 
00950   if(param->type != "double") {
00951     QString message = "Parameter [" + paramName + "] is not a double.";
00952     throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
00953   }
00954 
00955   values.clear();
00956   Isis::IString value;
00957   if(param->values.size() == 0) {
00958     if(param->defaultValues.size() == 0) {
00959       QString message = "Parameter [" + paramName + "] has no value.";
00960       throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
00961     }
00962     else {
00963       for(unsigned int i = 0; i < param->defaultValues.size(); i++)
00964         value = param->defaultValues[i];
00965       values.push_back(value.ToDouble());
00966     }
00967   }
00968   else {
00969     for(unsigned int i = 0; i < param->values.size(); i++)
00970       value = param->values[i];
00971     values.push_back(value.ToDouble());
00972   }
00973 
00974   return;
00975 }
00976 
00977 
00978 // Public: Returns the first element of the value member of a parameter whos
00979 // name starts with paramName as a bool
00989 bool IsisAml::GetBoolean(const QString &paramName) const {
00990 
00991   const IsisParameterData *param = ReturnParam(paramName);
00992 
00993   if(param->type != "boolean") {
00994     QString message = "Parameter [" + paramName + "] is not a boolean.";
00995     throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
00996   }
00997 
00998   QString value;
00999   if(param->values.size() == 0) {
01000     if(param->defaultValues.size() == 0) {
01001       QString message = "Parameter [" + paramName + "] has no value.";
01002       throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
01003     }
01004     else {
01005       value = param->defaultValues[0];
01006     }
01007   }
01008   else {
01009     value = param->values[0];
01010   }
01011 
01012   return Isis::toBool(value);
01013 
01014 }
01015 
01016 
01017 // Public: Returns the value member of a parameter whose name starts with paramName
01018 // as a vector<bool>
01029 void IsisAml::GetBoolean(const QString &paramName,
01030                          vector<bool> &values) const {
01031 
01032   const IsisParameterData *param = ReturnParam(paramName);
01033 
01034   if(param->type != "boolean") {
01035     QString message = "Parameter [" + paramName + "] is not a boolean.";
01036     throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
01037   }
01038 
01039   values.clear();
01040   vector <QString> value;
01041   QString tmp;
01042   if(param->values.size() == 0) {
01043     if(param->defaultValues.size() == 0) {
01044       QString message = "Parameter [" + paramName + "] has no value.";
01045       throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
01046     }
01047     else {
01048       for(unsigned int i = 0; i < param->defaultValues.size(); i++) {
01049         tmp = param->defaultValues[i].toUpper();
01050         value.push_back(tmp);
01051       }
01052     }
01053   }
01054   else {
01055     for(unsigned int i = 0; i < param->values.size(); i++) {
01056       tmp = param->values[i].toUpper();
01057       value.push_back(tmp);
01058     }
01059   }
01060 
01061   for(unsigned int i = 0; i < value.size(); i++) {
01062     values.push_back(StringToBool(value[i]));
01063 
01064   }
01065 
01066   return;
01067 }
01073 QString IsisAml::ProgramName() const {
01074   QString tmp = name;
01075   return tmp;
01076 }
01077 
01078 
01084 QString IsisAml::Brief() const {
01085   return brief;
01086 }
01087 
01088 
01094 QString IsisAml::Description() const {
01095   return description;
01096 }
01097 
01103 int IsisAml::NumGroups() const {
01104   return groups.size();
01105 }
01106 
01114 QString IsisAml::GroupName(const int &index) const {
01115   QString s = groups[index].name;
01116   return s;
01117 }
01118 
01128 int IsisAml::GroupIndex(const QString & grpName) const {
01129   for(int i=0; i<(int)groups.size(); i++) {
01130     if(Isis::IString(grpName).DownCase() == Isis::IString(groups[i].name).DownCase()) {
01131       return i;
01132     }
01133   }
01134   return -1;
01135 }
01136 
01150 void IsisAml::CreatePVL(Isis::Pvl &pvlDef , QString guiGrpName, QString pvlObjName, QString pvlGrpName, vector<QString> & include) {
01151 
01152   Isis::PvlObject *pvlObj = NULL;
01153   if (pvlObjName != "") {
01154     pvlObj = new Isis::PvlObject(pvlObjName);
01155   }
01156 
01157   // Get Gui Group index
01158   int grpIndex= GroupIndex(guiGrpName);
01159 
01160   if (pvlGrpName == "" || grpIndex == -1 ) {
01161     QString errMsg = "Must provide Group Name\n";
01162     throw Isis::IException(Isis::IException::User, errMsg, _FILEINFO_);
01163   }
01164 
01165   Isis::PvlGroup grp(pvlGrpName);
01166   for(int i=0; i<NumParams(grpIndex); i++) {
01167     QString paramName = ParamName(grpIndex, i);
01168 
01169     if(IsParamInPvlInclude(paramName,include)) {
01170       Isis::IString paramType = Isis::IString(ParamType(grpIndex, i)).DownCase();
01171       if(paramType == "double") {
01172         grp += Isis::PvlKeyword(paramName, Isis::toString(GetDouble(paramName)));
01173       }
01174       if(paramType == "integer") {
01175         grp += Isis::PvlKeyword(paramName, Isis::toString(GetInteger(paramName)));
01176       }
01177       if(paramType == "boolean") {
01178         grp += Isis::PvlKeyword(paramName, Isis::toString(GetBoolean(paramName)));
01179       }
01180       if(paramType == "string" || paramType == "filename" || paramType == "combo") {
01181         grp += Isis::PvlKeyword(paramName, GetAsString(paramName));
01182       }
01183     }
01184   }
01185 
01186   if(pvlObj != NULL) {
01187     *pvlObj += grp;
01188     pvlDef  += *pvlObj;
01189     delete (pvlObj);
01190     pvlObj = NULL;
01191   }
01192   else {
01193     pvlDef += grp;
01194   }
01195 }
01196 
01207 bool IsisAml::IsParamInPvlInclude(QString & paramName, vector<QString> & include) {
01208 
01209   for(int i=0; i<(int)include.size(); i++) {
01210     if(Isis::IString(paramName).DownCase() == Isis::IString(include[i]).DownCase()) {
01211       return true;
01212     }
01213   }
01214   return false;
01215 }
01223 int IsisAml::NumParams(const int &group) const {
01224   return groups[group].parameters.size();
01225 }
01226 
01235 QString IsisAml::ParamName(const int &group, const int &param) const {
01236   QString s = groups[group].parameters[param].name;
01237   return s;
01238 }
01239 
01248 QString IsisAml::ParamBrief(const int &group, const int &param) const {
01249   QString s = groups[group].parameters[param].brief;
01250   return s;
01251 }
01252 
01261 QString IsisAml::ParamDescription(const int &group, const int &param) const {
01262   QString s = groups[group].parameters[param].description;
01263   return s;
01264 }
01265 
01274 QString IsisAml::ParamMinimum(const int &group, const int &param) const {
01275   QString s = groups[group].parameters[param].minimum;
01276   return s;
01277 }
01278 
01287 QString IsisAml::ParamMaximum(const int &group, const int &param) const {
01288   QString s = groups[group].parameters[param].maximum;
01289   return s;
01290 }
01291 
01300 QString IsisAml::ParamMinimumInclusive(const int &group, const int &param) const {
01301   QString s = groups[group].parameters[param].minimum_inclusive;
01302   return s;
01303 }
01304 
01313 QString IsisAml::ParamMaximumInclusive(const int &group, const int &param) const {
01314   QString s = groups[group].parameters[param].maximum_inclusive;
01315   return s;
01316 }
01317 
01327 QString IsisAml::ParamOdd(const int &group, const int &param) const {
01328   QString s = groups[group].parameters[param].odd;
01329   return s;
01330 }
01331 
01340 int IsisAml::ParamGreaterThanSize(const int &group, const int &param) const {
01341   return groups[group].parameters[param].greaterThan.size();
01342 }
01343 
01352 int IsisAml::ParamGreaterThanOrEqualSize(const int &group,
01353     const int &param) const {
01354   return groups[group].parameters[param].greaterThanOrEqual.size();
01355 }
01356 
01365 int IsisAml::ParamLessThanSize(const int &group, const int &param) const {
01366   return groups[group].parameters[param].lessThan.size();
01367 }
01368 
01377 int IsisAml::ParamLessThanOrEqualSize(const int &group,
01378                                       const int &param) const {
01379   return groups[group].parameters[param].lessThanOrEqual.size();
01380 }
01381 
01390 int IsisAml::ParamNotEqualSize(const int &group, const int &param) const {
01391   return groups[group].parameters[param].notEqual.size();
01392 }
01393 
01403 QString IsisAml::ParamGreaterThan(const int &group, const int &param,
01404                                  const int &great) const {
01405   QString s = groups[group].parameters[param].greaterThan[great];
01406   return s;
01407 }
01408 
01418 QString IsisAml::ParamGreaterThanOrEqual(const int &group, const int &param,
01419                                         const int &great) const {
01420   QString s = groups[group].parameters[param].greaterThanOrEqual[great];
01421   return s;
01422 }
01423 
01433 QString IsisAml::ParamLessThan(const int &group, const int &param,
01434                               const int &les) const {
01435   QString s = groups[group].parameters[param].lessThan[les];
01436   return s;
01437 }
01438 
01448 QString IsisAml::ParamLessThanOrEqual(const int &group, const int &param,
01449                                      const int &les) const {
01450   QString s = groups[group].parameters[param].lessThanOrEqual[les];
01451   return s;
01452 }
01453 
01463 QString IsisAml::ParamNotEqual(const int &group, const int &param,
01464                               const int &notEq) const {
01465   QString s = groups[group].parameters[param].notEqual[notEq];
01466   return s;
01467 }
01468 
01478 QString IsisAml::ParamExclude(const int &group, const int &param,
01479                              const int &exclude) const {
01480   QString s = groups[group].parameters[param].exclude[exclude];
01481   return s;
01482 }
01483 
01493 QString IsisAml::ParamInclude(const int &group, const int &param,
01494                              const int &include) const {
01495   QString s = groups[group].parameters[param].include[include];
01496   return s;
01497 }
01498 
01499 
01508 QString IsisAml::ParamType(const int &group, const int &param) const {
01509   QString s = groups[group].parameters[param].type;
01510   return s;
01511 }
01512 
01521 QString IsisAml::ParamDefault(const int &group, const int &param) const {
01522   QString s;
01523   if(groups[group].parameters[param].defaultValues.size() == 0) {
01524     s = "";
01525   }
01526   else {
01527     s = groups[group].parameters[param].defaultValues[0];
01528   }
01529   return s;
01530 }
01531 
01540 QString IsisAml::ParamInternalDefault(const int &group, const int &param) const {
01541   QString s;
01542   if(groups[group].parameters[param].internalDefault.size() == 0) {
01543     s = "";
01544   }
01545   else {
01546     s = groups[group].parameters[param].internalDefault;
01547   }
01548   return s;
01549 }
01550 
01559 QString IsisAml::ParamFilter(const int &group, const int &param) const {
01560   QString s;
01561   if(groups[group].parameters[param].filter.size() == 0) {
01562     s = "";
01563   }
01564   else {
01565     s = groups[group].parameters[param].filter;
01566   }
01567   return s;
01568 }
01569 
01578 QString IsisAml::ParamPath(const int &group, const int &param) const {
01579   QString s;
01580   if(groups[group].parameters[param].path.size() == 0) {
01581     s = "";
01582   }
01583   else {
01584     s = groups[group].parameters[param].path;
01585   }
01586   return s;
01587 }
01588 
01597 QString IsisAml::ParamFileMode(const int &group, const int &param) const {
01598   QString s;
01599   if(groups[group].parameters[param].fileMode.size() == 0) {
01600     s = "";
01601   }
01602   else {
01603     s = groups[group].parameters[param].fileMode;
01604   }
01605   return s;
01606 }
01607 
01617 int IsisAml::ParamListSize(const int &group, const int &param) const {
01618   return groups[group].parameters[param].listOptions.size();
01619 }
01620 
01621 
01631 QString IsisAml::ParamListValue(const int &group, const int &param,
01632                                const int &option) const {
01633   QString s = groups[group].parameters[param].listOptions[option].value;
01634   return s;
01635 }
01636 
01646 QString IsisAml::ParamListBrief(const int &group, const int &param,
01647                                const int &option) const {
01648   QString s = groups[group].parameters[param].listOptions[option].brief;
01649   return s;
01650 }
01651 
01661 QString IsisAml::ParamListDescription(const int &group, const int &param,
01662                                      const int &option) const {
01663   QString s = groups[group].parameters[param].listOptions[option].description;
01664   return s;
01665 }
01666 
01676 int IsisAml::ParamListExcludeSize(const int &group, const int &param,
01677                                   const int &option) const {
01678   return groups[group].parameters[param].listOptions[option].exclude.size();
01679 }
01680 
01691 QString IsisAml::ParamListExclude(const int &group, const int &param,
01692                                  const int &option, const int &exclude) const {
01693   QString s = groups[group].parameters[param].listOptions[option].exclude[exclude];
01694   return s;
01695 }
01696 
01706 int IsisAml::ParamListIncludeSize(const int &group, const int &param,
01707                                   const int &option) const {
01708   return groups[group].parameters[param].listOptions[option].include.size();
01709 }
01710 
01721 QString IsisAml::ParamListInclude(const int &group, const int &param,
01722                                  const int &option, const int &include) const {
01723   QString s = groups[group].parameters[param].listOptions[option].include[include];
01724   return s;
01725 }
01726 
01735 int IsisAml::ParamExcludeSize(const int &group, const int &param) const {
01736   return groups[group].parameters[param].exclude.size();
01737 }
01738 
01747 int IsisAml::ParamIncludeSize(const int &group, const int &param) const {
01748   return groups[group].parameters[param].include.size();
01749 }
01750 
01759 QString IsisAml::PixelType(const int &group, const int &param) const {
01760   return groups[group].parameters[param].pixelType;
01761 }
01762 
01771 int IsisAml::HelpersSize(const int &group, const int &param) const {
01772   return groups[group].parameters[param].helpers.size();
01773 }
01774 
01784 QString IsisAml::HelperButtonName(const int &group, const int &param,
01785                                  const int &helper) const {
01786   return groups[group].parameters[param].helpers[helper].name;
01787 }
01788 
01798 QString IsisAml::HelperFunction(const int &group, const int &param,
01799                                const int &helper) const {
01800   return groups[group].parameters[param].helpers[helper].function;
01801 }
01802 
01812 QString IsisAml::HelperBrief(const int &group, const int &param,
01813                             const int &helper) const {
01814   return groups[group].parameters[param].helpers[helper].brief;
01815 }
01816 
01826 QString IsisAml::HelperDescription(const int &group, const int &param,
01827                                   const int &helper) const {
01828   return groups[group].parameters[param].helpers[helper].description;
01829 }
01830 
01840 QString IsisAml::HelperIcon(const int &group, const int &param,
01841                            const int &helper) const {
01842   return groups[group].parameters[param].helpers[helper].icon;
01843 }
01844 
01852 bool IsisAml::WasEntered(const QString &paramName) const {
01853 
01854   const IsisParameterData *param = ReturnParam(paramName);
01855 
01856   if(param->values.size() == 0) {
01857     return false;
01858   }
01859 
01860   return true;
01861 }
01862 
01868 void IsisAml::Clear(const QString &paramName) {
01869 
01870   IsisParameterData *param = const_cast <IsisParameterData *>(ReturnParam(paramName));
01871   param->values.clear();
01872 
01873   param->outCubeAtt.setAttributes("+" + param->pixelType);
01874   param->inCubeAtt.setAttributes("");
01875 
01876   return;
01877 }
01878 
01879 
01890 Isis::CubeAttributeInput &IsisAml::GetInputAttribute(const QString &paramName) {
01891 
01892   IsisParameterData *param = const_cast <IsisParameterData *>(ReturnParam(paramName));
01893 
01894   if(param->type != "cube") {
01895     QString message = "Unable to get input cube attributes.  Parameter ["
01896       + paramName + "] is not a cube. Parameter type = [" + param->type + "].";
01897     throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
01898   }
01899 
01900   QString value;
01901   if(param->values.size() == 0) {
01902     if(param->defaultValues.size() == 0) {
01903       value.clear();
01904 //      QString message = "Parameter [" + paramName + "] has no value.";
01905 //      throw Isis::IException(Isis::IException::User,message, _FILEINFO_);
01906     }
01907     else {
01908       value = param->defaultValues[0];
01909     }
01910   }
01911   else {
01912     value = param->values[0];
01913   }
01914   if(param->fileMode == "input") {
01915     param->inCubeAtt.setAttributes(value);
01916   }
01917   else {
01918     QString message = "Unable to get input cube attributes.  Parameter ["
01919       + paramName + "] is not an input. Parameter fileMode = [" + param->fileMode + "].";
01920     throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
01921   }
01922   return param->inCubeAtt;
01923 }
01924 
01935 Isis::CubeAttributeOutput &IsisAml::GetOutputAttribute(const QString &paramName) {
01936 
01937   IsisParameterData *param = const_cast <IsisParameterData *>(ReturnParam(paramName));
01938 
01939   if(param->type != "cube") {
01940     QString message = "Unable to get output cube attributes.  Parameter ["
01941       + paramName + "] is not a cube. Parameter type = [" + param->type + "].";
01942     throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
01943   }
01944 
01945   QString value;
01946   if(param->values.size() == 0) {
01947     if(param->defaultValues.size() == 0) {
01948       value.clear();
01949 //      QString message = "Parameter [" + paramName + "] has no value.";
01950 //      throw Isis::IException(Isis::IException::User,message, _FILEINFO_);
01951     }
01952     else {
01953       value = param->defaultValues[0];
01954     }
01955   }
01956   else {
01957     value = param->values[0];
01958   }
01959   if(param->fileMode == "output") {
01960     param->outCubeAtt.setAttributes("+" + param->pixelType);
01961     param->outCubeAtt.addAttributes(Isis::FileName(value));
01962   }
01963   else {
01964     QString message = "Unable to get output cube attributes.  Parameter ["
01965       + paramName + "] is not an output. Parameter fileMode = [" + param->fileMode + "].";
01966     throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
01967   }
01968   return param->outCubeAtt;
01969 }
01970 
01981 const IsisParameterData *IsisAml::ReturnParam(const QString &paramName) const {
01982   Isis::IString pn = paramName;
01983   pn.UpCase();
01984   int found = 0;
01985   bool exact = false;
01986   const IsisParameterData *param = NULL;
01987   Isis::IString cur_pn;
01988 
01989   for(unsigned int g = 0; g < groups.size(); g++) {
01990     for(unsigned int p = 0; p < groups[g].parameters.size(); p++) {
01991       cur_pn = groups[g].parameters[p].name;
01992       cur_pn.UpCase();
01993       if(cur_pn.find(pn) == 0) {
01994         if(cur_pn == pn) {
01995           if(exact) {
01996             QString message = "Parameter [" + paramName + "] is not unique.";
01997             throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
01998           }
01999           else {
02000             exact = true;
02001             found = 0;
02002             param = &(groups[g].parameters[p]);
02003           }
02004         }
02005         else if(!exact) {
02006           found++;
02007           param = &(groups[g].parameters[p]);
02008         }
02009       }
02010     }
02011   }
02012   if(param == NULL) {
02013     QString message = "Unknown parameter [" + paramName + "].";
02014     throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
02015   }
02016   else if((found > 1) && (!exact)) {
02017     QString message = "Parameter [" + paramName + "] is not unique.";
02018     throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
02019   }
02020   return param;
02021 }
02022 
02033 void IsisAml::Verify(const IsisParameterData *param) {
02034 
02035   // Check to make sure the value QString can be converted to the correct type
02036   for(unsigned int i = 0; i < param->values.size(); i++) {
02037     if(param->type == "integer") {
02038       try {
02039         Isis::IString value(param->values[i]);
02040         value.ToInteger();
02041       }
02042       catch(Isis::IException &e) {
02043         QString message = "Unable to convert [" + param->values[i] + "] to an integer,"
02044                          " parameter [" + param->name + "].";
02045         throw Isis::IException(e, Isis::IException::User, message, _FILEINFO_);
02046       }
02047     }
02048     else if(param->type == "double") {
02049       try {
02050         Isis::IString value(param->values[i]);
02051         value.ToDouble();
02052       }
02053       catch(Isis::IException &e) {
02054         QString message = "Unable to convert [" + param->values[i] + "] to a double,"
02055                          " parameter [" + param->name + "].";
02056         throw Isis::IException(e, Isis::IException::User, message, _FILEINFO_);
02057       }
02058     }
02059     else if(param->type == "boolean") {
02060       QString v = param->values[i].toUpper();
02061 
02062       try {
02063         StringToBool(v);
02064       }
02065       catch(Isis::IException &e) {
02066         QString message = "Illegal value for [" + param->name + "], [" + param->values[i] + "].";
02067         throw Isis::IException(e, Isis::IException::User, message, _FILEINFO_);
02068       }
02069     }
02070     else if(param->type == "filename") {
02071       // If this is an output file and a file with this name already exists,
02072       // check user filename customization preferences.
02073       QString value(param->values[i]);
02074       Isis::FileName name(value);
02075       value = name.expanded();
02076       if(name.fileExists() && param->fileMode == "output") {
02077         CheckFileNamePreference(value, param->name);
02078       }
02079     }
02080     // THIS IS CURRENTLY HANDLED IN THE CUBE CLASS, see CubeIoHandler.cpp
02081     // 2010-07-15 Jeannie Walldren
02082     //
02083     //  else if(param->type == "cube") {
02084     //    Isis::IString value(param->values[i]);
02085     //    Isis::FileName name(value);
02086     //    value = name.expanded();
02087     //    if (name.Exists() && param->fileMode == "output"
02088     //        && Isis::Preference::Preferences().FindGroup("CubeCustomization").FindKeyword("Overwrite")[0] == "Error") {
02089     //      QString message = "Invalid output cube for [" + param->name + "]. The cube file [" + value + "] already exists.  " +
02090     //                       "The user preference cube customization group is set to disallow cube overwrites.";
02091     //      throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
02092     //    }
02093     //  }
02094   }
02095 
02096   // Check the default values if there were no values
02097   if(param->values.size() == 0) {
02098     for(unsigned int i = 0; i < param->defaultValues.size(); i++) {
02099       // Check to make sure the DefaultValue QString can be converted to the
02100       // correct type
02101       if(param->type == "integer") {
02102         try {
02103           Isis::IString value(param->defaultValues[i]);
02104           value.ToInteger();
02105         }
02106         catch(Isis::IException &e) {
02107           QString message = "Unable to convert default [" + param->defaultValues[i] +
02108                            "] to an integer, parameter [" + param->name + "].";
02109           throw Isis::IException(e, Isis::IException::Programmer, message, _FILEINFO_);
02110         }
02111       }
02112       else if(param->type == "double") {
02113         try {
02114           Isis::IString value(param->defaultValues[i]);
02115           value.ToDouble();
02116         }
02117         catch(Isis::IException &e) {
02118           QString message = "Unable to convert default [" + param->defaultValues[i] +
02119                            "] to a double, parameter [" + param->name + "].";
02120           throw Isis::IException(e, Isis::IException::Programmer, message, _FILEINFO_);
02121         }
02122       }
02123       else if(param->type == "boolean") {
02124         QString v = param->defaultValues[i].toUpper();
02125 
02126         try {
02127           StringToBool(v);
02128         }
02129         catch(Isis::IException &e) {
02130           QString message = "Illegal default value for [" + param->name + "], ["
02131                            + param->defaultValues[i] + "].";
02132           throw Isis::IException(e, Isis::IException::User, message, _FILEINFO_);
02133         }
02134       }
02135       else if(param->type == "filename") {
02136         // Put something here once we figure out what to do with filenames
02137         QString value(param->defaultValues[i]);
02138         Isis::FileName name(value);
02139         value = name.expanded();
02140         if(name.fileExists() && param->fileMode == "output") {
02141           CheckFileNamePreference(value, param->name);
02142         }
02143       }
02144     }
02145   }
02146 
02147   // Check the values against the values list if there is one
02148   if(param->listOptions.size() > 0) {
02149     for(unsigned int i = 0; i < param->values.size(); i++) {
02150       Isis::IString value = param->values[i];
02151       value = value.UpCase();
02152       int partial = 0;
02153       bool exact = false;
02154       for(unsigned int p = 0; p < param->listOptions.size(); p++) {
02155         Isis::IString option = param->listOptions[p].value;
02156         option = option.UpCase();
02157         // Check to see if the value matches the list option exactly
02158         if(value == option) {
02159           // If we already have one exact match then there is an error
02160           if(exact) {
02161             QString message = "Duplicate list options [" +
02162                              param->listOptions[p].value +
02163                              "] in parameter [" + param->name + "].";
02164             throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
02165           }
02166           exact = true;
02167         }
02168         // Check for a partial match
02169         // Compare the shorter of the two (values[i]) to a subQString of the
02170         // longer QString (listOptions[p].value)
02171         else if(option.compare(0, min(value.size(), option.size()),
02172                                value, 0, min(value.size(), option.size())) == 0) {
02173           partial++;
02174         }
02175       }
02176       if(!exact && partial == 0) {
02177         QString message = "Value of [" + param->name + "] must be one of [" +
02178                          param->listOptions[0].value;
02179         for(unsigned int p = 1; p < param->listOptions.size(); p++) {
02180           message += ", " + param->listOptions[p].value;
02181         }
02182         message += "].";
02183         throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
02184       }
02185       else if(!exact && partial > 1) {
02186         QString msg = "Value of [" + param->name +
02187                      "] does not match a list option uniquely.";
02188         throw Isis::IException(Isis::IException::Programmer, msg, _FILEINFO_);
02189       }
02190     }
02191   }
02192 
02193   // Check the values against the minimum
02194   if(param->minimum.length() > 0) {
02195     QString incl = param->minimum_inclusive;
02196     for(unsigned int i = 0; i < param->values.size(); i++) {
02197       if(param->type == "integer") {
02198         QString value(param->values[i]);
02199         int temp = Isis::toInt(value);
02200         value = param->minimum;
02201         int min = Isis::toInt(value);
02202         if(StringToBool(incl) && (temp < min)) {
02203           QString message = "Parameter [" + param->name +
02204                            "] must be greater than or equal to [" + param->minimum + "].";
02205           throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
02206         }
02207         else if(!StringToBool(incl) && (temp <= min)) {
02208           QString message = "Parameter [" + param->name +
02209                            "] must be greater than [" + param->minimum + "].";
02210           throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
02211         }
02212       }
02213       else if(param->type == "double") {
02214         Isis::IString value(param->values[i]);
02215         double temp = value.ToDouble();
02216         value = param->minimum;
02217         double min = value.ToDouble();
02218         if(StringToBool(incl) && (temp < min)) {
02219           QString message = "Parameter [" + param->name +
02220                            "] must be greater than or equal to [" + param->minimum + "].";
02221           throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
02222         }
02223         else if(!StringToBool(incl) && (temp <= min)) {
02224           QString message = "Parameter [" + param->name +
02225                            "] must be greater than [" + param->minimum + "].";
02226           throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
02227         }
02228       }
02229     }
02230     if(param->values.size() == 0) {
02231       for(unsigned int i = 0; i < param->defaultValues.size(); i++) {
02232         if(param->type == "integer") {
02233           Isis::IString value(param->defaultValues[i]);
02234           int temp = value.ToInteger();
02235           value = param->minimum;
02236           int min = value.ToInteger();
02237           if(StringToBool(incl) && (temp < min)) {
02238             QString message = "Parameter [" + param->name +
02239                              "] must be greater than or equal to [" + param->minimum + "].";
02240             throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
02241           }
02242           else if(!StringToBool(incl) && (temp <= min)) {
02243             QString message = "Parameter [" + param->name +
02244                              "] must be greater than [" + param->minimum + "].";
02245             throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
02246           }
02247         }
02248         else if(param->type == "double") {
02249           Isis::IString value(param->defaultValues[i]);
02250           double temp = value.ToDouble();
02251           value = param->minimum;
02252           double min = value.ToDouble();
02253           if(StringToBool(incl) && (temp < min)) {
02254             QString message = "Parameter [" + param->name +
02255                              "] must be greater than or equal to [" + param->minimum + "].";
02256             throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
02257           }
02258           else if(!StringToBool(incl) && (temp <= min)) {
02259             QString message = "Parameter [" + param->name +
02260                              "] must be greater than [" + param->minimum + "].";
02261             throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
02262           }
02263         }
02264       }
02265     }
02266   }
02267 
02268   // Check the values against the maximum
02269   if(param->maximum.length() > 0) {
02270     QString incl = param->maximum_inclusive.toLower();
02271     for(unsigned int i = 0; i < param->values.size(); i++) {
02272       if(param->type == "integer") {
02273         QString value(param->values[i]);
02274         int temp = Isis::toInt(value);
02275         value = param->maximum;
02276         int max = Isis::toInt(value);
02277         if(StringToBool(incl) && (temp > max)) {
02278           QString message = "Parameter [" + param->name +
02279                            "] must be less than or equal to [" + param->maximum + "].";
02280           throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
02281         }
02282         else if(!StringToBool(incl) && (temp >= max)) {
02283           QString message = "Parameter [" + param->name +
02284                            "] must be less than [" + param->maximum + "].";
02285           throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
02286         }
02287       }
02288       else if(param->type == "double") {
02289         Isis::IString value(param->values[i]);
02290         double temp = value.ToDouble();
02291         value = param->maximum;
02292         double max = value.ToDouble();
02293         if(StringToBool(incl) && (temp > max)) {
02294           QString message = "Parameter [" + param->name +
02295                            "] must be less than or equal to [" + param->maximum + "].";
02296           throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
02297         }
02298         else if(!StringToBool(incl) && (temp >= max)) {
02299           QString message = "Parameter [" + param->name +
02300                            "] must be less than [" + param->maximum + "].";
02301           throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
02302         }
02303       }
02304     }
02305     if(param->values.size() == 0) {
02306       for(unsigned int i = 0; i < param->defaultValues.size(); i++) {
02307         if(param->type == "integer") {
02308           Isis::IString value(param->defaultValues[i]);
02309           int temp = value.ToInteger();
02310           value = param->maximum;
02311           int max = value.ToInteger();
02312           if(StringToBool(incl) && (temp > max)) {
02313             QString message = "Parameter [" + param->name +
02314                              "] must be less than or equal to [" + param->maximum + "].";
02315             throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
02316           }
02317           else if(!StringToBool(incl) && (temp >= max)) {
02318             QString message = "Parameter [" + param->name +
02319                              "] must be less than [" + param->maximum + "].";
02320             throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
02321           }
02322         }
02323         else if(param->type == "double") {
02324           Isis::IString value(param->defaultValues[i]);
02325           double temp = value.ToDouble();
02326           value = param->maximum;
02327           double max = value.ToDouble();
02328           if(StringToBool(incl) && (temp > max)) {
02329             QString message = "Parameter [" + param->name +
02330                              "] must be less than or equal to [" + param->maximum + "].";
02331             throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
02332           }
02333           else if(!StringToBool(incl) && (temp >= max)) {
02334             QString message = "Parameter [" + param->name +
02335                              "] must be less than [" + param->maximum + "].";
02336             throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
02337           }
02338         }
02339       }
02340     }
02341   }
02342 
02343   // Check the value for an odd test
02344   QString odd = param->odd.toLower();
02345 
02346   if((odd != "") || StringToBool(odd)) {
02347     if(param->type != "integer") {
02348       QString message = "Parameter [" + param->name +
02349                        "] must be of type integer to have an [odd] test.";
02350       throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
02351     }
02352     else {
02353       for(unsigned int i = 0; i < param->values.size(); i++) {
02354         Isis::IString value(param->values[i]);
02355         if((value.ToInteger() % 2) != 1) {
02356           QString message = "Value for [" + param->name + "] must be odd.";
02357           throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
02358         }
02359       }
02360     }
02361   }
02362   return;
02363 }
02364 
02365 
02383 void IsisAml::CheckFileNamePreference(QString filename, QString paramname) {
02384   Isis::PvlGroup fileCustomization = Isis::Preference::Preferences().FindGroup("FileCustomization");
02385   QString overwritePreference = fileCustomization.FindKeyword("Overwrite")[0].simplified().trimmed();
02386   QString temp = overwritePreference;
02387   if(overwritePreference.toUpper() == "ERROR") {
02388     QString message = "Invalid output filename for [" + paramname + "]. The file [" + filename + "] already exists.  " +
02389                      "The user preference file customization group is set to disallow file overwrites.";
02390     throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
02391   }
02392   else if(overwritePreference.toUpper() != "ALLOW") { // not set to ERROR or ALLOW
02393     QString message = "Invalid entry in user preference file FileCustomization group.";
02394     message += "  Overwrite = [" + temp + "].  Valid values: [Allow] or [Error].";
02395     throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
02396   }
02397 }
02398 
02399 
02403 void IsisAml::VerifyAll() {
02404   for(unsigned int g = 0; g < groups.size(); g++) {
02405     for(unsigned int p = 0; p < groups[g].parameters.size(); p++) {
02406       IsisParameterData *param = &(this->groups[g].parameters[p]);
02407 
02408       Verify(param);
02409 
02410       // Check the values for inclusive clauses
02411       for(unsigned int item = 0; item < param->include.size(); item++) {
02412         // If this parameter is a boolean and it is true/yes
02413         // all included parameters must have some type of value
02414         if(param->type == "boolean") {
02415           if(((param->values.size() > 0) && StringToBool(param->values[0])) ||
02416               ((param->values.size() == 0) && (param->defaultValues.size() > 0)
02417                && StringToBool(param->defaultValues[0]))) {
02418 
02419             const IsisParameterData *param2 = ReturnParam(param->include[item]);
02420             if((param2->values.size()) == 0 &&
02421                 (param2->defaultValues.size() == 0) &&
02422                 (param2->internalDefault.size() == 0)) {
02423               QString message = "Parameter [" + param2->name +
02424                                "] must be used if parameter [" +
02425                                param->name + "] equates to true.";
02426               throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
02427             }
02428           }
02429         }
02430         // This parameter is NOT a boolean but the other one might be
02431         else {
02432           // If the other parameter is a boolean and it is true/yes
02433           // then this parameter must have some type of value
02434           const IsisParameterData *param2 = ReturnParam(param->include[item]);
02435           if(param2->type == "boolean") {
02436             if(((param2->values.size() > 0) && StringToBool(param2->values[0])) ||
02437                 ((param2->values.size() == 0) && (param2->defaultValues.size() > 0) &&
02438                  StringToBool(param2->defaultValues[0]))) {
02439               if((param->values.size()) == 0 &&
02440                   (param->defaultValues.size() == 0) &&
02441                   (param->internalDefault.size() == 0)) {
02442                 QString message = "Parameter [" + param2->name +
02443                                  "] must be used if parameter [" +
02444                                  param->name + "] is used.";
02445                 throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
02446               }
02447             }
02448           }
02449           // Neithter parameter is a boolean so
02450           // If this one has a value the other parameter must have some type of value
02451           else {
02452             if(param->values.size() > 0 &&
02453                 param2->values.size() == 0 &&
02454                 param2->defaultValues.size() == 0 &&
02455                 param2->internalDefault.size() == 0) {
02456               QString message = "Parameter [" + param2->name +
02457                                "] must be used if parameter [" +
02458                                param->name + "] is used.";
02459               throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
02460             }
02461           }
02462         }
02463       }
02464       // Check the values for exclusive clauses
02465       for(unsigned int item = 0; item < param->exclude.size(); item++) {
02466         // If this parameter is a boolean that is true/yes
02467         // the other parameter should not have a value
02468         if(param->type == "boolean") {
02469           if(((param->values.size() > 0) && StringToBool(param->values[0])) ||
02470               ((param->values.size() == 0) && (param->defaultValues.size() > 0) &&
02471                StringToBool(param->defaultValues[0]))) {
02472 
02473             const IsisParameterData *param2 = ReturnParam(param->exclude[item]);
02474             if(param2->values.size() > 0) {
02475               QString message = "Parameter [" + param2->name +
02476                                "] must NOT be used if parameter [" +
02477                                param->name + "] equates to true.";
02478               throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
02479             }
02480           }
02481         }
02482         // This parameter is NOT a boolean but the other one might be
02483         else {
02484           const IsisParameterData *param2 = ReturnParam(param->exclude[item]);
02485           if(param2->type == "boolean") {
02486             if(((param2->values.size() > 0) && StringToBool(param2->values[0])) ||
02487                 ((param2->values.size() == 0) && (param2->defaultValues.size() > 0) &&
02488                  StringToBool(param2->defaultValues[0]))) {
02489               if(param->values.size() > 0) {
02490                 QString message = "Parameter [" + param2->name +
02491                                  "] must be used if parameter [" +
02492                                  param->name + "] is used.";
02493                 throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
02494               }
02495             }
02496           }
02497           // Neither parameter is a boolean
02498           else {
02499             if(param->values.size() > 0 && param2->values.size() > 0) {
02500               QString message = "Parameter [" + param2->name +
02501                                "] must NOT be used if parameter [" +
02502                                param->name + "] is used.";
02503               throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
02504             }
02505           }
02506         }
02507       }
02508 
02509       // Check the values for greaterThan clauses
02510       if(param->values.size() > 0) {
02511         for(unsigned int item = 0; item < param->greaterThan.size(); item++) {
02512           const IsisParameterData *param2 = ReturnParam(param->greaterThan[item]);
02513           if(param2->values.size() != 0) {
02514             double double1, double2;
02515             if(param->type == "integer") {
02516               double1 = (double) GetInteger(param->name);
02517             }
02518             else if(param->type == "double") {
02519               double1 = GetDouble(param->name);
02520             }
02521             else {
02522               QString msg = "Parameter is not INTEGER or DOUBLE type [" +
02523                            param->name + "]";
02524               throw Isis::IException(Isis::IException::Programmer, msg, _FILEINFO_);
02525             }
02526 
02527             if(param2->type == "integer") {
02528               double2 = GetInteger(param2->name);
02529             }
02530             else if(param2->type == "double") {
02531               double2 = GetDouble(param2->name);
02532             }
02533             else {
02534               QString msg = "Parameter is not INTEGER or DOUBLE type [" +
02535                            param->name + "]";
02536               throw Isis::IException(Isis::IException::Programmer, msg, _FILEINFO_);
02537             }
02538 
02539             if(double2 >= double1) {
02540               QString message = "Parameter [" + param->name +
02541                                "] must be greater than parameter [" +
02542                                param2->name + "].";
02543               throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
02544             }
02545           }
02546         }
02547       }
02548 
02549       // Check the values for greaterThanOrEqual clauses
02550       if(param->values.size() > 0) {
02551         for(unsigned int item = 0; item < param->greaterThanOrEqual.size(); item++) {
02552           const IsisParameterData *param2 =
02553             ReturnParam(param->greaterThanOrEqual[item]);
02554           if(param2->values.size() != 0) {
02555             double double1, double2;
02556             if(param->type == "integer") {
02557               double1 = (double) GetInteger(param->name);
02558             }
02559             else if(param->type == "double") {
02560               double1 = GetDouble(param->name);
02561             }
02562             else {
02563               QString msg = "Parameter is not INTEGER or DOUBLE type [" +
02564                            param->name + "]";
02565               throw Isis::IException(Isis::IException::Programmer, msg, _FILEINFO_);
02566             }
02567 
02568             if(param2->type == "integer") {
02569               double2 = GetInteger(param2->name);
02570             }
02571             else if(param2->type == "double") {
02572               double2 = GetDouble(param2->name);
02573             }
02574             else {
02575               QString msg = "Parameter is not INTEGER or DOUBLE type [" +
02576                            param->name + "]";
02577               throw Isis::IException(Isis::IException::Programmer, msg, _FILEINFO_);
02578             }
02579 
02580             if(double2 > double1) {
02581               QString message = "Parameter [" + param->name +
02582                                "] must be greater than or equal to parameter [" +
02583                                param2->name + "].";
02584               throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
02585             }
02586           }
02587         }
02588       }
02589       // Check the values for lessThan clauses
02590       if(param->values.size() > 0) {
02591         for(unsigned int item = 0; item < param->lessThan.size(); item++) {
02592           const IsisParameterData *param2 = ReturnParam(param->lessThan[item]);
02593           if(param2->values.size() != 0) {
02594             double double1, double2;
02595             if(param->type == "integer") {
02596               double1 = (double) GetInteger(param->name);
02597             }
02598             else if(param->type == "double") {
02599               double1 = GetDouble(param->name);
02600             }
02601             else {
02602               QString msg = "Parameter is not INTEGER or DOUBLE type [" +
02603                            param->name + "]";
02604               throw Isis::IException(Isis::IException::Programmer, msg, _FILEINFO_);
02605             }
02606 
02607             if(param2->type == "integer") {
02608               double2 = GetInteger(param2->name);
02609             }
02610             else if(param2->type == "double") {
02611               double2 = GetDouble(param2->name);
02612             }
02613             else {
02614               QString msg = "Parameter is not INTEGER or DOUBLE type [" +
02615                            param->name + "]";
02616               throw Isis::IException(Isis::IException::Programmer, msg, _FILEINFO_);
02617             }
02618 
02619             if(double2 <= double1) {
02620               QString message = "Parameter [" + param->name +
02621                                "] must be less than parameter [" +
02622                                param2->name + "].";
02623               throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
02624             }
02625           }
02626         }
02627       }
02628 
02629       // Check the values for lessThanOrEqual clauses
02630       if(param->values.size() > 0) {
02631         for(unsigned int item = 0; item < param->lessThanOrEqual.size(); item++) {
02632           const IsisParameterData *param2 =
02633             ReturnParam(param->lessThanOrEqual[item]);
02634           if(param2->values.size() != 0) {
02635             double double1, double2;
02636             if(param->type == "integer") {
02637               double1 = (double) GetInteger(param->name);
02638             }
02639             else if(param->type == "double") {
02640               double1 = GetDouble(param->name);
02641             }
02642             else {
02643               QString msg = "Parameter is not INTEGER or DOUBLE type [" +
02644                            param->name + "]";
02645               throw Isis::IException(Isis::IException::Programmer, msg, _FILEINFO_);
02646             }
02647 
02648             if(param2->type == "integer") {
02649               double2 = GetInteger(param2->name);
02650             }
02651             else if(param2->type == "double") {
02652               double2 = GetDouble(param2->name);
02653             }
02654             else {
02655               QString msg = "Parameter is not INTEGER or DOUBLE type [" +
02656                            param->name + "]";
02657               throw Isis::IException(Isis::IException::Programmer, msg, _FILEINFO_);
02658             }
02659 
02660             if(double2 < double1) {
02661               QString message = "Parameter [" + param->name +
02662                                "] must be less than or equal to parameter [" +
02663                                param2->name + "].";
02664               throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
02665             }
02666           }
02667         }
02668       }
02669 
02670       // Check the values for notEqual clauses
02671       if(param->values.size() > 0) {
02672         for(unsigned int item = 0; item < param->notEqual.size(); item++) {
02673           const IsisParameterData *param2 = ReturnParam(param->notEqual[item]);
02674           if(param2->values.size() != 0) {
02675             double double1, double2;
02676             if(param->type == "integer") {
02677               double1 = (double) GetInteger(param->name);
02678             }
02679             else if(param->type == "double") {
02680               double1 = GetDouble(param->name);
02681             }
02682             else {
02683               QString msg = "Parameter is not INTEGER or DOUBLE type [" +
02684                            param->name + "]";
02685               throw Isis::IException(Isis::IException::Programmer, msg, _FILEINFO_);
02686             }
02687 
02688             if(param2->type == "integer") {
02689               double2 = GetInteger(param2->name);
02690             }
02691             else if(param2->type == "double") {
02692               double2 = GetDouble(param2->name);
02693             }
02694             else {
02695               QString msg = "Parameter is not INTEGER or DOUBLE type [" +
02696                            param->name + "]";
02697               throw Isis::IException(Isis::IException::Programmer, msg, _FILEINFO_);
02698             }
02699 
02700             if(double2 == double1) {
02701               QString message = "Parameter [" + param->name +
02702                                "] must NOT be equal to parameter [" +
02703                                param2->name + "].";
02704               throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
02705             }
02706           }
02707         }
02708       }
02709 
02710       // If this parameter has a value, and a list/option/exclude, make sure
02711       // the excluded parameter has NO value
02712       if(((param->values.size() > 0) || (param->defaultValues.size())) > 0) {
02713         for(unsigned int o2 = 0; o2 < param->listOptions.size(); o2++) {
02714           QString value, option;
02715           if(param->type == "string"  || param->type == "combo") {
02716             value = GetString(param->name);
02717             value = value.toUpper();
02718             option = param->listOptions[o2].value;
02719             option = option.toUpper();
02720           }
02721           else if(param->type == "integer") {
02722             value = GetAsString(param->name);
02723             value = value.trimmed();
02724             option = param->listOptions[o2].value;
02725             option = option.trimmed();
02726           }
02727           if(value == option) {
02728             for(unsigned int e2 = 0; e2 < param->listOptions[o2].exclude.size(); e2++) {
02729               const IsisParameterData *param2 =
02730                 ReturnParam(param->listOptions[o2].exclude[e2]);
02731               if(param2->values.size() > 0) {
02732                 QString message = "Parameter [" + param2->name +
02733                                  "] can not be entered if parameter [" +
02734                                  param->name + "] is equal to [" +
02735                                  value + "]";
02736                 throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
02737               }
02738             }
02739           }
02740         }
02741       }
02742 
02743       // If this parameter has a value, and a list/option/include, make sure
02744       // the included parameter has a value
02745       if(((param->values.size() > 0) || (param->defaultValues.size())) > 0) {
02746         for(unsigned int o2 = 0; o2 < param->listOptions.size(); o2++) {
02747           QString value, option;
02748           if(param->type == "string"  || param->type == "combo") {
02749             value = GetString(param->name);
02750             value = value.toUpper();
02751             option = param->listOptions[o2].value;
02752             option = option.toUpper();
02753           }
02754           else if(param->type == "integer") {
02755             value = GetAsString(param->name);
02756             value = value.trimmed();
02757             option = param->listOptions[o2].value;
02758             option = option.trimmed();
02759           }
02760           if(value == option) {
02761             for(unsigned int e2 = 0; e2 < param->listOptions[o2].include.size(); e2++) {
02762               const IsisParameterData *param2 =
02763                 ReturnParam(param->listOptions[o2].include[e2]);
02764               if((param2->values.size() == 0) &&
02765                   (param2->defaultValues.size() == 0)) {
02766                 QString message = "Parameter [" + param2->name +
02767                                  "] must be entered if parameter [" +
02768                                  param->name + "] is equal to [" +
02769                                  value + "]";
02770                 throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
02771               }
02772             }
02773           }
02774         }
02775       }
02776 
02777       // If this parameter has no value, default value or internal default
02778       // value then it must be excluded by some other parameter with an
02779       // exclude or list/option/exclude
02780       //   OR
02781       // it must include a boolean which is false
02782       if((param->values.size() == 0) && (param->defaultValues.size() == 0) &&
02783           (param->internalDefault.size() == 0)) {
02784         bool excluded = false;
02785         // See if another parameter has a list option excluding this parameter
02786         for(unsigned int g2 = 0; g2 < groups.size(); g2++) {
02787           for(unsigned int p2 = 0; p2 < groups[g2].parameters.size(); p2++) {
02788             for(unsigned int o2 = 0;
02789                 o2 < groups[g2].parameters[p2].listOptions.size(); o2++) {
02790               for(unsigned int e2 = 0;
02791                   e2 < groups[g2].parameters[p2].listOptions[o2].exclude.size();
02792                   e2++) {
02793                 QString excl =
02794                   this->groups[g2].parameters[p2].listOptions[o2].exclude[e2];
02795                 if(excl == param->name) {
02796                   excluded = true;
02797                   break;
02798                 }
02799               }
02800             }
02801 
02802             if(groups[g2].parameters[p2].type == "boolean") {
02803               const IsisParameterData *param2 = &groups[g2].parameters[p2];
02804               if(((param2->values.size() > 0) && !StringToBool(param2->values[0])) ||
02805                   ((param2->values.size() == 0) && (param2->defaultValues.size() > 0) &&
02806                    !StringToBool(param2->defaultValues[0]))) {
02807                 for(unsigned int e2 = 0; e2 < groups[g2].parameters[p2].include.size();
02808                     e2++) {
02809                   QString incl =
02810                     this->groups[g2].parameters[p2].include[e2];
02811                   if(incl == param->name) {
02812                     excluded = true;
02813                   }
02814                 }
02815               }
02816               else if(((param2->values.size() > 0) && StringToBool(param2->values[0])) ||
02817                       ((param2->values.size() == 0) && (param2->defaultValues.size() > 0) &&
02818                        StringToBool(param2->defaultValues[0]))) {
02819                 for(unsigned int e2 = 0; e2 < groups[g2].parameters[p2].exclude.size();
02820                     e2++) {
02821                   QString excl =
02822                     this->groups[g2].parameters[p2].exclude[e2];
02823                   if(excl == param->name) {
02824                     excluded = true;
02825                   }
02826                 }
02827               }
02828             }
02829           }
02830         }
02831 
02832         // See if this parameter excludes any other (this implies the other
02833         // one also excludes this one too
02834         for(unsigned int item = 0; item < param->exclude.size(); item++) {
02835           const IsisParameterData *param2 = ReturnParam(param->exclude[item]);
02836           if((param2->values.size() != 0) ||
02837               (param2->defaultValues.size() != 0) ||
02838               (param2->internalDefault.size() != 0)) {
02839             if(param2->type != "boolean") {
02840               excluded = true;
02841             }
02842             else {
02843               if(((param2->values.size() > 0) && !StringToBool(param2->values[0])) ||
02844                   ((param2->values.size() == 0) && (param2->defaultValues.size() > 0) &&
02845                    !StringToBool(param2->defaultValues[0]))) {
02846                 excluded = true;
02847               }
02848             }
02849           }
02850         }
02851 
02852         // See if this parameter includes a boolean that is false
02853         // then it doesn't need a value
02854         for(unsigned int item = 0; item < param->include.size(); item++) {
02855           const IsisParameterData *param2 = ReturnParam(param->include[item]);
02856           if(param2->type == "boolean") {
02857             if(((param2->values.size() > 0) && !StringToBool(param2->values[0])) ||
02858                 ((param2->values.size() == 0) && (param2->defaultValues.size() > 0) &&
02859                  !StringToBool(param2->defaultValues[0]))) {
02860               excluded = true;
02861             }
02862           }
02863         }
02864 
02865         if(!excluded) {
02866           QString message = "Parameter [" + param->name + "] must be entered.";
02867           throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
02868         }
02869       }
02870     }
02871   }
02872 }
02873 
02883 bool IsisAml::StringToBool(QString value) const {
02884 
02885   value = value.toUpper();
02886   if(value == "") {
02887     return false;
02888   }
02889   else if(!value.compare("NO")) {
02890     return false;
02891   }
02892   else if(!value.compare("FALSE")) {
02893     return false;
02894   }
02895   else if(!value.compare("F")) {
02896     return false;
02897   }
02898   else if(!value.compare("N")) {
02899     return false;
02900   }
02901   else if(!value.compare("YES")) {
02902     return true;
02903   }
02904   else if(!value.compare("TRUE")) {
02905     return true;
02906   }
02907   else if(!value.compare("Y")) {
02908     return true;
02909   }
02910   else if(!value.compare("T")) {
02911     return true;
02912   }
02913   else {
02914     QString message = "Invalid boolean value [" + value + "].";
02915     throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
02916   }
02917   return false;
02918 }
02919 
02920 
02926 void IsisAml::CommandLine(Isis::Pvl &cont) const {
02927   Isis::PvlGroup group("UserParameters");
02928 
02929   // Add appropriate keywords
02930   for(unsigned int g = 0; g < groups.size(); g++) {
02931     for(unsigned int p = 0; p < groups[g].parameters.size(); p++) {
02932       const IsisParameterData *param = ReturnParam(ParamName(g, p));
02933       // If this param has a value add it to the command line
02934       if(param->values.size() > 0) {
02935         Isis::PvlKeyword paramKeyword(param->name);
02936 
02937         for(unsigned int value = 0; value < param->values.size(); value++) {
02938           paramKeyword.AddValue(param->values[value]);
02939         }
02940 
02941         group += paramKeyword;
02942       }
02943 
02944       // Or if it has a default value add it to the command line
02945       else if(param->defaultValues.size() > 0) {
02946         Isis::PvlKeyword paramKeyword(param->name);
02947 
02948         for(unsigned int value = 0;
02949            value < param->defaultValues.size();
02950            value++) {
02951           paramKeyword.AddValue(param->defaultValues[value]);
02952         }
02953 
02954         group += paramKeyword;
02955       }
02956     }
02957   }
02958   // Remove excluded keywords
02959   for(unsigned int g = 0; g < groups.size(); g++) {
02960     for(unsigned int p = 0; p < groups[g].parameters.size(); p++) {
02961       const IsisParameterData *param = ReturnParam(ParamName(g, p));
02962 
02963       if(((param->values.size() > 0) || (param->defaultValues.size())) > 0) {
02964         for(unsigned int o2 = 0; o2 < param->listOptions.size(); o2++) {
02965           Isis::IString value, option;
02966           if(param->type == "string"  || param->type == "combo") {
02967             value = GetAsString(param->name);
02968             value = value.UpCase();
02969             option = param->listOptions[o2].value;
02970             option = option.UpCase();
02971           }
02972           else if(param->type == "integer") {
02973             value = GetAsString(param->name);
02974             value = value.Trim("\n\r\t\f\v\b");
02975             option = param->listOptions[o2].value;
02976             option = option.Trim("\n\r\t\f\v\b");
02977           }
02978           if(value == option) {
02979             for(unsigned int e2 = 0; e2 < param->listOptions[o2].exclude.size(); e2++) {
02980               const IsisParameterData *param2 =
02981                 ReturnParam(param->listOptions[o2].exclude[e2]);
02982               if(group.HasKeyword(param2->name)) {
02983                 group.DeleteKeyword(param2->name);
02984               }
02985             }
02986           }
02987         }
02988       }
02989     }
02990   }
02991 
02992   cont.Clear();
02993   cont.AddGroup(group);
02994   return;
02995 }
02996 
02997 
03003 QString IsisAml::Version() const {
03004   QString st = "000-00-00";
03005   for(unsigned int i = 0; i < changes.size(); i++) {
03006     if(changes[i].date > st) st = changes[i].date;
03007   }
03008   return st;
03009 }
03010 
03011 
03019 void IsisAml::StartParser(const char *xmlfile) {
03020 
03021   // Initialize the XML system
03022   try {
03023     XERCES::XMLPlatformUtils::Initialize();
03024   }
03025 
03026   catch(const XERCES::XMLException &toCatch) {
03027     QString message = "Error during XML parser initialization" +
03028                      (QString)XERCES::XMLString::transcode(toCatch.getMessage());
03029     throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
03030     return;
03031   }
03032 
03033   //
03034   //  Create a SAX parser object. Then, set it to validate for an IsisAml file
03035   //
03036   parser = XERCES::XMLReaderFactory::createXMLReader();
03037 
03038 //  SAX2XMLReader::ValSchemes valScheme = SAX2XMLReader::Val_Auto;
03039   XERCES::SAX2XMLReader::ValSchemes valScheme = XERCES::SAX2XMLReader::Val_Never;
03040   if(valScheme == XERCES::SAX2XMLReader::Val_Auto) {
03041     parser->setFeature(XERCES::XMLString::transcode("http://xml.org/sax/features/validation"), true);
03042     parser->setFeature(XERCES::XMLString::transcode("http://apache.org/xml/features/validation/dynamic"), true);
03043   }
03044   else if(valScheme == XERCES::SAX2XMLReader::Val_Never) {
03045     parser->setFeature(XERCES::XMLString::transcode("http://xml.org/sax/features/validation"), false);
03046   }
03047 
03048   else if(valScheme == XERCES::SAX2XMLReader::Val_Always) {
03049     parser->setFeature(XERCES::XMLString::transcode("http://xml.org/sax/features/validation"), true);
03050     parser->setFeature(XERCES::XMLString::transcode("http://apache.org/xml/features/validation/dynamic"), false);
03051   }
03052 
03053 //  bool doSchema = true;
03054   bool doSchema = false;
03055   parser->setFeature(XERCES::XMLString::transcode("http://apache.org/xml/features/validation/schema"), doSchema);
03056 
03057   bool schemaFullChecking = false;
03058   parser->setFeature(XERCES::XMLString::transcode("http://apache.org/xml/features/validation/schema-full-checking"), schemaFullChecking);
03059 
03060   //  Create the handler object for an application
03061   //  Then parse the file
03062   char *encodingName = const_cast<char *>("LATIN1");
03063   bool expandNamespaces = false ;
03064 
03065   try {
03066     IsisAmlData *mydata = this;
03067     appHandler = new IsisXMLApplication(encodingName, expandNamespaces, parser, mydata);
03068     parser->parse(xmlfile);
03069   }
03070   catch(const XERCES::XMLException &toCatch) {
03071     QString message = "Error in application XML file: " +
03072                      (QString)XERCES::XMLString::transcode(toCatch.getMessage());
03073     throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
03074     XERCES::XMLPlatformUtils::Terminate();
03075     return;
03076   }
03077 
03078   //  Delete the parser
03079   delete parser;
03080   XERCES::XMLPlatformUtils::Terminate();
03081   delete appHandler;
03082   return;
03083 }
03084