예제 #1
0
 int getThresholdLayerInfo(Layer* pLayer, struct ThresholdLayerInfo* pInfo)
 {
    ThresholdLayer* pThresh = dynamic_cast<ThresholdLayer*>(pLayer);
    if (pThresh == NULL || pInfo == NULL)
    {
       setLastError(SIMPLE_BAD_PARAMS);
       return 1;
    }
    // convert the threshold values to the current threshold region units
    pInfo->firstThreshold = pThresh->convertThreshold(RAW_VALUE,
       pThresh->getFirstThreshold(), pThresh->getRegionUnits());
    pInfo->secondThreshold = pThresh->convertThreshold(RAW_VALUE,
       pThresh->getSecondThreshold(), pThresh->getRegionUnits());
    switch(pThresh->getPassArea())
    {
    case LOWER:
       pInfo->passArea = 0;
       break;
    case UPPER:
       pInfo->passArea = 1;
       break;
    case MIDDLE:
       pInfo->passArea = 2;
       break;
    case OUTSIDE:
       pInfo->passArea = 3;
       break;
    default:
       setLastError(SIMPLE_OTHER_FAILURE);
       return 1;
    }
    switch(pThresh->getRegionUnits())
    {
    case RAW_VALUE:
       pInfo->regionUnits = 0;
       break;
    case PERCENTAGE:
       pInfo->regionUnits = 1;
       break;
    case PERCENTILE:
       pInfo->regionUnits = 2;
       break;
    case STD_DEV:
       pInfo->regionUnits = 3;
       break;
    default:
       setLastError(SIMPLE_OTHER_FAILURE);
       return 1;
    }
    setLastError(SIMPLE_NO_ERROR);
    return 0;
 }
예제 #2
0
QWidget* ResultsExporter::getExportOptionsWidget(const PlugInArgList *pInArgList)
{
    const DataDescriptor* pDescriptor = NULL;
    if (pInArgList != NULL)
    {
        RasterElement* pElement = pInArgList->getPlugInArgValue<RasterElement>(Exporter::ExportItemArg());
        if (pElement != NULL)
        {
            pDescriptor = pElement->getDataDescriptor();
        }
    }
    if (mpOptionsWidget == NULL)
    {
        Service<DesktopServices> pDesktop;
        VERIFY(pDesktop.get() != NULL);

        mpOptionsWidget = new ResultsOptionsWidget(pDesktop->getMainWidget());
    }

    if (mpOptionsWidget != NULL)
    {
        const string& name = pDescriptor->getName();
        const string& type = pDescriptor->getType();
        DataElement* pParent = pDescriptor->getParent();

        RasterElement* pResults = dynamic_cast<RasterElement*>(mpModel->getElement(name, type, pParent));
        if (pResults != NULL)
        {
            PassArea passArea = MIDDLE;
            double dFirstThreshold = 0.0;
            double dSecondThreshold = 0.0;

            SpatialDataWindow* pWindow = dynamic_cast<SpatialDataWindow*>(mpDesktop->getCurrentWorkspaceWindow());
            if (pWindow != NULL)
            {
                SpatialDataView* pView = pWindow->getSpatialDataView();
                if (pView != NULL)
                {
                    LayerList* pLayerList = pView->getLayerList();
                    if (pLayerList != NULL)
                    {
                        ThresholdLayer* pThresholdLayer =
                            static_cast<ThresholdLayer*>(pLayerList->getLayer(THRESHOLD, pResults));
                        if (pThresholdLayer != NULL)
                        {
                            passArea = pThresholdLayer->getPassArea();
                            dFirstThreshold = pThresholdLayer->getFirstThreshold();
                            dSecondThreshold = pThresholdLayer->getSecondThreshold();
                        }
                        else
                        {
                            Statistics* pStatistics = pResults->getStatistics();
                            if (pStatistics != NULL)
                            {
                                dFirstThreshold = pStatistics->getMin();
                                dSecondThreshold = pStatistics->getMax();
                            }
                        }
                    }

                    LatLonLayer* pLatLonLayer = static_cast<LatLonLayer*>(pView->getTopMostLayer(LAT_LONG));
                    if (pLatLonLayer != NULL)
                    {
                        GeocoordType geocoordType = pLatLonLayer->getGeocoordType();
                        mpOptionsWidget->setGeocoordType(geocoordType);
                    }
                }
            }

            mpOptionsWidget->setPassArea(passArea);
            mpOptionsWidget->setFirstThreshold(dFirstThreshold);
            mpOptionsWidget->setSecondThreshold(dSecondThreshold);
        }
    }

    return mpOptionsWidget;
}