mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-06 03:29:44 -06:00
Feature/codegen (#1480)
* Add the ability to automatically generate code to extract values out of a Dictionary (see https://github.com/openspace/codegen for more information on how to use this) * Applied this technique to a large number of cases in the codebase * Don't add _codegen files to the repository Co-authored-by: Emma Broman <emma.broman@liu.se>
This commit is contained in:
@@ -41,24 +41,20 @@ namespace {
|
||||
"this value is changed, the image at the new path will automatically be loaded "
|
||||
"and displayed."
|
||||
};
|
||||
|
||||
struct [[codegen::Dictionary(RenderablePlaneImageOnline)]] Parameters {
|
||||
// [[codegen::verbatim(TextureInfo.description)]]
|
||||
std::string url [[codegen::key("URL")]];
|
||||
};
|
||||
#include "renderableplaneimageonline_codegen.cpp"
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
documentation::Documentation RenderablePlaneImageOnline::Documentation() {
|
||||
using namespace documentation;
|
||||
return {
|
||||
"Renderable Plane Image Online",
|
||||
"base_renderable_plane_image_online",
|
||||
{
|
||||
{
|
||||
TextureInfo.identifier,
|
||||
new StringVerifier,
|
||||
Optional::No,
|
||||
TextureInfo.description,
|
||||
}
|
||||
}
|
||||
};
|
||||
documentation::Documentation doc = codegen::doc<Parameters>();
|
||||
doc.id = "base_renderable_plane_image_online";
|
||||
return doc;
|
||||
}
|
||||
|
||||
RenderablePlaneImageOnline::RenderablePlaneImageOnline(
|
||||
@@ -66,20 +62,12 @@ RenderablePlaneImageOnline::RenderablePlaneImageOnline(
|
||||
: RenderablePlane(dictionary)
|
||||
, _texturePath(TextureInfo)
|
||||
{
|
||||
documentation::testSpecificationAndThrow(
|
||||
Documentation(),
|
||||
dictionary,
|
||||
"RenderablePlaneImageOnline"
|
||||
);
|
||||
const Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
|
||||
_texturePath.onChange([this]() { _textureIsDirty = true; });
|
||||
addProperty(_texturePath);
|
||||
|
||||
std::string texturePath;
|
||||
if (dictionary.hasKey(TextureInfo.identifier)) {
|
||||
_texturePath = dictionary.value<std::string>(TextureInfo.identifier);
|
||||
}
|
||||
|
||||
_texturePath = p.url;
|
||||
addProperty(_texturePath);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user