mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-05 19:19:39 -06:00
Add a global propertyowner namespace to which the InteractionHandler is added, removing the need for the earlier hack
This commit is contained in:
@@ -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<std::string>& 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;
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ class SceneGraphNode;
|
||||
|
||||
namespace interaction {
|
||||
|
||||
class InteractionHandler : public properties::PropertyOwner{
|
||||
class InteractionHandler : public properties::PropertyOwner {
|
||||
public:
|
||||
InteractionHandler();
|
||||
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <openspace/interaction/luaconsole.h>
|
||||
#include <openspace/interaction/mousecontroller.h>
|
||||
#include <openspace/network/networkengine.h>
|
||||
#include <openspace/properties/propertyowner.h>
|
||||
#include <openspace/rendering/renderengine.h>
|
||||
#include <openspace/scripting/scriptengine.h>
|
||||
#include <openspace/scene/scene.h>
|
||||
@@ -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
|
||||
|
||||
@@ -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](){
|
||||
|
||||
@@ -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:
|
||||
// <node name>.{<property owner>.}^(0..n)<property id>
|
||||
|
||||
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:
|
||||
// <node name>.{<property owner>.}^(0..n)<property id>
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user