void GuiAppInstance::goToNextKeyframe() { ///runs only in the main thread assert( QThread::currentThread() == qApp->thread() ); _imp->timelineKeyframes.sort(); TimeLinePtr timeline = getProject()->getTimeLine(); SequenceTime currentFrame = timeline->currentFrame(); std::list<SequenceTime>::iterator upperBound = std::upper_bound(_imp->timelineKeyframes.begin(), _imp->timelineKeyframes.end(), currentFrame); if ( upperBound != _imp->timelineKeyframes.end() ) { timeline->seekFrame(*upperBound, true, OutputEffectInstancePtr(), eTimelineChangeReasonPlaybackSeek); } }
bool ProjectPrivate::restoreFromSerialization(const ProjectSerialization & obj, const QString& name, const QString& path, bool* mustSave) { /*1st OFF RESTORE THE PROJECT KNOBS*/ bool ok; { CreatingNodeTreeFlag_RAII creatingNodeTreeFlag( _publicInterface->getApp() ); projectCreationTime = QDateTime::fromMSecsSinceEpoch( obj.getCreationDate() ); _publicInterface->getApp()->updateProjectLoadStatus( tr("Restoring project settings...") ); /*we must restore the entries in the combobox before restoring the value*/ std::vector<std::string> entries; for (std::list<Format>::const_iterator it = builtinFormats.begin(); it != builtinFormats.end(); ++it) { QString formatStr = ProjectPrivate::generateStringFromFormat(*it); entries.push_back( formatStr.toStdString() ); } const std::list<Format> & objAdditionalFormats = obj.getAdditionalFormats(); for (std::list<Format>::const_iterator it = objAdditionalFormats.begin(); it != objAdditionalFormats.end(); ++it) { QString formatStr = ProjectPrivate::generateStringFromFormat(*it); entries.push_back( formatStr.toStdString() ); } additionalFormats = objAdditionalFormats; formatKnob->populateChoices(entries); autoSetProjectFormat = false; const std::list<KnobSerializationPtr> & projectSerializedValues = obj.getProjectKnobsValues(); const std::vector< KnobIPtr > & projectKnobs = _publicInterface->getKnobs(); /// 1) restore project's knobs. for (U32 i = 0; i < projectKnobs.size(); ++i) { ///try to find a serialized value for this knob for (std::list<KnobSerializationPtr>::const_iterator it = projectSerializedValues.begin(); it != projectSerializedValues.end(); ++it) { if ( (*it)->getName() == projectKnobs[i]->getName() ) { ///EDIT: Allow non persistent params to be loaded if we found a valid serialization for them //if ( projectKnobs[i]->getIsPersistant() ) { KnobChoicePtr isChoice = toKnobChoice(projectKnobs[i]); if (isChoice) { const TypeExtraData* extraData = (*it)->getExtraData(); const ChoiceExtraData* choiceData = dynamic_cast<const ChoiceExtraData*>(extraData); assert(choiceData); if (choiceData) { KnobChoicePtr serializedKnob = toKnobChoice( (*it)->getKnob() ); assert(serializedKnob); if (serializedKnob) { isChoice->choiceRestoration(serializedKnob, choiceData); } } } else { projectKnobs[i]->clone( (*it)->getKnob() ); } //} break; } } if (projectKnobs[i] == envVars) { ///For eAppTypeBackgroundAutoRunLaunchedFromGui don't change the project path since it is controlled ///by the main GUI process if (appPTR->getAppType() != AppManager::eAppTypeBackgroundAutoRunLaunchedFromGui) { autoSetProjectDirectory(path); } _publicInterface->onOCIOConfigPathChanged(appPTR->getOCIOConfigPath(), false); } else if (projectKnobs[i] == natronVersion) { std::string v = natronVersion->getValue(); if (v == "Natron v1.0.0") { _publicInterface->getApp()->setProjectWasCreatedWithLowerCaseIDs(true); } } } /// 2) restore the timeline timeline->seekFrame(obj.getCurrentTime(), false, OutputEffectInstancePtr(), eTimelineChangeReasonOtherSeek); /// 3) Restore the nodes std::map<std::string, bool> processedModules; ok = NodeCollectionSerialization::restoreFromSerialization(obj.getNodesSerialization().getNodesSerialization(), _publicInterface->shared_from_this(), true, &processedModules); for (std::map<std::string, bool>::iterator it = processedModules.begin(); it != processedModules.end(); ++it) { if (it->second) { *mustSave = true; break; } } _publicInterface->getApp()->updateProjectLoadStatus( tr("Restoring graph stream preferences...") ); } // CreatingNodeTreeFlag_RAII creatingNodeTreeFlag(_publicInterface->getApp()); _publicInterface->forceComputeInputDependentDataOnAllTrees(); QDateTime time = QDateTime::currentDateTime(); autoSetProjectFormat = false; hasProjectBeenSavedByUser = true; projectName->setValue( name.toStdString() ); projectPath->setValue( path.toStdString() ); ageSinceLastSave = time; lastAutoSave = time; _publicInterface->getApp()->setProjectWasCreatedWithLowerCaseIDs(false); if (obj.getVersion() < PROJECT_SERIALIZATION_REMOVES_TIMELINE_BOUNDS) { _publicInterface->recomputeFrameRangeFromReaders(); } return ok; } // restoreFromSerialization