Commit d409c2d5 authored by ssides's avatar ssides
Browse files

Add ability for Cube class to handle input attributes

parent c828e573
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -18,6 +18,7 @@
using namespace std;

namespace Isis {

// Function to create a keyword with same values of a specified count
  template <typename T> PvlKeyword makeKey(const QString &name,
                                           const int &nvals,
@@ -30,22 +31,21 @@ namespace Isis {
    double m_albedo;
  };


  // Computes the special MORPHOLOGYRANK and ALBEDORANK planes
  static MosData *getMosaicIndicies(Camera &camera, MosData &md);
  // Updates BandBin keyword
  static void UpdateBandKey(const QString &keyname, PvlGroup &bb, const int &nvals,
                     const QString &default_value = "Null");


  void phocube(UserInterface &ui) {
    Cube icube;
    CubeAttributeInput inAtt = ui.GetInputAttribute("FROM");
    if (inAtt.bands().size() != 0) {
      icube.setVirtualBands(inAtt.bands());
    }
    icube.open(ui.GetFileName("FROM"));
    icube.open(ui.GetCubeName("FROM"));
    phocube(&icube, ui);
  }


  void phocube(Cube *icube, UserInterface &ui)  {

    // Get the camera information if this is not a mosaic. Otherwise, get the
+10 −2
Original line number Diff line number Diff line
@@ -617,7 +617,9 @@ namespace Isis {


  /**
   * This method will open an isis cube for reading or reading/writing.
   * This method will open an existing isis cube for reading or 
   * reading/writing. Any input cube attributes following the file
   * name will be applied.
   *
   * @param[in] cubeFileName Name of the cube file to open. Environment
   *     variables in the filename will be automatically expanded.
@@ -625,8 +627,8 @@ namespace Isis {
   *     accessed. Either read-only "r" or read-write "rw".
   */
  void Cube::open(const QString &cubeFileName, QString access) {
    // Already opened?

    // Already opened?
    if (isOpen()) {
      string msg = "You already have a cube opened";
      throw IException(IException::Programmer, msg, _FILEINFO_);
@@ -634,6 +636,12 @@ namespace Isis {

    initLabelFromFile(cubeFileName, (access == "rw"));

    Isis::CubeAttributeInput att(cubeFileName);
    if(att.bands().size() != 0) {
      vector<QString> bands = att.bands();
      setVirtualBands(bands);
    }

    // Figure out the name of the data file
    try {
      PvlObject &core = m_label->findObject("IsisCube").findObject("Core");
+59 −0
Original line number Diff line number Diff line
@@ -678,6 +678,65 @@ void IsisAml::GetFileName(const QString &paramName,
}









/**
 * Retrieves of a value for a parameter of type "cubename".
 *
 * @param paramName The partial or full name of the parameter to be retrieved.
 * @param extension A default extension to add if it does not already exist on
 * the file name.  For example, "txt" will make /mydir/myfile into
 * /mydir/myfile.txt
 *
 * @return The value of the parameter.
 */
QString IsisAml::GetCubeName(const QString &paramName, QString extension) const {

  const IsisParameterData *param = ReturnParam(paramName);

  if (param->type != "cube") {
    QString message = "Parameter [" + paramName + "] is not a cubename.";
    throw Isis::IException(Isis::IException::Programmer, message, _FILEINFO_);
  }

  QString value;
  if (param->values.size() == 0) {
    if (param->defaultValues.size() == 0) {
      QString message = "Parameter [" + paramName + "] has no value.";
      throw Isis::IException(Isis::IException::User, message, _FILEINFO_);
    }
    else {
      value = param->defaultValues[0];
    }
  }
  else {
    value = param->values[0];
  }

  Isis::FileName name(value);
  if (extension != "") name = name.addExtension(extension);
  value = name.expanded();
  if (name.attributes().length() > 0) {
    value += "+" + name.attributes();
  }

  return value;
}










// Public: Returns the first element of the value member of a parameter whos
// name starts with paramName as a QString
/**
+2 −0
Original line number Diff line number Diff line
@@ -172,6 +172,8 @@ class IsisAml : protected IsisAmlData {
    QString GetFileName(const QString &paramName, QString extension = "") const;
    void GetFileName(const QString &paramName, std::vector<QString> &values) const;

    QString GetCubeName(const QString &paramName, QString extension = "") const;

    QString GetString(const QString &paramName) const;
    void GetString(const QString &paramName, std::vector<QString> &values) const;