diff --git a/apps/TaskRunner/main.cpp b/apps/TaskRunner/main.cpp index 5edbd82b41..83d426cd23 100644 --- a/apps/TaskRunner/main.cpp +++ b/apps/TaskRunner/main.cpp @@ -31,12 +31,15 @@ #include #include #include +#include +#include +#include #include +#include +#include #include - #include - #include #include #include @@ -62,10 +65,54 @@ void initTextureReaders() { #endif // GHOUL_USE_FREEIMAGE } +void performTasks(const std::string& path) { + using namespace openspace; + + TaskLoader taskLoader; + std::vector> tasks = taskLoader.tasksFromFile(path); + + size_t nTasks = tasks.size(); + if (nTasks == 1) { + LINFO("Task queue has 1 item"); + } + else { + LINFO("Task queue has " << tasks.size() << " items"); + } + + for (size_t i = 0; i < tasks.size(); i++) { + Task& task = *tasks[i].get(); + LINFO("Performing task " << (i + 1) << " out of " << tasks.size() << ": " << task.description()); + ProgressBar progressBar(100); + auto onProgress = [&progressBar](float progress) { + progressBar.print(progress * 100); + }; + task.perform(onProgress); + } + std::cout << "Done performing tasks." << std::endl; +} + int main(int argc, char** argv) { using namespace openspace; ghoul::initialize(); + + ghoul::logging::LogManager::initialize( + ghoul::logging::LogLevel::Debug, + ghoul::logging::LogManager::ImmediateFlush::Yes + ); + LogMgr.addLog(std::make_unique< ghoul::logging::ConsoleLog>()); + + LDEBUG("Initialize FileSystem"); + + ghoul::filesystem::Directory launchDirectory = FileSys.currentDirectory(); + +#ifdef __APPLE__ + ghoul::filesystem::File app(argv[0]); + std::string dirName = app.directoryName(); + LINFO("Setting starting directory to '" << dirName << "'"); + FileSys.setCurrentDirectory(dirName); +#endif + initTextureReaders(); FactoryManager::initialize(); @@ -98,34 +145,49 @@ int main(int argc, char** argv) { ModuleEngine moduleEngine; moduleEngine.initialize(); - - std::string tasksPath; - configuration.getValue(ConfigurationManager::KeyConfigTask, tasksPath); - LINFO("Initialization done."); - TaskLoader taskLoader; - std::vector> tasks = taskLoader.tasksFromFile(tasksPath); - - size_t nTasks = tasks.size(); - if (nTasks == 1) { - LINFO("Task queue has 1 item"); - } else { - LINFO("Task queue has " << tasks.size() << " items"); + // Parse commandline arguments + std::vector args(argv, argv + argc); + + ghoul::cmdparser::CommandlineParser commandlineParser( + "OpenSpace TaskRunner", + ghoul::cmdparser::CommandlineParser::AllowUnknownCommands::Yes + ); + + std::string tasksPath = ""; + commandlineParser.addCommand( + std::make_unique>( + &tasksPath, + "--task", + "-t", + "Provides the path to a task file to execute" + ) + ); + + commandlineParser.setCommandLine(args); + commandlineParser.execute(); + + FileSys.setCurrentDirectory(launchDirectory); + + if (tasksPath != "") { + performTasks(tasksPath); + return 0; } - for (size_t i = 0; i < tasks.size(); i++) { - Task& task = *tasks[i].get(); - LINFO("Performing task " << (i+1) << " out of " << tasks.size() << ": " << task.description()); - ProgressBar progressBar(100); - auto onProgress = [&progressBar](float progress) { - progressBar.print(progress * 100); - }; - task.perform(onProgress); + // If no task file was specified in as argument, run in CLI mode. + + std::string tasksRoot; + if (configuration.getValue(ConfigurationManager::KeyConfigTasksRoot, tasksRoot)) { + LINFO("Task root: " << tasksRoot); + FileSys.setCurrentDirectory(ghoul::filesystem::Directory(absPath(tasksRoot))); } - std::cout << "Done performing tasks." << std::endl; + std::cout << "TASK >"; + while (std::cin >> tasksPath) { + performTasks(tasksPath); + std::cout << "TASK >"; + } - std::cin.get(); return 0; }; diff --git a/ext/ghoul b/ext/ghoul index 3fd891bcc8..620e4faf5f 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 3fd891bcc8a7b31eee4021033e9a1dbc72846f1d +Subproject commit 620e4faf5f948259d793c17634314a97fc9d5fe8 diff --git a/include/openspace/engine/configurationmanager.h b/include/openspace/engine/configurationmanager.h index 2f9c387251..75163f2c75 100644 --- a/include/openspace/engine/configurationmanager.h +++ b/include/openspace/engine/configurationmanager.h @@ -69,8 +69,8 @@ public: static const std::string KeyFactoryDocumentation; /// The key that stores the location of the scene file that is initially loaded static const std::string KeyConfigScene; - /// The key that stores the location of the tasks file that is initially loaded - static const std::string KeyConfigTask; + /// The key that stores the location of the tasks files + static const std::string KeyConfigTasksRoot; /// The key that stores the subdirectory containing a list of all startup scripts to /// be executed on application start before the scene file is loaded static const std::string KeyStartupScript; diff --git a/include/openspace/rendering/framebufferrenderer.h b/include/openspace/rendering/framebufferrenderer.h index 9a0d6c9799..c82be8e536 100644 --- a/include/openspace/rendering/framebufferrenderer.h +++ b/include/openspace/rendering/framebufferrenderer.h @@ -46,7 +46,6 @@ namespace ghoul::opengl { namespace openspace { -class RenderableVolume; class Camera; class Scene; diff --git a/include/openspace/util/timemanager.h b/include/openspace/util/timemanager.h index a499c2d400..2a7ef4d21b 100644 --- a/include/openspace/util/timemanager.h +++ b/include/openspace/util/timemanager.h @@ -42,8 +42,11 @@ public: void removeKeyframesBefore(double timestamp); void removeKeyframesAfter(double timestamp); void clearKeyframes(); + void setTimeNextFrame(Time t); size_t nKeyframes() const; private: + bool _shouldSetTime; + Time _timeNextFrame; Timeline