From d5ddaf84b8ba8a0b68200479a4fa773e32be5eb2 Mon Sep 17 00:00:00 2001 From: Gene Payne Date: Wed, 15 Jun 2016 14:46:19 +0200 Subject: [PATCH] Working on global settings integrated in gui but no functionality yet --- include/openspace/engine/openspaceengine.h | 4 +- include/openspace/engine/settingsengine.h | 44 +++++++++++++++++++ .../engine/wrapper/sgctwindowwrapper.h | 1 + .../openspace/engine/wrapper/windowwrapper.h | 6 +++ modules/onscreengui/include/gui.h | 1 + modules/onscreengui/src/gui.cpp | 6 +++ src/CMakeLists.txt | 2 + src/engine/openspaceengine.cpp | 10 +++++ src/engine/settingsengine.cpp | 36 +++++++++++++++ src/engine/wrapper/sgctwindowwrapper.cpp | 6 ++- src/engine/wrapper/windowwrapper.cpp | 2 + 11 files changed, 116 insertions(+), 2 deletions(-) create mode 100644 include/openspace/engine/settingsengine.h create mode 100644 src/engine/settingsengine.cpp diff --git a/include/openspace/engine/openspaceengine.h b/include/openspace/engine/openspaceengine.h index ee36f2f0f8..f8b614b8ad 100644 --- a/include/openspace/engine/openspaceengine.h +++ b/include/openspace/engine/openspaceengine.h @@ -50,6 +50,7 @@ class RenderEngine; class SyncBuffer; class ModuleEngine; class WindowWrapper; +class SettingsEngine; namespace interaction { class InteractionHandler; } namespace gui { class GUI; } @@ -130,13 +131,14 @@ private: std::unique_ptr _commandlineParser; std::unique_ptr _console; std::unique_ptr _moduleEngine; + std::unique_ptr _settingsEngine; #ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED std::unique_ptr _gui; #endif std::unique_ptr _parallelConnection; std::unique_ptr _windowWrapper; std::unique_ptr _fontManager; - + // Others std::unique_ptr _globalPropertyNamespace; std::unique_ptr _syncBuffer; diff --git a/include/openspace/engine/settingsengine.h b/include/openspace/engine/settingsengine.h new file mode 100644 index 0000000000..583abba854 --- /dev/null +++ b/include/openspace/engine/settingsengine.h @@ -0,0 +1,44 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ + +#ifndef __SETTINGSENGINE_H__ +#define __SETTINGSENGINE_H__ + +#include +#include + +namespace openspace { + +class SettingsEngine : public properties::PropertyOwner { +public: + SettingsEngine(); + +private: + properties::FloatProperty _eyeSeparation; +}; + +} // namespace openspace + + +#endif //#ifndef __SETTINGSENGINE_H__ diff --git a/include/openspace/engine/wrapper/sgctwindowwrapper.h b/include/openspace/engine/wrapper/sgctwindowwrapper.h index 6a1c170dd0..1003807288 100644 --- a/include/openspace/engine/wrapper/sgctwindowwrapper.h +++ b/include/openspace/engine/wrapper/sgctwindowwrapper.h @@ -52,6 +52,7 @@ public: glm::mat4 viewProjectionMatrix() const override; void setNearFarClippingPlane(float near, float far) override; + void setEyeSeparationDistance(float distance) override; glm::ivec4 viewportPixelCoordinates() const override; diff --git a/include/openspace/engine/wrapper/windowwrapper.h b/include/openspace/engine/wrapper/windowwrapper.h index d20f5339db..2d2ee26ecd 100644 --- a/include/openspace/engine/wrapper/windowwrapper.h +++ b/include/openspace/engine/wrapper/windowwrapper.h @@ -140,6 +140,12 @@ public: */ virtual void setNearFarClippingPlane(float near, float far); + /** + * Sets the stereo eye separation distance for the render engine. + * \param distance The distance between eyes for stereo rendering. + */ + virtual void setEyeSeparationDistance(float distance); + /** * Returns the location and size of the current viewport (x, * width, y, and height). If there is only a diff --git a/modules/onscreengui/include/gui.h b/modules/onscreengui/include/gui.h index 7bd37b0f85..fb15983609 100644 --- a/modules/onscreengui/include/gui.h +++ b/modules/onscreengui/include/gui.h @@ -74,6 +74,7 @@ public: GuiPropertyComponent _property; // GuiPropertyComponent _iSWAproperty; GuiPropertyComponent _screenSpaceProperty; + GuiPropertyComponent _globalProperty; GuiTimeComponent _time; GuiIswaComponent _iswa; diff --git a/modules/onscreengui/src/gui.cpp b/modules/onscreengui/src/gui.cpp index 4353468086..7f4d62008c 100644 --- a/modules/onscreengui/src/gui.cpp +++ b/modules/onscreengui/src/gui.cpp @@ -206,6 +206,7 @@ void GUI::initialize() { _property.initialize(); _screenSpaceProperty.initialize(); + _globalProperty.initialize(); _performance.initialize(); _help.initialize(); _iswa.initialize(); @@ -254,6 +255,7 @@ void GUI::initializeGL() { _property.initializeGL(); _screenSpaceProperty.initializeGL(); + _globalProperty.initializeGL(); _performance.initializeGL(); _help.initializeGL(); _iswa.initializeGL(); @@ -267,6 +269,7 @@ void GUI::deinitializeGL() { _property.deinitializeGL(); _screenSpaceProperty.deinitializeGL(); + _globalProperty.deinitializeGL(); _performance.deinitializeGL(); _help.deinitializeGL(); _iswa.deinitializeGL(); @@ -302,6 +305,8 @@ void GUI::endFrame() { _property.render(); if (_screenSpaceProperty.isEnabled()) _screenSpaceProperty.render(); + if (_globalProperty.isEnabled()) + _globalProperty.render(); if (_performance.isEnabled()) _performance.render(); if (_help.isEnabled()) @@ -404,6 +409,7 @@ void GUI::renderMainWindow() { ImGui::Checkbox("Scene Graph Properties", &_property._isEnabled); ImGui::Checkbox("ScreenSpace Properties", &_screenSpaceProperty._isEnabled); + ImGui::Checkbox("Global Properties", &_globalProperty._isEnabled); #ifdef OPENSPACE_MODULE_ISWA_ENABLED ImGui::Checkbox("iSWA", &_iswa._isEnabled); #endif diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1d7d1a7670..1dd0430a65 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -30,6 +30,7 @@ set(OPENSPACE_SOURCE ${OPENSPACE_BASE_DIR}/src/engine/moduleengine.cpp ${OPENSPACE_BASE_DIR}/src/engine/moduleengine_lua.inl ${OPENSPACE_BASE_DIR}/src/engine/openspaceengine.cpp + ${OPENSPACE_BASE_DIR}/src/engine/settingsengine.cpp ${OPENSPACE_BASE_DIR}/src/engine/wrapper/sgctwindowwrapper.cpp ${OPENSPACE_BASE_DIR}/src/engine/wrapper/windowwrapper.cpp ${OPENSPACE_BASE_DIR}/src/interaction/controller.cpp @@ -104,6 +105,7 @@ set(OPENSPACE_HEADER ${OPENSPACE_BASE_DIR}/include/openspace/engine/logfactory.h ${OPENSPACE_BASE_DIR}/include/openspace/engine/moduleengine.h ${OPENSPACE_BASE_DIR}/include/openspace/engine/openspaceengine.h + ${OPENSPACE_BASE_DIR}/include/openspace/engine/settingsengine.h ${OPENSPACE_BASE_DIR}/include/openspace/engine/wrapper/sgctwindowwrapper.h ${OPENSPACE_BASE_DIR}/include/openspace/engine/wrapper/windowwrapper.h ${OPENSPACE_BASE_DIR}/include/openspace/interaction/controller.h diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index df02e58e3a..f741268b7d 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -109,6 +110,10 @@ namespace { namespace openspace { +namespace properties { + class Property; +} + OpenSpaceEngine* OpenSpaceEngine::_engine = nullptr; OpenSpaceEngine::OpenSpaceEngine(std::string programName, @@ -123,6 +128,7 @@ OpenSpaceEngine::OpenSpaceEngine(std::string programName, )) , _console(new LuaConsole) , _moduleEngine(new ModuleEngine) + , _settingsEngine(new SettingsEngine) #ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED , _gui(new gui::GUI) #endif @@ -135,6 +141,7 @@ OpenSpaceEngine::OpenSpaceEngine(std::string programName, { _interactionHandler->setPropertyOwner(_globalPropertyNamespace.get()); _globalPropertyNamespace->addPropertySubOwner(_interactionHandler.get()); + _globalPropertyNamespace->addPropertySubOwner(_settingsEngine.get()); FactoryManager::initialize(); FactoryManager::ref().addFactory( std::make_unique>() @@ -165,6 +172,7 @@ OpenSpaceEngine::~OpenSpaceEngine() { _commandlineParser = nullptr; _console = nullptr; _moduleEngine = nullptr; + _settingsEngine = nullptr; #ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED _gui = nullptr; #endif @@ -429,6 +437,8 @@ bool OpenSpaceEngine::initialize() { #ifdef OPENSPACE_MODULE_ONSCREENGUI_ENABLED LINFO("Initializing GUI"); _gui->initialize(); + for (properties::Property* p : _settingsEngine->propertiesRecursive()) + _gui->_globalProperty.registerProperty(p); #endif #ifdef OPENSPACE_MODULE_ISWA_ENABLED diff --git a/src/engine/settingsengine.cpp b/src/engine/settingsengine.cpp new file mode 100644 index 0000000000..6be68b91e2 --- /dev/null +++ b/src/engine/settingsengine.cpp @@ -0,0 +1,36 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ + +#include + +namespace openspace { + +SettingsEngine::SettingsEngine() : + _eyeSeparation("eyeSeparation", "Eye Separation" , 0.f, 0.f, 10.f) +{ + addProperty(_eyeSeparation); + setName("Global"); +} + +} diff --git a/src/engine/wrapper/sgctwindowwrapper.cpp b/src/engine/wrapper/sgctwindowwrapper.cpp index b3a3134a22..992e3ca91b 100644 --- a/src/engine/wrapper/sgctwindowwrapper.cpp +++ b/src/engine/wrapper/sgctwindowwrapper.cpp @@ -119,7 +119,11 @@ glm::mat4 SGCTWindowWrapper::viewProjectionMatrix() const { void SGCTWindowWrapper::setNearFarClippingPlane(float nearPlane, float farPlane) { sgct::Engine::instance()->setNearAndFarClippingPlanes(nearPlane, farPlane); } - + +void SGCTWindowWrapper::setEyeSeparationDistance(float distance) { + sgct::Engine::instance()->setEyeSeparation(distance); +} + glm::ivec4 SGCTWindowWrapper::viewportPixelCoordinates() const { int x1, xSize, y1, ySize; sgct::Engine::instance()->getCurrentWindowPtr()->getCurrentViewportPixelCoords(x1, diff --git a/src/engine/wrapper/windowwrapper.cpp b/src/engine/wrapper/windowwrapper.cpp index 8283edf577..79a9390ca0 100644 --- a/src/engine/wrapper/windowwrapper.cpp +++ b/src/engine/wrapper/windowwrapper.cpp @@ -77,6 +77,8 @@ glm::mat4 WindowWrapper::viewProjectionMatrix() const { } void WindowWrapper::setNearFarClippingPlane(float near, float far) {} + +void WindowWrapper::setEyeSeparationDistance(float distance) {} glm::ivec4 WindowWrapper::viewportPixelCoordinates() const { return glm::ivec4(