bool MultiLayerMovie::setupAnimations() { // Create the controller Service<AnimationServices> pServices; AnimationController* pController = pServices->getAnimationController("MultiLayerMovie"); if (pController != NULL) { pServices->destroyAnimationController(pController); } pController = pServices->createAnimationController("MultiLayerMovie", FRAME_TIME); if (pController == NULL) { return false; } pController->setCanDropFrames(false); // Set the controller into each of the views SpatialDataView* pView = dynamic_cast<SpatialDataView*>(mpWindow->getView()); if (pView == NULL) { pServices->destroyAnimationController(pController); return false; } pView->setAnimationController(pController); // Create the animations for each layer Animation* pAnimation1 = pController->createAnimation("MultiLayerMovie1"); Animation* pAnimation2 = pController->createAnimation("MultiLayerMovie2"); Animation* pAnimation3 = pController->createAnimation("MultiLayerMovie3"); if (pAnimation1 == NULL || pAnimation2 == NULL || pAnimation3 == NULL) { pServices->destroyAnimationController(pController); return false; } // Set up the frames for each animation const int timeOffset = mNumBands/4; vector<AnimationFrame> frames1; vector<AnimationFrame> frames2; vector<AnimationFrame> frames3; for (int i = 0; i < mNumBands; ++i) { AnimationFrame frame1("frame", i, static_cast<double>(i)/mNumBands); AnimationFrame frame2("frame", i, static_cast<double>(i+timeOffset)/(mNumBands+timeOffset)); AnimationFrame frame3("frame", i, static_cast<double>(i+2*timeOffset)/(mNumBands+timeOffset)); frames1.push_back(frame1); frames2.push_back(frame2); frames3.push_back(frame3); } // Set the frames into the animations pAnimation1->setFrames(frames1); pAnimation2->setFrames(frames2); pAnimation3->setFrames(frames3); // Assign the animations to the layers mpLayer1->setAnimation(pAnimation1); mpLayer2->setAnimation(pAnimation2); mpLayer3->setAnimation(pAnimation3); return true; }
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); }