diff --git a/modules/volume/rendering/renderabletimevaryingvolume.cpp b/modules/volume/rendering/renderabletimevaryingvolume.cpp index c3df6e831e..68e6e34a02 100644 --- a/modules/volume/rendering/renderabletimevaryingvolume.cpp +++ b/modules/volume/rendering/renderabletimevaryingvolume.cpp @@ -158,8 +158,7 @@ namespace { // [[codegen::verbatim(GridTypeInfo.description)]] std::optional gridType [[codegen::inlist("Spherical", "Cartesian")]]; - // @TODO Missing documentation - std::optional clipPlanes; + std::optional> clipPlanes [[codegen::reference("volume_volumeclipplane")]]; }; #include "renderabletimevaryingvolume_codegen.cpp" } // namespace @@ -209,10 +208,8 @@ RenderableTimeVaryingVolume::RenderableTimeVaryingVolume( _secondsBefore = p.secondsBefore.value_or(_secondsBefore); _secondsAfter = p.secondsAfter; - const ghoul::Dictionary clipPlanesDict = p.clipPlanes.value_or(ghoul::Dictionary()); - _clipPlanes = std::make_shared(clipPlanesDict); - _clipPlanes->setIdentifier("clipPlanes"); - _clipPlanes->setGuiName("Clip Planes"); + const std::vector clipPlanes = p.clipPlanes.value_or(std::vector()); + _clipPlanes = std::make_shared(clipPlanes); if (p.gridType.has_value()) { const VolumeGridType gridType = volume::parseGridType(*p.gridType); diff --git a/modules/volume/rendering/volumeclipplane.cpp b/modules/volume/rendering/volumeclipplane.cpp index 8ba0d38877..24bebf1ccf 100644 --- a/modules/volume/rendering/volumeclipplane.cpp +++ b/modules/volume/rendering/volumeclipplane.cpp @@ -54,8 +54,12 @@ namespace { namespace openspace::volume { +documentation::Documentation VolumeClipPlane::Documentation() { + return codegen::doc("volume_volumeclipplane"); +} + VolumeClipPlane::VolumeClipPlane(const ghoul::Dictionary& dictionary) - : properties::PropertyOwner({ "" }) // @TODO Missing name + : properties::PropertyOwner({ "" }) // Name set from parent , _normal( NormalInfo, glm::vec3(1.f, 0.f, 0.f), diff --git a/modules/volume/rendering/volumeclipplane.h b/modules/volume/rendering/volumeclipplane.h index 352d932690..d196a83016 100644 --- a/modules/volume/rendering/volumeclipplane.h +++ b/modules/volume/rendering/volumeclipplane.h @@ -32,6 +32,8 @@ namespace ghoul { class Dictionary; } +namespace openspace::documentation { struct Documentation; } + namespace openspace::volume { class VolumeClipPlane : public properties::PropertyOwner { @@ -42,6 +44,8 @@ public: glm::vec3 normal() const; glm::vec2 offsets() const; + static documentation::Documentation Documentation(); + private: properties::Vec3Property _normal; properties::Vec2Property _offsets; diff --git a/modules/volume/rendering/volumeclipplanes.cpp b/modules/volume/rendering/volumeclipplanes.cpp index 14ad128458..52d6c10a40 100644 --- a/modules/volume/rendering/volumeclipplanes.cpp +++ b/modules/volume/rendering/volumeclipplanes.cpp @@ -25,36 +25,56 @@ #include +#include #include +namespace { + + //constexpr openspace::properties::PropertyOwner::PropertyOwnerInfo ClipPlanesInfo = { + //"ClipPlanes", + //"Clip Planes", + //"Documentation" + //}; + + + constexpr openspace::properties::Property::PropertyInfo NClipPlanesInfo = { + "nClipPlanes", + "# Clip Planes", + "Number of clip planes" + }; + +} // namespace + namespace openspace::volume { -VolumeClipPlanes::VolumeClipPlanes(const ghoul::Dictionary& dictionary) - : properties::PropertyOwner({ "" }) // @TODO Missing name + + +VolumeClipPlanes::VolumeClipPlanes(const std::vector& planes) + : properties::PropertyOwner({ "ClipPlanes", "Clip Planes" }) // @TODO Missing name // @TODO Missing documentation - , _nClipPlanes({ "nClipPlanes", "Number of clip planes", "" }, 0, 0, 10) + , _nClipPlanes(NClipPlanesInfo, 0, 0, 10) { - for (const std::string_view key : dictionary.keys()) { - const ghoul::Dictionary cutplane = dictionary.value(key); - VolumeClipPlane clipPlane = VolumeClipPlane(cutplane); - clipPlane.setIdentifier(std::string(key)); + int index = 0; + for (const ghoul::Dictionary& c : planes) { + std::unique_ptr clipPlane = std::make_unique(c); + clipPlane->setIdentifier(std::format("clipPlane_{}", index++)); // TODO 2025-05-06 check if this is ok to do with Alex / Emma + addPropertySubOwner(clipPlane.get()); _clipPlanes.push_back(std::move(clipPlane)); + } - _nClipPlanes = static_cast(dictionary.keys().size()); + + _nClipPlanes = static_cast(_clipPlanes.size()); + addProperty(_nClipPlanes); } void VolumeClipPlanes::initialize() { - addProperty(_nClipPlanes); - for (VolumeClipPlane& clipPlane : _clipPlanes) { - addPropertySubOwner(clipPlane); - } } std::vector VolumeClipPlanes::normals() { std::vector normals; normals.reserve(_clipPlanes.size()); - for (const VolumeClipPlane& clipPlane : _clipPlanes) { - normals.push_back(clipPlane.normal()); + for (const std::unique_ptr& clipPlane : _clipPlanes) { + normals.push_back(clipPlane->normal()); } return normals; } @@ -62,8 +82,8 @@ std::vector VolumeClipPlanes::normals() { std::vector VolumeClipPlanes::offsets() { std::vector offsets; offsets.reserve(_clipPlanes.size()); - for (const VolumeClipPlane& clipPlane : _clipPlanes) { - offsets.push_back(clipPlane.offsets()); + for (const std::unique_ptr& clipPlane : _clipPlanes) { + offsets.push_back(clipPlane->offsets()); } return offsets; } diff --git a/modules/volume/rendering/volumeclipplanes.h b/modules/volume/rendering/volumeclipplanes.h index 1343c61251..a18a04493c 100644 --- a/modules/volume/rendering/volumeclipplanes.h +++ b/modules/volume/rendering/volumeclipplanes.h @@ -32,6 +32,7 @@ #include namespace ghoul { class Dictionary; } +namespace documentation { struct Documentation; } namespace openspace::volume { @@ -39,7 +40,7 @@ class VolumeClipPlane; class VolumeClipPlanes : public properties::PropertyOwner { public: - explicit VolumeClipPlanes(const ghoul::Dictionary& dictionary); + explicit VolumeClipPlanes(const std::vector& planes); ~VolumeClipPlanes() override = default; void initialize(); @@ -49,7 +50,7 @@ public: private: properties::IntProperty _nClipPlanes; - std::vector _clipPlanes; + std::vector> _clipPlanes; }; } // namespace openspace::volume diff --git a/modules/volume/volumemodule.cpp b/modules/volume/volumemodule.cpp index 40883dd571..756f3697f1 100644 --- a/modules/volume/volumemodule.cpp +++ b/modules/volume/volumemodule.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -57,7 +58,8 @@ void VolumeModule::internalInitialize(const ghoul::Dictionary&) { std::vector VolumeModule::documentations() const { return { RenderableTimeVaryingVolume::Documentation(), - GenerateRawVolumeTask::Documentation() + GenerateRawVolumeTask::Documentation(), + VolumeClipPlane::Documentation() }; }