Esempio n. 1
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);
}