diff --git a/data/assets/scene/solarsystem/planets/mars/mars.asset b/data/assets/scene/solarsystem/planets/mars/mars.asset index ce0b6a175c..3d2d7e3f10 100644 --- a/data/assets/scene/solarsystem/planets/mars/mars.asset +++ b/data/assets/scene/solarsystem/planets/mars/mars.asset @@ -25,6 +25,7 @@ local color_layers = { FilePath = mapServiceConfigs .. "/Utah/Mars_Color.wms", Enabled = true, Fallback = { + Identifier = "Mars_Texture", Name = "Mars Texture", FilePath = textures .. "/mars.jpg", Enabled = true @@ -35,6 +36,7 @@ local color_layers = { Name = "MOC WA Color [Sweden]", FilePath = mapServiceConfigs .. "/LiU/Color.wms", Fallback = { + Identifier = "Mars_Texture", Name = "Mars Texture", FilePath = textures .. "/mars.jpg", Enabled = true diff --git a/include/openspace/documentation/documentation.h b/include/openspace/documentation/documentation.h index 089e19d776..6dc9432799 100644 --- a/include/openspace/documentation/documentation.h +++ b/include/openspace/documentation/documentation.h @@ -57,7 +57,6 @@ struct TestResult { */ enum class Reason { MissingKey, ///< The offending key that was requested was not found - ExtraKey, ///< The exhaustive documentation contained an extra key WrongType, ///< The key's value was not of the expected type Verification, ///< The value did not pass a necessary non-type verifier UnknownIdentifier ///< The identifier for a ReferencingVerifier did not exist diff --git a/modules/globebrowsing/globebrowsingmodule.cpp b/modules/globebrowsing/globebrowsingmodule.cpp index c1d976da57..bbd35e3acf 100644 --- a/modules/globebrowsing/globebrowsingmodule.cpp +++ b/modules/globebrowsing/globebrowsingmodule.cpp @@ -28,7 +28,11 @@ #include #include #include +#include #include +#include +#include +#include #include #include #include @@ -482,6 +486,15 @@ scripting::LuaLibrary GlobeBrowsingModule::luaLibrary() const { return res; } +std::vector GlobeBrowsingModule::documentations() const { + return { + globebrowsing::Layer::Documentation(), + globebrowsing::LayerAdjustment::Documentation(), + globebrowsing::LayerManager::Documentation(), + GlobeLabelsComponent::Documentation() + }; +} + void GlobeBrowsingModule::goToChunk(const globebrowsing::RenderableGlobe& globe, int x, int y, int level) { diff --git a/modules/globebrowsing/globebrowsingmodule.h b/modules/globebrowsing/globebrowsingmodule.h index 89e397d8ab..8f9367a0fd 100644 --- a/modules/globebrowsing/globebrowsingmodule.h +++ b/modules/globebrowsing/globebrowsingmodule.h @@ -65,6 +65,8 @@ public: globebrowsing::cache::MemoryAwareTileCache* tileCache(); scripting::LuaLibrary luaLibrary() const override; + std::vector documentations() const override; + const globebrowsing::RenderableGlobe* castFocusNodeRenderableToGlobe(); struct Layer { diff --git a/modules/globebrowsing/src/layer.cpp b/modules/globebrowsing/src/layer.cpp index e07f632bbb..b176825333 100644 --- a/modules/globebrowsing/src/layer.cpp +++ b/modules/globebrowsing/src/layer.cpp @@ -24,6 +24,8 @@ #include +#include +#include #include #include #include @@ -93,6 +95,114 @@ namespace { }; } // namespace +documentation::Documentation Layer::Documentation() { + using namespace documentation; + return { + "Layer", + "globebrowsing_layer", + { + { + KeyIdentifier, + new StringVerifier, + Optional::No, + "The unique identifier for this layer. May not contain '.' or spaces." + }, + { + KeyName, + new StringVerifier, + Optional::Yes, + "A human-readable name for the user interface. If this is omitted, the " + "identifier is used instead." + }, + { + KeyDesc, + new StringVerifier, + Optional::Yes, + "A human-readable description of the layer to be used in informational " + "texts presented to the user." + }, + { + "Type", + new StringInListVerifier({ + "DefaultTileLayer", "SingleImageTileLayer", "SizeReferenceTileLayer", + "TemporalTileLayer", "TileIndexTileLayer", "ByIndexTileLayer", + "ByLevelTileLayer", "SolidColor" + }), + Optional::Yes, + "Specifies the type of layer that is to be added. If this value is not " + "specified, the layer is a DefaultTileLayer." + }, + { + EnabledInfo.identifier, + new BoolVerifier, + Optional::Yes, + "Determine whether the layer is enabled or not. If this value is not " + "specified, the layer is disabled." + }, + { + KeyPadTiles, + new BoolVerifier, + Optional::Yes, + "Determines whether the downloaded tiles should have a padding added to " + "the borders." + }, + { + KeySettings, + new TableVerifier({ + { + KeyOpacity, + new DoubleInRangeVerifier(0.0, 1.0), + Optional::Yes, + "The opacity value of the layer." + }, + { + KeyGamma, + new DoubleVerifier, + Optional::Yes, + "The gamma value that is applied to each pixel of the layer." + }, + { + KeyMultiplier, + new DoubleVerifier, + Optional::Yes, + "The multiplicative factor that is applied to each pixel of the " + "layer." + }, + { + KeyOffset, + new DoubleVerifier, + Optional::Yes, + "An additive offset that is applied to each pixel of the layer." + } + }), + Optional::Yes, + "Specifies the render settings that should be applied to this layer." + }, + { + KeyAdjustment, + new ReferencingVerifier("globebrowsing_layeradjustment"), + Optional::Yes, + "" + }, + { + BlendModeInfo.identifier, + new StringInListVerifier({ + "Normal", "Multiply", "Add", "Subtract", "Color" + }), + Optional::Yes, + "Sets the blend mode of this layer to determine how it interacts with " + "other layers on top of this." + }, + { + "Fallback", + new ReferencingVerifier("globebrowsing_layer"), + Optional::Yes, + "If the primary layer creation fails, this layer is used as a fallback" + } + } + }; +} + Layer::Layer(layergroupid::GroupID id, const ghoul::Dictionary& layerDict, LayerGroup& parent) : properties::PropertyOwner({ @@ -109,13 +219,15 @@ Layer::Layer(layergroupid::GroupID id, const ghoul::Dictionary& layerDict, , _solidColor(ColorInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(1.f)) , _layerGroupId(id) { + documentation::testSpecificationAndThrow(Documentation(), layerDict, "Layer"); + layergroupid::TypeID typeID; if (layerDict.hasKeyAndValue("Type")) { const std::string& typeString = layerDict.value("Type"); typeID = ghoul::from_string(typeString); } else { - typeID = layergroupid::TypeID::DefaultTileLayer; + typeID = layergroupid::TypeID::DefaultTileLayer; } if (typeID == layergroupid::TypeID::Unknown) { throw ghoul::RuntimeError("Unknown layer type!"); diff --git a/modules/globebrowsing/src/layer.h b/modules/globebrowsing/src/layer.h index 908217611f..fb8f30dfd4 100644 --- a/modules/globebrowsing/src/layer.h +++ b/modules/globebrowsing/src/layer.h @@ -34,6 +34,8 @@ #include #include +namespace openspace::documentation { struct Documentation; } + namespace openspace::globebrowsing { struct LayerGroup; @@ -72,6 +74,8 @@ public: glm::vec2 tileUvToTextureSamplePosition(const TileUvTransform& uvTransform, const glm::vec2& tileUV, const glm::uvec2& resolution); + static documentation::Documentation Documentation(); + private: void initializeBasedOnType(layergroupid::TypeID typeId, ghoul::Dictionary initDict); void addVisibleProperties(); diff --git a/modules/globebrowsing/src/layeradjustment.cpp b/modules/globebrowsing/src/layeradjustment.cpp index e529c544ed..3317133bb0 100644 --- a/modules/globebrowsing/src/layeradjustment.cpp +++ b/modules/globebrowsing/src/layeradjustment.cpp @@ -24,6 +24,9 @@ #include +#include +#include + namespace { constexpr const char* KeyType = "Type"; constexpr const char* KeyChromaKeyColor = "ChromaKeyColor"; @@ -51,6 +54,35 @@ namespace { namespace openspace::globebrowsing { +documentation::Documentation LayerAdjustment::Documentation() { + using namespace documentation; + return { + "LayerAdjustment", + "globebrowsing_layeradjustment", + { + { + KeyType, + new StringInListVerifier({ "None", "ChromaKey", "TransferFunction" }), + Optional::Yes, + "Specifies the type of the adjustment that is applied" + }, + { + KeyChromaKeyColor, + new DoubleVector3Verifier, + Optional::Yes, + "Specifies the chroma key used when selecting 'ChromaKey' for the 'Type'." + }, + { + KeyChromaKeyTolerance, + new DoubleVerifier, + Optional::Yes, + "Specifies the tolerance to match the color to the chroma key when the " + "'ChromaKey' type is selected for the 'Type'." + } + } + }; +} + LayerAdjustment::LayerAdjustment() : properties::PropertyOwner({ "adjustment" }) , _chromaKeyColor(ChromaKeyColorInfo, glm::vec3(0.f), glm::vec3(0.f), glm::vec3(1.f)) @@ -89,6 +121,12 @@ LayerAdjustment::LayerAdjustment() } void LayerAdjustment::setValuesFromDictionary(const ghoul::Dictionary& adjustmentDict) { + documentation::testSpecificationAndThrow( + Documentation(), + adjustmentDict, + "LayerAdjustment" + ); + if (adjustmentDict.hasKeyAndValue(KeyType)) { std::string dictType = adjustmentDict.value(KeyType); _typeOption = static_cast( diff --git a/modules/globebrowsing/src/layeradjustment.h b/modules/globebrowsing/src/layeradjustment.h index eefa79c047..07c7c9460c 100644 --- a/modules/globebrowsing/src/layeradjustment.h +++ b/modules/globebrowsing/src/layeradjustment.h @@ -32,6 +32,8 @@ #include #include +namespace openspace::documentation { struct Documentation; } + namespace openspace::globebrowsing { namespace tileprovider { struct TileProvider; } @@ -50,6 +52,8 @@ public: void onChange(std::function callback); + static documentation::Documentation Documentation(); + private: void addVisibleProperties(); diff --git a/modules/globebrowsing/src/layergroup.cpp b/modules/globebrowsing/src/layergroup.cpp index df012f3a9f..909eb3dae4 100644 --- a/modules/globebrowsing/src/layergroup.cpp +++ b/modules/globebrowsing/src/layergroup.cpp @@ -25,6 +25,7 @@ #include #include +#include #include namespace { @@ -106,6 +107,14 @@ int LayerGroup::update() { } Layer* LayerGroup::addLayer(const ghoul::Dictionary& layerDict) { + documentation::TestResult res = documentation::testSpecification( + Layer::Documentation(), + layerDict + ); + if (!res.success) { + LERROR("Error adding layer. " + ghoul::to_string(res)); + } + if (!layerDict.hasKeyAndValue("Identifier")) { LERROR("'Identifier' must be specified for layer."); return nullptr; diff --git a/modules/globebrowsing/src/layermanager.cpp b/modules/globebrowsing/src/layermanager.cpp index 825f465fa7..18b91da259 100644 --- a/modules/globebrowsing/src/layermanager.cpp +++ b/modules/globebrowsing/src/layermanager.cpp @@ -28,10 +28,28 @@ #include #include #include +#include +#include #include 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) { diff --git a/modules/globebrowsing/src/layermanager.h b/modules/globebrowsing/src/layermanager.h index bd504210c1..3052f8f4ee 100644 --- a/modules/globebrowsing/src/layermanager.h +++ b/modules/globebrowsing/src/layermanager.h @@ -35,6 +35,8 @@ namespace ghoul { class Dictionary; } +namespace openspace::documentation { struct Documentation; } + namespace openspace::globebrowsing { class Layer; @@ -70,6 +72,8 @@ public: void onChange(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 51c263d9c3..285c19c13a 100644 --- a/modules/globebrowsing/src/renderableglobe.cpp +++ b/modules/globebrowsing/src/renderableglobe.cpp @@ -31,6 +31,8 @@ #include #include #include +#include +#include #include #include #include @@ -424,6 +426,57 @@ Chunk::Chunk(const TileIndex& ti) , status(Status::DoNothing) {} +documentation::Documentation RenderableGlobe::Documentation() { + using namespace documentation; + return { + "RenderableGlobe", + "globebrowsing_renderableglobe", + { + { + "Type", + new StringEqualVerifier("RenderableGlobe"), + Optional::No, + "" + }, + { + KeyRadii, + new OrVerifier({ new DoubleVector3Verifier, new DoubleVerifier }), + Optional::Yes, + "Specifies the radii for this planet. If the Double version of this is " + "used, all three radii are assumed to be equal." + }, + { + "PerformShading", + new BoolVerifier, + Optional::Yes, + "Specifies whether the planet should be shaded by the primary light " + "source or not. If it is disabled, all parts of the planet are " + "illuminated." + }, + { + KeyLayers, + new TableVerifier({ + { + "*", + new ReferencingVerifier("globebrowsing_layermanager"), + Optional::Yes, + "Descriptions of the individual layer groups" + } + }), + Optional::Yes, + "A list of all the layers that should be added" + }, + { + KeyLabels, + new ReferencingVerifier("globebrowsing_globelabelscomponent"), + Optional::Yes, + "Specifies information about planetary labels that can be rendered on " + "the object's surface." + } + } + }; +} + RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary) : Renderable(dictionary) , _debugProperties({ diff --git a/modules/globebrowsing/src/renderableglobe.h b/modules/globebrowsing/src/renderableglobe.h index 7886c0d3e2..26cd45573c 100644 --- a/modules/globebrowsing/src/renderableglobe.h +++ b/modules/globebrowsing/src/renderableglobe.h @@ -41,6 +41,8 @@ #include #include +namespace openspace::documentation { struct Documentation; } + namespace openspace::globebrowsing { class GPULayerGroup; @@ -111,6 +113,8 @@ public: LayerManager& layerManager(); const glm::dmat4& modelTransform() const; + static documentation::Documentation Documentation(); + private: constexpr static const int MinSplitDepth = 2; constexpr static const int MaxSplitDepth = 22; diff --git a/src/documentation/documentation.cpp b/src/documentation/documentation.cpp index cfd5e5db9c..9f42f6d3c8 100644 --- a/src/documentation/documentation.cpp +++ b/src/documentation/documentation.cpp @@ -94,8 +94,6 @@ template <> std::string to_string(const openspace::documentation::TestResult::Offense::Reason& value) { switch (value) { - case openspace::documentation::TestResult::Offense::Reason::ExtraKey: - return "Extra key"; case openspace::documentation::TestResult::Offense::Reason::MissingKey: return "Missing key"; case openspace::documentation::TestResult::Offense::Reason::UnknownIdentifier: