From ec0117b6439523db3ca2f5996541fb99e44afc58 Mon Sep 17 00:00:00 2001 From: Willy Scheibel Date: Thu, 14 Sep 2017 18:49:07 +0200 Subject: [PATCH 1/5] Start using cppexpose type refactoring --- .../demo-stages-plugins/AssimpMeshLoader.cpp | 2 +- .../demo-stages-plugins/ColorGradientDemo.h | 2 +- .../demo-stages-plugins/ShaderDemoPipeline.h | 2 +- .../examples/demo-stages-plugins/ShapeDemo.h | 2 +- .../source/loaders/QtTextureLoader.cpp | 2 +- .../include/gloperate-qtquick/QmlEngine.h | 2 +- .../gloperate-qtquick/QmlScriptFunction.h | 2 +- source/gloperate-qtquick/source/QmlEngine.cpp | 2 +- .../source/QmlObjectWrapper.cpp | 2 +- .../source/TextureItemRenderer_ogl.cpp | 2 +- .../include/gloperate-text/Alignment.h | 5 +- .../include/gloperate-text/FontLoader.h | 2 +- .../include/gloperate-text/LineAnchor.h | 5 +- source/gloperate/CMakeLists.txt | 2 +- .../gloperate/include/gloperate/base/Canvas.h | 2 +- .../gloperate/base/ExtendedProperties.h | 8 ++- .../include/gloperate/base/ResourceManager.h | 2 +- .../include/gloperate/pipeline/AbstractSlot.h | 5 ++ .../include/gloperate/pipeline/Input.h | 6 +- .../include/gloperate/pipeline/Output.h | 6 +- .../include/gloperate/pipeline/Slot.h | 62 +++++++++++++++--- .../include/gloperate/pipeline/Slot.inl | 29 +++++---- .../include/gloperate/pipeline/Stage.inl | 8 ++- .../gloperate/rendering/AttachmentType.h | 7 +- .../include/gloperate/rendering/Light.h | 8 +++ .../gloperate/rendering/RenderTargetType.h | 7 +- .../include/gloperate/rendering/ShapeType.h | 19 +++--- .../stages/base/BasicFramebufferStage.h | 4 +- .../include/gloperate/stages/base/BlitStage.h | 2 +- .../gloperate/stages/base/ClearStage.h | 1 + .../gloperate/stages/base/TextureLoadStage.h | 4 +- .../stages/base/ViewportScaleStage.h | 4 +- .../stages/interfaces/CanvasInterface.h | 4 +- .../stages/interfaces/RenderInterface.h | 4 +- .../gloperate/tools/AbstractVideoExporter.h | 2 +- source/gloperate/source/base/Canvas.cpp | 65 ++++++++++--------- .../source/base/ComponentManager.cpp | 27 ++++---- .../source/base/ExtendedProperties.cpp | 2 +- .../source/loaders/ColorGradientLoader.cpp | 21 +++--- .../source/loaders/GlrawTextureLoader.cpp | 2 +- .../gloperate/source/loaders/ShaderLoader.cpp | 2 +- .../source/pipeline/AbstractSlot.cpp | 54 ++++++++++++++- source/gloperate/source/pipeline/Pipeline.cpp | 4 +- source/gloperate/source/pipeline/Stage.cpp | 9 ++- .../stages/base/BasicFramebufferStage.cpp | 2 + .../stages/base/ColorGradientTextureStage.cpp | 4 +- .../source/stages/base/RenderPassStage.cpp | 27 ++++---- .../source/stages/base/ViewportScaleStage.cpp | 2 + .../stages/interfaces/CanvasInterface.cpp | 6 +- .../stages/interfaces/RenderInterface.cpp | 2 +- .../FFMPEGVideoEncoder.h | 2 +- 51 files changed, 301 insertions(+), 158 deletions(-) diff --git a/source/examples/demo-stages-plugins/AssimpMeshLoader.cpp b/source/examples/demo-stages-plugins/AssimpMeshLoader.cpp index 32ce5312..9bcca1a8 100644 --- a/source/examples/demo-stages-plugins/AssimpMeshLoader.cpp +++ b/source/examples/demo-stages-plugins/AssimpMeshLoader.cpp @@ -14,7 +14,7 @@ #include -#include +#include #include diff --git a/source/examples/demo-stages-plugins/ColorGradientDemo.h b/source/examples/demo-stages-plugins/ColorGradientDemo.h index 4f6e7074..5b406d27 100644 --- a/source/examples/demo-stages-plugins/ColorGradientDemo.h +++ b/source/examples/demo-stages-plugins/ColorGradientDemo.h @@ -5,7 +5,7 @@ #include #include -#include +//#include #include #include #include diff --git a/source/examples/demo-stages-plugins/ShaderDemoPipeline.h b/source/examples/demo-stages-plugins/ShaderDemoPipeline.h index 1191ca02..899b981c 100644 --- a/source/examples/demo-stages-plugins/ShaderDemoPipeline.h +++ b/source/examples/demo-stages-plugins/ShaderDemoPipeline.h @@ -5,7 +5,7 @@ #include #include -#include +//#include #include #include #include diff --git a/source/examples/demo-stages-plugins/ShapeDemo.h b/source/examples/demo-stages-plugins/ShapeDemo.h index 259021a6..b7d08d71 100644 --- a/source/examples/demo-stages-plugins/ShapeDemo.h +++ b/source/examples/demo-stages-plugins/ShapeDemo.h @@ -5,7 +5,7 @@ #include #include -#include +//#include #include #include #include diff --git a/source/gloperate-qt/source/loaders/QtTextureLoader.cpp b/source/gloperate-qt/source/loaders/QtTextureLoader.cpp index 4acdb377..aecb8e8e 100644 --- a/source/gloperate-qt/source/loaders/QtTextureLoader.cpp +++ b/source/gloperate-qt/source/loaders/QtTextureLoader.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include #include diff --git a/source/gloperate-qtquick/include/gloperate-qtquick/QmlEngine.h b/source/gloperate-qtquick/include/gloperate-qtquick/QmlEngine.h index 979a1f49..f2f50462 100644 --- a/source/gloperate-qtquick/include/gloperate-qtquick/QmlEngine.h +++ b/source/gloperate-qtquick/include/gloperate-qtquick/QmlEngine.h @@ -6,7 +6,7 @@ #include #include -#include +#include #include diff --git a/source/gloperate-qtquick/include/gloperate-qtquick/QmlScriptFunction.h b/source/gloperate-qtquick/include/gloperate-qtquick/QmlScriptFunction.h index e8b140eb..04a5bd76 100644 --- a/source/gloperate-qtquick/include/gloperate-qtquick/QmlScriptFunction.h +++ b/source/gloperate-qtquick/include/gloperate-qtquick/QmlScriptFunction.h @@ -4,7 +4,7 @@ #include -#include +#include #include #include diff --git a/source/gloperate-qtquick/source/QmlEngine.cpp b/source/gloperate-qtquick/source/QmlEngine.cpp index 078e334e..6b286ec2 100644 --- a/source/gloperate-qtquick/source/QmlEngine.cpp +++ b/source/gloperate-qtquick/source/QmlEngine.cpp @@ -2,6 +2,7 @@ #include #include +#include #include #include @@ -10,7 +11,6 @@ #include #include -#include #include #include diff --git a/source/gloperate-qtquick/source/QmlObjectWrapper.cpp b/source/gloperate-qtquick/source/QmlObjectWrapper.cpp index bc399479..d784be9d 100644 --- a/source/gloperate-qtquick/source/QmlObjectWrapper.cpp +++ b/source/gloperate-qtquick/source/QmlObjectWrapper.cpp @@ -5,7 +5,7 @@ #include #include -#include +#include #include diff --git a/source/gloperate-qtquick/source/TextureItemRenderer_ogl.cpp b/source/gloperate-qtquick/source/TextureItemRenderer_ogl.cpp index 5b5de113..674deed1 100644 --- a/source/gloperate-qtquick/source/TextureItemRenderer_ogl.cpp +++ b/source/gloperate-qtquick/source/TextureItemRenderer_ogl.cpp @@ -66,7 +66,7 @@ void TextureItemRenderer::renderTexture() if (!slot) return; // Check if it is a texture slot - if (slot && slot->type() == typeid(globjects::Texture *)) + if (slot && slot->type() == cppexpose::ConcreteType()) { texture = static_cast< Slot * >(slot)->value(); } diff --git a/source/gloperate-text/include/gloperate-text/Alignment.h b/source/gloperate-text/include/gloperate-text/Alignment.h index a9fc526c..035354ed 100644 --- a/source/gloperate-text/include/gloperate-text/Alignment.h +++ b/source/gloperate-text/include/gloperate-text/Alignment.h @@ -60,9 +60,10 @@ namespace cppexpose * Template specialization of enum strings for Alignment. */ template<> -struct EnumDefaultStrings +class EnumValues { - std::map operator()() +public: + static std::map namedValues() { return{ { gloperate_text::Alignment::LeftAligned, "LeftAligned" }, diff --git a/source/gloperate-text/include/gloperate-text/FontLoader.h b/source/gloperate-text/include/gloperate-text/FontLoader.h index 77d2ff1d..d7718b49 100644 --- a/source/gloperate-text/include/gloperate-text/FontLoader.h +++ b/source/gloperate-text/include/gloperate-text/FontLoader.h @@ -5,7 +5,7 @@ #include #include -#include +#include #include #include diff --git a/source/gloperate-text/include/gloperate-text/LineAnchor.h b/source/gloperate-text/include/gloperate-text/LineAnchor.h index 6b01b284..7bcd6bb3 100644 --- a/source/gloperate-text/include/gloperate-text/LineAnchor.h +++ b/source/gloperate-text/include/gloperate-text/LineAnchor.h @@ -44,9 +44,10 @@ namespace cppexpose template<> -struct EnumDefaultStrings +class EnumValues { - std::map operator()() +public: + static std::map namedValues() { return { { gloperate_text::LineAnchor::Ascent, "Ascent" }, diff --git a/source/gloperate/CMakeLists.txt b/source/gloperate/CMakeLists.txt index f5b82ad7..ac53fb77 100644 --- a/source/gloperate/CMakeLists.txt +++ b/source/gloperate/CMakeLists.txt @@ -188,7 +188,7 @@ set(sources ${source_path}/base/AbstractLoader.cpp ${source_path}/base/AbstractStorer.cpp ${source_path}/base/Range.cpp - ${source_path}/base/ExtendedProperties.cpp + #${source_path}/base/ExtendedProperties.cpp ${source_path}/pipeline/Stage.cpp ${source_path}/pipeline/Pipeline.cpp diff --git a/source/gloperate/include/gloperate/base/Canvas.h b/source/gloperate/include/gloperate/base/Canvas.h index 74ce700e..424410c3 100644 --- a/source/gloperate/include/gloperate/base/Canvas.h +++ b/source/gloperate/include/gloperate/base/Canvas.h @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include diff --git a/source/gloperate/include/gloperate/base/ExtendedProperties.h b/source/gloperate/include/gloperate/base/ExtendedProperties.h index a0d90faf..334be780 100644 --- a/source/gloperate/include/gloperate/base/ExtendedProperties.h +++ b/source/gloperate/include/gloperate/base/ExtendedProperties.h @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include @@ -155,6 +155,12 @@ class TypedGlmVec : public cppexpose::Typed bool fromVariant(const cppexpose::Variant & value) override; }; +template +struct GLOPERATE_TEMPLATE_API GetType +{ + using Type = BaseTypeImplGeneric; +}; + template struct GetTyped { diff --git a/source/gloperate/include/gloperate/base/ResourceManager.h b/source/gloperate/include/gloperate/base/ResourceManager.h index fc9021d8..2315b3a3 100644 --- a/source/gloperate/include/gloperate/base/ResourceManager.h +++ b/source/gloperate/include/gloperate/base/ResourceManager.h @@ -7,7 +7,7 @@ #include #include -#include +#include #include diff --git a/source/gloperate/include/gloperate/pipeline/AbstractSlot.h b/source/gloperate/include/gloperate/pipeline/AbstractSlot.h index 8dee5181..87257a5b 100644 --- a/source/gloperate/include/gloperate/pipeline/AbstractSlot.h +++ b/source/gloperate/include/gloperate/pipeline/AbstractSlot.h @@ -282,6 +282,11 @@ class GLOPERATE_API AbstractSlot : public cppexpose::AbstractProperty bool isOfAnyType() const; + // Copied from cppexpose::Object + cppexpose::Variant toVariant() const; + bool fromVariant(const cppexpose::Variant & value); + + protected: /** * @brief diff --git a/source/gloperate/include/gloperate/pipeline/Input.h b/source/gloperate/include/gloperate/pipeline/Input.h index 88659c0a..e7d442c3 100644 --- a/source/gloperate/include/gloperate/pipeline/Input.h +++ b/source/gloperate/include/gloperate/pipeline/Input.h @@ -84,13 +84,13 @@ class GLOPERATE_TEMPLATE_API Input : public Slot protected: // Virtual AbstractSlot interface - virtual void onValueInvalidated() override; + virtual void onValueInvalidated(); // Virtual Typed interface - virtual void onValueChanged(const T & value) override; + virtual void onValueChanged(const T & value); // Virtual AbstractProperty interface - virtual void onOptionChanged(const std::string & option) override; + virtual void onOptionChanged(const std::string & option); protected: diff --git a/source/gloperate/include/gloperate/pipeline/Output.h b/source/gloperate/include/gloperate/pipeline/Output.h index 65cde2e7..5cd3b79b 100644 --- a/source/gloperate/include/gloperate/pipeline/Output.h +++ b/source/gloperate/include/gloperate/pipeline/Output.h @@ -80,11 +80,11 @@ class GLOPERATE_TEMPLATE_API Output : public Slot protected: // Virtual AbstractSlot interface - virtual void onValueInvalidated() override; - virtual void onRequiredChanged() override; + virtual void onValueInvalidated(); + virtual void onRequiredChanged(); // Virtual Typed interface - virtual void onValueChanged(const T & value) override; + virtual void onValueChanged(const T & value); }; diff --git a/source/gloperate/include/gloperate/pipeline/Slot.h b/source/gloperate/include/gloperate/pipeline/Slot.h index 86771f92..5837fb58 100644 --- a/source/gloperate/include/gloperate/pipeline/Slot.h +++ b/source/gloperate/include/gloperate/pipeline/Slot.h @@ -2,7 +2,6 @@ #pragma once -#include #include #include @@ -21,7 +20,7 @@ namespace gloperate * @see AbstractSlot */ template -class GLOPERATE_TEMPLATE_API Slot : public cppexpose::DirectValue +class GLOPERATE_TEMPLATE_API Slot : public AbstractSlot { protected: //@{ @@ -153,18 +152,60 @@ class GLOPERATE_TEMPLATE_API Slot : public cppexpose::DirectValue interface - virtual T value() const override; - virtual void setValue(const T & value) override; - virtual const T * ptr() const override; - virtual T * ptr() override; - - // Virtual AbstractTyped interface - virtual std::unique_ptr clone() const override; + // Typed value interface + virtual T value() const; + virtual void setValue(const T & value); + virtual const T * ptr() const; + virtual T * ptr(); + + // Virtual Typed interface + virtual const cppexpose::Type & type() const override; + virtual cppexpose::Type & type() override; + virtual const cppexpose::AbstractBaseType * baseType() const override; + virtual cppexpose::AbstractBaseType * baseType() override; + virtual const cppexpose::Type & elementType() const override; + virtual cppexpose::Type & elementType() override; + virtual const std::string & typeName() const override; + virtual bool isNull() const override; + virtual bool isType() const override; + virtual bool isConst() const override; + virtual bool isArray() const override; + virtual bool isDynamicArray() const override; + virtual bool isMap() const override; + virtual bool isBoolean() const override; + virtual bool isNumber() const override; + virtual bool isIntegral() const override; + virtual bool isUnsigned() const override; + virtual bool isFloatingPoint() const override; + virtual bool isString() const override; + + // Virtual AbstractValueContainer interface + virtual std::unique_ptr createCopy() const override; + virtual bool compareTypeAndValue(const AbstractValueContainer & value) const override; + virtual std::string toString() const override; + virtual bool fromString(const std::string & value) override; + virtual bool toBool() const override; + virtual bool fromBool(bool value) override; + virtual long long toLongLong() const override; + virtual bool fromLongLong(long long value) override; + virtual unsigned long long toULongLong() const override; + virtual bool fromULongLong(unsigned long long value) override; + virtual double toDouble() const override; + virtual bool fromDouble(double value) override; + virtual size_t numElements() const override; + virtual cppexpose::Variant element(size_t i) const override; + virtual void setElement(size_t i, const cppexpose::Variant & value) override; + virtual void pushElement(const cppexpose::Variant & value) override; + virtual std::vector keys() const override; + virtual cppexpose::Variant element(const std::string & key) const override; + virtual void setElement(const std::string & key, const cppexpose::Variant & value) override; // Virtual AbstractProperty interface virtual bool isObject() const override; + // Required interface from Input and Output + virtual void onValueChanged(const T & value) = 0; + protected: void promoteConnection(); @@ -172,6 +213,7 @@ class GLOPERATE_TEMPLATE_API Slot : public cppexpose::DirectValue m_value; ///< Actual value bool m_valid; ///< Does the slot have a valid value? bool m_changed; ///< Was the slot changed since the last time it's pipeline was processed Slot * m_source; ///< Connected slot (can be null) diff --git a/source/gloperate/include/gloperate/pipeline/Slot.inl b/source/gloperate/include/gloperate/pipeline/Slot.inl index 77159fc5..83a7b346 100644 --- a/source/gloperate/include/gloperate/pipeline/Slot.inl +++ b/source/gloperate/include/gloperate/pipeline/Slot.inl @@ -4,8 +4,6 @@ #include -#include - #include #include @@ -38,28 +36,32 @@ auto Slot::DereferenceHelper::pointer(U * const * value) -> Pointer template Slot::Slot(SlotType slotType, const std::string & name, Stage * parent, const T & value) -: cppexpose::DirectValue(value) +: AbstractSlot(name) +, m_value(value) , m_valid(true) , m_source(nullptr) { + // TODO: implement // Do not add property to object, yet. Just initialize the property itself - this->initProperty(name, nullptr); + //this->initProperty(name, nullptr); // Initialize slot, will also add slot as a property - this->initSlot(slotType, parent); + //this->initSlot(slotType, parent); } template Slot::Slot(SlotType slotType, const std::string & name, const T & value) -: cppexpose::DirectValue(value) +: AbstractSlot(name) +, m_value(value) , m_valid(true) , m_source(nullptr) { // Make as a dynamic slot this->m_dynamic = true; + // TODO: reimplement // Do not add property to object, yet. Just initialize the property itself - this->initProperty(name, nullptr); + //this->initProperty(name, nullptr); // Initialize slot this->initSlot(slotType, nullptr); @@ -92,7 +94,6 @@ bool Slot::connect(Slot * source) { this->onValueInvalidated(); } ); - // Emit events this->promoteConnection(); this->promoteRequired(); @@ -166,7 +167,7 @@ void Slot::disconnect() // Emit events this->promoteConnection(); - this->onValueChanged(this->m_value); + this->onValueChanged(this->m_value.value()); } template @@ -234,7 +235,7 @@ T Slot::value() const } // Return own data - return this->m_value; + return this->m_value.value(); } template @@ -251,7 +252,7 @@ void Slot::setValue(const T & value) this->m_valid = true; // Emit signal - this->onValueChanged(this->m_value); + this->onValueChanged(this->m_value.value()); } template @@ -264,7 +265,7 @@ const T * Slot::ptr() const } // Return own data - return &this->m_value; + return this->m_value.ptr(); } template @@ -277,11 +278,11 @@ T * Slot::ptr() } // Return own data - return &this->m_value; + return this->m_value.ptr(); } template -std::unique_ptr Slot::clone() const +std::unique_ptr Slot::createCopy() const { return nullptr; } diff --git a/source/gloperate/include/gloperate/pipeline/Stage.inl b/source/gloperate/include/gloperate/pipeline/Stage.inl index cc16d32c..1ee9a4ed 100644 --- a/source/gloperate/include/gloperate/pipeline/Stage.inl +++ b/source/gloperate/include/gloperate/pipeline/Stage.inl @@ -30,6 +30,8 @@ Input * Stage::CreateConnectedInputProxy::operator=(const T & value) template std::vector *> Stage::inputs() const { + static cppexpose::ConcreteType type; + auto result = std::vector *>{}; // We do not reserve a heuristically derived number of elements as we assume @@ -38,7 +40,7 @@ std::vector *> Stage::inputs() const for (auto input : inputs()) { - if (input->type() == typeid(T)) + if (input->type() == type) { result.push_back(static_cast *>(input)); } @@ -70,6 +72,8 @@ Input * Stage::createConnectedInput(const std::string & name, Slot & sourc template std::vector *> Stage::outputs() const { + static cppexpose::ConcreteType type; + auto result = std::vector *>{}; // We do not reserve a heuristically derived number of elements as we assume @@ -78,7 +82,7 @@ std::vector *> Stage::outputs() const for (auto output : outputs()) { - if (output->type() == typeid(T)) + if (output->type() == type) { result.push_back(static_cast *>(output)); } diff --git a/source/gloperate/include/gloperate/rendering/AttachmentType.h b/source/gloperate/include/gloperate/rendering/AttachmentType.h index 93cd58ca..01a9246a 100644 --- a/source/gloperate/include/gloperate/rendering/AttachmentType.h +++ b/source/gloperate/include/gloperate/rendering/AttachmentType.h @@ -3,7 +3,7 @@ #include -#include +#include namespace gloperate @@ -59,9 +59,10 @@ namespace cppexpose * Template specialization of enum strings for RenderTargetType. */ template<> -struct EnumDefaultStrings +class EnumValues { - std::map operator()() +public: + static std::map namedValues() { return { { gloperate::AttachmentType::Color, "Color" }, diff --git a/source/gloperate/include/gloperate/rendering/Light.h b/source/gloperate/include/gloperate/rendering/Light.h index 0a880478..261f8d22 100644 --- a/source/gloperate/include/gloperate/rendering/Light.h +++ b/source/gloperate/include/gloperate/rendering/Light.h @@ -12,10 +12,18 @@ namespace gloperate struct Light { +public: LightType type; glm::vec3 color; glm::vec3 position; glm::vec3 attenuationCoefficients; + + +public: + bool operator==(const Light & other) const + { + return this == &other; + } }; diff --git a/source/gloperate/include/gloperate/rendering/RenderTargetType.h b/source/gloperate/include/gloperate/rendering/RenderTargetType.h index e524c7ec..f3135260 100644 --- a/source/gloperate/include/gloperate/rendering/RenderTargetType.h +++ b/source/gloperate/include/gloperate/rendering/RenderTargetType.h @@ -3,7 +3,7 @@ #include -#include +#include namespace gloperate @@ -60,9 +60,10 @@ namespace cppexpose * Template specialization of enum strings for RenderTargetType. */ template<> -struct EnumDefaultStrings +class EnumValues { - std::map operator()() +public: + static std::map namedValues() { return { { gloperate::RenderTargetType::Invalid, "Invalid" }, diff --git a/source/gloperate/include/gloperate/rendering/ShapeType.h b/source/gloperate/include/gloperate/rendering/ShapeType.h index 15562157..3556b519 100644 --- a/source/gloperate/include/gloperate/rendering/ShapeType.h +++ b/source/gloperate/include/gloperate/rendering/ShapeType.h @@ -44,17 +44,18 @@ namespace cppexpose template <> -struct EnumDefaultStrings +class EnumValues { - std::map operator()() +public: + static std::map namedValues() { - std::map values; - values[gloperate::ShapeType::None] = "None"; - values[gloperate::ShapeType::Point] = "Point"; - values[gloperate::ShapeType::Quad] = "Quad"; - values[gloperate::ShapeType::Triangle] = "Triangle"; - values[gloperate::ShapeType::Box] = "Box"; - values[gloperate::ShapeType::Sphere] = "Sphere"; + std::map values; + values["None"] = gloperate::ShapeType::None; + values["Point"] = gloperate::ShapeType::Point; + values["Quad"] = gloperate::ShapeType::Quad; + values["Triangle"] = gloperate::ShapeType::Triangle; + values["Box"] = gloperate::ShapeType::Box; + values["Sphere"] = gloperate::ShapeType::Sphere; return values; } diff --git a/source/gloperate/include/gloperate/stages/base/BasicFramebufferStage.h b/source/gloperate/include/gloperate/stages/base/BasicFramebufferStage.h index 5115a3b7..a66dbca6 100644 --- a/source/gloperate/include/gloperate/stages/base/BasicFramebufferStage.h +++ b/source/gloperate/include/gloperate/stages/base/BasicFramebufferStage.h @@ -8,8 +8,10 @@ #include +#include + #include -#include +//#include #include #include #include diff --git a/source/gloperate/include/gloperate/stages/base/BlitStage.h b/source/gloperate/include/gloperate/stages/base/BlitStage.h index d07839b2..034d0eac 100644 --- a/source/gloperate/include/gloperate/stages/base/BlitStage.h +++ b/source/gloperate/include/gloperate/stages/base/BlitStage.h @@ -10,7 +10,7 @@ #include -#include +//#include #include #include #include diff --git a/source/gloperate/include/gloperate/stages/base/ClearStage.h b/source/gloperate/include/gloperate/stages/base/ClearStage.h index 284add1d..fe809716 100644 --- a/source/gloperate/include/gloperate/stages/base/ClearStage.h +++ b/source/gloperate/include/gloperate/stages/base/ClearStage.h @@ -11,6 +11,7 @@ #include #include #include +#include namespace globjects diff --git a/source/gloperate/include/gloperate/stages/base/TextureLoadStage.h b/source/gloperate/include/gloperate/stages/base/TextureLoadStage.h index 2ef2eba6..805de4f5 100644 --- a/source/gloperate/include/gloperate/stages/base/TextureLoadStage.h +++ b/source/gloperate/include/gloperate/stages/base/TextureLoadStage.h @@ -4,12 +4,14 @@ #include +#include + #include #include #include -#include +//#include #include #include #include diff --git a/source/gloperate/include/gloperate/stages/base/ViewportScaleStage.h b/source/gloperate/include/gloperate/stages/base/ViewportScaleStage.h index 7209b64c..4168e808 100644 --- a/source/gloperate/include/gloperate/stages/base/ViewportScaleStage.h +++ b/source/gloperate/include/gloperate/stages/base/ViewportScaleStage.h @@ -4,10 +4,12 @@ #include +#include + #include #include -#include +//#include #include #include #include diff --git a/source/gloperate/include/gloperate/stages/interfaces/CanvasInterface.h b/source/gloperate/include/gloperate/stages/interfaces/CanvasInterface.h index c89dacca..ab821607 100644 --- a/source/gloperate/include/gloperate/stages/interfaces/CanvasInterface.h +++ b/source/gloperate/include/gloperate/stages/interfaces/CanvasInterface.h @@ -2,7 +2,9 @@ #pragma once -#include +#include + +//#include #include #include diff --git a/source/gloperate/include/gloperate/stages/interfaces/RenderInterface.h b/source/gloperate/include/gloperate/stages/interfaces/RenderInterface.h index d0072f7a..daefc812 100644 --- a/source/gloperate/include/gloperate/stages/interfaces/RenderInterface.h +++ b/source/gloperate/include/gloperate/stages/interfaces/RenderInterface.h @@ -4,9 +4,11 @@ #include +#include + #include #include -#include +//#include namespace globjects diff --git a/source/gloperate/include/gloperate/tools/AbstractVideoExporter.h b/source/gloperate/include/gloperate/tools/AbstractVideoExporter.h index ccb43a49..ef38260d 100644 --- a/source/gloperate/include/gloperate/tools/AbstractVideoExporter.h +++ b/source/gloperate/include/gloperate/tools/AbstractVideoExporter.h @@ -7,7 +7,7 @@ #include -#include +#include #include diff --git a/source/gloperate/source/base/Canvas.cpp b/source/gloperate/source/base/Canvas.cpp index 5f2ed50f..fc07c397 100644 --- a/source/gloperate/source/base/Canvas.cpp +++ b/source/gloperate/source/base/Canvas.cpp @@ -5,6 +5,7 @@ #include #include +#include #include @@ -12,7 +13,7 @@ #include #include -#include +#include #include @@ -539,20 +540,20 @@ cppexpose::Variant Canvas::scr_getSlotTypes(const std::string & path) { Variant types = Variant::array(); - types.asArray()->push_back("bool"); - types.asArray()->push_back("int"); - types.asArray()->push_back("float"); - types.asArray()->push_back("vec2"); - types.asArray()->push_back("vec3"); - types.asArray()->push_back("vec4"); - types.asArray()->push_back("ivec2"); - types.asArray()->push_back("ivec3"); - types.asArray()->push_back("ivec4"); - types.asArray()->push_back("string"); - types.asArray()->push_back("file"); - types.asArray()->push_back("color"); - types.asArray()->push_back("texture"); - types.asArray()->push_back("fbo"); + types.pushElement("bool"); + types.pushElement("int"); + types.pushElement("float"); + types.pushElement("vec2"); + types.pushElement("vec3"); + types.pushElement("vec4"); + types.pushElement("ivec2"); + types.pushElement("ivec3"); + types.pushElement("ivec4"); + types.pushElement("string"); + types.pushElement("file"); + types.pushElement("color"); + types.pushElement("texture"); + types.pushElement("fbo"); return types; } @@ -652,11 +653,11 @@ cppexpose::Variant Canvas::scr_getConnections(const std::string & path) // Describe connection Variant connection = Variant::map(); - (*connection.asMap())["from"] = from; - (*connection.asMap())["to"] = to; + connection.setElement("from", from); + connection.setElement("to", to); // Add connection - obj.asArray()->push_back(connection); + obj.pushElement(connection); } }; @@ -725,25 +726,25 @@ cppexpose::Variant Canvas::scr_getStage(const std::string & path) // Compose stage information Variant obj = Variant::map(); - (*obj.asMap())["name"] = name(); + obj.setElement("name", name()); // List inputs Variant inputs = Variant::array(); for (auto input : stage->inputs()) { - inputs.asArray()->push_back(input->name()); + inputs.pushElement(input->name()); } - (*obj.asMap())["inputs"] = inputs; + obj.setElement("inputs", inputs); // List outputs Variant outputs = Variant::array(); for (auto output : stage->outputs()) { - outputs.asArray()->push_back(output->name()); + outputs.pushElement(output->name()); } - (*obj.asMap())["outputs"] = outputs; + obj.setElement("outputs", outputs); // List stages Variant stages = Variant::array(); @@ -754,11 +755,11 @@ cppexpose::Variant Canvas::scr_getStage(const std::string & path) auto stageList = pipeline->stages(); for (auto stage : stageList) { - stages.asArray()->push_back(stage->name()); + stages.pushElement(stage->name()); } } - (*obj.asMap())["stages"] = stages; + obj.setElement("stages", stages); // Return information about stage return obj; @@ -784,7 +785,8 @@ cppexpose::Variant Canvas::scr_getValue(const std::string & path, const std::str AbstractSlot * slot = stage->getSlot(slotName); if (slot) { - return slot->toVariant(); + // TODO: use real variant converter here + return cppexpose::Variant(slot->toString()); } } @@ -853,12 +855,13 @@ cppexpose::Variant Canvas::getSlotStatus(const std::string & path, const std::st if (slot) { // Compose slot information - (*status.asMap())["name"] = slot->name(); - (*status.asMap())["type"] = slot->typeName(); - (*status.asMap())["value"] = slot->toVariant(); + status.setElement("name", slot->name()); + status.setElement("type", slot->typeName()); + status.setElement("value", slot->toVariant()); + // TODO: implement // Include options - const VariantMap & options = slot->options(); + /*const VariantMap & options = slot->options(); for (auto it : options) { @@ -866,7 +869,7 @@ cppexpose::Variant Canvas::getSlotStatus(const std::string & path, const std::st Variant & value = it.second; (*status.asMap())[key] = value; - } + }*/ } } diff --git a/source/gloperate/source/base/ComponentManager.cpp b/source/gloperate/source/base/ComponentManager.cpp index 51b558ec..9e141e2f 100644 --- a/source/gloperate/source/base/ComponentManager.cpp +++ b/source/gloperate/source/base/ComponentManager.cpp @@ -3,7 +3,7 @@ #include -#include +#include using namespace cppexpose; @@ -68,7 +68,7 @@ cppexpose::Variant ComponentManager::scr_pluginPaths() cppexpose::Variant lst = cppexpose::Variant::array(); for (auto path : paths) { - lst.asArray()->push_back(cppexpose::Variant(path)); + lst.pushElement(cppexpose::Variant(path)); } return lst; @@ -96,18 +96,17 @@ cppexpose::Variant ComponentManager::scr_components() auto & components = this->components(); for (auto * component : components) { cppexpose::Variant obj = cppexpose::Variant::map(); - cppexpose::VariantMap & map = *obj.asMap(); - - map["name"] = cppexpose::Variant(component->name()); - map["description"] = cppexpose::Variant(component->description()); - map["type"] = cppexpose::Variant(component->type()); - map["tags"] = cppexpose::Variant(component->tags()); - map["icon"] = cppexpose::Variant(component->icon()); - map["annotations"] = cppexpose::Variant(component->annotations()); - map["vendor"] = cppexpose::Variant(component->vendor()); - map["version"] = cppexpose::Variant(component->version()); - - lst.asArray()->push_back(obj); + + obj.setElement("name", cppexpose::Variant(component->name())); + obj.setElement("description", cppexpose::Variant(component->description())); + obj.setElement("type", cppexpose::Variant(component->type())); + obj.setElement("tags", cppexpose::Variant(component->tags())); + obj.setElement("icon", cppexpose::Variant(component->icon())); + obj.setElement("annotations", cppexpose::Variant(component->annotations())); + obj.setElement("vendor", cppexpose::Variant(component->vendor())); + obj.setElement("version", cppexpose::Variant(component->version())); + + lst.pushElement(obj); } return lst; diff --git a/source/gloperate/source/base/ExtendedProperties.cpp b/source/gloperate/source/base/ExtendedProperties.cpp index f74cb3e3..ed0e7aae 100644 --- a/source/gloperate/source/base/ExtendedProperties.cpp +++ b/source/gloperate/source/base/ExtendedProperties.cpp @@ -1,5 +1,5 @@ -#include +//#include namespace gloperate diff --git a/source/gloperate/source/loaders/ColorGradientLoader.cpp b/source/gloperate/source/loaders/ColorGradientLoader.cpp index 90eb4a95..c9735d04 100644 --- a/source/gloperate/source/loaders/ColorGradientLoader.cpp +++ b/source/gloperate/source/loaders/ColorGradientLoader.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include #include @@ -75,29 +75,26 @@ ColorGradientList * ColorGradientLoader::load(const std::string & filename, cons return nullptr; } - const cppexpose::VariantMap * jsonMap = json.asMap(); - - for (const auto & gradientPair : *jsonMap) + for (const auto & baseName : json.keys()) { - const std::string & baseName = gradientPair.first; - const cppexpose::VariantMap * gradient = gradientPair.second.asMap(); + const cppexpose::Variant gradient = json.element(baseName); - for (const auto & classesPair : *gradient) + for (const auto & classNumber : gradient.keys()) { - const std::string & classNumber = classesPair.first; - if (classNumber == "type") { continue; } - const cppexpose::VariantArray * colorList = classesPair.second.asArray(); + const cppexpose::Variant colorList = gradient.element(classNumber); std::vector colors; - colors.reserve(colorList->size()); + colors.reserve(colorList.numElements()); - for (const auto & colorString : *colorList) + for (size_t i = 0; i < colorList.numElements(); ++i) { + const auto & colorString = colorList.element(i); + std::vector rgbValues = cppassist::string::extract(colorString.value(), R"([0-9]+)"); colors.emplace_back(std::stoi(rgbValues[0]), std::stoi(rgbValues[1]), std::stoi(rgbValues[2])); diff --git a/source/gloperate/source/loaders/GlrawTextureLoader.cpp b/source/gloperate/source/loaders/GlrawTextureLoader.cpp index dd6fcc36..81e83cdf 100644 --- a/source/gloperate/source/loaders/GlrawTextureLoader.cpp +++ b/source/gloperate/source/loaders/GlrawTextureLoader.cpp @@ -8,7 +8,7 @@ #include #include -#include +#include #include diff --git a/source/gloperate/source/loaders/ShaderLoader.cpp b/source/gloperate/source/loaders/ShaderLoader.cpp index 39acce07..6beebb7b 100644 --- a/source/gloperate/source/loaders/ShaderLoader.cpp +++ b/source/gloperate/source/loaders/ShaderLoader.cpp @@ -6,7 +6,7 @@ #include #include -#include +#include #include diff --git a/source/gloperate/source/pipeline/AbstractSlot.cpp b/source/gloperate/source/pipeline/AbstractSlot.cpp index 629b4ca4..fd475c74 100644 --- a/source/gloperate/source/pipeline/AbstractSlot.cpp +++ b/source/gloperate/source/pipeline/AbstractSlot.cpp @@ -12,15 +12,16 @@ namespace gloperate AbstractSlot::AbstractSlot() -: m_slotType(SlotType::Unknown) +: AbstractProperty("") +, m_slotType(SlotType::Unknown) , m_dynamic(false) , m_required(false) , m_feedback(false) { } -AbstractSlot::AbstractSlot(const cppexpose::Variant & options) -: AbstractProperty(options) +AbstractSlot::AbstractSlot(const cppexpose::Variant & /*options*/) +: AbstractProperty("") , m_slotType(SlotType::Unknown) , m_dynamic(false) , m_required(false) @@ -113,5 +114,52 @@ void AbstractSlot::initSlot(SlotType slotType, Stage * parent) } } +cppexpose::Variant AbstractSlot::toVariant() const +{ + // Create variant map from all properties in the object + cppexpose::Variant map = cppexpose::Variant::map(); + + // TODO: implement + /*for (const auto & it : m_propertiesMap) { + // Get name and property + const std::string & name = it.first; + AbstractProperty * prop = it.second; + + // Add to variant map + (*map.asMap())[name] = prop->toVariant(); + }*/ + + // Return variant representation + return map; +} + +bool AbstractSlot::fromVariant(const cppexpose::Variant & value) +{ + // Check if variant is a map + if (!value.isMap()) { + return false; + } + + // TODO: implement + /* + // Get all values from variant map + for (const auto & name : value.keys()) { + // Get name and value + const cppexpose::Variant & var = value.element(name); + + // If this names an existing property, set its value + AbstractProperty * prop = this->property(name); + + if (prop) + { + prop->fromVariant(var); + } + } + */ + + // Done + return true; +} + } // namespace gloperate diff --git a/source/gloperate/source/pipeline/Pipeline.cpp b/source/gloperate/source/pipeline/Pipeline.cpp index 59f10004..11658597 100644 --- a/source/gloperate/source/pipeline/Pipeline.cpp +++ b/source/gloperate/source/pipeline/Pipeline.cpp @@ -1,6 +1,8 @@ #include +#include + #include #include #include @@ -8,7 +10,7 @@ #include #include -#include +#include #include #include diff --git a/source/gloperate/source/pipeline/Stage.cpp b/source/gloperate/source/pipeline/Stage.cpp index c7ca7025..e9acddb8 100644 --- a/source/gloperate/source/pipeline/Stage.cpp +++ b/source/gloperate/source/pipeline/Stage.cpp @@ -6,15 +6,20 @@ #include #include -#include +#include #include #include -#include +//#include #include #include +// TODO: fix +#include +#include +#include + using namespace cppassist; using namespace cppexpose; diff --git a/source/gloperate/source/stages/base/BasicFramebufferStage.cpp b/source/gloperate/source/stages/base/BasicFramebufferStage.cpp index 7c32bb68..4ce79970 100644 --- a/source/gloperate/source/stages/base/BasicFramebufferStage.cpp +++ b/source/gloperate/source/stages/base/BasicFramebufferStage.cpp @@ -3,6 +3,8 @@ #include +#include + #include #include diff --git a/source/gloperate/source/stages/base/ColorGradientTextureStage.cpp b/source/gloperate/source/stages/base/ColorGradientTextureStage.cpp index 0e4d0404..466adf69 100644 --- a/source/gloperate/source/stages/base/ColorGradientTextureStage.cpp +++ b/source/gloperate/source/stages/base/ColorGradientTextureStage.cpp @@ -37,11 +37,13 @@ void ColorGradientTextureStage::onContextDeinit(AbstractGLContext *) void ColorGradientTextureStage::onProcess() { + static cppexpose::ConcreteType colorGradientListPointerType; + std::vector gradientLists; for (auto input : inputs()) { - if (input->type() == typeid(ColorGradientList *)) + if (input->type() == colorGradientListPointerType) { gradientLists.push_back(static_cast *>(input)->value()); } diff --git a/source/gloperate/source/stages/base/RenderPassStage.cpp b/source/gloperate/source/stages/base/RenderPassStage.cpp index bdc3b53a..2306fde5 100644 --- a/source/gloperate/source/stages/base/RenderPassStage.cpp +++ b/source/gloperate/source/stages/base/RenderPassStage.cpp @@ -123,7 +123,7 @@ void RenderPassStage::onProcess() continue; // Texture - if (input->type() == typeid(globjects::Texture *)) + if (input->type() == cppexpose::ConcreteType()) { // Get texture globjects::Texture * texture = static_cast *>(input)->value(); @@ -144,7 +144,7 @@ void RenderPassStage::onProcess() } // Shader storage buffer - else if (input->type() == typeid(globjects::Buffer *)) + else if (input->type() == cppexpose::ConcreteType()) { // Get buffer globjects::Buffer * buffer = static_cast *>(input)->value(); @@ -158,7 +158,7 @@ void RenderPassStage::onProcess() } // Color - else if (input->type() == typeid(Color)) + else if (input->type() == cppexpose::ConcreteType()) { // Get color const Color & color = **(static_cast *>(input)); @@ -180,23 +180,24 @@ void RenderPassStage::onProcess() void RenderPassStage::setUniformValue(globjects::Program * program, AbstractSlot * input) { - if (input->type() == typeid(float)) { + // TODO: finalize + if (input->type() == cppexpose::ConcreteType()) { program->setUniform(input->name(), static_cast *>(input)->value()); - } else if (input->type() == typeid(int)) { + } else if (input->type() == cppexpose::ConcreteType()) { program->setUniform(input->name(), static_cast *>(input)->value()); - } else if (input->type() == typeid(unsigned int)) { + } else if (input->type() == cppexpose::ConcreteType()) { program->setUniform(input->name(), static_cast *>(input)->value()); - } else if (input->type() == typeid(bool)) { + } else if (input->type() == cppexpose::ConcreteType()) { program->setUniform(input->name(), static_cast *>(input)->value()); - } else if (input->type() == typeid(glm::vec2)) { + } else if (input->type() == cppexpose::ConcreteType()) { program->setUniform(input->name(), static_cast *>(input)->value()); - } else if (input->type() == typeid(glm::vec3)) { + } else if (input->type() == cppexpose::ConcreteType()) { program->setUniform(input->name(), static_cast *>(input)->value()); - } else if (input->type() == typeid(glm::vec4)) { + } else if (input->type() == cppexpose::ConcreteType()) { program->setUniform(input->name(), static_cast *>(input)->value()); - } else if (input->type() == typeid(glm::ivec2)) { + } else if (input->type() == cppexpose::ConcreteType()) { program->setUniform(input->name(), static_cast *>(input)->value()); - } else if (input->type() == typeid(glm::ivec3)) { + }/* else if (input->type() == typeid(glm::ivec3)) { program->setUniform(input->name(), static_cast *>(input)->value()); } else if (input->type() == typeid(glm::ivec4)) { program->setUniform(input->name(), static_cast *>(input)->value()); @@ -276,7 +277,7 @@ void RenderPassStage::setUniformValue(globjects::Program * program, AbstractSlot program->setUniform>(input->name(), static_cast> *>(input)->value()); } else if (input->type() == typeid(std::vector)) { program->setUniform>(input->name(), static_cast> *>(input)->value()); - } + }*/ } diff --git a/source/gloperate/source/stages/base/ViewportScaleStage.cpp b/source/gloperate/source/stages/base/ViewportScaleStage.cpp index dbd80364..5ce59cbb 100644 --- a/source/gloperate/source/stages/base/ViewportScaleStage.cpp +++ b/source/gloperate/source/stages/base/ViewportScaleStage.cpp @@ -1,6 +1,8 @@ #include +#include + #include diff --git a/source/gloperate/source/stages/interfaces/CanvasInterface.cpp b/source/gloperate/source/stages/interfaces/CanvasInterface.cpp index bf0cb5f0..e7160dfb 100644 --- a/source/gloperate/source/stages/interfaces/CanvasInterface.cpp +++ b/source/gloperate/source/stages/interfaces/CanvasInterface.cpp @@ -13,9 +13,9 @@ CanvasInterface::CanvasInterface(Stage * stage) , timeDelta ("timeDelta", stage) { // Hide inputs in property editor - backgroundColor.setOption("hidden", true); - frameCounter .setOption("hidden", true); - timeDelta .setOption("hidden", true); + //backgroundColor.setOption("hidden", true); + //frameCounter .setOption("hidden", true); + //timeDelta .setOption("hidden", true); } CanvasInterface::~CanvasInterface() diff --git a/source/gloperate/source/stages/interfaces/RenderInterface.cpp b/source/gloperate/source/stages/interfaces/RenderInterface.cpp index c1c78bf0..a4d8dbe5 100644 --- a/source/gloperate/source/stages/interfaces/RenderInterface.cpp +++ b/source/gloperate/source/stages/interfaces/RenderInterface.cpp @@ -25,7 +25,7 @@ RenderInterface::RenderInterface(Stage * stage) : viewport("viewport", stage, glm::vec4(0.0, 0.0, -1.0, -1.0)) { // Hide inputs in property editor - viewport.setOption("hidden", true); + //viewport.setOption("hidden", true); stage->inputAdded.connect( [this] (AbstractSlot * connectedInput) { auto colorRenderTargetInput = dynamic_cast *>(connectedInput); diff --git a/source/plugins/gloperate-ffmpeg-exporter/FFMPEGVideoEncoder.h b/source/plugins/gloperate-ffmpeg-exporter/FFMPEGVideoEncoder.h index 338638bf..5902e562 100644 --- a/source/plugins/gloperate-ffmpeg-exporter/FFMPEGVideoEncoder.h +++ b/source/plugins/gloperate-ffmpeg-exporter/FFMPEGVideoEncoder.h @@ -4,7 +4,7 @@ #include -#include +#include #include From 76a29d547b74318b4e578e31c0da05673a0d6ef3 Mon Sep 17 00:00:00 2001 From: Willy Scheibel Date: Fri, 15 Sep 2017 15:10:19 +0200 Subject: [PATCH 2/5] Adaptions to new cppexpose type system --- source/gloperate-qtquick/source/QmlEngine.cpp | 16 +++++----- .../source/QmlObjectWrapper.cpp | 16 +++++----- .../include/gloperate-text/Alignment.h | 12 ++++---- .../include/gloperate-text/LineAnchor.h | 12 ++++---- .../include/gloperate/pipeline/Slot.h | 2 ++ .../include/gloperate/rendering/Image.h | 30 +++++++++++++++++++ source/gloperate/source/rendering/Image.cpp | 10 +++++++ .../FFMPEGVideoEncoder.cpp | 10 +++---- .../FFMPEGVideoExporter.cpp | 20 ++++++------- 9 files changed, 86 insertions(+), 42 deletions(-) diff --git a/source/gloperate-qtquick/source/QmlEngine.cpp b/source/gloperate-qtquick/source/QmlEngine.cpp index 6b286ec2..8b913dfc 100644 --- a/source/gloperate-qtquick/source/QmlEngine.cpp +++ b/source/gloperate-qtquick/source/QmlEngine.cpp @@ -250,24 +250,24 @@ QJSValue QmlEngine::toScriptValue(const cppexpose::Variant & var) return QJSValue(var.value().path().c_str()); } - else if (var.isBool()) { - return QJSValue(var.toBool()); + else if (var.isBoolean()) { + return QJSValue(var.value()); } - else if (var.isUnsignedIntegral()) { - return QJSValue((unsigned int)var.toULongLong()); + else if (var.isUnsigned()) { + return QJSValue(var.value()); } - else if (var.isSignedIntegral() || var.isIntegral()) { - return QJSValue((int)var.toLongLong()); + else if (var.isIntegral()) { + return QJSValue(var.value()); } else if (var.isFloatingPoint()) { - return QJSValue(var.toDouble()); + return QJSValue(var.value()); } else if (var.isString()) { - return QJSValue(var.toString().c_str()); + return QJSValue(var.value().c_str()); } else if (var.hasType()) { diff --git a/source/gloperate-qtquick/source/QmlObjectWrapper.cpp b/source/gloperate-qtquick/source/QmlObjectWrapper.cpp index d784be9d..e11c9b52 100644 --- a/source/gloperate-qtquick/source/QmlObjectWrapper.cpp +++ b/source/gloperate-qtquick/source/QmlObjectWrapper.cpp @@ -1,6 +1,8 @@ #include +#include + #include #include @@ -94,9 +96,9 @@ QJSValue QmlObjectWrapper::wrapObject() m_registerFunction = m_engine->evaluate(s_registerFunction); // Add properties to object - for (unsigned int i=0; inumSubValues(); i++) + for (const auto & propertyPair : m_object->properties()) { - AbstractProperty * property = m_object->property(i); + AbstractProperty * property = propertyPair.second; if (property->isObject()) { // Add object wrapper @@ -223,15 +225,15 @@ QJSValue QmlObjectWrapper::callFunc(const QString & name, const QJSValue & args) } // Get function arguments as array - cppexpose::VariantArray emptyArgs; cppexpose::Variant value = m_engine->fromScriptValue(args); - cppexpose::VariantArray * argList = value.asArray(); - if (!argList) { - argList = &emptyArgs; + cppexpose::VariantArray functionArgs; + if (value.isArray()) + { + functionArgs = value.value(); } // Call function - return m_engine->toScriptValue(function.call(*argList)); + return m_engine->toScriptValue(function.call(functionArgs)); } diff --git a/source/gloperate-text/include/gloperate-text/Alignment.h b/source/gloperate-text/include/gloperate-text/Alignment.h index 035354ed..f34b80b0 100644 --- a/source/gloperate-text/include/gloperate-text/Alignment.h +++ b/source/gloperate-text/include/gloperate-text/Alignment.h @@ -4,7 +4,7 @@ #include -#include +#include namespace gloperate_text @@ -63,12 +63,12 @@ template<> class EnumValues { public: - static std::map namedValues() + static std::map namedValues() { - return{ - { gloperate_text::Alignment::LeftAligned, "LeftAligned" }, - { gloperate_text::Alignment::Centered, "Centered" }, - { gloperate_text::Alignment::RightAligned, "RightAligned" } + return { + { "LeftAligned", gloperate_text::Alignment::LeftAligned }, + { "Centered", gloperate_text::Alignment::Centered }, + { "RightAligned", gloperate_text::Alignment::RightAligned } }; } }; diff --git a/source/gloperate-text/include/gloperate-text/LineAnchor.h b/source/gloperate-text/include/gloperate-text/LineAnchor.h index 7bcd6bb3..4398512e 100644 --- a/source/gloperate-text/include/gloperate-text/LineAnchor.h +++ b/source/gloperate-text/include/gloperate-text/LineAnchor.h @@ -4,7 +4,7 @@ #include -#include +#include namespace gloperate_text @@ -47,13 +47,13 @@ template<> class EnumValues { public: - static std::map namedValues() + static std::map namedValues() { return { - { gloperate_text::LineAnchor::Ascent, "Ascent" }, - { gloperate_text::LineAnchor::Center, "Centered" }, - { gloperate_text::LineAnchor::Baseline, "Baseline" }, - { gloperate_text::LineAnchor::Descent, "Descent" } + { "Ascent", gloperate_text::LineAnchor::Ascent }, + { "Centered", gloperate_text::LineAnchor::Center }, + { "Baseline", gloperate_text::LineAnchor::Baseline }, + { "Descent", gloperate_text::LineAnchor::Descent } }; } }; diff --git a/source/gloperate/include/gloperate/pipeline/Slot.h b/source/gloperate/include/gloperate/pipeline/Slot.h index 5837fb58..3a535246 100644 --- a/source/gloperate/include/gloperate/pipeline/Slot.h +++ b/source/gloperate/include/gloperate/pipeline/Slot.h @@ -192,6 +192,8 @@ class GLOPERATE_TEMPLATE_API Slot : public AbstractSlot virtual bool fromULongLong(unsigned long long value) override; virtual double toDouble() const override; virtual bool fromDouble(double value) override; + virtual cppexpose::Variant toVariant() const override; + virtual bool fromVariant(const cppexpose::Variant & variant) override; virtual size_t numElements() const override; virtual cppexpose::Variant element(size_t i) const override; virtual void setElement(size_t i, const cppexpose::Variant & value) override; diff --git a/source/gloperate/include/gloperate/rendering/Image.h b/source/gloperate/include/gloperate/rendering/Image.h index 6c0d79cb..ec17ce67 100644 --- a/source/gloperate/include/gloperate/rendering/Image.h +++ b/source/gloperate/include/gloperate/rendering/Image.h @@ -333,6 +333,36 @@ class GLOPERATE_API Image */ friend void swap(Image & first, Image & second) GLOPERATE_NOEXCEPT; + /** + * @brief + * Equality operator + * + * @param[in] other + * The other image for comparison + * + * @return + * 'true' if both images are equal, else 'false' + * + * @remarks + * Two images are considered equal if they are the same object + */ + bool operator==(const Image & other) const; + + /** + * @brief + * Inequality operator + * + * @param[in] other + * The other image for comparison + * + * @return + * 'true' if both image differ, else 'false' + * + * @remarks + * Two images are considered equal if they are the same object + */ + bool operator!=(const Image & other) const; + protected: /** diff --git a/source/gloperate/source/rendering/Image.cpp b/source/gloperate/source/rendering/Image.cpp index 71367092..a2e500eb 100644 --- a/source/gloperate/source/rendering/Image.cpp +++ b/source/gloperate/source/rendering/Image.cpp @@ -241,5 +241,15 @@ void Image::initializeImage(int width, int height, GLenum format, GLenum type) m_type = type; } +bool Image::operator==(const Image & other) const +{ + return this == &other; +} + +bool Image::operator!=(const Image & other) const +{ + return this != &other; +} + } // namespace gloperate diff --git a/source/plugins/gloperate-ffmpeg-exporter/FFMPEGVideoEncoder.cpp b/source/plugins/gloperate-ffmpeg-exporter/FFMPEGVideoEncoder.cpp index fd0699e7..2f6505a1 100644 --- a/source/plugins/gloperate-ffmpeg-exporter/FFMPEGVideoEncoder.cpp +++ b/source/plugins/gloperate-ffmpeg-exporter/FFMPEGVideoEncoder.cpp @@ -52,12 +52,12 @@ bool FFMPEGVideoEncoder::initEncoding(const cppexpose::VariantMap & parameters) auto filepath = parameters.at("filepath").toString(); auto format = parameters.at("format").toString(); auto codec = parameters.at("codec").toString(); - auto width = parameters.at("width").toULongLong(); - auto height = parameters.at("height").toULongLong(); - auto fps = parameters.at("fps").toULongLong(); + auto width = parameters.at("width").value(); + auto height = parameters.at("height").value(); + auto fps = parameters.at("fps").value(); - auto gopsize = parameters.at("gopsize").toLongLong() != 0 ? parameters.at("gopsize").toLongLong() : fps * 2; - auto bitrate = parameters.at("bitrate").toLongLong() != 0 ? parameters.at("bitrate").toLongLong() : 400000; + auto gopsize = parameters.at("gopsize").value() != 0 ? parameters.at("gopsize").value() : fps * 2; + auto bitrate = parameters.at("bitrate").value() != 0 ? parameters.at("bitrate").value() : 400000; if (filepath == "") { diff --git a/source/plugins/gloperate-ffmpeg-exporter/FFMPEGVideoExporter.cpp b/source/plugins/gloperate-ffmpeg-exporter/FFMPEGVideoExporter.cpp index f3f18947..d7ea5d9a 100644 --- a/source/plugins/gloperate-ffmpeg-exporter/FFMPEGVideoExporter.cpp +++ b/source/plugins/gloperate-ffmpeg-exporter/FFMPEGVideoExporter.cpp @@ -86,12 +86,12 @@ void FFMPEGVideoExporter::setTarget(gloperate::Canvas * canvas, const cppexpose: void FFMPEGVideoExporter::createVideo(AbstractVideoExporter::ContextHandling contextHandling, std::function progress) { - auto width = m_parameters.at("width").toULongLong(); - auto height = m_parameters.at("height").toULongLong(); + auto width = m_parameters.at("width").value(); + auto height = m_parameters.at("height").value(); auto viewport = glm::vec4(0, 0, width, height); - auto fps = m_parameters.at("fps").toULongLong(); - auto length = m_parameters.at("duration").toULongLong() * fps; + auto fps = m_parameters.at("fps").value(); + auto length = m_parameters.at("duration").value() * fps; //auto timeDelta = 1.f / static_cast(fps); initialize(contextHandling); @@ -150,8 +150,8 @@ void FFMPEGVideoExporter::onRender(ContextHandling contextHandling, globjects::F initialize(contextHandling); } - auto width = m_parameters.at("width").toULongLong(); - auto height = m_parameters.at("height").toULongLong(); + auto width = m_parameters.at("width").value(); + auto height = m_parameters.at("height").value(); auto viewport = glm::vec4(0, 0, width, height); m_canvas->render(m_fbo.get()); @@ -204,8 +204,8 @@ void FFMPEGVideoExporter::initialize(ContextHandling contextHandling) { m_contextHandling = contextHandling; - auto width = m_parameters.at("width").toULongLong(); - auto height = m_parameters.at("height").toULongLong(); + auto width = m_parameters.at("width").value(); + auto height = m_parameters.at("height").value(); auto viewport = glm::vec4(0, 0, width, height); @@ -296,8 +296,8 @@ void FFMPEGVideoExporter::createAndSetupShader() void FFMPEGVideoExporter::createAndSetupBuffer() { - auto width = m_parameters.at("width").toULongLong(); - auto height = m_parameters.at("height").toULongLong(); + auto width = m_parameters.at("width").value(); + auto height = m_parameters.at("height").value(); m_image = new Image(width, height, gl::GL_RGB, gl::GL_UNSIGNED_BYTE); From 7d82b83241510e4abd2ed254e3370c1b2ccca607 Mon Sep 17 00:00:00 2001 From: Willy Scheibel Date: Fri, 15 Sep 2017 15:45:21 +0200 Subject: [PATCH 3/5] Implement Slot member function overrides --- .../include/gloperate/pipeline/Slot.inl | 278 +++++++++++++++++- 1 file changed, 277 insertions(+), 1 deletion(-) diff --git a/source/gloperate/include/gloperate/pipeline/Slot.inl b/source/gloperate/include/gloperate/pipeline/Slot.inl index 83a7b346..9dfe1f12 100644 --- a/source/gloperate/include/gloperate/pipeline/Slot.inl +++ b/source/gloperate/include/gloperate/pipeline/Slot.inl @@ -85,7 +85,7 @@ bool Slot::connect(Slot * source) // Set source m_source = source; - // Connect to data container; no direct binding of member function to achive virtual lookup + // Connect to data container; no direct binding of member function to achive lookup m_valueConnection = m_source->valueChanged.connect([this] (const T & value) { this->onValueChanged(value); @@ -281,12 +281,288 @@ T * Slot::ptr() return this->m_value.ptr(); } +template +const cppexpose::Type & Slot::type() const +{ + return m_value.type(); +} + +template +cppexpose::Type & Slot::type() +{ + return m_value.type(); +} + +template +const cppexpose::AbstractBaseType * Slot::baseType() const +{ + return m_value.baseType(); +} + +template +cppexpose::AbstractBaseType * Slot::baseType() +{ + return m_value.baseType(); +} + +template +const cppexpose::Type & Slot::elementType() const +{ + return m_value.elementType(); +} + +template +cppexpose::Type & Slot::elementType() +{ + return m_value.elementType(); +} + +template +const std::string & Slot::typeName() const +{ + static cppexpose::BaseType subType; + static const auto name = std::string("slot<") + subType.typeName() + ">"; + + return name; +} + +template +bool Slot::isNull() const +{ + return false; +} + +template +bool Slot::isType() const +{ + return false; +} + +template +bool Slot::isConst() const +{ + return m_source != nullptr; +} + +template +bool Slot::isArray() const +{ + return false; +} + +template +bool Slot::isDynamicArray() const +{ + return false; +} + +template +bool Slot::isMap() const +{ + return false; +} + +template +bool Slot::isBoolean() const +{ + return false; +} + +template +bool Slot::isNumber() const +{ + return false; +} + +template +bool Slot::isIntegral() const +{ + return false; +} + +template +bool Slot::isUnsigned() const +{ + return false; +} + +template +bool Slot::isFloatingPoint() const +{ + return false; +} + +template +bool Slot::isString() const +{ + return false; +} + template std::unique_ptr Slot::createCopy() const { return nullptr; } +template +bool Slot::compareTypeAndValue(const AbstractValueContainer & value) const +{ + // TODO: implement + return false; +} + +template +std::string Slot::toString() const +{ + if (m_source) + { + return m_source->toString(); + } + + return m_value.toString(); +} + +template +bool Slot::fromString(const std::string & value) +{ + // TODO: implement + return false; +} + +template +bool Slot::toBool() const +{ + return false; +} + +template +bool Slot::fromBool(bool value) +{ + return false; +} + +template +long long Slot::toLongLong() const +{ + return 0; +} + +template +bool Slot::fromLongLong(long long value) +{ + return false; +} + +template +unsigned long long Slot::toULongLong() const +{ + return 0; +} + +template +bool Slot::fromULongLong(unsigned long long value) +{ + return false; +} + +template +double Slot::toDouble() const +{ + return 0.0; +} + +template +bool Slot::fromDouble(double value) +{ + return false; +} + +template +cppexpose::Variant Slot::toVariant() const +{ + if (m_source != nullptr) + { + return m_source->toVariant(); + } + + return m_value.toVariant(); +} + +template +bool Slot::fromVariant(const cppexpose::Variant & variant) +{ + return m_value.fromVariant(variant); + + // TODO: remove connection upon explicit value update? +} + +template +size_t Slot::numElements() const +{ + return m_source != nullptr ? m_source->numElements() : m_value.numElements(); +} + +template +cppexpose::Variant Slot::element(size_t i) const +{ + return m_source != nullptr ? m_source->element(i) : m_value.element(i); +} + +template +void Slot::setElement(size_t i, const cppexpose::Variant & value) +{ + if (isConst()) + { + return; + } + + m_value.setElement(i, value); +} + +template +void Slot::pushElement(const cppexpose::Variant & value) +{ + if (isConst()) + { + return; + } + + m_value.pushElement(value); +} + +template +std::vector Slot::keys() const +{ + if (m_source != nullptr) + { + return m_source->keys(); + } + + return m_value.keys(); +} + +template +cppexpose::Variant Slot::element(const std::string & key) const +{ + if (m_source != nullptr) + { + return m_source->element(key); + } + + return m_value.element(key); +} + +template +void Slot::setElement(const std::string & key, const cppexpose::Variant & value) +{ + if (isConst()) + { + return; + } + + m_value.setElement(key, value); +} + template bool Slot::isObject() const { From 0bfeb12fcf4ee06ac017e6b37bbcb662ca95020a Mon Sep 17 00:00:00 2001 From: Willy Scheibel Date: Fri, 15 Sep 2017 17:10:23 +0200 Subject: [PATCH 4/5] Adapt examples to new type system interfaces --- .../demo-stages-plugins/AssimpMeshLoader.cpp | 6 +++--- .../demo-stages-plugins/ColorGradientDemo.cpp | 12 ++++++------ .../examples/demo-stages-plugins/ColorGradientDemo.h | 2 ++ .../demo-stages-plugins/DemoTextRenderingPipeline.h | 2 ++ .../demo-stages-plugins/LightTestPipeline.cpp | 4 ++-- .../examples/demo-stages-plugins/LightTestPipeline.h | 2 ++ .../MultiFrameSceneRenderingStage.h | 3 +++ .../demo-stages-plugins/SSAOSceneRenderingStage.h | 3 +++ .../demo-stages-plugins/ShaderDemoPipeline.h | 2 ++ source/examples/demo-stages-plugins/ShapeDemo.cpp | 10 ++++++---- source/examples/demo-stages-plugins/ShapeDemo.h | 2 ++ 11 files changed, 33 insertions(+), 15 deletions(-) diff --git a/source/examples/demo-stages-plugins/AssimpMeshLoader.cpp b/source/examples/demo-stages-plugins/AssimpMeshLoader.cpp index 9bcca1a8..d6dfacc9 100644 --- a/source/examples/demo-stages-plugins/AssimpMeshLoader.cpp +++ b/source/examples/demo-stages-plugins/AssimpMeshLoader.cpp @@ -108,9 +108,9 @@ Drawable * AssimpMeshLoader::load(const std::string & filename, const cppexpose: bool smoothNormals = false; // Get options - const cppexpose::VariantMap * map = options.asMap(); - if (map) { - if (map->count("smoothNormals") > 0) smoothNormals = map->at("smoothNormals").value(); + if (!options.element("smoothNormals").isNull()) + { + smoothNormals = options.element("smoothNormals").value(); } // Import scene diff --git a/source/examples/demo-stages-plugins/ColorGradientDemo.cpp b/source/examples/demo-stages-plugins/ColorGradientDemo.cpp index 37d8b094..bb094181 100644 --- a/source/examples/demo-stages-plugins/ColorGradientDemo.cpp +++ b/source/examples/demo-stages-plugins/ColorGradientDemo.cpp @@ -45,9 +45,9 @@ ColorGradientDemo::ColorGradientDemo(Environment * environment, const std::strin std::string dataPath = gloperate::dataPath(); // Setup parameters - value.setOption("minimumValue", 0.0f); - value.setOption("maximumValue", 1.0f); - value.setOption("updateOnDrag", true); + //value.setOption("minimumValue", 0.0f); + //value.setOption("maximumValue", 1.0f); + //value.setOption("updateOnDrag", true); value.valueChanged.connect([this] (const float & value) { float v = 0.2 + 0.8 * value; @@ -71,11 +71,11 @@ ColorGradientDemo::ColorGradientDemo(Environment * environment, const std::strin m_colorGradientLoading->filePath << colors; m_colorGradientLoading->gradients.valueChanged.connect([this] (const gloperate::ColorGradientList * gradients) { - gradient.setOption("choices", cppexpose::Variant::fromVector(gradients->names())); - gradient.setOption("pixmaps", cppexpose::Variant::fromVector(gradients->pixmaps({ 80, 20 }))); + //gradient.setOption("choices", cppexpose::Variant::fromVector(gradients->names())); + //gradient.setOption("pixmaps", cppexpose::Variant::fromVector(gradients->pixmaps({ 80, 20 }))); }); // Explicitly set as ComboBox, even if gradients are not yet loaded - gradient.setOption("choices", cppexpose::Variant::array()); + //gradient.setOption("choices", cppexpose::Variant::array()); // Color gradients texture stage addStage(m_colorGradientTexture.get()); diff --git a/source/examples/demo-stages-plugins/ColorGradientDemo.h b/source/examples/demo-stages-plugins/ColorGradientDemo.h index 5b406d27..cd96d1bd 100644 --- a/source/examples/demo-stages-plugins/ColorGradientDemo.h +++ b/source/examples/demo-stages-plugins/ColorGradientDemo.h @@ -2,6 +2,8 @@ #pragma once +#include + #include #include diff --git a/source/examples/demo-stages-plugins/DemoTextRenderingPipeline.h b/source/examples/demo-stages-plugins/DemoTextRenderingPipeline.h index 0a3781bb..bb1d88a7 100644 --- a/source/examples/demo-stages-plugins/DemoTextRenderingPipeline.h +++ b/source/examples/demo-stages-plugins/DemoTextRenderingPipeline.h @@ -2,6 +2,8 @@ #pragma once +#include + #include #include diff --git a/source/examples/demo-stages-plugins/LightTestPipeline.cpp b/source/examples/demo-stages-plugins/LightTestPipeline.cpp index b6edf2f6..a2f9be35 100644 --- a/source/examples/demo-stages-plugins/LightTestPipeline.cpp +++ b/source/examples/demo-stages-plugins/LightTestPipeline.cpp @@ -38,10 +38,10 @@ LightTestPipeline::LightTestPipeline(gloperate::Environment * environment, const , m_depthBufferStage(cppassist::make_unique(environment)) , m_renderStage(cppassist::make_unique(environment)) { - glossiness.setOptions({ + /*glossiness.setOptions({ {"minimum", 0.0f}, {"maximum", 1.0f} - }); + });*/ addStage(m_lightDefStage1.get()); m_lightDefStage1->color << lightColor1; diff --git a/source/examples/demo-stages-plugins/LightTestPipeline.h b/source/examples/demo-stages-plugins/LightTestPipeline.h index 9e5e05c9..4c7aa53a 100644 --- a/source/examples/demo-stages-plugins/LightTestPipeline.h +++ b/source/examples/demo-stages-plugins/LightTestPipeline.h @@ -2,6 +2,8 @@ #pragma once +#include + #include #include diff --git a/source/examples/demo-stages-plugins/MultiFrameSceneRenderingStage.h b/source/examples/demo-stages-plugins/MultiFrameSceneRenderingStage.h index 83c50e7e..efe6e499 100644 --- a/source/examples/demo-stages-plugins/MultiFrameSceneRenderingStage.h +++ b/source/examples/demo-stages-plugins/MultiFrameSceneRenderingStage.h @@ -2,6 +2,9 @@ #pragma once +#include +#include + #include #include diff --git a/source/examples/demo-stages-plugins/SSAOSceneRenderingStage.h b/source/examples/demo-stages-plugins/SSAOSceneRenderingStage.h index 673c8139..514663ad 100644 --- a/source/examples/demo-stages-plugins/SSAOSceneRenderingStage.h +++ b/source/examples/demo-stages-plugins/SSAOSceneRenderingStage.h @@ -2,6 +2,9 @@ #pragma once +#include +#include + #include #include diff --git a/source/examples/demo-stages-plugins/ShaderDemoPipeline.h b/source/examples/demo-stages-plugins/ShaderDemoPipeline.h index 899b981c..92d9e9d3 100644 --- a/source/examples/demo-stages-plugins/ShaderDemoPipeline.h +++ b/source/examples/demo-stages-plugins/ShaderDemoPipeline.h @@ -2,6 +2,8 @@ #pragma once +#include + #include #include diff --git a/source/examples/demo-stages-plugins/ShapeDemo.cpp b/source/examples/demo-stages-plugins/ShapeDemo.cpp index b9e25d8a..31cd6f59 100644 --- a/source/examples/demo-stages-plugins/ShapeDemo.cpp +++ b/source/examples/demo-stages-plugins/ShapeDemo.cpp @@ -1,6 +1,8 @@ #include "ShapeDemo.h" +#include + #include #include @@ -62,9 +64,9 @@ ShapeDemo::ShapeDemo(Environment * environment, const std::string & name) // Setup parameters texture = dataPath + "/gloperate/textures/gloperate-logo.glraw"; - angle.setOption("minimumValue", 0.0f); - angle.setOption("maximumValue", 2.0f * glm::pi()); - angle.setOption("updateOnDrag", true); + //angle.setOption("minimumValue", 0.0f); + //angle.setOption("maximumValue", 2.0f * glm::pi()); + //angle.setOption("updateOnDrag", true); rotate.valueChanged.connect(this, &ShapeDemo::onRotateChanged); m_timer->virtualTime.valueChanged.connect([this](const float & angle) { @@ -75,7 +77,7 @@ ShapeDemo::ShapeDemo(Environment * environment, const std::string & name) // Timer stage addStage(m_timer.get()); m_timer->interval = 2.0f * glm::pi(); - m_timer->interval.setOption("maximumValue", 2.0f * glm::pi()); + //m_timer->interval.setOption("maximumValue", 2.0f * glm::pi()); addStage(m_floatSelection.get()); m_floatSelection->createInput("timerValue") << m_timer->virtualTime; diff --git a/source/examples/demo-stages-plugins/ShapeDemo.h b/source/examples/demo-stages-plugins/ShapeDemo.h index b7d08d71..565e6085 100644 --- a/source/examples/demo-stages-plugins/ShapeDemo.h +++ b/source/examples/demo-stages-plugins/ShapeDemo.h @@ -2,6 +2,8 @@ #pragma once +#include + #include #include From e041bd8a8d3febbaeaa13df645ebbe02a4daaebc Mon Sep 17 00:00:00 2001 From: Willy Scheibel Date: Fri, 15 Sep 2017 17:27:33 +0200 Subject: [PATCH 5/5] Reenable slot initialization on stage --- source/gloperate/include/gloperate/pipeline/Slot.inl | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/source/gloperate/include/gloperate/pipeline/Slot.inl b/source/gloperate/include/gloperate/pipeline/Slot.inl index 9dfe1f12..3e691c26 100644 --- a/source/gloperate/include/gloperate/pipeline/Slot.inl +++ b/source/gloperate/include/gloperate/pipeline/Slot.inl @@ -41,12 +41,11 @@ Slot::Slot(SlotType slotType, const std::string & name, Stage * parent, const , m_valid(true) , m_source(nullptr) { - // TODO: implement // Do not add property to object, yet. Just initialize the property itself //this->initProperty(name, nullptr); // Initialize slot, will also add slot as a property - //this->initSlot(slotType, parent); + this->initSlot(slotType, parent); } template