From 773828c057fadae19a8cfdd446fcb9573980c55e Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 11 May 2017 22:51:11 -0400 Subject: [PATCH] Adding documentations to more classes --- modules/base/basemodule.cpp | 6 +- modules/base/rendering/renderablemodel.cpp | 87 ++++++++++++------- modules/base/rendering/renderablemodel.h | 9 +- .../base/rendering/screenspaceframebuffer.cpp | 18 ++++ .../base/rendering/screenspaceframebuffer.h | 5 ++ modules/base/rendering/screenspaceimage.cpp | 52 ++++++++--- modules/base/rendering/screenspaceimage.h | 5 +- modules/base/scale/staticscale.cpp | 12 +-- 8 files changed, 138 insertions(+), 56 deletions(-) diff --git a/modules/base/basemodule.cpp b/modules/base/basemodule.cpp index fc8f383a3d..d0138eb781 100644 --- a/modules/base/basemodule.cpp +++ b/modules/base/basemodule.cpp @@ -97,7 +97,7 @@ void BaseModule::internalInitialize() { auto fScale = FactoryManager::ref().factory(); ghoul_assert(fScale, "Scale factory was not created"); - fScale->registerClass ("StaticScale"); + fScale->registerClass("StaticScale"); auto fModelGeometry = FactoryManager::ref().factory(); ghoul_assert(fModelGeometry, "Model geometry factory was not created"); @@ -106,6 +106,10 @@ void BaseModule::internalInitialize() { std::vector BaseModule::documentations() const { return { + RenderableModel::Documentation(), + ScreenSpaceFramebuffer::Documentation(), + ScreenSpaceImage::Documentation(), + StaticRotation::Documentation(), StaticScale::Documentation(), StaticTranslation::Documentation(), RenderableTrailOrbit::Documentation(), diff --git a/modules/base/rendering/renderablemodel.cpp b/modules/base/rendering/renderablemodel.cpp index 2f92b51d79..d1d2cfebee 100644 --- a/modules/base/rendering/renderablemodel.cpp +++ b/modules/base/rendering/renderablemodel.cpp @@ -24,6 +24,8 @@ #include +#include +#include #include #include #include @@ -34,6 +36,7 @@ #include #include +#include #include @@ -42,19 +45,44 @@ namespace { const std::string _loggerCat = "RenderableModel"; - const char* keyGeometry = "Geometry"; + + const char* KeyGeometry = "Geometry"; + const char* KeyTexture = "Textures.Color"; + + const char* keyBody = "Body"; const char* keyStart = "StartTime"; const char* keyEnd = "EndTime"; const char* keyFading = "Shading.Fadeable"; const char* keyModelTransform = "Rotation.ModelTransform"; - //const std::string keyGhosting = "Shading.Ghosting"; - -} +} // namespace namespace openspace { +documentation::Documentation RenderableModel::Documentation() { + using namespace documentation; + return { + "RenderableModel", + "base_renderable_model", + { + { + KeyGeometry, + new ReferencingVerifier("base_geometry_model"), + "This specifies the model that is rendered by the Renderable.", + Optional::No + }, + { + KeyTexture, + new StringVerifier, + "A color texture that can be applied to the model specified bny the " + "Geometry.", + Optional::Yes + } + } + }; +} + RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary) : Renderable(dictionary) , _colorTexturePath("colorTexture", "Color Texture") @@ -65,25 +93,31 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary) , _texture(nullptr) , _geometry(nullptr) , _alpha(1.f) - //, _isGhost(false) , _performShading("performShading", "Perform Shading", true) , _frameCount(0) { - std::string name; - bool success = dictionary.getValue(SceneGraphNode::KeyName, name); - ghoul_assert(success, "Name was not passed to RenderableModel"); + ghoul_precondition( + dictionary.hasKeyAndValue(SceneGraphNode::KeyName), + "Name was not passed to RenderableModel" + ); - ghoul::Dictionary geometryDictionary; - success = dictionary.getValue(keyGeometry, geometryDictionary); - if (success) { - geometryDictionary.setValue(SceneGraphNode::KeyName, name); - _geometry = modelgeometry::ModelGeometry::createFromDictionary(geometryDictionary); + documentation::testSpecificationAndThrow( + Documentation(), + dictionary, + "RenderableModel" + ); + + + if (dictionary.hasKey(KeyGeometry)) { + std::string name = dictionary.value(SceneGraphNode::KeyName); + ghoul::Dictionary dict = dictionary.value(KeyGeometry); + dict.setValue(SceneGraphNode::KeyName, name); + _geometry = modelgeometry::ModelGeometry::createFromDictionary(dict); } - std::string texturePath = ""; - success = dictionary.getValue("Textures.Color", texturePath); - if (success) - _colorTexturePath = absPath(texturePath); + if (dictionary.hasKey(KeyTexture)) { + _colorTexturePath = absPath(dictionary.value(KeyTexture)); + } addPropertySubOwner(_geometry.get()); @@ -92,17 +126,12 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary) addProperty(_debugModelRotation); - //dictionary.getValue(keySource, _source); - //dictionary.getValue(keyDestination, _destination); - if (dictionary.hasKeyAndValue(keyModelTransform)) + if (dictionary.hasKeyAndValue(keyModelTransform)) { dictionary.getValue(keyModelTransform, _modelTransform); - else + } + else { _modelTransform = glm::dmat3(1.f); - dictionary.getValue(keyBody, _target); - - //openspace::SpiceManager::ref().addFrame(_target, _source); - - //setBoundingSphere(pss(1.f, 9.f)); + } addProperty(_performShading); if (dictionary.hasKeyAndValue(keyFading)) { @@ -111,12 +140,6 @@ RenderableModel::RenderableModel(const ghoul::Dictionary& dictionary) _performFade = fading; } addProperty(_performFade); - - //if (dictionary.hasKeyAndValue(keyGhosting)) { - // bool ghosting; - // dictionary.getValue(keyGhosting, ghosting); - // _isGhost = ghosting; - //} } bool RenderableModel::isReady() const { diff --git a/modules/base/rendering/renderablemodel.h b/modules/base/rendering/renderablemodel.h index 153964d60a..03f1798f99 100644 --- a/modules/base/rendering/renderablemodel.h +++ b/modules/base/rendering/renderablemodel.h @@ -40,6 +40,8 @@ namespace openspace { +namespace documentation { struct Documentation; } + namespace modelgeometry { class ModelGeometry; } @@ -56,6 +58,7 @@ public: void render(const RenderData& data) override; void update(const UpdateData& data) override; + static documentation::Documentation Documentation(); protected: void loadTexture(); @@ -72,13 +75,7 @@ private: glm::dmat3 _modelTransform; float _alpha; - //glm::dmat3 _stateMatrix; - //std::string _source; - //std::string _destination; - std::string _target; - - //bool _isGhost; int _frameCount; glm::dvec3 _sunPos; diff --git a/modules/base/rendering/screenspaceframebuffer.cpp b/modules/base/rendering/screenspaceframebuffer.cpp index e41c126ae8..1f4d6fe118 100644 --- a/modules/base/rendering/screenspaceframebuffer.cpp +++ b/modules/base/rendering/screenspaceframebuffer.cpp @@ -23,6 +23,8 @@ ****************************************************************************************/ #include + +#include #include #include #include @@ -34,11 +36,27 @@ namespace openspace { +documentation::Documentation ScreenSpaceFramebuffer::Documentation() { + using namespace documentation; + return { + "ScreenSpace Framebuffer", + "base_screenspace_framebuffer", + {}, + Exhaustive::Yes + }; +} + ScreenSpaceFramebuffer::ScreenSpaceFramebuffer(const ghoul::Dictionary& dictionary) : ScreenSpaceRenderable(dictionary) , _size("size", "Size", glm::vec4(0), glm::vec4(0), glm::vec4(2000)) , _framebuffer(nullptr) { + documentation::testSpecificationAndThrow( + Documentation(), + dictionary, + "ScreenSpaceFramebuffer" + ); + _id = id(); setName("ScreenSpaceFramebuffer" + std::to_string(_id)); diff --git a/modules/base/rendering/screenspaceframebuffer.h b/modules/base/rendering/screenspaceframebuffer.h index 33a04a3655..772e19e99b 100644 --- a/modules/base/rendering/screenspaceframebuffer.h +++ b/modules/base/rendering/screenspaceframebuffer.h @@ -34,6 +34,9 @@ #include namespace openspace { + +namespace documentation { struct Documentation; } + /** * @brief Creates a texture by rendering to a framebuffer, this is then used on a screen space plane. * @details This class lets you ass renderfunctions that should render to a framebuffer with an attached texture. @@ -54,6 +57,8 @@ public: void addRenderFunction(std::shared_ptr> renderFunction); void removeAllRenderFunctions(); + static documentation::Documentation Documentation(); + private: void createFragmentbuffer(); static int id(); diff --git a/modules/base/rendering/screenspaceimage.cpp b/modules/base/rendering/screenspaceimage.cpp index 6b2e4e44bb..7d81e60faa 100644 --- a/modules/base/rendering/screenspaceimage.cpp +++ b/modules/base/rendering/screenspaceimage.cpp @@ -24,6 +24,9 @@ #include +#include +#include + #include #include #include @@ -36,39 +39,66 @@ namespace { const char* KeyName = "Name"; const char* KeyTexturePath = "TexturePath"; const char* KeyUrl = "URL"; -} +} // namespace namespace openspace { +documentation::Documentation ScreenSpaceImage::Documentation() { + using namespace openspace::documentation; + return { + "ScreenSpace Image", + "base_screenspace_image", + { + { + KeyName, + new StringVerifier, + "Specifies the GUI name of the ScreenspaceImage", + Optional::Yes + }, + { + KeyTexturePath, + new StringVerifier, + "Specifies the image that is shown on the screenspace-aligned plane. If " + "this value is set and the URL is not, the disk image is used.", + Optional::Yes + } + } + }; +} + ScreenSpaceImage::ScreenSpaceImage(const ghoul::Dictionary& dictionary) : ScreenSpaceRenderable(dictionary) , _downloadImage(false) , _textureIsDirty(false) , _texturePath("texturePath", "Texture path", "") { - std::string name; - if (dictionary.getValue(KeyName, name)) { - setName(name); - } else { + documentation::testSpecificationAndThrow( + Documentation(), + dictionary, + "ScreenSpaceImage" + ); + + if (dictionary.hasKey(KeyName)) { + setName(dictionary.value(KeyName)); + } + else { static int id = 0; setName("ScreenSpaceImage " + std::to_string(id)); ++id; } - addProperty(_texturePath); - std::string texturePath; if (dictionary.getValue(KeyTexturePath, texturePath)) { - _texturePath = texturePath; - _texturePath.onChange([this]() { _textureIsDirty = true; }); + _texturePath = dictionary.value(KeyTexturePath); } if (dictionary.getValue(KeyUrl, _url)) { _downloadImage = true; } -} -ScreenSpaceImage::~ScreenSpaceImage() {} + _texturePath.onChange([this]() { _textureIsDirty = true; }); + addProperty(_texturePath); +} bool ScreenSpaceImage::initialize() { _originalViewportSize = OsEng.windowWrapper().currentWindowResolution(); diff --git a/modules/base/rendering/screenspaceimage.h b/modules/base/rendering/screenspaceimage.h index 4788e6df72..9130627ee9 100644 --- a/modules/base/rendering/screenspaceimage.h +++ b/modules/base/rendering/screenspaceimage.h @@ -33,11 +33,12 @@ #include namespace openspace { + +namespace documentation { struct Documentation; } class ScreenSpaceImage : public ScreenSpaceRenderable { public: ScreenSpaceImage(const ghoul::Dictionary& dictionary); - ~ScreenSpaceImage(); bool initialize() override; bool deinitialize() override; @@ -45,6 +46,8 @@ public: void update() override; bool isReady() const override; + static documentation::Documentation Documentation(); + protected: void loadTexture(); void updateTexture(); diff --git a/modules/base/scale/staticscale.cpp b/modules/base/scale/staticscale.cpp index 5e53730ea8..6eb819e419 100644 --- a/modules/base/scale/staticscale.cpp +++ b/modules/base/scale/staticscale.cpp @@ -38,11 +38,13 @@ documentation::Documentation StaticScale::Documentation() { return { "Static Scaling", "base_scale_static", - {{ - KeyValue, - new DoubleVerifier, - "The scaling factor by which the scenegraph node is scaled." - }} + { + { + KeyValue, + new DoubleVerifier, + "The scaling factor by which the scenegraph node is scaled." + } + } }; }