Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "stretch app conversion" #4105

Merged
merged 1 commit into from
Nov 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 73 additions & 15 deletions isis/src/base/apps/stretch/main.cpp
Original file line number Diff line number Diff line change
@@ -1,26 +1,84 @@
#include "Isis.h"

#include "Application.h"
#include "UserInterface.h"

#include "stretch_app.h"
#include "TextFile.h"
#include "Statistics.h"
#include "ProcessByLine.h"
#include "SpecialPixel.h"
#include "Stretch.h"
#include "PvlGroup.h"
#include "PvlKeyword.h"

using namespace std;
using namespace Isis;

void stretch(Buffer &in, Buffer &out);
Stretch str;
Statistics stats;

void IsisMain() {
ProcessByLine p;
Cube *inCube = p.SetInputCube("FROM");

UserInterface &ui = Application::GetUserInterface();
Pvl results;
try{
stretch(ui, &results);

QString pairs;

// first just get the pairs from where ever and worry about
// whether they are dn values or %'s later
if(ui.GetBoolean("READFILE")) {
FileName pairsFileName = ui.GetFileName("INPUTFILE");
TextFile pairsFile;
pairsFile.SetComment("#");
pairsFile.Open(pairsFileName.expanded());

// concat all non-comment lines into one string (pairs)
QString line = "";
while(pairsFile.GetLine(line, true)) {
pairs += " " + line;
}
pairs += line;
}
catch(...){
for (int resultIndex = 0; resultIndex < results.groups(); resultIndex++) {
Application::Log(results.group(resultIndex));
}
throw;
else {
if(ui.WasEntered("PAIRS"))
pairs = ui.GetString("PAIRS");
}

if(ui.GetBoolean("USEPERCENTAGES")) {
str.Parse(pairs, inCube->histogram());
}
for (int resultIndex = 0; resultIndex < results.groups(); resultIndex++) {
Application::Log(results.group(resultIndex));
else
str.Parse(pairs);

// Setup new mappings for special pixels if necessary
if(ui.WasEntered("NULL"))
str.SetNull(StringToPixel(ui.GetString("NULL")));
if(ui.WasEntered("LIS"))
str.SetLis(StringToPixel(ui.GetString("LIS")));
if(ui.WasEntered("LRS"))
str.SetLrs(StringToPixel(ui.GetString("LRS")));
if(ui.WasEntered("HIS"))
str.SetHis(StringToPixel(ui.GetString("HIS")));
if(ui.WasEntered("HRS"))
str.SetHrs(StringToPixel(ui.GetString("HRS")));

p.SetOutputCube("TO");

// Start the processing
p.StartProcess(stretch);
p.EndProcess();

PvlKeyword dnPairs = PvlKeyword("StretchPairs");
dnPairs.addValue(str.Text());

PvlGroup results = PvlGroup("Results");
results.addKeyword(dnPairs);

Application::Log(results);

}

// Line processing routine
void stretch(Buffer &in, Buffer &out) {
for(int i = 0; i < in.size(); i++) {
out[i] = str.Map(in[i]);
}
}
93 changes: 0 additions & 93 deletions isis/src/base/apps/stretch/stretch_app.cpp

This file was deleted.

14 changes: 0 additions & 14 deletions isis/src/base/apps/stretch/stretch_app.h

This file was deleted.

20 changes: 6 additions & 14 deletions isis/src/base/objs/Process/Process.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ namespace Isis {
*
* @throws Isis::iException::Message
*/
Isis::Cube *Process::SetOutputCube(const QString &parameter, UserInterface *ui) {
Isis::Cube *Process::SetOutputCube(const QString &parameter) {
// Make sure we have an input cube to get a default size from
if(InputCubes.size() == 0) {
QString message = "No input images have been selected ... therefore";
Expand All @@ -274,7 +274,7 @@ namespace Isis {
int nl = InputCubes[0]->lineCount();
int ns = InputCubes[0]->sampleCount();
int nb = InputCubes[0]->bandCount();
return SetOutputCube(parameter, ns, nl, nb, ui);
return SetOutputCube(parameter, ns, nl, nb);
}

/**
Expand All @@ -300,24 +300,16 @@ namespace Isis {
* @throws Isis::iException::Message
*/
Isis::Cube *Process::SetOutputCube(const QString &parameter, const int ns,
const int nl, const int nb, UserInterface *ui) {
const int nl, const int nb) {
// Make sure we have good dimensions
if((ns <= 0) || (nl <= 0) || (nb <= 0)) {
ostringstream message;
message << "Invalid cube size specifications [ns=" << ns << ",nl=" << nl
<< ",nb=" << nb << "]";
throw IException(IException::Programmer, message.str().c_str(), _FILEINFO_);
}
QString fname;
Isis::CubeAttributeOutput atts;
if(ui==nullptr){
fname = Application::GetUserInterface().GetFileName(parameter);
atts = Application::GetUserInterface().GetOutputAttribute(parameter);
}
else{
fname = ui->GetFileName(parameter);
atts = ui->GetOutputAttribute(parameter);
}
QString fname = Application::GetUserInterface().GetFileName(parameter);
Isis::CubeAttributeOutput &atts = Application::GetUserInterface().GetOutputAttribute(parameter);
return SetOutputCube(fname, atts, ns, nl, nb);
}

Expand Down Expand Up @@ -416,7 +408,7 @@ namespace Isis {

// Allocate the cube
cube->create(fname);

// Transfer labels from the first input cube
if((p_propagateLabels) && (InputCubes.size() > 0)) {
Isis::PvlObject &incube =
Expand Down
4 changes: 2 additions & 2 deletions isis/src/base/objs/Process/Process.h
Original file line number Diff line number Diff line change
Expand Up @@ -240,9 +240,9 @@ namespace Isis {
virtual void SetInputCube(Isis::Cube *inCube);


virtual Isis::Cube *SetOutputCube(const QString &parameter, UserInterface *ui=nullptr);
virtual Isis::Cube *SetOutputCube(const QString &parameter);
virtual Isis::Cube *SetOutputCube(const QString &parameter, const int nsamps,
const int nlines, const int nbands = 1, UserInterface *ui=nullptr);
const int nlines, const int nbands = 1);
virtual Isis::Cube *SetOutputCube(const QString &fname,
const Isis::CubeAttributeOutput &att,
const int nsamps, const int nlines,
Expand Down
21 changes: 13 additions & 8 deletions isis/src/base/objs/ProcessImport/ProcessImport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1273,21 +1273,26 @@ namespace Isis {
*
* @throws Isis::iException::Message "Unsupported pixel type."
*/
Isis::Cube *ProcessImport::SetOutputCube(const QString &parameter, UserInterface *ui) {
CubeAttributeOutput att;
if (!ui) {
att = Application::GetUserInterface().GetOutputAttribute(parameter);
}
else {
att = ui->GetOutputAttribute(parameter);
}
Isis::Cube *ProcessImport::SetOutputCube(const QString &parameter) {
CubeAttributeOutput &att =
Application::GetUserInterface().GetOutputAttribute(parameter);

SetAttributes(att);

return Process::SetOutputCube(Application::GetUserInterface().GetFileName(parameter), att, p_ns, p_nl, p_nb);
}


/**
* Create the output file.
*
*/
Isis::Cube *ProcessImport::SetOutputCube(const QString &parameter, UserInterface &ui){
CubeAttributeOutput &att = ui.GetOutputAttribute(parameter);
SetAttributes(att);
return Isis::Process::SetOutputCube(ui.GetFileName(parameter), att, p_ns, p_nl, p_nb);
}

/**
* Create the output file. Note that all the appropiate calls to at least
* SetDimensions should be invoked prior to calling this method.
Expand Down
3 changes: 2 additions & 1 deletion isis/src/base/objs/ProcessImport/ProcessImport.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,8 @@ namespace Isis {
// ProcessImport objects and child objects

using Isis::Process::SetOutputCube; // make parent functions visable
Isis::Cube *SetOutputCube(const QString &parameter, UserInterface *ui=nullptr);
Isis::Cube *SetOutputCube(const QString &parameter);
Isis::Cube *SetOutputCube(const QString &parameter, UserInterface &ui);
virtual Isis::Cube *SetOutputCube(const QString &fname,
Isis::CubeAttributeOutput &att);

Expand Down
4 changes: 2 additions & 2 deletions isis/src/newhorizons/apps/leisa2isis/leisa2isis.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ namespace Isis {
PvlGroup extensionLabel = importFits.fitsImageLabel(5);
importFits.SetOrganization(ProcessImport::BIL);
importFits.setProcessFileStructure(5);
Cube *output = importFits.SetOutputCube("ERRORMAP", &ui);
Cube *output = importFits.SetOutputCube("ERRORMAP", ui);

// Save the input FITS label in the Cube original labels
Pvl origLabel;
Expand All @@ -269,7 +269,7 @@ namespace Isis {
PvlGroup extensionLabel = importFits.fitsImageLabel(6);
importFits.SetOrganization(ProcessImport::BIL);
importFits.setProcessFileStructure(6);
Cube *output = importFits.SetOutputCube("QUALITY", &ui);
Cube *output = importFits.SetOutputCube("QUALITY", ui);

// Save the input FITS label in the Cube original labels
Pvl origLabel;
Expand Down