本文整理汇总了C++中DataElement::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ DataElement::getName方法的具体用法?C++ DataElement::getName怎么用?C++ DataElement::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DataElement
的用法示例。
在下文中一共展示了DataElement::getName方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
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;
}
示例2: queryZDNames
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;
}
示例3: VERIFYNR
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());
}
}
}
示例4: threshold
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
//.........这里部分代码省略.........
示例5: execute
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);
}
//.........这里部分代码省略.........
示例6: writeOutput
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;
//.........这里部分代码省略.........
示例7: execute
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;
//.........这里部分代码省略.........
示例8: get_data_name
/**
* 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()));
}
示例9: execute
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);
}
//.........这里部分代码省略.........
示例10: execute
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;
}
示例11: ftPiButton
//.........这里部分代码省略.........
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());
}