From f231cb024a360585016bd2e06ef4389cbab4b74d Mon Sep 17 00:00:00 2001 From: Elon Olsson Date: Wed, 6 May 2020 16:40:04 -0400 Subject: [PATCH] toggle different textures with hotkey i --- data/assets/bastille-mas-model.scene | 78 +++++++++++-------- .../bastille_day_sun_textures.asset | 8 ++ .../mas/bastille_day/density_volume.asset | 9 +++ .../mas/bastille_day/fieldlines.asset | 9 +++ .../mas/bastille_day/magnetogram.asset | 38 ++++----- .../sun/magnetogram_textures.asset | 39 ++++++++++ .../renderablefieldlinessequence.cpp | 2 +- 7 files changed, 126 insertions(+), 57 deletions(-) rename data/assets/scene/solarsystem/sun/{ => heliosphere/mas/bastille_day}/bastille_day_sun_textures.asset (64%) create mode 100644 data/assets/scene/solarsystem/sun/magnetogram_textures.asset diff --git a/data/assets/bastille-mas-model.scene b/data/assets/bastille-mas-model.scene index ab2992c24b..c43f548b7a 100644 --- a/data/assets/bastille-mas-model.scene +++ b/data/assets/bastille-mas-model.scene @@ -5,40 +5,39 @@ local propertyHelper = asset.require('util/property_helper') local sceneHelper = asset.require('util/scene_helper') asset.require('util/default_dashboard') -asset.require('spice/base') +asset.require('scene/solarsystem/sun/magnetogram_textures') assetHelper.requestAll(asset, 'scene/solarsystem/sun/heliosphere') -openspace.setPropertyValueSingle("Scene.Sun.Renderable.Layers.ColorLayers.Texture.Enabled", false) - --- Namespaced global lua state -textureList = { - Options = { - TexIndex = 1 - }, - SunTextures = { - asset.require('./scene/solarsystem/sun/bastille_day_sun_textures').TexturesPath .. "/br_photo_bas05_trans_20G_offset.png", - asset.require('./scene/solarsystem/sun/bastille_day_sun_textures').TexturesPath .. "/br_photo_bas05_trans_100G_offset.png", - asset.require('./scene/solarsystem/sun/bastille_day_sun_textures').TexturesPath .. "/br_photo_bas05_trans_1000G_offset.png", - asset.require('./scene/solarsystem/sun/bastille_day_sun_textures').TexturesPath .. "/black.png", - asset.require('./scene/solarsystem/sun/sun_textures').TexturesPath .. "/sun.jpg", - } -} +-- must be >0 +textureIndex = 2; local Keybindings = { - { +-- the Shift+s key, might not reset as it is now because it simply +-- inverts multiple things that can be inverted indivitually +--[[ { Key = "Shift+s", Command = propertyHelper.invert('Scene.MAS_MHD_Fieldlines.Renderable.Enabled') .. - propertyHelper.invert('Scene.Sun.Renderable.Layers.ColorLayers.magnetogram.Enabled') .. - propertyHelper.invert('Scene.Sun.Renderable.Layers.ColorLayers.Texture.Enabled') .. propertyHelper.invert('Scene.MAS_MHD_density.Renderable.Enabled') .. propertyHelper.invert('Scene.SunGlare.Renderable.Enabled'), - Documentation = "Resets the s ubscene for showing the Sun volume rendering + fieldlines", + Documentation = "Resets the subscene for showing the Sun volume rendering + fieldlines", Name = "Reset MHD back", GuiPath = "/CCMC/MHD", Local = false - }, + },--]] + { + Key = "F6", + Command = propertyHelper.invert('Scene.MAS_MHD_density.Renderable.Enabled'), + Documentation = "Toggle volume", + Local = false + }, + { + Key = "F7", + Command = propertyHelper.invert('Scene.MAS_MHD_Fieldlines.Renderable.Enabled'), + Documentation = "Toggle fieldlines", + Local = false + }, { Key = "F8", Command = propertyHelper.invert('Scene.SunGlare.Renderable.Enabled'), @@ -54,33 +53,48 @@ local Keybindings = { { Key = "i", Command = [[ - if (textureList.Options.TexIndex == nil) then - textureList.Options.TexIndex = 1 + textureList = openspace.globebrowsing.getLayers('Sun', 'ColorLayers'); + + if (textureIndex == nil) then + textureIndex = 1; end; - textureList.Options.TexIndex = textureList.Options.TexIndex + 1 - if (textureList.Options.TexIndex > #textureList.SunTextures) then - textureList.Options.TexIndex = 1 + textureIndex = textureIndex + 1 + if (textureIndex >= #textureList) then + textureIndex = 1; + end; + + if (textureIndex == 1) then + openspace.setPropertyValue("Scene.Sun.Renderable.Layers.ColorLayers.*.Enabled", false); + openspace.setPropertyValueSingle("Scene.Sun.Renderable.Layers.ColorLayers.Texture.Enabled", true); + else + openspace.setPropertyValue("Scene.Sun.Renderable.Layers.ColorLayers.*.Enabled", false); + + str = "Scene.Sun.Renderable.Layers.ColorLayers.magnetogram-" .. textureIndex .. ".Enabled"; + openspace.setPropertyValueSingle(str, true); end; - openspace.setPropertyValueSingle('Scene.Sun.Renderable.Layers.ColorLayers.magnetogram.tileProvider.FilePath', textureList.SunTextures[textureList.Options.TexIndex]); ]], Documentation = "Display next sun texture in list of textures", Local = false - }, + } } -local sunAsset = asset.require('scene/solarsystem/sun/sun'); +local sunAsset = asset.require('scene/solarsystem/sun/sun'); --heliosphere/mas/bastille_day/ asset.onInitialize(function () - openspace.time.setTime("2000 JUL 14 09:33:37.100") + openspace.time.setTime("2000 JUL 14 08:33:37.100") sceneHelper.bindKeys(Keybindings) + + openspace.setPropertyValueSingle("Scene.Sun.Renderable.Layers.ColorLayers.Texture.Enabled", false) + local str = "Scene.Sun.Renderable.Layers.ColorLayers.magnetogram-" .. textureIndex .. ".Enabled"; + openspace.setPropertyValueSingle(str, true) openspace.setPropertyValueSingle('Scene.SunGlare.Renderable.Enabled', false) openspace.markInterestingNodes({ - "Earth", "Sun", "Moon", "FL_ENLIL_earth", "FL_MAS", "Mas_MHD" + "Earth", "Sun1", "Moon", "FL_ENLIL_earth", "FL_MAS", "Mas_MHD" }); openspace.addVirtualProperty( @@ -105,7 +119,7 @@ asset.onDeinitialize(function () sceneHelper.unbindKeys(Keybindings) openspace.removeInterestingNodes({ - "Earth", "Sun", "Moon", "FL_ENLIL_earth", "FL_MAS", "Mas_MHD" + "Earth", "Sun1", "Moon", "FL_ENLIL_earth", "FL_MAS", "Mas_MHD" }) openspace.removeVirtualProperty("*Trail.renderable.Enabled") diff --git a/data/assets/scene/solarsystem/sun/bastille_day_sun_textures.asset b/data/assets/scene/solarsystem/sun/heliosphere/mas/bastille_day/bastille_day_sun_textures.asset similarity index 64% rename from data/assets/scene/solarsystem/sun/bastille_day_sun_textures.asset rename to data/assets/scene/solarsystem/sun/heliosphere/mas/bastille_day/bastille_day_sun_textures.asset index 1d8a2329be..0725d818df 100644 --- a/data/assets/scene/solarsystem/sun/bastille_day_sun_textures.asset +++ b/data/assets/scene/solarsystem/sun/heliosphere/mas/bastille_day/bastille_day_sun_textures.asset @@ -2,6 +2,14 @@ -- Sun-to-Earth MHD Simulation of the 2000 July 14 Bastille Day Eruption. -- ApJ, -- 856:75. +asset.info = { + Name = "PREDSCI MAS Bastille Day Textures", + Version = "1.0", + Description = [[ Magnetograms of the sun ]], + Author = "OpenSpace Team", + URL = "https://ui.adsabs.harvard.edu/abs/2018ApJ...856...75T/abstract", + License = "" +} local TexturesPath = asset.syncedResource({ Name = "PREDSCI MAS Bastille Day Textures", diff --git a/data/assets/scene/solarsystem/sun/heliosphere/mas/bastille_day/density_volume.asset b/data/assets/scene/solarsystem/sun/heliosphere/mas/bastille_day/density_volume.asset index 849bc70f83..219f7c77f8 100644 --- a/data/assets/scene/solarsystem/sun/heliosphere/mas/bastille_day/density_volume.asset +++ b/data/assets/scene/solarsystem/sun/heliosphere/mas/bastille_day/density_volume.asset @@ -1,3 +1,12 @@ +asset.info = { + Name = "Volume Rendering Bastille Day", + Version = "1.0", + Description = [[ Volumetric rendering for the bastille day CME event ]], + Author = "OpenSpace Team", + URL = "", + License = "" +} + local assetHelper = asset.require("util/asset_helper") local sunTransforms = asset.require('scene/solarsystem/sun/transforms') diff --git a/data/assets/scene/solarsystem/sun/heliosphere/mas/bastille_day/fieldlines.asset b/data/assets/scene/solarsystem/sun/heliosphere/mas/bastille_day/fieldlines.asset index 47c8f73ffe..e38469f261 100644 --- a/data/assets/scene/solarsystem/sun/heliosphere/mas/bastille_day/fieldlines.asset +++ b/data/assets/scene/solarsystem/sun/heliosphere/mas/bastille_day/fieldlines.asset @@ -1,3 +1,12 @@ +asset.info = { + Name = "Fieldlines Bastille Day", + Version = "1.0", + Description = [[ Magnetic fieldlines for the bastille day CME event ]], + Author = "OpenSpace Team", + URL = "", + License = "" +} + local assetHelper = asset.require('util/asset_helper') local transforms = asset.require('./transforms') diff --git a/data/assets/scene/solarsystem/sun/heliosphere/mas/bastille_day/magnetogram.asset b/data/assets/scene/solarsystem/sun/heliosphere/mas/bastille_day/magnetogram.asset index 8349f8187b..8b237f55c4 100644 --- a/data/assets/scene/solarsystem/sun/heliosphere/mas/bastille_day/magnetogram.asset +++ b/data/assets/scene/solarsystem/sun/heliosphere/mas/bastille_day/magnetogram.asset @@ -1,31 +1,21 @@ -local assetHelper = asset.require('util/asset_helper') -local transforms = asset.require('./transforms') -local sun = asset.require('scene/solarsystem/sun/sun') +-- Torok, T., Downs, C., Linker, J. A., Lionello, R., Titov, V. S., Mikic, Z., Riley, P., Caplan, R. M., and Wijaya, J. (2018). +-- Sun-to-Earth MHD Simulation of the 2000 July 14 Bastille Day Eruption. +-- ApJ, +-- 856:75. +asset.info = { + Name = "PREDSCI MAS Bastille Day Textures", + Version = "1.0", + Description = [[ Magnetograms of the sun ]], + Author = "OpenSpace Team", + URL = "https://ui.adsabs.harvard.edu/abs/2018ApJ...856...75T/abstract", + License = "" +} -local magnetogramDirectory = asset.syncedResource({ +local TexturesPath = asset.syncedResource({ Name = "Bastille Day Magnetogram", Type = "HttpSynchronization", Identifier = "bastille_day_magnetogram", Version = 1 }) -asset.export("directory", magnetogramDirectory) - -asset.onInitialize(function () - openspace.globebrowsing.addLayer( - 'Sun', - 'ColorLayers', - { - Identifier = "magnetogram", - Name = "Magnetogram", - Description = "", - FilePath = magnetogramDirectory .. "/br_bas05_100G_inv_redblue.png", - Enabled = true - } - ) - -end) - -asset.onDeinitialize(function () - -end) +asset.export("TexturesPath", TexturesPath) diff --git a/data/assets/scene/solarsystem/sun/magnetogram_textures.asset b/data/assets/scene/solarsystem/sun/magnetogram_textures.asset new file mode 100644 index 0000000000..6f18a3a079 --- /dev/null +++ b/data/assets/scene/solarsystem/sun/magnetogram_textures.asset @@ -0,0 +1,39 @@ +local assetHelper = asset.require('util/asset_helper') +local transforms = asset.require('./transforms') +local sun = asset.require('scene/solarsystem/sun/sun') + +-- synced directories +local textureDirectory = asset.require('./heliosphere/mas/bastille_day/bastille_day_sun_textures').TexturesPath; +local magnetogramDirectory = asset.require('./heliosphere/mas/bastille_day/magnetogram').TexturesPath; + +-- lists of paths +local magnetograms = openspace.walkDirectoryFiles(magnetogramDirectory); +local textures = openspace.walkDirectoryFiles(textureDirectory); + +-- put elements from textures into magnetograms +for _, v in ipairs(textures) do + table.insert(magnetograms, v) +end + +asset.onInitialize(function () + -- add all all elements in magnetograms as layers + for i, imagename in ipairs(magnetograms) do + + openspace.globebrowsing.addLayer( + 'Sun', + 'ColorLayers', + { + Identifier = "magnetogram-" .. i, + Name = imagename, --"Magnetogram-" .. i, + Description = "", + FilePath = imagename, + Enabled = false + } + ) + end + +end) + +asset.onDeinitialize(function () + +end) diff --git a/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp b/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp index 2306870ef8..6b2eb162d3 100644 --- a/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp +++ b/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp @@ -243,7 +243,7 @@ namespace { return backupValue; } return tmp; - } + } } // namespace namespace openspace {