int setThresholdLayerInfo(Layer* pLayer, struct ThresholdLayerInfo* pInfo) { ThresholdLayer* pThresh = dynamic_cast<ThresholdLayer*>(pLayer); if (pThresh == NULL || pInfo == NULL) { setLastError(SIMPLE_BAD_PARAMS); return 1; } switch(pInfo->passArea) { case 0: pThresh->setPassArea(LOWER); break; case 1: pThresh->setPassArea(UPPER); break; case 2: pThresh->setPassArea(MIDDLE); break; case 3: pThresh->setPassArea(OUTSIDE); break; default: setLastError(SIMPLE_BAD_PARAMS); return 1; } switch(pInfo->regionUnits) { case 0: pThresh->setRegionUnits(RAW_VALUE); break; case 1: pThresh->setRegionUnits(PERCENTAGE); break; case 2: pThresh->setRegionUnits(PERCENTILE); break; case 3: pThresh->setRegionUnits(STD_DEV); break; default: setLastError(SIMPLE_BAD_PARAMS); return 1; } // convert the thresholds to raw from the specified units pThresh->setFirstThreshold(pThresh->convertThreshold(pInfo->firstThreshold, RAW_VALUE)); pThresh->setSecondThreshold(pThresh->convertThreshold(pInfo->secondThreshold, RAW_VALUE)); setLastError(SIMPLE_NO_ERROR); return 0; }
void SetThresholdUnits::executeRedo() { ThresholdLayer* pLayer = dynamic_cast<ThresholdLayer*>(getSessionItem()); if (pLayer != NULL) { pLayer->setRegionUnits(mNewUnits); } }
void ThresholdLayerMemento::toLayer(Layer* pLayer) const { ThresholdLayer* pThresholdLayer = dynamic_cast<ThresholdLayer*>(pLayer); if (pThresholdLayer != NULL) { pThresholdLayer->setFirstThreshold(mLowerThreshold); pThresholdLayer->setSecondThreshold(mUpperThreshold); pThresholdLayer->setPassArea(mPassArea); pThresholdLayer->setRegionUnits(mUnits); pThresholdLayer->setColor(mColor); pThresholdLayer->setSymbol(mSymbol); } }
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); }