void FrameLabelObjectImp::setAnimations(View* pView) { if (getLocked() == false) { reset(); vector<Animation*> pAnimations; if (pView != NULL) { SpatialDataView* pSpatialDataView = dynamic_cast<SpatialDataView*>(pView); if (pSpatialDataView == NULL) { mpView.reset(pView); mpAnimationController.reset(mpView->getAnimationController()); if (mpAnimationController.get() != NULL) { pAnimations = mpAnimationController->getAnimations(); } } else { mpLayerList.reset(pSpatialDataView->getLayerList()); VERIFYNRV(mpLayerList.get() != NULL); vector<Layer*> pLayers; mpLayerList->getLayers(RASTER, pLayers); for (vector<Layer*>::iterator iter = pLayers.begin(); iter != pLayers.end(); ++iter) { RasterLayer* pRasterLayer = dynamic_cast<RasterLayer*>(*iter); VERIFYNRV(pRasterLayer != NULL); pRasterLayer->attach(SIGNAL_NAME(RasterLayer, AnimationChanged), Slot(this, &FrameLabelObjectImp::updateAnimations)); pRasterLayer->attach(SIGNAL_NAME(Subject, Deleted), Slot(this, &FrameLabelObjectImp::layerDeleted)); mLayers.push_back(pRasterLayer); if (pRasterLayer->getAnimation() != NULL) { pAnimations.push_back(pRasterLayer->getAnimation()); } } } } insertAnimations(pAnimations); } }
bool TimelineWidget::saveAnimationTimes(Animation *pAnim) { if(pAnim == NULL) { return false; } bool success = false; const std::vector<AnimationFrame> frames = pAnim->getFrames(); std::vector<double> times(frames.size(), 0.0); for(unsigned int idx = 0; idx < frames.size(); idx++) { times[idx] = frames[idx].mTime; } 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(RASTER, layers); for(std::vector<Layer*>::iterator layer = layers.begin(); layer != layers.end(); ++layer) { RasterLayer *pLayer = static_cast<RasterLayer*>(*layer); if(pLayer->getAnimation() == pAnim) { RasterElement *pElement = static_cast<RasterElement*>(pLayer->getDataElement()); DynamicObject *pMetadata = static_cast<RasterDataDescriptor*>(pElement->getDataDescriptor())->getMetadata(); if(pMetadata != NULL) { success = success || pMetadata->setAttributeByPath(FRAME_TIMES_METADATA_PATH, times); } } } } return success; }
bool SampleGeoref::execute(PlugInArgList* pInArgList, PlugInArgList* pOutArgList) { // Do any kind of setup we need before converting coordinates. // In this case, get our X and Y factors. StepResource pStep("Run Sample Georef", "app", "CFCB8AA9-D504-42e9-86F0-547DF9B4798A"); Progress* pProgress = pInArgList->getPlugInArgValue<Progress>(Executable::ProgressArg()); FAIL_IF(!isBatch(), "Interactive mode is not supported.", return false); // Default values bool animated = false; // get factors from pInArgList pInArgList->getPlugInArgValue("XSize", mXSize); pInArgList->getPlugInArgValue("YSize", mYSize); pInArgList->getPlugInArgValue("Extrapolate", mExtrapolate); pInArgList->getPlugInArgValue("Animated", animated); pInArgList->getPlugInArgValue("Rotate", mRotate); View* pView = pInArgList->getPlugInArgValue<View>(Executable::ViewArg()); mpRaster = pInArgList->getPlugInArgValue<RasterElement>(Executable::DataElementArg()); FAIL_IF(mpRaster == NULL, "Could not find raster element", return false); if (mpGui != NULL) { mXSize = mpGui->getXSize(); mYSize = mpGui->getYSize(); animated = mpGui->getAnimated(); mRotate = mpGui->getRotate(); mExtrapolate = mpGui->getExtrapolate(); } if (animated) { SpatialDataView* pSpatialView = dynamic_cast<SpatialDataView*>(pView); FAIL_IF(pSpatialView == NULL, "Could not find spatial data view.", return false); LayerList* pLayerList = pSpatialView->getLayerList(); FAIL_IF(pLayerList == NULL, "Could not find layer list.", return false); RasterLayer* pLayer = dynamic_cast<RasterLayer*>(pLayerList->getLayer(RASTER, mpRaster)); FAIL_IF(pLayer == NULL, "Could not find raster layer", return false); Animation* pAnim = pLayer->getAnimation(); FAIL_IF(pAnim == NULL, "Could not find animation", return false); const std::vector<AnimationFrame>& frames = pAnim->getFrames(); FAIL_IF(frames.empty(), "No frames in animation.", return false); mpAnimation.reset(pAnim); mFrames = frames.size(); mCurrentFrame = 0; } RasterDataDescriptor* pDescriptor = dynamic_cast<RasterDataDescriptor*>(mpRaster->getDataDescriptor()); FAIL_IF(pDescriptor == NULL, "Could not get data descriptor.", return false); unsigned int rows = pDescriptor->getRowCount(); unsigned int cols = pDescriptor->getColumnCount(); unsigned int bands = pDescriptor->getBandCount(); mXScale = static_cast<double>(mXSize) / rows; mYScale = static_cast<double>(mYSize) / cols; mpRaster->setGeoreferencePlugin(this); mpGui = NULL; // Pointer not guaranteed to be valid after execute() is called return true; }