diff --git a/data/scene/atmosphereearth.scene b/data/scene/atmosphereearth.scene deleted file mode 100644 index 7688996950..0000000000 --- a/data/scene/atmosphereearth.scene +++ /dev/null @@ -1,57 +0,0 @@ -function preInitialization() - --[[ - The scripts in this function are executed after the scene is loaded but before the - scene elements have been initialized, thus they should be used to set the time at - which the scene should start and other settings that might determine initialization - critical objects. - ]]-- - - openspace.spice.loadKernel("${SPICE}/naif0012.tls") - openspace.spice.loadKernel("${SPICE}/pck00010.tpc") - - openspace.time.setTime(openspace.time.currentWallTime()) - dofile(openspace.absPath('${SCRIPTS}/bind_common_keys.lua')) -end - -function postInitialization() - --[[ - The scripts in this function are executed after all objects in the scene have been - created and initialized, but before the first render call. This is the place to set - graphical settings for the renderables. - ]]-- - openspace.set_default_gui_sorting() - - openspace.printInfo("Setting default values") - openspace.setPropertyValue("Sun.renderable.Enabled", false) - openspace.setPropertyValue("SunMarker.renderable.Enabled", true) - openspace.setPropertyValue("EarthMarker.renderable.enabled", true) - openspace.setPropertyValue("Constellation Bounds.renderable.Enabled", false) - - openspace.setPropertyValue("MilkyWay.renderable.Transparency", 0.55) - openspace.setPropertyValue("MilkyWay.renderable.Segments", 50) - - openspace.printInfo("Done setting default values") - - if openspace.modules.isLoaded("ISWA") then - openspace.iswa.addCdfFiles("${OPENSPACE_DATA}/cdflist.json"); - end -end - - -return { - ScenePath = ".", - CommonFolder = "common", - Camera = { - Focus = "Earth", - Position = {1, 0, 0}, - Rotation = {0.250635, -0.028751, 0.879269, 0.404030}, - }, - Modules = { - "sun", - "earth", - "stars/digitaluniverse", - -- "stars/denver", - "milkyway/digitaluniverse", - --"milkyway/eso", - } -} diff --git a/data/scene/dawn.scene b/data/scene/dawn.scene index 68c09bd636..a1903a6120 100644 --- a/data/scene/dawn.scene +++ b/data/scene/dawn.scene @@ -5,9 +5,10 @@ function preInitialization() which the scene should start and other settings that might determine initialization critical objects. ]]-- + openspace.set_default_dashboard() - openspace.spice.loadKernel("${SPICE}/naif0012.tls") - openspace.spice.loadKernel("${SPICE}/pck00010.tpc") + openspace.spice.loadKernel(openspace.absPath("${SPICE}/naif0012.tls")) + openspace.spice.loadKernel(openspace.absPath("${SPICE}/pck00010.tpc")) openspace.time.setTime("2011 AUG 06 00:00:00") dofile(openspace.absPath('${SCRIPTS}/bind_common_keys.lua')) diff --git a/data/scene/default.scene b/data/scene/default.scene index 296b67c9b6..824d2d3f7c 100644 --- a/data/scene/default.scene +++ b/data/scene/default.scene @@ -25,9 +25,10 @@ function preInitialization() which the scene should start and other settings that might determine initialization critical objects. ]]-- + openspace.set_default_dashboard() - openspace.spice.loadKernel("${SPICE}/naif0012.tls") - openspace.spice.loadKernel("${SPICE}/pck00010.tpc") + openspace.spice.loadKernel(openspace.absPath("${SPICE}/naif0012.tls")) + openspace.spice.loadKernel(openspace.absPath("${SPICE}/pck00010.tpc")) openspace.time.setTime(openspace.time.currentWallTime()) dofile(openspace.absPath('${SCRIPTS}/bind_common_keys.lua')) diff --git a/data/scene/fieldlines.scene b/data/scene/fieldlines.scene index eec14509f8..2833ca5645 100644 --- a/data/scene/fieldlines.scene +++ b/data/scene/fieldlines.scene @@ -5,9 +5,10 @@ function preInitialization() which the scene should start and other settings that might determine initialization critical objects. ]]-- + openspace.set_default_dashboard() - openspace.spice.loadKernel("${SPICE}/naif0012.tls") - openspace.spice.loadKernel("${SPICE}/pck00010.tpc") + openspace.spice.loadKernel(openspace.absPath("${SPICE}/naif0012.tls")) + openspace.spice.loadKernel(openspace.absPath("${SPICE}/pck00010.tpc")) openspace.time.setTime("2015 JAN 01 12:00:00.000") dofile(openspace.absPath('${SCRIPTS}/bind_common_keys.lua')) diff --git a/data/scene/juno.scene b/data/scene/juno.scene index 23fc7bcab7..054cb1033a 100755 --- a/data/scene/juno.scene +++ b/data/scene/juno.scene @@ -5,8 +5,10 @@ function preInitialization() which the scene should start and other settings that might determine initialization critical objects. ]]-- - openspace.spice.loadKernel("${SPICE}/naif0012.tls") - openspace.spice.loadKernel("${SPICE}/pck00010.tpc") + openspace.set_default_dashboard() + + openspace.spice.loadKernel(openspace.absPath("${SPICE}/naif0012.tls")) + openspace.spice.loadKernel(openspace.absPath("${SPICE}/pck00010.tpc")) openspace.time.setTime("2016-07-01T10:05:00.00") diff --git a/data/scene/newhorizons.scene b/data/scene/newhorizons.scene index 34c5545542..9691e8ea28 100644 --- a/data/scene/newhorizons.scene +++ b/data/scene/newhorizons.scene @@ -26,10 +26,27 @@ function preInitialization() which the scene should start and other settings that might determine initialization critical objects. ]]-- - openspace.set_default_gui_sorting() + openspace.set_default_dashboard() - openspace.spice.loadKernel("${SPICE}/naif0012.tls") - openspace.spice.loadKernel("${SPICE}/pck00010.tpc") + openspace.dashboard.addDashboardItem({ + Type = "DashboardItemSpacing", + Spacing = 50 + }) + + openspace.dashboard.addDashboardItem({ + Type = "DashboardItemDistance", + SourceType = "Node", + SourceNodeName = "NewHorizons", + DestinationType = "Node Surface", + DestinationNodeName = "Pluto" + }) + + openspace.dashboard.addDashboardItem({ + Type = "DashboardItemInstruments" + }) + + openspace.spice.loadKernel(openspace.absPath("${SPICE}/naif0012.tls")) + openspace.spice.loadKernel(openspace.absPath("${SPICE}/pck00010.tpc")) openspace.time.setTime("2015-07-14T08:00:00.00") diff --git a/data/scene/osirisrex.scene b/data/scene/osirisrex.scene index ca77dc7cdf..84a11b840e 100644 --- a/data/scene/osirisrex.scene +++ b/data/scene/osirisrex.scene @@ -7,9 +7,10 @@ function preInitialization() which the scene should start and other settings that might determine initialization critical objects. ]]-- + openspace.set_default_dashboard() - openspace.spice.loadKernel("${SPICE}/naif0012.tls") - openspace.spice.loadKernel("${SPICE}/pck00010.tpc") + openspace.spice.loadKernel(openspace.absPath("${SPICE}/naif0012.tls")) + openspace.spice.loadKernel(openspace.absPath("${SPICE}/pck00010.tpc")) --local startTime = "2019 APR 16 12:03:00.00" openspace.time.setTime("2016 SEP 8 23:00:00.500") @@ -72,7 +73,7 @@ function preInitialization() "Toggles the visibility of the text marking the location of the Earth." ) - openspace.scriptScheduler.loadFile("${OPENSPACE_DATA}/scene/missions/osirisrex/scheduled_scripts.lua") + openspace.scriptScheduler.loadFile(openspace.absPath("${OPENSPACE_DATA}/scene/missions/osirisrex/scheduled_scripts.lua")) end function postInitialization() diff --git a/data/scene/rosetta.scene b/data/scene/rosetta.scene index 8c6f0acd04..72b650d7a8 100644 --- a/data/scene/rosetta.scene +++ b/data/scene/rosetta.scene @@ -5,9 +5,10 @@ function preInitialization() which the scene should start and other settings that might determine initialization critical objects. ]]-- + openspace.set_default_dashboard() - openspace.spice.loadKernel("${SPICE}/naif0012.tls") - openspace.spice.loadKernel("${SPICE}/pck00010.tpc") + openspace.spice.loadKernel(openspace.absPath("${SPICE}/naif0012.tls")) + openspace.spice.loadKernel(openspace.absPath("${SPICE}/pck00010.tpc")) -- Usual start openspace.time.setTime("2014-08-01T03:05:18.101") diff --git a/data/scene/tests.scene b/data/scene/tests.scene new file mode 100644 index 0000000000..dbce97ee34 --- /dev/null +++ b/data/scene/tests.scene @@ -0,0 +1,237 @@ +function preInitialization() + --[[ + The scripts in this function are executed after the scene is loaded but before the + scene elements have been initialized, thus they should be used to set the time at + which the scene should start and other settings that might determine initialization + critical objects. + ]]-- + -- dofile(openspace.absPath('${SCRIPTS}/default_setup.lua')) + + local TestFontSize1 = 20 + local TestFontSize2 = 14 + + -- DashboardItemDate tests + openspace.dashboard.addDashboardItem({ + Type = "DashboardItemDate" + }) + openspace.dashboard.addDashboardItem({ + Type = "DashboardItemDate", + FontName = "Console" + }) + openspace.dashboard.addDashboardItem({ + Type = "DashboardItemDate", + FontName = "Light", + FontSize = TestFontSize1 + }) + openspace.dashboard.addDashboardItem({ + Type = "DashboardItemDate", + FontSize = TestFontSize2 + }) + + -- DashboardItemDistance tests + openspace.dashboard.addDashboardItem({ + Type = "DashboardItemDistance" + }) + openspace.dashboard.addDashboardItem({ + Type = "DashboardItemDistance", + FontName = "Console", + SourceType = "Node", + SourceNodeName = "Moon" + }) + openspace.dashboard.addDashboardItem({ + Type = "DashboardItemDistance", + FontName = "Light", + FontSize = TestFontSize1, + SourceType = "Focus", + DestinationType = "Camera" + }) + openspace.dashboard.addDashboardItem({ + Type = "DashboardItemDistance", + FontSize = TestFontSize2, + SourceType = "Focus", + DestinationType = "Node", + DestinationNodeName = "Sun" + }) + openspace.dashboard.addDashboardItem({ + Type = "DashboardItemDistance", + SourceType = "Camera", + DestinationType = "Focus" + }) + openspace.dashboard.addDashboardItem({ + Type = "DashboardItemDistance", + SourceType = "Camera", + SourceType = "Node", + SourceNodeName = "Saturn", + DestinationType = "Node", + DestinationNodeName = "Sun" + }) + + openspace.dashboard.addDashboardItem({ + Type = "DashboardItemSpacing", + Spacing = 100 + }) + + -- DashboardItemFramerate + openspace.dashboard.addDashboardItem({ + Type = "DashboardItemFramerate" + }) + + openspace.dashboard.addDashboardItem({ + Type = "DashboardItemFramerate", + FontName = "Light", + FontSize = TestFontSize1, + FrametimeType = "Average Deltatime" + }) + + openspace.dashboard.addDashboardItem({ + Type = "DashboardItemFramerate", + FontName = "Console", + FrametimeType = "Frames per second" + }) + + openspace.dashboard.addDashboardItem({ + Type = "DashboardItemFramerate", + FontSize = TestFontSize2, + FrametimeType = "Average frames per second" + }) + + openspace.dashboard.addDashboardItem({ + Type = "DashboardItemFramerate", + FrametimeType = "None" + }) + + openspace.dashboard.addDashboardItem({ + Type = "DashboardItemSpacing" + }) + + -- DashboardItemSimulationIncrement + openspace.dashboard.addDashboardItem({ + Type = "DashboardItemSimulationIncrement" + }) + + openspace.dashboard.addDashboardItem({ + Type = "DashboardItemSimulationIncrement", + FontName = "Light", + FontSize = TestFontSize1, + }) + + openspace.dashboard.addDashboardItem({ + Type = "DashboardItemSimulationIncrement", + FontName = "Console" + }) + openspace.dashboard.addDashboardItem({ + Type = "DashboardItemSimulationIncrement", + FontSize = TestFontSize2 + }) + + openspace.dashboard.addDashboardItem({ + Type = "DashboardItemSpacing" + }) + + -- DashboardItemAngle + openspace.dashboard.addDashboardItem({ + Type = "DashboardItemAngle", + ReferenceType = "Node", + ReferenceNodeName = "Moon", + }) + openspace.dashboard.addDashboardItem({ + Type = "DashboardItemAngle", + FontName = "Console", + SourceType = "Node", + SourceNodeName = "Moon", + ReferenceType = "Node", + ReferenceNodeName = "Moon", + }) + openspace.dashboard.addDashboardItem({ + Type = "DashboardItemAngle", + FontName = "Light", + FontSize = TestFontSize1, + SourceType = "Focus", + ReferenceType = "Node", + ReferenceNodeName = "Moon", + DestinationType = "Camera" + }) + openspace.dashboard.addDashboardItem({ + Type = "DashboardItemAngle", + FontSize = TestFontSize2, + SourceType = "Focus", + ReferenceType = "Node", + ReferenceNodeName = "Moon", + DestinationType = "Node", + DestinationNodeName = "Sun" + }) + openspace.dashboard.addDashboardItem({ + Type = "DashboardItemAngle", + SourceType = "Camera", + ReferenceType = "Node", + ReferenceNodeName = "Moon", + DestinationType = "Focus" + }) + openspace.dashboard.addDashboardItem({ + Type = "DashboardItemAngle", + SourceType = "Camera", + SourceType = "Node", + SourceNodeName = "Saturn", + ReferenceType = "Node", + ReferenceNodeName = "Moon", + DestinationType = "Node", + DestinationNodeName = "Sun" + }) + + + openspace.spice.loadKernel(openspace.absPath("${SPICE}/naif0012.tls")) + openspace.spice.loadKernel(openspace.absPath("${SPICE}/pck00010.tpc")) + + openspace.time.setTime("2000 JAN 01") + dofile(openspace.absPath('${SCRIPTS}/bind_common_keys.lua')) +end + +function postInitialization() + openspace.printInfo("Setting default values") + + openspace.setPropertyValueSingle("Global Properties.GlobeBrowsing.GdalWrapper.LogGdalErrors", false) + openspace.setPropertyValueSingle("Earth.RenderableGlobe.Debug.LevelByProjectedAreaElseDistance", false) + + openspace.globebrowsing.goToGeo(58.5877, 16.1924, 20000000) + + openspace.printInfo("Done setting default values") + + -- Defined in scene_helper.lua + -- Used to create focus buttons for a subset of scenegraph nodes + mark_interesting_nodes({ + "Earth" + }) +end + + +return { + ScenePath = ".", + CommonFolder = "common", + Camera = { + Focus = "Earth", + Position = {0, 0, 0}, + Rotation = {0.758797, 0.221490, -0.605693, -0.091135}, + }, + Modules = { + -- # Solar system objects + "sun", + "mercury", + "venus", + "earth", + "moon", + "mars", + "jupiter", + "saturn", + "uranus", + "neptune", + -- "satellites", + + -- "grids", + -- "digitaluniverse", + "stars/digitaluniverse", + "milkyway/digitaluniverse", + + -- "missions/voyager" + } +} + diff --git a/data/scene/volumetricmilkyway.scene b/data/scene/volumetricmilkyway.scene index 0a82b3b19a..cdac50ae1f 100644 --- a/data/scene/volumetricmilkyway.scene +++ b/data/scene/volumetricmilkyway.scene @@ -5,9 +5,10 @@ function preInitialization() which the scene should start and other settings that might determine initialization critical objects. ]]-- + openspace.set_default_dashboard() - openspace.spice.loadKernel("${SPICE}/naif0012.tls") - openspace.spice.loadKernel("${SPICE}/pck00010.tpc") + openspace.spice.loadKernel(openspace.absPath("${SPICE}/naif0012.tls")) + openspace.spice.loadKernel(openspace.absPath("${SPICE}/pck00010.tpc")) openspace.time.setTime(openspace.time.currentWallTime()) dofile(openspace.absPath('${SCRIPTS}/bind_keys.lua')) diff --git a/data/scene/voyager.scene b/data/scene/voyager.scene index 7be5b4a3cf..1c9c4e6354 100644 --- a/data/scene/voyager.scene +++ b/data/scene/voyager.scene @@ -5,9 +5,10 @@ function preInitialization() which the scene should start and other settings that might determine initialization critical objects. ]]-- + openspace.set_default_dashboard() - openspace.spice.loadKernel("${SPICE}/naif0012.tls") - openspace.spice.loadKernel("${SPICE}/pck00010.tpc") + openspace.spice.loadKernel(openspace.absPath("${SPICE}/naif0012.tls")) + openspace.spice.loadKernel(openspace.absPath("${SPICE}/pck00010.tpc")) -- openspace.time.setTime(openspace.time.currentWallTime()) openspace.time.setTime("1977 SEP 10 12:00:00") diff --git a/ext/ghoul b/ext/ghoul index bbf1018920..52bb0bae10 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit bbf1018920fd1d774ff4851971543e18c08422f5 +Subproject commit 52bb0bae102b16d0fe8b5fe0575d2280ba9736e6 diff --git a/include/openspace/engine/openspaceengine.h b/include/openspace/engine/openspaceengine.h index 860c9f69bc..528218e52e 100644 --- a/include/openspace/engine/openspaceengine.h +++ b/include/openspace/engine/openspaceengine.h @@ -43,6 +43,7 @@ namespace ghoul::fontrendering { class FontManager; } namespace openspace { class ConfigurationManager; +class Dashboard; class DownloadManager; class GUI; class LoadingScreen; @@ -107,6 +108,7 @@ public: // Guaranteed to return a valid pointer ConfigurationManager& configurationManager(); LuaConsole& console(); + Dashboard& dashboard(); DownloadManager& downloadManager(); ModuleEngine& moduleEngine(); LoadingScreen& loadingScreen(); @@ -183,6 +185,7 @@ private: // Components std::unique_ptr _configurationManager; std::unique_ptr _sceneManager; + std::unique_ptr _dashboard; std::unique_ptr _downloadManager; std::unique_ptr _console; std::unique_ptr _moduleEngine; diff --git a/include/openspace/interaction/keybindingmanager.h b/include/openspace/interaction/keybindingmanager.h index b2f97ba854..eb9caf2a88 100644 --- a/include/openspace/interaction/keybindingmanager.h +++ b/include/openspace/interaction/keybindingmanager.h @@ -71,7 +71,7 @@ public: void removeKeyBinding(const std::string& key); std::vector> keyBinding( - const std::string& key) const; + const std::string& key) const; static scripting::LuaLibrary luaLibrary(); diff --git a/include/openspace/rendering/dashboard.h b/include/openspace/rendering/dashboard.h new file mode 100644 index 0000000000..8493f76698 --- /dev/null +++ b/include/openspace/rendering/dashboard.h @@ -0,0 +1,67 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_CORE___DASHBOARD___H__ +#define __OPENSPACE_CORE___DASHBOARD___H__ + +#include + +#include + +#include + +#include +#include + +namespace openspace { + +namespace scripting { struct LuaLibrary; } + +class DashboardItem; + +class Dashboard : public properties::PropertyOwner { +public: + Dashboard(); + + void render(glm::vec2& penPosition); + + void addDashboardItem(std::unique_ptr item); + bool hasItem(int index) const; + const DashboardItem& item(int index) const; + void removeDashboardItem(int index); + void removeDashboardItems(); + + /** + * Returns the Lua library that contains all Lua functions available to affect the + * rendering. + */ + static scripting::LuaLibrary luaLibrary(); + +private: + std::vector> _items; +}; + +} // openspace + +#endif // __OPENSPACE_CORE___DASHBOARD___H__ diff --git a/include/openspace/rendering/dashboarditem.h b/include/openspace/rendering/dashboarditem.h new file mode 100644 index 0000000000..b91ae71e17 --- /dev/null +++ b/include/openspace/rendering/dashboarditem.h @@ -0,0 +1,58 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_CORE___DASHBOARDITEM___H__ +#define __OPENSPACE_CORE___DASHBOARDITEM___H__ + +#include + +#include + +#include +#include + +#include + +namespace openspace { + +class DashboardItem : public properties::PropertyOwner { +public: + static std::unique_ptr createFromDictionary( + ghoul::Dictionary dictionary + ); + + DashboardItem(std::string name); + + bool isEnabled() const; + virtual void render(glm::vec2& penPosition) = 0; + + virtual glm::vec2 size() const = 0; + +protected: + properties::BoolProperty _isEnabled; +}; + +} // openspace + +#endif // __OPENSPACE_CORE___DASHBOARDITEM___H__ diff --git a/include/openspace/rendering/renderengine.h b/include/openspace/rendering/renderengine.h index 806c0b02d4..b7cce6c050 100644 --- a/include/openspace/rendering/renderengine.h +++ b/include/openspace/rendering/renderengine.h @@ -64,13 +64,6 @@ public: Invalid }; - enum class FrametimeType { - DtTimeAvg = 0, - FPS, - FPSAvg, - None - }; - RenderEngine(); ~RenderEngine(); @@ -129,8 +122,6 @@ public: std::string csPath, const ghoul::Dictionary& dictionary = ghoul::Dictionary()); - std::string progressToStr(int size, double t); - void removeRenderProgram( const std::unique_ptr& program); @@ -182,8 +173,6 @@ private: void setRenderer(std::unique_ptr renderer); RendererImplementation rendererFromString(const std::string& method) const; - void renderInformation(); - Camera* _camera; Scene* _scene; std::unique_ptr _raycasterManager; @@ -198,12 +187,6 @@ private: ghoul::Dictionary _resolveData; ScreenLog* _log; - properties::OptionProperty _frametimeType; - - //FrametimeType _frametimeType; - - properties::BoolProperty _showDate; - properties::BoolProperty _showInfo; properties::BoolProperty _showLog; properties::BoolProperty _showVersionInfo; properties::BoolProperty _showCameraInfo; diff --git a/include/openspace/util/openspacemodule.h b/include/openspace/util/openspacemodule.h index 97eaf3c9d0..8bc31baa04 100644 --- a/include/openspace/util/openspacemodule.h +++ b/include/openspace/util/openspacemodule.h @@ -82,6 +82,15 @@ public: */ virtual scripting::LuaLibrary luaLibrary() const; + /** + * Returns the Lua libraries that are defined by objects contained in this + * OpenSpaceModule. Note that the #luaLibrary library is *not* contained in this list + * as this is solely the list of libraries as defined by, for example Renderables, + * defined in the OpenSpaceModule. + * \return A list of libraries defined by items contained in this OpenSpaceModule + */ + virtual std::vector luaLibraries() const; + /** * Returns the minimum required OpenGL version of this OpenSpaceModule. Unless * overwritten, it returns an OpenGL version of 3.3. diff --git a/modules/base/CMakeLists.txt b/modules/base/CMakeLists.txt index dd6592ce96..6f35acd911 100644 --- a/modules/base/CMakeLists.txt +++ b/modules/base/CMakeLists.txt @@ -25,6 +25,14 @@ include(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake) set(HEADER_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/dashboard/dashboarditemangle.h + ${CMAKE_CURRENT_SOURCE_DIR}/dashboard/dashboarditemdate.h + ${CMAKE_CURRENT_SOURCE_DIR}/dashboard/dashboarditemdistance.h + ${CMAKE_CURRENT_SOURCE_DIR}/dashboard/dashboarditemframerate.h + ${CMAKE_CURRENT_SOURCE_DIR}/dashboard/dashboarditemmission.h + ${CMAKE_CURRENT_SOURCE_DIR}/dashboard/dashboarditemparallelconnection.h + ${CMAKE_CURRENT_SOURCE_DIR}/dashboard/dashboarditemsimulationincrement.h + ${CMAKE_CURRENT_SOURCE_DIR}/dashboard/dashboarditemspacing.h ${CMAKE_CURRENT_SOURCE_DIR}/rendering/modelgeometry.h ${CMAKE_CURRENT_SOURCE_DIR}/rendering/multimodelgeometry.h ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablemodel.h @@ -49,6 +57,14 @@ set(HEADER_FILES source_group("Header Files" FILES ${HEADER_FILES}) set(SOURCE_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/dashboard/dashboarditemangle.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/dashboard/dashboarditemdate.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/dashboard/dashboarditemdistance.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/dashboard/dashboarditemframerate.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/dashboard/dashboarditemmission.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/dashboard/dashboarditemparallelconnection.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/dashboard/dashboarditemsimulationincrement.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/dashboard/dashboarditemspacing.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rendering/modelgeometry.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rendering/multimodelgeometry.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablemodel.cpp diff --git a/modules/base/basemodule.cpp b/modules/base/basemodule.cpp index 1b5b75c9f4..d4d434d7db 100644 --- a/modules/base/basemodule.cpp +++ b/modules/base/basemodule.cpp @@ -31,6 +31,15 @@ #include +#include +#include +#include +#include +#include +#include +#include +#include + #include #include #include @@ -78,6 +87,22 @@ void BaseModule::internalInitialize() { fSsRenderable->registerClass("ScreenSpaceImageOnline"); fSsRenderable->registerClass("ScreenSpaceFramebuffer"); + auto fDashboard = FactoryManager::ref().factory(); + ghoul_assert(fDashboard, "Dashboard factory was not created"); + + fDashboard->registerClass("DashboardItemAngle"); + fDashboard->registerClass("DashboardItemDate"); + fDashboard->registerClass("DashboardItemDistance"); + fDashboard->registerClass("DashboardItemFramerate"); + fDashboard->registerClass("DashboardItemMission"); + fDashboard->registerClass( + "DashboardItemParallelConnection" + ); + fDashboard->registerClass( + "DashboardItemSimulationIncrement" + ); + fDashboard->registerClass("DashboardItemSpacing"); + auto fRenderable = FactoryManager::ref().factory(); ghoul_assert(fRenderable, "Renderable factory was not created"); @@ -114,24 +139,43 @@ void BaseModule::internalInitialize() { std::vector BaseModule::documentations() const { return { + DashboardItemDate::Documentation(), + DashboardItemDistance::Documentation(), + DashboardItemFramerate::Documentation(), + DashboardItemMission::Documentation(), + DashboardItemParallelConnection::Documentation(), + DashboardItemSimulationIncrement::Documentation(), + DashboardItemSpacing::Documentation(), + RenderableModel::Documentation(), RenderablePlane::Documentation(), RenderableSphere::Documentation(), RenderableTrailOrbit::Documentation(), RenderableTrailTrajectory::Documentation(), + ScreenSpaceDashboard::Documentation(), ScreenSpaceFramebuffer::Documentation(), ScreenSpaceImageLocal::Documentation(), ScreenSpaceImageOnline::Documentation(), + FixedRotation::Documentation(), LuaRotation::Documentation(), StaticRotation::Documentation(), + LuaScale::Documentation(), StaticScale::Documentation(), + LuaTranslation::Documentation(), StaticTranslation::Documentation(), + modelgeometry::ModelGeometry::Documentation(), }; } +std::vector BaseModule::luaLibraries() const { + return { + ScreenSpaceDashboard::luaLibrary() + }; +} + } // namespace openspace diff --git a/modules/base/basemodule.h b/modules/base/basemodule.h index 8cb316d515..d984e69bfa 100644 --- a/modules/base/basemodule.h +++ b/modules/base/basemodule.h @@ -35,7 +35,9 @@ public: BaseModule(); virtual ~BaseModule() = default; + std::vector documentations() const override; + std::vector luaLibraries() const override; protected: void internalInitialize() override; diff --git a/modules/base/dashboard/dashboarditemangle.cpp b/modules/base/dashboard/dashboarditemangle.cpp new file mode 100644 index 0000000000..5ac9dceb97 --- /dev/null +++ b/modules/base/dashboard/dashboarditemangle.cpp @@ -0,0 +1,443 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +namespace { + const char* KeyFontMono = "Mono"; + + const float DefaultFontSize = 10.f; + + static const openspace::properties::Property::PropertyInfo FontNameInfo = { + "FontName", + "Font Name", + "This value is the name of the font that is used. It can either refer to an " + "internal name registered previously, or it can refer to a path that is used." + }; + + static const openspace::properties::Property::PropertyInfo FontSizeInfo = { + "FontSize", + "Font Size", + "This value determines the size of the font that is used to render the date." + }; + + static const openspace::properties::Property::PropertyInfo SourceTypeInfo = { + "SourceType", + "Source Type", + "The type of position that is used as the triangle apex used to calculate the " + "angle. The default value is 'Camera'." + }; + + static const openspace::properties::Property::PropertyInfo SourceNodeNameInfo = { + "SourceNodeName", + "Source Node Name", + "If a scene graph node is selected as type, this value specifies the name of the " + "node that is to be used as the apex of the triangle used to calculate the " + "angle. The computed angle is the incident angle to Source in the triangle (" + "Source, Reference, Destination)." + }; + + static const openspace::properties::Property::PropertyInfo ReferenceTypeInfo = { + "ReferenceType", + "Reference Type", + "The type of position that is used as the destination of the reference line used " + "to calculate the angle. The computed angle is the incident angle to Source in " + "the triangle (Source, Reference, Destination)." + }; + + static const openspace::properties::Property::PropertyInfo ReferenceNodeNameInfo = { + "ReferenceNodeName", + "Reference Node Name", + "If a scene graph node is selected as type, this value specifies the name of the " + "node that is to be used as the reference direction to compute the angle." + }; + + static const openspace::properties::Property::PropertyInfo DestinationTypeInfo = { + "DestinationType", + "Destination Type", + "The type of position that is used as the destination to calculate the angle. " + "The computed angle is the incident angle to Source in the triangle (" + "Source, Reference, Destination). The default value for this is 'Focus'." + }; + + static const openspace::properties::Property::PropertyInfo DestinationNodeNameInfo = { + "DestinationNodeName", + "Destination Node Name", + "If a scene graph node is selected as type, this value specifies the name of the " + "node that is to be used as the destination for computing the angle." + }; +} // namespace + +namespace openspace { + +documentation::Documentation DashboardItemAngle::Documentation() { + using namespace documentation; + return { + "DashboardItem Angle", + "base_dashboarditem_angle", + { + { + "Type", + new StringEqualVerifier("DashboardItemAngle"), + Optional::No + }, + { + FontNameInfo.identifier, + new StringVerifier, + Optional::Yes, + FontNameInfo.description + }, + { + FontSizeInfo.identifier, + new IntVerifier, + Optional::Yes, + FontSizeInfo.description + }, + { + SourceTypeInfo.identifier, + new StringInListVerifier({ + "Node", "Focus", "Camera" + }), + Optional::Yes, + SourceTypeInfo.description + }, + { + SourceNodeNameInfo.identifier, + new StringVerifier, + Optional::Yes, + SourceNodeNameInfo.description + }, + { + ReferenceTypeInfo.identifier, + new StringInListVerifier({ + "Node", "Focus", "Camera" + }), + Optional::No, + ReferenceTypeInfo.description + }, + { + ReferenceNodeNameInfo.identifier, + new StringVerifier, + Optional::Yes, + ReferenceNodeNameInfo.description + }, + { + DestinationTypeInfo.identifier, + new StringInListVerifier({ + "Node", "Focus", "Camera" + }), + Optional::Yes, + DestinationTypeInfo.description + }, + { + DestinationNodeNameInfo.identifier, + new StringVerifier, + Optional::Yes, + DestinationNodeNameInfo.description + } + } + }; +} + +DashboardItemAngle::DashboardItemAngle(ghoul::Dictionary dictionary) + : DashboardItem("Distance") + , _fontName(FontNameInfo, KeyFontMono) + , _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f) + , _source{ + properties::OptionProperty( + SourceTypeInfo, + properties::OptionProperty::DisplayType::Dropdown + ), + properties::StringProperty(SourceNodeNameInfo), + nullptr + } + , _reference{ + properties::OptionProperty( + ReferenceTypeInfo, + properties::OptionProperty::DisplayType::Dropdown + ), + properties::StringProperty(ReferenceNodeNameInfo), + nullptr + } + , _destination{ + properties::OptionProperty( + DestinationTypeInfo, + properties::OptionProperty::DisplayType::Dropdown + ), + properties::StringProperty(DestinationNodeNameInfo), + nullptr + } +{ + documentation::testSpecificationAndThrow( + Documentation(), + dictionary, + "DashboardItemAngle" + ); + + if (dictionary.hasKey(FontNameInfo.identifier)) { + _fontName = dictionary.value(FontNameInfo.identifier); + } + if (dictionary.hasKey(FontSizeInfo.identifier)) { + _fontSize = static_cast( + dictionary.value(FontSizeInfo.identifier) + ); + } + + _fontName.onChange([this]() { + _font = OsEng.fontManager().font(_fontName, _fontSize); + }); + addProperty(_fontName); + + _fontSize.onChange([this]() { + _font = OsEng.fontManager().font(_fontName, _fontSize); + }); + addProperty(_fontSize); + + _source.type.addOptions({ + { Type::Node, "Node" }, + { Type::Focus, "Focus" }, + { Type::Camera, "Camera" } + }); + _source.type.onChange([this]() { + _source.nodeName.setVisibility( + properties::Property::Visibility(_source.type == Type::Node) + ); + }); + if (dictionary.hasKey(SourceTypeInfo.identifier)) { + std::string value = dictionary.value(SourceTypeInfo.identifier); + if (value == "Node") { + _source.type = Type::Node; + } + else if (value == "Focus") { + _source.type = Type::Focus; + } + else { + _source.type = Type::Camera; + } + } + else { + _source.type = Type::Camera; + } + addProperty(_source.type); + + _source.nodeName.onChange([this]() { + _source.node = nullptr; + }); + if (_source.type == Type::Node) { + if (dictionary.hasKey(SourceNodeNameInfo.identifier)) { + _source.nodeName = dictionary.value( + SourceNodeNameInfo.identifier + ); + } + else { + LERRORC( + "DashboardItemAngle", + "Node type was selected for source but no node specified" + ); + } + } + addProperty(_source.nodeName); + + + _reference.type.addOptions({ + { Type::Node, "Node" }, + { Type::Focus, "Focus" }, + { Type::Camera, "Camera" } + }); + _reference.type.onChange([this]() { + _reference.nodeName.setVisibility( + properties::Property::Visibility(_reference.type == Type::Node) + ); + }); + std::string value = dictionary.value(ReferenceTypeInfo.identifier); + if (value == "Node") { + _reference.type = Type::Node; + } + else if (value == "Focus") { + _reference.type = Type::Focus; + } + else { + _reference.type = Type::Camera; + } + addProperty(_reference.type); + + _reference.nodeName.onChange([this]() { + _reference.node = nullptr; + }); + if (_reference.type == Type::Node) { + if (dictionary.hasKey(ReferenceNodeNameInfo.identifier)) { + _reference.nodeName = dictionary.value( + ReferenceNodeNameInfo.identifier + ); + } + else { + LERRORC( + "DashboardItemAngle", + "Node type was selected for reference but no node specified" + ); + } + } + addProperty(_source.nodeName); + + _destination.type.addOptions({ + { Type::Node, "Node" }, + { Type::Focus, "Focus" }, + { Type::Camera, "Camera" } + }); + _destination.type.onChange([this]() { + _destination.nodeName.setVisibility( + properties::Property::Visibility(_source.type == Type::Node) + ); + }); + if (dictionary.hasKey(DestinationTypeInfo.identifier)) { + std::string value = dictionary.value(DestinationTypeInfo.identifier); + if (value == "Node") { + _destination.type = Type::Node; + } + else if (value == "Focus") { + _destination.type = Type::Focus; + } + else { + _destination.type = Type::Camera; + } + } + else { + _destination.type = Type::Focus; + } + addProperty(_destination.type); + _destination.nodeName.onChange([this]() { + _destination.node = nullptr; + }); + if (_destination.type == Type::Node) { + if (dictionary.hasKey(DestinationNodeNameInfo.identifier)) { + _destination.nodeName = dictionary.value( + DestinationNodeNameInfo.identifier + ); + } + else { + LERRORC( + "DashboardItemAngle", + "Node type was selected for destination but no node specified" + ); + } + } + addProperty(_destination.nodeName); + + _font = OsEng.fontManager().font(_fontName, _fontSize); +} + +std::pair DashboardItemAngle::positionAndLabel( + Component& comp) const +{ + if (comp.type == Type::Node) { + if (!comp.node) { + comp.node = OsEng.renderEngine().scene()->sceneGraphNode( + comp.nodeName + ); + + if (!comp.node) { + LERRORC( + "DashboardItemAngle", + "Could not find node '" + comp.nodeName.value() + "'" + ); + return { glm::dvec3(0.0), "Node" }; + } + } + } + + switch (comp.type) { + case Type::Node: + return { comp.node->worldPosition(), comp.node->name() }; + case Type::Focus: + return { + OsEng.navigationHandler().focusNode()->worldPosition(), + "focus" + }; + case Type::Camera: + return { OsEng.renderEngine().camera()->positionVec3(), "camera" }; + default: + return { glm::dvec3(0.0), "Unknown" }; + } +}; + +void DashboardItemAngle::render(glm::vec2& penPosition) { + std::pair sourceInfo = positionAndLabel(_source); + std::pair referenceInfo = positionAndLabel(_reference); + std::pair destinationInfo = positionAndLabel(_destination); + + glm::dvec3 a = referenceInfo.first - sourceInfo.first; + glm::dvec3 b = destinationInfo.first - sourceInfo.first; + + if (glm::length(a) == 0.0 || glm::length(b) == 0) { + penPosition.y -= _font->height(); + RenderFont( + *_font, + penPosition, + "Could not compute angle at %s between %s and %s", + sourceInfo.second.c_str(), + destinationInfo.second.c_str(), + referenceInfo.second.c_str() + ); + } + else { + double angle = glm::degrees( + glm::acos(glm::dot(a, b) / (glm::length(a) * glm::length(b))) + ); + + penPosition.y -= _font->height(); + RenderFont( + *_font, + penPosition, + "Angle at %s between %s and %s: %f degrees", + sourceInfo.second.c_str(), + destinationInfo.second.c_str(), + referenceInfo.second.c_str(), + angle + ); + } +} + +glm::vec2 DashboardItemAngle::size() const { + double angle = 120; + + return ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox( + *_font, + "Angle: %f %s", + angle + ).boundingBox; +} + +} // namespace openspace diff --git a/modules/base/dashboard/dashboarditemangle.h b/modules/base/dashboard/dashboarditemangle.h new file mode 100644 index 0000000000..a272c6e6a4 --- /dev/null +++ b/modules/base/dashboard/dashboarditemangle.h @@ -0,0 +1,82 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_BASE___DASHBOARDITEMANGLE___H__ +#define __OPENSPACE_MODULE_BASE___DASHBOARDITEMANGLE___H__ + +#include + +#include +#include +#include + +#include + +namespace ghoul::fontrendering { class Font; } + +namespace openspace { + +class SceneGraphNode; + +namespace documentation { struct Documentation; } + +class DashboardItemAngle : public DashboardItem { +public: + DashboardItemAngle(ghoul::Dictionary dictionary); + virtual ~DashboardItemAngle() = default; + + void render(glm::vec2& penPosition) override; + + glm::vec2 size() const override; + + static documentation::Documentation Documentation(); + +private: + enum Type { + Node = 0, + Focus, + Camera + }; + + struct Component { + properties::OptionProperty type; + properties::StringProperty nodeName; + SceneGraphNode* node; + }; + + std::pair positionAndLabel(Component& mainComp) const; + + properties::StringProperty _fontName; + properties::FloatProperty _fontSize; + + Component _source; + Component _reference; + Component _destination; + + std::shared_ptr _font; +}; + +} // namespace openspace + +#endif // __OPENSPACE_MODULE_BASE___DASHBOARDITEMANGLE___H__ diff --git a/modules/base/dashboard/dashboarditemdate.cpp b/modules/base/dashboard/dashboarditemdate.cpp new file mode 100644 index 0000000000..79e0cc15e6 --- /dev/null +++ b/modules/base/dashboard/dashboarditemdate.cpp @@ -0,0 +1,132 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + +#include +#include +#include +#include + +#include +#include + +namespace { + const char* KeyFontMono = "Mono"; + const float DefaultFontSize = 15.f; + + static const openspace::properties::Property::PropertyInfo FontNameInfo = { + "FontName", + "Font Name", + "This value is the name of the font that is used. It can either refer to an " + "internal name registered previously, or it can refer to a path that is used." + }; + + static const openspace::properties::Property::PropertyInfo FontSizeInfo = { + "FontSize", + "Font Size", + "This value determines the size of the font that is used to render the date." + }; +} // namespace + +namespace openspace { + +documentation::Documentation DashboardItemDate::Documentation() { + using namespace documentation; + return { + "DashboardItem Date", + "base_dashboarditem_date", + { + { + "Type", + new StringEqualVerifier("DashboardItemDate"), + Optional::No + }, + { + FontNameInfo.identifier, + new StringVerifier, + Optional::Yes, + FontNameInfo.description + }, + { + FontSizeInfo.identifier, + new IntVerifier, + Optional::Yes, + FontSizeInfo.description + } + } + }; +} + +DashboardItemDate::DashboardItemDate(ghoul::Dictionary dictionary) + : DashboardItem("Date") + , _fontName(FontNameInfo, KeyFontMono) + , _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f) +{ + documentation::testSpecificationAndThrow( + Documentation(), + dictionary, + "DashboardItemDate" + ); + + if (dictionary.hasKey(FontNameInfo.identifier)) { + _fontName = dictionary.value(FontNameInfo.identifier); + } + _fontName.onChange([this](){ + _font = OsEng.fontManager().font(_fontName, _fontSize); + }); + addProperty(_fontName); + + if (dictionary.hasKey(FontSizeInfo.identifier)) { + _fontSize = static_cast( + dictionary.value(FontSizeInfo.identifier) + ); + } + _fontSize.onChange([this](){ + _font = OsEng.fontManager().font(_fontName, _fontSize); + }); + addProperty(_fontSize); + + _font = OsEng.fontManager().font(_fontName, _fontSize); +} + +void DashboardItemDate::render(glm::vec2& penPosition) { + penPosition.y -= _font->height(); + RenderFont( + *_font, + penPosition, + "Date: %s", + OsEng.timeManager().time().UTC().c_str() + ); +} + +glm::vec2 DashboardItemDate::size() const { + return ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox( + *_font, + "Date: %s", + OsEng.timeManager().time().UTC().c_str() + ).boundingBox; +} + +} // namespace openspace diff --git a/modules/base/dashboard/dashboarditemdate.h b/modules/base/dashboard/dashboarditemdate.h new file mode 100644 index 0000000000..6359b604a2 --- /dev/null +++ b/modules/base/dashboard/dashboarditemdate.h @@ -0,0 +1,61 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_BASE___DASHBOARDITEMDATE___H__ +#define __OPENSPACE_MODULE_BASE___DASHBOARDITEMDATE___H__ + +#include + +#include +#include + +namespace ghoul::fontrendering { + class Font; +} // namespace ghoul::fontrendering + +namespace openspace { + +namespace documentation { struct Documentation; } + +class DashboardItemDate : public DashboardItem { +public: + DashboardItemDate(ghoul::Dictionary dictionary); + ~DashboardItemDate() = default; + + void render(glm::vec2& penPosition) override; + + glm::vec2 size() const override; + + static documentation::Documentation Documentation(); + +private: + properties::StringProperty _fontName; + properties::FloatProperty _fontSize; + + std::shared_ptr _font; +}; + +} // namespace openspace + +#endif // __OPENSPACE_MODULE_BASE___DASHBOARDITEMDATE___H__ diff --git a/modules/base/dashboard/dashboarditemdistance.cpp b/modules/base/dashboard/dashboarditemdistance.cpp new file mode 100644 index 0000000000..4be8128b6c --- /dev/null +++ b/modules/base/dashboard/dashboarditemdistance.cpp @@ -0,0 +1,383 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +namespace { + const char* KeyFontMono = "Mono"; + + const float DefaultFontSize = 10.f; + + static const openspace::properties::Property::PropertyInfo FontNameInfo = { + "FontName", + "Font Name", + "This value is the name of the font that is used. It can either refer to an " + "internal name registered previously, or it can refer to a path that is used." + }; + + static const openspace::properties::Property::PropertyInfo FontSizeInfo = { + "FontSize", + "Font Size", + "This value determines the size of the font that is used to render the date." + }; + + static const openspace::properties::Property::PropertyInfo SourceTypeInfo = { + "SourceType", + "Source Type", + "The type of position that is used as the source to calculate the distance. The " + "default value is 'Camera'." + }; + + static const openspace::properties::Property::PropertyInfo SourceNodeNameInfo = { + "SourceNodeName", + "Source Node Name", + "If a scene graph node is selected as type, this value specifies the name of the " + "node that is to be used as the source for computing the distance." + }; + + static const openspace::properties::Property::PropertyInfo DestinationTypeInfo = { + "DestinationType", + "Destination Type", + "The type of position that is used as the destination to calculate the distance. " + "The default value for this is 'Focus'." + }; + + static const openspace::properties::Property::PropertyInfo DestinationNodeNameInfo = { + "DestinationNodeName", + "Destination Node Name", + "If a scene graph node is selected as type, this value specifies the name of the " + "node that is to be used as the destination for computing the distance." + }; +} // namespace + +namespace openspace { + +documentation::Documentation DashboardItemDistance::Documentation() { + using namespace documentation; + return { + "DashboardItem Distance", + "base_dashboarditem_distance", + { + { + "Type", + new StringEqualVerifier("DashboardItemDistance"), + Optional::No + }, + { + FontNameInfo.identifier, + new StringVerifier, + Optional::Yes, + FontNameInfo.description + }, + { + FontSizeInfo.identifier, + new IntVerifier, + Optional::Yes, + FontSizeInfo.description + }, + { + SourceTypeInfo.identifier, + new StringInListVerifier({ + "Node", "Node Surface", "Focus", "Camera" + }), + Optional::Yes, + SourceTypeInfo.description + }, + { + SourceNodeNameInfo.identifier, + new StringVerifier, + Optional::Yes, + SourceNodeNameInfo.description + }, + { + DestinationTypeInfo.identifier, + new StringInListVerifier({ + "Node", "Node Surface", "Focus", "Camera" + }), + Optional::Yes, + DestinationTypeInfo.description + }, + { + DestinationNodeNameInfo.identifier, + new StringVerifier, + Optional::Yes, + DestinationNodeNameInfo.description + } + } + }; +} + +DashboardItemDistance::DashboardItemDistance(ghoul::Dictionary dictionary) + : DashboardItem("Distance") + , _fontName(FontNameInfo, KeyFontMono) + , _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f) + , _source{ + properties::OptionProperty( + SourceTypeInfo, + properties::OptionProperty::DisplayType::Dropdown + ), + properties::StringProperty(SourceNodeNameInfo), + nullptr + } + , _destination{ + properties::OptionProperty( + DestinationTypeInfo, + properties::OptionProperty::DisplayType::Dropdown + ), + properties::StringProperty(DestinationNodeNameInfo), + nullptr + } +{ + documentation::testSpecificationAndThrow( + Documentation(), + dictionary, + "DashboardItemDistance" + ); + + if (dictionary.hasKey(FontNameInfo.identifier)) { + _fontName = dictionary.value(FontNameInfo.identifier); + } + if (dictionary.hasKey(FontSizeInfo.identifier)) { + _fontSize = static_cast( + dictionary.value(FontSizeInfo.identifier) + ); + } + + _fontName.onChange([this]() { + _font = OsEng.fontManager().font(_fontName, _fontSize); + }); + addProperty(_fontName); + + _fontSize.onChange([this]() { + _font = OsEng.fontManager().font(_fontName, _fontSize); + }); + addProperty(_fontSize); + + _source.type.addOptions({ + { Type::Node, "Node" }, + { Type::NodeSurface, "Node Surface" }, + { Type::Focus, "Focus" }, + { Type::Camera, "Camera" } + }); + _source.type.onChange([this]() { + _source.nodeName.setVisibility( + properties::Property::Visibility( + _source.type == Type::Node || _source.type == Type::NodeSurface + ) + ); + }); + if (dictionary.hasKey(SourceTypeInfo.identifier)) { + std::string value = dictionary.value(SourceTypeInfo.identifier); + if (value == "Node") { + _source.type = Type::Node; + } + else if (value == "Node Surface") { + _source.type = Type::NodeSurface; + } + else if (value == "Focus") { + _source.type = Type::Focus; + } + else { + _source.type = Type::Camera; + } + } + else { + _source.type = Type::Camera; + } + addProperty(_source.type); + + _source.nodeName.onChange([this]() { + _source.node = nullptr; + }); + if (_source.type == Type::Node || _source.type == Type::NodeSurface) { + if (dictionary.hasKey(SourceNodeNameInfo.identifier)) { + _source.nodeName = dictionary.value( + SourceNodeNameInfo.identifier + ); + } + else { + LERRORC( + "DashboardItemDistance", + "Node type was selected for source but no node specified" + ); + } + } + addProperty(_source.nodeName); + + _destination.type.addOptions({ + { Type::Node, "Node" }, + { Type::NodeSurface, "Node Surface" }, + { Type::Focus, "Focus" }, + { Type::Camera, "Camera" } + }); + _destination.type.onChange([this]() { + _destination.nodeName.setVisibility( + properties::Property::Visibility( + _source.type == Type::Node || _source.type == Type::NodeSurface + ) + ); + }); + if (dictionary.hasKey(DestinationTypeInfo.identifier)) { + std::string value = dictionary.value(DestinationTypeInfo.identifier); + if (value == "Node") { + _destination.type = Type::Node; + } + else if (value == "Node Surface") { + _destination.type = Type::NodeSurface; + } + else if (value == "Focus") { + _destination.type = Type::Focus; + } + else { + _destination.type = Type::Camera; + } + } + else { + _destination.type = Type::Focus; + } + addProperty(_destination.type); + _destination.nodeName.onChange([this]() { + _destination.node = nullptr; + }); + if (_destination.type == Type::Node || _destination.type == Type::NodeSurface) { + if (dictionary.hasKey(DestinationNodeNameInfo.identifier)) { + _destination.nodeName = dictionary.value( + DestinationNodeNameInfo.identifier + ); + } + else { + LERRORC( + "DashboardItemDistance", + "Node type was selected for destination but no node specified" + ); + } + } + addProperty(_destination.nodeName); + + _font = OsEng.fontManager().font(_fontName, _fontSize); +} + +std::pair DashboardItemDistance::positionAndLabel( + Component& mainComp, + Component& otherComp) const +{ + if (mainComp.type == Type::Node || mainComp.type == Type::NodeSurface) { + if (!mainComp.node) { + mainComp.node = OsEng.renderEngine().scene()->sceneGraphNode( + mainComp.nodeName + ); + + if (!mainComp.node) { + LERRORC( + "DashboardItemDistance", + "Could not find node '" + mainComp.nodeName.value() + "'" + ); + return { glm::dvec3(0.0), "Node" }; + } + } + } + + switch (mainComp.type) { + case Type::Node: + return { mainComp.node->worldPosition(), mainComp.node->name() }; + case Type::NodeSurface: + { + glm::dvec3 otherPos; + if (otherComp.type == Type::NodeSurface) { + // We are only interested in the direction, and we want to prevent + // infinite recursion + otherPos = otherComp.node->worldPosition(); + } + else { + otherPos = positionAndLabel(otherComp, mainComp).first; + } + glm::dvec3 thisPos = mainComp.node->worldPosition(); + + glm::dvec3 dir = glm::normalize(otherPos - thisPos); + glm::dvec3 dirLength = dir * glm::dvec3(mainComp.node->boundingSphere()); + + return { thisPos + dirLength, "surface of " + mainComp.node->name() }; + } + case Type::Focus: + return { + OsEng.navigationHandler().focusNode()->worldPosition(), + "focus" + }; + case Type::Camera: + return { OsEng.renderEngine().camera()->positionVec3(), "camera" }; + default: + return { glm::dvec3(0.0), "Unknown" }; + } +}; + +void DashboardItemDistance::render(glm::vec2& penPosition) { + std::pair sourceInfo = positionAndLabel( + _source, + _destination + ); + std::pair destinationInfo = positionAndLabel( + _destination, + _source + ); + + double distance = glm::length(sourceInfo.first - destinationInfo.first); + std::pair dist = simplifyDistance(distance); + penPosition.y -= _font->height(); + RenderFont( + *_font, + penPosition, + "Distance from %s to %s: %f %s", + sourceInfo.second.c_str(), + destinationInfo.second.c_str(), + dist.first, + dist.second.c_str() + ); +} + +glm::vec2 DashboardItemDistance::size() const { + double distance = 1e20; + std::pair dist = simplifyDistance(distance); + + return ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox( + *_font, + "Distance from focus: %f %s", + dist.first, + dist.second.c_str() + ).boundingBox; +} + +} // namespace openspace diff --git a/modules/base/dashboard/dashboarditemdistance.h b/modules/base/dashboard/dashboarditemdistance.h new file mode 100644 index 0000000000..bffdd2ab15 --- /dev/null +++ b/modules/base/dashboard/dashboarditemdistance.h @@ -0,0 +1,85 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_BASE___DASHBOARDITEMDISTANCE___H__ +#define __OPENSPACE_MODULE_BASE___DASHBOARDITEMDISTANCE___H__ + +#include + +#include +#include +#include + +#include + +namespace ghoul::fontrendering { class Font; } + +namespace openspace { + +class SceneGraphNode; + +namespace documentation { struct Documentation; } + +class DashboardItemDistance : public DashboardItem { +public: + DashboardItemDistance(ghoul::Dictionary dictionary); + virtual ~DashboardItemDistance() = default; + + void render(glm::vec2& penPosition) override; + + glm::vec2 size() const override; + + static documentation::Documentation Documentation(); + +private: + enum Type { + Node = 0, + NodeSurface, + Focus, + Camera + }; + + struct Component { + properties::OptionProperty type; + properties::StringProperty nodeName; + SceneGraphNode* node; + }; + + std::pair positionAndLabel(Component& mainComp, + Component& otherComp) const; + + properties::StringProperty _fontName; + properties::FloatProperty _fontSize; + + + + Component _source; + Component _destination; + + std::shared_ptr _font; +}; + +} // namespace openspace + +#endif // __OPENSPACE_MODULE_BASE___DASHBOARDITEMDISTANCE___H__ diff --git a/modules/base/dashboard/dashboarditemframerate.cpp b/modules/base/dashboard/dashboarditemframerate.cpp new file mode 100644 index 0000000000..23063067f9 --- /dev/null +++ b/modules/base/dashboard/dashboarditemframerate.cpp @@ -0,0 +1,220 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + +#include +#include +#include +#include + +#include +#include + +namespace { + const char* KeyFontMono = "Mono"; + const float DefaultFontSize = 10.f; + + static const openspace::properties::Property::PropertyInfo FontNameInfo = { + "FontName", + "Font Name", + "This value is the name of the font that is used. It can either refer to an " + "internal name registered previously, or it can refer to a path that is used." + }; + + static const openspace::properties::Property::PropertyInfo FontSizeInfo = { + "FontSize", + "Font Size", + "This value determines the size of the font that is used to render the date." + }; + + static const openspace::properties::Property::PropertyInfo FrametimeInfo = { + "FrametimeType", + "Type of the frame time display", + "This value determines the units in which the frame time is displayed." + }; +} // namespace + +namespace openspace { + +documentation::Documentation DashboardItemFramerate::Documentation() { + using namespace documentation; + return { + "DashboardItem Framerate", + "base_dashboarditem_framerate", + { + { + "Type", + new StringEqualVerifier("DashboardItemFramerate"), + Optional::No + }, + { + FontNameInfo.identifier, + new StringVerifier, + Optional::Yes, + FontNameInfo.description + }, + { + FontSizeInfo.identifier, + new IntVerifier, + Optional::Yes, + FontSizeInfo.description + }, + { + FrametimeInfo.identifier, + new StringInListVerifier({ + "Average Deltatime", "Frames per second", "Average frames per second", + "None" + }), + Optional::Yes, + FrametimeInfo.description + } + } + }; +} + +DashboardItemFramerate::DashboardItemFramerate(ghoul::Dictionary dictionary) + : DashboardItem("Framerate") + , _fontName(FontNameInfo, KeyFontMono) + , _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f) + , _frametimeType(FrametimeInfo, properties::OptionProperty::DisplayType::Dropdown) +{ + documentation::testSpecificationAndThrow( + Documentation(), + dictionary, + "DashboardItemDate" + ); + + if (dictionary.hasKey(FontNameInfo.identifier)) { + _fontName = dictionary.value(FontNameInfo.identifier); + } + _fontName.onChange([this](){ + _font = OsEng.fontManager().font(_fontName, _fontSize); + }); + addProperty(_fontName); + + if (dictionary.hasKey(FontSizeInfo.identifier)) { + _fontSize = static_cast( + dictionary.value(FontSizeInfo.identifier) + ); + } + _fontSize.onChange([this](){ + _font = OsEng.fontManager().font(_fontName, _fontSize); + }); + addProperty(_fontSize); + + _frametimeType.addOptions({ + { static_cast(FrametimeType::DtTimeAvg), "Average Deltatime" }, + { static_cast(FrametimeType::FPS), "Frames per second" }, + { static_cast(FrametimeType::FPSAvg), "Average frames per second" }, + { static_cast(FrametimeType::None), "None" } + }); + + if (dictionary.hasKey(FrametimeInfo.identifier)) { + std::string value = dictionary.value(FrametimeInfo.identifier); + if (value == "Average Deltatime") { + _frametimeType = static_cast(FrametimeType::DtTimeAvg); + } + else if (value == "Frames per second") { + _frametimeType = static_cast(FrametimeType::FPS); + } + else if (value == "Average frames per second") { + _frametimeType = static_cast(FrametimeType::FPSAvg); + } + else { + _frametimeType = static_cast(FrametimeType::None); + } + } + else { + _frametimeType = static_cast(FrametimeType::FPS); + } + addProperty(_frametimeType); + + _font = OsEng.fontManager().font(_fontName, _fontSize); +} + +void DashboardItemFramerate::render(glm::vec2& penPosition) { + FrametimeType frametimeType = FrametimeType(_frametimeType.value()); + switch (frametimeType) { + case FrametimeType::DtTimeAvg: + penPosition.y -= _font->height(); + RenderFont( + *_font, + penPosition, + "Avg. Frametime: %.5f", + OsEng.windowWrapper().averageDeltaTime() + ); + break; + case FrametimeType::FPS: + penPosition.y -= _font->height(); + RenderFont( + *_font, + penPosition, + "FPS: %3.2f", + 1.0 / OsEng.windowWrapper().deltaTime() + ); + break; + case FrametimeType::FPSAvg: + penPosition.y -= _font->height(); + RenderFont( + *_font, + penPosition, + "Avg. FPS: %3.2f", + 1.0 / OsEng.windowWrapper().averageDeltaTime() + ); + break; + case FrametimeType::None: + break; + } +} + +glm::vec2 DashboardItemFramerate::size() const { + FrametimeType frametimeType = FrametimeType(_frametimeType.value()); + switch (frametimeType) { + case FrametimeType::DtTimeAvg: + return ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox( + *_font, + "Avg. Frametime: %.5f", + OsEng.windowWrapper().averageDeltaTime() + ).boundingBox; + case FrametimeType::FPS: + return ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox( + *_font, + "FPS: %3.2f", + 1.0 / OsEng.windowWrapper().deltaTime() + ).boundingBox; + case FrametimeType::FPSAvg: + return ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox( + *_font, + "Avg. FPS: %3.2f", + 1.0 / OsEng.windowWrapper().averageDeltaTime() + ).boundingBox; + case FrametimeType::None: + return { 0.f, 0.f }; + default: + return { 0.f, 0.f }; + } +} + +} // namespace openspace diff --git a/modules/base/dashboard/dashboarditemframerate.h b/modules/base/dashboard/dashboarditemframerate.h new file mode 100644 index 0000000000..1ede425ba8 --- /dev/null +++ b/modules/base/dashboard/dashboarditemframerate.h @@ -0,0 +1,69 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_CORE___DASHBOARDFRAMERATE___H__ +#define __OPENSPACE_CORE___DASHBOARDFRAMERATE___H__ + +#include + +#include +#include +#include + +#include + +namespace ghoul::fontrendering { + class Font; +} // namespace ghoul::fontrendering + +namespace openspace { + +namespace documentation { struct Documentation; } + +class DashboardItemFramerate : public DashboardItem { +public: + enum class FrametimeType { + DtTimeAvg = 0, + FPS, + FPSAvg, + None + }; + + DashboardItemFramerate(ghoul::Dictionary dict); + + void render(glm::vec2& penPosition) override; + glm::vec2 size() const override; + static documentation::Documentation Documentation(); + +private: + properties::StringProperty _fontName; + properties::FloatProperty _fontSize; + properties::OptionProperty _frametimeType; + + std::shared_ptr _font; +}; + +} // openspace + +#endif // __OPENSPACE_CORE___DASHBOARDFRAMERATE___H__ diff --git a/modules/base/dashboard/dashboarditemmission.cpp b/modules/base/dashboard/dashboarditemmission.cpp new file mode 100644 index 0000000000..9201466191 --- /dev/null +++ b/modules/base/dashboard/dashboarditemmission.cpp @@ -0,0 +1,247 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +namespace { + const char* KeyFontMono = "Mono"; + const float DefaultFontSize = 15.f; + + static const openspace::properties::Property::PropertyInfo FontNameInfo = { + "FontName", + "Font Name", + "This value is the name of the font that is used. It can either refer to an " + "internal name registered previously, or it can refer to a path that is used." + }; + + static const openspace::properties::Property::PropertyInfo FontSizeInfo = { + "FontSize", + "Font Size", + "This value determines the size of the font that is used to render the date." + }; + + std::string progressToStr(int size, double t) { + std::string progress = "|"; + int g = static_cast((t * (size - 1)) + 1); + g = std::max(g, 0); + for (int i = 0; i < g; i++) { + progress.append("-"); + } + progress.append(">"); + for (int i = 0; i < size - g; i++) { + progress.append(" "); + } + progress.append("|"); + return progress; + } + +} // namespace + +namespace openspace { + +documentation::Documentation DashboardItemMission::Documentation() { + using namespace documentation; + return { + "DashboardItem Mission", + "base_dashboarditem_mission", + { + { + "Type", + new StringEqualVerifier("DashboardItemMission"), + Optional::No + }, + { + FontNameInfo.identifier, + new StringVerifier, + Optional::Yes, + FontNameInfo.description + }, + { + FontSizeInfo.identifier, + new IntVerifier, + Optional::Yes, + FontSizeInfo.description + } + } + }; +} + +DashboardItemMission::DashboardItemMission(ghoul::Dictionary dictionary) + : DashboardItem("Mission") + , _fontName(FontNameInfo, KeyFontMono) + , _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f) +{ + documentation::testSpecificationAndThrow( + Documentation(), + dictionary, + "DashboardItemDate" + ); + + if (dictionary.hasKey(FontNameInfo.identifier)) { + _fontName = dictionary.value(FontNameInfo.identifier); + } + _fontName.onChange([this](){ + _font = OsEng.fontManager().font(_fontName, _fontSize); + }); + addProperty(_fontName); + + if (dictionary.hasKey(FontSizeInfo.identifier)) { + _fontSize = static_cast( + dictionary.value(FontSizeInfo.identifier) + ); + } + _fontSize.onChange([this](){ + _font = OsEng.fontManager().font(_fontName, _fontSize); + }); + addProperty(_fontSize); + + _font = OsEng.fontManager().font(_fontName, _fontSize); +} + +void DashboardItemMission::render(glm::vec2& penPosition) { + if (MissionManager::ref().hasCurrentMission()) { + double currentTime = OsEng.timeManager().time().j2000Seconds(); + const Mission& mission = MissionManager::ref().currentMission(); + + if (mission.phases().size() > 0) { + static const glm::vec4 nextMissionColor(0.7, 0.3, 0.3, 1); + //static const glm::vec4 missionProgressColor(0.4, 1.0, 1.0, 1); + static const glm::vec4 currentMissionColor(0.0, 0.5, 0.5, 1); + static const glm::vec4 missionProgressColor = currentMissionColor; + // static const glm::vec4 currentLeafMissionColor = missionProgressColor; + static const glm::vec4 nonCurrentMissionColor(0.3, 0.3, 0.3, 1); + + // Add spacing + RenderFontCr(*_font, penPosition, nonCurrentMissionColor, " "); + + auto phaseTrace = mission.phaseTrace(currentTime); + + if (phaseTrace.size()) { + const MissionPhase& phase = phaseTrace.back().get(); + std::string title = "Current Mission Phase: " + phase.name(); + penPosition.y -= _font->height(); + RenderFont( + *_font, + penPosition, + missionProgressColor, + title.c_str() + ); + double remaining = phase.timeRange().end - currentTime; + float t = static_cast( + 1.0 - remaining / phase.timeRange().duration() + ); + std::string progress = progressToStr(25, t); + penPosition.y -= _font->height(); + RenderFont(*_font, penPosition, missionProgressColor, + "%.0f s %s %.1f %%", remaining, progress.c_str(), t * 100); + } + else { + penPosition.y -= _font->height(); + RenderFont( + *_font, + penPosition, + nextMissionColor, + "Next Mission:" + ); + double remaining = mission.timeRange().start - currentTime; + penPosition.y -= _font->height(); + RenderFont(*_font, penPosition, nextMissionColor, + "%.0f s", remaining); + } + + bool showAllPhases = false; + + typedef std::pair PhaseWithDepth; + std::stack S; + int pixelIndentation = 20; + S.push({ &mission, 0 }); + while (!S.empty()) { + const MissionPhase* phase = S.top().first; + int depth = S.top().second; + S.pop(); + + bool isCurrentPhase = phase->timeRange().includes(currentTime); + + penPosition.x += depth * pixelIndentation; + if (isCurrentPhase) { + double remaining = phase->timeRange().end - currentTime; + float t = static_cast( + 1.0 - remaining / phase->timeRange().duration() + ); + std::string progress = progressToStr(25, t); + penPosition.y -= _font->height(); + RenderFont(*_font, penPosition, currentMissionColor, + "%s %s %.1f %%", + phase->name().c_str(), + progress.c_str(), + t * 100 + ); + } + else { + if (!phase->name().empty()) { + penPosition.y -= _font->height(); + RenderFont( + *_font, + penPosition, + nonCurrentMissionColor, + phase->name().c_str() + ); + } + } + penPosition.x -= depth * pixelIndentation; + + if (isCurrentPhase || showAllPhases) { + // phases are sorted increasingly by start time, and will be + // popped last-in-first-out from the stack, so add them in + // reversed order. + int indexLastPhase = static_cast( + phase->phases().size() + ) - 1; + for (int i = indexLastPhase; 0 <= i; --i) { + S.push({ &phase->phases()[i], depth + 1 }); + } + } + } + } + } +} + +glm::vec2 DashboardItemMission::size() const { + // @TODO fix this up ---abock + return { 0.f, 0.f }; +} + +} // namespace openspace diff --git a/modules/base/dashboard/dashboarditemmission.h b/modules/base/dashboard/dashboarditemmission.h new file mode 100644 index 0000000000..65c0fe531d --- /dev/null +++ b/modules/base/dashboard/dashboarditemmission.h @@ -0,0 +1,61 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_BASE___DASHBOARDITEMMISSION___H__ +#define __OPENSPACE_MODULE_BASE___DASHBOARDITEMMISSION___H__ + +#include + +#include +#include + +namespace ghoul::fontrendering { + class Font; +} // namespace ghoul::fontrendering + +namespace openspace { + +namespace documentation { struct Documentation; } + +class DashboardItemMission : public DashboardItem { +public: + DashboardItemMission(ghoul::Dictionary dictionary); + virtual ~DashboardItemMission() = default; + + void render(glm::vec2& penPosition) override; + + glm::vec2 size() const override; + + static documentation::Documentation Documentation(); + +private: + properties::StringProperty _fontName; + properties::FloatProperty _fontSize; + + std::shared_ptr _font; +}; + +} // namespace openspace + +#endif // __OPENSPACE_MODULE_BASE___DASHBOARDITEMMISSION___H__ diff --git a/modules/base/dashboard/dashboarditemparallelconnection.cpp b/modules/base/dashboard/dashboarditemparallelconnection.cpp new file mode 100644 index 0000000000..93df3e1fbe --- /dev/null +++ b/modules/base/dashboard/dashboarditemparallelconnection.cpp @@ -0,0 +1,221 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +namespace { + const char* KeyFontMono = "Mono"; + const float DefaultFontSize = 10.f; + + static const openspace::properties::Property::PropertyInfo FontNameInfo = { + "FontName", + "Font Name", + "This value is the name of the font that is used. It can either refer to an " + "internal name registered previously, or it can refer to a path that is used." + }; + + static const openspace::properties::Property::PropertyInfo FontSizeInfo = { + "FontSize", + "Font Size", + "This value determines the size of the font that is used to render the date." + }; +} // namespace + +namespace openspace { + +documentation::Documentation DashboardItemParallelConnection::Documentation() { + using namespace documentation; + return { + "DashboardItem Parallel Connection", + "base_dashboarditem_parallelconnection", + { + { + "Type", + new StringEqualVerifier("DashboardItemParallelConnection"), + Optional::No + }, + { + FontNameInfo.identifier, + new StringVerifier, + Optional::Yes, + FontNameInfo.description + }, + { + FontSizeInfo.identifier, + new IntVerifier, + Optional::Yes, + FontSizeInfo.description + } + } + }; +} + +DashboardItemParallelConnection::DashboardItemParallelConnection(ghoul::Dictionary dictionary) + : DashboardItem("Parallel Connection") + , _fontName(FontNameInfo, KeyFontMono) + , _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f) +{ + documentation::testSpecificationAndThrow( + Documentation(), + dictionary, + "DashboardItemDate" + ); + + if (dictionary.hasKey(FontNameInfo.identifier)) { + _fontName = dictionary.value(FontNameInfo.identifier); + } + _fontName.onChange([this](){ + _font = OsEng.fontManager().font(_fontName, _fontSize); + }); + addProperty(_fontName); + + if (dictionary.hasKey(FontSizeInfo.identifier)) { + _fontSize = static_cast( + dictionary.value(FontSizeInfo.identifier) + ); + } + _fontSize.onChange([this](){ + _font = OsEng.fontManager().font(_fontName, _fontSize); + }); + addProperty(_fontSize); + + _font = OsEng.fontManager().font(_fontName, _fontSize); +} + +void DashboardItemParallelConnection::render(glm::vec2& penPosition) { + ParallelConnection::Status status = OsEng.parallelConnection().status(); + size_t nConnections = OsEng.parallelConnection().nConnections(); + const std::string& hostName = OsEng.parallelConnection().hostName(); + + std::string connectionInfo = ""; + int nClients = static_cast(nConnections); + if (status == ParallelConnection::Status::Host) { + nClients--; + if (nClients == 1) { + connectionInfo = "Hosting session with 1 client"; + } + else { + connectionInfo = + "Hosting session with " + std::to_string(nClients) + " clients"; + } + } + else if (status == ParallelConnection::Status::ClientWithHost) { + nClients--; + connectionInfo = "Session hosted by '" + hostName + "'"; + } + else if (status == ParallelConnection::Status::ClientWithoutHost) { + connectionInfo = "Host is disconnected"; + } + + if (status == ParallelConnection::Status::ClientWithHost || + status == ParallelConnection::Status::ClientWithoutHost) { + connectionInfo += "\n"; + if (nClients > 2) { + std::string c = std::to_string(nClients - 1); + connectionInfo += "You and " + c + " more clients are tuned in"; + } + else if (nClients == 2) { + std::string c = std::to_string(nClients - 1); + connectionInfo += "You and " + c + " more client are tuned in"; + } + else if (nClients == 1) { + connectionInfo += "You are the only client"; + } + } + + if (!connectionInfo.empty()) { + penPosition.y -= _font->height(); + RenderFont( + *_font, + penPosition, + connectionInfo.c_str() + ); + } +} + +glm::vec2 DashboardItemParallelConnection::size() const { + ParallelConnection::Status status = OsEng.parallelConnection().status(); + size_t nConnections = OsEng.parallelConnection().nConnections(); + const std::string& hostName = OsEng.parallelConnection().hostName(); + + std::string connectionInfo = ""; + int nClients = static_cast(nConnections); + if (status == ParallelConnection::Status::Host) { + nClients--; + if (nClients == 1) { + connectionInfo = "Hosting session with 1 client"; + } + else { + connectionInfo = + "Hosting session with " + std::to_string(nClients) + " clients"; + } + } + else if (status == ParallelConnection::Status::ClientWithHost) { + nClients--; + connectionInfo = "Session hosted by '" + hostName + "'"; + } + else if (status == ParallelConnection::Status::ClientWithoutHost) { + connectionInfo = "Host is disconnected"; + } + + if (status == ParallelConnection::Status::ClientWithHost || + status == ParallelConnection::Status::ClientWithoutHost) { + connectionInfo += "\n"; + if (nClients > 2) { + std::string c = std::to_string(nClients - 1); + connectionInfo += "You and " + c + " more clients are tuned in"; + } + else if (nClients == 2) { + std::string c = std::to_string(nClients - 1); + connectionInfo += "You and " + c + " more client are tuned in"; + } + else if (nClients == 1) { + connectionInfo += "You are the only client"; + } + } + + if (!connectionInfo.empty()) { + return ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox( + *_font, + connectionInfo.c_str() + ).boundingBox; + } + else { + return { 0.f, 0.f }; + } +} + +} // namespace openspace diff --git a/modules/base/dashboard/dashboarditemparallelconnection.h b/modules/base/dashboard/dashboarditemparallelconnection.h new file mode 100644 index 0000000000..1b163e3179 --- /dev/null +++ b/modules/base/dashboard/dashboarditemparallelconnection.h @@ -0,0 +1,61 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_BASE___DASHBOARDITEMPARALLELCONNECTION___H__ +#define __OPENSPACE_MODULE_BASE___DASHBOARDITEMPARALLELCONNECTION___H__ + +#include + +#include +#include + +namespace ghoul::fontrendering { + class Font; +} // namespace ghoul::fontrendering + +namespace openspace { + +namespace documentation { struct Documentation; } + +class DashboardItemParallelConnection : public DashboardItem { +public: + DashboardItemParallelConnection(ghoul::Dictionary dictionary); + virtual ~DashboardItemParallelConnection() = default; + + void render(glm::vec2& penPosition) override; + + glm::vec2 size() const override; + + static documentation::Documentation Documentation(); + +private: + properties::StringProperty _fontName; + properties::FloatProperty _fontSize; + + std::shared_ptr _font; +}; + +} // namespace openspace + +#endif // __OPENSPACE_MODULE_BASE___DASHBOARDITEMPARALLELCONNECTION___H__ diff --git a/modules/base/dashboard/dashboarditemsimulationincrement.cpp b/modules/base/dashboard/dashboarditemsimulationincrement.cpp new file mode 100644 index 0000000000..f2e4b2c8ef --- /dev/null +++ b/modules/base/dashboard/dashboarditemsimulationincrement.cpp @@ -0,0 +1,141 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + +#include +#include +#include +#include +#include + +#include +#include + +namespace { + const char* KeyFontMono = "Mono"; + const float DefaultFontSize = 10.f; + + static const openspace::properties::Property::PropertyInfo FontNameInfo = { + "FontName", + "Font Name", + "This value is the name of the font that is used. It can either refer to an " + "internal name registered previously, or it can refer to a path that is used." + }; + + static const openspace::properties::Property::PropertyInfo FontSizeInfo = { + "FontSize", + "Font Size", + "This value determines the size of the font that is used to render the date." + }; +} // namespace + +namespace openspace { + +documentation::Documentation DashboardItemSimulationIncrement::Documentation() { + using namespace documentation; + return { + "DashboardItem Simulation Increment", + "base_dashboarditem_simulationincrement", + { + { + "Type", + new StringEqualVerifier("DashboardItemSimulationIncrement"), + Optional::No + }, + { + FontNameInfo.identifier, + new StringVerifier, + Optional::Yes, + FontNameInfo.description + }, + { + FontSizeInfo.identifier, + new IntVerifier, + Optional::Yes, + FontSizeInfo.description + } + } + }; +} + +DashboardItemSimulationIncrement::DashboardItemSimulationIncrement(ghoul::Dictionary dictionary) + : DashboardItem("Simulation Increment") + , _fontName(FontNameInfo, KeyFontMono) + , _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f) +{ + documentation::testSpecificationAndThrow( + Documentation(), + dictionary, + "DashboardItemDate" + ); + + if (dictionary.hasKey(FontNameInfo.identifier)) { + _fontName = dictionary.value(FontNameInfo.identifier); + } + _fontName.onChange([this](){ + _font = OsEng.fontManager().font(_fontName, _fontSize); + }); + addProperty(_fontName); + + if (dictionary.hasKey(FontSizeInfo.identifier)) { + _fontSize = static_cast( + dictionary.value(FontSizeInfo.identifier) + ); + } + _fontSize.onChange([this](){ + _font = OsEng.fontManager().font(_fontName, _fontSize); + }); + addProperty(_fontSize); + + _font = OsEng.fontManager().font(_fontName, _fontSize); +} + +void DashboardItemSimulationIncrement::render(glm::vec2& penPosition) { + std::pair deltaTime = simplifyTime( + OsEng.timeManager().time().deltaTime() + ); + penPosition.y -= _font->height(); + RenderFont( + *_font, + penPosition, + "Simulation increment: %.1f %s / second", + deltaTime.first, + deltaTime.second.c_str() + ); +} + +glm::vec2 DashboardItemSimulationIncrement::size() const { + std::pair deltaTime = simplifyTime( + OsEng.timeManager().time().deltaTime() + ); + return ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox( + *_font, + "Simulation increment: %.1f %s / second", + deltaTime.first, + deltaTime.second.c_str() + ).boundingBox; +} + +} // namespace openspace diff --git a/modules/base/dashboard/dashboarditemsimulationincrement.h b/modules/base/dashboard/dashboarditemsimulationincrement.h new file mode 100644 index 0000000000..492d529b75 --- /dev/null +++ b/modules/base/dashboard/dashboarditemsimulationincrement.h @@ -0,0 +1,60 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_BASE___DASHBOARDITEMSIMULATIONINCREMENT___H__ +#define __OPENSPACE_MODULE_BASE___DASHBOARDITEMSIMULATIONINCREMENT___H__ + +#include + +#include +#include + +namespace ghoul::fontrendering { + class Font; +} // namespace ghoul::fontrendering + +namespace openspace { + +namespace documentation { struct Documentation; } + +class DashboardItemSimulationIncrement : public DashboardItem { +public: + DashboardItemSimulationIncrement(ghoul::Dictionary dictionary); + virtual ~DashboardItemSimulationIncrement() = default; + + void render(glm::vec2& penPosition) override; + glm::vec2 size() const override; + + static documentation::Documentation Documentation(); + +private: + properties::StringProperty _fontName; + properties::FloatProperty _fontSize; + + std::shared_ptr _font; +}; + +} // namespace openspace + +#endif // __OPENSPACE_MODULE_BASE___DASHBOARDITEMSIMULATIONINCREMENT___H__ diff --git a/modules/base/dashboard/dashboarditemspacing.cpp b/modules/base/dashboard/dashboarditemspacing.cpp new file mode 100644 index 0000000000..3848163cfb --- /dev/null +++ b/modules/base/dashboard/dashboarditemspacing.cpp @@ -0,0 +1,86 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + +#include +#include + +namespace { + static const openspace::properties::Property::PropertyInfo SpacingInfo = { + "Spacing", + "Spacing", + "This value determines the spacing (in pixels) that this item represents. The " + "default value is 15." + }; +} // namespace + +namespace openspace { + +documentation::Documentation DashboardItemSpacing::Documentation() { + using namespace documentation; + return { + "DashboardItem Spacing", + "base_dashboarditem_spacing", + { + { + "Type", + new StringEqualVerifier("DashboardItemSpacing"), + Optional::No + }, + { + SpacingInfo.identifier, + new DoubleVerifier, + Optional::Yes, + SpacingInfo.description + } + } + }; +} + +DashboardItemSpacing::DashboardItemSpacing(ghoul::Dictionary dictionary) + : DashboardItem("Spacing") + , _spacing(SpacingInfo, 15.f, 0.f, 2048.f) +{ + documentation::testSpecificationAndThrow( + Documentation(), + dictionary, + "DashboardItemSpacing" + ); + + if (dictionary.hasKey(SpacingInfo.identifier)) { + _spacing = static_cast(dictionary.value(SpacingInfo.identifier)); + } + addProperty(_spacing); +} + +void DashboardItemSpacing::render(glm::vec2& penPosition) { + penPosition.y -= _spacing; +} + +glm::vec2 DashboardItemSpacing::size() const { + return { 0.f, _spacing }; +} + +} // namespace openspace diff --git a/modules/base/dashboard/dashboarditemspacing.h b/modules/base/dashboard/dashboarditemspacing.h new file mode 100644 index 0000000000..ef2458525e --- /dev/null +++ b/modules/base/dashboard/dashboarditemspacing.h @@ -0,0 +1,53 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_BASE___DASHBOARDITEMSPACING___H__ +#define __OPENSPACE_MODULE_BASE___DASHBOARDITEMSPACING___H__ + +#include + +#include + +namespace openspace { + +namespace documentation { struct Documentation; } + +class DashboardItemSpacing : public DashboardItem { +public: + DashboardItemSpacing(ghoul::Dictionary dictionary); + virtual ~DashboardItemSpacing() = default; + + void render(glm::vec2& penPosition) override; + + glm::vec2 size() const override; + + static documentation::Documentation Documentation(); + +private: + properties::FloatProperty _spacing; +}; + +} // namespace openspace + +#endif // __OPENSPACE_MODULE_BASE___DASHBOARDITEMSPACING___H__ diff --git a/modules/base/rendering/renderablemodel.cpp b/modules/base/rendering/renderablemodel.cpp index 1c5a5a5b8a..8f9c07736a 100644 --- a/modules/base/rendering/renderablemodel.cpp +++ b/modules/base/rendering/renderablemodel.cpp @@ -159,8 +159,8 @@ bool RenderableModel::isReady() const { void RenderableModel::initializeGL() { _programObject = OsEng.renderEngine().buildRenderProgram( "ModelProgram", - "${MODULE_BASE}/shaders/model_vs.glsl", - "${MODULE_BASE}/shaders/model_fs.glsl" + absPath("${MODULE_BASE}/shaders/model_vs.glsl"), + absPath("${MODULE_BASE}/shaders/model_fs.glsl") ); loadTexture(); diff --git a/modules/base/rendering/renderableplane.cpp b/modules/base/rendering/renderableplane.cpp index e28a923812..c4309072f5 100644 --- a/modules/base/rendering/renderableplane.cpp +++ b/modules/base/rendering/renderableplane.cpp @@ -183,9 +183,10 @@ void RenderablePlane::initializeGL() { glGenBuffers(1, &_vertexPositionBuffer); // generate buffer createPlane(); - _shader = OsEng.renderEngine().buildRenderProgram("PlaneProgram", - "${MODULE_BASE}/shaders/plane_vs.glsl", - "${MODULE_BASE}/shaders/plane_fs.glsl" + _shader = OsEng.renderEngine().buildRenderProgram( + "PlaneProgram", + absPath("${MODULE_BASE}/shaders/plane_vs.glsl"), + absPath("${MODULE_BASE}/shaders/plane_fs.glsl") ); loadTexture(); diff --git a/modules/base/rendering/renderablesphere.cpp b/modules/base/rendering/renderablesphere.cpp index 7f2681159d..dbb5e923cc 100644 --- a/modules/base/rendering/renderablesphere.cpp +++ b/modules/base/rendering/renderablesphere.cpp @@ -262,9 +262,11 @@ void RenderableSphere::initializeGL() { _sphere->initialize(); // pscstandard - _shader = OsEng.renderEngine().buildRenderProgram("Sphere", - "${MODULE_BASE}/shaders/sphere_vs.glsl", - "${MODULE_BASE}/shaders/sphere_fs.glsl"); + _shader = OsEng.renderEngine().buildRenderProgram( + "Sphere", + absPath("${MODULE_BASE}/shaders/sphere_vs.glsl"), + absPath("${MODULE_BASE}/shaders/sphere_fs.glsl") + ); loadTexture(); } diff --git a/modules/base/rendering/renderablesphericalgrid.cpp b/modules/base/rendering/renderablesphericalgrid.cpp index f9478e4f91..587d1c24bf 100644 --- a/modules/base/rendering/renderablesphericalgrid.cpp +++ b/modules/base/rendering/renderablesphericalgrid.cpp @@ -32,6 +32,7 @@ #include #include +#include #include namespace { @@ -179,9 +180,9 @@ bool RenderableSphericalGrid::isReady() const { void RenderableSphericalGrid::initializeGL() { _gridProgram = OsEng.renderEngine().buildRenderProgram( - "GridProgram", - "${MODULE_BASE}/shaders/grid_vs.glsl", - "${MODULE_BASE}/shaders/grid_fs.glsl" + "GridProgram", + absPath("${MODULE_BASE}/shaders/grid_vs.glsl"), + absPath("${MODULE_BASE}/shaders/grid_fs.glsl") ); glGenVertexArrays(1, &_vaoID); diff --git a/modules/base/rendering/renderabletrail.cpp b/modules/base/rendering/renderabletrail.cpp index 416f71b0c1..812fa6ed39 100644 --- a/modules/base/rendering/renderabletrail.cpp +++ b/modules/base/rendering/renderabletrail.cpp @@ -31,6 +31,7 @@ #include #include +#include #include namespace { @@ -221,8 +222,8 @@ void RenderableTrail::initializeGL() { RenderEngine& renderEngine = OsEng.renderEngine(); _programObject = renderEngine.buildRenderProgram( "EphemerisProgram", - "${MODULE_BASE}/shaders/renderabletrail_vs.glsl", - "${MODULE_BASE}/shaders/renderabletrail_fs.glsl" + absPath("${MODULE_BASE}/shaders/renderabletrail_vs.glsl"), + absPath("${MODULE_BASE}/shaders/renderabletrail_fs.glsl") ); setRenderBin(Renderable::RenderBin::Overlay); diff --git a/modules/base/rendering/screenspacedashboard.cpp b/modules/base/rendering/screenspacedashboard.cpp index 215f3f0fe3..1700e4063d 100644 --- a/modules/base/rendering/screenspacedashboard.cpp +++ b/modules/base/rendering/screenspacedashboard.cpp @@ -32,21 +32,102 @@ #include #include #include -#include > +#include #include #include +#include + #include #include namespace { const char* KeyName = "Name"; - const char* KeyFontMono = "Mono"; + static const openspace::properties::Property::PropertyInfo UseMainInfo = { + "UseMainDashboard", + "Use main dashboard", + "If this value is set to 'true', this ScreenSpaceDashboard will use the " + "main dashboard instead of creating an independent one." + }; } // namespace namespace openspace { +namespace luascriptfunctions { + +/** +* \ingroup LuaScripts +* addDashboardItemToScreenSpace(string, table): +*/ +int addDashboardItemToScreenSpace(lua_State* L) { + int nArguments = lua_gettop(L); + if (nArguments != 2) { + return luaL_error(L, "Expected %i arguments, got %i", 2, nArguments); + } + + std::string name = luaL_checkstring(L, -2); + int type = lua_type(L, -1); + if (type != LUA_TTABLE) { + return luaL_error(L, "Expected argument of type 'table'"); + } + else { + ghoul::Dictionary d; + try { + ghoul::lua::luaDictionaryFromState(L, d); + } + catch (const ghoul::lua::LuaFormatException& e) { + LERRORC("addDashboardItem", e.what()); + return 0; + } + + std::shared_ptr ssr = + OsEng.renderEngine().screenSpaceRenderable(name); + + if (!ssr) { + return luaL_error(L, "Provided name is not a ScreenSpace item"); + } + + ScreenSpaceDashboard* dash = dynamic_cast(ssr.get()); + if (!dash) { + return luaL_error(L, "Provided name is a ScreenSpace item but not a dashboard"); + } + + dash->dashboard().addDashboardItem(DashboardItem::createFromDictionary(d)); + return 0; + } +} + +/** +* \ingroup LuaScripts +* removeDashboardItemsFromScreenSpace(string): +*/ +int removeDashboardItemsFromScreenSpace(lua_State* L) { + int nArguments = lua_gettop(L); + if (nArguments != 1) { + return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); + } + + std::string name = luaL_checkstring(L, -1); + std::shared_ptr ssr = + OsEng.renderEngine().screenSpaceRenderable(name); + + if (!ssr) { + return luaL_error(L, "Provided name is not a ScreenSpace item"); + } + + ScreenSpaceDashboard* dash = dynamic_cast(ssr.get()); + if (!dash) { + return luaL_error(L, "Provided name is a ScreenSpace item but not a dashboard"); + } + + dash->dashboard().removeDashboardItems(); + return 0; +} + +} // namespace luascriptfunctions + + documentation::Documentation ScreenSpaceDashboard::Documentation() { using namespace openspace::documentation; return { @@ -58,6 +139,12 @@ documentation::Documentation ScreenSpaceDashboard::Documentation() { new StringVerifier, Optional::Yes, "Specifies the GUI name of the ScreenSpaceDashboard" + }, + { + UseMainInfo.identifier, + new BoolVerifier, + Optional::Yes, + UseMainInfo.description } } }; @@ -65,9 +152,7 @@ documentation::Documentation ScreenSpaceDashboard::Documentation() { ScreenSpaceDashboard::ScreenSpaceDashboard(const ghoul::Dictionary& dictionary) : ScreenSpaceFramebuffer(dictionary) - , _fontRenderer(nullptr) - , _fontDate(nullptr) - , _fontInfo(nullptr) + , _useMainDashboard(UseMainInfo, false) { documentation::testSpecificationAndThrow( Documentation(), @@ -89,12 +174,13 @@ ScreenSpaceDashboard::ScreenSpaceDashboard(const ghoul::Dictionary& dictionary) ++id; } + if (dictionary.hasKey(UseMainInfo.identifier)) { + _useMainDashboard = dictionary.value(UseMainInfo.identifier); + } + addProperty(_useMainDashboard); + _scale = 1.f; _scale.setMaxValue(15.f); - - _size.onChange([this]() { - _fontRenderer->setFramebufferSize({ _size.value().z, _size.value().w }); - }); } ScreenSpaceDashboard::~ScreenSpaceDashboard() {} @@ -102,71 +188,32 @@ ScreenSpaceDashboard::~ScreenSpaceDashboard() {} bool ScreenSpaceDashboard::initializeGL() { ScreenSpaceFramebuffer::initializeGL(); - _fontRenderer = ghoul::fontrendering::FontRenderer::createDefault(); - _fontRenderer->setFramebufferSize({ _size.value().z, _size.value().w }); - - - _fontDate = OsEng.fontManager().font( - KeyFontMono, - 48 - ); - _fontInfo = OsEng.fontManager().font( - KeyFontMono, - 32 - ); - addRenderFunction([this]() { - glm::vec2 penPosition = glm::vec2( 10.f, _size.value().w ); - penPosition.y -= _fontDate->height(); - RenderFontCr( - *_fontDate, - penPosition, - "Date: %s", - OsEng.timeManager().time().UTC().c_str() - ); - - std::pair deltaTime = simplifyTime( - OsEng.timeManager().time().deltaTime() - ); - RenderFontCr( - *_fontInfo, - penPosition, - "Simulation increment: %.1f %s / second", - deltaTime.first, - deltaTime.second.c_str() - ); - - double distance = glm::length( - OsEng.renderEngine().camera()->positionVec3() - - OsEng.navigationHandler().focusNode()->worldPosition() - ); - std::pair dist = simplifyDistance(distance); - RenderFontCr( - *_fontInfo, - penPosition, - "Distance from focus: %f %s", - dist.first, - dist.second.c_str() - ); + if (_useMainDashboard) { + OsEng.dashboard().render(penPosition); + } + else { + _dashboard.render(penPosition); + } }); return true; } bool ScreenSpaceDashboard::deinitializeGL() { - _fontRenderer = nullptr; + //_fontRenderer = nullptr; return ScreenSpaceFramebuffer::deinitializeGL(); } bool ScreenSpaceDashboard::isReady() const { - return (_fontRenderer != nullptr) && + return /*(_fontRenderer != nullptr) && (_fontDate != nullptr) && - (_fontInfo != nullptr) && + (_fontInfo != nullptr) &&*/ ScreenSpaceFramebuffer::isReady(); } @@ -179,4 +226,31 @@ void ScreenSpaceDashboard::update() { } } +Dashboard& ScreenSpaceDashboard::dashboard() { + return _dashboard; +} + +const Dashboard& ScreenSpaceDashboard::dashboard() const { + return _dashboard; +} + +scripting::LuaLibrary ScreenSpaceDashboard::luaLibrary() { + return { + "dashboard", + { + { + "addDashboardItemToScreenSpace", + &luascriptfunctions::addDashboardItemToScreenSpace, + "string, table", + "Adds a new dashboard item to an existing SceenSpaceDashboard." + }, + { + "removeDashboardItemsFromScreenSpace", + &luascriptfunctions::removeDashboardItemsFromScreenSpace, + "string", + "Removes all dashboard items from an existing ScreenSpaceDashboard." + } + } + }; +} } // namespace openspace diff --git a/modules/base/rendering/screenspacedashboard.h b/modules/base/rendering/screenspacedashboard.h index fe2b3e6c23..9746af2b1e 100644 --- a/modules/base/rendering/screenspacedashboard.h +++ b/modules/base/rendering/screenspacedashboard.h @@ -27,6 +27,9 @@ #include +#include +#include + namespace ghoul::fontrendering { class Font; class FontRenderer; @@ -35,6 +38,7 @@ namespace ghoul::fontrendering { namespace openspace { namespace documentation { struct Documentation; } +namespace scripting { struct LuaLibrary; } class ScreenSpaceDashboard: public ScreenSpaceFramebuffer { public: @@ -47,13 +51,20 @@ public: bool isReady() const override; void update() override; + Dashboard& dashboard(); + const Dashboard& dashboard() const; + + static scripting::LuaLibrary luaLibrary(); + static documentation::Documentation Documentation(); private: - std::unique_ptr _fontRenderer; + Dashboard _dashboard; + properties::BoolProperty _useMainDashboard; + //std::unique_ptr _fontRenderer; - std::shared_ptr _fontDate; - std::shared_ptr _fontInfo; + //std::shared_ptr _fontDate; + //std::shared_ptr _fontInfo; }; } // namespace openspace diff --git a/modules/debugging/rendering/debugrenderer.cpp b/modules/debugging/rendering/debugrenderer.cpp index d29a1c24a8..4575a9bb01 100644 --- a/modules/debugging/rendering/debugrenderer.cpp +++ b/modules/debugging/rendering/debugrenderer.cpp @@ -31,6 +31,7 @@ #include #include +#include #include #include @@ -45,9 +46,9 @@ DebugRenderer* DebugRenderer::_reference = nullptr; DebugRenderer::DebugRenderer() { _programObject = OsEng.renderEngine().buildRenderProgram( "BasicDebugShader", - "${MODULE_DEBUGGING}/rendering/debugshader_vs.glsl", - "${MODULE_DEBUGGING}/rendering/debugshader_fs.glsl" - ); + absPath("${MODULE_DEBUGGING}/rendering/debugshader_vs.glsl"), + absPath("${MODULE_DEBUGGING}/rendering/debugshader_fs.glsl") + ); } DebugRenderer::DebugRenderer(std::unique_ptr programObject) diff --git a/modules/debugging/rendering/renderabledebugplane.cpp b/modules/debugging/rendering/renderabledebugplane.cpp index 1e1847ae38..1de3d6624f 100644 --- a/modules/debugging/rendering/renderabledebugplane.cpp +++ b/modules/debugging/rendering/renderabledebugplane.cpp @@ -198,9 +198,9 @@ void RenderableDebugPlane::initializeGL() { if (!_shader) { RenderEngine& renderEngine = OsEng.renderEngine(); _shader = renderEngine.buildRenderProgram("PlaneProgram", - "${MODULE_BASE}/shaders/plane_vs.glsl", - "${MODULE_BASE}/shaders/plane_fs.glsl" - ); + absPath("${MODULE_BASE}/shaders/plane_vs.glsl"), + absPath("${MODULE_BASE}/shaders/plane_fs.glsl") + ); } } diff --git a/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp b/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp index 6198e89fc2..e4089b56d5 100644 --- a/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp +++ b/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp @@ -601,10 +601,12 @@ void RenderableBillboardsCloud::initialize() { void RenderableBillboardsCloud::initializeGL() { RenderEngine& renderEngine = OsEng.renderEngine(); - _program = renderEngine.buildRenderProgram("RenderableBillboardsCloud", - "${MODULE_DIGITALUNIVERSE}/shaders/billboard2_vs.glsl", - "${MODULE_DIGITALUNIVERSE}/shaders/billboard2_fs.glsl", - "${MODULE_DIGITALUNIVERSE}/shaders/billboard2_gs.glsl"); + _program = renderEngine.buildRenderProgram( + "RenderableBillboardsCloud", + absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboard2_vs.glsl"), + absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboard2_fs.glsl"), + absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboard2_gs.glsl") + ); if (_hasPolygon) { createPolygonTexture(); diff --git a/modules/digitaluniverse/rendering/renderabledumeshes.cpp b/modules/digitaluniverse/rendering/renderabledumeshes.cpp index f388d9ff8e..299d542132 100644 --- a/modules/digitaluniverse/rendering/renderabledumeshes.cpp +++ b/modules/digitaluniverse/rendering/renderabledumeshes.cpp @@ -391,9 +391,11 @@ bool RenderableDUMeshes::isReady() const { void RenderableDUMeshes::initializeGL() { RenderEngine& renderEngine = OsEng.renderEngine(); - _program = renderEngine.buildRenderProgram("RenderableDUMeshes", - "${MODULE_DIGITALUNIVERSE}/shaders/dumesh_vs.glsl", - "${MODULE_DIGITALUNIVERSE}/shaders/dumesh_fs.glsl"); + _program = renderEngine.buildRenderProgram( + "RenderableDUMeshes", + absPath("${MODULE_DIGITALUNIVERSE}/shaders/dumesh_vs.glsl"), + absPath("${MODULE_DIGITALUNIVERSE}/shaders/dumesh_fs.glsl") + ); bool success = loadData(); if (!success) { diff --git a/modules/digitaluniverse/rendering/renderableplanescloud.cpp b/modules/digitaluniverse/rendering/renderableplanescloud.cpp index 7d0728a392..bf2fdc3499 100644 --- a/modules/digitaluniverse/rendering/renderableplanescloud.cpp +++ b/modules/digitaluniverse/rendering/renderableplanescloud.cpp @@ -502,9 +502,11 @@ void RenderablePlanesCloud::initialize() { void RenderablePlanesCloud::initializeGL() { RenderEngine& renderEngine = OsEng.renderEngine(); - _program = renderEngine.buildRenderProgram("RenderablePlanesCloud", - "${MODULE_DIGITALUNIVERSE}/shaders/plane2_vs.glsl", - "${MODULE_DIGITALUNIVERSE}/shaders/plane2_fs.glsl"); + _program = renderEngine.buildRenderProgram( + "RenderablePlanesCloud", + absPath("${MODULE_DIGITALUNIVERSE}/shaders/plane2_vs.glsl"), + absPath("${MODULE_DIGITALUNIVERSE}/shaders/plane2_fs.glsl") + ); createPlanes(); diff --git a/modules/digitaluniverse/rendering/renderablepoints.cpp b/modules/digitaluniverse/rendering/renderablepoints.cpp index 4f84585cc4..b08a0b4ef4 100644 --- a/modules/digitaluniverse/rendering/renderablepoints.cpp +++ b/modules/digitaluniverse/rendering/renderablepoints.cpp @@ -263,15 +263,18 @@ namespace openspace { void RenderablePoints::initializeGL() { RenderEngine& renderEngine = OsEng.renderEngine(); if (_hasSpriteTexture) { - _program = renderEngine.buildRenderProgram("RenderablePoints", - "${MODULE_DIGITALUNIVERSE}/shaders/points_vs.glsl", - "${MODULE_DIGITALUNIVERSE}/shaders/points_sprite_fs.glsl"); + _program = renderEngine.buildRenderProgram( + "RenderablePoints", + absPath("${MODULE_DIGITALUNIVERSE}/shaders/points_vs.glsl"), + absPath("${MODULE_DIGITALUNIVERSE}/shaders/points_sprite_fs.glsl") + ); } else { - _program = renderEngine.buildRenderProgram("RenderablePoints", - "${MODULE_DIGITALUNIVERSE}/shaders/points_vs.glsl", - "${MODULE_DIGITALUNIVERSE}/shaders/points_fs.glsl");// , - //"${MODULE_DIGITALUNIVERSE}/shaders/points_gs.glsl"); + _program = renderEngine.buildRenderProgram( + "RenderablePoints", + absPath("${MODULE_DIGITALUNIVERSE}/shaders/points_vs.glsl"), + absPath("${MODULE_DIGITALUNIVERSE}/shaders/points_fs.glsl") + ); } } diff --git a/modules/fieldlines/rendering/renderablefieldlines.cpp b/modules/fieldlines/rendering/renderablefieldlines.cpp index c038b13891..05fef687d5 100644 --- a/modules/fieldlines/rendering/renderablefieldlines.cpp +++ b/modules/fieldlines/rendering/renderablefieldlines.cpp @@ -242,9 +242,9 @@ void RenderableFieldlines::initializeGL() { _program = OsEng.renderEngine().buildRenderProgram( "Fieldline", - "${MODULE_FIELDLINES}/shaders/fieldline_vs.glsl", - "${MODULE_FIELDLINES}/shaders/fieldline_fs.glsl", - "${MODULE_FIELDLINES}/shaders/fieldline_gs.glsl" + absPath("${MODULE_FIELDLINES}/shaders/fieldline_vs.glsl"), + absPath("${MODULE_FIELDLINES}/shaders/fieldline_fs.glsl"), + absPath("${MODULE_FIELDLINES}/shaders/fieldline_gs.glsl") ); } diff --git a/modules/fieldlinessequence/rendering/renderablefieldlinessequencesetup.cpp b/modules/fieldlinessequence/rendering/renderablefieldlinessequencesetup.cpp index 4547f444f2..0225f126ea 100644 --- a/modules/fieldlinessequence/rendering/renderablefieldlinessequencesetup.cpp +++ b/modules/fieldlinessequence/rendering/renderablefieldlinessequencesetup.cpp @@ -266,8 +266,8 @@ void RenderableFieldlinesSequence::initialize() { // Setup shader program _shaderProgram = OsEng.renderEngine().buildRenderProgram( "FieldlinesSequence", - "${MODULE_FIELDLINESSEQUENCE}/shaders/fieldlinessequence_vs.glsl", - "${MODULE_FIELDLINESSEQUENCE}/shaders/fieldlinessequence_fs.glsl" + absPath("${MODULE_FIELDLINESSEQUENCE}/shaders/fieldlinessequence_vs.glsl"), + absPath("${MODULE_FIELDLINESSEQUENCE}/shaders/fieldlinessequence_fs.glsl") ); if (!_shaderProgram) { @@ -342,7 +342,12 @@ bool RenderableFieldlinesSequence::extractMandatoryInfoFromDictionary( [inputFileTypeString](std::string str) { const size_t extLength = inputFileTypeString.length(); std::string sub = str.substr(str.length() - extLength, extLength); - std::transform(sub.begin(), sub.end(), sub.begin(), ::tolower); + std::transform( + sub.begin(), + sub.end(), + sub.begin(), + [](char c) { return static_cast(::tolower(c)); } + ); return sub != inputFileTypeString; }), _sourceFiles.end()); // Ensure that there are available and valid source files left @@ -416,7 +421,12 @@ void RenderableFieldlinesSequence::extractOptionalInfoFromDictionary( bool RenderableFieldlinesSequence::extractJsonInfoFromDictionary(fls::Model& model) { std::string modelStr; if (_dictionary->getValue(KeyJsonSimulationModel, modelStr)) { - std::transform(modelStr.begin(), modelStr.end(), modelStr.begin(), ::tolower); + std::transform( + modelStr.begin(), + modelStr.end(), + modelStr.begin(), + [](char c) { return static_cast(::tolower(c)); } + ); model = fls::stringToModel(modelStr); } else { LERROR(_name << ": Must specify '" << KeyJsonSimulationModel << "'"); diff --git a/modules/fieldlinessequence/util/kameleonfieldlinehelper.cpp b/modules/fieldlinessequence/util/kameleonfieldlinehelper.cpp index be5a64d975..b46d64f14b 100644 --- a/modules/fieldlinessequence/util/kameleonfieldlinehelper.cpp +++ b/modules/fieldlinessequence/util/kameleonfieldlinehelper.cpp @@ -28,9 +28,21 @@ #include #ifdef OPENSPACE_MODULE_KAMELEON_ENABLED - #include - #include - #include + +#ifdef _MSC_VER +#pragma warning (push) + // Boost throws #pragma warning: there is no warning number '4675' +#pragma warning (disable : 4619) +#endif // _MSC_VER + +#include +#include +#include + +#ifdef _MSC_VER +#pragma warning (pop) +#endif // _MSC_VER + #endif // OPENSPACE_MODULE_KAMELEON_ENABLED #include diff --git a/modules/galaxy/rendering/renderablegalaxy.cpp b/modules/galaxy/rendering/renderablegalaxy.cpp index 39e7432dcd..a301688b69 100644 --- a/modules/galaxy/rendering/renderablegalaxy.cpp +++ b/modules/galaxy/rendering/renderablegalaxy.cpp @@ -260,10 +260,12 @@ void RenderableGalaxy::initializeGL() { RenderEngine& renderEngine = OsEng.renderEngine(); - _pointsProgram = renderEngine.buildRenderProgram("Galaxy points", - "${MODULE_GALAXY}/shaders/points.vs", - "${MODULE_GALAXY}/shaders/points.fs", - ghoul::Dictionary()); + _pointsProgram = renderEngine.buildRenderProgram( + "Galaxy points", + absPath("${MODULE_GALAXY}/shaders/points.vs"), + absPath("${MODULE_GALAXY}/shaders/points.fs"), + ghoul::Dictionary() + ); _pointsProgram->setIgnoreUniformLocationError( ghoul::opengl::ProgramObject::IgnoreError::Yes diff --git a/modules/globebrowsing/cache/memoryawaretilecache.cpp b/modules/globebrowsing/cache/memoryawaretilecache.cpp index 65d75d83bc..f907edd645 100644 --- a/modules/globebrowsing/cache/memoryawaretilecache.cpp +++ b/modules/globebrowsing/cache/memoryawaretilecache.cpp @@ -267,7 +267,7 @@ void MemoryAwareTileCache::createTileAndPut(ProviderTileKey key, ghoul_assert(texture->dataOwnership(), "Texture must have ownership of old data to avoid leaks"); texture->setPixelData(rawTile->imageData, Texture::TakeOwnership::Yes); - size_t expectedDataSize = texture->expectedPixelDataSize(); + [[ maybe_unused ]] size_t expectedDataSize = texture->expectedPixelDataSize(); size_t numBytes = rawTile->textureInitData->totalNumBytes(); ghoul_assert(expectedDataSize == numBytes, "Pixel data size is incorrect"); _numTextureBytesAllocatedOnCPU += numBytes - previousExpectedDataSize; diff --git a/modules/globebrowsing/globebrowsingmodule.cpp b/modules/globebrowsing/globebrowsingmodule.cpp index d3bed24ac7..621fc2eb82 100644 --- a/modules/globebrowsing/globebrowsingmodule.cpp +++ b/modules/globebrowsing/globebrowsingmodule.cpp @@ -54,7 +54,19 @@ #ifdef GLOBEBROWSING_USE_GDAL #include + +#ifdef _MSC_VER +#pragma warning (push) +// CPL throws warning about missing DLL interface +#pragma warning (disable : 4251) +#endif // _MSC_VER + #include + +#ifdef _MSC_VER +#pragma warning (pop) +#endif // _MSC_VER + #endif // GLOBEBROWSING_USE_GDAL #include "globebrowsingmodule_lua.inl" diff --git a/modules/globebrowsing/globes/pointglobe.cpp b/modules/globebrowsing/globes/pointglobe.cpp index 630cbd300c..a12301d610 100644 --- a/modules/globebrowsing/globes/pointglobe.cpp +++ b/modules/globebrowsing/globes/pointglobe.cpp @@ -31,6 +31,7 @@ #include #include +#include #include namespace { @@ -67,8 +68,9 @@ PointGlobe::~PointGlobe() { void PointGlobe::initialize() { _programObject = OsEng.renderEngine().buildRenderProgram( "PointGlobe", - "${MODULE_GLOBEBROWSING}/shaders/pointglobe_vs.glsl", - "${MODULE_GLOBEBROWSING}/shaders/pointglobe_fs.glsl"); + absPath("${MODULE_GLOBEBROWSING}/shaders/pointglobe_vs.glsl"), + absPath("${MODULE_GLOBEBROWSING}/shaders/pointglobe_fs.glsl") + ); glGenVertexArrays(1, &_vaoID); glGenBuffers(1, &_vertexBufferID); diff --git a/modules/globebrowsing/rendering/layershadermanager.cpp b/modules/globebrowsing/rendering/layershadermanager.cpp index 991e7d0d47..3ed4f9abaa 100644 --- a/modules/globebrowsing/rendering/layershadermanager.cpp +++ b/modules/globebrowsing/rendering/layershadermanager.cpp @@ -33,6 +33,7 @@ #include #include +#include #include namespace openspace::globebrowsing { @@ -227,8 +228,8 @@ void LayerShaderManager::recompileShaderProgram( _programObject = OsEng.renderEngine().buildRenderProgram( _shaderName, - _vsPath, - _fsPath, + absPath(_vsPath), + absPath(_fsPath), shaderDictionary ); diff --git a/modules/globebrowsing/tile/rawtiledatareader/gdalrawtiledatareader.cpp b/modules/globebrowsing/tile/rawtiledatareader/gdalrawtiledatareader.cpp index 9b324a9700..1073e70e64 100644 --- a/modules/globebrowsing/tile/rawtiledatareader/gdalrawtiledatareader.cpp +++ b/modules/globebrowsing/tile/rawtiledatareader/gdalrawtiledatareader.cpp @@ -37,12 +37,22 @@ #include #include +#ifdef _MSC_VER +#pragma warning (push) + // CPL throws warning about missing DLL interface +#pragma warning (disable : 4251) +#endif // _MSC_VER + #include #include #include #include +#ifdef _MSC_VER +#pragma warning (pop) +#endif // _MSC_VER + #include namespace openspace::globebrowsing { diff --git a/modules/globebrowsing/tile/rawtiledatareader/rawtiledatareader.cpp b/modules/globebrowsing/tile/rawtiledatareader/rawtiledatareader.cpp index 062b4cfc4b..20dd4a0dbb 100644 --- a/modules/globebrowsing/tile/rawtiledatareader/rawtiledatareader.cpp +++ b/modules/globebrowsing/tile/rawtiledatareader/rawtiledatareader.cpp @@ -361,8 +361,8 @@ PixelRegion::PixelCoordinate RawTileDataReader::geodeticToPixel( // ref: https://www.wolframalpha.com/input/?i=X+%3D+a0+%2B+a1P+%2B+a2L, // +Y+%3D+b0+%2B+b1P+%2B+b2L,+solve+for+P+and+L - double Xp = a[0] + P*a[1] + L*a[2]; - double Yp = b[0] + P*b[1] + L*b[2]; + [[ maybe_unused ]] double Xp = a[0] + P*a[1] + L*a[2]; + [[ maybe_unused ]] double Yp = b[0] + P*b[1] + L*b[2]; ghoul_assert(std::abs(X - Xp) < 1e-10, "inverse should yield X as before"); ghoul_assert(std::abs(Y - Yp) < 1e-10, "inverse should yield Y as before"); diff --git a/modules/globebrowsing/tile/rawtiledatareader/tiledatatype.cpp b/modules/globebrowsing/tile/rawtiledatareader/tiledatatype.cpp index 8d585addbe..0b12503e4c 100644 --- a/modules/globebrowsing/tile/rawtiledatareader/tiledatatype.cpp +++ b/modules/globebrowsing/tile/rawtiledatareader/tiledatatype.cpp @@ -25,8 +25,19 @@ #include #ifdef GLOBEBROWSING_USE_GDAL +#ifdef _MSC_VER +#pragma warning (push) + // CPL throws warning about missing DLL interface +#pragma warning (disable : 4251) +#endif // _MSC_VER + #include #include + +#ifdef _MSC_VER +#pragma warning (pop) +#endif // _MSC_VER + #endif // GLOBEBROWSING_USE_GDAL #include diff --git a/modules/imgui/imguimodule.cpp b/modules/imgui/imguimodule.cpp index 10c0d1360b..9e329b9119 100644 --- a/modules/imgui/imguimodule.cpp +++ b/modules/imgui/imguimodule.cpp @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -68,7 +69,8 @@ ImGUIModule::ImGUIModule() : OpenSpaceModule(Name) { &(OsEng.navigationHandler()), &(OsEng.renderEngine()), &(OsEng.parallelConnection()), - &(OsEng.console()) + &(OsEng.console()), + &(OsEng.dashboard()) }; return res; } diff --git a/modules/imgui/src/gui.cpp b/modules/imgui/src/gui.cpp index da648ae7d4..05a785f28d 100644 --- a/modules/imgui/src/gui.cpp +++ b/modules/imgui/src/gui.cpp @@ -529,8 +529,8 @@ void GUI::deinitialize() { void GUI::initializeGL() { _program = ghoul::opengl::ProgramObject::Build( "GUI", - "${MODULE_IMGUI}/shaders/gui_vs.glsl", - "${MODULE_IMGUI}/shaders/gui_fs.glsl" + absPath("${MODULE_IMGUI}/shaders/gui_vs.glsl"), + absPath("${MODULE_IMGUI}/shaders/gui_fs.glsl") ); if (!_program) { return; @@ -812,7 +812,7 @@ void GUI::render() { ImGui::SetNextWindowCollapsed(_isCollapsed); ImGui::Begin("OpenSpace GUI", nullptr); - + _isCollapsed = ImGui::IsWindowCollapsed(); bool property = _property.isEnabled(); @@ -893,7 +893,7 @@ void GUI::render() { addScreenSpaceRenderableOnline(std::string(addImageOnlineBuffer)); } - bool addDashboard = ImGui::Button("Add Dashboard"); + bool addDashboard = ImGui::Button("Add New Dashboard"); if (addDashboard) { OsEng.scriptEngine().queueScript( "openspace.addScreenSpaceRenderable({ Type = 'ScreenSpaceDashboard' });", @@ -901,6 +901,16 @@ void GUI::render() { ); } + bool addDashboardCopy = ImGui::Button("Add Copy of Main Dashboard"); + if (addDashboardCopy) { + OsEng.scriptEngine().queueScript( + "openspace.addScreenSpaceRenderable({ " + "Type = 'ScreenSpaceDashboard', UseMainDashboard = true " + "});", + openspace::scripting::ScriptEngine::RemoteScripting::Yes + ); + } + ImGui::Checkbox("ImGUI Internals", &_showInternals); if (_showInternals) { ImGui::Begin("Style Editor"); diff --git a/modules/imgui/src/guifilepathcomponent.cpp b/modules/imgui/src/guifilepathcomponent.cpp index d137fde5e2..6e2f663efa 100644 --- a/modules/imgui/src/guifilepathcomponent.cpp +++ b/modules/imgui/src/guifilepathcomponent.cpp @@ -36,7 +36,7 @@ GuiFilePathComponent::GuiFilePathComponent() void GuiFilePathComponent::render() { ImGui::SetNextWindowCollapsed(_isCollapsed); - + bool v = _isEnabled; ImGui::Begin("File Path", &v); _isCollapsed = ImGui::IsWindowCollapsed(); diff --git a/modules/imgui/src/guiiswacomponent.cpp b/modules/imgui/src/guiiswacomponent.cpp index bf363a4c1a..a9a4916cfc 100644 --- a/modules/imgui/src/guiiswacomponent.cpp +++ b/modules/imgui/src/guiiswacomponent.cpp @@ -55,7 +55,7 @@ void GuiIswaComponent::render() { bool oldIonDataValue = _ionData; ImGui::SetNextWindowCollapsed(_isCollapsed); - + bool e = _isEnabled; ImGui::Begin("ISWA", &e, WindowSize, 0.5f); _isEnabled = e; diff --git a/modules/imgui/src/guimissioncomponent.cpp b/modules/imgui/src/guimissioncomponent.cpp index 263311dab8..32972268e0 100644 --- a/modules/imgui/src/guimissioncomponent.cpp +++ b/modules/imgui/src/guimissioncomponent.cpp @@ -102,7 +102,7 @@ void GuiMissionComponent::render() { bool v = _isEnabled; ImGui::Begin(name().c_str(), &v, Size, 0.75f); _isEnabled = v; - + _isCollapsed = ImGui::IsWindowCollapsed(); ghoul_assert( diff --git a/modules/imgui/src/renderproperties.cpp b/modules/imgui/src/renderproperties.cpp index f56497bf8c..8b224cfff2 100644 --- a/modules/imgui/src/renderproperties.cpp +++ b/modules/imgui/src/renderproperties.cpp @@ -297,7 +297,7 @@ void renderStringListProperty(Property* prop, const std::string& ownerName, } } script += "}"; - + executeScript( p->fullyQualifiedIdentifier(), std::move(script), diff --git a/modules/iswa/rendering/iswacygnet.cpp b/modules/iswa/rendering/iswacygnet.cpp index 208709f1db..3f767e99bf 100644 --- a/modules/iswa/rendering/iswacygnet.cpp +++ b/modules/iswa/rendering/iswacygnet.cpp @@ -31,6 +31,7 @@ #include #include +#include #include namespace { @@ -266,9 +267,10 @@ void IswaCygnet::initializeTime() { bool IswaCygnet::createShader() { if (_shader == nullptr) { RenderEngine& renderEngine = OsEng.renderEngine(); - _shader = renderEngine.buildRenderProgram(_programName, - _vsPath, - _fsPath + _shader = renderEngine.buildRenderProgram( + _programName, + absPath(_vsPath), + absPath(_fsPath) ); if (!_shader) { return false; diff --git a/modules/iswa/util/dataprocessor.cpp b/modules/iswa/util/dataprocessor.cpp index 7132ba55a2..421a8ff2c4 100644 --- a/modules/iswa/util/dataprocessor.cpp +++ b/modules/iswa/util/dataprocessor.cpp @@ -173,7 +173,7 @@ void DataProcessor::calculateFilterValues(std::vector selectedOptions) { standardDeviation, _normValues ); - filterWidth = fabs(0.5-normalizeWithStandardScore( + filterWidth = fabs(0.5f-normalizeWithStandardScore( filterWidth, mean, standardDeviation, diff --git a/modules/kameleon/src/kameleonhelper.cpp b/modules/kameleon/src/kameleonhelper.cpp index 6d52f5d01a..f3b02a7069 100644 --- a/modules/kameleon/src/kameleonhelper.cpp +++ b/modules/kameleon/src/kameleonhelper.cpp @@ -26,7 +26,18 @@ #include +#ifdef _MSC_VER +#pragma warning (push) +// Boost throws #pragma warning: there is no warning number '4675' +#pragma warning (disable : 4619) +#endif // _MSC_VER + #include + +#ifdef _MSC_VER +#pragma warning (pop) +#endif // _MSC_VER + #include diff --git a/modules/kameleonvolume/rendering/renderablekameleonvolume.cpp b/modules/kameleonvolume/rendering/renderablekameleonvolume.cpp index 79da27d01f..3f863c183c 100644 --- a/modules/kameleonvolume/rendering/renderablekameleonvolume.cpp +++ b/modules/kameleonvolume/rendering/renderablekameleonvolume.cpp @@ -338,7 +338,7 @@ bool RenderableKameleonVolume::cachingEnabled() { } void RenderableKameleonVolume::load() { - if (!FileSys.fileExists(_sourcePath)) { + if (!FileSys.fileExists(ghoul::filesystem::File(_sourcePath))) { LERROR("File " << _sourcePath << " does not exist."); return; } diff --git a/modules/space/rendering/renderableconstellationbounds.cpp b/modules/space/rendering/renderableconstellationbounds.cpp index 0355f5009a..1c5dd07b42 100644 --- a/modules/space/rendering/renderableconstellationbounds.cpp +++ b/modules/space/rendering/renderableconstellationbounds.cpp @@ -198,8 +198,8 @@ RenderableConstellationBounds::RenderableConstellationBounds( void RenderableConstellationBounds::initializeGL() { _program = OsEng.renderEngine().buildRenderProgram( "ConstellationBounds", - "${MODULE_SPACE}/shaders/constellationbounds_vs.glsl", - "${MODULE_SPACE}/shaders/constellationbounds_fs.glsl" + absPath("${MODULE_SPACE}/shaders/constellationbounds_vs.glsl"), + absPath("${MODULE_SPACE}/shaders/constellationbounds_fs.glsl") ); diff --git a/modules/space/rendering/renderableplanet.cpp b/modules/space/rendering/renderableplanet.cpp index 163bbbcf15..d352d62559 100644 --- a/modules/space/rendering/renderableplanet.cpp +++ b/modules/space/rendering/renderableplanet.cpp @@ -341,29 +341,33 @@ void RenderablePlanet::initializeGL() { // shadow program _programObject = renderEngine.buildRenderProgram( "shadowNightProgram", - "${MODULE_SPACE}/shaders/shadow_nighttexture_vs.glsl", - "${MODULE_SPACE}/shaders/shadow_nighttexture_fs.glsl"); + absPath("${MODULE_SPACE}/shaders/shadow_nighttexture_vs.glsl"), + absPath("${MODULE_SPACE}/shaders/shadow_nighttexture_fs.glsl") + ); } else if (_programObject == nullptr && _shadowEnabled) { // shadow program _programObject = renderEngine.buildRenderProgram( "shadowProgram", - "${MODULE_SPACE}/shaders/shadow_vs.glsl", - "${MODULE_SPACE}/shaders/shadow_fs.glsl"); + absPath("${MODULE_SPACE}/shaders/shadow_vs.glsl"), + absPath("${MODULE_SPACE}/shaders/shadow_fs.glsl") + ); } else if (_programObject == nullptr && _hasNightTexture) { // Night texture program _programObject = renderEngine.buildRenderProgram( "nightTextureProgram", - "${MODULE_SPACE}/shaders/nighttexture_vs.glsl", - "${MODULE_SPACE}/shaders/nighttexture_fs.glsl"); + absPath("${MODULE_SPACE}/shaders/nighttexture_vs.glsl"), + absPath("${MODULE_SPACE}/shaders/nighttexture_fs.glsl") + ); } else if (_programObject == nullptr) { // pscstandard _programObject = renderEngine.buildRenderProgram( "pscstandard", - "${MODULE_SPACE}/shaders/renderableplanet_vs.glsl", - "${MODULE_SPACE}/shaders/renderableplanet_fs.glsl"); + absPath("${MODULE_SPACE}/shaders/renderableplanet_vs.glsl"), + absPath("${MODULE_SPACE}/shaders/renderableplanet_fs.glsl") + ); } using IgnoreError = ghoul::opengl::ProgramObject::IgnoreError; diff --git a/modules/space/rendering/renderablerings.cpp b/modules/space/rendering/renderablerings.cpp index 5c29b9108b..2f14d37544 100644 --- a/modules/space/rendering/renderablerings.cpp +++ b/modules/space/rendering/renderablerings.cpp @@ -186,10 +186,11 @@ bool RenderableRings::isReady() const { void RenderableRings::initializeGL() { if (!_shader) { RenderEngine& renderEngine = OsEng.renderEngine(); - _shader = renderEngine.buildRenderProgram("RingProgram", - "${MODULE_SPACE}/shaders/rings_vs.glsl", - "${MODULE_SPACE}/shaders/rings_fs.glsl" - ); + _shader = renderEngine.buildRenderProgram( + "RingProgram", + absPath("${MODULE_SPACE}/shaders/rings_vs.glsl"), + absPath("${MODULE_SPACE}/shaders/rings_fs.glsl") + ); _shader->setIgnoreUniformLocationError( ghoul::opengl::ProgramObject::IgnoreError::Yes ); diff --git a/modules/space/rendering/renderablestars.cpp b/modules/space/rendering/renderablestars.cpp index c81e189746..5bfe57451d 100644 --- a/modules/space/rendering/renderablestars.cpp +++ b/modules/space/rendering/renderablestars.cpp @@ -289,9 +289,10 @@ bool RenderableStars::isReady() const { void RenderableStars::initializeGL() { RenderEngine& renderEngine = OsEng.renderEngine(); _program = renderEngine.buildRenderProgram("Star", - "${MODULE_SPACE}/shaders/star_vs.glsl", - "${MODULE_SPACE}/shaders/star_fs.glsl", - "${MODULE_SPACE}/shaders/star_ge.glsl"); + absPath("${MODULE_SPACE}/shaders/star_vs.glsl"), + absPath("${MODULE_SPACE}/shaders/star_fs.glsl"), + absPath("${MODULE_SPACE}/shaders/star_ge.glsl") + ); bool success = loadData(); if (!success) { diff --git a/modules/space/translation/spicetranslation.cpp b/modules/space/translation/spicetranslation.cpp index 0fa2e97d95..ce223bfc52 100644 --- a/modules/space/translation/spicetranslation.cpp +++ b/modules/space/translation/spicetranslation.cpp @@ -147,13 +147,13 @@ SpiceTranslation::SpiceTranslation(const ghoul::Dictionary& dictionary) // Due to the specification, we can be sure it is either a Dictionary or a string if (dictionary.hasValue(KeyKernels)) { std::string kernel = dictionary.value(KeyKernels); - loadKernel(kernel); + loadKernel(absPath(kernel)); } else { ghoul::Dictionary kernels = dictionary.value(KeyKernels); for (size_t i = 1; i <= kernels.size(); ++i) { std::string kernel = kernels.value(std::to_string(i)); - loadKernel(kernel); + loadKernel(absPath(kernel)); } } } diff --git a/modules/spacecraftinstruments/CMakeLists.txt b/modules/spacecraftinstruments/CMakeLists.txt index 1a31aa5e9e..888ab68c08 100644 --- a/modules/spacecraftinstruments/CMakeLists.txt +++ b/modules/spacecraftinstruments/CMakeLists.txt @@ -25,6 +25,7 @@ include(${OPENSPACE_CMAKE_EXT_DIR}/module_definition.cmake) set(HEADER_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/dashboard/dashboarditeminstruments.h ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablecrawlingline.h ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablefov.h ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableplaneprojection.h @@ -47,6 +48,7 @@ set(HEADER_FILES source_group("Header Files" FILES ${HEADER_FILES}) set(SOURCE_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/dashboard/dashboarditeminstruments.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablecrawlingline.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderablefov.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rendering/renderableplaneprojection.cpp diff --git a/modules/spacecraftinstruments/dashboard/dashboarditeminstruments.cpp b/modules/spacecraftinstruments/dashboard/dashboarditeminstruments.cpp new file mode 100644 index 0000000000..93e12d863d --- /dev/null +++ b/modules/spacecraftinstruments/dashboard/dashboarditeminstruments.cpp @@ -0,0 +1,498 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#include + +namespace { + const char* KeyFontMono = "Mono"; + const float DefaultFontSize = 10.f; + + static const openspace::properties::Property::PropertyInfo FontNameInfo = { + "FontName", + "Font Name", + "This value is the name of the font that is used. It can either refer to an " + "internal name registered previously, or it can refer to a path that is used." + }; + + static const openspace::properties::Property::PropertyInfo FontSizeInfo = { + "FontSize", + "Font Size", + "This value determines the size of the font that is used to render the date." + }; + + static const openspace::properties::Property::PropertyInfo ActiveColorInfo = { + "ActiveColor", + "Active Color", + "This value determines the color that the active instrument is rendered in. " + "Shortly after activation, the used color is mixture of this and the flash color. " + "The default value is (0.6, 1.0, 0.0)." + }; + + static const openspace::properties::Property::PropertyInfo FlashColorInfo = { + "FlashColor", + "Flash Color", + "This value determines the color that is used shortly after an instrument " + "activation. The default value is (0.9, 1.0, 0.75)" + }; + + std::string progressToStr(int size, double t) { + std::string progress = "|"; + int g = static_cast((t * (size - 1)) + 1); + g = std::max(g, 0); + for (int i = 0; i < g; i++) { + progress.append("-"); + } + progress.append(">"); + for (int i = 0; i < size - g; i++) { + progress.append(" "); + } + progress.append("|"); + return progress; + } + + glm::vec2 addToBoundingbox(glm::vec2 lhs, glm::vec2 rhs) { + return { + std::max(lhs.x, rhs.x), + lhs.y + rhs.y + }; + } +} // namespace + +namespace openspace { + +documentation::Documentation DashboardItemInstruments::Documentation() { + using namespace documentation; + return { + "DashboardItem Instruments", + "spacecraftinstruments_dashboarditem_instuments", + { + { + "Type", + new StringEqualVerifier("DashboardItemInstruments"), + Optional::No + }, + { + FontNameInfo.identifier, + new StringVerifier, + Optional::Yes, + FontNameInfo.description + }, + { + FontSizeInfo.identifier, + new IntVerifier, + Optional::Yes, + FontSizeInfo.description + }, + { + ActiveColorInfo.identifier, + new DoubleVector3Verifier, + Optional::Yes, + ActiveColorInfo.description + }, + { + FlashColorInfo.identifier, + new DoubleVector3Verifier, + Optional::Yes, + FlashColorInfo.description + } + } + }; +} + +DashboardItemInstruments::DashboardItemInstruments(ghoul::Dictionary dictionary) + : DashboardItem("Instruments") + , _fontName(FontNameInfo, KeyFontMono) + , _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f) + , _activeColor( + ActiveColorInfo, + glm::vec3(0.6f, 1.f, 0.f), + glm::vec3(0.f), + glm::vec3(1.f) + ) + , _activeFlash(FlashColorInfo, + glm::vec3(0.9f, 1.f, 0.75f), + glm::vec3(0.f), + glm::vec3(1.f) + ) + , _font(OsEng.fontManager().font(KeyFontMono, 10)) +{ + documentation::testSpecificationAndThrow( + Documentation(), + dictionary, + "DashboardItemInstruments" + ); + + if (dictionary.hasKey(FontNameInfo.identifier)) { + _fontName = dictionary.value(FontNameInfo.identifier); + } + if (dictionary.hasKey(FontSizeInfo.identifier)) { + _fontSize = static_cast( + dictionary.value(FontSizeInfo.identifier) + ); + } + + _fontName.onChange([this]() { + _font = OsEng.fontManager().font(_fontName, _fontSize); + }); + addProperty(_fontName); + + _fontSize.onChange([this]() { + _font = OsEng.fontManager().font(_fontName, _fontSize); + }); + addProperty(_fontSize); + + _activeColor.setViewOption(properties::Property::ViewOptions::Color); + addProperty(_activeColor); + _activeFlash.setViewOption(properties::Property::ViewOptions::Color); + addProperty(_activeFlash); + + _font = OsEng.fontManager().font(_fontName, _fontSize); +} + +void DashboardItemInstruments::render(glm::vec2& penPosition) { + double currentTime = OsEng.timeManager().time().j2000Seconds(); + + if (ImageSequencer::ref().isReady()) { + penPosition.y -= 25.f; + + glm::vec4 targetColor(0.f, 0.75f, 1.f, 1.f); + + double remaining = ImageSequencer::ref().getNextCaptureTime() - currentTime; + float t = static_cast( + 1.0 - remaining / ImageSequencer::ref().getIntervalLength() + ); + + if (remaining > 0) { + RenderFontCr(*_font, + penPosition, + glm::vec4(glm::mix(_activeColor.value(), _activeFlash.value(), t), 1.f), + //active * t + brigther_active, + "Next instrument activity:" + ); + + const int Size = 25; + int p = std::max(static_cast((t * (Size - 1)) + 1), 0); + RenderFontCr(*_font, + penPosition, + glm::vec4(glm::mix(_activeColor.value(), _activeFlash.value(), t), 1.f), + "%4.0f s |%s>%s| %.1f %%", + remaining, + std::string(p, '-').c_str(), + std::string(Size - p, ' ').c_str(), + t * 100 + ); + + std::string str = SpiceManager::ref().dateFromEphemerisTime( + ImageSequencer::ref().getNextCaptureTime(), + "YYYY MON DD HR:MN:SC" + ); + + RenderFontCr(*_font, + penPosition, + glm::vec4(_activeColor.value(), 1.f), + "Data acquisition time: %s", + str.c_str() + ); + } + std::pair nextTarget = ImageSequencer::ref().getNextTarget(); + std::pair currentTarget = + ImageSequencer::ref().getCurrentTarget(); + + if (currentTarget.first > 0.0) { + using namespace std::chrono; + seconds tls = seconds(static_cast(nextTarget.first - currentTime)); + + hours tlh = duration_cast(tls); + tls -= tlh; + minutes tlm = duration_cast(tls); + tls -= tlm; + + RenderFontCr(*_font, + penPosition, + targetColor, + "Next image: [%02i:%02i:%02i]", + tlh.count(), tlm.count(), tls.count() + ); + + penPosition.y -= _font->height(); + + std::map activeMap = + ImageSequencer::ref().getActiveInstruments(); + glm::vec4 firing(0.58 - t, 1 - t, 1 - t, 1); + glm::vec4 notFiring(0.5, 0.5, 0.5, 1); + + RenderFontCr(*_font, + penPosition, + glm::vec4(_activeColor.value(), 1.f), + "Active Instruments:" + ); + + for (auto m : activeMap) { + if (m.second == false) { + RenderFont(*_font, + penPosition, + glm::vec4(0.3, 0.3, 0.3, 1), + "| |" + ); + RenderFontCr(*_font, + penPosition, + glm::vec4(0.3, 0.3, 0.3, 1), + " %5s", + m.first.c_str() + ); + + } + else { + RenderFont(*_font, + penPosition, + glm::vec4(0.3, 0.3, 0.3, 1), + "|" + ); + if (m.first == "NH_LORRI") { + RenderFont(*_font, + penPosition, + firing, + " + " + ); + } + RenderFont(*_font, + penPosition, + glm::vec4(0.3, 0.3, 0.3, 1), + " |" + ); + RenderFontCr(*_font, + penPosition, + glm::vec4(_activeColor.value(), 1.f), + " %5s", + m.first.c_str() + ); + } + } + } + } +} + +glm::vec2 DashboardItemInstruments::size() const { + glm::vec2 size = { 0.f, 0.f }; + //return ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox( + bool hasNewHorizons = OsEng.renderEngine().scene()->sceneGraphNode("NewHorizons"); + double currentTime = OsEng.timeManager().time().j2000Seconds(); + + if (ImageSequencer::ref().isReady()) { + glm::vec4 targetColor(0.f, 0.75f, 1.f, 1.f); + + if (hasNewHorizons) { + try { + double lt; + glm::dvec3 p = SpiceManager::ref().targetPosition( + "PLUTO", + "NEW HORIZONS", + "GALACTIC", + {}, + currentTime, + lt + ); + psc nhPos = PowerScaledCoordinate::CreatePowerScaledCoordinate( + p.x, + p.y, + p.z + ); + float a, b; + glm::dvec3 radii; + SpiceManager::ref().getValue("PLUTO", "RADII", radii); + a = static_cast(radii.x); + b = static_cast(radii.y); + float radius = (a + b) / 2.f; + float distToSurf = glm::length(nhPos.vec3()) - radius; + + size = addToBoundingbox( + size, + ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox( + *_font, + "Distance to Pluto: % .1f (KM)", + distToSurf + ).boundingBox + ); + } + catch (...) { + // @CLEANUP: This is bad as it will discard all exceptions + // without telling us about it! ---abock + } + } + + double remaining = openspace::ImageSequencer::ref().getNextCaptureTime() - + currentTime; + float t = static_cast( + 1.0 - remaining / openspace::ImageSequencer::ref().getIntervalLength() + ); + + std::string str = SpiceManager::ref().dateFromEphemerisTime( + ImageSequencer::ref().getNextCaptureTime(), + "YYYY MON DD HR:MN:SC" + ); + + + if (remaining > 0) { + std::string progress = progressToStr(25, t); + + size = addToBoundingbox( + size, + ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox( + *_font, + "Next instrument activity:" + ).boundingBox + ); + + size = addToBoundingbox( + size, + ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox( + *_font, + "%.0f s %s %.1f %%", + remaining, progress.c_str(), t * 100 + ).boundingBox + ); + + size = addToBoundingbox( + size, + ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox( + *_font, + "Data acquisition time: %s", + str.c_str() + ).boundingBox + ); + } + std::pair nextTarget = ImageSequencer::ref().getNextTarget(); + std::pair currentTarget = + ImageSequencer::ref().getCurrentTarget(); + + if (currentTarget.first > 0.0) { + int timeleft = static_cast(nextTarget.first - currentTime); + + int hour = timeleft / 3600; + int second = timeleft % 3600; + int minute = second / 60; + second = second % 60; + + std::string hh, mm, ss; + + if (hour < 10) + hh.append("0"); + if (minute < 10) + mm.append("0"); + if (second < 10) + ss.append("0"); + + hh.append(std::to_string(hour)); + mm.append(std::to_string(minute)); + ss.append(std::to_string(second)); + + size = addToBoundingbox( + size, + ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox( + *_font, + "Data acquisition adjacency: [%s:%s:%s]", + hh.c_str(), mm.c_str(), ss.c_str() + ).boundingBox + ); + + size.y += _font->height(); + + std::map activeMap = + ImageSequencer::ref().getActiveInstruments(); + glm::vec4 firing(0.58 - t, 1 - t, 1 - t, 1); + glm::vec4 notFiring(0.5, 0.5, 0.5, 1); + + size = addToBoundingbox( + size, + ghoul::fontrendering::FontRenderer::defaultRenderer().boundingBox( + *_font, + "Active Instruments:" + ).boundingBox + ); + + // @TODO: Fix this up ---abock + + //for (auto m : activeMap) { + // if (m.second == false) { + // RenderFont(*_font, + // penPosition, + // glm::vec4(0.3, 0.3, 0.3, 1), + // "| |" + // ); + // RenderFontCr(*_font, + // penPosition, + // glm::vec4(0.3, 0.3, 0.3, 1), + // " %5s", + // m.first.c_str() + // ); + + // } + // else { + // RenderFont(*_font, + // penPosition, + // glm::vec4(0.3, 0.3, 0.3, 1), + // "|" + // ); + // if (m.first == "NH_LORRI") { + // RenderFont(*_font, + // penPosition, + // firing, + // " + " + // ); + // } + // RenderFont(*_font, + // penPosition, + // glm::vec4(0.3, 0.3, 0.3, 1), + // " |" + // ); + // RenderFontCr(*_font, + // penPosition, + // active, + // " %5s", + // m.first.c_str() + // ); + // } + //} + } + } + + return size; +} + +} // namespace openspace diff --git a/modules/spacecraftinstruments/dashboard/dashboarditeminstruments.h b/modules/spacecraftinstruments/dashboard/dashboarditeminstruments.h new file mode 100644 index 0000000000..c67e293c14 --- /dev/null +++ b/modules/spacecraftinstruments/dashboard/dashboarditeminstruments.h @@ -0,0 +1,64 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 __OPENSPACE_MODULE_SPACECRAFTINSTRUMENTS___DASHBOARDITEMINSTRUMENTS___H__ +#define __OPENSPACE_MODULE_SPACECRAFTINSTRUMENTS___DASHBOARDITEMINSTRUMENTS___H__ + +#include + +#include +#include +#include + +namespace ghoul::fontrendering { class Font; } + +namespace openspace { + +namespace documentation { struct Documentation; } + +class DashboardItemInstruments : public DashboardItem { +public: + DashboardItemInstruments(ghoul::Dictionary dictionary); + ~DashboardItemInstruments() = default; + + void render(glm::vec2& penPosition) override; + + glm::vec2 size() const override; + + static documentation::Documentation Documentation(); + +private: + properties::StringProperty _fontName; + properties::FloatProperty _fontSize; + + properties::Vec3Property _activeColor; + properties::Vec3Property _activeFlash; + + + std::shared_ptr _font; +}; + +} // namespace openspace + +#endif // __OPENSPACE_MODULE_SPACECRAFTINSTRUMENTS___DASHBOARDITEMINSTRUMENTS___H__ diff --git a/modules/spacecraftinstruments/rendering/renderablecrawlingline.cpp b/modules/spacecraftinstruments/rendering/renderablecrawlingline.cpp index 6b711a7132..98dc9a7bdd 100644 --- a/modules/spacecraftinstruments/rendering/renderablecrawlingline.cpp +++ b/modules/spacecraftinstruments/rendering/renderablecrawlingline.cpp @@ -32,6 +32,7 @@ #include #include +#include #include #include @@ -139,8 +140,8 @@ void RenderableCrawlingLine::initializeGL() { RenderEngine& renderEngine = OsEng.renderEngine(); _program = renderEngine.buildRenderProgram( "RenderableCrawlingLine", - "${MODULE_SPACECRAFTINSTRUMENTS}/shaders/crawlingline_vs.glsl", - "${MODULE_SPACECRAFTINSTRUMENTS}/shaders/crawlingline_fs.glsl" + absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/crawlingline_vs.glsl"), + absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/crawlingline_fs.glsl") ); glGenVertexArrays(1, &_vao); diff --git a/modules/spacecraftinstruments/rendering/renderablefov.cpp b/modules/spacecraftinstruments/rendering/renderablefov.cpp index 226c089204..297559e824 100644 --- a/modules/spacecraftinstruments/rendering/renderablefov.cpp +++ b/modules/spacecraftinstruments/rendering/renderablefov.cpp @@ -32,6 +32,7 @@ #include #include +#include #include #include @@ -301,8 +302,8 @@ void RenderableFov::initializeGL() { RenderEngine& renderEngine = OsEng.renderEngine(); _programObject = renderEngine.buildRenderProgram( "FovProgram", - "${MODULE_SPACECRAFTINSTRUMENTS}/shaders/fov_vs.glsl", - "${MODULE_SPACECRAFTINSTRUMENTS}/shaders/fov_fs.glsl" + absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/fov_vs.glsl"), + absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/fov_fs.glsl") ); // Fetch information about the specific instrument diff --git a/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp b/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp index 52f7d53a80..0e864f897e 100644 --- a/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp +++ b/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp @@ -182,21 +182,31 @@ bool RenderableModelProjection::isReady() const { void RenderableModelProjection::initializeGL() { RenderEngine& renderEngine = OsEng.renderEngine(); - _programObject = renderEngine.buildRenderProgram("ModelShader", - "${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderableModel_vs.glsl", - "${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderableModel_fs.glsl"); + _programObject = renderEngine.buildRenderProgram( + "ModelShader", + absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderableModel_vs.glsl"), + absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderableModel_fs.glsl") + ); - _fboProgramObject = ghoul::opengl::ProgramObject::Build("ProjectionPass", - "${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderableModelProjection_vs.glsl", - "${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderableModelProjection_fs.glsl"); + _fboProgramObject = ghoul::opengl::ProgramObject::Build( + "ProjectionPass", + absPath( + "${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderableModelProjection_vs.glsl" + ), + absPath( + "${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderableModelProjection_fs.glsl" + ) + ); _fboProgramObject->setIgnoreUniformLocationError( ghoul::opengl::ProgramObject::IgnoreError::Yes ); - _depthFboProgramObject = ghoul::opengl::ProgramObject::Build("DepthPass", - "${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderableModelDepth_vs.glsl", - "${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderableModelDepth_fs.glsl"); + _depthFboProgramObject = ghoul::opengl::ProgramObject::Build( + "DepthPass", + absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderableModelDepth_vs.glsl"), + absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderableModelDepth_fs.glsl") + ); loadTextures(); diff --git a/modules/spacecraftinstruments/rendering/renderableplaneprojection.cpp b/modules/spacecraftinstruments/rendering/renderableplaneprojection.cpp index e90c6b7ed6..c60e9fa154 100644 --- a/modules/spacecraftinstruments/rendering/renderableplaneprojection.cpp +++ b/modules/spacecraftinstruments/rendering/renderableplaneprojection.cpp @@ -100,8 +100,8 @@ void RenderablePlaneProjection::initializeGL() { RenderEngine& renderEngine = OsEng.renderEngine(); _shader = renderEngine.buildRenderProgram( "Image Plane", - "${MODULE_BASE}/shaders/imageplane_vs.glsl", - "${MODULE_BASE}/shaders/imageplane_fs.glsl" + absPath("${MODULE_BASE}/shaders/imageplane_vs.glsl"), + absPath("${MODULE_BASE}/shaders/imageplane_fs.glsl") ); setTarget(_defaultTarget); diff --git a/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp b/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp index 4471e33193..7eb6119d96 100644 --- a/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp +++ b/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp @@ -226,14 +226,18 @@ RenderablePlanetProjection::~RenderablePlanetProjection() {} void RenderablePlanetProjection::initializeGL() { _programObject = OsEng.renderEngine().buildRenderProgram( "projectiveProgram", - "${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderablePlanet_vs.glsl", - "${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderablePlanet_fs.glsl" + absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderablePlanet_vs.glsl"), + absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderablePlanet_fs.glsl") ); _fboProgramObject = ghoul::opengl::ProgramObject::Build( "fboPassProgram", - "${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderablePlanetProjection_vs.glsl", - "${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderablePlanetProjection_fs.glsl" + absPath( + "${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderablePlanetProjection_vs.glsl" + ), + absPath( + "${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderablePlanetProjection_fs.glsl" + ) ); loadTextures(); diff --git a/modules/spacecraftinstruments/rendering/renderableshadowcylinder.cpp b/modules/spacecraftinstruments/rendering/renderableshadowcylinder.cpp index 02dc695cf9..bffb6d2a34 100644 --- a/modules/spacecraftinstruments/rendering/renderableshadowcylinder.cpp +++ b/modules/spacecraftinstruments/rendering/renderableshadowcylinder.cpp @@ -31,6 +31,7 @@ #include #include +#include #include namespace { @@ -267,8 +268,8 @@ void RenderableShadowCylinder::initializeGL() { RenderEngine& renderEngine = OsEng.renderEngine(); _shader = renderEngine.buildRenderProgram( "ShadowCylinderProgram", - "${MODULE_SPACECRAFTINSTRUMENTS}/shaders/terminatorshadow_vs.glsl", - "${MODULE_SPACECRAFTINSTRUMENTS}/shaders/terminatorshadow_fs.glsl" + absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/terminatorshadow_vs.glsl"), + absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/terminatorshadow_fs.glsl") ); } diff --git a/modules/spacecraftinstruments/spacecraftinstrumentsmodule.cpp b/modules/spacecraftinstruments/spacecraftinstrumentsmodule.cpp index 22a46eacb2..e021a9c86b 100644 --- a/modules/spacecraftinstruments/spacecraftinstrumentsmodule.cpp +++ b/modules/spacecraftinstruments/spacecraftinstrumentsmodule.cpp @@ -24,6 +24,8 @@ #include +#include + #include #include #include @@ -53,6 +55,11 @@ void SpacecraftInstrumentsModule::internalInitialize() { "Decoder" ); + auto fDashboard = FactoryManager::ref().factory(); + ghoul_assert(fDashboard, "Dashboard factory was not created"); + + fDashboard->registerClass("DashboardItemInstruments"); + auto fRenderable = FactoryManager::ref().factory(); ghoul_assert(fRenderable, "No renderable factory existed"); diff --git a/modules/spacecraftinstruments/util/hongkangparser.cpp b/modules/spacecraftinstruments/util/hongkangparser.cpp index a38a2e03f4..5df2265aa5 100644 --- a/modules/spacecraftinstruments/util/hongkangparser.cpp +++ b/modules/spacecraftinstruments/util/hongkangparser.cpp @@ -297,11 +297,7 @@ bool HongKangParser::augmentWithSpice(Image& image, std::string spacecraft, std::vector potentialTargets) { image.target = "VOID"; - // we have (?) to cast to int, unfortunately - // Why? --abock - // because: old comment --m - - int exposureTime = image.timeRange.duration(); + int exposureTime = static_cast(image.timeRange.duration()); if (exposureTime == 0) { exposureTime = 1; } diff --git a/modules/touch/src/touchinteraction.cpp b/modules/touch/src/touchinteraction.cpp index 9bcb77fe04..0fc502bb7c 100644 --- a/modules/touch/src/touchinteraction.cpp +++ b/modules/touch/src/touchinteraction.cpp @@ -1034,11 +1034,11 @@ void TouchInteraction::step(double dt) { directionToCenter = normalize(-centerToCam); dvec3 lookUpWhenFacingCenter = globalCamRot * dvec3(_camera->lookUpVectorCameraSpace()); - dmat4 lookAtMat = lookAt( + dmat4 lookAtMatrix = lookAt( dvec3(0, 0, 0), directionToCenter, lookUpWhenFacingCenter); - globalCamRot = normalize(quat_cast(inverse(lookAtMat))); + globalCamRot = normalize(quat_cast(inverse(lookAtMatrix))); } { // Zooming centerToBoundingSphere = -directionToCenter * boundingSphere; diff --git a/modules/touch/src/touchmarker.cpp b/modules/touch/src/touchmarker.cpp index d71404b413..2509c59ada 100644 --- a/modules/touch/src/touchmarker.cpp +++ b/modules/touch/src/touchmarker.cpp @@ -94,9 +94,10 @@ bool TouchMarker::initialize() { glGenBuffers(1, &_vertexPositionBuffer); // generate buffer try { - _shader = OsEng.renderEngine().buildRenderProgram("MarkerProgram", - "${MODULE_TOUCH}/shaders/marker_vs.glsl", - "${MODULE_TOUCH}/shaders/marker_fs.glsl" + _shader = OsEng.renderEngine().buildRenderProgram( + "MarkerProgram", + absPath("${MODULE_TOUCH}/shaders/marker_vs.glsl"), + absPath("${MODULE_TOUCH}/shaders/marker_fs.glsl") ); } catch (const ghoul::opengl::ShaderObject::ShaderCompileError& e) { diff --git a/openspace.cfg b/openspace.cfg index 200b3ae122..03c66afc74 100644 --- a/openspace.cfg +++ b/openspace.cfg @@ -38,6 +38,7 @@ return { -- Scene = "${SCENE}/rosetta.scene", -- Scene = "${SCENE}/osirisrex.scene", -- Scene = "${SCENE}/satellites.scene", + -- Scene = "${SCENE}/voyager.scene", TasksRoot = "${OPENSPACE_DATA}/tasks", diff --git a/scripts/scene_helper.lua b/scripts/scene_helper.lua index e8d19c7e98..5f3c10f246 100644 --- a/scripts/scene_helper.lua +++ b/scripts/scene_helper.lua @@ -12,6 +12,14 @@ openspace.documentation = { Documentation = "This function sets the default GUI sorting for the space " .. "environment to increasing size, from solar system, through Milky Way, " .. "Universe and finishing with other elements" + }, + { + Name = "set_default_dashboard", + Arguments = "", + Documentation = "This function sets the default values for the dashboard " .. + "consisting of 'DashboardItemDate', 'DashboardItemSimulationIncrement', " .. + "'DashboardItemDistance', 'DashboardItemFramerate', and " .. + "'DashboardItemParallelConnection'." } } @@ -23,6 +31,28 @@ openspace.mark_interesting_nodes = function(nodes) end end +openspace.set_default_dashboard = function() + openspace.dashboard.addDashboardItem({ + Type = "DashboardItemDate" + }) + + openspace.dashboard.addDashboardItem({ + Type = "DashboardItemSimulationIncrement" + }) + + openspace.dashboard.addDashboardItem({ + Type = "DashboardItemDistance" + }) + + openspace.dashboard.addDashboardItem({ + Type = "DashboardItemFramerate" + }) + + openspace.dashboard.addDashboardItem({ + Type = "DashboardItemParallelConnection" + }) +end + openspace.set_default_gui_sorting = function() openspace.setPropertyValueSingle( 'Global Properties.ImGUI.Main.Properties.Ordering', @@ -30,4 +60,4 @@ openspace.set_default_gui_sorting = function() "Solar System", "Milky Way", "Universe", "Other" } ) -end \ No newline at end of file +end diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index ee95c98925..8211de259c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -120,6 +120,9 @@ set(OPENSPACE_SOURCE ${OPENSPACE_BASE_DIR}/src/properties/vector/vec4property.cpp ${OPENSPACE_BASE_DIR}/src/query/query.cpp ${OPENSPACE_BASE_DIR}/src/rendering/abufferrenderer.cpp + ${OPENSPACE_BASE_DIR}/src/rendering/dashboard.cpp + ${OPENSPACE_BASE_DIR}/src/rendering/dashboard_lua.inl + ${OPENSPACE_BASE_DIR}/src/rendering/dashboarditem.cpp ${OPENSPACE_BASE_DIR}/src/rendering/framebufferrenderer.cpp ${OPENSPACE_BASE_DIR}/src/rendering/deferredcastermanager.cpp ${OPENSPACE_BASE_DIR}/src/rendering/loadingscreen.cpp @@ -287,6 +290,8 @@ set(OPENSPACE_HEADER ${OPENSPACE_BASE_DIR}/include/openspace/properties/vector/vec4property.h ${OPENSPACE_BASE_DIR}/include/openspace/query/query.h ${OPENSPACE_BASE_DIR}/include/openspace/rendering/abufferrenderer.h + ${OPENSPACE_BASE_DIR}/include/openspace/rendering/dashboard.h + ${OPENSPACE_BASE_DIR}/include/openspace/rendering/dashboarditem.h ${OPENSPACE_BASE_DIR}/include/openspace/rendering/framebufferrenderer.h ${OPENSPACE_BASE_DIR}/include/openspace/rendering/deferredcasterlistener.h ${OPENSPACE_BASE_DIR}/include/openspace/rendering/deferredcastermanager.h diff --git a/src/documentation/core_registration.cpp b/src/documentation/core_registration.cpp index c06fcc4721..03c058e98a 100644 --- a/src/documentation/core_registration.cpp +++ b/src/documentation/core_registration.cpp @@ -34,6 +34,7 @@ #include #include #include +#include #include #include #include @@ -51,8 +52,8 @@ namespace openspace { void registerCoreClasses(documentation::DocumentationEngine& engine) { - engine.addDocumentation(LogFactoryDocumentation()); engine.addDocumentation(ConfigurationManager::Documentation()); + engine.addDocumentation(LogFactoryDocumentation()); engine.addDocumentation(Mission::Documentation()); engine.addDocumentation(Renderable::Documentation()); engine.addDocumentation(Rotation::Documentation()); @@ -65,19 +66,19 @@ void registerCoreClasses(documentation::DocumentationEngine& engine) { } void registerCoreClasses(scripting::ScriptEngine& engine) { + engine.addLibrary(Dashboard::luaLibrary()); + engine.addLibrary(MissionManager::luaLibrary()); + engine.addLibrary(ModuleEngine::luaLibrary()); engine.addLibrary(OpenSpaceEngine::luaLibrary()); - engine.addLibrary(SpiceManager::luaLibrary()); + engine.addLibrary(ParallelConnection::luaLibrary()); engine.addLibrary(RenderEngine::luaLibrary()); + engine.addLibrary(SpiceManager::luaLibrary()); engine.addLibrary(Scene::luaLibrary()); engine.addLibrary(Time::luaLibrary()); + engine.addLibrary(WindowWrapper::luaLibrary()); engine.addLibrary(interaction::KeyBindingManager::luaLibrary()); engine.addLibrary(interaction::NavigationHandler::luaLibrary()); - engine.addLibrary(ParallelConnection::luaLibrary()); - engine.addLibrary(ModuleEngine::luaLibrary()); engine.addLibrary(scripting::ScriptScheduler::luaLibrary()); - engine.addLibrary(WindowWrapper::luaLibrary()); - engine.addLibrary(MissionManager::luaLibrary()); - engine.addLibrary(scripting::generalSystemCapabilities()); engine.addLibrary(scripting::openglSystemCapabilities()); } diff --git a/src/engine/configurationmanager.cpp b/src/engine/configurationmanager.cpp index a070a79aed..97496bc63f 100644 --- a/src/engine/configurationmanager.cpp +++ b/src/engine/configurationmanager.cpp @@ -157,8 +157,7 @@ void ConfigurationManager::loadFromFile(const string& filename) { FileSystem::TokenClosingBraces; // Retrieving the directory in which the configuration file lies - string absolutePath = FileSys.absolutePath(filename); - string basePath = ghoul::filesystem::File(absolutePath).directoryName(); + string basePath = ghoul::filesystem::File(filename).directoryName(); FileSys.registerPathToken(basePathToken, basePath); ghoul::lua::LuaState state; diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index 579ac61145..f492efff13 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -41,6 +41,8 @@ #include #include #include +#include +#include #include #include #include @@ -146,6 +148,7 @@ OpenSpaceEngine::OpenSpaceEngine(std::string programName, std::unique_ptr windowWrapper) : _configurationManager(new ConfigurationManager) , _sceneManager(new SceneManager) + , _dashboard(new Dashboard) , _downloadManager(nullptr) , _console(new LuaConsole) , _moduleEngine(new ModuleEngine) @@ -177,13 +180,14 @@ OpenSpaceEngine::OpenSpaceEngine(std::string programName, { _navigationHandler->setPropertyOwner(_globalPropertyNamespace.get()); - // New property subowners also have to be added to the OnScreenGuiModule callback! + // New property subowners also have to be added to the ImGuiModule callback! _globalPropertyNamespace->addPropertySubOwner(_navigationHandler.get()); _globalPropertyNamespace->addPropertySubOwner(_settingsEngine.get()); _globalPropertyNamespace->addPropertySubOwner(_renderEngine.get()); _globalPropertyNamespace->addPropertySubOwner(_windowWrapper.get()); _globalPropertyNamespace->addPropertySubOwner(_parallelConnection.get()); _globalPropertyNamespace->addPropertySubOwner(_console.get()); + _globalPropertyNamespace->addPropertySubOwner(_dashboard.get()); _versionInformation.versionString.setReadOnly(true); @@ -212,6 +216,10 @@ OpenSpaceEngine::OpenSpaceEngine(std::string programName, std::make_unique>(), "Task" ); + FactoryManager::ref().addFactory( + std::make_unique>(), + "DashboardItem" + ); SpiceManager::initialize(); TransformationManager::initialize(); @@ -515,6 +523,10 @@ void OpenSpaceEngine::initialize() { for (OpenSpaceModule* module : _moduleEngine->modules()) { _scriptEngine->addLibrary(module->luaLibrary()); + + for (scripting::LuaLibrary& l : module->luaLibraries()) { + _scriptEngine->addLibrary(l); + } } // TODO: Maybe move all scenegraph and renderengine stuff to initializeGL @@ -597,7 +609,7 @@ void OpenSpaceEngine::loadScene(const std::string& scenePath) { } bool showNodeNames = true; - std::string kNames = + std::string kNames = ConfigurationManager::KeyLoadingScreen + "." + ConfigurationManager::PartShowNodeNames; @@ -907,12 +919,12 @@ void OpenSpaceEngine::runGlobalCustomizationScripts(const std::string& sceneDesc if (_configurationManager->hasKey(k)) { ghoul::Dictionary dict = _configurationManager->value(k); for (int i = 1; i <= dict.size(); ++i) { - std::string script = dict.value(std::to_string(i)); + std::string script = absPath(dict.value(std::to_string(i))); if (FileSys.fileExists(script)) { try { LINFO("Running global customization script: " << script); - ghoul::lua::runScriptFile(state, absPath(script)); + ghoul::lua::runScriptFile(state, script); } catch (ghoul::RuntimeError& e) { LERRORC(e.component, e.message); } @@ -1627,6 +1639,11 @@ LuaConsole& OpenSpaceEngine::console() { return *_console; } +Dashboard& OpenSpaceEngine::dashboard() { + ghoul_assert(_dashboard, "Dashboard must not be nullptr"); + return *_dashboard; +} + DownloadManager& OpenSpaceEngine::downloadManager() { ghoul_assert(_downloadManager, "Download Manager must not be nullptr"); return *_downloadManager; diff --git a/src/interaction/luaconsole.cpp b/src/interaction/luaconsole.cpp index 532f0bf750..6d97fa68ce 100644 --- a/src/interaction/luaconsole.cpp +++ b/src/interaction/luaconsole.cpp @@ -223,8 +223,8 @@ void LuaConsole::initialize() { _program = ghoul::opengl::ProgramObject::Build( "Console", - "${SHADERS}/luaconsole.vert", - "${SHADERS}/luaconsole.frag" + absPath("${SHADERS}/luaconsole.vert"), + absPath("${SHADERS}/luaconsole.frag") ); GLfloat data[] = { diff --git a/src/rendering/dashboard.cpp b/src/rendering/dashboard.cpp new file mode 100644 index 0000000000..c62dab5170 --- /dev/null +++ b/src/rendering/dashboard.cpp @@ -0,0 +1,114 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + +#include +#include + +#include "dashboard_lua.inl" + +namespace openspace { + +Dashboard::Dashboard() + : properties::PropertyOwner({ "Dashboard" }) +{} + +void Dashboard::addDashboardItem(std::unique_ptr item) { + std::string originalName = item->name(); + int suffix = 1; + while (true) { + auto it = std::find_if( + _items.begin(), + _items.end(), + [&item](const std::unique_ptr& i) { + return (i->name() == item->name()); + } + ); + + if (it == _items.end()) { + // We found a unique name + break; + } + else { + item->setName(originalName + " " + std::to_string(suffix)); + ++suffix; + } + } + + addPropertySubOwner(item.get()); + _items.push_back(std::move(item)); +} + +void Dashboard::removeDashboardItem(int index) { + ghoul_assert(index < _items.size(), "Invalid index"); + removePropertySubOwner(_items[index].get()); + _items.erase(_items.begin() + index); +} + +bool Dashboard::hasItem(int index) const { + return (index >= 0) && (index < _items.size()); +} + +const DashboardItem& Dashboard::item(int index) const { + ghoul_assert(index < _items.size(), "Invalid index"); + return *_items[index]; +} + +void Dashboard::removeDashboardItems() { + for (const std::unique_ptr& item : _items) { + removePropertySubOwner(item.get()); + } + _items.clear(); +} + +void Dashboard::render(glm::vec2& penPosition) { + for (const std::unique_ptr& item : _items) { + if (item->isEnabled()) { + item->render(penPosition); + } + } +} + +scripting::LuaLibrary Dashboard::luaLibrary() { + return { + "dashboard", + { + { + "addDashboardItem", + &luascriptfunctions::addDashboardItem, + "table", + "Adds a new dashboard item to the main dashboard." + }, + { + "removeDashboardItems", + &luascriptfunctions::removeDashboardItems, + "", + "Removes all dashboard items from the main dashboard." + } + } + }; +} + +} // namespace openspace diff --git a/src/rendering/dashboard_lua.inl b/src/rendering/dashboard_lua.inl new file mode 100644 index 0000000000..ea5ba1dcb8 --- /dev/null +++ b/src/rendering/dashboard_lua.inl @@ -0,0 +1,74 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 +#include +#include + +namespace openspace::luascriptfunctions { + +/** +* \ingroup LuaScripts +* addDashboardItem(table): +*/ +int addDashboardItem(lua_State* L) { + int nArguments = lua_gettop(L); + if (nArguments != 1) { + return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); + } + + int type = lua_type(L, -1); + if (type == LUA_TTABLE) { + ghoul::Dictionary d; + try { + ghoul::lua::luaDictionaryFromState(L, d); + } + catch (const ghoul::lua::LuaFormatException& e) { + LERRORC("addDashboardItem", e.what()); + return 0; + } + + OsEng.dashboard().addDashboardItem(DashboardItem::createFromDictionary(d)); + return 0; + } + else { + return luaL_error(L, "Expected argument of type 'string' or 'table'"); + } +} + +/** +* \ingroup LuaScripts +* removeDashboardItems(): +*/ +int removeDashboardItems(lua_State* L) { + int nArguments = lua_gettop(L); + if (nArguments > 1) { + return luaL_error(L, "Expected %i or %i arguments, got %i", 0, 1, nArguments); + } + + OsEng.dashboard().removeDashboardItems(); + return 0; +} + +}// namespace openspace::luascriptfunctions diff --git a/src/rendering/dashboarditem.cpp b/src/rendering/dashboarditem.cpp new file mode 100644 index 0000000000..dd4275312d --- /dev/null +++ b/src/rendering/dashboarditem.cpp @@ -0,0 +1,65 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2017 * + * * + * 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 + +#include + +#include + +namespace { + const char* KeyType = "Type"; + + static const openspace::properties::Property::PropertyInfo EnabledInfo = { + "Enabled", + "Is Enabled", + "If this value is set to 'true' this dashboard item is shown in the dashboard" + }; +} // namespace + +namespace openspace { + +std::unique_ptr DashboardItem::createFromDictionary( + ghoul::Dictionary dictionary) +{ + auto factory = FactoryManager::ref().factory(); + ghoul_assert(factory, "DashboardItem factory did not exist"); + + std::string dashboardType = dictionary.value(KeyType); + + return factory->create(dashboardType, dictionary); +} + +DashboardItem::DashboardItem(std::string name) + : properties::PropertyOwner({ std::move(name) }) + , _isEnabled(EnabledInfo, true) +{ + addProperty(_isEnabled); +} + +bool DashboardItem::isEnabled() const { + return _isEnabled; +} + +} // namespace openspace diff --git a/src/rendering/framebufferrenderer.cpp b/src/rendering/framebufferrenderer.cpp index b74ef29d6f..a6e2a1735c 100644 --- a/src/rendering/framebufferrenderer.cpp +++ b/src/rendering/framebufferrenderer.cpp @@ -43,6 +43,7 @@ #include +#include #include #include #include @@ -190,8 +191,8 @@ void FramebufferRenderer::initialize() { try { _resolveProgram = ghoul::opengl::ProgramObject::Build( "Framebuffer Resolve", - "${SHADERS}/framebuffer/resolveframebuffer.vert", - "${SHADERS}/framebuffer/resolveframebuffer.frag" + absPath("${SHADERS}/framebuffer/resolveframebuffer.vert"), + absPath("${SHADERS}/framebuffer/resolveframebuffer.frag") ); } catch (const ghoul::RuntimeError& e) { LERRORC(e.component, e.message); diff --git a/src/rendering/loadingscreen.cpp b/src/rendering/loadingscreen.cpp index 9a34ec9cd0..cb32bdb457 100644 --- a/src/rendering/loadingscreen.cpp +++ b/src/rendering/loadingscreen.cpp @@ -115,8 +115,8 @@ LoadingScreen::LoadingScreen(ShowMessage showMessage, ShowNodeNames showNodeName { _program = ghoul::opengl::ProgramObject::Build( "Loading Screen", - "${SHADERS}/loadingscreen.vert", - "${SHADERS}/loadingscreen.frag" + absPath("${SHADERS}/loadingscreen.vert"), + absPath("${SHADERS}/loadingscreen.frag") ); _loadingFont = OsEng.fontManager().font( @@ -268,7 +268,7 @@ void LoadingScreen::render() { // // Clear background - // + // glClearColor(0.f, 0.f, 0.f, 1.f); glClear(ClearBufferMask::GL_COLOR_BUFFER_BIT); @@ -279,7 +279,7 @@ void LoadingScreen::render() { // // Render logo - // + // _program->activate(); ghoul::opengl::TextureUnit unit; @@ -321,7 +321,7 @@ void LoadingScreen::render() { // Depending on the progress, we only want to draw the progress bar to a mixture // of the lowerleft and upper right extent - float progress = _nItems != 0 ? + float progress = _nItems != 0 ? static_cast(_iProgress) / static_cast(_nItems) : 0.f; @@ -409,7 +409,7 @@ void LoadingScreen::render() { // // "Loading" text - // + // using FR = ghoul::fontrendering::FontRenderer; FR& renderer = FR::defaultRenderer(); @@ -520,12 +520,12 @@ void LoadingScreen::render() { bool barOverlap = _showProgressbar ? rectOverlaps( - ndcToScreen(progressbarLl, res), + ndcToScreen(progressbarLl, res), ndcToScreen(progressbarUr, res), ll, ur - ) : - false; + ) : + false; if (logoOverlap || loadingOverlap || messageOverlap || barOverlap) { continue; diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index 7b94b71e29..6f59840598 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -24,9 +24,6 @@ #include -#ifdef OPENSPACE_MODULE_SPACECRAFTINSTRUMENTS_ENABLED -#include -#endif #include #include @@ -37,7 +34,10 @@ #include #include #include +#include #include +#include +#include #include #include #include @@ -47,14 +47,12 @@ #include #include #include -#include #include -#include #include #include -#include #include +#include #include #include #include @@ -101,12 +99,6 @@ namespace { "performance." }; - static const openspace::properties::Property::PropertyInfo FrametimeInfo = { - "FrametimeType", - "Type of the frame time display", - "This value determines the units in which the frame time is displayed." - }; - static const openspace::properties::Property::PropertyInfo ShowDateInfo = { "ShowDate", "Show Date Information", @@ -233,9 +225,6 @@ RenderEngine::RenderEngine() , _renderer(nullptr) , _rendererImplementation(RendererImplementation::Invalid) , _log(nullptr) - , _frametimeType(FrametimeInfo, properties::OptionProperty::DisplayType::Dropdown) - , _showDate(ShowDateInfo, true) - , _showInfo(ShowInfoInfo, true) , _showLog(ShowLogInfo, true) , _showVersionInfo(ShowVersionInfo, true) , _showCameraInfo(ShowCameraInfo, true) @@ -286,16 +275,6 @@ RenderEngine::RenderEngine() }); addProperty(_doPerformanceMeasurements); - _frametimeType.addOptions({ - { static_cast(FrametimeType::DtTimeAvg), "Average Deltatime" }, - { static_cast(FrametimeType::FPS), "Frames per second" }, - { static_cast(FrametimeType::FPSAvg), "Average frames per second" }, - { static_cast(FrametimeType::None), "None" } - }); - addProperty(_frametimeType); - - addProperty(_showDate); - addProperty(_showInfo); addProperty(_showLog); addProperty(_showVersionInfo); addProperty(_showCameraInfo); @@ -602,7 +581,21 @@ void RenderEngine::render(const glm::mat4& sceneMatrix, const glm::mat4& viewMat // Print some useful information on the master viewport if (wrapper.isMaster() && wrapper.isSimpleRendering()) { - renderInformation(); + std::unique_ptr perf; + if (_performanceManager) { + perf = std::make_unique( + "Main Dashboard::render", + OsEng.renderEngine().performanceManager() + ); + } + glm::vec2 penPosition = glm::vec2( + 10.f, + fontResolution().y + ); + + penPosition.y -= OsEng.console().currentHeight(); + + OsEng.dashboard().render(penPosition); } if (_showFrameNumber) { @@ -748,7 +741,7 @@ std::unique_ptr RenderEngine::buildRenderProgram( std::unique_ptr program = ProgramObject::Build( name, vsPath, - RenderFsPath, + absPath(RenderFsPath), dict ); @@ -778,7 +771,7 @@ std::unique_ptr RenderEngine::buildRenderProgram( std::unique_ptr program = ProgramObject::Build( name, vsPath, - RenderFsPath, + absPath(RenderFsPath), csPath, dict ); @@ -991,7 +984,8 @@ RenderEngine::RendererImplementation RenderEngine::rendererFromString( return RendererImplementation::Invalid; } } - +/* +<<<<<<< HEAD std::string RenderEngine::progressToStr(int size, double t) { std::string progress = "|"; int g = static_cast((t * (size - 1)) + 1); @@ -1413,6 +1407,9 @@ void RenderEngine::renderInformation() { } } +======= +>>>>>>> master +*/ void RenderEngine::renderCameraInformation() { if (!_showCameraInfo) { return; diff --git a/src/rendering/renderengine_lua.inl b/src/rendering/renderengine_lua.inl index cdd14c5247..54b090e354 100644 --- a/src/rendering/renderengine_lua.inl +++ b/src/rendering/renderengine_lua.inl @@ -119,7 +119,7 @@ int addScreenSpaceRenderable(lua_State* L) { ); OsEng.renderEngine().addScreenSpaceRenderable(s); - return 1; + return 0; } int removeScreenSpaceRenderable(lua_State* L) { @@ -145,7 +145,7 @@ int removeScreenSpaceRenderable(lua_State* L) { OsEng.renderEngine().removeScreenSpaceRenderable(s); - return 1; + return 0; } }// namespace openspace::luascriptfunctions diff --git a/src/rendering/screenspacerenderable.cpp b/src/rendering/screenspacerenderable.cpp index ec240858d5..47abbf74ac 100644 --- a/src/rendering/screenspacerenderable.cpp +++ b/src/rendering/screenspacerenderable.cpp @@ -238,7 +238,6 @@ ScreenSpaceRenderable::ScreenSpaceRenderable(const ghoul::Dictionary& dictionary addProperty(_depth); addProperty(_scale); addProperty(_alpha); - addProperty(_delete); if (dictionary.hasKey(EnabledInfo.identifier)) { _enabled = dictionary.value(EnabledInfo.identifier); @@ -298,9 +297,10 @@ ScreenSpaceRenderable::ScreenSpaceRenderable(const ghoul::Dictionary& dictionary "openspace.removeScreenSpaceRenderable('" + name() + "');"; OsEng.scriptEngine().queueScript( script, - scripting::ScriptEngine::RemoteScripting::Yes + scripting::ScriptEngine::RemoteScripting::No ); }); + addProperty(_delete); } bool ScreenSpaceRenderable::initialize() { @@ -506,6 +506,7 @@ void ScreenSpaceRenderable::draw(glm::mat4 modelTransform) { _shader->setUniform("OcclusionDepth", 1.f - _depth); _shader->setUniform("Alpha", _alpha); _shader->setUniform("ModelTransform", modelTransform); + _shader->setUniform( "ViewProjectionMatrix", OsEng.renderEngine().camera()->viewProjectionMatrix() diff --git a/src/scene/scenegraphnode.cpp b/src/scene/scenegraphnode.cpp index 8aa1540fc9..01cf9357ec 100644 --- a/src/scene/scenegraphnode.cpp +++ b/src/scene/scenegraphnode.cpp @@ -86,22 +86,6 @@ std::unique_ptr SceneGraphNode::createFromDictionary( std::string name = dictionary.value(KeyName); result->setName(name); - if (dictionary.hasValue(KeyRenderable)) { - ghoul::Dictionary renderableDictionary; - dictionary.getValue(KeyRenderable, renderableDictionary); - - renderableDictionary.setValue(KeyName, name); - - result->_renderable = Renderable::createFromDictionary(renderableDictionary); - if (result->_renderable == nullptr) { - LERROR("Failed to create renderable for SceneGraphNode '" - << result->name() << "'"); - return nullptr; - } - result->addPropertySubOwner(result->_renderable.get()); - LDEBUG("Successfully created renderable for '" << result->name() << "'"); - } - if (dictionary.hasKey(keyTransformTranslation)) { ghoul::Dictionary translationDictionary; dictionary.getValue(keyTransformTranslation, translationDictionary); @@ -143,6 +127,23 @@ std::unique_ptr SceneGraphNode::createFromDictionary( LDEBUG("Successfully created scale for '" << result->name() << "'"); } + // We initialize the renderable last as it probably has the most dependencies + if (dictionary.hasValue(KeyRenderable)) { + ghoul::Dictionary renderableDictionary; + dictionary.getValue(KeyRenderable, renderableDictionary); + + renderableDictionary.setValue(KeyName, name); + + result->_renderable = Renderable::createFromDictionary(renderableDictionary); + if (result->_renderable == nullptr) { + LERROR("Failed to create renderable for SceneGraphNode '" + << result->name() << "'"); + return nullptr; + } + result->addPropertySubOwner(result->_renderable.get()); + LDEBUG("Successfully created renderable for '" << result->name() << "'"); + } + if (dictionary.hasKey(KeyTag)) { if (dictionary.hasKeyAndValue(KeyTag)) { std::string tagName = dictionary.value(KeyTag); diff --git a/src/scripting/scriptengine_lua.inl b/src/scripting/scriptengine_lua.inl index 883f6774a2..b613ed0f71 100644 --- a/src/scripting/scriptengine_lua.inl +++ b/src/scripting/scriptengine_lua.inl @@ -198,7 +198,7 @@ int absolutePath(lua_State* L) { std::string path = luaL_checkstring(L, -1); path = absPath(path); - path = FileSys.convertPathSeparator(path, '/'); + //path = FileSys.convertPathSeparator(path, '/'); lua_pushstring(L, path.c_str()); return 1; } diff --git a/src/util/distanceconversion.cpp b/src/util/distanceconversion.cpp index 2484517e7f..d73fbdfad8 100644 --- a/src/util/distanceconversion.cpp +++ b/src/util/distanceconversion.cpp @@ -26,48 +26,63 @@ #include +#include + namespace openspace { std::pair simplifyDistance(double meters) { - if (meters > 1e-3 && meters < 1e3) { - return { meters, "meter" }; + double metersVal = glm::abs(meters); + + if (metersVal == 0.0) { + return { 0.0, "meters"}; + } + else if (metersVal > 1e-3 && metersVal < 1e3) { + return { meters, meters == 1.0 ? "meter" : "meters" }; } - if (meters < 1e-9) { - return { meters / 1e-9, "nanometer" }; + if (metersVal < 1e-9) { + return { meters / 1e-9, (meters / 1e-9) == 1.0 ? "nanometer" : "nanometers" }; } - else if (meters < 1e-6) { - return { meters / 1e-6, "micrometer" }; + else if (metersVal < 1e-6) { + return { meters / 1e-6, (meters / 1e-6) == 1.0 ? "micrometer" : "micrometers" }; } - else if (meters < 1e-3) { - return { meters / 1e-3, "millimeter" }; + else if (metersVal < 1e-3) { + return { meters / 1e-3, (meters / 1e-3) == 1.0 ? "millimeter" : "millimeters" }; } - if (meters > (1e9 * distanceconstants::Parsec)) { - return { meters / (1e9 * distanceconstants::Parsec) , "Gigaparsec" }; + if (metersVal > (1e9 * distanceconstants::Parsec)) { + double val = meters / (1e9 * distanceconstants::Parsec); + return { val, val == 1.0 ? "Gigaparsec" : "Gigaparsecs" }; } - else if (meters > (1e6 * distanceconstants::Parsec)) { - return { meters / (1e6 * distanceconstants::Parsec), "Megaparsec" }; + else if (metersVal > (1e6 * distanceconstants::Parsec)) { + double val = meters / (1e6 * distanceconstants::Parsec); + return { val, val == 1.0 ? "Megaparsec" : "Megaparsecs" }; } - else if (meters > (1e3 * distanceconstants::Parsec)) { - return { meters / (1e3 * distanceconstants::Parsec), "Kiloparsec" }; + else if (metersVal > (1e3 * distanceconstants::Parsec)) { + double val = meters / (1e3 * distanceconstants::Parsec); + return { val, val == 1.0 ? "Kiloparsec" : "Kiloparsecs" }; } - else if (meters > distanceconstants::Parsec) { - return { meters / distanceconstants::Parsec, "Parsec" }; + else if (metersVal > distanceconstants::Parsec) { + double val = meters / distanceconstants::Parsec; + return { val, val == 1.0 ? "Parsec" : "Parsecs" }; } - else if (meters > distanceconstants::LightYear) { - return { meters / distanceconstants::LightYear, "Lightyears" }; + else if (metersVal > distanceconstants::LightYear) { + double val = meters / distanceconstants::LightYear; + return { val, val == 1.0 ? "Lightyear" : "Lightyears" }; } - else if (meters > distanceconstants::LightMonth) { - return { meters / distanceconstants::LightMonth, "Lightmonth" }; + else if (metersVal > distanceconstants::LightMonth) { + double val = meters / distanceconstants::LightMonth; + return { val, val == 1.0 ? "Lightmonth" : "Lightmonths" }; } - else if (meters > distanceconstants::LightDay) { - return { meters / distanceconstants::LightDay, "Lightday" }; + else if (metersVal > distanceconstants::LightDay) { + double val = meters / distanceconstants::LightDay; + return { val, val == 1.0 ? "Lightday" : "Lightdays" }; } - else if (meters > distanceconstants::LightHour) { - return { meters / distanceconstants::LightDay, "Lighthour" }; + else if (metersVal > distanceconstants::LightHour) { + double val = meters / distanceconstants::LightDay; + return { val, val == 1.0 ? "Lighthour" : "Lighthours" }; } - else if (meters > distanceconstants::AstronomicalUnit) { + else if (metersVal > distanceconstants::AstronomicalUnit) { return { meters / distanceconstants::AstronomicalUnit, "AU" }; } else { diff --git a/src/util/openspacemodule.cpp b/src/util/openspacemodule.cpp index 3a0694d68f..4e8c47b2ed 100644 --- a/src/util/openspacemodule.cpp +++ b/src/util/openspacemodule.cpp @@ -78,6 +78,10 @@ scripting::LuaLibrary OpenSpaceModule::luaLibrary() const { return {}; } +std::vector OpenSpaceModule::luaLibraries() const { + return {}; +} + ghoul::systemcapabilities::Version OpenSpaceModule::requiredOpenGLVersion() const { return { 3, 3, 0 }; } @@ -92,7 +96,7 @@ std::string OpenSpaceModule::modulePath() const { ); // First try the internal module directory - if (FileSys.directoryExists("${MODULES}/" + moduleName)) { + if (FileSys.directoryExists(absPath("${MODULES}/" + moduleName))) { return absPath("${MODULES}/" + moduleName); } else { // Otherwise, it might be one of the external directories diff --git a/src/util/taskloader.cpp b/src/util/taskloader.cpp index c8365b1fa7..bfc4b2bddd 100644 --- a/src/util/taskloader.cpp +++ b/src/util/taskloader.cpp @@ -65,8 +65,7 @@ std::vector> TaskLoader::tasksFromDictionary( std::vector> TaskLoader::tasksFromFile(const std::string& path) { std::string absTasksFile = absPath(path); - using RawPath = ghoul::filesystem::FileSystem::RawPath; - if (!FileSys.fileExists(absTasksFile, RawPath::Yes)) { + if (!FileSys.fileExists(ghoul::filesystem::File(absTasksFile))) { LERROR("Could not load tasks file '" << absTasksFile << "'. " << "File not found"); return std::vector>(); diff --git a/support/cmake/set_openspace_compile_settings.cmake b/support/cmake/set_openspace_compile_settings.cmake index 36118936b7..1e94d55467 100644 --- a/support/cmake/set_openspace_compile_settings.cmake +++ b/support/cmake/set_openspace_compile_settings.cmake @@ -56,7 +56,8 @@ function (set_openspace_compile_settings project) "/w44548" # expression before comma has no effect; expected expression with side-effect "/w44549" # 'operator': operator before comma has no effect; did you intend 'operator'? "/w44555" # expression has no effect; expected expression with side-effect - "/w44574" # 'identifier' is defined to be '0': did you mean to use '#if identifier'? + # This is disabled until GLM is updated to version 0.9.9 that removes occurrance of this warning + # "/w44574" # 'identifier' is defined to be '0': did you mean to use '#if identifier'? "/w44608" # 'symbol1' has already been initialized by another union member in the initializer list, 'symbol2' "/w44619" # #pragma warning: there is no warning number 'number' "/w44628" # digraphs not supported with -Ze. Character sequence 'digraph' not interpreted as alternate token for 'char'