From 0547c14389d16853653f377b559455962c50da51 Mon Sep 17 00:00:00 2001 From: Emil Axelsson Date: Thu, 29 Mar 2018 18:00:47 +0200 Subject: [PATCH 01/17] Fix dashboard item bugs related to unloading and loading assets at runtime (#572) --- data/assets/dawn.scene | 3 +- data/assets/default.scene | 2 +- data/assets/juno.scene | 2 +- data/assets/newhorizons.scene | 32 +++++---- data/assets/osirisrex.scene | 34 ++++++---- data/assets/rosetta.scene | 32 +++++---- data/assets/util/asset_helper.asset | 15 +++++ data/assets/util/default_dashboard.asset | 29 ++++++++ data/assets/voyager.scene | 2 +- include/openspace/rendering/dashboard.h | 3 +- include/openspace/rendering/dashboarditem.h | 6 +- modules/base/dashboard/dashboarditemangle.cpp | 2 +- modules/base/dashboard/dashboarditemdate.cpp | 2 +- .../base/dashboard/dashboarditemdistance.cpp | 2 +- .../base/dashboard/dashboarditemframerate.cpp | 2 +- .../base/dashboard/dashboarditemmission.cpp | 2 +- .../dashboarditemparallelconnection.cpp | 2 +- .../dashboarditemsimulationincrement.cpp | 2 +- .../base/dashboard/dashboarditemspacing.cpp | 2 +- .../base/rendering/screenspacedashboard.cpp | 2 +- .../dashboard/dashboarditeminstruments.cpp | 2 +- scripts/core_scripts.lua | 22 ------- src/mission/missionmanager.cpp | 4 ++ src/rendering/dashboard.cpp | 30 ++++++++- src/rendering/dashboard_lua.inl | 25 ++++++- src/rendering/dashboarditem.cpp | 66 ++++++++++++++++++- 26 files changed, 241 insertions(+), 86 deletions(-) create mode 100644 data/assets/util/default_dashboard.asset diff --git a/data/assets/dawn.scene b/data/assets/dawn.scene index 7af21ba55f..ffd93aa271 100644 --- a/data/assets/dawn.scene +++ b/data/assets/dawn.scene @@ -13,13 +13,14 @@ asset.require('scene/solarsystem/missions/dawn/vesta') -- Load default key bindings applicable to most scenes asset.require('util/default_keybindings') +asset.require('util/default_dashboard') + local DawnAsset = asset.require('scene/solarsystem/missions/dawn/dawn') asset.onInitialize(function () openspace.time.setTime("2011 AUG 06 00:00:00") - openspace.setDefaultDashboard() openspace.setDefaultGuiSorting() openspace.markInterestingNodes({ diff --git a/data/assets/default.scene b/data/assets/default.scene index 4d43bd51f7..aa54ad4635 100644 --- a/data/assets/default.scene +++ b/data/assets/default.scene @@ -11,6 +11,7 @@ asset.require('scene/solarsystem/planets/mars/moons/deimos') assetHelper.requestAll(asset, 'scene/digitaluniverse') -- Load default key bindings applicable to most scenes asset.require('util/default_keybindings') +asset.require('util/default_dashboard') asset.request('customization/globebrowsing') @@ -59,7 +60,6 @@ asset.onInitialize(function () openspace.time.setTime(openspace.time.currentWallTime()) sceneHelper.bindKeys(Keybindings) - openspace.setDefaultDashboard() openspace.setDefaultGuiSorting() openspace.globebrowsing.loadWMSServersFromFile( diff --git a/data/assets/juno.scene b/data/assets/juno.scene index 353af80afd..c73a8fd830 100644 --- a/data/assets/juno.scene +++ b/data/assets/juno.scene @@ -11,13 +11,13 @@ assetHelper.requireAll(asset, 'scene/solarsystem/missions/juno') -- Load default key bindings applicable to most scenes asset.require('util/default_keybindings') +asset.require('util/default_dashboard') local junoAsset = asset.require('scene/solarsystem/missions/juno/juno') asset.onInitialize(function () openspace.time.setTime("2016-07-01T10:05:00.00") - openspace.setDefaultDashboard() openspace.setDefaultGuiSorting() sceneHelper.setDeltaTimeKeys({ diff --git a/data/assets/newhorizons.scene b/data/assets/newhorizons.scene index af40f70ee0..822f41a1b3 100644 --- a/data/assets/newhorizons.scene +++ b/data/assets/newhorizons.scene @@ -13,6 +13,7 @@ asset.require('scene/solarsystem/missions/newhorizons/newhorizons') -- Load default key bindings applicable to most scenes asset.require('util/default_keybindings') +asset.require('util/default_dashboard') -- Custom Keybindings local Keybindings = { @@ -131,27 +132,32 @@ local Keybindings = { local NewHorizonsAsset = asset.require('scene/solarsystem/missions/newhorizons/model') -asset.onInitialize(function () - openspace.time.setTime("2015-07-14T08:00:00.00") - sceneHelper.bindKeys(Keybindings) - - openspace.setDefaultDashboard() - openspace.dashboard.addDashboardItem({ +assetHelper.registerDashboardItems(asset, { + { Type = "DashboardItemSpacing", + Identifier = "NewHorizonsSpacing", + GuiName = "New Horizons Spacing", Spacing = 25 - }) - - openspace.dashboard.addDashboardItem({ + }, + { Type = "DashboardItemDistance", + Identifier = "NewHorizonsPlutoDistance", + GuiName = "New Horizons Pluto Distance", SourceType = "Node", SourceNodeName = "NewHorizons", DestinationType = "Node Surface", DestinationNodeName = "Pluto" - }) + }, + { + Type = "DashboardItemInstruments", + Identifier = "NewHorizonsInstruments", + GuiName = "NewHorizons Instruments", + } +}) - openspace.dashboard.addDashboardItem({ - Type = "DashboardItemInstruments" - }) +asset.onInitialize(function () + openspace.time.setTime("2015-07-14T08:00:00.00") + sceneHelper.bindKeys(Keybindings) openspace.setDefaultGuiSorting() diff --git a/data/assets/osirisrex.scene b/data/assets/osirisrex.scene index 2a41142844..dcdb949548 100644 --- a/data/assets/osirisrex.scene +++ b/data/assets/osirisrex.scene @@ -12,6 +12,7 @@ asset.require('scene/solarsystem/missions/osirisrex/osirisrex') -- Load default key bindings applicable to most scenes asset.require('util/default_keybindings') +asset.require('util/default_dashboard') -- Custom Keybindings local Keybindings = { @@ -79,28 +80,33 @@ local Keybindings = { local OsirisRexAsset = asset.require('scene/solarsystem/missions/osirisrex/model') -asset.onInitialize(function () - -- openspace.time.setTime("2019 APR 16 12:03:00.00") - openspace.time.setTime("2016 SEP 8 23:00:00.500") - sceneHelper.bindKeys(Keybindings) - - openspace.setDefaultDashboard() - openspace.dashboard.addDashboardItem({ +assetHelper.registerDashboardItems(asset, { + { Type = "DashboardItemSpacing", + Identifier = "OsirisRexSpacing", + GuiName = "OSIRIS-REx Spacing", Spacing = 25 - }) - - openspace.dashboard.addDashboardItem({ + }, + { Type = "DashboardItemDistance", + Identifier = "OsirisRexBennuDistance", + GuiName = "OSIRIS-REx Bennu Distance", SourceType = "Node", SourceNodeName = "OsirisRex", DestinationType = "Node", DestinationNodeName = "BennuBarycenter" - }) + }, + { + Type = "DashboardItemInstruments", + Identifier = "OsirisRexInstruments", + GuiName = "OSIRIS-REx Instruments", + } +}) - openspace.dashboard.addDashboardItem({ - Type = "DashboardItemInstruments" - }) +asset.onInitialize(function () + -- openspace.time.setTime("2019 APR 16 12:03:00.00") + openspace.time.setTime("2016 SEP 8 23:00:00.500") + sceneHelper.bindKeys(Keybindings) openspace.setDefaultGuiSorting() diff --git a/data/assets/rosetta.scene b/data/assets/rosetta.scene index 612ad671ef..7a068c01cc 100644 --- a/data/assets/rosetta.scene +++ b/data/assets/rosetta.scene @@ -14,6 +14,7 @@ asset.require('scene/solarsystem/missions/rosetta/rosetta') -- Load default key bindings applicable to most scenes asset.require('util/default_keybindings') +asset.require('util/default_dashboard') -- Custom Keybindings local Keybindings = { @@ -82,27 +83,32 @@ local Keybindings = { local Comet67PAsset = asset.require('scene/solarsystem/missions/rosetta/67p') -asset.onInitialize(function () - openspace.time.setTime("2014-08-01T03:05:00.000") - sceneHelper.bindKeys(Keybindings) - - openspace.setDefaultDashboard() - openspace.dashboard.addDashboardItem({ +assetHelper.registerDashboardItems(asset, { + { Type = "DashboardItemSpacing", + Identifier = "RosettaSpacing", + GuiName = "Rosetta Spacing", Spacing = 25 - }) - - openspace.dashboard.addDashboardItem({ + }, + { Type = "DashboardItemDistance", + Identifier = "Rosetta67PDistance", + GuiName = "Rosetta 67P Distance", SourceType = "Node", SourceNodeName = "Rosetta", DestinationType = "Node", DestinationNodeName = "67P" - }) + }, + { + Type = "DashboardItemInstruments", + Identifier = "RosettaInstruments", + GuiName = "Rosetta Instruments", + } +}) - openspace.dashboard.addDashboardItem({ - Type = "DashboardItemInstruments" - }) +asset.onInitialize(function () + openspace.time.setTime("2014-08-01T03:05:00.000") + sceneHelper.bindKeys(Keybindings) openspace.setDefaultGuiSorting() diff --git a/data/assets/util/asset_helper.asset b/data/assets/util/asset_helper.asset index 956b3a5758..9408794485 100644 --- a/data/assets/util/asset_helper.asset +++ b/data/assets/util/asset_helper.asset @@ -42,6 +42,20 @@ local registerSceneGraphNodes = function (sceneAsset, nodes, override) end) end +local registerDashboardItems = function (dashboardAsset, items) + dashboardAsset.onInitialize(function () + for i, item in ipairs(items) do + openspace.dashboard.addDashboardItem(item) + end + end) + dashboardAsset.onDeinitialize(function () + for i = #items, 1, -1 do + item = items[i] + openspace.dashboard.removeDashboardItem(item.Identifier) + end + end) +end + local registerSceneGraphNodesAndExport = function (sceneAsset, nodes, override) override = override or false if not override then @@ -110,5 +124,6 @@ end asset.export("registerSceneGraphNodes", registerSceneGraphNodes) asset.export("registerSceneGraphNodesAndExport", registerSceneGraphNodesAndExport) asset.export("registerSpiceKernels", registerSpiceKernels) +asset.export("registerDashboardItems", registerDashboardItems) asset.export("requireAll", requireAll) asset.export("requestAll", requestAll) diff --git a/data/assets/util/default_dashboard.asset b/data/assets/util/default_dashboard.asset new file mode 100644 index 0000000000..f4e01457f8 --- /dev/null +++ b/data/assets/util/default_dashboard.asset @@ -0,0 +1,29 @@ +local assetHelper = asset.require('util/asset_helper') + +assetHelper.registerDashboardItems(asset, { + { + Identifier = "Date", + GuiName = "Date", + Type = "DashboardItemDate" + }, + { + Identifier = "SimulationIncrement", + GuiName = "Simulation Increment", + Type = "DashboardItemSimulationIncrement" + }, + { + Identifier = "Distance", + GuiName = "Distance", + Type = "DashboardItemDistance" + }, + { + Identifier = "Framerate", + GuiName = "Framerate", + Type = "DashboardItemFramerate" + }, + { + Identifier = "ParallelConnection", + GuiName = "Parallel Connection", + Type = "DashboardItemParallelConnection" + } +}) diff --git a/data/assets/voyager.scene b/data/assets/voyager.scene index a5d24cd235..2de0961651 100644 --- a/data/assets/voyager.scene +++ b/data/assets/voyager.scene @@ -18,13 +18,13 @@ asset.require('scene/solarsystem/missions/voyager/voyager2') -- Load default key bindings applicable to most scenes asset.require('util/default_keybindings') +asset.require('util/default_dashboard') local VoyagerAsset = asset.require('scene/solarsystem/missions/voyager/voyager1') asset.onInitialize(function () openspace.time.setTime("1977 SEP 10 12:00:00") - openspace.setDefaultDashboard() openspace.setDefaultGuiSorting() sceneHelper.setDeltaTimeKeys({ diff --git a/include/openspace/rendering/dashboard.h b/include/openspace/rendering/dashboard.h index 848f12513d..f317615a6c 100644 --- a/include/openspace/rendering/dashboard.h +++ b/include/openspace/rendering/dashboard.h @@ -48,8 +48,9 @@ public: void addDashboardItem(std::unique_ptr item); bool hasItem(int index) const; const DashboardItem& item(int index) const; + void removeDashboardItem(const std::string& identifier); void removeDashboardItem(int index); - void removeDashboardItems(); + void clearDashboardItems(); /** * Returns the Lua library that contains all Lua functions available to affect the diff --git a/include/openspace/rendering/dashboarditem.h b/include/openspace/rendering/dashboarditem.h index a76d7d9485..7d239dae82 100644 --- a/include/openspace/rendering/dashboarditem.h +++ b/include/openspace/rendering/dashboarditem.h @@ -36,13 +36,17 @@ namespace openspace { +namespace documentation { struct Documentation; } + class DashboardItem : public properties::PropertyOwner { public: + static documentation::Documentation Documentation(); + static std::unique_ptr createFromDictionary( ghoul::Dictionary dictionary ); - DashboardItem(std::string identifier, std::string guiName = ""); + DashboardItem(ghoul::Dictionary dictionary); bool isEnabled() const; virtual void render(glm::vec2& penPosition) = 0; diff --git a/modules/base/dashboard/dashboarditemangle.cpp b/modules/base/dashboard/dashboarditemangle.cpp index 8c1e953120..181956704a 100644 --- a/modules/base/dashboard/dashboarditemangle.cpp +++ b/modules/base/dashboard/dashboarditemangle.cpp @@ -174,7 +174,7 @@ documentation::Documentation DashboardItemAngle::Documentation() { } DashboardItemAngle::DashboardItemAngle(ghoul::Dictionary dictionary) - : DashboardItem("Angle") + : DashboardItem(dictionary) , _fontName(FontNameInfo, KeyFontMono) , _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f) , _source{ diff --git a/modules/base/dashboard/dashboarditemdate.cpp b/modules/base/dashboard/dashboarditemdate.cpp index 16401ec100..42337c4b80 100644 --- a/modules/base/dashboard/dashboarditemdate.cpp +++ b/modules/base/dashboard/dashboarditemdate.cpp @@ -81,7 +81,7 @@ documentation::Documentation DashboardItemDate::Documentation() { } DashboardItemDate::DashboardItemDate(ghoul::Dictionary dictionary) - : DashboardItem("Date") + : DashboardItem(dictionary) , _fontName(FontNameInfo, KeyFontMono) , _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f) { diff --git a/modules/base/dashboard/dashboarditemdistance.cpp b/modules/base/dashboard/dashboarditemdistance.cpp index ac001d2cde..30e4e8766f 100644 --- a/modules/base/dashboard/dashboarditemdistance.cpp +++ b/modules/base/dashboard/dashboarditemdistance.cpp @@ -183,7 +183,7 @@ documentation::Documentation DashboardItemDistance::Documentation() { } DashboardItemDistance::DashboardItemDistance(ghoul::Dictionary dictionary) - : DashboardItem("Distance") + : DashboardItem(dictionary) , _fontName(FontNameInfo, KeyFontMono) , _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f) , _doSimplification(SimplificationInfo, true) diff --git a/modules/base/dashboard/dashboarditemframerate.cpp b/modules/base/dashboard/dashboarditemframerate.cpp index 0bf6238a6b..7a0915cb4f 100644 --- a/modules/base/dashboard/dashboarditemframerate.cpp +++ b/modules/base/dashboard/dashboarditemframerate.cpp @@ -96,7 +96,7 @@ documentation::Documentation DashboardItemFramerate::Documentation() { } DashboardItemFramerate::DashboardItemFramerate(ghoul::Dictionary dictionary) - : DashboardItem("Framerate") + : DashboardItem(dictionary) , _fontName(FontNameInfo, KeyFontMono) , _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f) , _frametimeType(FrametimeInfo, properties::OptionProperty::DisplayType::Dropdown) diff --git a/modules/base/dashboard/dashboarditemmission.cpp b/modules/base/dashboard/dashboarditemmission.cpp index 331e3c92d9..af767f2f22 100644 --- a/modules/base/dashboard/dashboarditemmission.cpp +++ b/modules/base/dashboard/dashboarditemmission.cpp @@ -101,7 +101,7 @@ documentation::Documentation DashboardItemMission::Documentation() { } DashboardItemMission::DashboardItemMission(ghoul::Dictionary dictionary) - : DashboardItem("Mission") + : DashboardItem(dictionary) , _fontName(FontNameInfo, KeyFontMono) , _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f) { diff --git a/modules/base/dashboard/dashboarditemparallelconnection.cpp b/modules/base/dashboard/dashboarditemparallelconnection.cpp index 60cad0df7d..b75fccb6f3 100644 --- a/modules/base/dashboard/dashboarditemparallelconnection.cpp +++ b/modules/base/dashboard/dashboarditemparallelconnection.cpp @@ -86,7 +86,7 @@ documentation::Documentation DashboardItemParallelConnection::Documentation() { DashboardItemParallelConnection::DashboardItemParallelConnection( ghoul::Dictionary dictionary) - : DashboardItem("ParallelConnection", "Parallel Connection") + : DashboardItem(dictionary) , _fontName(FontNameInfo, KeyFontMono) , _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f) { diff --git a/modules/base/dashboard/dashboarditemsimulationincrement.cpp b/modules/base/dashboard/dashboarditemsimulationincrement.cpp index 55e18ef1c0..61a206eaab 100644 --- a/modules/base/dashboard/dashboarditemsimulationincrement.cpp +++ b/modules/base/dashboard/dashboarditemsimulationincrement.cpp @@ -123,7 +123,7 @@ documentation::Documentation DashboardItemSimulationIncrement::Documentation() { DashboardItemSimulationIncrement::DashboardItemSimulationIncrement( ghoul::Dictionary dictionary) - : DashboardItem("SimulationIncrement", "Simulation Increment") + : DashboardItem(dictionary) , _fontName(FontNameInfo, KeyFontMono) , _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f) , _doSimplification(SimplificationInfo, true) diff --git a/modules/base/dashboard/dashboarditemspacing.cpp b/modules/base/dashboard/dashboarditemspacing.cpp index 45355e7e60..c2345b9f7f 100644 --- a/modules/base/dashboard/dashboarditemspacing.cpp +++ b/modules/base/dashboard/dashboarditemspacing.cpp @@ -60,7 +60,7 @@ documentation::Documentation DashboardItemSpacing::Documentation() { } DashboardItemSpacing::DashboardItemSpacing(ghoul::Dictionary dictionary) - : DashboardItem("Spacing") + : DashboardItem(dictionary) , _spacing(SpacingInfo, 15.f, 0.f, 2048.f) { documentation::testSpecificationAndThrow( diff --git a/modules/base/rendering/screenspacedashboard.cpp b/modules/base/rendering/screenspacedashboard.cpp index 2956b57807..5f9ea9e638 100644 --- a/modules/base/rendering/screenspacedashboard.cpp +++ b/modules/base/rendering/screenspacedashboard.cpp @@ -120,7 +120,7 @@ int removeDashboardItemsFromScreenSpace(lua_State* L) { return luaL_error(L, "Provided name is a ScreenSpace item but not a dashboard"); } - dash->dashboard().removeDashboardItems(); + dash->dashboard().clearDashboardItems(); return 0; } diff --git a/modules/spacecraftinstruments/dashboard/dashboarditeminstruments.cpp b/modules/spacecraftinstruments/dashboard/dashboarditeminstruments.cpp index ea96ec80f0..aa9678fa6b 100644 --- a/modules/spacecraftinstruments/dashboard/dashboarditeminstruments.cpp +++ b/modules/spacecraftinstruments/dashboard/dashboarditeminstruments.cpp @@ -138,7 +138,7 @@ documentation::Documentation DashboardItemInstruments::Documentation() { } DashboardItemInstruments::DashboardItemInstruments(ghoul::Dictionary dictionary) - : DashboardItem("Instruments") + : DashboardItem(dictionary) , _fontName(FontNameInfo, KeyFontMono) , _fontSize(FontSizeInfo, DefaultFontSize, 6.f, 144.f, 1.f) , _activeColor( diff --git a/scripts/core_scripts.lua b/scripts/core_scripts.lua index 8016df5cd6..e07db48ad0 100644 --- a/scripts/core_scripts.lua +++ b/scripts/core_scripts.lua @@ -52,28 +52,6 @@ openspace.removeInterestingNodes = function(nodes) end end -openspace.setDefaultDashboard = 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.setDefaultGuiSorting = function() openspace.setPropertyValueSingle( 'Modules.ImGUI.Main.SceneProperties.Ordering', diff --git a/src/mission/missionmanager.cpp b/src/mission/missionmanager.cpp index ca38c88c84..77db904caa 100644 --- a/src/mission/missionmanager.cpp +++ b/src/mission/missionmanager.cpp @@ -88,6 +88,10 @@ void MissionManager::unloadMission(const std::string& missionName) { "missionName must name a previously loaded mission" ); + if (it == _currentMission) { + _currentMission = _missionMap.end(); + } + _missionMap.erase(it); } diff --git a/src/rendering/dashboard.cpp b/src/rendering/dashboard.cpp index 5b447029c3..64fd512ab9 100644 --- a/src/rendering/dashboard.cpp +++ b/src/rendering/dashboard.cpp @@ -81,6 +81,23 @@ void Dashboard::removeDashboardItem(int index) { _items.erase(_items.begin() + index); } +void Dashboard::removeDashboardItem(const std::string& identifier) { + const auto it = std::find_if( + _items.begin(), + _items.end(), + [&identifier](const std::unique_ptr& i) { + return i->identifier() == identifier; + } + ); + + if (it == _items.end()) { + return; + } + + removePropertySubOwner(it->get()); + _items.erase(it); +} + bool Dashboard::hasItem(int index) const { return (index >= 0) && (index < static_cast(_items.size())); } @@ -90,7 +107,7 @@ const DashboardItem& Dashboard::item(int index) const { return *_items[index]; } -void Dashboard::removeDashboardItems() { +void Dashboard::clearDashboardItems() { for (const std::unique_ptr& item : _items) { removePropertySubOwner(item.get()); } @@ -121,8 +138,15 @@ scripting::LuaLibrary Dashboard::luaLibrary() { "Adds a new dashboard item to the main dashboard." }, { - "removeDashboardItems", - &luascriptfunctions::removeDashboardItems, + "removeDashboardItem", + &luascriptfunctions::removeDashboardItem, + {}, + "string", + "Removes the dashboard item with the specified identifier." + }, + { + "clearDashboardItems", + &luascriptfunctions::clearDashboardItems, {}, "", "Removes all dashboard items from the main dashboard." diff --git a/src/rendering/dashboard_lua.inl b/src/rendering/dashboard_lua.inl index 90de001788..5d96243bf5 100644 --- a/src/rendering/dashboard_lua.inl +++ b/src/rendering/dashboard_lua.inl @@ -58,14 +58,33 @@ int addDashboardItem(lua_State* L) { } } +/** +* \ingroup LuaScripts +* removeDashboardItem(string): +*/ +int removeDashboardItem(lua_State* L) { + using ghoul::lua::errorLocation; + + ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::removeDashbordItem"); + + std::string identifier = luaL_checkstring(L, -1); + + OsEng.dashboard().removeDashboardItem(identifier); + + lua_settop(L, 0); + ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); + return 0; +} + + /** * \ingroup LuaScripts * removeDashboardItems(): */ -int removeDashboardItems(lua_State* L) { - ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::removeDashboardItems"); +int clearDashboardItems(lua_State* L) { + ghoul::lua::checkArgumentsAndThrow(L, 0, "lua::clearDashboardItems"); - OsEng.dashboard().removeDashboardItems(); + OsEng.dashboard().clearDashboardItems(); ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; diff --git a/src/rendering/dashboarditem.cpp b/src/rendering/dashboarditem.cpp index 56809d7432..db195fdd71 100644 --- a/src/rendering/dashboarditem.cpp +++ b/src/rendering/dashboarditem.cpp @@ -25,6 +25,8 @@ #include #include +#include +#include #include @@ -36,10 +38,56 @@ namespace { "Is Enabled", "If this value is set to 'true' this dashboard item is shown in the dashboard" }; + + static const openspace::properties::Property::PropertyInfo TypeInfo = { + "Type", + "Type", + "" + }; + + static const openspace::properties::Property::PropertyInfo IdentifierInfo = { + "Identifier", + "Identifier", + "" + }; + + static const openspace::properties::Property::PropertyInfo GuiNameInfo = { + "GuiName", + "Gui Name", + "" + }; } // namespace namespace openspace { +documentation::Documentation DashboardItem::Documentation() { + using namespace documentation; + return { + "DashboardItem", + "dashboarditem", + { + { + TypeInfo.identifier, + new StringVerifier, + Optional::No, + TypeInfo.description + }, + { + IdentifierInfo.identifier, + new StringVerifier, + Optional::No, + IdentifierInfo.description + }, + { + GuiNameInfo.identifier, + new StringVerifier, + Optional::Yes, + GuiNameInfo.description + } + } + }; +} + std::unique_ptr DashboardItem::createFromDictionary( ghoul::Dictionary dictionary) { @@ -51,10 +99,24 @@ std::unique_ptr DashboardItem::createFromDictionary( return factory->create(dashboardType, dictionary); } -DashboardItem::DashboardItem(std::string identifier, std::string guiName) - : properties::PropertyOwner({ std::move(identifier), std::move(guiName) }) +DashboardItem::DashboardItem(ghoul::Dictionary dictionary) + : properties::PropertyOwner({ "", "" }) , _isEnabled(EnabledInfo, true) { + documentation::testSpecificationAndThrow( + Documentation(), + dictionary, + "DashboardItem" + ); + + const std::string identifier = + dictionary.value(IdentifierInfo.identifier); + + const std::string guiName = + dictionary.value(GuiNameInfo.identifier); + + setIdentifier(identifier); + setGuiName(guiName); addProperty(_isEnabled); } From 182e344f302e9fbbf46fa812d3cd07f4733e25ac Mon Sep 17 00:00:00 2001 From: Emil Axelsson Date: Thu, 29 Mar 2018 18:02:17 +0200 Subject: [PATCH 02/17] Change Name to Identifier in globe browsing helper code (#567) --- modules/globebrowsing/scripts/layer_support.lua | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/modules/globebrowsing/scripts/layer_support.lua b/modules/globebrowsing/scripts/layer_support.lua index 5041e90410..f8935c1eab 100644 --- a/modules/globebrowsing/scripts/layer_support.lua +++ b/modules/globebrowsing/scripts/layer_support.lua @@ -166,7 +166,7 @@ openspace.globebrowsing.parseInfoFile = function (file) local color = nil if ColorFile then color = { - Name = Name, + Identifier = Identifier, Description = Description or "", FilePath = dir .. '/' .. ColorFile, BlendMode = "Color" @@ -176,7 +176,7 @@ openspace.globebrowsing.parseInfoFile = function (file) local height = nil if HeightFile then height = { - Name = Name, + Identifier = Identifier, Description = Description or "", FilePath = dir .. '/' .. HeightFile, TilePixelSize = 90 @@ -194,11 +194,11 @@ openspace.globebrowsing.addBlendingLayersFromDirectory = function (dir, node_nam c, h = openspace.globebrowsing.parseInfoFile(file) if c then - openspace.printInfo("Adding color layer '" .. c["Name"] .. "'") + openspace.printInfo("Adding color layer '" .. c["Identifier"] .. "'") openspace.globebrowsing.addLayer(node_name, "ColorLayers", c) end if h then - openspace.printInfo("Adding height layer '" .. h["Name"] .. "'") + openspace.printInfo("Adding height layer '" .. h["Identifier"] .. "'") openspace.globebrowsing.addLayer(node_name, "HeightLayers", h) end end From 9177f5f4327ec5d9742d6ca6e7d570423257ed0c Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Fri, 30 Mar 2018 00:01:57 -0400 Subject: [PATCH 03/17] Enable clearing multiple keys with the same function call Slightly speedup application close --- modules/sync/syncmodule.cpp | 5 +++++ modules/sync/syncmodule.h | 1 + modules/sync/torrentclient.cpp | 4 ---- modules/sync/torrentclient.h | 3 --- src/engine/moduleengine.cpp | 8 +++++++- src/interaction/keybindingmanager.cpp | 6 ++++-- src/interaction/keybindingmanager_lua.inl | 19 ++++++++++++++++--- 7 files changed, 33 insertions(+), 13 deletions(-) diff --git a/modules/sync/syncmodule.cpp b/modules/sync/syncmodule.cpp index cc7e66bc5a..1a42018370 100644 --- a/modules/sync/syncmodule.cpp +++ b/modules/sync/syncmodule.cpp @@ -122,6 +122,11 @@ void SyncModule::internalInitialize(const ghoul::Dictionary& configuration) { }); } +void SyncModule::internalDeinitialize() { + _torrentClient.deinitialize(); +} + + std::string SyncModule::synchronizationRoot() const { return _synchronizationRoot; } diff --git a/modules/sync/syncmodule.h b/modules/sync/syncmodule.h index e3e51b39a6..dee6df8178 100644 --- a/modules/sync/syncmodule.h +++ b/modules/sync/syncmodule.h @@ -48,6 +48,7 @@ public: protected: void internalInitialize(const ghoul::Dictionary& configuration) override; + void internalDeinitialize() override; private: TorrentClient _torrentClient; diff --git a/modules/sync/torrentclient.cpp b/modules/sync/torrentclient.cpp index 4a53c05281..87905af398 100644 --- a/modules/sync/torrentclient.cpp +++ b/modules/sync/torrentclient.cpp @@ -61,10 +61,6 @@ TorrentError::TorrentError(std::string msg) : RuntimeError(std::move(msg), "TorrentClient") {} -TorrentClient::~TorrentClient() { - deinitialize(); -} - void TorrentClient::initialize() { #ifdef SYNC_USE_LIBTORRENT libtorrent::settings_pack settings; diff --git a/modules/sync/torrentclient.h b/modules/sync/torrentclient.h index 2aa16effbf..a84aca8f52 100644 --- a/modules/sync/torrentclient.h +++ b/modules/sync/torrentclient.h @@ -84,9 +84,6 @@ public: using TorrentProgressCallback = std::function; using TorrentId = int32_t; - //TorrentClient(); - ~TorrentClient(); - void initialize(); void deinitialize(); diff --git a/src/engine/moduleengine.cpp b/src/engine/moduleengine.cpp index 6b45cbd2cc..1b8f8cf2a9 100644 --- a/src/engine/moduleengine.cpp +++ b/src/engine/moduleengine.cpp @@ -63,8 +63,14 @@ void ModuleEngine::deinitialize() { LDEBUG(fmt::format("Deinitializing module '{}'", m->identifier())); m->deinitialize(); } - _modules.clear(); + + for (std::unique_ptr& m : _modules) { + LDEBUG(fmt::format("Destroying module '{}'", m->identifier())); + m = nullptr; + } + LDEBUG("Finished destroying modules"); + _modules.clear(); } void ModuleEngine::registerModule(std::unique_ptr m, diff --git a/src/interaction/keybindingmanager.cpp b/src/interaction/keybindingmanager.cpp index b0b0cecb0a..60cd6258f4 100644 --- a/src/interaction/keybindingmanager.cpp +++ b/src/interaction/keybindingmanager.cpp @@ -185,8 +185,10 @@ scripting::LuaLibrary KeyBindingManager::luaLibrary() { "clearKey", &luascriptfunctions::clearKey, {}, - "string", - "Unbinds all of the scripts that are bound to the provided key + modifier" + "string or strings", + "Unbinds the key or keys that have been provided. This function can be " + "called with a single key or with an array of keys to remove all of the " + "provided keys at once" }, { "bindKey", diff --git a/src/interaction/keybindingmanager_lua.inl b/src/interaction/keybindingmanager_lua.inl index 38bdb9b17b..33f7edf830 100644 --- a/src/interaction/keybindingmanager_lua.inl +++ b/src/interaction/keybindingmanager_lua.inl @@ -162,9 +162,22 @@ int getKeyBindings(lua_State* L) { int clearKey(lua_State* L) { ghoul::lua::checkArgumentsAndThrow(L, 1, "lua::clearKey"); - std::string key = ghoul::lua::checkStringAndPop(L); - - OsEng.keyBindingManager().removeKeyBinding(key); + int t = lua_type(L, 1); + if (t == LUA_TSTRING) { + // The user provided a single key + std::string key = ghoul::lua::checkStringAndPop(L); + OsEng.keyBindingManager().removeKeyBinding(key); + } + else { + // The user provided a list of keys + ghoul::Dictionary d; + ghoul::lua::luaDictionaryFromState(L, d); + for (int i = 1; i <= d.size(); ++i) { + std::string k = d.value(std::to_string(i)); + OsEng.keyBindingManager().removeKeyBinding(k); + } + lua_pop(L, 1); + } ghoul_assert(lua_gettop(L) == 0, "Incorrect number of items left on stack"); return 0; From ae7e22dfe069f1d67267de68aeb93c55616a059d Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Fri, 30 Mar 2018 13:03:17 -0400 Subject: [PATCH 04/17] Adapt to typesafe ghoul::Boolean parameters --- apps/OpenSpace/main.cpp | 2 +- ext/ghoul | 2 +- include/openspace/documentation/documentation.h | 2 +- include/openspace/engine/syncengine.h | 2 +- include/openspace/interaction/keybindingmanager.h | 4 ++-- include/openspace/rendering/deferredcasterlistener.h | 3 ++- include/openspace/rendering/framebufferrenderer.h | 2 +- include/openspace/rendering/loadingscreen.h | 8 ++++---- include/openspace/scene/scene.h | 2 +- include/openspace/scene/scenegraphnode.h | 2 +- include/openspace/scripting/scriptengine.h | 2 +- include/openspace/util/httprequest.h | 2 +- include/openspace/util/spicemanager.h | 2 +- modules/globebrowsing/meshes/trianglesoup.h | 9 ++++----- modules/globebrowsing/other/statscollector.h | 2 +- modules/globebrowsing/tile/asynctiledataprovider.h | 2 +- .../tile/rawtiledatareader/rawtiledatareader.h | 2 +- modules/globebrowsing/tile/tiletextureinitdata.h | 2 +- modules/imgui/include/guipropertycomponent.h | 2 +- modules/imgui/include/renderproperties.h | 8 +++----- modules/sync/syncs/httpsynchronization.cpp | 2 +- modules/sync/syncs/torrentsynchronization.cpp | 2 +- modules/sync/syncs/urlsynchronization.cpp | 2 +- src/interaction/luaconsole.cpp | 4 ++-- src/rendering/deferredcastermanager.cpp | 10 ++++++++-- src/rendering/framebufferrenderer.cpp | 2 +- src/util/httprequest.cpp | 2 +- 27 files changed, 45 insertions(+), 41 deletions(-) diff --git a/apps/OpenSpace/main.cpp b/apps/OpenSpace/main.cpp index 8586b6d98e..b97d159420 100644 --- a/apps/OpenSpace/main.cpp +++ b/apps/OpenSpace/main.cpp @@ -655,7 +655,7 @@ int main_main(int argc, char** argv) { "Unknown OpenGL version. Missing statement in version mapping map" ); - using IsInitialized = ghoul::Boolean; + BooleanType(IsInitialized); auto cleanup = [&](IsInitialized isInitialized){ if (isInitialized) { OsEng.deinitialize(); diff --git a/ext/ghoul b/ext/ghoul index f1bc4ab860..fd1187437c 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit f1bc4ab860f3155c0b90f9af4bb08339663b449a +Subproject commit fd1187437c59553f2dba74684b791220cbb8d7fc diff --git a/include/openspace/documentation/documentation.h b/include/openspace/documentation/documentation.h index 5f521328ff..14ed0595fe 100644 --- a/include/openspace/documentation/documentation.h +++ b/include/openspace/documentation/documentation.h @@ -36,7 +36,7 @@ namespace ghoul { class Dictionary; } namespace openspace::documentation { -using Optional = ghoul::Boolean; +BooleanType(Optional); /** * The TestResult structure returns the information from the #testSpecification method. It diff --git a/include/openspace/engine/syncengine.h b/include/openspace/engine/syncengine.h index d4f994057d..acd5da35bd 100644 --- a/include/openspace/engine/syncengine.h +++ b/include/openspace/engine/syncengine.h @@ -42,7 +42,7 @@ class Syncable; */ class SyncEngine { public: - using IsMaster = ghoul::Boolean; + BooleanType(IsMaster); /** * Creates a new SyncEngine which a buffer size of \p syncBufferSize diff --git a/include/openspace/interaction/keybindingmanager.h b/include/openspace/interaction/keybindingmanager.h index 31ee66044f..c4a47d7631 100644 --- a/include/openspace/interaction/keybindingmanager.h +++ b/include/openspace/interaction/keybindingmanager.h @@ -40,8 +40,8 @@ namespace openspace::interaction { class KeyBindingManager : public DocumentationGenerator { public: - using IsLocalBind = ghoul::Boolean; - using IsSynchronized = ghoul::Boolean; + BooleanType(IsLocalBind); + BooleanType(IsSynchronized); struct KeyInformation { std::string command; diff --git a/include/openspace/rendering/deferredcasterlistener.h b/include/openspace/rendering/deferredcasterlistener.h index dd84e98bc9..c9f57d4351 100644 --- a/include/openspace/rendering/deferredcasterlistener.h +++ b/include/openspace/rendering/deferredcasterlistener.h @@ -33,7 +33,8 @@ class Deferredcaster; class DeferredcasterListener { public: - using isAttached = ghoul::Boolean; + BooleanType(isAttached); + virtual ~DeferredcasterListener() = default; virtual void deferredcastersChanged(Deferredcaster& deferredcaster, diff --git a/include/openspace/rendering/framebufferrenderer.h b/include/openspace/rendering/framebufferrenderer.h index 470abafe84..66fc0801f0 100644 --- a/include/openspace/rendering/framebufferrenderer.h +++ b/include/openspace/rendering/framebufferrenderer.h @@ -91,7 +91,7 @@ public: virtual void raycastersChanged(VolumeRaycaster& raycaster, bool attached) override; virtual void deferredcastersChanged(Deferredcaster& deferredcaster, - ghoul::Boolean isAttached) override; + isAttached isAttached) override; private: std::map _raycastData; diff --git a/include/openspace/rendering/loadingscreen.h b/include/openspace/rendering/loadingscreen.h index e823d9eefb..899bcc6f71 100644 --- a/include/openspace/rendering/loadingscreen.h +++ b/include/openspace/rendering/loadingscreen.h @@ -49,10 +49,10 @@ namespace openspace { class LoadingScreen { public: - using ShowMessage = ghoul::Boolean; - using ShowNodeNames = ghoul::Boolean; - using ShowProgressbar = ghoul::Boolean; - using CatastrophicError = ghoul::Boolean; + BooleanType(ShowMessage); + BooleanType(ShowNodeNames); + BooleanType(ShowProgressbar); + BooleanType(CatastrophicError); LoadingScreen(ShowMessage showMessage, ShowNodeNames showNodeNames, ShowProgressbar showProgressbar); diff --git a/include/openspace/scene/scene.h b/include/openspace/scene/scene.h index b25d0bdb21..5321349519 100644 --- a/include/openspace/scene/scene.h +++ b/include/openspace/scene/scene.h @@ -54,7 +54,7 @@ class Scene : public properties::PropertyOwner { public: - using UpdateDependencies = ghoul::Boolean; + BooleanType(UpdateDependencies); struct InvalidSceneError : ghoul::RuntimeError { /** diff --git a/include/openspace/scene/scenegraphnode.h b/include/openspace/scene/scenegraphnode.h index 363d3bd659..65f497f33a 100644 --- a/include/openspace/scene/scenegraphnode.h +++ b/include/openspace/scene/scenegraphnode.h @@ -61,7 +61,7 @@ public: GLInitialized }; - using UpdateScene = ghoul::Boolean; + BooleanType(UpdateScene); struct PerformanceRecord { long long renderTime; // time in ns diff --git a/include/openspace/scripting/scriptengine.h b/include/openspace/scripting/scriptengine.h index 562da4427a..65e7d26242 100644 --- a/include/openspace/scripting/scriptengine.h +++ b/include/openspace/scripting/scriptengine.h @@ -52,7 +52,7 @@ namespace openspace::scripting { */ class ScriptEngine : public Syncable, public DocumentationGenerator { public: - using RemoteScripting = ghoul::Boolean; + BooleanType(RemoteScripting); ScriptEngine(); diff --git a/include/openspace/util/httprequest.h b/include/openspace/util/httprequest.h index 76eb42baa8..de515ef4fe 100644 --- a/include/openspace/util/httprequest.h +++ b/include/openspace/util/httprequest.h @@ -222,7 +222,7 @@ private: class HttpFileDownload : public virtual HttpDownload { public: - using Overwrite = ghoul::Boolean; + BooleanType(Overwrite); HttpFileDownload() = default; HttpFileDownload(std::string destination, Overwrite = Overwrite::No); diff --git a/include/openspace/util/spicemanager.h b/include/openspace/util/spicemanager.h index b1dbdd8a1b..f764619794 100644 --- a/include/openspace/util/spicemanager.h +++ b/include/openspace/util/spicemanager.h @@ -45,7 +45,7 @@ class SpiceManager : public ghoul::Singleton { friend class ghoul::Singleton; public: using TransformMatrix = std::array; - using UseException = ghoul::Boolean; + BooleanType(UseException); using KernelHandle = unsigned int; struct SpiceException : public ghoul::RuntimeError { diff --git a/modules/globebrowsing/meshes/trianglesoup.h b/modules/globebrowsing/meshes/trianglesoup.h index 166b20df44..f31db1e413 100644 --- a/modules/globebrowsing/meshes/trianglesoup.h +++ b/modules/globebrowsing/meshes/trianglesoup.h @@ -44,12 +44,11 @@ namespace openspace::globebrowsing { // that is faster class TriangleSoup { public: - using Positions = ghoul::Boolean; - using TextureCoordinates = ghoul::Boolean; - using Normals = ghoul::Boolean; + BooleanType(Positions); + BooleanType(TextureCoordinates); + BooleanType(Normals); - TriangleSoup( - std::vector elements, // At least elements are required + TriangleSoup(std::vector elements, // At least elements are required Positions usePositions = Positions::No, TextureCoordinates useTextures = TextureCoordinates::No, Normals useNormals = Normals::No); diff --git a/modules/globebrowsing/other/statscollector.h b/modules/globebrowsing/other/statscollector.h index b2bfb7ec4b..46b42304c8 100644 --- a/modules/globebrowsing/other/statscollector.h +++ b/modules/globebrowsing/other/statscollector.h @@ -78,7 +78,7 @@ class StatsCollector { public: StatsCollector() = delete; - using Enabled = ghoul::Boolean; + BooleanType(Enabled); StatsCollector(const std::string& filename, int dumpEveryXRecord, Enabled enabled = Enabled::Yes, const std::string& delimiter = ","); diff --git a/modules/globebrowsing/tile/asynctiledataprovider.h b/modules/globebrowsing/tile/asynctiledataprovider.h index 2a4f10c31d..4c0328c140 100644 --- a/modules/globebrowsing/tile/asynctiledataprovider.h +++ b/modules/globebrowsing/tile/asynctiledataprovider.h @@ -82,7 +82,7 @@ public: float noDataValueAsFloat() const; protected: - using ResetRawTileDataReader = ghoul::Boolean; + BooleanType(ResetRawTileDataReader); enum class ResetMode { ShouldResetAll, diff --git a/modules/globebrowsing/tile/rawtiledatareader/rawtiledatareader.h b/modules/globebrowsing/tile/rawtiledatareader/rawtiledatareader.h index 9fbb139b8c..e510457688 100644 --- a/modules/globebrowsing/tile/rawtiledatareader/rawtiledatareader.h +++ b/modules/globebrowsing/tile/rawtiledatareader/rawtiledatareader.h @@ -46,7 +46,7 @@ class GeodeticPatch; class RawTileDataReader { public: - using PerformPreprocessing = ghoul::Boolean; + BooleanType(PerformPreprocessing); RawTileDataReader(const TileTextureInitData& initData, PerformPreprocessing preprocess = PerformPreprocessing::No); diff --git a/modules/globebrowsing/tile/tiletextureinitdata.h b/modules/globebrowsing/tile/tiletextureinitdata.h index fb5e103306..d7732ad965 100644 --- a/modules/globebrowsing/tile/tiletextureinitdata.h +++ b/modules/globebrowsing/tile/tiletextureinitdata.h @@ -39,7 +39,7 @@ namespace openspace::globebrowsing { class TileTextureInitData { public: using HashKey = unsigned long long; - using ShouldAllocateDataOnCPU = ghoul::Boolean; + BooleanType(ShouldAllocateDataOnCPU); using Format = ghoul::opengl::Texture::Format; TileTextureInitData(size_t width, size_t height, GLenum glType, Format textureFormat, diff --git a/modules/imgui/include/guipropertycomponent.h b/modules/imgui/include/guipropertycomponent.h index 8475dfad06..1b54282e00 100644 --- a/modules/imgui/include/guipropertycomponent.h +++ b/modules/imgui/include/guipropertycomponent.h @@ -48,7 +48,7 @@ class GuiPropertyComponent : public GuiComponent { public: using SourceFunction = std::function()>; - using UseTreeLayout = ghoul::Boolean; + BooleanType(UseTreeLayout); GuiPropertyComponent(std::string identifier, std::string guiName = "", diff --git a/modules/imgui/include/renderproperties.h b/modules/imgui/include/renderproperties.h index 6ddbbb9a5b..d09a0a8fe4 100644 --- a/modules/imgui/include/renderproperties.h +++ b/modules/imgui/include/renderproperties.h @@ -29,14 +29,12 @@ #include -namespace openspace::properties { - class Property; -} // namespace openspace::properties +namespace openspace::properties { class Property; } namespace openspace { -using IsRegularProperty = ghoul::Boolean; -using ShowToolTip = ghoul::Boolean; +BooleanType(IsRegularProperty); +BooleanType(ShowToolTip); void executeScript(const std::string& id, const std::string& value, IsRegularProperty isRegular = IsRegularProperty::Yes); diff --git a/modules/sync/syncs/httpsynchronization.cpp b/modules/sync/syncs/httpsynchronization.cpp index b1eb47d5e7..53f8c96705 100644 --- a/modules/sync/syncs/httpsynchronization.cpp +++ b/modules/sync/syncs/httpsynchronization.cpp @@ -167,7 +167,7 @@ void HttpSynchronization::createSyncFile() { std::string directoryName = directory(); std::string filepath = directoryName + ".ossync"; - FileSys.createDirectory(directoryName, ghoul::filesystem::Directory::Recursive::Yes); + FileSys.createDirectory(directoryName, ghoul::filesystem::FileSystem::Recursive::Yes); std::ofstream syncFile(filepath, std::ofstream::out); syncFile << "Synchronized"; diff --git a/modules/sync/syncs/torrentsynchronization.cpp b/modules/sync/syncs/torrentsynchronization.cpp index bd16bb8e9c..b96c0f74c3 100644 --- a/modules/sync/syncs/torrentsynchronization.cpp +++ b/modules/sync/syncs/torrentsynchronization.cpp @@ -168,7 +168,7 @@ void TorrentSynchronization::createSyncFile() { std::string directoryName = directory(); std::string filepath = directoryName + ".ossync"; - FileSys.createDirectory(directoryName, ghoul::filesystem::Directory::Recursive::Yes); + FileSys.createDirectory(directoryName, ghoul::filesystem::FileSystem::Recursive::Yes); std::ofstream syncFile(filepath, std::ofstream::out); syncFile << "Synchronized"; diff --git a/modules/sync/syncs/urlsynchronization.cpp b/modules/sync/syncs/urlsynchronization.cpp index 11ee8b6e21..51a06cfe4b 100644 --- a/modules/sync/syncs/urlsynchronization.cpp +++ b/modules/sync/syncs/urlsynchronization.cpp @@ -265,7 +265,7 @@ bool UrlSynchronization::nTotalBytesIsKnown() { void UrlSynchronization::createSyncFile() { std::string dir = directory(); std::string filepath = dir + ".ossync"; - FileSys.createDirectory(dir, ghoul::filesystem::Directory::Recursive::Yes); + FileSys.createDirectory(dir, ghoul::filesystem::FileSystem::Recursive::Yes); std::ofstream syncFile(filepath, std::ofstream::out); syncFile << "Synchronized"; syncFile.close(); diff --git a/src/interaction/luaconsole.cpp b/src/interaction/luaconsole.cpp index 57cf60be1f..f1da932d49 100644 --- a/src/interaction/luaconsole.cpp +++ b/src/interaction/luaconsole.cpp @@ -263,13 +263,13 @@ void LuaConsole::initialize() { _font = OsEng.fontManager().font( FontName, EntryFontSize, - ghoul::fontrendering::Font::Outline::No + ghoul::fontrendering::FontManager::Outline::No ); _historyFont = OsEng.fontManager().font( FontName, HistoryFontSize, - ghoul::fontrendering::Font::Outline::No + ghoul::fontrendering::FontManager::Outline::No ); OsEng.parallelPeer().connectionEvent()->subscribe( diff --git a/src/rendering/deferredcastermanager.cpp b/src/rendering/deferredcastermanager.cpp index 5321684a7b..eabf05fb86 100644 --- a/src/rendering/deferredcastermanager.cpp +++ b/src/rendering/deferredcastermanager.cpp @@ -40,7 +40,10 @@ void DeferredcasterManager::attachDeferredcaster(Deferredcaster& deferredcaster) _deferredcasters.push_back(&deferredcaster); } for (auto &listener : _listeners) { - listener->deferredcastersChanged(deferredcaster, ghoul::Boolean::Yes); + listener->deferredcastersChanged( + deferredcaster, + DeferredcasterListener::isAttached::Yes + ); } } @@ -53,7 +56,10 @@ void DeferredcasterManager::detachDeferredcaster(Deferredcaster& deferredcaster) if (it != _deferredcasters.end()) { _deferredcasters.erase(it); for (auto &listener : _listeners) { - listener->deferredcastersChanged(deferredcaster, ghoul::Boolean::No); + listener->deferredcastersChanged( + deferredcaster, + DeferredcasterListener::isAttached::No + ); } } } diff --git a/src/rendering/framebufferrenderer.cpp b/src/rendering/framebufferrenderer.cpp index 1d4a732904..7984166b24 100644 --- a/src/rendering/framebufferrenderer.cpp +++ b/src/rendering/framebufferrenderer.cpp @@ -261,7 +261,7 @@ void FramebufferRenderer::raycastersChanged(VolumeRaycaster&, bool) { } void FramebufferRenderer::deferredcastersChanged(Deferredcaster& deferredcaster, - ghoul::Boolean isAttached) + isAttached isAttached) { (void) deferredcaster; (void) isAttached; diff --git a/src/util/httprequest.cpp b/src/util/httprequest.cpp index 41fde1bc65..86a8765ad9 100644 --- a/src/util/httprequest.cpp +++ b/src/util/httprequest.cpp @@ -331,7 +331,7 @@ bool HttpFileDownload::initDownload() { { std::lock_guard g(_directoryCreationMutex); if (!FileSys.directoryExists(d)) { - FileSys.createDirectory(d, ghoul::filesystem::Directory::Recursive::Yes); + FileSys.createDirectory(d, ghoul::filesystem::FileSystem::Recursive::Yes); } } From cae4ed9ce063cb98ac9444aa9f97adc3237b4aca Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 9 Apr 2018 10:20:36 -0400 Subject: [PATCH 05/17] Sort nodes in GlobeBrowsing UI by whether they have URLs associated with them or not (closes #580) --- modules/globebrowsing/globebrowsingmodule.cpp | 5 ++ modules/globebrowsing/globebrowsingmodule.h | 1 + .../imgui/src/guiglobebrowsingcomponent.cpp | 59 ++++++++++++++++--- 3 files changed, 57 insertions(+), 8 deletions(-) diff --git a/modules/globebrowsing/globebrowsingmodule.cpp b/modules/globebrowsing/globebrowsingmodule.cpp index c6900b915e..eeeec0f331 100644 --- a/modules/globebrowsing/globebrowsingmodule.cpp +++ b/modules/globebrowsing/globebrowsingmodule.cpp @@ -628,6 +628,11 @@ GlobeBrowsingModule::urlInfo(const std::string& globe) const return res; } +bool GlobeBrowsingModule::hasUrlInfo(const std::string& globe) const { + return _urlList.find(globe) != _urlList.end(); +} + + #endif // GLOBEBROWSING_USE_GDAL } // namespace openspace diff --git a/modules/globebrowsing/globebrowsingmodule.h b/modules/globebrowsing/globebrowsingmodule.h index fcb3aacdf7..64da904daf 100644 --- a/modules/globebrowsing/globebrowsingmodule.h +++ b/modules/globebrowsing/globebrowsingmodule.h @@ -79,6 +79,7 @@ public: Capabilities capabilities(const std::string& name); std::vector urlInfo(const std::string& globe) const; + bool hasUrlInfo(const std::string& globe) const; void removeWMSServer(const std::string& name); diff --git a/modules/imgui/src/guiglobebrowsingcomponent.cpp b/modules/imgui/src/guiglobebrowsingcomponent.cpp index 988435433a..83e2a12f5d 100644 --- a/modules/imgui/src/guiglobebrowsingcomponent.cpp +++ b/modules/imgui/src/guiglobebrowsingcomponent.cpp @@ -79,9 +79,9 @@ void GuiGlobeBrowsingComponent::render() { std::remove_if( nodes.begin(), nodes.end(), - [](SceneGraphNode* n) { - return !(n->renderable() && - n->renderable()->identifier() == "RenderableGlobe"); + [module](SceneGraphNode* n) { + Renderable* r = n->renderable(); + return !r || r->identifier() != "RenderableGlobe"; } ), nodes.end() @@ -89,13 +89,40 @@ void GuiGlobeBrowsingComponent::render() { std::sort( nodes.begin(), nodes.end(), - [](SceneGraphNode* lhs, SceneGraphNode* rhs) { + [module](SceneGraphNode* lhs, SceneGraphNode* rhs) { + bool lhsHasUrl = module->hasUrlInfo(lhs->identifier()); + bool rhsHasUrl = module->hasUrlInfo(rhs->identifier()); + + if (lhsHasUrl && !rhsHasUrl) { + return true; + } + if (!lhsHasUrl && rhsHasUrl) { + return false; + } + return lhs->guiName() < rhs->guiName(); } ); + + + auto firstWithoutUrl = std::find_if( + nodes.begin(), + nodes.end(), + [module](SceneGraphNode* n) { + return !module->hasUrlInfo(n->identifier()); + } + ); + nodes.insert(firstWithoutUrl, nullptr); + std::string nodeNames; for (SceneGraphNode* n : nodes) { - nodeNames += n->identifier() + '\0'; + // Add separator between nodes with URL and nodes without + if (n) { + nodeNames += n->identifier() + '\0'; + } + else { + nodeNames += std::string("===== =====") + '\0'; + } } int iNode = -1; @@ -116,7 +143,7 @@ void GuiGlobeBrowsingComponent::render() { nodes.cbegin(), nodes.cend(), [this](SceneGraphNode* lhs) { - return lhs->identifier() == _currentNode; + return lhs && (lhs->identifier() == _currentNode); } ); iNode = static_cast(std::distance(nodes.cbegin(), it)); @@ -141,6 +168,12 @@ void GuiGlobeBrowsingComponent::render() { // or if there are no nodes return; } + + if (!nodes[iNode]) { + // The user selected the separator + return; + } + _currentNode = nodes[iNode]->identifier(); if (nodeChanged) { @@ -225,7 +258,7 @@ void GuiGlobeBrowsingComponent::render() { } - if (iServer == -1) { + if (iServer < 0) { return; } _currentServer = urlInfo[iServer].name; @@ -299,16 +332,26 @@ void GuiGlobeBrowsingComponent::render() { auto addFunc = [this, &l](const std::string& type) { std::string layerName = l.name; std::replace(layerName.begin(), layerName.end(), '.', '-'); + layerName.erase( + std::remove(layerName.begin(), layerName.end(), ' '), + layerName.end() + ); OsEng.scriptEngine().queueScript( fmt::format( "openspace.globebrowsing.addLayer(\ '{}', \ '{}', \ - {{ Name = '{}', FilePath = '{}', Enabled = true }}\ + {{ \ + Identifier = '{}',\ + Name = '{}',\ + FilePath = '{}',\ + Enabled = true\ + }}\ );", _currentNode, type, layerName, + l.name, l.url ), scripting::ScriptEngine::RemoteScripting::Yes From 07e995187aa62683d3f6da21a88d5335fb8b66b0 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 9 Apr 2018 13:37:06 -0400 Subject: [PATCH 06/17] Pass radius of planets into the skirt length computation rather than use a fixed minimum length (fixed #582) --- .../globebrowsing/globes/chunkedlodglobe.cpp | 9 ++++- .../globebrowsing/globes/chunkedlodglobe.h | 4 +- .../globebrowsing/globes/renderableglobe.cpp | 19 +++++----- .../globebrowsing/rendering/chunkrenderer.cpp | 37 +++++++++++++------ .../globebrowsing/rendering/chunkrenderer.h | 7 +++- 5 files changed, 49 insertions(+), 27 deletions(-) diff --git a/modules/globebrowsing/globes/chunkedlodglobe.cpp b/modules/globebrowsing/globes/chunkedlodglobe.cpp index 6528d563fb..1ce0faff67 100644 --- a/modules/globebrowsing/globes/chunkedlodglobe.cpp +++ b/modules/globebrowsing/globes/chunkedlodglobe.cpp @@ -56,7 +56,8 @@ const TileIndex ChunkedLodGlobe::RIGHT_HEMISPHERE_INDEX = TileIndex(1, 0, 1); const GeodeticPatch ChunkedLodGlobe::COVERAGE = GeodeticPatch(0, 0, 90, 180); ChunkedLodGlobe::ChunkedLodGlobe(const RenderableGlobe& owner, size_t segmentsPerPatch, - std::shared_ptr layerManager) + std::shared_ptr layerManager, + Ellipsoid& ellipsoid) : Renderable({ { "Identifier", owner.identifier() }, { "Name", owner.guiName() } }) , minSplitDepth(2) , maxSplitDepth(22) @@ -87,7 +88,11 @@ ChunkedLodGlobe::ChunkedLodGlobe(const RenderableGlobe& owner, size_t segmentsPe _chunkEvaluatorByDistance = std::make_unique(); - _renderer = std::make_unique(geometry, layerManager); + _renderer = std::make_unique( + geometry, + layerManager, + ellipsoid + ); } // The destructor is defined here to make it feasiable to use a unique_ptr diff --git a/modules/globebrowsing/globes/chunkedlodglobe.h b/modules/globebrowsing/globes/chunkedlodglobe.h index 4aeab8e241..cc5ff5a5e9 100644 --- a/modules/globebrowsing/globes/chunkedlodglobe.h +++ b/modules/globebrowsing/globes/chunkedlodglobe.h @@ -27,7 +27,6 @@ #include -#include #include #include @@ -42,6 +41,7 @@ namespace culling { class ChunkCuller; } class Chunk; class ChunkNode; class ChunkRenderer; +class Ellipsoid; struct Geodetic2; class LayerManager; class RenderableGlobe; @@ -49,7 +49,7 @@ class RenderableGlobe; class ChunkedLodGlobe : public Renderable { public: ChunkedLodGlobe(const RenderableGlobe& owner, size_t segmentsPerPatch, - std::shared_ptr layerManager); + std::shared_ptr layerManager, Ellipsoid& ellipsoid); ~ChunkedLodGlobe(); bool isReady() const override; diff --git a/modules/globebrowsing/globes/renderableglobe.cpp b/modules/globebrowsing/globes/renderableglobe.cpp index a3f7e406f4..eed0649d4f 100644 --- a/modules/globebrowsing/globes/renderableglobe.cpp +++ b/modules/globebrowsing/globes/renderableglobe.cpp @@ -30,13 +30,13 @@ #include namespace { - const char* keyFrame = "Frame"; - const char* keyRadii = "Radii"; - const char* keySegmentsPerPatch = "SegmentsPerPatch"; - const char* keyLayers = "Layers"; - const char* keyShadowGroup = "ShadowGroup"; - const char* keyShadowSource = "Source"; - const char* keyShadowCaster = "Caster"; + constexpr const char* keyFrame = "Frame"; + constexpr const char* keyRadii = "Radii"; + constexpr const char* keySegmentsPerPatch = "SegmentsPerPatch"; + constexpr const char* keyLayers = "Layers"; + constexpr const char* keyShadowGroup = "ShadowGroup"; + constexpr const char* keyShadowSource = "Source"; + constexpr const char* keyShadowCaster = "Caster"; static const openspace::properties::Property::PropertyInfo SaveOrThrowInfo = { "SaveOrThrowCamera", @@ -234,8 +234,9 @@ RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary) _chunkedLodGlobe = std::make_shared( *this, patchSegments, - _layerManager - ); + _layerManager, + _ellipsoid + ); //_pointGlobe = std::make_shared(*this); _distanceSwitch.addSwitchValue(_chunkedLodGlobe); diff --git a/modules/globebrowsing/rendering/chunkrenderer.cpp b/modules/globebrowsing/rendering/chunkrenderer.cpp index 20c0e3d376..0219456f4d 100644 --- a/modules/globebrowsing/rendering/chunkrenderer.cpp +++ b/modules/globebrowsing/rendering/chunkrenderer.cpp @@ -41,19 +41,23 @@ namespace { namespace openspace::globebrowsing { ChunkRenderer::ChunkRenderer(std::shared_ptr grid, - std::shared_ptr layerManager) + std::shared_ptr layerManager, + Ellipsoid& ellipsoid) : _grid(grid) , _layerManager(layerManager) + , _ellipsoid(ellipsoid) { _globalLayerShaderManager = std::make_shared( - "GlobalChunkedLodPatch", - "${MODULE_GLOBEBROWSING}/shaders/globalchunkedlodpatch_vs.glsl", - "${MODULE_GLOBEBROWSING}/shaders/globalchunkedlodpatch_fs.glsl"); + "GlobalChunkedLodPatch", + "${MODULE_GLOBEBROWSING}/shaders/globalchunkedlodpatch_vs.glsl", + "${MODULE_GLOBEBROWSING}/shaders/globalchunkedlodpatch_fs.glsl" + ); _localLayerShaderManager = std::make_shared( - "LocalChunkedLodPatch", - "${MODULE_GLOBEBROWSING}/shaders/localchunkedlodpatch_vs.glsl", - "${MODULE_GLOBEBROWSING}/shaders/localchunkedlodpatch_fs.glsl"); + "LocalChunkedLodPatch", + "${MODULE_GLOBEBROWSING}/shaders/localchunkedlodpatch_vs.glsl", + "${MODULE_GLOBEBROWSING}/shaders/localchunkedlodpatch_fs.glsl" + ); _globalGpuLayerManager = std::make_shared(); _localGpuLayerManager = std::make_shared(); @@ -101,11 +105,20 @@ ghoul::opengl::ProgramObject* ChunkRenderer::getActivatedProgramWithTileData( gpuLayerManager->setValue(programObject, *_layerManager, tileIndex); // The length of the skirts is proportional to its size - // TODO: Skirt length should probably be proportional to the size reffered to by - // the chunk's most high resolution height map. - programObject->setUniform("skirtLength", - glm::min(static_cast(chunk.surfacePatch().halfSize().lat * 1000000), - 8700.0f)); + programObject->setUniform( + "skirtLength", + static_cast( + glm::min( + chunk.surfacePatch().halfSize().lat * 1000000, + _ellipsoid.minimumRadius() + ) + ) + ); + + //programObject->setUniform("skirtLength", + // glm::min(static_cast(chunk.surfacePatch().halfSize().lat * 1000000), + // 8700.0f)); + programObject->setUniform("xSegments", _grid->xSegments()); if (chunk.owner().debugProperties().showHeightResolution) { diff --git a/modules/globebrowsing/rendering/chunkrenderer.h b/modules/globebrowsing/rendering/chunkrenderer.h index d6b3c9227e..1a1c8aeffc 100644 --- a/modules/globebrowsing/rendering/chunkrenderer.h +++ b/modules/globebrowsing/rendering/chunkrenderer.h @@ -25,6 +25,7 @@ #ifndef __OPENSPACE_MODULE_GLOBEBROWSING___CHUNK_RENDERER___H__ #define __OPENSPACE_MODULE_GLOBEBROWSING___CHUNK_RENDERER___H__ +#include #include namespace ghoul::opengl { class ProgramObject; } @@ -42,8 +43,8 @@ class RenderableGlobe; class ChunkRenderer { public: - ChunkRenderer(std::shared_ptr grid, - std::shared_ptr layerManager); + ChunkRenderer(std::shared_ptr grid, std::shared_ptr layerManager, + Ellipsoid& ellipsoid); /** * Chooses to render a chunk either locally or globally depending on the chunklevel @@ -93,6 +94,8 @@ private: std::shared_ptr _grid; std::shared_ptr _layerManager; + Ellipsoid& _ellipsoid; + // Two different shader programs. One for global and one for local rendering. std::shared_ptr _globalLayerShaderManager; std::shared_ptr _localLayerShaderManager; From 233dc50a92650f64558a8dc5ac1b48163c572ba8 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 9 Apr 2018 14:25:40 -0400 Subject: [PATCH 07/17] Change the default FOV to 40 degrees (closes #590) --- scripts/configuration_helper.lua | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/configuration_helper.lua b/scripts/configuration_helper.lua index 28e47e634e..2b6bc60440 100644 --- a/scripts/configuration_helper.lua +++ b/scripts/configuration_helper.lua @@ -660,8 +660,8 @@ function sgct.config.single(arg) assert(type(arg["windowSize"][2]) == "number", "windowPos[2] must be a number") local ratio = arg["windowSize"][1] / arg["windowSize"][2] - local horizontalFov = 30 - local verticalFov = 30 + local horizontalFov = 40 + local verticalFov = 40 if (ratio > 1) then verticalFov = horizontalFov / ratio @@ -676,10 +676,14 @@ function sgct.config.single(arg) right = horizontalFov } else - arg["fov"] = { down = 16.875, up = 16.875, left = 30.0, right = 30.0 } + arg["fov"] = { down = 22.5, up = 22.5, left = 40.0, right = 40.0 } end end + assert( + type(arg["tracked"]) == "boolean" or type(arg["tracked"]) == "nil", + "tracked must be a boolean or nil" + ) if (arg["tracked"] ~= nil and arg["tracked"] == true) then trackedSpecifier = "tracked=\"true\"" else From 62eca12e25cbccf464a52f7d3328f75592a518f9 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 9 Apr 2018 14:33:02 -0400 Subject: [PATCH 08/17] Enable 'tracked' viewports on default --- openspace.cfg | 8 ++++---- scripts/configuration_helper.lua | 9 +++++---- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/openspace.cfg b/openspace.cfg index 160919cb3a..c50197e970 100644 --- a/openspace.cfg +++ b/openspace.cfg @@ -7,13 +7,13 @@ return { -- occurs in a single window, a fisheye projection, or a dome cluster system -- A regular 1280x720 window - SGCTConfig = sgct.config.single{tracked=true}, + SGCTConfig = sgct.config.single{}, -- A regular 1920x1080 window - -- SGCTConfig = sgct.config.single{1920, 1080, tracked=true}, + -- SGCTConfig = sgct.config.single{1920, 1080}, -- A windowed 1920x1080 fullscreen - -- SGCTConfig = sgct.config.single{1920, 1080, border=false, windowPos={0,0}, shared=true, name="WV_OBS_SPOUT1", tracked=true}, + -- SGCTConfig = sgct.config.single{1920, 1080, border=false, windowPos={0,0}, shared=true, name="WV_OBS_SPOUT1"}, -- A 1k fisheye rendering -- SGCTConfig = sgct.config.fisheye{1024, 1024}, @@ -22,7 +22,7 @@ return { -- SGCTConfig = sgct.config.fisheye{1024, 1024, res={4096, 4096}, quality="2k", tilt=27}, -- Streaming OpenSpace via Spout to OBS - -- SGCTConfig = sgct.config.single{2560, 1440, shared=true, name="WV_OBS_SPOUT1", tracked=true}, + -- SGCTConfig = sgct.config.single{2560, 1440, shared=true, name="WV_OBS_SPOUT1"}, -- SGCTConfig = "${CONFIG}/spout_output.xml", diff --git a/scripts/configuration_helper.lua b/scripts/configuration_helper.lua index 2b6bc60440..9002ef9222 100644 --- a/scripts/configuration_helper.lua +++ b/scripts/configuration_helper.lua @@ -39,7 +39,8 @@ function sgct.makeConfig(config) end -- [example: scene = {offset = {x = 1.0, y = 1.0, z = 2.0}, orientation = { yaw = 120, pitch = 15, roll = 0.0 }, scale = 10.0}] -- capture: Settings to configure the image capture [example: capture = { path = "./images"] -- sgctDebug: Determines whether a higher debug level in SGCT is enabled [example: sgctDebug=true] {default: false} --- fov: The field of view settings [example: fov={ left=20, right=30, up=10, down=50}] {default: { left=30.0, right=30.0, up=16.875, down=16.875}} +-- fov: The field of view settings [example: fov={ left=20, right=30, up=10, down=50}] {default: { left=40.0, right=40.0, up=22.5, down=22.5}} +-- tracked: Determines whether the aspect ratio of the camera defined at application startup should persist when the window is resized [example: tracked=false] {default: true} -- Thus this function can be called the following ways: -- sgct.config.single() -> Leading to a 1280x720 resolution window @@ -684,9 +685,9 @@ function sgct.config.single(arg) type(arg["tracked"]) == "boolean" or type(arg["tracked"]) == "nil", "tracked must be a boolean or nil" ) - if (arg["tracked"] ~= nil and arg["tracked"] == true) then - trackedSpecifier = "tracked=\"true\"" - else + trackedSpecifier = "tracked=\"true\"" + + if (arg["tracked"] ~= nil and arg["tracked"] == false) then trackedSpecifier = "tracked=\"false\"" end From 34987e9f853ec9bcd791b197743329888adc7433 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 10 Apr 2018 15:04:41 -0400 Subject: [PATCH 09/17] Prevent floating point over- and underflows; specifically when interpolating the camera position (closes #575) --- include/openspace/scene/scenegraphnode.h | 2 +- .../rendering/atmospheredeferredcaster.cpp | 8 +++++++- .../chunk/culling/horizonculler.cpp | 20 +++++++++++++------ .../globebrowsing/rendering/chunkrenderer.cpp | 7 +++++-- src/interaction/luaconsole.cpp | 13 +++++++++--- src/interaction/orbitalnavigator.cpp | 6 +++++- src/rendering/renderable.cpp | 1 + src/scene/scenegraphnode.cpp | 11 +++++----- 8 files changed, 49 insertions(+), 19 deletions(-) diff --git a/include/openspace/scene/scenegraphnode.h b/include/openspace/scene/scenegraphnode.h index 65f497f33a..fc93581281 100644 --- a/include/openspace/scene/scenegraphnode.h +++ b/include/openspace/scene/scenegraphnode.h @@ -173,7 +173,7 @@ private: // Cached transform data glm::dvec3 _worldPositionCached; glm::dmat3 _worldRotationCached; - double _worldScaleCached; + double _worldScaleCached = 1.0; glm::dmat4 _modelTransformCached; glm::dmat4 _inverseModelTransformCached; diff --git a/modules/atmosphere/rendering/atmospheredeferredcaster.cpp b/modules/atmosphere/rendering/atmospheredeferredcaster.cpp index 11d81184e1..21692091ec 100644 --- a/modules/atmosphere/rendering/atmospheredeferredcaster.cpp +++ b/modules/atmosphere/rendering/atmospheredeferredcaster.cpp @@ -292,7 +292,13 @@ void AtmosphereDeferredcaster::preRaycast(const RenderData& renderData, } // Sun Position in Object Space - program.setUniform(_uniformCache2.sunDirectionObj, glm::normalize(glm::dvec3(sunPosObj))); + const double l = glm::length(glm::dvec3(sunPosObj)); + program.setUniform( + _uniformCache2.sunDirectionObj, + l > 0.0 ? + glm::normalize(glm::dvec3(sunPosObj)) : + glm::dvec3(0.0) + ); // Shadow calculations.. if (!_shadowConfArray.empty()) { diff --git a/modules/globebrowsing/chunk/culling/horizonculler.cpp b/modules/globebrowsing/chunk/culling/horizonculler.cpp index 79fb3a4080..87c1bb0926 100644 --- a/modules/globebrowsing/chunk/culling/horizonculler.cpp +++ b/modules/globebrowsing/chunk/culling/horizonculler.cpp @@ -85,13 +85,21 @@ bool HorizonCuller::isCullable(const glm::dvec3& cameraPosition, double objectBoundingSphereRadius, double minimumGlobeRadius) { - double distanceToHorizon = - sqrt(pow(length(cameraPosition - globePosition), 2) - - pow(minimumGlobeRadius, 2)); + const double objectP = pow(length(objectPosition - globePosition), 2); + const double horizonP = pow(minimumGlobeRadius - objectBoundingSphereRadius, 2); + if (objectP < horizonP) { + return false; + } - double minimumAllowedDistanceToObjectFromHorizon = sqrt( - pow(length(objectPosition - globePosition), 2) - - pow(minimumGlobeRadius - objectBoundingSphereRadius, 2)); + const double cameraP = pow(length(cameraPosition - globePosition), 2); + const double minR = pow(minimumGlobeRadius, 2); + if (cameraP < minR) { + return false; + } + + + double minimumAllowedDistanceToObjectFromHorizon = sqrt(objectP - horizonP); + double distanceToHorizon = sqrt(cameraP - minR); // Minimum allowed for the object to be occluded double minimumAllowedDistanceToObjectSquared = diff --git a/modules/globebrowsing/rendering/chunkrenderer.cpp b/modules/globebrowsing/rendering/chunkrenderer.cpp index 0219456f4d..f9e452a4fb 100644 --- a/modules/globebrowsing/rendering/chunkrenderer.cpp +++ b/modules/globebrowsing/rendering/chunkrenderer.cpp @@ -271,8 +271,11 @@ void ChunkRenderer::setCommonUniforms(ghoul::opengl::ProgramObject& programObjec chunk.owner().generalProperties().atmosphereEnabled || chunk.owner().generalProperties().performShading) { - glm::vec3 directionToSunWorldSpace = - glm::normalize(-data.modelTransform.translation); + glm::dvec3 directionToSunWorldSpace = + length(data.modelTransform.translation) > 0.0 ? + glm::normalize(-data.modelTransform.translation) : + glm::dvec3(0.0); + glm::vec3 directionToSunCameraSpace = glm::vec3(viewTransform * glm::dvec4(directionToSunWorldSpace, 0)); programObject.setUniform( diff --git a/src/interaction/luaconsole.cpp b/src/interaction/luaconsole.cpp index f1da932d49..d87905c31c 100644 --- a/src/interaction/luaconsole.cpp +++ b/src/interaction/luaconsole.cpp @@ -641,15 +641,22 @@ void LuaConsole::update() { _fullHeight = (bbox.boundingBox.y + EntryFontSize + SeparatorSpace); _targetHeight = _isVisible ? _fullHeight : 0; - const float frametime = static_cast(OsEng.windowWrapper().deltaTime()); + // The first frame is going to be finished in approx 10 us, which causes a floating + // point overflow when computing dHeight + const double frametime = std::max( + OsEng.windowWrapper().deltaTime(), + 1e-4 + ); // Update the current height. // The current height is the offset that is used to slide // the console in from the top. const glm::ivec2 res = OsEng.windowWrapper().currentWindowResolution(); const glm::vec2 dpiScaling = OsEng.windowWrapper().dpiScaling(); - _currentHeight += (_targetHeight - _currentHeight) * - std::pow(0.98f, 1.f / (ConsoleOpenSpeed / dpiScaling.y * frametime)); + const double dHeight = (_targetHeight - _currentHeight) * + std::pow(0.98, 1.0 / (ConsoleOpenSpeed / dpiScaling.y * frametime)); + + _currentHeight += static_cast(dHeight); _currentHeight = std::max(0.0f, _currentHeight); _currentHeight = std::min(static_cast(res.y), _currentHeight); diff --git a/src/interaction/orbitalnavigator.cpp b/src/interaction/orbitalnavigator.cpp index 6642f22ebe..29de597abe 100644 --- a/src/interaction/orbitalnavigator.cpp +++ b/src/interaction/orbitalnavigator.cpp @@ -377,7 +377,11 @@ glm::dquat OrbitalNavigator::interpolateLocalRotation(double deltaTime, localCameraRotation, glm::dquat(glm::dvec3(0.0)), glm::min(t * _rotateToFocusNodeInterpolator.deltaTimeScaled(), 1.0)); - if (angle(result) < 0.01) { + + // Retrieving the angle of a quaternion uses acos on the w component, which can + // have numerical instability for values close to 1.0 + constexpr double Epsilon = 1.0e-13; + if (abs((abs(result.w) - 1.0)) < Epsilon || angle(result) < 0.01) { _rotateToFocusNodeInterpolator.end(); } return result; diff --git a/src/rendering/renderable.cpp b/src/rendering/renderable.cpp index 3693b4ed2f..97576bbca5 100644 --- a/src/rendering/renderable.cpp +++ b/src/rendering/renderable.cpp @@ -107,6 +107,7 @@ Renderable::Renderable(const ghoul::Dictionary& dictionary) , _enabled(EnabledInfo, true) , _opacity(OpacityInfo, 1.f, 0.f, 1.f) , _renderBin(RenderBin::Opaque) + , _boundingSphere(0.f) , _startTime("") , _endTime("") , _hasTimeInterval(false) diff --git a/src/scene/scenegraphnode.cpp b/src/scene/scenegraphnode.cpp index 84f720dfc5..6396222e34 100644 --- a/src/scene/scenegraphnode.cpp +++ b/src/scene/scenegraphnode.cpp @@ -585,11 +585,12 @@ bool SceneGraphNode::hasGuiHintHidden() const { glm::dvec3 SceneGraphNode::calculateWorldPosition() const { // recursive up the hierarchy if there are parents available if (_parent) { - return - _parent->calculateWorldPosition() + - _parent->worldRotationMatrix() * - _parent->worldScale() * - position(); + const glm::dvec3 wp = _parent->calculateWorldPosition(); + const glm::dmat3 wrot = _parent->worldRotationMatrix(); + const double ws = _parent->worldScale(); + const glm::dvec3 p = position(); + + return wp + wrot * ws * p; } else { return position(); From 40dbf875c57beae888d93a87900d05875b6ff9f9 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 10 Apr 2018 15:55:52 -0400 Subject: [PATCH 10/17] Issue/525 (#593) * Add initializeGL and deinitializeGL methods to OpenSpaceModule Call releaseAll from ProgramObjectManager in deinitializeGL to guard against errors when deinitializing assets * Change removeProgramObject function in RenderEngine to take a non-owning pointer instead of a reference to a unique pointer to make it compatible with the ProgramObjectManager Update Ghoul repository * Using ProgramObjectManager in more modules to reduce the number of programs compiled at startup --- ext/sgct | 2 +- include/openspace/engine/moduleengine.h | 10 + include/openspace/rendering/renderengine.h | 3 +- include/openspace/util/openspacemodule.h | 27 ++- modules/base/basemodule.cpp | 6 + modules/base/basemodule.h | 5 + modules/base/rendering/renderablemodel.cpp | 29 ++- modules/base/rendering/renderablemodel.h | 2 +- modules/base/rendering/renderableplane.cpp | 30 ++- modules/base/rendering/renderableplane.h | 2 +- modules/base/rendering/renderablesphere.cpp | 30 ++- modules/base/rendering/renderablesphere.h | 2 +- .../rendering/renderablesphericalgrid.cpp | 24 ++- .../base/rendering/renderablesphericalgrid.h | 2 +- modules/base/rendering/renderabletrail.cpp | 32 +-- modules/base/rendering/renderabletrail.h | 2 +- .../rendering/renderabledebugplane.cpp | 2 +- .../digitaluniverse/digitaluniversemodule.cpp | 6 + .../digitaluniverse/digitaluniversemodule.h | 5 + .../rendering/renderablebillboardscloud.cpp | 71 ++++--- .../rendering/renderablebillboardscloud.h | 4 +- .../rendering/renderabledumeshes.cpp | 28 ++- .../rendering/renderabledumeshes.h | 2 +- .../rendering/renderableplanescloud.cpp | 30 ++- .../rendering/renderableplanescloud.h | 191 +++++++++--------- .../rendering/renderablepoints.cpp | 46 +++-- .../rendering/renderablepoints.h | 2 +- .../rendering/renderablefieldlines.cpp | 2 +- .../renderablefieldlinessequence.cpp | 2 +- .../rendering/layershadermanager.cpp | 4 +- modules/iswa/rendering/iswacygnet.cpp | 2 +- .../renderableconstellationbounds.cpp | 2 +- modules/space/rendering/renderableplanet.cpp | 95 +++++---- modules/space/rendering/renderableplanet.h | 2 +- modules/space/rendering/renderablerings.cpp | 2 +- modules/space/rendering/renderablestars.cpp | 2 +- modules/space/spacemodule.cpp | 6 + modules/space/spacemodule.h | 5 + .../rendering/renderablecrawlingline.cpp | 2 +- .../rendering/renderablefov.cpp | 29 ++- .../rendering/renderablefov.h | 2 +- .../rendering/renderablemodelprojection.cpp | 2 +- .../rendering/renderableplaneprojection.cpp | 2 +- .../rendering/renderableplanetprojection.cpp | 96 +++++---- .../rendering/renderableplanetprojection.h | 4 +- .../rendering/renderableshadowcylinder.cpp | 37 ++-- .../rendering/renderableshadowcylinder.h | 2 +- .../spacecraftinstrumentsmodule.cpp | 6 + .../spacecraftinstrumentsmodule.h | 5 + modules/touch/src/touchmarker.cpp | 2 +- src/engine/moduleengine.cpp | 21 ++ src/engine/openspaceengine.cpp | 3 + src/rendering/renderengine.cpp | 7 +- src/rendering/screenspacerenderable.cpp | 2 +- src/util/openspacemodule.cpp | 12 ++ 55 files changed, 621 insertions(+), 332 deletions(-) diff --git a/ext/sgct b/ext/sgct index 0f689a49a8..52e2943cd7 160000 --- a/ext/sgct +++ b/ext/sgct @@ -1 +1 @@ -Subproject commit 0f689a49a8d0e47cdba9d57b9b9cf5e98fb7847a +Subproject commit 52e2943cd74bb8346db0411bf17ed3dab4245e03 diff --git a/include/openspace/engine/moduleengine.h b/include/openspace/engine/moduleengine.h index 1ad4f7af11..57f6766e63 100644 --- a/include/openspace/engine/moduleengine.h +++ b/include/openspace/engine/moduleengine.h @@ -61,12 +61,22 @@ public: */ void initialize(const ghoul::Dictionary& moduleConfigurations); + /** + * Calls the initializeGL functions of all registered OpenSpaceModule%s. + */ + void initializeGL(); + /** * Deinitializes all of the contained OpenSpaceModule%s by calling the * OpenSpaceModule::deinitialize methods. */ void deinitialize(); + /** + * Calls the deinitializeGL functions of all registered OpenSpaceModule%s. + */ + void deinitializeGL(); + /** * Registers the passed \p module with this ModuleEngine. The OpenSpaceModule::create * method will be called on the \p module in the process. diff --git a/include/openspace/rendering/renderengine.h b/include/openspace/rendering/renderengine.h index ce6c09331f..5438b6d194 100644 --- a/include/openspace/rendering/renderengine.h +++ b/include/openspace/rendering/renderengine.h @@ -120,8 +120,7 @@ public: std::string csPath, const ghoul::Dictionary& dictionary = ghoul::Dictionary()); - void removeRenderProgram( - const std::unique_ptr& program); + void removeRenderProgram(ghoul::opengl::ProgramObject* program); /** * Set raycasting uniforms on the program object, and setup raycasting. diff --git a/include/openspace/util/openspacemodule.h b/include/openspace/util/openspacemodule.h index 23ea912f7a..bf2baa36c5 100644 --- a/include/openspace/util/openspacemodule.h +++ b/include/openspace/util/openspacemodule.h @@ -66,7 +66,13 @@ public: * internalInitialize method for further customization for each subclass. */ void initialize(const ModuleEngine* moduleEngine, - const ghoul::Dictionary& configuration); + const ghoul::Dictionary& configuration); + + /** + * This method calls the internalInitializeGL method for further customization for + * each subclass. + */ + void initializeGL(); /** * Empty deinitialization method that will call the internalDeinitialize method for @@ -74,6 +80,11 @@ public: */ void deinitialize(); + /** + * This method will call the internalDeinitializeGL method for each subclass. + */ + void deinitializeGL(); + /** * Returns a list of Documentation classes that are valid for this OpenSpaceModule. * \return A list of Documentation classes that are valid for this OpenSapceModule @@ -112,12 +123,26 @@ protected: */ virtual void internalInitialize(const ghoul::Dictionary& configuration); + /** + * Customization point for each derived class. The internalInitializeGL method is + * called by the initializeGL method at a time when a valid OpenGL state is + * guaranteed. + */ + virtual void internalInitializeGL(); + /** * Customization point for each derived class. The internalDeinitialize method is * called by the deinitialize method. */ virtual void internalDeinitialize(); + /** + * Customization point for each derived class. The internalDeinitializeGL method is + * called by the deinitializeGL method at a time when a valid OpenGL state is + * guaranteed. + */ + virtual void internalDeinitializeGL(); + /** * Returns the path for this module, possibly containing ghoul::filesystem::FileSystem * path tokens. diff --git a/modules/base/basemodule.cpp b/modules/base/basemodule.cpp index 2d39afc6bf..964720eb10 100644 --- a/modules/base/basemodule.cpp +++ b/modules/base/basemodule.cpp @@ -66,6 +66,8 @@ namespace openspace { +ghoul::opengl::ProgramObjectManager BaseModule::ProgramObjectManager; + BaseModule::BaseModule() : OpenSpaceModule(BaseModule::Name) {} void BaseModule::internalInitialize(const ghoul::Dictionary&) { @@ -137,6 +139,10 @@ void BaseModule::internalInitialize(const ghoul::Dictionary&) { fGeometry->registerClass("MultiModelGeometry"); } +void BaseModule::internalDeinitializeGL() { + ProgramObjectManager.releaseAll(ghoul::opengl::ProgramObjectManager::Warnings::Yes); +} + std::vector BaseModule::documentations() const { return { DashboardItemDate::Documentation(), diff --git a/modules/base/basemodule.h b/modules/base/basemodule.h index 28675841a0..30064dced0 100644 --- a/modules/base/basemodule.h +++ b/modules/base/basemodule.h @@ -27,6 +27,8 @@ #include +#include + namespace openspace { class BaseModule : public OpenSpaceModule { @@ -39,8 +41,11 @@ public: std::vector documentations() const override; std::vector luaLibraries() const override; + static ghoul::opengl::ProgramObjectManager ProgramObjectManager; + protected: void internalInitialize(const ghoul::Dictionary&) override; + void internalDeinitializeGL() override; }; } // namespace openspace diff --git a/modules/base/rendering/renderablemodel.cpp b/modules/base/rendering/renderablemodel.cpp index 25dc829a86..a59d9b850d 100644 --- a/modules/base/rendering/renderablemodel.cpp +++ b/modules/base/rendering/renderablemodel.cpp @@ -24,8 +24,8 @@ #include +#include #include - #include #include #include @@ -43,7 +43,8 @@ #include namespace { - const char* KeyGeometry = "Geometry"; + constexpr const char* ProgramName = "ModelProgram"; + constexpr const char* KeyGeometry = "Geometry"; static const openspace::properties::Property::PropertyInfo TextureInfo = { "ColorTexture", @@ -154,10 +155,15 @@ bool RenderableModel::isReady() const { } void RenderableModel::initializeGL() { - _programObject = OsEng.renderEngine().buildRenderProgram( - "ModelProgram", - absPath("${MODULE_BASE}/shaders/model_vs.glsl"), - absPath("${MODULE_BASE}/shaders/model_fs.glsl") + _programObject = BaseModule::ProgramObjectManager.requestProgramObject( + ProgramName, + []() -> std::unique_ptr { + return OsEng.renderEngine().buildRenderProgram( + ProgramName, + absPath("${MODULE_BASE}/shaders/model_vs.glsl"), + absPath("${MODULE_BASE}/shaders/model_fs.glsl") + ); + } ); _uniformCache.opacity = _programObject->uniformLocation("opacity"); @@ -188,10 +194,13 @@ void RenderableModel::deinitializeGL() { } _texture = nullptr; - if (_programObject) { - OsEng.renderEngine().removeRenderProgram(_programObject); - _programObject = nullptr; - } + BaseModule::ProgramObjectManager.releaseProgramObject( + ProgramName, + [](ghoul::opengl::ProgramObject* p) { + OsEng.renderEngine().removeRenderProgram(p); + } + ); + _programObject = nullptr; } void RenderableModel::render(const RenderData& data, RendererTasks&) { diff --git a/modules/base/rendering/renderablemodel.h b/modules/base/rendering/renderablemodel.h index 37d41a86e5..e72463d7da 100644 --- a/modules/base/rendering/renderablemodel.h +++ b/modules/base/rendering/renderablemodel.h @@ -73,7 +73,7 @@ private: properties::BoolProperty _performShading; properties::Mat3Property _modelTransform; - std::unique_ptr _programObject; + ghoul::opengl::ProgramObject* _programObject; UniformCache(opacity, directionToSunViewSpace, modelViewTransform, projectionTransform, performShading, texture) _uniformCache; diff --git a/modules/base/rendering/renderableplane.cpp b/modules/base/rendering/renderableplane.cpp index 91c9da3816..3562b480b1 100644 --- a/modules/base/rendering/renderableplane.cpp +++ b/modules/base/rendering/renderableplane.cpp @@ -24,6 +24,7 @@ #include +#include #include #include #include @@ -39,6 +40,8 @@ #include namespace { + constexpr const char* ProgramName = "Plane"; + enum BlendMode { BlendModeNormal = 0, BlendModeAdditive @@ -164,11 +167,16 @@ void RenderablePlane::initializeGL() { glGenBuffers(1, &_vertexPositionBuffer); // generate buffer createPlane(); - _shader = OsEng.renderEngine().buildRenderProgram( - "PlaneProgram", - absPath("${MODULE_BASE}/shaders/plane_vs.glsl"), - absPath("${MODULE_BASE}/shaders/plane_fs.glsl") - ); + _shader = BaseModule::ProgramObjectManager.requestProgramObject( + ProgramName, + []() -> std::unique_ptr { + return OsEng.renderEngine().buildRenderProgram( + ProgramName, + absPath("${MODULE_BASE}/shaders/plane_vs.glsl"), + absPath("${MODULE_BASE}/shaders/plane_fs.glsl") + ); + } + ); } void RenderablePlane::deinitializeGL() { @@ -178,11 +186,13 @@ void RenderablePlane::deinitializeGL() { glDeleteBuffers(1, &_vertexPositionBuffer); _vertexPositionBuffer = 0; - RenderEngine& renderEngine = OsEng.renderEngine(); - if (_shader) { - renderEngine.removeRenderProgram(_shader); - _shader = nullptr; - } + BaseModule::ProgramObjectManager.releaseProgramObject( + ProgramName, + [](ghoul::opengl::ProgramObject* p) { + OsEng.renderEngine().removeRenderProgram(p); + } + ); + _shader = nullptr; } void RenderablePlane::render(const RenderData& data, RendererTasks&) { diff --git a/modules/base/rendering/renderableplane.h b/modules/base/rendering/renderableplane.h index 5ccbc153da..e2a5d6d1a9 100644 --- a/modules/base/rendering/renderableplane.h +++ b/modules/base/rendering/renderableplane.h @@ -73,7 +73,7 @@ private: properties::FloatProperty _size; properties::OptionProperty _blendMode; - std::unique_ptr _shader; + ghoul::opengl::ProgramObject* _shader; GLuint _quad; GLuint _vertexPositionBuffer; diff --git a/modules/base/rendering/renderablesphere.cpp b/modules/base/rendering/renderablesphere.cpp index e2dbe510b9..4f4478df35 100644 --- a/modules/base/rendering/renderablesphere.cpp +++ b/modules/base/rendering/renderablesphere.cpp @@ -24,6 +24,7 @@ #include +#include #include #include #include @@ -39,6 +40,8 @@ #include namespace { + constexpr const char* ProgramName = "Sphere"; + enum Orientation { Outside = 1, Inside = 2 @@ -238,11 +241,15 @@ void RenderableSphere::initializeGL() { ); _sphere->initialize(); - // pscstandard - _shader = OsEng.renderEngine().buildRenderProgram( - "Sphere", - absPath("${MODULE_BASE}/shaders/sphere_vs.glsl"), - absPath("${MODULE_BASE}/shaders/sphere_fs.glsl") + _shader = BaseModule::ProgramObjectManager.requestProgramObject( + ProgramName, + []() -> std::unique_ptr { + return OsEng.renderEngine().buildRenderProgram( + ProgramName, + absPath("${MODULE_BASE}/shaders/sphere_vs.glsl"), + absPath("${MODULE_BASE}/shaders/sphere_fs.glsl") + ); + } ); _uniformCache.opacity = _shader->uniformLocation("opacity"); @@ -256,10 +263,13 @@ void RenderableSphere::initializeGL() { void RenderableSphere::deinitializeGL() { _texture = nullptr; - if (_shader) { - OsEng.renderEngine().removeRenderProgram(_shader); - _shader = nullptr; - } + BaseModule::ProgramObjectManager.releaseProgramObject( + ProgramName, + [](ghoul::opengl::ProgramObject* p) { + OsEng.renderEngine().removeRenderProgram(p); + } + ); + _shader = nullptr; } void RenderableSphere::render(const RenderData& data, RendererTasks&) { @@ -275,7 +285,7 @@ void RenderableSphere::render(const RenderData& data, RendererTasks&) { _shader->setUniform(_uniformCache.viewProjection, data.camera.viewProjectionMatrix()); _shader->setUniform(_uniformCache.modelTransform, transform); - setPscUniforms(*_shader.get(), data.camera, data.position); + setPscUniforms(*_shader, data.camera, data.position); float adjustedTransparency = _opacity; diff --git a/modules/base/rendering/renderablesphere.h b/modules/base/rendering/renderablesphere.h index f8fbf0984b..e7b4eda891 100644 --- a/modules/base/rendering/renderablesphere.h +++ b/modules/base/rendering/renderablesphere.h @@ -74,7 +74,7 @@ private: float _fadeOutThreshold; float _fadeInThreshold; - std::unique_ptr _shader; + ghoul::opengl::ProgramObject* _shader; std::unique_ptr _texture; std::unique_ptr _sphere; diff --git a/modules/base/rendering/renderablesphericalgrid.cpp b/modules/base/rendering/renderablesphericalgrid.cpp index e56d8eb140..e59f0a274e 100644 --- a/modules/base/rendering/renderablesphericalgrid.cpp +++ b/modules/base/rendering/renderablesphericalgrid.cpp @@ -24,6 +24,7 @@ #include +#include #include #include #include @@ -36,6 +37,8 @@ #include namespace { + constexpr const char* ProgramName = "GridProgram"; + static const openspace::properties::Property::PropertyInfo GridColorInfo = { "GridColor", "Grid Color", @@ -182,10 +185,15 @@ bool RenderableSphericalGrid::isReady() const { } void RenderableSphericalGrid::initializeGL() { - _gridProgram = OsEng.renderEngine().buildRenderProgram( - "GridProgram", - absPath("${MODULE_BASE}/shaders/grid_vs.glsl"), - absPath("${MODULE_BASE}/shaders/grid_fs.glsl") + _gridProgram = BaseModule::ProgramObjectManager.requestProgramObject( + ProgramName, + []() -> std::unique_ptr { + return OsEng.renderEngine().buildRenderProgram( + ProgramName, + absPath("${MODULE_BASE}/shaders/grid_vs.glsl"), + absPath("${MODULE_BASE}/shaders/grid_fs.glsl") + ); + } ); glGenVertexArrays(1, &_vaoID); @@ -208,6 +216,14 @@ void RenderableSphericalGrid::deinitializeGL() { glDeleteBuffers(1, &_iBufferID); _iBufferID = 0; + + BaseModule::ProgramObjectManager.releaseProgramObject( + ProgramName, + [](ghoul::opengl::ProgramObject* p) { + OsEng.renderEngine().removeRenderProgram(p); + } + ); + _gridProgram = nullptr; } void RenderableSphericalGrid::render(const RenderData& data, RendererTasks&){ diff --git a/modules/base/rendering/renderablesphericalgrid.h b/modules/base/rendering/renderablesphericalgrid.h index d8c7ac1376..c854f1c7e0 100644 --- a/modules/base/rendering/renderablesphericalgrid.h +++ b/modules/base/rendering/renderablesphericalgrid.h @@ -63,7 +63,7 @@ protected: float location[3]; }; - std::unique_ptr _gridProgram; + ghoul::opengl::ProgramObject* _gridProgram; properties::DMat4Property _gridMatrix; properties::Vec4Property _gridColor; diff --git a/modules/base/rendering/renderabletrail.cpp b/modules/base/rendering/renderabletrail.cpp index 5ee7b0a2be..1cfc4d3ef0 100644 --- a/modules/base/rendering/renderabletrail.cpp +++ b/modules/base/rendering/renderabletrail.cpp @@ -24,6 +24,7 @@ #include +#include #include #include #include @@ -35,7 +36,8 @@ #include namespace { - const char* KeyTranslation = "Translation"; + constexpr const char* ProgramName = "EphemerisProgram"; + constexpr const char* KeyTranslation = "Translation"; // The possible values for the _renderingModes property enum RenderingMode { @@ -222,11 +224,15 @@ RenderableTrail::RenderableTrail(const ghoul::Dictionary& dictionary) } void RenderableTrail::initializeGL() { - RenderEngine& renderEngine = OsEng.renderEngine(); - _programObject = renderEngine.buildRenderProgram( - "EphemerisProgram", - absPath("${MODULE_BASE}/shaders/renderabletrail_vs.glsl"), - absPath("${MODULE_BASE}/shaders/renderabletrail_fs.glsl") + _programObject = BaseModule::ProgramObjectManager.requestProgramObject( + ProgramName, + []() -> std::unique_ptr { + return OsEng.renderEngine().buildRenderProgram( + ProgramName, + absPath("${MODULE_BASE}/shaders/renderabletrail_vs.glsl"), + absPath("${MODULE_BASE}/shaders/renderabletrail_fs.glsl") + ); + } ); _uniformCache.opacity = _programObject->uniformLocation("opacity"); @@ -246,11 +252,13 @@ void RenderableTrail::initializeGL() { } void RenderableTrail::deinitializeGL() { - RenderEngine& renderEngine = OsEng.renderEngine(); - if (_programObject) { - renderEngine.removeRenderProgram(_programObject); - _programObject = nullptr; - } + BaseModule::ProgramObjectManager.releaseProgramObject( + ProgramName, + [](ghoul::opengl::ProgramObject* p) { + OsEng.renderEngine().removeRenderProgram(p); + } + ); + _programObject = nullptr; } bool RenderableTrail::isReady() const { @@ -305,7 +313,7 @@ void RenderableTrail::render(const RenderData& data, RendererTasks&) { glEnable(GL_PROGRAM_POINT_SIZE); } - auto render = [renderLines, renderPoints, p = _programObject.get(), &data, + auto render = [renderLines, renderPoints, p = _programObject, &data, &modelTransform, pointSize = _pointSize.value(), c = _uniformCache] (RenderInformation& info, int nVertices, int offset) { diff --git a/modules/base/rendering/renderabletrail.h b/modules/base/rendering/renderabletrail.h index 62ea0d466d..c3b8b3091d 100644 --- a/modules/base/rendering/renderabletrail.h +++ b/modules/base/rendering/renderabletrail.h @@ -158,7 +158,7 @@ private: properties::OptionProperty _renderingModes; /// Program object used to render the data stored in RenderInformation - std::unique_ptr _programObject; + ghoul::opengl::ProgramObject* _programObject; UniformCache(opacity, modelView, projection, color, useLineFade, lineFade, vertexSorting, idOffset, nVertices, stride, pointSize, renderPhase) _uniformCache; diff --git a/modules/debugging/rendering/renderabledebugplane.cpp b/modules/debugging/rendering/renderabledebugplane.cpp index f7d884ce1d..8943e88229 100644 --- a/modules/debugging/rendering/renderabledebugplane.cpp +++ b/modules/debugging/rendering/renderabledebugplane.cpp @@ -213,7 +213,7 @@ void RenderableDebugPlane::deinitializeGL() { RenderEngine& renderEngine = OsEng.renderEngine(); if (_shader) { - renderEngine.removeRenderProgram(_shader); + renderEngine.removeRenderProgram(_shader.get()); _shader = nullptr; } } diff --git a/modules/digitaluniverse/digitaluniversemodule.cpp b/modules/digitaluniverse/digitaluniversemodule.cpp index 24b052a374..340fc3403b 100644 --- a/modules/digitaluniverse/digitaluniversemodule.cpp +++ b/modules/digitaluniverse/digitaluniversemodule.cpp @@ -40,6 +40,8 @@ namespace openspace { +ghoul::opengl::ProgramObjectManager DigitalUniverseModule::ProgramObjectManager; + DigitalUniverseModule::DigitalUniverseModule() : OpenSpaceModule(DigitalUniverseModule::Name) {} @@ -54,6 +56,10 @@ void DigitalUniverseModule::internalInitialize(const ghoul::Dictionary&) { fRenderable->registerClass("RenderableDUMeshes"); } +void DigitalUniverseModule::internalDeinitializeGL() { + ProgramObjectManager.releaseAll(ghoul::opengl::ProgramObjectManager::Warnings::Yes); +} + std::vector DigitalUniverseModule::documentations() const { return { RenderablePoints::Documentation(), diff --git a/modules/digitaluniverse/digitaluniversemodule.h b/modules/digitaluniverse/digitaluniversemodule.h index a4a15fe557..cff672cebd 100644 --- a/modules/digitaluniverse/digitaluniversemodule.h +++ b/modules/digitaluniverse/digitaluniversemodule.h @@ -27,6 +27,8 @@ #include +#include + namespace openspace { class DigitalUniverseModule : public OpenSpaceModule { @@ -37,8 +39,11 @@ public: virtual ~DigitalUniverseModule() = default; std::vector documentations() const override; + static ghoul::opengl::ProgramObjectManager ProgramObjectManager; + protected: void internalInitialize(const ghoul::Dictionary&) override; + void internalDeinitializeGL() override; }; } // namespace openspace diff --git a/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp b/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp index dcac27b3f1..39503c6f0a 100644 --- a/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp +++ b/modules/digitaluniverse/rendering/renderablebillboardscloud.cpp @@ -24,12 +24,12 @@ #include +#include #include #include #include #include #include - #include #include #include @@ -39,10 +39,8 @@ #include #include #include - #include #include - #include #include #include @@ -51,6 +49,9 @@ namespace { constexpr const char* _loggerCat = "RenderableBillboardsCloud"; + constexpr const char* ProgramObjectName = "RenderableBillboardsCloud"; + constexpr const char* RenderToPolygonProgram = "RenderableBillboardsCloud_Polygon"; + constexpr const char* KeyFile = "File"; constexpr const char* keyColor = "Color"; constexpr const char* keyUnit = "Unit"; @@ -391,6 +392,7 @@ RenderableBillboardsCloud::RenderableBillboardsCloud(const ghoul::Dictionary& di , _polygonTexture(nullptr) , _spriteTexture(nullptr) , _program(nullptr) + , _renderToPolygonProgram(nullptr) , _font(nullptr) , _speckFile("") , _colorMapFile("") @@ -623,15 +625,32 @@ void RenderableBillboardsCloud::initialize() { } void RenderableBillboardsCloud::initializeGL() { - RenderEngine& renderEngine = OsEng.renderEngine(); - - _program = renderEngine.buildRenderProgram( - "RenderableBillboardsCloud", - absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboard_vs.glsl"), - absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboard_fs.glsl"), - absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboard_gs.glsl") + _program = DigitalUniverseModule::ProgramObjectManager.requestProgramObject( + ProgramObjectName, + []() -> std::unique_ptr { + return OsEng.renderEngine().buildRenderProgram( + ProgramObjectName, + absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboard_vs.glsl"), + absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboard_fs.glsl"), + absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboard_gs.glsl") + ); + } ); + _renderToPolygonProgram = + DigitalUniverseModule::ProgramObjectManager.requestProgramObject( + RenderToPolygonProgram, + []() -> std::unique_ptr { + return ghoul::opengl::ProgramObject::Build( + RenderToPolygonProgram, + absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboardpolygon_vs.glsl"), + absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboardpolygon_fs.glsl"), + absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboardpolygon_gs.glsl") + ); + } + ); + + _uniformCache.modelViewProjection = _program->uniformLocation( "modelViewProjectionTransform" ); @@ -678,11 +697,18 @@ void RenderableBillboardsCloud::deinitializeGL() { glDeleteVertexArrays(1, &_vao); _vao = 0; - RenderEngine& renderEngine = OsEng.renderEngine(); - if (_program) { - renderEngine.removeRenderProgram(_program); - _program = nullptr; - } + DigitalUniverseModule::ProgramObjectManager.releaseProgramObject( + ProgramObjectName, + [](ghoul::opengl::ProgramObject* p) { + OsEng.renderEngine().removeRenderProgram(p); + } + ); + _program = nullptr; + + DigitalUniverseModule::ProgramObjectManager.releaseProgramObject( + RenderToPolygonProgram + ); + _renderToPolygonProgram = nullptr; if (_hasSpriteTexture) { _spriteTexture = nullptr; @@ -1689,25 +1715,18 @@ void RenderableBillboardsCloud::loadPolygonGeometryForRendering() { } void RenderableBillboardsCloud::renderPolygonGeometry(GLuint vao) { - std::unique_ptr program = - ghoul::opengl::ProgramObject::Build("RenderableBillboardsCloud_Polygon", - absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboardpolygon_vs.glsl"), - absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboardpolygon_fs.glsl"), - absPath("${MODULE_DIGITALUNIVERSE}/shaders/billboardpolygon_gs.glsl") - ); - - program->activate(); + _renderToPolygonProgram->activate(); static const float black[] = { 0.0f, 0.0f, 0.0f, 0.0f }; glClearBufferfv(GL_COLOR, 0, black); - program->setUniform("sides", _polygonSides); - program->setUniform("polygonColor", _pointColor); + _renderToPolygonProgram->setUniform("sides", _polygonSides); + _renderToPolygonProgram->setUniform("polygonColor", _pointColor); glBindVertexArray(vao); glDrawArrays(GL_POINTS, 0, 1); glBindVertexArray(0); - program->deactivate(); + _renderToPolygonProgram->deactivate(); } } // namespace openspace diff --git a/modules/digitaluniverse/rendering/renderablebillboardscloud.h b/modules/digitaluniverse/rendering/renderablebillboardscloud.h index a33af736b3..7a9db171a1 100644 --- a/modules/digitaluniverse/rendering/renderablebillboardscloud.h +++ b/modules/digitaluniverse/rendering/renderablebillboardscloud.h @@ -141,7 +141,9 @@ private: std::unique_ptr _polygonTexture; std::unique_ptr _spriteTexture; std::unique_ptr _spriteTextureFile; - std::unique_ptr _program; + ghoul::opengl::ProgramObject* _program; + ghoul::opengl::ProgramObject* _renderToPolygonProgram; + UniformCache(modelViewProjection, cameraPos, cameraLookup, renderOption, centerSceenInWorldPos, minBillboardSize, maxBillboardSize, color, sides, alphaValue, scaleFactor, up, right, fadeInValue, screenSize, diff --git a/modules/digitaluniverse/rendering/renderabledumeshes.cpp b/modules/digitaluniverse/rendering/renderabledumeshes.cpp index 6d6e4aaa77..96000dc2d7 100644 --- a/modules/digitaluniverse/rendering/renderabledumeshes.cpp +++ b/modules/digitaluniverse/rendering/renderabledumeshes.cpp @@ -24,6 +24,7 @@ #include +#include #include #include #include @@ -48,6 +49,8 @@ namespace { constexpr const char* _loggerCat = "RenderableDUMeshes"; + constexpr const char* ProgramObjectName = "RenderableDUMeshes"; + constexpr const char* KeyFile = "File"; constexpr const char* keyColor = "Color"; constexpr const char* keyUnit = "Unit"; @@ -398,11 +401,15 @@ bool RenderableDUMeshes::isReady() const { } void RenderableDUMeshes::initializeGL() { - RenderEngine& renderEngine = OsEng.renderEngine(); - _program = renderEngine.buildRenderProgram( - "RenderableDUMeshes", - absPath("${MODULE_DIGITALUNIVERSE}/shaders/dumesh_vs.glsl"), - absPath("${MODULE_DIGITALUNIVERSE}/shaders/dumesh_fs.glsl") + _program = DigitalUniverseModule::ProgramObjectManager.requestProgramObject( + ProgramObjectName, + []() -> std::unique_ptr { + return OsEng.renderEngine().buildRenderProgram( + "RenderableDUMeshes", + absPath("${MODULE_DIGITALUNIVERSE}/shaders/dumesh_vs.glsl"), + absPath("${MODULE_DIGITALUNIVERSE}/shaders/dumesh_fs.glsl") + ); + } ); _uniformCache.modelViewTransform = _program->uniformLocation("modelViewTransform"); @@ -439,11 +446,12 @@ void RenderableDUMeshes::deinitializeGL() { } } - RenderEngine& renderEngine = OsEng.renderEngine(); - if (_program) { - renderEngine.removeRenderProgram(_program); - _program = nullptr; - } + DigitalUniverseModule::ProgramObjectManager.releaseProgramObject( + ProgramObjectName, + [](ghoul::opengl::ProgramObject* p) { + OsEng.renderEngine().removeRenderProgram(p); + } + ); } void RenderableDUMeshes::renderMeshes(const RenderData&, diff --git a/modules/digitaluniverse/rendering/renderabledumeshes.h b/modules/digitaluniverse/rendering/renderabledumeshes.h index 9043c015e9..8fa3adacd7 100644 --- a/modules/digitaluniverse/rendering/renderabledumeshes.h +++ b/modules/digitaluniverse/rendering/renderabledumeshes.h @@ -139,7 +139,7 @@ private: // DEBUG: properties::OptionProperty _renderOption; - std::unique_ptr _program; + ghoul::opengl::ProgramObject* _program; UniformCache(modelViewTransform, projectionTransform, alphaValue, /*scaleFactor,*/ color) _uniformCache; std::shared_ptr _font; diff --git a/modules/digitaluniverse/rendering/renderableplanescloud.cpp b/modules/digitaluniverse/rendering/renderableplanescloud.cpp index 70d59fd4b8..56481d3669 100644 --- a/modules/digitaluniverse/rendering/renderableplanescloud.cpp +++ b/modules/digitaluniverse/rendering/renderableplanescloud.cpp @@ -24,6 +24,7 @@ #include +#include #include #include #include @@ -50,6 +51,9 @@ namespace { constexpr const char* _loggerCat = "RenderablePlanesCloud"; + constexpr const char* ProgramObjectName = "RenderablePlanesCloud"; + + constexpr const char* KeyFile = "File"; constexpr const char* keyUnit = "Unit"; constexpr const char* MeterUnit = "m"; @@ -517,12 +521,15 @@ void RenderablePlanesCloud::initialize() { } void RenderablePlanesCloud::initializeGL() { - RenderEngine& renderEngine = OsEng.renderEngine(); - - _program = renderEngine.buildRenderProgram( - "RenderablePlanesCloud", - absPath("${MODULE_DIGITALUNIVERSE}/shaders/plane_vs.glsl"), - absPath("${MODULE_DIGITALUNIVERSE}/shaders/plane_fs.glsl") + _program = DigitalUniverseModule::ProgramObjectManager.requestProgramObject( + ProgramObjectName, + []() -> std::unique_ptr { + return OsEng.renderEngine().buildRenderProgram( + "RenderablePlanesCloud", + absPath("${MODULE_DIGITALUNIVERSE}/shaders/plane_vs.glsl"), + absPath("${MODULE_DIGITALUNIVERSE}/shaders/plane_fs.glsl") + ); + } ); _uniformCache.modelViewProjectionTransform = _program->uniformLocation( @@ -560,11 +567,12 @@ void RenderablePlanesCloud::deleteDataGPU() { void RenderablePlanesCloud::deinitializeGL() { deleteDataGPU(); - RenderEngine& renderEngine = OsEng.renderEngine(); - if (_program) { - renderEngine.removeRenderProgram(_program); - _program = nullptr; - } + DigitalUniverseModule::ProgramObjectManager.releaseProgramObject( + ProgramObjectName, + [](ghoul::opengl::ProgramObject* p) { + OsEng.renderEngine().removeRenderProgram(p); + } + ); } void RenderablePlanesCloud::renderPlanes(const RenderData&, diff --git a/modules/digitaluniverse/rendering/renderableplanescloud.h b/modules/digitaluniverse/rendering/renderableplanescloud.h index 745d14aeba..ce78efbc7c 100644 --- a/modules/digitaluniverse/rendering/renderableplanescloud.h +++ b/modules/digitaluniverse/rendering/renderableplanescloud.h @@ -50,112 +50,113 @@ namespace ghoul::opengl { } // namespace ghoul::opengl namespace openspace { - // (x, y, z, w, s, t) * 6 = 36 - const int PLANES_VERTEX_DATA_SIZE = 36; - namespace documentation { struct Documentation; } +// (x, y, z, w, s, t) * 6 = 36 +const int PLANES_VERTEX_DATA_SIZE = 36; - class RenderablePlanesCloud : public Renderable { - public: - explicit RenderablePlanesCloud(const ghoul::Dictionary& dictionary); - ~RenderablePlanesCloud() = default; +namespace documentation { struct Documentation; } - void initialize() override; - void initializeGL() override; - void deinitializeGL() override; +class RenderablePlanesCloud : public Renderable { +public: + explicit RenderablePlanesCloud(const ghoul::Dictionary& dictionary); + ~RenderablePlanesCloud() = default; - bool isReady() const override; + void initialize() override; + void initializeGL() override; + void deinitializeGL() override; - void render(const RenderData& data, RendererTasks& rendererTask) override; - void update(const UpdateData& data) override; + bool isReady() const override; - static documentation::Documentation Documentation(); + void render(const RenderData& data, RendererTasks& rendererTask) override; + void update(const UpdateData& data) override; - private: - enum Unit { - Meter = 0, - Kilometer = 1, - Parsec = 2, - Kiloparsec = 3, - Megaparsec = 4, - Gigaparsec = 5, + static documentation::Documentation Documentation(); - GigalightYears = 6 - }; +private: + enum Unit { + Meter = 0, + Kilometer = 1, + Parsec = 2, + Kiloparsec = 3, + Megaparsec = 4, + Gigaparsec = 5, - struct RenderingPlane { - int planeIndex; - GLuint vao; - GLuint vbo; - GLfloat vertexData[PLANES_VERTEX_DATA_SIZE]; - }; - - void deleteDataGPU(); - void createPlanes(); - void renderPlanes(const RenderData& data, const glm::dmat4& modelViewMatrix, - const glm::dmat4& projectionMatrix, float fadeInVariable); - void renderLabels(const RenderData& data, - const glm::dmat4& modelViewProjectionMatrix, const glm::dvec3& orthoRight, - const glm::dvec3& orthoUp, float fadeInVarible); - - bool loadData(); - bool loadTextures(); - bool readSpeckFile(); - bool readLabelFile(); - bool loadCachedFile(const std::string& file); - bool saveCachedFile(const std::string& file) const; - - bool _hasSpeckFile; - bool _dataIsDirty; - bool _textColorIsDirty; - bool _hasLabel; - bool _labelDataIsDirty; - - int _textMinSize; - int _textMaxSize; - int _planeStartingIndexPos; - int _textureVariableIndex; - - properties::FloatProperty _alphaValue; - properties::FloatProperty _scaleFactor; - properties::Vec4Property _textColor; - properties::FloatProperty _textSize; - properties::BoolProperty _drawElements; - properties::OptionProperty _blendMode; - properties::Vec2Property _fadeInDistance; - properties::BoolProperty _disableFadeInDistance; - properties::FloatProperty _planeMinSize; - - // DEBUG: - properties::OptionProperty _renderOption; - - std::unique_ptr _program; - UniformCache(modelViewProjectionTransform, alphaValue, scaleFactor, fadeInValue, - galaxyTexture) _uniformCache; - std::shared_ptr _font; - std::unordered_map> _textureMap; - std::unordered_map _textureFileMap; - - std::string _speckFile; - std::string _labelFile; - std::string _texturesPath; - std::string _luminosityVar; - - Unit _unit; - - std::vector _fullData; - std::vector> _labelData; - std::unordered_map _variableDataPositionMap; - - int _nValuesPerAstronomicalObject; - - float _sluminosity; - - glm::dmat4 _transformationMatrix; - - std::vector _renderingPlanesArray; + GigalightYears = 6 }; + struct RenderingPlane { + int planeIndex; + GLuint vao; + GLuint vbo; + GLfloat vertexData[PLANES_VERTEX_DATA_SIZE]; + }; + + void deleteDataGPU(); + void createPlanes(); + void renderPlanes(const RenderData& data, const glm::dmat4& modelViewMatrix, + const glm::dmat4& projectionMatrix, float fadeInVariable); + void renderLabels(const RenderData& data, + const glm::dmat4& modelViewProjectionMatrix, const glm::dvec3& orthoRight, + const glm::dvec3& orthoUp, float fadeInVarible); + + bool loadData(); + bool loadTextures(); + bool readSpeckFile(); + bool readLabelFile(); + bool loadCachedFile(const std::string& file); + bool saveCachedFile(const std::string& file) const; + + bool _hasSpeckFile; + bool _dataIsDirty; + bool _textColorIsDirty; + bool _hasLabel; + bool _labelDataIsDirty; + + int _textMinSize; + int _textMaxSize; + int _planeStartingIndexPos; + int _textureVariableIndex; + + properties::FloatProperty _alphaValue; + properties::FloatProperty _scaleFactor; + properties::Vec4Property _textColor; + properties::FloatProperty _textSize; + properties::BoolProperty _drawElements; + properties::OptionProperty _blendMode; + properties::Vec2Property _fadeInDistance; + properties::BoolProperty _disableFadeInDistance; + properties::FloatProperty _planeMinSize; + + // DEBUG: + properties::OptionProperty _renderOption; + + ghoul::opengl::ProgramObject* _program; + UniformCache(modelViewProjectionTransform, alphaValue, scaleFactor, fadeInValue, + galaxyTexture) _uniformCache; + std::shared_ptr _font; + std::unordered_map> _textureMap; + std::unordered_map _textureFileMap; + + std::string _speckFile; + std::string _labelFile; + std::string _texturesPath; + std::string _luminosityVar; + + Unit _unit; + + std::vector _fullData; + std::vector> _labelData; + std::unordered_map _variableDataPositionMap; + + int _nValuesPerAstronomicalObject; + + float _sluminosity; + + glm::dmat4 _transformationMatrix; + + std::vector _renderingPlanesArray; +}; + } // namespace openspace diff --git a/modules/digitaluniverse/rendering/renderablepoints.cpp b/modules/digitaluniverse/rendering/renderablepoints.cpp index 12f7351d60..01f16215e6 100644 --- a/modules/digitaluniverse/rendering/renderablepoints.cpp +++ b/modules/digitaluniverse/rendering/renderablepoints.cpp @@ -24,12 +24,12 @@ #include +#include #include #include #include #include #include - #include #include #include @@ -37,7 +37,6 @@ #include #include #include - #include #include #include @@ -46,6 +45,7 @@ namespace { constexpr const char* _loggerCat = "RenderablePoints"; + constexpr const char* KeyFile = "File"; constexpr const char* keyColor = "Color"; constexpr const char* keyUnit = "Unit"; @@ -267,12 +267,21 @@ void RenderablePoints::initialize() { } void RenderablePoints::initializeGL() { - RenderEngine& renderEngine = OsEng.renderEngine(); + // OBS: The ProgramObject name is later used to release the program as well, so the + // name parameter to requestProgramObject and the first parameter to + // buildRenderProgram has to be the same or an assertion will be thrown at the + // end of the program. + if (_hasSpriteTexture) { - _program = renderEngine.buildRenderProgram( - "RenderablePoints", - absPath("${MODULE_DIGITALUNIVERSE}/shaders/points_vs.glsl"), - absPath("${MODULE_DIGITALUNIVERSE}/shaders/points_sprite_fs.glsl") + _program = DigitalUniverseModule::ProgramObjectManager.requestProgramObject( + "RenderablePoints Sprite", + []() -> std::unique_ptr { + return OsEng.renderEngine().buildRenderProgram( + "RenderablePoints Sprite", + absPath("${MODULE_DIGITALUNIVERSE}/shaders/points_vs.glsl"), + absPath("${MODULE_DIGITALUNIVERSE}/shaders/points_sprite_fs.glsl") + ); + } ); _uniformCache.modelViewProjectionTransform = _program->uniformLocation( @@ -286,10 +295,15 @@ void RenderablePoints::initializeGL() { _uniformCache.hasColorMap = _program->uniformLocation("hasColorMap"); } else { - _program = renderEngine.buildRenderProgram( + _program = DigitalUniverseModule::ProgramObjectManager.requestProgramObject( "RenderablePoints", - absPath("${MODULE_DIGITALUNIVERSE}/shaders/points_vs.glsl"), - absPath("${MODULE_DIGITALUNIVERSE}/shaders/points_fs.glsl") + []() -> std::unique_ptr { + return OsEng.renderEngine().buildRenderProgram( + "RenderablePoints", + absPath("${MODULE_DIGITALUNIVERSE}/shaders/points_vs.glsl"), + absPath("${MODULE_DIGITALUNIVERSE}/shaders/points_sprite_fs.glsl") + ); + } ); _uniformCache.modelViewProjectionTransform = _program->uniformLocation( @@ -309,11 +323,13 @@ void RenderablePoints::deinitializeGL() { glDeleteVertexArrays(1, &_vao); _vao = 0; - RenderEngine& renderEngine = OsEng.renderEngine(); - if (_program) { - renderEngine.removeRenderProgram(_program); - _program = nullptr; - } + + DigitalUniverseModule::ProgramObjectManager.releaseProgramObject( + _program->name(), + [](ghoul::opengl::ProgramObject* p) { + OsEng.renderEngine().removeRenderProgram(p); + } + ); if (_hasSpriteTexture) { _spriteTexture = nullptr; diff --git a/modules/digitaluniverse/rendering/renderablepoints.h b/modules/digitaluniverse/rendering/renderablepoints.h index 62866d92dc..e4f24787ea 100644 --- a/modules/digitaluniverse/rendering/renderablepoints.h +++ b/modules/digitaluniverse/rendering/renderablepoints.h @@ -98,7 +98,7 @@ namespace openspace { std::unique_ptr _spriteTexture; std::unique_ptr _spriteTextureFile; - std::unique_ptr _program; + ghoul::opengl::ProgramObject* _program; UniformCache(modelViewProjectionTransform, color, sides, alphaValue, scaleFactor, spriteTexture, hasColorMap) _uniformCache; diff --git a/modules/fieldlines/rendering/renderablefieldlines.cpp b/modules/fieldlines/rendering/renderablefieldlines.cpp index b636be2c7c..46352fd44c 100644 --- a/modules/fieldlines/rendering/renderablefieldlines.cpp +++ b/modules/fieldlines/rendering/renderablefieldlines.cpp @@ -248,7 +248,7 @@ void RenderableFieldlines::deinitializeGL() { RenderEngine& renderEngine = OsEng.renderEngine(); if (_program) { - renderEngine.removeRenderProgram(_program); + renderEngine.removeRenderProgram(_program.get()); _program = nullptr; } } diff --git a/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp b/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp index 5ff44d90ae..81583ee16f 100644 --- a/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp +++ b/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp @@ -1003,7 +1003,7 @@ void RenderableFieldlinesSequence::deinitializeGL() { RenderEngine& renderEngine = OsEng.renderEngine(); if (_shaderProgram) { - renderEngine.removeRenderProgram(_shaderProgram); + renderEngine.removeRenderProgram(_shaderProgram.get()); _shaderProgram = nullptr; } diff --git a/modules/globebrowsing/rendering/layershadermanager.cpp b/modules/globebrowsing/rendering/layershadermanager.cpp index 753b38bb7d..9108e4f814 100644 --- a/modules/globebrowsing/rendering/layershadermanager.cpp +++ b/modules/globebrowsing/rendering/layershadermanager.cpp @@ -144,7 +144,7 @@ LayerShaderManager::LayerShaderManager(const std::string& shaderName, LayerShaderManager::~LayerShaderManager() { if (_programObject) { RenderEngine& renderEngine = OsEng.renderEngine(); - renderEngine.removeRenderProgram(_programObject); + renderEngine.removeRenderProgram(_programObject.get()); _programObject = nullptr; } } @@ -230,7 +230,7 @@ void LayerShaderManager::recompileShaderProgram( } // Remove old program - OsEng.renderEngine().removeRenderProgram(_programObject); + OsEng.renderEngine().removeRenderProgram(_programObject.get()); _programObject = OsEng.renderEngine().buildRenderProgram( _shaderName, diff --git a/modules/iswa/rendering/iswacygnet.cpp b/modules/iswa/rendering/iswacygnet.cpp index f0d76ae17a..7aa37a31d9 100644 --- a/modules/iswa/rendering/iswacygnet.cpp +++ b/modules/iswa/rendering/iswacygnet.cpp @@ -241,7 +241,7 @@ void IswaCygnet::update(const UpdateData&) { bool IswaCygnet::destroyShader() { RenderEngine& renderEngine = OsEng.renderEngine(); if (_shader) { - renderEngine.removeRenderProgram(_shader); + renderEngine.removeRenderProgram(_shader.get()); _shader = nullptr; } return true; diff --git a/modules/space/rendering/renderableconstellationbounds.cpp b/modules/space/rendering/renderableconstellationbounds.cpp index 1c8898d62a..8bf2a231d2 100644 --- a/modules/space/rendering/renderableconstellationbounds.cpp +++ b/modules/space/rendering/renderableconstellationbounds.cpp @@ -228,7 +228,7 @@ void RenderableConstellationBounds::deinitializeGL() { _vao = 0; if (_program) { - OsEng.renderEngine().removeRenderProgram(_program); + OsEng.renderEngine().removeRenderProgram(_program.get()); _program = nullptr; } } diff --git a/modules/space/rendering/renderableplanet.cpp b/modules/space/rendering/renderableplanet.cpp index 0611908e5f..8429372ef9 100644 --- a/modules/space/rendering/renderableplanet.cpp +++ b/modules/space/rendering/renderableplanet.cpp @@ -24,24 +24,22 @@ #include +#include +#include #include #include - -#include -#include -#include -#include #include #include - +#include +#include +#include #include -#include #include +#include +#include #include #include #include -#include - #include #include @@ -51,6 +49,11 @@ #include namespace { + constexpr const char* PlainProgramName = "PlanetProgram"; + constexpr const char* ShadowNightProgramName = "ShadowNightPlanetProgram"; + constexpr const char* NightProgramName = "NightPlanetProgram"; + constexpr const char* ShadowProgramName = "ShadowPlanetProgram"; + constexpr const char* KeyBody = "Body"; constexpr const char* KeyGeometry = "Geometry"; constexpr const char* KeyRadius = "Radius"; @@ -352,38 +355,57 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary) } void RenderablePlanet::initializeGL() { - RenderEngine& renderEngine = OsEng.renderEngine(); + // @FRAGILE: The shader deinitialization below relies on the name names for the + // request and the parameters to buildRenderProgram. That way, we can use + // the ProgramObject name in the releaseProgramObject method and release the + // correct one. if (_programObject == nullptr && _shadowEnabled && _hasNightTexture) { - // shadow program - _programObject = renderEngine.buildRenderProgram( - "shadowNightProgram", - absPath("${MODULE_SPACE}/shaders/shadow_nighttexture_vs.glsl"), - absPath("${MODULE_SPACE}/shaders/shadow_nighttexture_fs.glsl") + _programObject = SpaceModule::ProgramObjectManager.requestProgramObject( + ShadowNightProgramName, + []() -> std::unique_ptr { + return OsEng.renderEngine().buildRenderProgram( + ShadowNightProgramName, + 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", - absPath("${MODULE_SPACE}/shaders/shadow_vs.glsl"), - absPath("${MODULE_SPACE}/shaders/shadow_fs.glsl") + _programObject = SpaceModule::ProgramObjectManager.requestProgramObject( + ShadowProgramName, + []() -> std::unique_ptr { + return OsEng.renderEngine().buildRenderProgram( + ShadowProgramName, + 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", - absPath("${MODULE_SPACE}/shaders/nighttexture_vs.glsl"), - absPath("${MODULE_SPACE}/shaders/nighttexture_fs.glsl") + _programObject = SpaceModule::ProgramObjectManager.requestProgramObject( + NightProgramName, + []() -> std::unique_ptr { + return OsEng.renderEngine().buildRenderProgram( + NightProgramName, + absPath("${MODULE_SPACE}/shaders/nighttexture_vs.glsl"), + absPath("${MODULE_SPACE}/shaders/nighttexture_fs.glsl") + ); + } ); } else if (_programObject == nullptr) { - // pscstandard - _programObject = renderEngine.buildRenderProgram( - "pscstandard", - absPath("${MODULE_SPACE}/shaders/renderableplanet_vs.glsl"), - absPath("${MODULE_SPACE}/shaders/renderableplanet_fs.glsl") + _programObject = SpaceModule::ProgramObjectManager.requestProgramObject( + PlainProgramName, + []() -> std::unique_ptr { + return OsEng.renderEngine().buildRenderProgram( + PlainProgramName, + absPath("${MODULE_SPACE}/shaders/renderableplanet_vs.glsl"), + absPath("${MODULE_SPACE}/shaders/renderableplanet_fs.glsl") + ); + } ); } @@ -405,11 +427,12 @@ void RenderablePlanet::deinitializeGL() { _geometry = nullptr; } - RenderEngine& renderEngine = OsEng.renderEngine(); - if (_programObject) { - renderEngine.removeRenderProgram(_programObject); - _programObject = nullptr; - } + SpaceModule::ProgramObjectManager.releaseProgramObject( + _programObject->name(), + [](ghoul::opengl::ProgramObject* p) { + OsEng.renderEngine().removeRenderProgram(p); + } + ); _geometry = nullptr; _texture = nullptr; @@ -482,7 +505,7 @@ void RenderablePlanet::render(const RenderData& data, RendererTasks&) { // glm::mat4 ModelViewTrans = data.camera.viewMatrix() * scaleCamTrans * // translateCamTrans * translateObjTrans * glm::mat4(modelTransform); - setPscUniforms(*_programObject.get(), data.camera, data.position); + setPscUniforms(*_programObject, data.camera, data.position); _programObject->setUniform("_performShading", _performShading); _programObject->setUniform("_hasHeightMap", _hasHeightTexture); diff --git a/modules/space/rendering/renderableplanet.h b/modules/space/rendering/renderableplanet.h index 427df28cb9..df5acd4c6a 100644 --- a/modules/space/rendering/renderableplanet.h +++ b/modules/space/rendering/renderableplanet.h @@ -94,7 +94,7 @@ private: properties::StringProperty _nightTexturePath; properties::StringProperty _heightMapTexturePath; - std::unique_ptr _programObject; + ghoul::opengl::ProgramObject* _programObject; std::unique_ptr _texture; std::unique_ptr _nightTexture; diff --git a/modules/space/rendering/renderablerings.cpp b/modules/space/rendering/renderablerings.cpp index 4046515226..1fb453f690 100644 --- a/modules/space/rendering/renderablerings.cpp +++ b/modules/space/rendering/renderablerings.cpp @@ -216,7 +216,7 @@ void RenderableRings::deinitializeGL() { _textureFile = nullptr; _texture = nullptr; - OsEng.renderEngine().removeRenderProgram(_shader); + OsEng.renderEngine().removeRenderProgram(_shader.get()); _shader = nullptr; } diff --git a/modules/space/rendering/renderablestars.cpp b/modules/space/rendering/renderablestars.cpp index 36b25de8da..1d517082e5 100644 --- a/modules/space/rendering/renderablestars.cpp +++ b/modules/space/rendering/renderablestars.cpp @@ -323,7 +323,7 @@ void RenderableStars::deinitializeGL() { RenderEngine& renderEngine = OsEng.renderEngine(); if (_program) { - renderEngine.removeRenderProgram(_program); + renderEngine.removeRenderProgram(_program.get()); _program = nullptr; } } diff --git a/modules/space/spacemodule.cpp b/modules/space/spacemodule.cpp index c1d525bfa4..3407f2bbe2 100644 --- a/modules/space/spacemodule.cpp +++ b/modules/space/spacemodule.cpp @@ -45,6 +45,8 @@ namespace openspace { +ghoul::opengl::ProgramObjectManager SpaceModule::ProgramObjectManager; + SpaceModule::SpaceModule() : OpenSpaceModule(Name) {} void SpaceModule::internalInitialize(const ghoul::Dictionary&) { @@ -80,6 +82,10 @@ void SpaceModule::internalInitialize(const ghoul::Dictionary&) { fGeometry->registerClass("SimpleSphere"); } +void SpaceModule::internalDeinitializeGL() { + ProgramObjectManager.releaseAll(ghoul::opengl::ProgramObjectManager::Warnings::Yes); +} + std::vector SpaceModule::documentations() const { return { RenderableConstellationBounds::Documentation(), diff --git a/modules/space/spacemodule.h b/modules/space/spacemodule.h index 8f67d2a405..c158959826 100644 --- a/modules/space/spacemodule.h +++ b/modules/space/spacemodule.h @@ -27,6 +27,8 @@ #include +#include + namespace openspace { class SpaceModule : public OpenSpaceModule { @@ -37,8 +39,11 @@ public: virtual ~SpaceModule() = default; std::vector documentations() const override; + static ghoul::opengl::ProgramObjectManager ProgramObjectManager; + private: void internalInitialize(const ghoul::Dictionary&) override; + void internalDeinitializeGL() override; }; } // namespace openspace diff --git a/modules/spacecraftinstruments/rendering/renderablecrawlingline.cpp b/modules/spacecraftinstruments/rendering/renderablecrawlingline.cpp index 161e0eb30b..13e3b1cc80 100644 --- a/modules/spacecraftinstruments/rendering/renderablecrawlingline.cpp +++ b/modules/spacecraftinstruments/rendering/renderablecrawlingline.cpp @@ -175,7 +175,7 @@ void RenderableCrawlingLine::deinitializeGL() { RenderEngine& renderEngine = OsEng.renderEngine(); if (_program) { - renderEngine.removeRenderProgram(_program); + renderEngine.removeRenderProgram(_program.get()); _program = nullptr; } } diff --git a/modules/spacecraftinstruments/rendering/renderablefov.cpp b/modules/spacecraftinstruments/rendering/renderablefov.cpp index e519bbcad6..a494775b35 100644 --- a/modules/spacecraftinstruments/rendering/renderablefov.cpp +++ b/modules/spacecraftinstruments/rendering/renderablefov.cpp @@ -24,24 +24,23 @@ #include +#include #include - #include #include #include #include #include - #include #include #include #include - #include #include namespace { + constexpr const char* ProgramName = "FovProgram"; constexpr const char* KeyBody = "Body"; constexpr const char* KeyFrame = "Frame"; // const char* KeyColor = "RGB"; @@ -317,12 +316,17 @@ RenderableFov::RenderableFov(const ghoul::Dictionary& dictionary) } void RenderableFov::initializeGL() { - RenderEngine& renderEngine = OsEng.renderEngine(); - _programObject = renderEngine.buildRenderProgram( - "FovProgram", - absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/fov_vs.glsl"), - absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/fov_fs.glsl") - ); + _programObject = + SpacecraftInstrumentsModule::ProgramObjectManager.requestProgramObject( + ProgramName, + []() -> std::unique_ptr { + return OsEng.renderEngine().buildRenderProgram( + ProgramName, + absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/fov_vs.glsl"), + absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/fov_fs.glsl") + ); + } + ); _uniformCache.modelViewProjection = _programObject->uniformLocation( "modelViewProjectionTransform" @@ -481,7 +485,12 @@ void RenderableFov::initializeGL() { } void RenderableFov::deinitializeGL() { - OsEng.renderEngine().removeRenderProgram(_programObject); + SpacecraftInstrumentsModule::ProgramObjectManager.releaseProgramObject( + ProgramName, + [](ghoul::opengl::ProgramObject* p) { + OsEng.renderEngine().removeRenderProgram(p); + } + ); _programObject = nullptr; glDeleteBuffers(1, &_orthogonalPlane.vbo); diff --git a/modules/spacecraftinstruments/rendering/renderablefov.h b/modules/spacecraftinstruments/rendering/renderablefov.h index 5fcbcf1e06..b5ce83bde1 100644 --- a/modules/spacecraftinstruments/rendering/renderablefov.h +++ b/modules/spacecraftinstruments/rendering/renderablefov.h @@ -92,7 +92,7 @@ private: properties::FloatProperty _lineWidth; properties::BoolProperty _drawSolid; properties::DoubleProperty _standOffDistance; - std::unique_ptr _programObject; + ghoul::opengl::ProgramObject* _programObject; UniformCache(modelViewProjection, defaultColorStart, defaultColorEnd, activeColor, targetInFieldOfViewColor, intersectionStartColor, intersectionEndColor, squareColor, interpolation) _uniformCache; diff --git a/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp b/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp index 8578873d69..0e5b148298 100644 --- a/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp +++ b/modules/spacecraftinstruments/rendering/renderablemodelprojection.cpp @@ -257,7 +257,7 @@ void RenderableModelProjection::deinitializeGL() { _projectionComponent.deinitialize(); - OsEng.renderEngine().removeRenderProgram(_programObject); + OsEng.renderEngine().removeRenderProgram(_programObject.get()); _programObject = nullptr; } diff --git a/modules/spacecraftinstruments/rendering/renderableplaneprojection.cpp b/modules/spacecraftinstruments/rendering/renderableplaneprojection.cpp index d5ffe15f1f..9abaf7762f 100644 --- a/modules/spacecraftinstruments/rendering/renderableplaneprojection.cpp +++ b/modules/spacecraftinstruments/rendering/renderableplaneprojection.cpp @@ -111,7 +111,7 @@ void RenderablePlaneProjection::initializeGL() { void RenderablePlaneProjection::deinitializeGL() { RenderEngine& renderEngine = OsEng.renderEngine(); if (_shader) { - renderEngine.removeRenderProgram(_shader); + renderEngine.removeRenderProgram(_shader.get()); _shader = nullptr; } diff --git a/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp b/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp index a940d39a74..dbeea2bfc0 100644 --- a/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp +++ b/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp @@ -24,35 +24,29 @@ #include +#include #include - +#include #include #include #include +#include #include #include #include - +#include #include #include +#include +#include #include #include -#include - -#include -#include -#include - -#include -#include -#ifdef WIN32 -#define _USE_MATH_DEFINES -#include -#endif - namespace { constexpr const char* _loggerCat = "RenderablePlanetProjection"; + constexpr const char* ProjectiveProgramName = "ProjectiveProgram"; + constexpr const char* FBOPassProgramName = "FBOPassProgram"; + constexpr const char* KeyGeometry = "Geometry"; constexpr const char* KeyProjection = "Projection"; @@ -327,11 +321,21 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary& RenderablePlanetProjection::~RenderablePlanetProjection() {} void RenderablePlanetProjection::initializeGL() { - _programObject = OsEng.renderEngine().buildRenderProgram( - "projectiveProgram", - absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderablePlanet_vs.glsl"), - absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderablePlanet_fs.glsl") - ); + _programObject = + SpacecraftInstrumentsModule::ProgramObjectManager.requestProgramObject( + ProjectiveProgramName, + []() -> std::unique_ptr { + return OsEng.renderEngine().buildRenderProgram( + ProjectiveProgramName, + absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/" + "renderablePlanet_vs.glsl" + ), + absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/" + "renderablePlanet_fs.glsl" + ) + ); + } + ); _mainUniformCache.sunPos = _programObject->uniformLocation("sun_pos"); _mainUniformCache.modelTransform = _programObject->uniformLocation("modelTransform"); @@ -356,15 +360,23 @@ void RenderablePlanetProjection::initializeGL() { ); _mainUniformCache.heightTexture = _programObject->uniformLocation("heightTexture"); - _fboProgramObject = ghoul::opengl::ProgramObject::Build( - "fboPassProgram", - absPath( - "${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderablePlanetProjection_vs.glsl" - ), - absPath( - "${MODULE_SPACECRAFTINSTRUMENTS}/shaders/renderablePlanetProjection_fs.glsl" - ) - ); + _fboProgramObject = + SpacecraftInstrumentsModule::ProgramObjectManager.requestProgramObject( + FBOPassProgramName, + []() -> std::unique_ptr { + return ghoul::opengl::ProgramObject::Build( + FBOPassProgramName, + absPath( + "${MODULE_SPACECRAFTINSTRUMENTS}/shaders/" + "renderablePlanetProjection_vs.glsl" + ), + absPath( + "${MODULE_SPACECRAFTINSTRUMENTS}/shaders/" + "renderablePlanetProjection_fs.glsl" + ) + ); + } + ); _fboUniformCache.projectionTexture = _fboProgramObject->uniformLocation( "projectionTexture" @@ -426,9 +438,17 @@ void RenderablePlanetProjection::deinitializeGL() { glDeleteVertexArrays(1, &_quad); glDeleteBuffers(1, &_vertexPositionBuffer); - OsEng.renderEngine().removeRenderProgram(_programObject); + SpacecraftInstrumentsModule::ProgramObjectManager.releaseProgramObject( + ProjectiveProgramName, + [](ghoul::opengl::ProgramObject* p) { + OsEng.renderEngine().removeRenderProgram(p); + } + ); _programObject = nullptr; + SpacecraftInstrumentsModule::ProgramObjectManager.releaseProgramObject( + FBOPassProgramName + ); _fboProgramObject = nullptr; } @@ -487,12 +507,12 @@ void RenderablePlanetProjection::attitudeParameters(double time) { //90 deg rotation w.r.t spice req. glm::mat4 rot = glm::rotate( _transform, - static_cast(M_PI_2), + glm::half_pi(), glm::vec3(1, 0, 0) ); glm::mat4 roty = glm::rotate( _transform, - static_cast(M_PI_2), + glm::half_pi(), glm::vec3(0, -1, 0) ); @@ -597,8 +617,16 @@ void RenderablePlanetProjection::render(const RenderData& data, RendererTasks&) // meridian and y completes the right handed coordinate system. // Doing this is part of changing from using the transforms defined by the // scenegraph node (data.modelTransform) to achieve higher precision rendering. //KB - glm::dmat4 rot = glm::rotate(glm::dmat4(1.0), M_PI_2, glm::dvec3(1, 0, 0)); - glm::dmat4 roty = glm::rotate(glm::dmat4(1.0), M_PI_2, glm::dvec3(0, -1, 0)); + glm::dmat4 rot = glm::rotate( + glm::dmat4(1.0), + glm::half_pi(), + glm::dvec3(1.0, 0.0, 0.0) + ); + glm::dmat4 roty = glm::rotate( + glm::dmat4(1.0), + glm::half_pi(), + glm::dvec3(0.0, -1.0, 0.0) + ); modelTransform = modelTransform * rot * roty; glm::dmat4 modelViewTransform = data.camera.combinedViewMatrix() * modelTransform; diff --git a/modules/spacecraftinstruments/rendering/renderableplanetprojection.h b/modules/spacecraftinstruments/rendering/renderableplanetprojection.h index 30728d1b7c..98fe7a32d5 100644 --- a/modules/spacecraftinstruments/rendering/renderableplanetprojection.h +++ b/modules/spacecraftinstruments/rendering/renderableplanetprojection.h @@ -76,8 +76,8 @@ private: properties::StringProperty _addHeightMapTexturePath; bool _heightMapTextureDirty; - std::unique_ptr _programObject; - std::unique_ptr _fboProgramObject; + ghoul::opengl::ProgramObject* _programObject; + ghoul::opengl::ProgramObject* _fboProgramObject; UniformCache(sunPos, modelTransform, modelViewProjectionTransform, hasBaseMap, hasHeightMap, heightExaggeration, meridianShift, ambientBrightness, projectionFading, baseTexture, projectionTexture, heightTexture) diff --git a/modules/spacecraftinstruments/rendering/renderableshadowcylinder.cpp b/modules/spacecraftinstruments/rendering/renderableshadowcylinder.cpp index 5de7efbecd..97a7099c0f 100644 --- a/modules/spacecraftinstruments/rendering/renderableshadowcylinder.cpp +++ b/modules/spacecraftinstruments/rendering/renderableshadowcylinder.cpp @@ -24,18 +24,19 @@ #include +#include #include #include #include #include #include #include - #include #include namespace { - const char* MainFrame = "GALACTIC"; + constexpr const char* ProgramName = "ShadowCylinderProgram"; + constexpr const char* MainFrame = "GALACTIC"; static const openspace::properties::Property::PropertyInfo NumberPointsInfo = { "AmountOfPoints", @@ -265,11 +266,19 @@ void RenderableShadowCylinder::initializeGL() { glGenVertexArrays(1, &_vao); glGenBuffers(1, &_vbo); - RenderEngine& renderEngine = OsEng.renderEngine(); - _shader = renderEngine.buildRenderProgram( - "ShadowCylinderProgram", - absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/terminatorshadow_vs.glsl"), - absPath("${MODULE_SPACECRAFTINSTRUMENTS}/shaders/terminatorshadow_fs.glsl") + _shader = SpacecraftInstrumentsModule::ProgramObjectManager.requestProgramObject( + ProgramName, + []() -> std::unique_ptr { + return OsEng.renderEngine().buildRenderProgram( + ProgramName, + absPath( + "${MODULE_SPACECRAFTINSTRUMENTS}/shaders/terminatorshadow_vs.glsl" + ), + absPath( + "${MODULE_SPACECRAFTINSTRUMENTS}/shaders/terminatorshadow_fs.glsl" + ) + ); + } ); _uniformCache.modelViewProjectionTransform = _shader->uniformLocation( @@ -281,12 +290,14 @@ void RenderableShadowCylinder::initializeGL() { } void RenderableShadowCylinder::deinitializeGL() { - RenderEngine& renderEngine = OsEng.renderEngine(); - if (_shader) { - renderEngine.removeRenderProgram(_shader); - _shader = nullptr; - } - + SpacecraftInstrumentsModule::ProgramObjectManager.releaseProgramObject( + ProgramName, + [](ghoul::opengl::ProgramObject* p) { + OsEng.renderEngine().removeRenderProgram(p); + } + ); + _shader = nullptr; + glDeleteVertexArrays(1, &_vao); _vao = 0; glDeleteBuffers(1, &_vbo); diff --git a/modules/spacecraftinstruments/rendering/renderableshadowcylinder.h b/modules/spacecraftinstruments/rendering/renderableshadowcylinder.h index 3d8c99e987..0f43500ed7 100644 --- a/modules/spacecraftinstruments/rendering/renderableshadowcylinder.h +++ b/modules/spacecraftinstruments/rendering/renderableshadowcylinder.h @@ -78,7 +78,7 @@ private: properties::StringProperty _bodyFrame; properties::OptionProperty _aberration; - std::unique_ptr _shader; + ghoul::opengl::ProgramObject* _shader; UniformCache(modelViewProjectionTransform, shadowColor) _uniformCache; glm::dmat3 _stateMatrix; diff --git a/modules/spacecraftinstruments/spacecraftinstrumentsmodule.cpp b/modules/spacecraftinstruments/spacecraftinstrumentsmodule.cpp index 17de1481b8..b92e900241 100644 --- a/modules/spacecraftinstruments/spacecraftinstrumentsmodule.cpp +++ b/modules/spacecraftinstruments/spacecraftinstrumentsmodule.cpp @@ -45,6 +45,8 @@ namespace openspace { +ghoul::opengl::ProgramObjectManager SpacecraftInstrumentsModule::ProgramObjectManager; + SpacecraftInstrumentsModule::SpacecraftInstrumentsModule() : OpenSpaceModule(Name) {} void SpacecraftInstrumentsModule::internalInitialize(const ghoul::Dictionary&) { @@ -79,6 +81,10 @@ void SpacecraftInstrumentsModule::internalDeinitialize() { ImageSequencer::deinitialize(); } +void SpacecraftInstrumentsModule::internalDeinitializeGL() { + ProgramObjectManager.releaseAll(ghoul::opengl::ProgramObjectManager::Warnings::Yes); +} + std::vector SpacecraftInstrumentsModule::documentations() const { diff --git a/modules/spacecraftinstruments/spacecraftinstrumentsmodule.h b/modules/spacecraftinstruments/spacecraftinstrumentsmodule.h index 71c593da31..0727b4ea61 100644 --- a/modules/spacecraftinstruments/spacecraftinstrumentsmodule.h +++ b/modules/spacecraftinstruments/spacecraftinstrumentsmodule.h @@ -27,6 +27,8 @@ #include +#include + namespace openspace { class SpacecraftInstrumentsModule : public OpenSpaceModule { @@ -37,9 +39,12 @@ public: std::vector documentations() const override; + static ghoul::opengl::ProgramObjectManager ProgramObjectManager; + protected: void internalInitialize(const ghoul::Dictionary&) override; void internalDeinitialize() override; + void internalDeinitializeGL() override; }; } // namespace openspace diff --git a/modules/touch/src/touchmarker.cpp b/modules/touch/src/touchmarker.cpp index 4f350c0892..dfa5ebf227 100644 --- a/modules/touch/src/touchmarker.cpp +++ b/modules/touch/src/touchmarker.cpp @@ -113,7 +113,7 @@ void TouchMarker::deinitialize() { RenderEngine& renderEngine = OsEng.renderEngine(); if (_shader) { - renderEngine.removeRenderProgram(_shader); + renderEngine.removeRenderProgram(_shader.get()); _shader = nullptr; } } diff --git a/src/engine/moduleengine.cpp b/src/engine/moduleengine.cpp index 1b8f8cf2a9..d43b403abd 100644 --- a/src/engine/moduleengine.cpp +++ b/src/engine/moduleengine.cpp @@ -57,6 +57,15 @@ void ModuleEngine::initialize(const ghoul::Dictionary& moduleConfigurations) { } } +void ModuleEngine::initializeGL() { + LDEBUG("Initializing OpenGL of modules"); + for (std::unique_ptr& m : _modules) { + LDEBUG(fmt::format("Initializing OpenGL of module '{}'", m->identifier())); + m->initializeGL(); + } + LDEBUG("Finished initializing OpenGL of modules"); +} + void ModuleEngine::deinitialize() { LDEBUG("Deinitializing modules"); for (std::unique_ptr& m : _modules) { @@ -64,6 +73,8 @@ void ModuleEngine::deinitialize() { m->deinitialize(); } + LDEBUG("Finished deinitializing modules"); + for (std::unique_ptr& m : _modules) { LDEBUG(fmt::format("Destroying module '{}'", m->identifier())); m = nullptr; @@ -73,6 +84,16 @@ void ModuleEngine::deinitialize() { _modules.clear(); } +void ModuleEngine::deinitializeGL() { + LDEBUG("Deinitializing OpenGL of modules"); + for (std::unique_ptr& m : _modules) { + LDEBUG(fmt::format("Deinitializing OpenGL of module '{}'", m->identifier())); + m->deinitializeGL(); + + } + LDEBUG("Finished deinitializing OpenGL of modules"); +} + void ModuleEngine::registerModule(std::unique_ptr m, const ghoul::Dictionary& configuration) { diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index 3a885b8fdd..99d2caf3c4 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -464,6 +464,7 @@ void OpenSpaceEngine::destroy() { _engine->_renderEngine->deinitializeGL(); + _engine->_moduleEngine->deinitializeGL(); _engine->_moduleEngine->deinitialize(); _engine->_console->deinitialize(); @@ -1228,6 +1229,8 @@ void OpenSpaceEngine::initializeGL() { LDEBUG("Initializing Rendering Engine"); _renderEngine->initializeGL(); + _moduleEngine->initializeGL(); + for (const auto& func : _moduleCallbacks.initializeGL) { func(); } diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index 461f57a96c..8c95ec06ca 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -780,7 +780,6 @@ std::unique_ptr RenderEngine::buildRenderProgram( std::string name, std::string vsPath, std::string fsPath, const ghoul::Dictionary& data) { - ghoul::Dictionary dict = data; // set path to the current renderer's main fragment shader @@ -835,9 +834,7 @@ std::unique_ptr RenderEngine::buildRenderProgram( return program; } -void RenderEngine::removeRenderProgram( - const std::unique_ptr& program) -{ +void RenderEngine::removeRenderProgram(ghoul::opengl::ProgramObject* program) { if (!program) { return; } @@ -845,7 +842,7 @@ void RenderEngine::removeRenderProgram( auto it = std::find( _programs.begin(), _programs.end(), - program.get() + program ); if (it != _programs.end()) { diff --git a/src/rendering/screenspacerenderable.cpp b/src/rendering/screenspacerenderable.cpp index 61a2e23043..ac3f8cee77 100644 --- a/src/rendering/screenspacerenderable.cpp +++ b/src/rendering/screenspacerenderable.cpp @@ -357,7 +357,7 @@ bool ScreenSpaceRenderable::deinitializeGL() { RenderEngine& renderEngine = OsEng.renderEngine(); if (_shader) { - renderEngine.removeRenderProgram(_shader); + renderEngine.removeRenderProgram(_shader.get()); _shader = nullptr; } diff --git a/src/util/openspacemodule.cpp b/src/util/openspacemodule.cpp index fb40e0c5f8..2cca17b7d5 100644 --- a/src/util/openspacemodule.cpp +++ b/src/util/openspacemodule.cpp @@ -71,10 +71,18 @@ void OpenSpaceModule::initialize(const ModuleEngine* moduleEngine, internalInitialize(configuration); } +void OpenSpaceModule::initializeGL() { + internalInitializeGL(); +} + void OpenSpaceModule::deinitialize() { internalDeinitialize(); } +void OpenSpaceModule::deinitializeGL() { + internalDeinitializeGL(); +} + std::vector OpenSpaceModule::documentations() const { return {}; } @@ -126,6 +134,10 @@ const ModuleEngine* OpenSpaceModule::moduleEngine() const { void OpenSpaceModule::internalInitialize(const ghoul::Dictionary&) {} +void OpenSpaceModule::internalInitializeGL() {} + void OpenSpaceModule::internalDeinitialize() {} +void OpenSpaceModule::internalDeinitializeGL() {} + } // namespace openspace From 1c70f9145b6b52931ec4608d7d6b1139e6b81e6a Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 10 Apr 2018 16:12:28 -0400 Subject: [PATCH 11/17] Feature/focusmarkers (#594) * Add function to optionally automatically create focus nodes based on info files --- data/assets/customization/globebrowsing.asset | 6 +++ .../globebrowsing/scripts/layer_support.lua | 54 ++++++++++++++++++- 2 files changed, 58 insertions(+), 2 deletions(-) diff --git a/data/assets/customization/globebrowsing.asset b/data/assets/customization/globebrowsing.asset index ccdaec8893..e7dad3f248 100644 --- a/data/assets/customization/globebrowsing.asset +++ b/data/assets/customization/globebrowsing.asset @@ -2,6 +2,8 @@ -- example: -- asset.require('../scene/solarsystem/planets/mars/mars') +local CreateFocusNodes = false + -- Add folders to this list that contain .info files describing patches -- OBS: Even on Windows, you have to use forward slashes (/) or double backslashes (\\) -- rather than single backslashes (\) as they are otherwise interpreted as escape @@ -34,6 +36,10 @@ asset.onInitialize(function () for obj, list in pairs(vrt_folders) do for _, dir in pairs(list) do openspace.globebrowsing.addBlendingLayersFromDirectory(dir, obj) + + if CreateFocusNodes then + openspace.globebrowsing.addFocusNodesFromDirectory(dir, obj) + end end end end) diff --git a/modules/globebrowsing/scripts/layer_support.lua b/modules/globebrowsing/scripts/layer_support.lua index f8935c1eab..71f3350027 100644 --- a/modules/globebrowsing/scripts/layer_support.lua +++ b/modules/globebrowsing/scripts/layer_support.lua @@ -70,6 +70,16 @@ openspace.globebrowsing.documentation = { "to the second argument." .. "Usage: openspace.globebrowsing.addBlendingLayersFromDirectory(directory, \"Earth\")" }, + { + Name = "addFocusNodesFromDirectory", + Arguments = "string, string", + Documentation = + "Retrieves all info files recursively in the directory passed as the first " .. + "argument to this function. The name and location retrieved from these info " .. + "files are then used to create new SceneGraphNodes that can be used as " .. + "focus nodes. " .. + "Usage: openspace.globebrowsing.addFocusNodesFromDirectory(directory, \"Mars\")" + }, { Name = "loadWMSServersFromFile", Arguments = "string", @@ -163,6 +173,11 @@ openspace.globebrowsing.parseInfoFile = function (file) local dir = openspace.directoryForPath(file) dofile(file) + local name = nil + if Name then + name = Name + end + local color = nil if ColorFile then color = { @@ -183,7 +198,12 @@ openspace.globebrowsing.parseInfoFile = function (file) } end - return color, height + local location = nil + if Location then + location = Location + end + + return name, color, height, location end openspace.globebrowsing.addBlendingLayersFromDirectory = function (dir, node_name) @@ -191,7 +211,7 @@ openspace.globebrowsing.addBlendingLayersFromDirectory = function (dir, node_nam for _, file in pairs(files) do if file and file:find('.info') then - c, h = openspace.globebrowsing.parseInfoFile(file) + _, c, h, _ = openspace.globebrowsing.parseInfoFile(file) if c then openspace.printInfo("Adding color layer '" .. c["Identifier"] .. "'") @@ -205,6 +225,36 @@ openspace.globebrowsing.addBlendingLayersFromDirectory = function (dir, node_nam end end +openspace.globebrowsing.addFocusNodesFromDirectory = function (dir, node_name) + local files = openspace.walkDirectoryFiles(dir, true, true) + + for _, file in pairs(files) do + if file and file:find('.info') then + n, _, _, l = openspace.globebrowsing.parseInfoFile(file) + + if n and l then + openspace.printInfo("Creating focus node for '" .. n .. "'") + + local lat = l.Center[2] + local long = l.Center[1] + local a, b, c = openspace.globebrowsing.getGeoPosition(node_name, lat, long, 0.0) + local p = { a, b, c } + + openspace.addSceneGraphNode({ + Name = node_name .. " - " .. n, + Parent = node_name, + Transform = { + Translation = { + Type = "StaticTranslation", + Position = { p[1], p[2], p[3] } + } + } + }) + end + end + end +end + openspace.globebrowsing.loadWMSServersFromFile = function (file_path) local servers = dofile(file_path) From 09e7a642bfe2f1f2d83df061b2e2fdc6ba689262 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 10 Apr 2018 17:24:27 -0400 Subject: [PATCH 12/17] Fix correct aspect ratio --- scripts/configuration_helper.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/configuration_helper.lua b/scripts/configuration_helper.lua index 9002ef9222..5093432d61 100644 --- a/scripts/configuration_helper.lua +++ b/scripts/configuration_helper.lua @@ -677,7 +677,7 @@ function sgct.config.single(arg) right = horizontalFov } else - arg["fov"] = { down = 22.5, up = 22.5, left = 40.0, right = 40.0 } + arg["fov"] = { down = 25, up = 25, left = 40.0, right = 40.0 } end end From 0b332a586a944b970fc17664655bbaaa7b29fa97 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 12 Apr 2018 09:50:21 -0400 Subject: [PATCH 13/17] Render Saturn's rings without warnings (closes #584) --- data/assets/scene/solarsystem/planets/saturn/saturn.asset | 2 +- modules/space/rendering/renderablerings.cpp | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/data/assets/scene/solarsystem/planets/saturn/saturn.asset b/data/assets/scene/solarsystem/planets/saturn/saturn.asset index 5eba3cd243..0a60fdeb1b 100644 --- a/data/assets/scene/solarsystem/planets/saturn/saturn.asset +++ b/data/assets/scene/solarsystem/planets/saturn/saturn.asset @@ -55,7 +55,7 @@ local SaturnRings = { Name = "Saturn Rings", Path = "/Solar System/Planets/Saturn" } -}, +} diff --git a/modules/space/rendering/renderablerings.cpp b/modules/space/rendering/renderablerings.cpp index 1fb453f690..d70df74c65 100644 --- a/modules/space/rendering/renderablerings.cpp +++ b/modules/space/rendering/renderablerings.cpp @@ -243,8 +243,6 @@ void RenderableRings::render(const RenderData& data, RendererTasks&) { _sunPosition ); - setPscUniforms(*_shader, data.camera, data.position); - ghoul::opengl::TextureUnit unit; unit.activate(); _texture->bind(); From 20b83191617617e7d73ebf8848b33b648c5bf456 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 12 Apr 2018 10:02:04 -0400 Subject: [PATCH 14/17] Forward mouse-released events to the navigation handler regardless of whether a callback has consumed them --- src/engine/openspaceengine.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index 99d2caf3c4..b9e1d2946c 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -1474,7 +1474,16 @@ void OpenSpaceEngine::mouseButtonCallback(MouseButton button, MouseAction action for (const auto& func : _moduleCallbacks.mouseButton) { bool consumed = func(button, action); if (consumed) { - return; + // If the mouse was released, we still want to forward it to the navigation + // handler in order to reliably terminate a rotation or zoom. Accidentally + // moving the cursor over a UI window is easy to miss and leads to weird + // continuing movement + if (action == MouseAction::Release) { + break; + } + else { + return; + } } } From 12db1dd0c2c7c771dcea05ab44d220f07c548b7c Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Tue, 17 Apr 2018 18:44:02 -0400 Subject: [PATCH 15/17] =?UTF-8?q?Fix=20Norrk=C3=B6ping=20WMS=20servers?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mars/map_service_configs/LiU/CTX.wms | 20 ++++++---- .../LiU/Mola_Elevation.wms | 39 +++++++++++++++++-- 2 files changed, 48 insertions(+), 11 deletions(-) diff --git a/data/assets/scene/solarsystem/planets/mars/map_service_configs/LiU/CTX.wms b/data/assets/scene/solarsystem/planets/mars/map_service_configs/LiU/CTX.wms index 7c0effdee4..4bebebede3 100644 --- a/data/assets/scene/solarsystem/planets/mars/map_service_configs/LiU/CTX.wms +++ b/data/assets/scene/solarsystem/planets/mars/map_service_configs/LiU/CTX.wms @@ -1,18 +1,22 @@ - - http://wms.itn.liu.se/OnMars/wms.cgi? - CTX Mosaic - TRUE + + http://wms.itn.liu.se/Mars/CTX/tile/${z}/${y}/${x} -180.0 90.0 180.0 -90.0 - 256 - 256 + 4194304 + 2097152 + 13 + top - 400,204,404 - true + GEOGCS["Mars 2000", DATUM["D_Mars_2000", SPHEROID["MARS_2000_IAU_IAG",3396190.0,169.894447222361179]],PRIMEM["Greenwich"0], UNIT["Decimal_Degree",0.0174532925199433]] + 256 + 256 + 2 + false + ./gdal-cache/ctx 5 diff --git a/data/assets/scene/solarsystem/planets/mars/map_service_configs/LiU/Mola_Elevation.wms b/data/assets/scene/solarsystem/planets/mars/map_service_configs/LiU/Mola_Elevation.wms index de304c2a37..52c6b9c84b 100644 --- a/data/assets/scene/solarsystem/planets/mars/map_service_configs/LiU/Mola_Elevation.wms +++ b/data/assets/scene/solarsystem/planets/mars/map_service_configs/LiU/Mola_Elevation.wms @@ -1,15 +1,48 @@ - - http://wms.itn.liu.se/OnMars/wms.cgi? - Mola Elevation + + http://wms.itn.liu.se/Mars/Mola_Elevation/tile/${z}/${y}/${x} -180.0 90.0 180.0 -90.0 + 46080 + 23040 + 6 bottom + Int16 + GEOGCS["GCS_Mars_2000_Sphere",DATUM["D_Mars_2000_Sphere",SPHEROID["Mars_2000_Sphere_IAU_IAG",3396190.0,0.0]],PRIMEM["Reference_Meridian",0.0],UNIT["Degree",0.0174532925199433]] + 256 + 256 + 1 false + ./gdal-cache/mola_elevation 5 + + + \ No newline at end of file From 4041bbb93555f3a7de1157075a1863ae306578b5 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 19 Apr 2018 13:27:15 -0400 Subject: [PATCH 16/17] Cleanup (#600) * General Code Cleanup * Add check for TABs to check_style_guide.py * Removing warnings --- apps/Wormhole/main.cpp | 2 +- ext/ghoul | 2 +- ext/sgct | 2 +- .../openspace/engine/configurationmanager.h | 7 +- include/openspace/network/messagestructures.h | 2 +- include/openspace/properties/binaryproperty.h | 44 +-- .../openspace/properties/numericalproperty.h | 2 +- .../properties/numericalproperty.inl | 12 +- include/openspace/properties/property.h | 6 +- include/openspace/properties/propertyowner.h | 6 +- include/openspace/rendering/renderable.h | 2 +- include/openspace/scene/scene.h | 4 +- modules/atmosphere/atmospheremodule.cpp | 9 +- modules/atmosphere/atmospheremodule.h | 3 +- .../rendering/atmospheredeferredcaster.cpp | 27 +- .../shaders/atmosphere_deferred_vs.glsl | 2 +- .../atmosphere/shaders/deltaE_calc_fs.glsl | 2 +- .../atmosphere/shaders/deltaE_calc_vs.glsl | 2 +- .../atmosphere/shaders/deltaJ_calc_fs.glsl | 2 +- .../atmosphere/shaders/deltaJ_calc_gs.glsl | 2 +- .../atmosphere/shaders/deltaJ_calc_vs.glsl | 2 +- .../atmosphere/shaders/deltaS_calc_fs.glsl | 4 +- .../atmosphere/shaders/deltaS_calc_gs.glsl | 2 +- .../atmosphere/shaders/deltaS_calc_vs.glsl | 2 +- .../shaders/deltaS_sup_calc_fs.glsl | 2 +- .../shaders/deltaS_sup_calc_gs.glsl | 2 +- .../shaders/deltaS_sup_calc_vs.glsl | 2 +- .../shaders/inScattering_calc_fs.glsl | 2 +- .../shaders/inScattering_calc_gs.glsl | 2 +- .../shaders/inScattering_calc_vs.glsl | 2 +- .../shaders/inScattering_sup_calc_fs.glsl | 2 +- .../shaders/inScattering_sup_calc_gs.glsl | 2 +- .../shaders/inScattering_sup_calc_vs.glsl | 2 +- .../shaders/irradiance_calc_fs.glsl | 2 +- .../shaders/irradiance_calc_vs.glsl | 2 +- .../shaders/irradiance_final_fs.glsl | 3 +- .../shaders/irradiance_final_vs.glsl | 2 +- .../shaders/irradiance_sup_calc_fs.glsl | 2 +- .../shaders/irradiance_sup_calc_vs.glsl | 2 +- .../shaders/transmittance_calc_fs.glsl | 2 +- .../shaders/transmittance_calc_vs.glsl | 2 +- modules/base/dashboard/dashboarditemangle.cpp | 6 +- modules/base/dashboard/dashboarditemangle.h | 1 - modules/base/dashboard/dashboarditemdate.h | 4 +- modules/base/rendering/renderableplane.cpp | 2 +- .../base/rendering/screenspacedashboard.cpp | 2 - .../base/rendering/screenspaceimagelocal.cpp | 2 - .../base/rendering/screenspaceimageonline.cpp | 2 - modules/base/rotation/fixedrotation.cpp | 2 +- modules/cefwebgui/CMakeLists.txt | 2 +- modules/cefwebgui/cefwebguimodule.cpp | 2 +- modules/cefwebgui/cefwebguimodule.h | 8 +- modules/cefwebgui/include/guirenderhandler.h | 14 +- modules/cefwebgui/src/guirenderhandler.cpp | 2 +- .../renderablefieldlinessequence.cpp | 4 +- .../rendering/layershadermanager.cpp | 5 +- .../imgui/src/guiglobebrowsingcomponent.cpp | 2 +- modules/kameleon/src/kameleonwrapper.cpp | 16 +- .../kameleonvolume/kameleonvolumereader.cpp | 2 +- modules/kameleonvolume/kameleonvolumereader.h | 2 +- .../rendering/renderablekameleonvolume.cpp | 10 +- .../tasks/kameleonvolumetorawtask.cpp | 2 - modules/server/CMakeLists.txt | 2 +- modules/server/include/authorizationtopic.h | 15 +- modules/server/include/connection.h | 13 +- modules/server/include/connectionpool.h | 13 +- modules/server/include/getpropertytopic.h | 10 +- modules/server/include/jsonconverters.h | 10 +- modules/server/include/luascripttopic.h | 52 +-- modules/server/include/setpropertytopic.h | 10 +- modules/server/include/subscriptiontopic.h | 10 +- modules/server/include/timetopic.h | 13 +- modules/server/include/topic.h | 16 +- modules/server/include/triggerpropertytopic.h | 52 +-- modules/server/servermodule.cpp | 8 +- modules/server/servermodule.h | 2 +- modules/server/src/connection.cpp | 37 +- modules/server/src/connectionpool.cpp | 15 +- modules/server/src/jsonconverters.cpp | 2 +- .../server/src/topics/authorizationtopic.cpp | 24 +- .../server/src/topics/getpropertytopic.cpp | 6 +- modules/server/src/topics/luascripttopic.cpp | 11 +- .../server/src/topics/setpropertytopic.cpp | 2 +- .../server/src/topics/subscriptiontopic.cpp | 2 +- modules/server/src/topics/timetopic.cpp | 2 +- modules/server/src/topics/topic.cpp | 2 +- .../src/topics/triggerpropertytopic.cpp | 8 +- .../rendering/renderableshadowcylinder.cpp | 2 +- modules/sync/syncs/urlsynchronization.cpp | 2 +- modules/touch/ext/levmarq.cpp | 29 +- modules/touch/include/touchmarker.h | 1 - modules/touch/src/touchinteraction.cpp | 19 +- modules/touch/src/touchmarker.cpp | 10 +- modules/volume/envelope.cpp | 357 ++++++++++-------- modules/volume/envelope.h | 114 +++--- .../volume/rendering/basicvolumeraycaster.h | 3 +- modules/volume/transferfunction.cpp | 47 +-- modules/volume/transferfunction.h | 105 +++--- modules/volume/transferfunctionhandler.cpp | 44 +-- modules/volume/transferfunctionhandler.h | 59 ++- modules/volume/transferfunctionproperty.cpp | 44 +-- modules/volume/transferfunctionproperty.h | 52 +-- modules/volume/volumegridtype.cpp | 6 +- modules/volume/volumegridtype.h | 16 +- modules/webbrowser/CMakeLists.txt | 4 +- modules/webbrowser/include/browserclient.h | 4 +- modules/webbrowser/include/browserinstance.h | 11 +- modules/webbrowser/include/cefhost.h | 8 +- .../include/defaultbrowserlauncher.h | 22 +- modules/webbrowser/include/eventhandler.h | 20 +- .../webbrowser/include/screenspacebrowser.h | 23 +- .../include/screenspacerenderhandler.h | 14 +- modules/webbrowser/include/webbrowserapp.h | 14 +- modules/webbrowser/include/webrenderhandler.h | 8 +- modules/webbrowser/src/browserclient.cpp | 2 +- modules/webbrowser/src/browserinstance.cpp | 22 +- modules/webbrowser/src/cefhost.cpp | 12 +- .../webbrowser/src/defaultbrowserlauncher.cpp | 2 +- modules/webbrowser/src/eventhandler.cpp | 25 +- modules/webbrowser/src/processhelpermac.cpp | 2 +- .../webbrowser/src/processhelperwindows.cpp | 17 +- modules/webbrowser/src/screenspacebrowser.cpp | 18 +- .../src/screenspacerenderhandler.cpp | 2 +- modules/webbrowser/src/webbrowserapp.cpp | 2 +- modules/webbrowser/src/webrenderhandler.cpp | 27 +- modules/webbrowser/webbrowsermodule.cpp | 34 +- modules/webbrowser/webbrowsermodule.h | 2 +- modules/webgui/CMakeLists.txt | 2 +- modules/webgui/webguimodule.cpp | 2 +- modules/webgui/webguimodule.h | 11 +- src/engine/configurationmanager.cpp | 75 ---- src/engine/configurationmanager_doc.inl | 23 +- src/engine/downloadmanager.cpp | 4 +- src/engine/openspaceengine.cpp | 7 +- src/engine/virtualpropertymanager.cpp | 4 +- src/engine/wrapper/sgctwindowwrapper.cpp | 7 +- src/interaction/keybindingmanager_lua.inl | 2 +- src/interaction/touchbar.mm | 2 + src/network/parallelconnection.cpp | 15 +- src/network/parallelpeer.cpp | 30 +- src/network/parallelserver.cpp | 12 +- src/properties/binaryproperty.cpp | 46 +-- src/properties/property.cpp | 29 +- src/properties/scalar/ucharproperty.cpp | 2 +- src/rendering/framebufferrenderer.cpp | 4 +- src/rendering/renderengine.cpp | 4 +- src/scene/scene.cpp | 1 - src/scene/scenegraphnode.cpp | 2 +- src/util/httprequest.cpp | 4 +- support/coding/check_style_guide.py | 153 ++++++-- tests/test_rawvolumeio.inl | 2 +- 151 files changed, 1229 insertions(+), 1033 deletions(-) diff --git a/apps/Wormhole/main.cpp b/apps/Wormhole/main.cpp index a688f80a13..92ab97ea96 100644 --- a/apps/Wormhole/main.cpp +++ b/apps/Wormhole/main.cpp @@ -62,7 +62,7 @@ int main(int argc, char** argv) { ); std::stringstream defaultPassword; - defaultPassword << std::hex << std::setfill('0') << std::setw(6) << + defaultPassword << std::hex << std::setfill('0') << std::setw(6) << (std::hash{}( std::chrono::system_clock::now().time_since_epoch().count() ) % 0xffffff); diff --git a/ext/ghoul b/ext/ghoul index fd1187437c..f0e8a06c9a 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit fd1187437c59553f2dba74684b791220cbb8d7fc +Subproject commit f0e8a06c9a92a282d2c7197c9388db1301d797ce diff --git a/ext/sgct b/ext/sgct index 52e2943cd7..03a8cd877e 160000 --- a/ext/sgct +++ b/ext/sgct @@ -1 +1 @@ -Subproject commit 52e2943cd74bb8346db0411bf17ed3dab4245e03 +Subproject commit 03a8cd877e540beb2e4762be6036cf895ee77647 diff --git a/include/openspace/engine/configurationmanager.h b/include/openspace/engine/configurationmanager.h index ac7c325e27..63881b2dd3 100644 --- a/include/openspace/engine/configurationmanager.h +++ b/include/openspace/engine/configurationmanager.h @@ -86,9 +86,10 @@ public: /// The key that stores the factory documentation values static constexpr const char* KeyFactoryDocumentation = "FactoryDocumentation"; - /// The key that decides whether or not we should require incoming web socket connections - /// to authorize or not - static constexpr const char* KeyRequireSocketAuthentication = "RequireSocketAuthentication"; + /// The key that decides whether or not we should require incoming web socket + /// connections to authorize or not + static constexpr const char* KeyRequireSocketAuthentication = + "RequireSocketAuthentication"; /// The key that stores the location of the asset file that is initially loaded static constexpr const char* KeyConfigAsset = "Asset"; diff --git a/include/openspace/network/messagestructures.h b/include/openspace/network/messagestructures.h index e677f1f306..d542d99d68 100644 --- a/include/openspace/network/messagestructures.h +++ b/include/openspace/network/messagestructures.h @@ -206,7 +206,7 @@ struct TimeKeyframe { // Timestamp size = sizeof(_timestamp); memcpy(&_timestamp, buffer.data() + offset, size); - offset += size; + // offset += size; }; }; diff --git a/include/openspace/properties/binaryproperty.h b/include/openspace/properties/binaryproperty.h index d810a8b8b7..443216c6c3 100644 --- a/include/openspace/properties/binaryproperty.h +++ b/include/openspace/properties/binaryproperty.h @@ -1,26 +1,26 @@ /***************************************************************************************** -* * -* 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. * -****************************************************************************************/ + * * + * OpenSpace * + * * + * Copyright (c) 2014-2018 * + * * + * 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___BINARYPROPERTY___H__ #define __OPENSPACE_CORE___BINARYPROPERTY___H__ diff --git a/include/openspace/properties/numericalproperty.h b/include/openspace/properties/numericalproperty.h index 1be4a3a5d9..fb6c75d271 100644 --- a/include/openspace/properties/numericalproperty.h +++ b/include/openspace/properties/numericalproperty.h @@ -70,7 +70,7 @@ public: void setInterpolationTarget(ghoul::any value) override; void setLuaInterpolationTarget(lua_State* state) override; void setStringInterpolationTarget(std::string value) override; - + void interpolateValue(float t, ghoul::EasingFunc easingFunc = nullptr) override; diff --git a/include/openspace/properties/numericalproperty.inl b/include/openspace/properties/numericalproperty.inl index 91fe0ddee6..d4bfc6d9be 100644 --- a/include/openspace/properties/numericalproperty.inl +++ b/include/openspace/properties/numericalproperty.inl @@ -388,10 +388,14 @@ void NumericalProperty::setExponent(float exponent) { template std::string NumericalProperty::generateAdditionalJsonDescription() const { std::string result = "{ "; - result += "\"" + MinimumValueKey + "\": " + luaToJson(std::to_string(_minimumValue)) + ","; - result += "\"" + MaximumValueKey + "\": " + luaToJson(std::to_string(_maximumValue)) + ","; - result += "\"" + SteppingValueKey + "\": " + luaToJson(std::to_string(_stepping)) + ","; - result += "\"" + ExponentValueKey + "\": " + luaToJson(std::to_string(_exponent)); + result += + "\"" + MinimumValueKey + "\": " + luaToJson(std::to_string(_minimumValue)) + ","; + result += + "\"" + MaximumValueKey + "\": " + luaToJson(std::to_string(_maximumValue)) + ","; + result += + "\"" + SteppingValueKey + "\": " + luaToJson(std::to_string(_stepping)) + ","; + result += + "\"" + ExponentValueKey + "\": " + luaToJson(std::to_string(_exponent)); result += " }"; return result; } diff --git a/include/openspace/properties/property.h b/include/openspace/properties/property.h index 4e51e5e740..c90d7b53e3 100644 --- a/include/openspace/properties/property.h +++ b/include/openspace/properties/property.h @@ -396,8 +396,8 @@ public: const ghoul::Dictionary& metaData() const; /** - * Convert the Property into a string containing a JSON representation of the Property. - * Includes description of the object. + * Convert the Property into a string containing a JSON representation of the + * Property. Includes description of the object. * @return the JSON string */ virtual std::string toJson() const; @@ -412,7 +412,7 @@ public: virtual void setInterpolationTarget(ghoul::any value); virtual void setLuaInterpolationTarget(lua_State* state); virtual void setStringInterpolationTarget(std::string value); - + virtual void interpolateValue(float t, ghoul::EasingFunc easingFunction = nullptr); diff --git a/include/openspace/properties/propertyowner.h b/include/openspace/properties/propertyowner.h index fe0d367795..6be2ea0c19 100644 --- a/include/openspace/properties/propertyowner.h +++ b/include/openspace/properties/propertyowner.h @@ -83,8 +83,8 @@ public: /** * Sets the identifier for this PropertyOwner. If the PropertyOwner does not have an * owner itself, the identifier must be globally unique. If the PropertyOwner has an - * owner, the identifier must be unique to the owner (including the owner's - * properties). No uniqueness check will be preformed here, but rather in the + * owner, the identifier must be unique to the owner (including the owner's + * properties). No uniqueness check will be preformed here, but rather in the * PropertyOwner::addProperty and PropertyOwner::addPropertySubOwner methods). * * \param identifier The identifier of this PropertyOwner. It must not contain any @@ -102,7 +102,7 @@ public: std::string identifier() const; /** - * Sets the user-facing name of this PropertyOwner. This name does not have to be + * Sets the user-facing name of this PropertyOwner. This name does not have to be * unique, but it is recommended to be. * * \param guiName The new user-facing name for this PropertyOwner diff --git a/include/openspace/rendering/renderable.h b/include/openspace/rendering/renderable.h index 575045be36..3b6817ed9f 100644 --- a/include/openspace/rendering/renderable.h +++ b/include/openspace/rendering/renderable.h @@ -101,7 +101,7 @@ public: protected: properties::BoolProperty _enabled; properties::FloatProperty _opacity; - + void registerUpdateRenderBinFromOpacity(); private: diff --git a/include/openspace/scene/scene.h b/include/openspace/scene/scene.h index 5321349519..b07c8c3029 100644 --- a/include/openspace/scene/scene.h +++ b/include/openspace/scene/scene.h @@ -176,7 +176,7 @@ public: * Adds an interpolation request for the passed \p prop that will run for * \p durationSeconds seconds. Every time the #updateInterpolations method is called * the Property will be notified that it has to update itself using the stored - * interpolation values. If an interpolation record already exists for the passed + * interpolation values. If an interpolation record already exists for the passed * \p prop, the previous record will be overwritten and the remaining time of the old * interpolation is ignored. * @@ -186,7 +186,7 @@ public: * * \pre \p prop must not be \c nullptr * \pre \p durationSeconds must be positive and not 0 - * \post A new interpolation record exists for \p that is not expired + * \post A new interpolation record exists for \p that is not expired */ void addInterpolation(properties::Property* prop, float durationSeconds, ghoul::EasingFunction easingFunction = ghoul::EasingFunction::Linear); diff --git a/modules/atmosphere/atmospheremodule.cpp b/modules/atmosphere/atmospheremodule.cpp index 226c36ffab..82c50072b9 100644 --- a/modules/atmosphere/atmospheremodule.cpp +++ b/modules/atmosphere/atmospheremodule.cpp @@ -23,16 +23,15 @@ ****************************************************************************************/ #include + +#include +#include #include #include -#include - -#include - namespace openspace { -AtmosphereModule::AtmosphereModule() : OpenSpaceModule("Atmosphere") {} +AtmosphereModule::AtmosphereModule() : OpenSpaceModule(Name) {} void AtmosphereModule::internalInitialize(const ghoul::Dictionary&) { auto fRenderable = FactoryManager::ref().factory(); diff --git a/modules/atmosphere/atmospheremodule.h b/modules/atmosphere/atmospheremodule.h index 3553d9f3e6..e66485f29e 100644 --- a/modules/atmosphere/atmospheremodule.h +++ b/modules/atmosphere/atmospheremodule.h @@ -26,12 +26,13 @@ #define __OPENSPACE_MODULE_ATMOSPHERE___ATMOSPHERE_MODULE___H__ #include -#include namespace openspace { class AtmosphereModule : public OpenSpaceModule { public: + constexpr static const char* Name = "Atmosphere"; + AtmosphereModule(); private: diff --git a/modules/atmosphere/rendering/atmospheredeferredcaster.cpp b/modules/atmosphere/rendering/atmospheredeferredcaster.cpp index 21692091ec..fb44789aad 100644 --- a/modules/atmosphere/rendering/atmospheredeferredcaster.cpp +++ b/modules/atmosphere/rendering/atmospheredeferredcaster.cpp @@ -59,14 +59,8 @@ */ #include -#include -#include -#include -#include -#include -#include -#include +#include #include #include #include @@ -74,12 +68,17 @@ #include #include #include +#include +#include +#include +#include +#include +#include #include #include #include #include #include - #include #include @@ -90,16 +89,16 @@ namespace { - const char* _loggerCat = "AtmosphereDeferredcaster"; - const char* GlslDeferredcastPath = + constexpr const char* _loggerCat = "AtmosphereDeferredcaster"; + constexpr const char* GlslDeferredcastPath = "${MODULES}/atmosphere/shaders/atmosphere_deferred_fs.glsl"; - const char* GlslDeferredcastFSPath = + constexpr const char* GlslDeferredcastFSPath = "${MODULES}/atmosphere/shaders/atmosphere_deferred_fs.glsl"; - const char* GlslDeferredcastVsPath = + constexpr const char* GlslDeferredcastVsPath = "${MODULES}/atmosphere/shaders/atmosphere_deferred_vs.glsl"; - const float ATM_EPS = 2.0; - const double KM_TO_M = 1000.0; + constexpr const float ATM_EPS = 2.f; + constexpr const float KM_TO_M = 1000.f; } // namespace namespace openspace { diff --git a/modules/atmosphere/shaders/atmosphere_deferred_vs.glsl b/modules/atmosphere/shaders/atmosphere_deferred_vs.glsl index 9568c60136..76fae77721 100644 --- a/modules/atmosphere/shaders/atmosphere_deferred_vs.glsl +++ b/modules/atmosphere/shaders/atmosphere_deferred_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/deltaE_calc_fs.glsl b/modules/atmosphere/shaders/deltaE_calc_fs.glsl index bacc9e0734..ce445632c9 100644 --- a/modules/atmosphere/shaders/deltaE_calc_fs.glsl +++ b/modules/atmosphere/shaders/deltaE_calc_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/deltaE_calc_vs.glsl b/modules/atmosphere/shaders/deltaE_calc_vs.glsl index 578d7ab02f..b379e97bfe 100644 --- a/modules/atmosphere/shaders/deltaE_calc_vs.glsl +++ b/modules/atmosphere/shaders/deltaE_calc_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/deltaJ_calc_fs.glsl b/modules/atmosphere/shaders/deltaJ_calc_fs.glsl index 9598e4d5c9..80f02f1862 100644 --- a/modules/atmosphere/shaders/deltaJ_calc_fs.glsl +++ b/modules/atmosphere/shaders/deltaJ_calc_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/deltaJ_calc_gs.glsl b/modules/atmosphere/shaders/deltaJ_calc_gs.glsl index a4dd2d50b5..eb98fa1059 100644 --- a/modules/atmosphere/shaders/deltaJ_calc_gs.glsl +++ b/modules/atmosphere/shaders/deltaJ_calc_gs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/deltaJ_calc_vs.glsl b/modules/atmosphere/shaders/deltaJ_calc_vs.glsl index 578d7ab02f..b379e97bfe 100644 --- a/modules/atmosphere/shaders/deltaJ_calc_vs.glsl +++ b/modules/atmosphere/shaders/deltaJ_calc_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/deltaS_calc_fs.glsl b/modules/atmosphere/shaders/deltaS_calc_fs.glsl index 014cd535fb..1f66741387 100644 --- a/modules/atmosphere/shaders/deltaS_calc_fs.glsl +++ b/modules/atmosphere/shaders/deltaS_calc_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -21,7 +21,7 @@ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ - + #version __CONTEXT__ #include "atmosphere_common.glsl" diff --git a/modules/atmosphere/shaders/deltaS_calc_gs.glsl b/modules/atmosphere/shaders/deltaS_calc_gs.glsl index a4dd2d50b5..eb98fa1059 100644 --- a/modules/atmosphere/shaders/deltaS_calc_gs.glsl +++ b/modules/atmosphere/shaders/deltaS_calc_gs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/deltaS_calc_vs.glsl b/modules/atmosphere/shaders/deltaS_calc_vs.glsl index 578d7ab02f..b379e97bfe 100644 --- a/modules/atmosphere/shaders/deltaS_calc_vs.glsl +++ b/modules/atmosphere/shaders/deltaS_calc_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/deltaS_sup_calc_fs.glsl b/modules/atmosphere/shaders/deltaS_sup_calc_fs.glsl index 09cf5026b3..0fc114328c 100644 --- a/modules/atmosphere/shaders/deltaS_sup_calc_fs.glsl +++ b/modules/atmosphere/shaders/deltaS_sup_calc_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/deltaS_sup_calc_gs.glsl b/modules/atmosphere/shaders/deltaS_sup_calc_gs.glsl index 8ca6044fd1..15b4964390 100644 --- a/modules/atmosphere/shaders/deltaS_sup_calc_gs.glsl +++ b/modules/atmosphere/shaders/deltaS_sup_calc_gs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/deltaS_sup_calc_vs.glsl b/modules/atmosphere/shaders/deltaS_sup_calc_vs.glsl index 7e3574bd9d..7cb84d0439 100644 --- a/modules/atmosphere/shaders/deltaS_sup_calc_vs.glsl +++ b/modules/atmosphere/shaders/deltaS_sup_calc_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/inScattering_calc_fs.glsl b/modules/atmosphere/shaders/inScattering_calc_fs.glsl index a55cbc78e1..f93fd6c304 100644 --- a/modules/atmosphere/shaders/inScattering_calc_fs.glsl +++ b/modules/atmosphere/shaders/inScattering_calc_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/inScattering_calc_gs.glsl b/modules/atmosphere/shaders/inScattering_calc_gs.glsl index aed3744bd2..93935134c4 100644 --- a/modules/atmosphere/shaders/inScattering_calc_gs.glsl +++ b/modules/atmosphere/shaders/inScattering_calc_gs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/inScattering_calc_vs.glsl b/modules/atmosphere/shaders/inScattering_calc_vs.glsl index 578d7ab02f..b379e97bfe 100644 --- a/modules/atmosphere/shaders/inScattering_calc_vs.glsl +++ b/modules/atmosphere/shaders/inScattering_calc_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/inScattering_sup_calc_fs.glsl b/modules/atmosphere/shaders/inScattering_sup_calc_fs.glsl index c7c4f09561..e07de3be1d 100644 --- a/modules/atmosphere/shaders/inScattering_sup_calc_fs.glsl +++ b/modules/atmosphere/shaders/inScattering_sup_calc_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/inScattering_sup_calc_gs.glsl b/modules/atmosphere/shaders/inScattering_sup_calc_gs.glsl index 8ca6044fd1..15b4964390 100644 --- a/modules/atmosphere/shaders/inScattering_sup_calc_gs.glsl +++ b/modules/atmosphere/shaders/inScattering_sup_calc_gs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/inScattering_sup_calc_vs.glsl b/modules/atmosphere/shaders/inScattering_sup_calc_vs.glsl index 7e3574bd9d..7cb84d0439 100644 --- a/modules/atmosphere/shaders/inScattering_sup_calc_vs.glsl +++ b/modules/atmosphere/shaders/inScattering_sup_calc_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/irradiance_calc_fs.glsl b/modules/atmosphere/shaders/irradiance_calc_fs.glsl index 48cc7ce40f..7042c6bddd 100644 --- a/modules/atmosphere/shaders/irradiance_calc_fs.glsl +++ b/modules/atmosphere/shaders/irradiance_calc_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/irradiance_calc_vs.glsl b/modules/atmosphere/shaders/irradiance_calc_vs.glsl index 578d7ab02f..b379e97bfe 100644 --- a/modules/atmosphere/shaders/irradiance_calc_vs.glsl +++ b/modules/atmosphere/shaders/irradiance_calc_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/irradiance_final_fs.glsl b/modules/atmosphere/shaders/irradiance_final_fs.glsl index 47771e8898..a0800fc507 100644 --- a/modules/atmosphere/shaders/irradiance_final_fs.glsl +++ b/modules/atmosphere/shaders/irradiance_final_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -21,6 +21,7 @@ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ + #version __CONTEXT__ #include "atmosphere_common.glsl" diff --git a/modules/atmosphere/shaders/irradiance_final_vs.glsl b/modules/atmosphere/shaders/irradiance_final_vs.glsl index f55a966566..e266156549 100644 --- a/modules/atmosphere/shaders/irradiance_final_vs.glsl +++ b/modules/atmosphere/shaders/irradiance_final_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/irradiance_sup_calc_fs.glsl b/modules/atmosphere/shaders/irradiance_sup_calc_fs.glsl index 005e1db59a..cdf31ca38c 100644 --- a/modules/atmosphere/shaders/irradiance_sup_calc_fs.glsl +++ b/modules/atmosphere/shaders/irradiance_sup_calc_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/irradiance_sup_calc_vs.glsl b/modules/atmosphere/shaders/irradiance_sup_calc_vs.glsl index 578d7ab02f..b379e97bfe 100644 --- a/modules/atmosphere/shaders/irradiance_sup_calc_vs.glsl +++ b/modules/atmosphere/shaders/irradiance_sup_calc_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/transmittance_calc_fs.glsl b/modules/atmosphere/shaders/transmittance_calc_fs.glsl index 7f57a7e0b2..411565b06c 100644 --- a/modules/atmosphere/shaders/transmittance_calc_fs.glsl +++ b/modules/atmosphere/shaders/transmittance_calc_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/transmittance_calc_vs.glsl b/modules/atmosphere/shaders/transmittance_calc_vs.glsl index d9ea954427..6e457a03e6 100644 --- a/modules/atmosphere/shaders/transmittance_calc_vs.glsl +++ b/modules/atmosphere/shaders/transmittance_calc_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/base/dashboard/dashboarditemangle.cpp b/modules/base/dashboard/dashboarditemangle.cpp index 181956704a..56843babde 100644 --- a/modules/base/dashboard/dashboarditemangle.cpp +++ b/modules/base/dashboard/dashboarditemangle.cpp @@ -32,15 +32,14 @@ #include #include #include - #include #include #include namespace { - const char* KeyFontMono = "Mono"; + constexpr const char* KeyFontMono = "Mono"; - const float DefaultFontSize = 10.f; + constexpr const float DefaultFontSize = 10.f; static const openspace::properties::Property::PropertyInfo FontNameInfo = { "FontName", @@ -106,6 +105,7 @@ namespace openspace { documentation::Documentation DashboardItemAngle::Documentation() { using namespace documentation; + return { "DashboardItem Angle", "base_dashboarditem_angle", diff --git a/modules/base/dashboard/dashboarditemangle.h b/modules/base/dashboard/dashboarditemangle.h index f61a23fbcf..34fdbdabee 100644 --- a/modules/base/dashboard/dashboarditemangle.h +++ b/modules/base/dashboard/dashboarditemangle.h @@ -30,7 +30,6 @@ #include #include #include - #include namespace ghoul::fontrendering { class Font; } diff --git a/modules/base/dashboard/dashboarditemdate.h b/modules/base/dashboard/dashboarditemdate.h index 8698948475..37e3f9b95b 100644 --- a/modules/base/dashboard/dashboarditemdate.h +++ b/modules/base/dashboard/dashboarditemdate.h @@ -30,9 +30,7 @@ #include #include -namespace ghoul::fontrendering { - class Font; -} // namespace ghoul::fontrendering +namespace ghoul::fontrendering { class Font; } namespace openspace { diff --git a/modules/base/rendering/renderableplane.cpp b/modules/base/rendering/renderableplane.cpp index 3562b480b1..7e4911415b 100644 --- a/modules/base/rendering/renderableplane.cpp +++ b/modules/base/rendering/renderableplane.cpp @@ -176,7 +176,7 @@ void RenderablePlane::initializeGL() { absPath("${MODULE_BASE}/shaders/plane_fs.glsl") ); } - ); + ); } void RenderablePlane::deinitializeGL() { diff --git a/modules/base/rendering/screenspacedashboard.cpp b/modules/base/rendering/screenspacedashboard.cpp index 5f9ea9e638..33730c82e2 100644 --- a/modules/base/rendering/screenspacedashboard.cpp +++ b/modules/base/rendering/screenspacedashboard.cpp @@ -42,8 +42,6 @@ #include namespace { - const char* KeyName = "Name"; - static const openspace::properties::Property::PropertyInfo UseMainInfo = { "UseMainDashboard", "Use main dashboard", diff --git a/modules/base/rendering/screenspaceimagelocal.cpp b/modules/base/rendering/screenspaceimagelocal.cpp index e42c33db64..86d6705918 100644 --- a/modules/base/rendering/screenspaceimagelocal.cpp +++ b/modules/base/rendering/screenspaceimagelocal.cpp @@ -37,8 +37,6 @@ #include namespace { - const char* KeyName = "Name"; - static const openspace::properties::Property::PropertyInfo TexturePathInfo = { "TexturePath", "Texture path", diff --git a/modules/base/rendering/screenspaceimageonline.cpp b/modules/base/rendering/screenspaceimageonline.cpp index 4df3149a8e..8940ec8fa1 100644 --- a/modules/base/rendering/screenspaceimageonline.cpp +++ b/modules/base/rendering/screenspaceimageonline.cpp @@ -36,8 +36,6 @@ #include namespace { - constexpr const char* KeyName = "Name"; - static const openspace::properties::Property::PropertyInfo TextureInfo = { "URL", "Image URL", diff --git a/modules/base/rotation/fixedrotation.cpp b/modules/base/rotation/fixedrotation.cpp index fdcb009971..bba3dc1566 100644 --- a/modules/base/rotation/fixedrotation.cpp +++ b/modules/base/rotation/fixedrotation.cpp @@ -335,7 +335,7 @@ FixedRotation::FixedRotation(const ghoul::Dictionary& dictionary) _attachedNode = sceneGraphNode(_attachedObject); }); - auto setPropertyVisibility = [this](Axis& axis) { + auto setPropertyVisibility = [](Axis& axis) { using Visibility = properties::Property::Visibility; switch (axis.type) { case Axis::Type::Object: diff --git a/modules/cefwebgui/CMakeLists.txt b/modules/cefwebgui/CMakeLists.txt index 32f763226c..d61943247a 100644 --- a/modules/cefwebgui/CMakeLists.txt +++ b/modules/cefwebgui/CMakeLists.txt @@ -2,7 +2,7 @@ # # # OpenSpace # # # -# Copyright (c) 2014-2017 # +# Copyright (c) 2014-2018 # # # # 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 # diff --git a/modules/cefwebgui/cefwebguimodule.cpp b/modules/cefwebgui/cefwebguimodule.cpp index 123b69cd34..3186b1d326 100644 --- a/modules/cefwebgui/cefwebguimodule.cpp +++ b/modules/cefwebgui/cefwebguimodule.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/cefwebgui/cefwebguimodule.h b/modules/cefwebgui/cefwebguimodule.h index 576bc39927..7c0bc93584 100644 --- a/modules/cefwebgui/cefwebguimodule.h +++ b/modules/cefwebgui/cefwebguimodule.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef OPENSPACE_CEFWEBGUIMODULE_H -#define OPENSPACE_CEFWEBGUIMODULE_H +#ifndef __OPENSPACE_MODULE_CEFWEBGUI___CEFWEBGUIMODULE___H__ +#define __OPENSPACE_MODULE_CEFWEBGUI___CEFWEBGUIMODULE___H__ #include #include @@ -45,4 +45,4 @@ private: } -#endif //OPENSPACE_WEBGUIMODULE_H +#endif // __OPENSPACE_MODULE_CEFWEBGUI___CEFWEBGUIMODULE___H__ diff --git a/modules/cefwebgui/include/guirenderhandler.h b/modules/cefwebgui/include/guirenderhandler.h index 88da19389e..659a5e5184 100644 --- a/modules/cefwebgui/include/guirenderhandler.h +++ b/modules/cefwebgui/include/guirenderhandler.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_MODULE_WEBBROWSER___GUI_RENDER_HANDLER___H__ -#define __OPENSPACE_MODULE_WEBBROWSER___GUI_RENDER_HANDLER___H__ +#ifndef __OPENSPACE_MODULE_CEFWEBGUI___GUI_RENDER_HANDLER___H__ +#define __OPENSPACE_MODULE_CEFWEBGUI___GUI_RENDER_HANDLER___H__ #include #include @@ -41,14 +41,16 @@ public: GUIRenderHandler(); void initializeGL(); - void draw(void); + void draw(); void render() {}; private: std::unique_ptr _programObject; - GLuint _program, _vao, _vbo; + GLuint _program; + GLuint _vao; + GLuint _vbo; }; } // namespace openspace -#endif // __OPENSPACE_MODULE_WEBBROWSER___GUI_RENDER_HANDLER___H__ +#endif // __OPENSPACE_MODULE_CEFWEBGUI___GUI_RENDER_HANDLER___H__ diff --git a/modules/cefwebgui/src/guirenderhandler.cpp b/modules/cefwebgui/src/guirenderhandler.cpp index 047c632e0e..d4de455ab2 100644 --- a/modules/cefwebgui/src/guirenderhandler.cpp +++ b/modules/cefwebgui/src/guirenderhandler.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp b/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp index 81583ee16f..70b487955a 100644 --- a/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp +++ b/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp @@ -452,7 +452,9 @@ bool RenderableFieldlinesSequence::extractMandatoryInfoFromDictionary( } else { LERROR(fmt::format( - "{}: FieldlinesSequence {} is not a valid directory", _identifier, sourceFolderPath + "{}: FieldlinesSequence {} is not a valid directory", + _identifier, + sourceFolderPath )); return false; } diff --git a/modules/globebrowsing/rendering/layershadermanager.cpp b/modules/globebrowsing/rendering/layershadermanager.cpp index 9108e4f814..cbe2ea6588 100644 --- a/modules/globebrowsing/rendering/layershadermanager.cpp +++ b/modules/globebrowsing/rendering/layershadermanager.cpp @@ -219,7 +219,10 @@ void LayerShaderManager::recompileShaderProgram( ghoul::Dictionary layerGroupNames; for (int i = 0; i < layergroupid::NUM_LAYER_GROUPS; ++i) { - layerGroupNames.setValue(std::to_string(i), layergroupid::LAYER_GROUP_IDENTIFIERS[i]); + layerGroupNames.setValue( + std::to_string(i), + layergroupid::LAYER_GROUP_IDENTIFIERS[i] + ); } shaderDictionary.setValue("layerGroups", layerGroupNames); diff --git a/modules/imgui/src/guiglobebrowsingcomponent.cpp b/modules/imgui/src/guiglobebrowsingcomponent.cpp index 83e2a12f5d..a2606ba5a2 100644 --- a/modules/imgui/src/guiglobebrowsingcomponent.cpp +++ b/modules/imgui/src/guiglobebrowsingcomponent.cpp @@ -79,7 +79,7 @@ void GuiGlobeBrowsingComponent::render() { std::remove_if( nodes.begin(), nodes.end(), - [module](SceneGraphNode* n) { + [](SceneGraphNode* n) { Renderable* r = n->renderable(); return !r || r->identifier() != "RenderableGlobe"; } diff --git a/modules/kameleon/src/kameleonwrapper.cpp b/modules/kameleon/src/kameleonwrapper.cpp index 621a6c45ae..befdf6a92a 100644 --- a/modules/kameleon/src/kameleonwrapper.cpp +++ b/modules/kameleon/src/kameleonwrapper.cpp @@ -226,15 +226,15 @@ float* KameleonWrapper::getUniformSampledValues( LDEBUG(fmt::format("{} Max: {}", var, varMax)); // HISTOGRAM - const int bins = 200; + constexpr const int NBins = 200; const float truncLim = 0.9f; - std::vector histogram (bins,0); - auto mapToHistogram = [varMin, varMax, bins](double val) { + std::vector histogram (NBins, 0); + auto mapToHistogram = [NBins, varMin, varMax](double val) { double zeroToOne = (val-varMin)/(varMax-varMin); - zeroToOne *= static_cast(bins); + zeroToOne *= static_cast(NBins); int izerotoone = static_cast(zeroToOne); - return glm::clamp(izerotoone, 0, bins-1); + return glm::clamp(izerotoone, 0, NBins - 1); }; //ProgressBar pb(static_cast(outDimensions.x)); @@ -332,7 +332,7 @@ float* KameleonWrapper::getUniformSampledValues( // std::cout << std::endl; //} // - // for(int i = 0; i < bins-1; ++i) { + // for(int i = 0; i < NBins-1; ++i) { // // sum += histogram[i]; // // if(sum + histogram[i+1] > sumuntil) { // // stop = i; @@ -345,7 +345,7 @@ float* KameleonWrapper::getUniformSampledValues( int sum = 0; int stop = 0; const int sumuntil = static_cast(static_cast(size) * truncLim); - for(int i = 0; i < bins; ++i) { + for(int i = 0; i < NBins; ++i) { sum += histogram[i]; if(sum > sumuntil) { stop = i; @@ -356,7 +356,7 @@ float* KameleonWrapper::getUniformSampledValues( } double dist = varMax - varMin; - dist = (dist / static_cast(bins)) * static_cast(stop); + dist = (dist / static_cast(NBins)) * static_cast(stop); varMax = varMin + dist; //LDEBUG(var << "Min: " << varMin); diff --git a/modules/kameleonvolume/kameleonvolumereader.cpp b/modules/kameleonvolume/kameleonvolumereader.cpp index bbf9b30caa..1f547b303b 100644 --- a/modules/kameleonvolume/kameleonvolumereader.cpp +++ b/modules/kameleonvolume/kameleonvolumereader.cpp @@ -114,7 +114,7 @@ std::unique_ptr> KameleonVolumeReader::readFloatVolume( volumeCoords[2]); }; - auto sample = [this, &variable, &interpolate](glm::vec3 volumeCoords) { + auto sample = [&variable, &interpolate](glm::vec3 volumeCoords) { return interpolate(variable, volumeCoords); }; diff --git a/modules/kameleonvolume/kameleonvolumereader.h b/modules/kameleonvolume/kameleonvolumereader.h index 96d49b1931..0ff6011639 100644 --- a/modules/kameleonvolume/kameleonvolumereader.h +++ b/modules/kameleonvolume/kameleonvolumereader.h @@ -74,7 +74,7 @@ public: std::string simulationEnd() const; std::string getVisUnit(const std::string& variable) const; float elapsedTime() const; - + double minValue(const std::string& variable) const; double maxValue(const std::string& variable) const; diff --git a/modules/kameleonvolume/rendering/renderablekameleonvolume.cpp b/modules/kameleonvolume/rendering/renderablekameleonvolume.cpp index c0c16da95a..90367eaa51 100644 --- a/modules/kameleonvolume/rendering/renderablekameleonvolume.cpp +++ b/modules/kameleonvolume/rendering/renderablekameleonvolume.cpp @@ -172,7 +172,9 @@ RenderableKameleonVolume::RenderableKameleonVolume(const ghoul::Dictionary& dict std::string transferFunctionPath; if (dictionary.getValue(KeyTransferFunction, transferFunctionPath)) { _transferFunctionPath = transferFunctionPath; - _transferFunctionHandler = std::make_shared(_transferFunctionPath); + _transferFunctionHandler = std::make_shared( + _transferFunctionPath + ); } std::string sourcePath; @@ -263,7 +265,11 @@ void RenderableKameleonVolume::initializeGL() { _volumeTexture->uploadTexture(); _transferFunctionHandler->initialize(); - _raycaster = std::make_unique(_volumeTexture, _transferFunctionHandler, _clipPlanes); + _raycaster = std::make_unique( + _volumeTexture, + _transferFunctionHandler, + _clipPlanes + ); _raycaster->setStepSize(_stepSize); _gridType.onChange([this] { diff --git a/modules/kameleonvolume/tasks/kameleonvolumetorawtask.cpp b/modules/kameleonvolume/tasks/kameleonvolumetorawtask.cpp index 2fdd160b73..92cb361e8f 100644 --- a/modules/kameleonvolume/tasks/kameleonvolumetorawtask.cpp +++ b/modules/kameleonvolume/tasks/kameleonvolumetorawtask.cpp @@ -51,8 +51,6 @@ namespace { constexpr const char* KeyMaxValue = "MaxValue"; constexpr const char* KeyVisUnit = "VisUnit"; - constexpr const char* _loggerCat = "KameleonVolumeToRawTask"; - } // namespace namespace openspace { diff --git a/modules/server/CMakeLists.txt b/modules/server/CMakeLists.txt index 848a3001a7..f5755ab4ac 100644 --- a/modules/server/CMakeLists.txt +++ b/modules/server/CMakeLists.txt @@ -2,7 +2,7 @@ # # # OpenSpace # # # -# Copyright (c) 2014-2017 # +# Copyright (c) 2014-2018 # # # # 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 # diff --git a/modules/server/include/authorizationtopic.h b/modules/server/include/authorizationtopic.h index edd6b83951..7c666a0039 100644 --- a/modules/server/include/authorizationtopic.h +++ b/modules/server/include/authorizationtopic.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef OPENSPACE_MODULES_SERVER__AUTHENTICATION_TOPIC_H -#define OPENSPACE_MODULES_SERVER__AUTHENTICATION_TOPIC_H +#ifndef __OPENSPACE_MODULE_SERVER___AUTHORIZATION_TOPIC___H__ +#define __OPENSPACE_MODULE_SERVER___AUTHORIZATION_TOPIC___H__ #include #include @@ -38,7 +38,6 @@ namespace openspace { class AuthorizationTopic : public Topic { public: AuthorizationTopic(); - ~AuthorizationTopic() {}; void handleJson(nlohmann::json json); bool isDone(); @@ -53,14 +52,16 @@ public: NotImplemented = 501 }; + private: bool _isAuthenticated; const std::string getKey() const; bool authorize(const std::string key); - nlohmann::json message(const std::string &message, StatusCode statusCode = StatusCode::NotImplemented); + nlohmann::json message(const std::string &message, + StatusCode statusCode = StatusCode::NotImplemented); }; -} +} // namespace openspace -#endif //OPENSPACE_MODULES_SERVER__AUTHENTICATION_TOPIC_H +#endif // __OPENSPACE_MODULE_SERVER___AUTHORIZATION_TOPIC___H__ diff --git a/modules/server/include/connection.h b/modules/server/include/connection.h index 9c9097ddb6..3cc26508f2 100644 --- a/modules/server/include/connection.h +++ b/modules/server/include/connection.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef OPENSPACE_MODOULES_SERVER__CONNECTION_H -#define OPENSPACE_MODOULES_SERVER__CONNECTION_H +#ifndef __OPENSPACE_MODULE_SERVER___CONNECTION___H__ +#define __OPENSPACE_MODULE_SERVER___CONNECTION___H__ #include #include @@ -53,8 +53,7 @@ public: void setAuthorized(const bool status); bool isAuthorized(); - - + std::shared_ptr socket(); std::thread& thread(); void setThread(std::thread&& thread); @@ -74,6 +73,6 @@ private: bool isWhitelisted(); }; -} +} // namespace openspace -#endif //OPENSPACE_MODOULES_SERVER__CONNECTION_H +#endif // __OPENSPACE_MODULE_SERVER___CONNECTION___H__ diff --git a/modules/server/include/connectionpool.h b/modules/server/include/connectionpool.h index f040cc9ff5..3f5ce55a21 100644 --- a/modules/server/include/connectionpool.h +++ b/modules/server/include/connectionpool.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -27,7 +27,6 @@ #include - #include #include #include @@ -36,25 +35,25 @@ #include #include - namespace openspace { class ConnectionPool { public: - ConnectionPool(std::function socket)> handleSocket); + ConnectionPool( + std::function socket)> handleSocket); ~ConnectionPool(); + void addServer(std::shared_ptr server); void removeServer(ghoul::io::SocketServer* server); void clearServers(); void updateConnections(); - -private: +private: void disconnectAllConnections(); std::mutex _connectionMutex; void removeDisconnectedSockets(); void acceptNewSockets(); - + std::function)> _handleSocket; std::vector> _socketServers; std::vector> _sockets; diff --git a/modules/server/include/getpropertytopic.h b/modules/server/include/getpropertytopic.h index fe00c2dcec..c8190577b8 100644 --- a/modules/server/include/getpropertytopic.h +++ b/modules/server/include/getpropertytopic.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef OPENSPACE_MODULES_SERVER__GETPROPERTY_TOPIC_H -#define OPENSPACE_MODULES_SERVER__GETPROPERTY_TOPIC_H +#ifndef __OPENSPACE_MODULE_SERVER___GETPROPERTY_TOPIC___H__ +#define __OPENSPACE_MODULE_SERVER___GETPROPERTY_TOPIC___H__ #include #include "topic.h" @@ -43,6 +43,6 @@ private: nlohmann::json getPropertyFromKey(const std::string& key); }; -} +} // namespace openspace -#endif //OPENSPACE_MODULES_SERVER__GETPROPERTY_TOPIC_H +#endif // __OPENSPACE_MODULE_SERVER___GETPROPERTY_TOPIC___H__ diff --git a/modules/server/include/jsonconverters.h b/modules/server/include/jsonconverters.h index b3009ddefb..0b7a4e2aec 100644 --- a/modules/server/include/jsonconverters.h +++ b/modules/server/include/jsonconverters.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef OPENSPACE_MODULES_SERVER__JSON_CONVERTERS_INL -#define OPENSPACE_MODULES_SERVER__JSON_CONVERTERS_INL +#ifndef __OPENSPACE_MODULE_SERVER___JSON_CONVERTERS___H__ +#define __OPENSPACE_MODULE_SERVER___JSON_CONVERTERS___H__ #include #include @@ -56,6 +56,6 @@ namespace glm { void to_json(json &j, const dvec3 &v); -} +} // namespace glm -#endif +#endif // __OPENSPACE_MODULE_SERVER___JSON_CONVERTERS___H__ diff --git a/modules/server/include/luascripttopic.h b/modules/server/include/luascripttopic.h index 0312259d17..0c45bcc305 100644 --- a/modules/server/include/luascripttopic.h +++ b/modules/server/include/luascripttopic.h @@ -1,29 +1,29 @@ /***************************************************************************************** -* * -* 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. * -****************************************************************************************/ + * * + * OpenSpace * + * * + * Copyright (c) 2014-2018 * + * * + * 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_MODULES_SERVER__LUASCRIPTTOPIC_H -#define OPENSPACE_MODULES_SERVER__LUASCRIPTTOPIC_H +#ifndef __OPENSPACE_MODULE_SERVER___LUASCRIPTTOPIC___H__ +#define __OPENSPACE_MODULE_SERVER___LUASCRIPTTOPIC___H__ #include #include @@ -38,6 +38,6 @@ public: bool isDone() { return true; }; }; -} +} // namespace openspace -#endif //OPENSPACE_MODULES_SERVER__LUASCRIPTTOPIC_H +#endif // __OPENSPACE_MODULE_SERVER___LUASCRIPTTOPIC___H__ diff --git a/modules/server/include/setpropertytopic.h b/modules/server/include/setpropertytopic.h index 45d760a50e..0ccd39da3e 100644 --- a/modules/server/include/setpropertytopic.h +++ b/modules/server/include/setpropertytopic.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef OPENSPACE_MODULES_SERVER__SETPROPERTYTOPIC_H -#define OPENSPACE_MODULES_SERVER__SETPROPERTYTOPIC_H +#ifndef __OPENSPACE_MODULE_SERVER___SETPROPERTYTOPIC___H__ +#define __OPENSPACE_MODULE_SERVER___SETPROPERTYTOPIC___H__ #include #include @@ -41,6 +41,6 @@ private: void setTime(const std::string& value); }; -} +} // namespace -#endif //OPENSPACE_MODULES_SERVER__SETPROPERTYTOPIC_H +#endif // __OPENSPACE_MODULE_SERVER___SETPROPERTYTOPIC___H__ diff --git a/modules/server/include/subscriptiontopic.h b/modules/server/include/subscriptiontopic.h index ec7190887b..f805ee6cad 100644 --- a/modules/server/include/subscriptiontopic.h +++ b/modules/server/include/subscriptiontopic.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef OPENSPACE_MODULES_SERVER__SUBSCRIPTION_TOPIC_H -#define OPENSPACE_MODULES_SERVER__SUBSCRIPTION_TOPIC_H +#ifndef __OPENSPACE_MODULE_SERVER___SUBSCRIPTION_TOPIC___H__ +#define __OPENSPACE_MODULE_SERVER___SUBSCRIPTION_TOPIC___H__ #include #include @@ -47,6 +47,6 @@ private: properties::Property* _prop; }; -} +} // namespace openspace -#endif //OPENSPACE_MODULES_SERVER__SUBSCRIPTION_TOPIC_H +#endif // __OPENSPACE_MODULE_SERVER___SUBSCRIPTION_TOPIC___H__ diff --git a/modules/server/include/timetopic.h b/modules/server/include/timetopic.h index 884223380d..00d314984d 100644 --- a/modules/server/include/timetopic.h +++ b/modules/server/include/timetopic.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef OPENSPACE_MODULES_SERVER__TIME_TOPIC_H -#define OPENSPACE_MODULES_SERVER__TIME_TOPIC_H +#ifndef __OPENSPACE_MODULE_SERVER___TIME_TOPIC___H__ +#define __OPENSPACE_MODULE_SERVER___TIME_TOPIC___H__ #include #include "topic.h" @@ -36,7 +36,8 @@ public: ~TimeTopic(); void handleJson(nlohmann::json json); bool isDone(); -private: + +private: nlohmann::json currentTime(); nlohmann::json deltaTime(); @@ -45,6 +46,6 @@ private: std::chrono::system_clock::time_point _lastUpdateTime; }; -} +} // namespace openspace -#endif //OPENSPACE_MODULES_SERVER__TIME_TOPIC_H +#endif // __OPENSPACE_MODULE_SERVER___TIME_TOPIC___H__ diff --git a/modules/server/include/topic.h b/modules/server/include/topic.h index 7f233ef0a1..f3ed19938b 100644 --- a/modules/server/include/topic.h +++ b/modules/server/include/topic.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef OPENSPACE_MODULES_SERVER__TOPIC_H -#define OPENSPACE_MODULES_SERVER__TOPIC_H +#ifndef __OPENSPACE_MODULE_SERVER___TOPIC___H__ +#define __OPENSPACE_MODULE_SERVER___TOPIC___H__ #include @@ -34,10 +34,12 @@ class Connection; class Topic { public: Topic() {}; - virtual ~Topic() {}; + virtual ~Topic() = default; + void initialize(Connection* connection, size_t topicId); nlohmann::json wrappedPayload(const nlohmann::json &payload) const; - nlohmann::json wrappedError(std::string message = "Could not complete request.", int code = 500); + nlohmann::json wrappedError(std::string message = "Could not complete request.", + int code = 500); virtual void handleJson(nlohmann::json json) = 0; virtual bool isDone() = 0; @@ -54,6 +56,6 @@ public: bool isDone() { return false; } }; -} +} // namespace openspace -#endif //OPENSPACE_MODULES_SERVER__TOPIC_H +#endif // __OPENSPACE_MODULE_SERVER___TOPIC___H__ diff --git a/modules/server/include/triggerpropertytopic.h b/modules/server/include/triggerpropertytopic.h index 67ebc74e1b..f8deb135e5 100644 --- a/modules/server/include/triggerpropertytopic.h +++ b/modules/server/include/triggerpropertytopic.h @@ -1,29 +1,29 @@ /***************************************************************************************** -* * -* 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. * -****************************************************************************************/ + * * + * OpenSpace * + * * + * Copyright (c) 2014-2018 * + * * + * 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_MODULES_SERVER__TRIGGERPROPERTYTOPIC_H -#define OPENSPACE_MODULES_SERVER__TRIGGERPROPERTYTOPIC_H +#ifndef __OPENSPACE_MODULE_SERVER___TRIGGERPROPERTYTOPIC___H__ +#define __OPENSPACE_MODULE_SERVER___TRIGGERPROPERTYTOPIC___H__ #include #include @@ -38,6 +38,6 @@ public: bool isDone() { return true; }; }; -} +} // namespace -#endif //OPENSPACE_MODULES_SERVER__TRIGGERPROPERTYTOPIC_H +#endif // __OPENSPACE_MODULE_SERVER___TRIGGERPROPERTYTOPIC___H__ diff --git a/modules/server/servermodule.cpp b/modules/server/servermodule.cpp index 7e2882e884..d1ef4b59d9 100644 --- a/modules/server/servermodule.cpp +++ b/modules/server/servermodule.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -87,7 +87,7 @@ void ServerModule::preSync() { // Join threads for sockets that disconnected. cleanUpFinishedThreads(); } - + void ServerModule::cleanUpFinishedThreads() { for (auto& connectionData : _connections) { std::shared_ptr& connection = connectionData.connection; @@ -106,7 +106,7 @@ void ServerModule::cleanUpFinishedThreads() { } ), _connections.end()); } - + void ServerModule::disconnectAll() { for (auto& connectionData : _connections) { std::shared_ptr& connection = connectionData.connection; @@ -117,7 +117,7 @@ void ServerModule::disconnectAll() { } } } - + void ServerModule::handleConnection(std::shared_ptr connection) { std::string messageString; while (connection->socket()->getMessage(messageString)) { diff --git a/modules/server/servermodule.h b/modules/server/servermodule.h index 2996e7fa5f..0c19ef95d5 100644 --- a/modules/server/servermodule.h +++ b/modules/server/servermodule.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/server/src/connection.cpp b/modules/server/src/connection.cpp index b584d245dc..e6e4e7a0fb 100644 --- a/modules/server/src/connection.cpp +++ b/modules/server/src/connection.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -32,23 +32,23 @@ #include namespace { -const char* _loggerCat = "ServerModule: Connection"; + constexpr const char* _loggerCat = "ServerModule: Connection"; -const char* MessageKeyType = "type"; -const char* MessageKeyPayload = "payload"; -const char* MessageKeyTopic = "topic"; + constexpr const char* MessageKeyType = "type"; + constexpr const char* MessageKeyPayload = "payload"; + constexpr const char* MessageKeyTopic = "topic"; -const char* AuthenticationTopicKey = "authorize"; -const char* GetPropertyTopicKey = "get"; -const char* LuaScriptTopicKey = "luascript"; -const char* SetPropertyTopicKey = "set"; -const char* SubscriptionTopicKey = "subscribe"; -const char* TimeTopicKey = "time"; -const char* TriggerPropertyTopicKey = "trigger"; -const char* BounceTopicKey = "bounce"; + constexpr const char* AuthenticationTopicKey = "authorize"; + constexpr const char* GetPropertyTopicKey = "get"; + constexpr const char* LuaScriptTopicKey = "luascript"; + constexpr const char* SetPropertyTopicKey = "set"; + constexpr const char* SubscriptionTopicKey = "subscribe"; + constexpr const char* TimeTopicKey = "time"; + constexpr const char* TriggerPropertyTopicKey = "trigger"; + constexpr const char* BounceTopicKey = "bounce"; -const int ThrottleMessageWaitInMs = 100; -} + constexpr const int ThrottleMessageWaitInMs = 100; +} // namespace namespace openspace { @@ -67,9 +67,10 @@ Connection::Connection(std::shared_ptr s, const std::string & _topicFactory.registerClass(BounceTopicKey); // see if the default config for requiring auth (on) is overwritten - const bool hasAuthenticationConfiguration = OsEng.configurationManager().hasKeyAndValue( - ConfigurationManager::KeyRequireSocketAuthentication); - if (hasAuthenticationConfiguration) { + const bool hasAuthConfiguration = OsEng.configurationManager().hasKeyAndValue( + ConfigurationManager::KeyRequireSocketAuthentication + ); + if (hasAuthConfiguration) { _requireAuthorization = OsEng.configurationManager().value( ConfigurationManager::KeyRequireSocketAuthentication); } else { diff --git a/modules/server/src/connectionpool.cpp b/modules/server/src/connectionpool.cpp index 28db0f4d00..413f373dde 100644 --- a/modules/server/src/connectionpool.cpp +++ b/modules/server/src/connectionpool.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -31,7 +31,8 @@ namespace openspace { -ConnectionPool::ConnectionPool(std::function socket)> handleSocket) +ConnectionPool::ConnectionPool( + std::function socket)> handleSocket) : _handleSocket(std::move(handleSocket)) {} @@ -69,9 +70,13 @@ void ConnectionPool::acceptNewSockets() { } void ConnectionPool::removeDisconnectedSockets() { - std::remove_if(_sockets.begin(), _sockets.end(), [](const std::shared_ptr socket) { - return !socket || !socket->isConnected(); - }); + std::remove_if( + _sockets.begin(), + _sockets.end(), + [](const std::shared_ptr socket) { + return !socket || !socket->isConnected(); + } + ); } void ConnectionPool::disconnectAllConnections() { diff --git a/modules/server/src/jsonconverters.cpp b/modules/server/src/jsonconverters.cpp index 72d355647a..e899af496c 100644 --- a/modules/server/src/jsonconverters.cpp +++ b/modules/server/src/jsonconverters.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/server/src/topics/authorizationtopic.cpp b/modules/server/src/topics/authorizationtopic.cpp index bc000989c3..c693dad79c 100644 --- a/modules/server/src/topics/authorizationtopic.cpp +++ b/modules/server/src/topics/authorizationtopic.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -52,9 +52,13 @@ void AuthorizationTopic::handleJson(nlohmann::json json) { _connection->sendJson(message("Invalid key", StatusCode::NotAcceptable)); } } catch (const std::out_of_range& e) { - _connection->sendJson(message("Invalid request, key must be provided.", StatusCode::BadRequest)); + _connection->sendJson( + message("Invalid request, key must be provided.", StatusCode::BadRequest) + ); } catch (const std::domain_error& e) { - _connection->sendJson(message("Invalid request, invalid key format.", StatusCode::BadRequest)); + _connection->sendJson( + message("Invalid request, invalid key format.", StatusCode::BadRequest) + ); } } }; @@ -65,7 +69,7 @@ bool AuthorizationTopic::authorize(const std::string key) { } const std::string AuthorizationTopic::getKey() const { - const bool hasConfigPassword = OsEng.configurationManager().hasKeyAndValue( + bool hasConfigPassword = OsEng.configurationManager().hasKeyAndValue( ConfigurationManager::KeyServerPasskey); if (hasConfigPassword) { return OsEng.configurationManager().value( @@ -75,9 +79,13 @@ const std::string AuthorizationTopic::getKey() const { return "17308"; } -nlohmann::json AuthorizationTopic::message(const std::string &message, StatusCode statusCode) { - nlohmann::json error = {{"message", message}, {"code", static_cast(statusCode)}}; - return error; +nlohmann::json AuthorizationTopic::message(const std::string& message, + StatusCode statusCode) +{ + return { + { "message", message }, + { "code", static_cast(statusCode) } + }; } -} +} // namespace openspace diff --git a/modules/server/src/topics/getpropertytopic.cpp b/modules/server/src/topics/getpropertytopic.cpp index 1297e9e422..d9e1c2387f 100644 --- a/modules/server/src/topics/getpropertytopic.cpp +++ b/modules/server/src/topics/getpropertytopic.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -65,7 +65,9 @@ void GetPropertyTopic::handleJson(json j) { response = wrappedPayload(sceneGraph()->allSceneGraphNodes()); } else if (requestedKey == AllScreenSpaceRenderablesValue) { - response = wrappedPayload({ { "value", OsEng.renderEngine().screenSpaceRenderables() } }); + response = wrappedPayload({ + { "value", OsEng.renderEngine().screenSpaceRenderables() } + }); } else if (requestedKey == RootPropertyOwner) { response = wrappedPayload(OsEng.rootPropertyOwner()); diff --git a/modules/server/src/topics/luascripttopic.cpp b/modules/server/src/topics/luascripttopic.cpp index 21c4bb3d9a..96c0c28e6a 100644 --- a/modules/server/src/topics/luascripttopic.cpp +++ b/modules/server/src/topics/luascripttopic.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -38,10 +38,13 @@ void LuaScriptTopic::handleJson(nlohmann::json json) { try { auto script = json.at(ScriptKey).get(); LDEBUG("Queueing Lua script: " + script); - OsEng.scriptEngine().queueScript(script, scripting::ScriptEngine::RemoteScripting::No); + OsEng.scriptEngine().queueScript( + script, + scripting::ScriptEngine::RemoteScripting::No + ); } - catch (std::out_of_range& e) { - LERROR("Could run script -- key or value is missing in payload"); + catch (const std::out_of_range& e) { + LERROR("Could not run script -- key or value is missing in payload"); LERROR(e.what()); } } diff --git a/modules/server/src/topics/setpropertytopic.cpp b/modules/server/src/topics/setpropertytopic.cpp index a371afcaed..9239e5f842 100644 --- a/modules/server/src/topics/setpropertytopic.cpp +++ b/modules/server/src/topics/setpropertytopic.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/server/src/topics/subscriptiontopic.cpp b/modules/server/src/topics/subscriptiontopic.cpp index bc1bd1845b..1860a22570 100644 --- a/modules/server/src/topics/subscriptiontopic.cpp +++ b/modules/server/src/topics/subscriptiontopic.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/server/src/topics/timetopic.cpp b/modules/server/src/topics/timetopic.cpp index 2f0f7419b2..31f3a713a3 100644 --- a/modules/server/src/topics/timetopic.cpp +++ b/modules/server/src/topics/timetopic.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/server/src/topics/topic.cpp b/modules/server/src/topics/topic.cpp index 6be5b7349b..dd84de279f 100644 --- a/modules/server/src/topics/topic.cpp +++ b/modules/server/src/topics/topic.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/server/src/topics/triggerpropertytopic.cpp b/modules/server/src/topics/triggerpropertytopic.cpp index 144414a6a6..ad5b5a672d 100644 --- a/modules/server/src/topics/triggerpropertytopic.cpp +++ b/modules/server/src/topics/triggerpropertytopic.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -45,16 +45,16 @@ void TriggerPropertyTopic::handleJson(nlohmann::json json) { if (prop != nullptr) { LDEBUG("Triggering " + propertyKey); prop->set("poke"); - } + } else { LWARNING("Could not find property " + propertyKey); } } - catch (std::out_of_range& e) { + catch (const std::out_of_range& e) { LERROR("Could not poke property -- key or value is missing in payload"); LERROR(e.what()); } - catch (ghoul::RuntimeError e) { + catch (const ghoul::RuntimeError& e) { LERROR("Could not poke property -- runtime error:"); LERROR(e.what()); } diff --git a/modules/spacecraftinstruments/rendering/renderableshadowcylinder.cpp b/modules/spacecraftinstruments/rendering/renderableshadowcylinder.cpp index 97a7099c0f..0280b9e11a 100644 --- a/modules/spacecraftinstruments/rendering/renderableshadowcylinder.cpp +++ b/modules/spacecraftinstruments/rendering/renderableshadowcylinder.cpp @@ -297,7 +297,7 @@ void RenderableShadowCylinder::deinitializeGL() { } ); _shader = nullptr; - + glDeleteVertexArrays(1, &_vao); _vao = 0; glDeleteBuffers(1, &_vbo); diff --git a/modules/sync/syncs/urlsynchronization.cpp b/modules/sync/syncs/urlsynchronization.cpp index 51a06cfe4b..365aa0523b 100644 --- a/modules/sync/syncs/urlsynchronization.cpp +++ b/modules/sync/syncs/urlsynchronization.cpp @@ -203,7 +203,7 @@ void UrlSynchronization::start() { // If we are forcing the override, we download to a temporary file first, // so when we are done here, we need to rename the file to the original // name - + const std::string& tempName = d->destination(); std::string originalName = tempName.substr( 0, diff --git a/modules/touch/ext/levmarq.cpp b/modules/touch/ext/levmarq.cpp index 2fecba156b..657ebef839 100644 --- a/modules/touch/ext/levmarq.cpp +++ b/modules/touch/ext/levmarq.cpp @@ -1,4 +1,4 @@ -/* +/* 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 @@ -26,6 +26,7 @@ OTHER DEALINGS IN THE SOFTWARE. #include #include #include +#include namespace { std::chrono::milliseconds TimeLimit(200); @@ -82,6 +83,20 @@ bool levmarq(int npar, double *par, int ny, double *dysq, double* d = new double[npar]; double* delta = new double[npar]; double* newpar = new double[npar]; + + defer { + // deallocate the arrays + for (i = 0; i < npar; i++) { + delete[] h[i]; + delete[] ch[i]; + } + delete[] h; + delete[] ch; + delete[] g; + delete[] d; + delete[] delta; + delete[] newpar; + }; verbose = lmstat->verbose; nit = lmstat->max_it; @@ -216,18 +231,6 @@ bool levmarq(int npar, double *par, int ny, double *dysq, lmstat->final_derr = derr; lmstat->data = data; - // deallocate the arrays - for (i = 0; i < npar; i++) { - delete[] h[i]; - delete[] ch[i]; - } - delete[] h; - delete[] ch; - delete[] g; - delete[] d; - delete[] delta; - delete[] newpar; - return (it != lmstat->max_it); } diff --git a/modules/touch/include/touchmarker.h b/modules/touch/include/touchmarker.h index b3aa625576..653284c8ab 100644 --- a/modules/touch/include/touchmarker.h +++ b/modules/touch/include/touchmarker.h @@ -70,7 +70,6 @@ private: std::vector _vertexData; GLuint _quad = 0; GLuint _vertexPositionBuffer = 0; - int _numFingers = 0; }; } // openspace namespace diff --git a/modules/touch/src/touchinteraction.cpp b/modules/touch/src/touchinteraction.cpp index e694c39505..9246f28462 100644 --- a/modules/touch/src/touchinteraction.cpp +++ b/modules/touch/src/touchinteraction.cpp @@ -607,7 +607,7 @@ void TouchInteraction::directControl(const std::vector& list) { _lmSuccess = levmarq( nDOF, par.data(), - screenPoints.size(), + static_cast(screenPoints.size()), nullptr, distToMinimize, gradient, @@ -905,11 +905,9 @@ int TouchInteraction::interpretInteraction(const std::vector& list, return ROT; } else { - float avgDistance = static_cast( - std::abs(dist - lastDist) / list.at(0).getMotionSpeed() - ); + float avgDistance = std::abs(dist - lastDist) / list.at(0).getMotionSpeed(); // if average distance between 3 fingers are constant we have panning - if (_panEnabled && (std::abs(dist - lastDist) / list.at(0).getMotionSpeed() < _interpretPan && list.size() == 3)) { + if (_panEnabled && (avgDistance < _interpretPan && list.size() == 3)) { return PAN; } @@ -917,9 +915,9 @@ int TouchInteraction::interpretInteraction(const std::vector& list, // centroid is over _rollAngleThreshold (_centroidStillThreshold is used to void // misinterpretations) else if (std::abs(minDiff) < _inputStillThreshold || - (std::abs(rollOn) < 100.0 && - normalizedCentroidDistance < _centroidStillThreshold)) { - + (std::abs(rollOn) < 100.0 && + normalizedCentroidDistance < _centroidStillThreshold)) + { return ROLL; } else { @@ -997,7 +995,10 @@ void TouchInteraction::computeVelocities(const std::vector& list, pinchConsecZoomFactor += zoomFactor; #endif if ((length(currDistanceToFocusNode) / distanceFromFocusSurface) > _zoomSensitivityDistanceThreshold) { - zoomFactor *= pow(distanceFromFocusSurface, (float)_zoomSensitivity); + zoomFactor *= pow( + distanceFromFocusSurface, + static_cast(_zoomSensitivity) + ); } _vel.zoom += zoomFactor * _sensitivity.zoom * std::max(_touchScreenSize.value() * 0.1, 1.0); diff --git a/modules/touch/src/touchmarker.cpp b/modules/touch/src/touchmarker.cpp index dfa5ebf227..5da6eaf0a8 100644 --- a/modules/touch/src/touchmarker.cpp +++ b/modules/touch/src/touchmarker.cpp @@ -33,7 +33,6 @@ namespace { const std::string _loggerCat = "TouchMarker"; - const int MAX_FINGERS = 20; static const openspace::properties::Property::PropertyInfo VisibilityInfo = { "Visibility", @@ -134,7 +133,7 @@ void TouchMarker::render(const std::vector& list) { glEnable(GL_PROGRAM_POINT_SIZE); // Enable gl_PointSize in vertex shader glPolygonMode(GL_FRONT_AND_BACK, GL_POINT); glBindVertexArray(_quad); - glDrawArrays(GL_POINTS, 0, _vertexData.size() / 2); + glDrawArrays(GL_POINTS, 0, static_cast(_vertexData.size() / 2)); _shader->deactivate(); } @@ -152,7 +151,12 @@ void TouchMarker::createVertexList(const std::vector& list) { glBindVertexArray(_quad); glBindBuffer(GL_ARRAY_BUFFER, _vertexPositionBuffer); - glBufferData(GL_ARRAY_BUFFER, _vertexData.size() * sizeof(GLfloat), _vertexData.data(), GL_STATIC_DRAW); + glBufferData( + GL_ARRAY_BUFFER, + _vertexData.size() * sizeof(GLfloat), + _vertexData.data(), + GL_STATIC_DRAW + ); glEnableVertexAttribArray(0); glVertexAttribPointer( 0, diff --git a/modules/volume/envelope.cpp b/modules/volume/envelope.cpp index e4db69a95b..8b74f5091a 100644 --- a/modules/volume/envelope.cpp +++ b/modules/volume/envelope.cpp @@ -1,176 +1,223 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2018 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ + #include -namespace openspace { - namespace volume { - Envelope::Envelope() { } +namespace openspace::volume { - Envelope::Envelope(std::vector vec) { - _points = vec; - } +EnvelopePoint::EnvelopePoint(glm::vec3 c, float x, float y) + : color(c) + , colorHex(getHexadecimalFromVec3(c)) + , position(std::make_pair(x, y)) +{} - bool Envelope::operator!=(const Envelope& env) const { - const double minDist = 0.0001; +EnvelopePoint::EnvelopePoint(std::string c, float x, float y) + : color(hexadecimalToRGBConversion(c)) + , colorHex(c) + , position(std::make_pair(x, y)) +{} - if (_points.size() != env._points.size()) - return true; +Envelope::Envelope() {} - auto iter = _points.begin(); - auto envIter = env._points.begin(); - for (; iter != _points.end(); ++iter, ++envIter) { - if (abs(iter->position.first - envIter->position.first) > minDist || - abs(iter->position.second - envIter->position.second) > minDist || - iter->color != envIter->color) - return true; - } - return false; - } +Envelope::Envelope(std::vector vec) { + _points = vec; +} +bool Envelope::operator!=(const Envelope& env) const { + const double minDist = 0.0001; - void Envelope::setPoints(std::vector vec) { - this->_points = vec; - } + if (_points.size() != env._points.size()) { + return true; + } - std::vector Envelope::getPoints() { - return _points; - } - - bool Envelope::isValueInEnvelope(float pos) const { - if (!_points.empty()) { - if (_points.front().position.first <= pos && _points.back().position.first >= pos) - return true; - } - return false; - } - - bool Envelope::isEnvelopeValid() const { - auto currentIter = _points.begin(); - auto nextIter = currentIter + 1; - for (; nextIter != _points.end(); ++currentIter, ++nextIter) { - if (currentIter->position.first > nextIter->position.first) - return false; - } + auto iter = _points.begin(); + auto envIter = env._points.begin(); + for (; iter != _points.end(); ++iter, ++envIter) { + if (abs(iter->position.first - envIter->position.first) > minDist || + abs(iter->position.second - envIter->position.second) > minDist || + iter->color != envIter->color) return true; - } + } + return false; +} - glm::vec3 Envelope::normalizeColor(glm::vec3 vec) const{ - return glm::vec3{ vec.r / 255.f, vec.g / 255.f , vec.b / 255.f }; - } - - glm::vec4 Envelope::getValueAtPosition(float pos) const { - auto afterIter = _points.begin(); - glm::vec4 color{ 0.f, 0.f , 0.f , 0.f }; - while (afterIter->position.first < pos ) { - if(afterIter == _points.end()) - return color; - ++afterIter; - } - if (afterIter->position.first == pos) { - return glm::vec4{ afterIter->color, afterIter->position.second }; - } - auto beforeIter = afterIter -1; +void Envelope::setPoints(std::vector vec) { + this->_points = vec; +} - float dist = afterIter->position.first - beforeIter->position.first; - float alpha; - if(dist < 0.0001) - color = { normalizeColor((beforeIter->color + afterIter->color) / 2.f), - std::max(beforeIter->position.second, afterIter->position.second) }; - else - color = { normalizeColor(beforeIter->color *(abs(pos - afterIter->position.first) / dist) + afterIter->color *(abs(pos - beforeIter->position.first) / dist)), - beforeIter->position.second *(abs(pos - afterIter->position.first) / dist) + afterIter->position.second *(abs(pos - beforeIter->position.first) / dist) }; +std::vector Envelope::getPoints() { + return _points; +} +bool Envelope::isValueInEnvelope(float pos) const { + if (!_points.empty()) { + if (_points.front().position.first <= pos && _points.back().position.first >= pos) + return true; + } + return false; +} + +bool Envelope::isEnvelopeValid() const { + auto currentIter = _points.begin(); + auto nextIter = currentIter + 1; + for (; nextIter != _points.end(); ++currentIter, ++nextIter) { + if (currentIter->position.first > nextIter->position.first) + return false; + } + return true; +} + +glm::vec3 Envelope::normalizeColor(glm::vec3 vec) const{ + + return glm::vec3{ vec.r / 255.f, vec.g / 255.f , vec.b / 255.f }; +} + +glm::vec4 Envelope::getValueAtPosition(float pos) const { + auto afterIter = _points.begin(); + glm::vec4 color{ 0.f, 0.f , 0.f , 0.f }; + while (afterIter->position.first < pos ) { + if(afterIter == _points.end()) return color; - } + ++afterIter; + } + if (afterIter->position.first == pos) { + return glm::vec4{ afterIter->color, afterIter->position.second }; + } + auto beforeIter = afterIter -1; - int EnvelopePoint::HexadecimalToDecimal(std::string hex) const { - int hexLength = hex.length(); - double dec = 0; - for (int i = 0; i < hexLength; ++i) - { - char b = hex[i]; + float dist = afterIter->position.first - beforeIter->position.first; + float alpha; + if(dist < 0.0001) + color = { normalizeColor((beforeIter->color + afterIter->color) / 2.f), + std::max(beforeIter->position.second, afterIter->position.second) }; + else + color = { + normalizeColor( + beforeIter->color * (abs(pos - afterIter->position.first) / dist) + + afterIter->color * (abs(pos - beforeIter->position.first) / dist) + ), + beforeIter->position.second * (abs(pos - afterIter->position.first) / dist) + + afterIter->position.second * + (abs(pos - beforeIter->position.first) / dist) + }; - if (b >= 48 && b <= 57) - b -= 48; - else if (b >= 65 && b <= 70) - b -= 55; - else if (b >= 97 && b <= 102) - b -= 87; - dec += b * pow(16, ((hexLength - i) - 1)); + return color; +} + +int EnvelopePoint::HexadecimalToDecimal(std::string hex) const { + int hexLength = hex.length(); + double dec = 0; + for (int i = 0; i < hexLength; ++i) + { + char b = hex[i]; + + if (b >= 48 && b <= 57) + b -= 48; + else if (b >= 65 && b <= 70) + b -= 55; + else if (b >= 97 && b <= 102) + b -= 87; + dec += b * pow(16, ((hexLength - i) - 1)); + } + return (int)dec; +} + +std::string EnvelopePoint::DecimalToHexadecimal(int dec) const { + if (dec < 1) return "00"; + + int hex = dec; + std::string hexStr = ""; + + while (dec > 0) + { + hex = dec % 16; + + if (hex < 10) + hexStr = hexStr.insert(0, std::string(1, (hex + 48))); + else + hexStr = hexStr.insert(0, std::string(1, (hex + 55))); + dec /= 16; + } + return hexStr; +} + +glm::vec3 EnvelopePoint::hexadecimalToRGBConversion(std::string hex) const { + float r = static_cast(HexadecimalToDecimal(hex.substr(1, 2))); + float g = static_cast(HexadecimalToDecimal(hex.substr(3, 2))); + float b = static_cast(HexadecimalToDecimal(hex.substr(5, 2))); + + return glm::vec3(r, g, b); +} + +std::string EnvelopePoint::getHexadecimalFromVec3(glm::vec3 vec) const { + + std::string r = DecimalToHexadecimal(static_cast(vec.r)); + std::string g = DecimalToHexadecimal(static_cast(vec.g)); + std::string b = DecimalToHexadecimal(static_cast(vec.b)); + + return ("#" + r + g + b); +} + +json Envelope::getJSONPoints() const { + json j; + for (int i = 0; i < _points.size(); i++) { + j[i] = { + { "color", _points.at(i).colorHex }, + { "position",{ + { "x", _points.at(i).position.first }, + { "y", _points.at(i).position.second }, + }, } - return (int)dec; - } + }; + } + return j; +} - std::string EnvelopePoint::DecimalToHexadecimal(int dec) const { - if (dec < 1) return "00"; +json Envelope::getJSONEnvelope() const { + json j; + j["points"] = getJSONPoints(); + return j; +} - int hex = dec; - std::string hexStr = ""; +void Envelope::setEnvelopeLuaTable(lua_State* state) const { + for (auto iter = _points.begin(); iter != _points.end(); ++iter) { + lua_newtable(state); + lua_pushstring(state, iter->colorHex.c_str()); + lua_setfield(state, -2, "color"); + lua_newtable(state); + lua_pushnumber(state, static_cast(iter->position.first)); + lua_setfield(state, -2, "x"); + lua_pushnumber(state, static_cast(iter->position.second)); + lua_setfield(state, -2, "y"); + lua_setfield(state, -2, "position"); + lua_setfield( + state, + -2, + ("[\"" + std::to_string(iter - _points.begin() + 1) + "\"]").c_str() + ); + } +} - while (dec > 0) - { - hex = dec % 16; - - if (hex < 10) - hexStr = hexStr.insert(0, std::string(1, (hex + 48))); - else - hexStr = hexStr.insert(0, std::string(1, (hex + 55))); - dec /= 16; - } - return hexStr; - } - - glm::vec3 EnvelopePoint::hexadecimalToRGBConversion(std::string hex) const { - float r = static_cast(HexadecimalToDecimal(hex.substr(1, 2))); - float g = static_cast(HexadecimalToDecimal(hex.substr(3, 2))); - float b = static_cast(HexadecimalToDecimal(hex.substr(5, 2))); - - return glm::vec3(r, g, b); - } - - std::string EnvelopePoint::getHexadecimalFromVec3(glm::vec3 vec) const { - - std::string r = DecimalToHexadecimal(static_cast(vec.r)); - std::string g = DecimalToHexadecimal(static_cast(vec.g)); - std::string b = DecimalToHexadecimal(static_cast(vec.b)); - - return ("#" + r + g + b); - } - - json Envelope::getJSONPoints() const { - json j; - for (int i = 0; i < _points.size(); i++) { - j[i] = { - { "color", _points.at(i).colorHex }, - { "position",{ - { "x", _points.at(i).position.first }, - { "y", _points.at(i).position.second }, - }, - } - }; - } - return j; - } - - json Envelope::getJSONEnvelope() const { - json j; - j["points"] = getJSONPoints(); - return j; - } - - void Envelope::setEnvelopeLuaTable(lua_State* state) const { - for (auto iter = _points.begin(); iter != _points.end(); ++iter) { - lua_newtable(state); - lua_pushstring(state, iter->colorHex.c_str()); - lua_setfield(state, -2, "color"); - lua_newtable(state); - lua_pushnumber(state, static_cast(iter->position.first)); - lua_setfield(state, -2, "x"); - lua_pushnumber(state, static_cast(iter->position.second)); - lua_setfield(state, -2, "y"); - lua_setfield(state, -2, "position"); - lua_setfield(state, -2, ("[\"" + std::to_string(iter - _points.begin() + 1) + "\"]").c_str()); - } - } - - }//namespace volume -}//namespace openspace +} //namespace openspace::volume diff --git a/modules/volume/envelope.h b/modules/volume/envelope.h index 5a251ed917..d9b98e1120 100644 --- a/modules/volume/envelope.h +++ b/modules/volume/envelope.h @@ -1,26 +1,26 @@ /***************************************************************************************** -* * -* 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. * -****************************************************************************************/ + * * + * OpenSpace * + * * + * Copyright (c) 2014-2018 * + * * + * 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_VOLUME___ENVELOPE___H__ #define __OPENSPACE_MODULE_VOLUME___ENVELOPE___H__ @@ -32,46 +32,46 @@ using json = nlohmann::json; -namespace openspace { - namespace volume { - class EnvelopePoint { - public: - EnvelopePoint(glm::vec3 c, float x, float y) : color(c), colorHex(getHexadecimalFromVec3(c)), position(std::make_pair(x, y)) {} - EnvelopePoint(std::string c, float x, float y) : color(hexadecimalToRGBConversion(c)), colorHex(c), position(std::make_pair(x, y)) {} +namespace openspace::volume { - int HexadecimalToDecimal(std::string hex) const; - std::string DecimalToHexadecimal(int dec) const; - glm::vec3 hexadecimalToRGBConversion(std::string hex) const; - std::string getHexadecimalFromVec3(glm::vec3 vec) const; +class EnvelopePoint { +public: + EnvelopePoint(glm::vec3 c, float x, float y); + EnvelopePoint(std::string c, float x, float y); - glm::vec3 color; - std::string colorHex; - std::pair position; - }; - class Envelope { - public: - Envelope(); - Envelope(std::vector vec); + int HexadecimalToDecimal(std::string hex) const; + std::string DecimalToHexadecimal(int dec) const; + glm::vec3 hexadecimalToRGBConversion(std::string hex) const; + std::string getHexadecimalFromVec3(glm::vec3 vec) const; - void setPoints(std::vector vec); - std::vector getPoints(); + glm::vec3 color; + std::string colorHex; + std::pair position; +}; - glm::vec4 getValueAtPosition(float pos) const; - glm::vec3 normalizeColor(glm::vec3 vec) const; - json getJSONPoints() const; - json getJSONEnvelope() const; - void setEnvelopeLuaTable(lua_State* state) const; +class Envelope { +public: + Envelope(); + Envelope(std::vector vec); - bool isValueInEnvelope(float pos) const; - bool isEnvelopeValid() const; + void setPoints(std::vector vec); + std::vector getPoints(); - bool operator!=(const Envelope& env) const; + glm::vec4 getValueAtPosition(float pos) const; + glm::vec3 normalizeColor(glm::vec3 vec) const; + json getJSONPoints() const; + json getJSONEnvelope() const; + void setEnvelopeLuaTable(lua_State* state) const; - private: - - std::vector _points; - }; + bool isValueInEnvelope(float pos) const; + bool isEnvelopeValid() const; - }//namespace volume -}//namespace openspace -#endif __OPENSPACE_MODULE_VOLUME___ENVELOPE___H__ + bool operator!=(const Envelope& env) const; + +private: + std::vector _points; +}; + +} //namespace openspace::volume + +#endif // __OPENSPACE_MODULE_VOLUME___ENVELOPE___H__ diff --git a/modules/volume/rendering/basicvolumeraycaster.h b/modules/volume/rendering/basicvolumeraycaster.h index d15c3c8bd0..9c691ed68d 100644 --- a/modules/volume/rendering/basicvolumeraycaster.h +++ b/modules/volume/rendering/basicvolumeraycaster.h @@ -80,7 +80,8 @@ public: void setVolumeTexture(std::shared_ptr texture); std::shared_ptr volumeTexture() const; - void setTransferFunctionHandler(std::shared_ptr transferFunctionHandler); + void setTransferFunctionHandler( + std::shared_ptr transferFunctionHandler); void setStepSize(float stepSize); float opacity() const; diff --git a/modules/volume/transferfunction.cpp b/modules/volume/transferfunction.cpp index f6d4ff7c19..f4bdffca6b 100644 --- a/modules/volume/transferfunction.cpp +++ b/modules/volume/transferfunction.cpp @@ -1,28 +1,29 @@ -/**************************************************************************************** -* * -* 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. * -****************************************************************************************/ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2018 * + * * + * 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 diff --git a/modules/volume/transferfunction.h b/modules/volume/transferfunction.h index 9f807788de..34327329db 100644 --- a/modules/volume/transferfunction.h +++ b/modules/volume/transferfunction.h @@ -1,26 +1,26 @@ /***************************************************************************************** -* * -* 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. * -****************************************************************************************/ + * * + * OpenSpace * + * * + * Copyright (c) 2014-2018 * + * * + * 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_VOLUME___TRANSFERFUNCTION___H__ #define __OPENSPACE_MODULE_VOLUME___TRANSFERFUNCTION___H__ @@ -30,40 +30,39 @@ namespace ghoul { class Dictionary; } -namespace openspace { - namespace volume { - class TransferFunction { - public: - TransferFunction(); - TransferFunction(int s); - TransferFunction(std::string); - TransferFunction(const TransferFunction& tf); - TransferFunction(TransferFunction&& tf); +namespace openspace::volume { +class TransferFunction { +public: + TransferFunction(); + TransferFunction(int s); + TransferFunction(std::string); + TransferFunction(const TransferFunction& tf); + TransferFunction(TransferFunction&& tf); - bool getEnvelopesToLua(lua_State* state); - - bool setEnvelopesFromString(std::string s); - bool setEnvelopesFromLua(lua_State* lua); + bool getEnvelopesToLua(lua_State* state); - void loadEnvelopesFromFile(const std::string& path); - void saveEnvelopesToFile(const std::string& path); + bool setEnvelopesFromString(std::string s); + bool setEnvelopesFromLua(lua_State* lua); - TransferFunction& operator=(const TransferFunction& tf); - TransferFunction& operator=(TransferFunction&& tf); - bool operator!=(const TransferFunction& tf); - bool hasEnvelopes() const; + void loadEnvelopesFromFile(const std::string& path); + void saveEnvelopesToFile(const std::string& path); - bool createTexture(std::shared_ptr ptr); - std::string getSerializedToString() const; + TransferFunction& operator=(const TransferFunction& tf); + TransferFunction& operator=(TransferFunction&& tf); + bool operator!=(const TransferFunction& tf); + bool hasEnvelopes() const; - private: - int _width = 1024; - double lower = 0.0; - double upper = 1.0; - std::string _loadableFilePath; - std::vector _envelopes; - }; + bool createTexture(std::shared_ptr ptr); + std::string getSerializedToString() const; - }//namespace volume -}//namespace openspace -#endif __OPENSPACE_MODULE_VOLUME___TRANSFERFUNCTION___H__ +private: + int _width = 1024; + double lower = 0.0; + double upper = 1.0; + std::string _loadableFilePath; + std::vector _envelopes; +}; + +} // namespace openspace::volume + +#endif // __OPENSPACE_MODULE_VOLUME___TRANSFERFUNCTION___H__ diff --git a/modules/volume/transferfunctionhandler.cpp b/modules/volume/transferfunctionhandler.cpp index 82b75ae4d5..4e30c6c35b 100644 --- a/modules/volume/transferfunctionhandler.cpp +++ b/modules/volume/transferfunctionhandler.cpp @@ -1,26 +1,26 @@ /***************************************************************************************** -* * -* 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. * -****************************************************************************************/ + * * + * OpenSpace * + * * + * Copyright (c) 2014-2018 * + * * + * 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 diff --git a/modules/volume/transferfunctionhandler.h b/modules/volume/transferfunctionhandler.h index f526c61d21..cdfaaa567e 100644 --- a/modules/volume/transferfunctionhandler.h +++ b/modules/volume/transferfunctionhandler.h @@ -1,26 +1,26 @@ /***************************************************************************************** -* * -* 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. * -****************************************************************************************/ + * * + * OpenSpace * + * * + * Copyright (c) 2014-2018 * + * * + * 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_VOLUME___TRANSFERFUNCTIONHANDLER___H__ #define __OPENSPACE_MODULE_VOLUME___TRANSFERFUNCTIONHANDLER___H__ @@ -41,17 +41,16 @@ #include #include -namespace openspace { -namespace volume { +namespace openspace::volume { class Envelope; - + class TransferFunctionHandler : public properties::PropertyOwner{ public: TransferFunctionHandler(const properties::StringProperty& prop); - + void initialize(); - + void setHistogramProperty(std::shared_ptr histogram); void setTexture(); @@ -81,6 +80,6 @@ private: std::shared_ptr _texture = nullptr; }; -}//namespace volume -}//namespace openspace -#endif __OPENSPACE_MODULE_VOLUME___TRANSFERFUNCTIONHANDLER___H__ +} //namespace openspace::volume + +#endif // __OPENSPACE_MODULE_VOLUME___TRANSFERFUNCTIONHANDLER___H__ diff --git a/modules/volume/transferfunctionproperty.cpp b/modules/volume/transferfunctionproperty.cpp index 6c6a84d043..dbd8ab5b6c 100644 --- a/modules/volume/transferfunctionproperty.cpp +++ b/modules/volume/transferfunctionproperty.cpp @@ -1,26 +1,26 @@ /***************************************************************************************** -* * -* 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. * -****************************************************************************************/ + * * + * OpenSpace * + * * + * Copyright (c) 2014-2018 * + * * + * 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 diff --git a/modules/volume/transferfunctionproperty.h b/modules/volume/transferfunctionproperty.h index ccd981b23f..9754e4ee6b 100644 --- a/modules/volume/transferfunctionproperty.h +++ b/modules/volume/transferfunctionproperty.h @@ -1,37 +1,37 @@ /***************************************************************************************** -* * -* 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. * -****************************************************************************************/ + * * + * OpenSpace * + * * + * Copyright (c) 2014-2018 * + * * + * 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___TRANSFERFUNCTIONPROPERTY___H__ -#define __OPENSPACE_CORE___TRANSFERFUNCTIONPROPERTY___H__ +#ifndef __OPENSPACE_MODULE_VOLUME___TRANSFERFUNCTIONPROPERTY___H__ +#define __OPENSPACE_MODULE_VOLUME___TRANSFERFUNCTIONPROPERTY___H__ #include #include namespace openspace::properties { - REGISTER_TEMPLATEPROPERTY_HEADER(TransferFunctionProperty, volume::TransferFunction) +REGISTER_TEMPLATEPROPERTY_HEADER(TransferFunctionProperty, volume::TransferFunction) } // namespace openspace::properties -#endif // __OPENSPACE_CORE___TRANSFERFUNCTIONPROPERTY___H__ +#endif // __OPENSPACE_MODULE_VOLUME___TRANSFERFUNCTIONPROPERTY___H__ diff --git a/modules/volume/volumegridtype.cpp b/modules/volume/volumegridtype.cpp index 9c2d6f29e9..87fe622a12 100644 --- a/modules/volume/volumegridtype.cpp +++ b/modules/volume/volumegridtype.cpp @@ -26,8 +26,7 @@ #include -namespace openspace { -namespace volume { +namespace openspace::volume { VolumeGridType parseGridType(const std::string& gridType) { if (gridType == "Cartesian") { @@ -44,5 +43,4 @@ InvalidGridTypeError::InvalidGridTypeError(std::string gt) , gridType(std::move(gt)) {} -} // namespace volume -} // namespace openspace +} // namespace openspace::volume diff --git a/modules/volume/volumegridtype.h b/modules/volume/volumegridtype.h index 7993cadb4a..8997d699db 100644 --- a/modules/volume/volumegridtype.h +++ b/modules/volume/volumegridtype.h @@ -22,13 +22,12 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_MODULE_VOLUME___VOLUMEGRIDTYPE_H__ -#define __OPENSPACE_MODULE_VOLUME___VOLUMEGRIDTYPE_H__ +#ifndef __OPENSPACE_MODULE_VOLUME___VOLUMEGRIDTYPE___H__ +#define __OPENSPACE_MODULE_VOLUME___VOLUMEGRIDTYPE___H__ #include -namespace openspace { -namespace volume { +namespace openspace::volume { enum class VolumeGridType : int { Cartesian = 0, @@ -36,13 +35,12 @@ enum class VolumeGridType : int { }; struct InvalidGridTypeError : public ghoul::RuntimeError { - explicit InvalidGridTypeError(std::string gridType); - std::string gridType; + explicit InvalidGridTypeError(std::string gridType); + std::string gridType; }; VolumeGridType parseGridType(const std::string& gridType); -} // namespace volume -} // namespace openspace +} // namespace openspace::volume -#endif // __OPENSPACE_MODULE_VOLUME___VOLUMEGRIDTYPE_H__ +#endif // __OPENSPACE_MODULE_VOLUME___VOLUMEGRIDTYPE___H__ diff --git a/modules/webbrowser/CMakeLists.txt b/modules/webbrowser/CMakeLists.txt index fcbd21acde..6bfd9f485c 100644 --- a/modules/webbrowser/CMakeLists.txt +++ b/modules/webbrowser/CMakeLists.txt @@ -2,7 +2,7 @@ # # # OpenSpace # # # -# Copyright (c) 2014-2017 # +# Copyright (c) 2014-2018 # # # # 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 # @@ -152,7 +152,7 @@ if(OS_MACOSX) target_link_libraries(${CEF_HELPER_TARGET} libcef_lib libcef_dll_wrapper ${CEF_STANDARD_LIBS}) set_target_properties(${CEF_HELPER_TARGET} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/mac/helper-Info.plist - ) + ) # Fix the framework rpath in the helper executable. FIX_MACOSX_HELPER_FRAMEWORK_RPATH(${CEF_HELPER_TARGET}) diff --git a/modules/webbrowser/include/browserclient.h b/modules/webbrowser/include/browserclient.h index 1a2ed9937b..be1922626e 100644 --- a/modules/webbrowser/include/browserclient.h +++ b/modules/webbrowser/include/browserclient.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -51,4 +51,4 @@ private: } // namespace openspace -#endif // __OPENSPACE_MODULE_WEBBROWSER___BROWSER_CLIENT___H__ +#endif // __OPENSPACE_MODULE_WEBBROWSER___BROWSER_CLIENT___H__ diff --git a/modules/webbrowser/include/browserinstance.h b/modules/webbrowser/include/browserinstance.h index 0c9247df27..fc3f472e7e 100644 --- a/modules/webbrowser/include/browserinstance.h +++ b/modules/webbrowser/include/browserinstance.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -47,8 +47,9 @@ public: void close(bool force = false); bool sendKeyEvent(const CefKeyEvent &event); - bool sendMouseClickEvent(const CefMouseEvent &event, CefBrowserHost::MouseButtonType button, - bool mouseUp, int clickCount = SINGLE_CLICK); + bool sendMouseClickEvent(const CefMouseEvent &event, + CefBrowserHost::MouseButtonType button, bool mouseUp, + int clickCount = SINGLE_CLICK); bool sendMouseMoveEvent(const CefMouseEvent &event); bool sendMouseWheelEvent(const CefMouseEvent &event, glm::ivec2 delta); void reloadBrowser(); @@ -66,6 +67,6 @@ private: bool _isInitialized; }; -} +} // namespace openspace -#endif //__OPENSPACE_MODULE_WEBBROWSER__BROWSER_INSTANCE_H +#endif // __OPENSPACE_MODULE_WEBBROWSER__BROWSER_INSTANCE_H diff --git a/modules/webbrowser/include/cefhost.h b/modules/webbrowser/include/cefhost.h index 886d3f70d4..cbede7013c 100644 --- a/modules/webbrowser/include/cefhost.h +++ b/modules/webbrowser/include/cefhost.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_MODULE_WEBBROWSER__CEF_HOST_H -#define __OPENSPACE_MODULE_WEBBROWSER__CEF_HOST_H +#ifndef __OPENSPACE_MODULE_WEBBROWSER___CEF_HOST___H__ +#define __OPENSPACE_MODULE_WEBBROWSER___CEF_HOST___H__ #include #include @@ -46,4 +46,4 @@ private: } // namespace openspace -#endif //__OPENSPACE_MODULE_WEBBROWSER__CEF_HOST_H +#endif // __OPENSPACE_MODULE_WEBBROWSER___CEF_HOST___H__ diff --git a/modules/webbrowser/include/defaultbrowserlauncher.h b/modules/webbrowser/include/defaultbrowserlauncher.h index 6b37809c74..436caa399c 100644 --- a/modules/webbrowser/include/defaultbrowserlauncher.h +++ b/modules/webbrowser/include/defaultbrowserlauncher.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -33,17 +33,13 @@ namespace openspace { class DefaultBrowserLauncher : public CefLifeSpanHandler, public CefRequestHandler { public: - bool OnBeforePopup(CefRefPtr parentBrowser, - const CefPopupFeatures& popupFeatures, - CefWindowInfo& windowInfo, - const CefString& url, - CefRefPtr& client, - CefBrowserSettings& settings); - bool OnOpenURLFromTab(CefRefPtr browser, - CefRefPtr frame, - const CefString& target_url, - CefRequestHandler::WindowOpenDisposition target_disposition, - bool user_gesture); + bool OnBeforePopup(CefRefPtr parentBrowser, + const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo, + const CefString& url, CefRefPtr& client, CefBrowserSettings& settings); + + bool OnOpenURLFromTab(CefRefPtr browser, CefRefPtr frame, + const CefString& target_url, + CefRequestHandler::WindowOpenDisposition target_disposition, bool userGesture); private: void launchBrowser(const std::string &url) const; @@ -52,4 +48,4 @@ private: } // namespace openspace -#endif // __OPENSPACE_MODULE_WEBBROWSER___DEFAULT_BROWSER_LAUNCHER___H__ +#endif // __OPENSPACE_MODULE_WEBBROWSER___DEFAULT_BROWSER_LAUNCHER___H__ diff --git a/modules/webbrowser/include/eventhandler.h b/modules/webbrowser/include/eventhandler.h index 75813a3880..658810c80a 100644 --- a/modules/webbrowser/include/eventhandler.h +++ b/modules/webbrowser/include/eventhandler.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -22,7 +22,6 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ - #ifndef __OPENSPACE_MODULE_WEBBROWSER___EVENT_HANDLER___H__ #define __OPENSPACE_MODULE_WEBBROWSER___EVENT_HANDLER___H__ @@ -37,8 +36,6 @@ namespace openspace { class EventHandler { public: - EventHandler() : _mousePosition(0, 0), _browserInstance(nullptr), _lastClickPosition(0, 0) {}; - void initialize(); void setBrowser(const CefRefPtr &browser); void setBrowserInstance(const std::shared_ptr & browserInstance); @@ -62,8 +59,9 @@ private: bool _leftMouseDown = false; - std::shared_ptr _browserInstance; - glm::vec2 _mousePosition, _lastClickPosition; + std::shared_ptr _browserInstance = nullptr; + glm::vec2 _mousePosition = { 0.f, 0.f }; + glm::vec2 _lastClickPosition = { 0.f, 0.f }; std::chrono::high_resolution_clock::time_point _lastClickTime; /** @@ -73,19 +71,21 @@ private: bool isDoubleClick() const; /** - * get the number of milliseconds that is allowed between two clicks for it to count as a double click + * get the number of milliseconds that is allowed between two clicks for it to count + * as a double click * @return */ static int doubleClickTime(); /** - * get the rectangle width around the first click in a double click that the second click has to be _within_ + * get the rectangle width around the first click in a double click that the second + * click has to be _within_ * @return */ static int maxDoubleClickDistance(); }; -} +} // namespace openspace -#endif //__OPENSPACE_MODULE_WEBBROWSER___EVENT_HANDLER___H__ +#endif // __OPENSPACE_MODULE_WEBBROWSER___EVENT_HANDLER___H__ diff --git a/modules/webbrowser/include/screenspacebrowser.h b/modules/webbrowser/include/screenspacebrowser.h index a02d39c89c..359ff6a78d 100644 --- a/modules/webbrowser/include/screenspacebrowser.h +++ b/modules/webbrowser/include/screenspacebrowser.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_MODULE_WEBBROWSER__SCREEN_SPACE_BROWSER_H -#define __OPENSPACE_MODULE_WEBBROWSER__SCREEN_SPACE_BROWSER_H +#ifndef __OPENSPACE_MODULE_WEBBROWSER___SCREEN_SPACE_BROWSER___H__ +#define __OPENSPACE_MODULE_WEBBROWSER___SCREEN_SPACE_BROWSER___H__ #include #include @@ -36,19 +36,6 @@ #include "include/screenspacerenderhandler.h" #include "include/browserinstance.h" -namespace { -static const openspace::properties::Property::PropertyInfo BrowserDimensionsInfo = { - "Dimensions", - "Browser Dimensions", - "Set the dimensions of the web browser windows." -}; -static const openspace::properties::Property::PropertyInfo UrlInfo = { - "URL", - "url", - "The URL to load" -}; -} - namespace openspace { class ScreenSpaceBrowser : public ScreenSpaceRenderable { @@ -72,6 +59,6 @@ private: bool _dimensionsAreDirty; }; -}; +} // namespace openspace -#endif //__OPENSPACE_MODULE_WEBBROWSER__SCREEN_SPACE_BROWSER_H +#endif // __OPENSPACE_MODULE_WEBBROWSER___SCREEN_SPACE_BROWSER___H__ diff --git a/modules/webbrowser/include/screenspacerenderhandler.h b/modules/webbrowser/include/screenspacerenderhandler.h index f1de964115..28b8dffbc5 100644 --- a/modules/webbrowser/include/screenspacerenderhandler.h +++ b/modules/webbrowser/include/screenspacerenderhandler.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_MODULE_WEBBROWSER___SCREEN_SPACE_RENDER_HANDLER_H -#define __OPENSPACE_MODULE_WEBBROWSER___SCREEN_SPACE_RENDER_HANDLER_H +#ifndef __OPENSPACE_MODULE_WEBBROWSER___SCREEN_SPACE_RENDER_HANDLER___H__ +#define __OPENSPACE_MODULE_WEBBROWSER___SCREEN_SPACE_RENDER_HANDLER___H__ #include "include/webrenderhandler.h" @@ -31,14 +31,12 @@ namespace openspace { class ScreenSpaceRenderHandler : public WebRenderHandler { public: - ScreenSpaceRenderHandler() {}; - - void draw(void); + void draw(); void render(); void setTexture(const GLuint&); }; -} +} // namespace openspace -#endif //__OPENSPACE_MODULE_WEBBROWSER___SCREEN_SPACE_RENDER_HANDLER_H +#endif // __OPENSPACE_MODULE_WEBBROWSER___SCREEN_SPACE_RENDER_HANDLER___H__ diff --git a/modules/webbrowser/include/webbrowserapp.h b/modules/webbrowser/include/webbrowserapp.h index 0a84373e2a..7c8544135f 100644 --- a/modules/webbrowser/include/webbrowserapp.h +++ b/modules/webbrowser/include/webbrowserapp.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_MODULE_WEBBROWSER__WEBBROWSERAPP_H -#define __OPENSPACE_MODULE_WEBBROWSER__WEBBROWSERAPP_H +#ifndef __OPENSPACE_MODULE_WEBBROWSER___WEBBROWSERAPP___H__ +#define __OPENSPACE_MODULE_WEBBROWSER___WEBBROWSERAPP___H__ #include #include @@ -39,11 +39,13 @@ public: WebBrowserApp(); CefRefPtr GetRenderProcessHandler() override; - void OnContextCreated(CefRefPtr, CefRefPtr, CefRefPtr) override; + void OnContextCreated(CefRefPtr, CefRefPtr, + CefRefPtr) override; private: IMPLEMENT_REFCOUNTING(WebBrowserApp); }; -}; -#endif // __OPENSPACE_MODULE_WEBBROWSER__WEBBROWSERAPP_H +} // namespace openspace + +#endif // __OPENSPACE_MODULE_WEBBROWSER___WEBBROWSERAPP___H__ diff --git a/modules/webbrowser/include/webrenderhandler.h b/modules/webbrowser/include/webrenderhandler.h index 8e489d9bbc..e883465e9f 100644 --- a/modules/webbrowser/include/webrenderhandler.h +++ b/modules/webbrowser/include/webrenderhandler.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -47,8 +47,8 @@ public: void reshape(int, int); bool GetViewRect(CefRefPtr browser, CefRect &rect) override; - void OnPaint(CefRefPtr browser, PaintElementType type, const RectList &dirtyRects, const void *buffer, - int width, int height) override; + void OnPaint(CefRefPtr browser, PaintElementType type, + const RectList &dirtyRects, const void* buffer, int width, int height) override; bool hasContent(int x, int y); protected: @@ -73,4 +73,4 @@ protected: } // namespace openspace -#endif //__OPENSPACE_MODULE_WEBBROWSER__WEB_RENDER_HANDLER_H +#endif // __OPENSPACE_MODULE_WEBBROWSER__WEB_RENDER_HANDLER_H diff --git a/modules/webbrowser/src/browserclient.cpp b/modules/webbrowser/src/browserclient.cpp index 040021a160..ad9a17e113 100644 --- a/modules/webbrowser/src/browserclient.cpp +++ b/modules/webbrowser/src/browserclient.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/webbrowser/src/browserinstance.cpp b/modules/webbrowser/src/browserinstance.cpp index 1b8434e335..bd84354f45 100644 --- a/modules/webbrowser/src/browserinstance.cpp +++ b/modules/webbrowser/src/browserinstance.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -32,7 +32,9 @@ const bool DID_NOT_LEAVE_WINDOW = false; namespace openspace { -BrowserInstance::BrowserInstance(WebRenderHandler* renderer) : _isInitialized(false) { +BrowserInstance::BrowserInstance(WebRenderHandler* renderer) + : _isInitialized(false) +{ _renderHandler = renderer; _client = new BrowserClient(_renderHandler); @@ -44,7 +46,13 @@ BrowserInstance::BrowserInstance(WebRenderHandler* renderer) : _isInitialized(fa browserSettings.windowless_frame_rate = 60; std::string url = ""; - _browser = CefBrowserHost::CreateBrowserSync(windowInfo, _client.get(), url, browserSettings, NULL); + _browser = CefBrowserHost::CreateBrowserSync( + windowInfo, + _client.get(), + url, + browserSettings, + nullptr + ); } BrowserInstance::~BrowserInstance() { @@ -52,7 +60,7 @@ BrowserInstance::~BrowserInstance() { } void BrowserInstance::initialize() { - auto &wrapper = OsEng.windowWrapper(); + auto& wrapper = OsEng.windowWrapper(); reshape(wrapper.currentWindowSize()); _isInitialized = true; @@ -112,8 +120,10 @@ bool BrowserInstance::sendKeyEvent(const CefKeyEvent &event) { return false; } -bool BrowserInstance::sendMouseClickEvent(const CefMouseEvent &event, CefBrowserHost::MouseButtonType button, - bool mouseUp, int clickCount) { +bool BrowserInstance::sendMouseClickEvent(const CefMouseEvent &event, + CefBrowserHost::MouseButtonType button, + bool mouseUp, int clickCount) +{ _browser->GetHost()->SendMouseClickEvent(event, button, mouseUp, clickCount); return hasContent(event.x, event.y); } diff --git a/modules/webbrowser/src/cefhost.cpp b/modules/webbrowser/src/cefhost.cpp index 3ddee68ec8..d24434a35f 100644 --- a/modules/webbrowser/src/cefhost.cpp +++ b/modules/webbrowser/src/cefhost.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -35,7 +35,10 @@ CefHost::CefHost(std::string helperLocation) { CefMainArgs args; CefSettings settings; - CefString(&settings.browser_subprocess_path).FromASCII((char*) helperLocation.c_str()); + CefString(&settings.browser_subprocess_path).FromASCII( + // This is bad as it casts away the const + (char*) helperLocation.c_str() + ); attachDebugSettings(settings); #ifdef WIN32 @@ -55,7 +58,10 @@ CefHost::~CefHost() { void CefHost::attachDebugSettings(CefSettings &settings) { settings.remote_debugging_port = 8088; - LDEBUG(fmt::format("Remote WebBrowser debugging available on http://localhost:{}", settings.remote_debugging_port)); + LDEBUG(fmt::format( + "Remote WebBrowser debugging available on http://localhost:{}", + settings.remote_debugging_port + )); // settings.single_process = true; } diff --git a/modules/webbrowser/src/defaultbrowserlauncher.cpp b/modules/webbrowser/src/defaultbrowserlauncher.cpp index 87233d9f9a..229ff51a95 100644 --- a/modules/webbrowser/src/defaultbrowserlauncher.cpp +++ b/modules/webbrowser/src/defaultbrowserlauncher.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/webbrowser/src/eventhandler.cpp b/modules/webbrowser/src/eventhandler.cpp index 174dd24109..62b3b35211 100644 --- a/modules/webbrowser/src/eventhandler.cpp +++ b/modules/webbrowser/src/eventhandler.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -28,10 +28,11 @@ #include "include/eventhandler.h" namespace { -const std::string _loggerCat = "WebBrowser:EventHandler"; -} + const std::string _loggerCat = "WebBrowser:EventHandler"; +} // namespace namespace openspace { + void EventHandler::initialize() { OsEng.registerModuleCharCallback( [this](unsigned int charCode, KeyModifier mod) -> bool { @@ -96,7 +97,12 @@ bool EventHandler::mouseButtonCallback(MouseButton button, MouseAction action) { _lastClickPosition = _mousePosition; } - return _browserInstance->sendMouseClickEvent(mouseEvent(), MBT_LEFT, !_leftMouseDown, clickCount); + return _browserInstance->sendMouseClickEvent( + mouseEvent(), + MBT_LEFT, + !_leftMouseDown, + clickCount + ); } bool EventHandler::isDoubleClick() const { @@ -159,7 +165,8 @@ bool EventHandler::keyboardCallback(Key key, KeyModifier modifier, KeyAction act } /** - * Detect if there is a special event that should be caught by the GUI before it is sent to CEF + * Detect if there is a special event that should be caught by the GUI before it is sent + * to CEF. * @param key the pressed key * @return true if event found, false otherwise */ @@ -222,14 +229,18 @@ CefMouseEvent EventHandler::mouseEvent() { return event; } -void EventHandler::setBrowserInstance(const std::shared_ptr &browserInstance) { +void EventHandler::setBrowserInstance( + const std::shared_ptr& browserInstance) +{ LDEBUG("Setting browser instance."); _browserInstance = browserInstance; } void EventHandler::detachBrowser() { if (_browserInstance) { - LDEBUG(fmt::format("Detaching browser instance with use count {}", _browserInstance.use_count())); + LDEBUG(fmt::format( + "Detaching browser instance with use count {}", _browserInstance.use_count() + )); } _browserInstance = nullptr; } diff --git a/modules/webbrowser/src/processhelpermac.cpp b/modules/webbrowser/src/processhelpermac.cpp index a1e5f189f1..e4b013c8ca 100644 --- a/modules/webbrowser/src/processhelpermac.cpp +++ b/modules/webbrowser/src/processhelpermac.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/webbrowser/src/processhelperwindows.cpp b/modules/webbrowser/src/processhelperwindows.cpp index f64f323975..98c7cce615 100644 --- a/modules/webbrowser/src/processhelperwindows.cpp +++ b/modules/webbrowser/src/processhelperwindows.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -30,15 +30,12 @@ #include "include/webbrowserapp.h" // Entry point function for sub-processes. -int main(HINSTANCE hInstance, - HINSTANCE hPrevInstance, - LPTSTR lpCmdLine, - int nCmdShow) { - // Provide CEF with command-line arguments. - CefMainArgs main_args(hInstance); +int main(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { + // Provide CEF with command-line arguments. + CefMainArgs main_args(hInstance); - CefRefPtr app(new openspace::WebBrowserApp); + CefRefPtr app(new openspace::WebBrowserApp); - // Execute the sub-process. - return CefExecuteProcess(main_args, app.get(), NULL); + // Execute the sub-process. + return CefExecuteProcess(main_args, app.get(), NULL); } diff --git a/modules/webbrowser/src/screenspacebrowser.cpp b/modules/webbrowser/src/screenspacebrowser.cpp index 7ae604f5e3..05c85f7578 100644 --- a/modules/webbrowser/src/screenspacebrowser.cpp +++ b/modules/webbrowser/src/screenspacebrowser.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -30,6 +30,18 @@ namespace { const char* KeyIdentifier = "Indentifier"; const char* KeyUrl = "URL"; const std::string _loggerCat = "ScreenSpaceBrowser"; + +static const openspace::properties::Property::PropertyInfo BrowserDimensionsInfo = { + "Dimensions", + "Browser Dimensions", + "Set the dimensions of the web browser windows." +}; +static const openspace::properties::Property::PropertyInfo UrlInfo = { + "URL", + "url", + "The URL to load" +}; + } // namespace namespace openspace { @@ -60,7 +72,9 @@ ScreenSpaceBrowser::ScreenSpaceBrowser(const ghoul::Dictionary &dictionary) glm::vec2 windowDimensions = OsEng.windowWrapper().currentWindowSize(); _dimensions = windowDimensions; - _texture = std::make_unique(glm::uvec3(windowDimensions, 1.0f)); + _texture = std::make_unique( + glm::uvec3(windowDimensions, 1.0f) + ); _renderHandler = new ScreenSpaceRenderHandler(); _browserInstance = std::make_shared(_renderHandler); diff --git a/modules/webbrowser/src/screenspacerenderhandler.cpp b/modules/webbrowser/src/screenspacerenderhandler.cpp index 24162c3bfd..79d14c9d02 100644 --- a/modules/webbrowser/src/screenspacerenderhandler.cpp +++ b/modules/webbrowser/src/screenspacerenderhandler.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/webbrowser/src/webbrowserapp.cpp b/modules/webbrowser/src/webbrowserapp.cpp index 202bae5621..8846417322 100644 --- a/modules/webbrowser/src/webbrowserapp.cpp +++ b/modules/webbrowser/src/webbrowserapp.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/webbrowser/src/webrenderhandler.cpp b/modules/webbrowser/src/webrenderhandler.cpp index bd8165299d..d16a5c0b69 100644 --- a/modules/webbrowser/src/webrenderhandler.cpp +++ b/modules/webbrowser/src/webrenderhandler.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -28,23 +28,34 @@ namespace openspace { void WebRenderHandler::reshape(int w, int h) { -// LDEBUGC("WebRenderHandler", fmt::format("Reshaping browser window. Width: {}, height: {}", w, h)); _width = w; _height = h; _alphaMask.clear(); _alphaMask.resize(w * h); } -bool WebRenderHandler::GetViewRect(CefRefPtr browser, CefRect &rect) { +bool WebRenderHandler::GetViewRect(CefRefPtr browser, CefRect& rect) { rect = CefRect(0, 0, _width, _height); return true; } -void WebRenderHandler::OnPaint(CefRefPtr browser, CefRenderHandler::PaintElementType type, - const CefRenderHandler::RectList &dirtyRects, const void *buffer, - int w, int h) { +void WebRenderHandler::OnPaint(CefRefPtr browser, + CefRenderHandler::PaintElementType type, + const CefRenderHandler::RectList& dirtyRects, + const void* buffer, int w, int h) +{ glBindTexture(GL_TEXTURE_2D, _texture); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _width, _height, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, (unsigned char*) buffer); + glTexImage2D( + GL_TEXTURE_2D, + 0, + GL_RGBA, + _width, + _height, + 0, + GL_BGRA_EXT, + GL_UNSIGNED_BYTE, + buffer + ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); @@ -66,4 +77,4 @@ bool WebRenderHandler::hasContent(int x, int y) { return _alphaMask[index]; } -} +} // namespace openspace diff --git a/modules/webbrowser/webbrowsermodule.cpp b/modules/webbrowser/webbrowsermodule.cpp index 575b6b02d9..9ef6cbc859 100644 --- a/modules/webbrowser/webbrowsermodule.cpp +++ b/modules/webbrowser/webbrowsermodule.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -68,7 +68,9 @@ std::string WebBrowserModule::findHelperExecutable() { auto execLocation = absPath(OsEng.configurationManager().value( ConfigurationManager::KeyWebHelperLocation) + SUBPROCESS_ENDING); if (!FileSys.fileExists(execLocation)) { - LERROR(fmt::format("Could not find web helper executable at location: {}" , execLocation)); + LERROR(fmt::format( + "Could not find web helper executable at location: {}" , execLocation + )); } return execLocation; } @@ -78,19 +80,29 @@ std::string WebBrowserModule::findHelperExecutable() { LWARNING(fmt::format("Assuming web helper name is {}", subprocessName)); auto subLength = (int)subprocessName.length(); - Directory binDir("${BASE}/bin/openspace", Directory::AbsolutePath::No); - std::vector foundFiles = binDir.readFiles(Directory::Recursive::Yes, Directory::Sort::Yes); + Directory binDir("${BASE}/bin/openspace", Directory::RawPath::No); + std::vector foundFiles = binDir.readFiles( + Directory::Recursive::Yes, + Directory::Sort::Yes + ); // find files matching the given file name std::vector matchingFiles; - std::copy_if(foundFiles.begin(), foundFiles.end(), std::back_inserter(matchingFiles), + std::copy_if( + foundFiles.begin(), + foundFiles.end(), + std::back_inserter(matchingFiles), [subprocessName, subLength](std::string s) { - s = s.substr(s.size() - subLength); - return s == subprocessName; - }); + s = s.substr(s.size() - subLength); + return s == subprocessName; + } + ); if (matchingFiles.empty()) { - LERROR(fmt::format("Could not find requested sub process executable file name: {}", subprocessName)); + LERROR(fmt::format( + "Could not find requested sub process executable file name: {}", + subprocessName + )); } return matchingFiles.back(); @@ -125,7 +137,9 @@ void WebBrowserModule::removeBrowser(std::shared_ptr browser) { LDEBUG(fmt::format("Number of browsers stored: {}", _browsers.size())); } -void WebBrowserModule::attachEventHandler(std::shared_ptr browserInstance) { +void WebBrowserModule::attachEventHandler( + std::shared_ptr browserInstance) +{ _eventHandler.setBrowserInstance(browserInstance); } diff --git a/modules/webbrowser/webbrowsermodule.h b/modules/webbrowser/webbrowsermodule.h index 85c74902cf..319e4a88e3 100644 --- a/modules/webbrowser/webbrowsermodule.h +++ b/modules/webbrowser/webbrowsermodule.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/webgui/CMakeLists.txt b/modules/webgui/CMakeLists.txt index 114b209408..b602c87287 100644 --- a/modules/webgui/CMakeLists.txt +++ b/modules/webgui/CMakeLists.txt @@ -2,7 +2,7 @@ # # # OpenSpace # # # -# Copyright (c) 2014-2017 # +# Copyright (c) 2014-2018 # # # # 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 # diff --git a/modules/webgui/webguimodule.cpp b/modules/webgui/webguimodule.cpp index 768944cc63..5dd1ebbd34 100644 --- a/modules/webgui/webguimodule.cpp +++ b/modules/webgui/webguimodule.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/webgui/webguimodule.h b/modules/webgui/webguimodule.h index f5f3f06dcc..141551682e 100644 --- a/modules/webgui/webguimodule.h +++ b/modules/webgui/webguimodule.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -22,11 +22,10 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef OPENSPACE_WEBGUIMODULE_H -#define OPENSPACE_WEBGUIMODULE_H +#ifndef __OPENSPACE_MODULE_WEBGUI___WEBGUIMODULE___H__ +#define __OPENSPACE_MODULE_WEBGUI___WEBGUIMODULE___H__ #include -#include namespace openspace { @@ -36,6 +35,6 @@ public: WebGuiModule(); }; -} +} // namespace openspace -#endif //OPENSPACE_WEBGUIMODULE_H +#endif // __OPENSPACE_MODULE_WEBGUI___WEBGUIMODULE___H__ diff --git a/src/engine/configurationmanager.cpp b/src/engine/configurationmanager.cpp index 6f62e808d7..9db7940a23 100644 --- a/src/engine/configurationmanager.cpp +++ b/src/engine/configurationmanager.cpp @@ -47,81 +47,6 @@ namespace { namespace openspace { -// static constexpr const char* ConfigurationManager::KeyPaths = "Paths"; -// const string ConfigurationManager::KeyCache = "CACHE"; -// const string ConfigurationManager::KeyFonts = "Fonts"; -// const string ConfigurationManager::KeyConfigSgct = "SGCTConfig"; -// const string ConfigurationManager::KeyGlobalCustomizationScripts = - // "GlobalCustomizationScripts"; - -// const string ConfigurationManager::PartType = "Type"; -// const string ConfigurationManager::PartFile = "File"; - -// const string ConfigurationManager::KeyLuaDocumentation = "LuaDocumentation"; -// const string ConfigurationManager::KeyScriptLog = "ScriptLog"; -// const string ConfigurationManager::KeyPropertyDocumentation = "PropertyDocumentation"; -// const string ConfigurationManager::KeyScenePropertyDocumentation = - // "ScenePropertyDocumentation"; -// const string ConfigurationManager::KeyKeyboardShortcuts = "KeyboardShortcuts"; -// const string ConfigurationManager::KeyDocumentation = "Documentation"; -// const string ConfigurationManager::KeyFactoryDocumentation = "FactoryDocumentation"; - -// const string ConfigurationManager::KeyConfigAsset = "Asset"; -// const string ConfigurationManager::KeySceneLicenseDocumentation = "LicenseDocumentation"; - -// const string ConfigurationManager::KeyLogging = "Logging"; -// const string ConfigurationManager::PartLogDir = "LogDir"; -// const string ConfigurationManager::PartLogLevel = "LogLevel"; -// const string ConfigurationManager::PartImmediateFlush = "ImmediateFlush"; -// const string ConfigurationManager::PartLogPerformancePrefix = "PerformancePrefix"; - -// const string ConfigurationManager::PartLogs = "Logs"; -// const string ConfigurationManager::PartAppend = "Append"; -// const string ConfigurationManager::PartCapabilitiesVerbosity = "CapabilitiesVerbosity"; - -// const string ConfigurationManager::KeyLauncher = "Launcher"; - -// const string ConfigurationManager::KeyCapabilitiesVerbosity = - // KeyLogging + "." + PartCapabilitiesVerbosity; - -// const string ConfigurationManager::KeyShutdownCountdown = "ShutdownCountdown"; -// const string ConfigurationManager::KeyDisableMasterRendering = "DisableRenderingOnMaster"; -// const string ConfigurationManager::KeyDisableSceneOnMaster = "DisableSceneOnMaster"; -// const string ConfigurationManager::KeyPerSceneCache = "PerSceneCache"; -// const string ConfigurationManager::KeyRenderingMethod = "RenderingMethod"; - -// const string ConfigurationManager::KeyOnScreenTextScaling = "OnScreenTextScaling"; - -// const string ConfigurationManager::KeyHttpProxy = "HttpProxy"; -// const string ConfigurationManager::PartHttpProxyAddress = "Address"; -// const string ConfigurationManager::PartHttpProxyPort = "Port"; -// const string ConfigurationManager::PartHttpProxyAuthentication = "Authentication"; -// const string ConfigurationManager::PartHttpProxyUser = "User"; -// const string ConfigurationManager::PartHttpProxyPassword = "Password"; - -// const string ConfigurationManager::KeyOpenGLDebugContext = "OpenGLDebugContext"; -// const string ConfigurationManager::PartActivate = "Activate"; -// const string ConfigurationManager::PartSynchronous = "Synchronous"; -// const string ConfigurationManager::PartFilterIdentifier = "FilterIdentifier"; -// const string ConfigurationManager::PartFilterIdentifierSource = "Source"; -// const string ConfigurationManager::PartFilterIdentifierType = "Type"; -// const string ConfigurationManager::PartFilterIdentifierIdentifier = "Identifier"; -// const string ConfigurationManager::PartFilterSeverity = "PartFilterSeverity"; -// const string ConfigurationManager::KeyCheckOpenGLState = "CheckOpenGLState"; -// const string ConfigurationManager::KeyLogEachOpenGLCall = "LogEachOpenGLCall"; - -// const string ConfigurationManager::KeyUseMultithreadedInitialization = - // "UseMultithreadedInitialization"; - -// const string ConfigurationManager::KeyLoadingScreen = "LoadingScreen"; -// const string ConfigurationManager::PartShowMessage = "ShowMessage"; -// const string ConfigurationManager::PartShowNodeNames = "ShowNodeNames"; -// const string ConfigurationManager::PartShowProgressbar = "ShowProgressbar"; - -// const string ConfigurationManager::KeyScreenshotUseDate = "ScreenshotUseDate"; - -// const string ConfigurationManager::KeyModuleConfigurations = "ModuleConfigurations"; - string ConfigurationManager::findConfiguration(const string& filename) { using ghoul::filesystem::Directory; diff --git a/src/engine/configurationmanager_doc.inl b/src/engine/configurationmanager_doc.inl index 3650da9157..a365448508 100644 --- a/src/engine/configurationmanager_doc.inl +++ b/src/engine/configurationmanager_doc.inl @@ -69,7 +69,6 @@ documentation::Documentation ConfigurationManager::Documentation() { "in all other configuration files or scripts." }, { - ConfigurationManager::KeyCachePath, new StringVerifier, Optional::No, @@ -205,21 +204,21 @@ documentation::Documentation ConfigurationManager::Documentation() { ConfigurationManager::KeyRequireSocketAuthentication, new BoolVerifier, Optional::Yes, - "If socket connections should be authenticated or not before they are allowed to " - "get or set information. Defaults to `true`." + "If socket connections should be authenticated or not before they are " + "allowed to get or set information. Defaults to 'true'." }, { ConfigurationManager::KeyServerPasskey, - new StringVerifier, - Optional::Yes, - "Passkey to limit server access. Used to authorize incoming connections." + new StringVerifier, + Optional::Yes, + "Passkey to limit server access. Used to authorize incoming connections." }, { ConfigurationManager::KeyServerClientAddressWhitelist, - new StringVerifier, - Optional::Yes, - "String containing white listed client IP addresses that won't need to be" - "authorized with the server. Space separated" + new StringVerifier, + Optional::Yes, + "String containing white listed client IP addresses that won't need to be " + "authorized with the server. Space separated" }, { ConfigurationManager::KeySceneLicenseDocumentation, @@ -368,8 +367,8 @@ documentation::Documentation ConfigurationManager::Documentation() { new BoolVerifier, Optional::Yes, "Determines whether the OpenGL debug callbacks are performed " - "synchronously. If set to the callbacks are in the same thread " - "as the context and in the scope of the OpenGL function that " + "synchronously. If set to the callbacks are in the same " + "thread as the context and in the scope of the OpenGL function that " "triggered the message. The default value is ." }, { diff --git a/src/engine/downloadmanager.cpp b/src/engine/downloadmanager.cpp index d594a0218d..9f87dd24e0 100644 --- a/src/engine/downloadmanager.cpp +++ b/src/engine/downloadmanager.cpp @@ -91,8 +91,8 @@ namespace { ghoul_assert(p, "Passed progress information is nullptr"); ProgressInformation* i = static_cast(p); ghoul_assert(i, "Passed pointer is not a ProgressInformation"); - ghoul_assert(i->future, "FileFuture is not initialized"); - ghoul_assert(i->callback, "Callback pointer is nullptr"); + ghoul_assert(i && i->future, "FileFuture is not initialized"); + ghoul_assert(i && i->callback, "Callback pointer is nullptr"); if (i->future->abortDownload) { i->future->isAborted = true; diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index b9e1d2946c..a34b2252ac 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -293,7 +293,7 @@ void OpenSpaceEngine::create(int argc, char** argv, // Parse commandline arguments std::vector args(argv, argv + argc); - std::shared_ptr> arguments = + const std::vector& arguments = _engine->_commandlineParser->setCommandLine(args); bool showHelp = _engine->_commandlineParser->execute(); @@ -302,7 +302,8 @@ void OpenSpaceEngine::create(int argc, char** argv, requestClose = true; return; } - sgctArguments = *arguments; + std::vector argumentsCopy = arguments; + sgctArguments = std::move(argumentsCopy); // Find configuration std::string configurationFilePath = commandlineArgumentPlaceholders.configurationName; @@ -1476,7 +1477,7 @@ void OpenSpaceEngine::mouseButtonCallback(MouseButton button, MouseAction action if (consumed) { // If the mouse was released, we still want to forward it to the navigation // handler in order to reliably terminate a rotation or zoom. Accidentally - // moving the cursor over a UI window is easy to miss and leads to weird + // moving the cursor over a UI window is easy to miss and leads to weird // continuing movement if (action == MouseAction::Release) { break; diff --git a/src/engine/virtualpropertymanager.cpp b/src/engine/virtualpropertymanager.cpp index 124f5bc96c..516b334c02 100644 --- a/src/engine/virtualpropertymanager.cpp +++ b/src/engine/virtualpropertymanager.cpp @@ -28,7 +28,9 @@ namespace openspace { -VirtualPropertyManager::VirtualPropertyManager() : properties::PropertyOwner({ "VirtualPropertyManager" }) {} +VirtualPropertyManager::VirtualPropertyManager() + : properties::PropertyOwner({ "VirtualPropertyManager" }) +{} void VirtualPropertyManager::addProperty(std::unique_ptr prop) { // PropertyOwner does not take the ownership of the pointer diff --git a/src/engine/wrapper/sgctwindowwrapper.cpp b/src/engine/wrapper/sgctwindowwrapper.cpp index fef3b7b9ff..f635b96bd7 100644 --- a/src/engine/wrapper/sgctwindowwrapper.cpp +++ b/src/engine/wrapper/sgctwindowwrapper.cpp @@ -176,9 +176,10 @@ int SGCTWindowWrapper::currentNumberOfAaSamples() const { bool SGCTWindowWrapper::isRegularRendering() const { sgct::SGCTWindow* w = sgct::Engine::instance()->getCurrentWindowPtr(); - std::size_t nViewports = w->getNumberOfViewports(); - (void)nViewports; // Unused in Release mode - ghoul_assert(nViewports > 0, "At least one viewport must exist at this time"); + ghoul_assert( + w->getNumberOfViewports() > 0, + "At least one viewport must exist at this time" + ); sgct_core::Viewport* vp = w->getViewport(0); sgct_core::NonLinearProjection* nlp = vp->getNonLinearProjectionPtr(); return nlp == nullptr; diff --git a/src/interaction/keybindingmanager_lua.inl b/src/interaction/keybindingmanager_lua.inl index 33f7edf830..0e3f6a27c9 100644 --- a/src/interaction/keybindingmanager_lua.inl +++ b/src/interaction/keybindingmanager_lua.inl @@ -172,7 +172,7 @@ int clearKey(lua_State* L) { // The user provided a list of keys ghoul::Dictionary d; ghoul::lua::luaDictionaryFromState(L, d); - for (int i = 1; i <= d.size(); ++i) { + for (size_t i = 1; i <= d.size(); ++i) { std::string k = d.value(std::to_string(i)); OsEng.keyBindingManager().removeKeyBinding(k); } diff --git a/src/interaction/touchbar.mm b/src/interaction/touchbar.mm index a1461a879b..813d0a1aa6 100644 --- a/src/interaction/touchbar.mm +++ b/src/interaction/touchbar.mm @@ -78,6 +78,8 @@ NSArray* focusIdentifiers; - (NSTouchBarItem *)touchBar:(NSTouchBar *)touchBar makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier { + // @TODO(abock): Potential memory leak here by returning an alloc? + // Remove the unused variable warning (void)touchBar; diff --git a/src/network/parallelconnection.cpp b/src/network/parallelconnection.cpp index fb5694f308..516853901d 100644 --- a/src/network/parallelconnection.cpp +++ b/src/network/parallelconnection.cpp @@ -45,7 +45,9 @@ bool ParallelConnection::isConnectedOrConnecting() { return _socket->isConnected() || _socket->isConnecting(); } -void ParallelConnection::sendDataMessage(const ParallelConnection::DataMessage& dataMessage) { +void ParallelConnection::sendDataMessage( + const ParallelConnection::DataMessage& dataMessage) +{ uint32_t dataMessageTypeOut = static_cast(dataMessage.type); std::vector messageContent; @@ -57,7 +59,10 @@ void ParallelConnection::sendDataMessage(const ParallelConnection::DataMessage& dataMessage.content.begin(), dataMessage.content.end()); - sendMessage(ParallelConnection::Message(ParallelConnection::MessageType::Data, messageContent)); + sendMessage(ParallelConnection::Message( + ParallelConnection::MessageType::Data, + messageContent + )); } bool ParallelConnection::sendMessage(const ParallelConnection::Message& message) { @@ -112,7 +117,6 @@ ParallelConnection::Message ParallelConnection::receiveMessage() { std::vector headerBuffer(headerSize); std::vector messageBuffer; - // Receive the header data if (!_socket->get(headerBuffer.data(), headerSize)) { LERROR("Failed to read header from socket. Disconencting."); @@ -150,7 +154,10 @@ ParallelConnection::Message ParallelConnection::receiveMessage() { } // And delegate decoding depending on type - return ParallelConnection::Message(static_cast(messageTypeIn), messageBuffer); + return ParallelConnection::Message( + static_cast(messageTypeIn), + messageBuffer + ); } } // namespace openspace diff --git a/src/network/parallelpeer.cpp b/src/network/parallelpeer.cpp index e388914926..45fcf4102a 100644 --- a/src/network/parallelpeer.cpp +++ b/src/network/parallelpeer.cpp @@ -205,7 +205,10 @@ void ParallelPeer::sendAuthentication() { buffer.insert(buffer.end(), name.begin(), name.end()); // Send message - _connection.sendMessage(ParallelConnection::Message(ParallelConnection::MessageType::Authentication, buffer)); + _connection.sendMessage(ParallelConnection::Message( + ParallelConnection::MessageType::Authentication, + buffer + )); } void ParallelPeer::queueInMessage(const ParallelConnection::Message& message) { @@ -414,12 +417,18 @@ void ParallelPeer::requestHostship() { reinterpret_cast(&passwordHash), reinterpret_cast(&passwordHash) + sizeof(uint64_t) ); - _connection.sendMessage(ParallelConnection::Message(ParallelConnection::MessageType::HostshipRequest, buffer)); + _connection.sendMessage(ParallelConnection::Message( + ParallelConnection::MessageType::HostshipRequest, + buffer + )); } void ParallelPeer::resignHostship() { std::vector buffer; - _connection.sendMessage(ParallelConnection::Message(ParallelConnection::MessageType::HostshipResignation, buffer)); + _connection.sendMessage(ParallelConnection::Message( + ParallelConnection::MessageType::HostshipResignation, + buffer + )); } void ParallelPeer::setPassword(std::string pwd) { @@ -441,7 +450,10 @@ void ParallelPeer::sendScript(std::string script) { std::vector buffer; sm.serialize(buffer); - ParallelConnection::DataMessage message(datamessagestructures::Type::ScriptData, buffer); + ParallelConnection::DataMessage message( + datamessagestructures::Type::ScriptData, + buffer + ); _connection.sendDataMessage(message); } @@ -550,7 +562,10 @@ void ParallelPeer::sendCameraKeyframe() { kf.serialize(buffer); // Send message - _connection.sendDataMessage(ParallelConnection::DataMessage(datamessagestructures::Type::CameraData, buffer)); + _connection.sendDataMessage(ParallelConnection::DataMessage( + datamessagestructures::Type::CameraData, + buffer + )); } void ParallelPeer::sendTimeKeyframe() { @@ -574,7 +589,10 @@ void ParallelPeer::sendTimeKeyframe() { kf.serialize(buffer); // Send message - _connection.sendDataMessage(ParallelConnection::DataMessage(datamessagestructures::Type::TimeData, buffer)); + _connection.sendDataMessage(ParallelConnection::DataMessage( + datamessagestructures::Type::TimeData, + buffer + )); _timeJumped = false; } diff --git a/src/network/parallelserver.cpp b/src/network/parallelserver.cpp index bb9281d374..0f76f1348d 100644 --- a/src/network/parallelserver.cpp +++ b/src/network/parallelserver.cpp @@ -52,7 +52,7 @@ void ParallelServer::start( } void ParallelServer::setDefaultHostAddress(std::string defaultHostAddress) { - std::lock_guard lock(_hostInfoMutex); + std::lock_guard lock(_hostInfoMutex); _defaultHostAddress = std::move(defaultHostAddress); } @@ -89,7 +89,7 @@ void ParallelServer::handleNewPeers() { }); } } - + std::shared_ptr ParallelServer::peer(size_t id) { std::lock_guard lock(_peerListMutex); const auto& it = _peers.find(id); @@ -142,7 +142,7 @@ void ParallelServer::handlePeerMessage(PeerMessage peerMessage) { } std::shared_ptr& peer = it->second; - + switch (messageType) { case ParallelConnection::MessageType::Authentication: handleAuthentication(peer, std::move(data)); @@ -165,7 +165,7 @@ void ParallelServer::handlePeerMessage(PeerMessage peerMessage) { break; } } - + void ParallelServer::handleAuthentication(std::shared_ptr peer, std::vector message) { @@ -219,7 +219,7 @@ void ParallelServer::handleAuthentication(std::shared_ptr peer, setNConnections(nConnections() + 1); } - + void ParallelServer::handleData(std::shared_ptr peer, std::vector data) { if (peer->id != _hostPeerId) { LINFO(fmt::format( @@ -259,7 +259,7 @@ void ParallelServer::handleHostshipRequest(std::shared_ptr peer, assignHost(peer); LINFO(fmt::format("Switched host from {} to {}.", oldHostPeerId, peer->id)); } - + void ParallelServer::handleHostshipResignation(std::shared_ptr peer, std::vector data) { diff --git a/src/properties/binaryproperty.cpp b/src/properties/binaryproperty.cpp index 4c78a37d16..3ebb294761 100644 --- a/src/properties/binaryproperty.cpp +++ b/src/properties/binaryproperty.cpp @@ -1,26 +1,26 @@ /***************************************************************************************** -* * -* 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. * -****************************************************************************************/ + * * + * OpenSpace * + * * + * Copyright (c) 2014-2018 * + * * + * 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 @@ -49,7 +49,7 @@ REGISTER_TEMPLATEPROPERTY_SOURCE( return result; }, [](std::string& outValue, std::vector inValue) -> bool { - // TODO: To json conversion + // TODO: To json conversion outValue = ""; return true; }, diff --git a/src/properties/property.cpp b/src/properties/property.cpp index 6fa6a8f80d..4678dc16ca 100644 --- a/src/properties/property.cpp +++ b/src/properties/property.cpp @@ -191,8 +191,11 @@ const ghoul::Dictionary& Property::metaData() const { std::string Property::toJson() const { std::string result = "{"; - result += "\"" + std::string(DescriptionKey) + "\": " + generateBaseJsonDescription() + ", "; - result += "\"" + std::string(JsonValueKey) + "\": " + jsonValue(); + result += + "\"" + std::string(DescriptionKey) + "\": " + + generateBaseJsonDescription() + ", "; + result += + "\"" + std::string(JsonValueKey) + "\": " + jsonValue(); result += "}"; return result; } @@ -280,13 +283,15 @@ void Property::notifyDeleteListeners() { } std::string Property::generateBaseJsonDescription() const { - return + return "{ \"" + std::string(TypeKey) + "\": \"" + className() + "\", " + - "\"" + std::string(IdentifierKey) + "\": \"" + fullyQualifiedIdentifier() + "\", " + + "\"" + std::string(IdentifierKey) + "\": \"" + + fullyQualifiedIdentifier() + "\", " + "\"" + std::string(NameKey) + "\": \"" + guiName() + "\", " + - "\"" + std::string(MetaDataKey) + "\": " + generateMetaDataJsonDescription() + ", " + - "\"" + std::string(AdditionalDataKey) + "\": " + generateAdditionalJsonDescription() + - " }"; + "\"" + std::string(MetaDataKey) + "\": " + + generateMetaDataJsonDescription() + ", " + + "\"" + std::string(AdditionalDataKey) + "\": " + + generateAdditionalJsonDescription() + " }"; } std::string Property::generateMetaDataJsonDescription() const { @@ -306,9 +311,13 @@ std::string Property::generateMetaDataJsonDescription() const { } std::string result = "{ "; - result += "\"" + std::string(MetaDataKeyGroup) + "\": \"" + groupIdentifier() + "\", "; - result += "\"" + std::string(MetaDataKeyVisibility) + "\": \"" + vis + "\", "; - result += "\"" + std::string(MetaDataKeyReadOnly) + "\": " + (isReadOnly ? "true" : "false"); + result += + "\"" + std::string(MetaDataKeyGroup) + "\": \"" + groupIdentifier() + "\", "; + result += + "\"" + std::string(MetaDataKeyVisibility) + "\": \"" + vis + "\", "; + result += + "\"" + std::string(MetaDataKeyReadOnly) + "\": " + + (isReadOnly ? "true" : "false"); result += " }"; return result; } diff --git a/src/properties/scalar/ucharproperty.cpp b/src/properties/scalar/ucharproperty.cpp index d8e34420a2..75f4fce161 100644 --- a/src/properties/scalar/ucharproperty.cpp +++ b/src/properties/scalar/ucharproperty.cpp @@ -50,7 +50,7 @@ bool toLuaConversion(lua_State* state, unsigned char value) { unsigned char fromStringConversion(std::string val, bool& success) { std::stringstream s(val); - unsigned char v; + unsigned char v = 0; s >> v; success = !s.fail(); if (success) { diff --git a/src/rendering/framebufferrenderer.cpp b/src/rendering/framebufferrenderer.cpp index 7984166b24..aedd04ed1a 100644 --- a/src/rendering/framebufferrenderer.cpp +++ b/src/rendering/framebufferrenderer.cpp @@ -539,7 +539,7 @@ void FramebufferRenderer::updateDeferredcastData() { absPath(vsPath), absPath(deferredShaderPath), deferredDict); - + using IgnoreError = ghoul::opengl::ProgramObject::IgnoreError; _deferredcastPrograms[caster]->setIgnoreSubroutineUniformLocationError( IgnoreError::Yes @@ -547,7 +547,7 @@ void FramebufferRenderer::updateDeferredcastData() { _deferredcastPrograms[caster]->setIgnoreUniformLocationError( IgnoreError::Yes ); - + caster->initializeCachedVariables(*_deferredcastPrograms[caster]); } catch (ghoul::RuntimeError& e) { diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index 8c95ec06ca..c6d1dc46ad 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -410,7 +410,7 @@ void RenderEngine::initialize() { #ifdef GHOUL_USE_STB_IMAGE ghoul::io::TextureReader::ref().addReader( std::make_shared() - ); + ); #endif // GHOUL_USE_STB_IMAGE ghoul::io::TextureReader::ref().addReader( @@ -596,8 +596,8 @@ void RenderEngine::render(const glm::mat4& sceneMatrix, const glm::mat4& viewMat _camera->sgctInternal.setViewMatrix(viewMatrix * sceneMatrix); _camera->sgctInternal.setSceneMatrix(sceneMatrix); } + _camera->sgctInternal.setProjectionMatrix(projectionMatrix); } - _camera->sgctInternal.setProjectionMatrix(projectionMatrix); bool masterEnabled = wrapper.isMaster() ? !_disableMasterRendering : true; if (masterEnabled && !wrapper.isGuiWindow() && _globalBlackOutFactor > 0.f) { diff --git a/src/scene/scene.cpp b/src/scene/scene.cpp index a3361b0907..b4a4f25e7c 100644 --- a/src/scene/scene.cpp +++ b/src/scene/scene.cpp @@ -60,7 +60,6 @@ namespace { constexpr const char* _loggerCat = "Scene"; - constexpr const char* KeyName = "Name"; constexpr const char* KeyIdentifier = "Identifier"; constexpr const char* KeyParent = "Parent"; } // namespace diff --git a/src/scene/scenegraphnode.cpp b/src/scene/scenegraphnode.cpp index 6396222e34..d883056eed 100644 --- a/src/scene/scenegraphnode.cpp +++ b/src/scene/scenegraphnode.cpp @@ -627,7 +627,7 @@ Scene* SceneGraphNode::scene() { void SceneGraphNode::setScene(Scene* scene) { // Unregister from previous scene, bottom up - traversePostOrder([scene](SceneGraphNode* node) { + traversePostOrder([](SceneGraphNode* node) { if (node->_scene) { node->_scene->unregisterNode(node); } diff --git a/src/util/httprequest.cpp b/src/util/httprequest.cpp index 86a8765ad9..04b83213e8 100644 --- a/src/util/httprequest.cpp +++ b/src/util/httprequest.cpp @@ -362,7 +362,9 @@ bool HttpFileDownload::initDownload() { std::string message(Buffer, size); - LERROR(fmt::format("Cannot open file {}: {}", std::string(destinationFile), message)); + LERROR(fmt::format( + "Cannot open file {}: {}", std::string(destinationFile), message) + ); return false; } diff --git a/support/coding/check_style_guide.py b/support/coding/check_style_guide.py index 715b45632d..c53290df47 100644 --- a/support/coding/check_style_guide.py +++ b/support/coding/check_style_guide.py @@ -44,6 +44,7 @@ guards for correctness. At the moment this includes: * Checking whether a file as empty-only lines * Checking whether the default assert macros are used anywhere instead of the ghoul_assert macro + * Checking whether there are TABs in the file If this script is executed from the base directory of OpenSpace, no arguments need to be passed, otherwise the first and only argument has to point to the base directory. @@ -58,6 +59,7 @@ import sys current_year = '2018' is_strict_mode = False +is_silent_mode = False def get_ifndef_symbol(lines): index = [i for i,s in enumerate(lines) if '#ifndef ' in s] @@ -332,6 +334,12 @@ def check_empty_character_at_end(lines): return '' +def check_for_tab(lines): + index = [i + 1 for i, s in enumerate(lines) if '\t' in s] + if len(index) > 0: + return index + else: + return '' previousSymbols = {} def check_header_file(file, component): @@ -425,6 +433,10 @@ def check_header_file(file, component): if assert_usage: print(file, '\t', 'Wrong assert usage: ', assert_usage) + tabs = check_for_tab(lines) + if tabs: + print(file, '\t', 'TABs found: ', tabs) + def check_inline_file(file, component): @@ -479,6 +491,11 @@ def check_inline_file(file, component): if assert_usage: print(file, '\t', 'Wrong assert usage: ', assert_usage) + tabs = check_for_tab(lines) + if tabs: + print(file, '\t', 'TABs found: ', tabs) + + def check_source_file(file, component): @@ -522,11 +539,23 @@ def check_source_file(file, component): if assert_usage: print(file, '\t', 'Wrong assert usage: ', assert_usage) + tabs = check_for_tab(lines) + if tabs: + print(file, '\t', 'TABs found: ', tabs) + + def check_files(positiveList, negativeList, component, check_function): - files = glob.glob(positiveList, recursive=True) - negativeFiles = glob.glob(negativeList, recursive=True) + files = [] + for p in positiveList: + f = glob.glob(p, recursive=True) + files.extend(f) + + negativeFiles = [] + for n in negativeList: + f = glob.glob(n, recursive=True) + negativeFiles.extend(f) files = [f for f in files if f not in negativeFiles] @@ -545,28 +574,106 @@ if len(sys.argv) > 1: for a in sys.argv: if a == "strict": is_strict_mode = True + if a == "silent": + is_silent_mode = True + # Check header files -print("Checking header files") -print("=====================") -check_files(basePath + 'include/**/*.h', '', 'openspace_core', check_header_file) -check_files(basePath + 'apps/**/*.h', basePath + 'apps/**/ext/**/*.h', 'openspace_app', check_header_file) -check_files(basePath + 'modules/**/*.h', basePath + 'modules/**/ext/**/*.h', 'openspace_module', check_header_file) -check_files(basePath + 'ext/ghoul/include/**/*.h', '', 'ghoul', check_header_file) -print("") +if not is_silent_mode: + print("Checking header files") + print("=====================") -print("Checking inline files") -print("=====================") -check_files(basePath + 'include/**/*.inl', '', 'openspace_core', check_inline_file) -check_files(basePath + 'src/**/*.inl', '', 'openspace_core', check_inline_file) -check_files(basePath + 'apps/**/*.inl', basePath + 'apps/**/ext/**/*.h', 'openspace_app', check_inline_file) -check_files(basePath + 'modules/**/*.inl', basePath + 'modules/**/ext/**/*.h', 'openspace_module', check_inline_file) -check_files(basePath + 'ext/ghoul/include/**/*.inl', '', 'ghoul', check_inline_file) -print("") +check_files( + [basePath + 'include/**/*.h'], + [], + 'openspace_core', + check_header_file +) +check_files( + [basePath + 'apps/**/*.h'], + [basePath + 'apps/**/ext/**/*.h'], + 'openspace_app', + check_header_file +) +check_files( + [basePath + 'modules/**/*.h'], + [ + basePath + 'modules/**/ext/**/*.h', + basePath + 'modules/**/node_modules/**/*.h', + basePath + 'modules/webbrowser/resource.h' + ], + 'openspace_module', + check_header_file +) +check_files( + [basePath + 'ext/ghoul/include/**/*.h'], + [], + 'ghoul', + check_header_file +) -print("Checking source files") -print("=====================") -check_files(basePath + 'src/**/*.cpp', '', 'openspace_core', check_source_file) -check_files(basePath + 'apps/**/*.cpp', basePath + 'apps/**/ext/**/*.cpp', 'openspace_app', check_source_file) -check_files(basePath + 'modules/**/*.cpp', basePath + 'modules/**/ext/**/*.cpp', 'openspace_module', check_source_file) -check_files(basePath + 'ext/ghoul/src/**/*.cpp', '', 'ghoul', check_source_file) +if not is_silent_mode: + print("") + print("Checking inline files") + print("=====================") + +check_files( + [basePath + 'include/**/*.inl'], + [], + 'openspace_core', + check_inline_file +) +check_files( + [basePath + 'src/**/*.inl'], + [], + 'openspace_core', + check_inline_file +) +check_files( + [basePath + 'apps/**/*.inl'], + [basePath + 'apps/**/ext/**/*.h'], + 'openspace_app', + check_inline_file +) +check_files( + [basePath + 'modules/**/*.inl'], + [basePath + 'modules/**/ext/**/*.h'], + 'openspace_module', + check_inline_file +) +check_files( + [basePath + 'ext/ghoul/include/**/*.inl'], + [], + 'ghoul', + check_inline_file +) + +if not is_silent_mode: + print("") + print("Checking source files") + print("=====================") + +check_files( + [basePath + 'src/**/*.cpp'], + [], + 'openspace_core', + check_source_file +) +check_files( + [basePath + 'apps/**/*.cpp'], + [basePath + 'apps/**/ext/**/*.cpp'], + 'openspace_app', + check_source_file +) +check_files( + [basePath + 'modules/**/*.cpp'], + [basePath + 'modules/**/ext/**/*.cpp', basePath + 'modules/**/node_modules/**/*.cpp'], + 'openspace_module', + check_source_file +) +check_files( + [basePath + 'ext/ghoul/src/**/*.cpp'], + [], + 'ghoul', + check_source_file +) diff --git a/tests/test_rawvolumeio.inl b/tests/test_rawvolumeio.inl index cacb18b60d..0450543e02 100644 --- a/tests/test_rawvolumeio.inl +++ b/tests/test_rawvolumeio.inl @@ -64,7 +64,7 @@ TEST_F(RawVolumeIoTest, BasicInputOutput) { glm::uvec3 dims{ 2, 4, 8 }; auto value = [dims](glm::uvec3 v) { - return v.z * 8 * 4 + v.y * 4 + v.x; + return v.z * dims.z * dims.y + v.y * dims.y + v.x; }; RawVolume vol(dims); From a1e1c3841a152d40e6710a6d28df2b3a022a6b05 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 19 Apr 2018 13:36:32 -0400 Subject: [PATCH 17/17] Remove option from torrentclient to auto-select a port --- modules/sync/torrentclient.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/sync/torrentclient.cpp b/modules/sync/torrentclient.cpp index 87905af398..4e65107798 100644 --- a/modules/sync/torrentclient.cpp +++ b/modules/sync/torrentclient.cpp @@ -72,7 +72,7 @@ void TorrentClient::initialize() { settings.set_str( libtorrent::settings_pack::listen_interfaces, - "0.0.0.0:6881,0.0.0.0:20280,0.0.0.0:20285,0.0.0.0:20290,0.0.0.0:0" + "0.0.0.0:6881,0.0.0.0:20280,0.0.0.0:20285,0.0.0.0:20290" ); settings.set_bool(libtorrent::settings_pack::allow_multiple_connections_per_ip, true); settings.set_bool(libtorrent::settings_pack::enable_upnp, true);