mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-05-06 11:29:55 -05:00
Finished support for modules and markInterestingNodes
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
#define __OPENSPACE_CORE___MODULEENGINE___H__
|
||||
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
#include <openspace/scene/profile.h>
|
||||
|
||||
#include <map>
|
||||
#include <memory>
|
||||
@@ -116,6 +117,14 @@ public:
|
||||
*/
|
||||
ghoul::systemcapabilities::Version requiredOpenGLVersion() const;
|
||||
|
||||
/**
|
||||
* Reads a list of modules from a profile, and executes scripts based on whether or
|
||||
* not the corresponding module is loaded.
|
||||
*
|
||||
* \param p The Profile to be read.
|
||||
*/
|
||||
void setFromProfile_modules(const Profile& p);
|
||||
|
||||
/**
|
||||
* Returns the Lua library that contains all Lua functions available to affect the
|
||||
* modules.
|
||||
|
||||
@@ -264,6 +264,15 @@ public:
|
||||
void property_pushValueFromProfileToLuaState(ghoul::lua::LuaState& L,
|
||||
const std::string& value);
|
||||
|
||||
/**
|
||||
* Reads list of nodes from profile to be marked as interesting nodes.
|
||||
* If any nodes are listed, a script to mark these will be queued with the
|
||||
* script engine.
|
||||
*
|
||||
* \param p The Profile to be read.
|
||||
*/
|
||||
void setFromProfile_markInterestingNodes(const Profile& p);
|
||||
|
||||
private:
|
||||
/**
|
||||
* Update dependencies.
|
||||
|
||||
@@ -27,6 +27,7 @@
|
||||
#include <openspace/documentation/documentation.h>
|
||||
#include <openspace/moduleregistration.h>
|
||||
#include <openspace/scripting/lualibrary.h>
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
#include <openspace/util/openspacemodule.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
#include <ghoul/misc/profiling.h>
|
||||
@@ -163,6 +164,29 @@ ghoul::systemcapabilities::Version ModuleEngine::requiredOpenGLVersion() const {
|
||||
return version;
|
||||
}
|
||||
|
||||
void ModuleEngine::setFromProfile_modules(const Profile& p)
|
||||
{
|
||||
for (Profile::Module mod : p.modules) {
|
||||
const std::vector<OpenSpaceModule*>& m = modules();
|
||||
if (std::find(m.begin(), m.end(), mod.name) != m.end()) {
|
||||
if (mod.loadedInstruction.has_value()) {
|
||||
global::scriptEngine->queueScript(
|
||||
mod.loadedInstruction.value(),
|
||||
scripting::ScriptEngine::RemoteScripting::Yes
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (mod.notLoadedInstruction.has_value()) {
|
||||
global::scriptEngine->queueScript(
|
||||
mod.notLoadedInstruction.value(),
|
||||
scripting::ScriptEngine::RemoteScripting::Yes
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
scripting::LuaLibrary ModuleEngine::luaLibrary() {
|
||||
return {
|
||||
"modules",
|
||||
|
||||
@@ -1128,6 +1128,9 @@ void OpenSpaceEngine::preSynchronization() {
|
||||
global::navigationHandler->setFromProfile_camera(*global::profile);
|
||||
global::actionManager->setFromProfile_actions(*global::profile);
|
||||
global::keybindingManager->setFromProfile_keybindings(*global::profile);
|
||||
global::moduleEngine->setFromProfile_modules(*global::profile);
|
||||
global::renderEngine->scene()->setFromProfile_markInterestingNodes(
|
||||
*global::profile);
|
||||
global::profile->ignoreUpdates = false;
|
||||
resetPropertyChangeFlagsOfSubowners(global::rootPropertyOwner);
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include <openspace/scene/scenelicensewriter.h>
|
||||
#include <openspace/scene/sceneinitializer.h>
|
||||
#include <openspace/scripting/lualibrary.h>
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
#include <openspace/util/updatestructures.h>
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <ghoul/logging/logmanager.h>
|
||||
@@ -682,6 +683,21 @@ void Scene::property_pushValueFromProfileToLuaState(ghoul::lua::LuaState& L,
|
||||
}
|
||||
}
|
||||
|
||||
void Scene::setFromProfile_markInterestingNodes(const Profile& p) {
|
||||
std::string nodesToMark;
|
||||
for (auto node : p.markNodes) {
|
||||
nodesToMark += fmt::format("[[{}]],", node);
|
||||
}
|
||||
if (!nodesToMark.empty()) {
|
||||
std::string markCmd = fmt::format("openspace.markInterestingNodes({{ {} }});",
|
||||
nodesToMark);
|
||||
global::scriptEngine->queueScript(
|
||||
markCmd,
|
||||
scripting::ScriptEngine::RemoteScripting::Yes
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
scripting::LuaLibrary Scene::luaLibrary() {
|
||||
return {
|
||||
"",
|
||||
|
||||
Reference in New Issue
Block a user