Simplify Property code (#1575)

* Remove the PropertyDelegate

* Remove some unused and redundant property types

* Use helper functions for Lua/Json conversion

* Solve a bug in SelectionProperty that occurred when re-setting options

* General simplification and refactoring of the code
This commit is contained in:
Emma Broman
2021-05-04 09:32:29 +02:00
committed by GitHub
parent d47ac2f248
commit 804444e267
135 changed files with 1560 additions and 6710 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ asset.require('./static_server')
local guiCustomization = asset.require('customization/gui')
-- Select which commit hashes to use for the frontend and backend
local frontendHash = "391f8d3ed74e598a0e8a1b16016324d8f747e18d"
local frontendHash = "17b69f29a4a596d488ba8c9de953cc22fb0dce5c"
local dataProvider = "data.openspaceproject.com/files/webgui"
local frontend = asset.syncedResource({
@@ -94,24 +94,6 @@ private:
const std::vector<HandlebarTemplate> _handlebarTemplates;
};
/**
* This function takes a \p text and escapes all necessary characters () that JSON
* does not want in its strings.
* \param text The text that is to be escaped
* \return The same text will all required characteres escaped
*/
std::string escapedJson(const std::string& text);
/**
* This function takes a \p list of text and escapes all necessary characters () that JSON
* does not want in its strings.
* \param text The list text that is to be escaped
* \return The same text will all required characteres escaped
*/
std::string escapedJson(const std::vector<std::string>& list);
} // namespace openspace
#endif // __OPENSPACE_CORE___DOCUMENTATIONGENERATOR___H__
@@ -31,35 +31,21 @@ namespace openspace::properties {
class DoubleListProperty : public ListProperty<double> {
public:
DoubleListProperty(Property::PropertyInfo info);
DoubleListProperty(Property::PropertyInfo info, std::vector<double> values);
DoubleListProperty(Property::PropertyInfo info,
std::vector<double> values = std::vector<double>());
std::string className() const override;
int typeLua() const override;
using TemplateProperty<std::vector<double>>::operator std::vector<double>;
using TemplateProperty<std::vector<double>>::operator=;
protected:
std::vector<double> fromLuaConversion(lua_State* state, bool& success) const override;
void toLuaConversion(lua_State* state) const override;
std::string toStringConversion() const override;
};
template <>
std::string PropertyDelegate<TemplateProperty<std::vector<double>>>::className();
template <>
template <>
std::vector<double>
PropertyDelegate<TemplateProperty<std::vector<double>>>::fromLuaValue(
lua_State* state, bool& success);
template <>
template <>
bool PropertyDelegate<TemplateProperty<std::vector<double>>>::toLuaValue(
lua_State* state, const std::vector<double>& value);
template <>
int PropertyDelegate<TemplateProperty<std::vector<double>>>::typeLua();
template <>
template <>
bool PropertyDelegate<TemplateProperty<std::vector<double>>>::toString(
std::string& outValue, const std::vector<double>& inValue);
} // namespace openspace::properties
#endif // __OPENSPACE_CORE___DOUBLELISTPROPERTY___H__
@@ -31,34 +31,21 @@ namespace openspace::properties {
class IntListProperty : public ListProperty<int> {
public:
IntListProperty(Property::PropertyInfo info);
IntListProperty(Property::PropertyInfo info, std::vector<int> values);
IntListProperty(Property::PropertyInfo info,
std::vector<int> values = std::vector<int>());
std::string className() const override;
int typeLua() const override;
using TemplateProperty<std::vector<int>>::operator std::vector<int>;
using TemplateProperty<std::vector<int>>::operator=;
protected:
std::vector<int> fromLuaConversion(lua_State* state, bool& success) const override;
void toLuaConversion(lua_State* state) const override;
std::string toStringConversion() const override;
};
template <>
std::string PropertyDelegate<TemplateProperty<std::vector<int>>>::className();
template <>
template <>
std::vector<int> PropertyDelegate<TemplateProperty<std::vector<int>>>::fromLuaValue(
lua_State* state, bool& success);
template <>
template <>
bool PropertyDelegate<TemplateProperty<std::vector<int>>>::toLuaValue(
lua_State* state, const std::vector<int>& value);
template <>
int PropertyDelegate<TemplateProperty<std::vector<int>>>::typeLua();
template <>
template <>
bool PropertyDelegate<TemplateProperty<std::vector<int>>>::toString(
std::string& outValue, const std::vector<int>& inValue);
} // namespace openspace::properties
#endif // __OPENSPACE_CORE___INTLISTPROPERTY___H__
@@ -32,35 +32,22 @@ namespace openspace::properties {
class StringListProperty : public ListProperty<std::string> {
public:
StringListProperty(Property::PropertyInfo info);
StringListProperty(Property::PropertyInfo info, std::vector<std::string> values);
StringListProperty(Property::PropertyInfo info,
std::vector<std::string> values = std::vector<std::string>());
std::string className() const override;
int typeLua() const override;
using TemplateProperty<std::vector<std::string>>::operator std::vector<std::string>;
using TemplateProperty<std::vector<std::string>>::operator=;
protected:
std::vector<std::string> fromLuaConversion(lua_State* state,
bool& success) const override;
void toLuaConversion(lua_State* state) const override;
std::string toStringConversion() const override;
};
template <>
std::string PropertyDelegate<TemplateProperty<std::vector<std::string>>>::className();
template <>
template <>
std::vector<std::string>
PropertyDelegate<TemplateProperty<std::vector<std::string>>>::fromLuaValue(
lua_State* state, bool& success);
template <>
template <>
bool PropertyDelegate<TemplateProperty<std::vector<std::string>>>::toLuaValue(
lua_State* state, const std::vector<std::string>& value);
template <>
int PropertyDelegate<TemplateProperty<std::vector<std::string>>>::typeLua();
template <>
template <>
bool PropertyDelegate<TemplateProperty<std::vector<std::string>>>::toString(
std::string& outValue, const std::vector<std::string>& inValue);
} // namespace openspace::properties
#endif // __OPENSPACE_CORE___STRINGLISTPROPERTY___H__
@@ -33,7 +33,6 @@ namespace openspace::properties {
template <typename T>
class ListProperty : public TemplateProperty<std::vector<T>> {
public:
ListProperty(Property::PropertyInfo info);
ListProperty(Property::PropertyInfo info, std::vector<T> values);
virtual ~ListProperty() = 0;
@@ -24,11 +24,6 @@
namespace openspace::properties {
template <typename T>
ListProperty<T>::ListProperty(Property::PropertyInfo info)
: TemplateProperty<std::vector<T>>(std::move(info))
{}
template <typename T>
ListProperty<T>::ListProperty(Property::PropertyInfo info, std::vector<T> values)
: TemplateProperty<std::vector<T>>(std::move(info), std::move(values))
@@ -28,10 +28,27 @@
#include <openspace/properties/numericalproperty.h>
#include <ghoul/glm.h>
#include <limits>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(DMat2Property, glm::dmat2x2)
class DMat2Property : public NumericalProperty<glm::dmat2x2> {
public:
DMat2Property(Property::PropertyInfo info, glm::dmat2x2 value = glm::dmat2x2(0.0),
glm::dmat2x2 minValue =
ghoul::createFillMat2x2<double>(std::numeric_limits<double>::lowest()),
glm::dmat2x2 maxValue =
ghoul::createFillMat2x2<double>(std::numeric_limits<double>::max()),
glm::dmat2x2 stepValue = ghoul::createFillMat2x2<double>(0.01));
std::string className() const override;
int typeLua() const override;
using TemplateProperty<glm::dmat2x2>::operator=;
protected:
glm::dmat2x2 fromLuaConversion(lua_State* state, bool& success) const override;
};
} // namespace openspace::properties
@@ -1,38 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___DMAT2X3PROPERTY___H__
#define __OPENSPACE_CORE___DMAT2X3PROPERTY___H__
#include <openspace/properties/numericalproperty.h>
#include <ghoul/glm.h>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(DMat2x3Property, glm::dmat2x3)
} // namespace openspace::properties
#endif // __OPENSPACE_CORE___DMAT2X3PROPERTY___H__
@@ -1,38 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___DMAT2X4PROPERTY___H__
#define __OPENSPACE_CORE___DMAT2X4PROPERTY___H__
#include <openspace/properties/numericalproperty.h>
#include <ghoul/glm.h>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(DMat2x4Property, glm::dmat2x4)
} // namespace openspace::properties
#endif // __OPENSPACE_CORE___DMAT2X4PROPERTY___H__
@@ -28,10 +28,27 @@
#include <openspace/properties/numericalproperty.h>
#include <ghoul/glm.h>
#include <limits>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(DMat3Property, glm::dmat3x3)
class DMat3Property : public NumericalProperty<glm::dmat3x3> {
public:
DMat3Property(Property::PropertyInfo info, glm::dmat3x3 value = glm::dmat3x3(0.0),
glm::dmat3x3 minValue =
ghoul::createFillMat3x3<double>(std::numeric_limits<double>::lowest()),
glm::dmat3x3 maxValue =
ghoul::createFillMat3x3<double>(std::numeric_limits<double>::max()),
glm::dmat3x3 stepValue = ghoul::createFillMat3x3<double>(0.01));
std::string className() const override;
int typeLua() const override;
using TemplateProperty<glm::dmat3x3>::operator=;
protected:
glm::dmat3x3 fromLuaConversion(lua_State* state, bool& success) const override;
};
} // namespace openspace::properties
@@ -1,38 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___DMAT3X2PROPERTY___H__
#define __OPENSPACE_CORE___DMAT3X2PROPERTY___H__
#include <openspace/properties/numericalproperty.h>
#include <ghoul/glm.h>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(DMat3x2Property, glm::dmat3x2)
} // namespace openspace::properties
#endif // __OPENSPACE_CORE___DMAT3X2PROPERTY___H__
@@ -1,38 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___DMAT3X4PROPERTY___H__
#define __OPENSPACE_CORE___DMAT3X4PROPERTY___H__
#include <openspace/properties/numericalproperty.h>
#include <ghoul/glm.h>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(DMat3x4Property, glm::dmat3x4)
} // namespace openspace::properties
#endif // __OPENSPACE_CORE___DMAT3X4PROPERTY___H__
@@ -28,10 +28,27 @@
#include <openspace/properties/numericalproperty.h>
#include <ghoul/glm.h>
#include <limits>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(DMat4Property, glm::dmat4x4)
class DMat4Property : public NumericalProperty<glm::dmat4x4> {
public:
DMat4Property(Property::PropertyInfo info, glm::dmat4x4 value = glm::dmat4x4(0.0),
glm::dmat4x4 minValue =
ghoul::createFillMat4x4<double>(std::numeric_limits<double>::lowest()),
glm::dmat4x4 maxValue =
ghoul::createFillMat4x4<double>(std::numeric_limits<double>::max()),
glm::dmat4x4 stepValue = ghoul::createFillMat4x4<double>(0.01));
std::string className() const override;
int typeLua() const override;
using TemplateProperty<glm::dmat4x4>::operator=;
protected:
glm::dmat4x4 fromLuaConversion(lua_State* state, bool& success) const override;
};
} // namespace openspace::properties
@@ -1,38 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___DMAT4X2PROPERTY___H__
#define __OPENSPACE_CORE___DMAT4X2PROPERTY___H__
#include <openspace/properties/numericalproperty.h>
#include <ghoul/glm.h>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(DMat4x2Property, glm::dmat4x2)
} // namespace openspace::properties
#endif // __OPENSPACE_CORE___DMAT4X2PROPERTY___H__
@@ -1,38 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___DMAT4X3PROPERTY___H__
#define __OPENSPACE_CORE___DMAT4X3PROPERTY___H__
#include <openspace/properties/numericalproperty.h>
#include <ghoul/glm.h>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(DMat4x3Property, glm::dmat4x3)
} // namespace openspace::properties
#endif // __OPENSPACE_CORE___DMAT4X3PROPERTY___H__
@@ -28,10 +28,27 @@
#include <openspace/properties/numericalproperty.h>
#include <ghoul/glm.h>
#include <limits>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(Mat2Property, glm::mat2x2)
class Mat2Property : public NumericalProperty<glm::mat2x2> {
public:
Mat2Property(Property::PropertyInfo info, glm::mat2x2 value = glm::mat2x2(0.f),
glm::mat2x2 minValue =
ghoul::createFillMat2x2<float>(std::numeric_limits<float>::lowest()),
glm::mat2x2 maxValue =
ghoul::createFillMat2x2<float>(std::numeric_limits<float>::max()),
glm::mat2x2 stepValue = ghoul::createFillMat2x2<float>(0.01f));
std::string className() const override;
int typeLua() const override;
using TemplateProperty<glm::mat2x2>::operator=;
protected:
glm::mat2x2 fromLuaConversion(lua_State* state, bool& success) const override;
};
} // namespace openspace::properties
@@ -1,38 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___MAT2X3PROPERTY___H__
#define __OPENSPACE_CORE___MAT2X3PROPERTY___H__
#include <openspace/properties/numericalproperty.h>
#include <ghoul/glm.h>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(Mat2x3Property, glm::mat2x3)
} // namespace openspace::properties
#endif // __OPENSPACE_CORE___MAT2X3PROPERTY___H__
@@ -1,38 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___MAT2X4PROPERTY___H__
#define __OPENSPACE_CORE___MAT2X4PROPERTY___H__
#include <openspace/properties/numericalproperty.h>
#include <ghoul/glm.h>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(Mat2x4Property, glm::mat2x4)
} // namespace openspace::properties
#endif // __OPENSPACE_CORE___MAT2X4PROPERTY___H__
@@ -28,10 +28,27 @@
#include <openspace/properties/numericalproperty.h>
#include <ghoul/glm.h>
#include <limits>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(Mat3Property, glm::mat3x3)
class Mat3Property : public NumericalProperty<glm::mat3x3> {
public:
Mat3Property(Property::PropertyInfo info, glm::mat3x3 value = glm::mat3x3(),
glm::mat3x3 minValue =
ghoul::createFillMat3x3<float>(std::numeric_limits<float>::lowest()),
glm::mat3x3 maxValue =
ghoul::createFillMat3x3<float>(std::numeric_limits<float>::max()),
glm::mat3x3 stepValue = ghoul::createFillMat3x3<float>(0.01f));
std::string className() const override;
int typeLua() const override;
using TemplateProperty<glm::mat3x3>::operator=;
protected:
glm::mat3x3 fromLuaConversion(lua_State* state, bool& success) const override;
};
} // namespace openspace::properties
@@ -1,38 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___MAT3X2PROPERTY___H__
#define __OPENSPACE_CORE___MAT3X2PROPERTY___H__
#include <openspace/properties/numericalproperty.h>
#include <ghoul/glm.h>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(Mat3x2Property, glm::mat3x2)
} // namespace openspace::properties
#endif // __OPENSPACE_CORE___MAT3X2PROPERTY___H__
@@ -1,38 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___MAT3X4PROPERTY___H__
#define __OPENSPACE_CORE___MAT3X4PROPERTY___H__
#include <openspace/properties/numericalproperty.h>
#include <ghoul/glm.h>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(Mat3x4Property, glm::mat3x4)
} // namespace openspace::properties
#endif // __OPENSPACE_CORE___MAT3X4PROPERTY___H__
@@ -28,10 +28,27 @@
#include <openspace/properties/numericalproperty.h>
#include <ghoul/glm.h>
#include <limits>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(Mat4Property, glm::mat4x4)
class Mat4Property : public NumericalProperty<glm::mat4x4> {
public:
Mat4Property(Property::PropertyInfo info, glm::mat4x4 value = glm::mat4x4(),
glm::mat4x4 minValue =
ghoul::createFillMat4x4<float>(std::numeric_limits<float>::lowest()),
glm::mat4x4 maxValue =
ghoul::createFillMat4x4<float>(std::numeric_limits<float>::max()),
glm::mat4x4 stepValue = ghoul::createFillMat4x4<float>(0.01f));
std::string className() const override;
int typeLua() const override;
using TemplateProperty<glm::mat4x4>::operator=;
protected:
glm::mat4x4 fromLuaConversion(lua_State* state, bool& success) const override;
};
} // namespace openspace::properties
@@ -1,38 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___MAT4X2PROPERTY___H__
#define __OPENSPACE_CORE___MAT4X2PROPERTY___H__
#include <openspace/properties/numericalproperty.h>
#include <ghoul/glm.h>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(Mat4x2Property, glm::mat4x2)
} // namespace openspace::properties
#endif // __OPENSPACE_CORE___MAT4X2PROPERTY___H__
@@ -1,38 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___MAT4X3PROPERTY___H__
#define __OPENSPACE_CORE___MAT4X3PROPERTY___H__
#include <openspace/properties/numericalproperty.h>
#include <ghoul/glm.h>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(Mat4x3Property, glm::mat4x3)
} // namespace openspace::properties
#endif // __OPENSPACE_CORE___MAT4X3PROPERTY___H__
@@ -32,20 +32,11 @@ namespace openspace::properties {
template <typename T>
class NumericalProperty : public TemplateProperty<T> {
public:
NumericalProperty(Property::PropertyInfo info);
NumericalProperty(Property::PropertyInfo info, T value);
NumericalProperty(Property::PropertyInfo info, T value, T minimumValue,
T maximumValue);
NumericalProperty(Property::PropertyInfo info, T value, T minimumValue,
T maximumValue, T steppingValue);
NumericalProperty(Property::PropertyInfo info, T value, T minimumValue,
T maximumValue, T steppingValue, float exponent);
T maximumValue, T steppingValue, float exponent = 1.f);
bool getLuaValue(lua_State* state) const override;
bool setLuaValue(lua_State* state) override;
int typeLua() const override;
bool getStringValue(std::string& value) const override;
virtual std::string className() const override = 0;
virtual int typeLua() const override = 0;
T minValue() const;
void setMinValue(T value);
@@ -59,8 +50,6 @@ public:
float exponent() const;
void setExponent(float exponent);
virtual std::string className() const override;
std::string jsonValue() const override;
using TemplateProperty<T>::operator=;
@@ -71,13 +60,16 @@ public:
void interpolateValue(float t,
ghoul::EasingFunc<float> easingFunc = nullptr) override;
protected:
static const std::string MinimumValueKey;
static const std::string MaximumValueKey;
static const std::string SteppingValueKey;
static const std::string ExponentValueKey;
virtual T fromLuaConversion(lua_State* state, bool& success) const override = 0;
virtual void toLuaConversion(lua_State* state) const override;
virtual std::string toStringConversion() const override;
std::string generateAdditionalJsonDescription() const override;
/**
@@ -22,175 +22,12 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <openspace/util/json_helper.h>
#include <ghoul/lua/ghoul_lua.h>
#include <glm/ext/matrix_common.hpp>
namespace openspace::properties {
#define REGISTER_NUMERICALPROPERTY_HEADER(CLASS_NAME, TYPE) \
using CLASS_NAME = NumericalProperty<TYPE>; \
\
template <> \
std::string PropertyDelegate<NumericalProperty<TYPE>>::className(); \
\
template <> \
std::string PropertyDelegate<TemplateProperty<TYPE>>::className(); \
\
template <> \
template <> \
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultValue<TYPE>(); \
\
template <> \
template <> \
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultMinimumValue<TYPE>(); \
\
template <> \
template <> \
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultMaximumValue<TYPE>(); \
\
template <> \
template <> \
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultSteppingValue<TYPE>(); \
\
template <> \
template <> \
TYPE PropertyDelegate<TemplateProperty<TYPE>>::fromLuaValue(lua_State* state, \
bool& success); \
template <> \
template <> \
TYPE PropertyDelegate<NumericalProperty<TYPE>>::fromLuaValue(lua_State* state, \
bool& success); \
template <> \
template <> \
bool PropertyDelegate<TemplateProperty<TYPE>>::toLuaValue(lua_State* state, \
const TYPE& value); \
template <> \
template <> \
bool PropertyDelegate<NumericalProperty<TYPE>>::toLuaValue(lua_State* state, \
const TYPE& value); \
template <> \
int PropertyDelegate<TemplateProperty<TYPE>>::typeLua(); \
template <> \
int PropertyDelegate<NumericalProperty<TYPE>>::typeLua(); \
\
template <> \
template <> \
bool PropertyDelegate<TemplateProperty<TYPE>>::toString(std::string& outValue, \
const TYPE& inValue); \
\
template <> \
template <> \
bool PropertyDelegate<NumericalProperty<TYPE>>::toString(std::string& outValue, \
const TYPE& inValue);
#define REGISTER_NUMERICALPROPERTY_SOURCE(CLASS_NAME, TYPE, DEFAULT_VALUE, \
DEFAULT_MIN_VALUE, DEFAULT_MAX_VALUE, \
DEFAULT_STEPPING, FROM_LUA_LAMBDA_EXPRESSION, \
TO_LUA_LAMBDA_EXPRESSION, \
TO_STRING_LAMBDA_EXPRESSION, LUA_TYPE) \
template <> \
std::string PropertyDelegate<TemplateProperty<TYPE>>::className() \
{ \
return #CLASS_NAME; \
} \
\
template <> \
std::string PropertyDelegate<NumericalProperty<TYPE>>::className() \
{ \
return PropertyDelegate<TemplateProperty<TYPE>>::className(); \
} \
\
template <> \
template <> \
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultValue<TYPE>() \
{ \
return DEFAULT_VALUE; \
} \
\
template <> \
template <> \
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultMinimumValue<TYPE>() \
{ \
return DEFAULT_MIN_VALUE; \
} \
\
template <> \
template <> \
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultMaximumValue<TYPE>() \
{ \
return DEFAULT_MAX_VALUE; \
} \
\
template <> \
template <> \
TYPE PropertyDelegate<NumericalProperty<TYPE>>::defaultSteppingValue<TYPE>() \
{ \
return DEFAULT_STEPPING; \
} \
\
template <> \
template <> \
TYPE PropertyDelegate<TemplateProperty<TYPE>>::fromLuaValue<TYPE>(lua_State* state, \
bool& success) \
{ \
return FROM_LUA_LAMBDA_EXPRESSION(state, success); \
} \
\
template <> \
template <> \
TYPE PropertyDelegate<NumericalProperty<TYPE>>::fromLuaValue<TYPE>(lua_State* state, \
bool& success) \
{ \
return PropertyDelegate<TemplateProperty<TYPE>>::fromLuaValue<TYPE>( \
state, success); \
} \
\
template <> \
template <> \
bool PropertyDelegate<TemplateProperty<TYPE>>::toLuaValue<TYPE>(lua_State* state, \
const TYPE& value) \
{ \
return TO_LUA_LAMBDA_EXPRESSION(state, value); \
} \
\
template <> \
template <> \
bool PropertyDelegate<NumericalProperty<TYPE>>::toLuaValue<TYPE>(lua_State* state, \
const TYPE& value) \
{ \
return PropertyDelegate<TemplateProperty<TYPE>>::toLuaValue<TYPE>(state, value); \
} \
\
template <> \
int PropertyDelegate<TemplateProperty<TYPE>>::typeLua() \
{ \
return LUA_TYPE; \
} \
\
template <> \
int PropertyDelegate<NumericalProperty<TYPE>>::typeLua() \
{ \
return PropertyDelegate<TemplateProperty<TYPE>>::typeLua(); \
} \
\
template <> \
template <> \
bool PropertyDelegate<TemplateProperty<TYPE>>::toString(std::string& outValue, \
const TYPE& inValue) \
{ \
return TO_STRING_LAMBDA_EXPRESSION(outValue, inValue); \
} \
\
template <> \
template <> \
bool PropertyDelegate<NumericalProperty<TYPE>>::toString(std::string& outValue, \
const TYPE& inValue) \
{ \
return PropertyDelegate<TemplateProperty<TYPE>>::toString(outValue, inValue); \
}
template <typename T>
const std::string NumericalProperty<T>::MinimumValueKey = "MinimumValue";
@@ -203,60 +40,6 @@ const std::string NumericalProperty<T>::SteppingValueKey = "SteppingValue";
template <typename T>
const std::string NumericalProperty<T>::ExponentValueKey = "Exponent";
// Delegating constructors are necessary; automatic template deduction cannot
// deduce template argument for 'U' if 'default' methods are used as default values in
// a single constructor
template <typename T>
NumericalProperty<T>::NumericalProperty(Property::PropertyInfo info)
: NumericalProperty<T>(
std::move(info),
PropertyDelegate<NumericalProperty<T>>::template defaultValue<T>(),
PropertyDelegate<NumericalProperty<T>>::template defaultMinimumValue<T>(),
PropertyDelegate<NumericalProperty<T>>::template defaultMaximumValue<T>(),
PropertyDelegate<NumericalProperty<T>>::template defaultSteppingValue<T>(),
1.f
)
{}
template <typename T>
NumericalProperty<T>::NumericalProperty(Property::PropertyInfo info, T value)
: NumericalProperty<T>(
std::move(info),
std::move(value),
PropertyDelegate<NumericalProperty<T>>::template defaultMinimumValue<T>(),
PropertyDelegate<NumericalProperty<T>>::template defaultMaximumValue<T>(),
PropertyDelegate<NumericalProperty<T>>::template defaultSteppingValue<T>(),
1.f
)
{}
template <typename T>
NumericalProperty<T>::NumericalProperty(Property::PropertyInfo info, T value,
T minimumValue, T maximumValue)
: NumericalProperty<T>(
std::move(info),
std::move(value),
std::move(minimumValue),
std::move(maximumValue),
PropertyDelegate<NumericalProperty<T>>::template defaultSteppingValue<T>(),
1.f
)
{}
template <typename T>
NumericalProperty<T>::NumericalProperty(Property::PropertyInfo info, T value,
T minimumValue, T maximumValue, T steppingValue)
: NumericalProperty<T>(
std::move(info),
std::move(value),
std::move(minimumValue),
std::move(maximumValue),
std::move(steppingValue),
1.f
)
{}
template <typename T>
NumericalProperty<T>::NumericalProperty(Property::PropertyInfo info, T value,
T minimumValue, T maximumValue, T steppingValue,
@@ -268,44 +51,6 @@ NumericalProperty<T>::NumericalProperty(Property::PropertyInfo info, T value,
, _exponent(exponent)
{}
template <typename T>
std::string NumericalProperty<T>::className() const {
return PropertyDelegate<NumericalProperty<T>>::className();
}
template <typename T>
bool NumericalProperty<T>::setLuaValue(lua_State* state) {
bool success = false;
T value = PropertyDelegate<NumericalProperty<T>>::template fromLuaValue<T>(
state, success
);
if (success) {
TemplateProperty<T>::setValue(std::move(value));
}
return success;
}
template <typename T>
bool NumericalProperty<T>::getLuaValue(lua_State* state) const {
bool success = PropertyDelegate<NumericalProperty<T>>::template toLuaValue<T>(
state, TemplateProperty<T>::_value
);
return success;
}
template <typename T>
int NumericalProperty<T>::typeLua() const {
return PropertyDelegate<NumericalProperty<T>>::typeLua();
}
template <typename T>
bool NumericalProperty<T>::getStringValue(std::string& value) const {
bool success = PropertyDelegate<NumericalProperty<T>>::template toString<T>(
value, TemplateProperty<T>::_value
);
return success;
}
template <typename T>
T NumericalProperty<T>::minValue() const {
return _minimumValue;
@@ -374,8 +119,7 @@ std::string NumericalProperty<T>::luaToJson(std::string luaValue) const {
template <typename T>
std::string NumericalProperty<T>::jsonValue() const {
std::string value;
getStringValue(value);
std::string value = toStringConversion();
return luaToJson(value);
}
@@ -390,13 +134,10 @@ void NumericalProperty<T>::setInterpolationTarget(std::any value) {
template <typename T>
void NumericalProperty<T>::setLuaInterpolationTarget(lua_State* state) {
bool success = false;
T thisValue = PropertyDelegate<NumericalProperty<T>>::template fromLuaValue<T>(
state,
success
);
T targetValue = fromLuaConversion(state, success);
if (success) {
_interpolationStart = TemplateProperty<T>::_value;
_interpolationEnd = std::move(thisValue);
_interpolationEnd = std::move(targetValue);
}
}
@@ -412,4 +153,14 @@ void NumericalProperty<T>::interpolateValue(float t,
));
}
template <typename T>
void NumericalProperty<T>::toLuaConversion(lua_State* state) const {
ghoul::lua::push(state, TemplateProperty<T>::_value);
}
template <typename T>
std::string NumericalProperty<T>::toStringConversion() const {
return formatJson(TemplateProperty<T>::_value);
}
} // namespace openspace::properties
@@ -1,161 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___PROPERTYDELEGATE___H__
#define __OPENSPACE_CORE___PROPERTYDELEGATE___H__
#include <string>
struct lua_State;
namespace openspace::properties {
/**
* The PropertyDelegate class is used by (among others) the TemplateProperty and the
* NumericalProperty classes to outsource the definitions of class names, default values,
* etc. Using the PropertyDelegate, it is possible to create new TemplateProperty types
* without subclassing the TemplateProperty, but rather creating a specialized instance
* of PropertyDelegate. See
* (https://github.com/OpenSpace/OpenSpace/wiki/Concepts-Properties) for more detailed
* information.
* \see TemplateProperty
* \see NumericalProperty
* \tparam T The full class for which this specialized instance of PropertyDelegate is
* responsible. For example <code>T = TemplateProperty<std::string></code>.
*/
template <typename T>
class PropertyDelegate {
public:
/**
* This method returns the class name for the class <code>T</code>. The default
* implementation will lead to a compile-time error if the class method is not
* specialized.
* \return The class name for the class <code>T</code>
*/
static std::string className();
/**
* This method will return the preferred default value for the class <code>T</code>.
* The default implementation will lead to a compile-time error if the class method is
* not specialized.
* \return The default value that the class <code>T</code> should use
* \tparam U The type by which the class T is specialized. If
* <code>T = TemplateProperty<std::string></code>, then <code>U = std::string</code>
*/
template <typename U>
static U defaultValue();
/**
* This method will return the preferred default minimum value for the class
* <code>T</code>. The default implementation will lead to a compile-time error if the
* class method is not specialized. This method is not used in TemplateProperty, but
* only NumericalProperty, so the TemplateProperty does not require this method to be
* specialized.
* \return The default minimum value that the class <code>T</code> should use
* \tparam U The type by which the class T is specialized. If
* <code>T = NumericalProperty<int></code>, then <code>U = int</code>
*/
template <typename U>
static U defaultMinimumValue();
/**
* This method will return the preferred default maximum value for the class
* <code>T</code>. The default implementation will lead to a compile-time error if the
* class method is not specialized. This method is not used in TemplateProperty, but
* only NumericalProperty, so the TemplateProperty does not require this method to be
* specialized.
* \return The default maximum value that the class <code>T</code> should use
* \tparam U The type by which the class T is specialized. If
* <code>T = NumericalProperty<int></code>, then <code>U = int</code>
*/
template <typename U>
static U defaultMaximumValue();
/**
* The method returns the default stepping value for the class <code>T</code> used in
* GUI elements. The default implementation will lead to a compile-time error if the
* class method is not specialized. This method is not used in TemplateProperty, but
* only NumericalProperty, so the TemplateProperty does not require this method to be
* specialized.
* \return The default stepping that the class <code>T</code> should use
* \tparam U The type by which the class T is specialized. If
* <code>T = NumericalProperty<int></code>, then <code>U = int</code>
*/
template <typename U>
static U defaultSteppingValue();
/**
* This method converts the top value from the Lua stack into a value of type
* <code>U</code> and reports the <code>success</code> back to the caller. The default
* implementation will lead to a compile-time error if the class method is not
* specialized.
* \param state The Lua state from which the value is retrieved
* \param success Will be <code>true</code> if the conversion succeeded;
* <code>false</code> otherwise
* \return The value that was created by converting the top value from the stack
* \tparam U The type by which the class T is specialized. If
* <code>T = TemplateProperty<std::string></code>, then <code>U = std::string</code>
*/
template <typename U>
static U fromLuaValue(lua_State* state, bool& success);
/**
* This method converts the passed <code>value</code>, encodes it and places it on the
* top value of the Lua stack and returns the success back to the caller. The default
* implementation will lead to a compile-time error if the class method is not
* specialized.
* \param state The Lua state from which the value is retrieved
* \param value The value that will be converted into a Lua object
* \return <code>true</code> if the conversion succeeded; <code>false</code> otherwise
* \tparam U The type by which the class T is specialized. If
* <code>T = TemplateProperty<std::string></code>, then <code>U = std::string</code>
*/
template <typename U>
static bool toLuaValue(lua_State* state, const U& value);
/**
* Returns the Lua type that will be put onto the stack in the
* PropertyDelegate::toLuaValue method and which will be consumed by the
* PropertyDelegate::fromLuaValue method. The returned value can belong to the set of
* Lua types: <code>LUA_TNONE</code>, <code>LUA_TNIL</code>,
* <code>LUA_TBOOLEAN</code>, <code>LUA_TLIGHTUSERDATA</code>,
* <code>LUA_TNUMBER</code>, <code>LUA_TSTRING</code>, <code>LUA_TTABLE</code>,
* <code>LUA_TFUNCTION</code>, <code>LUA_TUSERDATA</code>, or
* <code>LUA_TTHREAD</code>. The default implementation will return
* <code>LUA_TNONE</code>. The default implementation will lead to a compile-time
* error if the class method is not specialized.
* \return The Lua type that will be consumed or produced by the
* PropertyDelegate::toLuaValue and PropertyDelegate::fromLuaValue methods.
*/
static int typeLua();
template <typename U>
static bool toString(std::string& outValue, const U& inValue);
};
} // namespace openspace::properties
#include <openspace/properties/propertydelegate.inl>
#endif // __OPENSPACE_CORE___PROPERTYDELEGATE___H__
@@ -44,7 +44,20 @@
namespace openspace::properties {
REGISTER_TEMPLATEPROPERTY_HEADER(BoolProperty, bool)
class BoolProperty : public TemplateProperty<bool> {
public:
BoolProperty(Property::PropertyInfo info, bool value = false);
std::string className() const override;
int typeLua() const override;
using TemplateProperty<bool>::operator=;
protected:
bool fromLuaConversion(lua_State* state, bool& success) const override;
void toLuaConversion(lua_State* state) const override;
std::string toStringConversion() const override;
};
} // namespace openspace::properties
@@ -1,51 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___CHARPROPERTY___H__
#define __OPENSPACE_CORE___CHARPROPERTY___H__
/**
* \file charproperty.h
*
* \addtogroup openspace
* @{
* \addtogroup properties
* @{
* \class CharProperty
* This class is a concrete implementation of openspace::properties::TemplateProperty with
* the type <code>char</code>.
* @} @}
*/
#include <openspace/properties/numericalproperty.h>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(CharProperty, char)
} // namespace openspace::properties
#endif // __OPENSPACE_CORE___CHARPROPERTY___H__
@@ -41,10 +41,24 @@
*/
#include <openspace/properties/numericalproperty.h>
#include <limits>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(DoubleProperty, double)
class DoubleProperty : public NumericalProperty<double> {
public:
DoubleProperty(Property::PropertyInfo info, double value = 0.0,
double minValue = std::numeric_limits<double>::lowest(),
double maxValue = std::numeric_limits<double>::max(), double stepValue = 0.01);
std::string className() const override;
int typeLua() const override;
using TemplateProperty<double>::operator=;
protected:
double fromLuaConversion(lua_State* state, bool& success) const override;
};
} // namespace openspace::properties
@@ -41,10 +41,24 @@
*/
#include <openspace/properties/numericalproperty.h>
#include <limits>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(FloatProperty, float)
class FloatProperty : public NumericalProperty<float> {
public:
FloatProperty(Property::PropertyInfo info, float value = 0.f,
float minValue = std::numeric_limits<float>::lowest(),
float maxValue = std::numeric_limits<float>::max(), float stepValue = 0.01f);
std::string className() const override;
int typeLua() const override;
using TemplateProperty<float>::operator=;
protected:
float fromLuaConversion(lua_State* state, bool& success) const override;
};
} // namespace openspace::properties
@@ -41,10 +41,24 @@
*/
#include <openspace/properties/numericalproperty.h>
#include <limits>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(IntProperty, int)
class IntProperty : public NumericalProperty<int> {
public:
IntProperty(Property::PropertyInfo info, int value = 0,
int minValue = std::numeric_limits<int>::lowest(),
int maxValue = std::numeric_limits<int>::max(), int stepValue = 1);
std::string className() const override;
int typeLua() const override;
using TemplateProperty<int>::operator=;
protected:
int fromLuaConversion(lua_State* state, bool& success) const override;
};
} // namespace openspace::properties
@@ -1,51 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___LONGDOUBLEPROPERTY___H__
#define __OPENSPACE_CORE___LONGDOUBLEPROPERTY___H__
/**
* \file longdoubleproperty.h
*
* \addtogroup openspace
* @{
* \addtogroup properties
* @{
* \class LongDoubleProperty
* This class is a concrete implementation of openspace::properties::TemplateProperty with
* the type <code>long double</code>.
* @} @}
*/
#include <openspace/properties/numericalproperty.h>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(LongDoubleProperty, long double)
} // namespace openspace::properties
#endif // __OPENSPACE_CORE___LONGDOUBLEPROPERTY___H__
@@ -1,51 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___LONGLONGPROPERTY___H__
#define __OPENSPACE_CORE___LONGLONGPROPERTY___H__
/**
* \file longlongproperty.h
*
* \addtogroup openspace
* @{
* \addtogroup properties
* @{
* \class LongLongProperty
* This class is a concrete implementation of openspace::properties::TemplateProperty with
* the type <code>long long</code>.
* @} @}
*/
#include <openspace/properties/numericalproperty.h>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(LongLongProperty, long long)
} // namespace openspace::properties
#endif // __OPENSPACE_CORE___LONGLONGPROPERTY___H__
@@ -41,10 +41,25 @@
*/
#include <openspace/properties/numericalproperty.h>
#include <limits>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(LongProperty, long)
class LongProperty : public NumericalProperty<long> {
public:
LongProperty(Property::PropertyInfo info, long value = long(0),
long minValue = std::numeric_limits<long>::lowest(),
long maxValue = std::numeric_limits<long>::max(),
long stepValue = long(1));
std::string className() const override;
int typeLua() const override;
using TemplateProperty<long>::operator=;
protected:
long fromLuaConversion(lua_State* state, bool& success) const override;
};
} // namespace openspace::properties
@@ -41,10 +41,25 @@
*/
#include <openspace/properties/numericalproperty.h>
#include <limits>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(ShortProperty, short)
class ShortProperty : public NumericalProperty<short> {
public:
ShortProperty(Property::PropertyInfo info, short value = short(0),
short minValue = std::numeric_limits<short>::lowest(),
short maxValue = std::numeric_limits<short>::max(),
short stepValue = short(1));
std::string className() const override;
int typeLua() const override;
using TemplateProperty<short>::operator=;
protected:
short fromLuaConversion(lua_State* state, bool& success) const override;
};
} // namespace openspace::properties
@@ -1,51 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___SIGNEDCHARPROPERTY___H__
#define __OPENSPACE_CORE___SIGNEDCHARPROPERTY___H__
/**
* \file signedcharproperty.h
*
* \addtogroup openspace
* @{
* \addtogroup properties
* @{
* \class SignedCharProperty
* This class is a concrete implementation of openspace::properties::TemplateProperty with
* the type <code>signed char</code>.
* @} @}
*/
#include <openspace/properties/numericalproperty.h>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(SignedCharProperty, signed char)
} // namespace openspace::properties
#endif // __OPENSPACE_CORE___SIGNEDCHARPROPERTY___H__
@@ -1,51 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___UCHARPROPERTY___H__
#define __OPENSPACE_CORE___UCHARPROPERTY___H__
/**
* \file ucharproperty.h
*
* \addtogroup openspace
* @{
* \addtogroup properties
* @{
* \class UCharProperty
* This class is a concrete implementation of openspace::properties::TemplateProperty with
* the type <code>unsigned char</code>.
* @} @}
*/
#include <openspace/properties/numericalproperty.h>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(UCharProperty, unsigned char)
} // namespace openspace::properties
#endif // __OPENSPACE_CORE___UCHARPROPERTY___H__
@@ -41,10 +41,25 @@
*/
#include <openspace/properties/numericalproperty.h>
#include <limits>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(UIntProperty, unsigned int)
class UIntProperty : public NumericalProperty<unsigned int> {
public:
UIntProperty(Property::PropertyInfo info, unsigned int value = 0,
unsigned int minValue = std::numeric_limits<unsigned int>::lowest(),
unsigned int maxValue = std::numeric_limits<unsigned int>::max(),
unsigned int stepValue = 1);
std::string className() const override;
int typeLua() const override;
using TemplateProperty<unsigned int>::operator=;
protected:
unsigned int fromLuaConversion(lua_State* state, bool& success) const override;
};
} // namespace openspace::properties
@@ -1,51 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___ULONGLONGPROPERTY___H__
#define __OPENSPACE_CORE___ULONGLONGPROPERTY___H__
/**
* \file ulonglongproperty.h
*
* \addtogroup openspace
* @{
* \addtogroup properties
* @{
* \class ULongLongProperty
* This class is a concrete implementation of openspace::properties::TemplateProperty with
* the type <code>unsigned long long</code>.
* @} @}
*/
#include <openspace/properties/numericalproperty.h>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(ULongLongProperty, unsigned long long)
} // namespace openspace::properties
#endif // __OPENSPACE_CORE___ULONGLONGPROPERTY___H__
@@ -41,10 +41,25 @@
*/
#include <openspace/properties/numericalproperty.h>
#include <limits>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(ULongProperty, unsigned long)
class ULongProperty : public NumericalProperty<unsigned long> {
public:
ULongProperty(Property::PropertyInfo info, unsigned long value = 0ul,
unsigned long minValue = std::numeric_limits<unsigned long>::lowest(),
unsigned long maxValue = std::numeric_limits<unsigned long>::max(),
unsigned long stepValue = 1ul);
std::string className() const override;
int typeLua() const override;
using TemplateProperty<unsigned long>::operator=;
protected:
unsigned long fromLuaConversion(lua_State* state, bool& success) const override;
};
} // namespace openspace::properties
@@ -41,10 +41,25 @@
*/
#include <openspace/properties/numericalproperty.h>
#include <limits>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(UShortProperty, unsigned short)
class UShortProperty : public NumericalProperty<unsigned short> {
public:
UShortProperty(Property::PropertyInfo info, unsigned short value = 0,
unsigned short minValue = std::numeric_limits<unsigned short>::lowest(),
unsigned short maxValue = std::numeric_limits<unsigned short>::max(),
unsigned short stepValue = 1);
std::string className() const override;
int typeLua() const override;
using TemplateProperty<unsigned short>::operator=;
protected:
unsigned short fromLuaConversion(lua_State* state, bool& success) const override;
};
} // namespace openspace::properties
@@ -1,51 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___WCHARPROPERTY___H__
#define __OPENSPACE_CORE___WCHARPROPERTY___H__
/**
* \file wcharproperty.h
*
* \addtogroup openspace
* @{
* \addtogroup properties
* @{
* \class WCharProperty
* This class is a concrete implementation of openspace::properties::TemplateProperty with
* the type <code>wchar_t</code>.
* @} @}
*/
#include <openspace/properties/numericalproperty.h>
namespace openspace::properties {
//REGISTER_NUMERICALPROPERTY_HEADER(WCharProperty, wchar_t)
} // namespace openspace::properties
#endif // __OPENSPACE_CORE___WCHARPROPERTY___H__
@@ -37,6 +37,9 @@ class SelectionProperty : public TemplateProperty<std::set<std::string>> {
public:
SelectionProperty(Property::PropertyInfo info);
std::string className() const override;
int typeLua() const override;
/**
* This method sets the stored value to the provided value <code>val</code>.
* If the value is different, the listeners are notified. It also removes any
@@ -110,6 +113,13 @@ public:
using TemplateProperty<std::set<std::string>>::operator=;
protected:
std::set<std::string> fromLuaConversion(lua_State* state, bool& success) const override;
void toLuaConversion(lua_State* state) const override;
std::string toStringConversion() const override;
private:
void sortOptions();
bool removeInvalidKeys(std::set<std::string>& keys);
@@ -120,28 +130,6 @@ private:
std::vector<std::string> _options;
};
template <>
std::string PropertyDelegate<TemplateProperty<std::set<std::string>>>::className();
template <>
template <>
std::set<std::string>
PropertyDelegate<TemplateProperty<std::set<std::string>>>::fromLuaValue(lua_State* state,
bool& success);
template <>
template <>
bool PropertyDelegate<TemplateProperty<std::set<std::string>>>::toLuaValue(
lua_State* state, const std::set<std::string>& value);
template <>
int PropertyDelegate<TemplateProperty<std::set<std::string>>>::typeLua();
template <>
template <>
bool PropertyDelegate<TemplateProperty<std::set<std::string>>>::toString(
std::string& outValue, const std::set<std::string>& inValue);
} // namespace openspace::properties
#endif // __OPENSPACE_CORE___SELECTIONPROPERTY___H__
+14 -1
View File
@@ -29,7 +29,20 @@
namespace openspace::properties {
REGISTER_TEMPLATEPROPERTY_HEADER(StringProperty, std::string)
class StringProperty : public TemplateProperty<std::string> {
public:
StringProperty(Property::PropertyInfo info, std::string value = "");
std::string className() const override;
int typeLua() const override;
using TemplateProperty<std::string>::operator=;
protected:
std::string fromLuaConversion(lua_State* state, bool& success) const override;
void toLuaConversion(lua_State* state) const override;
std::string toStringConversion() const override;
};
} // namespace openspace::properties
+46 -34
View File
@@ -27,12 +27,10 @@
#include <openspace/properties/property.h>
#include <openspace/properties/propertydelegate.h>
namespace openspace::properties {
/**
* This concrete subclass of Property handles a single parameter value that is of type
* This subclass of Property handles a single parameter value that is of type
* <code>T</code>. It provides all the necessary methods to automatically access the
* value. One notable instantiation of this class is StringProperty, using
* <code>T = std::string</code> while NumericalProperty is a templated subclass dealing
@@ -40,16 +38,14 @@ namespace openspace::properties {
* The accessor operator and assignment operators are overloaded, so that the
* TemplateProperty can be used just in the same way as a regular member variable. In the
* case that these cannot not be used inline, the Property::get method will work.
* The default value for the stored value of this TemplateProperty is retrieved via a call
* to the PropertyDelegate::defaultValue method, providing the template parameter
* <code>T</code> as argument. When a new TemplateProperty is required, that method needs
* to be specialized for the new type or a compile-time error will occur
* (See https://github.com/OpenSpace/OpenSpace/wiki/Concepts-Properties).
*
* Each instantiation of this class should provide a constructor that deals with the
* default value for that specific type <code>T</code>, so that a property can be
* created from just a Property::PropertyInfo object.
*
* \tparam T The type of value that is stored in this TemplateProperty
* \see Property
* \see NumericalProperty
* \see PropertyDelegate
*/
template <typename T>
class TemplateProperty : public Property {
@@ -67,19 +63,15 @@ public:
* \pre \p info.identifier must not be empty
* \pre \p info.guiName must not be empty
*/
TemplateProperty(Property::PropertyInfo info,
T value = PropertyDelegate<TemplateProperty<T>>::template defaultValue<T>());
TemplateProperty(Property::PropertyInfo info, T value);
/**
* Returns the class name for this TemplateProperty. The default implementation makes
* a call to the PropertyDelegate::className method with the template parameter
* <code>T</code> as argument. For this to work, that method needs to be specialized
* to return the correct class name for the new template parameter T, or a
* compile-time error will occur.
* Returns the class name for this TemplateProperty. This method has to be
* specialized for each new type.
*
* \return The class name for the TemplateProperty
*/
virtual std::string className() const override;
virtual std::string className() const override = 0;
/**
* Returns the stored value packed into a ghoul::any object.
@@ -108,41 +100,34 @@ public:
/**
* This method encodes the stored value into a Lua object and pushes that object onto
* the stack. The encoding is performed by calling PropertyDelegate::toLuaValue with
* the template parameter <code>T</code> as an argument. This method has to be
* specialized for each new type, or a compile-time error will occur.
* the stack.
*
* \param state The Lua state onto which the encoded object will be pushed
* \return \c true if the encoding succeeded; \c false otherwise
*/
bool getLuaValue(lua_State* state) const override;
virtual bool getLuaValue(lua_State* state) const override;
/**
* Sets the value of this TemplateProperty by decoding the object at the top of the Lua
* stack and, if successful, assigning it using the Property::set method. The decoding
* is performed by calling the PropertyDelegate::fromLuaValue with the template
* parameter <code>T</code> as argument. If the decoding is successful, the new value
* is set, otherwise it remains unchanged.
* Sets the value of this TemplateProperty by decoding the object at the top of the
* stack and, if successful, assigning it using the Property::set method. If the
* decoding is successful, the new value is set, otherwise it remains unchanged.
*
* \param state The Lua state from which the value will be decoded
* \return \c true if the decoding succeeded; \c false otherwise
*/
bool setLuaValue(lua_State* state) override;
virtual bool setLuaValue(lua_State* state) override;
/// \see Property::typeLua
int typeLua() const override;
virtual int typeLua() const override = 0;
/**
* This method encodes the stored value into a std::string object. The encoding is
* performed by calling PropertyDelegate::toStringValue with the template parameter
* <code>T</code> as an argument. This method has to be specialized for each new
* type, or a compile-time error will occur. The resulting encoding must also be a
* valid JSON representation fo the property.
* This method encodes the stored value into a std::string object. The resulting
* encoding must also be a valid JSON representation fo the property.
*
* \param value The string object in which to store the resulting encoding
* \return \c true if the encoding succeeded; \c false otherwise
*/
bool getStringValue(std::string& value) const override;
virtual bool getStringValue(std::string& value) const override;
/**
* Returns the description for this TemplateProperty as a Lua script that returns a
@@ -199,6 +184,33 @@ public:
T value() const;
protected:
/**
* Decodes the object at the top of the stack to a value of the type <code>T</code>
* and returns it. This method has to be specialized for each new type.
*
* \param state The Lua state from which the value will be decoded
* \param success Set to true \c true if the decoding succeeded; \c false otherwise
* \return the decoded value
*/
virtual T fromLuaConversion(lua_State* state, bool& success) const = 0;
/**
* Encodes the stored value into a Lua object and pushes that object onto
* the stack. This method has to be specialized for each new type.
*
* \param state The Lua state onto which the encoded object will be pushed
*/
virtual void toLuaConversion(lua_State* state) const = 0;
/**
* Encodes the stored value into a std::string object, in a format that is a valid
* JSON representation of the property. This method has to be specialized for each
* new type.
*
* \return The resulting encoding
*/
virtual std::string toStringConversion() const = 0;
/// The value that this TemplateProperty currently stores
T _value;
};
@@ -24,118 +24,12 @@
namespace openspace::properties {
// The following macros can be used to quickly generate the necessary PropertyDelegate
// specializations required by the TemplateProperty class. Use the
// REGISTER_TEMPLATEPROPERTY_HEADER macro in the header file and the
// REGISTER_TEMPLATEPROPERTY_SOURCE macro in the source file of your new
// specialization of a TemplateProperty
// CLASS_NAME = The string that the Property::className() should return as well as the
// C++ class name for which a typedef will be created
// TYPE = The template parameter T for which the TemplateProperty is specialized
#define REGISTER_TEMPLATEPROPERTY_HEADER(CLASS_NAME, TYPE) \
using CLASS_NAME = TemplateProperty<TYPE>; \
\
template <> \
std::string PropertyDelegate<TemplateProperty<TYPE>>::className(); \
\
template <> \
template <> \
TYPE PropertyDelegate<TemplateProperty<TYPE>>::defaultValue<TYPE>(); \
\
template <> \
template <> \
TYPE PropertyDelegate<TemplateProperty<TYPE>>::fromLuaValue(lua_State* state, \
bool& success); \
\
template <> \
template <> \
bool PropertyDelegate<TemplateProperty<TYPE>>::toLuaValue(lua_State* state, \
const TYPE& value); \
\
template <> \
int PropertyDelegate<TemplateProperty<TYPE>>::typeLua(); \
\
template <> \
template <> \
bool PropertyDelegate<TemplateProperty<TYPE>>::toString(std::string& outValue, \
const TYPE& inValue);
// CLASS_NAME = The string that the Property::className() should return as well as the
// C++ class name for which a typedef will be created
// TYPE = The template parameter T for which the TemplateProperty is specialized
// DEFAULT_VALUE = The value (as type T) which should be used as a default value
// FROM_LUA_LAMBDA_EXPRESSION = A lambda expression receiving a lua_State* as the first
// parameter, a bool& as the second parameter and returning
// a value T. It is used by the fromLua method of
// TemplateProperty. The lambda expression must extract the
// stored value from the lua_State, return the value and
// report success in the second argument
// TO_LUA_LAMBDA_EXPRESSION = A lambda expression receiving a lua_State*, a value T and
// returning a bool. The lambda expression must encode the
// value T onto the lua_State stack and return the success
// LUA_TYPE = The Lua type that will be produced/consumed by the previous
// Lambda expressions
#define REGISTER_TEMPLATEPROPERTY_SOURCE(CLASS_NAME, TYPE, DEFAULT_VALUE, \
FROM_LUA_LAMBDA_EXPRESSION, \
TO_LUA_LAMBDA_EXPRESSION, \
TO_STRING_LAMBDA_EXPRESSION, LUA_TYPE) \
template <> \
std::string PropertyDelegate<TemplateProperty<TYPE>>::className() \
{ \
return #CLASS_NAME; \
} \
\
template <> \
template <> \
TYPE PropertyDelegate<TemplateProperty<TYPE>>::defaultValue<TYPE>() \
{ \
return DEFAULT_VALUE; \
} \
\
template <> \
template <> \
TYPE PropertyDelegate<TemplateProperty<TYPE>>::fromLuaValue<TYPE>(lua_State* state, \
bool& success) \
{ \
return FROM_LUA_LAMBDA_EXPRESSION(state, success); \
} \
\
template <> \
template <> \
bool PropertyDelegate<TemplateProperty<TYPE>>::toLuaValue<TYPE>(lua_State* state, \
const TYPE& value) \
{ \
return TO_LUA_LAMBDA_EXPRESSION(state, value); \
} \
\
template <> \
int PropertyDelegate<TemplateProperty<TYPE>>::typeLua() { \
return LUA_TYPE; \
} \
\
template <> \
template <> \
bool PropertyDelegate<TemplateProperty<TYPE>>::toString(std::string& outValue, \
const TYPE& inValue) \
{ \
return TO_STRING_LAMBDA_EXPRESSION(outValue, inValue); \
} \
template <typename T>
TemplateProperty<T>::TemplateProperty(Property::PropertyInfo info, T value)
: Property(std::move(info))
, _value(std::move(value))
{}
template <typename T>
std::string TemplateProperty<T>::className() const {
return PropertyDelegate<TemplateProperty<T>>::className();
}
template <typename T>
TemplateProperty<T>::operator T() {
return _value;
@@ -190,20 +84,14 @@ const std::type_info& TemplateProperty<T>::type() const {
template <typename T>
bool TemplateProperty<T>::getLuaValue(lua_State* state) const {
bool success = PropertyDelegate<TemplateProperty<T>>::template toLuaValue<T>(
state,
_value
);
return success;
toLuaConversion(state);
return true;
}
template <typename T>
bool TemplateProperty<T>::setLuaValue(lua_State* state) {
bool success = false;
T thisValue = PropertyDelegate<TemplateProperty<T>>::template fromLuaValue<T>(
state,
success
);
T thisValue = fromLuaConversion(state, success);
if (success) {
set(std::any(thisValue));
}
@@ -211,17 +99,9 @@ bool TemplateProperty<T>::setLuaValue(lua_State* state) {
}
template <typename T>
int TemplateProperty<T>::typeLua() const {
return PropertyDelegate<TemplateProperty<T>>::typeLua();
}
template <typename T>
bool TemplateProperty<T>::getStringValue(std::string& value) const {
bool success = PropertyDelegate<TemplateProperty<T>>::template toString<T>(
value,
_value
);
return success;
bool TemplateProperty<T>::getStringValue(std::string& outValue) const {
outValue = toStringConversion();
return true;
}
} // namespace openspace::properties
@@ -1,38 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___BVEC2PROPERTY___H__
#define __OPENSPACE_CORE___BVEC2PROPERTY___H__
#include <openspace/properties/numericalproperty.h>
#include <ghoul/glm.h>
namespace openspace::properties {
REGISTER_TEMPLATEPROPERTY_HEADER(BVec2Property, glm::bvec2)
} // namespace openspace::properties
#endif // __OPENSPACE_CORE___BVEC2PROPERTY___H__
@@ -1,38 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___BVEC3PROPERTY___H__
#define __OPENSPACE_CORE___BVEC3PROPERTY___H__
#include <openspace/properties/numericalproperty.h>
#include <ghoul/glm.h>
namespace openspace::properties {
REGISTER_TEMPLATEPROPERTY_HEADER(BVec3Property, glm::bvec3)
} // namespace openspace::properties
#endif // __OPENSPACE_CORE___BVEC3PROPERTY___H__
@@ -1,38 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___BVEC4PROPERTY___H__
#define __OPENSPACE_CORE___BVEC4PROPERTY___H__
#include <openspace/properties/numericalproperty.h>
#include <ghoul/glm.h>
namespace openspace::properties {
REGISTER_TEMPLATEPROPERTY_HEADER(BVec4Property, glm::bvec4)
} // namespace openspace::properties
#endif // __OPENSPACE_CORE___BVEC4PROPERTY___H__
@@ -28,10 +28,25 @@
#include <openspace/properties/numericalproperty.h>
#include <ghoul/glm.h>
#include <limits>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(DVec2Property, glm::dvec2)
class DVec2Property : public NumericalProperty<glm::dvec2> {
public:
DVec2Property(Property::PropertyInfo info, glm::dvec2 value = glm::dvec2(0.0),
glm::dvec2 minValue = glm::dvec2(std::numeric_limits<double>::lowest()),
glm::dvec2 maxValue = glm::dvec2(std::numeric_limits<double>::max()),
glm::dvec2 stepValue = glm::dvec2(0.01));
std::string className() const override;
int typeLua() const override;
using TemplateProperty<glm::dvec2>::operator=;
protected:
glm::dvec2 fromLuaConversion(lua_State* state, bool& success) const override;
};
} // namespace openspace::properties
@@ -28,10 +28,25 @@
#include <openspace/properties/numericalproperty.h>
#include <ghoul/glm.h>
#include <limits>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(DVec3Property, glm::dvec3)
class DVec3Property : public NumericalProperty<glm::dvec3> {
public:
DVec3Property(Property::PropertyInfo info, glm::dvec3 value = glm::dvec3(0.0),
glm::dvec3 minValue = glm::dvec3(std::numeric_limits<double>::lowest()),
glm::dvec3 maxValue = glm::dvec3(std::numeric_limits<double>::max()),
glm::dvec3 stepValue = glm::dvec3(0.01));
std::string className() const override;
int typeLua() const override;
using TemplateProperty<glm::dvec3>::operator=;
protected:
glm::dvec3 fromLuaConversion(lua_State* state, bool& success) const override;
};
} // namespace openspace::properties
@@ -28,10 +28,25 @@
#include <openspace/properties/numericalproperty.h>
#include <ghoul/glm.h>
#include <limits>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(DVec4Property, glm::dvec4)
class DVec4Property : public NumericalProperty<glm::dvec4> {
public:
DVec4Property(Property::PropertyInfo info, glm::dvec4 value = glm::dvec4(0.0),
glm::dvec4 minValue = glm::dvec4(std::numeric_limits<double>::lowest()),
glm::dvec4 maxValue = glm::dvec4(std::numeric_limits<double>::max()),
glm::dvec4 stepValue = glm::dvec4(0.01));
std::string className() const override;
int typeLua() const override;
using TemplateProperty<glm::dvec4>::operator=;
protected:
glm::dvec4 fromLuaConversion(lua_State* state, bool& success) const override;
};
} // namespace openspace::properties
@@ -28,10 +28,25 @@
#include <openspace/properties/numericalproperty.h>
#include <ghoul/glm.h>
#include <limits>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(IVec2Property, glm::ivec2)
class IVec2Property : public NumericalProperty<glm::ivec2> {
public:
IVec2Property(Property::PropertyInfo info, glm::ivec2 value = glm::ivec2(0),
glm::ivec2 minValue = glm::ivec2(std::numeric_limits<int>::lowest()),
glm::ivec2 maxValue = glm::ivec2(std::numeric_limits<int>::max()),
glm::ivec2 stepValue = glm::ivec2(1));
std::string className() const override;
int typeLua() const override;
using TemplateProperty<glm::ivec2>::operator=;
protected:
glm::ivec2 fromLuaConversion(lua_State* state, bool& success) const override;
};
} // namespace openspace::properties
@@ -28,10 +28,25 @@
#include <openspace/properties/numericalproperty.h>
#include <ghoul/glm.h>
#include <limits>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(IVec3Property, glm::ivec3)
class IVec3Property : public NumericalProperty<glm::ivec3> {
public:
IVec3Property(Property::PropertyInfo info, glm::ivec3 value = glm::ivec3(0),
glm::ivec3 minValue = glm::ivec3(std::numeric_limits<int>::lowest()),
glm::ivec3 maxValue = glm::ivec3(std::numeric_limits<int>::max()),
glm::ivec3 stepValue = glm::ivec3(1));
std::string className() const override;
int typeLua() const override;
using TemplateProperty<glm::ivec3>::operator=;
protected:
glm::ivec3 fromLuaConversion(lua_State* state, bool& success) const override;
};
} // namespace openspace::properties
@@ -28,10 +28,25 @@
#include <openspace/properties/numericalproperty.h>
#include <ghoul/glm.h>
#include <limits>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(IVec4Property, glm::ivec4)
class IVec4Property : public NumericalProperty<glm::ivec4> {
public:
IVec4Property(Property::PropertyInfo info, glm::ivec4 value = glm::ivec4(0),
glm::ivec4 minValue = glm::ivec4(std::numeric_limits<int>::lowest()),
glm::ivec4 maxValue = glm::ivec4(std::numeric_limits<int>::max()),
glm::ivec4 stepValue = glm::ivec4(1));
std::string className() const override;
int typeLua() const override;
using TemplateProperty<glm::ivec4>::operator=;
protected:
glm::ivec4 fromLuaConversion(lua_State* state, bool& success) const override;
};
} // namespace openspace::properties
@@ -28,10 +28,25 @@
#include <openspace/properties/numericalproperty.h>
#include <ghoul/glm.h>
#include <limits>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(UVec2Property, glm::uvec2)
class UVec2Property : public NumericalProperty<glm::uvec2> {
public:
UVec2Property(Property::PropertyInfo info, glm::uvec2 value = glm::uvec2(0),
glm::uvec2 minValue = glm::uvec2(std::numeric_limits<unsigned int>::lowest()),
glm::uvec2 maxValue = glm::uvec2(std::numeric_limits<unsigned int>::max()),
glm::uvec2 stepValue = glm::uvec2(1));
std::string className() const override;
int typeLua() const override;
using TemplateProperty<glm::uvec2>::operator=;
protected:
glm::uvec2 fromLuaConversion(lua_State* state, bool& success) const override;
};
} // namespace openspace::properties
@@ -28,10 +28,25 @@
#include <openspace/properties/numericalproperty.h>
#include <ghoul/glm.h>
#include <limits>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(UVec3Property, glm::uvec3)
class UVec3Property : public NumericalProperty<glm::uvec3> {
public:
UVec3Property(Property::PropertyInfo info, glm::uvec3 value = glm::uvec3(0),
glm::uvec3 minValue = glm::uvec3(std::numeric_limits<unsigned int>::lowest()),
glm::uvec3 maxValue = glm::uvec3(std::numeric_limits<unsigned int>::max()),
glm::uvec3 stepValue = glm::uvec3(1));
std::string className() const override;
int typeLua() const override;
using TemplateProperty<glm::uvec3>::operator=;
protected:
glm::uvec3 fromLuaConversion(lua_State* state, bool& success) const override;
};
} // namespace openspace::properties
@@ -28,10 +28,25 @@
#include <openspace/properties/numericalproperty.h>
#include <ghoul/glm.h>
#include <limits>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(UVec4Property, glm::uvec4)
class UVec4Property : public NumericalProperty<glm::uvec4> {
public:
UVec4Property(Property::PropertyInfo info, glm::uvec4 value = glm::uvec4(0),
glm::uvec4 minValue = glm::uvec4(std::numeric_limits<unsigned int>::lowest()),
glm::uvec4 maxValue = glm::uvec4(std::numeric_limits<unsigned int>::max()),
glm::uvec4 stepValue = glm::uvec4(1));
std::string className() const override;
int typeLua() const override;
using TemplateProperty<glm::uvec4>::operator=;
protected:
glm::uvec4 fromLuaConversion(lua_State* state, bool& success) const override;
};
} // namespace openspace::properties
@@ -28,10 +28,25 @@
#include <openspace/properties/numericalproperty.h>
#include <ghoul/glm.h>
#include <limits>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(Vec2Property, glm::vec2)
class Vec2Property : public NumericalProperty<glm::vec2> {
public:
Vec2Property(Property::PropertyInfo info, glm::vec2 value = glm::vec2(0.f),
glm::vec2 minValue = glm::vec2(std::numeric_limits<float>::lowest()),
glm::vec2 maxValue = glm::vec2(std::numeric_limits<float>::max()),
glm::vec2 stepValue = glm::vec2(0.01f));
std::string className() const override;
int typeLua() const override;
using TemplateProperty<glm::vec2>::operator=;
protected:
glm::vec2 fromLuaConversion(lua_State* state, bool& success) const override;
};
} // namespace openspace::properties
@@ -28,10 +28,25 @@
#include <openspace/properties/numericalproperty.h>
#include <ghoul/glm.h>
#include <limits>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(Vec3Property, glm::vec3)
class Vec3Property : public NumericalProperty<glm::vec3> {
public:
Vec3Property(Property::PropertyInfo info, glm::vec3 value = glm::vec3(0.f),
glm::vec3 minValue = glm::vec3(std::numeric_limits<float>::lowest()),
glm::vec3 maxValue = glm::vec3(std::numeric_limits<float>::max()),
glm::vec3 stepValue = glm::vec3(0.01f));
std::string className() const override;
int typeLua() const override;
using TemplateProperty<glm::vec3>::operator=;
protected:
glm::vec3 fromLuaConversion(lua_State* state, bool& success) const override;
};
} // namespace openspace::properties
@@ -28,10 +28,25 @@
#include <openspace/properties/numericalproperty.h>
#include <ghoul/glm.h>
#include <limits>
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_HEADER(Vec4Property, glm::vec4)
class Vec4Property : public NumericalProperty<glm::vec4> {
public:
Vec4Property(Property::PropertyInfo info, glm::vec4 value = glm::vec4(0.f),
glm::vec4 minValue = glm::vec4(std::numeric_limits<float>::lowest()),
glm::vec4 maxValue = glm::vec4(std::numeric_limits<float>::max()),
glm::vec4 stepValue = glm::vec4(0.01f));
std::string className() const override;
int typeLua() const override;
using TemplateProperty<glm::vec4>::operator=;
protected:
glm::vec4 fromLuaConversion(lua_State* state, bool& success) const override;
};
} // namespace openspace::properties
@@ -22,51 +22,47 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <openspace/properties/scalar/charproperty.h>
#ifndef __OPENSPACE_CORE___JSON_HELPER___H__
#define __OPENSPACE_CORE___JSON_HELPER___H__
#include <ghoul/lua/ghoul_lua.h>
#include <string>
#include <limits>
#include <sstream>
namespace openspace {
namespace {
/**
* This function takes a \p text and escapes all necessary characters () that JSON
* does not want in its strings.
* \param text The text that is to be escaped
* \return The same text with all required characteres escaped
*/
std::string escapedJson(const std::string& text);
char fromLuaConversion(lua_State* state, bool& success) {
success = (lua_isnumber(state, -1) == 1);
if (success) {
char val = static_cast<char>(lua_tonumber(state, -1));
return val;
}
else {
return char(0);
}
}
/**
* This function takes a \p list of text and escapes all necessary characters () that
* JSON does not want in its strings.
* \param text The list of text that is to be escaped
* \return The same text with all required characteres escaped
*/
std::string escapedJson(const std::vector<std::string>& list);
bool toLuaConversion(lua_State* state, char value) {
lua_pushnumber(state, static_cast<lua_Number>(value));
return true;
}
/**
* Convert the input value to a valid JSON formatted string. Nan and Inf values
* are not vald JSON and will be represented by 'null'
* \param d The value to format
* \return The resulting JSON formatted string
*/
std::string formatJsonNumber(double d);
bool toStringConversion(std::string& outValue, char inValue) {
outValue = std::to_string(inValue);
return true;
}
/**
* Convert the input value to a valid JSON formatted string
* \param value The value to be converted
* \return The resulting JSON formatted string
*/
template <typename T>
std::string formatJson(T value);
} // namespace
} // namespace openspace
namespace openspace::properties {
#include "json_helper.inl"
REGISTER_NUMERICALPROPERTY_SOURCE(
CharProperty,
char,
char(0),
std::numeric_limits<char>::lowest(),
std::numeric_limits<char>::max(),
char(1),
fromLuaConversion,
toLuaConversion,
toStringConversion,
LUA_TNUMBER
)
} // namespace openspace::properties
#endif // __OPENSPACE_CORE___JSON_HELPER___H__
@@ -22,73 +22,75 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <typeinfo>
#include <ghoul/fmt.h>
#include <ghoul/glm.h>
#include <ghoul/misc/dictionaryjsonformatter.h>
#include <type_traits>
namespace openspace::properties {
namespace openspace {
namespace internal {
template <class T, class... Ts>
struct is_any : std::disjunction<std::is_same<T, Ts>...> {};
template <typename T>
std::string PropertyDelegate<T>::className() {
static_assert(sizeof(T) == 0,
"Unimplemented PropertyDelegate::className specialization");
return "";
constexpr bool isGlmMatrix() {
return is_any<T,
glm::mat2x2, glm::mat2x3, glm::mat2x4,
glm::mat3x2, glm::mat3x3, glm::mat3x4,
glm::mat4x2, glm::mat4x3, glm::mat4x4,
glm::dmat2x2, glm::dmat2x3, glm::dmat2x4,
glm::dmat3x2, glm::dmat3x3, glm::dmat3x4,
glm::dmat4x2, glm::dmat4x3, glm::dmat4x4>::value;
}
template <typename T>
template <typename U>
U PropertyDelegate<T>::defaultValue() {
static_assert(sizeof(T) == 0,
"Unimplemented PropertyDelegate::defaultValue specialization");
constexpr bool isGlmVector() {
return is_any<T,
glm::vec2, glm::vec3, glm::vec4,
glm::ivec2, glm::ivec3, glm::ivec4,
glm::dvec2, glm::dvec3, glm::dvec4,
glm::uvec2, glm::uvec3, glm::uvec4>::value;
}
} // namespace internal
template <typename T>
template <typename U>
U PropertyDelegate<T>::defaultMinimumValue() {
static_assert(sizeof(T) == 0,
"Unimplemented PropertyDelegate::defaultMinimumValue specialization");
std::string formatJson(T value) {
if constexpr (std::is_same_v<T, bool>) {
return value ? "true" : "false";
}
else if constexpr (std::is_arithmetic_v<T>) {
return formatJsonNumber(static_cast<double>(value));
}
else if constexpr (std::is_same_v<T, std::string>) {
return escapedJson(value);
}
else if constexpr (std::is_same_v<T, ghoul::Dictionary>) {
return return ghoul::formatJson(value);
}
else if constexpr (internal::isGlmVector<T>()) {
std::string values;
for (glm::length_t i = 0; i < ghoul::glm_components<T>::value; ++i) {
values += std::to_string(value[i]) + ',';
}
values.pop_back();
return fmt::format("[{}]", values);
}
else if constexpr (internal::isGlmMatrix<T>()) {
std::string values;
for (glm::length_t i = 0; i < T::type::row_type::length(); ++i) {
for (glm::length_t j = 0; j < T::type::col_type::length(); ++j) {
values += std::to_string(value[i][j]) + ',';
}
}
values.pop_back();
return fmt::format("[{}]", values);
}
else {
static_assert(sizeof(T) == 0, "JSON formatting of type T not implemented");
}
}
template <typename T>
template <typename U>
U PropertyDelegate<T>::defaultMaximumValue() {
static_assert(sizeof(T) == 0,
"Unimplemented PropertyDelegate::defaultMaximumValue specialization");
}
template <typename T>
template <typename U>
U PropertyDelegate<T>::defaultSteppingValue() {
static_assert(sizeof(T) == 0,
"Unimplemented PropertyDelegate::defaultSteppingValue specialization");
}
template <typename T>
template <typename U>
U PropertyDelegate<T>::fromLuaValue(lua_State*, bool&) {
static_assert(sizeof(T) == 0,
"Unimplemented PropertyDelegate::fromLuaValue specialization");
}
template <typename T>
template <typename U>
bool PropertyDelegate<T>::toLuaValue(lua_State*, const U&) {
static_assert(sizeof(T) == 0,
"Unimplemented PropertyDelegate::toLuaValue specialization");
return false;
}
template <typename T>
int PropertyDelegate<T>::typeLua() {
static_assert(sizeof(T) == 0,
"Unimplemented PropertyDelegate::luaType specialization");
return 0;
}
template <typename T>
template <typename U>
bool PropertyDelegate<T>::toString(std::string&, const U&) {
static_assert(sizeof(T) == 0,
"Unimplemented PropertyDelegate::toString specialization");
return false;
}
} // namespace openspace::properties
} // namespace openspace
@@ -133,7 +133,7 @@ namespace {
"Clear Projection Buffer",
"Remove all pending projections from the buffer"
};
struct [[codegen::Dictionary(RenderablePlanetProjection)]] Parameters {
// The geometry that is used for rendering this planet
ghoul::Dictionary geometry [[codegen::reference("space_geometry_planet")]];
@@ -177,7 +177,7 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary&
, _addColorTexturePath(AddColorTextureInfo)
, _heightMapTexturePaths(HeightTexturePathsInfo)
, _addHeightMapTexturePath(AddHeightTextureInfo)
, _heightExaggeration(HeightExaggerationInfo, 1.f, 0.f, 1e6f, 1.f, 3.f)
, _heightExaggeration(HeightExaggerationInfo, 1.f, 0.f, 1e6f, 1.f)
, _meridianShift(MeridianShiftInfo, false)
, _ambientBrightness(AmbientBrightnessInfo, 0.075f, 0.f, 1.f)
, _maxProjectionsPerFrame(MaxProjectionsPerFrameInfo, 1, 1, 64)
@@ -220,8 +220,6 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary&
});
addProperty(_addColorTexturePath);
_heightMapTexturePaths.addOption(0, NoImageText);
_heightMapTexturePaths.onChange([this]() { _heightMapTextureDirty = true; });
addProperty(_heightMapTexturePaths);
@@ -266,9 +264,10 @@ RenderablePlanetProjection::RenderablePlanetProjection(const ghoul::Dictionary&
addPropertySubOwner(_geometry.get());
addPropertySubOwner(_projectionComponent);
_heightExaggeration.setExponent(3.f);
_heightExaggeration = p.heightExaggeration.value_or(_heightExaggeration);
addProperty(_heightExaggeration);
_maxProjectionsPerFrame = p.maxProjectionsPerFrame.value_or(_maxProjectionsPerFrame);
addProperty(_maxProjectionsPerFrame);
+1 -2
View File
@@ -90,7 +90,7 @@ bool TransferFunction::setEnvelopesFromLua(lua_State* state) {
return success;
}
bool TransferFunction::envelopesToLua(lua_State* state) {
void TransferFunction::envelopesToLua(lua_State* state) const {
lua_newtable(state);
for (auto iter = _envelopes.begin(); iter != _envelopes.end(); ++iter) {
lua_newtable(state);
@@ -101,7 +101,6 @@ bool TransferFunction::envelopesToLua(lua_State* state) {
("[\"" + std::to_string(iter - _envelopes.begin() + 1) + "\"]").c_str()
);
}
return true;
}
void TransferFunction::loadEnvelopesFromFile(const std::string& path) {
+1 -1
View File
@@ -38,7 +38,7 @@ public:
TransferFunction() = default;
TransferFunction(const std::string& string);
bool envelopesToLua(lua_State* state);
void envelopesToLua(lua_State* state) const;
bool setEnvelopesFromString(const std::string& s);
bool setEnvelopesFromLua(lua_State* lua);
+21 -22
View File
@@ -23,38 +23,37 @@
****************************************************************************************/
#include <modules/volume/transferfunctionproperty.h>
#include <ghoul/lua/ghoul_lua.h>
namespace {
namespace openspace::properties {
openspace::volume::TransferFunction fromLuaConversion(lua_State* state, bool& success) {
TransferFunctionProperty::TransferFunctionProperty(Property::PropertyInfo info,
volume::TransferFunction value)
: TemplateProperty<volume::TransferFunction>(std::move(info), value)
{}
std::string TransferFunctionProperty::className() const {
return "TransferFunctionProperty";
}
int TransferFunctionProperty::typeLua() const {
return LUA_TTABLE;
}
openspace::volume::TransferFunction
TransferFunctionProperty::fromLuaConversion(lua_State* state, bool& success) const
{
openspace::volume::TransferFunction tf;
success = tf.setEnvelopesFromLua(state);
return tf;
}
bool toLuaConversion(lua_State* state, openspace::volume::TransferFunction value) {
return value.envelopesToLua(state);
void TransferFunctionProperty::toLuaConversion(lua_State* state) const {
_value.envelopesToLua(state);
}
bool toStringConversion(std::string& outValue,
openspace::volume::TransferFunction inValue)
{
outValue = inValue.serializedToString();
return true;
std::string TransferFunctionProperty::toStringConversion() const {
return _value.serializedToString();
}
} // namespace
namespace openspace::properties {
REGISTER_TEMPLATEPROPERTY_SOURCE(TransferFunctionProperty, volume::TransferFunction,
volume::TransferFunction(),
fromLuaConversion,
toLuaConversion,
toStringConversion,
LUA_TTABLE
)
} // namespace openspace::properties
+16 -1
View File
@@ -30,7 +30,22 @@
namespace openspace::properties {
REGISTER_TEMPLATEPROPERTY_HEADER(TransferFunctionProperty, volume::TransferFunction)
class TransferFunctionProperty : public TemplateProperty<volume::TransferFunction> {
public:
TransferFunctionProperty(Property::PropertyInfo info,
volume::TransferFunction value = volume::TransferFunction());
std::string className() const override;
int typeLua() const override;
using TemplateProperty<volume::TransferFunction>::operator=;
protected:
volume::TransferFunction fromLuaConversion(lua_State* state,
bool& success) const override;
void toLuaConversion(lua_State* state) const override;
std::string toStringConversion() const override;
};
} // namespace openspace::properties
+1 -1
View File
@@ -27,7 +27,7 @@
#include <modules/server/servermodule.h>
#include <openspace/engine/globals.h>
#include <openspace/engine/moduleengine.h>
#include <openspace/documentation/documentationgenerator.h>
#include <openspace/util/json_helper.h>
#include <ghoul/fmt.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/logging/logmanager.h>
+3 -46
View File
@@ -81,42 +81,20 @@ set(OPENSPACE_SOURCE
${OPENSPACE_BASE_DIR}/src/properties/list/intlistproperty.cpp
${OPENSPACE_BASE_DIR}/src/properties/list/stringlistproperty.cpp
${OPENSPACE_BASE_DIR}/src/properties/matrix/dmat2property.cpp
${OPENSPACE_BASE_DIR}/src/properties/matrix/dmat2x3property.cpp
${OPENSPACE_BASE_DIR}/src/properties/matrix/dmat2x4property.cpp
${OPENSPACE_BASE_DIR}/src/properties/matrix/dmat3x2property.cpp
${OPENSPACE_BASE_DIR}/src/properties/matrix/dmat3property.cpp
${OPENSPACE_BASE_DIR}/src/properties/matrix/dmat3x4property.cpp
${OPENSPACE_BASE_DIR}/src/properties/matrix/dmat4x2property.cpp
${OPENSPACE_BASE_DIR}/src/properties/matrix/dmat4x3property.cpp
${OPENSPACE_BASE_DIR}/src/properties/matrix/dmat4property.cpp
${OPENSPACE_BASE_DIR}/src/properties/matrix/mat2property.cpp
${OPENSPACE_BASE_DIR}/src/properties/matrix/mat2x3property.cpp
${OPENSPACE_BASE_DIR}/src/properties/matrix/mat2x4property.cpp
${OPENSPACE_BASE_DIR}/src/properties/matrix/mat3x2property.cpp
${OPENSPACE_BASE_DIR}/src/properties/matrix/mat3property.cpp
${OPENSPACE_BASE_DIR}/src/properties/matrix/mat3x4property.cpp
${OPENSPACE_BASE_DIR}/src/properties/matrix/mat4x2property.cpp
${OPENSPACE_BASE_DIR}/src/properties/matrix/mat4x3property.cpp
${OPENSPACE_BASE_DIR}/src/properties/matrix/mat4property.cpp
${OPENSPACE_BASE_DIR}/src/properties/scalar/boolproperty.cpp
${OPENSPACE_BASE_DIR}/src/properties/scalar/charproperty.cpp
${OPENSPACE_BASE_DIR}/src/properties/scalar/doubleproperty.cpp
${OPENSPACE_BASE_DIR}/src/properties/scalar/floatproperty.cpp
${OPENSPACE_BASE_DIR}/src/properties/scalar/intproperty.cpp
${OPENSPACE_BASE_DIR}/src/properties/scalar/longdoubleproperty.cpp
${OPENSPACE_BASE_DIR}/src/properties/scalar/longlongproperty.cpp
${OPENSPACE_BASE_DIR}/src/properties/scalar/longproperty.cpp
${OPENSPACE_BASE_DIR}/src/properties/scalar/shortproperty.cpp
${OPENSPACE_BASE_DIR}/src/properties/scalar/signedcharproperty.cpp
${OPENSPACE_BASE_DIR}/src/properties/scalar/ucharproperty.cpp
${OPENSPACE_BASE_DIR}/src/properties/scalar/uintproperty.cpp
${OPENSPACE_BASE_DIR}/src/properties/scalar/ulonglongproperty.cpp
${OPENSPACE_BASE_DIR}/src/properties/scalar/ulongproperty.cpp
${OPENSPACE_BASE_DIR}/src/properties/scalar/ushortproperty.cpp
${OPENSPACE_BASE_DIR}/src/properties/scalar/wcharproperty.cpp
${OPENSPACE_BASE_DIR}/src/properties/vector/bvec2property.cpp
${OPENSPACE_BASE_DIR}/src/properties/vector/bvec3property.cpp
${OPENSPACE_BASE_DIR}/src/properties/vector/bvec4property.cpp
${OPENSPACE_BASE_DIR}/src/properties/vector/dvec2property.cpp
${OPENSPACE_BASE_DIR}/src/properties/vector/dvec3property.cpp
${OPENSPACE_BASE_DIR}/src/properties/vector/dvec4property.cpp
@@ -178,6 +156,7 @@ set(OPENSPACE_SOURCE
${OPENSPACE_BASE_DIR}/src/util/distanceconversion.cpp
${OPENSPACE_BASE_DIR}/src/util/factorymanager.cpp
${OPENSPACE_BASE_DIR}/src/util/httprequest.cpp
${OPENSPACE_BASE_DIR}/src/util/json_helper.cpp
${OPENSPACE_BASE_DIR}/src/util/keys.cpp
${OPENSPACE_BASE_DIR}/src/util/openspacemodule.cpp
${OPENSPACE_BASE_DIR}/src/util/planegeometry.cpp
@@ -268,8 +247,6 @@ set(OPENSPACE_HEADER
${OPENSPACE_BASE_DIR}/include/openspace/properties/numericalproperty.inl
${OPENSPACE_BASE_DIR}/include/openspace/properties/optionproperty.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/property.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/propertydelegate.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/propertydelegate.inl
${OPENSPACE_BASE_DIR}/include/openspace/properties/propertyowner.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/selectionproperty.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/stringproperty.h
@@ -280,42 +257,20 @@ set(OPENSPACE_HEADER
${OPENSPACE_BASE_DIR}/include/openspace/properties/list/intlistproperty.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/list/stringlistproperty.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/matrix/dmat2property.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/matrix/dmat2x3property.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/matrix/dmat2x4property.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/matrix/dmat3x2property.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/matrix/dmat3property.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/matrix/dmat3x4property.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/matrix/dmat4x2property.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/matrix/dmat4x3property.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/matrix/dmat4property.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/matrix/mat2property.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/matrix/mat2x3property.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/matrix/mat2x4property.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/matrix/mat3x2property.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/matrix/mat3property.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/matrix/mat3x4property.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/matrix/mat4x2property.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/matrix/mat4x3property.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/matrix/mat4property.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/scalar/boolproperty.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/scalar/charproperty.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/scalar/doubleproperty.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/scalar/floatproperty.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/scalar/intproperty.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/scalar/longdoubleproperty.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/scalar/longlongproperty.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/scalar/longproperty.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/scalar/shortproperty.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/scalar/signedcharproperty.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/scalar/ucharproperty.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/scalar/uintproperty.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/scalar/ulonglongproperty.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/scalar/ulongproperty.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/scalar/ushortproperty.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/scalar/wcharproperty.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/vector/bvec2property.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/vector/bvec3property.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/vector/bvec4property.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/vector/dvec2property.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/vector/dvec3property.h
${OPENSPACE_BASE_DIR}/include/openspace/properties/vector/dvec4property.h
@@ -382,6 +337,8 @@ set(OPENSPACE_HEADER
${OPENSPACE_BASE_DIR}/include/openspace/util/factorymanager.inl
${OPENSPACE_BASE_DIR}/include/openspace/util/httprequest.h
${OPENSPACE_BASE_DIR}/include/openspace/util/job.h
${OPENSPACE_BASE_DIR}/include/openspace/util/json_helper.h
${OPENSPACE_BASE_DIR}/include/openspace/util/json_helper.inl
${OPENSPACE_BASE_DIR}/include/openspace/util/keys.h
${OPENSPACE_BASE_DIR}/include/openspace/util/memorymanager.h
${OPENSPACE_BASE_DIR}/include/openspace/util/mouse.h
@@ -27,6 +27,7 @@
#include <openspace/openspace.h>
#include <openspace/documentation/core_registration.h>
#include <openspace/documentation/verifier.h>
#include <openspace/util/json_helper.h>
#include <ghoul/fmt.h>
#include <ghoul/filesystem/filesystem.h>
#include <ghoul/misc/profiling.h>
@@ -58,66 +58,4 @@ std::string DocumentationGenerator::jsonName() {
return _jsonName;
}
std::string escapedJson(const std::vector<std::string>& list) {
std::string jsonString;
jsonString += "[";
for (const std::string& text : list) {
jsonString += "\\\"";
for (const char& c : text) {
switch (c) {
case '\t':
jsonString += "\\t"; // Replace tab with \t.
break;
case '"':
jsonString += "\\\""; // Replace " with \".
break;
case '\\':
jsonString += "\\\\"; // Replace \ with \\.
break;
case '\n':
jsonString += "\\\\n"; // Replace newline with \n.
break;
case '\r':
jsonString += "\\r"; // Replace carriage return with \r.
break;
default:
jsonString += c;
}
}
jsonString += "\\\",";
}
if (jsonString.length() > 1) {
jsonString.pop_back();
}
jsonString += "]";
return jsonString;
}
std::string escapedJson(const std::string& text) {
std::string jsonString;
for (const char& c : text) {
switch (c) {
case '\t':
jsonString += "\\t"; // Replace tab with \t.
break;
case '"':
jsonString += "\\\""; // Replace " with \".
break;
case '\\':
jsonString += "\\\\"; // Replace \ with \\.
break;
case '\n':
jsonString += "\\\\n"; // Replace newline with \n.
break;
case '\r':
jsonString += "\\r"; // Replace carriage return with \r.
break;
default:
jsonString += c;
}
}
return jsonString;
}
} // namespace openspace
+3 -1
View File
@@ -27,6 +27,7 @@
#include <openspace/engine/globals.h>
#include <openspace/scripting/lualibrary.h>
#include <openspace/scripting/scriptengine.h>
#include <openspace/util/json_helper.h>
#include <ghoul/misc/profiling.h>
#include <ghoul/glm.h>
#include <sstream>
@@ -195,7 +196,8 @@ std::string KeybindingManager::generateJson() const {
json << R"("script": ")" << escapedJson(p.second.command) << "\",";
json << R"("remoteScripting": )"
<< (p.second.synchronization ? "true," : "false,");
json << R"("documentation": ")" << escapedJson(p.second.documentation) << "\",";
json << R"("documentation": ")"
<< escapedJson(p.second.documentation) << "\",";
json << R"("name": ")" << escapedJson(p.second.name) << "\"";
json << "}";
}
+28 -38
View File
@@ -27,16 +27,30 @@
#include <openspace/json.h>
#include <ghoul/logging/logmanager.h>
#include <ghoul/lua/ghoul_lua.h>
#include <ghoul/lua/lua_helper.h>
#include <ghoul/misc/misc.h>
namespace {
namespace openspace::properties {
constexpr const char* _loggerCat = "DoubleListProperty";
DoubleListProperty::DoubleListProperty(Property::PropertyInfo info,
std::vector<double> values)
: ListProperty(std::move(info), std::move(values))
{}
std::vector<double> fromLuaConversion(lua_State* state, bool& success) {
std::string DoubleListProperty::className() const {
return "DoubleListProperty";
}
int DoubleListProperty::typeLua() const {
return LUA_TTABLE;
}
std::vector<double> DoubleListProperty::fromLuaConversion(lua_State* state,
bool& success) const
{
if (!lua_istable(state, -1)) {
success = false;
LERROR("Conversion from Lua failed. The input was not a table");
LERRORC(className(), "Conversion from Lua failed. The input was not a table");
return {};
}
@@ -48,7 +62,8 @@ std::vector<double> fromLuaConversion(lua_State* state, bool& success) {
}
else {
success = false;
LERROR(
LERRORC(
className(),
"Conversion from Lua failed. The input table contains non-number values"
);
return {};
@@ -59,46 +74,21 @@ std::vector<double> fromLuaConversion(lua_State* state, bool& success) {
return result;
}
bool toLuaConversion(lua_State* state, std::vector<double> val) {
lua_createtable(state, static_cast<int>(val.size()), 0);
void DoubleListProperty::toLuaConversion(lua_State* state) const {
lua_createtable(state, static_cast<int>(_value.size()), 0);
int i = 1;
for (int v : val) {
lua_pushinteger(state, i);
lua_pushinteger(state, v);
for (double v : _value) {
ghoul::lua::push(state, i);
ghoul::lua::push(state, v);
lua_settable(state, -3);
++i;
}
return true;
}
bool toStringConversion(std::string& outValue, const std::vector<double>& inValue) {
nlohmann::json json(inValue);
outValue = json.dump();
return true;
std::string DoubleListProperty::toStringConversion() const {
nlohmann::json json(_value);
return json.dump();
}
} // namespace
namespace openspace::properties {
DoubleListProperty::DoubleListProperty(Property::PropertyInfo info)
: ListProperty(std::move(info))
{}
DoubleListProperty::DoubleListProperty(Property::PropertyInfo info, std::vector<double> values)
: ListProperty(std::move(info), std::move(values))
{}
REGISTER_TEMPLATEPROPERTY_SOURCE(
DoubleListProperty,
std::vector<double>,
std::vector<double>(),
fromLuaConversion,
toLuaConversion,
toStringConversion,
LUA_TTABLE
)
} // namespace openspace::properties
+27 -38
View File
@@ -27,16 +27,29 @@
#include <openspace/json.h>
#include <ghoul/logging/logmanager.h>
#include <ghoul/lua/ghoul_lua.h>
#include <ghoul/lua/lua_helper.h>
#include <ghoul/misc/misc.h>
namespace {
namespace openspace::properties {
constexpr const char* _loggerCat = "IntListProperty";
IntListProperty::IntListProperty(Property::PropertyInfo info, std::vector<int> values)
: ListProperty(std::move(info), std::move(values))
{}
std::vector<int> fromLuaConversion(lua_State* state, bool& success) {
std::string IntListProperty::className() const {
return "IntListProperty";
}
int IntListProperty::typeLua() const {
return LUA_TTABLE;
}
std::vector<int> IntListProperty::fromLuaConversion(lua_State* state,
bool& success) const
{
if (!lua_istable(state, -1)) {
success = false;
LERROR("Conversion from Lua failed. The input was not a table");
LERRORC(className(), "Conversion from Lua failed. The input was not a table");
return {};
}
@@ -48,7 +61,8 @@ std::vector<int> fromLuaConversion(lua_State* state, bool& success) {
}
else {
success = false;
LERROR(
LERRORC(
className(),
"Conversion from Lua failed. The input table contains non-number values"
);
return {};
@@ -59,46 +73,21 @@ std::vector<int> fromLuaConversion(lua_State* state, bool& success) {
return result;
}
bool toLuaConversion(lua_State* state, std::vector<int> val) {
lua_createtable(state, static_cast<int>(val.size()), 0);
void IntListProperty::toLuaConversion(lua_State* state) const {
lua_createtable(state, static_cast<int>(_value.size()), 0);
int i = 1;
for (const int& v : val) {
lua_pushinteger(state, i);
lua_pushinteger(state, v);
for (int v : _value) {
ghoul::lua::push(state, i);
ghoul::lua::push(state, v);
lua_settable(state, -3);
++i;
}
return true;
}
bool toStringConversion(std::string& outValue, const std::vector<int>& inValue) {
nlohmann::json json(inValue);
outValue = json.dump();
return true;
std::string IntListProperty::toStringConversion() const {
nlohmann::json json(_value);
return json.dump();
}
} // namespace
namespace openspace::properties {
IntListProperty::IntListProperty(Property::PropertyInfo info)
: ListProperty(std::move(info))
{}
IntListProperty::IntListProperty(Property::PropertyInfo info, std::vector<int> values)
: ListProperty(std::move(info), std::move(values))
{}
REGISTER_TEMPLATEPROPERTY_SOURCE(
IntListProperty,
std::vector<int>,
std::vector<int>(),
fromLuaConversion,
toLuaConversion,
toStringConversion,
LUA_TTABLE
)
} // namespace openspace::properties
+26 -40
View File
@@ -27,18 +27,30 @@
#include <openspace/json.h>
#include <ghoul/logging/logmanager.h>
#include <ghoul/lua/ghoul_lua.h>
#include <ghoul/lua/lua_helper.h>
#include <ghoul/misc/misc.h>
namespace {
constexpr const char* _loggerCat = "IntListProperty";
} // namespace
namespace openspace::properties {
namespace {
StringListProperty::StringListProperty(Property::PropertyInfo info,
std::vector<std::string> values)
: ListProperty(std::move(info), std::move(values))
{}
std::vector<std::string> fromLuaConversion(lua_State* state, bool& success) {
std::string StringListProperty::className() const {
return "StringListProperty";
}
int StringListProperty::typeLua() const {
return LUA_TTABLE;
}
std::vector<std::string> StringListProperty::fromLuaConversion(lua_State* state,
bool& success) const
{
if (!lua_istable(state, -1)) {
success = false;
LERROR("Conversion from Lua failed. The input was not a table");
LERRORC(className(), "Conversion from Lua failed. The input was not a table");
return {};
}
@@ -58,47 +70,21 @@ std::vector<std::string> fromLuaConversion(lua_State* state, bool& success) {
return result;
}
bool toLuaConversion(lua_State* state, std::vector<std::string> val) {
lua_createtable(state, static_cast<int>(val.size()), 0);
void StringListProperty::toLuaConversion(lua_State* state) const {
lua_createtable(state, static_cast<int>(_value.size()), 0);
int i = 1;
for (const std::string& v : val) {
lua_pushinteger(state, i);
lua_pushstring(state, v.c_str());
for (const std::string& v : _value) {
ghoul::lua::push(state, i);
ghoul::lua::push(state, v.c_str());
lua_settable(state, -3);
++i;
}
return true;
}
bool toStringConversion(std::string& outValue, const std::vector<std::string>& inValue) {
nlohmann::json json(inValue);
outValue = json.dump();
return true;
std::string StringListProperty::toStringConversion() const {
nlohmann::json json(_value);
return json.dump();
}
} // namespace
namespace openspace::properties {
StringListProperty::StringListProperty(Property::PropertyInfo info)
: ListProperty(std::move(info))
{}
StringListProperty::StringListProperty(Property::PropertyInfo info,
std::vector<std::string> values)
: ListProperty(std::move(info), std::move(values))
{}
REGISTER_TEMPLATEPROPERTY_SOURCE(
StringListProperty,
std::vector<std::string>,
std::vector<std::string>(),
fromLuaConversion,
toLuaConversion,
toStringConversion,
LUA_TTABLE
)
} // namespace openspace::properties
+24 -75
View File
@@ -24,84 +24,33 @@
#include <openspace/properties/matrix/dmat2property.h>
#include <ghoul/misc/misc.h>
#include <limits>
#include <sstream>
#include <vector>
namespace {
glm::dmat2x2 fromLuaConversion(lua_State* state, bool& success) {
glm::dmat2x2 result;
lua_pushnil(state);
int number = 1;
for (glm::length_t i = 0; i < glm::dmat2x2::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::dmat2x2::col_type::length(); ++j) {
int hasNext = lua_next(state, -2);
if (hasNext != 1) {
success = false;
return glm::dmat2x2(0.0);
}
if (lua_isnumber(state, -1) != 1) {
success = false;
return glm::dmat2x2(0.0);
}
else {
result[i][j] = lua_tonumber(state, -1);
lua_pop(state, 1);
++number;
}
}
}
// The last accessor argument and the table are still on the stack
lua_pop(state, 1);
success = true;
return result;
}
bool toLuaConversion(lua_State* state, glm::dmat2x2 value) {
lua_newtable(state);
int number = 1;
for (glm::length_t i = 0; i < glm::dmat2x2::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::dmat2x2::col_type::length(); ++j) {
lua_pushnumber(state, value[i][j]);
lua_rawseti(state, -2, number);
++number;
}
}
return true;
}
bool toStringConversion(std::string& outValue, glm::dmat2x2 inValue) {
outValue = "[";
for (glm::length_t i = 0; i < glm::dmat2x2::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::dmat2x2::col_type::length(); ++j) {
outValue += std::to_string(inValue[i][j]) + ",";
}
}
outValue.pop_back();
outValue += "]";
return true;
}
} // namespace
#include <ghoul/lua/ghoul_lua.h>
#include <ghoul/lua/lua_helper.h>
namespace openspace::properties {
using nl = std::numeric_limits<double>;
DMat2Property::DMat2Property(Property::PropertyInfo info, glm::dmat2x2 value,
glm::dmat2x2 minValue, glm::dmat2x2 maxValue,
glm::dmat2x2 stepValue)
: NumericalProperty<glm::dmat2x2>(
std::move(info),
std::move(value),
std::move(minValue),
std::move(maxValue),
std::move(stepValue)
)
{}
REGISTER_NUMERICALPROPERTY_SOURCE(
DMat2Property,
glm::dmat2x2,
glm::dmat2x2(0.0),
glm::dmat2x2(nl::lowest(), nl::lowest(), nl::lowest(), nl::lowest()),
glm::dmat2x2(nl::max(), nl::max(), nl::max(), nl::max()),
glm::dmat2x2(0.01, 0.01, 0.01, 0.01),
fromLuaConversion,
toLuaConversion,
toStringConversion,
LUA_TTABLE
)
std::string DMat2Property::className() const {
return "DMat2Property";
}
int DMat2Property::typeLua() const {
return LUA_TTABLE;
}
glm::dmat2x2 DMat2Property::fromLuaConversion(lua_State* state, bool& success) const {
return ghoul::lua::tryGetValue<glm::dmat2x2>(state, success);
}
} // namespace openspace::properties
-115
View File
@@ -1,115 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <openspace/properties/matrix/dmat2x3property.h>
#include <ghoul/misc/misc.h>
#include <limits>
#include <sstream>
#include <vector>
namespace {
glm::dmat2x3 fromLuaConversion(lua_State* state, bool& success) {
glm::dmat2x3 result;
lua_pushnil(state);
int number = 1;
for (glm::length_t i = 0; i < glm::dmat2x3::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::dmat2x3::col_type::length(); ++j) {
int hasNext = lua_next(state, -2);
if (hasNext != 1) {
success = false;
return glm::dmat2x3(0.0);
}
if (lua_isnumber(state, -1) != 1) {
success = false;
return glm::dmat2x3(0.0);
}
else {
result[i][j] = lua_tonumber(state, -1);
lua_pop(state, 1);
++number;
}
}
}
// The last accessor argument and the table are still on the stack
lua_pop(state, 1);
success = true;
return result;
}
bool toLuaConversion(lua_State* state, glm::dmat2x3 value) {
lua_newtable(state);
int number = 1;
for (glm::length_t i = 0; i < glm::dmat2x3::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::dmat2x3::col_type::length(); ++j) {
lua_pushnumber(state, value[i][j]);
lua_rawseti(state, -2, number);
++number;
}
}
return true;
}
bool toStringConversion(std::string& outValue, glm::dmat2x3 inValue) {
outValue = "[";
for (glm::length_t i = 0; i < glm::dmat2x3::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::dmat2x3::col_type::length(); ++j) {
outValue += std::to_string(inValue[i][j]) + ",";
}
}
outValue.pop_back();
outValue += "]";
return true;
}
} // namespace
namespace openspace::properties {
using nl = std::numeric_limits<double>;
REGISTER_NUMERICALPROPERTY_SOURCE(
DMat2x3Property,
glm::dmat2x3,
glm::dmat2x3(0.0),
glm::dmat2x3(
nl::lowest(), nl::lowest(),
nl::lowest(), nl::lowest(),
nl::lowest(), nl::lowest()
),
glm::dmat2x3(
nl::max(), nl::max(),
nl::max(), nl::max(),
nl::max(), nl::max()
),
glm::dmat2x3(0.01, 0.01, 0.01, 0.01, 0.01, 0.01),
fromLuaConversion,
toLuaConversion,
toStringConversion,
LUA_TTABLE
)
} // namespace openspace::properties
-117
View File
@@ -1,117 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <openspace/properties/matrix/dmat2x4property.h>
#include <ghoul/misc/misc.h>
#include <limits>
#include <sstream>
#include <vector>
namespace {
glm::dmat2x4 fromLuaConversion(lua_State* state, bool& success) {
glm::dmat2x4 result;
lua_pushnil(state);
int number = 1;
for (glm::length_t i = 0; i < glm::dmat2x4::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::dmat2x4::col_type::length(); ++j) {
int hasNext = lua_next(state, -2);
if (hasNext != 1) {
success = false;
return glm::dmat2x4(0.0);
}
if (lua_isnumber(state, -1) != 1) {
success = false;
return glm::dmat2x4(0.0);
}
else {
result[i][j] = lua_tonumber(state, -1);
lua_pop(state, 1);
++number;
}
}
}
// The last accessor argument and the table are still on the stack
lua_pop(state, 1);
success = true;
return result;
}
bool toLuaConversion(lua_State* state, glm::dmat2x4 value) {
lua_newtable(state);
int number = 1;
for (glm::length_t i = 0; i < glm::dmat2x4::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::dmat2x4::col_type::length(); ++j) {
lua_pushnumber(state, value[i][j]);
lua_rawseti(state, -2, number);
++number;
}
}
return true;
}
bool toStringConversion(std::string& outValue, glm::dmat2x4 inValue) {
outValue = "[";
for (glm::length_t i = 0; i < glm::dmat2x4::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::dmat2x4::col_type::length(); ++j) {
outValue += std::to_string(inValue[i][j]) + ",";
}
}
outValue.pop_back();
outValue += "]";
return true;
}
} // namespace
namespace openspace::properties {
using nl = std::numeric_limits<double>;
REGISTER_NUMERICALPROPERTY_SOURCE(
DMat2x4Property,
glm::dmat2x4,
glm::dmat2x4(0.0),
glm::dmat2x4(
nl::lowest(), nl::lowest(),
nl::lowest(), nl::lowest(),
nl::lowest(), nl::lowest(),
nl::lowest(), nl::lowest()
),
glm::dmat2x4(
nl::max(), nl::max(),
nl::max(), nl::max(),
nl::max(), nl::max(),
nl::max(), nl::max()
),
glm::dmat2x4(0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01, 0.01),
fromLuaConversion,
toLuaConversion,
toStringConversion,
LUA_TTABLE
)
} // namespace openspace::properties
+24 -88
View File
@@ -24,97 +24,33 @@
#include <openspace/properties/matrix/dmat3property.h>
#include <ghoul/misc/misc.h>
#include <limits>
#include <sstream>
#include <vector>
namespace {
glm::dmat3x3 fromLuaConversion(lua_State* state, bool& success) {
glm::dmat3x3 result;
lua_pushnil(state);
int number = 1;
for (glm::length_t i = 0; i < glm::dmat3x3::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::dmat2x3::col_type::length(); ++j) {
int hasNext = lua_next(state, -2);
if (hasNext != 1) {
success = false;
return glm::dmat3x3(0.0);
}
if (lua_isnumber(state, -1) != 1) {
success = false;
return glm::dmat3x3(0.0);
}
else {
result[i][j] = lua_tonumber(state, -1);
lua_pop(state, 1);
++number;
}
}
}
// The last accessor argument and the table are still on the stack
lua_pop(state, 1);
success = true;
return result;
}
bool toLuaConversion(lua_State* state, glm::dmat3x3 value) {
lua_newtable(state);
int number = 1;
for (glm::length_t i = 0; i < glm::dmat3x3::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::dmat2x3::col_type::length(); ++j) {
lua_pushnumber(state, value[i][j]);
lua_rawseti(state, -2, number);
++number;
}
}
return true;
}
bool toStringConversion(std::string& outValue, glm::dmat3x3 inValue) {
outValue = "[";
for (glm::length_t i = 0; i < glm::dmat3x3::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::dmat2x3::col_type::length(); ++j) {
outValue += std::to_string(inValue[i][j]) + ",";
}
}
outValue.pop_back();
outValue += "]";
return true;
}
} // namespace
#include <ghoul/lua/ghoul_lua.h>
#include <ghoul/lua/lua_helper.h>
namespace openspace::properties {
using nl = std::numeric_limits<double>;
DMat3Property::DMat3Property(Property::PropertyInfo info, glm::dmat3x3 value,
glm::dmat3x3 minValue, glm::dmat3x3 maxValue,
glm::dmat3x3 stepValue)
: NumericalProperty<glm::dmat3x3>(
std::move(info),
std::move(value),
std::move(minValue),
std::move(maxValue),
std::move(stepValue)
)
{}
REGISTER_NUMERICALPROPERTY_SOURCE(
DMat3Property,
glm::dmat3x3,
glm::dmat3x3(0.0),
glm::dmat3x3(
nl::lowest(), nl::lowest(), nl::lowest(),
nl::lowest(), nl::lowest(), nl::lowest(),
nl::lowest(), nl::lowest(), nl::lowest()
),
glm::dmat3x3(
nl::max(), nl::max(), nl::max(),
nl::max(), nl::max(), nl::max(),
nl::max(), nl::max(), nl::max()
),
glm::dmat3x3(
0.01, 0.01, 0.01,
0.01, 0.01, 0.01,
0.01, 0.01, 0.01
),
fromLuaConversion,
toLuaConversion,
toStringConversion,
LUA_TTABLE
)
std::string DMat3Property::className() const {
return "DMat3Property";
}
int DMat3Property::typeLua() const {
return LUA_TTABLE;
}
glm::dmat3x3 DMat3Property::fromLuaConversion(lua_State* state, bool& success) const {
return ghoul::lua::tryGetValue<glm::mat3x3>(state, success);
}
} // namespace openspace::properties
-116
View File
@@ -1,116 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <openspace/properties/matrix/dmat3x2property.h>
#include <ghoul/misc/misc.h>
#include <limits>
#include <sstream>
#include <vector>
namespace {
glm::dmat3x2 fromLuaConversion(lua_State* state, bool& success) {
glm::dmat3x2 result;
lua_pushnil(state);
int number = 1;
for (glm::length_t i = 0; i < glm::dmat3x2::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::dmat3x2::col_type::length(); ++j) {
int hasNext = lua_next(state, -2);
if (hasNext != 1) {
success = false;
return glm::dmat3x2(0.0);
}
if (lua_isnumber(state, -1) != 1) {
success = false;
return glm::dmat3x2(0.0);
}
else {
result[i][j] = lua_tonumber(state, -1);
lua_pop(state, 1);
++number;
}
}
}
// The last accessor argument and the table are still on the stack
lua_pop(state, 1);
success = true;
return result;
}
bool toLuaConversion(lua_State* state, glm::dmat3x2 value) {
lua_newtable(state);
int number = 1;
for (glm::length_t i = 0; i < glm::dmat3x2::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::dmat3x2::col_type::length(); ++j) {
lua_pushnumber(state, value[i][j]);
lua_rawseti(state, -2, number);
++number;
}
}
return true;
}
bool toStringConversion(std::string& outValue, glm::dmat3x2 inValue) {
outValue = "[";
for (glm::length_t i = 0; i < glm::dmat3x2::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::dmat3x2::col_type::length(); ++j) {
outValue += std::to_string(inValue[i][j]) + ",";
}
}
outValue.pop_back();
outValue += "]";
return true;
}
} // namespace
namespace openspace::properties {
using nl = std::numeric_limits<double>;
REGISTER_NUMERICALPROPERTY_SOURCE(
DMat3x2Property,
glm::dmat3x2,
glm::dmat3x2(0.0),
glm::dmat3x2(
nl::lowest(), nl::lowest(), nl::lowest(),
nl::lowest(), nl::lowest(), nl::lowest()
),
glm::dmat3x2(
nl::max(), nl::max(), nl::max(),
nl::max(), nl::max(), nl::max()
),
glm::dmat3x2(
0.01, 0.01, 0.01,
0.01, 0.01, 0.01
),
fromLuaConversion,
toLuaConversion,
toStringConversion,
LUA_TTABLE
)
} // namespace openspace::properties
-122
View File
@@ -1,122 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <openspace/properties/matrix/dmat3x4property.h>
#include <ghoul/misc/misc.h>
#include <limits>
#include <sstream>
#include <vector>
namespace {
glm::dmat3x4 fromLuaConversion(lua_State* state, bool& success) {
glm::dmat3x4 result;
lua_pushnil(state);
int number = 1;
for (glm::length_t i = 0; i < glm::dmat3x4::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::dmat3x4::col_type::length(); ++j) {
int hasNext = lua_next(state, -2);
if (hasNext != 1) {
success = false;
return glm::dmat3x4(0.0);
}
if (lua_isnumber(state, -1) != 1) {
success = false;
return glm::dmat3x4(0.0);
}
else {
result[i][j] = lua_tonumber(state, -1);
lua_pop(state, 1);
++number;
}
}
}
// The last accessor argument and the table are still on the stack
lua_pop(state, 1);
success = true;
return result;
}
bool toLuaConversion(lua_State* state, glm::dmat3x4 value) {
lua_newtable(state);
int number = 1;
for (glm::length_t i = 0; i < glm::dmat3x4::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::dmat3x4::col_type::length(); ++j) {
lua_pushnumber(state, value[i][j]);
lua_rawseti(state, -2, number);
++number;
}
}
return true;
}
bool toStringConversion(std::string& outValue, glm::dmat3x4 inValue) {
outValue = "[";
for (glm::length_t i = 0; i < glm::dmat3x4::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::dmat3x4::col_type::length(); ++j) {
outValue += std::to_string(inValue[i][j]) + ",";
}
}
outValue.pop_back();
outValue += "]";
return true;
}
} // namespace
namespace openspace::properties {
using nl = std::numeric_limits<double>;
REGISTER_NUMERICALPROPERTY_SOURCE(
DMat3x4Property,
glm::dmat3x4,
glm::dmat3x4(0.0),
glm::dmat3x4(
nl::lowest(), nl::lowest(), nl::lowest(),
nl::lowest(), nl::lowest(), nl::lowest(),
nl::lowest(), nl::lowest(), nl::lowest(),
nl::lowest(), nl::lowest(), nl::lowest()
),
glm::dmat3x4(
nl::max(), nl::max(), nl::max(),
nl::max(), nl::max(), nl::max(),
nl::max(), nl::max(), nl::max(),
nl::max(), nl::max(), nl::max()
),
glm::dmat3x4(
0.01, 0.01, 0.01,
0.01, 0.01, 0.01,
0.01, 0.01, 0.01,
0.01, 0.01, 0.01
),
fromLuaConversion,
toLuaConversion,
toStringConversion,
LUA_TTABLE
)
} // namespace openspace::properties
+24 -90
View File
@@ -24,99 +24,33 @@
#include <openspace/properties/matrix/dmat4property.h>
#include <ghoul/misc/misc.h>
#include <limits>
#include <sstream>
#include <vector>
namespace {
glm::dmat4x4 fromLuaConversion(lua_State* state, bool& success) {
glm::dmat4x4 result;
lua_pushnil(state);
int number = 1;
for (glm::length_t i = 0; i < glm::dmat4x4::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::dmat4x4::col_type::length(); ++j) {
int hasNext = lua_next(state, -2);
if (hasNext != 1) {
success = false;
return glm::dmat4x4(0.0);
}
if (lua_isnumber(state, -1) != 1) {
success = false;
return glm::dmat4x4(0.0);
}
else {
result[i][j] = lua_tonumber(state, -1);
lua_pop(state, 1);
++number;
}
}
}
// The last accessor argument and the table are still on the stack
lua_pop(state, 1);
success = true;
return result;
}
bool toLuaConversion(lua_State* state, glm::dmat4x4 value) {
lua_newtable(state);
int number = 1;
for (glm::length_t i = 0; i < glm::dmat4x4::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::dmat4x4::col_type::length(); ++j) {
lua_pushnumber(state, value[i][j]);
lua_rawseti(state, -2, number);
++number;
}
}
return true;
}
bool toStringConversion(std::string& outValue, glm::dmat4x4 inValue) {
outValue = "[";
for (glm::length_t i = 0; i < glm::dmat4x4::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::dmat4x4::col_type::length(); ++j) {
outValue += std::to_string(inValue[i][j]) + ",";
}
}
outValue.pop_back();
outValue += "]";
return true;
}
} // namespace
#include <ghoul/lua/ghoul_lua.h>
#include <ghoul/lua/lua_helper.h>
namespace openspace::properties {
using nl = std::numeric_limits<double>;
DMat4Property::DMat4Property(Property::PropertyInfo info, glm::dmat4x4 value,
glm::dmat4x4 minValue, glm::dmat4x4 maxValue,
glm::dmat4x4 stepValue)
: NumericalProperty<glm::dmat4x4>(
std::move(info),
std::move(value),
std::move(minValue),
std::move(maxValue),
std::move(stepValue)
)
{}
REGISTER_NUMERICALPROPERTY_SOURCE(
DMat4Property,
glm::dmat4x4,
glm::dmat4x4(0.0),
glm::dmat4x4(
nl::lowest(), nl::lowest(), nl::lowest(), nl::lowest(),
nl::lowest(), nl::lowest(), nl::lowest(), nl::lowest(),
nl::lowest(), nl::lowest(), nl::lowest(), nl::lowest(),
nl::lowest(), nl::lowest(), nl::lowest(), nl::lowest()
),
glm::dmat4x4(
nl::max(), nl::max(), nl::max(), nl::max(),
nl::max(), nl::max(), nl::max(), nl::max(),
nl::max(), nl::max(), nl::max(), nl::max(),
nl::max(), nl::max(), nl::max(), nl::max()
),
glm::dmat4x4(
0.01, 0.01, 0.01, 0.01,
0.01, 0.01, 0.01, 0.01,
0.01, 0.01, 0.01, 0.01,
0.01, 0.01, 0.01, 0.01
),
fromLuaConversion,
toLuaConversion,
toStringConversion,
LUA_TTABLE
)
std::string DMat4Property::className() const {
return "DMat4Property";
}
int DMat4Property::typeLua() const {
return LUA_TTABLE;
}
glm::dmat4x4 DMat4Property::fromLuaConversion(lua_State* state, bool& success) const {
return ghoul::lua::tryGetValue<glm::dmat4x4>(state, success);
}
} // namespace openspace::properties
-116
View File
@@ -1,116 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <openspace/properties/matrix/dmat4x2property.h>
#include <ghoul/misc/misc.h>
#include <limits>
#include <sstream>
#include <vector>
namespace {
glm::dmat4x2 fromLuaConversion(lua_State* state, bool& success) {
glm::dmat4x2 result;
lua_pushnil(state);
int number = 1;
for (glm::length_t i = 0; i < glm::dmat4x2::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::dmat4x2::col_type::length(); ++j) {
int hasNext = lua_next(state, -2);
if (hasNext != 1) {
success = false;
return glm::dmat4x2(0.0);
}
if (lua_isnumber(state, -1) != 1) {
success = false;
return glm::dmat4x2(0.0);
}
else {
result[i][j] = lua_tonumber(state, -1);
lua_pop(state, 1);
++number;
}
}
}
// The last accessor argument and the table are still on the stack
lua_pop(state, 1);
success = true;
return result;
}
bool toLuaConversion(lua_State* state, glm::dmat4x2 value) {
lua_newtable(state);
int number = 1;
for (glm::length_t i = 0; i < glm::dmat4x2::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::dmat4x2::col_type::length(); ++j) {
lua_pushnumber(state, value[i][j]);
lua_rawseti(state, -2, number);
++number;
}
}
return true;
}
bool toStringConversion(std::string& outValue, glm::dmat4x2 inValue) {
outValue = "[";
for (glm::length_t i = 0; i < glm::dmat4x2::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::dmat4x2::col_type::length(); ++j) {
outValue += std::to_string(inValue[i][j]) + ",";
}
}
outValue.pop_back();
outValue += "]";
return true;
}
} // namespace
namespace openspace::properties {
using nl = std::numeric_limits<double>;
REGISTER_NUMERICALPROPERTY_SOURCE(
DMat4x2Property,
glm::dmat4x2,
glm::dmat4x2(0.0),
glm::dmat4x2(
nl::lowest(), nl::lowest(), nl::lowest(), nl::lowest(),
nl::lowest(), nl::lowest(), nl::lowest(), nl::lowest()
),
glm::dmat4x2(
nl::max(), nl::max(), nl::max(), nl::max(),
nl::max(), nl::max(), nl::max(), nl::max()
),
glm::dmat4x2(
0.01, 0.01, 0.01, 0.01,
0.01, 0.01, 0.01, 0.01
),
fromLuaConversion,
toLuaConversion,
toStringConversion,
LUA_TTABLE
)
} // namespace openspace::properties
-119
View File
@@ -1,119 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <openspace/properties/matrix/dmat4x3property.h>
#include <ghoul/misc/misc.h>
#include <limits>
#include <sstream>
#include <vector>
namespace {
glm::dmat4x3 fromLuaConversion(lua_State* state, bool& success) {
glm::dmat4x3 result;
lua_pushnil(state);
int number = 1;
for (glm::length_t i = 0; i < glm::dmat4x3::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::dmat4x3::col_type::length(); ++j) {
int hasNext = lua_next(state, -2);
if (hasNext != 1) {
success = false;
return glm::dmat4x3(0.0);
}
if (lua_isnumber(state, -1) != 1) {
success = false;
return glm::dmat4x3(0.0);
}
else {
result[i][j] = lua_tonumber(state, -1);
lua_pop(state, 1);
++number;
}
}
}
// The last accessor argument and the table are still on the stack
lua_pop(state, 1);
success = true;
return result;
}
bool toLuaConversion(lua_State* state, glm::dmat4x3 value) {
lua_newtable(state);
int number = 1;
for (glm::length_t i = 0; i < glm::dmat4x3::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::dmat4x3::col_type::length(); ++j) {
lua_pushnumber(state, value[i][j]);
lua_rawseti(state, -2, number);
++number;
}
}
return true;
}
bool toStringConversion(std::string& outValue, glm::dmat4x3 inValue) {
outValue = "[";
for (glm::length_t i = 0; i < glm::dmat4x3::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::dmat4x3::col_type::length(); ++j) {
outValue += std::to_string(inValue[i][j]) + ",";
}
}
outValue.pop_back();
outValue += "]";
return true;
}
} // namespace
namespace openspace::properties {
using nl = std::numeric_limits<double>;
REGISTER_NUMERICALPROPERTY_SOURCE(
DMat4x3Property,
glm::dmat4x3,
glm::dmat4x3(0.0),
glm::dmat4x3(
nl::lowest(), nl::lowest(), nl::lowest(), nl::lowest(),
nl::lowest(), nl::lowest(), nl::lowest(), nl::lowest(),
nl::lowest(), nl::lowest(), nl::lowest(), nl::lowest()
),
glm::dmat4x3(
nl::max(), nl::max(), nl::max(), nl::max(),
nl::max(), nl::max(), nl::max(), nl::max(),
nl::max(), nl::max(), nl::max(), nl::max()
),
glm::dmat4x3(
0.01, 0.01, 0.01, 0.01,
0.01, 0.01, 0.01, 0.01,
0.01, 0.01, 0.01, 0.01
),
fromLuaConversion,
toLuaConversion,
toStringConversion,
LUA_TTABLE
)
} // namespace openspace::properties
+24 -86
View File
@@ -24,95 +24,33 @@
#include <openspace/properties/matrix/mat2property.h>
#include <ghoul/misc/misc.h>
#include <limits>
#include <sstream>
#include <vector>
namespace {
glm::mat2x2 fromLuaConversion(lua_State* state, bool& success) {
glm::mat2x2 result = glm::mat2x2(1.f);
lua_pushnil(state);
int number = 1;
for (glm::length_t i = 0; i < glm::mat2x2::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::mat2x2::col_type::length(); ++j) {
int hasNext = lua_next(state, -2);
if (hasNext != 1) {
success = false;
return glm::mat2x2(1.f);
}
if (lua_isnumber(state, -1) != 1) {
success = false;
return glm::mat2x2(1.f);
}
else {
result[i][j] = static_cast<glm::mat2x2::value_type>(
lua_tonumber(state, -1)
);
lua_pop(state, 1);
++number;
}
}
}
// The last accessor argument and the table are still on the stack
lua_pop(state, 1);
success = true;
return result;
}
bool toLuaConversion(lua_State* state, glm::mat2x2 value) {
lua_newtable(state);
int number = 1;
for (glm::length_t i = 0; i < glm::mat2x2::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::mat2x2::col_type::length(); ++j) {
lua_pushnumber(state, static_cast<lua_Number>(value[i][j]));
lua_rawseti(state, -2, number);
++number;
}
}
return true;
}
bool toStringConversion(std::string& outValue, glm::mat2x2 inValue) {
outValue = "[";
for (glm::length_t i = 0; i < glm::mat2x2::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::mat2x2::col_type::length(); ++j) {
outValue += std::to_string(inValue[i][j]) + ",";
}
}
outValue.pop_back();
outValue += "]";
return true;
}
} // namespace
#include <ghoul/lua/ghoul_lua.h>
#include <ghoul/lua/lua_helper.h>
namespace openspace::properties {
using nl = std::numeric_limits<float>;
Mat2Property::Mat2Property(Property::PropertyInfo info, glm::mat2x2 value,
glm::mat2x2 minValue, glm::mat2x2 maxValue,
glm::mat2x2 stepValue)
: NumericalProperty<glm::mat2x2>(
std::move(info),
std::move(value),
std::move(minValue),
std::move(maxValue),
std::move(stepValue)
)
{}
REGISTER_NUMERICALPROPERTY_SOURCE(
Mat2Property,
glm::mat2x2,
glm::mat2x2(1.f),
glm::mat2x2(
nl::lowest(), nl::lowest(),
nl::lowest(), nl::lowest()
),
glm::mat2x2(
nl::max(), nl::max(),
nl::max(), nl::max()
),
glm::mat2x2(
0.01f, 0.01f,
0.01f, 0.01f
),
fromLuaConversion,
toLuaConversion,
toStringConversion,
LUA_TTABLE
)
std::string Mat2Property::className() const {
return "Mat2Property";
}
int Mat2Property::typeLua() const {
return LUA_TTABLE;
}
glm::mat2x2 Mat2Property::fromLuaConversion(lua_State* state, bool& success) const {
return ghoul::lua::tryGetValue<glm::mat2x2>(state, success);
}
} // namespace openspace::properties
-121
View File
@@ -1,121 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <openspace/properties/matrix/mat2x3property.h>
#include <ghoul/misc/misc.h>
#include <limits>
#include <sstream>
#include <vector>
using std::numeric_limits;
namespace {
glm::mat2x3 fromLuaConversion(lua_State* state, bool& success) {
glm::mat2x3 result = glm::mat2x3(1.f);
lua_pushnil(state);
int number = 1;
for (glm::length_t i = 0; i < glm::mat2x3::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::mat2x3::col_type::length(); ++j) {
int hasNext = lua_next(state, -2);
if (hasNext != 1) {
success = false;
return glm::mat2x3(1.f);
}
if (lua_isnumber(state, -1) != 1) {
success = false;
return glm::mat2x3(1.f);
}
else {
result[i][j]
= static_cast<glm::mat2x3::value_type>(lua_tonumber(state, -1));
lua_pop(state, 1);
++number;
}
}
}
// The last accessor argument and the table are still on the stack
lua_pop(state, 1);
success = true;
return result;
}
bool toLuaConversion(lua_State* state, glm::mat2x3 value) {
lua_newtable(state);
int number = 1;
for (glm::length_t i = 0; i < glm::mat2x3::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::mat2x3::col_type::length(); ++j) {
lua_pushnumber(state, static_cast<lua_Number>(value[i][j]));
lua_rawseti(state, -2, number);
++number;
}
}
return true;
}
bool toStringConversion(std::string& outValue, glm::mat2x3 inValue) {
outValue = "[";
for (glm::length_t i = 0; i < glm::mat2x3::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::mat2x3::col_type::length(); ++j) {
outValue += std::to_string(inValue[i][j]) + ",";
}
}
outValue.pop_back();
outValue += "]";
return true;
}
} // namespace
namespace openspace::properties {
using nl = std::numeric_limits<float>;
REGISTER_NUMERICALPROPERTY_SOURCE(
Mat2x3Property,
glm::mat2x3,
glm::mat2x3(1.f),
glm::mat2x3(
nl::lowest(), nl::lowest(),
nl::lowest(), nl::lowest(),
nl::lowest(), nl::lowest()
),
glm::mat2x3(
nl::max(), nl::max(),
nl::max(), nl::max(),
nl::max(), nl::max()
),
glm::mat2x3(
0.01f, 0.01f, 0.01f,
0.01f, 0.01f, 0.01f
),
fromLuaConversion,
toLuaConversion,
toStringConversion,
LUA_TTABLE
)
} // namespace openspace::properties
-123
View File
@@ -1,123 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <openspace/properties/matrix/mat2x4property.h>
#include <ghoul/misc/misc.h>
#include <limits>
#include <sstream>
#include <vector>
namespace {
glm::mat2x4 fromLuaConversion(lua_State* state, bool& success) {
glm::mat2x4 result = glm::mat2x4(1.f);
lua_pushnil(state);
int number = 1;
for (glm::length_t i = 0; i < glm::mat2x4::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::mat2x4::col_type::length(); ++j) {
int hasNext = lua_next(state, -2);
if (hasNext != 1) {
success = false;
return glm::mat2x4(1.f);
}
if (lua_isnumber(state, -1) != 1) {
success = false;
return glm::mat2x4(1.f);
}
else {
result[i][j]
= static_cast<glm::mat2x4::value_type>(lua_tonumber(state, -1));
lua_pop(state, 1);
++number;
}
}
}
// The last accessor argument and the table are still on the stack
lua_pop(state, 1);
success = true;
return result;
}
bool toLuaConversion(lua_State* state, glm::mat2x4 value) {
lua_newtable(state);
int number = 1;
for (glm::length_t i = 0; i < glm::mat2x4::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::mat2x4::col_type::length(); ++j) {
lua_pushnumber(state, static_cast<lua_Number>(value[i][j]));
lua_rawseti(state, -2, number);
++number;
}
}
return true;
}
bool toStringConversion(std::string& outValue, glm::mat2x4 inValue) {
outValue = "[";
for (glm::length_t i = 0; i < glm::mat2x4::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::mat2x4::col_type::length(); ++j) {
outValue += std::to_string(inValue[i][j]) + ",";
}
}
outValue.pop_back();
outValue += "]";
return true;
}
} // namespace
namespace openspace::properties {
using nl = std::numeric_limits<float>;
REGISTER_NUMERICALPROPERTY_SOURCE(
Mat2x4Property,
glm::mat2x4,
glm::mat2x4(1.f),
glm::mat2x4(
nl::lowest(), nl::lowest(),
nl::lowest(), nl::lowest(),
nl::lowest(), nl::lowest(),
nl::lowest(), nl::lowest()
),
glm::mat2x4(
nl::max(), nl::max(),
nl::max(), nl::max(),
nl::max(), nl::max(),
nl::max(), nl::max()
),
glm::mat2x4(
0.01f, 0.01f,
0.01f, 0.01f,
0.01f, 0.01f,
0.01f, 0.01f
),
fromLuaConversion,
toLuaConversion,
toStringConversion,
LUA_TTABLE
)
} // namespace openspace::properties
+24 -88
View File
@@ -24,97 +24,33 @@
#include <openspace/properties/matrix/mat3property.h>
#include <ghoul/misc/misc.h>
#include <limits>
#include <sstream>
#include <vector>
namespace {
glm::mat3x3 fromLuaConversion(lua_State* state, bool& success) {
glm::mat3x3 result = glm::mat3x3(1.f);
lua_pushnil(state);
int number = 1;
for (glm::length_t i = 0; i < glm::mat3x3::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::mat3x3::col_type::length(); ++j) {
int hasNext = lua_next(state, -2);
if (hasNext != 1) {
success = false;
return glm::mat3x3(1.f);
}
if (lua_isnumber(state, -1) != 1) {
success = false;
return glm::mat3x3(1.f);
}
else {
result[i][j]
= static_cast<glm::mat3x3::value_type>(lua_tonumber(state, -1));
lua_pop(state, 1);
++number;
}
}
}
// The last accessor argument and the table are still on the stack
lua_pop(state, 1);
success = true;
return result;
}
bool toLuaConversion(lua_State* state, glm::mat3x3 value) {
lua_newtable(state);
int number = 1;
for (glm::length_t i = 0; i < glm::mat3x3::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::mat3x3::col_type::length(); ++j) {
lua_pushnumber(state, static_cast<lua_Number>(value[i][j]));
lua_rawseti(state, -2, number);
++number;
}
}
return true;
}
bool toStringConversion(std::string& outValue, glm::mat3x3 inValue) {
outValue = "[";
for (glm::length_t i = 0; i < glm::mat3x3::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::mat3x3::col_type::length(); ++j) {
outValue += std::to_string(inValue[i][j]) + ",";
}
}
outValue.pop_back();
outValue += "]";
return true;
}
} // namespace
#include <ghoul/lua/ghoul_lua.h>
#include <ghoul/lua/lua_helper.h>
namespace openspace::properties {
using nl = std::numeric_limits<float>;
Mat3Property::Mat3Property(Property::PropertyInfo info, glm::mat3x3 value,
glm::mat3x3 minValue, glm::mat3x3 maxValue,
glm::mat3x3 stepValue)
: NumericalProperty<glm::mat3x3>(
std::move(info),
std::move(value),
std::move(minValue),
std::move(maxValue),
std::move(stepValue)
)
{}
REGISTER_NUMERICALPROPERTY_SOURCE(
Mat3Property,
glm::mat3x3,
glm::mat3x3(1.f),
glm::mat3x3(
nl::lowest(), nl::lowest(), nl::lowest(),
nl::lowest(), nl::lowest(), nl::lowest(),
nl::lowest(), nl::lowest(), nl::lowest()
),
glm::mat3x3(
nl::max(), nl::max(), nl::max(),
nl::max(), nl::max(), nl::max(),
nl::max(), nl::max(), nl::max()
),
glm::mat3x3(
0.01f, 0.01f, 0.01f,
0.01f, 0.01f, 0.01f,
0.01f, 0.01f, 0.01f
),
fromLuaConversion,
toLuaConversion,
toStringConversion,
LUA_TTABLE
)
std::string Mat3Property::className() const {
return "Mat3Property";
}
int Mat3Property::typeLua() const {
return LUA_TTABLE;
}
glm::mat3x3 Mat3Property::fromLuaConversion(lua_State* state, bool& success) const {
return ghoul::lua::tryGetValue<glm::mat3x3>(state, success);
}
} // namespace openspace::properties
-117
View File
@@ -1,117 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <openspace/properties/matrix/mat3x2property.h>
#include <ghoul/misc/misc.h>
#include <limits>
#include <sstream>
#include <vector>
namespace {
glm::mat3x2 fromLuaConversion(lua_State* state, bool& success) {
glm::mat3x2 result = glm::mat3x2(1.f);
lua_pushnil(state);
int number = 1;
for (glm::length_t i = 0; i < glm::mat3x2::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::mat3x2::col_type::length(); ++j) {
int hasNext = lua_next(state, -2);
if (hasNext != 1) {
success = false;
return glm::mat3x2(0.f);
}
if (lua_isnumber(state, -1) != 1) {
success = false;
return glm::mat3x2(0.f);
}
else {
result[i][j]
= static_cast<glm::mat3x2::value_type>(lua_tonumber(state, -1));
lua_pop(state, 1);
++number;
}
}
}
// The last accessor argument and the table are still on the stack
lua_pop(state, 1);
success = true;
return result;
}
bool toLuaConversion(lua_State* state, glm::mat3x2 value) {
lua_newtable(state);
int number = 1;
for (glm::length_t i = 0; i < glm::mat3x2::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::mat3x2::col_type::length(); ++j) {
lua_pushnumber(state, static_cast<lua_Number>(value[i][j]));
lua_rawseti(state, -2, number);
++number;
}
}
return true;
}
bool toStringConversion(std::string& outValue, glm::mat3x2 inValue) {
outValue = "[";
for (glm::length_t i = 0; i < glm::mat3x2::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::mat3x2::col_type::length(); ++j) {
outValue += std::to_string(inValue[i][j]) + ",";
}
}
outValue.pop_back();
outValue += "]";
return true;
}
} // namespace
namespace openspace::properties {
using nl = std::numeric_limits<float>;
REGISTER_NUMERICALPROPERTY_SOURCE(
Mat3x2Property,
glm::mat3x2,
glm::mat3x2(1.f),
glm::mat3x2(
nl::lowest(), nl::lowest(), nl::lowest(),
nl::lowest(), nl::lowest(), nl::lowest()
),
glm::mat3x2(
nl::max(), nl::max(), nl::max(),
nl::max(), nl::max(), nl::max()
),
glm::mat3x2(
0.01f, 0.01f, 0.01f,
0.01f, 0.01f, 0.01f
),
fromLuaConversion,
toLuaConversion,
toStringConversion,
LUA_TTABLE
)
} // namespace openspace::properties
-123
View File
@@ -1,123 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <openspace/properties/matrix/mat3x4property.h>
#include <ghoul/misc/misc.h>
#include <limits>
#include <sstream>
#include <vector>
namespace {
glm::mat3x4 fromLuaConversion(lua_State* state, bool& success) {
glm::mat3x4 result = glm::mat3x4(1.f);
lua_pushnil(state);
int number = 1;
for (glm::length_t i = 0; i < glm::mat3x4::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::mat3x4::col_type::length(); ++j) {
int hasNext = lua_next(state, -2);
if (hasNext != 1) {
success = false;
return glm::mat3x4(1.f);
}
if (lua_isnumber(state, -1) != 1) {
success = false;
return glm::mat3x4(1.f);
}
else {
result[i][j]
= static_cast<glm::mat3x4::value_type>(lua_tonumber(state, -1));
lua_pop(state, 1);
++number;
}
}
}
// The last accessor argument and the table are still on the stack
lua_pop(state, 1);
success = true;
return result;
}
bool toLuaConversion(lua_State* state, glm::mat3x4 value) {
lua_newtable(state);
int number = 1;
for (glm::length_t i = 0; i < glm::mat3x4::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::mat3x4::col_type::length(); ++j) {
lua_pushnumber(state, static_cast<lua_Number>(value[i][j]));
lua_rawseti(state, -2, number);
++number;
}
}
return true;
}
bool toStringConversion(std::string& outValue, glm::mat3x4 inValue) {
outValue = "[";
for (glm::length_t i = 0; i < glm::mat3x4::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::mat3x4::col_type::length(); ++j) {
outValue += std::to_string(inValue[i][j]) + ",";
}
}
outValue.pop_back();
outValue += "]";
return true;
}
} // namespace
namespace openspace::properties {
using nl = std::numeric_limits<float>;
REGISTER_NUMERICALPROPERTY_SOURCE(
Mat3x4Property,
glm::mat3x4,
glm::mat3x4(1.f),
glm::mat3x4(
nl::lowest(), nl::lowest(), nl::lowest(),
nl::lowest(), nl::lowest(), nl::lowest(),
nl::lowest(), nl::lowest(), nl::lowest(),
nl::lowest(), nl::lowest(), nl::lowest()
),
glm::mat3x4(
nl::max(), nl::max(), nl::max(),
nl::max(), nl::max(), nl::max(),
nl::max(), nl::max(), nl::max(),
nl::max(), nl::max(), nl::max()
),
glm::mat3x4(
0.01f, 0.01f, 0.01f,
0.01f, 0.01f, 0.01f,
0.01f, 0.01f, 0.01f,
0.01f, 0.01f, 0.01f
),
fromLuaConversion,
toLuaConversion,
toStringConversion,
LUA_TTABLE
)
} // namespace openspace::properties
+24 -93
View File
@@ -24,102 +24,33 @@
#include <openspace/properties/matrix/mat4property.h>
#include <ghoul/misc/misc.h>
#include <limits>
#include <sstream>
#include <vector>
using std::numeric_limits;
namespace {
glm::mat4x4 fromLuaConversion(lua_State* state, bool& success) {
glm::mat4x4 result = glm::mat4x4(1.f);
lua_pushnil(state);
int number = 1;
for (glm::length_t i = 0; i < glm::mat4x4::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::mat4x4::col_type::length(); ++j) {
int hasNext = lua_next(state, -2);
if (hasNext != 1) {
success = false;
return glm::mat4x4(1.f);
}
if (lua_isnumber(state, -1) != 1) {
success = false;
return glm::mat4x4(1.f);
}
else {
result[i][j]
= static_cast<glm::mat4x4::value_type>(lua_tonumber(state, -1));
lua_pop(state, 1);
++number;
}
}
}
// The last accessor argument and the table are still on the stack
lua_pop(state, 1);
success = true;
return result;
}
bool toLuaConversion(lua_State* state, glm::mat4x4 value) {
lua_newtable(state);
int number = 1;
for (glm::length_t i = 0; i < glm::mat4x4::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::mat4x4::col_type::length(); ++j) {
lua_pushnumber(state, static_cast<lua_Number>(value[i][j]));
lua_rawseti(state, -2, number);
++number;
}
}
return true;
}
bool toStringConversion(std::string& outValue, glm::mat4x4 inValue) {
outValue = "[";
for (glm::length_t i = 0; i < glm::mat4x4::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::mat4x4::col_type::length(); ++j) {
outValue += std::to_string(inValue[i][j]) + ",";
}
}
outValue.pop_back();
outValue += "]";
return true;
}
} // namespace
#include <ghoul/lua/ghoul_lua.h>
#include <ghoul/lua/lua_helper.h>
namespace openspace::properties {
using nl = std::numeric_limits<float>;
Mat4Property::Mat4Property(Property::PropertyInfo info, glm::mat4x4 value,
glm::mat4x4 minValue, glm::mat4x4 maxValue,
glm::mat4x4 stepValue)
: NumericalProperty<glm::mat4x4>(
std::move(info),
std::move(value),
std::move(minValue),
std::move(maxValue),
std::move(stepValue)
)
{}
REGISTER_NUMERICALPROPERTY_SOURCE(
Mat4Property,
glm::mat4x4,
glm::mat4x4(1.f),
glm::mat4x4(
nl::lowest(), nl::lowest(), nl::lowest(), nl::lowest(),
nl::lowest(), nl::lowest(), nl::lowest(), nl::lowest(),
nl::lowest(), nl::lowest(), nl::lowest(), nl::lowest(),
nl::lowest(), nl::lowest(), nl::lowest(), nl::lowest()
),
glm::mat4x4(
nl::max(), nl::max(), nl::max(), nl::max(),
nl::max(), nl::max(), nl::max(), nl::max(),
nl::max(), nl::max(), nl::max(), nl::max(),
nl::max(), nl::max(), nl::max(), nl::max()
),
glm::mat4x4(
0.01f, 0.01f, 0.01f, 0.01f,
0.01f, 0.01f, 0.01f, 0.01f,
0.01f, 0.01f, 0.01f, 0.01f,
0.01f, 0.01f, 0.01f, 0.01f
),
fromLuaConversion,
toLuaConversion,
toStringConversion,
LUA_TTABLE
)
std::string Mat4Property::className() const {
return "Mat4Property";
}
int Mat4Property::typeLua() const {
return LUA_TTABLE;
}
glm::mat4x4 Mat4Property::fromLuaConversion(lua_State* state, bool& success) const {
return ghoul::lua::tryGetValue<glm::mat4x4>(state, success);
}
} // namespace openspace::properties
-117
View File
@@ -1,117 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <openspace/properties/matrix/mat4x2property.h>
#include <ghoul/misc/misc.h>
#include <limits>
#include <sstream>
#include <vector>
namespace {
glm::mat4x2 fromLuaConversion(lua_State* state, bool& success) {
glm::mat4x2 result = glm::mat4x2(1.f);
lua_pushnil(state);
int number = 1;
for (glm::length_t i = 0; i < glm::mat4x2::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::mat4x2::col_type::length(); ++j) {
int hasNext = lua_next(state, -2);
if (hasNext != 1) {
success = false;
return glm::mat4x2(1.f);
}
if (lua_isnumber(state, -1) != 1) {
success = false;
return glm::mat4x2(1.f);
}
else {
result[i][j]
= static_cast<glm::mat4x2::value_type>(lua_tonumber(state, -1));
lua_pop(state, 1);
++number;
}
}
}
// The last accessor argument and the table are still on the stack
lua_pop(state, 1);
success = true;
return result;
}
bool toLuaConversion(lua_State* state, glm::mat4x2 value) {
lua_newtable(state);
int number = 1;
for (glm::length_t i = 0; i < glm::mat4x2::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::mat4x2::col_type::length(); ++j) {
lua_pushnumber(state, static_cast<lua_Number>(value[i][j]));
lua_rawseti(state, -2, number);
++number;
}
}
return true;
}
bool toStringConversion(std::string& outValue, glm::mat4x2 inValue) {
outValue = "[";
for (glm::length_t i = 0; i < glm::mat4x2::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::mat4x2::col_type::length(); ++j) {
outValue += std::to_string(inValue[i][j]) + ",";
}
}
outValue.pop_back();
outValue += "]";
return true;
}
} // namespace
namespace openspace::properties {
using nl = std::numeric_limits<float>;
REGISTER_NUMERICALPROPERTY_SOURCE(
Mat4x2Property,
glm::mat4x2,
glm::mat4x2(1.f),
glm::mat4x2(
nl::lowest(), nl::lowest(), nl::lowest(), nl::lowest(),
nl::lowest(), nl::lowest(), nl::lowest(), nl::lowest()
),
glm::mat4x2(
nl::max(), nl::max(), nl::max(), nl::max(),
nl::max(), nl::max(), nl::max(), nl::max()
),
glm::mat4x2(
0.01f, 0.01f, 0.01f, 0.01f,
0.01f, 0.01f, 0.01f, 0.01f
),
fromLuaConversion,
toLuaConversion,
toStringConversion,
LUA_TTABLE
)
} // namespace openspace::properties
-120
View File
@@ -1,120 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014-2021 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#include <openspace/properties/matrix/mat4x3property.h>
#include <ghoul/misc/misc.h>
#include <limits>
#include <sstream>
#include <vector>
namespace {
glm::mat4x3 fromLuaConversion(lua_State* state, bool& success) {
glm::mat4x3 result = glm::mat4x3(1.f);
lua_pushnil(state);
int number = 1;
for (glm::length_t i = 0; i < glm::mat4x3::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::mat4x3::col_type::length(); ++j) {
int hasNext = lua_next(state, -2);
if (hasNext != 1) {
success = false;
return glm::mat4x3(1.f);
}
if (lua_isnumber(state, -1) != 1) {
success = false;
return glm::mat4x3(1.f);
}
else {
result[i][j]
= static_cast<glm::mat4x3::value_type>(lua_tonumber(state, -1));
lua_pop(state, 1);
++number;
}
}
}
// The last accessor argument and the table are still on the stack
lua_pop(state, 1);
success = true;
return result;
}
bool toLuaConversion(lua_State* state, glm::mat4x3 value) {
lua_newtable(state);
int number = 1;
for (glm::length_t i = 0; i < glm::mat4x3::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::mat4x3::col_type::length(); ++j) {
lua_pushnumber(state, static_cast<lua_Number>(value[i][j]));
lua_rawseti(state, -2, number);
++number;
}
}
return true;
}
bool toStringConversion(std::string& outValue, glm::mat4x3 inValue) {
outValue = "[";
for (glm::length_t i = 0; i < glm::mat4x3::row_type::length(); ++i) {
for (glm::length_t j = 0; j < glm::mat4x3::col_type::length(); ++j) {
outValue += std::to_string(inValue[i][j]) + ",";
}
}
outValue.pop_back();
outValue += "]";
return true;
}
} // namespace
namespace openspace::properties {
using nl = std::numeric_limits<float>;
REGISTER_NUMERICALPROPERTY_SOURCE(
Mat4x3Property,
glm::mat4x3,
glm::mat4x3(1.f),
glm::mat4x3(
nl::lowest(), nl::lowest(), nl::lowest(), nl::lowest(),
nl::lowest(), nl::lowest(), nl::lowest(), nl::lowest(),
nl::lowest(), nl::lowest(), nl::lowest(), nl::lowest()
),
glm::mat4x3(
nl::max(), nl::max(), nl::max(), nl::max(),
nl::max(), nl::max(), nl::max(), nl::max(),
nl::max(), nl::max(), nl::max(), nl::max()
),
glm::mat4x3(
0.01f, 0.01f, 0.01f, 0.01f,
0.01f, 0.01f, 0.01f, 0.01f,
0.01f, 0.01f, 0.01f, 0.01f
),
fromLuaConversion,
toLuaConversion,
toStringConversion,
LUA_TTABLE
)
} // namespace openspace::properties
+1
View File
@@ -23,6 +23,7 @@
****************************************************************************************/
#include <openspace/properties/property.h>
#include <openspace/properties/propertyowner.h>
#include <ghoul/logging/logmanager.h>
#include <ghoul/lua/ghoul_lua.h>
+1 -26
View File
@@ -26,6 +26,7 @@
#include <openspace/properties/property.h>
#include <openspace/scene/scene.h>
#include <openspace/util/json_helper.h>
#include <ghoul/fmt.h>
#include <ghoul/logging/logmanager.h>
#include <ghoul/misc/assert.h>
@@ -36,32 +37,6 @@
namespace {
constexpr const char* _loggerCat = "PropertyOwner";
std::string escapedJson(const std::string& text) {
std::string jsonString;
for (const char& c : text) {
switch (c) {
case '\t':
jsonString += "\\t"; // Replace tab with \t.
break;
case '"':
jsonString += "\\\""; // Replace " with \".
break;
case '\\':
jsonString += "\\\\"; // Replace \ with \\.
break;
case '\n':
jsonString += "\\\\n"; // Replace newline with \n.
break;
case '\r':
jsonString += "\\r"; // Replace carriage return with \r.
break;
default:
jsonString += c;
}
}
return jsonString;
}
void createJson(openspace::properties::PropertyOwner* owner, std::vector<char>& buf) {
ZoneScoped
+25 -36
View File
@@ -25,44 +25,33 @@
#include <openspace/properties/scalar/boolproperty.h>
#include <ghoul/lua/ghoul_lua.h>
#include <limits>
#include <sstream>
namespace {
bool fromLuaConversion(lua_State* state, bool& success) {
success = (lua_isboolean(state, -1) == 1);
if (success) {
return lua_toboolean(state, -1) == 1;
}
else {
return false;
}
}
bool toLuaConversion(lua_State* state, bool value) {
lua_pushboolean(state, value);
return true;
}
bool toStringConversion(std::string& outValue, bool inValue) {
outValue = inValue ? "true" : "false";
return true;
}
} // namespace
#include <ghoul/lua/lua_helper.h>
namespace openspace::properties {
REGISTER_TEMPLATEPROPERTY_SOURCE(
BoolProperty,
bool,
false,
fromLuaConversion,
toLuaConversion,
toStringConversion,
LUA_TBOOLEAN
)
BoolProperty::BoolProperty(Property::PropertyInfo info, bool value)
: TemplateProperty<bool>(std::move(info), value)
{}
std::string BoolProperty::className() const {
return "BoolProperty";
}
int BoolProperty::typeLua() const {
return LUA_TBOOLEAN;
}
bool BoolProperty::fromLuaConversion(lua_State* state, bool& success) const {
success = (lua_isboolean(state, -1) == 1);
return success ? (lua_toboolean(state, -1) == 1) : false;
}
void BoolProperty::toLuaConversion(lua_State* state) const {
ghoul::lua::push(state, _value);
}
std::string BoolProperty::toStringConversion() const {
return _value ? "true" : "false";
}
} // namespace openspace::properties
+14 -31
View File
@@ -26,12 +26,22 @@
#include <ghoul/lua/ghoul_lua.h>
#include <limits>
#include <sstream>
namespace openspace::properties {
namespace {
DoubleProperty::DoubleProperty(Property::PropertyInfo info, double value,
double minValue, double maxValue, double stepValue)
: NumericalProperty<double>(std::move(info), value, minValue, maxValue, stepValue)
{}
double fromLuaConversion(lua_State* state, bool& success) {
std::string DoubleProperty::className() const {
return "DoubleProperty";
}
int DoubleProperty::typeLua() const {
return LUA_TNUMBER;
}
double DoubleProperty::fromLuaConversion(lua_State* state, bool& success) const {
success = (lua_isnumber(state, -1) == 1);
if (success) {
double val = lua_tonumber(state, -1);
@@ -42,31 +52,4 @@ double fromLuaConversion(lua_State* state, bool& success) {
}
}
bool toLuaConversion(lua_State* state, double value) {
lua_pushnumber(state, value);
return true;
}
bool toStringConversion(std::string& outValue, double inValue) {
outValue = std::to_string(inValue);
return true;
}
} // namespace
namespace openspace::properties {
REGISTER_NUMERICALPROPERTY_SOURCE(
DoubleProperty,
double,
0.0,
std::numeric_limits<double>::lowest(),
std::numeric_limits<double>::max(),
0.01,
fromLuaConversion,
toLuaConversion,
toStringConversion,
LUA_TNUMBER
)
} // namespace openspace::properties

Some files were not shown because too many files have changed in this diff Show More