mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-02-21 12:29:04 -06:00
Make use of new verifiers (Color and File) (#1510)
* Use codegen for renderable discs * Utilize color and file verifier * Add missing property assignment in exoplanets module
This commit is contained in:
@@ -58,7 +58,7 @@ namespace {
|
||||
|
||||
struct [[codegen::Dictionary(RenderableBoxGrid)]] Parameters {
|
||||
// [[codegen::verbatim(ColorInfo.description)]]
|
||||
std::optional<glm::vec3> color;
|
||||
std::optional<glm::vec3> color [[codegen::color()]];
|
||||
|
||||
// [[codegen::verbatim(LineWidthInfo.description)]]
|
||||
std::optional<float> lineWidth;
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace {
|
||||
|
||||
struct [[codegen::Dictionary(RenderableGrid)]] Parameters {
|
||||
// [[codegen::verbatim(ColorInfo.description)]]
|
||||
std::optional<glm::vec3> color;
|
||||
std::optional<glm::vec3> color [[codegen::color()]];
|
||||
|
||||
// [[codegen::verbatim(SegmentsInfo.description)]]
|
||||
std::optional<glm::ivec2> segments;
|
||||
|
||||
@@ -80,7 +80,7 @@ namespace {
|
||||
|
||||
struct [[codegen::Dictionary(RenderableRadialGrid)]] Parameters {
|
||||
// [[codegen::verbatim(ColorInfo.description)]]
|
||||
std::optional<glm::vec3> color;
|
||||
std::optional<glm::vec3> color [[codegen::color()]];
|
||||
|
||||
// [[codegen::verbatim(GridSegmentsInfo.description)]]
|
||||
std::optional<glm::ivec2> gridSegments;
|
||||
|
||||
@@ -59,7 +59,7 @@ namespace {
|
||||
|
||||
struct [[codegen::Dictionary(RenderableSphericalGrid)]] Parameters {
|
||||
// [[codegen::verbatim(ColorInfo.description)]]
|
||||
std::optional<glm::vec3> color;
|
||||
std::optional<glm::vec3> color [[codegen::color()]];
|
||||
|
||||
// [[codegen::verbatim(SegmentsInfo.description)]]
|
||||
std::optional<int> segments;
|
||||
|
||||
@@ -60,13 +60,13 @@ namespace {
|
||||
|
||||
struct [[codegen::Dictionary(RenderableCartesianAxes)]] Parameters {
|
||||
// [[codegen::verbatim(XColorInfo.description)]]
|
||||
std::optional<glm::vec3> xColor;
|
||||
std::optional<glm::vec3> xColor [[codegen::color()]];
|
||||
|
||||
// [[codegen::verbatim(YColorInfo.description)]]
|
||||
std::optional<glm::vec3> yColor;
|
||||
std::optional<glm::vec3> yColor [[codegen::color()]];
|
||||
|
||||
// [[codegen::verbatim(ZColorInfo.description)]]
|
||||
std::optional<glm::vec3> zColor;
|
||||
std::optional<glm::vec3> zColor [[codegen::color()]];
|
||||
|
||||
};
|
||||
#include "renderablecartesianaxes_codegen.cpp"
|
||||
@@ -83,24 +83,9 @@ documentation::Documentation RenderableCartesianAxes::Documentation() {
|
||||
RenderableCartesianAxes::RenderableCartesianAxes(const ghoul::Dictionary& dictionary)
|
||||
: Renderable(dictionary)
|
||||
, _program(nullptr)
|
||||
, _xColor(
|
||||
XColorInfo,
|
||||
glm::vec3(1.f, 0.f, 0.f),
|
||||
glm::vec3(0.f),
|
||||
glm::vec3(1.f)
|
||||
)
|
||||
, _yColor(
|
||||
YColorInfo,
|
||||
glm::vec3(0.f, 1.f, 0.f),
|
||||
glm::vec3(0.f),
|
||||
glm::vec3(1.f)
|
||||
)
|
||||
, _zColor(
|
||||
ZColorInfo,
|
||||
glm::vec3(0.f, 0.f, 1.f),
|
||||
glm::vec3(0.f),
|
||||
glm::vec3(1.f)
|
||||
)
|
||||
, _xColor(XColorInfo, glm::vec3(1.f, 0.f, 0.f), glm::vec3(0.f), glm::vec3(1.f))
|
||||
, _yColor(YColorInfo, glm::vec3(0.f, 1.f, 0.f), glm::vec3(0.f), glm::vec3(1.f))
|
||||
, _zColor(ZColorInfo, glm::vec3(0.f, 0.f, 1.f), glm::vec3(0.f), glm::vec3(1.f))
|
||||
{
|
||||
const Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
_xColor = p.xColor.value_or(_xColor);
|
||||
|
||||
@@ -35,6 +35,8 @@
|
||||
#include <ghoul/opengl/openglstatecache.h>
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <ghoul/opengl/textureunit.h>
|
||||
#include <filesystem>
|
||||
#include <optional>
|
||||
|
||||
namespace {
|
||||
constexpr const char _loggerCat[] = "RenderableDisc";
|
||||
@@ -63,36 +65,26 @@ namespace {
|
||||
"based on the given size and this value should be set between 0 and 1. A value "
|
||||
"of 1 results in a full circle and 0.5 a disc with an inner radius of 0.5*size."
|
||||
};
|
||||
|
||||
struct [[codegen::Dictionary(RenderableDisc)]] Parameters {
|
||||
// [[codegen::verbatim(TextureInfo.description)]]
|
||||
std::filesystem::path texture;
|
||||
|
||||
// [[codegen::verbatim(SizeInfo.description)]]
|
||||
std::optional<float> size;
|
||||
|
||||
// [[codegen::verbatim(WidthInfo.description)]]
|
||||
std::optional<float> width;
|
||||
};
|
||||
#include "renderabledisc_codegen.cpp"
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
documentation::Documentation RenderableDisc::Documentation() {
|
||||
using namespace documentation;
|
||||
return {
|
||||
"Renderable Disc",
|
||||
"renderable_disc",
|
||||
{
|
||||
{
|
||||
TextureInfo.identifier,
|
||||
new StringVerifier,
|
||||
Optional::No,
|
||||
TextureInfo.description
|
||||
},
|
||||
{
|
||||
SizeInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
Optional::Yes,
|
||||
SizeInfo.description
|
||||
},
|
||||
{
|
||||
WidthInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
Optional::Yes,
|
||||
WidthInfo.description
|
||||
}
|
||||
}
|
||||
};
|
||||
documentation::Documentation doc = codegen::doc<Parameters>();
|
||||
doc.id = "base_renderable_disc";
|
||||
return doc;
|
||||
}
|
||||
|
||||
RenderableDisc::RenderableDisc(const ghoul::Dictionary& dictionary)
|
||||
@@ -101,27 +93,20 @@ RenderableDisc::RenderableDisc(const ghoul::Dictionary& dictionary)
|
||||
, _size(SizeInfo, 1.f, 0.f, 1e13f)
|
||||
, _width(WidthInfo, 0.5f, 0.f, 1.f)
|
||||
{
|
||||
documentation::testSpecificationAndThrow(
|
||||
Documentation(),
|
||||
dictionary,
|
||||
"RenderableDisc"
|
||||
);
|
||||
const Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
|
||||
_texturePath = absPath(dictionary.value<std::string>(TextureInfo.identifier));
|
||||
_texturePath = p.texture.string();
|
||||
_texturePath.onChange([&]() { _texture->loadFromFile(_texturePath); });
|
||||
addProperty(_texturePath);
|
||||
|
||||
if (dictionary.hasKey(SizeInfo.identifier)) {
|
||||
_size = static_cast<float>(dictionary.value<double>(SizeInfo.identifier));
|
||||
}
|
||||
_size = p.size.value_or(_size);
|
||||
setBoundingSphere(_size);
|
||||
_size.onChange([&]() { _planeIsDirty = true; });
|
||||
addProperty(_size);
|
||||
|
||||
if (dictionary.hasKey(WidthInfo.identifier)) {
|
||||
_width = static_cast<float>(dictionary.value<double>(WidthInfo.identifier));
|
||||
}
|
||||
_width = p.width.value_or(_width);
|
||||
addProperty(_width);
|
||||
|
||||
addProperty(_opacity);
|
||||
|
||||
setRenderBin(Renderable::RenderBin::PostDeferredTransparent);
|
||||
@@ -173,7 +158,6 @@ void RenderableDisc::render(const RenderData& data, RendererTasks&) {
|
||||
data.camera.projectionMatrix() * glm::mat4(modelViewTransform)
|
||||
);
|
||||
_shader->setUniform(_uniformCache.width, _width);
|
||||
|
||||
_shader->setUniform(_uniformCache.opacity, _opacity);
|
||||
|
||||
ghoul::opengl::TextureUnit unit;
|
||||
|
||||
@@ -194,7 +194,7 @@ namespace {
|
||||
std::optional<Orientation> labelOrientationOption;
|
||||
|
||||
// [[codegen::verbatim(LabelColorInfo.description)]]
|
||||
std::optional<glm::vec3> labelColor;
|
||||
std::optional<glm::vec3> labelColor [[codegen::color()]];
|
||||
|
||||
// [[codegen::verbatim(LabelTextInfo.description)]]
|
||||
std::optional<std::string> labelText;
|
||||
@@ -511,7 +511,7 @@ RenderableLabels::RenderableLabels(const ghoul::Dictionary& dictionary)
|
||||
_fadeEndUnitOption = AU;
|
||||
}
|
||||
addProperty(_fadeEndUnitOption);
|
||||
|
||||
|
||||
_fadeEndSpeed = p.fadeEndSpeed.value_or(_fadeEndSpeed);
|
||||
addProperty(_fadeEndSpeed);
|
||||
}
|
||||
|
||||
@@ -93,7 +93,7 @@ namespace {
|
||||
std::optional<std::string> endNode;
|
||||
|
||||
// [[codegen::verbatim(LineColorInfo.description)]]
|
||||
std::optional<glm::vec3> color;
|
||||
std::optional<glm::vec3> color [[codegen::color()]];
|
||||
|
||||
// [[codegen::verbatim(LineWidthInfo.description)]]
|
||||
std::optional<float> lineWidth;
|
||||
@@ -128,7 +128,7 @@ RenderableNodeLine::RenderableNodeLine(const ghoul::Dictionary& dictionary)
|
||||
|
||||
_lineColor = p.color.value_or(_lineColor);
|
||||
addProperty(_lineColor);
|
||||
|
||||
|
||||
_lineWidth = p.lineWidth.value_or(_lineWidth);
|
||||
addProperty(_lineWidth);
|
||||
|
||||
|
||||
@@ -76,7 +76,7 @@ namespace {
|
||||
|
||||
// [[codegen::verbatim(SizeInfo.description)]]
|
||||
float size;
|
||||
|
||||
|
||||
enum class BlendMode {
|
||||
Normal,
|
||||
Additive
|
||||
|
||||
@@ -234,7 +234,7 @@ namespace {
|
||||
std::optional<std::string> file;
|
||||
|
||||
// [[codegen::verbatim(ColorInfo.description)]]
|
||||
glm::vec3 color;
|
||||
glm::vec3 color [[codegen::color()]];
|
||||
|
||||
// [[codegen::verbatim(SpriteTextureInfo.description)]]
|
||||
std::optional<std::string> texture;
|
||||
@@ -277,7 +277,7 @@ namespace {
|
||||
std::optional<bool> drawLabels;
|
||||
|
||||
// [[codgen::verbatim(TextColorInfo.description)]]
|
||||
std::optional<glm::vec3> textColor;
|
||||
std::optional<glm::vec3> textColor [[codegen::color()]];
|
||||
|
||||
// [[codgen::verbatim(TextOpacityInfo.description)]]
|
||||
std::optional<float> textOpacity;
|
||||
|
||||
@@ -151,7 +151,7 @@ namespace {
|
||||
std::optional<Unit> unit;
|
||||
|
||||
// [[codegen::verbatim(TextColorInfo.description)]]
|
||||
std::optional<glm::vec3> textColor;
|
||||
std::optional<glm::vec3> textColor [[codegen::color()]];
|
||||
|
||||
// [[codegen::verbatim(TextOpacityInfo.description)]]
|
||||
std::optional<float> textOpacity;
|
||||
|
||||
@@ -180,7 +180,7 @@ namespace {
|
||||
std::optional<float> scaleFactor;
|
||||
|
||||
// [[codegen::verbatim(TextColorInfo.description)]]
|
||||
std::optional<glm::vec3> textColor;
|
||||
std::optional<glm::vec3> textColor [[codegen::color()]];
|
||||
|
||||
// [[codegen::verbatim(TextOpacityInfo.description)]]
|
||||
std::optional<float> textOpacity;
|
||||
@@ -381,7 +381,7 @@ RenderablePlanesCloud::RenderablePlanesCloud(const ghoul::Dictionary& dictionary
|
||||
}
|
||||
|
||||
_planeMinSize = p.planeMinSize.value_or(_planeMinSize);
|
||||
|
||||
|
||||
if (p.planeMinSize.has_value()) {
|
||||
addProperty(_planeMinSize);
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ namespace {
|
||||
std::string file;
|
||||
|
||||
// Astronomical Object Color (r,g,b)
|
||||
glm::vec3 color;
|
||||
glm::vec3 color [[codegen::color()]];
|
||||
|
||||
enum class Unit {
|
||||
Meter [[codegen::key("m")]],
|
||||
|
||||
@@ -33,8 +33,7 @@
|
||||
#include <openspace/scene/scenegraphnode.h>
|
||||
#include <openspace/scene/scene.h>
|
||||
#include <openspace/util/factorymanager.h>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
#include <filesystem>
|
||||
|
||||
#include "exoplanetsmodule_lua.inl"
|
||||
|
||||
@@ -115,19 +114,19 @@ namespace {
|
||||
|
||||
struct [[codegen::Dictionary(ExoplanetsModule)]] Parameters {
|
||||
// [[codegen::verbatim(DataFolderInfo.description)]]
|
||||
std::optional<std::string> dataFolder;
|
||||
std::optional<std::filesystem::path> dataFolder [[codegen::directory()]];
|
||||
|
||||
// [[codegen::verbatim(StarTextureInfo.description)]]
|
||||
std::optional<std::string> starTexture;
|
||||
std::optional<std::filesystem::path> starTexture;
|
||||
|
||||
// [[codegen::verbatim(NoDataTextureInfo.description)]]
|
||||
std::optional<std::string> noDataTexture;
|
||||
std::optional<std::filesystem::path> noDataTexture;
|
||||
|
||||
// [[codegen::verbatim(OrbitDiscTextureInfo.description)]]
|
||||
std::optional<std::string> orbitDiscTexture;
|
||||
std::optional<std::filesystem::path> orbitDiscTexture;
|
||||
|
||||
// [[codegen::verbatim(HabitableZoneTextureInfo.description)]]
|
||||
std::optional<std::string> habitableZoneTexture;
|
||||
std::optional<std::filesystem::path> habitableZoneTexture;
|
||||
|
||||
// [[codegen::verbatim(ShowComparisonCircleInfo.description)]]
|
||||
std::optional<bool> showComparisonCircle;
|
||||
@@ -258,16 +257,32 @@ scripting::LuaLibrary ExoplanetsModule::luaLibrary() const {
|
||||
|
||||
void ExoplanetsModule::internalInitialize(const ghoul::Dictionary& dict) {
|
||||
const Parameters p = codegen::bake<Parameters>(dict);
|
||||
_exoplanetsDataFolder = p.dataFolder.value_or(_exoplanetsDataFolder);
|
||||
_starTexturePath = p.starTexture.value_or(_starTexturePath);
|
||||
_noDataTexturePath = p.noDataTexture.value_or(_noDataTexturePath);
|
||||
_orbitDiscTexturePath = p.orbitDiscTexture.value_or(_orbitDiscTexturePath);
|
||||
_habitableZoneTexturePath = p.habitableZoneTexture.value_or(_habitableZoneTexturePath);
|
||||
if (p.dataFolder.has_value()) {
|
||||
_exoplanetsDataFolder = p.dataFolder.value().string();
|
||||
}
|
||||
|
||||
if (p.starTexture.has_value()) {
|
||||
_starTexturePath = p.starTexture.value().string();
|
||||
}
|
||||
|
||||
if (p.noDataTexture.has_value()) {
|
||||
_noDataTexturePath = p.noDataTexture.value().string();
|
||||
}
|
||||
|
||||
if (p.orbitDiscTexture.has_value()) {
|
||||
_orbitDiscTexturePath = p.orbitDiscTexture.value().string();
|
||||
}
|
||||
|
||||
if (p.habitableZoneTexture.has_value()) {
|
||||
_habitableZoneTexturePath = p.habitableZoneTexture.value().string();
|
||||
}
|
||||
|
||||
_showComparisonCircle = p.showComparisonCircle.value_or(_showComparisonCircle);
|
||||
_showHabitableZone = p.showHabitableZone.value_or(_showHabitableZone);
|
||||
_useOptimisticZone = p.useOptimisticZone.value_or(_useOptimisticZone);
|
||||
|
||||
_habitableZoneOpacity = p.habitableZoneOpacity.value_or(_habitableZoneOpacity);
|
||||
|
||||
auto fTask = FactoryManager::ref().factory<Task>();
|
||||
auto fRenderable = FactoryManager::ref().factory<Renderable>();
|
||||
ghoul_assert(fTask, "No task factory existed");
|
||||
|
||||
@@ -36,6 +36,8 @@
|
||||
#include <ghoul/opengl/openglstatecache.h>
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <ghoul/opengl/textureunit.h>
|
||||
#include <filesystem>
|
||||
#include <optional>
|
||||
|
||||
namespace {
|
||||
constexpr const std::array<const char*, 6> UniformNames = {
|
||||
@@ -71,42 +73,29 @@ namespace {
|
||||
"relative to the size of the semi-major axis. That is, 0 means no deviation "
|
||||
"from the semi-major axis and 1 is a whole semi-major axis's worth of deviation."
|
||||
};
|
||||
|
||||
struct [[codegen::Dictionary(RenderableOrbitDisc)]] Parameters {
|
||||
// [[codegen::verbatim(TextureInfo.description)]]
|
||||
std::filesystem::path texture;
|
||||
|
||||
// [[codegen::verbatim(SizeInfo.description)]]
|
||||
float size;
|
||||
|
||||
// [[codegen::verbatim(EccentricityInfo.description)]]
|
||||
float eccentricity;
|
||||
|
||||
// [[codegen::verbatim(OffsetInfo.description)]]
|
||||
std::optional<glm::vec2> offset;
|
||||
};
|
||||
#include "renderableorbitdisc_codegen.cpp"
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
documentation::Documentation RenderableOrbitDisc::Documentation() {
|
||||
using namespace documentation;
|
||||
return {
|
||||
"Renderable Orbit Disc",
|
||||
"exoplanets_renderable_orbit_disc",
|
||||
{
|
||||
{
|
||||
TextureInfo.identifier,
|
||||
new StringVerifier,
|
||||
Optional::No,
|
||||
TextureInfo.description
|
||||
},
|
||||
{
|
||||
SizeInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
Optional::No,
|
||||
SizeInfo.description
|
||||
},
|
||||
{
|
||||
EccentricityInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
Optional::No,
|
||||
EccentricityInfo.description
|
||||
},
|
||||
{
|
||||
OffsetInfo.identifier,
|
||||
new DoubleVector2Verifier,
|
||||
Optional::Yes,
|
||||
OffsetInfo.description
|
||||
}
|
||||
}
|
||||
};
|
||||
documentation::Documentation doc = codegen::doc<Parameters>();
|
||||
doc.id = "exoplanets_renderableorbitdisc";
|
||||
return doc;
|
||||
}
|
||||
|
||||
RenderableOrbitDisc::RenderableOrbitDisc(const ghoul::Dictionary& dictionary)
|
||||
@@ -116,31 +105,23 @@ RenderableOrbitDisc::RenderableOrbitDisc(const ghoul::Dictionary& dictionary)
|
||||
, _eccentricity(EccentricityInfo, 0.f, 0.f, 1.f)
|
||||
, _offset(OffsetInfo, glm::vec2(0.f), glm::vec2(0.f), glm::vec2(1.f))
|
||||
{
|
||||
documentation::testSpecificationAndThrow(
|
||||
Documentation(),
|
||||
dictionary,
|
||||
"RenderableOrbitDisc"
|
||||
);
|
||||
const Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
|
||||
if (dictionary.hasKey(OffsetInfo.identifier)) {
|
||||
_offset = dictionary.value<glm::dvec2>(OffsetInfo.identifier);
|
||||
}
|
||||
_offset = p.offset.value_or(_offset);
|
||||
_offset.onChange([&]() { _planeIsDirty = true; });
|
||||
addProperty(_offset);
|
||||
|
||||
_size = static_cast<float>(dictionary.value<double>(SizeInfo.identifier));
|
||||
_size = p.size;
|
||||
_size.onChange([&]() { _planeIsDirty = true; });
|
||||
addProperty(_size);
|
||||
|
||||
setBoundingSphere(_size + _offset.value().y * _size);
|
||||
|
||||
_texturePath = absPath(dictionary.value<std::string>(TextureInfo.identifier));
|
||||
_texturePath = p.texture.string();
|
||||
_texturePath.onChange([&]() { _texture->loadFromFile(_texturePath); });
|
||||
addProperty(_texturePath);
|
||||
|
||||
_eccentricity = static_cast<float>(
|
||||
dictionary.value<double>(EccentricityInfo.identifier)
|
||||
);
|
||||
_eccentricity = p.eccentricity;
|
||||
_eccentricity.onChange([&]() { _planeIsDirty = true; });
|
||||
addProperty(_eccentricity);
|
||||
|
||||
|
||||
@@ -449,13 +449,13 @@ documentation::Documentation ExoplanetsDataPreparationTask::documentation() {
|
||||
{
|
||||
{
|
||||
KeyInputDataFile,
|
||||
new StringAnnotationVerifier("A valid filepath"),
|
||||
new FileVerifier,
|
||||
Optional::No,
|
||||
"The csv file to extract data from"
|
||||
},
|
||||
{
|
||||
KeyInputSpeck,
|
||||
new StringAnnotationVerifier("A file path to a speck file"),
|
||||
new FileVerifier,
|
||||
Optional::No,
|
||||
"The speck file with star locations"
|
||||
},
|
||||
@@ -473,9 +473,10 @@ documentation::Documentation ExoplanetsDataPreparationTask::documentation() {
|
||||
},
|
||||
{
|
||||
KeyTeffToBv,
|
||||
new StringAnnotationVerifier("A valid filepath"),
|
||||
new FileVerifier,
|
||||
Optional::No,
|
||||
"The path to a teff to bv conversion file"
|
||||
"The path to a teff to bv conversion file. Should be a txt file where "
|
||||
"each line has the format 'teff,bv'"
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -217,7 +217,7 @@ documentation::Documentation GlobeLabelsComponent::Documentation() {
|
||||
},
|
||||
{
|
||||
LabelsColorInfo.identifier,
|
||||
new DoubleVector3Verifier,
|
||||
new Color3Verifier,
|
||||
Optional::Yes,
|
||||
LabelsColorInfo.description
|
||||
},
|
||||
|
||||
@@ -108,7 +108,7 @@ namespace {
|
||||
std::optional<std::string> description;
|
||||
|
||||
// [[codegen::verbatim(ColorInfo.description)]]
|
||||
std::optional<glm::vec3> color;
|
||||
std::optional<glm::vec3> color [[codegen::color()]];
|
||||
|
||||
// Specifies the type of layer that is to be added. If this value is not
|
||||
// specified, the layer is a DefaultTileLayer
|
||||
|
||||
@@ -68,7 +68,7 @@ documentation::Documentation LayerAdjustment::Documentation() {
|
||||
},
|
||||
{
|
||||
KeyChromaKeyColor,
|
||||
new DoubleVector3Verifier,
|
||||
new Color3Verifier,
|
||||
Optional::Yes,
|
||||
"Specifies the chroma key used when selecting 'ChromaKey' for the 'Type'."
|
||||
},
|
||||
|
||||
@@ -84,7 +84,7 @@ namespace {
|
||||
std::optional<std::string> constellationFile;
|
||||
|
||||
// [[codegen::verbatim(ColorInfo.description)]]
|
||||
std::optional<glm::vec3> color;
|
||||
std::optional<glm::vec3> color [[codegen::color()]];
|
||||
|
||||
// [[codegen::verbatim(LineWidthInfo.description)]]
|
||||
std::optional<float> lineWidth;
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
#include <ghoul/opengl/openglstatecache.h>
|
||||
#include <ghoul/opengl/programobject.h>
|
||||
#include <ghoul/opengl/textureunit.h>
|
||||
#include <optional>
|
||||
|
||||
namespace {
|
||||
constexpr const char _loggerCat[] = "RenderableHabitableZone";
|
||||
@@ -75,42 +76,28 @@ namespace {
|
||||
"a simpler method by Tom E. Harris is used. This method only uses the star "
|
||||
"luminosity and does not include computation of the optimistic boundaries."
|
||||
};
|
||||
|
||||
struct [[codegen::Dictionary(RenderableHabitableZone)]] Parameters {
|
||||
// [[codegen::verbatim(EffectiveTemperatureInfo.description)]]
|
||||
float effectiveTemperature;
|
||||
|
||||
// [[codegen::verbatim(LuminosityInfo.description)]]
|
||||
float luminosity;
|
||||
|
||||
// [[codegen::verbatim(OptimisticInfo.description)]]
|
||||
std::optional<bool> optimistic;
|
||||
|
||||
// [[codegen::verbatim(KopparapuTeffIntervalInfo.description)]]
|
||||
std::optional<glm::vec2> kopparapuTeffInterval;
|
||||
};
|
||||
#include "renderablehabitablezone_codegen.cpp"
|
||||
} // namespace
|
||||
|
||||
namespace openspace {
|
||||
|
||||
documentation::Documentation RenderableHabitableZone::Documentation() {
|
||||
using namespace documentation;
|
||||
documentation::Documentation doc {
|
||||
"Renderable Habitable Zone",
|
||||
"exoplanets_renderable_habitable_zone",
|
||||
{
|
||||
{
|
||||
EffectiveTemperatureInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
Optional::No,
|
||||
EffectiveTemperatureInfo.description
|
||||
},
|
||||
{
|
||||
LuminosityInfo.identifier,
|
||||
new DoubleVerifier,
|
||||
Optional::No,
|
||||
LuminosityInfo.description
|
||||
},
|
||||
{
|
||||
OptimisticInfo.identifier,
|
||||
new BoolVerifier,
|
||||
Optional::Yes,
|
||||
OptimisticInfo.description
|
||||
},
|
||||
{
|
||||
KopparapuTeffIntervalInfo.identifier,
|
||||
new DoubleVector2Verifier,
|
||||
Optional::Yes,
|
||||
KopparapuTeffIntervalInfo.description
|
||||
}
|
||||
}
|
||||
};
|
||||
documentation::Documentation doc = codegen::doc<Parameters>();
|
||||
doc.id = "space_renderablehabitablezone";
|
||||
|
||||
// @TODO cleanup
|
||||
// Insert the parents documentation entries until we have a verifier that can deal
|
||||
@@ -132,31 +119,17 @@ RenderableHabitableZone::RenderableHabitableZone(const ghoul::Dictionary& dictio
|
||||
, _showOptimistic(OptimisticInfo, false)
|
||||
, _kopparapuTeffInterval(KopparapuTeffIntervalInfo, glm::vec2(1000.f, 10000.f))
|
||||
{
|
||||
documentation::testSpecificationAndThrow(
|
||||
Documentation(),
|
||||
dictionary,
|
||||
"RenderableHabitableZone"
|
||||
);
|
||||
const Parameters p = codegen::bake<Parameters>(dictionary);
|
||||
|
||||
if (dictionary.hasKey(EffectiveTemperatureInfo.identifier)) {
|
||||
_teff = static_cast<float>(
|
||||
dictionary.value<double>(EffectiveTemperatureInfo.identifier)
|
||||
);
|
||||
}
|
||||
_teff = p.effectiveTemperature;
|
||||
_teff.onChange([this]() { computeZone(); });
|
||||
addProperty(_teff);
|
||||
|
||||
if (dictionary.hasKey(LuminosityInfo.identifier)) {
|
||||
_luminosity = static_cast<float>(
|
||||
dictionary.value<double>(LuminosityInfo.identifier)
|
||||
);
|
||||
}
|
||||
_luminosity = p.luminosity;
|
||||
_luminosity.onChange([this]() { computeZone(); });
|
||||
addProperty(_luminosity);
|
||||
|
||||
if (dictionary.hasKey(OptimisticInfo.identifier)) {
|
||||
_showOptimistic = dictionary.value<bool>(OptimisticInfo.identifier);
|
||||
}
|
||||
_showOptimistic = p.optimistic.value_or(_showOptimistic);
|
||||
addProperty(_showOptimistic);
|
||||
|
||||
// The user should not be able to change this property. It's just used to communicate
|
||||
|
||||
@@ -242,7 +242,7 @@ namespace {
|
||||
std::optional<double> lineWidth;
|
||||
|
||||
// [[codegen::verbatim(LineColorInfo.description)]]
|
||||
glm::dvec3 color;
|
||||
glm::dvec3 color [[codegen::color()]];
|
||||
|
||||
// [[codegen::verbatim(TrailFadeInfo.description)]]
|
||||
std::optional<double> trailFade;
|
||||
|
||||
@@ -96,10 +96,10 @@ namespace {
|
||||
std::optional<float> fontSize;
|
||||
|
||||
// [[codegen::verbatim(ActiveColorInfo.description)]]
|
||||
std::optional<glm::dvec3> activeColor;
|
||||
std::optional<glm::dvec3> activeColor [[codegen::color()]];
|
||||
|
||||
// [[codegen::verbatim(FlashColorInfo.description)]]
|
||||
std::optional<glm::dvec3> flashColor;
|
||||
std::optional<glm::dvec3> flashColor [[codegen::color()]];
|
||||
};
|
||||
#include "dashboarditeminstruments_codegen.cpp"
|
||||
} // namespace
|
||||
|
||||
@@ -86,13 +86,13 @@ documentation::Documentation RenderableCrawlingLine::Documentation() {
|
||||
new TableVerifier({
|
||||
{
|
||||
KeyColorStart,
|
||||
new DoubleVector4Verifier,
|
||||
new Color4Verifier,
|
||||
Optional::No,
|
||||
"The color at the start of the line",
|
||||
},
|
||||
{
|
||||
KeyColorEnd,
|
||||
new DoubleVector4Verifier,
|
||||
new Color4Verifier,
|
||||
Optional::No,
|
||||
"The color at the end of the line"
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ namespace {
|
||||
"Aberration",
|
||||
"This value determines the aberration method that is used to compute the shadow "
|
||||
"cylinder."
|
||||
};
|
||||
};
|
||||
|
||||
struct [[codegen::Dictionary(RenderableShadowCylinder)]] Parameters {
|
||||
// [[codegen::verbatim(NumberPointsInfo.description)]]
|
||||
@@ -114,7 +114,7 @@ namespace {
|
||||
std::optional<float> shadowLength;
|
||||
|
||||
// [[codegen::verbatim(ShadowColorInfo.description)]]
|
||||
std::optional<glm::vec3> shadowColor;
|
||||
std::optional<glm::vec3> shadowColor [[codegen::color()]];
|
||||
|
||||
enum class TerminatorType {
|
||||
Umbral [[codegen::key("UMBRAL")]],
|
||||
|
||||
@@ -310,10 +310,7 @@ int createSingeColorImage(lua_State* L) {
|
||||
const std::string& key = "color";
|
||||
ghoul::Dictionary colorDict;
|
||||
colorDict.setValue(key, d);
|
||||
TestResult res = DoubleVector3Verifier()(colorDict, key);
|
||||
|
||||
// @TODO (emmbr 2020-02-04) A 'ColorVerifier' would be really useful here, to easily
|
||||
// check that we have a vector with values in [0, 1]
|
||||
TestResult res = Color3Verifier()(colorDict, key);
|
||||
|
||||
if (!res.success) {
|
||||
return ghoul::lua::luaError(
|
||||
|
||||
@@ -105,18 +105,14 @@ TEST_CASE("CreateSingleColorImage: Faulty color value (invalid values)",
|
||||
{
|
||||
ghoul::lua::LuaState L;
|
||||
ghoul::lua::push(L, "notCreatedColorFile");
|
||||
ghoul::lua::push(L, std::vector{ 255.0, 0.0, 0.0 });
|
||||
ghoul::lua::push(L, std::vector{ 255.0, 0.0, 0.0 }); // not a valid color
|
||||
|
||||
// @TODO (emmbr 2020-02-04) This test case should be here, but as of now this case is
|
||||
// not handled. Finish it up when we have a better way of verifying that a dictionary
|
||||
// is a color
|
||||
|
||||
//CHECK_THROWS_WITH(
|
||||
// openspace::luascriptfunctions::createSingeColorImage(L),
|
||||
// Catch::Matchers::Contains(
|
||||
// "Invalid color. Expected three double values {r, g, b} in range 0 to 1"
|
||||
// )
|
||||
//);
|
||||
CHECK_THROWS_WITH(
|
||||
openspace::luascriptfunctions::createSingeColorImage(L),
|
||||
Catch::Matchers::Contains(
|
||||
"Invalid color. Expected three double values {r, g, b} in range 0 to 1"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
TEST_CASE("CreateSingleColorImage: Check if file was created",
|
||||
|
||||
Reference in New Issue
Block a user