12#include "SessionLog.h" 
   16#include "IException.h" 
   18#include "Preference.h" 
   19#include "Application.h" 
   21#include "OriginalLabel.h" 
   22#include "LineManager.h" 
   72    if(att.bands().size() != 0) {
 
   73      vector<QString> lame = att.bands();
 
   78      if(requirements & Isis::ReadWrite) {
 
   79        cube->
open(fname, 
"rw");
 
 
  112    if(inCube != NULL && inCube->
isOpen()) {
 
  114      AddInputCube(inCube, 
false);
 
  117      QString message = 
"Input cube does not exist";
 
 
  140                                    const int requirements) {
 
 
  166      QString message = 
"No input images have been selected ... therefore";
 
  167      message += 
"the output image size can not be determined";
 
 
  199      QString message = 
"No input images have been selected ... therefore";
 
  200      message += 
"the output image size can not be determined";
 
 
  234                                     const int nl, 
const int nb) {
 
  236    if((ns <= 0) || (nl <= 0) || (nb <= 0)) {
 
  237      ostringstream message;
 
  238      message << 
"Invalid cube size specifications [ns=" << ns << 
",nl=" << nl
 
  239              << 
",nb=" << nb << 
"]";
 
 
  278  if((ns <= 0) || (nl <= 0) || (nb <= 0)) {
 
  279    ostringstream message;
 
  280    message << 
"Invalid cube size specifications [ns=" << ns << 
",nl=" << nl
 
  281            << 
",nb=" << nb << 
"]";
 
  291    fname = ui->GetCubeName(parameter);
 
  292    atts = ui->GetOutputAttribute(parameter);
 
 
  317                                     const int ns, 
const int nl,
 
  320    if ((ns <= 0) || (nl <= 0) || (nb <= 0)) {
 
  321      ostringstream message;
 
  322      message << 
"Invalid cube size specifications [ns=" << ns << 
",nl=" << nl
 
  323              << 
",nb=" << nb << 
"]";
 
  334      if(att.propagatePixelType()) {
 
  339          QString msg = 
"You told me to propagate PixelType from input to output";
 
  340          msg += 
" cube but there are no input cubes loaded";
 
  348      if(att.propagateMinimumMaximum()) {
 
  353          QString msg = 
"You told me to propagate base/multiplier from input to output";
 
  354          msg += 
" cube but there are no input cubes loaded";
 
  362        else if((cube->
pixelType() != Isis::Real) &&
 
  363                (cube->
pixelType() != Isis::UnsignedByte) &&
 
  364                (cube->
pixelType() != Isis::UnsignedWord) &&
 
  365                (cube->
pixelType() != Isis::SignedWord) &&
 
  366                (cube->
pixelType() != Isis::UnsignedInteger) &&
 
  367                (cube->
pixelType() != Isis::SignedInteger)) {
 
  368          QString msg = 
"Looks like your refactoring to add different pixel types";
 
  369          msg += 
" you'll need to make changes here";
 
  373          QString msg = 
"You've chosen to reduce your output PixelType for [" +
 
  374                       fname + 
"] you must specify the output pixel range too";
 
  380        cube->
setMinMax(att.minimum(), att.maximum());
 
  384        int needLabBytes = 
InputCubes[0]->labelSize(
true) + (1024 * 6);
 
  398        for(
int i = 0; i < incube.groups(); i++) {
 
  399          outcube.addGroup(incube.group(i));
 
  402        if (
InputCubes[0]->label()->hasObject(
"NaifKeywords")) {
 
  404              InputCubes[0]->label()->findObject(
"NaifKeywords"));
 
  411        for(
int i = 0; i < inlab.objects(); i++) {
 
  412          if(inlab.object(i).isNamed(
"Table")) {
 
  413            Isis::Blob t((QString)inlab.object(i)[
"Name"], inlab.object(i).name());
 
  423        for(
int i = 0; i < inlab.objects(); i++) {
 
  424          if(inlab.object(i).isNamed(
"Polygon")) {
 
  425            Isis::Blob t((QString)inlab.object(i)[
"Name"], inlab.object(i).name());
 
  435        for(
int i = 0; i < inlab.objects(); i++) {
 
  436          if(inlab.object(i).isNamed(
"OriginalLabel")) {
 
 
  476  void Process::AddInputCube(
Cube *cube, 
bool owned) {
 
  482  void Process::AddOutputCube(Cube *cube, 
bool owned) {
 
  515    if(requirements & Isis::AllMatchOrOne) {
 
  519            QString message = 
"The number of lines in the secondary input cubes must match";
 
  520            message += 
" the primary input cube or be exactly one";
 
  527            QString message = 
"The number of samples in the secondary input cubes must match";
 
  528            message += 
" the primary input cube or be exactly one";
 
  534            QString message = 
"The number of bands in the secondary input cubes must match";
 
  535            message += 
" the primary input cube or be exactly one";
 
  541        requirements = requirements & !Isis::SpatialMatch;
 
  546    if(requirements & Isis::SizeMatch) {
 
  549          QString message = 
"The number of lines in the input cubes must match";
 
  553          QString message = 
"The number of samples in the input cubes must match";
 
  557          QString message = 
"The number of bands in the input cubes must match";
 
  564    if(requirements & Isis::SpatialMatch) {
 
  567          QString message = 
"The number of lines in the input cubes must match";
 
  571          QString message = 
"The number of samples in the input cubes must match";
 
  578    if(requirements & Isis::OneBand) {
 
  580        QString message = 
"Input cube [" + cube->
fileName() + 
"] must have one band";
 
  586    if(requirements & Isis::BandMatchOrOne) {
 
  590            QString message = 
"The number of bands in the secondary input cubes must match";
 
  591            message += 
" the primary input cube or be exactly one";
 
 
  616    for (
unsigned int i = 0; i < 
InputCubes.size(); i++) {
 
 
  631    for (
unsigned int i = 0; i < 
OutputCubes.size(); i++) {
 
 
  675      for(
int g = 0; g < inCubeLabels.groups(); g++) {
 
  676        outCubeLabels.addGroup(inCubeLabels.group(g));
 
  679      if (inLabels.hasObject(
"NaifKeywords")) {
 
  680        outLabels.addObject(inLabels.findObject(
"NaifKeywords"));
 
 
  716    fromCube->
open(fromName);
 
  717    const Pvl *fromLabels = fromCube->
label();
 
  719    for (
unsigned int i = 0; i < 
OutputCubes.size(); i++) {
 
  720      for (
int j = 0; j < fromLabels->objects(); j++) {
 
  723        if (
object.isNamed(
"Table")) {
 
  724          if (tableNames.isEmpty() || tableNames.contains(
object[
"Name"])) {
 
  725            Blob table((QString) 
object[
"Name"], 
object.name());
 
  726            fromCube->
read(table);
 
 
  789                              bool highestVersion) {
 
  790    Isis::PvlGroup &dataDir = Isis::Preference::Preferences().findGroup(
"DataDirectory");
 
  791    QString dir = dataDir[mission];
 
  795    if(!installed.fileExists()) {
 
  796      QString message = 
"Data directory for mission [" + mission + 
"] " +
 
  797                       "is not installed at your site";
 
  805    if (highestVersion) {
 
  810        QString message = 
"The file [" + expanded.
original() + 
"] " +
 
  811                          "cannot be found under [" + mission + 
"]";
 
 
  824      bool addedHist = 
false;
 
  827        for(
int i = 0; i < inlab.objects(); i++) {
 
  828          if(inlab.object(i).isNamed(
"History") && Isis::iApp != NULL) {
 
  829            QString histBlobName = (QString)inlab.
object(i)[
"Name"];
 
  832            cube.
write(h, histBlobName);
 
  838      if(!addedHist && Isis::iApp != NULL) {
 
 
  859    for(
unsigned cubeNum = 0; cubeNum < 
InputCubes.size(); cubeNum++) {
 
  870      QString cubeNumStr = 
toString(cubeNum + 1);
 
  872      QString msg = 
"Calculating statistics for cube " + cubeNumStr + 
" of " + totalCubes;
 
  880      vector<Statistics *> allBandStats;
 
  881      for(
int useBand = bandStart; useBand <= bandStop; useBand++) {
 
  884        for(
int i = 1; i <= cube->
lineCount(); i++) {
 
  892        allBandStats.push_back(bandStats);
 
 
static UserInterface & GetUserInterface()
Returns the UserInterface object.
 
int size() const
Returns the total number of pixels in the shape buffer.
 
double * DoubleBuffer() const
Returns the value of the shape buffer.
 
Manipulate and parse attributes of output cube filenames.
 
IO Handler for Isis Cubes.
 
void setPixelType(PixelType pixelType)
Used prior to the Create method, this will specify the output pixel type.
 
void setFormat(Format format)
Used prior to the Create method, this will specify the format of the cube, either band,...
 
void setLabelsAttached(bool attached)
Use prior to calling create, this sets whether or not to use separate label and data files.
 
void setDimensions(int ns, int nl, int nb)
Used prior to the Create method to specify the size of the cube.
 
bool isOpen() const
Test if a cube file has been opened/created.
 
void setBaseMultiplier(double base, double mult)
Used prior to the Create method, this will specify the base and multiplier for converting 8-bit/16-bi...
 
void setMinMax(double min, double max)
Used prior to the Create method, this will compute a good base and multiplier value given the minimum...
 
void create(const QString &cfile)
This method will create an isis cube for writing.
 
void open(const QString &cfile, QString access="r")
This method will open an existing isis cube for reading or reading/writing.
 
PixelType pixelType() const
 
void setVirtualBands(const QList< QString > &vbands)
This allows the programmer to specify a subset of bands to work with.
 
void read(Blob &blob, const std::vector< PvlKeyword > keywords=std::vector< PvlKeyword >()) const
This method will read data from the specified Blob object.
 
void setLabelSize(int labelBytes)
Used prior to the Create method, this will allocate a specific number of bytes in the label area for ...
 
virtual QString fileName() const
Returns the opened cube's filename.
 
void write(Blob &blob, bool overwrite=true)
This method will write a blob of data (e.g.
 
void close(bool remove=false)
Closes the cube and updates the labels.
 
History readHistory(const QString &name="IsisCube") const
Read the History from the Cube.
 
int labelSize(bool actual=false) const
Returns the number of bytes used by the label.
 
virtual int bandCount() const
Returns the number of virtual bands for the cube.
 
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
 
void setByteOrder(ByteOrder byteOrder)
Used prior to the Create method, this will specify the byte order of pixels, either least or most sig...
 
File name manipulation and expansion.
 
bool fileExists() const
Returns true if the file exists; false otherwise.
 
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
 
FileName highestVersion() const
Searches the directory specified in the file name for the highest version of the file name.
 
QString original() const
Returns the full file name including the file path.
 
void AddEntry()
Adds History PvlObject.
 
@ User
A type of error that could only have occurred due to a mistake on the user's part (e....
 
@ Programmer
This error is for when a programmer made an API call that was illegal.
 
@ Io
A type of error that occurred when performing an actual I/O operation.
 
Buffer manager, for moving through a cube in lines.
 
bool SetLine(const int line, const int band=1)
Positions the buffer at the requested line and returns a status indicator if the set was succesful or...
 
Read and store original labels.
 
void PropagateLabels(const bool prop)
This method allows the programmer to turn on/off the propagation of labels from the 1st input cube to...
 
bool p_propagatePolygons
Flag indicating if blobs are be propagated to output cubes.
 
virtual void EndProcess()
End the processing sequence and cleans up by closing cubes, freeing memory, etc.
 
void PropagateHistory(const bool prop)
This method allows the programmer to propagate history to the output cube (default is true)
 
bool p_propagateOriginalLabel
Flag indicating if original lable is to be propagated to output cubes.
 
bool p_propagateLabels
Flag indicating if labels are be propagated to output cubes.
 
std::vector< std::vector< Isis::Statistics * > > p_bandStats
Holds the calculated statistics for each band separately of every input cubei after the CalculateStat...
 
virtual ~Process()
Destroys the Process Object. It will close all opened cubes.
 
std::vector< Isis::Statistics * > p_cubeStats
Holds the calculated statistics for every band together of every input cubei after the CalculateStati...
 
void PropagateOriginalLabel(const bool prop)
This method allows the programmer to propagate original labels to the output cube (default is true)
 
Process()
Constructs a Process Object.
 
std::vector< Isis::Cube * > InputCubes
A vector of pointers to opened Cube objects.
 
QString MissionData(const QString &mission, const QString &file, bool highestVersion=false)
This method reads the mission specific data directory from the user preference file,...
 
void PropagateTables(const bool prop)
This method allows the programmer to propagate input tables to the output cube (default is true)
 
void WriteHistory(Cube &cube)
Writes out the History blob to the cube.
 
virtual Isis::Cube * SetOutputCubeStretch(const QString ¶meter, UserInterface *ui=nullptr)
Allocates a user-specified output cube whose size matches the first input cube.
 
QSet< Isis::Cube * > * m_ownedCubes
A list of cubes owned by this instant.
 
bool p_propagateHistory
Flag indicating if history is to be propagated to output cubes.
 
Isis::Progress * p_progress
Pointer to a Progress object.
 
virtual Isis::Cube * SetOutputCube(const QString ¶meter)
Allocates a user-specified output cube whose size matches the first input cube.
 
std::vector< Isis::Cube * > OutputCubes
A vector of pointers to allocated Cube objects.
 
void CalculateStatistics()
Calculates and stores off statistics on every band of every cube added to this process via the SetInp...
 
void CheckRequirements(const Cube *cube, const int requirements)
Checks to make sure the input cube meets the inputted requirements.
 
virtual Isis::Cube * SetInputCube(const QString ¶meter, const int requirements=0)
Opens an input cube specified by the user and verifies requirements are met.
 
void PropagatePolygons(const bool prop)
This method allows the programmer to propagate input blobs to the output cube (default is true)
 
void ClearInputCubes()
Close owned input cubes from the list and clear the list.
 
bool p_propagateTables
Flag indicating if tables are be propagated to output cubes.
 
void ClearOutputCubes()
Close owned output cubes from the list and clear the list.
 
void ClearCubes()
Close owned cubes from the list and clear the list.
 
virtual void Finalize()
Cleans up by closing cubes and freeing memory for owned cubes.
 
Program progress reporter.
 
void SetMaximumSteps(const int steps)
This sets the maximum number of steps in the process.
 
void SetText(const QString &text)
Changes the value of the text string reported just before 0% processed.
 
void CheckStatus()
Checks and updates the status.
 
Contains multiple PvlContainers.
 
Container for cube-like labels.
 
Contains Pvl Groups and Pvl Objects.
 
PvlObjectIterator findObject(const QString &name, PvlObjectIterator beg, PvlObjectIterator end)
Find the index of object with a specified name, between two indexes.
 
PvlObject & object(const int index)
Return the object at the specified index.
 
void addObject(const PvlObject &object)
Add a PvlObject.
 
This class is used to accumulate statistics on double arrays.
 
Command Line and Xml loader, validation, and access.
 
This is free and unencumbered software released into the public domain.
 
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
 
@ AttachedLabel
The input label is embedded in the image file.
 
Namespace for the standard library.