Пример #1
0
void SetThresholdColor::executeRedo()
{
   ThresholdLayer* pLayer = dynamic_cast<ThresholdLayer*>(getSessionItem());
   if (pLayer != NULL)
   {
      pLayer->setColor(mNewColor);
   }
}
Пример #2
0
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);
   }
}
Пример #3
0
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);
}