Merge branch 'master' into thesis/2020/software-integration

This commit is contained in:
Emma Broman
2021-02-09 13:38:00 +01:00
175 changed files with 4837 additions and 5101 deletions

1
.gitignore vendored
View File

@@ -38,3 +38,4 @@ Thumbs.db
customization.lua
# The COMMIT info is generated everytime CMake is run
COMMIT.md
*_codegen.cpp

3
.gitmodules vendored
View File

@@ -29,3 +29,6 @@
[submodule "ext/date"]
path = ext/date
url = https://github.com/HowardHinnant/date
[submodule "support/coding/codegen"]
path = support/coding/codegen
url = https://github.com/OpenSpace/codegen

View File

@@ -139,12 +139,29 @@ if (UNIX AND CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -stdlib=libc++ -lc++ -lc++abi")
endif ()
# Add external dependencies
add_subdirectory(${OPENSPACE_BASE_DIR}/ext)
add_subdirectory(ext)
# include(src/CMakeLists.txt)
add_subdirectory(src)
add_subdirectory(support/coding/codegen)
# It is important that the __codegen.h do not actually exist so
# that this target is never considered as finished
add_custom_target(
run_codegen
ALL DEPENDS
"${CMAKE_CURRENT_BINARY_DIR}/__codegen.h"
)
add_dependencies(run_codegen codegen)
add_custom_command(
OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/__codegen.h"
COMMAND codegen ARGS "${OPENSPACE_BASE_DIR}/modules" "${OPENSPACE_BASE_DIR}/src"
VERBATIM
)
set_folder_location(codegen-lib "support")
set_folder_location(codegen "support")
set_folder_location(run_codegen "support")
# Qt
# Unfortunately, we have to set this value manually; sigh
# In the future, if the Qt version is updated, just add to this variable ---abock
@@ -176,6 +193,12 @@ begin_header("Configuring Modules")
add_subdirectory("${CMAKE_CURRENT_SOURCE_DIR}/modules")
end_header("End: Configuring Modules")
add_subdirectory(support/coding/codegen/tests)
set_folder_location(run_test_codegen "Unit Tests/support")
set_folder_location(codegentest "Unit Tests")
begin_header("Configuring Applications")
add_subdirectory("${OPENSPACE_APPS_DIR}")
end_header("End: Configuring Applications")

5
Jenkinsfile vendored
View File

@@ -114,6 +114,7 @@ linux_gcc_make: {
}
stage('linux-gcc-make/test') {
// testHelper.runUnitTests('build/OpenSpaceTest');
// testHelper.runUnitTests('bin/codegentest')
}
cleanWs()
} // node('linux')
@@ -134,6 +135,7 @@ linux_gcc_ninja: {
}
stage('linux-gcc-ninja/test') {
// testHelper.runUnitTests('build/OpenSpaceTest');
// testHelper.runUnitTests('bin/codegentest')
}
cleanWs()
} // node('linux')
@@ -155,6 +157,7 @@ linux_clang_make: {
}
stage('linux-clang-make/test') {
// testHelper.runUnitTests('build/OpenSpaceTest');
// testHelper.runUnitTests('bin/codegentest')
}
cleanWs()
} // node('linux')
@@ -175,6 +178,7 @@ linux_clang_ninja: {
}
stage('linux-clang-ninja/test') {
// testHelper.runUnitTests('build/OpenSpaceTest');
// testHelper.runUnitTests('bin/codegentest')
}
cleanWs()
} // node('linux')
@@ -194,6 +198,7 @@ windows_msvc: {
stage('windows-msvc/test') {
// Currently, the unit tests are failing on Windows
// testHelper.runUnitTests('bin\\Debug\\OpenSpaceTest')
testHelper.runUnitTests('bin\\Debug\\codegentest')
}
cleanWs()
} // node('windows')

View File

@@ -90,3 +90,11 @@ set_openspace_compile_settings(openspace-ui-launcher)
target_include_directories(openspace-ui-launcher PUBLIC include)
target_link_libraries(openspace-ui-launcher PUBLIC Qt5::Core Qt5::Gui Qt5::Widgets openspace-core)
if (MSVC)
set(MSVC_WARNINGS
"/wd4619" # #pragma warning: there is no warning number (raised by Qt headers)
"/wd4946" # reinterpret_cast used between related classes:
)
target_compile_options(openspace-ui-launcher INTERFACE ${MSVC_WARNINGS})
endif ()

View File

@@ -41,11 +41,11 @@
#include <ghoul/lua/ghoul_lua.h>
#include <ghoul/misc/assert.h>
#include <ghoul/misc/boolean.h>
//#include <ghoul/opengl/ghoul_gl.h>
#include <GLFW/glfw3.h>
#include <ghoul/opengl/ghoul_gl.h>
#ifdef WIN32
#define GLFW_EXPOSE_NATIVE_WIN32
#endif
#include <GLFW/glfw3.h>
#include <GLFW/glfw3native.h>
#include <sgct/clustermanager.h>
#include <sgct/commandline.h>
@@ -576,7 +576,7 @@ void mainPostDrawFunc() {
glBindTexture(GL_TEXTURE_2D, texId);
w.leftOrMain.handle->SendTexture(
texId,
GL_TEXTURE_2D,
GLuint(GL_TEXTURE_2D),
window.framebufferResolution().x,
window.framebufferResolution().y
);
@@ -587,7 +587,7 @@ void mainPostDrawFunc() {
glBindTexture(GL_TEXTURE_2D, tId);
w.right.handle->SendTexture(
tId,
GL_TEXTURE_2D,
GLuint(GL_TEXTURE_2D),
window.framebufferResolution().x,
window.framebufferResolution().y
);
@@ -1013,7 +1013,6 @@ std::string selectedSgctProfileFromLauncher(LauncherWindow& lw, bool hasCliSGCTC
}
int main(int argc, char* argv[]) {
#ifdef WIN32
SetUnhandledExceptionFilter(generateMiniDump);
#endif // WIN32

View File

@@ -8,11 +8,10 @@ asset.require('examples/pointscloud')
-- Specifying which other assets should be loaded in this scene
asset.require('scene/solarsystem/sun/sun')
asset.require('scene/solarsystem/sun/glare')
asset.require('scene/solarsystem/sun/habitablezone')
asset.require('scene/solarsystem/sun/default_layers')
asset.require('scene/solarsystem/planets/planets')
asset.require('scene/solarsystem/planets/default_layers')
asset.require('scene/solarsystem/planets/mars/moons/phobos')
asset.require('scene/solarsystem/planets/mars/moons/deimos')
asset.require('scene/solarsystem/dwarf_planets/pluto/system')
asset.require('scene/solarsystem/dwarf_planets/pluto/default_layers')
asset.require('scene/solarsystem/dwarf_planets/pluto/charon/default_layers')
@@ -22,9 +21,11 @@ asset.require('scene/milkyway/constellations/constellation_keybinds')
asset.require('scene/milkyway/objects/orionnebula/orionnebula')
asset.require('util/launcher_images')
local assetHelper = asset.require('util/asset_helper')
-- For exoplanet system visualizations
asset.require('scene/milkyway/exoplanets/exoplanets_data')
asset.require('scene/milkyway/exoplanets/exoplanets_textures')
local assetHelper = asset.require('util/asset_helper')
asset.require('scene/digitaluniverse/2dF')
asset.require('scene/digitaluniverse/2mass')
asset.require('scene/digitaluniverse/6dF')

View File

@@ -0,0 +1,25 @@
local assetHelper = asset.require('util/asset_helper')
local color = {0.0, 1.0, 1.0}
-- @TODO (emmbr 2020-02-03) Potential threading issue later on? This will run on the main thread
local singeColorTexturePath = openspace.createSingeColorImage("example_ring_color", color)
local BasicDisc = {
Identifier = "BasicDisc",
Parent = "Root",
Renderable = {
Type = "RenderableDisc",
Texture = singeColorTexturePath,
Size = 1e10,
Width = 0.5
},
GUI = {
Name = "Basic Disc",
Path = "/Examples/Discs"
}
}
assetHelper.registerSceneGraphNodesAndExport(asset, {
BasicDisc
})

View File

@@ -5,3 +5,14 @@ local DataPath = asset.syncedResource({
Version = 2
})
asset.export("DataPath", DataPath)
asset.meta = {
Name = "Exoplanet Data",
Version = "2.0",
Description = [[ The data that is used for the exoplanet systems. The data has been
derived from the 'Planetary Systems Composite Data' dataset from the NASA Exoplanet
Archive]],
Author = "OpenSpace Team",
URL = "https://exoplanetarchive.ipac.caltech.edu/docs/data.html",
License = "MIT license",
}

View File

@@ -1,7 +1,19 @@
asset.require('./../habitable_zones/habitable_zone_textures')
local TexturesPath = asset.syncedResource({
Name = "Exoplanet Textures",
Type = "HttpSynchronization",
Identifier = "exoplanets_textures",
Version = 1
Version = 2
})
asset.export("TexturesPath", TexturesPath)
asset.meta = {
Name = "Exoplanet Textures",
Version = "2.0",
Description = [[ Adds all textures that are required for the exoplanet system
visualizations]],
Author = "OpenSpace Team",
URL = "http://openspaceproject.com",
License = "MIT license",
}

View File

@@ -0,0 +1,17 @@
local TexturesPath = asset.syncedResource({
Name = "Habitable Zone Textures",
Type = "HttpSynchronization",
Identifier = "habitable_zone_textures",
Version = 1
})
asset.export("TexturesPath", TexturesPath)
asset.meta = {
Name = "Habitable Zone Textures",
Version = "1.0",
Description = [[ Default textures that can be used for the habitable zone
rendering]],
Author = "OpenSpace Team",
URL = "http://openspaceproject.com",
License = "MIT license",
}

View File

@@ -31,16 +31,17 @@ local Charon = {
Enable = false,
FileName = labelsPath .. "/charon.labels",
LabelAlignmentOption = "Horizontally", -- or Circularly
LabelsFontSize = 14.0,
LabelsFontSize = 40.0,
LabelsSize = 8.0,
LabelsMinSize = 1.0,
LabelsMaxSize = 1500.0,
ProximityEnabled = false,
LabelsFadeInEnabled = true,
FadeInStartingDistance = 500000.0,
FadeOutStartingDistance = 1000000.0,
LabelsFadeOutEnabled = true,
FadeInStartingDistance = 2000000.0,
FadeOutStartingDistance = 800000.0,
LabelsForceDomeRendering = true,
LabelsDistanceEPS = 1350000.0,
LabelsDistanceEPS = 250000.0,
LabelsColor = { 1.0, 1.0, 0.0 }
}
},

View File

@@ -31,16 +31,17 @@ local Pluto = {
Enable = false,
FileName = labelsPath .. "/pluto.labels",
LabelAlignmentOption = "Horizontally", -- or Circularly
LabelsFontSize = 14.0,
LabelsFontSize = 28.0,
LabelsSize = 8.0,
LabelsMinSize = 1.0,
LabelsMaxSize = 1500.0,
ProximityEnabled = false,
LabelsFadeInEnabled = true,
FadeInStartingDistance = 500000.0,
FadeOutStartingDistance = 1000000.0,
LabelsFadeOutEnabled = true,
FadeInStartingDistance = 4000000.0,
FadeOutStartingDistance = 650000.0,
LabelsForceDomeRendering = true,
LabelsDistanceEPS = 1350000.0,
LabelsDistanceEPS = 500000.0,
LabelsColor = { 1.0, 1.0, 0.0 }
}
},

View File

@@ -15,7 +15,7 @@ local kernelsList = {kernelsFolder .. '/p10-a.bsp'}
local Pioneer10NAIF = "-23"
local Pioneer10 = {
Identifier = "Pioneer10",
Identifier = "Pioneer_10",
Parent = sunTransforms.SolarSystemBarycenter.Identifier,
Transform = {
Translation = {
@@ -27,13 +27,15 @@ local Pioneer10 = {
},
Renderable = model.PioneerModel,
GUI = {
Name = "Pioneer 10",
Path = "/Solar System/Missions/Pioneer/10"
Name = "Pioneer 10 Spacecraft",
Path = "/Solar System/Missions/Pioneer",
Description = [[Pioneer 10 Spacecraft. Positioned by SPICE data.]]
}
}
local Pioneer10Trail = {
Identifier = "Pioneer10Trail",
Identifier = "Pioneer_10Trail",
Parent = sunTransforms.SolarSystemBarycenter.Identifier,
Renderable = {
Type = "RenderableTrailTrajectory",
@@ -51,8 +53,10 @@ local Pioneer10Trail = {
-- 6545 is the number of days between the Start and End time (aka sample every 2d)
},
GUI = {
Name = "Pioneer 10 Trail",
Path = "/Solar System/Missions/Pioneer/10"
Name = "Pioneer 10 Trail (SPICE)",
Path = "/Solar System/Missions/Pioneer",
Description = [[Pioneer 10 Trail, spanning March 3rd, 1972 to January 2nd, 1990.
Data from SPICE]]
}
}
@@ -60,3 +64,15 @@ assetHelper.registerSceneGraphNodesAndExport(asset, {
Pioneer10,
Pioneer10Trail,
})
asset.meta = {
Name = "Pioneer 10",
Version = "1.0",
Description = [[ Pioneer 10 Model and Trail. Driven by SPICE data for high accuracy
from March 3rd, 1972 to January 2nd, 1990.]],
Author = "OpenSpace Team",
URL = "http://openspaceproject.com",
License = "MIT license",
Identifiers = {"Pioneer_10", "Pioneer_10Trail"}
}

View File

@@ -30,13 +30,14 @@ local Pioneer11 = {
},
Renderable = model.PioneerModel,
GUI = {
Name = "Pioneer 11",
Path = "/Solar System/Missions/Pioneer/11"
Name = "Pioneer 11 Spacecraft",
Path = "/Solar System/Missions/Pioneer",
Description = [[Pioneer 11 Spacecraft. Positioned by SPICE data.]]
}
}
local Pioneer11Trail = {
Identifier = "Pioneer11Trail",
Identifier = "Pioneer_11Trail",
Parent = sunTransforms.SolarSystemBarycenter.Identifier,
Renderable = {
Type = "RenderableTrailTrajectory",
@@ -54,8 +55,10 @@ local Pioneer11Trail = {
--6087 is the number of days between the Start and End time (so sample every 2d)
},
GUI = {
Name = "Pioneer 11 Trail",
Path = "/Solar System/Missions/Pioneer/11"
Name = "Pioneer 11 Trail (SPICE)",
Path = "/Solar System/Missions/Pioneer",
Description = [[Pioneer 11 Trail, spanning April 6th, 1973 to January 2nd, 1990.
Data from SPICE.]]
}
}
@@ -63,3 +66,15 @@ assetHelper.registerSceneGraphNodesAndExport(asset, {
Pioneer11,
Pioneer11Trail,
})
asset.meta = {
Name = "Pioneer 11",
Version = "1.0",
Description = [[ Pioneer 11 Model and Trail. Driven by SPICE data for high accuracy
from April 6th, 1973 to January 2nd, 1990.]],
Author = "OpenSpace Team",
URL = "http://openspaceproject.com",
License = "MIT license",
Identifiers = {"Pioneer_11", "Pioneer_11Trail"}
}

View File

@@ -1,5 +1,5 @@
local assetHelper = asset.require('util/asset_helper')
local sunTransforms = asset.require('scene/solarsystem/sun/transforms')
local modelFolder = asset.syncedResource({
Name = "Pioneer 10/11 Models",
@@ -21,3 +21,13 @@ local ModelRenderable = {
}
asset.export("PioneerModel", ModelRenderable)
asset.meta = {
Name = "Pioneer Model",
Version = "1.0",
Description = [[ Pioneer model asset. Used by both pioneer 10 and pioneer 11 asset.
Untextured version of model from NASA 3D resources.]],
Author = "NASA",
URL = "https://nasa3d.arc.nasa.gov/detail/eoss-pioneer",
License = "NASA"
}

View File

@@ -20,8 +20,10 @@ local voyager1 = {
TimeStampSubsampleFactor = 1
},
GUI = {
Name = "Voyager 1",
Path = "/Solar System/Missions"
Name = "Voyager 1 Trail",
Path = "/Solar System/Missions/Voyager",
Description = [[Voyager 1 Trail, spanning September 6th, 1977 to December 31st,
2030. Data from JPL Horizons.]]
}
}
@@ -43,8 +45,10 @@ local voyager2 = {
TimeStampSubsampleFactor = 1
},
GUI = {
Name = "Voyager 2",
Path = "/Solar System/Missions"
Name = "Voyager 2 Trail",
Path = "/Solar System/Missions/Voyager",
Description = [[Voyager 2 Trail, spanning August 21st, 1977 to December 31st, 2030.
Data from JPL Horizons.]]
}
}
@@ -66,8 +70,10 @@ local pioneer10 = {
TimeStampSubsampleFactor = 1
},
GUI = {
Name = "Pioneer 10",
Path = "/Solar System/Missions"
Name = "Pioneer 10 Trail",
Path = "/Solar System/Missions/Pioneer",
Description = [[Pioneer 10 Trail, spanning March 4th, 1972 to December 31st, 2030.
Data from JPL Horizons.]]
}
}
@@ -89,9 +95,24 @@ local pioneer11 ={
TimeStampSubsampleFactor = 1
},
GUI = {
Name = "Pioneer 11",
Path = "/Solar System/Missions"
Name = "Pioneer 11 Trail",
Path = "/Solar System/Missions/Pioneer",
Description = [[Pioneer 11 Trail, spanning April 7th, 1973 to December 31st, 2030.
Data from JPL Horizons.]]
}
}
assetHelper.registerSceneGraphNodesAndExport(asset, { voyager1, voyager2, pioneer10, pioneer11 })
asset.meta = {
Name = "Pioneer and Voyager Trails",
Version = "1.0",
Description = [[ Pioneer 10, Pioneer 11, Voyager 1 and Voyager 2 trails. Driven by JPL
Horizons data for better performance then spice but lower resolution. Data is from
shortly after mission launches until December 31st, 2030.]],
Author = "OpenSpace Team",
URL = "http://openspaceproject.com",
License = "MIT license",
Identifiers = {"Pioneer10", "Pioneer11", "Voyager1", "Voyager2"}
}

View File

@@ -8,6 +8,8 @@ asset.require('./jupiter/ganymede/default_layers')
asset.require('./jupiter/io/default_layers')
asset.require('./mars/default_layers')
asset.require('./mars/moons/layers/colorlayers/deimos_viking')
asset.require('./mars/moons/layers/colorlayers/phobos_viking')
asset.require('./mercury/default_layers')

View File

@@ -26,15 +26,15 @@ local Earth = {
Enable = false,
FileName = labelsPath .. "/Earth.labels",
LabelAlignmentOption = "Horizontally", -- or Circularly
LabelsFontSize = 41.0,
LabelsSize = 0.52,
LabelsFontSize = 40.0,
LabelsSize = 4.0,
LabelsMinSize = 1.0,
LabelsMaxSize = 1500.0,
ProximityEnabled = false,
LabelsFadeInEnabled = true,
LabelsFadeOutEnabled = false,
FadeInStartingDistance = 50000.0,
FadeOutStartingDistance = 80000.0,
LabelsFadeOutEnabled = true,
FadeInStartingDistance = 300000.0,
FadeOutStartingDistance = 10000.0,
LabelsForceDomeRendering = true,
LabelsDistanceEPS = 1500000.0,
LabelsColor = { 1.0, 0.0, 0.0 }

View File

@@ -43,8 +43,9 @@ local Moon = {
LabelsMaxSize = 1500.0,
ProximityEnabled = false,
LabelsFadeInEnabled = true,
LabelsFadeOutEnabled = true,
FadeInStartingDistance = 500000.0,
FadeOutStartingDistance = 1000000.0,
FadeOutStartingDistance = 100000.0,
LabelsForceDomeRendering = true,
LabelsDistanceEPS = 1350000.0,
LabelsColor = { 1.0, 1.0, 0.0 }

View File

@@ -37,8 +37,9 @@ local Callisto = {
LabelsMaxSize = 1500.0,
ProximityEnabled = false,
LabelsFadeInEnabled = true,
LabelsFadeOutEnabled = true,
FadeInStartingDistance = 15000000.0,
FadeOutStartingDistance = 1000000.0,
FadeOutStartingDistance = 5000000.0,
LabelsForceDomeRendering = true,
LabelsDistanceEPS = 1350000.0,
LabelsColor = { 1.0, 1.0, 0.0 }

View File

@@ -32,15 +32,16 @@ local Europa = {
FileName = labelsPath .. "/europa.labels",
LabelAlignmentOption = "Horizontally", -- or Circularly
LabelsFontSize = 40.0,
LabelsSize = 10.5,
LabelsSize = 10.0,
LabelsMinSize = 1.0,
LabelsMaxSize = 1500.0,
ProximityEnabled = false,
LabelsFadeInEnabled = true,
FadeInStartingDistance = 15000000.0,
FadeOutStartingDistance = 1000000.0,
LabelsFadeOutEnabled = true,
FadeInStartingDistance = 8000000.0,
FadeOutStartingDistance = 5000000.0,
LabelsForceDomeRendering = true,
LabelsDistanceEPS = 1350000.0,
LabelsDistanceEPS = 700000.0,
LabelsColor = { 1.0, 1.0, 0.0 }
}
},

View File

@@ -37,10 +37,11 @@ local Ganymede = {
LabelsMaxSize = 1500.0,
ProximityEnabled = false,
LabelsFadeInEnabled = true,
FadeInStartingDistance = 15000000.0,
FadeOutStartingDistance = 1000000.0,
LabelsFadeOutEnabled = true,
FadeInStartingDistance = 8000000.0,
FadeOutStartingDistance = 2250000.0,
LabelsForceDomeRendering = true,
LabelsDistanceEPS = 1350000.0,
LabelsDistanceEPS = 1750000.0,
LabelsColor = {1.0, 1.0, 0.0}
}
},

View File

@@ -32,15 +32,16 @@ local Io = {
FileName = labelsPath .. "/io.labels",
LabelAlignmentOption = "Horizontally", -- or Circularly
LabelsFontSize = 40.0,
LabelsSize = 10.5,
LabelsSize = 10.0,
LabelsMinSize = 1.0,
LabelsMaxSize = 1500.0,
ProximityEnabled = false,
LabelsFadeInEnabled = true,
FadeInStartingDistance = 15000000.0,
FadeOutStartingDistance = 1000000.0,
LabelsFadeOutEnabled = true,
FadeInStartingDistance = 8500000.0,
FadeOutStartingDistance = 4000000.0,
LabelsForceDomeRendering = true,
LabelsDistanceEPS = 1350000.0,
LabelsDistanceEPS = 1000000.0,
LabelsColor = { 1.0, 1.0, 0.0 }
}
},

View File

@@ -4,7 +4,7 @@ local globeIdentifier = asset.require("./../../mars").Mars.Identifier
local layer = {
Identifier = "HiRISE-LS-DEM",
Name = "HiRISE Local Set DEM",
FilePath = mapServiceConfigs .. "/ESRI/HiRISE/HiRISE_DEM.wms",
FilePath = mapServiceConfigs .. "/ESRI/HiRISE/HiRISE_DEM.dem",
Description = [[ HiRISE (High Resolution Imaging Science Experiment) is the most
powerful camera ever sent to another planet, one of six instruments onboard the
Mars Reconnaissance Orbiter. We launched in 2005, arrived at Mars in 2006 and have

View File

@@ -1,6 +1,6 @@
<GDAL_WMS>
<Service name="TMS">
<ServerUrl>http://astro.arcgis.com/arcgis/rest/services/OnMars/HiRISE_DEM/ImageServer/tile/${z}/${y}/${x}</ServerUrl>
<ServerUrl>http://astro.arcgis.com/arcgis/rest/services/OnMars/HiRISE_DEM/raw/tile/${z}/${y}/${x}</ServerUrl>
</Service>
<DataWindow>
<UpperLeftX>-180</UpperLeftX> <UpperLeftY>90</UpperLeftY>
@@ -11,7 +11,7 @@
<Projection>GEOGCS["GCS_Mars_2000_Sphere",DATUM["D_Mars_2000_Sphere",SPHEROID["Mars_2000_Sphere_IAU_IAG",3396190,0]],PRIMEM["Reference_Meridian",0],UNIT["Degree",0.0174532925199433]]</Projection>
<BlockSizeX>512</BlockSizeX> <BlockSizeY>512</BlockSizeY>
<BandsCount>1</BandsCount> <DataType>Int16</DataType>
<DataValues NoData="-32768" Min="-8528" Max="21226"/>
<DataValues NoData="0" Min="-8528" Max="21226"/>
<MaxConnections>5</MaxConnections>
<ZeroBlockHttpCodes>404,400</ZeroBlockHttpCodes>
</GDAL_WMS>

View File

@@ -1,17 +0,0 @@
<GDAL_WMS>
<Service name="TMS">
<ServerUrl>http://astro.arcgis.com/arcgis/rest/services/OnMars/HiRISE_DEM/ImageServer/tile/${z}/${y}/${x}</ServerUrl>
</Service>
<DataWindow>
<UpperLeftX>-180</UpperLeftX> <UpperLeftY>90</UpperLeftY>
<LowerRightX>180</LowerRightX> <LowerRightY>-90</LowerRightY>
<SizeX>20971520</SizeX> <SizeY>10485760</SizeY>
<TileLevel>15</TileLevel> <YOrigin>top</YOrigin>
</DataWindow>
<Projection>GEOGCS["GCS_Mars_2000_Sphere",DATUM["D_Mars_2000_Sphere",SPHEROID["Mars_2000_Sphere_IAU_IAG",3396190,0]],PRIMEM["Reference_Meridian",0],UNIT["Degree",0.0174532925199433]]</Projection>
<BlockSizeX>512</BlockSizeX> <BlockSizeY>512</BlockSizeY>
<BandsCount>1</BandsCount> <DataType>Int16</DataType>
<DataValues NoData="0" Min="-10000" Max="10000"></DataValues>
<MaxConnections>5</MaxConnections>
<ZeroBlockHttpCodes>404,400</ZeroBlockHttpCodes>
</GDAL_WMS>

View File

@@ -27,15 +27,16 @@ local Mars = {
FileName = labelsPath .. "/mars.labels",
LabelAlignmentOption = "Horizontally", -- or Circularly
LabelsFontSize = 14.0,
LabelsSize = 8.0,
LabelsSize = 9.0,
LabelsMinSize = 1.0,
LabelsMaxSize = 1500.0,
ProximityEnabled = false,
LabelsFadeInEnabled = true,
FadeInStartingDistance = 500000.0,
FadeOutStartingDistance = 1000000.0,
LabelsFadeOutEnabled = true,
FadeInStartingDistance = 2000000.0,
FadeOutStartingDistance = 750000.0,
LabelsForceDomeRendering = true,
LabelsDistanceEPS = 1350000.0,
LabelsDistanceEPS = 2500000.0,
LabelsColor = { 1.0, 1.0, 0.0 }
}
},

View File

@@ -0,0 +1,29 @@
local globeIdentifier = asset.require("./../../deimos").Deimos.Identifier
local layer = {
Identifier = "Deimos_Global_Mosaic_USGS",
Name = "Deimos Global Mosaic [USGS]",
Enabled = true,
FilePath = "WMS:https://wms.wr.usgs.gov/cgi-bin/mapserv?map=/maps/mars/deimos_simp_cyl.map&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&LAYERS=Deimos_Simple_Cylindrical_Rasters&SRS=EPSG:4326&BBOX=-180,-90,360,90",
Description = [[ This Viking-based cylindrical map of Deimos was created by Philip
Stooke with the assistance of Chris Jongkind and Megan Arntz. Control is based on a
shape model and mosaic by Peter Thomas and colleagues at Cornell University. Date
released 26 October 2001. (Description from URL)]]
}
asset.onInitialize(function ()
openspace.globebrowsing.addLayer(globeIdentifier, "ColorLayers", layer)
end)
asset.export("layer", layer)
asset.meta = {
Name = "Deimos Global Mosaic [USGS]",
Version = "1.0",
Author = "Philip Stooke/NASA",
URL = "https://astrowebmaps.wr.usgs.gov/webmapatlas/Layers/maps.html",
License = "NASA/PDS",
Identifiers = {'Deimos_Global_Mosaic_USGS'}
}

View File

@@ -0,0 +1,26 @@
local globeIdentifier = asset.require("./../../phobos").Phobos.Identifier
local layer = {
Identifier = "Phobos_Global_Shaded_Relief_USGS",
Name = "Phobos Global Shaded Relief [USGS]",
Enabled = true,
FilePath = "WMS:https://wms.wr.usgs.gov/cgi-bin/mapserv?map=/maps/mars/phobos_simp_cyl.map&SERVICE=WMS&VERSION=1.1.1&REQUEST=GetMap&LAYERS=Phobos_Simple_Cylindrical_Rasters&SRS=EPSG:4326&BBOX=-180,-90,360,90",
Description = [[ Viking-base Phobos shaded relief created by USGS.]]
}
asset.onInitialize(function ()
openspace.globebrowsing.addLayer(globeIdentifier, "ColorLayers", layer)
end)
asset.export("layer", layer)
asset.meta = {
Name = "Phobos Global Shaded Relief [USGS]",
Version = "1.0",
Author = "USGS/NASA",
URL = "https://astrowebmaps.wr.usgs.gov/webmapatlas/Layers/maps.html",
License = "NASA/PDS",
Identifiers = {'Phobos_Global_Shaded_Relief_USGS'}
}

View File

@@ -27,13 +27,15 @@ local Mercury = {
Enable = false,
FileName = labelsPath .. "/Mercury.labels",
LabelAlignmentOption = "Horizontally", -- or Circularly
LabelsFontSize = 40.0,
LabelsFontSize = 22.0,
LabelsSize = 10.0,
LabelsMinSize = 1.0,
LabelsMaxSize = 1500.0,
ProximityEnabled = false,
FadeInStartingDistance = 40000000.0,
FadeOutStartingDistance = 80000.0,
LabelsFadeInEnabled = true,
LabelsFadeOutEnabled = true,
FadeInStartingDistance = 5000000.0,
FadeOutStartingDistance = 1800000.0,
LabelsForceDomeRendering = true,
LabelsDistanceEPS = 1500000.0,
LabelsColor = { 1.0, 1.0, 0.0 }

View File

@@ -14,6 +14,8 @@ asset.require('./earth/moon/trail')
asset.require('./mars/mars')
asset.require('./mars/atmosphere')
asset.require('./mars/moons/phobos')
asset.require('./mars/moons/deimos')
asset.require('./jupiter/jupiter')
asset.require('./jupiter/major_moons')

View File

@@ -29,16 +29,17 @@ local Dione = {
Enable = false,
FileName = labelsPath .. "/dione.labels",
LabelAlignmentOption = "Horizontally", -- or Circularly
LabelsFontSize = 14.0,
LabelsFontSize = 32.0,
LabelsSize = 8.0,
LabelsMinSize = 1.0,
LabelsMaxSize = 1500.0,
ProximityEnabled = false,
LabelsFadeInEnabled = true,
FadeInStartingDistance = 500000.0,
LabelsFadeOutEnabled = true,
FadeInStartingDistance = 3500000.0,
FadeOutStartingDistance = 1000000.0,
LabelsForceDomeRendering = true,
LabelsDistanceEPS = 1350000.0,
LabelsDistanceEPS = 200000.0,
LabelsColor = { 1.0, 1.0, 0.0 }
}
},

View File

@@ -29,16 +29,17 @@ local Enceladus = {
Enable = false,
FileName = labelsPath .. "/enceladus.labels",
LabelAlignmentOption = "Horizontally", -- or Circularly
LabelsFontSize = 14.0,
LabelsFontSize = 22.0,
LabelsSize = 8.0,
LabelsMinSize = 1.0,
LabelsMaxSize = 1500.0,
ProximityEnabled = false,
LabelsFadeInEnabled = true,
FadeInStartingDistance = 500000.0,
FadeOutStartingDistance = 1000000.0,
LabelsFadeOutEnabled = true,
FadeInStartingDistance = 1000000.0,
FadeOutStartingDistance = 500000.0,
LabelsForceDomeRendering = true,
LabelsDistanceEPS = 1350000.0,
LabelsDistanceEPS = 100000.0,
LabelsColor = { 1.0, 1.0, 0.0 }
}
},

View File

@@ -29,16 +29,17 @@ local Iapetus = {
Enable = false,
FileName = labelsPath .. "/iapetus.labels",
LabelAlignmentOption = "Horizontally", -- or Circularly
LabelsFontSize = 14.0,
LabelsFontSize = 30.0,
LabelsSize = 8.0,
LabelsMinSize = 1.0,
LabelsMaxSize = 1500.0,
ProximityEnabled = false,
LabelsFadeInEnabled = true,
FadeInStartingDistance = 500000.0,
FadeOutStartingDistance = 1000000.0,
LabelsFadeOutEnabled = true,
FadeInStartingDistance = 3500000.0,
FadeOutStartingDistance = 600000.0,
LabelsForceDomeRendering = true,
LabelsDistanceEPS = 1350000.0,
LabelsDistanceEPS = 250000.0,
LabelsColor = { 1.0, 1.0, 0.0 }
}
},

View File

@@ -35,10 +35,11 @@ local Mimas = {
LabelsMaxSize = 1500.0,
ProximityEnabled = false,
LabelsFadeInEnabled = true,
FadeInStartingDistance = 500000.0,
FadeOutStartingDistance = 1000000.0,
LabelsFadeOutEnabled = true,
FadeInStartingDistance = 1000000.0,
FadeOutStartingDistance = 400000.0,
LabelsForceDomeRendering = true,
LabelsDistanceEPS = 1350000.0,
LabelsDistanceEPS = 25000.0,
LabelsColor = { 1.0, 1.0, 0.0 }
}
},

View File

@@ -29,16 +29,17 @@ local Rhea = {
Enable = false,
FileName = labelsPath .. "/rhea.labels",
LabelAlignmentOption = "Horizontally", -- or Circularly
LabelsFontSize = 14.0,
LabelsFontSize = 40.0,
LabelsSize = 8.0,
LabelsMinSize = 1.0,
LabelsMaxSize = 1500.0,
ProximityEnabled = false,
LabelsFadeInEnabled = true,
FadeInStartingDistance = 500000.0,
LabelsFadeOutEnabled = true,
FadeInStartingDistance = 2500000.0,
FadeOutStartingDistance = 1000000.0,
LabelsForceDomeRendering = true,
LabelsDistanceEPS = 1350000.0,
LabelsDistanceEPS = 250000.0,
LabelsColor = { 1.0, 1.0, 0.0 }
}
},

