48 p_progress->SetText(
"Working");
49 p_propagateLabels =
true;
50 p_propagateTables =
true;
51 p_propagatePolygons =
true;
52 p_propagateHistory =
true;
53 p_propagateOriginalLabel =
true;
86 if(att.
bands().size() != 0) {
87 vector<QString> lame = att.
bands();
92 if(requirements & Isis::ReadWrite) {
93 cube->
open(fname,
"rw");
105 if(requirements & Isis::AllMatchOrOne) {
106 if(InputCubes.size() > 0) {
108 if(cube->
lineCount() != InputCubes[0]->lineCount()) {
109 QString message =
"The number of lines in the secondary input cubes must match";
110 message +=
" the primary input cube or be exactly one";
116 if(cube->
sampleCount() != InputCubes[0]->sampleCount()) {
117 QString message =
"The number of samples in the secondary input cubes must match";
118 message +=
" the primary input cube or be exactly one";
123 if(cube->
bandCount() != InputCubes[0]->bandCount()) {
124 QString message =
"The number of bands in the secondary input cubes must match";
125 message +=
" the primary input cube or be exactly one";
131 requirements = requirements & !Isis::SpatialMatch;
136 if(requirements & Isis::SizeMatch) {
137 if(InputCubes.size() > 0) {
138 if(cube->
lineCount() != InputCubes[0]->lineCount()) {
139 QString message =
"The number of lines in the input cubes must match";
142 if(cube->
sampleCount() != InputCubes[0]->sampleCount()) {
143 QString message =
"The number of samples in the input cubes must match";
146 if(cube->
bandCount() != InputCubes[0]->bandCount()) {
147 QString message =
"The number of bands in the input cubes must match";
154 if(requirements & Isis::SpatialMatch) {
155 if(InputCubes.size() > 0) {
156 if(cube->
lineCount() != InputCubes[0]->lineCount()) {
157 QString message =
"The number of lines in the input cubes must match";
160 if(cube->
sampleCount() != InputCubes[0]->sampleCount()) {
161 QString message =
"The number of samples in the input cubes must match";
168 if(requirements & Isis::OneBand) {
170 QString message =
"Input cube [" + fname +
"] must have one band";
176 if(requirements & Isis::BandMatchOrOne) {
178 if(InputCubes.size() > 0) {
179 if(cube->
bandCount() != InputCubes[0]->bandCount()) {
180 QString message =
"The number of bands in the secondary input cubes must match";
181 message +=
" the primary input cube or be exactly one";
203 if(inCube != NULL && inCube->
isOpen()) {
204 AddInputCube(inCube,
false);
207 QString message =
"Input cube does not exist";
244 const int requirements) {
245 QString fname = Application::GetUserInterface().GetFileName(parameter);
247 return SetInputCube(fname, att, requirements);
266 Isis::Cube *Process::SetOutputCube(
const QString ¶meter) {
268 if(InputCubes.size() == 0) {
269 QString message =
"No input images have been selected ... therefore";
270 message +=
"the output image size can not be determined";
274 int nl = InputCubes[0]->lineCount();
275 int ns = InputCubes[0]->sampleCount();
276 int nb = InputCubes[0]->bandCount();
277 return SetOutputCube(parameter, ns, nl, nb);
302 Isis::Cube *Process::SetOutputCube(
const QString ¶meter,
const int ns,
303 const int nl,
const int nb) {
305 if((ns <= 0) || (nl <= 0) || (nb <= 0)) {
306 ostringstream message;
307 message <<
"Invalid cube size specifications [ns=" << ns <<
",nl=" << nl
308 <<
",nb=" << nb <<
"]";
312 QString fname = Application::GetUserInterface().GetFileName(parameter);
314 return SetOutputCube(fname, atts, ns, nl, nb);
336 const int ns,
const int nl,
339 if ((ns <= 0) || (nl <= 0) || (nb <= 0)) {
340 ostringstream message;
341 message <<
"Invalid cube size specifications [ns=" << ns <<
",nl=" << nl
342 <<
",nb=" << nb <<
"]";
355 if(InputCubes.size() > 0) {
359 QString msg =
"You told me to propagate PixelType from input to output";
360 msg +=
" cube but there are no input cubes loaded";
372 else if(InputCubes.size() == 0) {
373 QString msg =
"You told me to propagate base/multiplier from input to output";
374 msg +=
" cube but there are no input cubes loaded";
377 else if(cube->
pixelType() >= InputCubes[0]->pixelType()) {
378 double base = InputCubes[0]->base();
379 double mult = InputCubes[0]->multiplier();
382 else if((cube->
pixelType() != Isis::Real) &&
383 (cube->
pixelType() != Isis::UnsignedByte) &&
384 (cube->
pixelType() != Isis::UnsignedWord) &&
385 (cube->
pixelType() != Isis::SignedWord) &&
386 (cube->
pixelType() != Isis::UnsignedInteger) &&
387 (cube->
pixelType() != Isis::SignedInteger)) {
388 QString msg =
"Looks like your refactoring to add different pixel types";
389 msg +=
" you'll need to make changes here";
393 QString msg =
"You've chosen to reduce your output PixelType for [" +
394 fname +
"] you must specify the output pixel range too";
403 if(InputCubes.size() > 0) {
404 int needLabBytes = InputCubes[0]->labelSize(
true) + (1024 * 6);
414 if((p_propagateLabels) && (InputCubes.size() > 0)) {
416 InputCubes[0]->label()->
findObject(
"IsisCube");
418 for(
int i = 0; i < incube.
groups(); i++) {
422 if (InputCubes[0]->label()->hasObject(
"NaifKeywords")) {
424 InputCubes[0]->label()->findObject(
"NaifKeywords"));
429 if((p_propagateTables) && (InputCubes.size() > 0)) {
430 Isis::Pvl &inlab = *InputCubes[0]->label();
431 for(
int i = 0; i < inlab.
objects(); i++) {
434 InputCubes[0]->read(t);
441 if((p_propagatePolygons) && (InputCubes.size() > 0)) {
442 Isis::Pvl &inlab = *InputCubes[0]->label();
443 for(
int i = 0; i < inlab.
objects(); i++) {
446 InputCubes[0]->read(t);
453 if((p_propagateOriginalLabel) && (InputCubes.size() > 0)) {
454 Isis::Pvl &inlab = *InputCubes[0]->label();
455 for(
int i = 0; i < inlab.
objects(); i++) {
458 InputCubes[0]->read(ol);
483 void Process::EndProcess() {
491 void Process::Finalize() {
495 void Process::AddInputCube(
Cube *cube,
bool owned) {
496 InputCubes.push_back(cube);
497 if (owned) m_ownedCubes->insert(cube);
500 void Process::AddOutputCube(Cube *cube,
bool owned) {
501 OutputCubes.push_back(cube);
502 if (owned) m_ownedCubes->insert(cube);
509 void Process::ClearCubes() {
513 m_ownedCubes->clear();
519 void Process::ClearInputCubes() {
521 for (
unsigned int i = 0; i < InputCubes.size(); i++) {
522 if (m_ownedCubes->contains(InputCubes[i])) {
523 InputCubes[i]->close();
524 delete InputCubes[i];
533 void Process::ClearOutputCubes() {
535 for (
unsigned int i = 0; i < OutputCubes.size(); i++) {
536 if (m_ownedCubes->contains(OutputCubes[i])) {
537 OutputCubes[i]->close();
538 delete OutputCubes[i];
555 void Process::PropagateLabels(
const bool prop) {
556 p_propagateLabels = prop;
566 void Process::PropagateLabels(
const QString &cube) {
571 for(
int i = 0; i < (int)OutputCubes.size(); i++) {
574 Isis::Pvl &outLabels(*OutputCubes[i]->label());
577 for(
int g = 0; g < inCubeLabels.
groups(); g++) {
581 if (inLabels.
hasObject(
"NaifKeywords")) {
594 void Process::PropagateTables(
const bool prop) {
595 p_propagateTables = prop;
614 void Process::PropagateTables(
const QString &fromName,
const QList<QString> &tableNames) {
616 fromCube->
open(fromName);
617 const Pvl *fromLabels = fromCube->
label();
619 for (
unsigned int i = 0; i < OutputCubes.size(); i++) {
620 for (
int j = 0; j < fromLabels->
objects(); j++) {
623 if (
object.isNamed(
"Table")) {
624 if (tableNames.isEmpty() || tableNames.contains(
object[
"Name"])) {
625 Blob table((QString)
object[
"Name"],
object.name());
626 fromCube->
read(table);
627 OutputCubes[i]->write(table);
641 void Process::PropagatePolygons(
const bool prop) {
642 p_propagatePolygons = prop;
651 void Process::PropagateHistory(
const bool prop) {
652 p_propagateHistory = prop;
662 void Process::PropagateOriginalLabel(
const bool prop) {
663 p_propagateOriginalLabel = prop;
682 QString Process::MissionData(
const QString &mission,
const QString &file,
683 bool highestVersion) {
685 QString dir = dataDir[mission];
690 QString message =
"Data directory for mission [" + mission +
"] " +
691 "is not installed at your site";
703 void Process::WriteHistory(
Cube &cube) {
704 if(p_propagateHistory) {
705 bool addedHist =
false;
706 if(InputCubes.size() > 0) {
707 Isis::Pvl & inlab = *InputCubes[0]->label();
708 for(
int i = 0; i < inlab.
objects(); i++) {
709 if(inlab.
object(i).
isNamed(
"History") && Isis::iApp != NULL) {
711 InputCubes[0]->read(h);
719 if(!addedHist && Isis::iApp != NULL) {
737 void Process::CalculateStatistics() {
738 for(
unsigned cubeNum = 0; cubeNum < InputCubes.size(); cubeNum++) {
739 Cube *cube = InputCubes[cubeNum];
749 QString cubeNumStr =
toString(cubeNum + 1);
750 QString totalCubes =
toString((
int)InputCubes.size());
751 QString msg =
"Calculating statistics for cube " + cubeNumStr +
" of " + totalCubes;
759 vector<Statistics *> allBandStats;
760 for(
int useBand = bandStart; useBand <= bandStop; useBand++) {
763 for(
int i = 1; i <= cube->
lineCount(); i++) {
771 allBandStats.push_back(bandStats);
774 p_bandStats.push_back(allBandStats);
775 p_cubeStats.push_back(cubeStats);
PvlObject & object(const int index)
Return the object at the specified index.
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.
double * DoubleBuffer() const
Returns the value of the shape buffer.
PixelType pixelType() const
Return the pixel type as an Isis::PixelType.
void SetMaximumSteps(const int steps)
This sets the maximum number of steps in the process.
PvlGroupIterator findGroup(const QString &name, PvlGroupIterator beg, PvlGroupIterator end)
Find a group with the specified name, within these indexes.
ByteOrder byteOrder() const
Return the byte order as an Isis::ByteOrder.
File name manipulation and expansion.
int objects() const
Returns the number of objects.
PvlObjectIterator findObject(const QString &name, PvlObjectIterator beg, PvlObjectIterator end)
Find the index of object with a specified name, between two indexes.
void addGroup(const Isis::PvlGroup &group)
Add a group to the object.
void setFormat(Format format)
Used prior to the Create method, this will specify the format of the cube, either band...
Namespace for the standard library.
bool propagatePixelType() const
Return true if the pixel type is to be propagated from an input cube.
bool isOpen() const
Test if a cube file has been opened/created.
void setLabelsAttached(bool attached)
Use prior to calling create, this sets whether or not to use separate label and data files...
bool propagateMinimumMaximum() const
Return true if the min/max are to be propagated from an input cube.
QString toString(bool boolToConvert)
Global function to convert a boolean to a string.
void CheckStatus()
Checks and updates the status.
void setDimensions(int ns, int nl, int nb)
Used prior to the Create method to specify the size of the cube.
int size() const
Returns the total number of pixels in the shape buffer.
bool hasObject(const QString &name) const
Returns a boolean value based on whether the object exists in the current PvlObject or not...
void addObject(const PvlObject &object)
Add a PvlObject.
Buffer manager, for moving through a cube in lines.
QString name() const
Returns the container name.
This class is used to accumulate statistics on double arrays.
Program progress reporter.
void setPixelType(PixelType pixelType)
Used prior to the Create method, this will specify the output pixel type.
void SetText(const QString &text)
Changes the value of the text string reported just before 0% processed.
Contains multiple PvlContainers.
#define _FILEINFO_
Macro for the filename and line number.
void setVirtualBands(const QList< QString > &vbands)
This allows the programmer to specify a subset of bands to work with.
Manipulate and parse attributes of output cube filenames.
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...
double maximum() const
Return the output cube attribute maximum.
void read(Blob &blob) const
This method will read data from the specified Blob object.
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
void open(const QString &cfile, QString access="r")
This method will open an isis cube for reading or reading/writing.
The input label is embedded in the image file.
Cube::Format fileFormat() const
Return the file format an Cube::Format.
Container for cube-like labels.
PixelType pixelType() const
void setByteOrder(ByteOrder byteOrder)
Used prior to the Create method, this will specify the byte order of pixels, either least or most sig...
bool isNamed(const QString &match) const
Returns whether the given string is equal to the container name or not.
PvlGroup & group(const int index)
Return the group at the specified index.
void setMinMax(double min, double max)
Used prior to the Create method, this will compute a good base and multiplier value given the minimum...
Pvl * label() const
Returns a pointer to the IsisLabel object associated with the cube.
void write(Blob &blob)
This method will write a blob of data (e.g.
void AddEntry()
Adds History PvlObject.
FileName highestVersion() const
Searches the directory specified in the file name for the highest version of the file name...
Namespace for ISIS/Bullet specific routines.
virtual int bandCount() const
Returns the number of virtual bands for the cube.
int groups() const
Returns the number of groups contained.
int labelSize(bool actual=false) const
Returns the number of bytes used by the label.
double minimum() const
Return the output cube attribute minimum.
void AddData(const double *data, const unsigned int count)
Add an array of doubles to the accumulators and counters.
Contains Pvl Groups and Pvl Objects.
void create(const QString &cfile)
This method will create an isis cube for writing.
bool fileExists() const
Returns true if the file exists; false otherwise.
void setLabelSize(int labelBytes)
Used prior to the Create method, this will allocate a specific number of bytes in the label area for ...
IO Handler for Isis Cubes.