Commit 280f07bb authored by Kaitlyn Lee's avatar Kaitlyn Lee Committed by jlaura
Browse files

Fixed bug where findrx was not adding a history blob to the input cube (#3186)

* Added writeHistory to findrx.

* Rearranged includes in findrx.
parent 7bbf89b6
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -44,6 +44,10 @@
    <change name="Jeannie Walldren" date="2010-08-02">
        Updated to use new SearchChip SubchipValidPercent value from the template.
    </change>
    <change name="Kaitlyn Lee" date="2019-03-25">
        Added method writeHistory() to add an entry to the history blob of the input cube.
        Updated code up to coding standards.
    </change>
  </history>

  <groups>
+48 −16
Original line number Diff line number Diff line
#include "Isis.h"
#include "PvlGroup.h"
#include "UserInterface.h"
#include "Cube.h"
#include "Chip.h"
#include "Progress.h"
#include "IException.h"

#include "Application.h"
#include "AutoReg.h"
#include "AutoRegFactory.h"
#include "Brick.h"
#include "Chip.h"
#include "Cube.h"
#include "History.h"
#include "IException.h"
#include "Progress.h"
#include "PvlGroup.h"
#include "UserInterface.h"

using namespace std;
using namespace Isis;

void writeHistory(Cube &cube);

void IsisMain() {
  // Import cube data & PVL information
  Cube cube;
@@ -119,5 +124,32 @@ void IsisMain() {
  reseaus["Status"] = "Refined";

  pattern.close();
  writeHistory(cube);
  cube.close();
}


/**
 * Writes out the History blob to a cube
 *
 * @param cube Cube to add History blob to
 */
void writeHistory(Cube &cube) {
  bool addedHist = false;
  Isis::Pvl *inlabel = cube.label();
  for (int i = 0; i < inlabel->objects(); i++) {
    if (inlabel->object(i).isNamed("History") && Isis::iApp != NULL) {
      Isis::History h( (QString)inlabel->object(i)["Name"] );
      cube.read(h);
      h.AddEntry();
      cube.write(h);
      addedHist = true;
    }
  }

  if (!addedHist && Isis::iApp != NULL) {
    Isis::History h("IsisCube");
    h.AddEntry();
    cube.write(h);
  }
}