View File

@@ -29,16 +29,17 @@ local Tethys = {
Enable = false,
FileName = labelsPath .. "/tethys.labels",
LabelAlignmentOption = "Horizontally", -- or Circularly
LabelsFontSize = 14.0,
LabelsFontSize = 24.0,
LabelsSize = 8.0,
LabelsMinSize = 1.0,
LabelsMaxSize = 1500.0,
ProximityEnabled = false,
LabelsFadeInEnabled = true,
FadeInStartingDistance = 500000.0,
FadeOutStartingDistance = 1000000.0,
LabelsFadeOutEnabled = true,
FadeInStartingDistance = 1500000.0,
FadeOutStartingDistance = 500000.0,
LabelsForceDomeRendering = true,
LabelsDistanceEPS = 1350000.0,
LabelsDistanceEPS = 200000.0,
LabelsColor = { 1.0, 1.0, 0.0 }
}
},

View File

@@ -30,13 +30,14 @@ local Titan = {
FileName = labelsPath .. "/titan.labels",
LabelAlignmentOption = "Horizontally", -- or Circularly
LabelsFontSize = 14.0,
LabelsSize = 8.0,
LabelsSize = 10.0,
LabelsMinSize = 1.0,
LabelsMaxSize = 1500.0,
ProximityEnabled = false,
LabelsFadeInEnabled = true,
FadeInStartingDistance = 500000.0,
FadeOutStartingDistance = 1000000.0,
LabelsFadeOutEnabled = true,
FadeInStartingDistance = 7500000.0,
FadeOutStartingDistance = 6000000.0,
LabelsForceDomeRendering = true,
LabelsDistanceEPS = 1350000.0,
LabelsColor = { 1.0, 1.0, 0.0 }

View File

@@ -30,15 +30,17 @@ local Venus = {
FileName = labelsPath .. "/venus.labels",
LabelAlignmentOption = "Horizontally", -- or Circularly
LabelsFontSize = 40.0,
LabelsSize = 12.0,
LabelsSize = 10.0,
LabelsMinSize = 1.0,
LabelsMaxSize = 1500.0,
ProximityEnabled = false,
LabelsFadeInEnabled = true,
FadeInStartingDistance = 500000.0,
FadeOutStartingDistance = 1000000.0,
LabelsFadeInEnabled = true,
LabelsFadeOutEnabled = true,
FadeInStartingDistance = 7000000.0,
FadeOutStartingDistance = 2000000.0,
LabelsForceDomeRendering = true,
LabelsDistanceEPS = 3500000.0,
LabelsDistanceEPS = 4000000.0,
LabelsColor = { 1.0, 1.0, 0.0 }
}
},

View File

@@ -0,0 +1,34 @@
local assetHelper = asset.require("util/asset_helper")
local transforms = asset.require("./transforms")
local textures = asset.require('scene/milkyway/habitable_zones/habitable_zone_textures').TexturesPath
local HabitableZone = {
Identifier = "SunHabitableZone",
Parent = transforms.SunECLIPJ2000.Identifier,
Renderable = {
Type = "RenderableHabitableZone",
Enabled = false,
Texture = textures .. "/hot_to_cold_faded.png",
EffectiveTemperature = 5780, -- Kelvin
Luminosity = 1, -- solar
Opacity = 0.1
},
GUI = {
Name = "Sun Habitable Zone",
Path = "/Solar System/Sun",
Description = "Habitable zone for the sun in our solar system."
}
}
assetHelper.registerSceneGraphNodesAndExport(asset, { HabitableZone })
asset.meta = {
Name = "Sun Habitable Zone",
Version = "1.0",
Description = [[ The habitable zone around our sun, computed using formula and
coefficients by Kopparapu et al. (2015) https://arxiv.org/abs/1404.5292]],
Author = "OpenSpace Team",
URL = "http://openspaceproject.com",
License = "MIT license",
Identifiers = {"SunHabitableZone"}
}

View File

@@ -39,7 +39,7 @@
"is_local": false,
"key": "I",
"name": "Setup scene for insight EDL",
"script": "openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.HeightLayers.Mola_Utah.Settings.Offset', -469.300000);openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.HeightLayers.OnMarsHiRISE-LS-DEM.Settings.Offset', -470.800006);openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.HeightLayers.OnMarsHiRISE-LS-DEM.Enabled', true);openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.ColorLayers.OnMarsHiRISE-LS.Enabled', true);openspace.time.setPause(true);openspace.time.setTime('2018 NOV 26 19:39:03.68');openspace.navigation.setNavigationState({Anchor = 'Insight',Pitch = 0.567457E-4,Position = { 1.240506E1,-1.369270E1,-2.423553E0 },ReferenceFrame = 'Root',Up = { 0.441211E0,0.247019E0,0.862737E0 },Yaw = -0.446853E-4});"
"script": "openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.HeightLayers.Mola_Utah.Settings.Offset', -469.300000);openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.HeightLayers.HiRISE-LS-DEM.Settings.Offset', -470.800006);openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.HeightLayers.HiRISE-LS-DEM.Enabled', true);openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.ColorLayers.HiRISE-LS.Enabled', true);openspace.time.setPause(true);openspace.time.setTime('2018 NOV 26 19:39:03.68');openspace.navigation.setNavigationState({Anchor = 'Insight',Pitch = 0.567457E-4,Position = { 1.240506E1,-1.369270E1,-2.423553E0 },ReferenceFrame = 'Root',Up = { 0.441211E0,0.247019E0,0.862737E0 },Yaw = -0.446853E-4});"
},
{
"documentation": "Disable Mars layer settings used for insight EDL",
@@ -47,7 +47,7 @@
"is_local": false,
"key": "SHIFT+I",
"name": "Unset Insight Landing",
"script": "openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.HeightLayers.Mola_Utah.Settings.Offset', 0);openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.HeightLayers.OnMarsHiRISE-LS-DEM.Settings.Offset', 0);openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.HeightLayers.OnMarsHiRISE-LS-DEM.Enabled', false);openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.ColorLayers.OnMarsHiRISE-LS.Enabled', false);"
"script": "openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.HeightLayers.Mola_Utah.Settings.Offset', 0);openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.HeightLayers.HiRISE-LS-DEM.Settings.Offset', 0);openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.HeightLayers.HiRISE-LS-DEM.Enabled', false);openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.ColorLayers.HiRISE-LS.Enabled', false);"
},
{
"documentation": "Sets time and layers for Perseverance landing",
@@ -55,7 +55,7 @@
"is_local": false,
"key": "P",
"name": "Setup and Goto Perseverance",
"script": "openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.HeightLayers.Mola_Utah.Settings.Offset', -1677.088867);openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.HeightLayers.OnMarsHiRISE-LS-DEM.Settings.Offset', -1677.088867);openspace.time.setPause(true);openspace.time.setTime('2021 FEB 18 20:32:16');openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.HeightLayers.OnMarsHiRISE-LS-DEM.Enabled', true);openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.ColorLayers.OnMarsHiRISE-LS.Enabled', true);openspace.navigation.setNavigationState({Anchor = 'Perseverance',Pitch = 0.567457E-4,Position = { 1.240506E1,-1.369270E1,-2.423553E0 },ReferenceFrame = 'Root',Up = { 0.441211E0,0.247019E0,0.862737E0 },Yaw = -0.446853E-4});"
"script": "openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.HeightLayers.Mola_Utah.Settings.Offset', -1677.088867);openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.HeightLayers.HiRISE-LS-DEM.Settings.Offset', -1677.088867);openspace.time.setPause(true);openspace.time.setTime('2021 FEB 18 20:32:16');openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.HeightLayers.HiRISE-LS-DEM.Enabled', true);openspace.setPropertyValueSingle('Scene.Mars.Renderable.Layers.ColorLayers.HiRISE-LS.Enabled', true);openspace.navigation.setNavigationState({Anchor = 'Perseverance',Pitch = 0.567457E-4,Position = { 1.240506E1,-1.369270E1,-2.423553E0 },ReferenceFrame = 'Root',Up = { 0.441211E0,0.247019E0,0.862737E0 },Yaw = -0.446853E-4});"
}
],
"mark_nodes": [
@@ -77,6 +77,6 @@
},
"version": {
"major": 1,
"minor": 0
"minor": 1
}
}

View File

@@ -323,4 +323,11 @@ std::string to_string(const openspace::documentation::TestResult::Warning::Reaso
} // namespace ghoul
// The verifier header depends on the classes defined in here, but we want to make it
// easier for consumers of this header to just have access to all verifiers without
// needing to include this file separately. Particularly with the use of the codegen, it
// might lead to some unexcepted error messages about recognized identifiers in the
// generated code which look scary
#include <openspace/documentation/verifier.h>
#endif // __OPENSPACE_CORE___DOCUMENTATION___H__

View File

