bool PrintView::getInputSpecification(PlugInArgList*& pArgList) { pArgList = NULL; if (mbInteractive) { VERIFY(DesktopItems::getInputSpecification(pArgList) && pArgList != NULL); Service<PlugInManagerServices> pPlugInManager; VERIFY(pPlugInManager.get() != NULL); // Add args PlugInArg* pArg = pPlugInManager->getPlugInArg(); VERIFY(pArg != NULL); pArg->setName("Data set"); pArg->setType("RasterElement"); pArg->setDefaultValue(NULL); pArg->setDescription("Data set to be printed."); pArgList->addArg(*pArg); pArg = pPlugInManager->getPlugInArg(); VERIFY(pArg != NULL); pArg->setName("Setup Dialog"); pArg->setType("bool"); pArg->setDefaultValue(&mbPrintDialog); pArg->setDescription("Whether to show the setup dialog before printing."); pArgList->addArg(*pArg); } return true; }
bool SaveLayer::getInputSpecification(PlugInArgList*& pArgList) { pArgList = NULL; if (mbInteractive) { VERIFY(DesktopItems::getInputSpecification(pArgList) && pArgList != NULL); Service<PlugInManagerServices> pPlugInManager; VERIFY(pPlugInManager.get() != NULL); // Add args PlugInArg* pArg = pPlugInManager->getPlugInArg(); VERIFY(pArg != NULL); pArg->setName("Filename"); pArg->setType("Filename"); pArg->setDefaultValue(NULL); pArg->setDescription("Location to save the file at."); pArgList->addArg(*pArg); LayerType eType = getLayerType(); string modelType = getModelType(eType); VERIFY(!modelType.empty()); pArg = pPlugInManager->getPlugInArg(); VERIFY(pArg != NULL); pArg->setName("Layer Element"); pArg->setType(modelType); pArg->setDefaultValue(NULL); pArg->setDescription("Layer element to save."); pArgList->addArg(*pArg); } return true; }
bool GenericConvolution::getInputSpecification(PlugInArgList*& pInArgList) { if (!ConvolutionFilterShell::getInputSpecification(pInArgList)) { return false; } PlugInArg* pArg = Service<PlugInManagerServices>()->getPlugInArg(); VERIFY(pArg != NULL); pArg->setName("Kernel"); pArg->setDescription("The convolution kernel as an ossim NEWMAT::Matrix."); pArg->setType("NEWMAT::Matrix"); pInArgList->addArg(*pArg); return true; }
bool BandMath::getOutputSpecification(PlugInArgList*& pArgList) { // Set up list pArgList = mpPluginManager->getPlugInArgList(); VERIFY(pArgList != NULL); PlugInArg* pArg = mpPluginManager->getPlugInArg(); VERIFY(pArg != NULL); pArg->setName("Band Math Result"); pArg->setType("RasterElement"); pArg->setDefaultValue(NULL); pArg->setDescription("Output element for the result of the band math operation."); pArgList->addArg(*pArg); return true; }
bool PlugInTester::getInputSpecification(PlugInArgList *&pArgList) { bool bSuccess = false; pArgList = mpPlugMgr->getPlugInArgList(); if (pArgList != NULL) { PlugInArg* pArg = mpPlugMgr->getPlugInArg(); if (pArg != NULL) { pArg->setName(Executable::ProgressArg()); pArg->setType("Progress"); pArg->setDefaultValue(NULL); pArg->setDescription(Executable::ProgressArgDescription()); bSuccess = pArgList->addArg(*pArg); } } return bSuccess; }
bool CreateExportFileDescriptor::getOutputSpecification(PlugInArgList*& pArgList) { Service<PlugInManagerServices> pPlugInManager; VERIFY(pPlugInManager.get() != NULL); // Set up list pArgList = pPlugInManager->getPlugInArgList(); VERIFY(pArgList != NULL); // Add args PlugInArg* pArg = pPlugInManager->getPlugInArg(); VERIFY(pArg != NULL); pArg->setName("File Descriptor"); // File descriptor pArg->setType("FileDescriptor"); pArg->setDefaultValue(NULL); pArg->setDescription("Resulting descriptor."); pArgList->addArg(*pArg); return true; }
bool RasterElementImporterShell::parseInputArgList(PlugInArgList* pInArgList) { if (pInArgList == NULL) { return false; } StepResource pStep("Validate Inputs", "app", "4CDCFA20-2A40-452D-9956-264A35F8B883"); // Extract the input args PlugInArg* pArg = NULL; bool bSuccess = false; // Progress bSuccess = pInArgList->getArg(Executable::ProgressArg(), pArg); if ((bSuccess == true) && (pArg != NULL)) { if (pArg->isActualSet() == true) { mpProgress = reinterpret_cast<Progress*>(pArg->getActualValue()); } } // Sensor data mpRasterElement = pInArgList->getPlugInArgValue<RasterElement>(Importer::ImportElementArg()); if (mpRasterElement == NULL) { string msg = "The raster element input value is invalid!"; if (mpProgress != NULL) { mpProgress->updateProgress(msg, 0, ERRORS); } pStep->finalize(Message::Failure, msg); return false; } pStep->finalize(Message::Success); return true; }
bool CgmImporter::getInputSpecification(PlugInArgList*& pInArgList) { pInArgList = mpPlugInManager->getPlugInArgList(); VERIFY(pInArgList != NULL); PlugInArg* pArg = NULL; VERIFY((pArg = mpPlugInManager->getPlugInArg()) != NULL); pArg->setName(Executable::ProgressArg()); pArg->setType("Progress"); pArg->setDefaultValue(NULL); pArg->setDescription(Executable::ProgressArgDescription()); pInArgList->addArg(*pArg); VERIFY((pArg = mpPlugInManager->getPlugInArg()) != NULL); pArg->setName(Importer::ImportElementArg()); pArg->setType("DataElement"); pArg->setDefaultValue(NULL); pArg->setDescription("Data element to be imported."); pInArgList->addArg(*pArg); return true; }
bool BandMath::execute(PlugInArgList* pInputArgList, PlugInArgList* pOutputArgList) { StepResource pStep("Start BandMath", "app", "02E18066-1355-4a5f-ABC5-0366D9890C1C"); mpStep = pStep.get(); // Initilize variables initialize(); // Get pointers // parse arg in list if (!parse(pInputArgList, pOutputArgList)) { meGabbiness = ERRORS; displayErrorMessage(); return false; } // Get important stuff pStep->addProperty("Dataset", mpCube->getFilename()); const RasterDataDescriptor* pDescriptor = dynamic_cast<const RasterDataDescriptor*>(mpCube->getDataDescriptor()); if (pDescriptor != NULL) { mCubeRows = pDescriptor->getRowCount(); mCubeColumns = pDescriptor->getColumnCount(); mCubeBands = pDescriptor->getBandCount(); } std::string tmpResultName; vector<DataElement*> elements = mpDataModel->getElements("RasterElement"); vector<DataElement*>::iterator iter; for (iter = elements.begin(); iter != elements.end(); ++iter) { RasterElement* pRaster = static_cast<RasterElement*>(*iter); if (pRaster != NULL) { const RasterDataDescriptor* pCurrentDescriptor = dynamic_cast<const RasterDataDescriptor*>(pRaster->getDataDescriptor()); if (pCurrentDescriptor != NULL) { if ((mCubeRows == static_cast<int>(pCurrentDescriptor->getRowCount())) && (mCubeColumns == static_cast<int>(pCurrentDescriptor->getColumnCount())) && (mCubeBands == static_cast<int>(pCurrentDescriptor->getBandCount()))) { mCubesList.push_back(pRaster); } } } } char errorVal[80]; int errorCode = -1; if (mbInteractive) { QWidget* pParent = mpDesktop->getMainWidget(); FrmBM frmASIT(pDescriptor, mCubesList, pParent); if (frmASIT.exec() == QDialog::Rejected) { pStep->finalize(Message::Abort); return false; } mExpression = frmASIT.getExpression(true).toStdString(); mbDegrees = frmASIT.isDegrees(); mbCubeMath = frmASIT.isMultiCube(); mbAsLayerOnExistingView = frmASIT.isResultsMatrix(); } else { mbCubeMath = false; //check for cube math unsigned int pos = mExpression.find_first_of(string("cC")); if ((pos >= 0) && (pos < (mExpression.length() - 1)) && ((mExpression[pos + 1] > '0') && (mExpression[pos + 1] < '9'))) { mbCubeMath = true; } } if (!createReturnValue(mExpression)) { mstrProgressString = "Could not allocate space for results."; meGabbiness = ERRORS; displayErrorMessage(); return false; } { StepResource pResultStep("Compute result", "app", "CDCC12AC-32DD-4831-BC6B-225538C92053"); mpStep = pResultStep.get(); pResultStep->addProperty("Expression", mExpression); FactoryResource<DataRequest> pReturnRequest; pReturnRequest->setInterleaveFormat(BIP); pReturnRequest->setWritable(true); DataAccessor returnDa = mpResultData->getDataAccessor(pReturnRequest.release()); if (!returnDa.isValid()) { mstrProgressString = "Could not access the result data."; meGabbiness = ERRORS; displayErrorMessage(); return false; } if (!mbCubeMath) { FactoryResource<DataRequest> pCubeRequest; pCubeRequest->setInterleaveFormat(BIP); DataAccessor cubeDa = mpCube->getDataAccessor(pCubeRequest.release()); if (!cubeDa.isValid()) { mstrProgressString = "Reading this cube format is not supported."; meGabbiness = ERRORS; displayErrorMessage(); return false; } vector<DataAccessor> accessors(1, cubeDa); vector<EncodingType> types(1, pDescriptor->getDataType()); char* mutableExpression = new char[mExpression.size() + 1]; strcpy(mutableExpression, mExpression.c_str()); errorCode = eval(mpProgress, accessors, types, mCubeRows, mCubeColumns, mCubeBands, mutableExpression, returnDa, mbDegrees, errorVal, mbCubeMath, mbInteractive); delete [] mutableExpression; } else // cube math { EncodingType type = pDescriptor->getDataType(); vector<DataAccessor> accessors; vector<EncodingType> dataTypes; for (unsigned int i = 0; i < mCubesList.size(); ++i) { FactoryResource<DataRequest> pRequest; pRequest->setInterleaveFormat(BIP); DataAccessor daCube = mCubesList[i]->getDataAccessor(pRequest.release()); accessors.push_back(daCube); const RasterDataDescriptor* pDdCube = dynamic_cast<RasterDataDescriptor*>(mCubesList.at(i)-> getDataDescriptor()); if (pDdCube != NULL) { dataTypes.push_back(pDdCube->getDataType()); } else { mstrProgressString = "Could not get data description for cube."; meGabbiness = ERRORS; displayErrorMessage(); return false; } } char* mutableExpression = new char[mExpression.size() + 1]; strcpy(mutableExpression, mExpression.c_str()); errorCode = eval(mpProgress, accessors, dataTypes, mCubeRows, mCubeColumns, mCubeBands, mutableExpression, returnDa, mbDegrees, errorVal, mbCubeMath, mbInteractive); delete [] mutableExpression; } if (errorCode != 0) { mbError = true; if (errorCode == -1) { mstrProgressString = errorVal; meGabbiness = ERRORS; } else if (errorCode == -2) { mstrProgressString = "BandMath was cancelled due to an error in the input expression."; meGabbiness = ABORT; } else { mstrProgressString = "Unknown error has occured while executing BandMath."; meGabbiness = ERRORS; } displayErrorMessage(); return false; } pResultStep->finalize(Message::Success); } mpStep = pStep.get(); if (!createReturnGuiElement()) { mstrProgressString = "Could not create GUI element."; meGabbiness = ERRORS; displayErrorMessage(); return false; } // Fill output arg list if (pOutputArgList != NULL) { PlugInArg* pArg = NULL; pOutputArgList->getArg("Band Math Result", pArg); VERIFY(pArg != NULL); pArg->setActualValue(mpResultData); } mpResultData->updateData(); if (mpProgress != NULL) { mpProgress->updateProgress("Algorithm completed successfully", 100, meGabbiness); } pStep->finalize(Message::Success); mpStep = NULL; return true; }
bool ResultsExporter::getInputSpecification(PlugInArgList*& pArgList) { // Set up list pArgList = mpPlugInManager->getPlugInArgList(); VERIFY(pArgList != NULL); PlugInArg* pArg = mpPlugInManager->getPlugInArg(); VERIFY(pArg != NULL); pArg->setName(Executable::ProgressArg()); pArg->setType("Progress"); pArg->setDefaultValue(NULL); pArg->setDescription(Executable::ProgressArgDescription()); pArgList->addArg(*pArg); pArg = mpPlugInManager->getPlugInArg(); VERIFY(pArg != NULL); pArg->setName(Exporter::ExportItemArg()); pArg->setType("RasterElement"); pArg->setDefaultValue(NULL); pArg->setDescription("Element to be exported."); pArgList->addArg(*pArg); pArg = mpPlugInManager->getPlugInArg(); VERIFY(pArg != NULL); pArg->setName(Exporter::ExportDescriptorArg()); pArg->setType("RasterFileDescriptor"); pArg->setDefaultValue(NULL); pArg->setDescription("File descriptor for the output file."); pArgList->addArg(*pArg); if (!mbInteractive) { pArg = mpPlugInManager->getPlugInArg(); VERIFY(pArg != NULL); pArg->setName("Pass Area"); pArg->setType("PassArea"); pArg->setDefaultValue(&mPassArea); pArg->setDescription("The area of the threshold from which results should be exported."); pArgList->addArg(*pArg); pArg = mpPlugInManager->getPlugInArg(); VERIFY(pArg != NULL); pArg->setName("First Threshold"); pArg->setType("double"); pArg->setDefaultValue(&mFirstThreshold); pArg->setDescription("The lower boundary of the threshold."); pArgList->addArg(*pArg); pArg = mpPlugInManager->getPlugInArg(); VERIFY(pArg != NULL); pArg->setName("Second Threshold"); pArg->setType("double"); pArg->setDefaultValue(&mSecondThreshold); pArg->setDescription("The upper boundary of the threshold."); pArgList->addArg(*pArg); pArg = mpPlugInManager->getPlugInArg(); VERIFY(pArg != NULL); pArg->setName("Geocoordinate Type"); pArg->setType("GeocoordType"); pArg->setDefaultValue(&mGeocoordType); pArg->setDescription("Coordinate type for georeferenced files."); pArgList->addArg(*pArg); pArg = mpPlugInManager->getPlugInArg(); VERIFY(pArg != NULL); pArg->setName("Metadata"); pArg->setType("bool"); pArg->setDefaultValue(&mbMetadata); pArg->setDescription("Whether associated metadata should be exported."); pArgList->addArg(*pArg); pArg = mpPlugInManager->getPlugInArg(); VERIFY(pArg != NULL); pArg->setName("Append To File"); pArg->setType("bool"); pArg->setDefaultValue(&mbAppendFile); pArg->setDescription("Whether to append to an existing file or create a new file for the results."); pArgList->addArg(*pArg); } return true; }
bool PlugInTester::execute(PlugInArgList* pInArgs, PlugInArgList* pOutArgs) { VERIFY(pInArgs != NULL); Progress* pProgress = NULL; PlugInArg* pArg = NULL; if (pInArgs != NULL && pInArgs->getArg(Executable::ProgressArg(), pArg) && pArg != NULL) { pProgress = reinterpret_cast<Progress*>(pArg->getActualValue()); } vector<PlugInDescriptor*> allPlugins = mpPlugMgr->getPlugInDescriptors(); vector<string> testablePlugins; for (vector<PlugInDescriptor*>::const_iterator it = allPlugins.begin(); it != allPlugins.end(); ++it) { PlugInDescriptor* pDescriptor = *it; if (pDescriptor == NULL) { continue; } if (pDescriptor->isTestable()) { testablePlugins.push_back(pDescriptor->getName()); } } string msg; bool bSuccess = false; PlugInSelectorDlg dlg(mpDesktop->getMainWidget(), testablePlugins); int stat = dlg.exec(); if (stat == QDialog::Accepted) { const vector<string>& pluginsToTest = dlg.getSelectedPlugins(); // TODO: Set up a ProgressTracker for each plug-in to test vector<string>::const_iterator it; for (it = pluginsToTest.begin(); it != pluginsToTest.end(); ++it) { PlugInResource pPlugIn(*it); Testable* pTestable = dynamic_cast<Testable*>(pPlugIn.get()); if (pTestable == NULL) { msg += "The Plug-In " + *it + " cannot be created!"; if (pProgress != NULL) { pProgress->updateProgress(msg, 0, ERRORS); } return false; } msg += "Testing " + *it + "..."; if (pProgress != NULL) { pProgress->updateProgress(msg, 0, NORMAL); } stringstream ostr; bSuccess = pTestable->runAllTests(pProgress, ostr); msg += "Testing of Plug-In " + *it + " has been completed"; ReportingLevel lvl = NORMAL; if (!bSuccess) { lvl = ERRORS; msg += " with errors!"; } else { msg += "!"; } if (ostr.str().size() > 0) { msg += "\n" + ostr.str() + "\n"; } else { msg += "\n"; } if (pProgress != NULL) { pProgress->updateProgress(msg, 100, lvl); } } } return bSuccess; }
bool CreateExportFileDescriptor::getInputSpecification(PlugInArgList*& pArgList) { bool bSuccess = ModelItems::getInputSpecification(pArgList); if (bSuccess == false) { return false; } VERIFY(pArgList != NULL); Service<PlugInManagerServices> pPlugInManager; VERIFY(pPlugInManager.get() != NULL); // Add args PlugInArg* pArg = pPlugInManager->getPlugInArg(); VERIFY(pArg != NULL); pArg->setName("Filename"); // Filename pArg->setType("Filename"); pArg->setDefaultValue(NULL); pArg->setDescription("Location on-disk for the file data."); pArgList->addArg(*pArg); pArg = pPlugInManager->getPlugInArg(); VERIFY(pArg != NULL); pArg->setName("Data Set"); // Data element pArg->setType("DataElement"); pArg->setDefaultValue(NULL); pArg->setDescription("Element to create the new descriptor from."); pArgList->addArg(*pArg); pArg = pPlugInManager->getPlugInArg(); VERIFY(pArg != NULL); pArg->setName("Start Row"); // Start row pArg->setType("unsigned int"); pArg->setDefaultValue(NULL); pArg->setDescription("Beginning row for this descriptor."); pArgList->addArg(*pArg); pArg = pPlugInManager->getPlugInArg(); VERIFY(pArg != NULL); pArg->setName("End Row"); // End row pArg->setType("unsigned int"); pArg->setDefaultValue(NULL); pArg->setDescription("Ending row for this descriptor."); pArgList->addArg(*pArg); pArg = pPlugInManager->getPlugInArg(); VERIFY(pArg != NULL); pArg->setName("Row Skip Factor"); // Row skip factor pArg->setType("unsigned int"); pArg->setDefaultValue(NULL); pArg->setDescription("Row skip factor for this descriptor."); pArgList->addArg(*pArg); pArg = pPlugInManager->getPlugInArg(); VERIFY(pArg != NULL); pArg->setName("Start Column"); // Start column pArg->setType("unsigned int"); pArg->setDefaultValue(NULL); pArg->setDescription("Beginning column for this descriptor."); pArgList->addArg(*pArg); pArg = pPlugInManager->getPlugInArg(); VERIFY(pArg != NULL); pArg->setName("End Column"); // End column pArg->setType("unsigned int"); pArg->setDefaultValue(NULL); pArg->setDescription("Ending column for this descriptor."); pArgList->addArg(*pArg); pArg = pPlugInManager->getPlugInArg(); VERIFY(pArg != NULL); pArg->setName("Column Skip Factor"); // Column skip factor pArg->setType("unsigned int"); pArg->setDefaultValue(NULL); pArg->setDescription("Column skip factor for this descriptor."); pArgList->addArg(*pArg); pArg = pPlugInManager->getPlugInArg(); VERIFY(pArg != NULL); pArg->setName("Start Band"); // Start band pArg->setType("unsigned int"); pArg->setDefaultValue(NULL); pArg->setDescription("Beginning band for this descriptor."); pArgList->addArg(*pArg); pArg = pPlugInManager->getPlugInArg(); VERIFY(pArg != NULL); pArg->setName("End Band"); // End band pArg->setType("unsigned int"); pArg->setDefaultValue(NULL); pArg->setDescription("Ending band for this descriptor."); pArgList->addArg(*pArg); pArg = pPlugInManager->getPlugInArg(); VERIFY(pArg != NULL); pArg->setName("Band Skip Factor"); // Band skip factor pArg->setType("unsigned int"); pArg->setDefaultValue(NULL); pArg->setDescription("Band skip factor for this descriptor."); pArgList->addArg(*pArg); return true; }
bool AutoImporter::getInputSpecification(PlugInArgList*& pArgList) { pArgList = NULL; pArgList = mpPlugInManager->getPlugInArgList(); if (pArgList == NULL) { return false; } // Menu command PlugInArg* pArg = mpPlugInManager->getPlugInArg(); VERIFY(pArg != NULL); pArg->setName(Executable::MenuCommandArg()); pArg->setType("string"); pArg->setDescription("String name for the menu command."); pArg->setDefaultValue(NULL); pArgList->addArg(*pArg); // Progress pArg = mpPlugInManager->getPlugInArg(); VERIFY(pArg != NULL); pArg->setName(Executable::ProgressArg()); pArg->setType("Progress"); pArg->setDescription(Executable::ProgressArgDescription()); pArg->setDefaultValue(NULL); pArgList->addArg(*pArg); // Data element pArg = mpPlugInManager->getPlugInArg(); VERIFY(pArg != NULL); pArg->setName(Importer::ImportElementArg()); pArg->setType("DataElement"); pArg->setDescription("Data element to be imported."); pArg->setDefaultValue(NULL); pArgList->addArg(*pArg); return true; }
bool ModelExporter::getInputSpecification(PlugInArgList*& pInArgList) { pInArgList = mpPlugInManager->getPlugInArgList(); VERIFY(pInArgList != NULL); PlugInArg* pArg = NULL; VERIFY((pArg = mpPlugInManager->getPlugInArg()) != NULL); pArg->setName(Executable::ProgressArg()); pArg->setType("Progress"); pArg->setDefaultValue(NULL); pArg->setDescription(Executable::ProgressArgDescription()); pInArgList->addArg(*pArg); VERIFY((pArg = mpPlugInManager->getPlugInArg()) != NULL); pArg->setName(Exporter::ExportDescriptorArg()); pArg->setType("FileDescriptor"); pArg->setDefaultValue(NULL); pArg->setDescription("File descriptor for the output file."); pInArgList->addArg(*pArg); VERIFY((pArg = mpPlugInManager->getPlugInArg()) != NULL); pArg->setName(Exporter::ExportItemArg()); pArg->setType(mDataElementSubclass); pArg->setDefaultValue(NULL); pArg->setDescription("Model item to export."); pInArgList->addArg(*pArg); return true; }
bool BandMath::isInputValid(PlugInArgList& pArgList) { PlugInArg* pArg = NULL; // The following must always have values set for them // Sensor data if (!pArgList.getArg(Executable::DataElementArg(), pArg) || (pArg == NULL) || !pArg->isActualSet()) { mpStep->finalize(Message::Failure, "Sensor data input argument not present."); meGabbiness = ERRORS; return false; } if (!mbInteractive) { // Sensor data if (!pArgList.getArg("Cube 2", pArg) || (pArg == NULL) || !pArg->isActualSet()) { mpStep->finalize(Message::Failure, "Sensor data input argument not present."); meGabbiness = ERRORS; return false; } // Sensor data if (!pArgList.getArg("Cube 3", pArg) || (pArg == NULL) || !pArg->isActualSet()) { mpStep->finalize(Message::Failure, "Sensor data input argument not present."); meGabbiness = ERRORS; return false; } // Sensor data if (!pArgList.getArg("Cube 4", pArg) || (pArg == NULL)) { mpStep->finalize(Message::Failure, "Sensor data input argument not present."); meGabbiness = ERRORS; return false; } // Sensor data if (!pArgList.getArg("Cube 5", pArg) || (pArg == NULL)) { mpStep->finalize(Message::Failure, "Sensor data input argument not present."); meGabbiness = ERRORS; return false; } // Test if (pArgList.getArg("Input Expression", pArg) || (pArg == NULL) || !pArg->isActualSet()) { mpStep->finalize(Message::Failure, "Expression input argument not present."); meGabbiness = ERRORS; return false; } // Test Display Results if (pArgList.getArg("Display Results", pArg) || (pArg == NULL) || !pArg->isActualSet()) { mpStep->finalize(Message::Failure, "Display Results input argument not present."); meGabbiness = ERRORS; return false; } // Test Degrees if (pArgList.getArg("Degrees", pArg) || (pArg == NULL) || !pArg->isActualSet()) { mpStep->finalize(Message::Failure, "Degrees input argument not present."); meGabbiness = ERRORS; return false; } } return true; }
bool CreateExportFileDescriptor::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList) { StepResource pStep("Execute Wizard Item", "app", "E15CA38D-02CD-464B-8412-C0937D05A1FB"); pStep->addProperty("Item", getName()); mpStep = pStep.get(); if (extractInputArgs(pInArgList) == false) { return false; } VERIFY(mpFilename != NULL); // Create a file descriptor with the values in the element's data descriptor FileDescriptor* pFileDescriptor = NULL; if (mpElement != NULL) { const RasterDataDescriptor* pRasterDescriptor = dynamic_cast<const RasterDataDescriptor*>(mpElement->getDataDescriptor()); if (pRasterDescriptor != NULL) { // Start row DimensionDescriptor startRow; if (mpStartRow != NULL) { startRow = pRasterDescriptor->getOriginalRow(*mpStartRow - 1); } // End row DimensionDescriptor endRow; if (mpEndRow != NULL) { endRow = pRasterDescriptor->getOriginalRow(*mpEndRow - 1); } // Row skip unsigned int rowSkip = 0; if (mpRowSkipFactor != NULL) { rowSkip = *mpRowSkipFactor; } // Start column DimensionDescriptor startColumn; if (mpStartColumn != NULL) { startColumn = pRasterDescriptor->getOriginalColumn(*mpStartColumn - 1); } // End column DimensionDescriptor endColumn; if (mpEndColumn != NULL) { endColumn = pRasterDescriptor->getOriginalColumn(*mpEndColumn - 1); } // Column skip unsigned int columnSkip = 0; if (mpColumnSkipFactor != NULL) { columnSkip = *mpColumnSkipFactor; } // Start band DimensionDescriptor startBand; if (mpStartBand != NULL) { startBand = pRasterDescriptor->getOriginalBand(*mpStartBand - 1); } // End band DimensionDescriptor endBand; if (mpEndBand != NULL) { endBand = pRasterDescriptor->getOriginalBand(*mpEndBand - 1); } // Band skip unsigned int bandSkip = 0; if (mpBandSkipFactor != NULL) { bandSkip = *mpBandSkipFactor; } pFileDescriptor = RasterUtilities::generateFileDescriptorForExport(pRasterDescriptor, mpFilename->getFullPathAndName(), startRow, endRow, rowSkip, startColumn, endColumn, columnSkip, startBand, endBand, bandSkip); } } // Create a file descriptor with the input filename if (pFileDescriptor == NULL) { FactoryResource<FileDescriptor> pFactoryFileDescriptor; pFileDescriptor = pFactoryFileDescriptor.release(); if (pFileDescriptor != NULL) { pFileDescriptor->setFilename(mpFilename->getFullPathAndName()); } } if (pFileDescriptor == NULL) { reportError("Could not create the file descriptor!", "219F9340-1681-4BD8-90B4-2D9335E8B751"); return false; } // Set the output arg value if (pOutArgList != NULL) { PlugInArg* pArg = NULL; // File descriptor if (pOutArgList->getArg("File Descriptor", pArg) && (pArg != NULL)) { pArg->setActualValue(pFileDescriptor); } else { // Destroy the file descriptor Service<ApplicationServices> pApp; if (pApp.get() != NULL) { ObjectFactory* pObjFact = pApp->getObjectFactory(); if (pObjFact != NULL) { pObjFact->destroyObject(pFileDescriptor, "FileDescriptor"); } } reportError("Could not set the file descriptor output value!", "98FB7EB3-BC2A-4075-9DE2-FD28ABAECE5B"); return false; } } reportComplete(); return true; }
bool SioImporter::ensureStatisticsReadProperly(Progress *pProgress, std::ostream& failure) { bool success = true; success &= setBatch(); PlugInArgList* pInList = NULL; PlugInArgList* pOutList = NULL; isseas(getInputSpecification(pInList) != false, failure); isseas(getOutputSpecification(pOutList) != false, failure); PlugInArg* pRasterElementArg = NULL; isseas(pInList->getArg(Importer::ImportElementArg(), pRasterElementArg) != false, failure); string testFilePath = TestUtilities::getTestDataPath() + "tipjul5bands.sio"; RasterElement* pRasterElement = NULL; if (success) { vector<ImportDescriptor*> descriptors = getImportDescriptors(testFilePath); if (descriptors.empty() == false) { ImportDescriptor* pImportDescriptor = descriptors.front(); if (pImportDescriptor != NULL) { DataDescriptor* pDescriptor = pImportDescriptor->getDataDescriptor(); if (pDescriptor != NULL) { Service<ModelServices> pModel; pRasterElement = dynamic_cast<RasterElement*>(pModel->createElement(pDescriptor)); if (pRasterElement != NULL) { pRasterElementArg->setActualValue(pRasterElement); } } } } } isseas(execute(pInList, pOutList) != false, failure); isseas(pRasterElement != NULL, failure); if (success) { RasterDataDescriptor* pDescriptor = dynamic_cast<RasterDataDescriptor*>(pRasterElement->getDataDescriptor()); isseas(pDescriptor != NULL, failure); const vector<DimensionDescriptor>& loadedBands = pDescriptor->getBands(); isseas(loadedBands.size() == 5, failure); int iNumBandsWithStats = 0; for (int i = 0; i < 5; ++i) { // we don't want to do an assert yet... only when we know 4 bands have computed statistics Statistics* pStatistics = pRasterElement->getStatistics(loadedBands[i]); if (pStatistics != NULL) { if (pStatistics->areStatisticsCalculated() == true) { if (success) { iNumBandsWithStats++; } } } } // success of the band computation is dependent on 4 bands with statistics isseas(iNumBandsWithStats == 3, failure); } if (pRasterElement != NULL) { Service<ModelServices> pModel; pModel->destroyElement(pRasterElement); pRasterElement = NULL; } Service<PlugInManagerServices> pPim; if (pInList) { pPim->destroyPlugInArgList(pInList); } if (pOutList) { pPim->destroyPlugInArgList(pOutList); } return success; }
bool BandMath::getInputSpecification(PlugInArgList*& pArgList) { // Set up list pArgList = mpPluginManager->getPlugInArgList(); VERIFY(pArgList != NULL); PlugInArg* pArg = mpPluginManager->getPlugInArg(); //progress VERIFY(pArg != NULL); pArg->setName(Executable::ProgressArg()); pArg->setType("Progress"); pArg->setDefaultValue(NULL); pArg->setDescription(Executable::ProgressArgDescription()); pArgList->addArg(*pArg); pArg = mpPluginManager->getPlugInArg(); //cube VERIFY(pArg != NULL); pArg->setName(Executable::DataElementArg()); pArg->setType("RasterElement"); pArg->setDefaultValue(NULL); pArg->setDescription("Element on which band math will be performed."); pArgList->addArg(*pArg); if (!mbInteractive) { pArg = mpPluginManager->getPlugInArg(); //cube2 VERIFY(pArg != NULL); pArg->setName("Raster Element 2"); pArg->setType("RasterElement"); pArg->setDefaultValue(NULL); pArg->setDescription("Second element to perform band math on."); pArgList->addArg(*pArg); pArg = mpPluginManager->getPlugInArg(); //cube3 VERIFY(pArg != NULL); pArg->setName("Raster Element 3"); pArg->setType("RasterElement"); pArg->setDefaultValue(NULL); pArg->setDescription("Third element to perform band math on."); pArgList->addArg(*pArg); pArg = mpPluginManager->getPlugInArg(); //cube4 VERIFY(pArg != NULL); pArg->setName("Raster Element 4"); pArg->setType("RasterElement"); pArg->setDefaultValue(NULL); pArg->setDescription("Fourth element to perform band math on."); pArgList->addArg(*pArg); pArg = mpPluginManager->getPlugInArg(); //cube5 VERIFY(pArg != NULL); pArg->setName("Raster Element 5"); pArg->setType("RasterElement"); pArg->setDefaultValue(NULL); pArg->setDescription("Fifth element to perform band math on."); pArgList->addArg(*pArg); pArg = mpPluginManager->getPlugInArg(); // Input Expression VERIFY(pArg != NULL); pArg->setName("Input Expression"); pArg->setType("string"); pArg->setDefaultValue(&mExpression); pArg->setDescription("Expression for band math to evaluate."); pArgList->addArg(*pArg); bool temp = true; pArg = mpPluginManager->getPlugInArg(); // Display Results VERIFY(pArg != NULL); pArg->setName("Display Results"); pArg->setType("bool"); pArg->setDefaultValue(&temp); pArg->setDescription("Whether or not to display the result of the band math operation."); pArgList->addArg(*pArg); temp = false; pArg = mpPluginManager->getPlugInArg(); VERIFY(pArg != NULL); pArg->setName("Degrees"); pArg->setType("bool"); pArg->setDefaultValue(&temp); pArg->setDescription("True causes band math to use degrees; false uses radians (default)."); pArgList->addArg(*pArg); VERIFY(pArgList->addArg<bool>("Overlay Results", mbAsLayerOnExistingView, "Flag for whether " "the results should be added to the original view or a new view. A new view is created " "by default if results are displayed.")); } return true; }
bool SaveLayerFromDataSet::getInputSpecification(PlugInArgList*& pArgList) { pArgList = NULL; if (mbInteractive) { VERIFY(DesktopItems::getInputSpecification(pArgList) && pArgList != NULL); Service<PlugInManagerServices> pPlugInManager; VERIFY(pPlugInManager.get() != NULL); // Add args PlugInArg* pArg = NULL; pArg = pPlugInManager->getPlugInArg(); VERIFY(pArg != NULL); pArg->setName("Filename"); pArg->setType("Filename"); pArg->setDefaultValue(NULL); pArg->setDescription("Location to save the file at."); pArgList->addArg(*pArg); pArg = pPlugInManager->getPlugInArg(); VERIFY(pArg != NULL); pArg->setName("Data set"); pArg->setType("RasterElement"); pArg->setDefaultValue(NULL); pArg->setDescription("Data set to be saved."); pArgList->addArg(*pArg); pArg = pPlugInManager->getPlugInArg(); VERIFY(pArg != NULL); LayerType eType = getLayerType(); pArg->setName("Layer Name"); pArg->setType("string"); pArg->setDefaultValue(NULL); pArg->setDescription("Name of the layer to be saved."); pArgList->addArg(*pArg); } return true; }