vector<string> ModelServicesImp::getElementNames(const string& filename, const string& type) const { vector<string> elementNames; multimap<Key, DataElement*>::const_iterator iter; for (iter = mElements.begin(); iter != mElements.end(); ++iter) { DataElement* pElement = iter->second; if (pElement != NULL) { string currentFilename = pElement->getFilename(); string lowerCurrentFilename = StringUtilities::toLower(currentFilename); string lowerElementFilename = StringUtilities::toLower(filename); if (lowerCurrentFilename == lowerElementFilename) { if ((type.empty() == true) || (pElement->isKindOf(type) == true)) { elementNames.push_back(pElement->getName()); } } } } return elementNames; }
bool ZoneData::queryZDNames(int simNum, int zoneNum, vector<string> &names) { int numZDs = 0; Tools::ClassManager *cm = Tools::ClassManager::getInstance(); DataElement *zdInfo = NULL; names.clear(); if (queryNumZDs(simNum, zoneNum, numZDs)) { zdInfo = (DataElement *)cm->getObject("DTF_Lib::DataElement"); for (int i = 0; i < numZDs; i++) if (queryZDbyNum(simNum, zoneNum, i, *zdInfo)) names.push_back(zdInfo->getName()); if (zdInfo != NULL) { cm->deleteObject(zdInfo->getID()); zdInfo = NULL; } return true; } return false; }
vector<string> ModelServicesImp::getElementNames(const string& type) const { vector<string> elementNames; multimap<Key, DataElement*>::const_iterator iter; for (iter = mElements.begin(); iter != mElements.end(); ++iter) { DataElement* pElement = iter->second; if (pElement != NULL) { if ((type.empty() == true) || (pElement->isKindOf(type) == true)) { elementNames.push_back(pElement->getName()); } } } return elementNames; }
void GetDataElement<T>::populateTreeWidgetItem(QTreeWidgetItem* pRoot) { VERIFYNR(pRoot != NULL); QVariant value = pRoot->data(GetSessionItemBase<T>::NameColumn, GetSessionItemBase<T>::SessionItemRole); void* pValue = value.value<void*>(); DataElement* const pRootElement = reinterpret_cast<DataElement*>(pValue); const std::vector<DataElement*> elements = Service<ModelServices>()->getElements(pRootElement, std::string()); for (std::vector<DataElement*>::const_iterator iter = elements.begin(); iter != elements.end(); ++iter) { DataElement* pChildElement = *iter; if (pChildElement == NULL) { // Disallow NULL elements since that would result in infinite recursion. continue; } std::auto_ptr<QTreeWidgetItem> pChild(new QTreeWidgetItem); std::string name = pChildElement->getDisplayName(); if (name.empty() == true) { name = pChildElement->getName(); } pChild->setText(GetSessionItemBase<T>::NameColumn, QString::fromStdString(name)); pChild->setData(GetSessionItemBase<T>::NameColumn, GetSessionItemBase<T>::SessionItemRole, QVariant::fromValue<void*>(pChildElement)); pChild->setText(GetSessionItemBase<T>::TypeColumn, QString::fromStdString(pChildElement->getType())); populateTreeWidgetItem(pChild.get()); const bool isValid = pChildElement->isKindOf(TypeConverter::toString<T>()); pChild->setFlags(isValid ? Qt::ItemIsEnabled | Qt::ItemIsSelectable : Qt::NoItemFlags); if (isValid == true || pChild->childCount() > 0) { pRoot->addChild(pChild.release()); } } }
LocateDialog::LocateDialog(const RasterElement* pRaster, QWidget* pParent) : QDialog(pParent, Qt::WindowCloseButtonHint), mpRaster(pRaster), mLayerNameBase("Spectral Library Match Locate Results - "), mpAlgCombo(NULL), mpThreshold(NULL), mpOutputLayerName(NULL), mpUseAoi(NULL), mpAoiCombo(NULL), mpSaveSettings(NULL) { setWindowTitle("Locate Matched Signatures Settings"); // layout QGridLayout* pGrid = new QGridLayout(this); pGrid->setSpacing(5); pGrid->setMargin(10); QLabel* pNameLabel = new QLabel("Dataset:", this); QLabel* pDataLabel = new QLabel(QString::fromStdString(pRaster->getDisplayName(true)), this); pDataLabel->setToolTip(QString::fromStdString(pRaster->getName())); QLabel* pAlgLabel = new QLabel("Algorithm:", this); mpAlgCombo = new QComboBox(this); QLabel* pThresLabel = new QLabel("Threshold:", this); mpThreshold = new QDoubleSpinBox(this); mpThreshold->setSingleStep(0.1); QLabel* pLayerLabel = new QLabel("Output Layer Name:", this); mpOutputLayerName = new QLineEdit(this); mpUseAoi = new QCheckBox("Area of Interest:", this); mpUseAoi->setToolTip("Check box to limit the Locate function to an AOI"); mpAoiCombo = new QComboBox(this); mpAoiCombo->setEnabled(false); mpSaveSettings = new QCheckBox("Save the algorithm and threshold settings", this); QFrame* pLineSeparator = new QFrame(this); pLineSeparator->setFrameStyle(QFrame::HLine | QFrame::Sunken); QDialogButtonBox* pButtons = new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel, Qt::Horizontal, this); pGrid->addWidget(pNameLabel, 0, 0, Qt::AlignRight); pGrid->addWidget(pDataLabel, 0, 1); pGrid->addWidget(pAlgLabel, 1, 0, Qt::AlignRight); pGrid->addWidget(mpAlgCombo, 1, 1); pGrid->addWidget(pThresLabel, 2, 0, Qt::AlignRight); pGrid->addWidget(mpThreshold, 2, 1); pGrid->addWidget(pLayerLabel, 3, 0, Qt::AlignRight); pGrid->addWidget(mpOutputLayerName, 3, 1); pGrid->addWidget(mpUseAoi, 4, 0, Qt::AlignRight); pGrid->addWidget(mpAoiCombo, 4, 1); pGrid->addWidget(mpSaveSettings, 5, 1); pGrid->addWidget(pLineSeparator, 7, 0, 1, 2); pGrid->addWidget(pButtons, 8, 0, 1, 2, Qt::AlignRight); pGrid->setRowStretch(6, 10); pGrid->setColumnStretch(1, 10); // initialize algorithm combo std::vector<std::string> algNames = StringUtilities::getAllEnumValuesAsDisplayString<SpectralLibraryMatch::LocateAlgorithm>(); for (std::vector<std::string>::const_iterator it = algNames.begin(); it != algNames.end(); ++it) { mpAlgCombo->addItem(QString::fromStdString(*it)); } // set up algorithm threshold map std::vector<std::string> algorithmNames = StringUtilities::getAllEnumValuesAsDisplayString<SpectralLibraryMatch::LocateAlgorithm>(); for (std::vector<std::string>::iterator it = algorithmNames.begin(); it != algorithmNames.end(); ++it) { float threshold(0.0f); switch (StringUtilities::fromDisplayString<SpectralLibraryMatch::LocateAlgorithm>(*it)) { case SpectralLibraryMatch::SLLA_CEM: threshold = SpectralLibraryMatchOptions::getSettingLocateCemThreshold(); break; case SpectralLibraryMatch::SLLA_SAM: threshold = SpectralLibraryMatchOptions::getSettingLocateSamThreshold(); break; case SpectralLibraryMatch::SLLA_WBI: threshold = SpectralLibraryMatchOptions::getSettingLocateWbiThreshold(); break; default: threshold = 0.0f; break; } mLocateThresholds.insert(std::pair<std::string, float>(*it, threshold)); } // load aoi combo std::vector<DataElement*> aois = Service<ModelServices>()->getElements(pRaster, TypeConverter::toString<AoiElement>()); for (std::vector<DataElement*>::const_iterator it = aois.begin(); it != aois.end(); ++it) { mpAoiCombo->addItem(QString::fromStdString((*it)->getName())); } // try to determine the active aoi layer and set combo to the element for that layer std::vector<Window*> windows; SpatialDataView* pView(NULL); Service<DesktopServices>()->getWindows(SPATIAL_DATA_WINDOW, windows); for (std::vector<Window*>::iterator it = windows.begin(); it != windows.end(); ++it) { SpatialDataWindow* pWindow = dynamic_cast<SpatialDataWindow*>(*it); if (pWindow != NULL) { SpatialDataView* pTmpView = dynamic_cast<SpatialDataView*>(pWindow->getView()); if (pTmpView != NULL) { LayerList* pLayerList = pTmpView->getLayerList(); if (pLayerList != NULL) { if (pRaster == pLayerList->getPrimaryRasterElement()) { pView = pTmpView; break; } } } } } if (pView != NULL) { Layer* pLayer = pView->getActiveLayer(); if (pLayer != NULL) { DataElement* pElement = pLayer->getDataElement(); if (pElement != NULL) { std::string elementName = pElement->getName(); int index = mpAoiCombo->findText(QString::fromStdString(elementName)); if (index != -1) { mpAoiCombo->setCurrentIndex(index); } } } } if (mpAoiCombo->count() == 0) { mpUseAoi->setEnabled(false); } // Initialize From Settings SpectralLibraryMatch::LocateAlgorithm locType = StringUtilities::fromXmlString<SpectralLibraryMatch::LocateAlgorithm>( SpectralLibraryMatchOptions::getSettingLocateAlgorithm()); mpAlgCombo->setCurrentIndex(mpAlgCombo->findText(QString::fromStdString( StringUtilities::toDisplayString<SpectralLibraryMatch::LocateAlgorithm>(locType)))); mpThreshold->setValue(mLocateThresholds[mpAlgCombo->currentText().toStdString()]); QString layerName = mLayerNameBase; switch (locType) { case SpectralLibraryMatch::SLLA_CEM: layerName += "CEM"; break; case SpectralLibraryMatch::SLLA_SAM: layerName += "SAM"; break; case SpectralLibraryMatch::SLLA_WBI: layerName += "WBI"; break; default: layerName += "Unknown Algorithm"; break; } mpOutputLayerName->setText(layerName); // connections VERIFYNR(connect(pButtons, SIGNAL(accepted()), this, SLOT(accept()))); VERIFYNR(connect(pButtons, SIGNAL(rejected()), this, SLOT(reject()))); VERIFYNR(connect(mpAlgCombo, SIGNAL(currentIndexChanged(const QString&)), this, SLOT(algorithmChanged(const QString&)))); VERIFYNR(connect(mpThreshold, SIGNAL(valueChanged(double)), this, SLOT(thresholdChanged(double)))); VERIFYNR(connect(mpUseAoi, SIGNAL(toggled(bool)), mpAoiCombo, SLOT(setEnabled(bool)))); }
bool CgmImporter::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList) { Progress* pProgress = NULL; DataElement* pElement = NULL; StepResource pStep("Import cgm element", "app", "8D5522FE-4A89-44cb-9735-6920A3BFC903"); // get input arguments and log some useful info about them { // scope the MessageResource MessageResource pMsg("Input arguments", "app", "A1735AC7-C182-45e6-826F-690DBA15D84A"); pProgress = pInArgList->getPlugInArgValue<Progress>(Executable::ProgressArg()); pMsg->addBooleanProperty("Progress Present", (pProgress != NULL)); pElement = pInArgList->getPlugInArgValue<DataElement>(Importer::ImportElementArg()); if (pElement == NULL) { if (pProgress != NULL) { pProgress->updateProgress("No data element", 0, ERRORS); } pStep->finalize(Message::Failure, "No data element"); return false; } pMsg->addProperty("Element name", pElement->getName()); } if (pProgress != NULL) { pProgress->updateProgress((string("Read and parse file ") + pElement->getFilename()), 20, NORMAL); } // Create a new annotation layer for a spatial data view or get the layout layer for a product view if (pProgress != NULL) { pProgress->updateProgress("Create a new layer", 30, NORMAL); } View* pView = mpDesktop->getCurrentWorkspaceWindowView(); if (pView == NULL) { if (pProgress != NULL) { pProgress->updateProgress("Could not access the current view.", 0, ERRORS); } pStep->finalize(Message::Failure, "Could not access the current view."); return false; } UndoGroup undoGroup(pView, "Import CGM"); AnnotationLayer* pLayer = NULL; SpatialDataView* pSpatialDataView = dynamic_cast<SpatialDataView*>(pView); if (pSpatialDataView != NULL) { // Set the parent element of the annotation element to the primary raster element LayerList* pLayerList = pSpatialDataView->getLayerList(); if (pLayerList != NULL) { RasterElement* pNewParentElement = pLayerList->getPrimaryRasterElement(); if (pNewParentElement != NULL) { Service<ModelServices> pModel; pModel->setElementParent(pElement, pNewParentElement); } } pLayer = dynamic_cast<AnnotationLayer*>(pSpatialDataView->createLayer(ANNOTATION, pElement)); } else { ProductView* pProductView = dynamic_cast<ProductView*>(mpDesktop->getCurrentWorkspaceWindowView()); if (pProductView != NULL) { pLayer = pProductView->getLayoutLayer(); } } if (pLayer == NULL) { if (pProgress != NULL) { pProgress->updateProgress("Unable to get the annotation layer", 0, ERRORS); } pStep->finalize(Message::Failure, "Unable to get the annotation layer"); return false; } // add the CGM object if (pProgress != NULL) { pProgress->updateProgress("Create the CGM object", 60, NORMAL); } CgmObject* pCgmObject = dynamic_cast<CgmObject*>(pLayer->addObject(CGM_OBJECT)); if (pCgmObject == NULL) { if (pProgress != NULL) { pProgress->updateProgress("Unable to create the CGM object", 0, ERRORS); } pStep->finalize(Message::Failure, "Unable to create the CGM object"); return false; } // load the CGM file if (pProgress != NULL) { pProgress->updateProgress("Load the CGM file", 90, NORMAL); } string fname = pElement->getDataDescriptor()->getFileDescriptor()->getFilename().getFullPathAndName(); if (!pCgmObject->deserializeCgm(fname)) { if (pProgress != NULL) { pProgress->updateProgress("Error loading the CGM element", 0, ERRORS); } pStep->finalize(Message::Failure, "Unable to parse the CGM file."); return false; } if (pProgress != NULL) { pProgress->updateProgress("Successfully loaded the CGM file", 100, NORMAL); } pStep->finalize(Message::Success); return true; }
bool ResultsExporter::writeOutput(ostream &stream) { mMessage = "Exporting results matrix..."; if (mpProgress != NULL) { mpProgress->updateProgress(mMessage, 0, NORMAL); } StepResource pStep(mMessage, "app", "D890E37C-B960-4527-8AAC-D62F2DE7A541"); RasterDataDescriptor* pDescriptor = dynamic_cast<RasterDataDescriptor*>(mpResults->getDataDescriptor()); if (pDescriptor == NULL) { mMessage = "Could not get the results data descriptor!"; if (mpProgress != NULL) { mpProgress->updateProgress(mMessage, 0, ERRORS); } pStep->finalize(Message::Failure); return false; } VERIFY(mpResults != NULL); string name = mpResults->getName(); VERIFY(mpFileDescriptor != NULL); const vector<DimensionDescriptor>& rows = mpFileDescriptor->getRows(); const vector<DimensionDescriptor>& columns = mpFileDescriptor->getColumns(); unsigned int numRows = pDescriptor->getRowCount(); unsigned int numColumns = pDescriptor->getColumnCount(); EncodingType eDataType = pDescriptor->getDataType(); const vector<int>& badValues = pDescriptor->getBadValues(); if (mbMetadata) { stream << APP_NAME << " Results Raster\n"; stream << "Version = 4\n"; stream << "Results Name = " << name << "\n"; DataElement* pParent = mpResults->getParent(); if (pParent != NULL) { stream << "Data Set Name = " << pParent->getName() << "\n"; } stream << "Rows = " << numRows << "\n"; stream << "Columns = " << numColumns << "\n"; string dataType = StringUtilities::toDisplayString(eDataType); stream << "Data Type = " << dataType << "\n"; Statistics* pStatistics = mpResults->getStatistics(); if (pStatistics != NULL) { stream << "Min = " << pStatistics->getMin() << "\n"; stream << "Max = " << pStatistics->getMax() << "\n"; stream << "Average = " << pStatistics->getAverage() << "\n"; stream << "Standard Deviation = " << pStatistics->getStandardDeviation() << "\n\n"; } } RasterElement* pGeo = getGeoreferencedRaster(); DataAccessor da = mpResults->getDataAccessor(); if (!da.isValid()) { mMessage = "Could not access the data in the results raster!"; if (mpProgress != NULL) { mpProgress->updateProgress(mMessage, 0, ERRORS); } pStep->finalize(Message::Failure); return false; } unsigned int activeRowNumber = 0; for (unsigned int r = 0; r < rows.size(); ++r) { if (mbAbort) { mMessage = "Results exporter aborted!"; if (mpProgress != NULL) { mpProgress->updateProgress(mMessage, 0, ABORT); } pStep->finalize(Message::Abort); return false; } DimensionDescriptor rowDim = rows[r]; // Skip to the next row for (; activeRowNumber < rowDim.getActiveNumber(); ++activeRowNumber) { da->nextRow(); } unsigned int activeColumnNumber = 0; for (unsigned int c = 0; c < columns.size(); ++c) { DimensionDescriptor columnDim = columns[c]; // Skip to the next column for (; activeColumnNumber < columnDim.getActiveNumber(); ++activeColumnNumber) { da->nextColumn(); } VERIFY(da.isValid()); double dValue = ModelServices::getDataValue(eDataType, da->getColumn(), COMPLEX_MAGNITUDE, 0); if (isValueExported(dValue, badValues)) { string location = getLocationString(r, c, pGeo); char buffer[1024]; sprintf(buffer, "%lf\n", dValue); stream << name << " " << location << " " << buffer; } } // Update the progress int iProgress = (r * 100) / rows.size(); if (iProgress == 100) { iProgress = 99; } if (mpProgress != NULL) { mpProgress->updateProgress(mMessage, iProgress, NORMAL); } } stream << "\n"; return true; }
bool ResultsExporter::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList) { StepResource pStep("Execute results exporter", "app", "ABF9EDE4-4672-4361-86BB-3258ADFB0793"); mpStep = pStep.get(); if (!extractInputArgs(pInArgList)) { return false; } // Check for complex data RasterDataDescriptor* pDescriptor = dynamic_cast<RasterDataDescriptor*>(mpResults->getDataDescriptor()); if (pDescriptor == NULL) { mMessage = "Could not get the data descriptor from the results matrix!"; if (mpProgress != NULL) { mpProgress->updateProgress(mMessage, 0, ERRORS); } pStep->finalize(Message::Failure, mMessage); return false; } EncodingType eDataType = pDescriptor->getDataType(); if ((eDataType == INT4SCOMPLEX) || (eDataType == FLT8COMPLEX)) { mMessage = "Cannot save complex data in text format!"; if (mpProgress != NULL) { mpProgress->updateProgress(mMessage, 0, ERRORS); } pStep->finalize(Message::Failure, mMessage); return false; } if (pDescriptor->getBandCount() > 1) { mMessage = "Can only export single band data."; if (mpProgress != NULL) { mpProgress->updateProgress(mMessage, 0, ERRORS); } pStep->finalize(Message::Failure, mMessage); return false; } pDescriptor->addToMessageLog(pStep.get()); const string& filename = mpFileDescriptor->getFilename(); pStep->addProperty("filename", filename); pStep->addProperty("firstThreshold", mFirstThreshold); pStep->addProperty("secondThreshold", mSecondThreshold); pStep->addProperty("passArea", mPassArea); pStep->addProperty("geocoordType", mGeocoordType); pStep->addProperty("metadata", mbMetadata); pStep->addProperty("appendFile", mbAppendFile); DataElement* pParent = mpResults->getParent(); if (pParent != NULL) { pStep->addProperty("sourceDataSet", pParent->getName()); } ofstream fileOutput; fileOutput.open(filename.c_str(), mbAppendFile ? ios_base::app : ios_base::trunc); if (!fileOutput.is_open()) { mMessage = "Could not open the output file for writing!"; if (mpProgress != NULL) { mpProgress->updateProgress(mMessage, 0, ERRORS); } pStep->finalize(Message::Failure, mMessage); return false; } if (!writeOutput(fileOutput)) { if (mbAbort) { pStep->finalize(Message::Abort); } fileOutput.close(); remove(filename.c_str()); } mMessage = "Results matrix export complete!"; if (mpProgress != NULL) { mpProgress->updateProgress(mMessage, 100, NORMAL); } pStep->finalize(Message::Success); return true; }
/** * Get the data element name of a specified layer. * * @param[in] [1] @opt * The name of the layer. Defaults to the top most layer. * @param[in] WINDOW @opt * The name of the window. Defaults to the active window. * @param[in] DATASET @opt * If \p [1] is not specified and this flag it set, get the * data set name of the top most raster layer. * @return The name of the data element. * @usage print,get_data_name(/DATASET) * @endusage */ IDL_VPTR get_data_name(int argc, IDL_VPTR pArgv[], char* pArgk) { typedef struct { IDL_KW_RESULT_FIRST_FIELD; int windowExists; IDL_STRING windowName; int datasetExists; IDL_LONG dataset; } KW_RESULT; //IDL_KW_FAST_SCAN is the type of scan we are using, following it is the //name of the keyword, followed by the type, the mask(which should be 1), //flags, a boolean whether the value was populated and finally the value itself static IDL_KW_PAR kw_pars[] = { IDL_KW_FAST_SCAN, {"DATASET", IDL_TYP_INT, 1, 0, reinterpret_cast<int*>(IDL_KW_OFFSETOF(datasetExists)), reinterpret_cast<char*>(IDL_KW_OFFSETOF(dataset))}, {"WINDOW", IDL_TYP_STRING, 1, 0, reinterpret_cast<int*>(IDL_KW_OFFSETOF(windowExists)), reinterpret_cast<char*>(IDL_KW_OFFSETOF(windowName))}, {NULL} }; IdlFunctions::IdlKwResource<KW_RESULT> kw(argc, pArgv, pArgk, kw_pars, 0, 1); std::string windowName; std::string layerName; std::string name; if (kw->windowExists) { windowName = IDL_STRING_STR(&kw->windowName); } //retrieve the layer name passed in as a parameter if (argc >= 1) { layerName = IDL_VarGetString(pArgv[0]); } //get the layer bool datasets = false; if (kw->datasetExists) { if (kw->dataset != 0) { datasets = true; } } Layer* pLayer = IdlFunctions::getLayerByName(windowName, layerName, datasets); if (pLayer != NULL) { //get the spectral element of the layer and return its name DataElement* pElement = pLayer->getDataElement(); if (pElement != NULL) { name = pElement->getName(); } } else { IDL_Message(IDL_M_GENERIC, IDL_MSG_RET, "the layer name passed into get_data_name " "was invalid."); return IDL_StrToSTRING(""); } return IDL_StrToSTRING(const_cast<char*>(name.c_str())); }
bool LayerImporter::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList) { Layer* pLayer = NULL; Progress* pProgress = NULL; DataElement* pElement = NULL; SpatialDataView* pView = NULL; StepResource pStep("Import layer", "app", "DF24688A-6B34-4244-98FF-5FFE2063AC05"); // get input arguments and log some useful info about them { // scope the MessageResource MessageResource pMsg("Input arguments", "app", "C0A532DE-0E19-44D3-837C-16ABD267B2C1"); pProgress = pInArgList->getPlugInArgValue<Progress>(Executable::ProgressArg()); pMsg->addBooleanProperty("Progress Present", (pProgress != NULL)); pElement = pInArgList->getPlugInArgValue<DataElement>(Importer::ImportElementArg()); if (pElement == NULL) { if (pProgress != NULL) { pProgress->updateProgress("No data element", 100, ERRORS); } pStep->finalize(Message::Failure, "No data element"); return false; } pMsg->addProperty("Element name", pElement->getName()); pView = pInArgList->getPlugInArgValue<SpatialDataView>(Executable::ViewArg()); if (pView != NULL) { pMsg->addProperty("View name", pView->getName()); } } if (pProgress != NULL) { pProgress->updateProgress((string("Read and parse file ") + pElement->getFilename()), 20, NORMAL); } // parse the xml XmlReader xml(Service<MessageLogMgr>()->getLog()); XERCES_CPP_NAMESPACE_QUALIFIER DOMDocument* pDomDocument = xml.parse(pElement->getFilename()); if (pDomDocument == NULL) { if (pProgress != NULL) { pProgress->updateProgress("Unable to parse the file", 100, ERRORS); } pStep->finalize(Message::Failure, "Unable to parse the file"); return false; } DOMElement* pRootElement = pDomDocument->getDocumentElement(); VERIFY(pRootElement != NULL); if (pProgress != NULL) { pProgress->updateProgress("Create the layer", 40, NORMAL); } string name(A(pRootElement->getAttribute(X("name")))); string type(A(pRootElement->getAttribute(X("type")))); unsigned int formatVersion = atoi(A(pRootElement->getAttribute(X("version")))); { // scope the MessageResource MessageResource pMsg("Layer information", "app", "AA358F7A-107E-456E-8D11-36DDBE5B1645"); pMsg->addProperty("name", name); pMsg->addProperty("type", type); pMsg->addProperty("format version", formatVersion); } // If user requested pixel coordinates be used. bool usePixelCoords = false; DataDescriptor* pDesc = pElement->getDataDescriptor(); VERIFY( pDesc ); pDesc->getMetadata()->getAttributeByPath( "Layer/Import Options/Use Pixel Coordinates" ).getValue( usePixelCoords ); if (usePixelCoords) { // Remove geoVertices and geoBox elements. removeGeoNodes(pRootElement); } if (pView == NULL) { //no view provided, so find current view SpatialDataWindow* pWindow = dynamic_cast<SpatialDataWindow*>(mpDesktop->getCurrentWorkspaceWindow()); if (pWindow != NULL) { pView = pWindow->getSpatialDataView(); } } if (pView == NULL) { if (pProgress != NULL) { pProgress->updateProgress("Could not access the view to create the layer.", 100, ERRORS); } pStep->finalize(Message::Failure, "Could not access the view to create the layer."); return false; } bool error = false; LayerType layerType = StringUtilities::fromXmlString<LayerType>(type, &error); if (error == true) { if (pProgress != NULL) { pProgress->updateProgress("The layer type is invalid.", 100, ERRORS); } pStep->finalize(Message::Failure, "The layer type is invalid."); return false; } LayerList* pLayerList = pView->getLayerList(); if (pLayerList != NULL) { RasterElement* pNewParentElement = pLayerList->getPrimaryRasterElement(); if (pNewParentElement != NULL) { Service<ModelServices> pModel; if (pModel->setElementParent(pElement, pNewParentElement) == false) { pProgress->updateProgress("The layer already exists.", 100, ERRORS); pStep->finalize(Message::Failure, "The layer already exists."); return false; } } } UndoGroup group(pView, "Import " + StringUtilities::toDisplayString(layerType) + " Layer"); pLayer = pView->createLayer(layerType, pElement); if (pLayer == NULL) { if (pProgress != NULL) { pProgress->updateProgress("Unable to create the layer", 100, ERRORS); } pStep->finalize(Message::Failure, "Unable to create the layer"); return false; } if (pProgress != NULL) { pProgress->updateProgress("Build the layer", 60, NORMAL); } // deserialize the layer try { if (pLayer->fromXml(pRootElement, formatVersion) == false) { pProgress->updateProgress("Problem with layer file.", 100, ERRORS); pStep->finalize(Message::Failure, "Problem with layer file."); return false; } } catch (XmlReader::DomParseException&) { return false; } pStep->finalize(Message::Success); if (pProgress != NULL) { pProgress->updateProgress("Finished loading the layer", 100, NORMAL); } // Add the layer to the view pView->addLayer(pLayer); pView->setActiveLayer(pLayer); pView->setMouseMode("LayerMode"); if (pOutArgList != NULL) { // set the output arguments pOutArgList->setPlugInArgValue("Layer", pLayer); } return true; }
bool ModelExporter::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList) { Progress* pProgress = NULL; FileDescriptor* pFileDescriptor = NULL; DataElement* pElement = NULL; StepResource pStep("Export model element", "app", "2BF48AAB-4832-4694-8583-882A8D584E97"); // get input arguments and log some useful info about them { // scope the MessageResource MessageResource pMsg("Input arguments", "app", "1B02F950-2E04-4BEF-8561-BB8D993340F7"); pProgress = pInArgList->getPlugInArgValue<Progress>(Executable::ProgressArg()); pMsg->addBooleanProperty("Progress Present", (pProgress != NULL)); pFileDescriptor = pInArgList->getPlugInArgValue<FileDescriptor>(Exporter::ExportDescriptorArg()); if (pFileDescriptor == NULL) { if (pProgress != NULL) { pProgress->updateProgress("No file specified", 100, ERRORS); } pStep->finalize(Message::Failure, "No file specified"); return false; } pMsg->addProperty("Destination", pFileDescriptor->getFilename()); pElement = pInArgList->getPlugInArgValueUnsafe<DataElement>(Exporter::ExportItemArg()); if (pElement == NULL) { if (pProgress != NULL) { pProgress->updateProgress("No model element specified", 100, ERRORS); } pStep->finalize(Message::Failure, "No model element specified"); return false; } pMsg->addProperty("Name", pElement->getName()); } if (pProgress != NULL) { pProgress->updateProgress("Open output file", 10, NORMAL); } FILE* pFile = fopen(pFileDescriptor->getFilename().getFullPathAndName().c_str(), "w"); if (pFile == NULL) { if (pProgress != NULL) { pProgress->updateProgress("File can not be created", 100, ERRORS); } pStep->finalize(Message::Failure, "File can not be created"); return false; } DataDescriptor* pElementDescriptor = pElement->getDataDescriptor(); VERIFY(pElementDescriptor != NULL); if (pProgress != NULL) { pProgress->updateProgress("Save element", 20, NORMAL); } string elementName = pElementDescriptor->getType(); XMLWriter xml(elementName.c_str(), Service<MessageLogMgr>()->getLog()); if (!pElement->toXml(&xml)) { if (pProgress != NULL) { pProgress->updateProgress("Error saving model element", 100, ERRORS); } pStep->finalize(Message::Failure, "Error saving model element"); return false; } else { xml.writeToFile(pFile); } fclose(pFile); if (pProgress != NULL) { pProgress->updateProgress("Finished saving the model element", 100, NORMAL); } pStep->finalize(Message::Success); return true; }
bool SaveLayer::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList) { StepResource pStep("Execute Wizard Item", "app", "DCBBB270-9360-4c96-8CE9-A9D414FC68EE"); pStep->addProperty("Item", getName()); mpStep = pStep.get(); if (!extractInputArgs(pInArgList)) { reportError("Unable to extract input arguments.", "CE17C3AD-05BD-4624-A9AD-9694430E1A6C"); return false; } // Check for valid input values string filename = ""; if (mpOutputFilename != NULL) { filename = mpOutputFilename->getFullPathAndName(); } if (filename.empty()) { reportError("The filename input value is invalid!", "2682BD10-8A8E-4aed-B2D8-7F7B4CC857A4"); return false; } if (mpStep != NULL) { mpStep->addProperty("filename", filename); } if (mpElement == NULL) { reportError("The data element input value is invalid!", "CC2017C8-FB19-43c0-B1C6-C70625BFE611"); return false; } DataElement* pParent = mpElement->getParent(); if (mpStep != NULL) { if (pParent != NULL) { mpStep->addProperty("dataSet", pParent->getName()); } else { mpStep->addProperty("dataSet", mpElement->getName()); } } // Get the Layer Layer* pLayer = NULL; vector<Window*> windows; Service<DesktopServices> pDesktop; VERIFY(pDesktop.get() != NULL); pDesktop->getWindows(SPATIAL_DATA_WINDOW, windows); for (vector<Window*>::iterator iter = windows.begin(); iter != windows.end(); ++iter) { SpatialDataWindow* pWindow = static_cast<SpatialDataWindow*>(*iter); if (pWindow != NULL) { SpatialDataView* pCurrentView = pWindow->getSpatialDataView(); if (pCurrentView != NULL) { LayerList* pLayerList = pCurrentView->getLayerList(); if (pLayerList != NULL) { vector<Layer*> layers; pLayerList->getLayers(layers); vector<Layer*>::iterator layerIter; for (layerIter = layers.begin(); layerIter != layers.end(); ++layerIter) { Layer* pCurrentLayer = *layerIter; if (pCurrentLayer != NULL) { if (pCurrentLayer->getDataElement() == mpElement) { pLayer = pCurrentLayer; break; } } } } } } } if (pLayer == NULL) { reportError("Could not get the layer to save!", "37EBD88F-9752-4b52-8A8A-F1BD9A98E608"); return false; } // Get the layer type LayerType eType = getLayerType(); // Save the layer FactoryResource<FileDescriptor> pFileDescriptor; VERIFY(pFileDescriptor.get() != NULL); pFileDescriptor->setFilename(filename); ExporterResource exporter("Layer Exporter", pLayer, pFileDescriptor.get()); VERIFY(exporter->getPlugIn() != NULL); bool bSaved = exporter->execute(); if (!bSaved) { reportError("Could not save the layer to the file: " + filename, "E2F6878E-E462-409b-AE8A-6E1555198316"); return false; } reportComplete(); return true; }
bool MetadataExporter::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList) { Progress* pProgress = NULL; FileDescriptor* pFileDescriptor = NULL; DataElement* pElement = NULL; StepResource pStep("Export metadata", "app", "{08701b89-565c-4e0a-92ef-9bf22395f902}"); // get input arguments and log some useful info about them { // scope the MessageResource MessageResource pMsg("Input arguments", "app", "{5e921da0-6470-44f1-a910-ed12af1e5ebc}"); pProgress = pInArgList->getPlugInArgValue<Progress>(Executable::ProgressArg()); pMsg->addBooleanProperty("Progress Present", (pProgress != NULL)); pFileDescriptor = pInArgList->getPlugInArgValue<FileDescriptor>(Exporter::ExportDescriptorArg()); if (pFileDescriptor == NULL) { if (pProgress != NULL) { pProgress->updateProgress("No file specified", 100, ERRORS); } pStep->finalize(Message::Failure, "No file specified"); return false; } pMsg->addProperty("Destination", pFileDescriptor->getFilename()); pElement = pInArgList->getPlugInArgValue<DataElement>(Exporter::ExportItemArg()); if (pElement == NULL) { if (pProgress != NULL) { pProgress->updateProgress("No data element specified", 100, ERRORS); } pStep->finalize(Message::Failure, "No data element specified"); return false; } pMsg->addProperty("Name", pElement->getName()); } if (pProgress != NULL) { pProgress->updateProgress("Open output file", 10, NORMAL); } FILE* pFile = fopen(pFileDescriptor->getFilename().getFullPathAndName().c_str(), "w"); if (pFile == NULL) { if (pProgress != NULL) { pProgress->updateProgress("File can not be created", 100, ERRORS); } pStep->finalize(Message::Failure, "File can not be created"); return false; } const DynamicObject* pMetadata = pElement->getMetadata(); VERIFY(pMetadata); if (pProgress != NULL) { pProgress->updateProgress("Save metadata", 20, NORMAL); } if (pMetadata->getNumAttributes() == 0) { if (pProgress != NULL) { pProgress->updateProgress("Metadata is empty. A file will be created anyway.", 20, WARNING); } pStep->addMessage("Metadata is empty. A file will be created anyway.", "app", "{29274eb3-c899-4778-ae1e-d267ea0dd346}", true); } XMLWriter xml("Metadata", Service<MessageLogMgr>()->getLog()); xml.pushAddPoint(NULL); if (!pMetadata->toXml(&xml)) { if (pProgress != NULL) { pProgress->updateProgress("Error saving metadata", 100, ERRORS); } pStep->finalize(Message::Failure, "Error saving metadata"); return false; } xml.popAddPoint(); xml.writeToFile(pFile); fclose(pFile); if (pProgress != NULL) { pProgress->updateProgress("Finished saving the metadata", 100, NORMAL); } pStep->finalize(Message::Success); return true; }
FrmBM::FrmBM(const RasterDataDescriptor* pDescriptor, const vector<RasterElement*>& cubeList, QWidget* parent) : QDialog(parent), mpDescriptor(pDescriptor) { setWindowTitle("Band Math"); setModal(true); // Units QGroupBox* pUnitsGroup = new QGroupBox(this); bgUnits = new QButtonGroup(pUnitsGroup); rbDegrees = new QRadioButton("Degrees", pUnitsGroup); rbRadians = new QRadioButton("Radians", pUnitsGroup); bgUnits->addButton(rbDegrees, 0); bgUnits->addButton(rbRadians, 1); QHBoxLayout* pUnitsLayout = new QHBoxLayout(pUnitsGroup); pUnitsLayout->setMargin(10); pUnitsLayout->setSpacing(5); pUnitsLayout->addWidget(rbDegrees); pUnitsLayout->addWidget(rbRadians); // Cube QGroupBox* pCubeGroup = new QGroupBox(this); bgCube = new QButtonGroup(pCubeGroup); rbBand = new QRadioButton("Single Cube", pCubeGroup); rbCube = new QRadioButton("Multi Cube", pCubeGroup); bgCube->addButton(rbBand, 0); bgCube->addButton(rbCube, 1); QHBoxLayout* pCubeLayout = new QHBoxLayout(pCubeGroup); pCubeLayout->setMargin(10); pCubeLayout->setSpacing(5); pCubeLayout->addWidget(rbBand); pCubeLayout->addWidget(rbCube); QHBoxLayout* pRadioLayout = new QHBoxLayout(); pRadioLayout->setMargin(0); pRadioLayout->setSpacing(10); pRadioLayout->addWidget(pUnitsGroup); pRadioLayout->addWidget(pCubeGroup); // Operators QGroupBox* pOperatorsGroup = new QGroupBox("Operators", this); bgOperators = new QButtonGroup(pOperatorsGroup); btnPlus = new QPushButton("+", pOperatorsGroup); btnPlus->setFixedSize(40, 40); bgOperators->addButton(btnPlus, 1); btnMinus = new QPushButton("-", pOperatorsGroup); btnMinus->setFixedSize(40, 40); bgOperators->addButton(btnMinus, 2); btnMultiply = new QPushButton("*", pOperatorsGroup); btnMultiply->setFixedSize(40, 40); bgOperators->addButton(btnMultiply, 3); btnDivide = new QPushButton("/", pOperatorsGroup); btnDivide->setFixedSize(40, 40); bgOperators->addButton(btnDivide, 4); btnPower = new QPushButton("^", pOperatorsGroup); btnPower->setFixedSize(40, 40); bgOperators->addButton(btnPower, 5); btnSqrt = new QPushButton("sqrt", pOperatorsGroup); btnSqrt->setFixedSize(40, 40); bgOperators->addButton(btnSqrt, 6); btnSin = new QPushButton("sin", pOperatorsGroup); btnSin->setFixedSize(40, 40); bgOperators->addButton(btnSin, 7); btnCos = new QPushButton("cos", pOperatorsGroup); btnCos->setFixedSize(40, 40); bgOperators->addButton(btnCos, 8); btnTan = new QPushButton("tan", pOperatorsGroup); btnTan->setFixedSize(40, 40); bgOperators->addButton(btnTan, 9); btnSec = new QPushButton("sec", pOperatorsGroup); btnSec->setFixedSize(40, 40); bgOperators->addButton(btnSec, 10); btnCsc = new QPushButton("csc", pOperatorsGroup); btnCsc->setFixedSize(40, 40); bgOperators->addButton(btnCsc, 11); btnCotan = new QPushButton("cot", pOperatorsGroup); btnCotan->setFixedSize(40, 40); bgOperators->addButton(btnCotan, 12); btnAsin = new QPushButton("asin", pOperatorsGroup); btnAsin->setFixedSize(40, 40); bgOperators->addButton(btnAsin, 13); btnAcos = new QPushButton("acos", pOperatorsGroup); btnAcos->setFixedSize(40, 40); bgOperators->addButton(btnAcos, 14); btnAtan = new QPushButton("atan", pOperatorsGroup); btnAtan->setFixedSize(40, 40); bgOperators->addButton(btnAtan, 15); btnAsec = new QPushButton("asec", pOperatorsGroup); btnAsec->setFixedSize(40, 40); bgOperators->addButton(btnAsec, 16); btnAcsc = new QPushButton("acsc", pOperatorsGroup); btnAcsc->setFixedSize(40, 40); bgOperators->addButton(btnAcsc, 17); btnAcotan = new QPushButton("acot", pOperatorsGroup); btnAcotan->setFixedSize(40, 40); bgOperators->addButton(btnAcotan, 18); btnSinh = new QPushButton("sinh", pOperatorsGroup); btnSinh->setFixedSize(40, 40); bgOperators->addButton(btnSinh, 19); btnCosh = new QPushButton("cosh", pOperatorsGroup); btnCosh->setFixedSize(40, 40); bgOperators->addButton(btnCosh, 20); btnTanh = new QPushButton("tanh", pOperatorsGroup); btnTanh->setFixedSize(40, 40); bgOperators->addButton(btnTanh, 21); btnSech = new QPushButton("sech", pOperatorsGroup); btnSech->setFixedSize(40, 40); bgOperators->addButton(btnSech, 22); btnCsch = new QPushButton("csch", pOperatorsGroup); btnCsch->setFixedSize(40, 40); bgOperators->addButton(btnCsch, 23); btnCotanh = new QPushButton("coth", pOperatorsGroup); btnCotanh->setFixedSize(40, 40); bgOperators->addButton(btnCotanh, 24); btnLog = new QPushButton("log", pOperatorsGroup); btnLog->setFixedSize(40, 40); bgOperators->addButton(btnLog, 25); btnLog2 = new QPushButton("log2", pOperatorsGroup); btnLog2->setFixedSize(40, 40); bgOperators->addButton(btnLog2, 26); btnLog10 = new QPushButton("log10", pOperatorsGroup); btnLog10->setFixedSize(40, 40); bgOperators->addButton(btnLog10, 27); btnExp = new QPushButton("exp", pOperatorsGroup); btnExp->setFixedSize(40, 40); bgOperators->addButton(btnExp, 28); btnAbs = new QPushButton("abs", pOperatorsGroup); btnAbs->setFixedSize(40, 40); bgOperators->addButton(btnAbs, 29); btnRand = new QPushButton("rand", pOperatorsGroup); btnRand->setFixedSize(40, 40); bgOperators->addButton(btnRand, 30); btnRand->hide(); btnInParen = new QPushButton("( )", pOperatorsGroup); btnInParen->setFixedSize(40, 40); bgOperators->addButton(btnInParen, 31); btnOutParen = new QPushButton("( ) ->", pOperatorsGroup); btnOutParen->setFixedSize(40, 40); bgOperators->addButton(btnOutParen, 32); QGridLayout* pOperatorGrid = new QGridLayout(pOperatorsGroup); pOperatorGrid->setMargin(15); pOperatorGrid->setSpacing(5); pOperatorGrid->addWidget(btnPlus, 0, 0); pOperatorGrid->addWidget(btnMinus, 0, 1); pOperatorGrid->addWidget(btnMultiply, 0, 2); pOperatorGrid->addWidget(btnDivide, 0, 3); pOperatorGrid->addWidget(btnPower, 0, 4); pOperatorGrid->addWidget(btnSqrt, 0, 5); pOperatorGrid->addWidget(btnSin, 1, 0); pOperatorGrid->addWidget(btnCos, 1, 1); pOperatorGrid->addWidget(btnTan, 1, 2); pOperatorGrid->addWidget(btnSec, 1, 3); pOperatorGrid->addWidget(btnCsc, 1, 4); pOperatorGrid->addWidget(btnCotan, 1, 5); pOperatorGrid->addWidget(btnAsin, 2, 0); pOperatorGrid->addWidget(btnAcos, 2, 1); pOperatorGrid->addWidget(btnAtan, 2, 2); pOperatorGrid->addWidget(btnAsec, 2, 3); pOperatorGrid->addWidget(btnAcsc, 2, 4); pOperatorGrid->addWidget(btnAcotan, 2, 5); pOperatorGrid->addWidget(btnSinh, 3, 0); pOperatorGrid->addWidget(btnCosh, 3, 1); pOperatorGrid->addWidget(btnTanh, 3, 2); pOperatorGrid->addWidget(btnSech, 3, 3); pOperatorGrid->addWidget(btnCsch, 3, 4); pOperatorGrid->addWidget(btnCotanh, 3, 5); pOperatorGrid->addWidget(btnLog, 4, 0); pOperatorGrid->addWidget(btnLog2, 4, 1); pOperatorGrid->addWidget(btnLog10, 4, 2); pOperatorGrid->addWidget(btnExp, 4, 3); pOperatorGrid->addWidget(btnAbs, 4, 4); pOperatorGrid->addWidget(btnRand, 4, 5); pOperatorGrid->addWidget(btnInParen, 5, 2); pOperatorGrid->addWidget(btnOutParen, 5, 3); // Numbers QGroupBox* pNumbersGroup = new QGroupBox("Numbers", this); bgNumbers = new QButtonGroup(pNumbersGroup); btn1 = new QPushButton("1", pNumbersGroup); btn1->setFixedSize(40, 40); bgNumbers->addButton(btn1, 1); btn2 = new QPushButton("2", pNumbersGroup); btn2->setFixedSize(40, 40); bgNumbers->addButton(btn2, 2); btn3 = new QPushButton("3", pNumbersGroup); btn3->setFixedSize(40, 40); bgNumbers->addButton(btn3, 3); btn4 = new QPushButton("4", pNumbersGroup); btn4->setFixedSize(40, 40); bgNumbers->addButton(btn4, 4); btn5 = new QPushButton("5", pNumbersGroup); btn5->setFixedSize(40, 40); bgNumbers->addButton(btn5, 5); btn6 = new QPushButton("6", pNumbersGroup); btn6->setFixedSize(40, 40); bgNumbers->addButton(btn6, 6); btn7 = new QPushButton("7", pNumbersGroup); btn7->setFixedSize(40, 40); bgNumbers->addButton(btn7, 7); btn8 = new QPushButton("8", pNumbersGroup); btn8->setFixedSize(40, 40); bgNumbers->addButton(btn8, 8); btn9 = new QPushButton("9", pNumbersGroup); btn9->setFixedSize(40, 40); bgNumbers->addButton(btn9, 9); btnPI = new QPushButton("p", pNumbersGroup); btnPI->setFixedSize(40, 40); QFont ftPiButton("symbol", 12); // Lower case first letter for Unix support btnPI->setFont(ftPiButton); bgNumbers->addButton(btnPI, 11); btn0 = new QPushButton("0", pNumbersGroup); btn0->setFixedSize(40, 40); bgNumbers->addButton(btn0, 0); btnE = new QPushButton("e", pNumbersGroup); btnE->setFixedSize(40, 40); bgNumbers->addButton(btnE, 12); btnDecimal = new QPushButton(".", pNumbersGroup); btnDecimal->setFixedSize(40, 40); bgNumbers->addButton(btnDecimal, 10); QGridLayout* pNumbersGrid = new QGridLayout(pNumbersGroup); pNumbersGrid->setMargin(15); pNumbersGrid->setSpacing(5); pNumbersGrid->addWidget(btn1, 0, 0); pNumbersGrid->addWidget(btn2, 0, 1); pNumbersGrid->addWidget(btn3, 0, 2); pNumbersGrid->addWidget(btn4, 1, 0); pNumbersGrid->addWidget(btn5, 1, 1); pNumbersGrid->addWidget(btn6, 1, 2); pNumbersGrid->addWidget(btn7, 2, 0); pNumbersGrid->addWidget(btn8, 2, 1); pNumbersGrid->addWidget(btn9, 2, 2); pNumbersGrid->addWidget(btnPI, 3, 0); pNumbersGrid->addWidget(btn0, 3, 1); pNumbersGrid->addWidget(btnE, 3, 2); pNumbersGrid->addWidget(btnDecimal, 4, 1); // Bands mpBandsLabel = new QLabel(this); lisBands = new QListWidget(this); lisBands->setMinimumWidth(150); QVBoxLayout* pBandsLayout = new QVBoxLayout(); pBandsLayout->setMargin(0); pBandsLayout->setSpacing(5); pBandsLayout->addWidget(mpBandsLabel); pBandsLayout->addWidget(lisBands, 10); // Expression txtExpression = new QTextEdit(this); txtExpression->setReadOnly(true); txtExpression->setWordWrapMode(QTextOption::WrapAnywhere); QFont txtExpression_font(txtExpression->font()); txtExpression_font.setBold(true); txtExpression->setFont(txtExpression_font); // Horizontal line QFrame* pLine = new QFrame(this); pLine->setFrameStyle(QFrame::HLine | QFrame::Sunken); // Buttons btnClear = new QPushButton("C&lear", this); btnUndo = new QPushButton("&Undo", this); btnProcess = new QPushButton("&Process", this); QPushButton* btnCancel = new QPushButton("&Cancel", this); cbResults = new QCheckBox("Overlay Results", this); QHBoxLayout* pButtonLayout = new QHBoxLayout(); pButtonLayout->setMargin(0); pButtonLayout->setSpacing(6); pButtonLayout->addWidget(btnClear); pButtonLayout->addWidget(btnUndo); pButtonLayout->addStretch(10); pButtonLayout->addWidget(cbResults); pButtonLayout->addWidget(btnProcess); pButtonLayout->addWidget(btnCancel); // Layout QGridLayout* pGrid = new QGridLayout(this); pGrid->setMargin(10); pGrid->setSpacing(10); pGrid->addLayout(pRadioLayout, 0, 0, 1, 2); pGrid->addWidget(pOperatorsGroup, 1, 0); pGrid->addWidget(pNumbersGroup, 1, 1); pGrid->addLayout(pBandsLayout, 0, 2, 3, 1); pGrid->addWidget(txtExpression, 2, 0, 1, 2); pGrid->addWidget(pLine, 3, 0, 1, 3); pGrid->addLayout(pButtonLayout, 4, 0, 1, 3); pGrid->setRowStretch(2, 10); pGrid->setColumnStretch(2, 10); // Connections connect(bgCube, SIGNAL(buttonClicked(int)), this, SLOT(setCubeList(int))); connect(bgOperators, SIGNAL(buttonClicked(int)), this, SLOT(addOperator(int))); connect(bgNumbers, SIGNAL(buttonClicked(int)), this, SLOT(addNumber(int))); connect(lisBands, SIGNAL(itemDoubleClicked(QListWidgetItem*)), this, SLOT(addBand())); connect(btnClear, SIGNAL(clicked()), this, SLOT(clear())); connect(btnUndo, SIGNAL(clicked()), this, SLOT(undo())); connect(btnProcess, SIGNAL(clicked()), this, SLOT(accept())); connect(btnCancel, SIGNAL(clicked()), this, SLOT(reject())); const DynamicObject* pMetadata = pDescriptor->getMetadata(); const vector<double>* pCenterWavelengths = NULL; if (pMetadata != NULL) { string pCenterPath[] = { SPECIAL_METADATA_NAME, BAND_METADATA_NAME, CENTER_WAVELENGTHS_METADATA_NAME, END_METADATA_NAME }; pCenterWavelengths = dv_cast<vector<double> >(&pMetadata->getAttributeByPath(pCenterPath)); } vector<string> bandNames = RasterUtilities::getBandNames(pDescriptor); // Initialize for (vector<string>::size_type counter = 0; counter < bandNames.size(); ++counter) { string bandName = bandNames[counter]; QString strBandInfo; if (pCenterWavelengths != NULL) { double dWavelength = 0; if (counter < pCenterWavelengths->size()) { dWavelength = (*pCenterWavelengths)[counter]; } // Set the list box string strBandInfo = QString::fromStdString(bandName) + QString(" %1").arg(dWavelength); } else { strBandInfo = QString::fromStdString(bandName); } mBandList.append(strBandInfo); } for (unsigned int i = 0; i < cubeList.size(); i++) { DataElement* pElement = cubeList[i]; if (pElement != NULL) { // Set the list box string QString strCubeInfo; strCubeInfo.sprintf("Cube %-6d %s", i + 1, pElement->getName().c_str()); if (strCubeInfo.isEmpty() == false) { mCubeList.append(strCubeInfo); } } } clear(); lisBands->clear(); rbRadians->setChecked(true); rbBand->setChecked(true); setCubeList(0); resize(minimumSize()); }