void SetThresholdPassArea::executeRedo()
{
   ThresholdLayer* pLayer = dynamic_cast<ThresholdLayer*>(getSessionItem());
   if (pLayer != NULL)
   {
      pLayer->setPassArea(mNewPassArea);
   }
}
void SetThresholdColor::executeRedo()
{
   ThresholdLayer* pLayer = dynamic_cast<ThresholdLayer*>(getSessionItem());
   if (pLayer != NULL)
   {
      pLayer->setColor(mNewColor);
   }
}
void SetThresholdSymbol::executeRedo()
{
   ThresholdLayer* pLayer = dynamic_cast<ThresholdLayer*>(getSessionItem());
   if (pLayer != NULL)
   {
      pLayer->setSymbol(mNewSymbol);
   }
}
void SetThresholdUnits::executeRedo()
{
   ThresholdLayer* pLayer = dynamic_cast<ThresholdLayer*>(getSessionItem());
   if (pLayer != NULL)
   {
      pLayer->setRegionUnits(mNewUnits);
   }
}
void SetThresholdValues::executeRedo()
{
   ThresholdLayer* pLayer = dynamic_cast<ThresholdLayer*>(getSessionItem());
   if (pLayer != NULL)
   {
      if (pLayer->getFirstThreshold() != mNewLowerThreshold)
      {
         pLayer->setFirstThreshold(mNewLowerThreshold);
      }

      if (pLayer->getSecondThreshold() != mNewUpperThreshold)
      {
         pLayer->setSecondThreshold(mNewUpperThreshold);
      }
   }
}
Exemple #6
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;
 }
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);
   }
}
Exemple #8
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;
}
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);
}
Exemple #10
0
   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;
   }
Exemple #11
0
void TimelineWidget::sessionItemDropped(Subject &subject, const std::string &signal, const boost::any &v)
{
   SessionItem *pItem = boost::any_cast<SessionItem*>(v);
   if(pItem == NULL)
   {
      return;
   }
   RasterElement *pRasterElement = dynamic_cast<RasterElement*>(pItem);
   RasterLayer *pRasterLayer = dynamic_cast<RasterLayer*>(pItem);
   ThresholdLayer *pThresholdLayer = dynamic_cast<ThresholdLayer*>(pItem);
   if(pRasterElement != NULL)
   {
      std::vector<Window*> windows;
      Service<DesktopServices>()->getWindows(SPATIAL_DATA_WINDOW, windows);
      for(std::vector<Window*>::iterator window = windows.begin(); window != windows.end(); ++window)
      {
         SpatialDataView *pView = static_cast<SpatialDataWindow*>(*window)->getSpatialDataView();
         std::vector<Layer*> layers;
         pView->getLayerList()->getLayers(layers);
         for(std::vector<Layer*>::iterator layer = layers.begin(); layer != layers.end(); ++layer)
         {
            RasterLayer *pRasterLayer = dynamic_cast<RasterLayer*>(*layer);
            ThresholdLayer *pThresholdLayer = dynamic_cast<ThresholdLayer*>(*layer);
            RasterElement *pElement = static_cast<RasterElement*>((*layer)->getDataElement());
            if(pElement == pRasterElement && (pRasterLayer != NULL || pThresholdLayer != NULL))
            {
               if(mpD->mpController == NULL)
               {
                  createNewController(true, true, (*layer)->getName());
               }
               pView->setAnimationController(mpD->mpController);
               if(pRasterLayer != NULL)
               {
                  TimelineUtils::createAnimationForRasterLayer(pRasterLayer, mpD->mpController);
               }
               else
               {
                  TimelineUtils::createAnimationForThresholdLayer(pThresholdLayer, mpD->mpController);
               }
            }
         }
      }
   }
   else if(pRasterLayer != NULL)
   {
      if(mpD->mpController == NULL)
      {
         createNewController(true, true, pRasterLayer->getName());
      }
      TimelineUtils::createAnimationForRasterLayer(pRasterLayer, mpD->mpController);
   }
   else if(pThresholdLayer != NULL)
   {
      if(mpD->mpController == NULL)
      {
         createNewController(true, true, pThresholdLayer->getName());
      }
      TimelineUtils::createAnimationForThresholdLayer(pThresholdLayer, mpD->mpController);
   }
   layout(true);
}