diff --git a/README.md b/README.md index 2574661f66..51a719488f 100644 --- a/README.md +++ b/README.md @@ -42,7 +42,6 @@ This repository contains the source code and example profiles for OpenSpace, but Requirements for compiling are: - CMake version 3.25 or above - C++ compiler supporting C++20/C++23 (Visual Studio 2022 17.11, GCC13, Clang17, AppleClang 15.0.0) - - [Boost](http://www.boost.org/) - [Qt](http://www.qt.io/download) diff --git a/apps/OpenSpace/ext/sgct b/apps/OpenSpace/ext/sgct index b6171ab0a0..93dfc1caba 160000 --- a/apps/OpenSpace/ext/sgct +++ b/apps/OpenSpace/ext/sgct @@ -1 +1 @@ -Subproject commit b6171ab0a0df76a44ad53be41bdfd08ea39e4249 +Subproject commit 93dfc1caba38d300bcc438a3d8a1a4c808b12aef diff --git a/ext/ghoul b/ext/ghoul index e26ea6366c..0379738e63 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit e26ea6366ca7e634b88ecf646da5b4adc8168b95 +Subproject commit 0379738e63e13ca2d9671bdf8b9fd399de7ba578 diff --git a/include/openspace/documentation/documentation.h b/include/openspace/documentation/documentation.h index 738a88cb3e..0989e0697f 100644 --- a/include/openspace/documentation/documentation.h +++ b/include/openspace/documentation/documentation.h @@ -39,6 +39,7 @@ namespace openspace::documentation { class Verifier; BooleanType(Optional); +BooleanType(Private); /** * The TestResult structure returns the information from the #testSpecification method. It @@ -161,16 +162,20 @@ struct DocumentationEntry { * contains this DocumentationEntry will be matched * \param v The Verifier that is used to test the \p k%'s value to determine if it is * a valid value - * \param doc The textual documentation that describes the DocumentationEntry in a - * human readable format * \param opt Determines whether the Documentation containing this DocumentationEntry * must have a key \p key, or whether it is optional + * \param priv Determines whether the DocumentationEntry is considered private. If it + * is, then shall not be reported in a user-facing manner, but its values + * should still be checked when verifying the correctness and completeness of + * an entry + * \param doc The textual documentation that describes the DocumentationEntry in a + * human readable format * * \pre \p k must not be empty * \pre \p v must not be nullptr */ DocumentationEntry(std::string k, std::shared_ptr v, - Optional opt, std::string doc = ""); + Optional opt = Optional::No, Private priv = Private::No, std::string doc = ""); /** * The constructor for a DocumentationEntry describing a key \p k in a Documentation. @@ -187,15 +192,20 @@ struct DocumentationEntry { * \param v The Verifier that is used to test the \p key%'s value to determine if it * is a valid value. The DocumentationEntry will take ownership of the passed * object - * \param doc The textual documentation that describes the DocumentationEntry in a - * human readable format * \param opt Determines whether the Documentation containing this DocumentationEntry * must have a key \p key, or whether it is optional + * \param priv Determines whether the DocumentationEntry is considered private. If it + * is, then shall not be reported in a user-facing manner, but its values + * should still be checked when verifying the correctness and completeness of + * an entry + * \param doc The textual documentation that describes the DocumentationEntry in a + * human readable format * * \pre \p k must not be empty * \pre \p v must not be nullptr */ - DocumentationEntry(std::string k, Verifier* v, Optional opt, std::string doc = ""); + DocumentationEntry(std::string k, Verifier* v, Optional opt = Optional::No, + Private priv = Private::No, std::string doc = ""); /// The key that is described by this DocumentationEntry std::string key; @@ -203,6 +213,8 @@ struct DocumentationEntry { std::shared_ptr verifier; /// Determines whether the described DocumentationEntry is optional or not Optional optional; + /// Determines if the entry should be visible to the user + Private isPrivate; /// The textual description of this DocumentationEntry std::string documentation; }; diff --git a/include/openspace/documentation/verifier.h b/include/openspace/documentation/verifier.h index 5fa838f988..8108508459 100644 --- a/include/openspace/documentation/verifier.h +++ b/include/openspace/documentation/verifier.h @@ -369,7 +369,13 @@ class Vector2ListVerifier : public TableVerifier { public: Vector2ListVerifier(std::string elementDocumentation = "") : TableVerifier({ - { "*", new Vector2Verifier, Optional::No, std::move(elementDocumentation) } + { + "*", + new Vector2Verifier, + Optional::No, + Private::No, + std::move(elementDocumentation) + } }) {} @@ -387,7 +393,13 @@ class Vector3ListVerifier : public TableVerifier { public: Vector3ListVerifier(std::string elementDocumentation = "") : TableVerifier({ - { "*", new Vector3Verifier, Optional::No, std::move(elementDocumentation) } + { + "*", + new Vector3Verifier, + Optional::No, + Private::No, + std::move(elementDocumentation) + } }) {} @@ -405,7 +417,13 @@ class Vector4ListVerifier : public TableVerifier { public: Vector4ListVerifier(std::string elementDocumentation = "") : TableVerifier({ - { "*", new Vector4Verifier, Optional::No, std::move(elementDocumentation) } + { + "*", + new Vector4Verifier, + Optional::No, + Private::No, + std::move(elementDocumentation) + } }) {} diff --git a/include/openspace/documentation/verifier.inl b/include/openspace/documentation/verifier.inl index dab3c5d699..ce930ff558 100644 --- a/include/openspace/documentation/verifier.inl +++ b/include/openspace/documentation/verifier.inl @@ -422,7 +422,7 @@ NotInListVerifier::NotInListVerifier(std::vector vals) template TestResult NotInListVerifier::operator()(const ghoul::Dictionary& dict, - const std::string& key) const + const std::string& key) const { TestResult res = T::operator()(dict, key); if (res.success) { @@ -686,9 +686,7 @@ std::string NotInRangeVerifier::documentation() const { template AnnotationVerifier::AnnotationVerifier(std::string a) : annotation(std::move(a)) -{ - -} +{} template std::string AnnotationVerifier::documentation() const { diff --git a/include/openspace/engine/configuration.h b/include/openspace/engine/configuration.h index 537872502e..e592a907e6 100644 --- a/include/openspace/engine/configuration.h +++ b/include/openspace/engine/configuration.h @@ -156,7 +156,7 @@ struct Configuration { // Values not read from the openspace.cfg file std::string sgctConfigNameInitialized; - static documentation::Documentation Documentation; + static documentation::Documentation Documentation(); ghoul::lua::LuaState state; }; diff --git a/include/openspace/engine/moduleengine.h b/include/openspace/engine/moduleengine.h index 0a4bee8110..ac59c614c3 100644 --- a/include/openspace/engine/moduleengine.h +++ b/include/openspace/engine/moduleengine.h @@ -39,6 +39,7 @@ namespace openspace { class OpenSpaceModule; +namespace documentation { struct Documentation; } namespace scripting { struct LuaLibrary; } /** @@ -122,6 +123,11 @@ public: */ static scripting::LuaLibrary luaLibrary(); + /** + * Returns the list of all documentations for all modules. + */ + std::vector moduleDocumentations() const; + private: /// The list of all names of all registered OpenSpaceModules properties::StringListProperty _allModules; diff --git a/include/openspace/scripting/scriptengine.h b/include/openspace/scripting/scriptengine.h index 9b721617bf..fd518684c1 100644 --- a/include/openspace/scripting/scriptengine.h +++ b/include/openspace/scripting/scriptengine.h @@ -76,7 +76,7 @@ public: /// A callback that will be called when the script finishes executing and that /// provides access to the return value of the script - Callback callback; + Callback callback = Callback(); }; static constexpr std::string_view OpenSpaceLibraryName = "openspace"; diff --git a/include/openspace/util/openspacemodule.h b/include/openspace/util/openspacemodule.h index c519481073..0a110a0ce3 100644 --- a/include/openspace/util/openspacemodule.h +++ b/include/openspace/util/openspacemodule.h @@ -92,6 +92,12 @@ public: */ virtual std::vector documentations() const; + /** + * Returns the documentation that describes the parameters that can be passed to the + * initialize function of this module. + */ + static documentation::Documentation Documentation(); + /** * Returns the Lua library with functions defined by this OpenSpaceModule. The default * implementation returns an empty library. diff --git a/modules/CMakeLists.txt b/modules/CMakeLists.txt index 0450d19af1..c9c9ee2ad3 100644 --- a/modules/CMakeLists.txt +++ b/modules/CMakeLists.txt @@ -320,6 +320,7 @@ list(REMOVE_DUPLICATES topologically_sorted) set(MODULE_HEADERS "") set(MODULE_CLASSES "") +set(MODULE_DOCUMENTATION "") foreach (key RANGE ${enabled_module_count}) list(GET topologically_sorted ${key} name) @@ -335,6 +336,7 @@ foreach (key RANGE ${enabled_module_count}) list(APPEND MODULE_HEADERS "#include <${header_filepath}>\n") list(APPEND MODULE_CLASSES " new ${class_name},\n") + list(APPEND MODULE_DOCUMENTATION " ${class_name}::Documentation(),\n") endforeach () get_unique_include_paths( @@ -359,6 +361,10 @@ if (NOT "${MODULE_CLASSES}" STREQUAL "") string(REPLACE ";" "" MODULE_CLASSES ${MODULE_CLASSES}) endif () +if (NOT "${MODULE_DOCUMENTATION}" STREQUAL "") + string(REPLACE ";" "" MODULE_DOCUMENTATION ${MODULE_DOCUMENTATION}) +endif () + configure_file( ${PROJECT_SOURCE_DIR}/support/cmake/module_registration.template ${CMAKE_BINARY_DIR}/_generated/include/openspace/moduleregistration.h diff --git a/modules/audio/audiomodule.cpp b/modules/audio/audiomodule.cpp index 6a5cb8e7d5..26f3b97030 100644 --- a/modules/audio/audiomodule.cpp +++ b/modules/audio/audiomodule.cpp @@ -47,6 +47,10 @@ namespace { namespace openspace { +documentation::Documentation AudioModule::Documentation() { + return codegen::doc("module_audio"); +} + AudioModule::AudioModule() : OpenSpaceModule(Name) , _engine(std::make_unique()) diff --git a/modules/audio/audiomodule.h b/modules/audio/audiomodule.h index 943abfe08e..752f40bb93 100644 --- a/modules/audio/audiomodule.h +++ b/modules/audio/audiomodule.h @@ -287,6 +287,8 @@ public: */ glm::vec3 speakerPosition(int channel) const; + static documentation::Documentation Documentation(); + private: struct Info { std::unique_ptr sound; diff --git a/modules/base/rendering/grids/renderableboxgrid.cpp b/modules/base/rendering/grids/renderableboxgrid.cpp index 9a9b97e75b..0a6a3956aa 100644 --- a/modules/base/rendering/grids/renderableboxgrid.cpp +++ b/modules/base/rendering/grids/renderableboxgrid.cpp @@ -163,7 +163,7 @@ void RenderableBoxGrid::deinitializeGL() { _gridProgram = nullptr; } -void RenderableBoxGrid::render(const RenderData& data, RendererTasks&){ +void RenderableBoxGrid::render(const RenderData& data, RendererTasks&) { _gridProgram->activate(); auto [modelTransform, modelViewTransform, modelViewProjectionTransform] = diff --git a/modules/base/rendering/grids/renderablegrid.cpp b/modules/base/rendering/grids/renderablegrid.cpp index 2353ef282c..dd76443cdf 100644 --- a/modules/base/rendering/grids/renderablegrid.cpp +++ b/modules/base/rendering/grids/renderablegrid.cpp @@ -237,7 +237,7 @@ void RenderableGrid::deinitializeGL() { _gridProgram = nullptr; } -void RenderableGrid::render(const RenderData& data, RendererTasks&){ +void RenderableGrid::render(const RenderData& data, RendererTasks&) { _gridProgram->activate(); const glm::dmat4 modelTransform = calcModelTransform(data); diff --git a/modules/base/rendering/grids/renderablesphericalgrid.cpp b/modules/base/rendering/grids/renderablesphericalgrid.cpp index fe7f00379e..e18afe6285 100644 --- a/modules/base/rendering/grids/renderablesphericalgrid.cpp +++ b/modules/base/rendering/grids/renderablesphericalgrid.cpp @@ -179,7 +179,7 @@ void RenderableSphericalGrid::deinitializeGL() { _gridProgram = nullptr; } -void RenderableSphericalGrid::render(const RenderData& data, RendererTasks&){ +void RenderableSphericalGrid::render(const RenderData& data, RendererTasks&) { _gridProgram->activate(); auto [modelTransform, modelViewTransform, modelViewProjectionTransform] = diff --git a/modules/base/rendering/renderablecartesianaxes.cpp b/modules/base/rendering/renderablecartesianaxes.cpp index 3f57ea0b1a..42ff5a1d3d 100644 --- a/modules/base/rendering/renderablecartesianaxes.cpp +++ b/modules/base/rendering/renderablecartesianaxes.cpp @@ -184,7 +184,7 @@ void RenderableCartesianAxes::deinitializeGL() { _program = nullptr; } -void RenderableCartesianAxes::render(const RenderData& data, RendererTasks&){ +void RenderableCartesianAxes::render(const RenderData& data, RendererTasks&) { _program->activate(); const glm::dmat4 modelViewTransform = calcModelViewTransform(data); diff --git a/modules/base/rendering/renderableplanetimevaryingimage.cpp b/modules/base/rendering/renderableplanetimevaryingimage.cpp index 1d47dadc87..63de039e02 100644 --- a/modules/base/rendering/renderableplanetimevaryingimage.cpp +++ b/modules/base/rendering/renderableplanetimevaryingimage.cpp @@ -44,14 +44,18 @@ namespace { constexpr openspace::properties::Property::PropertyInfo SourceFolderInfo = { "SourceFolder", "Source Folder", - "An image directory that is loaded from disk and contains the textures to use " - "for this plane.", + "An image directory that is loaded from disk and contains the textures to use " + "for this plane.", openspace::properties::Property::Visibility::AdvancedUser }; struct [[codegen::Dictionary(RenderablePlaneTimeVaryingImage)]] Parameters { // [[codegen::verbatim(SourceFolderInfo.description)]] std::string sourceFolder; + + // If set to `true` the images are only loaded when it is about to be shown + // instead of preloading them + std::optional lazyLoading; }; #include "renderableplanetimevaryingimage_codegen.cpp" } // namespace @@ -83,20 +87,17 @@ RenderablePlaneTimeVaryingImage::RenderablePlaneTimeVaryingImage( addProperty(_sourceFolder); _sourceFolder.onChange([this]() { _texture = loadTexture(); }); - if (dictionary.hasKey(KeyLazyLoading)) { - _isLoadingLazily = dictionary.value(KeyLazyLoading); - - if (_isLoadingLazily) { - _enabled.onChange([this]() { - if (_enabled) { - _textureIsDirty = true; - } - else { - BaseModule::TextureManager.release(_texture); - _texture = nullptr; - } - }); - } + _isLoadingLazily = p.lazyLoading.value_or(_isLoadingLazily); + if (_isLoadingLazily) { + _enabled.onChange([this]() { + if (_enabled) { + _textureIsDirty = true; + } + else { + BaseModule::TextureManager.release(_texture); + _texture = nullptr; + } + }); } } diff --git a/modules/base/rendering/renderabletrail.cpp b/modules/base/rendering/renderabletrail.cpp index 9cf7518ecd..5b073c2d75 100644 --- a/modules/base/rendering/renderabletrail.cpp +++ b/modules/base/rendering/renderabletrail.cpp @@ -219,9 +219,7 @@ RenderableTrail::RenderableTrail(const ghoul::Dictionary& dictionary) setRenderBin(RenderBin::Overlay); addProperty(Fadeable::_opacity); - _translation = Translation::createFromDictionary( - dictionary.value("Translation") - ); + _translation = Translation::createFromDictionary(p.translation); addPropertySubOwner(_translation.get()); _appearance.lineColor = p.color; diff --git a/modules/base/rendering/screenspacedashboard.cpp b/modules/base/rendering/screenspacedashboard.cpp index 736e8555be..c76b17a9e5 100644 --- a/modules/base/rendering/screenspacedashboard.cpp +++ b/modules/base/rendering/screenspacedashboard.cpp @@ -46,6 +46,8 @@ namespace { }; struct [[codegen::Dictionary(ScreenSpaceDashboard)]] Parameters { + std::optional identifier; + // [[codegen::verbatim(UseMainInfo.description)]] std::optional useMainDashboard; @@ -72,15 +74,8 @@ ScreenSpaceDashboard::ScreenSpaceDashboard(const ghoul::Dictionary& dictionary) { const Parameters p = codegen::bake(dictionary); - std::string identifier; - if (dictionary.hasValue(KeyIdentifier)) { - identifier = dictionary.value(KeyIdentifier); - } - else { - identifier = "ScreenSpaceDashboard"; - } - identifier = makeUniqueIdentifier(identifier); - setIdentifier(std::move(identifier)); + std::string identifier = p.identifier.value_or("ScreenSpaceDashboard"); + setIdentifier(makeUniqueIdentifier(std::move(identifier))); _useMainDashboard = p.useMainDashboard.value_or(_useMainDashboard); addProperty(_useMainDashboard); diff --git a/modules/base/rendering/screenspaceimagelocal.cpp b/modules/base/rendering/screenspaceimagelocal.cpp index 984433c90d..696966bbcf 100644 --- a/modules/base/rendering/screenspaceimagelocal.cpp +++ b/modules/base/rendering/screenspaceimagelocal.cpp @@ -52,6 +52,8 @@ namespace { // To load an image from a web URL, see // [ScreenSpaceImageOnline](#base_screenspace_image_online). struct [[codegen::Dictionary(ScreenSpaceImageLocal)]] Parameters { + std::optional identifier; + // [[codegen::verbatim(TexturePathInfo.description)]] std::optional texturePath; }; @@ -70,15 +72,8 @@ ScreenSpaceImageLocal::ScreenSpaceImageLocal(const ghoul::Dictionary& dictionary { const Parameters p = codegen::bake(dictionary); - std::string identifier; - if (dictionary.hasValue(KeyIdentifier)) { - identifier = dictionary.value(KeyIdentifier); - } - else { - identifier = "ScreenSpaceImageLocal"; - } - identifier = makeUniqueIdentifier(identifier); - setIdentifier(identifier); + std::string identifier = p.identifier.value_or("ScreenSpaceImageLocal"); + setIdentifier(makeUniqueIdentifier(std::move(identifier))); _texturePath.onChange([this]() { if (!std::filesystem::is_regular_file(absPath(_texturePath))) { diff --git a/modules/base/rendering/screenspaceimageonline.cpp b/modules/base/rendering/screenspaceimageonline.cpp index 1c66b733e1..48c68e4414 100644 --- a/modules/base/rendering/screenspaceimageonline.cpp +++ b/modules/base/rendering/screenspaceimageonline.cpp @@ -52,6 +52,8 @@ namespace { // To load an image from a local file on disk, see // [`ScreenSpaceImageLocal`](#base_screenspace_image_local). struct [[codegen::Dictionary(ScreenSpaceImageOnline)]] Parameters { + std::optional identifier; + // [[codegen::verbatim(TextureInfo.description)]] std::optional url [[codegen::key("URL")]]; }; @@ -71,15 +73,8 @@ ScreenSpaceImageOnline::ScreenSpaceImageOnline(const ghoul::Dictionary& dictiona { const Parameters p = codegen::bake(dictionary); - std::string identifier; - if (dictionary.hasValue(KeyIdentifier)) { - identifier = dictionary.value(KeyIdentifier); - } - else { - identifier = "ScreenSpaceImageOnline"; - } - identifier = makeUniqueIdentifier(identifier); - setIdentifier(std::move(identifier)); + std::string identifier = p.identifier.value_or("ScreenSpaceImageOnline"); + setIdentifier(makeUniqueIdentifier(std::move(identifier))); _texturePath.onChange([this]() { _textureIsDirty = true; }); _texturePath = p.url.value_or(_texturePath); diff --git a/modules/cefwebgui/cefwebguimodule.cpp b/modules/cefwebgui/cefwebguimodule.cpp index e809d47350..08d88dfc31 100644 --- a/modules/cefwebgui/cefwebguimodule.cpp +++ b/modules/cefwebgui/cefwebguimodule.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -72,10 +73,27 @@ namespace { "GUI scale multiplier.", openspace::properties::Property::Visibility::Always }; + + struct [[codegen::Dictionary(CefWebGuiModule)]] Parameters { + // [[codegen::verbatim(GuiScaleInfo.description)]] + std::optional guiScale; + + // [[codegen::verbatim(EnabledInfo.description)]] + std::optional enabled; + + // [[codegen::verbatim(VisibleInfo.description)]] + std::optional visible; + + }; +#include "cefwebguimodule_codegen.cpp" } // namespace namespace openspace { +documentation::Documentation CefWebGuiModule::Documentation() { + return codegen::doc("module_cefwebgui"); +} + CefWebGuiModule::CefWebGuiModule() : OpenSpaceModule(CefWebGuiModule::Name) , _enabled(EnabledInfo, true) @@ -200,17 +218,10 @@ void CefWebGuiModule::internalInitialize(const ghoul::Dictionary& configuration) } ); - if (configuration.hasValue(GuiScaleInfo.identifier)) { - _guiScale = static_cast( - configuration.value(GuiScaleInfo.identifier) - ); - } - - _enabled = configuration.hasValue(EnabledInfo.identifier) && - configuration.value(EnabledInfo.identifier); - - _visible = configuration.hasValue(VisibleInfo.identifier) && - configuration.value(VisibleInfo.identifier); + const Parameters p = codegen::bake(configuration); + _guiScale = p.guiScale.value_or(_guiScale); + _enabled = p.enabled.value_or(_enabled); + _visible = p.visible.value_or(_visible); global::callback::initializeGL->emplace_back([this]() { startOrStopGui(); @@ -218,7 +229,7 @@ void CefWebGuiModule::internalInitialize(const ghoul::Dictionary& configuration) global::callback::postDraw->emplace_back([this]() { bool windowChanged = global::windowDelegate->windowHasResized(); - if (_instance && (windowChanged || _instance->_shouldReshape)){ + if (_instance && (windowChanged || _instance->_shouldReshape)) { const glm::ivec2 res = global::windowDelegate->guiWindowResolution(); _instance->reshape(static_cast( glm::vec2(res) * global::windowDelegate->dpiScaling() diff --git a/modules/cefwebgui/cefwebguimodule.h b/modules/cefwebgui/cefwebguimodule.h index f2855ab2b6..0b3c18ac5a 100644 --- a/modules/cefwebgui/cefwebguimodule.h +++ b/modules/cefwebgui/cefwebguimodule.h @@ -46,6 +46,8 @@ public: void internalInitialize(const ghoul::Dictionary& configuration) override; + static documentation::Documentation Documentation(); + private: void startOrStopGui(); diff --git a/modules/debugging/rendering/debugshader_fs.glsl b/modules/debugging/rendering/debugshader_fs.glsl index a8c3532d3e..75b69e40f7 100644 --- a/modules/debugging/rendering/debugshader_fs.glsl +++ b/modules/debugging/rendering/debugshader_fs.glsl @@ -30,7 +30,7 @@ in vec4 fs_vertexPosition; uniform vec4 color; -Fragment getFragment(){ +Fragment getFragment() { Fragment frag; frag.color = color; frag.depth = fs_vertexPosition.w; diff --git a/modules/debugging/rendering/debugshader_vs.glsl b/modules/debugging/rendering/debugshader_vs.glsl index decfa49b9d..1e1475f97e 100644 --- a/modules/debugging/rendering/debugshader_vs.glsl +++ b/modules/debugging/rendering/debugshader_vs.glsl @@ -30,7 +30,7 @@ layout(location = 0) in vec4 vertexPositionClippingSpace; out vec4 fs_vertexPosition; -void main(){ +void main() { fs_vertexPosition = z_normalization(vertexPositionClippingSpace); gl_Position = fs_vertexPosition; } diff --git a/modules/exoplanets/exoplanetsmodule.cpp b/modules/exoplanets/exoplanetsmodule.cpp index 5884d7426c..f27abf7ccc 100644 --- a/modules/exoplanets/exoplanetsmodule.cpp +++ b/modules/exoplanets/exoplanetsmodule.cpp @@ -225,6 +225,10 @@ namespace openspace { using namespace exoplanets; +documentation::Documentation ExoplanetsModule::Documentation() { + return codegen::doc("module_exoplanets"); +} + ExoplanetsModule::ExoplanetsModule() : OpenSpaceModule(Name) , _enabled(EnabledInfo) diff --git a/modules/exoplanets/exoplanetsmodule.h b/modules/exoplanets/exoplanetsmodule.h index 10de1c5f77..742df53ac6 100644 --- a/modules/exoplanets/exoplanetsmodule.h +++ b/modules/exoplanets/exoplanetsmodule.h @@ -63,6 +63,7 @@ public: scripting::LuaLibrary luaLibrary() const override; std::vector documentations() const override; + static documentation::Documentation Documentation(); protected: void internalInitialize(const ghoul::Dictionary& dict) override; diff --git a/modules/fitsfilereader/src/fitsfilereader.cpp b/modules/fitsfilereader/src/fitsfilereader.cpp index 83a66404a1..7a501e93ed 100644 --- a/modules/fitsfilereader/src/fitsfilereader.cpp +++ b/modules/fitsfilereader/src/fitsfilereader.cpp @@ -81,7 +81,7 @@ std::shared_ptr> FitsFileReader::readImage(const std::filesystem::p } // Extension HDU Object return readImageInternal(_infile->currentExtension()); - } catch (const FitsException& e){ + } catch (const FitsException& e) { LERROR("Could not read FITS image from table. " + e.message()); } diff --git a/modules/gaia/rendering/renderablegaiastars.cpp b/modules/gaia/rendering/renderablegaiastars.cpp index ecb71c2a30..787e415e8f 100644 --- a/modules/gaia/rendering/renderablegaiastars.cpp +++ b/modules/gaia/rendering/renderablegaiastars.cpp @@ -406,7 +406,7 @@ namespace { std::optional lastRow; // [codegen::verbatim(ColumnNamesInfo.description)]] - std::optional> columnNames; + std::optional columnNames; // [codegen::verbatim(LodPixelThresholdInfo.description)]] std::optional lodPixelThreshold; @@ -636,9 +636,7 @@ RenderableGaiaStars::RenderableGaiaStars(const ghoul::Dictionary& dictionary) addProperty(_lastRow); if (p.columnNames.has_value()) { - const ghoul::Dictionary tmpDict = dictionary.value( - ColumnNamesInfo.identifier - ); + const ghoul::Dictionary tmpDict = *p.columnNames; // Ugly fix for ASCII sorting when there are more columns read than 10. std::set intKeys; diff --git a/modules/gaia/shaders/gaia_ssbo_vs.glsl b/modules/gaia/shaders/gaia_ssbo_vs.glsl index faa139202d..31452e772d 100644 --- a/modules/gaia/shaders/gaia_ssbo_vs.glsl +++ b/modules/gaia/shaders/gaia_ssbo_vs.glsl @@ -176,7 +176,7 @@ void main() { // Remove stars without position, happens when VBO chunk is stuffed with zeros. // Has to be done in Geometry shader because Vertices cannot be discarded here. - if (length(in_position) > EPS){ + if (length(in_position) > EPS) { vs_gPosition = vec4(model * objectPosition); gl_Position = vec4(projection * viewPosition); } diff --git a/modules/gaia/tasks/readfitstask.cpp b/modules/gaia/tasks/readfitstask.cpp index a334b62ba5..3373319766 100644 --- a/modules/gaia/tasks/readfitstask.cpp +++ b/modules/gaia/tasks/readfitstask.cpp @@ -72,7 +72,7 @@ namespace { // A list of strings with the names of all the additional columns that are to be // read from the specified FITS file(s). These columns can be used for filtering // while constructing Octree later - std::optional> filterColumnNames; + std::optional filterColumnNames; }; #include "readfitstask_codegen.cpp" } // namespace @@ -90,8 +90,7 @@ ReadFitsTask::ReadFitsTask(const ghoul::Dictionary& dictionary) { _lastRow = p.lastRow.value_or(_lastRow); if (p.filterColumnNames.has_value()) { - const ghoul::Dictionary d = - dictionary.value(KeyFilterColumnNames); + const ghoul::Dictionary d = *p.filterColumnNames; // Ugly fix for ASCII sorting when there are more columns read than 10. std::set intKeys; diff --git a/modules/galaxy/tasks/milkywayconversiontask.cpp b/modules/galaxy/tasks/milkywayconversiontask.cpp index b199db45be..707db73a0f 100644 --- a/modules/galaxy/tasks/milkywayconversiontask.cpp +++ b/modules/galaxy/tasks/milkywayconversiontask.cpp @@ -31,35 +31,31 @@ #include namespace { - constexpr std::string_view KeyInFilenamePrefix = "InFilenamePrefix"; - constexpr std::string_view KeyInFilenameSuffix = "InFilenameSuffix"; - constexpr std::string_view KeyInFirstIndex = "InFirstIndex"; - constexpr std::string_view KeyInNSlices = "InNSlices"; - constexpr std::string_view KeyOutFilename = "OutFilename"; - constexpr std::string_view KeyOutDimensions = "OutDimensions"; + struct [[codegen::Dictionary(MilkywayConversionTask)]] Parameters { + std::string inFilenamePrefix; + std::string inFilenameSuffix; + int inFirstIndex; + int inNSlices; + std::string outFilename; + glm::ivec3 outDimensions; + }; +#include "milkywayconversiontask_codegen.cpp" } // namespace namespace openspace { + +documentation::Documentation MilkywayConversionTask::Documentation() { + return codegen::doc("galaxy_milkywayconversiontask"); +} MilkywayConversionTask::MilkywayConversionTask(const ghoul::Dictionary& dictionary) { - if (dictionary.hasKey(KeyInFilenamePrefix)) { - _inFilenamePrefix = dictionary.value(KeyInFilenamePrefix); - } - if (dictionary.hasKey(KeyInFilenameSuffix)) { - _inFilenameSuffix = dictionary.value(KeyInFilenameSuffix); - } - if (dictionary.hasKey(KeyInFirstIndex)) { - _inFirstIndex = static_cast(dictionary.value(KeyInFirstIndex)); - } - if (dictionary.hasKey(KeyInNSlices)) { - _inNSlices = static_cast(dictionary.value(KeyInNSlices)); - } - if (dictionary.hasKey(KeyOutFilename)) { - _outFilename = dictionary.value(KeyOutFilename); - } - if (dictionary.hasKey(KeyOutDimensions)) { - _outDimensions = dictionary.value(KeyOutDimensions); - } + const Parameters p = codegen::bake(dictionary); + _inFilenamePrefix = p.inFilenamePrefix; + _inFilenameSuffix = p.inFilenameSuffix; + _inFirstIndex = p.inFirstIndex; + _inNSlices = p.inNSlices; + _outFilename = p.outFilename; + _outDimensions = p.outDimensions; } std::string MilkywayConversionTask::description() { @@ -99,11 +95,4 @@ void MilkywayConversionTask::perform(const Task::ProgressCallback& onProgress) { rawWriter.write(sampleFunction, onProgress); } -documentation::Documentation MilkywayConversionTask::Documentation() { - return { - "MilkywayConversionTask", - "galaxy_milkywayconversiontask" - }; -} - } // namespace openspace diff --git a/modules/globebrowsing/globebrowsingmodule.cpp b/modules/globebrowsing/globebrowsingmodule.cpp index 6a9eafccb9..bfcb5fea0e 100644 --- a/modules/globebrowsing/globebrowsingmodule.cpp +++ b/modules/globebrowsing/globebrowsingmodule.cpp @@ -197,6 +197,10 @@ namespace { namespace openspace { +documentation::Documentation GlobeBrowsingModule::Documentation() { + return codegen::doc("module_globebrowsing"); +} + GlobeBrowsingModule::GlobeBrowsingModule() : OpenSpaceModule(Name) , _tileCacheSizeMB(TileCacheSizeInfo, 1024) @@ -330,7 +334,6 @@ std::vector GlobeBrowsingModule::documentations() return { globebrowsing::Layer::Documentation(), globebrowsing::LayerAdjustment::Documentation(), - globebrowsing::LayerManager::Documentation(), globebrowsing::GlobeTranslation::Documentation(), globebrowsing::GlobeRotation::Documentation(), globebrowsing::RenderableGlobe::Documentation(), @@ -343,7 +346,6 @@ std::vector GlobeBrowsingModule::documentations() globebrowsing::TileProviderByDate::Documentation(), globebrowsing::TileProviderByIndex::Documentation(), globebrowsing::TileProviderByLevel::Documentation(), - globebrowsing::GeoJsonManager::Documentation(), globebrowsing::GeoJsonComponent::Documentation(), globebrowsing::GeoJsonProperties::Documentation(), GlobeLabelsComponent::Documentation(), diff --git a/modules/globebrowsing/globebrowsingmodule.h b/modules/globebrowsing/globebrowsingmodule.h index c6d6cf279d..691fb794f8 100644 --- a/modules/globebrowsing/globebrowsingmodule.h +++ b/modules/globebrowsing/globebrowsingmodule.h @@ -71,6 +71,7 @@ public: globebrowsing::cache::MemoryAwareTileCache* tileCache(); scripting::LuaLibrary luaLibrary() const override; std::vector documentations() const override; + static documentation::Documentation Documentation(); const globebrowsing::RenderableGlobe* castFocusNodeRenderableToGlobe(); diff --git a/modules/globebrowsing/src/geojson/geojsoncomponent.cpp b/modules/globebrowsing/src/geojson/geojsoncomponent.cpp index d9b0dc972b..4c4e282a0b 100644 --- a/modules/globebrowsing/src/geojson/geojsoncomponent.cpp +++ b/modules/globebrowsing/src/geojson/geojsoncomponent.cpp @@ -363,7 +363,7 @@ GeoJsonComponent::GeoJsonComponent(const ghoul::Dictionary& dictionary, _defaultProperties.pointTexture.onChange([this]() { const std::filesystem::path texturePath = _defaultProperties.pointTexture.value(); - // Not ethat an empty texture is also valid => use default texture from module + // Note that an empty texture is also valid => use default texture from module if (std::filesystem::is_regular_file(texturePath) || texturePath.empty()) { _textureIsDirty = true; } @@ -378,9 +378,7 @@ GeoJsonComponent::GeoJsonComponent(const ghoul::Dictionary& dictionary, _defaultProperties.tessellation.enabled.onChange([this]() { _dataIsDirty = true; }); _defaultProperties.tessellation.useLevel.onChange([this]() { _dataIsDirty = true; }); _defaultProperties.tessellation.level.onChange([this]() { _dataIsDirty = true; }); - _defaultProperties.tessellation.distance.onChange([this]() { - _dataIsDirty = true; - }); + _defaultProperties.tessellation.distance.onChange([this]() { _dataIsDirty = true; }); _forceUpdateHeightData.onChange([this]() { for (GlobeGeometryFeature& f : _geometryFeatures) { diff --git a/modules/globebrowsing/src/geojson/geojsonmanager.cpp b/modules/globebrowsing/src/geojson/geojsonmanager.cpp index c0a4c61f2a..3e15c35d6e 100644 --- a/modules/globebrowsing/src/geojson/geojsonmanager.cpp +++ b/modules/globebrowsing/src/geojson/geojsonmanager.cpp @@ -36,17 +36,6 @@ namespace { namespace openspace::globebrowsing { -documentation::Documentation GeoJsonManager::Documentation() { - using namespace documentation; - return { - "GeoJsonManager", - "globebrowsing_geojsonmanager", - "", - {} - }; -} - -// TODO: Gui name and description GeoJsonManager::GeoJsonManager() : properties::PropertyOwner({ "GeoJson" }) {} void GeoJsonManager::initialize(RenderableGlobe* globe) { @@ -75,13 +64,6 @@ void GeoJsonManager::addGeoJsonLayer(const ghoul::Dictionary& layerDict) { ZoneScoped; try { - // Parse dictionary - documentation::testSpecificationAndThrow( - GeoJsonComponent::Documentation(), - layerDict, - "GeoJsonComponent" - ); - const std::string identifier = layerDict.value("Identifier"); if (hasPropertySubOwner(identifier)) { LERROR("GeoJson layer with identifier '" + identifier + "' already exists"); diff --git a/modules/globebrowsing/src/geojson/geojsonmanager.h b/modules/globebrowsing/src/geojson/geojsonmanager.h index 84109b4361..5798161fcc 100644 --- a/modules/globebrowsing/src/geojson/geojsonmanager.h +++ b/modules/globebrowsing/src/geojson/geojsonmanager.h @@ -54,16 +54,11 @@ public: bool isReady() const; void addGeoJsonLayer(const ghoul::Dictionary& layerDict); - //void addGeoJsonLayer(const std::string& filePath); // TODO: just add from file void deleteLayer(const std::string& layerIdentifier); void update(); void render(const RenderData& data); - //void onChange(std::function callback); - - static documentation::Documentation Documentation(); - private: std::vector> _geoJsonObjects; RenderableGlobe* _parentGlobe = nullptr; diff --git a/modules/globebrowsing/src/layer.cpp b/modules/globebrowsing/src/layer.cpp index 91f263208e..9366eaca4f 100644 --- a/modules/globebrowsing/src/layer.cpp +++ b/modules/globebrowsing/src/layer.cpp @@ -44,7 +44,6 @@ namespace { constexpr std::string_view KeyName = "Name"; constexpr std::string_view KeyDesc = "Description"; constexpr std::string_view KeyLayerGroupID = "LayerGroupID"; - constexpr std::string_view KeyAdjustment = "Adjustment"; constexpr openspace::properties::Property::PropertyInfo TypeInfo = { "Type", @@ -158,25 +157,9 @@ namespace { // Specifies the render settings that should be applied to this layer std::optional settings; - struct LayerAdjustment { - enum class Type { - None, - ChromaKey, - TransferFunction - }; - - // Specifies the type of the adjustment that is applied - std::optional type; - - // Specifies the chroma key used when selecting 'ChromaKey' for the 'Type' - std::optional chromaKeyColor; - - // Specifies the tolerance to match the color to the chroma key when the - // 'ChromaKey' type is selected for the 'Type' - std::optional chromaKeyTolerance; - }; // Parameters that set individual adjustment parameters for this layer - std::optional adjustment; + std::optional adjustment + [[codegen::reference("globebrowsing_layeradjustment")]]; enum class BlendMode { Normal, @@ -211,7 +194,6 @@ Layer::Layer(layers::Group::ID id, const ghoul::Dictionary& layerDict, LayerGrou , _guiDescription(GuiDescriptionInfo) , _solidColor(ColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f)) , _layerGroupId(id) - { const Parameters p = codegen::bake(layerDict); @@ -265,10 +247,8 @@ Layer::Layer(layers::Group::ID id, const ghoul::Dictionary& layerDict, LayerGrou p.settings->multiplier.value_or(_renderSettings.multiplier); _renderSettings.offset = p.settings->offset.value_or(_renderSettings.offset); } - if (layerDict.hasValue(KeyAdjustment)) { - _layerAdjustment.setValuesFromDictionary( - layerDict.value(KeyAdjustment) - ); + if (p.adjustment.has_value()) { + _layerAdjustment.setValuesFromDictionary(*p.adjustment); } // Add options to option properties @@ -530,7 +510,7 @@ void Layer::initializeBasedOnType(layers::Layer::ID id, ghoul::Dictionary initDi const std::string name = initDict.value(KeyName); LDEBUG("Initializing tile provider for layer: '" + name + "'"); } - _tileProvider = TileProvider::createFromDictionary(id, initDict); + _tileProvider = TileProvider::createFromDictionary(initDict); break; case layers::Layer::ID::SolidColor: if (initDict.hasValue(ColorInfo.identifier)) { @@ -541,7 +521,7 @@ void Layer::initializeBasedOnType(layers::Layer::ID id, ghoul::Dictionary initDi } void Layer::addVisibleProperties() { - switch (type()) { + switch (_typeId) { // Intentional fall through. Same for all tile layers case layers::Layer::ID::DefaultTileProvider: case layers::Layer::ID::SingleImageProvider: diff --git a/modules/globebrowsing/src/layeradjustment.cpp b/modules/globebrowsing/src/layeradjustment.cpp index d46d0eb495..e453f74d03 100644 --- a/modules/globebrowsing/src/layeradjustment.cpp +++ b/modules/globebrowsing/src/layeradjustment.cpp @@ -138,7 +138,7 @@ layers::Adjustment::ID LayerAdjustment::type() const { } void LayerAdjustment::addVisibleProperties() { - switch (type()) { + switch (_typeId) { case layers::Adjustment::ID::None: break; case layers::Adjustment::ID::ChromaKey: diff --git a/modules/globebrowsing/src/layergroup.cpp b/modules/globebrowsing/src/layergroup.cpp index 7d4d4aa64d..cc43c14119 100644 --- a/modules/globebrowsing/src/layergroup.cpp +++ b/modules/globebrowsing/src/layergroup.cpp @@ -57,19 +57,6 @@ LayerGroup::LayerGroup(layers::Group group) addProperty(_levelBlendingEnabled); } -void LayerGroup::setLayersFromDict(const ghoul::Dictionary& dict) { - for (size_t i = 1; i <= dict.size(); i++) { - const ghoul::Dictionary layer = dict.value(std::to_string(i)); - - try { - addLayer(layer); - } - catch (const ghoul::RuntimeError& e) { - LERRORC(e.component, e.message); - } - } -} - void LayerGroup::initialize() { ZoneScoped; diff --git a/modules/globebrowsing/src/layergroup.h b/modules/globebrowsing/src/layergroup.h index 1844178662..013cc07d67 100644 --- a/modules/globebrowsing/src/layergroup.h +++ b/modules/globebrowsing/src/layergroup.h @@ -41,8 +41,6 @@ struct TileProvider; struct LayerGroup : public properties::PropertyOwner { LayerGroup(layers::Group group); - void setLayersFromDict(const ghoul::Dictionary& dict); - void initialize(); void deinitialize(); diff --git a/modules/globebrowsing/src/layermanager.cpp b/modules/globebrowsing/src/layermanager.cpp index 3c088952fc..145d89f9e7 100644 --- a/modules/globebrowsing/src/layermanager.cpp +++ b/modules/globebrowsing/src/layermanager.cpp @@ -35,54 +35,38 @@ namespace openspace::globebrowsing { -documentation::Documentation LayerManager::Documentation() { - using namespace documentation; - return { - "LayerManager", - "globebrowsing_layermanager", - "", - { - { - "*", - new ReferencingVerifier("globebrowsing_layer"), - Optional::Yes, - "Specifies an individual layer" - } - } - }; -} - LayerManager::LayerManager() : properties::PropertyOwner({ "Layers" }) {} -void LayerManager::initialize(const ghoul::Dictionary& layerGroupsDict) { +void LayerManager::initialize(const std::map& dict) +{ ZoneScoped; // First create empty layer groups in case not all are specified for (size_t i = 0; i < _layerGroups.size(); i++) { _layerGroups[i] = std::make_unique(layers::Groups[i]); - } - - // Create all the layer groups - for (std::string_view group : layerGroupsDict.keys()) { - using namespace layers; - const Group::ID id = ghoul::from_string(group); - - if (id != Group::ID::Unknown) { - const ghoul::Dictionary d = layerGroupsDict.value(group); - _layerGroups[static_cast(id)]->setLayersFromDict(d); + addPropertySubOwner(_layerGroups[i].get()); + _layerGroups[i]->initialize(); + auto it = dict.find(layers::Groups[i].id); + if (!dict.empty() && it == dict.end()) { + LWARNINGC( + "LayerManager", + std::format("Unknown layer group '{}'", layers::Groups[i].identifier) + ); + continue; } - else { - LWARNINGC("LayerManager", std::format("Unknown layer group '{}'", group)); + + for (size_t j = 1; j <= dict.size(); j++) { + const ghoul::Dictionary layer = + it->second.value(std::to_string(j)); + + try { + _layerGroups[i]->addLayer(layer); + } + catch (const ghoul::RuntimeError& e) { + LERRORC(e.component, e.message); + } } } - - for (const std::unique_ptr& layerGroup : _layerGroups) { - addPropertySubOwner(layerGroup.get()); - } - - for (const std::unique_ptr& lg : _layerGroups) { - lg->initialize(); - } } void LayerManager::deinitialize() { diff --git a/modules/globebrowsing/src/layermanager.h b/modules/globebrowsing/src/layermanager.h index f55341c610..f76b0a7321 100644 --- a/modules/globebrowsing/src/layermanager.h +++ b/modules/globebrowsing/src/layermanager.h @@ -52,7 +52,7 @@ public: LayerManager(); - void initialize(const ghoul::Dictionary& layerGroupsDict); + void initialize(const std::map& dict); void deinitialize(); Layer* addLayer(layers::Group::ID id, const ghoul::Dictionary& layerDict); @@ -70,8 +70,6 @@ public: void onChange(const std::function& callback); - static documentation::Documentation Documentation(); - private: std::array, NumLayerGroups> _layerGroups; }; diff --git a/modules/globebrowsing/src/renderableglobe.cpp b/modules/globebrowsing/src/renderableglobe.cpp index ea02c0f744..1d5cd71e9d 100644 --- a/modules/globebrowsing/src/renderableglobe.cpp +++ b/modules/globebrowsing/src/renderableglobe.cpp @@ -294,9 +294,17 @@ namespace { // [[codegen::verbatim(OrenNayarRoughnessInfo.description)]] std::optional orenNayarRoughness; + enum class [[codegen::map(openspace::globebrowsing::layers::Group::ID)]] Group { + HeightLayers, + ColorLayers, + Overlays, + NightLayers, + WaterMasks, + }; + // A list of layers that should be added to the globe. - std::optional> layers - [[codegen::reference("globebrowsing_layermanager")]]; + std::optional> layers + [[codegen::reference("globebrowsing_layer")]]; // Specifies information about planetary labels that can be rendered on the // object's surface. @@ -636,16 +644,13 @@ RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary) setInteractionSphere(boundingSphere()); // Init layer manager - // @TODO (abock, 2021-03-25) The layermanager should be changed to take a - // std::map instead and then we don't need to get it - // as a bare dictionary anymore and can use the value from the struct directly - if (dictionary.hasValue("Layers")) { - const ghoul::Dictionary dict = dictionary.value("Layers"); - _layerManager.initialize(dict); - } - else { - _layerManager.initialize(ghoul::Dictionary()); + std::map layers; + if (p.layers.has_value()) { + for (const auto& [key, value] : *p.layers) { + layers[codegen::map(key)] = value; + } } + _layerManager.initialize(layers); addProperty(Fadeable::_opacity); @@ -764,14 +769,14 @@ RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary) // Components if (p.rings.has_value()) { - _ringsComponent = std::make_unique(dictionary); + _ringsComponent = std::make_unique(*p.rings); _ringsComponent->setParentFadeable(this); _ringsComponent->initialize(); addPropertySubOwner(_ringsComponent.get()); } if (p.shadows.has_value()) { - _shadowComponent = std::make_unique(dictionary); + _shadowComponent = std::make_unique(*p.shadows); _shadowComponent->initialize(); addPropertySubOwner(_shadowComponent.get()); _shadowMappingProperties.shadowMapping = true; diff --git a/modules/globebrowsing/src/ringscomponent.cpp b/modules/globebrowsing/src/ringscomponent.cpp index c075f1dec0..c0d28d6ebc 100644 --- a/modules/globebrowsing/src/ringscomponent.cpp +++ b/modules/globebrowsing/src/ringscomponent.cpp @@ -223,29 +223,17 @@ RingsComponent::RingsComponent(const ghoul::Dictionary& dictionary) , _nightFactor(NightFactorInfo, 0.33f, 0.f, 1.f) , _colorFilter(ColorFilterInfo, 0.15f, 0.f, 1.f) , _enabled(EnabledInfo, true) - , _zFightingPercentage(ZFightingPercentageInfo, 0.995f, 0.000001f, 1.f) + , _zFightingPercentage(ZFightingPercentageInfo, 0.95f, 0.000001f, 1.f) , _nShadowSamples(NumberShadowSamplesInfo, 2, 1, 7) + // @TODO (abock, 2019-12-16) It would be better to not store the dictionary long + // term and rather extract the values directly here. This would require a bit of + // a rewrite in the RenderableGlobe class to not create the RingsComponent in the + // class-initializer list though + // @TODO (abock, 2021-03-25) Righto! The RenderableGlobe passes this dictionary + // in as-is so it would be easy to just pass it directly to the initialize method + // instead , _ringsDictionary(dictionary) -{ - using ghoul::filesystem::File; - - if (dictionary.hasValue("Rings")) { - // @TODO (abock, 2019-12-16) It would be better to not store the dictionary long - // term and rather extract the values directly here. This would require a bit of - // a rewrite in the RenderableGlobe class to not create the RingsComponent in the - // class-initializer list though - // @TODO (abock, 2021-03-25) Righto! The RenderableGlobe passes this dictionary - // in as-is so it would be easy to just pass it directly to the initialize method - // instead - _ringsDictionary = dictionary.value("Rings"); - - documentation::testSpecificationAndThrow( - Documentation(), - _ringsDictionary, - "RingsComponent" - ); - } -} +{} void RingsComponent::initialize() { ZoneScoped; diff --git a/modules/globebrowsing/src/shadowcomponent.cpp b/modules/globebrowsing/src/shadowcomponent.cpp index c43c4cc9f4..30aeca2994 100644 --- a/modules/globebrowsing/src/shadowcomponent.cpp +++ b/modules/globebrowsing/src/shadowcomponent.cpp @@ -186,12 +186,7 @@ ShadowComponent::ShadowComponent(const ghoul::Dictionary& dictionary) // coded into the RenderableGlobe. Instead, the parent should unpack the dictionary // and pass the unpacked dictionary in here; Or maybe we don't want a dictionary at // this state anyway? - if (!dictionary.hasValue("Shadows")) { - return; - } - const ghoul::Dictionary d = dictionary.value("Shadows"); - - const Parameters p = codegen::bake(d); + const Parameters p = codegen::bake(dictionary); addProperty(_enabled); diff --git a/modules/globebrowsing/src/tileprovider/tileprovider.cpp b/modules/globebrowsing/src/tileprovider/tileprovider.cpp index d6af722e30..8cefb2f406 100644 --- a/modules/globebrowsing/src/tileprovider/tileprovider.cpp +++ b/modules/globebrowsing/src/tileprovider/tileprovider.cpp @@ -70,11 +70,16 @@ Tile DefaultTile = Tile { nullptr, std::nullopt, Tile::Status::Unavailable }; unsigned int TileProvider::NumTileProviders = 0; std::unique_ptr TileProvider::createFromDictionary( - layers::Layer::ID layerTypeID, const ghoul::Dictionary& dictionary) { ZoneScoped; + layers::Layer::ID layerTypeID = layers::Layer::ID::DefaultTileProvider; + if (dictionary.hasValue("Type")) { + const std::string type = dictionary.value("Type"); + layerTypeID = ghoul::from_string(type); + } + const std::string_view type = layers::Layers[static_cast(layerTypeID)].identifier; diff --git a/modules/globebrowsing/src/tileprovider/tileprovider.h b/modules/globebrowsing/src/tileprovider/tileprovider.h index 5712353df5..520d3054c7 100644 --- a/modules/globebrowsing/src/tileprovider/tileprovider.h +++ b/modules/globebrowsing/src/tileprovider/tileprovider.h @@ -75,7 +75,7 @@ struct TileProvider : public properties::PropertyOwner { static unsigned int NumTileProviders; static std::unique_ptr createFromDictionary( - layers::Layer::ID layerTypeID, const ghoul::Dictionary& dictionary); + const ghoul::Dictionary& dictionary); static void initializeDefaultTile(); static void deinitializeDefaultTile(); diff --git a/modules/globebrowsing/src/tileprovider/tileproviderbydate.cpp b/modules/globebrowsing/src/tileprovider/tileproviderbydate.cpp index 968f51bb1f..71b7d296a8 100644 --- a/modules/globebrowsing/src/tileprovider/tileproviderbydate.cpp +++ b/modules/globebrowsing/src/tileprovider/tileproviderbydate.cpp @@ -32,6 +32,12 @@ namespace { struct [[codegen::Dictionary(TileProviderByDate)]] Parameters { + // The layer needs to know about the LayerGroupID this but we don't want it to be + // part of the parameters struct as that would mean it would be visible to the end + // user, which we don't want since this value just comes from whoever creates it, + // not the user. + int layerGroupID [[codegen::private()]]; + // Specifies the list of tile providers and for which times they are used for. The // tile provider with the earliest time will be used for all dates prior to that // date and the provider with the latest time will be used for all dates @@ -53,16 +59,8 @@ TileProviderByDate::TileProviderByDate(const ghoul::Dictionary& dictionary) { Parameters p = codegen::bake(dictionary); - // For now we need to inject the LayerGroupID this way. We don't want it to be part of - // the parameters struct as that would mean it would be visible to the end user, which - // we don't want since this value just comes from whoever creates it, not the user - ghoul_assert(dictionary.hasValue("LayerGroupID"), "No Layer Group ID provided"); - const layers::Group::ID group = static_cast( - dictionary.value("LayerGroupID") - ); - for (std::pair& prov : p.providers) { - prov.second.setValue("LayerGroupID", static_cast(group)); + prov.second.setValue("LayerGroupID", p.layerGroupID); // Pass down the caching information from the enclosing dictionary if (dictionary.hasValue("GlobeName")) { @@ -70,12 +68,7 @@ TileProviderByDate::TileProviderByDate(const ghoul::Dictionary& dictionary) { } layers::Layer::ID typeID = layers::Layer::ID::DefaultTileProvider; - if (prov.second.hasValue("Type")) { - const std::string type = prov.second.value("Type"); - typeID = ghoul::from_string(type); - } - - std::unique_ptr tp = createFromDictionary(typeID, prov.second); + std::unique_ptr tp = createFromDictionary(prov.second); const std::string provId = prov.second.value("Identifier"); tp->setIdentifier(provId); const std::string providerName = prov.second.value("Name"); diff --git a/modules/globebrowsing/src/tileprovider/tileproviderbyindex.cpp b/modules/globebrowsing/src/tileprovider/tileproviderbyindex.cpp index 50caabde7f..2b95e8c1de 100644 --- a/modules/globebrowsing/src/tileprovider/tileproviderbyindex.cpp +++ b/modules/globebrowsing/src/tileprovider/tileproviderbyindex.cpp @@ -71,6 +71,12 @@ namespace { // The list of all TileProviders and the indices at which they are used. std::vector tileProviders; + + // The layer needs to know about the LayerGroupID this but we don't want it to be + // part of the parameters struct as that would mean it would be visible to the end + // user, which we don't want since this value just comes from whoever creates it, + // not the user. + int layerGroupID [[codegen::private()]]; }; #include "tileproviderbyindex_codegen.cpp" } // namespace @@ -86,22 +92,8 @@ TileProviderByIndex::TileProviderByIndex(const ghoul::Dictionary& dictionary) { Parameters p = codegen::bake(dictionary); - // For now we need to inject the LayerGroupID this way. We don't want it to be part of - // the parameters struct as that would mean it would be visible to the end user, which - // we don't want since this value just comes from whoever creates it, not the user - ghoul_assert(dictionary.hasValue("LayerGroupID"), "No Layer Group ID provided"); - const layers::Group::ID group = static_cast( - dictionary.value("LayerGroupID") - ); - - layers::Layer::ID typeID = layers::Layer::ID::DefaultTileProvider; - if (p.defaultTileProvider.hasValue("Type")) { - const std::string type = p.defaultTileProvider.value("Type"); - typeID = ghoul::from_string(type); - } - - p.defaultTileProvider.setValue("LayerGroupID", static_cast(group)); - _defaultTileProvider = createFromDictionary(typeID, p.defaultTileProvider); + p.defaultTileProvider.setValue("LayerGroupID", p.layerGroupID); + _defaultTileProvider = createFromDictionary(p.defaultTileProvider); for (Parameters::IndexProvider& ip : p.tileProviders) { const TileIndex tileIndex = TileIndex( @@ -110,17 +102,9 @@ TileProviderByIndex::TileProviderByIndex(const ghoul::Dictionary& dictionary) { static_cast(ip.index.level) ); - layers::Layer::ID providerID = layers::Layer::ID::DefaultTileProvider; - if (ip.tileProvider.hasValue("Type")) { - const std::string type = ip.tileProvider.value("Type"); - providerID = ghoul::from_string(type); - } - ip.tileProvider.setValue("LayerGroupID", static_cast(group)); - std::unique_ptr stp = createFromDictionary( - providerID, - ip.tileProvider - ); + ip.tileProvider.setValue("LayerGroupID", p.layerGroupID); + std::unique_ptr stp = createFromDictionary(ip.tileProvider); const TileIndex::TileHashKey key = tileIndex.hashKey(); _providers.emplace(key, std::move(stp)); } diff --git a/modules/globebrowsing/src/tileprovider/tileproviderbylevel.cpp b/modules/globebrowsing/src/tileprovider/tileproviderbylevel.cpp index 6abd4830e7..4bf86c241d 100644 --- a/modules/globebrowsing/src/tileprovider/tileproviderbylevel.cpp +++ b/modules/globebrowsing/src/tileprovider/tileproviderbylevel.cpp @@ -50,6 +50,12 @@ namespace { // The list of all tile providers that are used by this TileProviderByLevel. std::vector levelTileProviders; + + // The layer needs to know about the LayerGroupID this but we don't want it to be + // part of the parameters struct as that would mean it would be visible to the end + // user, which we don't want since this value just comes from whoever creates it, + // not the user. + int layerGroupID [[codegen::private()]]; }; #include "tileproviderbylevel_codegen.cpp" } // namespace @@ -65,17 +71,9 @@ TileProviderByLevel::TileProviderByLevel(const ghoul::Dictionary& dictionary) { const Parameters p = codegen::bake(dictionary); - // For now we need to inject the LayerGroupID this way. We don't want it to be part of - // the parameters struct as that would mean it would be visible to the end user, which - // we don't want since this value just comes from whoever creates it, not the user - ghoul_assert(dictionary.hasValue("LayerGroupID"), "No Layer Group ID provided"); - const layers::Group::ID group = static_cast( - dictionary.value("LayerGroupID") - ); - for (Parameters::Provider provider : p.levelTileProviders) { ghoul::Dictionary& tileProviderDict = provider.tileProvider; - tileProviderDict.setValue("LayerGroupID", static_cast(group)); + tileProviderDict.setValue("LayerGroupID", p.layerGroupID); // Pass down the caching information from the enclosing dictionary if (dictionary.hasValue("GlobeName")) { @@ -84,13 +82,8 @@ TileProviderByLevel::TileProviderByLevel(const ghoul::Dictionary& dictionary) { dictionary.value("GlobeName") ); } - layers::Layer::ID typeID = layers::Layer::ID::DefaultTileProvider; - if (tileProviderDict.hasValue("Type")) { - const std::string type = tileProviderDict.value("Type"); - typeID = ghoul::from_string(type); - } - std::unique_ptr tp = createFromDictionary(typeID, tileProviderDict); + std::unique_ptr tp = createFromDictionary(tileProviderDict); const std::string provId = tileProviderDict.value("Identifier"); tp->setIdentifier(provId); diff --git a/modules/imgui/src/guispacetimecomponent.cpp b/modules/imgui/src/guispacetimecomponent.cpp index e8ff797daf..27c2ca29bf 100644 --- a/modules/imgui/src/guispacetimecomponent.cpp +++ b/modules/imgui/src/guispacetimecomponent.cpp @@ -420,12 +420,9 @@ void GuiSpaceTimeComponent::render() { if (_slidingDelta != 0.f) { // No sync or send because time settings are always synced and sent // to the connected nodes and peers - const std::string script = std::format( + global::scriptEngine->queueScript(std::format( "openspace.time.setDeltaTime({})", _oldDeltaTime - ); - - using Script = scripting::ScriptEngine::Script; - global::scriptEngine->queueScript(script); + )); } _slidingDelta = 0.f; diff --git a/modules/iswa/rendering/dataplane.cpp b/modules/iswa/rendering/dataplane.cpp index 89ac02d673..b16f3ee076 100644 --- a/modules/iswa/rendering/dataplane.cpp +++ b/modules/iswa/rendering/dataplane.cpp @@ -144,7 +144,7 @@ void DataPlane::setUniforms() { _shader->setUniform("transparency", _alpha); } -std::vector DataPlane::textureData(){ +std::vector DataPlane::textureData() { // if the buffer in the datafile is empty, do not proceed if (_dataBuffer.empty()) { return std::vector(); diff --git a/modules/iswa/rendering/iswacygnet.cpp b/modules/iswa/rendering/iswacygnet.cpp index 565267dba4..c2372a1619 100644 --- a/modules/iswa/rendering/iswacygnet.cpp +++ b/modules/iswa/rendering/iswacygnet.cpp @@ -172,8 +172,8 @@ void IswaCygnet::render(const RenderData& data, RendererTasks&) { } glm::mat4 transform = glm::mat4(1.f); - for (int i = 0; i < 3; i++){ - for (int j = 0; j < 3; j++){ + for (int i = 0; i < 3; i++) { + for (int j = 0; j < 3; j++) { transform[i][j] = static_cast(_stateMatrix[i][j]); } } diff --git a/modules/iswa/util/iswamanager.cpp b/modules/iswa/util/iswamanager.cpp index 47c0fe9a45..3016fc33d8 100644 --- a/modules/iswa/util/iswamanager.cpp +++ b/modules/iswa/util/iswamanager.cpp @@ -553,7 +553,7 @@ void IswaManager::createSphere(MetadataFuture& data) { // check if this sphere already exist std::string name = _type[data.type] + _geom[data.geom] + std::to_string(data.id); - if (!data.group.empty()){ + if (!data.group.empty()) { std::string type = typeid(DataSphere).name(); registerGroup(data.group, type); @@ -693,7 +693,7 @@ void IswaManager::addCdfFiles(std::string cdfpath) { if (jsonFile.is_open()) { nlohmann::json cdfGroups = nlohmann::json::parse(jsonFile); - for(size_t i = 0; i < cdfGroups.size(); i++) { + for (size_t i = 0; i < cdfGroups.size(); i++) { nlohmann::json cdfGroup = cdfGroups.at(i); std::string groupName = cdfGroup["group"]; diff --git a/modules/kameleon/ext/kameleon b/modules/kameleon/ext/kameleon index 18aa3fdd93..33ae5e637d 160000 --- a/modules/kameleon/ext/kameleon +++ b/modules/kameleon/ext/kameleon @@ -1 +1 @@ -Subproject commit 18aa3fdd932e5a4a8e6cd9725b88acaa1fdafb49 +Subproject commit 33ae5e637dc95437458c667817e93ef5411c9be1 diff --git a/modules/kameleon/src/kameleonhelper.cpp b/modules/kameleon/src/kameleonhelper.cpp index 237e1c7fea..041ee36056 100644 --- a/modules/kameleon/src/kameleonhelper.cpp +++ b/modules/kameleon/src/kameleonhelper.cpp @@ -78,7 +78,7 @@ double getTime(ccmc::Kameleon* kameleon, double manualOffset) { // redundant! std::string seqStartStr; - if (kameleon->doesAttributeExist("start_time")){ + if (kameleon->doesAttributeExist("start_time")) { seqStartStr = kameleon->getGlobalAttribute("start_time").getAttributeString(); } diff --git a/modules/kameleon/src/kameleonwrapper.cpp b/modules/kameleon/src/kameleonwrapper.cpp index c103d86625..7d56a9c57c 100644 --- a/modules/kameleon/src/kameleonwrapper.cpp +++ b/modules/kameleon/src/kameleonwrapper.cpp @@ -303,7 +303,7 @@ float* KameleonWrapper::uniformSampledValues(const std::string& var, const double dist = ((varMax - varMin) / NBins) * stop; const double varMaxNew = varMin + dist; - for(size_t i = 0; i < size; i++) { + for (size_t i = 0; i < size; i++) { const double normalizedVal = (doubleData[i] - varMin) / (varMaxNew - varMin); data[i] = static_cast(glm::clamp(normalizedVal, 0.0, 1.0)); @@ -362,7 +362,7 @@ float* KameleonWrapper::uniformSliceValues(const std::string& var, for (size_t x = 0; x < outDimensions.x; ++x) { for (size_t y = 0; y < outDimensions.y; ++y) { - for(size_t z = 0; z < outDimensions.z; ++z){ + for (size_t z = 0; z < outDimensions.z; ++z) { const float xi = (hasXSlice) ? slice : x; const float yi = (hasYSlice) ? slice : y; diff --git a/modules/kameleonvolume/rendering/renderablekameleonvolume.cpp b/modules/kameleonvolume/rendering/renderablekameleonvolume.cpp index 5ee8b4e9b4..fed8680c63 100644 --- a/modules/kameleonvolume/rendering/renderablekameleonvolume.cpp +++ b/modules/kameleonvolume/rendering/renderablekameleonvolume.cpp @@ -27,7 +27,6 @@ #include #include #include -#include #include #include #include @@ -37,8 +36,10 @@ #include #include #include +#include #include #include +#include #include #include #include @@ -50,21 +51,6 @@ namespace { constexpr std::string_view _loggerCat = "RenderableKameleonVolume"; - constexpr std::string_view KeyDimensions = "Dimensions"; - constexpr std::string_view KeyStepSize = "StepSize"; - constexpr std::string_view KeyTransferFunction = "TransferFunction"; - constexpr std::string_view KeySource = "Source"; - constexpr std::string_view KeyVariable = "Variable"; - constexpr std::string_view KeyLowerDomainBound = "LowerDomainBound"; - constexpr std::string_view KeyUpperDomainBound = "UpperDomainBound"; - constexpr std::string_view KeyDomainScale = "DomainScale"; - constexpr std::string_view KeyLowerValueBound = "LowerValueBound"; - constexpr std::string_view KeyUpperValueBound = "UpperValueBound"; - constexpr std::string_view KeyClipPlanes = "ClipPlanes"; - constexpr std::string_view KeyCache = "Cache"; - constexpr std::string_view KeyGridType = "GridType"; - constexpr std::string_view ValueSphericalGridType = "Spherical"; - constexpr openspace::properties::Property::PropertyInfo DimensionsInfo = { "Dimensions", "Dimensions", @@ -148,6 +134,50 @@ namespace { "", // @TODO Missing documentation openspace::properties::Property::Visibility::Developer }; + + struct [[codegen::Dictionary(RenderableKameleonVolume)]] Parameters { + // [[codegen::verbatim(DimensionsInfo.description)]] + glm::ivec3 dimensions [[codegen::greater(glm::ivec3(0))]]; + + // [[codegen::verbatim(StepSizeInfo.description)]] + float stepSize; + + // [[codegen::verbatim(TransferFunctionInfo.description)]] + std::optional transferFunction; + + // [[codegen::verbatim(SourcePathInfo.description)]] + std::optional source; + + // [[codegen::verbatim(VariableInfo.description)]] + std::optional variable; + + // [[codegen::verbatim(LowerDomainBoundInfo.description)]] + std::optional lowerDomainBound; + + // [[codegen::verbatim(UpperDomainBoundInfo.description)]] + std::optional upperDomainBound; + + // [[codegen::verbatim(DomainScaleInfo.description)]] + std::optional domainScale; + + // [[codegen::verbatim(LowerValueBoundInfo.description)]] + std::optional lowerValueBound; + + // [[codegen::verbatim(UpperValueBoundInfo.description)]] + std::optional upperValueBound; + + std::optional clipPlanes; + + // [[codegen::verbatim(CacheInfo.description)]] + std::optional cache; + + enum class GridType { + Cartesian, + Spherical + }; + std::optional gridType; + }; +#include "renderablekameleonvolume_codegen.cpp" } // namespace namespace openspace::kameleonvolume { @@ -167,78 +197,42 @@ RenderableKameleonVolume::RenderableKameleonVolume(const ghoul::Dictionary& dict , _transferFunctionPath(TransferFunctionInfo) , _cache(CacheInfo) { - if (dictionary.hasValue(KeyDimensions)) { - _dimensions = dictionary.value(KeyDimensions); - } - else { - LWARNING("No dimensions specified for volumetric data, falling back to 32^3"); - _dimensions = glm::uvec3(32); - } + const Parameters p = codegen::bake(dictionary); - _stepSize = static_cast(dictionary.value(KeyStepSize)); + _dimensions = p.dimensions; + _stepSize = p.stepSize; - if (dictionary.hasValue(KeyTransferFunction)) { - _transferFunctionPath = dictionary.value(KeyTransferFunction); + if (p.transferFunction.has_value()) { + _transferFunctionPath = p.transferFunction->string(); _transferFunction = std::make_shared( _transferFunctionPath.value() ); } - if (dictionary.hasValue(KeySource)) { - _sourcePath = absPath(dictionary.value(KeySource)).string(); + if (p.source.has_value()) { + _sourcePath = p.source->string(); } - if (dictionary.hasValue(KeyVariable)) { - _variable = dictionary.value(KeyVariable); - } + _variable = p.variable.value_or(_variable); + _lowerDomainBound = p.lowerDomainBound.value_or(_lowerDomainBound); + _upperDomainBound = p.upperDomainBound.value_or(_upperDomainBound); + _autoDomainBounds = + !p.lowerDomainBound.has_value() || !p.upperDomainBound.has_value(); - if (dictionary.hasValue(KeyLowerDomainBound)) { - _lowerDomainBound = dictionary.value(KeyLowerDomainBound); - } - else { - _autoDomainBounds = true; - } + _domainScale = p.domainScale.value_or(_domainScale); - if (dictionary.hasValue(KeyUpperDomainBound)) { - _upperDomainBound = dictionary.value(KeyUpperDomainBound); - } - else { - _autoDomainBounds = true; - } + _lowerValueBound = p.lowerValueBound.value_or(_lowerValueBound); + _upperValueBound = p.upperValueBound.value_or(_upperValueBound); + _autoValueBounds = !p.lowerValueBound.has_value() || !p.upperValueBound.has_value(); - if (dictionary.hasValue(KeyDomainScale)) { - _domainScale = dictionary.value(KeyDomainScale); - } - if (dictionary.hasValue(KeyLowerValueBound)) { - _lowerValueBound = static_cast( - dictionary.value(KeyLowerValueBound) - ); - } - else { - _autoValueBounds = true; - } - - if (dictionary.hasValue(KeyUpperValueBound)) { - _upperValueBound = static_cast( - dictionary.value(KeyUpperValueBound) - ); - } - else { - _autoValueBounds = true; - } - - ghoul::Dictionary clipPlanesDictionary; - if (dictionary.hasValue(KeyClipPlanes)) { - clipPlanesDictionary = dictionary.value(KeyClipPlanes); - } - _clipPlanes = std::make_shared(clipPlanesDictionary); + _clipPlanes = std::make_shared( + p.clipPlanes.value_or(ghoul::Dictionary()) + ); _clipPlanes->setIdentifier("clipPlanes"); _clipPlanes->setGuiName("Clip Planes"); - if (dictionary.hasValue(KeyCache)) { - _cache = dictionary.value(KeyCache); - } + _cache = p.cache.value_or(_cache); _gridType.addOption( static_cast(volume::VolumeGridType::Cartesian), @@ -248,17 +242,17 @@ RenderableKameleonVolume::RenderableKameleonVolume(const ghoul::Dictionary& dict static_cast(volume::VolumeGridType::Spherical), "Spherical grid" ); - _gridType.setValue(static_cast(volume::VolumeGridType::Cartesian)); - if (dictionary.hasValue(KeyGridType)) { - const std::string& gridType = dictionary.value(KeyGridType); - if (gridType == ValueSphericalGridType) { + Parameters::GridType type = p.gridType.value_or(Parameters::GridType::Cartesian); + switch (type) { + case Parameters::GridType::Cartesian: + _gridType.setValue(static_cast(volume::VolumeGridType::Cartesian)); + break; + case Parameters::GridType::Spherical: _gridType.setValue(static_cast(volume::VolumeGridType::Spherical)); - } - else { - _autoGridType = true; - } + break; } + _autoGridType = !p.gridType.has_value(); } RenderableKameleonVolume::~RenderableKameleonVolume() {} diff --git a/modules/multiresvolume/rendering/renderablemultiresvolume.cpp b/modules/multiresvolume/rendering/renderablemultiresvolume.cpp index 3f8ee49dfa..1980a4dac8 100644 --- a/modules/multiresvolume/rendering/renderablemultiresvolume.cpp +++ b/modules/multiresvolume/rendering/renderablemultiresvolume.cpp @@ -35,6 +35,7 @@ #include #include #include +#include #include #include #include @@ -60,13 +61,6 @@ namespace { constexpr std::string_view _loggerCat = "RenderableMultiresVolume"; - constexpr std::string_view KeyDataSource = "Source"; - constexpr std::string_view KeyErrorHistogramsSource = "ErrorHistogramsSource"; - constexpr std::string_view KeyTransferFunction = "TransferFunction"; - - constexpr std::string_view KeyBrickSelector = "BrickSelector"; - constexpr std::string_view KeyStartTime = "StartTime"; - constexpr std::string_view KeyEndTime = "EndTime"; constexpr openspace::properties::Property::PropertyInfo StepSizeCoefficientInfo = { "StepSizeCoefficient", @@ -158,6 +152,24 @@ namespace { "", // @TODO Missing documentation openspace::properties::Property::Visibility::Developer }; + + struct [[codegen::Dictionary(RenderableMultiresVolume)]] Parameters { + std::filesystem::path source; + std::optional errorHistogramsSource; + std::optional scalingExponent; + std::optional stepSizeCoefficient; + std::optional scaling; + std::optional translation; + std::optional rotation; + + std::optional startTime; + std::optional endTime; + + std::filesystem::path transferFunction; + + std::optional brickSelector; + }; +#include "renderablemultiresvolume_codegen.cpp" } // namespace namespace openspace { @@ -183,49 +195,19 @@ RenderableMultiresVolume::RenderableMultiresVolume(const ghoul::Dictionary& dict ) , _scaling(ScalingInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(10.f)) { - if (dictionary.hasValue(KeyDataSource)) { - _filename = absPath(dictionary.value(KeyDataSource)); - } - else { - LERROR(std::format("Node did not contain a valid '{}'", KeyDataSource)); - return; - } + const Parameters p = codegen::bake(dictionary); - if (dictionary.hasValue(KeyErrorHistogramsSource)) { - _errorHistogramsPath = absPath( - dictionary.value(KeyErrorHistogramsSource) - ); - } + _filename = p.source; + _errorHistogramsPath = p.errorHistogramsSource.value_or(_errorHistogramsPath); + _scalingExponent = p.scalingExponent.value_or(_scalingExponent); + _stepSizeCoefficient = p.stepSizeCoefficient.value_or(_stepSizeCoefficient); + _scaling = p.scaling.value_or(_scaling); + _translation = p.translation.value_or(_translation); + _rotation = p.rotation.value_or(_rotation); - if (dictionary.hasValue("ScalingExponent")) { - _scalingExponent = static_cast(dictionary.value("ScalingExponent")); - } - - if (dictionary.hasValue("StepSizeCoefficient")) { - _stepSizeCoefficient = static_cast( - dictionary.value("StepSizeCoefficient") - ); - } - - if (dictionary.hasValue("Scaling")) { - _scaling = dictionary.value("Scaling"); - } - - if (dictionary.hasValue("Translation")) { - _translation = dictionary.value("Translation"); - } - - if (dictionary.hasValue("Rotation")) { - _rotation = dictionary.value("Rotation"); - } - - if (dictionary.hasValue(KeyStartTime) && - dictionary.hasValue(KeyEndTime)) - { - std::string startTimeString = dictionary.value(KeyStartTime); - std::string endTimeString = dictionary.value(KeyEndTime); - _startTime = SpiceManager::ref().ephemerisTimeFromDate(startTimeString); - _endTime = SpiceManager::ref().ephemerisTimeFromDate(endTimeString); + if (p.startTime.has_value() && p.endTime.has_value()) { + _startTime = SpiceManager::ref().ephemerisTimeFromDate(*p.startTime); + _endTime = SpiceManager::ref().ephemerisTimeFromDate(*p.endTime); _loop = false; } else { @@ -233,44 +215,13 @@ RenderableMultiresVolume::RenderableMultiresVolume(const ghoul::Dictionary& dict LWARNING("Node does not provide time information. Viewing one image / frame"); } - if (dictionary.hasValue(KeyTransferFunction)) { - _transferFunctionPath = absPath( - dictionary.value(KeyTransferFunction) - ); - _transferFunction = std::make_shared(_transferFunctionPath); - } - else { - LERROR(std::format("Node did not contain a valid '{}'", KeyTransferFunction)); - return; - } - - //_pscOffset = psc(glm::vec4(0.f)); - //_boxScaling = glm::vec3(1.f); - - - /*if (dictionary.hasKey(KeyBoxScaling)) { - glm::vec4 scalingVec4(_boxScaling, _w); - success = dictionary.getValue(KeyBoxScaling, scalingVec4); - if (success) { - _boxScaling = scalingVec4.xyz; - _w = scalingVec4.w; - } - else { - success = dictionary.getValue(KeyBoxScaling, _boxScaling); - if (!success) { - LERROR("Node '" << name << "' did not contain a valid '" << - KeyBoxScaling << "'"); - return; - } - } - }*/ + _transferFunctionPath = p.transferFunction; + _transferFunction = std::make_shared(_transferFunctionPath); _tsp = std::make_shared(_filename); _atlasManager = std::make_shared(_tsp.get()); - if (dictionary.hasValue(KeyBrickSelector)) { - _selectorName = dictionary.value(KeyBrickSelector); - } + _selectorName = p.brickSelector.value_or(_selectorName); std::string selectorName = _selectorName; if (selectorName == "simple") { diff --git a/modules/server/servermodule.cpp b/modules/server/servermodule.cpp index 6aae5399ce..ff79690a80 100644 --- a/modules/server/servermodule.cpp +++ b/modules/server/servermodule.cpp @@ -28,6 +28,7 @@ #include #include #include +#include #include #include #include @@ -41,11 +42,20 @@ #include namespace { - constexpr std::string_view KeyInterfaces = "Interfaces"; + struct [[codegen::Dictionary(ServerModule)]] Parameters { + std::optional interfaces; + std::optional> allowAddresses; + std::optional skyBrowserUpdateTime; + }; +#include "servermodule_codegen.cpp" } // namespace namespace openspace { +documentation::Documentation ServerModule::Documentation() { + return codegen::doc("module_server"); +} + ServerModule::ServerModule() : OpenSpaceModule(ServerModule::Name) , _interfaceOwner({"Interfaces", "Interfaces", "Server Interfaces"}) @@ -93,26 +103,17 @@ void ServerModule::internalInitialize(const ghoul::Dictionary& configuration) { preSync(); }); - if (!configuration.hasValue(KeyInterfaces)) { + const Parameters p = codegen::bake(configuration); + if (!p.interfaces.has_value()) { return; } - const ghoul::Dictionary interfaces = - configuration.value(KeyInterfaces); - for (const std::string_view key : interfaces.keys()) { - ghoul::Dictionary interfaceDictionary = interfaces.value(key); - // @TODO (abock, 2019-09-17); This is a hack to make the parsing of the - // openspace.cfg file not corrupt the heap and cause a potential crash at shutdown - // (see ticket https://github.com/OpenSpace/OpenSpace/issues/982) - // The AllowAddresses are specified externally and are injected here - interfaceDictionary.setValue( - "AllowAddresses", - configuration.value("AllowAddresses") - ); + for (const std::string_view key : p.interfaces->keys()) { + ghoul::Dictionary interface = p.interfaces->value(key); std::unique_ptr serverInterface = - ServerInterface::createFromDictionary(interfaceDictionary); + ServerInterface::createFromDictionary(interface); serverInterface->initialize(); @@ -122,11 +123,8 @@ void ServerModule::internalInitialize(const ghoul::Dictionary& configuration) { _interfaces.push_back(std::move(serverInterface)); } } - if (configuration.hasValue("SkyBrowserUpdateTime")) { - _skyBrowserUpdateTime = static_cast( - configuration.value("SkyBrowserUpdateTime") - ); - } + + _skyBrowserUpdateTime = p.skyBrowserUpdateTime.value_or(_skyBrowserUpdateTime); } void ServerModule::preSync() { diff --git a/modules/server/servermodule.h b/modules/server/servermodule.h index 3bf7823a11..f4c69990f9 100644 --- a/modules/server/servermodule.h +++ b/modules/server/servermodule.h @@ -62,6 +62,8 @@ public: CallbackHandle addPreSyncCallback(CallbackFunction cb); void removePreSyncCallback(CallbackHandle handle); + static documentation::Documentation Documentation(); + protected: void internalInitialize(const ghoul::Dictionary& configuration) override; diff --git a/modules/server/src/serverinterface.cpp b/modules/server/src/serverinterface.cpp index f2f5272381..16948d4eaf 100644 --- a/modules/server/src/serverinterface.cpp +++ b/modules/server/src/serverinterface.cpp @@ -23,20 +23,14 @@ ****************************************************************************************/ #include -#include +#include +#include #include #include #include namespace { - constexpr std::string_view KeyIdentifier = "Identifier"; - constexpr std::string_view TcpSocketType = "TcpSocket"; - constexpr std::string_view WebSocketType = "WebSocket"; - constexpr std::string_view DenyAccess = "Deny"; - constexpr std::string_view RequirePassword = "RequirePassword"; - constexpr std::string_view AllowAccess = "Allow"; - constexpr openspace::properties::Property::PropertyInfo EnabledInfo = { "Enabled", "Enabled", @@ -94,6 +88,45 @@ namespace { "Password for connecting to this interface.", openspace::properties::Property::Visibility::AdvancedUser }; + + struct [[codegen::Dictionary(ServerInterface)]] Parameters { + enum class [[codegen::stringify()]] Access { + Allow, + Deny, + RequirePassword + }; + + // [[codegen::verbatim(DefaultAccessInfo.description)]] + std::optional defaultAccess; + + std::string identifier; + + // [[codegen::verbatim(AllowAddressesInfo.description)]] + std::optional> allowAddresses; + + // [[codegen::verbatim(DenyAddressesInfo.description)]] + std::optional> denyAddresses; + + // [[codegen::verbatim(RequirePasswordAddressesInfo.description)]] + std::optional> requirePasswordAddresses; + + enum class [[codegen::stringify()]] Type { + TcpSocket, + WebSocket + }; + // [[codegen::verbatim(TypeInfo.description)]] + Type type; + + // [[codegen::verbatim(PasswordInfo.description)]] + std::optional password; + + // [[codegen::verbatim(PortInfo.description)]] + int port; + + // [[codegen::verbatim(EnabledInfo.description)]] + bool enabled; + }; +#include "serverinterface_codegen.cpp" } // namespace namespace openspace { @@ -117,80 +150,65 @@ ServerInterface::ServerInterface(const ghoul::Dictionary& dictionary) , _defaultAccess(DefaultAccessInfo) , _password(PasswordInfo) { + const Parameters p = codegen::bake(dictionary); _socketType.addOption( static_cast(InterfaceType::TcpSocket), - std::string(TcpSocketType) + "TcpSocket" ); _socketType.addOption( static_cast(InterfaceType::WebSocket), - std::string(WebSocketType) + "WebSocket" ); _defaultAccess.addOption( static_cast(Access::Deny), - std::string(DenyAccess) + "Deny" ); _defaultAccess.addOption( static_cast(Access::RequirePassword), - std::string(RequirePassword) + "RequirePassword" ); _defaultAccess.addOption( static_cast(Access::Allow), - std::string(AllowAccess) + "Allow" ); - if (dictionary.hasKey(DefaultAccessInfo.identifier)) { - const std::string access = dictionary.value( - DefaultAccessInfo.identifier - ); - if (access == DenyAccess) { - _defaultAccess.setValue(static_cast(Access::Deny)); - } - else if (access == RequirePassword) { - _defaultAccess.setValue(static_cast(Access::RequirePassword)); - } - else if (access == AllowAccess) { - _defaultAccess.setValue(static_cast(Access::Allow)); + if (p.defaultAccess.has_value()) { + switch (*p.defaultAccess) { + case Parameters::Access::Allow: + _defaultAccess.setValue(static_cast(Access::Allow)); + break; + case Parameters::Access::Deny: + _defaultAccess.setValue(static_cast(Access::Deny)); + break; + case Parameters::Access::RequirePassword: + _defaultAccess.setValue(static_cast(Access::RequirePassword)); + break; } } - const std::string identifier = dictionary.value(KeyIdentifier); + _allowAddresses = p.allowAddresses.value_or(_allowAddresses); + _denyAddresses = p.denyAddresses.value_or(_denyAddresses); + _requirePasswordAddresses = + p.requirePasswordAddresses.value_or(_requirePasswordAddresses); - auto readList = - [dictionary](const std::string& key, properties::StringListProperty& list) { - if (dictionary.hasValue(key)) { - const ghoul::Dictionary& dict = dictionary.value(key); - std::vector v; - for (const std::string_view k : dict.keys()) { - v.push_back(dict.value(k)); - } - list = v; - } - }; + setIdentifier(p.identifier); + setGuiName(p.identifier); + setDescription("Settings for server interface " + p.identifier); - readList(AllowAddressesInfo.identifier, _allowAddresses); - readList(DenyAddressesInfo.identifier, _denyAddresses); - readList(RequirePasswordAddressesInfo.identifier, _requirePasswordAddresses); - - setIdentifier(identifier); - setGuiName(identifier); - setDescription("Settings for server interface " + identifier); - - const std::string type = dictionary.value(TypeInfo.identifier); - if (type == TcpSocketType) { - _socketType = static_cast(InterfaceType::TcpSocket); - } - else if (type == WebSocketType) { - _socketType = static_cast(InterfaceType::WebSocket); + switch (p.type) { + case Parameters::Type::TcpSocket: + _socketType = static_cast(InterfaceType::TcpSocket); + break; + case Parameters::Type::WebSocket: + _socketType = static_cast(InterfaceType::WebSocket); + break; } - if (dictionary.hasValue(PasswordInfo.identifier)) { - _password = dictionary.value(PasswordInfo.identifier); - } - - _port = static_cast(dictionary.value(PortInfo.identifier)); - _enabled = dictionary.value(EnabledInfo.identifier); + _password = p.password.value_or(_password); + _port = p.port; + _enabled = p.enabled; auto reinitialize = [this]() { deinitialize(); @@ -198,19 +216,18 @@ ServerInterface::ServerInterface(const ghoul::Dictionary& dictionary) }; _socketType.onChange(reinitialize); - _port.onChange(reinitialize); - _enabled.onChange(reinitialize); - _defaultAccess.onChange(reinitialize); - _allowAddresses.onChange(reinitialize); - _requirePasswordAddresses.onChange(reinitialize); - _denyAddresses.onChange(reinitialize); - addProperty(_socketType); + _port.onChange(reinitialize); addProperty(_port); + _enabled.onChange(reinitialize); addProperty(_enabled); + _defaultAccess.onChange(reinitialize); addProperty(_defaultAccess); + _allowAddresses.onChange(reinitialize); addProperty(_allowAddresses); + _requirePasswordAddresses.onChange(reinitialize); addProperty(_requirePasswordAddresses); + _denyAddresses.onChange(reinitialize); addProperty(_denyAddresses); addProperty(_password); } diff --git a/modules/skybrowser/skybrowsermodule.cpp b/modules/skybrowser/skybrowsermodule.cpp index a7c0db4aab..e9f38758d1 100644 --- a/modules/skybrowser/skybrowsermodule.cpp +++ b/modules/skybrowser/skybrowsermodule.cpp @@ -160,6 +160,10 @@ namespace { namespace openspace { +documentation::Documentation SkyBrowserModule::Documentation() { + return codegen::doc("module_skybrowser"); +} + SkyBrowserModule::SkyBrowserModule() : OpenSpaceModule(SkyBrowserModule::Name) , _enabled(EnabledInfo) diff --git a/modules/skybrowser/skybrowsermodule.h b/modules/skybrowser/skybrowsermodule.h index b194768f83..1c0f5b9591 100644 --- a/modules/skybrowser/skybrowsermodule.h +++ b/modules/skybrowser/skybrowsermodule.h @@ -87,6 +87,7 @@ public: scripting::LuaLibrary luaLibrary() const override; std::vector documentations() const override; + static documentation::Documentation Documentation(); protected: void internalInitialize(const ghoul::Dictionary& dict) override; diff --git a/modules/space/horizonsfile.cpp b/modules/space/horizonsfile.cpp index b1bbcda8c2..b4e74cfc7d 100644 --- a/modules/space/horizonsfile.cpp +++ b/modules/space/horizonsfile.cpp @@ -800,7 +800,7 @@ std::pair HorizonsFile::parseValidTimeRange( "{} T {}", words[words.size() - 2], words[words.size() - 1] ); } - else if (words.size() > 2){ + else if (words.size() > 2) { // Sometimes the format can be yyyy-mon-dd without time startTime = words[words.size() - 2]; endTime = words[words.size() - 1]; diff --git a/modules/space/kepler.cpp b/modules/space/kepler.cpp index 8d0bf940a8..9ae20a9a28 100644 --- a/modules/space/kepler.cpp +++ b/modules/space/kepler.cpp @@ -440,7 +440,7 @@ std::vector readTleFile(const std::filesystem::path& file) { // patch it to the full year { const std::string id = firstLine.substr(9, 6); - const std::string prefix = [y = id.substr(0, 2)](){ + const std::string prefix = [y = id.substr(0, 2)]() { const int year = std::atoi(y.c_str()); return year >= 57 ? "19" : "20"; }(); diff --git a/modules/space/rendering/renderablestars.cpp b/modules/space/rendering/renderablestars.cpp index bae9fe64c5..b826718886 100644 --- a/modules/space/rendering/renderablestars.cpp +++ b/modules/space/rendering/renderablestars.cpp @@ -451,14 +451,18 @@ RenderableStars::RenderableStars(const ghoul::Dictionary& dictionary) properties::StringProperty(TextureInfo), properties::FloatProperty(MultiplierInfo, 1.f, 0.f, 20.f), properties::FloatProperty(GammaInfo, 1.f, 0.f, 5.f), - properties::FloatProperty(ScaleInfo, 1.f, 0.f, 1.f) + properties::FloatProperty(ScaleInfo, 1.f, 0.f, 1.f), + nullptr, + nullptr } , _glare { properties::PropertyOwner(GlareOwnerInfo), properties::StringProperty(TextureInfo), properties::FloatProperty(MultiplierInfo, 1.f, 0.f, 20.f), properties::FloatProperty(GammaInfo, 1.f, 0.f, 5.f), - properties::FloatProperty(ScaleInfo, 1.f, 0.f, 1.f) + properties::FloatProperty(ScaleInfo, 1.f, 0.f, 1.f), + nullptr, + nullptr } , _parameters { properties::PropertyOwner(SizeCompositionInfo), diff --git a/modules/space/rotation/spicerotation.cpp b/modules/space/rotation/spicerotation.cpp index bdba3390dc..cdb5e03ba7 100644 --- a/modules/space/rotation/spicerotation.cpp +++ b/modules/space/rotation/spicerotation.cpp @@ -111,13 +111,8 @@ SpiceRotation::SpiceRotation(const ghoul::Dictionary& dictionary) _fixedDate = p.fixedDate.value_or(_fixedDate); addProperty(_fixedDate); - if (dictionary.hasKey(TimeFrameInfo.identifier)) { - const ghoul::Dictionary timeFrameDictionary = - dictionary.value(TimeFrameInfo.identifier); - _timeFrame = TimeFrame::createFromDictionary(timeFrameDictionary); - if (_timeFrame == nullptr) { - throw ghoul::RuntimeError("Invalid dictionary for TimeFrame"); - } + if (p.timeFrame.has_value()) { + _timeFrame = TimeFrame::createFromDictionary(*p.timeFrame); addPropertySubOwner(_timeFrame.get()); } diff --git a/modules/space/shaders/fluxnodes_vs.glsl b/modules/space/shaders/fluxnodes_vs.glsl index c8da051462..c4ace2a360 100644 --- a/modules/space/shaders/fluxnodes_vs.glsl +++ b/modules/space/shaders/fluxnodes_vs.glsl @@ -152,7 +152,7 @@ void setEarthProximitySettings() { if (usingPulse) { int speed = 2; int modulusResult = int(speed * time) % 2; - if (fluxValue > thresholdFlux){ + if (fluxValue > thresholdFlux) { if (modulusResult == 1) { vs_color.a = 0.01; } @@ -199,7 +199,7 @@ void main() { vs_color.a = 0.0; } } - else if (colorMode == uniformColor){ + else if (colorMode == uniformColor) { vs_color = streamColor; } setEarthProximitySettings(); diff --git a/modules/space/spacemodule.cpp b/modules/space/spacemodule.cpp index 9c75829c99..c7bc8c3590 100644 --- a/modules/space/spacemodule.cpp +++ b/modules/space/spacemodule.cpp @@ -59,12 +59,23 @@ namespace { "disabled, the errors will be ignored silently.", openspace::properties::Property::Visibility::Developer }; + + struct [[codegen::Dictionary(SpaceModule)]] Parameters { + // [[codegen::verbatim(SpiceExceptionInfo.description)]] + std::optional showExceptions; + }; +#include "spacemodule_codegen.cpp" + } // namespace namespace openspace { ghoul::opengl::ProgramObjectManager SpaceModule::ProgramObjectManager; +documentation::Documentation SpaceModule::Documentation() { + return codegen::doc("module_space"); +} + SpaceModule::SpaceModule() : OpenSpaceModule(Name) , _showSpiceExceptions(SpiceExceptionInfo, true) @@ -109,9 +120,8 @@ void SpaceModule::internalInitialize(const ghoul::Dictionary& dictionary) { fRotation->registerClass("SpiceRotation"); - if (dictionary.hasValue(SpiceExceptionInfo.identifier)) { - _showSpiceExceptions = dictionary.value(SpiceExceptionInfo.identifier); - } + const Parameters p = codegen::bake(dictionary); + _showSpiceExceptions = p.showExceptions.value_or(_showSpiceExceptions); } void SpaceModule::internalDeinitializeGL() { diff --git a/modules/space/spacemodule.h b/modules/space/spacemodule.h index d53f42d0ff..1be7a72470 100644 --- a/modules/space/spacemodule.h +++ b/modules/space/spacemodule.h @@ -43,6 +43,7 @@ public: static ghoul::opengl::ProgramObjectManager ProgramObjectManager; scripting::LuaLibrary luaLibrary() const override; + static documentation::Documentation Documentation(); private: void internalInitialize(const ghoul::Dictionary&) override; diff --git a/modules/spacecraftinstruments/util/instrumenttimesparser.cpp b/modules/spacecraftinstruments/util/instrumenttimesparser.cpp index 5dfcaacfc0..b28cfc23f8 100644 --- a/modules/spacecraftinstruments/util/instrumenttimesparser.cpp +++ b/modules/spacecraftinstruments/util/instrumenttimesparser.cpp @@ -142,7 +142,7 @@ bool InstrumentTimesParser::create() { }; _subsetMap[_target]._subset.push_back(std::move(image)); } - if (successfulRead){ + if (successfulRead) { _subsetMap[_target]._range.include(instrumentActiveTimeRange); _instrumentTimes.emplace_back(instrumentID, instrumentActiveTimeRange); } diff --git a/modules/sync/syncmodule.cpp b/modules/sync/syncmodule.cpp index 90ebdbad30..e4e128b826 100644 --- a/modules/sync/syncmodule.cpp +++ b/modules/sync/syncmodule.cpp @@ -59,6 +59,10 @@ namespace { namespace openspace { +documentation::Documentation SyncModule::Documentation() { + return codegen::doc("module_sync"); +} + SyncModule::SyncModule() : OpenSpaceModule(Name) {} void SyncModule::internalInitialize(const ghoul::Dictionary& configuration) { diff --git a/modules/sync/syncmodule.h b/modules/sync/syncmodule.h index aeb8899372..b9ea6c5bc2 100644 --- a/modules/sync/syncmodule.h +++ b/modules/sync/syncmodule.h @@ -40,8 +40,8 @@ public: std::filesystem::path synchronizationRoot() const; std::vector documentations() const override; - scripting::LuaLibrary luaLibrary() const override; + static documentation::Documentation Documentation(); protected: void internalInitialize(const ghoul::Dictionary& configuration) override; diff --git a/modules/touch/touchmodule.cpp b/modules/touch/touchmodule.cpp index 5d8c043122..0761db66ac 100644 --- a/modules/touch/touchmodule.cpp +++ b/modules/touch/touchmodule.cpp @@ -117,7 +117,7 @@ bool TouchModule::isDefaultDirectTouchType(std::string_view renderableType) cons _sortedDefaultRenderableTypes.end(); } -void TouchModule::internalInitialize(const ghoul::Dictionary&){ +void TouchModule::internalInitialize(const ghoul::Dictionary&) { _ear.reset(new TuioEar()); global::callback::initializeGL->push_back([this]() { diff --git a/modules/toyvolume/rendering/renderabletoyvolume.cpp b/modules/toyvolume/rendering/renderabletoyvolume.cpp index b59cc5c6d0..3755f9f03a 100644 --- a/modules/toyvolume/rendering/renderabletoyvolume.cpp +++ b/modules/toyvolume/rendering/renderabletoyvolume.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -83,6 +84,33 @@ namespace { "The downscaling factor used when rendering the current volume.", openspace::properties::Property::Visibility::AdvancedUser }; + + struct [[codegen::Dictionary(RenderableToyVolume)]] Parameters { + // [[codegen::verbatim(ScalingExponentInfo.description)]] + std::optional scalingExponent; + + // [[codegen::verbatim(SizeInfo.description)]] + std::optional size; + + // [[codegen::verbatim(TranslationInfo.description)]] + std::optional translation; + + // [[codegen::verbatim(RotationInfo.description)]] + std::optional rotation; + + // [[codegen::verbatim(ColorInfo.description)]] + std::optional color [[codegen::color()]]; + + // [[codegen::verbatim(StepSizeInfo.description)]] + std::optional stepSize; + + // Raycast steps + std::optional steps; + + // [[codegen::verbatim(DownscaleVolumeRenderingInfo.description)]] + std::optional downscale; + }; +#include "renderabletoyvolume_codegen.cpp" } // namespace namespace openspace { @@ -102,47 +130,18 @@ RenderableToyVolume::RenderableToyVolume(const ghoul::Dictionary& dictionary) , _color(ColorInfo, glm::vec3(1.f, 0.f, 0.f), glm::vec3(0.f), glm::vec3(1.f)) , _downScaleVolumeRendering(DownscaleVolumeRenderingInfo, 1.f, 0.1f, 1.f) { - if (dictionary.hasValue(ScalingExponentInfo.identifier)) { - _scalingExponent = static_cast( - dictionary.value(ScalingExponentInfo.identifier) - ); - } + const Parameters p = codegen::bake(dictionary); - if (dictionary.hasValue(SizeInfo.identifier)) { - _size = dictionary.value(SizeInfo.identifier); - } - - if (dictionary.hasValue(TranslationInfo.identifier)) { - _translation = dictionary.value(TranslationInfo.identifier); - } - - if (dictionary.hasValue(RotationInfo.identifier)) { - _rotation = dictionary.value(RotationInfo.identifier); - } - - if (dictionary.hasValue(ColorInfo.identifier)) { - _color = dictionary.value(ColorInfo.identifier); - } - - if (dictionary.hasValue(StepSizeInfo.identifier)) { - _stepSize = static_cast(dictionary.value(StepSizeInfo.identifier)); - } + _scalingExponent = p.scalingExponent.value_or(_scalingExponent); + _size = p.size.value_or(_size); + _translation = p.translation.value_or(_translation); + _rotation = p.rotation.value_or(_rotation); + _color = p.color.value_or(_color); + _stepSize = p.stepSize.value_or(_stepSize); + _rayCastSteps = p.steps.value_or(_rayCastSteps); _downScaleVolumeRendering.setVisibility(properties::Property::Visibility::Developer); - if (dictionary.hasKey("Downscale")) { - _downScaleVolumeRendering = static_cast( - dictionary.value("Downscale") - ); - } - - if (dictionary.hasKey("Steps")) { - _rayCastSteps = static_cast(dictionary.value("Steps")); - } - else { - LINFO( - "Number of raycasting steps not specified for ToyVolume. Using default value" - ); - } + _downScaleVolumeRendering = p.downscale.value_or(_downScaleVolumeRendering); } RenderableToyVolume::~RenderableToyVolume() {} diff --git a/modules/video/src/screenspacevideo.cpp b/modules/video/src/screenspacevideo.cpp index 637a2600bc..5e1590dab8 100644 --- a/modules/video/src/screenspacevideo.cpp +++ b/modules/video/src/screenspacevideo.cpp @@ -41,7 +41,6 @@ documentation::Documentation ScreenSpaceVideo::Documentation() { documentation::Documentation doc = VideoPlayer::Documentation(); doc.name = "ScreenSpaceVideo"; doc.id = "video_screenspacevideo"; - return doc; } diff --git a/modules/video/videomodule.cpp b/modules/video/videomodule.cpp index b15d8d91a7..d30c93740e 100644 --- a/modules/video/videomodule.cpp +++ b/modules/video/videomodule.cpp @@ -50,6 +50,10 @@ namespace { namespace openspace { +documentation::Documentation VideoModule::Documentation() { + return codegen::doc("module_video"); +} + VideoModule::VideoModule() : OpenSpaceModule(VideoModule::Name) , _enabled(EnabledInfo) diff --git a/modules/video/videomodule.h b/modules/video/videomodule.h index ec425df31f..198dfae3b1 100644 --- a/modules/video/videomodule.h +++ b/modules/video/videomodule.h @@ -38,6 +38,7 @@ public: VideoModule(); std::vector documentations() const override; + static documentation::Documentation Documentation(); protected: void internalInitialize(const ghoul::Dictionary& dict) override; diff --git a/modules/volume/rendering/volumeclipplane.cpp b/modules/volume/rendering/volumeclipplane.cpp index 3f84fd7d3d..64586eb688 100644 --- a/modules/volume/rendering/volumeclipplane.cpp +++ b/modules/volume/rendering/volumeclipplane.cpp @@ -24,29 +24,57 @@ #include +#include #include +namespace { + constexpr openspace::properties::Property::PropertyInfo NormalInfo = { + "Normal", + "Normal", + // @TODO Missing documentation + "" + }; + + constexpr openspace::properties::Property::PropertyInfo OffsetsInfo = { + "Offsets", + "Offsets", + // @TODO Missing documentation + "" + }; + + struct [[codegen::Dictionary(VolumeClipPlane)]] Parameters { + // [[codegen::verbatim(NormalInfo.description)]] + glm::vec3 normal; + + // [[codegen::verbatim(OffsetsInfo.description)]] + glm::vec3 offsets; + }; +#include "volumeclipplane_codegen.cpp" +} // namespace + namespace openspace::volume { VolumeClipPlane::VolumeClipPlane(const ghoul::Dictionary& dictionary) : properties::PropertyOwner({ "" }) // @TODO Missing name , _normal( - { "Normal", "Normal", "" }, // @TODO Missing documentation + NormalInfo, glm::vec3(1.f, 0.f, 0.f), glm::vec3(-1.f), glm::vec3(1.f) ) , _offsets( - { "Offsets", "Offsets", "" }, // @TODO Missing documentation + OffsetsInfo, glm::vec2(-2.f, 0.f), glm::vec2(-2.f, 0.f), glm::vec2(2.f, 1.f) ) { - _normal = dictionary.value("Normal"); - _offsets = dictionary.value("Offsets"); + const Parameters p = codegen::bake(dictionary); + _normal = p.normal; addProperty(_normal); + + _offsets = p.offsets; addProperty(_offsets); } diff --git a/modules/webbrowser/src/browserclient.cpp b/modules/webbrowser/src/browserclient.cpp index bdb6868395..b266437944 100644 --- a/modules/webbrowser/src/browserclient.cpp +++ b/modules/webbrowser/src/browserclient.cpp @@ -82,10 +82,9 @@ bool BrowserClient::NoContextMenuHandler::RunContextMenu(CefRefPtr, return true; } -bool BrowserClient::DisplayHandler::OnCursorChange(CefRefPtr browser, - CefCursorHandle, - cef_cursor_type_t type, - const CefCursorInfo&) +bool BrowserClient::DisplayHandler::OnCursorChange(CefRefPtr, CefCursorHandle, + cef_cursor_type_t type, + const CefCursorInfo&) { WindowDelegate::Cursor newCursor; switch (type) { diff --git a/modules/webbrowser/src/screenspacebrowser.cpp b/modules/webbrowser/src/screenspacebrowser.cpp index 78ccc956fb..b5ae4ce420 100644 --- a/modules/webbrowser/src/screenspacebrowser.cpp +++ b/modules/webbrowser/src/screenspacebrowser.cpp @@ -96,9 +96,9 @@ documentation::Documentation ScreenSpaceBrowser::Documentation() { ScreenSpaceBrowser::ScreenSpaceBrowser(const ghoul::Dictionary& dictionary) : ScreenSpaceRenderable(dictionary) , _dimensions(DimensionsInfo, glm::uvec2(0), glm::uvec2(0), glm::uvec2(3000)) + , _renderHandler(new ScreenSpaceRenderHandler) , _url(UrlInfo) , _reload(ReloadInfo) - , _renderHandler(new ScreenSpaceRenderHandler) , _keyboardHandler(new WebKeyboardHandler) { const Parameters p = codegen::bake(dictionary); diff --git a/modules/webbrowser/src/webrenderhandler.cpp b/modules/webbrowser/src/webrenderhandler.cpp index f3bc9b6c54..6f70042979 100644 --- a/modules/webbrowser/src/webrenderhandler.cpp +++ b/modules/webbrowser/src/webrenderhandler.cpp @@ -27,11 +27,6 @@ #include #include -namespace { - constexpr std::string_view _loggerCat = "WebRenderHandler"; -} // namespace - - namespace openspace { WebRenderHandler::WebRenderHandler(bool accelerate) @@ -259,7 +254,7 @@ bool WebRenderHandler::hasContent(int x, int y) { glBindTexture(GL_TEXTURE_2D, _texture); // Read the texture data into the PBO - glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, 0); + glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, nullptr); // Map the PBO to the CPU memory space GLubyte* pixels = reinterpret_cast( diff --git a/modules/webbrowser/webbrowsermodule.cpp b/modules/webbrowser/webbrowsermodule.cpp index 7628edc62a..750e3342e5 100644 --- a/modules/webbrowser/webbrowsermodule.cpp +++ b/modules/webbrowser/webbrowsermodule.cpp @@ -90,10 +90,29 @@ namespace { return execLocation; } + struct [[codegen::Dictionary(WebBrowserModule)]] Parameters { + // The location of the web helper application + std::optional webHelperLocation; + + // Determines whether the WebBrowser module is enabled + std::optional enabled; + + // [[codegen::verbatim(UpdateBrowserBetweenRenderablesInfo.description)]] + std::optional updateBrowserBetweenRenderables; + + // [[codegen::verbatim(BrowserUpdateIntervalInfo.description)]] + std::optional browserUpdateInterval; + }; +#include "webbrowsermodule_codegen.cpp" + } // namespace namespace openspace { +documentation::Documentation WebBrowserModule::Documentation() { + return codegen::doc("module_webbrowser"); +} + WebBrowserModule::WebBrowserModule() : OpenSpaceModule(WebBrowserModule::Name) , _updateBrowserBetweenRenderables(UpdateBrowserBetweenRenderablesInfo, true) @@ -127,6 +146,31 @@ WebBrowserModule::WebBrowserModule() WebBrowserModule::~WebBrowserModule() {} +void WebBrowserModule::internalInitialize(const ghoul::Dictionary& dictionary) { + ZoneScoped; + + const Parameters p = codegen::bake(dictionary); + + _webHelperLocation = p.webHelperLocation.value_or(findHelperExecutable()); + _enabled = p.enabled.value_or(_enabled); + + LDEBUG(std::format("CEF using web helper executable: {}", _webHelperLocation)); + _cefHost = std::make_unique(_webHelperLocation.string()); + LDEBUG("Starting CEF... done"); + + _updateBrowserBetweenRenderables = + p.updateBrowserBetweenRenderables.value_or(_updateBrowserBetweenRenderables); + _browserUpdateInterval = p.browserUpdateInterval.value_or(_browserUpdateInterval); + + _eventHandler->initialize(); + + // register ScreenSpaceBrowser + ghoul::TemplateFactory* fScreenSpaceRenderable = + FactoryManager::ref().factory(); + ghoul_assert(fScreenSpaceRenderable, "ScreenSpaceRenderable factory was not created"); + fScreenSpaceRenderable->registerClass("ScreenSpaceBrowser"); +} + void WebBrowserModule::internalDeinitialize() { ZoneScoped; @@ -142,44 +186,6 @@ void WebBrowserModule::internalDeinitialize() { } } -void WebBrowserModule::internalInitialize(const ghoul::Dictionary& dictionary) { - ZoneScoped; - - if (dictionary.hasValue("WebHelperLocation")) { - _webHelperLocation = absPath(dictionary.value("WebHelperLocation")); - } - else { - _webHelperLocation = findHelperExecutable(); - } - - if (dictionary.hasValue("Enabled")) { - _enabled = dictionary.value("Enabled"); - } - - LDEBUG(std::format("CEF using web helper executable: {}", _webHelperLocation)); - _cefHost = std::make_unique(_webHelperLocation.string()); - LDEBUG("Starting CEF... done"); - - if (dictionary.hasValue(UpdateBrowserBetweenRenderablesInfo.identifier)) { - _updateBrowserBetweenRenderables = - dictionary.value(UpdateBrowserBetweenRenderablesInfo.identifier); - } - - if (dictionary.hasValue(BrowserUpdateIntervalInfo.identifier)) { - _browserUpdateInterval = static_cast( - dictionary.value(BrowserUpdateIntervalInfo.identifier) - ); - } - - _eventHandler->initialize(); - - // register ScreenSpaceBrowser - ghoul::TemplateFactory* fScreenSpaceRenderable = - FactoryManager::ref().factory(); - ghoul_assert(fScreenSpaceRenderable, "ScreenSpaceRenderable factory was not created"); - fScreenSpaceRenderable->registerClass("ScreenSpaceBrowser"); -} - void WebBrowserModule::addBrowser(BrowserInstance* browser) { ZoneScoped; diff --git a/modules/webbrowser/webbrowsermodule.h b/modules/webbrowser/webbrowsermodule.h index 7d595c5497..2938bfff73 100644 --- a/modules/webbrowser/webbrowsermodule.h +++ b/modules/webbrowser/webbrowsermodule.h @@ -61,6 +61,7 @@ public: static bool canUseAcceleratedRendering(); std::vector documentations() const override; + static documentation::Documentation Documentation(); protected: void internalInitialize(const ghoul::Dictionary& dictionary) override; diff --git a/modules/webgui/webguimodule.cpp b/modules/webgui/webguimodule.cpp index 94edb9e439..fc62990103 100644 --- a/modules/webgui/webguimodule.cpp +++ b/modules/webgui/webguimodule.cpp @@ -119,6 +119,10 @@ namespace { namespace openspace { +documentation::Documentation WebGuiModule::Documentation() { + return codegen::doc("module_webgui"); +} + WebGuiModule::WebGuiModule() : OpenSpaceModule(WebGuiModule::Name) , _enabled(ServerProcessEnabledInfo, true) diff --git a/modules/webgui/webguimodule.h b/modules/webgui/webguimodule.h index c7972b8144..c40481e26f 100644 --- a/modules/webgui/webguimodule.h +++ b/modules/webgui/webguimodule.h @@ -50,6 +50,8 @@ public: CallbackHandle addEndpointChangeCallback(EndpointCallback cb); void removeEndpointChangeCallback(CallbackHandle); + static documentation::Documentation Documentation(); + protected: void internalInitialize(const ghoul::Dictionary&) override; diff --git a/openspace.cfg b/openspace.cfg index a8eb2e3524..576edf3268 100644 --- a/openspace.cfg +++ b/openspace.cfg @@ -139,7 +139,6 @@ ModuleConfigurations = { } }, Server = { - AllowAddresses = { "127.0.0.1", "localhost" }, SkyBrowserUpdateTime = 50, Interfaces = { { @@ -148,6 +147,7 @@ ModuleConfigurations = { Port = 4681, Enabled = true, DefaultAccess = "Deny", + AllowAddresses = { "127.0.0.1", "localhost" }, RequirePasswordAddresses = {}, Password = "" }, @@ -157,6 +157,7 @@ ModuleConfigurations = { Port = 4682, Enabled = true, DefaultAccess = "Deny", + AllowAddresses = { "127.0.0.1", "localhost" }, RequirePasswordAddresses = {}, Password = "" } diff --git a/src/documentation/documentation.cpp b/src/documentation/documentation.cpp index c66e45de23..74f92f8e02 100644 --- a/src/documentation/documentation.cpp +++ b/src/documentation/documentation.cpp @@ -178,10 +178,11 @@ void logError(const SpecificationError& error, std::string component) { } DocumentationEntry::DocumentationEntry(std::string k, std::shared_ptr v, - Optional opt, std::string doc) + Optional opt, Private priv, std::string doc) : key(std::move(k)) , verifier(std::move(v)) , optional(opt) + , isPrivate(priv) , documentation(std::move(doc)) { ghoul_assert(!key.empty(), "Key must not be empty"); @@ -189,8 +190,8 @@ DocumentationEntry::DocumentationEntry(std::string k, std::shared_ptr } DocumentationEntry::DocumentationEntry(std::string k, Verifier* v, Optional opt, - std::string doc) - : DocumentationEntry(std::move(k), std::shared_ptr(v), opt, + Private priv, std::string doc) + : DocumentationEntry(std::move(k), std::shared_ptr(v), opt, priv, std::move(doc)) {} diff --git a/src/documentation/verifier.cpp b/src/documentation/verifier.cpp index 7c85cecbdc..3ca10c8208 100644 --- a/src/documentation/verifier.cpp +++ b/src/documentation/verifier.cpp @@ -689,7 +689,13 @@ std::string TableVerifier::type() const { StringListVerifier::StringListVerifier(std::string elementDocumentation) : TableVerifier({ - { "*", new StringVerifier, Optional::No, std::move(elementDocumentation) } + { + "*", + new StringVerifier, + Optional::No, + Private::No, + std::move(elementDocumentation) + } }) {} @@ -699,7 +705,13 @@ std::string StringListVerifier::type() const { IntListVerifier::IntListVerifier(std::string elementDocumentation) : TableVerifier({ - { "*", new IntVerifier, Optional::No, std::move(elementDocumentation) } + { + "*", + new IntVerifier, + Optional::No, + Private::No, + std::move(elementDocumentation) + } }) {} diff --git a/src/engine/configuration.cpp b/src/engine/configuration.cpp index 76458a7802..a9edfefd71 100644 --- a/src/engine/configuration.cpp +++ b/src/engine/configuration.cpp @@ -25,7 +25,9 @@ #include #include +#include #include +#include #include #include #include @@ -327,9 +329,6 @@ namespace { // Values in this table describe the behavior of the loading screen that is // displayed while the scene graph is created and initialized std::optional loadingScreen; - - // Configurations for each module - std::optional> moduleConfigurations; }; #include "configuration_codegen.cpp" } // namespace @@ -522,9 +521,7 @@ void parseLuaState(Configuration& configuration) { // We go through all of the entries and lift them from global scope into the table on // the stack so that we can create a ghoul::Dictionary from this new table - const documentation::Documentation doc = codegen::doc( - "core_configuration" - ); + const documentation::Documentation doc = Configuration::Documentation(); for (const documentation::DocumentationEntry& e : doc.entries) { lua_pushstring(s, e.key.c_str()); lua_getglobal(s, e.key.c_str()); @@ -611,7 +608,14 @@ void parseLuaState(Configuration& configuration) { l.showLogMessages.value_or(c.loadingScreen.isShowingLogMessages); } - c.moduleConfigurations = p.moduleConfigurations.value_or(c.moduleConfigurations); + // ModuleConfigurations depend on the list of modules that are added, which has to be + // done dynamically. Hence we can't have it written directly into the struct + if (d.hasValue("ModuleConfigurations")) { + ghoul::Dictionary dict = d.value("ModuleConfigurations"); + for (std::string_view key : dict.keys()) { + c.moduleConfigurations[std::string(key)] = dict.value(key); + } + } if (p.openGLDebugContext.has_value()) { const Parameters::OpenGLDebugContext& l = *p.openGLDebugContext; @@ -691,8 +695,38 @@ void patchConfiguration(Configuration& configuration, const Settings& settings) } } -documentation::Documentation Configuration::Documentation = - codegen::doc("core_configuration"); +documentation::Documentation Configuration::Documentation() { + using namespace documentation; + + documentation::Documentation doc = codegen::doc("core_configuration"); + + auto moduleConfiguration = std::make_shared(); + for (OpenSpaceModule* mod : global::moduleEngine->modules()) { + std::string name = mod->identifier(); + std::string id = mod->Documentation().id; + + if (id.empty()) { + continue; + } + + moduleConfiguration->documentations.push_back({ + name, + new ReferencingVerifier(id), + Optional::Yes, + Private::No, + mod->Documentation().description + }); + } + doc.entries.push_back({ + "ModuleConfigurations", + std::move(moduleConfiguration), + Optional::Yes, + Private::No, + "Configurations for each module" + }); + + return doc; +} std::filesystem::path findConfiguration(const std::string& filename) { std::filesystem::path directory = absPath("${BIN}"); diff --git a/src/engine/moduleengine.cpp b/src/engine/moduleengine.cpp index 0621df1589..5edb772d9a 100644 --- a/src/engine/moduleengine.cpp +++ b/src/engine/moduleengine.cpp @@ -185,4 +185,8 @@ scripting::LuaLibrary ModuleEngine::luaLibrary() { }; } +std::vector ModuleEngine::moduleDocumentations() const { + return AllModuleDocumentation(); +} + } // namespace openspace diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index 4bfd4e8662..ac7d32ca34 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -404,12 +404,15 @@ void OpenSpaceEngine::initialize() { // After registering the modules, the documentations for the available classes // can be added as well + for (documentation::Documentation d : global::moduleEngine->moduleDocumentations()) { + DocEng.addDocumentation(std::move(d)); + } for (OpenSpaceModule* m : global::moduleEngine->modules()) { for (const documentation::Documentation& doc : m->documentations()) { DocEng.addDocumentation(doc); } } - DocEng.addDocumentation(Configuration::Documentation); + DocEng.addDocumentation(Configuration::Documentation()); // Register the provided shader directories ghoul::opengl::ShaderPreprocessor::addIncludePath(absPath("${SHADERS}")); diff --git a/src/interaction/tasks/convertrecfileversiontask.cpp b/src/interaction/tasks/convertrecfileversiontask.cpp index 930f7a0112..f309eab39e 100644 --- a/src/interaction/tasks/convertrecfileversiontask.cpp +++ b/src/interaction/tasks/convertrecfileversiontask.cpp @@ -107,6 +107,7 @@ documentation::Documentation ConvertRecFileVersionTask::documentation() { "InputFilePath", new StringAnnotationVerifier("A valid filename to convert"), Optional::No, + Private::No, "The filename to update to the current file format", }, }, diff --git a/src/interaction/tasks/convertrecformattask.cpp b/src/interaction/tasks/convertrecformattask.cpp index 52c7e47def..d7f19fe300 100644 --- a/src/interaction/tasks/convertrecformattask.cpp +++ b/src/interaction/tasks/convertrecformattask.cpp @@ -314,12 +314,14 @@ documentation::Documentation ConvertRecFormatTask::documentation() { "InputFilePath", new StringAnnotationVerifier("A valid filename to convert"), Optional::No, + Private::No, "The filename to convert to the opposite format", }, { "OutputFilePath", new StringAnnotationVerifier("A valid output filename"), Optional::No, + Private::No, "The filename containing the converted result", }, }, diff --git a/src/network/parallelpeer.cpp b/src/network/parallelpeer.cpp index 8d2c13c7a8..d5be7e52f3 100644 --- a/src/network/parallelpeer.cpp +++ b/src/network/parallelpeer.cpp @@ -127,10 +127,10 @@ ParallelPeer::ParallelPeer() : properties::PropertyOwner({ "ParallelPeer", "Parallel Peer" }) , _password(PasswordInfo) , _hostPassword(HostPasswordInfo) + , _serverName(ServerNameInfo) , _port(PortInfo) , _address(AddressInfo) , _name(NameInfo) - , _serverName(ServerNameInfo) , _bufferTime(BufferTimeInfo, 0.2f, 0.01f, 5.0f) , _timeKeyframeInterval(TimeKeyFrameInfo, 0.1f, 0.f, 1.f) , _cameraKeyframeInterval(CameraKeyFrameInfo, 0.1f, 0.f, 1.f) diff --git a/src/rendering/transferfunction.cpp b/src/rendering/transferfunction.cpp index 232437a9c5..79e1458ac5 100644 --- a/src/rendering/transferfunction.cpp +++ b/src/rendering/transferfunction.cpp @@ -129,7 +129,7 @@ void TransferFunction::setTextureFromTxt() { float intensity = 0.f; glm::vec4 rgba; iss >> intensity; - for(int i = 0; i < 4; i++) { + for (int i = 0; i < 4; i++) { iss >> rgba[i]; } mappingKeys.emplace_back(intensity, rgba); diff --git a/src/util/histogram.cpp b/src/util/histogram.cpp index 3f96709933..3e20ba4a11 100644 --- a/src/util/histogram.cpp +++ b/src/util/histogram.cpp @@ -86,7 +86,7 @@ bool Histogram::add(float value, float repeat) { return true; } -void Histogram::changeRange(float minValue, float maxValue){ +void Histogram::changeRange(float minValue, float maxValue) { if (minValue > _minValue && maxValue < _maxValue) { return; } @@ -96,7 +96,7 @@ void Histogram::changeRange(float minValue, float maxValue){ const float oldMax = _maxValue; float* newData = new float[_numBins]{0.0}; - for(int i=0; i<_numBins; i++){ + for (int i = 0; i < _numBins; i++) { const float unNormalizedValue = i * (oldMax - oldMin) + oldMin; const float normalizedValue = (unNormalizedValue - _minValue) / (_maxValue - _minValue); // [0.0, 1.0] @@ -297,7 +297,7 @@ void Histogram::print() const { //// std::cout << std::endl << std::endl << std::endl<< "==============" << std::endl; } -float Histogram::highestBinValue(bool equalized, int overBins){ +float Histogram::highestBinValue(bool equalized, int overBins) { int highestBin = 0; float highestValue = 0; diff --git a/src/util/openspacemodule.cpp b/src/util/openspacemodule.cpp index 3200400660..1fb76804b8 100644 --- a/src/util/openspacemodule.cpp +++ b/src/util/openspacemodule.cpp @@ -89,6 +89,10 @@ std::vector OpenSpaceModule::documentations() cons return {}; } +documentation::Documentation OpenSpaceModule::Documentation() { + return {}; +} + scripting::LuaLibrary OpenSpaceModule::luaLibrary() const { return {}; } diff --git a/src/util/touch.cpp b/src/util/touch.cpp index e24e5ac33e..aed365a87d 100644 --- a/src/util/touch.cpp +++ b/src/util/touch.cpp @@ -98,7 +98,7 @@ bool TouchInputHolder::tryAddInput(TouchInput input) { _inputs.emplace_front(input); successful = true; } - else if (!sameTimeAsLastInput){ + else if (!sameTimeAsLastInput) { _inputs.front().timestamp = input.timestamp; successful = true; } diff --git a/support/cmake/module_documentation.template b/support/cmake/module_documentation.template new file mode 100644 index 0000000000..bf03dc8a78 --- /dev/null +++ b/support/cmake/module_documentation.template @@ -0,0 +1,15 @@ +// This file has been auto-generated by CMake based on +// support/cmake/module_documentation.template +// Do not change this file manually + +#ifndef __MODULE_DOCUMENTATION_H__ +#define __MODULE_DOCUMENTATION_H__ + +namespace { + struct [[codegen::Dictionary(ModuleConfiguration)]] Parameters { +@MODULE_DOCUMENTATION_CODEGEN@ + }; +#include "moduledocumentation_codegen.cpp" +} // namespace + +#endif // __MODULE_DOCUMENTATION_H__ diff --git a/support/cmake/module_path.template b/support/cmake/module_path.template deleted file mode 100644 index b2fd07b548..0000000000 --- a/support/cmake/module_path.template +++ /dev/null @@ -1,19 +0,0 @@ -// This file has been auto-generated by CMake based on -// support/cmake/module_path.template -// Do not change this file manually - -#ifndef __MODULE_PATH_H__ -#define __MODULE_PATH_H__ - -namespace openspace { - -constexpr std::string_view ModulePaths[] = { - // We need the empty string here or otherwise ModulePaths might be empty and thus - // cause a compiler error - "", -@MODULE_PATHS@ -}; - -} // namespace openspace - -#endif // __MODULE_PATH_H__ diff --git a/support/cmake/module_registration.template b/support/cmake/module_registration.template index e9f2a382a9..4b95a58ae2 100644 --- a/support/cmake/module_registration.template +++ b/support/cmake/module_registration.template @@ -8,11 +8,16 @@ @MODULE_HEADERS@ namespace openspace { -auto AllModules = []() -> std::vector { +constexpr auto AllModules = []() -> std::vector { return { @MODULE_CLASSES@ }; }; +constexpr auto AllModuleDocumentation = []() -> std::vector { + return { +@MODULE_DOCUMENTATION@ }; +}; + } // namespace openspace #endif // __MODULE_REGISTRATION_H__ diff --git a/support/coding/codegen b/support/coding/codegen index 32f22c537e..5e85e1ab58 160000 --- a/support/coding/codegen +++ b/support/coding/codegen @@ -1 +1 @@ -Subproject commit 32f22c537eb855a36f72fd3c1c39d9318e116238 +Subproject commit 5e85e1ab581bfe0cded3cb4d7dfae3cb24a435de diff --git a/tests/test_documentation.cpp b/tests/test_documentation.cpp index 35f53fc078..6372d89423 100644 --- a/tests/test_documentation.cpp +++ b/tests/test_documentation.cpp @@ -37,241 +37,71 @@ TEST_CASE("Documentation: Constructor", "[documentation]") { Documentation doc; // Basic Verifiers - doc.entries.emplace_back( - "BoolVerifier", - new BoolVerifier, - Optional::No - ); - doc.entries.emplace_back( - "DoubleVerifier", - new DoubleVerifier, - Optional::No - ); - doc.entries.emplace_back( - "IntVerifier", - new IntVerifier, - Optional::No - ); - doc.entries.emplace_back( - "StringVerifier", - new StringVerifier, - Optional::No - ); - doc.entries.emplace_back( - "IdentifierVerifier", - new IdentifierVerifier, - Optional::No - ); - doc.entries.emplace_back( - "FileVerifier", - new FileVerifier, - Optional::No - ); - doc.entries.emplace_back( - "DirectoryVerifier", - new DirectoryVerifier, - Optional::No - ); - doc.entries.emplace_back( - "DateTimeVerifier", - new DateTimeVerifier, - Optional::No - ); - doc.entries.emplace_back( - "TableVerifier", - new TableVerifier, - Optional::No - ); + doc.entries.emplace_back("BoolVerifier", new BoolVerifier); + doc.entries.emplace_back("DoubleVerifier", new DoubleVerifier); + doc.entries.emplace_back("IntVerifier", new IntVerifier); + doc.entries.emplace_back("StringVerifier", new StringVerifier); + doc.entries.emplace_back("IdentifierVerifier", new IdentifierVerifier); + doc.entries.emplace_back("FileVerifier", new FileVerifier); + doc.entries.emplace_back("DirectoryVerifier", new DirectoryVerifier); + doc.entries.emplace_back("DateTimeVerifier", new DateTimeVerifier); + doc.entries.emplace_back("TableVerifier", new TableVerifier); // Operator Verifiers - doc.entries.emplace_back( - "LessDouble", - new DoubleLessVerifier(0.0), - Optional::No - ); - doc.entries.emplace_back( - "LessInt", - new IntLessVerifier(0), - Optional::No - ); - doc.entries.emplace_back( - "LessEqualDouble", - new DoubleLessEqualVerifier(0.0), - Optional::No - ); - doc.entries.emplace_back( - "LessEqualInt", - new IntLessEqualVerifier(0), - Optional::No - ); + doc.entries.emplace_back("LessDouble", new DoubleLessVerifier(0.0)); + doc.entries.emplace_back("LessInt", new IntLessVerifier(0)); + doc.entries.emplace_back("LessEqualDouble", new DoubleLessEqualVerifier(0.0)); + doc.entries.emplace_back("LessEqualInt", new IntLessEqualVerifier(0)); - doc.entries.emplace_back( - "GreaterDouble", - new DoubleGreaterVerifier(0.0), - Optional::No - ); - doc.entries.emplace_back( - "GreaterInt", - new IntGreaterVerifier(0), - Optional::No - ); + doc.entries.emplace_back("GreaterDouble", new DoubleGreaterVerifier(0.0)); + doc.entries.emplace_back("GreaterInt", new IntGreaterVerifier(0)); - doc.entries.emplace_back( - "GreaterEqualDouble", - new DoubleGreaterEqualVerifier(0.0), - Optional::No - ); - doc.entries.emplace_back( - "GreaterEqualInt", - new IntGreaterEqualVerifier(0), - Optional::No - ); + doc.entries.emplace_back("GreaterEqualDouble", new DoubleGreaterEqualVerifier(0.0)); + doc.entries.emplace_back("GreaterEqualInt", new IntGreaterEqualVerifier(0)); - doc.entries.emplace_back( - "EqualBool", - new BoolEqualVerifier(false), - Optional::No - ); - doc.entries.emplace_back( - "EqualDouble", - new DoubleEqualVerifier(0.0), - Optional::No - ); - doc.entries.emplace_back( - "EqualInt", - new IntEqualVerifier(0), - Optional::No - ); - doc.entries.emplace_back( - "EqualString", - new StringEqualVerifier(""), - Optional::No - ); + doc.entries.emplace_back("EqualBool", new BoolEqualVerifier(false)); + doc.entries.emplace_back("EqualDouble", new DoubleEqualVerifier(0.0)); + doc.entries.emplace_back("EqualInt", new IntEqualVerifier(0)); + doc.entries.emplace_back("EqualString", new StringEqualVerifier("")); - doc.entries.emplace_back( - "UnequalBool", - new BoolUnequalVerifier(false), - Optional::No - ); - doc.entries.emplace_back( - "UnequalDouble", - new DoubleUnequalVerifier(0.0), - Optional::No - ); - doc.entries.emplace_back( - "UnequalInt", - new IntUnequalVerifier(0), - Optional::No - ); - doc.entries.emplace_back( - "UnequalString", - new StringUnequalVerifier(""), - Optional::No - ); + doc.entries.emplace_back("UnequalBool", new BoolUnequalVerifier(false)); + doc.entries.emplace_back("UnequalDouble", new DoubleUnequalVerifier(0.0)); + doc.entries.emplace_back("UnequalInt", new IntUnequalVerifier(0)); + doc.entries.emplace_back("UnequalString", new StringUnequalVerifier("")); // List Verifiers - doc.entries.emplace_back( - "InListBool", - new BoolInListVerifier({ true, false }), - Optional::No - ); - doc.entries.emplace_back( - "InListDouble", - new DoubleInListVerifier({ 0.0, 1.0}), - Optional::No - ); - doc.entries.emplace_back( - "InListInt", - new IntInListVerifier({ 0, 1 }), - Optional::No - ); - doc.entries.emplace_back( - "InListString", - new StringInListVerifier({ "", "a" }), - Optional::No - ); + doc.entries.emplace_back("InListBool", new BoolInListVerifier({ true, false })); + doc.entries.emplace_back("InListDouble", new DoubleInListVerifier({ 0.0, 1.0 })); + doc.entries.emplace_back("InListInt", new IntInListVerifier({ 0, 1 })); + doc.entries.emplace_back("InListString", new StringInListVerifier({ "", "a" })); - doc.entries.emplace_back( - "NotInListBool", - new BoolNotInListVerifier({ true, false }), - Optional::No - ); + doc.entries.emplace_back("NotInListBool", new BoolNotInListVerifier({ true, false })); doc.entries.emplace_back( "NotInListDouble", - new DoubleNotInListVerifier({ 0.0, 1.0 }), - Optional::No - ); - doc.entries.emplace_back( - "NotInListInt", - new IntNotInListVerifier({ 0, 1 }), - Optional::No - ); - doc.entries.emplace_back( - "NotInListString", - new StringNotInListVerifier({ "", "a" }), - Optional::No + new DoubleNotInListVerifier({ 0.0, 1.0 }) ); + doc.entries.emplace_back("NotInListInt", new IntNotInListVerifier({ 0, 1 })); + doc.entries.emplace_back("NotInListString", new StringNotInListVerifier({ "", "a" })); - doc.entries.emplace_back( - "StringListVerifier", - new StringListVerifier, - Optional::No - ); - doc.entries.emplace_back( - "IntListVerifier", - new IntListVerifier, - Optional::No - ); + doc.entries.emplace_back("StringListVerifier", new StringListVerifier); + doc.entries.emplace_back("IntListVerifier", new IntListVerifier); // Range Verifiers - doc.entries.emplace_back( - "InListDouble", - new DoubleInRangeVerifier({ 0.0, 1.0 }), - Optional::No - ); - doc.entries.emplace_back( - "InListInt", - new IntInRangeVerifier({ 0, 1 }), - Optional::No - ); + doc.entries.emplace_back("InListDouble", new DoubleInRangeVerifier({ 0.0, 1.0 })); + doc.entries.emplace_back("InListInt", new IntInRangeVerifier({ 0, 1 })); doc.entries.emplace_back( "NotInListDouble", - new DoubleNotInRangeVerifier({ 0.0, 1.0 }), - Optional::No - ); - doc.entries.emplace_back( - "NotInListInt", - new IntNotInRangeVerifier({ 0, 1 }), - Optional::No + new DoubleNotInRangeVerifier({ 0.0, 1.0 }) ); + doc.entries.emplace_back("NotInListInt", new IntNotInRangeVerifier({ 0, 1 })); // Misc Verifiers - doc.entries.emplace_back( - "AnnotationBool", - new BoolAnnotationVerifier("Bool"), - Optional::No - ); - doc.entries.emplace_back( - "AnnotationDouble", - new DoubleAnnotationVerifier("Double"), - Optional::No - ); - doc.entries.emplace_back( - "AnnotationInt", - new IntAnnotationVerifier("Int"), - Optional::No - ); - doc.entries.emplace_back( - "AnnotationString", - new StringAnnotationVerifier("String"), - Optional::No - ); - doc.entries.emplace_back( - "AnnotationTable", - new TableAnnotationVerifier("Table"), - Optional::No - ); + doc.entries.emplace_back("AnnotationBool", new BoolAnnotationVerifier("Bool")); + doc.entries.emplace_back("AnnotationDouble", new DoubleAnnotationVerifier("Double")); + doc.entries.emplace_back("AnnotationInt", new IntAnnotationVerifier("Int")); + doc.entries.emplace_back("AnnotationString", new StringAnnotationVerifier("String")); + doc.entries.emplace_back("AnnotationTable", new TableAnnotationVerifier("Table")); } TEST_CASE("Documentation: Initializer Constructor", "[documentation]") { @@ -280,63 +110,63 @@ TEST_CASE("Documentation: Initializer Constructor", "[documentation]") { const Documentation doc = { .entries = { // Basic Verifiers - { "BoolVerifier", new BoolVerifier, Optional::No }, - { "DoubleVerifier", new DoubleVerifier, Optional::No }, - { "IntVerifier", new IntVerifier, Optional::No }, - { "StringVerifier", new StringVerifier, Optional::No }, - { "IdentifierVerifier", new IdentifierVerifier, Optional::No }, - { "FileVerifier", new FileVerifier, Optional::No }, - { "DirectoryVerifier", new DirectoryVerifier, Optional::No }, - { "DateTimeVerifier", new DateTimeVerifier, Optional::No }, - { "TableVerifier", new TableVerifier, Optional::No }, + { "BoolVerifier", new BoolVerifier }, + { "DoubleVerifier", new DoubleVerifier }, + { "IntVerifier", new IntVerifier }, + { "StringVerifier", new StringVerifier }, + { "IdentifierVerifier", new IdentifierVerifier }, + { "FileVerifier", new FileVerifier }, + { "DirectoryVerifier", new DirectoryVerifier }, + { "DateTimeVerifier", new DateTimeVerifier }, + { "TableVerifier", new TableVerifier }, // Operator Verifiers - { "LessDouble", new DoubleLessVerifier(0.0), Optional::No }, - { "LessInt", new IntLessVerifier(0), Optional::No }, + { "LessDouble", new DoubleLessVerifier(0.0) }, + { "LessInt", new IntLessVerifier(0) }, - { "LessEqualDouble", new DoubleLessEqualVerifier(0.0), Optional::No }, - { "LessEqualInt", new IntLessEqualVerifier(0), Optional::No }, + { "LessEqualDouble", new DoubleLessEqualVerifier(0.0) }, + { "LessEqualInt", new IntLessEqualVerifier(0) }, - { "GreaterDouble", new DoubleGreaterVerifier(0.0), Optional::No }, - { "GreaterInt", new IntGreaterVerifier(0), Optional::No }, + { "GreaterDouble", new DoubleGreaterVerifier(0.0) }, + { "GreaterInt", new IntGreaterVerifier(0) }, - { "GreaterEqualDouble", new DoubleGreaterEqualVerifier(0.0), Optional::No }, - { "GreaterEqualInt", new IntGreaterEqualVerifier(0), Optional::No }, + { "GreaterEqualDouble", new DoubleGreaterEqualVerifier(0.0) }, + { "GreaterEqualInt", new IntGreaterEqualVerifier(0) }, - { "EqualBool", new BoolEqualVerifier(false), Optional::No }, - { "EqualDouble", new DoubleEqualVerifier(0.0), Optional::No }, - { "EqualInt", new IntEqualVerifier(0), Optional::No }, - { "EqualString", new StringEqualVerifier(""), Optional::No }, + { "EqualBool", new BoolEqualVerifier(false) }, + { "EqualDouble", new DoubleEqualVerifier(0.0) }, + { "EqualInt", new IntEqualVerifier(0) }, + { "EqualString", new StringEqualVerifier("") }, - { "UnequalBool", new BoolUnequalVerifier(false), Optional::No }, - { "UnequalDouble", new DoubleUnequalVerifier(0.0), Optional::No }, - { "UnequalInt", new IntUnequalVerifier(0), Optional::No }, - { "UnequalString", new StringUnequalVerifier(""), Optional::No }, + { "UnequalBool", new BoolUnequalVerifier(false) }, + { "UnequalDouble", new DoubleUnequalVerifier(0.0) }, + { "UnequalInt", new IntUnequalVerifier(0) }, + { "UnequalString", new StringUnequalVerifier("") }, // List Verifiers - { "InListBool", new BoolInListVerifier({ true, false }), Optional::No }, - { "InListDouble", new DoubleInListVerifier({ 0.0, 1.0 }), Optional::No }, - { "InListInt", new IntInListVerifier({ 0, 1 }), Optional::No }, - { "InListString", new StringInListVerifier({ "", "a" }), Optional::No }, + { "InListBool", new BoolInListVerifier({ true, false }) }, + { "InListDouble", new DoubleInListVerifier({ 0.0, 1.0 }) }, + { "InListInt", new IntInListVerifier({ 0, 1 }) }, + { "InListString", new StringInListVerifier({ "", "a" }) }, - { "NotInListBool", new BoolNotInListVerifier({ true, false }), Optional::No }, - { "NotInListDouble", new DoubleNotInListVerifier({ 0.0, 1.0 }), Optional::No }, - { "NotInListInt", new IntNotInListVerifier({ 0, 1 }), Optional::No }, - { "NotInListString", new StringNotInListVerifier({ "", "a" }), Optional::No }, + { "NotInListBool", new BoolNotInListVerifier({ true, false }) }, + { "NotInListDouble", new DoubleNotInListVerifier({ 0.0, 1.0 }) }, + { "NotInListInt", new IntNotInListVerifier({ 0, 1 }) }, + { "NotInListString", new StringNotInListVerifier({ "", "a" }) }, // Range Verifiers - { "InRangeDouble", new DoubleInRangeVerifier(0.0, 1.0), Optional::No }, - { "InRangeInt", new IntInRangeVerifier(0, 1), Optional::No }, + { "InRangeDouble", new DoubleInRangeVerifier(0.0, 1.0) }, + { "InRangeInt", new IntInRangeVerifier(0, 1) }, - { "InRangeDouble", new DoubleNotInRangeVerifier(0.0, 1.0), Optional::No }, - { "InRangeInt", new IntNotInRangeVerifier(0, 1), Optional::No }, + { "InRangeDouble", new DoubleNotInRangeVerifier(0.0, 1.0) }, + { "InRangeInt", new IntNotInRangeVerifier(0, 1) }, // Misc Verifiers - { "AnnotationBool", new BoolAnnotationVerifier("Bool"), Optional::No }, - { "AnnotationDouble", new DoubleAnnotationVerifier("Double"), Optional::No }, - { "AnnotationInt", new IntAnnotationVerifier("Int"), Optional::No }, - { "AnnotationString", new StringAnnotationVerifier("String"), Optional::No }, - { "AnnotationTable", new TableAnnotationVerifier("Table"), Optional::No } + { "AnnotationBool", new BoolAnnotationVerifier("Bool") }, + { "AnnotationDouble", new DoubleAnnotationVerifier("Double") }, + { "AnnotationInt", new IntAnnotationVerifier("Int") }, + { "AnnotationString", new StringAnnotationVerifier("String") }, + { "AnnotationTable", new TableAnnotationVerifier("Table") } } }; } @@ -345,9 +175,7 @@ TEST_CASE("Documentation: BoolVerifier", "[documentation]") { using namespace openspace::documentation; const Documentation doc = { - .entries = { - { "Bool", new BoolVerifier, Optional::No } - } + .entries = {{ "Bool", new BoolVerifier }} }; ghoul::Dictionary positive; @@ -378,9 +206,7 @@ TEST_CASE("Documentation: DoubleVerifier", "[documentation]") { using namespace openspace::documentation; const Documentation doc = { - .entries = { - { "Double", new DoubleVerifier, Optional::No } - } + .entries = {{ "Double", new DoubleVerifier }} }; ghoul::Dictionary positive; @@ -410,9 +236,7 @@ TEST_CASE("Documentation: IntVerifier", "[documentation]") { using namespace openspace::documentation; const Documentation doc = { - .entries = { - { "Int", new IntVerifier, Optional::No } - } + .entries = {{ "Int", new IntVerifier }} }; ghoul::Dictionary positive; @@ -449,9 +273,7 @@ TEST_CASE("Documentation: StringVerifier", "[documentation]") { using namespace std::string_literals; const Documentation doc = { - .entries = { - { "String", new StringVerifier, Optional::No } - } + .entries = {{ "String", new StringVerifier }} }; ghoul::Dictionary positive; @@ -482,9 +304,7 @@ TEST_CASE("Documentation: IdentifierVerifier", "[documentation]") { using namespace std::string_literals; const Documentation doc = { - .entries = { - { "Identifier", new IdentifierVerifier, Optional::No } - } + .entries = {{ "Identifier", new IdentifierVerifier }} }; ghoul::Dictionary positive; @@ -547,9 +367,7 @@ TEST_CASE("Documentation: FileVerifier", "[documentation]") { using namespace std::string_literals; const Documentation doc = { - .entries = { - { "File", new FileVerifier, Optional::No } - } + .entries = {{ "File", new FileVerifier }} }; ghoul::Dictionary positive; @@ -588,9 +406,7 @@ TEST_CASE("Documentation: DirectoryVerifier", "[documentation]") { using namespace std::string_literals; const Documentation doc = { - .entries = { - { "Dir", new DirectoryVerifier, Optional::No } - } + .entries = {{ "Dir", new DirectoryVerifier }} }; ghoul::Dictionary positive; @@ -629,9 +445,7 @@ TEST_CASE("Documentation: DateTimeVerifier", "[documentation]") { using namespace std::string_literals; const Documentation doc = { - .entries = { - { "DateTime", new DateTimeVerifier, Optional::No } - } + .entries = {{ "DateTime", new DateTimeVerifier }} }; ghoul::Dictionary positive; @@ -669,9 +483,7 @@ TEST_CASE("Documentation: TableVerifierType", "[documentation]") { using namespace openspace::documentation; const Documentation doc = { - .entries = { - { "Table", new TableVerifier, Optional::No } - } + .entries = {{ "Table", new TableVerifier }} }; ghoul::Dictionary positive; @@ -702,9 +514,7 @@ TEST_CASE("Documentation: StringListVerifierType", "[documentation]") { using namespace std::string_literals; const Documentation doc = { - .entries = { - { "StringList", new StringListVerifier, Optional::No } - } + .entries = {{ "StringList", new StringListVerifier }} }; ghoul::Dictionary positive; @@ -756,9 +566,7 @@ TEST_CASE("Documentation: IntListVerifierType", "[documentation]") { using namespace std::string_literals; const Documentation doc = { - .entries = { - { "IntList", new IntListVerifier, Optional::No } - } + .entries = {{ "IntList", new IntListVerifier }} }; ghoul::Dictionary positive; @@ -810,11 +618,11 @@ TEST_CASE("Documentation: MixedVerifiers", "[documentation]") { const Documentation doc = { .entries = { - { "Bool", new BoolVerifier, Optional::No }, - { "Double", new DoubleVerifier, Optional::No }, - { "Int", new IntVerifier, Optional::No }, - { "String", new StringVerifier, Optional::No }, - { "Table", new TableVerifier, Optional::No } + { "Bool", new BoolVerifier }, + { "Double", new DoubleVerifier }, + { "Int", new IntVerifier }, + { "String", new StringVerifier }, + { "Table", new TableVerifier } } }; @@ -861,19 +669,28 @@ TEST_CASE("Documentation: NestedTables", "[documentation]") { const Documentation doc = { .entries = { - { "Outer_Int", new IntVerifier, Optional::No }, - { "Outer_Table", new TableVerifier({ - { "Inner_Double", new DoubleVerifier, Optional::No }, - { "Inner_String", new StringVerifier, Optional::No } - }), Optional::No }, - { "Outer_Double", new DoubleVerifier, Optional::No }, - { "Outer_Table2" , new TableVerifier({ - { "Inner_Double2", new DoubleVerifier, Optional::No }, - { "Inner_String2", new StringVerifier, Optional::No }, - { "Inner_Table" , new TableVerifier({ - { "Inner_Inner_Int", new IntVerifier, Optional::No } - }), Optional::No } - }), Optional::No} + { "Outer_Int", new IntVerifier }, + { + "Outer_Table", + new TableVerifier({ + { "Inner_Double", new DoubleVerifier }, + { "Inner_String", new StringVerifier } + }) + }, + { "Outer_Double", new DoubleVerifier }, + { + "Outer_Table2", + new TableVerifier({ + { "Inner_Double2", new DoubleVerifier }, + { "Inner_String2", new StringVerifier }, + { + "Inner_Table", + new TableVerifier({ + { "Inner_Inner_Int", new IntVerifier } + }) + } + }) + } } }; @@ -1040,8 +857,8 @@ TEST_CASE("Documentation: Optional", "[documentation]") { const Documentation doc = { .entries = { - { "Bool_Force", new BoolVerifier, Optional::No }, - { "Bool_Optional", new BoolVerifier, Optional::Yes } + { "Bool_Force", new BoolVerifier }, + { "Bool_Optional", new BoolVerifier } } }; @@ -1090,18 +907,7 @@ TEST_CASE("Documentation: Required In Optional", "[documentation]") { .entries = { { "a", - new TableVerifier({ - { - "b", - new IntVerifier, - Optional::No - }, - { - "c", - new IntVerifier, - Optional::Yes - } - }), + new TableVerifier({{ "b", new IntVerifier }, { "c", new IntVerifier }}), Optional::Yes } } @@ -1150,9 +956,7 @@ TEST_CASE("Documentation: Exhaustive", "[documentation]") { using namespace openspace::documentation; const Documentation doc = { - .entries = { - { "Int", new IntVerifier, Optional::No } - } + .entries = {{ "Int", new IntVerifier }} }; ghoul::Dictionary positive; @@ -1182,13 +986,7 @@ TEST_CASE("Documentation: Nested Exhaustive", "[documentation]") { using namespace openspace::documentation; const Documentation doc = { - .entries = { - { - "Table", - new TableVerifier({ { "a", new IntVerifier, Optional::No } }), - Optional::No - } - } + .entries = {{ "Table", new TableVerifier({{ "a", new IntVerifier }}) }} }; ghoul::Dictionary positive; @@ -1235,9 +1033,7 @@ TEST_CASE("Documentation: Empty Nested Exhaustive", "[documentation]") { using namespace openspace::documentation; const Documentation doc = { - .entries = { - { "Table", new TableVerifier(), Optional::No } - } + .entries = {{ "Table", new TableVerifier() }} }; ghoul::Dictionary positive; @@ -1261,9 +1057,7 @@ TEST_CASE("Documentation: Less Int", "[documentation]") { using namespace openspace::documentation; const Documentation doc = { - .entries = { - { "Int", new IntLessVerifier(5), Optional::No } - } + .entries = {{ "Int", new IntLessVerifier(5) }} }; ghoul::Dictionary positive; @@ -1285,7 +1079,7 @@ TEST_CASE("Documentation: Less Double", "[documentation]") { using namespace openspace::documentation; const Documentation doc = { - .entries = { { "Double", new DoubleLessVerifier(5.0), Optional::No } } + .entries = {{ "Double", new DoubleLessVerifier(5.0) }} }; ghoul::Dictionary positive; @@ -1307,7 +1101,7 @@ TEST_CASE("Documentation: LessEqual Int", "[documentation]") { using namespace openspace::documentation; const Documentation doc = { - .entries = { { "Int", new IntLessEqualVerifier(5), Optional::No } } + .entries = {{ "Int", new IntLessEqualVerifier(5) }} }; ghoul::Dictionary positive; @@ -1335,7 +1129,7 @@ TEST_CASE("Documentation: LessEqual Double", "[documentation]") { using namespace openspace::documentation; const Documentation doc = { - .entries = { { "Double", new DoubleLessEqualVerifier(5.0), Optional::No } } + .entries = {{ "Double", new DoubleLessEqualVerifier(5.0) }} }; ghoul::Dictionary positive; @@ -1363,7 +1157,7 @@ TEST_CASE("Documentation: Greater Int", "[documentation]") { using namespace openspace::documentation; const Documentation doc = { - .entries = { { "Int", new IntGreaterVerifier(5), Optional::No } } + .entries = {{ "Int", new IntGreaterVerifier(5) }} }; ghoul::Dictionary positive; @@ -1385,7 +1179,7 @@ TEST_CASE("Documentation: Greater Double", "[documentation]") { using namespace openspace::documentation; const Documentation doc = { - .entries = { { "Double", new DoubleGreaterVerifier(5.0), Optional::No } } + .entries = {{ "Double", new DoubleGreaterVerifier(5.0) }} }; ghoul::Dictionary positive; @@ -1407,7 +1201,7 @@ TEST_CASE("Documentation: GreaterEqual Int", "[documentation]") { using namespace openspace::documentation; const Documentation doc = { - .entries = { { "Int", new IntGreaterEqualVerifier(5), Optional::No } } + .entries = {{ "Int", new IntGreaterEqualVerifier(5) }} }; ghoul::Dictionary positive; @@ -1435,7 +1229,7 @@ TEST_CASE("Documentation: GreaterEqual Double", "[documentation]") { using namespace openspace::documentation; const Documentation doc = { - .entries = { { "Double", new DoubleGreaterEqualVerifier(5.0), Optional::No } } + .entries = {{ "Double", new DoubleGreaterEqualVerifier(5.0) }} }; ghoul::Dictionary positive; @@ -1463,7 +1257,7 @@ TEST_CASE("Documentation: Equal Bool", "[documentation]") { using namespace openspace::documentation; const Documentation doc = { - .entries = { { "Bool", new BoolEqualVerifier(true), Optional::No } } + .entries = {{ "Bool", new BoolEqualVerifier(true) }} }; ghoul::Dictionary positive; @@ -1485,7 +1279,7 @@ TEST_CASE("Documentation: Equal Int", "[documentation]") { using namespace openspace::documentation; const Documentation doc = { - .entries = { { "Int", new IntEqualVerifier(1), Optional::No } } + .entries = {{ "Int", new IntEqualVerifier(1) }} }; ghoul::Dictionary positive; @@ -1507,7 +1301,7 @@ TEST_CASE("Documentation: Equal Double", "[documentation]") { using namespace openspace::documentation; const Documentation doc = { - .entries = { { "Double", new DoubleEqualVerifier(1.0), Optional::No } } + .entries = {{ "Double", new DoubleEqualVerifier(1.0) }} }; ghoul::Dictionary positive; @@ -1530,7 +1324,7 @@ TEST_CASE("Documentation: Equal String", "[documentation]") { using namespace std::string_literals; const Documentation doc = { - .entries = { { "String", new StringEqualVerifier("string"s), Optional::No } } + .entries = {{ "String", new StringEqualVerifier("string"s) }} }; ghoul::Dictionary positive; @@ -1552,7 +1346,7 @@ TEST_CASE("Documentation: Unequal Bool", "[documentation]") { using namespace openspace::documentation; const Documentation doc = { - .entries = { { "Bool", new BoolUnequalVerifier(true), Optional::No } } + .entries = {{ "Bool", new BoolUnequalVerifier(true) }} }; ghoul::Dictionary positive; @@ -1574,7 +1368,7 @@ TEST_CASE("Documentation: Unequal Int", "[documentation]") { using namespace openspace::documentation; const Documentation doc = { - .entries = { { "Int", new IntUnequalVerifier(1), Optional::No } } + .entries = {{ "Int", new IntUnequalVerifier(1) }} }; ghoul::Dictionary positive; @@ -1596,7 +1390,7 @@ TEST_CASE("Documentation: Unequal Double", "[documentation]") { using namespace openspace::documentation; const Documentation doc = { - .entries = { { "Double", new DoubleUnequalVerifier(1.0), Optional::No } } + .entries = {{ "Double", new DoubleUnequalVerifier(1.0) }} }; ghoul::Dictionary positive; @@ -1619,7 +1413,7 @@ TEST_CASE("Documentation: Unequal String", "[documentation]") { using namespace std::string_literals; const Documentation doc = { - .entries = { { "String", new StringUnequalVerifier("string"s), Optional::No } } + .entries = {{ "String", new StringUnequalVerifier("string"s) }} }; ghoul::Dictionary positive; @@ -1641,7 +1435,7 @@ TEST_CASE("Documentation: List Bool", "[documentation]") { using namespace openspace::documentation; const Documentation doc = { - .entries = { { "Bool" , new BoolInListVerifier({ true }), Optional::No } } + .entries = {{ "Bool", new BoolInListVerifier({ true }) }} }; ghoul::Dictionary positive; @@ -1663,7 +1457,7 @@ TEST_CASE("Documentation: List Int", "[documentation]") { using namespace openspace::documentation; const Documentation doc = { - .entries = { { "Int" , new IntInListVerifier({ 0, 1, 2 }), Optional::No } } + .entries = {{ "Int", new IntInListVerifier({ 0, 1, 2 }) }} }; ghoul::Dictionary positive; @@ -1691,9 +1485,7 @@ TEST_CASE("Documentation: List Double", "[documentation]") { using namespace openspace::documentation; const Documentation doc = { - .entries = { - { "Double" , new DoubleInListVerifier({ 0.0, 1.0, 2.0 }), Optional::No } - } + .entries = {{ "Double", new DoubleInListVerifier({ 0.0, 1.0, 2.0 }) }} }; ghoul::Dictionary positive; @@ -1722,9 +1514,7 @@ TEST_CASE("Documentation: List String", "[documentation]") { using namespace std::string_literals; const Documentation doc = { - .entries = { - { "String" , new StringInListVerifier({ "0"s, "1"s, "2"s }), Optional::No } - } + .entries = {{ "String", new StringInListVerifier({ "0"s, "1"s, "2"s }) }} }; ghoul::Dictionary positive; @@ -1752,7 +1542,7 @@ TEST_CASE("Documentation: NotList Bool", "[documentation]") { using namespace openspace::documentation; const Documentation doc = { - .entries = { { "Bool" , new BoolNotInListVerifier({ true }), Optional::No } } + .entries = {{ "Bool", new BoolNotInListVerifier({ true }) }} }; ghoul::Dictionary positive; @@ -1774,7 +1564,7 @@ TEST_CASE("Documentation: NotList Int", "[documentation]") { using namespace openspace::documentation; const Documentation doc = { - .entries = { { "Int" , new IntNotInListVerifier({ 0, 1, 2 }), Optional::No } } + .entries = {{ "Int", new IntNotInListVerifier({ 0, 1, 2 }) }} }; ghoul::Dictionary positive; @@ -1802,9 +1592,7 @@ TEST_CASE("Documentation: NotList Double", "[documentation]") { using namespace openspace::documentation; const Documentation doc = { - .entries = { - { "Double" , new DoubleNotInListVerifier({ 0.0, 1.0, 2.0 }), Optional::No } - } + .entries = {{ "Double", new DoubleNotInListVerifier({ 0.0, 1.0, 2.0 }) }} }; ghoul::Dictionary positive; @@ -1833,9 +1621,7 @@ TEST_CASE("Documentation: NotList String", "[documentation]") { using namespace std::string_literals; const Documentation doc = { - .entries = { - { "String" , new StringNotInListVerifier({ "0"s, "1"s, "2"s }), Optional::No } - } + .entries = {{ "String", new StringNotInListVerifier({ "0"s, "1"s, "2"s }) }} }; ghoul::Dictionary positive; @@ -1863,7 +1649,7 @@ TEST_CASE("Documentation: Annotation Bool", "[documentation]") { using namespace openspace::documentation; const Documentation doc = { - .entries = { { "Bool", new BoolAnnotationVerifier("Bool"), Optional::No } } + .entries = {{ "Bool", new BoolAnnotationVerifier("Bool") }} }; ghoul::Dictionary positive; @@ -1885,7 +1671,7 @@ TEST_CASE("Documentation: Annotation Int", "[documentation]") { using namespace openspace::documentation; const Documentation doc = { - .entries = { { "Int", new IntAnnotationVerifier("Int"), Optional::No } } + .entries = {{ "Int", new IntAnnotationVerifier("Int") }} }; ghoul::Dictionary positive; @@ -1907,7 +1693,7 @@ TEST_CASE("Documentation: Annotation Double", "[documentation]") { using namespace openspace::documentation; const Documentation doc = { - .entries = { { "Double", new DoubleAnnotationVerifier("Double"), Optional::No } } + .entries = {{ "Double", new DoubleAnnotationVerifier("Double") }} }; ghoul::Dictionary positive; @@ -1930,7 +1716,7 @@ TEST_CASE("Documentation: Annotation String", "[documentation]") { using namespace std::string_literals; const Documentation doc = { - .entries = { { "String", new StringAnnotationVerifier("String"), Optional::No } } + .entries = {{ "String", new StringAnnotationVerifier("String") }} }; ghoul::Dictionary positive; @@ -1952,7 +1738,7 @@ TEST_CASE("Documentation: Annotation Table", "[documentation]") { using namespace openspace::documentation; const Documentation doc = { - .entries = { { "Table", new TableAnnotationVerifier("Table"), Optional::No } } + .entries = {{ "Table", new TableAnnotationVerifier("Table") }} }; ghoul::Dictionary positive; @@ -1974,7 +1760,7 @@ TEST_CASE("Documentation: InRange Int", "[documentation]") { using namespace openspace::documentation; const Documentation doc = { - .entries = { { "Int", new InRangeVerifier(0, 5), Optional::No } } + .entries = {{ "Int", new InRangeVerifier(0, 5) }} }; ghoul::Dictionary positive; @@ -2008,9 +1794,7 @@ TEST_CASE("Documentation: InRange Double", "[documentation]") { using namespace openspace::documentation; const Documentation doc = { - .entries = { - { "Double", new InRangeVerifier(0.0, 5.0), Optional::No } - } + .entries = {{ "Double", new InRangeVerifier(0.0, 5.0) }} }; ghoul::Dictionary positive; @@ -2050,7 +1834,7 @@ TEST_CASE("Documentation: NotInRange Int", "[documentation]") { using namespace openspace::documentation; const Documentation doc = { - .entries = { { "Int", new NotInRangeVerifier(0, 5), Optional::No } } + .entries = {{ "Int", new NotInRangeVerifier(0, 5) }} }; ghoul::Dictionary positive; @@ -2094,9 +1878,7 @@ TEST_CASE("Documentation: NotInRange Double", "[documentation]") { using namespace openspace::documentation; const Documentation doc = { - .entries = { - { "Double", new NotInRangeVerifier(0.0, 5.0), Optional::No } - } + .entries = {{ "Double", new NotInRangeVerifier(0.0, 5.0) }} }; ghoul::Dictionary positive; @@ -2140,7 +1922,7 @@ TEST_CASE("Documentation: Wildcard", "[documentation]") { using namespace openspace::documentation; const Documentation doc = { - .entries = { { DocumentationEntry::Wildcard, new IntVerifier, Optional::No } } + .entries = {{ DocumentationEntry::Wildcard, new IntVerifier }} }; ghoul::Dictionary positive; @@ -2193,8 +1975,8 @@ TEST_CASE("Documentation: Wildcard Mixed", "[documentation]") { const Documentation doc = { .entries = { - { DocumentationEntry::Wildcard, new IntVerifier, Optional::No }, - { "b", new IntGreaterVerifier(5), Optional::No } + { DocumentationEntry::Wildcard, new IntVerifier }, + { "b", new IntGreaterVerifier(5) } } }; @@ -2264,17 +2046,12 @@ TEST_CASE("Documentation: Referencing", "[documentation]") { "Referenced Name", "referenced_id", "", - { - { "a", new IntVerifier, Optional::No }, - { "b", new DoubleVerifier, Optional::No } - }, + {{ "a", new IntVerifier }, { "b", new DoubleVerifier }}, }; DocEng.addDocumentation(referenced); const Documentation doc = { - .entries = { - { "Table", new ReferencingVerifier("referenced_id"), Optional::No } - } + .entries = {{ "Table", new ReferencingVerifier("referenced_id") }} }; ghoul::Dictionary positive; @@ -2311,9 +2088,7 @@ TEST_CASE("Documentation: Referencing", "[documentation]") { const Documentation wrongDoc = { - .entries = { - { "Table", new ReferencingVerifier("WRONG"), Optional::No } - } + .entries = {{ "Table", new ReferencingVerifier("WRONG") }} }; ghoul::Dictionary wrongNegative; { @@ -2336,9 +2111,7 @@ TEST_CASE("Documentation: OrOperator", "[documentation]") { using namespace std::string_literals; const Documentation doc = { - .entries = { - { "a", new OrVerifier({ new StringVerifier, new IntVerifier }), Optional::No } - } + .entries = {{ "a", new OrVerifier({ new StringVerifier, new IntVerifier }) }} }; ghoul::Dictionary positive; @@ -2366,9 +2139,7 @@ TEST_CASE("Documentation: IntVector2Verifier", "[documentation]") { using namespace openspace::documentation; const Documentation doc = { - .entries = { - { "a", new IntVector2Verifier, Optional::No } - } + .entries = {{ "a", new IntVector2Verifier }} }; ghoul::Dictionary positive; @@ -2403,9 +2174,7 @@ TEST_CASE("Documentation: DoubleVector2Verifier", "[documentation]") { using namespace openspace::documentation; const Documentation doc = { - .entries = { - { "a", new DoubleVector2Verifier, Optional::No } - } + .entries = {{ "a", new DoubleVector2Verifier }} }; ghoul::Dictionary positive; @@ -2441,9 +2210,7 @@ TEST_CASE("Documentation: IntVector3Verifier", "[documentation]") { using namespace std::string_literals; const Documentation doc = { - .entries = { - { "a", new IntVector3Verifier, Optional::No } - } + .entries = {{ "a", new IntVector3Verifier }} }; ghoul::Dictionary positive; @@ -2480,9 +2247,7 @@ TEST_CASE("Documentation: DoubleVector3Verifier", "[documentation]") { using namespace std::string_literals; const Documentation doc = { - .entries = { - { "a", new DoubleVector3Verifier, Optional::No } - } + .entries = {{ "a", new DoubleVector3Verifier }} }; ghoul::Dictionary positive; @@ -2519,9 +2284,7 @@ TEST_CASE("Documentation: IntVector4Verifier", "[documentation]") { using namespace std::string_literals; const Documentation doc = { - .entries = { - { "a", new IntVector4Verifier, Optional::No } - } + .entries = {{ "a", new IntVector4Verifier }} }; ghoul::Dictionary positive; @@ -2559,9 +2322,7 @@ TEST_CASE("Documentation: DoubleVector4Verifier", "[documentation]") { using namespace std::string_literals; const Documentation doc = { - .entries = { - { "a", new DoubleVector4Verifier, Optional::No } - } + .entries = {{ "a", new DoubleVector4Verifier }} }; ghoul::Dictionary positive; @@ -2599,9 +2360,7 @@ TEST_CASE("Documentation: DoubleMatrix2x2Verifier", "[documentation]") { using namespace std::string_literals; const Documentation doc = { - .entries = { - { "a", new DoubleMatrix2x2Verifier, Optional::No } - } + .entries = {{ "a", new DoubleMatrix2x2Verifier }} }; ghoul::Dictionary positive; @@ -2638,9 +2397,7 @@ TEST_CASE("Documentation: DoubleMatrix2x3Verifier", "[documentation]") { using namespace std::string_literals; const Documentation doc = { - .entries = { - { "a", new DoubleMatrix2x3Verifier, Optional::No } - } + .entries = {{ "a", new DoubleMatrix2x3Verifier }} }; ghoul::Dictionary positive; @@ -2677,9 +2434,7 @@ TEST_CASE("Documentation: DoubleMatrix2x4Verifier", "[documentation]") { using namespace std::string_literals; const Documentation doc = { - .entries = { - { "a", new DoubleMatrix2x4Verifier, Optional::No } - } + .entries = {{ "a", new DoubleMatrix2x4Verifier }} }; ghoul::Dictionary positive; @@ -2716,9 +2471,7 @@ TEST_CASE("Documentation: DoubleMatrix3x2Verifier", "[documentation]") { using namespace std::string_literals; const Documentation doc = { - .entries = { - { "a", new DoubleMatrix3x2Verifier, Optional::No } - } + .entries = {{ "a", new DoubleMatrix3x2Verifier }} }; ghoul::Dictionary positive; @@ -2755,9 +2508,7 @@ TEST_CASE("Documentation: DoubleMatrix3x3Verifier", "[documentation]") { using namespace std::string_literals; const Documentation doc = { - .entries = { - { "a", new DoubleMatrix3x3Verifier, Optional::No } - } + .entries = {{ "a", new DoubleMatrix3x3Verifier }} }; ghoul::Dictionary positive; @@ -2794,9 +2545,7 @@ TEST_CASE("Documentation: DoubleMatrix3x4Verifier", "[documentation]") { using namespace std::string_literals; const Documentation doc = { - .entries = { - { "a", new DoubleMatrix3x4Verifier, Optional::No } - } + .entries = {{ "a", new DoubleMatrix3x4Verifier }} }; ghoul::Dictionary positive; @@ -2833,9 +2582,7 @@ TEST_CASE("Documentation: DoubleMatrix4x2Verifier", "[documentation]") { using namespace std::string_literals; const Documentation doc = { - .entries = { - { "a", new DoubleMatrix4x2Verifier, Optional::No } - } + .entries = {{ "a", new DoubleMatrix4x2Verifier }} }; ghoul::Dictionary positive; @@ -2872,9 +2619,7 @@ TEST_CASE("Documentation: DoubleMatrix4x3Verifier", "[documentation]") { using namespace std::string_literals; const Documentation doc = { - .entries = { - { "a", new DoubleMatrix4x3Verifier, Optional::No } - } + .entries = {{ "a", new DoubleMatrix4x3Verifier }} }; ghoul::Dictionary positive; @@ -2911,9 +2656,7 @@ TEST_CASE("Documentation: DoubleMatrix4x4Verifier", "[documentation]") { using namespace std::string_literals; const Documentation doc = { - .entries = { - { "a", new DoubleMatrix4x4Verifier, Optional::No } - } + .entries = {{ "a", new DoubleMatrix4x4Verifier }} }; ghoul::Dictionary positive; diff --git a/tests/test_spicemanager.cpp b/tests/test_spicemanager.cpp index 3b0deb9585..fb257b02c2 100644 --- a/tests/test_spicemanager.cpp +++ b/tests/test_spicemanager.cpp @@ -229,7 +229,7 @@ TEST_CASE("SpiceManager: Get Target State", "[spicemanager]") { res = SpiceManager::ref().targetState("EARTH", "CASSINI", "J2000", corr, et) ); - for (int i = 0; i < 3; i++){ + for (int i = 0; i < 3; i++) { CHECK(state[i] == Catch::Approx(res.position[i])); CHECK(state[i+3] == Catch::Approx(res.velocity[i])); }