diff --git a/modules/space/rendering/renderableplanet.cpp b/modules/space/rendering/renderableplanet.cpp index c4bf732375..28c70d9264 100644 --- a/modules/space/rendering/renderableplanet.cpp +++ b/modules/space/rendering/renderableplanet.cpp @@ -65,6 +65,44 @@ namespace { const char* keyShadowSource = "Source"; const char* keyShadowCaster = "Caster"; const char* keyBody = "Body"; + + static const openspace::properties::Property::PropertyInfo ColorTextureInfo = { + "PlanetTexture", + "Color Base Texture", + "The path to the base color texture that is used on the planet prior to any " + "image projection." + }; + + static const openspace::properties::Property::PropertyInfo HeightTextureInfo = { + "HeightMap", + "Heightmap Texture", + "The path to the height map texture that is used for the planet. If no height " + "map is specified the planet does not use a height field." + }; + + static const openspace::properties::Property::PropertyInfo NightTextureInfo = { + "NightTexture", + "Night Texture", + "The path to the night texture that is used for the part of the planet that is " + "facing away from the Sun. If no night texture is loaded, the night side of the " + "planet is rendered dark." + }; + + static const openspace::properties::Property::PropertyInfo HeightExaggerationInfo = { + "HeightExaggeration", + "Height Exaggeration", + "This value determines the level of height exaggeration that is applied to a " + "potential height field. A value of '0' inhibits the height field, whereas a " + "value of '1' uses the measured height field." + }; + + static const openspace::properties::Property::PropertyInfo PerformShadingInfo = { + "PerformShading", + "Perform Shading", + "If this value is enabled, the model will be shaded based on the relative " + "location to the Sun. If this value is disabled, shading is disabled and the " + "entire model is rendered brightly." + }; } // namespace namespace openspace { @@ -89,19 +127,19 @@ documentation::Documentation RenderablePlanet::Documentation() { Optional::Yes }, { - KeyColorTexture, + KeyColorTexture, // @TODO Use ColorTextureInfo.identifier instead new StringVerifier, "Specifies the color texture that is used for this RenderablePlanet.", Optional::Yes }, { - KeyHeightTexture, + KeyHeightTexture, // @TODO Use HeightTextureInfo.identifier instead new StringVerifier, "Specifies the height texture that is used for this RenderablePlanet.", Optional::Yes }, { - KeyNightTexture, + KeyNightTexture, // @TODO Use NightTextureInfo.identifier instead new StringVerifier, "Specifies the texture that is used for the night side of this " "RenderablePlanet.", @@ -114,6 +152,18 @@ documentation::Documentation RenderablePlanet::Documentation() { "this value is 'false', any existing night texture will not be used. " "This value defaults to 'true'.", Optional::Yes + }, + { + HeightExaggerationInfo.identifier, + new DoubleVerifier, + HeightExaggerationInfo.description, + Optional::Yes + }, + { + PerformShadingInfo.identifier, + new BoolVerifier, + PerformShadingInfo.description, + Optional::Yes } } }; @@ -121,15 +171,15 @@ documentation::Documentation RenderablePlanet::Documentation() { RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary) : Renderable(dictionary) - , _colorTexturePath({ "ColorTexture", "Color Texture", "" }) // @TODO Missing documentation - , _nightTexturePath({ "NightTexture", "Night Texture", "" }) // @TODO Missing documentation - , _heightMapTexturePath({ "HeightMap", "Heightmap Texture", "" }) // @TODO Missing documentation + , _colorTexturePath(ColorTextureInfo) + , _nightTexturePath(NightTextureInfo) + , _heightMapTexturePath(HeightTextureInfo) , _programObject(nullptr) , _texture(nullptr) , _nightTexture(nullptr) - , _heightExaggeration({ "HeightExaggeration", "Height Exaggeration", "" }, 1.f, 0.f, 10.f) // @TODO Missing documentation + , _heightExaggeration(HeightExaggerationInfo, 1.f, 0.f, 10.f) , _geometry(nullptr) - , _performShading({ "PerformShading", "Perform Shading", "" }, true) // @TODO Missing documentation + , _performShading(PerformShadingInfo, true) , _alpha(1.f) , _planetRadius(0.f) , _hasNightTexture(false) @@ -201,7 +251,16 @@ RenderablePlanet::RenderablePlanet(const ghoul::Dictionary& dictionary) addProperty(_heightMapTexturePath); _heightMapTexturePath.onChange(loadTextureCallback); + if (dictionary.hasKey(HeightExaggerationInfo.identifier)) { + _heightExaggeration = static_cast( + dictionary.value(HeightExaggerationInfo.identifier) + ); + } addProperty(_heightExaggeration); + + if (dictionary.hasKey(HeightExaggerationInfo.identifier)) { + _performShading = dictionary.value(HeightExaggerationInfo.identifier); + } addProperty(_performShading); // Shadow data: diff --git a/modules/space/rendering/renderablerings.cpp b/modules/space/rendering/renderablerings.cpp index 7598a1d4ba..28367c68d1 100644 --- a/modules/space/rendering/renderablerings.cpp +++ b/modules/space/rendering/renderablerings.cpp @@ -38,9 +38,42 @@ #include namespace { - const char* KeyTexture = "Texture"; - const char* KeySize = "Size"; - const char* KeyOffset = "Offset"; + static const openspace::properties::Property::PropertyInfo TextureInfo = { + "Texture", + "Texture", + "This value is the path to a texture on disk that contains a one-dimensional " + "texture which is used for these rings." + }; + + static const openspace::properties::Property::PropertyInfo SizeInfo = { + "Size", + "Size", + "This value specifies the radius of the rings in meter." + }; + + static const openspace::properties::Property::PropertyInfo OffsetInfo = { + "Offset", + "Offset", + "This value is used to limit the width of the rings.Each of the two values is a " + "value between 0 and 1, where 0 is the center of the ring and 1 is the maximum " + "extent at the radius. If this value is, for example {0.5, 1.0}, the ring is " + "only shown between radius/2 and radius. It defaults to {0.0, 1.0}." + }; + + static const openspace::properties::Property::PropertyInfo NightFactorInfo = { + "NightFactor", + "Night Factor", + "This value is a multiplicative factor that is applied to the side of the rings " + "that is facing away from the Sun. If this value is equal to '1', no darkening " + "of the night side occurs." + }; + + static const openspace::properties::Property::PropertyInfo TransparencyInfo = { + "Transparency", + "Transparency", + "This value determines the transparency of part of the rings depending on the " + "color values. For this value v, the transparency is equal to length(color) / v." + }; } // namespace namespace openspace { @@ -58,38 +91,47 @@ documentation::Documentation RenderableRings::Documentation() { Optional::No }, { - KeyTexture, + TextureInfo.identifier, new StringVerifier, - "The one dimensional texture that is used for both sides of the ring.", + TextureInfo.description, Optional::No }, { - KeySize, + SizeInfo.identifier, new DoubleVerifier, - "The radius of the rings in meters.", + SizeInfo.description, Optional::No }, { - KeyOffset, + OffsetInfo.identifier, new DoubleVector2Verifier, - "The offset that is used to limit the width of the rings. Each of the " - "two values is a value between 0 and 1, where 0 is the center of the " - "ring and 1 is the maximum extent at the radius. If this value is, for " - "example {0.5, 1.0}, the ring is only shown between radius/2 and radius. " - "It defaults to {0.0, 1.0}.", + OffsetInfo.description, + Optional::Yes + }, + { + NightFactorInfo.identifier, + new DoubleVerifier, + NightFactorInfo.description, + Optional::Yes + }, + { + TransparencyInfo.identifier, + new DoubleVerifier, + TransparencyInfo.description, Optional::Yes } - } + }, + Exhaustive::Yes }; } RenderableRings::RenderableRings(const ghoul::Dictionary& dictionary) : Renderable(dictionary) - , _texturePath({ "Texture", "Texture", "" }) // @TODO Missing documentation - , _size({ "Size", "Size", "" }, 1.f, 0.f, std::pow(1.f, 25.f)) // @TODO Missing documentation - , _offset({ "Offset", "Offset", "" }, glm::vec2(0, 1.f), glm::vec2(0.f), glm::vec2(1.f)) // @TODO Missing documentation - , _nightFactor({ "NightFactor", "Night Factor", "" }, 0.33f, 0.f, 1.f) // @TODO Missing documentation - , _transparency({ "Transparency", "Transparency", "" }, 0.15f, 0.f, 1.f) // @TODO Missing documentation + , _texturePath(TextureInfo) + , _size(SizeInfo, 1.f, 0.f, 1e25) + , _offset(OffsetInfo, glm::vec2(0.f, 1.f), glm::vec2(0.f), glm::vec2(1.f)) + , _nightFactor(NightFactorInfo, 0.33f, 0.f, 1.f) + , _transparency(TransparencyInfo, 0.15f, 0.f, 1.f) , _shader(nullptr) , _texture(nullptr) , _textureFile(nullptr) @@ -106,26 +148,37 @@ RenderableRings::RenderableRings(const ghoul::Dictionary& dictionary) "RenderableRings" ); - _size = static_cast(dictionary.value(KeySize)); + _size = static_cast(dictionary.value(SizeInfo.identifier)); setBoundingSphere(_size); - addProperty(_size); _size.onChange([&]() { _planeIsDirty = true; }); + addProperty(_size); - _texturePath = absPath(dictionary.value(KeyTexture)); + _texturePath = absPath(dictionary.value(TextureInfo.identifier)); _textureFile = std::make_unique(_texturePath); - if (dictionary.hasKeyAndValue(KeyOffset)) { - _offset = dictionary.value(KeyOffset); + if (dictionary.hasKey(OffsetInfo.identifier)) { + _offset = dictionary.value(OffsetInfo.identifier); } addProperty(_offset); + _texturePath.onChange([&]() { loadTexture(); }); addProperty(_texturePath); - _texturePath.onChange([&](){ loadTexture(); }); _textureFile->setCallback([&](const File&) { _textureIsDirty = true; }); + if (dictionary.hasKey(NightFactorInfo.identifier)) { + _nightFactor = static_cast( + dictionary.value(NightFactorInfo.identifier) + ); + } addProperty(_nightFactor); + + if (dictionary.hasKey(TransparencyInfo.identifier)) { + _transparency = static_cast( + dictionary.value(TransparencyInfo.identifier) + ); + } addProperty(_transparency); } diff --git a/modules/space/rendering/renderablestars.cpp b/modules/space/rendering/renderablestars.cpp index 0e16a93cdd..ff414456da 100644 --- a/modules/space/rendering/renderablestars.cpp +++ b/modules/space/rendering/renderablestars.cpp @@ -45,8 +45,6 @@ namespace { const char* _loggerCat = "RenderableStars"; const char* KeyFile = "File"; - const char* KeyTexture = "Texture"; - const char* KeyColorMap = "ColorMap"; const int8_t CurrentCacheVersion = 1; @@ -79,6 +77,48 @@ namespace { float speed; }; + + static const openspace::properties::Property::PropertyInfo PsfTextureInfo = { + "Texture", + "Point Spread Function Texture", + "The path to the texture that should be used as a point spread function for the " + "stars." + }; + + static const openspace::properties::Property::PropertyInfo ColorTextureInfo = { + "ColorMap", + "ColorBV Texture", + "The path to the texture that is used to convert from the B-V value of the star " + "to its color. The texture is used as a one dimensional lookup function." + }; + + static const openspace::properties::Property::PropertyInfo ColorOptionInfo = { + "ColorOption", + "Color Option", + "This value determines which quantity is used for determining the color of the " + "stars." + }; + + static const openspace::properties::Property::PropertyInfo TransparencyInfo = { + "Transparency", + "Transparency", + "This value is a multiplicative factor that is applied to the transparency of " + "all stars." + }; + + static const openspace::properties::Property::PropertyInfo ScaleFactorInfo = { + "ScaleFactor", + "Scale Factor", + "This value is used as a multiplicative factor that is applied to the apparent " + "size of each star." + }; + + static const openspace::properties::Property::PropertyInfo MinBillboardSizeInfo = { + "MinBillboardSize", + "Min Billboard Size", + "This value is used as a lower limit on the size of stars that are rendered. Any " + "stars that have a smaller apparent size will be discarded entirely." + }; } // namespace namespace openspace { @@ -103,20 +143,42 @@ documentation::Documentation RenderableStars::Documentation() { Optional::No }, { - KeyTexture, + PsfTextureInfo.identifier, new StringVerifier, - "The path to the texture that should be used as a point spread function " - "for the stars. The path is relative to the location of the .mod file " - "and can contain file system token.", + PsfTextureInfo.description, Optional::No }, { - KeyColorMap, + ColorTextureInfo.identifier, new StringVerifier, - "The path to the texture that is used to convert from the B-V value of " - "the star to its color. The texture is used as a one dimensional lookup " - "function.", + ColorTextureInfo.description, Optional::No + }, + { + ColorOptionInfo.identifier, + new StringInListVerifier({ + "Color", "Velocity", "Speed" + }), + ColorOptionInfo.description, + Optional::Yes + }, + { + TransparencyInfo.identifier, + new DoubleVerifier, + TransparencyInfo.description, + Optional::Yes + }, + { + ScaleFactorInfo.identifier, + new DoubleVerifier, + ScaleFactorInfo.description, + Optional::Yes + }, + { + MinBillboardSizeInfo.identifier, + new DoubleVerifier, + MinBillboardSizeInfo.description, + Optional::Yes } } }; @@ -125,20 +187,17 @@ documentation::Documentation RenderableStars::Documentation() { RenderableStars::RenderableStars(const ghoul::Dictionary& dictionary) : Renderable(dictionary) - , _pointSpreadFunctionTexturePath({ "PsfTexture", "Point Spread Function Texture", "" }) // @TODO Missing documentation + , _pointSpreadFunctionTexturePath(PsfTextureInfo) , _pointSpreadFunctionTexture(nullptr) , _pointSpreadFunctionTextureIsDirty(true) - , _colorTexturePath({ "ColorTexture", "ColorBV Texture", "" }) // @TODO Missing documentation + , _colorTexturePath(ColorTextureInfo) , _colorTexture(nullptr) , _colorTextureIsDirty(true) - , _colorOption( - { "ColorOption", "Color Option", "" }, // @TODO Missing documentation - properties::OptionProperty::DisplayType::Dropdown - ) + , _colorOption(ColorOptionInfo, properties::OptionProperty::DisplayType::Dropdown) , _dataIsDirty(true) - , _alphaValue({ "AlphaValue", "Transparency", "" }, 1.f, 0.f, 1.f) // @TODO Missing documentation - , _scaleFactor({ "ScaleFactor", "Scale Factor", "" }, 1.f, 0.f, 10.f) // @TODO Missing documentation - , _minBillboardSize({ "MinBillboardSize", "Min Billboard Size", "" }, 1.f, 1.f, 100.f) // @TODO Missing documentation + , _alphaValue(TransparencyInfo, 1.f, 0.f, 1.f) + , _scaleFactor(ScaleFactorInfo, 1.f, 0.f, 10.f) + , _minBillboardSize(MinBillboardSizeInfo, 1.f, 1.f, 100.f) , _program(nullptr) , _speckFile("") , _nValuesPerStar(0) @@ -161,34 +220,62 @@ RenderableStars::RenderableStars(const ghoul::Dictionary& dictionary) _speckFile = absPath(dictionary.value(KeyFile)); - //_colorOption.addOptions({ - // { ColorOption::Color, "Color" }, - // { ColorOption::Velocity, "Velocity" }, - // { ColorOption::Speed, "Speed" } - //}); - _colorOption.addOption(ColorOption::Color, "Color"); - _colorOption.addOption(ColorOption::Velocity, "Velocity"); - _colorOption.addOption(ColorOption::Speed, "Speed"); + _colorOption.addOptions({ + { ColorOption::Color, "Color" }, + { ColorOption::Velocity, "Velocity" }, + { ColorOption::Speed, "Speed" } + }); + if (dictionary.hasKey(ColorOptionInfo.identifier)) { + const std::string colorOption = dictionary.value( + ColorOptionInfo.identifier + ); + if (colorOption == "Color") { + _colorOption = ColorOption::Color; + } + else if (colorOption == "Velocity") { + _colorOption = ColorOption::Velocity; + } + else { + _colorOption = ColorOption::Speed; + } + } + _colorOption.onChange([&] { _dataIsDirty = true; }); addProperty(_colorOption); - _colorOption.onChange([&]{ _dataIsDirty = true;}); - addProperty(_pointSpreadFunctionTexturePath); _pointSpreadFunctionTexturePath.onChange( [&]{ _pointSpreadFunctionTextureIsDirty = true; } ); _pointSpreadFunctionFile->setCallback( [&](const File&) { _pointSpreadFunctionTextureIsDirty = true; } ); + addProperty(_pointSpreadFunctionTexturePath); - addProperty(_colorTexturePath); _colorTexturePath.onChange([&]{ _colorTextureIsDirty = true; }); _colorTextureFile->setCallback( [&](const File&) { _colorTextureIsDirty = true; } ); + addProperty(_colorTexturePath); + if (dictionary.hasKey(TransparencyInfo.identifier)) { + _alphaValue = static_cast( + dictionary.value(TransparencyInfo.identifier) + ); + } addProperty(_alphaValue); + + if (dictionary.hasKey(ScaleFactorInfo.identifier)) { + _scaleFactor = static_cast( + dictionary.value(ScaleFactorInfo.identifier) + ); + } addProperty(_scaleFactor); + + if (dictionary.hasKey(MinBillboardSizeInfo.identifier)) { + _minBillboardSize = static_cast( + dictionary.value(MinBillboardSizeInfo.identifier) + ); + } addProperty(_minBillboardSize); } diff --git a/modules/space/rendering/simplespheregeometry.cpp b/modules/space/rendering/simplespheregeometry.cpp index 7d97071129..103e45855d 100644 --- a/modules/space/rendering/simplespheregeometry.cpp +++ b/modules/space/rendering/simplespheregeometry.cpp @@ -23,70 +23,108 @@ ****************************************************************************************/ #include -#include + +#include #include #include +#include namespace { const char* _loggerCat = "SimpleSphereGeometry"; - const char* keyRadius = "Radius"; - const char* keySegments = "Segments"; + static const openspace::properties::Property::PropertyInfo RadiusInfo = { + "Radius", + "Radius", + "This value specifies the radius of this sphere in meters." + }; + + static const openspace::properties::Property::PropertyInfo SegmentsInfo = { + "Segments", + "Segments", + "This value specifies the number of segments that this sphere is split into." + }; } // namespace namespace openspace::planetgeometry { +documentation::Documentation SimpleSphereGeometry::Documentation() { + using namespace documentation; + return { + "SimpleSphereGeometry", + "space_geometry_simplesphere", + { + { + "Type", + new StringEqualVerifier("SimpleSphereGeometry"), + "", + Optional::No + }, + { + RadiusInfo.identifier, + new OrVerifier( + new DoubleVerifier, + new DoubleVector3Verifier + ), + RadiusInfo.description, + Optional::No + }, + { + SegmentsInfo.identifier, + new IntVerifier, + SegmentsInfo.description, + Optional::No + } + }, + Exhaustive::Yes + }; +} + SimpleSphereGeometry::SimpleSphereGeometry(const ghoul::Dictionary& dictionary) : PlanetGeometry() - , _radius( - { "Radius", "Radius", "" }, // @TODO Missing documentation - glm::vec3(1.f, 1.f, 1.f), - glm::vec3(0.f, 0.f, 0.f), - glm::vec3(std::pow(10.f, 20.f), std::pow(10.f, 20.f), std::pow(10.f, 20.f))) - , _segments({ "Segments", "Segments", "" }, 20, 1, 5000) // @TODO Missing documentation + , _radius(RadiusInfo, glm::vec3(1.f), glm::vec3(0.f), glm::vec3(std::pow(10.f, 20.f))) + , _segments(SegmentsInfo, 20, 1, 5000) , _sphere(nullptr) { + documentation::testSpecificationAndThrow( + Documentation(), + dictionary, + "SimpleSphereGeometry" + ); + float sphereRadius = 0.f; glm::vec3 ellipsoidRadius; - if (dictionary.getValue(keyRadius, sphereRadius)) { - _radius = { sphereRadius, sphereRadius, sphereRadius }; - } else if (dictionary.getValue(keyRadius, ellipsoidRadius)) { - _radius = ellipsoidRadius; - } else { - LERROR("SimpleSphereGeometry did not provide a key '" - << keyRadius << "'"); + if (dictionary.hasKeyAndValue(RadiusInfo.identifier)) { + const float r = static_cast( + dictionary.value(RadiusInfo.identifier) + ); + _radius = { r, r, r }; + } + else { + _radius = dictionary.value(RadiusInfo.identifier); } - double segments = 0; - if (dictionary.getValue(keySegments, segments)) { - _segments = static_cast(segments); - } else { - LERROR("SimpleSphereGeometry did not provide a key '" - << keySegments << "'"); - } + _segments = dictionary.value(SegmentsInfo.identifier); // The shader need the radii values but they are not changeable runtime // TODO: Possibly add a scaling property @AA - addProperty(_radius); // Changing the radius/scaling should affect the shader but not the geometry? @AA - _radius.onChange(std::bind(&SimpleSphereGeometry::createSphere, this)); + _radius.onChange([&]() { createSphere(); }); + addProperty(_radius); + + _segments.onChange([&]() { createSphere(); }); addProperty(_segments); - _segments.onChange(std::bind(&SimpleSphereGeometry::createSphere, this)); } -SimpleSphereGeometry::~SimpleSphereGeometry() { -} +SimpleSphereGeometry::~SimpleSphereGeometry() {} -bool SimpleSphereGeometry::initialize(Renderable* parent) -{ +bool SimpleSphereGeometry::initialize(Renderable* parent) { bool success = PlanetGeometry::initialize(parent); createSphere(); return success; } void SimpleSphereGeometry::deinitialize() { - if (_sphere) - delete _sphere; + delete _sphere; _sphere = nullptr; } @@ -94,13 +132,11 @@ void SimpleSphereGeometry::render() { _sphere->render(); } -void SimpleSphereGeometry::createSphere(){ +void SimpleSphereGeometry::createSphere() { const glm::vec3 radius = _radius.value(); _parent->setBoundingSphere(std::max(std::max(radius[0], radius[1]), radius[2])); - if(_sphere) - delete _sphere; - + delete _sphere; _sphere = new PowerScaledSphere(glm::vec4(radius, 0.0), _segments); _sphere->initialize(); } diff --git a/modules/space/rendering/simplespheregeometry.h b/modules/space/rendering/simplespheregeometry.h index 20c7e84f60..78f42392b5 100644 --- a/modules/space/rendering/simplespheregeometry.h +++ b/modules/space/rendering/simplespheregeometry.h @@ -35,6 +35,8 @@ namespace openspace { class PowerScaledSphere; } // namespace openspace +namespace openspace::documentation { struct Documentation; } + namespace openspace::planetgeometry { class SimpleSphereGeometry : public PlanetGeometry { @@ -46,6 +48,8 @@ public: void deinitialize() override; void render() override; + static documentation::Documentation Documentation(); + private: void createSphere(); diff --git a/modules/space/rotation/spicerotation.cpp b/modules/space/rotation/spicerotation.cpp index d778a2039e..fe02d671bd 100644 --- a/modules/space/rotation/spicerotation.cpp +++ b/modules/space/rotation/spicerotation.cpp @@ -35,6 +35,20 @@ namespace { const char* KeySourceFrame = "SourceFrame"; const char* KeyDestinationFrame = "DestinationFrame"; const char* KeyKernels = "Kernels"; + + static const openspace::properties::Property::PropertyInfo SourceInfo = { + "Source", + "Source", + "This value specifies the source frame that is used as the basis for the " + "coordinate transformation. This has to be a valid SPICE name." + }; + + static const openspace::properties::Property::PropertyInfo DestinationInfo = { + "Destination", + "Destination", + "This value specifies the destination frame that is used for the coordinate " + "transformation. This has to be a valid SPICE name." + }; } // namespace namespace openspace { @@ -52,25 +66,21 @@ documentation::Documentation SpiceRotation::Documentation() { Optional::No }, { - KeySourceFrame, + SourceInfo.identifier, new StringAnnotationVerifier("A valid SPICE NAIF name or integer"), - "The source frame that is used as the basis for the coordinate " - "transformation. This has to be a valid SPICE name.", + SourceInfo.description, Optional::No }, { - KeyDestinationFrame, + DestinationInfo.identifier, new StringAnnotationVerifier("A valid SPICE NAIF name or integer"), - "The destination frame that is used for the coordinate transformation. " - "This has to be a valid SPICE name.", + DestinationInfo.description, Optional::No }, { KeyKernels, new OrVerifier( - new TableVerifier({ - { "*", new StringVerifier } - }), + new StringListVerifier, new StringVerifier ), "A single kernel or list of kernels that this SpiceTranslation depends " @@ -83,8 +93,8 @@ documentation::Documentation SpiceRotation::Documentation() { } SpiceRotation::SpiceRotation(const ghoul::Dictionary& dictionary) - : _sourceFrame({ "Source", "Source", "" }) // @TODO Missing documentation - , _destinationFrame({ "Destination", "Destination", "" }) // @TODO Missing documentation + : _sourceFrame(SourceInfo) // @TODO Missing documentation + , _destinationFrame(DestinationInfo) { documentation::testSpecificationAndThrow( Documentation(), @@ -92,8 +102,8 @@ SpiceRotation::SpiceRotation(const ghoul::Dictionary& dictionary) "SpiceRotation" ); - _sourceFrame = dictionary.value(KeySourceFrame); - _destinationFrame = dictionary.value(KeyDestinationFrame); + _sourceFrame = dictionary.value(SourceInfo.identifier); + _destinationFrame = dictionary.value(DestinationInfo.identifier); if (dictionary.hasKeyAndValue(KeyKernels)) { SpiceManager::ref().loadKernel(dictionary.value(KeyKernels)); diff --git a/modules/space/spacemodule.cpp b/modules/space/spacemodule.cpp index cd1baf6328..5b2ba60d00 100644 --- a/modules/space/spacemodule.cpp +++ b/modules/space/spacemodule.cpp @@ -86,7 +86,8 @@ std::vector SpaceModule::documentations() const { RenderableStars::Documentation(), SpiceRotation::Documentation(), SpiceTranslation::Documentation(), - planetgeometry::PlanetGeometry::Documentation() + planetgeometry::PlanetGeometry::Documentation(), + planetgeometry::SimpleSphereGeometry::Documentation() }; } diff --git a/modules/space/translation/spicetranslation.cpp b/modules/space/translation/spicetranslation.cpp index 4f3411f868..4ea74936a5 100644 --- a/modules/space/translation/spicetranslation.cpp +++ b/modules/space/translation/spicetranslation.cpp @@ -34,11 +34,30 @@ namespace { const char* KeyBody = "Body"; - const char* KeyObserver = "Observer"; - const char* KeyFrame = "Frame"; const char* KeyKernels = "Kernels"; - const char* DefaultReferenceFrame = "GALACTIC"; + static const openspace::properties::Property::PropertyInfo TargetInfo = { + "Target", + "Target", + "This is the SPICE NAIF name for the body whose translation is to be computed by " + "the SpiceTranslation. It can either be a fully qualified name (such as 'EARTH') " + "or a NAIF integer id code (such as '399')." + }; + + static const openspace::properties::Property::PropertyInfo OriginInfo = { + "Origin", + "Origin", + "This is the SPICE NAIF name for the parent of the body whose translation is to " + "be computed by the SpiceTranslation. It can either be a fully qualified name " + "(such as 'SOLAR SYSTEM BARYCENTER') or a NAIF integer id code (such as '0')." + }; + + static const openspace::properties::Property::PropertyInfo FrameInfo = { + "Frame", + "Reference Frame", + "This is the SPICE NAIF name for the reference frame in which the position " + "should be retrieved. The default value is GALACTIC." + }; } // namespace namespace openspace { @@ -57,7 +76,7 @@ documentation::Documentation SpiceTranslation::Documentation() { Optional::No }, { - KeyBody, + KeyBody, // @TODO Rename to TargetInfo.identifier new StringAnnotationVerifier("A valid SPICE NAIF name or identifier"), "This is the SPICE NAIF name for the body whose translation is to be " "computed by the SpiceTranslation. It can either be a fully qualified " @@ -65,22 +84,18 @@ documentation::Documentation SpiceTranslation::Documentation() { Optional::No }, { - KeyObserver, + OriginInfo.identifier, new StringAnnotationVerifier("A valid SPICE NAIF name or identifier"), - "This is the SPICE NAIF name for the parent of the body whose " - "translation is to be computed by the SpiceTranslation. It can either be " - "a fully qualified name (such as 'SOLAR SYSTEM BARYCENTER') or a NAIF " - "integer id code (such as '0').", + OriginInfo.description, Optional::No }, { - KeyFrame, + FrameInfo.identifier, new StringAnnotationVerifier( "A valid SPICE NAIF name for a reference frame" ), - "This is the SPICE NAIF name for the reference frame in which the " - "position should be retrieved. The default value is GALACTIC", - Optional::Yes + FrameInfo.description, + Optional::No }, { KeyKernels, @@ -99,9 +114,9 @@ documentation::Documentation SpiceTranslation::Documentation() { } SpiceTranslation::SpiceTranslation(const ghoul::Dictionary& dictionary) - : _target({ "Target", "Target", "" }) // @TODO Missing documentation - , _origin({ "Origin", "Origin", "" }) // @TODO Missing documentation - , _frame({ "Frame", "Reference Frame", "" }, DefaultReferenceFrame) // @TODO Missing documentation + : _target(TargetInfo) + , _origin(OriginInfo) + , _frame(FrameInfo) { documentation::testSpecificationAndThrow( Documentation(), @@ -109,12 +124,9 @@ SpiceTranslation::SpiceTranslation(const ghoul::Dictionary& dictionary) "SpiceTranslation" ); - _target = dictionary.value(KeyBody); - _origin = dictionary.value(KeyObserver); - - if (dictionary.hasKey(KeyFrame)) { - _frame = dictionary.value(KeyFrame); - } + _target = dictionary.value(TargetInfo.identifier); + _origin = dictionary.value(OriginInfo.identifier); + _frame = dictionary.value(FrameInfo.identifier); auto loadKernel = [](const std::string& kernel) { if (!FileSys.fileExists(kernel)) {