USGS

Isis 3.0 Application Source Code Reference

Home

cnetedit.cpp

Go to the documentation of this file.
00001 #define GUIHELPERS
00002 
00003 #include "Isis.h"
00004 
00005 #include <QList>
00006 #include <QMap>
00007 
00008 #include "ControlCubeGraphNode.h"
00009 #include "ControlMeasure.h"
00010 #include "ControlNet.h"
00011 #include "ControlNetValidMeasure.h"
00012 #include "ControlPoint.h"
00013 #include "ControlPointList.h"
00014 #include "Cube.h"
00015 #include "Filename.h"
00016 #include "iException.h"
00017 #include "MeasureValidationResults.h"
00018 #include "Progress.h"
00019 #include "Pvl.h"
00020 #include "PvlGroup.h"
00021 #include "PvlKeyword.h"
00022 #include "PvlObject.h"
00023 #include "SerialNumberList.h"
00024 
00025 #include "GuiEditFile.h"
00026 
00027 using namespace std;
00028 
00029 using namespace Isis;
00030 
00031 // Deletion test
00032 bool shouldDelete(ControlPoint *point);
00033 
00034 // Mutator methods
00035 void ignorePoint(ControlNet &cnet, ControlPoint *point, string cause);
00036 void ignoreMeasure(ControlNet &cnet, ControlPoint *point,
00037                    ControlMeasure *measure, string cause);
00038 void deletePoint(ControlNet &cnet, int cp);
00039 void deleteMeasure(ControlPoint *point, int cm);
00040 
00041 // Edit passes
00042 void populateLog(ControlNet &cnet);
00043 void processControlPoints(string fileName, ControlNet &cnet);
00044 void processControlMeasures(string fileName, ControlNet &cnet);
00045 void checkAllMeasureValidity(ControlNet &cnet, string cubeList);
00046 
00047 // Validity test
00048 MeasureValidationResults validateMeasure(const ControlMeasure *measure,
00049     Cube *cube, Camera *camera);
00050 
00051 // Logging helpers
00052 void logResult(QMap<string, string> *pointsLog, string pointId, string cause);
00053 void logResult(QMap<string, PvlGroup> *measuresLog,
00054     string pointId, string serial, string cause);
00055 PvlObject createLog(string label, QMap<string, string> *pointsMap);
00056 PvlObject createLog(string label,
00057     QMap<string, string> *pointsMap, QMap<string, PvlGroup> *measuresMap);
00058 
00059 void PrintTemp();
00060 void EditDefFile();
00061 
00062 map<string, void *> GuiHelpers() {
00063   map<string, void *> helper;
00064   helper["PrintTemp"]   = (void *) PrintTemp;
00065   helper["EditDefFile"] = (void *) EditDefFile;
00066   return helper;
00067 }
00068 
00069 // Global variables
00070 int numPointsDeleted;
00071 int numMeasuresDeleted;
00072 
00073 bool deleteIgnored;
00074 bool preservePoints;
00075 bool retainRef;
00076 bool keepLog;
00077 
00078 QMap<string, string> * ignoredPoints;
00079 QMap<string, PvlGroup> * ignoredMeasures;
00080 QMap<string, string> * retainedReferences;
00081 QMap<string, string> * editLockedPoints;
00082 QMap<string, PvlGroup> * editLockedMeasures;
00083 
00084 ControlNetValidMeasure *validator;
00085 
00086 
00087 // Main program
00088 void IsisMain() {
00089   // Reset the counts of points and measures deleted
00090   numPointsDeleted = 0;
00091   numMeasuresDeleted = 0;
00092 
00093   // Interface for getting user parameters
00094   UserInterface &ui = Application::GetUserInterface();
00095 
00096   // Get global user parameters
00097   deleteIgnored  = ui.GetBoolean("DELETE");
00098   preservePoints = ui.GetBoolean("PRESERVE");
00099   retainRef      = ui.GetBoolean("RETAIN_REFERENCE");
00100 
00101   // Data needed to keep track of ignored/deleted points and measures
00102   keepLog = ui.WasEntered("LOG");
00103   ignoredPoints = NULL;
00104   ignoredMeasures = NULL;
00105   retainedReferences = NULL;
00106   editLockedPoints = NULL;
00107   editLockedMeasures = NULL;
00108 
00109   // If the user wants to keep a log, go ahead and populate it with all the
00110   // existing ignored points and measures
00111   ControlNet cnet(ui.GetFilename("CNET"));
00112   if (keepLog && cnet.GetNumPoints() > 0)
00113     populateLog(cnet);
00114 
00115   /*
00116    * As a first pass, just try and delete anything that's already ignored
00117    * in the Control Network, if the user wants to delete ignored points and
00118    * measures.  Originally, this check was performed last, only if the user
00119    * didn't specify any other deletion methods.  However, performing this
00120    * check first will actually improve the running time in cases where there
00121    * are already ignored points and measures in the input network. The added
00122    * cost of doing this check here actually doesn't add to the running time at
00123    * all, because these same checks would need to have been done later
00124    * regardless.
00125    */
00126   if (deleteIgnored && cnet.GetNumPoints() > 0) {
00127 
00128     Progress progress;
00129     progress.SetText("Deleting Ignored in Input");
00130     progress.SetMaximumSteps(cnet.GetNumPoints());
00131     progress.CheckStatus();
00132 
00133     for (int cp = cnet.GetNumPoints() - 1; cp >= 0; cp--) {
00134       ControlPoint *point = cnet.GetPoint(cp);
00135       if (point->IsIgnored()) {
00136         deletePoint(cnet, cp);
00137       }
00138       else {
00139         for (int cm = point->GetNumMeasures() - 1; cm >= 0; cm--) {
00140           if (point->GetMeasure(cm)->IsIgnored()) {
00141             if (cm == point->IndexOfRefMeasure()) {
00142               // If the reference is ignored, the point must ignored too
00143               ignorePoint(cnet, point, "Reference measure ignored");
00144             }
00145             else {
00146               // Can't delete the reference without deleting the whole point
00147               deleteMeasure(point, cm);
00148             }
00149           }
00150         }
00151 
00152         // Check if the number of measures in the point is zero or there are too
00153         // few measures in the point and we don't want to preserve them.
00154         if (shouldDelete(point)) {
00155           deletePoint(cnet, cp);
00156         }
00157       }
00158 
00159       progress.CheckStatus();
00160     }
00161   }
00162 
00163   //List has Points Ids
00164   if (ui.WasEntered("POINTLIST") && cnet.GetNumPoints() > 0) {
00165     string pointlistFilename = ui.GetFilename("POINTLIST");
00166     processControlPoints(pointlistFilename, cnet);
00167   }
00168 
00169   //List has Cube file names
00170   if (ui.WasEntered("CUBELIST") && cnet.GetNumPoints() > 0) {
00171     string ignorelistFilename = ui.GetFilename("CUBELIST");
00172     processControlMeasures(ignorelistFilename, cnet);
00173   }
00174 
00175   // Perform validity check
00176   if (ui.GetBoolean("CHECKVALID") && cnet.GetNumPoints() > 0) {
00177     validator = NULL;
00178 
00179     // First validate DefFile's keywords and value type
00180     Pvl defFile(ui.GetFilename("DEFFILE"));
00181     Pvl pvlTemplate("$ISIS3DATA/base/templates/cnet_validmeasure/validmeasure.def");
00182     Pvl pvlResults;
00183     pvlTemplate.ValidatePvl(defFile, pvlResults);
00184     if (pvlResults.Groups() > 0 || pvlResults.Keywords() > 0) {
00185       Application::Log(pvlResults.Group(0));
00186       string sErrMsg = "Invalid Deffile\n";
00187       throw Isis::iException::Message(Isis::iException::User, sErrMsg, _FILEINFO_);
00188     }
00189 
00190     // Construct the validator from the user-specified definition file
00191     validator = new ControlNetValidMeasure(&defFile);
00192 
00193     // User also provided a list of all serial numbers corresponding to every
00194     // cube in the control network
00195     string cubeList = ui.GetFilename("FROMLIST");
00196     checkAllMeasureValidity(cnet, cubeList);
00197 
00198     // Delete the validator
00199     if (validator != NULL) {
00200       delete validator;
00201       validator = NULL;
00202     }
00203 
00204     // Log the DEFFILE to the print file
00205     Application::Log(defFile.FindGroup("ValidMeasure", Pvl::Traverse));
00206   }
00207 
00208   // Log statistics
00209   if (keepLog) {
00210     Pvl outputLog;
00211     
00212     outputLog.AddKeyword(PvlKeyword("PointsDeleted", numPointsDeleted));
00213     outputLog.AddKeyword(PvlKeyword("MeasuresDeleted", numMeasuresDeleted));
00214 
00215     PvlObject lockedLog = createLog(
00216         "EditLocked", editLockedPoints, editLockedMeasures);
00217     outputLog.AddObject(lockedLog);
00218 
00219     outputLog.AddObject(createLog("RetainedReferences", retainedReferences));
00220 
00221     // Depending on whether the user chose to delete ignored points and
00222     // measures, the log will either contain reasons for being ignored, or
00223     // reasons for being deleted
00224     PvlObject ignoredLog = createLog(
00225         deleteIgnored ? "Deleted" : "Ignored", ignoredPoints, ignoredMeasures);
00226     outputLog.AddObject(ignoredLog);
00227 
00228     // Write the log
00229     string logFilename = ui.GetFilename("LOG");
00230     outputLog.Write(logFilename);
00231 
00232     // Delete the structures keeping track of the ignored points and measures
00233     delete ignoredPoints;
00234     ignoredPoints = NULL;
00235 
00236     delete ignoredMeasures;
00237     ignoredMeasures = NULL;
00238 
00239     delete retainedReferences;
00240     retainedReferences = NULL;
00241 
00242     delete editLockedPoints;
00243     editLockedPoints = NULL;
00244 
00245     delete editLockedMeasures;
00246     editLockedMeasures = NULL;
00247   }
00248 
00249   // Write the network
00250   cnet.Write(ui.GetFilename("ONET"));
00251 }
00252 
00253 
00254 /**
00255  * After any modification to a point's measures or ignored status, this check
00256  * should be performed to determine if the changes should result in the point's
00257  * deletion.
00258  *
00259  * @param point The Control Point recently modified
00260  *
00261  * @return Whether or not the point should be deleted
00262  */
00263 bool shouldDelete(ControlPoint *point) {
00264   // If the point only has one measure, then unless it's a fixed point or the
00265   // user wishes to preserve such points, it should be deleted. As a side
00266   // effect, this check will also delete empty points that satisfy this
00267   // condition without having to do the next check
00268   if ((point->GetNumMeasures() < 2 && !preservePoints) &&
00269       point->GetType() != ControlPoint::Fixed)
00270     return true;
00271 
00272   // A point without any measures should always be deleted
00273   if (point->GetNumMeasures() == 0)
00274     return true;
00275 
00276   // If the user wants to delete ignored points, and this point is ignored,
00277   // then it follows that it should be deleted
00278   if (point->IsIgnored() && deleteIgnored)
00279     return true;
00280 
00281   // Otherwise, the point looks good
00282   return false;
00283 }
00284 
00285 
00286 /**
00287  * Set the point at the given index in the control network to ignored, and add
00288  * a new keyword to the list of ignored points with a cause for the ignoring,
00289  * if the user wished to keep a log.
00290  *
00291  * @param cnet  The Control Network being modified
00292  * @param point The Control Point we wish to ignore
00293  * @param cause A prose description of why the point was ignored (for logging)
00294  */
00295 void ignorePoint(ControlNet &cnet, ControlPoint *point, string cause) {
00296   ControlPoint::Status result = point->SetIgnored(true);
00297 
00298   logResult(result == ControlPoint::Success ? ignoredPoints : editLockedPoints,
00299       point->GetId(), cause);
00300 }
00301 
00302 
00303 /**
00304  * Set the measure to be ignored, and add a new keyword to the list of ignored
00305  * measures if the user wished to keep a log.
00306  *
00307  * @param cnet    The Control Network being modified
00308  * @param point   The Control Point of the Control Measure we wish to ignore
00309  * @param measure The Control Measure we wish to ignore
00310  * @param cause   A prose description of why the measure was ignored (for
00311  *                logging)
00312  */
00313 void ignoreMeasure(ControlNet &cnet, ControlPoint *point,
00314                    ControlMeasure *measure, string cause) {
00315 
00316   ControlMeasure::Status result = measure->SetIgnored(true);
00317 
00318   logResult(
00319       result == ControlMeasure::Success ? ignoredMeasures : editLockedMeasures,
00320       point->GetId(), measure->GetCubeSerialNumber(), cause);
00321 }
00322 
00323 
00324 /**
00325  * Delete the point, record how many points and measures have been deleted.
00326  *
00327  * @param cnet The Control Network being modified
00328  * @param cp   Index into the Control Network for the point we wish to delete
00329  */
00330 void deletePoint(ControlNet &cnet, int cp) {
00331   ControlPoint *point = cnet.GetPoint(cp);
00332 
00333   // Do the edit lock check up front so we don't accidentally log that a point
00334   // was deleted when in fact it was not
00335   if (!point->IsEditLocked()) {
00336     numMeasuresDeleted += point->GetNumMeasures();
00337     numPointsDeleted++;
00338 
00339     if (keepLog) {
00340       // If the point's being deleted but it wasn't set to ignore, it can only
00341       // be because the point has two few measures remaining
00342       if (!point->IsIgnored())
00343         ignorePoint(cnet, point, "Too few measures");
00344 
00345       // For any measures not ignored, mark their cause for deletion as being
00346       // caused by the point's deletion
00347       for (int cm = 0; cm < point->GetNumMeasures(); cm++) {
00348         ControlMeasure *measure = point->GetMeasure(cm);
00349         if (!measure->IsIgnored())
00350           ignoreMeasure(cnet, point, measure, "Point deleted");
00351       }
00352     }
00353 
00354     cnet.DeletePoint(cp);
00355   } 
00356   else {
00357     for (int cm = 0; cm < point->GetNumMeasures(); cm++) {
00358       if (point->GetMeasure(cm)->IsEditLocked()) {
00359         ignorePoint(cnet, point, "EditLocked point skipped");
00360       }
00361     }
00362   }
00363 }
00364 
00365 
00366 /**
00367  * Delete the measure, increment the count of measures deleted.
00368  *
00369  * @param cnet  The Control Network being modified
00370  * @param point The Control Point of the Control Measure we wish to delete
00371  * @param cm    Index into the Control Network for the measure we wish to delete
00372  */
00373 void deleteMeasure(ControlPoint *point, int cm) {
00374   if (point->Delete(cm) == ControlMeasure::Success) numMeasuresDeleted++;
00375 }
00376 
00377 
00378 /**
00379  * Seed the log with points and measures already ignored.
00380  *
00381  * @param cnet The Control Network being modified
00382  */
00383 void populateLog(ControlNet &cnet) {
00384   ignoredPoints = new QMap<string, string>;
00385   ignoredMeasures = new QMap<string, PvlGroup>;
00386 
00387   retainedReferences = new QMap<string, string>;
00388   
00389   editLockedPoints = new QMap<string, string>;
00390   editLockedMeasures = new QMap<string, PvlGroup>;
00391 
00392   Progress progress;
00393   progress.SetText("Initializing Log File");
00394   progress.SetMaximumSteps(cnet.GetNumPoints());
00395   progress.CheckStatus();
00396 
00397   for (int cp = 0; cp < cnet.GetNumPoints(); cp++) {
00398     ControlPoint *point = cnet.GetPoint(cp);
00399 
00400     if (point->IsIgnored()) {
00401       ignorePoint(cnet, point, "Ignored from input");
00402     }
00403 
00404     for (int cm = 0; cm < point->GetNumMeasures(); cm++) {
00405       ControlMeasure *measure = point->GetMeasure(cm);
00406 
00407       if (measure->IsIgnored()) {
00408         if (cm == point->IndexOfRefMeasure()) {
00409           // If the reference is ignored, the point must ignored too
00410           if (!point->IsIgnored()) {
00411             ignorePoint(cnet, point, "Reference measure ignored");
00412           }
00413         }
00414 
00415         ignoreMeasure(cnet, point, measure, "Ignored from input");
00416       }
00417     }
00418 
00419     progress.CheckStatus();
00420   }
00421 }
00422 
00423 
00424 /**
00425  * Iterates over the points in the Control Network looking for a match in the
00426  * list of Control Points to be ignored.  If a match is found, ignore the
00427  * point, and if the DELETE option was selected, the point will then be deleted
00428  * from the network.
00429  *
00430  * @param fileName Name of the file containing the list of Control Points
00431  * @param cnet     The Control Network being modified
00432  */
00433 void processControlPoints(string fileName, ControlNet &cnet) {
00434   ControlPointList cpList((Filename)fileName);
00435 
00436   Progress progress;
00437   progress.SetText("Comparing Points to POINTLIST");
00438   progress.SetMaximumSteps(cnet.GetNumPoints());
00439   progress.CheckStatus();
00440 
00441   for (int cp = cnet.GetNumPoints() - 1; cp >= 0; cp--) {
00442     ControlPoint *point = cnet.GetPoint(cp);
00443 
00444     // Compare each Point Id listed with the Point in the
00445     // Control Network for according exclusion
00446     if (!point->IsIgnored() && cpList.HasControlPoint(point->GetId())) {
00447       ignorePoint(cnet, point, "Point ID in POINTLIST");
00448     }
00449 
00450     if (deleteIgnored) {
00451       //look for previously ignored control points
00452       if (point->IsIgnored() || point->GetRefMeasure()->IsIgnored()) {
00453         deletePoint(cnet, cp);
00454       }
00455       else {
00456         //look for previously ignored control measures
00457         for (int cm = point->GetNumMeasures() - 1; cm >= 0; cm--) {
00458           if (point->GetMeasure(cm)->IsIgnored() && deleteIgnored) {
00459             deleteMeasure(point, cm);
00460           }
00461         }
00462         // Check if there are too few measures in the point or the point was
00463         // previously ignored
00464         if (shouldDelete(point)) {
00465           deletePoint(cnet, cp);
00466         }
00467       }
00468     }
00469 
00470     progress.CheckStatus();
00471   }
00472 }
00473 
00474 /**
00475  * Iterates over the list of Control Measures in the Control Network and
00476  * compares measure serial numbers with those in the input list of serial
00477  * numbers to be ignored.  If a match is found, ignore the measure.  If the
00478  * DELETE option was selected, the measure will then be deleted from the
00479  * network.
00480  *
00481  * @param fileName Name of the file containing the list of Serial Numbers to be
00482  *                 ignored
00483  * @param cnet     The Control Network being modified
00484  */
00485 void processControlMeasures(string fileName, ControlNet &cnet) {
00486   SerialNumberList snl = fileName;
00487 
00488   Progress progress;
00489   progress.SetText("Comparing Measures to CUBELIST");
00490   progress.SetMaximumSteps(cnet.GetNumPoints());
00491   progress.CheckStatus();
00492 
00493   for (int cp = cnet.GetNumPoints() - 1; cp >= 0; cp --) {
00494     ControlPoint *point = cnet.GetPoint(cp);
00495 
00496     // Compare each Serial Number listed with the serial number in the
00497     // Control Measure for according exclusion
00498     for (int cm = point->GetNumMeasures() - 1; cm >= 0; cm--) {
00499       ControlMeasure *measure = point->GetMeasure(cm);
00500       
00501       if (!point->IsIgnored() && point->GetMeasure(cm)->IsEditLocked()) {
00502         ignoreMeasure(cnet, point, measure, "EditLocked measure skipped");
00503       }
00504     
00505       string serialNumber = measure->GetCubeSerialNumber();
00506       
00507       if (snl.HasSerialNumber(serialNumber)) {
00508         string cause = "Serial Number in CUBELIST";
00509         if (cm == point->IndexOfRefMeasure() && retainRef) {
00510           logResult(retainedReferences, point->GetId(), cause);
00511         } 
00512         else if (!measure->IsIgnored() || cm == point->IndexOfRefMeasure()) {
00513           ignoreMeasure(cnet, point, measure, cause);
00514   
00515           if (cm == point->IndexOfRefMeasure() && !point->IsIgnored()) {
00516             ignorePoint(cnet, point, "Reference measure ignored");
00517           } 
00518         }
00519       }
00520 
00521       //also look for previously ignored control measures
00522       if (deleteIgnored && measure->IsIgnored() &&
00523           cm != point->IndexOfRefMeasure()) {
00524         deleteMeasure(point, cm);
00525       }
00526     }
00527     // Check if there are too few measures in the point or the point was
00528     // previously ignored
00529     if (shouldDelete(point)) {
00530       deletePoint(cnet, cp);
00531     }
00532 
00533     progress.CheckStatus();
00534   }
00535 }
00536 
00537 
00538 /**
00539  * Compare each measure in the Control Network against tolerances specified in
00540  * the input DEFFILE.  Ignore any measure whose values fall outside the valid
00541  * tolerances, and delete it if the user specified to do so.
00542  *
00543  * @param cnet     The Control Network being modified
00544  * @param cubeList Name of the file containing the list of all Serial Numbers
00545  *                 in the network
00546  */
00547 void checkAllMeasureValidity(ControlNet &cnet, string cubeList) {
00548   SerialNumberList serialNumbers(cubeList);
00549 
00550   QList<ControlCubeGraphNode *> graphNodes = cnet.GetCubeGraphNodes();
00551   Progress progress;
00552   progress.SetText("Checking Measure Validity");
00553   progress.SetMaximumSteps(graphNodes.size());
00554   progress.CheckStatus();
00555 
00556   for (int sn = 0; sn < graphNodes.size(); sn++) {
00557     ControlCubeGraphNode *graphNode = graphNodes[sn];
00558     iString serialNumber = graphNode->getSerialNumber();
00559 
00560     Cube *cube = NULL;
00561     Camera *camera = NULL;
00562     if (validator->IsCubeRequired()) {
00563       if (!serialNumbers.HasSerialNumber(serialNumber)) {
00564         string msg = "Serial Number [" + serialNumber + "] contains no ";
00565         msg += "matching cube in FROMLIST";
00566         throw iException::Message(iException::User, msg, _FILEINFO_);
00567       }
00568 
00569       cube = new Cube;
00570       cube->open(serialNumbers.Filename(serialNumber));
00571 
00572       if (validator->IsCameraRequired()) {
00573         try {
00574           camera = cube->getCamera();
00575         }
00576         catch (Isis::iException &e) {
00577           string msg = "Cannot Create Camera for Image:" + cube->getFilename();
00578           throw iException::Message(iException::User, msg, _FILEINFO_);
00579         }
00580       }
00581     }
00582 
00583     QList<ControlMeasure *> measures = graphNode->getMeasures();
00584     for (int cm = 0; cm < measures.size(); cm++) {
00585       ControlMeasure *measure = measures[cm];
00586       ControlPoint *point = measure->Parent();
00587 
00588       if (!measure->IsIgnored()) {
00589         MeasureValidationResults results =
00590             validateMeasure(measure, cube, camera);
00591 
00592         if (!results.isValid()) {
00593           string failure = results.toString().toStdString();
00594           string cause = "Validity Check " + failure;
00595 
00596           if (measure == point->GetRefMeasure() && retainRef) {
00597             logResult(retainedReferences, point->GetId(), cause);
00598           }
00599           else {
00600             ignoreMeasure(cnet, point, measure, cause);
00601   
00602             if (measure == point->GetRefMeasure()) {
00603               ignorePoint(cnet, point, "Reference measure ignored");
00604             }
00605           }
00606         }
00607       }
00608     }
00609 
00610     delete cube;
00611     progress.CheckStatus();
00612   }
00613 
00614   for (int cp = cnet.GetNumPoints() - 1; cp >= 0; cp--) {
00615     ControlPoint *point = cnet.GetPoint(cp);
00616 
00617     for (int cm = point->GetNumMeasures() - 1; cm >= 0; cm--) {
00618       ControlMeasure *measure = point->GetMeasure(cm);
00619 
00620       // Also look for previously ignored control measures
00621       if (deleteIgnored && measure->IsIgnored() &&
00622           measure != point->GetRefMeasure()) {
00623         deleteMeasure(point, cm);
00624       }
00625     }
00626 
00627     // Check if there are too few measures in the point or the point was
00628     // previously ignored
00629     if (shouldDelete(point))
00630       deletePoint(cnet, cp);
00631   }
00632 }
00633 
00634 
00635 /**
00636  * Test an individual measure against the user-specified tolerances and return
00637  * the result.
00638  *
00639  * @param curMeasure The measure currently being tested
00640  * @param cubeName   Name of the cube whose serial number matches that of the
00641  *                   current measure
00642  *
00643  * @return The results of validating the measure as an object containing the
00644  *         validity and a formatted error (or success) message
00645  */
00646 MeasureValidationResults validateMeasure(const ControlMeasure *measure,
00647     Cube *cube, Camera *camera) {
00648 
00649   MeasureValidationResults results =
00650       validator->ValidStandardOptions(measure, cube, camera);
00651 
00652   return results;
00653 }
00654 
00655 
00656 void logResult(QMap<string, string> *pointsLog, string pointId, string cause) {
00657   if (keepLog) {
00658     // Label the keyword as the Point ID, and make the cause into the value
00659     (*pointsLog)[pointId] = cause;
00660   }
00661 }
00662 
00663 
00664 void logResult(QMap<string, PvlGroup> *measuresLog,
00665     string pointId, string serial, string cause) {
00666 
00667   if (keepLog) {
00668     // Make the keyword label the measure Serial Number, and the cause into the
00669     // value
00670     PvlKeyword measureMessage(PvlKeyword(serial, cause));
00671 
00672     // Using a map to make accessing by Point ID a O(1) to O(lg n) operation
00673     if (measuresLog->contains(pointId)) {
00674       // If the map already has a group for the given Point ID, simply add the
00675       // new measure to it
00676       PvlGroup &pointGroup = (*measuresLog)[pointId];
00677       pointGroup.AddKeyword(measureMessage);
00678     }
00679     else {
00680       // Else there is no group for the Point ID of the measure being ignored,
00681       // so make a new group, add the measure, and insert it into the map
00682       PvlGroup pointGroup(pointId);
00683       pointGroup.AddKeyword(measureMessage);
00684       (*measuresLog)[pointId] = pointGroup;
00685     }
00686   }
00687 }
00688 
00689 
00690 PvlObject createLog(string label, QMap<string, string> *pointsMap) {
00691   PvlObject pointsLog(label);
00692 
00693   QList<string> pointIds = pointsMap->keys();
00694   for (int i = 0; i < pointIds.size(); i++) {
00695     string pointId = pointIds.at(i);
00696     pointsLog.AddKeyword(PvlKeyword(pointId, (*pointsMap)[pointId]));
00697   }
00698 
00699   return pointsLog;
00700 }
00701 
00702 
00703 PvlObject createLog(string label,
00704     QMap<string, string> *pointsMap, QMap<string, PvlGroup> *measuresMap) {
00705 
00706   PvlObject editLog(label);
00707 
00708   PvlObject pointsLog = createLog("Points", pointsMap);
00709   editLog.AddObject(pointsLog);
00710 
00711   // Get all the groups of measures from the map
00712   PvlObject measuresLog("Measures");
00713   QList<PvlGroup> measureGroups = measuresMap->values();
00714 
00715   for (int i = 0; i < measureGroups.size(); i++)
00716     measuresLog.AddGroup(measureGroups.at(i));
00717 
00718   editLog.AddObject(measuresLog);
00719   return editLog;
00720 }
00721 
00722 
00723 /**
00724  * Helper function to print out template to session log.
00725  */
00726 void PrintTemp() {
00727   UserInterface &ui = Application::GetUserInterface();
00728 
00729   // Get template PVL
00730   Pvl userTemp;
00731   userTemp.Read(ui.GetFilename("DEFFILE"));
00732 
00733   // Write template file out to the log
00734   Isis::Application::GuiLog(userTemp);
00735 }
00736 
00737 /**
00738  * Helper function to be able to edit the Deffile. 
00739  * Opens an editor to edit the file. 
00740  * 
00741  * @author Sharmila Prasad (5/23/2011)
00742  */
00743 void EditDefFile(void) {
00744   UserInterface &ui = Application::GetUserInterface();
00745   string sDefFile = ui.GetAsString("DEFFILE");
00746   
00747   GuiEditFile::EditFile(ui, sDefFile);
00748 }