@@ -29,6 +29,18 @@
namespace openspace::documentation {
template <>
TestResult TemplateVerifier<glm::ivec2>::operator()(const ghoul::Dictionary& dict,
const std::string& key) const;
template <>
TestResult TemplateVerifier<glm::ivec3>::operator()(const ghoul::Dictionary& dict,
const std::string& key) const;
template <>
TestResult TemplateVerifier<glm::ivec4>::operator()(const ghoul::Dictionary& dict,
const std::string& key) const;
template <typename T>
TestResult TemplateVerifier<T>::operator()(const ghoul::Dictionary& dict,
const std::string& key) const
@@ -122,7 +134,22 @@ TestResult OperatorVerifier<T, Operator>::operator()(const ghoul::Dictionary& di
{
TestResult res = T::operator()(dict, key);
if (res.success) {
if (Operator()(dict.value<typename T::Type>(key), value)) {
typename T::Type val;
if constexpr (std::is_same_v<typename T::Type, int>) {
const double d = dict.value<double>(key);
double intPart;
bool isInt = modf(d, &intPart) == 0.0;
if (isInt) {
val = static_cast<int>(d);
}
else {
return { false, { { key, TestResult::Offense::Reason::WrongType } }, {} };
}
}
else {
val = dict.value<typename T::Type>(key);
}
if (Operator()(val, value)) {
return { true, {}, {} };
}
else {
@@ -270,7 +297,21 @@ TestResult InRangeVerifier<T>::operator()(const ghoul::Dictionary& dict,
{
TestResult res = T::operator()(dict, key);
if (res.success) {
typename T::Type val = dict.value<typename T::Type>(key);
typename T::Type val;
if constexpr (std::is_same_v<typename T::Type, int>) {
const double d = dict.value<double>(key);
double intPart;
bool isInt = modf(d, &intPart) == 0.0;
if (isInt) {
val = static_cast<int>(d);
}
else {
return { false, { { key, TestResult::Offense::Reason::WrongType } }, {} };
}
}
else {
val = dict.value<typename T::Type>(key);
}
if (val >= lower && val <= upper) {
return { true, {}, {} };
@@ -303,7 +344,21 @@ TestResult NotInRangeVerifier<T>::operator()(const ghoul::Dictionary& dict,
const std::string& key) const {
TestResult res = T::operator()(dict, key);
if (res.success) {
typename T::Type val = dict.value<typename T::Type>(key);
typename T::Type val;
if constexpr (std::is_same_v<typename T::Type, int>) {
const double d = dict.value<double>(key);
double intPart;
bool isInt = modf(d, &intPart) == 0.0;
if (isInt) {
val = static_cast<int>(d);
}
else {
return { false, { { key, TestResult::Offense::Reason::WrongType } }, {} };
}
}
else {
val = dict.value<typename T::Type>(key);
}
if (val >= lower && val <= upper) {
return { false, { { key, TestResult::Offense::Reason::Verification } }, {} };

View File

@@ -139,4 +139,11 @@ private:
} // namespace openspace
// Lua functions - exposed for testing
namespace openspace::luascriptfunctions {
int createSingeColorImage(lua_State* L);
} // openspace::luascriptfunctions
#endif // __OPENSPACE_CORE___OPENSPACEENGINE___H__

View File

@@ -294,7 +294,6 @@ public:
// Generate JSON for documentation
std::string generateJson() const override;
protected:
/// The unique identifier of this PropertyOwner
std::string _identifier;

View File

@@ -61,7 +61,7 @@ public:
};
static ghoul::mm_unique_ptr<Renderable> createFromDictionary(
const ghoul::Dictionary& dictionary);
ghoul::Dictionary dictionary);
Renderable(const ghoul::Dictionary& dictionary);
virtual ~Renderable() = default;

View File

@@ -0,0 +1,72 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* 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___TEXTURECOMPONENT___H__
#define __OPENSPACE_CORE___TEXTURECOMPONENT___H__
#include <ghoul/opengl/texture.h>
namespace ghoul::filesystem { class File; }
namespace ghoul::opengl {class Texture; }
namespace openspace {
class TextureComponent {
public:
using Texture = ghoul::opengl::Texture;
const Texture* texture() const;
Texture* texture();
void setFilterMode(Texture::FilterMode filterMode);
void setWrapping(Texture::WrappingMode wrapping);
void setShouldWatchFileForChanges(bool value);
void setShouldPurgeFromRAM(bool value);
void bind();
void uploadToGpu();
// Loads a texture from a file on disk
void loadFromFile(const std::string& path);
// Function to call in a renderable's update function to make sure
// the texture is kept up to date
void update();
private:
std::unique_ptr<ghoul::filesystem::File> _textureFile;
std::unique_ptr<Texture> _texture;
Texture::FilterMode _filterMode = Texture::FilterMode::LinearMipMap;
Texture::WrappingMode _wrappingMode = Texture::WrappingMode::Repeat;
bool _shouldWatchFile = true;
bool _shouldPurgeFromRAM = true;
bool _fileIsDirty = false;
bool _textureIsDirty = false;
};
} // namespace openspace
#endif // __OPENSPACE_CORE___TEXTURECOMPONENT___H__

View File

@@ -0,0 +1,57 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* 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___PLANEGEOMETRY___H__
#define __OPENSPACE_CORE___PLANEGEOMETRY___H__
#include <ghoul/glm.h>
#include <ghoul/opengl/ghoul_gl.h>
namespace openspace {
class PlaneGeometry {
public:
PlaneGeometry(glm::vec2 size);
PlaneGeometry(float size);
~PlaneGeometry();
void initialize();
void deinitialize();
void render();
void updateSize(const glm::vec2& size);
void updateSize(const float size);
private:
void updateGeometry();
GLuint _vaoId = 0;
GLuint _vBufferId = 0;
glm::vec2 _size = glm::vec2(0.f);
};
} // namespace openspace
#endif // __OPENSPACE_CORE___PLANEGEOMETRY___H__

View File

@@ -288,6 +288,8 @@ foreach (val RANGE ${enabled_module_count})
list(APPEND all_enabled_modules "${library_name}")
begin_header("Module ${name} (${library_name})")
add_subdirectory(${path})
# Make sure that the code generator always runs before a module
add_dependencies(${library_name} run_codegen)
end_header("End: Module ${name}")
message(STATUS "")

View File

@@ -47,6 +47,7 @@
#include <glm/gtx/string_cast.hpp>
#include <fstream>
#include <memory>
#include <optional>
#ifdef WIN32
#define _USE_MATH_DEFINES
@@ -54,27 +55,6 @@
#include <math.h>
namespace {
static const char* _loggerCat = "RenderableAtmosphere";
constexpr const char* KeyShadowGroup = "ShadowGroup";
constexpr const char* KeyShadowSource = "Source";
constexpr const char* KeyShadowCaster = "Caster";
constexpr const char* KeyPlanetRadius = "PlanetRadius";
constexpr const char* KeyAverageGroundReflectance = "PlanetAverageGroundReflectance";
constexpr const char* KeyRayleigh = "Rayleigh";
constexpr const char* KeyRayleighHeightScale = "H_R";
constexpr const char* KeyOzone = "Ozone";
constexpr const char* KeyOzoneHeightScale = "H_O";
constexpr const char* KeyMie = "Mie";
constexpr const char* KeyMieHeightScale = "H_M";
constexpr const char* KeyMiePhaseConstant = "G";
constexpr const char* KeyImage = "Image";
constexpr const char* KeyToneMappingOp = "ToneMapping";
constexpr const char* KeyATMDebug = "Debug";
constexpr const char* KeyTextureScale = "PreCalculatedTextureScale";
constexpr const char* KeySaveTextures = "SaveCalculatedTextures";
constexpr openspace::properties::Property::PropertyInfo AtmosphereHeightInfo = {
"AtmosphereHeight",
"Atmosphere Height (KM)",
@@ -174,238 +154,97 @@ namespace {
"Enable Hard Shadows for Eclipses",
"Enable/Disables hard shadows through the atmosphere"
};
struct [[codegen::Dictionary(RenderableAtmosphere)]] Parameters {
struct ShadowGroup {
// Individual light sources
struct SourceElement {
// The scene graph node name of the source
std::string name;
// The radius of the object in meters
double radius;
};
// A list of light sources
std::vector<SourceElement> sources;
// Individual shadow casters
struct CasterElement {
// The scene graph node name of the source
std::string name;
// The radius of the object in meters
double radius;
};
// A list of objects that cast light on this atmosphere
std::vector<CasterElement> casters;
};
// Declares shadow groups, meaning which nodes are considered in shadow calculations
std::optional<ShadowGroup> shadowGroup;
// [[codegen::verbatim(AtmosphereHeightInfo.description)]]
float atmosphereHeight;
// The radius of the planet in meters
float planetRadius;
float planetAverageGroundReflectance;
// [[codegen::verbatim(SunIntensityInfo.description)]]
std::optional<float> sunIntensity;
// [[codegen::verbatim(MieScatteringExtinctionPropCoeffInfo.description)]]
std::optional<float> mieScatteringExtinctionPropCoefficient;
// [[codegen::verbatim(GroundRadianceEmittioninfo.description)]]
float groundRadianceEmission;
struct Rayleigh {
struct Coefficients {
glm::dvec3 wavelengths;
glm::dvec3 scattering;
};
Coefficients coefficients;
float heightScale [[codegen::key("H_R")]];
};
Rayleigh rayleigh;
struct Ozone {
struct Coefficients {
std::optional<glm::vec3> extinction;
};
std::optional<Coefficients> coefficients;
std::optional<float> heightScale [[codegen::key("H_O")]];
};
std::optional<Ozone> ozone;
struct Mie {
struct Coefficients {
glm::dvec3 scattering;
glm::dvec3 extinction;
};
Coefficients coefficients;
float heightScale [[codegen::key("H_M")]];
float phaseConstant [[codegen::key("G"), codegen::inrange(-1.0, 1.0)]];
};
Mie mie;
struct ATMDebug {
std::optional<float> preCalculatedTextureScale [[codegen::inrange(0.0, 1.0)]];
std::optional<bool> saveCalculatedTextures;
};
std::optional<ATMDebug> debug;
};
#include "renderableatmosphere_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation RenderableAtmosphere::Documentation() {
using namespace documentation;
TableVerifier* shadowGroupTable = new TableVerifier({
{
"Sources",
new TableVerifier({
{
"*",
new TableVerifier({
{
"Name",
new StringVerifier,
Optional::No,
"The scene graph node name of the source"
},
{
"Radius",
new DoubleVerifier,
Optional::No,
"The radius of the object in meters"
}
}),
Optional::Yes,
"Individual light sources"
}
}),
Optional::No,
"A list of light sources"
},
{
"Casters",
new TableVerifier({
{
"*",
new TableVerifier({
{
"Name",
new StringVerifier,
Optional::No,
"The scene graph node name of the caster"
},
{
"Radius",
new DoubleVerifier,
Optional::No,
"The radius of the object in meters"
}
}),
Optional::Yes,
"Individual shadow casters"
}
}),
Optional::No,
"A list of objects that cast light on this atmosphere"
}
});
TableVerifier* rayleighTable = new TableVerifier({
{
"Coefficients",
new TableVerifier({
{
"Wavelengths",
new DoubleVector3Verifier,
Optional::Yes,
""
},
{
"Scattering",
new DoubleVector3Verifier,
Optional::No,
""
}
}),
Optional::No,
""
},
{
KeyRayleighHeightScale,
new DoubleVerifier,
Optional::No,
""
},
});
TableVerifier* ozoneTable = new TableVerifier({
{
KeyOzoneHeightScale,
new DoubleVerifier,
Optional::Yes,
""
},
{
"Coefficients",
new TableVerifier({
{
"Extinction",
new DoubleVector4Verifier,
Optional::Yes,
""
}
}),
Optional::Yes,
""
}
});
TableVerifier* mieTable = new TableVerifier({
{
KeyMieHeightScale,
new DoubleVerifier,
Optional::No,
""
},
{
"Coefficients",
new TableVerifier({
{
"Scattering",
new DoubleVector3Verifier,
Optional::No,
""
},
{
"Extinction",
new DoubleVector3Verifier,
Optional::No,
""
}
}),
Optional::No,
""
},
{
KeyMiePhaseConstant,
new DoubleInRangeVerifier(-1.0, 1.0),
Optional::No,
""
}
});
return {
"RenderableAtmosphere",
"atmosphere_renderable_atmosphere",
{
{
KeyShadowGroup,
shadowGroupTable,
Optional::Yes,
"Declares shadow groups, meaning which nodes are considered in shadow "
"calculations"
},
{
AtmosphereHeightInfo.identifier,
new DoubleVerifier,
Optional::No,
AtmosphereHeightInfo.description
},
{
KeyPlanetRadius,
new DoubleVerifier,
Optional::No,
"The radius of the planet in meters"
},
{
KeyAverageGroundReflectance,
new DoubleVerifier,
Optional::No,
""
},
{
SunIntensityInfo.identifier,
new DoubleVerifier,
Optional::Yes,
SunIntensityInfo.description
},
{
MieScatteringExtinctionPropCoeffInfo.identifier,
new DoubleVerifier,
Optional::Yes,
MieScatteringExtinctionPropCoeffInfo.description
},
{
GroundRadianceEmittioninfo.identifier,
new DoubleVerifier,
Optional::No,
GroundRadianceEmittioninfo.description
},
{
KeyRayleigh,
rayleighTable,
Optional::No,
""
},
{
KeyOzone,
ozoneTable,
Optional::Yes,
""
},
{
KeyMie,
mieTable,
Optional::No,
""
},
{
KeyATMDebug,
new TableVerifier({
{
KeyTextureScale,
new DoubleInRangeVerifier(0.0, 1.0),
Optional::Yes,
""
},
{
KeySaveTextures,
new BoolVerifier,
Optional::Yes,
""
}
}),
Optional::Yes,
""
}
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "atmosphere_renderable_atmosphere";
return doc;
}
RenderableAtmosphere::RenderableAtmosphere(const ghoul::Dictionary& dictionary)
@@ -438,139 +277,6 @@ RenderableAtmosphere::RenderableAtmosphere(const ghoul::Dictionary& dictionary)
, _sunFollowingCameraEnabled(EnableSunOnCameraPositionInfo, false)
, _hardShadowsEnabled(EclipseHardShadowsInfo, false)
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"RenderableAtmosphere"
);
//================================================================
//======== Reads Shadow (Eclipses) Entries in asset file =========
//================================================================
if (dictionary.hasKey(KeyShadowGroup)) {
ghoul::Dictionary shadowDictionary =
dictionary.value<ghoul::Dictionary>(KeyShadowGroup);
std::vector<std::pair<std::string, double>> sourceArray;
ghoul::Dictionary sources = shadowDictionary.value<ghoul::Dictionary>("Sources");
for (std::string_view k : sources.keys()) {
ghoul::Dictionary source = sources.value<ghoul::Dictionary>(k);
std::string name = source.value<std::string>("Name");
double radius = source.value<double>("Radius");
sourceArray.emplace_back(name, radius);
}
std::vector<std::pair<std::string, double>> casterArray;
ghoul::Dictionary casters = shadowDictionary.value<ghoul::Dictionary>("Casters");
for (std::string_view k : casters.keys()) {
ghoul::Dictionary caster = casters.value<ghoul::Dictionary>(k);
std::string name = caster.value<std::string>("Name");
double radius = caster.value<double>("Radius");
casterArray.emplace_back(name, radius);
}
_shadowEnabled = !sourceArray.empty() && !casterArray.empty();
for (const std::pair<std::string, double>& source : sourceArray) {
for (const std::pair<std::string, double>& caster : casterArray) {
ShadowConfiguration sc;
sc.source = source;
sc.caster = caster;
_shadowConfArray.push_back(sc);
}
}
}
//================================================================
//========== Reads Atmosphere Entries from asset file ============
//================================================================
_atmosphereHeight = static_cast<float>(
dictionary.value<double>(AtmosphereHeightInfo.identifier)
);
_planetRadius = static_cast<float>(dictionary.value<double>(KeyPlanetRadius));
_groundAverageReflectance = static_cast<float>(
dictionary.value<double>(KeyAverageGroundReflectance)
);
_groundRadianceEmission = static_cast<float>(
dictionary.value<double>(GroundRadianceEmittioninfo.identifier)
);
if (dictionary.hasKey(SunIntensityInfo.identifier)) {
_sunIntensity = static_cast<float>(
dictionary.value<double>(SunIntensityInfo.identifier)
);
}
if (dictionary.hasKey(MieScatteringExtinctionPropCoeffInfo.identifier)) {
_mieScattExtPropCoefProp = static_cast<float>(
dictionary.value<double>(MieScatteringExtinctionPropCoeffInfo.identifier)
);
}
{
ghoul::Dictionary rayleighDict = dictionary.value<ghoul::Dictionary>(KeyRayleigh);
ghoul::Dictionary coeffs = rayleighDict.value<ghoul::Dictionary>("Coefficients");
_rayleighScatteringCoeff = coeffs.value<glm::dvec3>("Scattering");
_rayleighHeightScale = static_cast<float>(
rayleighDict.value<double>(KeyRayleighHeightScale)
);
}
if (dictionary.hasValue<ghoul::Dictionary>(KeyOzone)) {
ghoul::Dictionary ozoneDict = dictionary.value<ghoul::Dictionary>(KeyOzone);
if (ozoneDict.hasValue<double>(KeyOzoneHeightScale)) {
_ozoneHeightScale = static_cast<float>(
ozoneDict.value<double>(KeyOzoneHeightScale)
);
_ozoneEnabled = true;
}
if (ozoneDict.hasValue<ghoul::Dictionary>("Coefficients")) {
ghoul::Dictionary coeff = ozoneDict.value<ghoul::Dictionary>("Coefficients");
if (coeff.hasValue<glm::dvec3>("Extinction")) {
_ozoneCoeff = coeff.value<glm::dvec3>("Extinction");
}
}
}
{
ghoul::Dictionary mieDict = dictionary.value<ghoul::Dictionary>(KeyMie);
_mieHeightScale = static_cast<float>(mieDict.value<double>(KeyMieHeightScale));
ghoul::Dictionary coeffs = mieDict.value<ghoul::Dictionary>("Coefficients");
_mieScatteringCoeff = coeffs.value<glm::dvec3>("Scattering");
_mieExtinctionCoeff = coeffs.value<glm::dvec3>("Extinction");
_miePhaseConstant = static_cast<float>(
mieDict.value<double>(KeyMiePhaseConstant)
);
}
if (dictionary.hasValue<ghoul::Dictionary>(KeyATMDebug)) {
ghoul::Dictionary debugDict = dictionary.value<ghoul::Dictionary>(KeyATMDebug);
if (debugDict.hasKey(KeyTextureScale)) {
_preCalculatedTexturesScale = static_cast<float>(
debugDict.value<double>(KeyTextureScale)
);
LDEBUG(fmt::format(
"Atmosphere Texture Scaled to {}", _preCalculatedTexturesScale
));
}
if (debugDict.hasKey(KeySaveTextures)) {
_saveCalculationsToTexture = debugDict.value<bool>(KeySaveTextures);
LDEBUG("Saving Precalculated Atmosphere Textures");
}
}
//========================================================
//============== Atmosphere Properties ===================
//========================================================
auto updateWithCalculation = [this]() {
_deferredCasterNeedsUpdate = true;
_deferredCasterNeedsCalculation = true;
@@ -579,48 +285,93 @@ RenderableAtmosphere::RenderableAtmosphere(const ghoul::Dictionary& dictionary)
_deferredCasterNeedsUpdate = true;
};
const Parameters p = codegen::bake<Parameters>(dictionary);
_shadowEnabled = p.shadowGroup.has_value();
if (_shadowEnabled) {
for (const Parameters::ShadowGroup::SourceElement& s : p.shadowGroup->sources) {
for (const Parameters::ShadowGroup::CasterElement& c :
p.shadowGroup->casters)
{
ShadowConfiguration sc;
sc.source = std::pair(s.name, s.radius);
sc.caster = std::pair(c.name, c.radius);
_shadowConfArray.push_back(sc);
}
}
}
_atmosphereHeight = p.atmosphereHeight;
_atmosphereHeight.onChange(updateWithCalculation);
addProperty(_atmosphereHeight);
_planetRadius = p.planetRadius;
_groundAverageReflectance = p.planetAverageGroundReflectance;
_groundAverageReflectance.onChange(updateWithCalculation);
addProperty(_groundAverageReflectance);
_groundRadianceEmission.onChange(updateWithoutCalculation);
addProperty(_groundRadianceEmission);
_sunIntensity = p.sunIntensity.value_or(_sunIntensity);
_sunIntensity.onChange(updateWithoutCalculation);
addProperty(_sunIntensity);
_rayleighHeightScale.onChange(updateWithCalculation);
addProperty(_rayleighHeightScale);
_mieScattExtPropCoefProp =
p.mieScatteringExtinctionPropCoefficient.value_or(_mieScattExtPropCoefProp);
_rayleighScatteringCoeff = p.rayleigh.coefficients.scattering;
_rayleighScatteringCoeff.onChange(updateWithCalculation);
addProperty(_rayleighScatteringCoeff);
_rayleighHeightScale = p.rayleigh.heightScale;
_rayleighHeightScale.onChange(updateWithCalculation);
addProperty(_rayleighHeightScale);
if (p.ozone.has_value()) {
_ozoneHeightScale = p.ozone->heightScale.value_or(_ozoneHeightScale);
_ozoneEnabled = p.ozone->heightScale.has_value();
if (p.ozone->coefficients.has_value()) {
_ozoneCoeff = p.ozone->coefficients->extinction.value_or(_ozoneCoeff);
}
}
_ozoneEnabled.onChange(updateWithCalculation);
addProperty(_ozoneEnabled);
_ozoneHeightScale.onChange(updateWithCalculation);
addProperty(_ozoneHeightScale);
_ozoneCoeff.onChange(updateWithCalculation);
addProperty(_ozoneCoeff);
_mieHeightScale = p.mie.heightScale;
_mieHeightScale.onChange(updateWithCalculation);
addProperty(_mieHeightScale);
_mieScatteringCoeff = p.mie.coefficients.scattering;
_mieScatteringCoeff.onChange(updateWithCalculation);
addProperty(_mieScatteringCoeff);
_mieExtinctionCoeff = p.mie.coefficients.extinction;
_miePhaseConstant = p.mie.phaseConstant;
_miePhaseConstant.onChange(updateWithCalculation);
addProperty(_miePhaseConstant);
_mieScatteringExtinctionPropCoefficient =
_mieScattExtPropCoefProp != 1.f ? _mieScattExtPropCoefProp :
_mieScatteringCoeff.value().x / _mieExtinctionCoeff.x;
_mieScatteringExtinctionPropCoefficient.onChange(updateWithCalculation);
addProperty(_mieScatteringExtinctionPropCoefficient);
if (p.debug.has_value()) {
_preCalculatedTexturesScale =
p.debug->preCalculatedTextureScale.value_or(_preCalculatedTexturesScale);
_miePhaseConstant.onChange(updateWithCalculation);
addProperty(_miePhaseConstant);
_saveCalculationsToTexture =
p.debug->saveCalculatedTextures.value_or(_saveCalculationsToTexture);
}
_sunIntensity.onChange(updateWithoutCalculation);
addProperty(_sunIntensity);
_groundRadianceEmission = p.groundRadianceEmission;
_groundRadianceEmission.onChange(updateWithoutCalculation);
addProperty(_groundRadianceEmission);
_sunFollowingCameraEnabled.onChange(updateWithoutCalculation);
addProperty(_sunFollowingCameraEnabled);

View File

@@ -45,6 +45,7 @@ set(HEADER_FILES
rendering/grids/renderableradialgrid.h
rendering/grids/renderablesphericalgrid.h
rendering/renderablecartesianaxes.h
rendering/renderabledisc.h
rendering/renderablelabels.h
rendering/renderablemodel.h
rendering/renderablenodeline.h
@@ -73,7 +74,6 @@ set(HEADER_FILES
translation/luatranslation.h
translation/statictranslation.h
translation/timelinetranslation.h
)
source_group("Header Files" FILES ${HEADER_FILES})
@@ -98,6 +98,7 @@ set(SOURCE_FILES
rendering/grids/renderableradialgrid.cpp
rendering/grids/renderablesphericalgrid.cpp
rendering/renderablecartesianaxes.cpp
rendering/renderabledisc.cpp
rendering/renderablelabels.cpp
rendering/renderablemodel.cpp
rendering/renderablenodeline.cpp
@@ -132,6 +133,8 @@ source_group("Source Files" FILES ${SOURCE_FILES})
set(SHADER_FILES
shaders/axes_fs.glsl
shaders/axes_vs.glsl
shaders/disc_fs.glsl
shaders/disc_vs.glsl
shaders/grid_vs.glsl
shaders/grid_fs.glsl
shaders/imageplane_fs.glsl

View File

@@ -42,6 +42,7 @@
#include <modules/base/rendering/grids/renderableradialgrid.h>
#include <modules/base/rendering/grids/renderablesphericalgrid.h>
#include <modules/base/rendering/renderablecartesianaxes.h>
#include <modules/base/rendering/renderabledisc.h>
#include <modules/base/rendering/renderablelabels.h>
#include <modules/base/rendering/renderablemodel.h>
#include <modules/base/rendering/renderablenodeline.h>
@@ -129,6 +130,7 @@ void BaseModule::internalInitialize(const ghoul::Dictionary&) {
fRenderable->registerClass<RenderableBoxGrid>("RenderableBoxGrid");
fRenderable->registerClass<RenderableCartesianAxes>("RenderableCartesianAxes");
fRenderable->registerClass<RenderableDisc>("RenderableDisc");
fRenderable->registerClass<RenderableGrid>("RenderableGrid");
fRenderable->registerClass<RenderableLabels>("RenderableLabels");
fRenderable->registerClass<RenderableModel>("RenderableModel");
@@ -206,6 +208,7 @@ std::vector<documentation::Documentation> BaseModule::documentations() const {
RenderableNodeLine::Documentation(),
RenderablePlane::Documentation(),
RenderableRadialGrid::Documentation(),
RenderableDisc::Documentation(),
RenderableSphere::Documentation(),
RenderableSphericalGrid::Documentation(),
RenderableTrailOrbit::Documentation(),

View File

@@ -85,66 +85,36 @@ namespace {
"If a scene graph node is selected as type, this value specifies the name of the "
"node that is to be used as the destination for computing the angle."
};
struct [[codegen::Dictionary(DashboardItemAngle)]] Parameters {
enum class Type {
Node,
Focus,
Camera
};
// [[codegen::verbatim(SourceTypeInfo.description)]]
std::optional<Type> sourceType;
// [[codegen::verbatim(SourceNodeNameInfo.description)]]
std::optional<std::string> sourceNodeName;
// [[codegen::verbatim(ReferenceTypeInfo.description)]]
Type referenceType;
// [[codegen::verbatim(ReferenceNodeNameInfo.description)]]
std::optional<std::string> referenceNodeName;
// [[codegen::verbatim(DestinationTypeInfo.description)]]
std::optional<Type> destinationType;
// [[codegen::verbatim(DestinationNodeNameInfo.description)]]
std::optional<std::string> destinationNodeName;
};
#include "dashboarditemangle_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation DashboardItemAngle::Documentation() {
using namespace documentation;
return {
"DashboardItem Angle",
"base_dashboarditem_angle",
{
{
"Type",
new StringEqualVerifier("DashboardItemAngle"),
Optional::No
},
{
SourceTypeInfo.identifier,
new StringInListVerifier({
"Node", "Focus", "Camera"
}),
Optional::Yes,
SourceTypeInfo.description
},
{
SourceNodeNameInfo.identifier,
new StringVerifier,
Optional::Yes,
SourceNodeNameInfo.description
},
{
ReferenceTypeInfo.identifier,
new StringInListVerifier({
"Node", "Focus", "Camera"
}),
Optional::No,
ReferenceTypeInfo.description
},
{
ReferenceNodeNameInfo.identifier,
new StringVerifier,
Optional::Yes,
ReferenceNodeNameInfo.description
},
{
DestinationTypeInfo.identifier,
new StringInListVerifier({
"Node", "Focus", "Camera"
}),
Optional::Yes,
DestinationTypeInfo.description
},
{
DestinationNodeNameInfo.identifier,
new StringVerifier,
Optional::Yes,
DestinationNodeNameInfo.description
}
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_dashboarditem_angle";
return doc;
}
DashboardItemAngle::DashboardItemAngle(const ghoul::Dictionary& dictionary)
@@ -174,11 +144,7 @@ DashboardItemAngle::DashboardItemAngle(const ghoul::Dictionary& dictionary)
nullptr
}
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"DashboardItemAngle"
);
const Parameters p = codegen::bake<Parameters>(dictionary);
_source.type.addOptions({
{ Type::Node, "Node" },
@@ -190,16 +156,17 @@ DashboardItemAngle::DashboardItemAngle(const ghoul::Dictionary& dictionary)
properties::Property::Visibility(_source.type == Type::Node)
);
});
if (dictionary.hasKey(SourceTypeInfo.identifier)) {
std::string value = dictionary.value<std::string>(SourceTypeInfo.identifier);
if (value == "Node") {
_source.type = Type::Node;
}
else if (value == "Focus") {
_source.type = Type::Focus;
}
else {
_source.type = Type::Camera;
if (p.sourceType.has_value()) {
switch (*p.sourceType) {
case Parameters::Type::Node:
_source.type = Type::Node;
break;
case Parameters::Type::Focus:
_source.type = Type::Focus;
break;
default:
_source.type = Type::Camera;
break;
}
}
else {
@@ -209,10 +176,8 @@ DashboardItemAngle::DashboardItemAngle(const ghoul::Dictionary& dictionary)
_source.nodeName.onChange([this]() { _source.node = nullptr; });
if (_source.type == Type::Node) {
if (dictionary.hasKey(SourceNodeNameInfo.identifier)) {
_source.nodeName = dictionary.value<std::string>(
SourceNodeNameInfo.identifier
);
if (p.sourceNodeName.has_value()) {
_source.nodeName = *p.sourceNodeName;
}
else {
LERRORC(
@@ -234,24 +199,23 @@ DashboardItemAngle::DashboardItemAngle(const ghoul::Dictionary& dictionary)
properties::Property::Visibility(_reference.type == Type::Node)
);
});
std::string value = dictionary.value<std::string>(ReferenceTypeInfo.identifier);
if (value == "Node") {
_reference.type = Type::Node;
}
else if (value == "Focus") {
_reference.type = Type::Focus;
}
else {
_reference.type = Type::Camera;
switch (p.referenceType) {
case Parameters::Type::Node:
_reference.type = Type::Node;
break;
case Parameters::Type::Focus:
_reference.type = Type::Focus;
break;
default:
_reference.type = Type::Camera;
break;
}
addProperty(_reference.type);
_reference.nodeName.onChange([this]() { _reference.node = nullptr; });
if (_reference.type == Type::Node) {
if (dictionary.hasKey(ReferenceNodeNameInfo.identifier)) {
_reference.nodeName = dictionary.value<std::string>(
ReferenceNodeNameInfo.identifier
);
if (p.referenceNodeName.has_value()) {
_reference.nodeName = *p.referenceNodeName;
}
else {
LERRORC(
@@ -272,16 +236,17 @@ DashboardItemAngle::DashboardItemAngle(const ghoul::Dictionary& dictionary)
properties::Property::Visibility(_source.type == Type::Node)
);
});
if (dictionary.hasKey(DestinationTypeInfo.identifier)) {
std::string type = dictionary.value<std::string>(DestinationTypeInfo.identifier);
if (type == "Node") {
_destination.type = Type::Node;
}
else if (type == "Focus") {
_destination.type = Type::Focus;
}
else {
_destination.type = Type::Camera;
if (p.destinationType.has_value()) {
switch (*p.destinationType) {
case Parameters::Type::Node:
_destination.type = Type::Node;
break;
case Parameters::Type::Focus:
_destination.type = Type::Focus;
break;
default:
_destination.type = Type::Camera;
break;
}
}
else {
@@ -290,10 +255,8 @@ DashboardItemAngle::DashboardItemAngle(const ghoul::Dictionary& dictionary)
addProperty(_destination.type);
_destination.nodeName.onChange([this]() { _destination.node = nullptr; });
if (_destination.type == Type::Node) {
if (dictionary.hasKey(DestinationNodeNameInfo.identifier)) {
_destination.nodeName = dictionary.value<std::string>(
DestinationNodeNameInfo.identifier
);
if (p.destinationNodeName.has_value()) {
_destination.nodeName = *p.destinationNodeName;
}
else {
LERRORC(

View File

@@ -51,35 +51,23 @@ namespace {
"https://naif.jpl.nasa.gov/pub/naif/toolkit_docs/C/cspice/timout_c.html for full "
"information about how to structure this format"
};
struct [[codegen::Dictionary(DashboardItemDate)]] Parameters {
// [[codegen::verbatim(FormatStringInfo.description)]]
std::optional<std::string> formatString;
// [[codegen::verbatim(TimeFormatInfo.description)]]
std::optional<std::string> timeFormat;
};
#include "dashboarditemdate_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation DashboardItemDate::Documentation() {
using namespace documentation;
return {
"DashboardItem Date",
"base_dashboarditem_date",
{
{
"Type",
new StringEqualVerifier("DashboardItemDate"),
Optional::No
},
{
FormatStringInfo.identifier,
new StringVerifier,
Optional::Yes,
FormatStringInfo.description
},
{
TimeFormatInfo.identifier,
new StringVerifier,
Optional::Yes,
TimeFormatInfo.description
}
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_dashboarditem_date";
return doc;
}
DashboardItemDate::DashboardItemDate(const ghoul::Dictionary& dictionary)
@@ -87,20 +75,12 @@ DashboardItemDate::DashboardItemDate(const ghoul::Dictionary& dictionary)
, _formatString(FormatStringInfo, "Date: {} UTC")
, _timeFormat(TimeFormatInfo, "YYYY MON DDTHR:MN:SC.### ::RND")
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"DashboardItemDate"
);
const Parameters p = codegen::bake<Parameters>(dictionary);
if (dictionary.hasKey(FormatStringInfo.identifier)) {
_formatString = dictionary.value<std::string>(FormatStringInfo.identifier);
}
_formatString = p.formatString.value_or(_formatString);
addProperty(_formatString);
if (dictionary.hasKey(TimeFormatInfo.identifier)) {
_timeFormat = dictionary.value<std::string>(TimeFormatInfo.identifier);
}
_timeFormat = p.timeFormat.value_or(_timeFormat);
addProperty(_timeFormat);
}

View File

@@ -104,69 +104,45 @@ namespace {
);
return res;
}
struct [[codegen::Dictionary(DashboardItemDistance)]] Parameters {
enum class TypeInfo {
Node,
NodeSurface [[codegen::key("Node Surface")]],
Focus,
Camera
};
// [[codegen::verbatim(SourceTypeInfo.description)]]
std::optional<TypeInfo> sourceType;
// [[codegen::verbatim(SourceNodeNameInfo.description)]]
std::optional<std::string> sourceNodeName;
// [[codegen::verbatim(DestinationTypeInfo.description)]]
std::optional<TypeInfo> destinationType;
// [[codegen::verbatim(DestinationNodeNameInfo.description)]]
std::optional<std::string> destinationNodeName;
// [[codegen::verbatim(SimplificationInfo.description)]]
std::optional<bool> simplification;
// [[codegen::verbatim(RequestedUnitInfo.description)]]
std::optional<std::string> requestedUnit [[codegen::inlist(unitList())]];
// [[codegen::verbatim(FormatStringInfo.description)]]
std::optional<std::string> formatString;
};
#include "dashboarditemdistance_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation DashboardItemDistance::Documentation() {
using namespace documentation;
return {
"DashboardItem Distance",
"base_dashboarditem_distance",
{
{
"Type",
new StringEqualVerifier("DashboardItemDistance"),
Optional::No
},
{
SourceTypeInfo.identifier,
new StringInListVerifier({
"Node", "Node Surface", "Focus", "Camera"
}),
Optional::Yes,
SourceTypeInfo.description
},
{
SourceNodeNameInfo.identifier,
new StringVerifier,
Optional::Yes,
SourceNodeNameInfo.description
},
{
DestinationTypeInfo.identifier,
new StringInListVerifier({
"Node", "Node Surface", "Focus", "Camera"
}),
Optional::Yes,
DestinationTypeInfo.description
},
{
DestinationNodeNameInfo.identifier,
new StringVerifier,
Optional::Yes,
DestinationNodeNameInfo.description
},
{
SimplificationInfo.identifier,
new BoolVerifier,
Optional::Yes,
SimplificationInfo.description
},
{
RequestedUnitInfo.identifier,
new StringInListVerifier(unitList()),
Optional::Yes,
RequestedUnitInfo.description
},
{
FormatStringInfo.identifier,
new StringVerifier,
Optional::Yes,
FormatStringInfo.description
}
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_dashboarditem_distance";
return doc;
}
DashboardItemDistance::DashboardItemDistance(const ghoul::Dictionary& dictionary)
@@ -191,11 +167,7 @@ DashboardItemDistance::DashboardItemDistance(const ghoul::Dictionary& dictionary
nullptr
}
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"DashboardItemDistance"
);
const Parameters p = codegen::bake<Parameters>(dictionary);
_source.type.addOptions({
{ Type::Node, "Node" },
@@ -210,22 +182,20 @@ DashboardItemDistance::DashboardItemDistance(const ghoul::Dictionary& dictionary
)
);
});
if (dictionary.hasKey(SourceTypeInfo.identifier)) {
const std::string& value = dictionary.value<std::string>(
SourceTypeInfo.identifier
);
if (value == "Node") {
_source.type = Type::Node;
}
else if (value == "Node Surface") {
_source.type = Type::NodeSurface;
}
else if (value == "Focus") {
_source.type = Type::Focus;
}
else {
_source.type = Type::Camera;
if (p.sourceType.has_value()) {
switch (*p.sourceType) {
case Parameters::TypeInfo::Node:
_source.type = Type::Node;
break;
case Parameters::TypeInfo::NodeSurface:
_source.type = Type::NodeSurface;
break;
case Parameters::TypeInfo::Focus:
_source.type = Type::Focus;
break;
case Parameters::TypeInfo::Camera:
_source.type = Type::Camera;
break;
}
}
else {
@@ -235,10 +205,8 @@ DashboardItemDistance::DashboardItemDistance(const ghoul::Dictionary& dictionary
_source.nodeName.onChange([this]() { _source.node = nullptr; });
if (_source.type == Type::Node || _source.type == Type::NodeSurface) {
if (dictionary.hasKey(SourceNodeNameInfo.identifier)) {
_source.nodeName = dictionary.value<std::string>(
SourceNodeNameInfo.identifier
);
if (p.sourceNodeName.has_value()) {
_source.nodeName = *p.sourceNodeName;
}
else {
LERRORC(
@@ -262,21 +230,20 @@ DashboardItemDistance::DashboardItemDistance(const ghoul::Dictionary& dictionary
)
);
});
if (dictionary.hasKey(DestinationTypeInfo.identifier)) {
const std::string& value = dictionary.value<std::string>(
DestinationTypeInfo.identifier
);
if (value == "Node") {
_destination.type = Type::Node;
}
else if (value == "Node Surface") {
_destination.type = Type::NodeSurface;
}
else if (value == "Focus") {
_destination.type = Type::Focus;
}
else {
_destination.type = Type::Camera;
if (p.destinationType.has_value()) {
switch (*p.destinationType) {
case Parameters::TypeInfo::Node:
_destination.type = Type::Node;
break;
case Parameters::TypeInfo::NodeSurface:
_destination.type = Type::NodeSurface;
break;
case Parameters::TypeInfo::Focus:
_destination.type = Type::Focus;
break;
case Parameters::TypeInfo::Camera:
_destination.type = Type::Camera;
break;
}
}
else {
@@ -285,10 +252,8 @@ DashboardItemDistance::DashboardItemDistance(const ghoul::Dictionary& dictionary
addProperty(_destination.type);
_destination.nodeName.onChange([this]() { _destination.node = nullptr; });
if (_destination.type == Type::Node || _destination.type == Type::NodeSurface) {
if (dictionary.hasKey(DestinationNodeNameInfo.identifier)) {
_destination.nodeName = dictionary.value<std::string>(
DestinationNodeNameInfo.identifier
);
if (p.destinationNodeName.has_value()) {
_destination.nodeName = *p.destinationNodeName;
}
else {
LERRORC(
@@ -299,9 +264,7 @@ DashboardItemDistance::DashboardItemDistance(const ghoul::Dictionary& dictionary
}
addProperty(_destination.nodeName);
if (dictionary.hasKey(SimplificationInfo.identifier)) {
_doSimplification = dictionary.value<bool>(SimplificationInfo.identifier);
}
_doSimplification = p.simplification.value_or(_doSimplification);
_doSimplification.onChange([this]() {
_requestedUnit.setVisibility(
_doSimplification ?
@@ -315,19 +278,14 @@ DashboardItemDistance::DashboardItemDistance(const ghoul::Dictionary& dictionary
_requestedUnit.addOption(static_cast<int>(u), nameForDistanceUnit(u));
}
_requestedUnit = static_cast<int>(DistanceUnit::Meter);
if (dictionary.hasKey(RequestedUnitInfo.identifier)) {
const std::string& value = dictionary.value<std::string>(
RequestedUnitInfo.identifier
);
DistanceUnit unit = distanceUnitFromString(value.c_str());
if (p.requestedUnit.has_value()) {
DistanceUnit unit = distanceUnitFromString(p.requestedUnit->c_str());
_requestedUnit = static_cast<int>(unit);
}
_requestedUnit.setVisibility(properties::Property::Visibility::Hidden);
addProperty(_requestedUnit);
if (dictionary.hasKey(FormatStringInfo.identifier)) {
_formatString = dictionary.value<std::string>(FormatStringInfo.identifier);
}
_formatString = p.formatString.value_or(_formatString);
addProperty(_formatString);
_buffer.resize(256);

View File

@@ -32,6 +32,7 @@
#include <ghoul/font/fontmanager.h>
#include <ghoul/font/fontrenderer.h>
#include <ghoul/misc/profiling.h>
#include <optional>
namespace {
constexpr openspace::properties::Property::PropertyInfo FrametimeInfo = {
@@ -47,14 +48,6 @@ namespace {
"does not use any caching, this trigger does not do anything."
};
constexpr const char* ValueDtAvg = "Average Deltatime";
constexpr const char* ValueDtExtremes = "Deltatime extremes";
constexpr const char* ValueDtStandardDeviation = "Deltatime standard deviation";
constexpr const char* ValueDtCov = "Deltatime coefficient of variation";
constexpr const char* ValueFps = "Frames per second";
constexpr const char* ValueFpsAvg = "Average frames per second";
constexpr const char* ValueNone = "None";
[[ nodiscard ]] char* formatDt(std::vector<char>& buffer) {
return fmt::format_to(
buffer.data(),
@@ -133,32 +126,30 @@ namespace {
throw ghoul::MissingCaseException();
}
}
struct [[codegen::Dictionary(DashboardItemFramerate)]] Parameters {
enum class Type {
DtAvg [[codegen::key("Average Deltatime")]],
DtExtremes [[codegen::key("Deltatime extremes")]],
DtStandardDeviation [[codegen::key("Deltatime standard deviation")]],
DtCoefficientOfVariation [[codegen::key("Deltatime coefficient of variation")]],
FPS [[codegen::key("Frames per second")]],
FPSAvg [[codegen::key("Average frames per second")]]
};
// [[codegen::verbatim(FrametimeInfo.description)]]
std::optional<Type> frametimeType;
};
#include "dashboarditemframerate_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation DashboardItemFramerate::Documentation() {
using namespace documentation;
return {
"DashboardItem Framerate",
"base_dashboarditem_framerate",
{
{
"Type",
new StringEqualVerifier("DashboardItemFramerate"),
Optional::No
},
{
FrametimeInfo.identifier,
new StringInListVerifier({ ValueDtAvg, ValueDtExtremes,
ValueDtStandardDeviation, ValueDtCov, ValueFps, ValueFpsAvg, ValueNone
}),
Optional::Yes,
FrametimeInfo.description
}
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_dashboarditem_framerate";
return doc;
}
DashboardItemFramerate::DashboardItemFramerate(const ghoul::Dictionary& dictionary)
@@ -166,52 +157,44 @@ DashboardItemFramerate::DashboardItemFramerate(const ghoul::Dictionary& dictiona
, _frametimeType(FrametimeInfo, properties::OptionProperty::DisplayType::Dropdown)
, _clearCache(ClearCacheInfo)
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"DashboardItemFramerate"
);
const Parameters p = codegen::bake<Parameters>(dictionary);
_frametimeType.addOptions({
{ static_cast<int>(FrametimeType::DtTimeAvg), ValueDtAvg },
{ static_cast<int>(FrametimeType::DtTimeExtremes), ValueDtExtremes },
{ static_cast<int>(FrametimeType::DtTimeAvg), "Average Deltatime" },
{ static_cast<int>(FrametimeType::DtTimeExtremes), "Deltatime extremes" },
{
static_cast<int>(FrametimeType::DtStandardDeviation),
ValueDtStandardDeviation
"Deltatime standard deviation"
},
{
static_cast<int>(FrametimeType::DtCoefficientOfVariation),
ValueDtCov
"Deltatime coefficient of variation"
},
{ static_cast<int>(FrametimeType::FPS), ValueFps },
{ static_cast<int>(FrametimeType::FPSAvg), ValueFpsAvg },
{ static_cast<int>(FrametimeType::None), ValueNone }
{ static_cast<int>(FrametimeType::FPS), "Frames per second" },
{ static_cast<int>(FrametimeType::FPSAvg), "Average frames per second" },
{ static_cast<int>(FrametimeType::None), "None" }
});
if (dictionary.hasKey(FrametimeInfo.identifier)) {
const std::string& v = dictionary.value<std::string>(FrametimeInfo.identifier);
if (v == ValueDtAvg) {
_frametimeType = static_cast<int>(FrametimeType::DtTimeAvg);
}
else if (v == ValueDtExtremes) {
_frametimeType = static_cast<int>(FrametimeType::DtTimeExtremes);
}
else if (v == ValueDtStandardDeviation) {
_frametimeType =
static_cast<int>(FrametimeType::DtStandardDeviation);
}
else if (v == ValueDtCov) {
_frametimeType =
static_cast<int>(FrametimeType::DtCoefficientOfVariation);
}
else if (v == ValueFps) {
_frametimeType = static_cast<int>(FrametimeType::FPS);
}
else if (v == ValueFpsAvg) {
_frametimeType = static_cast<int>(FrametimeType::FPSAvg);
}
else {
_frametimeType = static_cast<int>(FrametimeType::None);
if (p.frametimeType.has_value()) {
switch (*p.frametimeType) {
case Parameters::Type::DtAvg:
_frametimeType = static_cast<int>(FrametimeType::DtTimeAvg);
break;
case Parameters::Type::DtExtremes:
_frametimeType = static_cast<int>(FrametimeType::DtTimeExtremes);
break;
case Parameters::Type::DtStandardDeviation:
_frametimeType = static_cast<int>(FrametimeType::DtStandardDeviation);
break;
case Parameters::Type::DtCoefficientOfVariation:
_frametimeType = static_cast<int>(FrametimeType::DtCoefficientOfVariation);
break;
case Parameters::Type::FPS:
_frametimeType = static_cast<int>(FrametimeType::FPS);
break;
case Parameters::Type::FPSAvg:
_frametimeType = static_cast<int>(FrametimeType::FPSAvg);
break;
}
}
else {

View File

@@ -51,7 +51,6 @@ namespace {
progress.append("|");
return progress;
}
} // namespace
namespace openspace {

View File

@@ -48,35 +48,23 @@ namespace {
"the value itself will be displayed), or it must contain extact one instance of "
"{}, which will be replaced with the value of the property during rendering."
};
struct [[codegen::Dictionary(DashboardItemPropertyValue)]] Parameters {
// [[codegen::verbatim(PropertyUriInfo.description)]]
std::optional<std::string> uri [[codegen::key("URI")]];
// [[codegen::verbatim(DisplayStringInfo.description)]]
std::optional<std::string> displayString;
};
#include "dashboarditempropertyvalue_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation DashboardItemPropertyValue::Documentation() {
using namespace documentation;
return {
"DashboardItem PropertyValue",
"base_dashboarditem_propertyvalue",
{
{
"Type",
new StringEqualVerifier("DashboardItemPropertyValue"),
Optional::No
},
{
PropertyUriInfo.identifier,
new StringVerifier,
Optional::Yes,
PropertyUriInfo.description
},
{
DisplayStringInfo.identifier,
new StringVerifier,
Optional::Yes,
DisplayStringInfo.description
}
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_dashboarditem_propertyvalue";
return doc;
}
DashboardItemPropertyValue::DashboardItemPropertyValue(
@@ -85,21 +73,13 @@ DashboardItemPropertyValue::DashboardItemPropertyValue(
, _propertyUri(PropertyUriInfo)
, _displayString(DisplayStringInfo)
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"DashboardItemPropertyValue"
);
const Parameters p = codegen::bake<Parameters>(dictionary);
if (dictionary.hasKey(PropertyUriInfo.identifier)) {
_propertyUri = dictionary.value<std::string>(PropertyUriInfo.identifier);
}
_propertyUri = p.uri.value_or(_propertyUri);
_propertyUri.onChange([this]() { _propertyIsDirty = true; });
addProperty(_propertyUri);
if (dictionary.hasKey(DisplayStringInfo.identifier)) {
_displayString = dictionary.value<std::string>(DisplayStringInfo.identifier);
}
_displayString = p.displayString.value_or(_displayString);
addProperty(_displayString);
}

View File

@@ -81,47 +81,29 @@ namespace {
);
return res;
}
struct [[codegen::Dictionary(DashboardItemSimulationIncrement)]] Parameters {
// [[codegen::verbatim(SimplificationInfo.description)]]
std::optional<bool> simplification;
// [[codegen::verbatim(RequestedUnitInfo.description)]]
std::optional<std::string> requestedUnit [[codegen::inlist(unitList())]];
// [[codegen::verbatim(TransitionFormatInfo.description)]]
std::optional<std::string> transitionFormat;
// [[codegen::verbatim(RegularFormatInfo.description)]]
std::optional<std::string> regularFormat;
};
#include "dashboarditemsimulationincrement_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation DashboardItemSimulationIncrement::Documentation() {
using namespace documentation;
return {
"DashboardItem Simulation Increment",
"base_dashboarditem_simulationincrement",
{
{
"Type",
new StringEqualVerifier("DashboardItemSimulationIncrement"),
Optional::No
},
{
SimplificationInfo.identifier,
new BoolVerifier,
Optional::Yes,
SimplificationInfo.description
},
{
RequestedUnitInfo.identifier,
new StringInListVerifier(unitList()),
Optional::Yes,
RequestedUnitInfo.description
},
{
TransitionFormatInfo.identifier,
new StringVerifier,
Optional::Yes,
TransitionFormatInfo.description
},
{
RegularFormatInfo.identifier,
new StringVerifier,
Optional::Yes,
RegularFormatInfo.description
}
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_dashboarditem_simulationincrement";
return doc;
}
DashboardItemSimulationIncrement::DashboardItemSimulationIncrement(
@@ -135,15 +117,9 @@ DashboardItemSimulationIncrement::DashboardItemSimulationIncrement(
)
, _regularFormat(RegularFormatInfo, "Simulation increment: {:.1f} {:s} / second{:s}")
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"DashboardItemSimulationIncrement"
);
const Parameters p = codegen::bake<Parameters>(dictionary);
if (dictionary.hasKey(SimplificationInfo.identifier)) {
_doSimplification = dictionary.value<bool>(SimplificationInfo.identifier);
}
_doSimplification = p.simplification.value_or(_doSimplification);
_doSimplification.onChange([this]() {
_requestedUnit.setVisibility(
_doSimplification ?
@@ -157,24 +133,17 @@ DashboardItemSimulationIncrement::DashboardItemSimulationIncrement(
_requestedUnit.addOption(static_cast<int>(u), nameForTimeUnit(u));
}
_requestedUnit = static_cast<int>(TimeUnit::Second);
if (dictionary.hasKey(RequestedUnitInfo.identifier)) {
std::string value = dictionary.value<std::string>(RequestedUnitInfo.identifier);
TimeUnit unit = timeUnitFromString(value.c_str());
if (p.requestedUnit.has_value()) {
TimeUnit unit = timeUnitFromString(p.requestedUnit->c_str());
_requestedUnit = static_cast<int>(unit);
}
_requestedUnit.setVisibility(properties::Property::Visibility::Hidden);
addProperty(_requestedUnit);
if (dictionary.hasKey(TransitionFormatInfo.identifier)) {
_transitionFormat = dictionary.value<std::string>(
TransitionFormatInfo.identifier
);
}
_transitionFormat = p.transitionFormat.value_or(_transitionFormat);
addProperty(_transitionFormat);
if (dictionary.hasKey(RegularFormatInfo.identifier)) {
_regularFormat = dictionary.value<std::string>(RegularFormatInfo.identifier);
}
_regularFormat = p.regularFormat.value_or(_regularFormat);
addProperty(_regularFormat);
}

View File

@@ -26,6 +26,7 @@
#include <openspace/documentation/documentation.h>
#include <openspace/documentation/verifier.h>
#include <optional>
namespace {
constexpr openspace::properties::Property::PropertyInfo SpacingInfo = {
@@ -34,44 +35,29 @@ namespace {
"This value determines the spacing (in pixels) that this item represents. The "
"default value is 15."
};
struct [[codegen::Dictionary(DashboardItemSpacing)]] Parameters {
// [[codegen::verbatim(SpacingInfo.description)]]
std::optional<float> spacing;
};
#include "dashboarditemspacing_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation DashboardItemSpacing::Documentation() {
using namespace documentation;
return {
"DashboardItem Spacing",
"base_dashboarditem_spacing",
{
{
"Type",
new StringEqualVerifier("DashboardItemSpacing"),
Optional::No
},
{
SpacingInfo.identifier,
new DoubleVerifier,
Optional::Yes,
SpacingInfo.description
}
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_dashboarditem_spacing";
return doc;
}
DashboardItemSpacing::DashboardItemSpacing(const ghoul::Dictionary& dictionary)
: DashboardItem(dictionary)
, _spacing(SpacingInfo, 15.f, 0.f, 2048.f)
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"DashboardItemSpacing"
);
const Parameters p = codegen::bake<Parameters>(dictionary);
if (dictionary.hasKey(SpacingInfo.identifier)) {
_spacing = static_cast<float>(dictionary.value<double>(SpacingInfo.identifier));
}
_spacing = p.spacing.value_or(_spacing);
addProperty(_spacing);
}

View File

@@ -31,6 +31,7 @@
#include <ghoul/font/fontmanager.h>
#include <ghoul/font/fontrenderer.h>
#include <ghoul/misc/profiling.h>
#include <optional>
namespace {
constexpr openspace::properties::Property::PropertyInfo TextInfo = {
@@ -38,44 +39,28 @@ namespace {
"Text",
"The text to be displayed"
};
struct [[codegen::Dictionary(DashboardItemText)]] Parameters {
// [[codegen::verbatim(TextInfo.description)]]
std::optional<std::string> text;
};
#include "dashboarditemtext_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation DashboardItemText::Documentation() {
using namespace documentation;
return {
"DashboardItem Text",
"base_dashboarditem_text",
{
{
"Type",
new StringEqualVerifier("DashboardItemText"),
Optional::No
},
{
TextInfo.identifier,
new StringVerifier,
Optional::Yes,
TextInfo.description
}
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_dashboarditem_text";
return doc;
}
DashboardItemText::DashboardItemText(const ghoul::Dictionary& dictionary)
: DashboardTextItem(dictionary)
, _text(TextInfo, "")
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"DashboardItemText"
);
if (dictionary.hasKey(TextInfo.identifier)) {
_text = dictionary.value<std::string>(TextInfo.identifier);
};
const Parameters p = codegen::bake<Parameters>(dictionary);
_text = p.text.value_or(_text);
addProperty(_text);
}

View File

@@ -68,35 +68,24 @@ namespace {
);
return res;
}
struct [[codegen::Dictionary(DashboardItemVelocity)]] Parameters {
// [[codegen::verbatim(SimplificationInfo.description)]]
std::optional<bool> simplification;
// [[codegen::verbatim(RequestedUnitInfo.description)]]
std::optional<std::string> requestedUnit [[codegen::inlist(unitList())]];
};
#include "dashboarditemvelocity_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation DashboardItemVelocity::Documentation() {
using namespace documentation;
return {
"DashboardItem Velocity",
"base_dashboarditem_velocity",
{
{
"Type",
new StringEqualVerifier("DashboardItemVelocity"),
Optional::No
},
{
SimplificationInfo.identifier,
new BoolVerifier,
Optional::Yes,
SimplificationInfo.description
},
{
RequestedUnitInfo.identifier,
new StringInListVerifier(unitList()),
Optional::Yes,
RequestedUnitInfo.description
}
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_dashboarditem_velocity";
return doc;
}
DashboardItemVelocity::DashboardItemVelocity(const ghoul::Dictionary& dictionary)
@@ -104,15 +93,8 @@ DashboardItemVelocity::DashboardItemVelocity(const ghoul::Dictionary& dictionary
, _doSimplification(SimplificationInfo, true)
, _requestedUnit(RequestedUnitInfo, properties::OptionProperty::DisplayType::Dropdown)
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"DashboardItemVelocity"
);
if (dictionary.hasKey(SimplificationInfo.identifier)) {
_doSimplification = dictionary.value<bool>(SimplificationInfo.identifier);
}
const Parameters p = codegen::bake<Parameters>(dictionary);
_doSimplification = p.simplification.value_or(_doSimplification);
_doSimplification.onChange([this]() {
_requestedUnit.setVisibility(
_doSimplification ?
@@ -126,11 +108,8 @@ DashboardItemVelocity::DashboardItemVelocity(const ghoul::Dictionary& dictionary
_requestedUnit.addOption(static_cast<int>(u), nameForDistanceUnit(u));
}
_requestedUnit = static_cast<int>(DistanceUnit::Meter);
if (dictionary.hasKey(RequestedUnitInfo.identifier)) {
const std::string& value = dictionary.value<std::string>(
RequestedUnitInfo.identifier
);
DistanceUnit unit = distanceUnitFromString(value.c_str());
if (p.requestedUnit.has_value()) {
DistanceUnit unit = distanceUnitFromString(p.requestedUnit->c_str());
_requestedUnit = static_cast<int>(unit);
}
_requestedUnit.setVisibility(properties::Property::Visibility::Hidden);
@@ -162,7 +141,7 @@ void DashboardItemVelocity::render(glm::vec2& penPosition) {
*_font,
penPosition,
fmt::format(
"Camera velocity: {} {}/s", dist.first, dist.second
"Camera velocity: {:.4f} {}/s", dist.first, dist.second
)
);
penPosition.y -= _font->height();

View File

@@ -27,6 +27,7 @@
#include <openspace/documentation/documentation.h>
#include <openspace/documentation/verifier.h>
#include <openspace/util/updatestructures.h>
#include <optional>
namespace {
constexpr openspace::properties::Property::PropertyInfo IntensityInfo = {
@@ -34,30 +35,20 @@ namespace {
"Intensity",
"The intensity of this light source"
};
struct [[codegen::Dictionary(CameraLightSource)]] Parameters {
// [[codegen::verbatim(IntensityInfo.description)]]
std::optional<float> intensity;
};
#include "cameralightsource_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation CameraLightSource::Documentation() {
using namespace openspace::documentation;
return {
"Camera Light Source",
"base_camera_light_source",
{
{
"Type",
new StringEqualVerifier("CameraLightSource"),
Optional::No,
"The type of this light source"
},
{
IntensityInfo.identifier,
new DoubleVerifier,
Optional::Yes,
IntensityInfo.description
}
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_camera_light_source";
return doc;
}
CameraLightSource::CameraLightSource()
@@ -70,18 +61,9 @@ CameraLightSource::CameraLightSource(const ghoul::Dictionary& dictionary)
: LightSource(dictionary)
, _intensity(IntensityInfo, 1.f, 0.f, 1.f)
{
const Parameters p = codegen::bake<Parameters>(dictionary);
_intensity = p.intensity.value_or(_intensity);
addProperty(_intensity);
documentation::testSpecificationAndThrow(Documentation(),
dictionary,
"CameraLightSource");
if (dictionary.hasValue<double>(IntensityInfo.identifier)) {
_intensity = static_cast<float>(
dictionary.value<double>(IntensityInfo.identifier)
);
}
}
float CameraLightSource::intensity() const {

View File

@@ -31,6 +31,7 @@
#include <openspace/scene/scene.h>
#include <openspace/util/updatestructures.h>
#include <ghoul/misc/profiling.h>
#include <optional>
namespace {
constexpr openspace::properties::Property::PropertyInfo IntensityInfo = {
@@ -44,36 +45,23 @@ namespace {
"Node",
"The identifier of the scene graph node to follow"
};
struct [[codegen::Dictionary(SceneGraphLightSource)]] Parameters {
// [[codegen::verbatim(IntensityInfo.description)]]
std::optional<float> intensity;
// [[codegen::verbatim(NodeInfo.description)]]
std::string node;
};
#include "scenegraphlightsource_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation SceneGraphLightSource::Documentation() {
using namespace openspace::documentation;
return {
"Scene Graph Light Source",
"base_scene_graph_light_source",
{
{
"Type",
new StringEqualVerifier("SceneGraphLightSource"),
Optional::No,
"The type of this light source"
},
{
IntensityInfo.identifier,
new DoubleVerifier,
Optional::Yes,
IntensityInfo.description
},
{
NodeInfo.identifier,
new StringVerifier,
Optional::No,
NodeInfo.description
},
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_scene_graph_light_source";
return doc;
}
SceneGraphLightSource::SceneGraphLightSource()
@@ -89,30 +77,17 @@ SceneGraphLightSource::SceneGraphLightSource(const ghoul::Dictionary& dictionary
, _intensity(IntensityInfo, 1.f, 0.f, 1.f)
, _sceneGraphNodeReference(NodeInfo, "")
{
const Parameters p = codegen::bake<Parameters>(dictionary);
_intensity = p.intensity.value_or(_intensity);
addProperty(_intensity);
addProperty(_sceneGraphNodeReference);
documentation::testSpecificationAndThrow(Documentation(),
dictionary,
"SceneGraphLightSource");
if (dictionary.hasValue<double>(IntensityInfo.identifier)) {
_intensity = static_cast<float>(
dictionary.value<double>(IntensityInfo.identifier)
);
}
if (dictionary.hasValue<std::string>(NodeInfo.identifier)) {
_sceneGraphNodeReference =
dictionary.value<std::string>(NodeInfo.identifier);
}
_sceneGraphNodeReference = p.node;
_sceneGraphNodeReference.onChange([this]() {
_sceneGraphNode =
global::renderEngine->scene()->sceneGraphNode(_sceneGraphNodeReference);
});
addProperty(_sceneGraphNodeReference);
}
bool SceneGraphLightSource::initialize() {

View File

@@ -55,36 +55,26 @@ namespace {
"Grid Size",
"This value species the size of each dimensions of the box"
};
struct [[codegen::Dictionary(RenderableBoxGrid)]] Parameters {
// [[codegen::verbatim(ColorInfo.description)]]
std::optional<glm::vec3> color;
// [[codegen::verbatim(LineWidthInfo.description)]]
std::optional<float> lineWidth;
// [[codegen::verbatim(SizeInfo.description)]]
std::optional<glm::vec3> size;
};
#include "renderableboxgrid_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation RenderableBoxGrid::Documentation() {
using namespace documentation;
return {
"RenderableBoxGrid",
"base_renderable_boxgrid",
{
{
ColorInfo.identifier,
new DoubleVector3Verifier,
Optional::Yes,
ColorInfo.description
},
{
LineWidthInfo.identifier,
new DoubleVerifier,
Optional::Yes,
LineWidthInfo.description
},
{
SizeInfo.identifier,
new DoubleVector3Verifier,
Optional::Yes,
SizeInfo.description
}
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_renderable_boxgrid";
return doc;
}
RenderableBoxGrid::RenderableBoxGrid(const ghoul::Dictionary& dictionary)
@@ -93,31 +83,19 @@ RenderableBoxGrid::RenderableBoxGrid(const ghoul::Dictionary& dictionary)
, _lineWidth(LineWidthInfo, 0.5f, 0.f, 20.f)
, _size(SizeInfo, glm::vec3(1.f), glm::vec3(1.f), glm::vec3(100.f))
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"RenderableBoxGrid"
);
const Parameters p = codegen::bake<Parameters>(dictionary);
addProperty(_opacity);
registerUpdateRenderBinFromOpacity();
if (dictionary.hasKey(ColorInfo.identifier)) {
_color = dictionary.value<glm::dvec3>(ColorInfo.identifier);
}
_color = p.color.value_or(_color);
_color.setViewOption(properties::Property::ViewOptions::Color);
addProperty(_color);
if (dictionary.hasKey(LineWidthInfo.identifier)) {
_lineWidth = static_cast<float>(
dictionary.value<double>(LineWidthInfo.identifier)
);
}
_lineWidth = p.lineWidth.value_or(_lineWidth);
addProperty(_lineWidth);
if (dictionary.hasKey(SizeInfo.identifier)) {
_size = dictionary.value<glm::dvec3>(SizeInfo.identifier);
}
_size = p.size.value_or(_size);
_size.onChange([&]() { _gridIsDirty = true; });
addProperty(_size);
}

View File

@@ -62,43 +62,29 @@ namespace {
"Grid Size",
"This value species the size of each dimensions of the grid"
};
struct [[codegen::Dictionary(RenderableGrid)]] Parameters {
// [[codegen::verbatim(ColorInfo.description)]]
std::optional<glm::vec3> color;
// [[codegen::verbatim(SegmentsInfo.description)]]
std::optional<glm::ivec2> segments;
// [[codegen::verbatim(LineWidthInfo.description)]]
std::optional<float> lineWidth;
// [[codegen::verbatim(SizeInfo.description)]]
std::optional<glm::vec2> size;
};
#include "renderablegrid_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation RenderableGrid::Documentation() {
using namespace documentation;
return {
"RenderableGrid",
"base_renderable_grid",
{
{
ColorInfo.identifier,
new DoubleVector3Verifier,
Optional::Yes,
ColorInfo.description
},
{
SegmentsInfo.identifier,
// @TODO (emmbr 2020-07-07): should be Int, but specification test fails..
new DoubleVector2Verifier,
Optional::Yes,
SegmentsInfo.description
},
{
LineWidthInfo.identifier,
new DoubleVerifier,
Optional::Yes,
LineWidthInfo.description
},
{
SizeInfo.identifier,
new DoubleVector2Verifier,
Optional::Yes,
SizeInfo.description
}
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_renderable_grid";
return doc;
}
RenderableGrid::RenderableGrid(const ghoul::Dictionary& dictionary)
@@ -108,39 +94,23 @@ RenderableGrid::RenderableGrid(const ghoul::Dictionary& dictionary)
, _lineWidth(LineWidthInfo, 0.5f, 0.f, 20.f)
, _size(SizeInfo, glm::vec2(1e20f), glm::vec2(1.f), glm::vec2(1e35f))
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"RenderableGrid"
);
const Parameters p = codegen::bake<Parameters>(dictionary);
addProperty(_opacity);
registerUpdateRenderBinFromOpacity();
if (dictionary.hasKey(ColorInfo.identifier)) {
_color = dictionary.value<glm::dvec3>(ColorInfo.identifier);
}
_color = p.color.value_or(_color);
_color.setViewOption(properties::Property::ViewOptions::Color);
addProperty(_color);
if (dictionary.hasKey(SegmentsInfo.identifier)) {
_segments = static_cast<glm::uvec2>(
dictionary.value<glm::dvec2>(SegmentsInfo.identifier)
);
}
_segments = p.segments.value_or(_segments);
_segments.onChange([&]() { _gridIsDirty = true; });
addProperty(_segments);
if (dictionary.hasKey(LineWidthInfo.identifier)) {
_lineWidth = static_cast<float>(
dictionary.value<double>(LineWidthInfo.identifier)
);
}
_lineWidth = p.lineWidth.value_or(_lineWidth);
addProperty(_lineWidth);
if (dictionary.hasKey(SizeInfo.identifier)) {
_size = dictionary.value<glm::dvec2>(SizeInfo.identifier);
}
_size = p.size.value_or(_size);
_size.onChange([&]() { _gridIsDirty = true; });
addProperty(_size);
}

View File

@@ -28,8 +28,8 @@
#include <openspace/rendering/renderable.h>
#include <openspace/properties/stringproperty.h>
#include <openspace/properties/vector/ivec2property.h>
#include <openspace/properties/scalar/floatproperty.h>
#include <openspace/properties/vector/uvec2property.h>
#include <openspace/properties/vector/vec2property.h>
#include <openspace/properties/vector/vec3property.h>
#include <ghoul/opengl/ghoul_gl.h>
@@ -61,7 +61,9 @@ protected:
ghoul::opengl::ProgramObject* _gridProgram = nullptr;
properties::Vec3Property _color;
properties::UVec2Property _segments;
// @TODO (abock, 2021-01-28) This was a UVec2Property before, but it wasn't supported
// be the codegen. As soon as it does, this should be changed back
properties::IVec2Property _segments;
properties::FloatProperty _lineWidth;
properties::Vec2Property _size;

View File

@@ -34,6 +34,7 @@
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/opengl/openglstatecache.h>
#include <ghoul/opengl/programobject.h>
#include <optional>
namespace {
constexpr const char* ProgramName = "GridProgram";
@@ -76,54 +77,35 @@ namespace {
"The inner radius of the circular grid, that is the radius of the inmost ring. "
"Must be smaller than the outer radius."
};
struct [[codegen::Dictionary(RenderableRadialGrid)]] Parameters {
// [[codegen::verbatim(ColorInfo.description)]]
std::optional<glm::vec3> color;
// [[codegen::verbatim(GridSegmentsInfo.description)]]
std::optional<glm::ivec2> gridSegments;
// [[codegen::verbatim(CircleSegmentsInfo.description)]]
std::optional<int> circleSegments;
// [[codegen::verbatim(LineWidthInfo.description)]]
std::optional<float> lineWidth;
// [[codegen::verbatim(OuterRadiusInfo.description)]]
std::optional<float> outerRadius;
// [[codegen::verbatim(InnerRadiusInfo.description)]]
std::optional<float> innerRadius;
};
#include "renderableradialgrid_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation RenderableRadialGrid::Documentation() {
using namespace documentation;
return {
"RenderableRadialGrid",
"base_renderable_radialgrid",
{
{
ColorInfo.identifier,
new DoubleVector3Verifier,
Optional::Yes,
ColorInfo.description
},
{
GridSegmentsInfo.identifier,
new DoubleVector2Verifier,
Optional::Yes,
GridSegmentsInfo.description
},
{
CircleSegmentsInfo.identifier,
new IntVerifier,
Optional::Yes,
CircleSegmentsInfo.description
},
{
LineWidthInfo.identifier,
new DoubleVerifier,
Optional::Yes,
LineWidthInfo.description
},
{
OuterRadiusInfo.identifier,
new DoubleVerifier,
Optional::Yes,
OuterRadiusInfo.description
},
{
InnerRadiusInfo.identifier,
new DoubleVerifier,
Optional::Yes,
InnerRadiusInfo.description
}
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_renderable_radialgrid";
return doc;
}
RenderableRadialGrid::RenderableRadialGrid(const ghoul::Dictionary& dictionary)
@@ -135,34 +117,20 @@ RenderableRadialGrid::RenderableRadialGrid(const ghoul::Dictionary& dictionary)
, _maxRadius(OuterRadiusInfo, 1.f, 0.f, 20.f)
, _minRadius(InnerRadiusInfo, 0.f, 0.f, 20.f)
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"RenderableRadialGrid"
);
const Parameters p = codegen::bake<Parameters>(dictionary);
addProperty(_opacity);
registerUpdateRenderBinFromOpacity();
if (dictionary.hasKey(ColorInfo.identifier)) {
_color = dictionary.value<glm::dvec3>(ColorInfo.identifier);
}
_color = p.color.value_or(_color);
_color.setViewOption(properties::Property::ViewOptions::Color);
addProperty(_color);
if (dictionary.hasKey(GridSegmentsInfo.identifier)) {
_gridSegments = static_cast<glm::ivec2>(
dictionary.value<glm::dvec2>(GridSegmentsInfo.identifier)
);
}
_gridSegments = p.gridSegments.value_or(_gridSegments);
_gridSegments.onChange([&]() { _gridIsDirty = true; });
addProperty(_gridSegments);
if (dictionary.hasKey(CircleSegmentsInfo.identifier)) {
_circleSegments = static_cast<int>(
dictionary.value<double>(CircleSegmentsInfo.identifier)
);
}
_circleSegments = p.circleSegments.value_or(_circleSegments);
_circleSegments.onChange([&]() {
if (_circleSegments.value() % 2 == 1) {
_circleSegments = _circleSegments - 1;
@@ -171,24 +139,11 @@ RenderableRadialGrid::RenderableRadialGrid(const ghoul::Dictionary& dictionary)
});
addProperty(_circleSegments);
if (dictionary.hasKey(LineWidthInfo.identifier)) {
_lineWidth = static_cast<float>(
dictionary.value<double>(LineWidthInfo.identifier)
);
}
_lineWidth = p.lineWidth.value_or(_lineWidth);
addProperty(_lineWidth);
if (dictionary.hasKey(OuterRadiusInfo.identifier)) {
_maxRadius = static_cast<float>(
dictionary.value<double>(OuterRadiusInfo.identifier)
);
}
if (dictionary.hasKey(InnerRadiusInfo.identifier)) {
_minRadius = static_cast<float>(
dictionary.value<double>(InnerRadiusInfo.identifier)
);
}
_minRadius = p.innerRadius.value_or(_minRadius);
_maxRadius = p.outerRadius.value_or(_maxRadius);
_maxRadius.setMinValue(_minRadius);
_minRadius.setMaxValue(_maxRadius);

View File

@@ -33,6 +33,7 @@
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/opengl/openglstatecache.h>
#include <ghoul/opengl/programobject.h>
#include <optional>
namespace {
constexpr const char* ProgramName = "GridProgram";
@@ -55,36 +56,26 @@ namespace {
"Line Width",
"This value specifies the line width of the spherical grid."
};
struct [[codegen::Dictionary(RenderableSphericalGrid)]] Parameters {
// [[codegen::verbatim(ColorInfo.description)]]
std::optional<glm::vec3> color;
// [[codegen::verbatim(SegmentsInfo.description)]]
std::optional<int> segments;
// [[codegen::verbatim(LineWidthInfo.description)]]
std::optional<float> lineWidth;
};
#include "renderablesphericalgrid_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation RenderableSphericalGrid::Documentation() {
using namespace documentation;
return {
"RenderableSphericalGrid",
"base_renderable_sphericalgrid",
{
{
ColorInfo.identifier,
new DoubleVector3Verifier,
Optional::Yes,
ColorInfo.description
},
{
SegmentsInfo.identifier,
new IntVerifier,
Optional::Yes,
SegmentsInfo.description
},
{
LineWidthInfo.identifier,
new DoubleVerifier,
Optional::Yes,
LineWidthInfo.description
}
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_renderable_sphericalgrid";
return doc;
}
RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictionary)
@@ -94,24 +85,16 @@ RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictio
, _segments(SegmentsInfo, 36, 4, 200)
, _lineWidth(LineWidthInfo, 0.5f, 0.f, 20.f)
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"RenderableSphericalGrid"
);
const Parameters p = codegen::bake<Parameters>(dictionary);
addProperty(_opacity);
registerUpdateRenderBinFromOpacity();
if (dictionary.hasKey(ColorInfo.identifier)) {
_color = dictionary.value<glm::dvec3>(ColorInfo.identifier);
}
_color = p.color.value_or(_color);
_color.setViewOption(properties::Property::ViewOptions::Color);
addProperty(_color);
if (dictionary.hasKey(SegmentsInfo.identifier)) {
_segments = static_cast<int>(dictionary.value<double>(SegmentsInfo.identifier));
}
_segments = p.segments.value_or(_segments);
_segments.onChange([&]() {
if (_segments.value() % 2 == 1) {
_segments = _segments - 1;
@@ -120,11 +103,7 @@ RenderableSphericalGrid::RenderableSphericalGrid(const ghoul::Dictionary& dictio
});
addProperty(_segments);
if (dictionary.hasKey(LineWidthInfo.identifier)) {
_lineWidth = static_cast<float>(
dictionary.value<double>(LineWidthInfo.identifier)
);
}
_lineWidth = p.lineWidth.value_or(_lineWidth);
addProperty(_lineWidth);
}

View File

@@ -34,6 +34,7 @@
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/opengl/openglstatecache.h>
#include <ghoul/opengl/programobject.h>
#include <optional>
namespace {
constexpr const char* ProgramName = "CartesianAxesProgram";
@@ -56,39 +57,29 @@ namespace {
"Z Color",
"This value determines the color of the z axis."
};
struct [[codegen::Dictionary(RenderableCartesianAxes)]] Parameters {
// [[codegen::verbatim(XColorInfo.description)]]
std::optional<glm::vec3> xColor;
// [[codegen::verbatim(YColorInfo.description)]]
std::optional<glm::vec3> yColor;
// [[codegen::verbatim(ZColorInfo.description)]]
std::optional<glm::vec3> zColor;
};
#include "renderablecartesianaxes_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation RenderableCartesianAxes::Documentation() {
using namespace documentation;
return {
"CartesianAxesProgram",
"base_renderable_cartesianaxes",
{
{
XColorInfo.identifier,
new DoubleVector3Verifier,
Optional::Yes,
XColorInfo.description
},
{
YColorInfo.identifier,
new DoubleVector3Verifier,
Optional::Yes,
YColorInfo.description
},
{
ZColorInfo.identifier,
new DoubleVector3Verifier,
Optional::Yes,
ZColorInfo.description
}
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_renderable_cartesianaxes";
return doc;
}
RenderableCartesianAxes::RenderableCartesianAxes(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _program(nullptr)
@@ -111,27 +102,16 @@ RenderableCartesianAxes::RenderableCartesianAxes(const ghoul::Dictionary& dictio
glm::vec3(1.f)
)
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"RenderableCartesianAxes"
);
if (dictionary.hasKey(XColorInfo.identifier)) {
_xColor = dictionary.value<glm::dvec3>(XColorInfo.identifier);
}
const Parameters p = codegen::bake<Parameters>(dictionary);
_xColor = p.xColor.value_or(_xColor);
_xColor.setViewOption(properties::Property::ViewOptions::Color);
addProperty(_xColor);
if (dictionary.hasKey(XColorInfo.identifier)) {
_yColor = dictionary.value<glm::dvec3>(YColorInfo.identifier);
}
_yColor = p.yColor.value_or(_yColor);
_yColor.setViewOption(properties::Property::ViewOptions::Color);
addProperty(_yColor);
if (dictionary.hasKey(ZColorInfo.identifier)) {
_zColor = dictionary.value<glm::dvec3>(ZColorInfo.identifier);
}
_zColor = p.zColor.value_or(_zColor);
_zColor.setViewOption(properties::Property::ViewOptions::Color);
addProperty(_zColor);
}

View File

@@ -0,0 +1,230 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* 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 <modules/base/rendering/renderabledisc.h>
#include <openspace/documentation/documentation.h>
#include <openspace/documentation/verifier.h>
#include <openspace/engine/globals.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/scene/scene.h>
#include <openspace/util/updatestructures.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/logging/logmanager.h>
#include <ghoul/opengl/openglstatecache.h>
#include <ghoul/opengl/programobject.h>
#include <ghoul/opengl/textureunit.h>
namespace {
constexpr const char _loggerCat[] = "RenderableDisc";
constexpr const std::array<const char*, 4> UniformNames = {
"modelViewProjectionTransform", "opacity", "width", "colorTexture"
};
constexpr openspace::properties::Property::PropertyInfo TextureInfo = {
"Texture",
"Texture",
"This value is the path to a texture on disk that contains a one-dimensional "
"texture to be used for the color."
};
constexpr openspace::properties::Property::PropertyInfo SizeInfo = {
"Size",
"Size",
"This value specifies the outer radius of the disc in meter."
};
constexpr openspace::properties::Property::PropertyInfo WidthInfo = {
"Width",
"Width",
"This value is used to set the width of the disc. The actual width is set "
"based on the given size and this value should be set between 0 and 1. A value "
"of 1 results in a full circle and 0.5 a disc with an inner radius of 0.5*size."
};
} // namespace
namespace openspace {
documentation::Documentation RenderableDisc::Documentation() {
using namespace documentation;
return {
"Renderable Disc",
"renderable_disc",
{
{
TextureInfo.identifier,
new StringVerifier,
Optional::No,
TextureInfo.description
},
{
SizeInfo.identifier,
new DoubleVerifier,
Optional::Yes,
SizeInfo.description
},
{
WidthInfo.identifier,
new DoubleVerifier,
Optional::Yes,
WidthInfo.description
}
}
};
}
RenderableDisc::RenderableDisc(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _texturePath(TextureInfo)
, _size(SizeInfo, 1.f, 0.f, 1e13f)
, _width(WidthInfo, 0.5f, 0.f, 1.f)
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"RenderableDisc"
);
_texturePath = absPath(dictionary.value<std::string>(TextureInfo.identifier));
_texturePath.onChange([&]() { _texture->loadFromFile(_texturePath); });
addProperty(_texturePath);
if (dictionary.hasKey(SizeInfo.identifier)) {
_size = static_cast<float>(dictionary.value<double>(SizeInfo.identifier));
}
setBoundingSphere(_size);
_size.onChange([&]() { _planeIsDirty = true; });
addProperty(_size);
if (dictionary.hasKey(WidthInfo.identifier)) {
_width = static_cast<float>(dictionary.value<double>(WidthInfo.identifier));
}
addProperty(_width);
addProperty(_opacity);
setRenderBin(Renderable::RenderBin::PostDeferredTransparent);
}
bool RenderableDisc::isReady() const {
return _shader && _texture && _plane;
}
void RenderableDisc::initialize() {
_texture = std::make_unique<TextureComponent>();
_texture->setFilterMode(ghoul::opengl::Texture::FilterMode::AnisotropicMipMap);
_texture->setWrapping(ghoul::opengl::Texture::WrappingMode::ClampToEdge);
_texture->setShouldWatchFileForChanges(true);
_plane = std::make_unique<PlaneGeometry>(planeSize());
}
void RenderableDisc::initializeGL() {
initializeShader();
_texture->loadFromFile(_texturePath);
_texture->uploadToGpu();
_plane->initialize();
}
void RenderableDisc::deinitializeGL() {
_plane->deinitialize();
_plane = nullptr;
_texture = nullptr;
global::renderEngine->removeRenderProgram(_shader.get());
_shader = nullptr;
}
void RenderableDisc::render(const RenderData& data, RendererTasks&) {
_shader->activate();
glm::dmat4 modelTransform =
glm::translate(glm::dmat4(1.0), data.modelTransform.translation) *
glm::dmat4(data.modelTransform.rotation) *
glm::scale(glm::dmat4(1.0), glm::dvec3(data.modelTransform.scale));
glm::dmat4 modelViewTransform = data.camera.combinedViewMatrix() * modelTransform;
_shader->setUniform(
_uniformCache.modelViewProjection,
data.camera.projectionMatrix() * glm::mat4(modelViewTransform)
);
_shader->setUniform(_uniformCache.width, _width);
_shader->setUniform(_uniformCache.opacity, _opacity);
ghoul::opengl::TextureUnit unit;
unit.activate();
_texture->bind();
_shader->setUniform(_uniformCache.texture, unit);
glEnablei(GL_BLEND, 0);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glDepthMask(false);
glDisable(GL_CULL_FACE);
_plane->render();
_shader->deactivate();
// Restores GL State
global::renderEngine->openglStateCache().resetBlendState();
global::renderEngine->openglStateCache().resetDepthState();
global::renderEngine->openglStateCache().resetPolygonAndClippingState();
}
void RenderableDisc::update(const UpdateData&) {
if (_shader->isDirty()) {
_shader->rebuildFromFile();
updateUniformLocations();
}
if (_planeIsDirty) {
_plane->updateSize(planeSize());
_planeIsDirty = false;
}
_texture->update();
}
void RenderableDisc::initializeShader() {
_shader = global::renderEngine->buildRenderProgram(
"DiscProgram",
absPath("${MODULE_BASE}/shaders/disc_vs.glsl"),
absPath("${MODULE_BASE}/shaders/disc_fs.glsl")
);
updateUniformLocations();
}
void RenderableDisc::updateUniformLocations() {
ghoul::opengl::updateUniformLocations(*_shader, _uniformCache, UniformNames);
}
float RenderableDisc::planeSize() const {
return _size;
}
} // namespace openspace

View File

@@ -0,0 +1,81 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_MODULE_BASE___RENDERABLEDISC___H__
#define __OPENSPACE_MODULE_BASE___RENDERABLEDISC___H__
#include <openspace/properties/stringproperty.h>
#include <openspace/properties/scalar/floatproperty.h>
#include <openspace/rendering/renderable.h>
#include <openspace/rendering/texturecomponent.h>
#include <openspace/util/planegeometry.h>
#include <ghoul/opengl/uniformcache.h>
#include <ghoul/opengl/ghoul_gl.h>
namespace ghoul::filesystem { class File; }
namespace ghoul::opengl { class ProgramObject; }
namespace openspace {
namespace documentation { struct Documentation; }
class RenderableDisc : public Renderable {
public:
RenderableDisc(const ghoul::Dictionary& dictionary);
void initialize() override;
void initializeGL() override;
void deinitializeGL() override;
bool isReady() const override;
void render(const RenderData& data, RendererTasks& rendererTask) override;
void update(const UpdateData& data) override;
static documentation::Documentation Documentation();
protected:
virtual void initializeShader();
virtual void updateUniformLocations();
virtual float planeSize() const;
properties::StringProperty _texturePath;
properties::FloatProperty _size;
properties::FloatProperty _width;
std::unique_ptr<ghoul::opengl::ProgramObject> _shader;
std::unique_ptr<PlaneGeometry> _plane;
std::unique_ptr<TextureComponent> _texture;
private:
UniformCache(modelViewProjection, opacity, width, texture) _uniformCache;
bool _planeIsDirty = false;
};
} // namespace openspace
#endif // __OPENSPACE_MODULE_BASE___RENDERABLEDISC___H__

View File

@@ -46,10 +46,9 @@
#include <ghoul/opengl/texture.h>
#include <ghoul/opengl/textureunit.h>
#include <glm/gtx/string_cast.hpp>
#include <optional>
namespace {
constexpr const char* _loggerCat = "base::RenderableLabels";
constexpr const char* MeterUnit = "m";
constexpr const char* KilometerUnit = "Km";
constexpr const char* MegameterUnit = "Mm";
@@ -176,122 +175,91 @@ namespace {
"Fade-In/-Out ending speed.",
"Fade-In/-Out ending speed."
};
struct [[codegen::Dictionary(RenderableLabels)]] Parameters {
enum class BlendMode {
Normal,
Additive
};
// [[codegen::verbatim(BlendModeInfo.description)]]
std::optional<BlendMode> blendMode;
enum class Orientation {
ViewDirection [[codegen::key("Camera View Direction")]],
PositionNormal [[codegen::key("Camera Position Normal")]]
};
// [[codegen::verbatim(LabelOrientationOptionInfo.description)]]
std::optional<Orientation> labelOrientationOption;
// [[codegen::verbatim(LabelColorInfo.description)]]
std::optional<glm::vec3> labelColor;
// [[codegen::verbatim(LabelTextInfo.description)]]
std::optional<std::string> labelText;
// [[codegen::verbatim(FontSizeInfo.description)]]
std::optional<float> fontSize;
// [[codegen::verbatim(LabelSizeInfo.description)]]
std::optional<float> labelSize;
// [[codegen::verbatim(LabelMinSizeInfo.description)]]
std::optional<float> labelMinSize;
// [[codegen::verbatim(LabelMaxSizeInfo.description)]]
std::optional<float> labelMaxSize;
// [[codegen::verbatim(EnableFadingEffectInfo.description)]]
std::optional<bool> enableFading;
// [[codegen::verbatim(PixelSizeControlInfo.description)]]
std::optional<bool> enablePixelControl;
// [[codegen::verbatim(TransformationMatrixInfo.description)]]
std::optional<glm::dmat4x4> transformationMatrix;
enum class Unit {
Meter [[codegen::key("m")]],
Kilometer [[codegen::key("Km")]],
Megameter [[codegen::key("Mm")]],
Gigameter [[codegen::key("Gm")]],
Terameter [[codegen::key("Tm")]],
Petameter [[codegen::key("Pm")]],
AstronomicalUnit [[codegen::key("au")]],
Parsec [[codegen::key("pc")]],
KiloParsec [[codegen::key("Kpc")]],
MegaParsec [[codgen::key("Mpc")]],
GigaParsec [[codegen::key("Gpc")]],
GigaLightyear [[codegen::key("Gly")]]
};
// [[codegen::verbatim(FadeStartUnitOptionInfo.description)]]
std::optional<Unit> fadeStartUnit;
// [[codegen::verbatim(FadeEndUnitOptionInfo.description)]]
std::optional<Unit> fadeEndUnit;
// [[codegen::verbatim(FadeStartDistInfo.description)]]
std::optional<float> fadeStartDistance;
// [[codegen::verbatim(FadeEndDistInfo.description)]]
std::optional<float> fadeEndDistance;
// [[codegen::verbatim(FadeStartSpeedInfo.description)]]
std::optional<float> fadeStartSpeed;
// [[codegen::verbatim(FadeEndSpeedInfo.description)]]
std::optional<float> fadeEndSpeed;
};
#include "renderablelabels_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation RenderableLabels::Documentation() {
using namespace documentation;
return {
"Renderable Labels",
"base_renderable_labels",
{
{
BlendModeInfo.identifier,
new StringInListVerifier({ "Normal", "Additive" }),
Optional::Yes,
BlendModeInfo.description, // + " The default value is 'Normal'.",
},
{
LabelOrientationOptionInfo.identifier,
new StringInListVerifier(
{ "Camera View Direction", "Camera Position Normal" }
),
Optional::Yes,
LabelOrientationOptionInfo.description,
},
{
LabelColorInfo.identifier,
new DoubleVector3Verifier,
Optional::Yes,
LabelColorInfo.description,
},
{
LabelTextInfo.identifier,
new StringVerifier,
Optional::Yes,
LabelTextInfo.description
},
{
FontSizeInfo.identifier,
new DoubleVerifier,
Optional::Yes,
FontSizeInfo.description
},
{
LabelSizeInfo.identifier,
new DoubleVerifier,
Optional::Yes,
LabelSizeInfo.description
},
{
LabelMinSizeInfo.identifier,
new DoubleVerifier,
Optional::Yes,
LabelMinSizeInfo.description
},
{
LabelMaxSizeInfo.identifier,
new DoubleVerifier,
Optional::Yes,
LabelMaxSizeInfo.description
},
{
EnableFadingEffectInfo.identifier,
new BoolVerifier,
Optional::Yes,
EnableFadingEffectInfo.description
},
{
PixelSizeControlInfo.identifier,
new BoolVerifier,
Optional::Yes,
PixelSizeControlInfo.description
},
{
FadeStartUnitOptionInfo.identifier,
new StringInListVerifier(
{ "m", "Km", "Mm", "Gm", "au", "Tm", "Pm", "pc", "Kpc", "Mpc",
"Gpc", "Gly"}
),
Optional::Yes,
FadeStartUnitOptionInfo.description,
},
{
FadeEndUnitOptionInfo.identifier,
new StringInListVerifier(
{"m", "Km", "Mm", "Gm", "au", "Tm", "Pm", "pc", "Kpc", "Mpc",
"Gpc", "Gly"}
),
Optional::Yes,
FadeEndUnitOptionInfo.description,
},
{
FadeStartDistInfo.identifier,
new DoubleVerifier,
Optional::Yes,
FadeStartDistInfo.description
},
{
FadeEndDistInfo.identifier,
new DoubleVerifier,
Optional::Yes,
FadeEndDistInfo.description
},
{
FadeStartSpeedInfo.identifier,
new DoubleVerifier,
Optional::Yes,
FadeStartSpeedInfo.description
},
{
FadeEndSpeedInfo.identifier,
new DoubleVerifier,
Optional::Yes,
FadeEndSpeedInfo.description
},
}
};
return codegen::doc<Parameters>();
}
RenderableLabels::RenderableLabels(const ghoul::Dictionary& dictionary)
@@ -327,11 +295,7 @@ RenderableLabels::RenderableLabels(const ghoul::Dictionary& dictionary)
properties::OptionProperty::DisplayType::Dropdown
)
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"RenderableLabels"
);
const Parameters p = codegen::bake<Parameters>(dictionary);
addProperty(_opacity);
registerUpdateRenderBinFromOpacity();
@@ -353,13 +317,14 @@ RenderableLabels::RenderableLabels(const ghoul::Dictionary& dictionary)
}
});
if (dictionary.hasKey(BlendModeInfo.identifier)) {
const std::string v = dictionary.value<std::string>(BlendModeInfo.identifier);
if (v == "Normal") {
_blendMode = BlendModeNormal;
}
else if (v == "Additive") {
_blendMode = BlendModeAdditive;
if (p.blendMode.has_value()) {
switch (*p.blendMode) {
case Parameters::BlendMode::Normal:
_blendMode = BlendModeNormal;
break;
case Parameters::BlendMode::Additive:
_blendMode = BlendModeAdditive;
break;
}
}
@@ -369,35 +334,26 @@ RenderableLabels::RenderableLabels(const ghoul::Dictionary& dictionary)
_labelOrientationOption.addOption(NormalDirection, "Camera Position Normal");
_labelOrientationOption = NormalDirection;
if (dictionary.hasValue<std::string>(LabelOrientationOptionInfo.identifier)) {
const std::string o = dictionary.value<std::string>(
LabelOrientationOptionInfo.identifier
);
if (o == "Camera View Direction") {
_labelOrientationOption = ViewDirection;
}
else if (o == "Camera Position Normal") {
_labelOrientationOption = NormalDirection;
if (p.labelOrientationOption.has_value()) {
switch (*p.labelOrientationOption) {
case Parameters::Orientation::ViewDirection:
_labelOrientationOption = ViewDirection;
break;
case Parameters::Orientation::PositionNormal:
_labelOrientationOption = NormalDirection;
break;
}
}
if (dictionary.hasKey(LabelTextInfo.identifier)) {
_labelText = dictionary.value<std::string>(LabelTextInfo.identifier);
}
addProperty(_labelText);
addProperty(_labelOrientationOption);
_labelText = p.labelText.value_or(_labelText);
addProperty(_labelText);
_labelColor = p.labelColor.value_or(_labelColor);
_labelColor.setViewOption(properties::Property::ViewOptions::Color);
if (dictionary.hasKey(LabelColorInfo.identifier)) {
_labelColor = dictionary.value<glm::dvec3>(LabelColorInfo.identifier);
}
addProperty(_labelColor);
if (dictionary.hasKey(FontSizeInfo.identifier)) {
_fontSize = static_cast<float>(dictionary.value<double>(FontSizeInfo.identifier));
}
_fontSize = p.fontSize.value_or(_fontSize);
_fontSize.onChange([&]() {
_font = global::fontManager->font(
"Mono",
@@ -408,49 +364,28 @@ RenderableLabels::RenderableLabels(const ghoul::Dictionary& dictionary)
});
addProperty(_fontSize);
if (dictionary.hasKey(LabelSizeInfo.identifier)) {
_labelSize = static_cast<float>(
dictionary.value<double>(LabelSizeInfo.identifier)
);
}
_labelSize = p.labelSize.value_or(_labelSize);
addProperty(_labelSize);
if (dictionary.hasKey(LabelMinSizeInfo.identifier)) {
_labelMinSize = static_cast<float>(
dictionary.value<double>(LabelMinSizeInfo.identifier)
);
}
_labelMinSize = p.labelMinSize.value_or(_labelMinSize);
addProperty(_labelMinSize);
if (dictionary.hasKey(LabelMaxSizeInfo.identifier)) {
_labelMaxSize = static_cast<float>(
dictionary.value<double>(LabelMaxSizeInfo.identifier)
);
}
_labelMaxSize = p.labelMaxSize.value_or(_labelMaxSize);
addProperty(_labelMaxSize);
if (dictionary.hasKey(TransformationMatrixInfo.identifier)) {
_transformationMatrix = dictionary.value<glm::dmat4>(
TransformationMatrixInfo.identifier
);
}
_transformationMatrix = p.transformationMatrix.value_or(_transformationMatrix);
if (dictionary.hasKey(PixelSizeControlInfo.identifier)) {
_pixelSizeControl = dictionary.value<bool>(PixelSizeControlInfo.identifier);
_pixelSizeControl = p.enablePixelControl.value_or(_pixelSizeControl);
if (_pixelSizeControl) {
// @TODO (abock, 2021-01-28) I don't know why we only add the property if the
// pixel control is enabled, but I think this is an error
addProperty(_pixelSizeControl);
}
if (dictionary.hasKey(EnableFadingEffectInfo.identifier)) {
_enableFadingEffect = dictionary.value<bool>(EnableFadingEffectInfo.identifier);
}
_enableFadingEffect = p.enableFading.value_or(_enableFadingEffect);
addProperty(_enableFadingEffect);
if (dictionary.hasKey(FadeStartDistInfo.identifier)) {
_fadeStartDistance = static_cast<float>(
dictionary.value<double>(FadeStartDistInfo.identifier)
);
}
_fadeStartDistance = p.fadeStartDistance.value_or(_fadeStartDistance);
addProperty(_fadeStartDistance);
_fadeStartUnitOption.addOption(Meter, MeterUnit);
@@ -466,72 +401,56 @@ RenderableLabels::RenderableLabels(const ghoul::Dictionary& dictionary)
_fadeStartUnitOption.addOption(Gigaparsec, GigaparsecUnit);
_fadeStartUnitOption.addOption(GigalightYears, GigalightyearUnit);
_fadeStartUnitOption = AU;
if (dictionary.hasKey(FadeStartUnitOptionInfo.identifier)) {
std::string unit = dictionary.value<std::string>(
FadeStartUnitOptionInfo.identifier
);
if (unit == MeterUnit) {
_fadeStartUnitOption = Meter;
}
else if (unit == KilometerUnit) {
_fadeStartUnitOption = Kilometer;
}
else if (unit == MegameterUnit) {
_fadeStartUnitOption = Megameter;
}
else if (unit == GigameterUnit) {
_fadeStartUnitOption = Gigameter;
}
else if (unit == AstronomicalUnit) {
_fadeStartUnitOption = AU;
}
else if (unit == TerameterUnit) {
_fadeStartUnitOption = Terameter;
}
else if (unit == PetameterUnit) {
_fadeStartUnitOption = Petameter;
}
else if (unit == ParsecUnit) {
_fadeStartUnitOption = Parsec;
}
else if (unit == KiloparsecUnit) {
_fadeStartUnitOption = Kiloparsec;
}
else if (unit == MegaparsecUnit) {
_fadeStartUnitOption = Megaparsec;
}
else if (unit == GigaparsecUnit) {
_fadeStartUnitOption = Gigaparsec;
}
else if (unit == GigalightyearUnit) {
_fadeStartUnitOption = GigalightYears;
}
else {
LWARNING(
"No unit given for RenderableLabels. Using kilometer as units."
);
_fadeStartUnitOption = Kilometer;
if (p.fadeStartUnit.has_value()) {
switch (*p.fadeStartUnit) {
case Parameters::Unit::Meter:
_fadeStartUnitOption = Meter;
break;
case Parameters::Unit::Kilometer:
_fadeStartUnitOption = Kilometer;
break;
case Parameters::Unit::Megameter:
_fadeStartUnitOption = Megameter;
break;
case Parameters::Unit::Gigameter:
_fadeStartUnitOption = Gigameter;
break;
case Parameters::Unit::Terameter:
_fadeStartUnitOption = Terameter;
break;
case Parameters::Unit::Petameter:
_fadeStartUnitOption = Petameter;
break;
case Parameters::Unit::AstronomicalUnit:
_fadeStartUnitOption = AU;
break;
case Parameters::Unit::Parsec:
_fadeStartUnitOption = Parsec;
break;
case Parameters::Unit::KiloParsec:
_fadeStartUnitOption = Kiloparsec;
break;
case Parameters::Unit::MegaParsec:
_fadeStartUnitOption = Megaparsec;
break;
case Parameters::Unit::GigaParsec:
_fadeStartUnitOption = Gigaparsec;
break;
case Parameters::Unit::GigaLightyear:
_fadeStartUnitOption = GigalightYears;
break;
}
}
else {
_fadeStartUnitOption = AU;
}
addProperty(_fadeStartUnitOption);
if (dictionary.hasKey(FadeStartSpeedInfo.identifier)) {
_fadeStartSpeed = static_cast<float>(
dictionary.value<double>(FadeStartSpeedInfo.identifier)
);
}
_fadeStartSpeed = p.fadeStartSpeed.value_or(_fadeStartSpeed);
addProperty(_fadeStartSpeed);
if (dictionary.hasKey(FadeEndDistInfo.identifier)) {
_fadeEndDistance = static_cast<float>(
dictionary.value<double>(FadeEndDistInfo.identifier)
);
}
_fadeEndDistance = p.fadeEndDistance.value_or(_fadeEndDistance);
addProperty(_fadeEndDistance);
_fadeEndUnitOption.addOption(Meter, MeterUnit);
@@ -547,64 +466,53 @@ RenderableLabels::RenderableLabels(const ghoul::Dictionary& dictionary)
_fadeEndUnitOption.addOption(Gigaparsec, GigaparsecUnit);
_fadeEndUnitOption.addOption(GigalightYears, GigalightyearUnit);
_fadeEndUnitOption = AU;
if (dictionary.hasKey(FadeEndUnitOptionInfo.identifier)) {
std::string unit = dictionary.value<std::string>(
FadeEndUnitOptionInfo.identifier
);
if (unit == MeterUnit) {
_fadeEndUnitOption = Meter;
}
else if (unit == KilometerUnit) {
_fadeEndUnitOption = Kilometer;
}
else if (unit == MegameterUnit) {
_fadeEndUnitOption = Megameter;
}
else if (unit == GigameterUnit) {
_fadeEndUnitOption = Gigameter;
}
else if (unit == AstronomicalUnit) {
_fadeEndUnitOption = AU;
}
else if (unit == TerameterUnit) {
_fadeEndUnitOption = Terameter;
}
else if (unit == PetameterUnit) {
_fadeEndUnitOption = Petameter;
}
else if (unit == ParsecUnit) {
_fadeEndUnitOption = Parsec;
}
else if (unit == KiloparsecUnit) {
_fadeEndUnitOption = Kiloparsec;
}
else if (unit == MegaparsecUnit) {
_fadeEndUnitOption = Megaparsec;
}
else if (unit == GigaparsecUnit) {
_fadeEndUnitOption = Gigaparsec;
}
else if (unit == GigalightyearUnit) {
_fadeEndUnitOption = GigalightYears;
}
else {
LWARNING(
"No unit given for RenderableLabels. Using kilometer as units."
);
_fadeEndUnitOption = Kilometer;
if (p.fadeEndUnit.has_value()) {
switch (*p.fadeEndUnit) {
case Parameters::Unit::Meter:
_fadeStartUnitOption = Meter;
break;
case Parameters::Unit::Kilometer:
_fadeStartUnitOption = Kilometer;
break;
case Parameters::Unit::Megameter:
_fadeStartUnitOption = Megameter;
break;
case Parameters::Unit::Gigameter:
_fadeStartUnitOption = Gigameter;
break;
case Parameters::Unit::Terameter:
_fadeStartUnitOption = Terameter;
break;
case Parameters::Unit::Petameter:
_fadeStartUnitOption = Petameter;
break;
case Parameters::Unit::AstronomicalUnit:
_fadeStartUnitOption = AU;
break;
case Parameters::Unit::Parsec:
_fadeStartUnitOption = Parsec;
break;
case Parameters::Unit::KiloParsec:
_fadeEndUnitOption = Kiloparsec;
break;
case Parameters::Unit::MegaParsec:
_fadeEndUnitOption = Megaparsec;
break;
case Parameters::Unit::GigaParsec:
_fadeEndUnitOption = Gigaparsec;
break;
case Parameters::Unit::GigaLightyear:
_fadeEndUnitOption = GigalightYears;
break;
}
}
else {
_fadeEndUnitOption = AU;
}
addProperty(_fadeEndUnitOption);
if (dictionary.hasKey(FadeEndSpeedInfo.identifier)) {
_fadeEndSpeed = static_cast<float>(
dictionary.value<double>(FadeEndSpeedInfo.identifier)
);
}
_fadeEndSpeed = p.fadeEndSpeed.value_or(_fadeEndSpeed);
addProperty(_fadeEndSpeed);
}

View File

@@ -84,42 +84,29 @@ namespace {
glm::dvec3 diffPos = worldPos - anchorNodePos;
return diffPos;
}
struct [[codegen::Dictionary(RenderableNodeLine)]] Parameters {
// [[codegen::verbatim(StartNodeInfo.description)]]
std::optional<std::string> startNode;
// [[codegen::verbatim(EndNodeInfo.description)]]
std::optional<std::string> endNode;
// [[codegen::verbatim(LineColorInfo.description)]]
std::optional<glm::vec3> color;
// [[codegen::verbatim(LineWidthInfo.description)]]
std::optional<float> lineWidth;
};
#include "renderablenodeline_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation RenderableNodeLine::Documentation() {
using namespace documentation;
return {
"Renderable Node Line",
"base_renderable_renderablenodeline",
{
{
StartNodeInfo.identifier,
new StringVerifier,
Optional::Yes,
StartNodeInfo.description
},
{
EndNodeInfo.identifier,
new StringVerifier,
Optional::Yes,
EndNodeInfo.description
},
{
LineColorInfo.identifier,
new DoubleVector3Verifier,
Optional::Yes,
LineColorInfo.description
},
{
LineWidthInfo.identifier,
new DoubleVerifier,
Optional::Yes,
LineWidthInfo.description
}
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_renderable_renderablenodeline";
return doc;
}
RenderableNodeLine::RenderableNodeLine(const ghoul::Dictionary& dictionary)
@@ -129,36 +116,22 @@ RenderableNodeLine::RenderableNodeLine(const ghoul::Dictionary& dictionary)
, _lineColor(LineColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f))
, _lineWidth(LineWidthInfo, 2.f, 1.f, 20.f)
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"RenderableNodeLine"
);
if (dictionary.hasKey(StartNodeInfo.identifier)) {
_start = dictionary.value<std::string>(StartNodeInfo.identifier);
}
if (dictionary.hasKey(EndNodeInfo.identifier)) {
_end = dictionary.value<std::string>(EndNodeInfo.identifier);
}
if (dictionary.hasKey(LineColorInfo.identifier)) {
_lineColor = dictionary.value<glm::dvec3>(LineColorInfo.identifier);
}
if (dictionary.hasKey(LineWidthInfo.identifier)) {
_lineWidth = static_cast<float>(
dictionary.value<double>(LineWidthInfo.identifier)
);
}
const Parameters p = codegen::bake<Parameters>(dictionary);
_start = p.startNode.value_or(_start);
_start.onChange([&]() { validateNodes(); });
_end.onChange([&]() { validateNodes(); });
addProperty(_start);
_end = p.endNode.value_or(_end);
_end.onChange([&]() { validateNodes(); });
addProperty(_end);
_lineColor = p.color.value_or(_lineColor);
addProperty(_lineColor);
_lineWidth = p.lineWidth.value_or(_lineWidth);
addProperty(_lineWidth);
addProperty(_opacity);
}

View File

@@ -40,6 +40,7 @@
#include <ghoul/opengl/textureunit.h>
#include <ghoul/glm.h>
#include <glm/gtx/string_cast.hpp>
#include <optional>
namespace {
constexpr const char* ProgramName = "Plane";
@@ -68,36 +69,30 @@ namespace {
"Blending Mode",
"This determines the blending mode that is applied to this plane."
};
struct [[codegen::Dictionary(RenderablePlane)]] Parameters {
// [[codegen::verbatim(BillboardInfo.description)]]
std::optional<bool> billboard;
// [[codegen::verbatim(SizeInfo.description)]]
float size;
enum class BlendMode {
Normal,
Additive
};
// [[codegen::verbatim(BlendModeInfo.description)]]
std::optional<BlendMode> blendMode;
};
#include "renderableplane_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation RenderablePlane::Documentation() {
using namespace documentation;
return {
"Renderable Plane",
"base_renderable_plane",
{
{
SizeInfo.identifier,
new DoubleVerifier,
Optional::No,
SizeInfo.description
},
{
BillboardInfo.identifier,
new BoolVerifier,
Optional::Yes,
BillboardInfo.description
},
{
BlendModeInfo.identifier,
new StringInListVerifier({ "Normal", "Additive" }),
Optional::Yes,
BlendModeInfo.description, // + " The default value is 'Normal'.",
}
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_renderable_plane";
return doc;
}
RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary)
@@ -106,20 +101,13 @@ RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary)
, _billboard(BillboardInfo, false)
, _size(SizeInfo, 10.f, 0.f, 1e25f)
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"RenderablePlane"
);
Parameters p = codegen::bake<Parameters>(dictionary);
addProperty(_opacity);
registerUpdateRenderBinFromOpacity();
_size = static_cast<float>(dictionary.value<double>(SizeInfo.identifier));
if (dictionary.hasKey(BillboardInfo.identifier)) {
_billboard = dictionary.value<bool>(BillboardInfo.identifier);
}
_size = p.size;
_billboard = p.billboard.value_or(_billboard);
_blendMode.addOptions({
{ BlendModeNormal, "Normal" },
@@ -144,12 +132,11 @@ RenderablePlane::RenderablePlane(const ghoul::Dictionary& dictionary)
}
});
if (dictionary.hasKey(BlendModeInfo.identifier)) {
const std::string v = dictionary.value<std::string>(BlendModeInfo.identifier);
if (v == "Normal") {
if (p.blendMode.has_value()) {
if (*p.blendMode == Parameters::BlendMode::Normal) {
_blendMode = BlendModeNormal;
}
else if (v == "Additive") {
else if (*p.blendMode == Parameters::BlendMode::Additive) {
_blendMode = BlendModeAdditive;
}
}

View File

@@ -35,10 +35,9 @@
#include <ghoul/misc/profiling.h>
#include <ghoul/opengl/texture.h>
#include <fstream>
#include <optional>
namespace {
constexpr const char* KeyLazyLoading = "LazyLoading";
constexpr openspace::properties::Property::PropertyInfo TextureInfo = {
"Texture",
"Texture",
@@ -52,54 +51,47 @@ namespace {
"This value specifies if the plane should be rendered in the Background,"
"Opaque, Transparent, or Overlay rendering step."
};
struct [[codegen::Dictionary(RenderablePlaneImageLocal)]] Parameters {
// [[codegen::verbatim(TextureInfo.description)]]
std::string texture;
enum class RenderType {
Background,
Opaque,
PreDeferredTransparency,
PostDeferredTransparency,
Overlay
};
// [[codegen::verbatim(RenderableTypeInfo.description)]]
std::optional<RenderType> renderType [[codegen::key("RenderableType")]];
// If this value is set to 'true', the image for this plane will not be loaded at
// startup but rather when image is shown for the first time. Additionally, if the
// plane is hidden, the image will automatically be unloaded
std::optional<bool> lazyLoading;
};
#include "renderableplaneimagelocal_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation RenderablePlaneImageLocal::Documentation() {
using namespace documentation;
return {
"Renderable Plane Image Local",
"base_renderable_plane_image_local",
{
{
TextureInfo.identifier,
new StringVerifier,
Optional::No,
TextureInfo.description
},
{
RenderableTypeInfo.identifier,
new StringVerifier,
Optional::Yes,
RenderableTypeInfo.description
},
{
KeyLazyLoading,
new BoolVerifier,
Optional::Yes,
"If this value is set to 'true', the image for this plane will not be "
"loaded at startup but rather when image is shown for the first time. "
"Additionally, if the plane is hidden, the image will automatically be "
"unloaded"
}
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_renderable_plane_image_local";
return doc;
}
RenderablePlaneImageLocal::RenderablePlaneImageLocal(const ghoul::Dictionary& dictionary)
: RenderablePlane(dictionary)
, _texturePath(TextureInfo)
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"RenderablePlaneImageLocal"
);
const Parameters p = codegen::bake<Parameters>(dictionary);
addProperty(_blendMode);
_texturePath = absPath(dictionary.value<std::string>(TextureInfo.identifier));
_texturePath = absPath(p.texture);
_textureFile = std::make_unique<ghoul::filesystem::File>(_texturePath);
addProperty(_texturePath);
@@ -108,44 +100,40 @@ RenderablePlaneImageLocal::RenderablePlaneImageLocal(const ghoul::Dictionary& di
[this](const ghoul::filesystem::File&) { _textureIsDirty = true; }
);
if (dictionary.hasKey(RenderableTypeInfo.identifier)) {
std::string renderType = dictionary.value<std::string>(
RenderableTypeInfo.identifier
);
if (renderType == "Background") {
setRenderBin(Renderable::RenderBin::Background);
}
else if (renderType == "Opaque") {
setRenderBin(Renderable::RenderBin::Opaque);
}
else if (renderType == "PreDeferredTransparent") {
setRenderBin(Renderable::RenderBin::PreDeferredTransparent);
}
else if (renderType == "PostDeferredTransparent") {
setRenderBin(Renderable::RenderBin::PostDeferredTransparent);
}
else if (renderType == "Overlay") {
setRenderBin(Renderable::RenderBin::Overlay);
if (p.renderType.has_value()) {
switch (*p.renderType) {
case Parameters::RenderType::Background:
setRenderBin(Renderable::RenderBin::Background);
break;
case Parameters::RenderType::Opaque:
setRenderBin(Renderable::RenderBin::Opaque);
break;
case Parameters::RenderType::PreDeferredTransparency:
setRenderBin(Renderable::RenderBin::PreDeferredTransparent);
break;
case Parameters::RenderType::PostDeferredTransparency:
setRenderBin(Renderable::RenderBin::PostDeferredTransparent);
break;
case Parameters::RenderType::Overlay:
setRenderBin(Renderable::RenderBin::Overlay);
break;
}
}
else {
setRenderBin(Renderable::RenderBin::Opaque);
}
if (dictionary.hasKey(KeyLazyLoading)) {
_isLoadingLazily = dictionary.value<bool>(KeyLazyLoading);
if (_isLoadingLazily) {
_enabled.onChange([this]() {
if (!_enabled) {
BaseModule::TextureManager.release(_texture);
_texture = nullptr;
}
if (_enabled) {
_textureIsDirty = true;
}
});
}
_isLoadingLazily = p.lazyLoading.value_or(_isLoadingLazily);
if (_isLoadingLazily) {
_enabled.onChange([this]() {
if (!_enabled) {
BaseModule::TextureManager.release(_texture);
_texture = nullptr;
}
if (_enabled) {
_textureIsDirty = true;
}
});
}
}

View File

@@ -41,24 +41,20 @@ namespace {
"this value is changed, the image at the new path will automatically be loaded "
"and displayed."
};
struct [[codegen::Dictionary(RenderablePlaneImageOnline)]] Parameters {
// [[codegen::verbatim(TextureInfo.description)]]
std::string url [[codegen::key("URL")]];
};
#include "renderableplaneimageonline_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation RenderablePlaneImageOnline::Documentation() {
using namespace documentation;
return {
"Renderable Plane Image Online",
"base_renderable_plane_image_online",
{
{
TextureInfo.identifier,
new StringVerifier,
Optional::No,
TextureInfo.description,
}
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_renderable_plane_image_online";
return doc;
}
RenderablePlaneImageOnline::RenderablePlaneImageOnline(
@@ -66,20 +62,12 @@ RenderablePlaneImageOnline::RenderablePlaneImageOnline(
: RenderablePlane(dictionary)
, _texturePath(TextureInfo)
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"RenderablePlaneImageOnline"
);
const Parameters p = codegen::bake<Parameters>(dictionary);
_texturePath.onChange([this]() { _textureIsDirty = true; });
addProperty(_texturePath);
std::string texturePath;
if (dictionary.hasKey(TextureInfo.identifier)) {
_texturePath = dictionary.value<std::string>(TextureInfo.identifier);
}
_texturePath = p.url;
addProperty(_texturePath);
}

View File

@@ -38,6 +38,7 @@
#include <ghoul/opengl/texture.h>
#include <ghoul/opengl/textureunit.h>
#include <ghoul/opengl/programobject.h>
#include <optional>
namespace {
constexpr const char* ProgramName = "Sphere";
@@ -117,81 +118,55 @@ namespace {
"Sets the current sphere rendering as a background rendering type",
"Enables/Disables background rendering."
};
struct [[codegen::Dictionary(RenderableSphere)]] Parameters {
// [[codegen::verbatim(SizeInfo.description)]]
float size;
// [[codegen::verbatim(SegmentsInfo.description)]]
int segments;
// [[codegen::verbatim(TextureInfo.description)]]
std::string texture;
enum class Orientation {
Outside,
Inside,
Both
};
// [[codegen::verbatim(OrientationInfo.description)]]
std::optional<Orientation> orientation;
// [[codegen::verbatim(UseAdditiveBlendingInfo.description)]]
std::optional<bool> useAdditiveBlending;
// [[codegen::verbatim(MirrorTextureInfo.description)]]
std::optional<bool> mirrorTexture;
// [[codegen::verbatim(FadeOutThresholdInfo.description)]]
std::optional<float> fadeOutThreshold [[codegen::inrange(0.0, 1.0)]];
// [[codegen::verbatim(FadeInThresholdInfo.description)]]
std::optional<float> fadeInThreshold;
// [[codegen::verbatim(DisableFadeInOutInfo.description)]]
std::optional<bool> disableFadeInOut;
// [[codegen::verbatim(BackgroundInfo.description)]]
std::optional<bool> background;
};
#include "renderablesphere_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation RenderableSphere::Documentation() {
using namespace documentation;
return {
"RenderableSphere",
"base_renderable_sphere",
{
{
SizeInfo.identifier,
new DoubleVerifier,
Optional::No,
SizeInfo.description
},
{
SegmentsInfo.identifier,
new IntVerifier,
Optional::No,
SegmentsInfo.description
},
{
TextureInfo.identifier,
new StringVerifier,
Optional::No,
TextureInfo.description
},
{
OrientationInfo.identifier,
new StringInListVerifier({ "Inside", "Outside", "Both" }),
Optional::Yes,
OrientationInfo.description
},
{
UseAdditiveBlendingInfo.identifier,
new BoolVerifier,
Optional::Yes,
UseAdditiveBlendingInfo.description
},
{
MirrorTextureInfo.identifier,
new BoolVerifier,
Optional::Yes,
MirrorTextureInfo.description
},
{
FadeOutThresholdInfo.identifier,
new DoubleInRangeVerifier(0.0, 1.0),
Optional::Yes,
FadeOutThresholdInfo.description
},
{
FadeInThresholdInfo.identifier,
new DoubleVerifier,
Optional::Yes,
FadeInThresholdInfo.description
},
{
DisableFadeInOutInfo.identifier,
new BoolVerifier,
Optional::Yes,
DisableFadeInOutInfo.description
},
{
BackgroundInfo.identifier,
new BoolVerifier,
Optional::Yes,
BackgroundInfo.description
},
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_renderable_sphere";
return doc;
}
RenderableSphere::RenderableSphere(const ghoul::Dictionary& dictionary)
: Renderable(dictionary)
, _texturePath(TextureInfo)
@@ -205,18 +180,14 @@ RenderableSphere::RenderableSphere(const ghoul::Dictionary& dictionary)
, _fadeInThreshold(FadeInThresholdInfo, -1.f, 0.f, 1.f)
, _fadeOutThreshold(FadeOutThresholdInfo, -1.f, 0.f, 1.f)
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"RenderableSphere"
);
const Parameters p = codegen::bake<Parameters>(dictionary);
addProperty(_opacity);
registerUpdateRenderBinFromOpacity();
_size = static_cast<float>(dictionary.value<double>(SizeInfo.identifier));
_segments = static_cast<int>(dictionary.value<double>(SegmentsInfo.identifier));
_texturePath = absPath(dictionary.value<std::string>(TextureInfo.identifier));
_size = p.size;
_segments = p.segments;
_texturePath = p.texture;
_orientation.addOptions({
{ static_cast<int>(Orientation::Outside), "Outside" },
@@ -224,19 +195,19 @@ RenderableSphere::RenderableSphere(const ghoul::Dictionary& dictionary)
{ static_cast<int>(Orientation::Both), "Both" }
});
if (dictionary.hasKey(OrientationInfo.identifier)) {
const std::string& v = dictionary.value<std::string>(OrientationInfo.identifier);
if (v == "Inside") {
_orientation = static_cast<int>(Orientation::Inside);
}
else if (v == "Outside") {
_orientation = static_cast<int>(Orientation::Outside);
}
else if (v == "Both") {
_orientation = static_cast<int>(Orientation::Both);
}
else {
throw ghoul::MissingCaseException();
if (p.orientation.has_value()) {
switch (*p.orientation) {
case Parameters::Orientation::Inside:
_orientation = static_cast<int>(Orientation::Inside);
break;
case Parameters::Orientation::Outside:
_orientation = static_cast<int>(Orientation::Outside);
break;
case Parameters::Orientation::Both:
_orientation = static_cast<int>(Orientation::Both);
break;
default:
throw ghoul::MissingCaseException();
}
}
else {
@@ -256,44 +227,34 @@ RenderableSphere::RenderableSphere(const ghoul::Dictionary& dictionary)
addProperty(_mirrorTexture);
addProperty(_useAdditiveBlending);
_mirrorTexture = p.mirrorTexture.value_or(_mirrorTexture);
_useAdditiveBlending = p.useAdditiveBlending.value_or(_useAdditiveBlending);
if (dictionary.hasKey(MirrorTextureInfo.identifier)) {
_mirrorTexture = dictionary.value<bool>(MirrorTextureInfo.identifier);
}
if (dictionary.hasKey(UseAdditiveBlendingInfo.identifier)) {
_useAdditiveBlending = dictionary.value<bool>(UseAdditiveBlendingInfo.identifier);
if (_useAdditiveBlending) {
setRenderBin(Renderable::RenderBin::PreDeferredTransparent);
}
if (_useAdditiveBlending) {
setRenderBin(Renderable::RenderBin::PreDeferredTransparent);
}
if (dictionary.hasKey(FadeOutThresholdInfo.identifier)) {
_fadeOutThreshold = static_cast<float>(
dictionary.value<double>(FadeOutThresholdInfo.identifier)
);
bool hasGivenFadeOut = p.fadeOutThreshold.has_value();
if (hasGivenFadeOut) {
_fadeOutThreshold = *p.fadeOutThreshold;
addProperty(_fadeOutThreshold);
}
if (dictionary.hasKey(FadeInThresholdInfo.identifier)) {
_fadeInThreshold = static_cast<float>(
dictionary.value<double>(FadeInThresholdInfo.identifier)
);
bool hasGivenFadeIn = p.fadeInThreshold.has_value();
if (hasGivenFadeIn) {
_fadeInThreshold = *p.fadeInThreshold;
addProperty(_fadeInThreshold);
}
if (dictionary.hasKey(FadeInThresholdInfo.identifier) ||
dictionary.hasKey(FadeOutThresholdInfo.identifier)) {
_disableFadeInDistance.set(false);
if (hasGivenFadeIn || hasGivenFadeOut) {
_disableFadeInDistance = false;
addProperty(_disableFadeInDistance);
}
if (dictionary.hasKey(BackgroundInfo.identifier)) {
_backgroundRendering = dictionary.value<bool>(BackgroundInfo.identifier);
_backgroundRendering = p.background.value_or(_backgroundRendering);
if (_backgroundRendering) {
setRenderBin(Renderable::RenderBin::Background);
}
if (_backgroundRendering) {
setRenderBin(Renderable::RenderBin::Background);
}
setRenderBinFromOpacity();

View File

@@ -34,7 +34,6 @@
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/misc/profiling.h>
#include <ghoul/opengl/programobject.h>
#include <cmath>
namespace {

View File

@@ -34,6 +34,7 @@
#include <ghoul/font/fontmanager.h>
#include <ghoul/font/fontrenderer.h>
#include <ghoul/logging/logmanager.h>
#include <optional>
namespace {
constexpr openspace::properties::Property::PropertyInfo UseMainInfo = {
@@ -42,6 +43,15 @@ namespace {
"If this value is set to 'true', this ScreenSpaceDashboard will use the "
"main dashboard instead of creating an independent one."
};
struct [[codegen::Dictionary(ScreenSpaceDashboard)]] Parameters {
// Specifies the GUI name of the ScreenSpaceDashboard
std::optional<std::string> name;
// [[codegen::verbatim(UseMainInfo.description)]]
std::optional<bool> useMainDashboard;
};
#include "screenspacedashboard_codegen.cpp"
} // namespace
namespace openspace {
@@ -115,42 +125,22 @@ int removeDashboardItemsFromScreenSpace(lua_State* L) {
dash->dashboard().clearDashboardItems();
return 0;
}
} // namespace luascriptfunctions
documentation::Documentation ScreenSpaceDashboard::Documentation() {
using namespace openspace::documentation;
return {
"ScreenSpace Dashboard",
"base_screenspace_dashboard",
{
{
KeyName,
new StringVerifier,
Optional::Yes,
"Specifies the GUI name of the ScreenSpaceDashboard"
},
{
UseMainInfo.identifier,
new BoolVerifier,
Optional::Yes,
UseMainInfo.description
}
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_screenspace_dashboard";
return doc;
}
ScreenSpaceDashboard::ScreenSpaceDashboard(const ghoul::Dictionary& dictionary)
: ScreenSpaceFramebuffer(dictionary)
, _useMainDashboard(UseMainInfo, false)
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"ScreenSpaceDashboard"
);
const Parameters p = codegen::bake<Parameters>(dictionary);
// @TODO (abock, 2021-01-29) Should this be the name variable? The identifier wasn't
// declared in the documentation
std::string identifier;
if (dictionary.hasValue<std::string>(KeyIdentifier)) {
identifier = dictionary.value<std::string>(KeyIdentifier);
@@ -161,9 +151,7 @@ ScreenSpaceDashboard::ScreenSpaceDashboard(const ghoul::Dictionary& dictionary)
identifier = makeUniqueIdentifier(identifier);
setIdentifier(std::move(identifier));
if (dictionary.hasKey(UseMainInfo.identifier)) {
_useMainDashboard = dictionary.value<bool>(UseMainInfo.identifier);
}
_useMainDashboard = p.useMainDashboard.value_or(_useMainDashboard);
addProperty(_useMainDashboard);
_scale = 1.f;

View File

@@ -32,6 +32,7 @@
#include <ghoul/opengl/programobject.h>
#include <ghoul/opengl/texture.h>
#include <ghoul/opengl/textureconversion.h>
#include <optional>
namespace {
constexpr openspace::properties::Property::PropertyInfo TexturePathInfo = {
@@ -42,42 +43,33 @@ namespace {
"and displayed. The size of the image will also automatically set the default "
"size of this plane."
};
struct [[codegen::Dictionary(ScreenSpaceImageLocal)]] Parameters {
// Specifies the GUI name of the ScreenspaceImage
std::optional<std::string> name;
// [[codegen::verbatim(TexturePathInfo.description)]]
std::optional<std::string> texturePath;
};
#include "screenspaceimagelocal_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation ScreenSpaceImageLocal::Documentation() {
using namespace openspace::documentation;
return {
"ScreenSpace Local Image",
"base_screenspace_image_local",
{
{
KeyName,
new StringVerifier,
Optional::Yes,
"Specifies the GUI name of the ScreenspaceImage"
},
{
TexturePathInfo.identifier,
new StringVerifier,
Optional::Yes,
TexturePathInfo.description
}
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_screenspace_image_local";
return doc;
}
ScreenSpaceImageLocal::ScreenSpaceImageLocal(const ghoul::Dictionary& dictionary)
: ScreenSpaceRenderable(dictionary)
, _texturePath(TexturePathInfo)
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"ScreenSpaceImageLocal"
);
const Parameters p = codegen::bake<Parameters>(dictionary);
// @TODO (abock, 2021-02-02) Should this be the name variable? The identifier wasn't
// declared in the documentation
std::string identifier;
if (dictionary.hasValue<std::string>(KeyIdentifier)) {
identifier = dictionary.value<std::string>(KeyIdentifier);
@@ -101,16 +93,15 @@ ScreenSpaceImageLocal::ScreenSpaceImageLocal(const ghoul::Dictionary& dictionary
});
addProperty(_texturePath);
if (dictionary.hasKey(TexturePathInfo.identifier)) {
std::string path = dictionary.value<std::string>(TexturePathInfo.identifier);
if (!FileSys.fileExists(FileSys.absolutePath(path))) {
LWARNINGC(
"ScreenSpaceImageLocal",
fmt::format("Image {} did not exist for {}", path, _identifier)
);
if (p.texturePath.has_value()) {
if (FileSys.fileExists(FileSys.absolutePath(*p.texturePath))) {
_texturePath = FileSys.absolutePath(*p.texturePath);
}
else {
_texturePath = path;
LWARNINGC(
"ScreenSpaceImageLocal",
fmt::format("Image {} did not exist for {}", *p.texturePath, _identifier)
);
}
}
}

View File

@@ -33,6 +33,7 @@
#include <ghoul/logging/logmanager.h>
#include <ghoul/opengl/texture.h>
#include <ghoul/opengl/programobject.h>
#include <optional>
namespace {
constexpr openspace::properties::Property::PropertyInfo TextureInfo = {
@@ -43,30 +44,23 @@ namespace {
"and displayed. The size of the image will also automatically set the default "
"size of this plane."
};
struct [[codegen::Dictionary(ScreenSpaceImageOnline)]] Parameters {
// Specifies the GUI name of the ScreenspaceImage
std::optional<std::string> name;
// [[codegen::verbatim(TextureInfo.description)]]
std::optional<std::string> url [[codegen::key("URL")]];
};
#include "screenspaceimageonline_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation ScreenSpaceImageOnline::Documentation() {
using namespace openspace::documentation;
return {
"ScreenSpace Online Image",
"base_screenspace_image_online",
{
{
KeyName,
new StringVerifier,
Optional::Yes,
"Specifies the GUI name of the ScreenspaceImage"
},
{
TextureInfo.identifier,
new StringVerifier,
Optional::Yes,
TextureInfo.description
}
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_screenspace_image_online";
return doc;
}
ScreenSpaceImageOnline::ScreenSpaceImageOnline(const ghoul::Dictionary& dictionary)
@@ -74,11 +68,7 @@ ScreenSpaceImageOnline::ScreenSpaceImageOnline(const ghoul::Dictionary& dictiona
, _textureIsDirty(false)
, _texturePath(TextureInfo)
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"ScreenSpaceImageOnline"
);
const Parameters p = codegen::bake<Parameters>(dictionary);
std::string identifier;
if (dictionary.hasValue<std::string>(KeyIdentifier)) {
@@ -92,11 +82,7 @@ ScreenSpaceImageOnline::ScreenSpaceImageOnline(const ghoul::Dictionary& dictiona
_texturePath.onChange([this]() { _textureIsDirty = true; });
addProperty(_texturePath);
std::string texturePath;
if (dictionary.hasKey(TextureInfo.identifier)) {
_texturePath = dictionary.value<std::string>(TextureInfo.identifier);
}
_texturePath = p.url.value_or(_texturePath);
}
ScreenSpaceImageOnline::~ScreenSpaceImageOnline() {} // NOLINT

View File

@@ -28,6 +28,7 @@
#include <openspace/documentation/verifier.h>
#include <openspace/util/updatestructures.h>
#include <glm/gtx/quaternion.hpp>
#include <optional>
namespace {
constexpr openspace::properties::Property::PropertyInfo RotationInfo = {
@@ -41,35 +42,22 @@ namespace {
"Rotation Rate",
"This value determines the number of revolutions per in-game second"
};
struct [[codegen::Dictionary(ConstantRotation)]] Parameters {
// [[codegen::verbatim(RotationInfo.description)]]
std::optional<glm::dvec3> rotationAxis;
// [[codegen::verbatim(RotationRateInfo.description)]]
std::optional<float> rotationRate;
};
#include "constantrotation_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation ConstantRotation::Documentation() {
using namespace openspace::documentation;
return {
"Static Rotation",
"base_transform_rotation_constant",
{
{
"Type",
new StringEqualVerifier("ConstantRotation"),
Optional::No
},
{
RotationInfo.identifier,
new DoubleVector3Verifier(),
Optional::Yes,
RotationInfo.description
},
{
RotationRateInfo.identifier,
new DoubleVerifier(),
Optional::Yes,
RotationRateInfo.description
}
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_transform_rotation_constant";
return doc;
}
ConstantRotation::ConstantRotation(const ghoul::Dictionary& dictionary)
@@ -81,18 +69,13 @@ ConstantRotation::ConstantRotation(const ghoul::Dictionary& dictionary)
)
, _rotationRate(RotationRateInfo, 1.f, -1000.f, 1000.f)
{
const Parameters p = codegen::bake<Parameters>(dictionary);
_rotationAxis = p.rotationAxis.value_or(_rotationAxis);
addProperty(_rotationAxis);
_rotationRate = p.rotationRate.value_or(_rotationRate);
addProperty(_rotationRate);
if (dictionary.hasKey(RotationInfo.identifier)) {
_rotationAxis = dictionary.value<glm::dvec3>(RotationInfo.identifier);
}
if (dictionary.hasKey(RotationRateInfo.identifier)) {
_rotationRate = static_cast<float>(
dictionary.value<double>(RotationRateInfo.identifier)
);
}
}
glm::dmat3 ConstantRotation::matrix(const UpdateData& data) const {

View File

@@ -32,16 +32,11 @@
#include <ghoul/logging/logmanager.h>
#include <ghoul/misc/assert.h>
#include <ghoul/misc/profiling.h>
#include <optional>
#include <string>
#include <variant>
namespace {
constexpr const char* KeyXAxis = "XAxis";
constexpr const char* KeyXAxisOrthogonal = "XAxisOrthogonal";
constexpr const char* KeyYAxis = "YAxis";
constexpr const char* KeyYAxisOrthogonal = "YAxisOrthogonal";
constexpr const char* KeyZAxis = "ZAxis";
constexpr const char* KeyZAxisOrthogonal = "ZAxisOrthogonal";
constexpr const openspace::properties::Property::PropertyInfo EnableInfo = {
"Enable",
"Enabled",
@@ -186,98 +181,59 @@ namespace {
"only needed if any of the three axis uses the Object type. In this case, the "
"location of the attached node is required to compute the relative direction."
};
struct [[codegen::Dictionary(FixedRotation)]] Parameters {
// This value specifies the direction of the new X axis. If this value is not
// specified, it will be computed by completing a right handed coordinate system
// from the Y and Z axis, which must be specified instead. If this value is a
// string, it is interpreted as the identifier of another scenegraph node. If this
// value is a 3-vector, it is interpreted as a direction vector
std::optional<std::variant<std::string, glm::vec3>> xAxis;
// [[codegen::verbatim(XAxisOrthogonalVectorInfo.description)]]
std::optional<bool> xAxisOrthogonal;
// [[codegen::verbatim(XAxisInvertObjectInfo.description)]]
std::optional<bool> xAxisInvert [[codegen::key("xAxis - InvertObject")]];
// This value specifies the direction of the new Y axis. If this value is not
// specified, it will be computed by completing a right handed coordinate system
// from the X and Z axis, which must be specified instead. If this value is a
// string, it is interpreted as the identifier of another scenegraph node. If this
// value is a 3-vector, it is interpreted as a direction vector
std::optional<std::variant<std::string, glm::vec3>> yAxis;
// [[codegen::verbatim(YAxisOrthogonalVectorInfo.description)]]
std::optional<bool> yAxisOrthogonal;
// [[codegen::verbatim(YAxisInvertObjectInfo.description)]]
std::optional<bool> yAxisInvert [[codegen::key("yAxis - InvertObject")]];
// This value specifies the direction of the new Z axis. If this value is not
// specified, it will be computed by completing a right handed coordinate system
// from the X and Y axis, which must be specified instead. If this value is a
// string, it is interpreted as the identifier of another scenegraph node. If this
// value is a 3-vector, it is interpreted as a direction vector
std::optional<std::variant<std::string, glm::vec3>> zAxis;
// [[codegen::verbatim(ZAxisOrthogonalVectorInfo.description)]]
std::optional<bool> zAxisOrthogonal;
// [[codegen::verbatim(ZAxisInvertObjectInfo.description)]]
std::optional<bool> zAxisInvert [[codegen::key("zAxis - InvertObject")]];
// [[codegen::verbatim(AttachedInfo.description)]]
std::optional<std::string> attached;
};
#include "fixedrotation_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation FixedRotation::Documentation() {
using namespace openspace::documentation;
return {
"Fixed Rotation",
"base_transform_rotation_fixed",
{
{
"Type",
new StringEqualVerifier("FixedRotation"),
Optional::No
},
{
KeyXAxis,
new OrVerifier({ new StringVerifier, new DoubleVector3Verifier, }),
Optional::Yes,
"This value specifies the direction of the new X axis. If this value is "
"not specified, it will be computed by completing a right handed "
"coordinate system from the Y and Z axis, which must be specified "
"instead. If this value is a string, it is interpreted as the identifier "
"of another scenegraph node. If this value is a 3-vector, it is "
"interpreted as a direction vector."
},
{
KeyXAxisOrthogonal,
new BoolVerifier,
Optional::Yes,
XAxisOrthogonalVectorInfo.description
},
{
XAxisInvertObjectInfo.identifier,
new BoolVerifier,
Optional::Yes,
XAxisInvertObjectInfo.description
},
{
KeyYAxis,
new OrVerifier({ new StringVerifier, new DoubleVector3Verifier, }),
Optional::Yes,
"This value specifies the direction of the new Y axis. If this value is "
"not specified, it will be computed by completing a right handed "
"coordinate system from the X and Z axis, which must be specified "
"instead. If this value is a string, it is interpreted as the identifier "
"of another scenegraph node. If this value is a 3-vector, it is "
"interpreted as a direction vector."
},
{
KeyYAxisOrthogonal,
new BoolVerifier,
Optional::Yes,
YAxisOrthogonalVectorInfo.description
},
{
YAxisInvertObjectInfo.identifier,
new BoolVerifier,
Optional::Yes,
YAxisInvertObjectInfo.description
},
{
KeyZAxis,
new OrVerifier({ new StringVerifier, new DoubleVector3Verifier, }),
Optional::Yes,
"This value specifies the direction of the new Z axis. If this value is "
"not specified, it will be computed by completing a right handed "
"coordinate system from the X and Y axis, which must be specified "
"instead. If this value is a string, it is interpreted as the identifier "
"of another scenegraph node. If this value is a 3-vector, it is "
"interpreted as a direction vector."
},
{
KeyZAxisOrthogonal,
new BoolVerifier,
Optional::Yes,
ZAxisOrthogonalVectorInfo.description
},
{
ZAxisInvertObjectInfo.identifier,
new BoolVerifier,
Optional::Yes,
ZAxisInvertObjectInfo.description
},
{
AttachedInfo.identifier,
new StringVerifier,
Optional::Yes,
AttachedInfo.description
}
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_transform_rotation_fixed";
return doc;
}
FixedRotation::FixedRotation(const ghoul::Dictionary& dictionary)
@@ -332,6 +288,9 @@ FixedRotation::FixedRotation(const ghoul::Dictionary& dictionary)
}
, _attachedObject(AttachedInfo, "")
{
// We check the Dictionary here in order to detect the errors early
codegen::bake<Parameters>(dictionary);
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
@@ -447,103 +406,79 @@ FixedRotation::FixedRotation(const ghoul::Dictionary& dictionary)
bool FixedRotation::initialize() {
ZoneScoped
// We have already checked this before, but still
const Parameters p = codegen::bake<Parameters>(_constructorDictionary);
// We need to do this in the initialize and not the constructor as the scene graph
// nodes referenced in the dictionary might not exist yet at construction time. At
// initialization time, however, we know that they already have been created
const bool res = Rotation::initialize();
if (_constructorDictionary.hasKey(AttachedInfo.identifier)) {
_attachedObject = _constructorDictionary.value<std::string>(
AttachedInfo.identifier
);
}
_attachedObject = p.attached.value_or(_attachedObject);
const bool hasXAxis = _constructorDictionary.hasKey(KeyXAxis);
if (hasXAxis) {
if (_constructorDictionary.hasValue<std::string>(KeyXAxis)) {
if (p.xAxis.has_value()) {
if (std::holds_alternative<std::string>(*p.xAxis)) {
_xAxis.type = Axis::Type::Object;
_xAxis.object = _constructorDictionary.value<std::string>(KeyXAxis);
_xAxis.object = std::get<std::string>(*p.xAxis);
}
else {
// We know it has to be a vector now
ghoul_assert(std::holds_alternative<glm::vec3>(*p.xAxis), "");
_xAxis.type = Axis::Type::Vector;
_xAxis.vector = _constructorDictionary.value<glm::dvec3>(KeyXAxis);
_xAxis.vector = std::get<glm::vec3>(*p.xAxis);
}
}
if (_constructorDictionary.hasKey(KeyXAxisOrthogonal)) {
_xAxis.isOrthogonal = _constructorDictionary.value<bool>(KeyXAxisOrthogonal);
}
if (_constructorDictionary.hasKey(XAxisInvertObjectInfo.identifier)) {
_xAxis.invertObject = _constructorDictionary.value<bool>(
XAxisInvertObjectInfo.identifier
);
}
_xAxis.isOrthogonal = p.xAxisOrthogonal.value_or(_xAxis.isOrthogonal);
if (_xAxis.isOrthogonal) {
_xAxis.type = Axis::Type::OrthogonalVector;
}
_xAxis.invertObject = p.xAxisInvert.value_or(_xAxis.invertObject);
const bool hasYAxis = _constructorDictionary.hasKey(KeyYAxis);
if (hasYAxis) {
if (_constructorDictionary.hasValue<std::string>(KeyYAxis)) {
if (p.yAxis.has_value()) {
if (std::holds_alternative<std::string>(*p.yAxis)) {
_yAxis.type = Axis::Type::Object;
_yAxis.object = _constructorDictionary.value<std::string>(KeyYAxis);
_yAxis.object = std::get<std::string>(*p.yAxis);
}
else {
// We know it has to be a vector now
ghoul_assert(std::holds_alternative<glm::vec3>(*p.yAxis), "");
_yAxis.type = Axis::Type::Vector;
_yAxis.vector = _constructorDictionary.value<glm::dvec3>(KeyYAxis);
_yAxis.vector = std::get<glm::vec3>(*p.yAxis);
}
}
if (_constructorDictionary.hasKey(KeyYAxisOrthogonal)) {
_yAxis.isOrthogonal = _constructorDictionary.value<bool>(KeyYAxisOrthogonal);
}
if (_constructorDictionary.hasKey(YAxisInvertObjectInfo.identifier)) {
_yAxis.invertObject = _constructorDictionary.value<bool>(
YAxisInvertObjectInfo.identifier
);
}
_yAxis.isOrthogonal = p.yAxisOrthogonal.value_or(_yAxis.isOrthogonal);
if (_yAxis.isOrthogonal) {
_yAxis.type = Axis::Type::OrthogonalVector;
}
_yAxis.invertObject = p.yAxisInvert.value_or(_yAxis.invertObject);
const bool hasZAxis = _constructorDictionary.hasKey(KeyZAxis);
if (hasZAxis) {
if (_constructorDictionary.hasValue<std::string>(KeyZAxis)) {
if (p.zAxis.has_value()) {
if (std::holds_alternative<std::string>(*p.zAxis)) {
_zAxis.type = Axis::Type::Object;
_zAxis.object = _constructorDictionary.value<std::string>(KeyZAxis);
_zAxis.object = std::get<std::string>(*p.zAxis);
}
else {
// We know it has to be a vector now
ghoul_assert(std::holds_alternative<glm::vec3>(*p.zAxis), "");
_zAxis.type = Axis::Type::Vector;
_zAxis.vector = _constructorDictionary.value<glm::dvec3>(KeyZAxis);
_zAxis.vector = std::get<glm::vec3>(*p.zAxis);
}
}
if (_constructorDictionary.hasKey(KeyZAxisOrthogonal)) {
_zAxis.isOrthogonal = _constructorDictionary.value<bool>(KeyZAxisOrthogonal);
}
if (_constructorDictionary.hasKey(ZAxisInvertObjectInfo.identifier)) {
_yAxis.invertObject = _constructorDictionary.value<bool>(
ZAxisInvertObjectInfo.identifier
);
}
_zAxis.isOrthogonal = p.zAxisOrthogonal.value_or(_zAxis.isOrthogonal);
if (_zAxis.isOrthogonal) {
_zAxis.type = Axis::Type::OrthogonalVector;
}
_zAxis.invertObject = p.zAxisInvert.value_or(_zAxis.invertObject);
if (!hasXAxis && hasYAxis && hasZAxis) {
if (!p.xAxis.has_value() && p.yAxis.has_value() && p.zAxis.has_value()) {
_xAxis.type = Axis::Type::CoordinateSystemCompletion;
}
if (hasXAxis && !hasYAxis && hasZAxis) {
if (p.xAxis.has_value() && !p.yAxis.has_value() && p.zAxis.has_value()) {
_yAxis.type = Axis::Type::CoordinateSystemCompletion;
}
if (hasXAxis && hasYAxis && !hasZAxis) {
if (p.xAxis.has_value() && p.yAxis.has_value() && !p.zAxis.has_value()) {
_zAxis.type = Axis::Type::CoordinateSystemCompletion;
}

View File

@@ -45,29 +45,20 @@ namespace {
"J2000 epoch as the second argument and computes the rotation returned as 9 "
"values."
};
struct [[codegen::Dictionary(LuaRotation)]] Parameters {
// [[codegen::verbatim(ScriptInfo.description)]]
std::string script;
};
#include "luarotation_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation LuaRotation::Documentation() {
using namespace openspace::documentation;
return {
"Lua Rotation",
"base_transform_rotation_lua",
{
{
"Type",
new StringEqualVerifier("LuaRotation"),
Optional::No
},
{
ScriptInfo.identifier,
new StringVerifier,
Optional::No,
ScriptInfo.description
}
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_transform_rotation_lua";
return doc;
}
LuaRotation::LuaRotation()
@@ -86,13 +77,9 @@ LuaRotation::LuaRotation()
}
LuaRotation::LuaRotation(const ghoul::Dictionary& dictionary) : LuaRotation() {
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"LuaRotation"
);
const Parameters p = codegen::bake<Parameters>(dictionary);
_luaScriptFile = absPath(dictionary.value<std::string>(ScriptInfo.identifier));
_luaScriptFile = absPath(p.script);
}
glm::dmat3 LuaRotation::matrix(const UpdateData& data) const {

View File

@@ -55,34 +55,21 @@ namespace {
}
return res;
}
struct [[codegen::Dictionary(StaticRotation)]] Parameters {
// Stores the static rotation as a vector containing Euler angles, a quaternion
// or a rotation matrix
std::variant<glm::dvec3, glm::dvec4, glm::dmat3x3> rotation;
};
#include "staticrotation_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation StaticRotation::Documentation() {
using namespace openspace::documentation;
return {
"Static Rotation",
"base_transform_rotation_static",
{
{
"Type",
new StringEqualVerifier("StaticRotation"),
Optional::No
},
{
RotationInfo.identifier,
new OrVerifier({
new DoubleVector3Verifier(),
new DoubleVector4Verifier(),
new DoubleMatrix3Verifier()
}),
Optional::No,
"Stores the static rotation as a vector containing Euler angles, "
" a quaternion or a rotation matrix."
}
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_transform_rotation_static";
return doc;
}
StaticRotation::StaticRotation()
@@ -101,31 +88,21 @@ StaticRotation::StaticRotation()
}
StaticRotation::StaticRotation(const ghoul::Dictionary& dictionary) : StaticRotation() {
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"StaticRotation"
);
const Parameters p = codegen::bake<Parameters>(dictionary);
if (dictionary.hasValue<glm::dvec3>(RotationInfo.identifier)) {
_eulerRotation = static_cast<glm::vec3>(
dictionary.value<glm::dvec3>(RotationInfo.identifier)
);
_matrixIsDirty = true;
if (std::holds_alternative<glm::dvec3>(p.rotation)) {
_eulerRotation = std::get<glm::dvec3>(p.rotation);
}
else if (dictionary.hasValue<glm::dvec4>(RotationInfo.identifier)) {
glm::dvec4 data = dictionary.value<glm::dvec4>(RotationInfo.identifier);
else if (std::holds_alternative<glm::dvec4>(p.rotation)) {
glm::dvec4 data = std::get<glm::dvec4>(p.rotation);
_eulerRotation = rotationMatrixToEulerAngles(
glm::mat3_cast(glm::dquat(data.w, data.x, data.y, data.z))
);
_matrixIsDirty = true;
}
else if (dictionary.hasValue<glm::dmat3>(RotationInfo.identifier)) {
_eulerRotation = rotationMatrixToEulerAngles(
dictionary.value<glm::dmat3>(RotationInfo.identifier)
);
_matrixIsDirty = true;
else if (std::holds_alternative<glm::dmat3>(p.rotation)) {
_eulerRotation = rotationMatrixToEulerAngles(std::get<glm::dmat3>(p.rotation));
}
_matrixIsDirty = true;
}
glm::dmat3 StaticRotation::matrix(const UpdateData&) const {

View File

@@ -30,7 +30,6 @@
#include <openspace/util/time.h>
namespace {
constexpr const char* KeyType = "Type";
constexpr const char* KeyKeyframes = "Keyframes";
} // namespace
@@ -42,11 +41,6 @@ documentation::Documentation TimelineRotation::Documentation() {
"Timeline Rotation",
"base_transform_rotation_keyframe",
{
{
KeyType,
new StringEqualVerifier("TimelineRotation"),
Optional::No
},
{
KeyKeyframes,
new TableVerifier({

View File

@@ -32,7 +32,6 @@
#include <ghoul/logging/logmanager.h>
#include <ghoul/lua/ghoul_lua.h>
#include <ghoul/lua/lua_helper.h>
#include <chrono>
namespace {
@@ -45,24 +44,20 @@ namespace {
"as the first argument, the current wall time as milliseconds past the J2000 "
"epoch the second argument and computes the three scaling factors."
};
struct [[codegen::Dictionary(LuaScale)]] Parameters {
// [[codegen::verbatim(ScriptInfo.description)]]
std::string script;
};
#include "luascale_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation LuaScale::Documentation() {
using namespace openspace::documentation;
return {
"Lua Scaling",
"base_scale_lua",
{
{
ScriptInfo.identifier,
new StringVerifier,
Optional::No,
ScriptInfo.description
}
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_scale_lua";
return doc;
}
LuaScale::LuaScale()
@@ -81,9 +76,8 @@ LuaScale::LuaScale()
}
LuaScale::LuaScale(const ghoul::Dictionary& dictionary) : LuaScale() {
documentation::testSpecificationAndThrow(Documentation(), dictionary, "LuaScale");
_luaScriptFile = absPath(dictionary.value<std::string>(ScriptInfo.identifier));
const Parameters p = codegen::bake<Parameters>(dictionary);
_luaScriptFile = absPath(p.script);
}
glm::dvec3 LuaScale::scaleValue(const UpdateData& data) const {

View File

@@ -34,24 +34,20 @@ namespace {
"These values are used as scaling factors for the scene graph node that this "
"transformation is attached to relative to its parent."
};
struct [[codegen::Dictionary(NonUniformStaticScale)]] Parameters {
// [[codegen::verbatim(ScaleInfo.description)]]
glm::dvec3 scale;
};
#include "nonuniformstaticscale_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation NonUniformStaticScale::Documentation() {
using namespace openspace::documentation;
return {
"Static Scaling",
"base_scale_static",
{
{
ScaleInfo.identifier,
new DoubleVector3Verifier,
Optional::No,
ScaleInfo.description
}
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_scale_nonuniformstatic";
return doc;
}
glm::dvec3 NonUniformStaticScale::scaleValue(const UpdateData&) const {
@@ -71,9 +67,8 @@ NonUniformStaticScale::NonUniformStaticScale()
NonUniformStaticScale::NonUniformStaticScale(const ghoul::Dictionary& dictionary)
: NonUniformStaticScale()
{
documentation::testSpecificationAndThrow(Documentation(), dictionary, "StaticScale");
_scaleValue = dictionary.value<glm::dvec3>(ScaleInfo.identifier);
const Parameters p = codegen::bake<Parameters>(dictionary);
_scaleValue = p.scale;
}
} // namespace openspace

View File

@@ -34,24 +34,20 @@ namespace {
"This value is used as a scaling factor for the scene graph node that this "
"transformation is attached to relative to its parent."
};
struct [[codegen::Dictionary(StaticScale)]] Parameters {
// [[codegen::verbatim(ScaleInfo.description)]]
float scale;
};
#include "staticscale_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation StaticScale::Documentation() {
using namespace openspace::documentation;
return {
"Static Scaling",
"base_scale_static",
{
{
ScaleInfo.identifier,
new DoubleVerifier,
Optional::No,
ScaleInfo.description
}
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_scale_static";
return doc;
}
glm::dvec3 StaticScale::scaleValue(const UpdateData&) const {
@@ -67,9 +63,8 @@ StaticScale::StaticScale() : _scaleValue(ScaleInfo, 1.f, 0.1f, 100.f) {
}
StaticScale::StaticScale(const ghoul::Dictionary& dictionary) : StaticScale() {
documentation::testSpecificationAndThrow(Documentation(), dictionary, "StaticScale");
_scaleValue = static_cast<float>(dictionary.value<double>(ScaleInfo.identifier));
const Parameters p = codegen::bake<Parameters>(dictionary);
_scaleValue = p.scale;
}
} // namespace openspace

View File

@@ -28,6 +28,7 @@
#include <openspace/documentation/verifier.h>
#include <openspace/util/time.h>
#include <openspace/util/updatestructures.h>
#include <optional>
namespace {
constexpr openspace::properties::Property::PropertyInfo ReferenceDateInfo = {
@@ -53,36 +54,26 @@ namespace {
"negative values. This is useful for instantaneous events that only propagate "
"forwards. The default value is 'true'."
};
struct [[codegen::Dictionary(TimeDependentScale)]] Parameters {
// [[codegen::verbatim(ReferenceDateInfo.description)]]
std::string referenceDate;
// [[codegen::verbatim(SpeedInfo.description)]]
std::optional<double> speed;
// [[codegen::verbatim(ClampToPositiveInfo.description)]]
std::optional<bool> clampToPositive;
};
#include "timedependentscale_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation TimeDependentScale::Documentation() {
using namespace openspace::documentation;
return {
"Timedependent Scaling",
"base_scale_timedependent",
{
{
ReferenceDateInfo.identifier,
new StringVerifier,
Optional::No,
ReferenceDateInfo.description
},
{
SpeedInfo.identifier,
new DoubleVerifier,
Optional::Yes,
SpeedInfo.description
},
{
ClampToPositiveInfo.identifier,
new BoolVerifier,
Optional::Yes,
ClampToPositiveInfo.description
}
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_scale_timedependent";
return doc;
}
TimeDependentScale::TimeDependentScale(const ghoul::Dictionary& dictionary)
@@ -90,21 +81,17 @@ TimeDependentScale::TimeDependentScale(const ghoul::Dictionary& dictionary)
, _speed(SpeedInfo, 1.0, 0.0, 1e12)
, _clampToPositive(ClampToPositiveInfo, true)
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"TimeDependentScale"
);
const Parameters p = codegen::bake<Parameters>(dictionary);
_referenceDate = dictionary.value<std::string>(ReferenceDateInfo.identifier);
_referenceDate = p.referenceDate;
_referenceDate.onChange([this]() { _cachedReferenceDirty = true; });
addProperty(_referenceDate);
if (dictionary.value<double>(SpeedInfo.identifier)) {
_speed = dictionary.value<double>(SpeedInfo.identifier);
}
_speed = p.speed.value_or(_speed);
addProperty(_speed);
// @TODO (abock, 2021-01-09) The clamp to positive value from the dictionary was never
// actually read. I think this should probably be done here?
addProperty(_clampToPositive);
}

View File

@@ -0,0 +1,58 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* 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 "fragment.glsl"
in vec2 vs_st;
in float vs_screenSpaceDepth;
uniform sampler1D colorTexture;
uniform float width;
uniform float opacity;
Fragment getFragment() {
// The length of the texture coordinates vector is our distance from the center
float radius = length(vs_st);
// We only want to consider ring-like objects so we need to discard everything else
if (radius > 1.0) {
discard;
}
// Remapping the texture coordinates
// Radius \in [0,1],
float inner = 1.0 - width;
float texCoord = (radius - inner) / (1.0 - inner);
if (texCoord < 0.0 || texCoord > 1.0) {
discard;
}
vec4 diffuse = texture(colorTexture, texCoord);
diffuse.a *= opacity;
Fragment frag;
frag.color = diffuse;
frag.depth = vs_screenSpaceDepth;
return frag;
}

View File

@@ -0,0 +1,47 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* 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. *
****************************************************************************************/
#version __CONTEXT__
#include "PowerScaling/powerScaling_vs.hglsl"
layout(location = 0) in vec2 in_position;
layout(location = 1) in vec2 in_st;
out vec2 vs_st;
out float vs_screenSpaceDepth;
uniform mat4 modelViewProjectionTransform;
void main() {
vec4 position = vec4(in_position.xy, 0.0, 1.0);
vec4 positionScreenSpace = z_normalization(modelViewProjectionTransform * position);
// Moving the origin to the center
vs_st = (in_st - vec2(0.5)) * 2.0;
vs_screenSpaceDepth = positionScreenSpace.w;
gl_Position = positionScreenSpace;
}

View File

@@ -28,6 +28,7 @@
#include <openspace/documentation/verifier.h>
#include <openspace/util/spicemanager.h>
#include <openspace/util/time.h>
#include <optional>
namespace {
constexpr const openspace::properties::Property::PropertyInfo HasStartInfo = {
@@ -53,42 +54,23 @@ namespace {
"End",
"Specifies the time when this TimeFrame becomes inactive"
};
struct [[codegen::Dictionary(TimeFrameInterval)]] Parameters {
// [[codegen::verbatim(StartInfo.description)]]
std::optional<std::variant<double, std::string>> start;
// [[codegen::verbatim(EndInfo.description)]]
std::optional<std::variant<double, std::string>> end;
};
#include "timeframeinterval_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation TimeFrameInterval::Documentation() {
using namespace openspace::documentation;
return {
"Time Frame Interval",
"base_time_frame_interval",
{
{
HasStartInfo.identifier,
new BoolVerifier,
Optional::Yes,
HasStartInfo.description
},
{
StartInfo.identifier,
new OrVerifier({ new DoubleVerifier, new StringVerifier }),
Optional::Yes,
StartInfo.description
},
{
HasEndInfo.identifier,
new BoolVerifier,
Optional::Yes,
HasEndInfo.description
},
{
EndInfo.identifier,
new OrVerifier({ new DoubleVerifier, new StringVerifier }),
Optional::Yes,
EndInfo.description
},
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_time_frame_interval";
return doc;
}
bool TimeFrameInterval::isActive(const Time& time) const {
@@ -119,38 +101,35 @@ TimeFrameInterval::TimeFrameInterval(const ghoul::Dictionary& dictionary)
, _hasEnd(HasEndInfo, false)
, _end(EndInfo, 0, 0, 1E9)
{
const Parameters p = codegen::bake<Parameters>(dictionary);
if (p.start.has_value()) {
if (std::holds_alternative<double>(*p.start)) {
_start = std::get<double>(*p.start);
}
else {
_start = SpiceManager::ref().ephemerisTimeFromDate(
std::get<std::string>(*p.start)
);
}
}
_hasStart = p.start.has_value();
addProperty(_hasStart);
addProperty(_start);
if (p.end.has_value()) {
if (std::holds_alternative<double>(*p.end)) {
_end = std::get<double>(*p.end);
}
else {
_end = SpiceManager::ref().ephemerisTimeFromDate(
std::get<std::string>(*p.end)
);
}
}
_hasEnd = p.end.has_value();
addProperty(_hasEnd);
addProperty(_end);
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"TimeFrameInterval"
);
if (dictionary.hasValue<std::string>(StartInfo.identifier)) {
_start = SpiceManager::ref().ephemerisTimeFromDate(
dictionary.value<std::string>(StartInfo.identifier)
);
_hasStart = true;
}
else if (dictionary.hasValue<double>(StartInfo.identifier)) {
_start = dictionary.value<double>(StartInfo.identifier);
_hasStart = true;
}
if (dictionary.hasValue<std::string>(EndInfo.identifier)) {
_end = SpiceManager::ref().ephemerisTimeFromDate(
dictionary.value<std::string>(EndInfo.identifier)
);
_hasEnd = true;
}
else if (dictionary.hasValue<double>(EndInfo.identifier)) {
_end = dictionary.value<double>(EndInfo.identifier);
_hasEnd = true;
}
}
} // namespace openspace

View File

@@ -38,30 +38,20 @@ namespace {
"The time frame is active when any of the contained time frames are, "
"but not in gaps between contained time frames."
};
struct [[codegen::Dictionary(TimeFrameUnion)]] Parameters {
// [[codegen::verbatim(TimeFramesInfo.description)]]
std::vector<std::monostate> timeFrames [[codegen::reference("core_time_frame")]];
};
#include "timeframeunion_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation TimeFrameUnion::Documentation() {
using namespace openspace::documentation;
return {
"Time Frame Union",
"base_time_frame_union",
{
{
TimeFramesInfo.identifier,
new TableVerifier({
{
"*",
new ReferencingVerifier("core_time_frame"),
Optional::Yes
}
}),
Optional::No,
TimeFramesInfo.description
},
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_time_frame_union";
return doc;
}
bool TimeFrameUnion::isActive(const Time& time) const {
@@ -76,9 +66,10 @@ bool TimeFrameUnion::isActive(const Time& time) const {
TimeFrameUnion::TimeFrameUnion(const ghoul::Dictionary& dictionary)
: TimeFrame()
{
documentation::testSpecificationAndThrow(Documentation(),
dictionary,
"TimeFrameUnion");
// I don't know how we can actually help the reference attribute properly. Since the
// Parameter list only contains the monostate, there is no need to actually create
// the object here
codegen::bake<Parameters>(dictionary);
ghoul::Dictionary frames =
dictionary.value<ghoul::Dictionary>(TimeFramesInfo.identifier);

View File

@@ -33,7 +33,6 @@
#include <ghoul/logging/logmanager.h>
#include <ghoul/lua/ghoul_lua.h>
#include <ghoul/lua/lua_helper.h>
#include <chrono>
namespace {
@@ -46,32 +45,22 @@ namespace {
"epoch as the first argument, the current wall time as milliseconds past the "
"J2000 epoch as the second argument and computes the translation."
};
struct [[codegen::Dictionary(LuaTranslation)]] Parameters {
// [[codegen::verbatim(ScriptInfo.description)]]
std::string script;
};
#include "luatranslation_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation LuaTranslation::Documentation() {
using namespace documentation;
return {
"Lua Translation",
"base_transform_translation_lua",
{
{
"Type",
new StringEqualVerifier("LuaTranslation"),
Optional::No
},
{
ScriptInfo.identifier,
new StringVerifier,
Optional::No,
ScriptInfo.description
}
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_transform_translation_lua";
return doc;
}
LuaTranslation::LuaTranslation()
: _luaScriptFile(ScriptInfo)
, _state(ghoul::lua::LuaState::IncludeStandardLibrary::No)
@@ -89,13 +78,8 @@ LuaTranslation::LuaTranslation()
}
LuaTranslation::LuaTranslation(const ghoul::Dictionary& dictionary) : LuaTranslation() {
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"StaticTranslation"
);
_luaScriptFile = absPath(dictionary.value<std::string>(ScriptInfo.identifier));
const Parameters p = codegen::bake<Parameters>(dictionary);
_luaScriptFile = absPath(p.script);
}
glm::dvec3 LuaTranslation::position(const UpdateData& data) const {

View File

@@ -34,32 +34,22 @@ namespace {
"This value is used as a static offset (in meters) that is applied to the scene "
"graph node that this transformation is attached to relative to its parent."
};
struct [[codegen::Dictionary(StaticTranslation)]] Parameters {
// [[codegen::verbatim(PositionInfo.description)]]
glm::dvec3 position;
};
#include "statictranslation_codegen.cpp"
} // namespace
namespace openspace {
documentation::Documentation StaticTranslation::Documentation() {
using namespace documentation;
return {
"Static Translation",
"base_transform_translation_static",
{
{
"Type",
new StringEqualVerifier("StaticTranslation"),
Optional::No
},
{
PositionInfo.identifier,
new DoubleVector3Verifier,
Optional::No,
PositionInfo.description
}
}
};
documentation::Documentation doc = codegen::doc<Parameters>();
doc.id = "base_transform_translation_static";
return doc;
}
StaticTranslation::StaticTranslation()
: _position(
PositionInfo,
@@ -79,13 +69,8 @@ StaticTranslation::StaticTranslation()
StaticTranslation::StaticTranslation(const ghoul::Dictionary& dictionary)
: StaticTranslation()
{
documentation::testSpecificationAndThrow(
Documentation(),
dictionary,
"StaticTranslation"
);
_position = dictionary.value<glm::dvec3>(PositionInfo.identifier);
const Parameters p = codegen::bake<Parameters>(dictionary);
_position = p.position;
}
glm::dvec3 StaticTranslation::position(const UpdateData&) const {

View File

@@ -30,7 +30,6 @@
#include <openspace/util/time.h>
namespace {
constexpr const char* KeyType = "Type";
constexpr const char* KeyKeyframes = "Keyframes";
} // namespace
@@ -42,11 +41,6 @@ documentation::Documentation TimelineTranslation::Documentation() {
"Timeline Translation",
"base_transform_translation_keyframe",
{
{
KeyType,
new StringEqualVerifier("TimelineTranslation"),
Optional::No
},
{
KeyKeyframes,
new TableVerifier({

Some files were not shown because too many files have changed in this diff Show More