Commit 3aaa607c authored by ssides's avatar ssides Committed by Jesse Mapel
Browse files

Add GUI helper to hist so user can see what the minimum and maximum DN values...

Add GUI helper to hist so user can see what the minimum and maximum DN values are of the specified band of the cube
parent 7f515561
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -88,6 +88,9 @@
      Re-added the ability to set number of bins without setting min/max values after the last update. 
      Follow-on to #3881.
    </change>
    <change name="Stuart Sides" date="2020-09-02">
      Added GUI helper for filling in computed min/max. Fixed #3880.
    </change>
  </history>

  <oldName>
@@ -138,6 +141,17 @@
        <description>
          Minimum DN value in histogram.  If not entered it will automatically be computed.
        </description>
        <helpers>
          <helper name="H1">
            <function>helperButtonCalcMinMax</function>
            <brief>Fill in the auto calculated MINIMUM and MAXIMUM for the input cube</brief>
            <description>
              This button will calculate what the default MINIMUM and MAXIMUM values would be
              and fills the respective GUI fields with them.
            </description>
            <icon>$ISISROOT/appdata/images/icons/exec.png</icon>
          </helper>
        </helpers>
        <lessThan>
          <item>MAXIMUM</item>
        </lessThan>
+50 −2
Original line number Diff line number Diff line
#define GUIHELPERS
#include "Isis.h"

#include <QDockWidget>
@@ -18,6 +19,15 @@
using namespace std;
using namespace Isis;

void helperButtonCalcMinMax();

map <QString, void *> GuiHelpers() {
  map <QString, void *> helper;
  helper ["helperButtonCalcMinMax"] = (void *) helperButtonCalcMinMax;
  return helper;
}


void IsisMain() {
  Process p;
  Cube *icube = p.SetInputCube("FROM");
@@ -236,3 +246,41 @@ void IsisMain() {
  delete hist;
  p.EndProcess();
}


// Helper function to fill in the auto calculated min/max.
void helperButtonCalcMinMax() {

  UserInterface &ui = Application::GetUserInterface();

  // Setup a cube for gathering stats from the user requested band
  QString file = ui.GetFileName("FROM");

  Cube inCube;
  CubeAttributeInput attrib = ui.GetInputAttribute("FROM");
  if (attrib.bands().size() != 0) {
     vector<QString> bands = attrib.bands();
     inCube.setVirtualBands(bands);
  }

  inCube.open(file, "r");

  LineManager line(inCube);
  Statistics cubeStats;

  for (int i = 1; i <= inCube.lineCount(); i++) {
    line.SetLine(i);
    inCube.read(line);
    cubeStats.AddData(line.DoubleBuffer(), line.size());
  }  

  inCube.close();

  // Write ranges to the GUI
  ui.Clear("MINIMUM");
  ui.PutDouble("MINIMUM", cubeStats.Minimum());
  ui.Clear("MAXIMUM");
  ui.PutDouble("MAXIMUM", cubeStats.Maximum());

}