diff --git a/include/openspace/engine/openspaceengine.h b/include/openspace/engine/openspaceengine.h index a2160a7194..1da8cbc773 100644 --- a/include/openspace/engine/openspaceengine.h +++ b/include/openspace/engine/openspaceengine.h @@ -57,10 +57,14 @@ namespace scripting { class ScriptEngine; } -namespace network{ +namespace network { class ParallelConnection; } - + +namespace properties { + class PropertyOwner; +} + class OpenSpaceEngine { public: static bool create(int argc, char** argv, std::vector& sgctArguments); @@ -84,6 +88,7 @@ public: LuaConsole* console(); ModuleEngine* moduleEngine(); network::ParallelConnection* parallelConnection(); + properties::PropertyOwner* globalPropertyOwner(); gui::GUI* gui(); @@ -132,6 +137,9 @@ private: ModuleEngine* _moduleEngine; gui::GUI* _gui; network::ParallelConnection* _parallelConnection; + + properties::PropertyOwner* _globalPropertyNamespace; + bool _isMaster; double _runTime; diff --git a/include/openspace/interaction/interactionhandler.h b/include/openspace/interaction/interactionhandler.h index c0c0ecc12e..52948cfe87 100644 --- a/include/openspace/interaction/interactionhandler.h +++ b/include/openspace/interaction/interactionhandler.h @@ -89,7 +89,7 @@ class SceneGraphNode; namespace interaction { - class InteractionHandler : public properties::PropertyOwner{ +class InteractionHandler : public properties::PropertyOwner { public: InteractionHandler(); diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index 2c2abf44c1..38a1b2a15d 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -37,6 +37,7 @@ #include #include #include +#include #include #include #include @@ -110,11 +111,14 @@ OpenSpaceEngine::OpenSpaceEngine(std::string programName) , _console(new LuaConsole) , _moduleEngine(new ModuleEngine) , _gui(new gui::GUI) + , _parallelConnection(new network::ParallelConnection) + , _globalPropertyNamespace(new properties::PropertyOwner) , _isMaster(false) , _runTime(0.0) , _syncBuffer(nullptr) - , _parallelConnection(new network::ParallelConnection) { + _globalPropertyNamespace->setName("Global"); + _interactionHandler->setPropertyOwner(_globalPropertyNamespace); FactoryManager::initialize(); SpiceManager::initialize(); Time::initialize(); @@ -818,5 +822,10 @@ network::ParallelConnection* OpenSpaceEngine::parallelConnection() { ghoul_assert(_parallelConnection != nullptr, "ParallelConnection is nullptr"); return _parallelConnection; } + +properties::PropertyOwner* OpenSpaceEngine::globalPropertyOwner() { + ghoul_assert(_globalPropertyNamespace, "Global Property Namespace"); + return _globalPropertyNamespace; +} } // namespace openspace diff --git a/src/interaction/interactionhandler.cpp b/src/interaction/interactionhandler.cpp index 8b8745d55b..d72e95c7e7 100644 --- a/src/interaction/interactionhandler.cpp +++ b/src/interaction/interactionhandler.cpp @@ -245,7 +245,8 @@ namespace openspace { namespace interaction { InteractionHandler::InteractionHandler() - : _camera(nullptr) + : properties::PropertyOwner() + , _camera(nullptr) , _focusNode(nullptr) , _deltaTime(0.0) , _validKeyLua(false) @@ -257,6 +258,7 @@ InteractionHandler::InteractionHandler() , _currentKeyframeTime(-1.0) , _origin("origin", "Origin", "") { + setName("Interaction"); addProperty(_origin); _origin.onChange([this](){ diff --git a/src/query/query.cpp b/src/query/query.cpp index a2443091f7..f0fa4a087e 100644 --- a/src/query/query.cpp +++ b/src/query/query.cpp @@ -1,4 +1,4 @@ -/***************************************************************************************** + /***************************************************************************************** * * * OpenSpace * * * @@ -52,37 +52,32 @@ Renderable* renderable(const std::string& name) { } properties::Property* property(const std::string& uri) { - // The URI consists of the following form at this stage: - // .{.}^(0..n) - - const size_t nodeNameSeparator = uri.find(properties::PropertyOwner::URISeparator); - if (nodeNameSeparator == std::string::npos) { - LERROR("Malformed URI '" << uri << "': At least one '" << nodeNameSeparator - << "' separator must be present."); - return nullptr; + properties::Property* globalProp = OsEng.globalPropertyOwner()->property(uri); + if (globalProp) { + return globalProp; } - const std::string nodeName = uri.substr(0, nodeNameSeparator); - const std::string remainingUri = uri.substr(nodeNameSeparator + 1); - - if (nodeName == "Interaction") { - properties::Property* p = OsEng.interactionHandler()->property(remainingUri); + else { + // The URI consists of the following form at this stage: + // .{.}^(0..n) - if (!p) { + const size_t nodeNameSeparator = uri.find(properties::PropertyOwner::URISeparator); + if (nodeNameSeparator == std::string::npos) { + LERROR("Malformed URI '" << uri << "': At least one '" << nodeNameSeparator + << "' separator must be present."); + return nullptr; + } + const std::string nodeName = uri.substr(0, nodeNameSeparator); + const std::string remainingUri = uri.substr(nodeNameSeparator + 1); + + SceneGraphNode* node = sceneGraphNode(nodeName); + if (!node) { LERROR("Node '" << nodeName << "' did not exist"); return nullptr; } - else - return p; + + properties::Property* property = node->property(remainingUri); + return property; } - - SceneGraphNode* node = sceneGraphNode(nodeName); - if (!node) { - LERROR("Node '" << nodeName << "' did not exist"); - return nullptr; - } - - properties::Property* property = node->property(remainingUri); - return property; } } // namespace