Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] Type system adaptions #407

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions source/examples/demo-stages-plugins/AssimpMeshLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@

#include <cppassist/logging/logging.h>

#include <cppexpose/variant/Variant.h>
#include <cppexpose/reflection/Variant.h>

#include <glbinding/gl/enum.h>

Expand Down Expand Up @@ -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<bool>();
if (!options.element("smoothNormals").isNull())
{
smoothNormals = options.element("smoothNormals").value<bool>();
}

// Import scene
Expand Down
12 changes: 6 additions & 6 deletions source/examples/demo-stages-plugins/ColorGradientDemo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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());
Expand Down
4 changes: 3 additions & 1 deletion source/examples/demo-stages-plugins/ColorGradientDemo.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
#pragma once


#include <cppassist/fs/FilePath.h>

#include <cppexpose/plugin/plugin_api.h>

#include <gloperate/gloperate-version.h>
#include <gloperate/base/ExtendedProperties.h>
//#include <gloperate/base/ExtendedProperties.h>
#include <gloperate/pipeline/Pipeline.h>
#include <gloperate/pipeline/Input.h>
#include <gloperate/stages/interfaces/CanvasInterface.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#pragma once


#include <glm/vec2.hpp>

#include <cppassist/fs/FilePath.h>

#include <cppexpose/plugin/plugin_api.h>
Expand Down
4 changes: 2 additions & 2 deletions source/examples/demo-stages-plugins/LightTestPipeline.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,10 @@ LightTestPipeline::LightTestPipeline(gloperate::Environment * environment, const
, m_depthBufferStage(cppassist::make_unique<gloperate::TextureRenderTargetStage>(environment))
, m_renderStage(cppassist::make_unique<LightTestStage>(environment))
{
glossiness.setOptions({
/*glossiness.setOptions({
{"minimum", 0.0f},
{"maximum", 1.0f}
});
});*/

addStage(m_lightDefStage1.get());
m_lightDefStage1->color << lightColor1;
Expand Down
2 changes: 2 additions & 0 deletions source/examples/demo-stages-plugins/LightTestPipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
#pragma once


#include <glm/vec3.hpp>

#include <cppexpose/plugin/plugin_api.h>

#include <gloperate/gloperate-version.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#pragma once


#include <glm/mat3x3.hpp>
#include <glm/mat4x4.hpp>

#include <cppexpose/plugin/plugin_api.h>

#include <globjects/Program.h>
Expand Down
3 changes: 3 additions & 0 deletions source/examples/demo-stages-plugins/SSAOSceneRenderingStage.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#pragma once


#include <glm/mat4x4.hpp>
#include <glm/mat3x3.hpp>

#include <cppexpose/plugin/plugin_api.h>

#include <globjects/VertexArray.h>
Expand Down
4 changes: 3 additions & 1 deletion source/examples/demo-stages-plugins/ShaderDemoPipeline.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
#pragma once


#include <cppassist/fs/FilePath.h>

#include <cppexpose/plugin/plugin_api.h>

#include <gloperate/gloperate-version.h>
#include <gloperate/base/ExtendedProperties.h>
//#include <gloperate/base/ExtendedProperties.h>
#include <gloperate/pipeline/Pipeline.h>
#include <gloperate/pipeline/Input.h>
#include <gloperate/stages/interfaces/CanvasInterface.h>
Expand Down
10 changes: 6 additions & 4 deletions source/examples/demo-stages-plugins/ShapeDemo.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@

#include "ShapeDemo.h"

#include <glm/gtc/constants.hpp>

#include <glbinding/gl/enum.h>

#include <gloperate/gloperate.h>
Expand Down Expand Up @@ -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<float>());
angle.setOption("updateOnDrag", true);
//angle.setOption("minimumValue", 0.0f);
//angle.setOption("maximumValue", 2.0f * glm::pi<float>());
//angle.setOption("updateOnDrag", true);

rotate.valueChanged.connect(this, &ShapeDemo::onRotateChanged);
m_timer->virtualTime.valueChanged.connect([this](const float & angle) {
Expand All @@ -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<float>();
m_timer->interval.setOption("maximumValue", 2.0f * glm::pi<float>());
//m_timer->interval.setOption("maximumValue", 2.0f * glm::pi<float>());

addStage(m_floatSelection.get());
m_floatSelection->createInput("timerValue") << m_timer->virtualTime;
Expand Down
4 changes: 3 additions & 1 deletion source/examples/demo-stages-plugins/ShapeDemo.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
#pragma once


#include <cppassist/fs/FilePath.h>

#include <cppexpose/plugin/plugin_api.h>

#include <gloperate/gloperate-version.h>
#include <gloperate/base/ExtendedProperties.h>
//#include <gloperate/base/ExtendedProperties.h>
#include <gloperate/rendering/Shape.h>
#include <gloperate/pipeline/Pipeline.h>
#include <gloperate/pipeline/Input.h>
Expand Down
2 changes: 1 addition & 1 deletion source/gloperate-qt/source/loaders/QtTextureLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <QImage>
#include <QImageReader>

#include <cppexpose/variant/Variant.h>
#include <cppexpose/reflection/Variant.h>

#include <glbinding/gl/gl.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
#include <QString>

#include <cppexpose/signal/Connection.h>
#include <cppexpose/variant/Variant.h>
#include <cppexpose/reflection/Variant.h>

#include <qmltoolbox/QmlApplicationEngine.h>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include <QJSValue>

#include <cppexpose/variant/Variant.h>
#include <cppexpose/reflection/Variant.h>
#include <cppexpose/function/AbstractFunction.h>

#include <gloperate-qtquick/gloperate-qtquick_api.h>
Expand Down
18 changes: 9 additions & 9 deletions source/gloperate-qtquick/source/QmlEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#include <gloperate-qtquick/QmlEngine.h>

#include <cstring>
#include <cassert>

#include <QVariant>
#include <QQmlContext>
Expand All @@ -10,7 +11,6 @@
#include <QImage>

#include <cppexpose/reflection/Property.h>
#include <cppexpose/typed/DirectValue.h>
#include <cppexpose/function/Function.h>

#include <cppassist/fs/FilePath.h>
Expand Down Expand Up @@ -250,24 +250,24 @@ QJSValue QmlEngine::toScriptValue(const cppexpose::Variant & var)
return QJSValue(var.value<cppassist::FilePath>().path().c_str());
}

else if (var.isBool()) {
return QJSValue(var.toBool());
else if (var.isBoolean()) {
return QJSValue(var.value<bool>());
}

else if (var.isUnsignedIntegral()) {
return QJSValue((unsigned int)var.toULongLong());
else if (var.isUnsigned()) {
return QJSValue(var.value<unsigned int>());
}

else if (var.isSignedIntegral() || var.isIntegral()) {
return QJSValue((int)var.toLongLong());
else if (var.isIntegral()) {
return QJSValue(var.value<int>());
}

else if (var.isFloatingPoint()) {
return QJSValue(var.toDouble());
return QJSValue(var.value<double>());
}

else if (var.isString()) {
return QJSValue(var.toString().c_str());
return QJSValue(var.value<std::string>().c_str());
}

else if (var.hasType<gloperate::Image>()) {
Expand Down
18 changes: 10 additions & 8 deletions source/gloperate-qtquick/source/QmlObjectWrapper.cpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@

#include <gloperate-qtquick/QmlObjectWrapper.h>

#include <cassert>

#include <QJSValueIterator>

#include <cppexpose/reflection/Object.h>
#include <cppexpose/reflection/Method.h>
#include <cppexpose/variant/Variant.h>
#include <cppexpose/reflection/Variant.h>

#include <gloperate-qtquick/QmlEngine.h>

Expand Down Expand Up @@ -94,9 +96,9 @@ QJSValue QmlObjectWrapper::wrapObject()
m_registerFunction = m_engine->evaluate(s_registerFunction);

// Add properties to object
for (unsigned int i=0; i<m_object->numSubValues(); i++)
for (const auto & propertyPair : m_object->properties())
{
AbstractProperty * property = m_object->property(i);
AbstractProperty * property = propertyPair.second;

if (property->isObject()) {
// Add object wrapper
Expand Down Expand Up @@ -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<VariantArray>();
}

// Call function
return m_engine->toScriptValue(function.call(*argList));
return m_engine->toScriptValue(function.call(functionArgs));
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<globjects::Texture *>())
{
texture = static_cast< Slot<globjects::Texture *> * >(slot)->value();
}
Expand Down
15 changes: 8 additions & 7 deletions source/gloperate-text/include/gloperate-text/Alignment.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include <functional>

#include <cppexpose/typed/TypedEnum.h>
#include <cppexpose/type/EnumValues.h>


namespace gloperate_text
Expand Down Expand Up @@ -60,14 +60,15 @@ namespace cppexpose
* Template specialization of enum strings for Alignment.
*/
template<>
struct EnumDefaultStrings<gloperate_text::Alignment>
class EnumValues<gloperate_text::Alignment>
{
std::map<gloperate_text::Alignment, std::string> operator()()
public:
static std::map<std::string, gloperate_text::Alignment> 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 }
};
}
};
Expand Down
2 changes: 1 addition & 1 deletion source/gloperate-text/include/gloperate-text/FontLoader.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include <iosfwd>

#include <cppexpose/plugin/plugin_api.h>
#include <cppexpose/variant/Variant.h>
#include <cppexpose/reflection/Variant.h>

#include <gloperate/base/Loader.h>
#include <gloperate/gloperate-version.h>
Expand Down
15 changes: 8 additions & 7 deletions source/gloperate-text/include/gloperate-text/LineAnchor.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include <functional>

#include <cppexpose/typed/TypedEnum.h>
#include <cppexpose/type/EnumValues.h>


namespace gloperate_text
Expand Down Expand Up @@ -44,15 +44,16 @@ namespace cppexpose


template<>
struct EnumDefaultStrings<gloperate_text::LineAnchor>
class EnumValues<gloperate_text::LineAnchor>
{
std::map<gloperate_text::LineAnchor, std::string> operator()()
public:
static std::map<std::string, gloperate_text::LineAnchor> 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 }
};
}
};
Expand Down
2 changes: 1 addition & 1 deletion source/gloperate/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion source/gloperate/include/gloperate/base/Canvas.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <glm/fwd.hpp>

#include <cppexpose/reflection/Object.h>
#include <cppexpose/variant/Variant.h>
#include <cppexpose/reflection/Variant.h>
#include <cppexpose/signal/Signal.h>
#include <cppexpose/signal/ScopedConnection.h>

Expand Down
Loading