From 0bb118b4cc6847fe4e8a6031363873936613969d Mon Sep 17 00:00:00 2001 From: Oskar Carlbaum Date: Thu, 5 Oct 2017 01:40:02 +0200 Subject: [PATCH] Save state to JSON when input is .osfls and an output folder is specified in the lua-modfile --- .../renderablefieldlinessequencesetup.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/modules/fieldlinessequence/rendering/renderablefieldlinessequencesetup.cpp b/modules/fieldlinessequence/rendering/renderablefieldlinessequencesetup.cpp index 5f960324b0..31ace78104 100644 --- a/modules/fieldlinessequence/rendering/renderablefieldlinessequencesetup.cpp +++ b/modules/fieldlinessequence/rendering/renderablefieldlinessequencesetup.cpp @@ -45,6 +45,7 @@ namespace { const char* KEY_COLOR_TABLE_PATHS = "ColorTablePaths"; // [STRING ARRAY] Values should be paths to .txt files const char* KEY_COLOR_TABLE_RANGES = "ColorTableRanges";// [VEC2 ARRAY] Values should be entered as {X, Y}, where X & Y are numbers const char* KEY_MASKING_RANGES = "MaskingRanges"; // [VEC2 ARRAY] Values should be entered as {X, Y}, where X & Y are numbers + const char* KEY_OUTPUT_FOLDER = "OutputFolder"; // [STRING] Value should be path to folder where states are saved (JSON/CDF input => osfls output & oslfs input => JSON output) const char* KEY_OSLFS_LOAD_AT_RUNTIME = "LoadAtRuntime"; // [BOOLEAN] If value False => Load in initializing step and store in RAM // ------------- POSSIBLE STRING VALUES FOR CORRESPONDING MODFILE KEY ------------- // @@ -235,6 +236,11 @@ void RenderableFieldlinesSequence::initialize() { _states.push_back(newState); _startTimes.push_back(newState.triggerTime()); _nStates++; + + if (SHOULD_SAVE_STATES) { + ghoul::filesystem::File tmpFile(filePath); + newState.saveStateToJson(outputFolderPath + tmpFile.baseName()); + } } } } @@ -352,6 +358,16 @@ void RenderableFieldlinesSequence::extractOptionalInfoFromDictionary( std::string& outputFolderPath) { // ------------------- EXTRACT OPTIONAL VALUES FROM DICTIONARY ------------------- // + if (_dictionary->getValue(KEY_OUTPUT_FOLDER, outputFolderPath)) { + ghoul::filesystem::Directory outputFolder(outputFolderPath); + if (FileSys.directoryExists(outputFolder)) { + outputFolderPath = absPath(outputFolderPath); + } else { + LERROR(_name << ": The specified output path: '" << outputFolderPath << "', does not exist!"); + outputFolderPath = ""; + } + } + ghoul::Dictionary colorTablesPathsDictionary; if (_dictionary->getValue(KEY_COLOR_TABLE_PATHS, colorTablesPathsDictionary)) { const size_t N_PROVIDED_PATHS = colorTablesPathsDictionary.size();