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::SignedWord)) {
385 QString msg =
"Looks like your refactoring to add different pixel types";
386 msg +=
" you'll need to make changes here";
390 QString msg =
"You've chosen to reduce your output PixelType for [" +
391 fname +
"] you must specify the output pixel range too";
400 if(InputCubes.size() > 0) {
401 int needLabBytes = InputCubes[0]->labelSize(
true) + (1024 * 6);
411 if((p_propagateLabels) && (InputCubes.size() > 0)) {
413 InputCubes[0]->label()->
findObject(
"IsisCube");
415 for(
int i = 0; i < incube.
groups(); i++) {
419 if (InputCubes[0]->label()->hasObject(
"NaifKeywords")) {
421 InputCubes[0]->label()->findObject(
"NaifKeywords"));
426 if((p_propagateTables) && (InputCubes.size() > 0)) {
427 Isis::Pvl &inlab = *InputCubes[0]->label();
428 for(
int i = 0; i < inlab.
objects(); i++) {
431 InputCubes[0]->read(t);
438 if((p_propagatePolygons) && (InputCubes.size() > 0)) {
439 Isis::Pvl &inlab = *InputCubes[0]->label();
440 for(
int i = 0; i < inlab.
objects(); i++) {
443 InputCubes[0]->read(t);
450 if((p_propagateOriginalLabel) && (InputCubes.size() > 0)) {
451 Isis::Pvl &inlab = *InputCubes[0]->label();
452 for(
int i = 0; i < inlab.
objects(); i++) {
455 InputCubes[0]->read(ol);
480 void Process::EndProcess() {
488 void Process::Finalize() {
492 void Process::AddInputCube(
Cube *cube,
bool owned) {
493 InputCubes.push_back(cube);
494 if (owned) m_ownedCubes->insert(cube);
497 void Process::AddOutputCube(Cube *cube,
bool owned) {
498 OutputCubes.push_back(cube);
499 if (owned) m_ownedCubes->insert(cube);
506 void Process::ClearCubes() {
510 m_ownedCubes->clear();
516 void Process::ClearInputCubes() {
518 for (
unsigned int i = 0; i < InputCubes.size(); i++) {
519 if (m_ownedCubes->contains(InputCubes[i])) {
520 InputCubes[i]->close();
521 delete InputCubes[i];
530 void Process::ClearOutputCubes() {
532 for (
unsigned int i = 0; i < OutputCubes.size(); i++) {
533 if (m_ownedCubes->contains(OutputCubes[i])) {
534 OutputCubes[i]->close();
535 delete OutputCubes[i];
552 void Process::PropagateLabels(
const bool prop) {
553 p_propagateLabels = prop;
563 void Process::PropagateLabels(
const QString &cube) {
568 for(
int i = 0; i < (int)OutputCubes.size(); i++) {
571 Isis::Pvl &outLabels(*OutputCubes[i]->label());
574 for(
int g = 0; g < inCubeLabels.
groups(); g++) {
578 if (inLabels.
hasObject(
"NaifKeywords")) {
591 void Process::PropagateTables(
const bool prop) {
592 p_propagateTables = prop;
600 void Process::PropagateTables(
const QString &fromName) {
602 fromCube->
open(fromName);
603 const Pvl *fromLabels = fromCube->
label();
605 for (
unsigned int i = 0; i < OutputCubes.size(); i++) {
606 for (
int j = 0; j < fromLabels->
objects(); j++) {
609 if (
object.isNamed(
"Table")) {
610 Blob table((QString)
object[
"Name"],
object.name());
611 fromCube->
read(table);
612 OutputCubes[i]->write(table);
625 void Process::PropagatePolygons(
const bool prop) {
626 p_propagatePolygons = prop;
635 void Process::PropagateHistory(
const bool prop) {
636 p_propagateHistory = prop;
646 void Process::PropagateOriginalLabel(
const bool prop) {
647 p_propagateOriginalLabel = prop;
666 QString Process::MissionData(
const QString &mission,
const QString &file,
667 bool highestVersion) {
669 QString dir = dataDir[mission];
673 if(!installed.fileExists()) {
674 QString message =
"Data directory for mission [" + mission +
"] " +
675 "is not installed at your site";
680 if(highestVersion) expanded = expanded.highestVersion();
681 return expanded.expanded();
687 void Process::WriteHistory(
Cube &cube) {
688 if(p_propagateHistory) {
689 bool addedHist =
false;
690 if(InputCubes.size() > 0) {
691 Isis::Pvl & inlab = *InputCubes[0]->label();
692 for(
int i = 0; i < inlab.
objects(); i++) {
693 if(inlab.
object(i).
isNamed(
"History") && Isis::iApp != NULL) {
695 InputCubes[0]->read(h);
703 if(!addedHist && Isis::iApp != NULL) {
721 void Process::CalculateStatistics() {
722 for(
unsigned cubeNum = 0; cubeNum < InputCubes.size(); cubeNum++) {
723 Cube *cube = InputCubes[cubeNum];
733 QString cubeNumStr =
toString(cubeNum + 1);
734 QString totalCubes =
toString((
int)InputCubes.size());
735 QString msg =
"Calculating statistics for cube " + cubeNumStr +
" of " + totalCubes;
743 vector<Statistics *> allBandStats;
744 for(
int useBand = bandStart; useBand <= bandStop; useBand++) {
747 for(
int i = 1; i <= cube->
lineCount(); i++) {
755 allBandStats.push_back(bandStats);
758 p_bandStats.push_back(allBandStats);
759 p_cubeStats.push_back(cubeStats);