本文整理汇总了C++中LayerList::getLayers方法的典型用法代码示例。如果您正苦于以下问题:C++ LayerList::getLayers方法的具体用法?C++ LayerList::getLayers怎么用?C++ LayerList::getLayers使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LayerList
的用法示例。
在下文中一共展示了LayerList::getLayers方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: VERIFYNR
void GetLayer<T>::populateTreeWidgetItemWithLayers(QTreeWidgetItem* pRoot)
{
VERIFYNR(pRoot != NULL);
QVariant value = pRoot->data(GetSessionItemBase<T>::NameColumn, GetSessionItemBase<T>::SessionItemRole);
void* pValue = value.value<void*>();
View* const pView = reinterpret_cast<View*>(pValue);
VERIFYNR(pView != NULL);
std::vector<Layer*> layers;
SpatialDataView* pSpatialDataView = dynamic_cast<SpatialDataView*>(pView);
if (pSpatialDataView != NULL)
{
LayerList* pLayerList = pSpatialDataView->getLayerList();
if (pLayerList != NULL)
{
pLayerList->getLayers(layers);
}
}
ProductView* pProductView = dynamic_cast<ProductView*>(pView);
if (pProductView != NULL)
{
layers.push_back(pProductView->getLayoutLayer());
layers.push_back(pProductView->getClassificationLayer());
}
PlotView* pPlotView = dynamic_cast<PlotView*>(pView);
if (pPlotView != NULL)
{
layers.push_back(pPlotView->getAnnotationLayer());
}
// Add the layer items in reverse order so that the top-most layer is added first
for (std::vector<Layer*>::reverse_iterator iter = layers.rbegin(); iter != layers.rend(); ++iter)
{
Layer* pLayer = *iter;
if (pLayer == NULL || pLayer->isKindOf(TypeConverter::toString<T>()) == false)
{
continue;
}
QTreeWidgetItem* pChild = new QTreeWidgetItem;
std::string name = pLayer->getDisplayName();
if (name.empty() == true)
{
name = pLayer->getName();
}
pChild->setText(GetSessionItemBase<T>::NameColumn, QString::fromStdString(name));
pChild->setData(GetSessionItemBase<T>::NameColumn,
GetSessionItemBase<T>::SessionItemRole, QVariant::fromValue<void*>(pLayer));
pChild->setText(GetSessionItemBase<T>::TypeColumn, QString::fromStdString(StringUtilities::toDisplayString(pLayer->getLayerType())));
pChild->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable);
pRoot->addChild(pChild);
}
}
示例2: createOverview
SpatialDataViewImp* OverviewWindow::createOverview()
{
SpatialDataViewImp* pOverview = NULL;
if (mpView != NULL)
{
pOverview = dynamic_cast<SpatialDataViewImp*>(mpView->copy());
VERIFYRV(pOverview != NULL, NULL);
pOverview->installEventFilter(this);
LayerList* pLayerList = NULL;
pLayerList = pOverview->getLayerList();
if (pLayerList != NULL)
{
// get primary raster layer from data view
LayerList* pSDVlist = mpView->getLayerList();
VERIFYRV(pSDVlist != NULL, NULL);
DataElement* pPrimElem = pSDVlist->getPrimaryRasterElement();
VERIFYRV(pPrimElem != NULL, NULL);
Layer* pPrimLayer = pSDVlist->getLayer(RASTER, pPrimElem);
VERIFYRV(pPrimLayer != NULL, NULL);
string primName(pPrimLayer->getName());
vector<Layer*> layers;
pLayerList->getLayers(layers);
for (unsigned int i = 0; i < layers.size(); i++)
{
Layer* pLayer = NULL;
pLayer = layers.at(i);
string layerName(pLayer->getName());
if (pLayer->getLayerType()==RASTER && layerName==primName)
{
pPrimLayer->linkLayer(pLayer);
// reset the scale to what is in the model
DataElement* pElement = pLayer->getDataElement();
VERIFYRV(pElement != NULL, NULL);
const RasterDataDescriptor* pDescriptor =
dynamic_cast<const RasterDataDescriptor*>(pElement->getDataDescriptor());
VERIFYRV(pDescriptor != NULL, NULL);
pLayer->setYScaleFactor(pDescriptor->getYPixelSize());
pLayer->setXScaleFactor(pDescriptor->getXPixelSize());
}
else
{
pOverview->deleteLayer(pLayer);
}
}
pOverview->resetOrientation();
}
}
return pOverview;
}
示例3: layerListDeleted
void FusionLayersSelectPage::layerListDeleted(Subject& subject, const string& signal, const boost::any& v)
{
LayerList* pLayerList = dynamic_cast<LayerList*>(&subject);
if (pLayerList != NULL)
{
vector<Layer*> pLayers;
pLayerList->getLayers(pLayers);
for (vector<Layer*>::iterator it = pLayers.begin(); it != pLayers.end(); ++it)
{
Layer* pLayer = *it;
if (pLayer != NULL)
{
pLayer->detach(SIGNAL_NAME(Subject, Deleted), Slot(this, &FusionLayersSelectPage::layerDeleted));
pLayer->detach(SIGNAL_NAME(Subject, Modified), Slot(this, &FusionLayersSelectPage::layerModified));
}
}
}
}
示例4: layerListModified
void FusionLayersSelectPage::layerListModified(Subject& subject, const string& signal, const boost::any& v)
{
LayerList* pLayerList = dynamic_cast<LayerList*>(&subject);
if (pLayerList != NULL)
{
vector<Layer*> layerListLayers;
pLayerList->getLayers(layerListLayers);
// for each layer list layer, check map. If not there, add it.
for (vector<Layer*>::iterator it = layerListLayers.begin(); it != layerListLayers.end(); ++it)
{
LayerMap::iterator found = mLayers.find(*it);
if (found == mLayers.end())
{
addLayerToGui(*it);
}
}
}
}
示例5: createChipView
SpatialDataView* ChippingWindow::createChipView() const
{
if (mpView == NULL)
{
return NULL;
}
SpatialDataView* pChipView = dynamic_cast<SpatialDataView*>(mpView->copy());
if (pChipView != NULL)
{
vector<std::pair<View*, LinkType> > linkedViews;
pChipView->getLinkedViews(linkedViews);
for (unsigned int i = 0; i < linkedViews.size(); ++i)
{
if (linkedViews[i].second == NO_LINK)
{
continue;
}
pChipView->unlinkView(linkedViews[i].first);
}
LayerList* pLayerList = pChipView->getLayerList();
if (pLayerList != NULL)
{
vector<Layer*> layers;
pLayerList->getLayers(layers);
for (unsigned int i = 0; i < layers.size(); i++)
{
Layer* pLayer = layers.at(i);
if (dynamic_cast<RasterLayer*>(pLayer) == NULL)
{
pChipView->deleteLayer(pLayer);
}
}
}
}
return pChipView;
}
示例6: execute
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);
//.........这里部分代码省略.........
示例7: execute
//.........这里部分代码省略.........
}
if (mpStep != NULL)
{
mpStep->addProperty("dataSet", mpRasterElement->getName());
}
if (mLayerName.empty())
{
reportError("The layer name input value is invalid!", "0DF331B8-05FF-4178-82D3-9A9CF2851DCF");
return false;
}
if (mpStep != NULL)
{
mpStep->addProperty("layerName", mLayerName);
}
// Get the view
SpatialDataView* pView = NULL;
vector<Window*> windows;
Service<DesktopServices> pDesktop;
if (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)
{
RasterElement* pRasterElement = pLayerList->getPrimaryRasterElement();
if (pRasterElement == mpRasterElement)
{
pView = pCurrentView;
break;
}
}
}
}
}
if (pView == NULL)
{
reportError("Could not get the view!", "830E3C55-561A-4c49-8269-06E1E04B1BFA");
return false;
}
// Get the spectral element
LayerType eType = getLayerType();
// Save the layer
bool bSaved = false;
LayerList* pLayerList = pView->getLayerList();
if (pLayerList != NULL)
{
std::vector<Layer*> layers;
pLayerList->getLayers(eType, layers);
Layer* pLayer = NULL;
for (std::vector<Layer*>::iterator it = layers.begin(); it != layers.end(); ++it)
{
if ((*it)->getName() == mLayerName)
{
pLayer = (*it);
break;
}
}
if (pLayer == NULL)
{
reportError("Could not get the layer to save!", "02F03D56-7CA8-4052-894D-BFDDFC3A814F");
return false;
}
FactoryResource<FileDescriptor> pFileDescriptor;
VERIFY(pFileDescriptor.get() != NULL);
pFileDescriptor->setFilename(filename);
std::string exporterName = StringUtilities::toDisplayString(eType) + " Layer Exporter";
ExporterResource exporter(exporterName, pLayer, pFileDescriptor.get());
VERIFY(exporter->getPlugIn() != NULL);
bSaved = exporter->execute();
}
if (!bSaved)
{
reportError("Could not save the layer to the file: " + filename, "CAFF2CD5-E6CB-4e90-80E7-87E094F2CB1C");
return false;
}
reportComplete();
return true;
}
示例8: displayPseudocolorResults
void AlgorithmPattern::displayPseudocolorResults(RasterElement* pRasterElement, std::vector<std::string>& sigNames,
Opticks::PixelOffset offset)
{
REQUIRE(pRasterElement != NULL);
SpatialDataView* pView = NULL;
vector<Window*> windows;
mpDesktopServices->getWindows(SPATIAL_DATA_WINDOW, windows);
for (unsigned int j = 0; j < windows.size() && pView == NULL; j++)
{
SpatialDataWindow* pWindow = static_cast<SpatialDataWindow*>(windows[j]);
if (pWindow != NULL)
{
SpatialDataView* pCurrentView = pWindow->getSpatialDataView();
if (pCurrentView != NULL)
{
LayerList* pLList = pCurrentView->getLayerList();
REQUIRE(pLList != NULL);
vector<Layer*> layers;
pLList->getLayers(RASTER, layers);
for (vector<Layer*>::const_iterator layer = layers.begin(); layer != layers.end(); ++layer)
{
if (*layer != NULL && static_cast<RasterElement*>((*layer)->getDataElement()) == getRasterElement())
{
pView = pCurrentView;
break;
}
}
}
}
}
REQUIRE(pView != NULL);
PseudocolorLayer* pLayer = NULL;
// Get or create a valid pseudocolor layer
LayerList* pLayerList = pView->getLayerList();
if (pLayerList != NULL)
{
pLayer = static_cast<PseudocolorLayer*>(pLayerList->getLayer(PSEUDOCOLOR, pRasterElement));
if (pLayer == NULL)
{
pLayer = static_cast<PseudocolorLayer*>(pView->createLayer(PSEUDOCOLOR, pRasterElement));
}
// Remove existing layers of other types
if (pLayer != NULL)
{
Layer* pThresholdLayer = pLayerList->getLayer(THRESHOLD, pRasterElement);
if (pThresholdLayer != NULL)
{
pView->deleteLayer(pThresholdLayer);
}
Layer* pRasterLayer = pLayerList->getLayer(RASTER, pRasterElement);
if (pRasterLayer != NULL)
{
pView->deleteLayer(pRasterLayer);
}
}
}
INVARIANT(pLayer != NULL);
UndoLock lock(pView);
int iSignatureCount = sigNames.size();
vector<ColorType> layerColors;
vector<ColorType> excludeColors;
excludeColors.push_back(ColorType(0, 0, 0));
excludeColors.push_back(ColorType(255, 255, 255));
// 1 for each sig + no sigs + multiple sigs
ColorType::getUniqueColors(iSignatureCount + 2, layerColors, excludeColors);
pLayer->clear();
for (int i = 0; i < iSignatureCount; i++)
{
pLayer->addInitializedClass(sigNames[i], i + 1, layerColors[i], true);
}
pLayer->addInitializedClass(std::string("Indeterminate"), -1, layerColors[iSignatureCount], true);
pLayer->addInitializedClass(std::string("No match"), 0, layerColors[iSignatureCount + 1], false);
pLayer->setXOffset(offset.mX);
pLayer->setYOffset(offset.mY);
}
示例9: displayThresholdResults
void AlgorithmPattern::displayThresholdResults(RasterElement* pRasterElement, ColorType color, PassArea passArea,
double firstThreshold, double secondThreshold,
Opticks::PixelOffset offset)
{
REQUIRE(pRasterElement != NULL);
SpatialDataView* pView = NULL;
vector<Window*> windows;
mpDesktopServices->getWindows(SPATIAL_DATA_WINDOW, windows);
for (unsigned int i = 0; i < windows.size() && pView == NULL; i++)
{
SpatialDataWindow* pWindow = static_cast<SpatialDataWindow*>(windows[i]);
if (pWindow != NULL)
{
SpatialDataView* pCurrentView = pWindow->getSpatialDataView();
if (pCurrentView != NULL)
{
LayerList* pLList = pCurrentView->getLayerList();
REQUIRE(pLList != NULL);
vector<Layer*> layers;
pLList->getLayers(RASTER, layers);
for (vector<Layer*>::const_iterator layer = layers.begin(); layer != layers.end(); ++layer)
{
if (*layer != NULL && static_cast<RasterElement*>((*layer)->getDataElement()) == getRasterElement())
{
pView = pCurrentView;
break;
}
}
}
}
}
REQUIRE(pView != NULL);
ThresholdLayer* pLayer = NULL;
// Get or create a valid threshold layer
LayerList* pLayerList = pView->getLayerList();
if (pLayerList != NULL)
{
pLayer = static_cast<ThresholdLayer*>(pLayerList->getLayer(THRESHOLD, pRasterElement));
if (pLayer == NULL)
{
pLayer = static_cast<ThresholdLayer*>(pView->createLayer(THRESHOLD, pRasterElement));
}
// Remove existing layers of other types
if (pLayer != NULL)
{
Layer* pRasterLayer = pLayerList->getLayer(RASTER, pRasterElement);
if (pRasterLayer != NULL)
{
pView->deleteLayer(pRasterLayer);
}
Layer* pPseudocolorLayer = pLayerList->getLayer(PSEUDOCOLOR, pRasterElement);
if (pPseudocolorLayer != NULL)
{
pView->deleteLayer(pPseudocolorLayer);
}
}
}
INVARIANT(pLayer != NULL);
UndoLock lock(pView);
if (color.isValid())
{
pLayer->setColor(color);
}
pLayer->setRegionUnits(RAW_VALUE);
pLayer->setPassArea(passArea);
pLayer->setFirstThreshold(firstThreshold);
pLayer->setSecondThreshold(secondThreshold);
pLayer->setXOffset(offset.mX);
pLayer->setYOffset(offset.mY);
}
示例10: getLayer
Layer* getLayer(const char* pName, const char* pType)
{
Layer* pLayer = NULL;
const std::string name(pName == NULL ? std::string() : pName);
const std::string type(pType == NULL ? std::string() : pType);
SessionItem* pSessionItem = Service<SessionManager>()->getSessionItem(name);
if (pSessionItem != NULL)
{
pLayer = dynamic_cast<Layer*>(pSessionItem);
if (pLayer == NULL || (!type.empty() && !pLayer->isKindOf(type)))
{
setLastError(SIMPLE_WRONG_TYPE);
return NULL;
}
}
else
{
std::vector<std::string> id = splitIdentifier(name);
SpatialDataView* pView = static_cast<SpatialDataView*>(getView(id.size() == 0 ? NULL : id.front().c_str(),
TypeConverter::toString<SpatialDataView>()));
LayerList* pLayerList = (pView == NULL) ? NULL : pView->getLayerList();
if (pLayerList == NULL)
{
setLastError(SIMPLE_NOT_FOUND);
return NULL;
}
if (id.size() < 2)
{
if (!type.empty() && type == TypeConverter::toString<RasterLayer>())
{
pLayer = pLayerList->getLayer(RASTER, pLayerList->getPrimaryRasterElement());
}
else
{
pLayer = pView->getActiveLayer();
if (pLayer != NULL && !type.empty() && !pLayer->isKindOf(type))
{
pLayer = NULL;
}
if (pLayer == NULL)
{
if (type.empty())
{
pLayer = pView->getTopMostLayer();
}
else
{
pLayer = pView->getTopMostLayer(StringUtilities::fromDisplayString<LayerType>(type));
}
}
}
}
if (pLayer == NULL)
{
std::vector<Layer*> layers;
pLayerList->getLayers(layers);
for (std::vector<Layer*>::reverse_iterator layer = layers.rbegin();
layer != layers.rend();
++layer)
{
if ((type.empty() || (*layer)->isKindOf(type)) &&
(id.empty() || (*layer)->getName() == id.back() || (*layer)->getDisplayName() == id.back()))
{
pLayer = *layer;
break;
}
}
}
if (pLayer == NULL)
{
setLastError(SIMPLE_NOT_FOUND);
return NULL;
}
}
setLastError(SIMPLE_NO_ERROR);
return pLayer;
}
示例11: getView
View* getView(const char* pName, const char* pType)
{
View* pView = NULL;
const std::string name(pName == NULL ? std::string() : pName);
const std::string type(pType == NULL ? std::string() : pType);
SessionItem* pSessionItem = Service<SessionManager>()->getSessionItem(name);
if (pSessionItem != NULL)
{
pView = dynamic_cast<View*>(pSessionItem);
if (pView == NULL || (!type.empty() && !pView->isKindOf(type)))
{
setLastError(SIMPLE_WRONG_TYPE);
return NULL;
}
}
else
{
std::vector<std::string> id = splitIdentifier(name);
if (id.empty() || id.front().empty())
{
pView = Service<DesktopServices>()->getCurrentWorkspaceWindowView();
if (pView == NULL)
{
setLastError(SIMPLE_NOT_FOUND);
return NULL;
}
else
{
if (!type.empty() && !pView->isKindOf(type))
{
setLastError(SIMPLE_WRONG_TYPE);
return NULL;
}
}
}
else
{
std::vector<Window*> windows;
Service<DesktopServices>()->getWindows(windows);
for (std::vector<Window*>::iterator window = windows.begin(); window != windows.end(); ++window)
{
ViewWindow* pTmp = dynamic_cast<ViewWindow*>(*window);
View* pTmpView = pTmp == NULL ? NULL : pTmp->getView();
if (pTmpView != NULL && (pTmpView->getName() == id.front() || pTmpView->getDisplayName() == id.front()))
{
if (!type.empty() && !pTmpView->isKindOf(type))
{
setLastError(SIMPLE_WRONG_TYPE);
return NULL;
}
else
{
if (id.size() == 1)
{
pView = pTmpView;
}
else
{
SpatialDataView* pSpatialDataView = dynamic_cast<SpatialDataView*>(pTmpView);
if (pSpatialDataView != NULL)
{
LayerList* pLayerList = pSpatialDataView->getLayerList();
if (pLayerList != NULL)
{
std::vector<Layer*> layers;
pLayerList->getLayers(layers);
for (std::vector<Layer*>::iterator iter = layers.begin(); iter != layers.end(); ++iter)
{
Layer* pLayer = *iter;
if (pLayer != NULL &&
(pLayer->getName() == id.back() || pLayer->getDisplayName() == id.back()))
{
pView = pTmpView;
break;
}
}
}
}
}
}
break;
}
}
if (pView == NULL)
{
setLastError(SIMPLE_NOT_FOUND);
return NULL;
}
}
}
setLastError(SIMPLE_NO_ERROR);
return pView;
}