Merge branch 'master' into thesis/2021/skybrowser

This commit is contained in:
Ylva Selling
2021-04-30 10:17:13 +02:00
744 changed files with 27135 additions and 25881 deletions
@@ -191,6 +191,17 @@ struct DirectoryVerifier : public StringVerifier {
std::string type() const override;
};
/**
* A Verifier that checks whether a given key inside a ghoul::Dictionary is a string and
* a valid date time
*/
struct DateTimeVerifier : public StringVerifier {
TestResult operator()(const ghoul::Dictionary& dict,
const std::string& key) const override;
std::string type() const override;
};
/**
* A Verifier that checks whether a given key inside a ghoul::Dictionary is another
* ghoul::Dictionary. The constructor takes a list of DocumentationEntry%s, which are used
@@ -0,0 +1,65 @@
/*****************************************************************************************
* *
* 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___DOUBLELISTPROPERTY___H__
#define __OPENSPACE_CORE___DOUBLELISTPROPERTY___H__
#include <openspace/properties/listproperty.h>
namespace openspace::properties {
class DoubleListProperty : public ListProperty<double> {
public:
DoubleListProperty(Property::PropertyInfo info);
DoubleListProperty(Property::PropertyInfo info, std::vector<double> values);
using TemplateProperty<std::vector<double>>::operator std::vector<double>;
using TemplateProperty<std::vector<double>>::operator=;
};
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__
@@ -0,0 +1,64 @@
/*****************************************************************************************
* *
* 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___INTLISTPROPERTY___H__
#define __OPENSPACE_CORE___INTLISTPROPERTY___H__
#include <openspace/properties/listproperty.h>
namespace openspace::properties {
class IntListProperty : public ListProperty<int> {
public:
IntListProperty(Property::PropertyInfo info);
IntListProperty(Property::PropertyInfo info, std::vector<int> values);
using TemplateProperty<std::vector<int>>::operator std::vector<int>;
using TemplateProperty<std::vector<int>>::operator=;
};
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__
@@ -0,0 +1,66 @@
/*****************************************************************************************
* *
* 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___STRINGLISTPROPERTY___H__
#define __OPENSPACE_CORE___STRINGLISTPROPERTY___H__
#include <openspace/properties/listproperty.h>
#include <string>
namespace openspace::properties {
class StringListProperty : public ListProperty<std::string> {
public:
StringListProperty(Property::PropertyInfo info);
StringListProperty(Property::PropertyInfo info, std::vector<std::string> values);
using TemplateProperty<std::vector<std::string>>::operator std::vector<std::string>;
using TemplateProperty<std::vector<std::string>>::operator=;
};
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__
@@ -0,0 +1,46 @@
/*****************************************************************************************
* *
* 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___LISTPROPERTY___H__
#define __OPENSPACE_CORE___LISTPROPERTY___H__
#include <openspace/properties/templateproperty.h>
#include <vector>
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;
};
} // namespace openspace::properties
#include "openspace/properties/listproperty.inl"
#endif // __OPENSPACE_CORE___LISTPROPERTY___H__
@@ -22,18 +22,20 @@
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
#ifndef __OPENSPACE_CORE___STRINGLISTPROPERTY___H__
#define __OPENSPACE_CORE___STRINGLISTPROPERTY___H__
#include <openspace/properties/templateproperty.h>
#include <string>
#include <vector>
namespace openspace::properties {
REGISTER_TEMPLATEPROPERTY_HEADER(StringListProperty, std::vector<std::string>)
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))
{}
template <typename T>
ListProperty<T>::~ListProperty() {}
} // namespace openspace::properties
#endif // __OPENSPACE_CORE___STRINGLISTPROPERTY___H__
@@ -46,7 +46,6 @@ public:
int typeLua() const override;
bool getStringValue(std::string& value) const override;
bool setStringValue(std::string value) override;
T minValue() const;
void setMinValue(T value);
@@ -66,10 +65,8 @@ public:
using TemplateProperty<T>::operator=;
void setInterpolationTarget(std::any value) override;
void setLuaInterpolationTarget(lua_State* state) override;
void setStringInterpolationTarget(std::string value) override;
void interpolateValue(float t,
ghoul::EasingFunc<float> easingFunc = nullptr) override;
@@ -75,16 +75,6 @@ namespace openspace::properties {
\
template <> \
template <> \
TYPE PropertyDelegate<TemplateProperty<TYPE>>::fromString(const std::string& value, \
bool& success); \
\
template <> \
template <> \
TYPE PropertyDelegate<NumericalProperty<TYPE>>::fromString(const std::string& value, \
bool& success); \
\
template <> \
template <> \
bool PropertyDelegate<TemplateProperty<TYPE>>::toString(std::string& outValue, \
const TYPE& inValue); \
\
@@ -98,7 +88,6 @@ namespace openspace::properties {
DEFAULT_MIN_VALUE, DEFAULT_MAX_VALUE, \
DEFAULT_STEPPING, FROM_LUA_LAMBDA_EXPRESSION, \
TO_LUA_LAMBDA_EXPRESSION, \
FROM_STRING_LAMBDA_EXPRESSION, \
TO_STRING_LAMBDA_EXPRESSION, LUA_TYPE) \
template <> \
std::string PropertyDelegate<TemplateProperty<TYPE>>::className() \
@@ -187,25 +176,6 @@ namespace openspace::properties {
\
template <> \
template <> \
TYPE PropertyDelegate<TemplateProperty<TYPE>>::fromString(const std::string& value, \
bool& success) \
{ \
return FROM_STRING_LAMBDA_EXPRESSION(value, success); \
} \
\
template <> \
template <> \
TYPE PropertyDelegate<NumericalProperty<TYPE>>::fromString(const std::string& value, \
bool& success) \
{ \
return PropertyDelegate<TemplateProperty<TYPE>>::fromString<TYPE>( \
value, \
success \
); \
} \
\
template <> \
template <> \
bool PropertyDelegate<TemplateProperty<TYPE>>::toString(std::string& outValue, \
const TYPE& inValue) \
{ \
@@ -336,18 +306,6 @@ bool NumericalProperty<T>::getStringValue(std::string& value) const {
return success;
}
template <typename T>
bool NumericalProperty<T>::setStringValue(std::string value) {
bool success = false;
T thisValue = PropertyDelegate<NumericalProperty<T>>::template fromString<T>(
value, success
);
if (success) {
TemplateProperty<T>::set(std::any(std::move(thisValue)));
}
return success;
}
template <typename T>
T NumericalProperty<T>::minValue() const {
return _minimumValue;
@@ -442,19 +400,6 @@ void NumericalProperty<T>::setLuaInterpolationTarget(lua_State* state) {
}
}
template <typename T>
void NumericalProperty<T>::setStringInterpolationTarget(std::string value) {
bool success = false;
T thisValue = PropertyDelegate<NumericalProperty<T>>::template fromString<T>(
value,
success
);
if (success) {
_interpolationStart = TemplateProperty<T>::_value;
_interpolationEnd = std::move(thisValue);
}
}
template <typename T>
void NumericalProperty<T>::interpolateValue(float t,
ghoul::EasingFunc<float> easingFunction)
+11 -27
View File
@@ -44,8 +44,7 @@ class PropertyOwner;
* used as a URI. This class is an abstract base class and each subclass (most notable
* TemplateProperty) needs to implement the methods Property::className, Property::get,
* Property::set, Property::type(), Property::getLuaValue, Property::setLuaValue,
* Property::getStringValue, Property::setStringValue and Property::typeLua to make full
* use of the infrastructure.
* Property::getStringValue, and Property::typeLua to make full use of the infrastructure.
* The most common types can be implemented by creating a specialized instantiation of
* TemplateProperty, which provides default implementations for these methods.
*
@@ -217,8 +216,7 @@ public:
/**
* This method encodes the encapsulated \p value of this Property as a
* <code>std::string</code>. The specific details of this serialization is up to the
* property developer. The implementation has to be synchronized with the
* Property::setStringValue method. The default implementation is a no-op.
* property developer. The default implementation is a no-op.
*
* \param value The value to which the Property will be encoded
* \return \p true if the encoding succeeded, \p false otherwise
@@ -235,18 +233,6 @@ public:
*/
std::string getStringValue() const;
/**
* This method sets the value encapsulated by this Property by deserializing the
* passed <code>std::string</code>. The specific details of the deserialization are up
* to the Property developer. The implementation has to be synchronized with the
* Property::getLuaValue method. The default implementation is a no-op.
*
* \param value The value from which the Property will be decoded
* \return \c true if the decoding and setting of the value succeeded, \c false
* otherwise
*/
virtual bool setStringValue(std::string value);
/**
* This method registers a \p callback function that will be called every time if
* either Property:set or Property::setLuaValue was called with a value that is
@@ -385,9 +371,9 @@ public:
/**
* This method determines if this Property should be read-only in external
* applications. This setting is only a hint and does not need to be followed by GUI
* applications and does not have any effect on the Property::set,
* Property::setLuaValue, or Property::setStringValue methods. The value is stored in
* the metaData Dictionary with the key: \c isReadOnly. The default value is \c false.
* applications and does not have any effect on the Property::set or
* Property::setLuaValue methods. The value is stored in the metaData Dictionary
* with the key: \c isReadOnly. The default value is \c false.
*
* \param state \c true if the Property should be read only, \c false otherwise
*/
@@ -395,22 +381,21 @@ public:
/**
* Default view options that can be used in the Property::setViewOption method. The
* values are: Property::ViewOptions::Color = \c color,
* Property::ViewOptions::LightPosition = \c lightPosition
* values are: Property::ViewOptions::Color = \c Color,
* Property::ViewOptions::Logarithmic = \c Logarithmic
*/
struct ViewOptions {
static const char* Color;
static const char* LightPosition;
static const char* Logarithmic;
};
/**
* This method allows the developer to give hints to the GUI about different
* representations for the GUI. The same Property (for example Vec4Property) can be
* used in different ways, each requiring a different input method. These values are
* stored in the metaData object using the <code>views.</code> prefix in front of the
* <code>option</code> parameter. See Property::ViewOptions for a default list of
* possible options. As these are only hints, the GUI is free to ignore any suggestion
* by the developer.
* stored in the metaData object under <code>ViewOptions</code>.
* See Property::ViewOptions for a default list of possible options. As these are
* only hints, the GUI is free to ignore any suggestion by the developer.
* \param option The view option that should be modified
* \param value Determines if the view option should be active (<code>true</code>) or
* deactivated (<code>false</code>)
@@ -456,7 +441,6 @@ public:
/// Interpolation methods
virtual void setInterpolationTarget(std::any value);
virtual void setLuaInterpolationTarget(lua_State* state);
virtual void setStringInterpolationTarget(std::string value);
virtual void interpolateValue(float t,
ghoul::EasingFunc<float> easingFunction = nullptr);
@@ -150,9 +150,6 @@ public:
*/
static int typeLua();
template <typename U>
static U fromString(const std::string& value, bool& success);
template <typename U>
static bool toString(std::string& outValue, const U& inValue);
};
@@ -91,11 +91,4 @@ bool PropertyDelegate<T>::toString(std::string&, const U&) {
return false;
}
template <typename T>
template <typename U>
U PropertyDelegate<T>::fromString(const std::string&, bool&) {
static_assert(sizeof(T) == 0,
"Unimplemented PropertyDelegate::fromString specialization");
}
} // namespace openspace::properties
@@ -27,62 +27,120 @@
#include <openspace/properties/templateproperty.h>
#include <set>
#include <vector>
namespace openspace::properties {
class SelectionProperty : public TemplateProperty<std::vector<int>> {
public:
struct Option {
int value;
std::string description;
};
class SelectionProperty : public TemplateProperty<std::set<std::string>> {
public:
SelectionProperty(Property::PropertyInfo info);
void addOption(Option option);
void removeOptions();
const std::vector<Option>& options() const;
/**
* 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
* invalid keys in the input set. A key is invalid if it does not correspond to
* an existing option in the SelectionProperty
*
* \param val The new value for this SelectionProperty
*/
void setValue(std::set<std::string> val) override;
using TemplateProperty<std::vector<int>>::operator std::vector<int>;
/**
* Checks if an option given by the provided <code>key</code> exists.
*
* \param key The key that should be checked for existence
* \return \c if the option exists; \c false otherwise
*/
bool hasOption(const std::string& key) const;
using TemplateProperty<std::vector<int>>::operator=;
/**
* Checks if an option given by the provided <code>key</code> is selected.
*
* \param key The key that should be checked
* \return \c true if the option is selected; \c false otherwise
*/
bool isSelected(const std::string& key) const;
/**
* Checks if the SelectionProperty has any selected values, that is, if its
* value is empty.
*
* \return \c true if there are selected options; \c false otherwise
*/
bool hasSelected() const;
/**
* Returns all available options for this SelectionProperty. Should be
* sorted alphabetically.
*
* \return A list of all available options
*/
const std::vector<std::string>& options() const;
/**
* This method sets all available options at once, removing any potential duplicates.
* If a selection exists, it is updated to that any selected option that does not
* match the new set of options is removed.
*
* \param keys The keys for the options to be set
*/
void setOptions(const std::vector<std::string>& keys);
/**
* Adds an individual option, if it did not already exist.
*
* \param key The key for the option to be added
*/
void addOption(const std::string& key);
/**
* This method clears the selection list, that is the value of this SelectionProperty
*/
void clearSelection();
/**
* This method clears the options list. As the selection must match the available
* options, the selection list is cleared as well.
*/
void clearOptions();
using TemplateProperty<std::set<std::string>>::operator std::set<std::string>;
using TemplateProperty<std::set<std::string>>::operator=;
private:
static const std::string OptionsKey;
void sortOptions();
bool removeInvalidKeys(std::set<std::string>& keys);
std::string generateAdditionalJsonDescription() const override;
/// The list of options which have been registered with this OptionProperty
std::vector<Option> _options;
std::vector<int> _values;
// A list of all available options that can be selected
std::vector<std::string> _options;
};
template <>
std::string PropertyDelegate<TemplateProperty<std::vector<int>>>::className();
std::string PropertyDelegate<TemplateProperty<std::set<std::string>>>::className();
template <>
template <>
std::vector<int> PropertyDelegate<TemplateProperty<std::vector<int>>>::fromLuaValue(
lua_State* state, bool& success);
std::set<std::string>
PropertyDelegate<TemplateProperty<std::set<std::string>>>::fromLuaValue(lua_State* state,
bool& success);
template <>
template <>
bool PropertyDelegate<TemplateProperty<std::vector<int>>>::toLuaValue(lua_State* state,
const std::vector<int>& value);
bool PropertyDelegate<TemplateProperty<std::set<std::string>>>::toLuaValue(
lua_State* state, const std::set<std::string>& value);
template <>
int PropertyDelegate<TemplateProperty<std::vector<int>>>::typeLua();
int PropertyDelegate<TemplateProperty<std::set<std::string>>>::typeLua();
template <>
template <>
std::vector<int> PropertyDelegate<TemplateProperty<std::vector<int>>>::fromString(
const std::string& value, bool& success);
template <>
template <>
bool PropertyDelegate<TemplateProperty<std::vector<int>>>::toString(
std::string& outValue, const std::vector<int>& inValue);
bool PropertyDelegate<TemplateProperty<std::set<std::string>>>::toString(
std::string& outValue, const std::set<std::string>& inValue);
} // namespace openspace::properties
@@ -118,7 +118,7 @@ public:
bool getLuaValue(lua_State* state) const override;
/**
* Sets the value of this TemplateProprty by decoding the object at the top of the Lua
* 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
@@ -132,10 +132,18 @@ public:
/// \see Property::typeLua
int typeLua() const override;
/**
* 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.
*
* \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;
bool setStringValue(std::string value) override;
/**
* Returns the description for this TemplateProperty as a Lua script that returns a
* table on execution.
@@ -169,15 +177,15 @@ public:
* the TemplateProperty::set method. It will be done internally by this method and it
* allows assignments such as <code>prop = T(1)</code>.
*
* \param val The value that should be set.
* \param val The value that should be set
*/
TemplateProperty<T>& operator=(T val);
/**
* These method sets the stored value to the provided value <code>val</code>,
* moving it into place. This move only happens if the provided value <code>val</code>
* This method sets the stored value to the provided value <code>val</code>,
* moving it into place. The move only happens if the provided value <code>val</code>
* is different from the stored value, which needs an operator== to exist for the type
* <code>T</code>. If the value are different, the listeners are notified.
* <code>T</code>. If the value is different, the listeners are notified.
*
* \param val The new value for this TemplateProperty
*/
@@ -59,11 +59,6 @@ namespace openspace::properties {
\
template <> \
template <> \
TYPE PropertyDelegate<TemplateProperty<TYPE>>::fromString(const std::string& value, \
bool& success); \
\
template <> \
template <> \
bool PropertyDelegate<TemplateProperty<TYPE>>::toString(std::string& outValue, \
const TYPE& inValue);
@@ -86,7 +81,6 @@ namespace openspace::properties {
#define REGISTER_TEMPLATEPROPERTY_SOURCE(CLASS_NAME, TYPE, DEFAULT_VALUE, \
FROM_LUA_LAMBDA_EXPRESSION, \
TO_LUA_LAMBDA_EXPRESSION, \
FROM_STRING_LAMBDA_EXPRESSION, \
TO_STRING_LAMBDA_EXPRESSION, LUA_TYPE) \
template <> \
std::string PropertyDelegate<TemplateProperty<TYPE>>::className() \
@@ -124,14 +118,6 @@ namespace openspace::properties {
\
template <> \
template <> \
TYPE PropertyDelegate<TemplateProperty<TYPE>>::fromString(const std::string& value, \
bool& success) \
{ \
return FROM_STRING_LAMBDA_EXPRESSION(value, success); \
} \
\
template <> \
template <> \
bool PropertyDelegate<TemplateProperty<TYPE>>::toString(std::string& outValue, \
const TYPE& inValue) \
{ \
@@ -194,11 +180,7 @@ std::any TemplateProperty<T>::get() const {
template <typename T>
void TemplateProperty<T>::set(std::any value) {
T v = std::any_cast<T>(std::move(value));
if (v != _value) {
_value = std::move(v);
notifyChangeListeners();
_isValueDirty = true;
}
setValue(v);
}
template <typename T>
@@ -242,17 +224,4 @@ bool TemplateProperty<T>::getStringValue(std::string& value) const {
return success;
}
template <typename T>
bool TemplateProperty<T>::setStringValue(std::string value) {
bool success = false;
T thisValue = PropertyDelegate<TemplateProperty<T>>::template fromString<T>(
value,
success
);
if (success) {
set(std::any(thisValue));
}
return success;
}
} // namespace openspace::properties
+13 -2
View File
@@ -61,12 +61,12 @@ void renderBox(const glm::vec2& position, const glm::vec2& size, const glm::vec4
struct Shaders {
struct {
std::unique_ptr<ghoul::opengl::ProgramObject> program;
UniformCache(tex, hasTexture, shouldFlipTexture, ortho, color) cache;
UniformCache(tex, hasTexture, shouldFlipTexture, proj, color) cache;
} xyuvrgba;
struct {
std::unique_ptr<ghoul::opengl::ProgramObject> program;
UniformCache(tex, hasTexture, shouldFlipTexture, ortho, color) cache;
UniformCache(tex, hasTexture, shouldFlipTexture, proj, color) cache;
} screenfilling;
};
@@ -76,6 +76,14 @@ struct VertexObjects {
GLuint vbo;
} square;
struct {
GLuint vao;
GLuint vbo;
GLuint ibo;
int nElements = 64;
} sphere;
struct {
GLuint vao;
} empty;
@@ -108,6 +116,9 @@ std::vector<VertexXYZ> convert(std::vector<Vertex> v);
std::vector<Vertex> createRing(int nSegments, float radius,
glm::vec4 colors = glm::vec4(1.f));
std::pair<std::vector<Vertex>, std::vector<GLushort>>
createSphere(int nSegments, glm::vec3 radii, glm::vec4 colors = glm::vec4(1.f));
} // namespace openspace::rendering::helper
#endif // __OPENSPACE_CORE___HELPER___H__
+21 -3
View File
@@ -31,6 +31,7 @@
#include <openspace/properties/scalar/doubleproperty.h>
#include <openspace/properties/scalar/floatproperty.h>
#include <openspace/properties/stringproperty.h>
#include <openspace/scene/scenegraphnode.h>
#include <ghoul/misc/managedmemoryuniqueptr.h>
namespace ghoul { class Dictionary; }
@@ -75,11 +76,17 @@ public:
bool isEnabled() const;
bool shouldUpdateIfDisabled() const;
void setBoundingSphere(double boundingSphere);
double boundingSphere() const;
double interactionSphere() const;
virtual void render(const RenderData& data, RendererTasks& rendererTask);
virtual void update(const UpdateData& data);
// The 'surface' in this case is the interaction sphere of this renderable. In some
// cases (i.e., planets) this corresponds directly to the physical surface, but in
// many cases, models, volumetric data, this will not. Regardless of what the physical
// representation is, the 'surface' is always the sphere around which interaction is
// handled
virtual SurfacePositionHandle calculateSurfacePositionHandle(
const glm::dvec3& targetModelSpace) const;
@@ -98,15 +105,26 @@ public:
protected:
properties::BoolProperty _enabled;
properties::FloatProperty _opacity;
properties::DoubleProperty _boundingSphere;
properties::StringProperty _renderableType;
bool _shouldUpdateIfDisabled = false;
void setBoundingSphere(double boundingSphere);
void setInteractionSphere(double interactionSphere);
void setRenderBinFromOpacity();
void registerUpdateRenderBinFromOpacity();
double _boundingSphere = 0.0;
double _interactionSphere = 0.0;
SceneGraphNode* _parent = nullptr;
bool _shouldUpdateIfDisabled = false;
private:
// We only want the SceneGraphNode to be able manipulate the parent, so we don't want
// to provide a set method for this. Otherwise, anyone might mess around with our
// parentage and that's no bueno
friend ghoul::mm_unique_ptr<SceneGraphNode> SceneGraphNode::createFromDictionary(
const ghoul::Dictionary&);
RenderBin _renderBin = RenderBin::Opaque;
};
+12 -1
View File
@@ -36,14 +36,16 @@
#include <ghoul/misc/boolean.h>
#include <ghoul/misc/managedmemoryuniqueptr.h>
#include <atomic>
#include <chrono>
#include <functional>
#include <memory>
#include <optional>
#include <vector>
#include <chrono>
//#define Debugging_Core_SceneGraphNode_Indices
namespace ghoul { class Dictionary; }
namespace ghoul::opengl { class ProgramObject; }
namespace openspace {
@@ -127,6 +129,7 @@ public:
std::vector<SceneGraphNode*> children() const;
double boundingSphere() const;
double interactionSphere() const;
SceneGraphNode* childNode(const std::string& identifier);
@@ -143,6 +146,7 @@ private:
glm::dmat3 calculateWorldRotation() const;
glm::dvec3 calculateWorldScale() const;
void computeScreenSpaceData(RenderData& newData);
void renderDebugSphere(const Camera& camera, double size, glm::vec4 color);
std::atomic<State> _state = State::Loaded;
std::vector<ghoul::mm_unique_ptr<SceneGraphNode>> _children;
@@ -178,6 +182,7 @@ private:
glm::dmat4 _modelTransformCached = glm::dmat4(1.0);
properties::DoubleProperty _boundingSphere;
properties::DoubleProperty _interactionSphere;
properties::BoolProperty _computeScreenSpaceValues;
properties::IVec2Property _screenSpacePosition;
properties::BoolProperty _screenVisibility;
@@ -189,6 +194,12 @@ private:
// are calculated when _computeScreenSpaceValues is true)
std::chrono::high_resolution_clock::time_point _lastScreenSpaceUpdateTime;
properties::BoolProperty _showDebugSphere;
static ghoul::opengl::ProgramObject* _debugSphereProgram;
std::optional<double> _overrideBoundingSphere;
std::optional<double> _overrideInteractionSphere;
#ifdef Debugging_Core_SceneGraphNode_Indices
int index = 0;
static int nextIndex;
@@ -35,6 +35,12 @@ namespace openspace::distanceconstants {
constexpr double LightHour = LightDay / 24;
constexpr double AstronomicalUnit = 1.495978707E11;
constexpr double Parsec = 3.0856776E16;
constexpr double Inch = 0.0254;
constexpr double Foot = 0.3048;
constexpr double Yard = 0.9144;
constexpr double Chain = 20.1168;
constexpr double Mile = 1609.344;
} // openspace::distanceconstants
#endif // __OPENSPACE_CORE___DISTANCECONSTANTS___H__
+95 -23
View File
@@ -39,6 +39,8 @@ enum class DistanceUnit {
Nanometer = 0,
Micrometer,
Millimeter,
Centimeter,
Decimeter,
Meter,
Kilometer,
AU,
@@ -66,6 +68,8 @@ enum class DistanceUnit {
constexpr const char* DistanceUnitNanometer = "nanometer";
constexpr const char* DistanceUnitMicrometer = "micrometer";
constexpr const char* DistanceUnitMillimeter = "millimeter";
constexpr const char* DistanceUnitCentimeter = "centimeter";
constexpr const char* DistanceUnitDecimeter = "decimeter";
constexpr const char* DistanceUnitMeter = "meter";
constexpr const char* DistanceUnitKilometer = "km";
constexpr const char* DistanceUnitAU = "AU";
@@ -91,6 +95,8 @@ constexpr const char* DistanceUnitLeague = "league";
constexpr const char* DistanceUnitNanometers = "nanometers";
constexpr const char* DistanceUnitMicrometers = "micrometers";
constexpr const char* DistanceUnitMillimeters = "millimeters";
constexpr const char* DistanceUnitCentimeters = "centimeters";
constexpr const char* DistanceUnitDecimeters = "decimeters";
constexpr const char* DistanceUnitMeters = "meters";
constexpr const char* DistanceUnitKilometers = "km";
constexpr const char* DistanceUnitAUs = "AU";
@@ -114,18 +120,20 @@ constexpr const char* DistanceUnitLeagues = "leagues";
constexpr const std::array<DistanceUnit, static_cast<int>(DistanceUnit::League) + 1>
DistanceUnits = {
DistanceUnit::Nanometer, DistanceUnit::Micrometer, DistanceUnit::Millimeter,
DistanceUnit::Meter, DistanceUnit::Kilometer, DistanceUnit::AU,
DistanceUnit::Lighthour, DistanceUnit::Lightday, DistanceUnit::Lightmonth,
DistanceUnit::Lightyear, DistanceUnit::Parsec, DistanceUnit::Kiloparsec,
DistanceUnit::Megaparsec, DistanceUnit::Gigaparsec, DistanceUnit::Thou,
DistanceUnit::Inch, DistanceUnit::Foot, DistanceUnit::Yard, DistanceUnit::Chain,
DistanceUnit::Furlong, DistanceUnit::Mile, DistanceUnit::League
DistanceUnit::Centimeter, DistanceUnit::Decimeter, DistanceUnit::Meter,
DistanceUnit::Kilometer, DistanceUnit::AU, DistanceUnit::Lighthour,
DistanceUnit::Lightday, DistanceUnit::Lightmonth, DistanceUnit::Lightyear,
DistanceUnit::Parsec, DistanceUnit::Kiloparsec, DistanceUnit::Megaparsec,
DistanceUnit::Gigaparsec, DistanceUnit::Thou, DistanceUnit::Inch,
DistanceUnit::Foot, DistanceUnit::Yard, DistanceUnit::Chain, DistanceUnit::Furlong,
DistanceUnit::Mile, DistanceUnit::League
};
constexpr const std::array<const char*, static_cast<int>(DistanceUnit::League) + 1>
DistanceUnitNamesSingular = {
DistanceUnitNanometer, DistanceUnitMicrometer, DistanceUnitMillimeter,
DistanceUnitMeter, DistanceUnitKilometer, DistanceUnitAU, DistanceUnitLighthour,
DistanceUnitCentimeter, DistanceUnitDecimeter, DistanceUnitMeter,
DistanceUnitKilometer, DistanceUnitAU, DistanceUnitLighthour,
DistanceUnitLightday, DistanceUnitLightmonth, DistanceUnitLightyear,
DistanceUnitParsec, DistanceUnitKiloparsec, DistanceUnitMegaparsec,
DistanceUnitGigaparsec, DistanceUnitThou, DistanceUnitInch, DistanceUnitFoot,
@@ -136,7 +144,8 @@ DistanceUnitNamesSingular = {
constexpr const std::array<const char*, static_cast<int>(DistanceUnit::League) + 1>
DistanceUnitNamesPlural = {
DistanceUnitNanometers, DistanceUnitMicrometers, DistanceUnitMillimeters,
DistanceUnitMeters, DistanceUnitKilometers, DistanceUnitAUs, DistanceUnitLighthours,
DistanceUnitCentimeters, DistanceUnitDecimeters, DistanceUnitMeters,
DistanceUnitKilometers, DistanceUnitAUs, DistanceUnitLighthours,
DistanceUnitLightdays, DistanceUnitLightmonths, DistanceUnitLightyears,
DistanceUnitParsecs, DistanceUnitKiloparsecs, DistanceUnitMegaparsecs,
DistanceUnitGigaparsecs, DistanceUnitThous, DistanceUnitInches, DistanceUnitFeet,
@@ -168,6 +177,8 @@ constexpr const char* nameForDistanceUnit(DistanceUnit unit, bool pluralForm = f
case DistanceUnit::Nanometer:
case DistanceUnit::Micrometer:
case DistanceUnit::Millimeter:
case DistanceUnit::Centimeter:
case DistanceUnit::Decimeter:
case DistanceUnit::Meter:
case DistanceUnit::Kilometer:
case DistanceUnit::AU:
@@ -232,7 +243,7 @@ constexpr DistanceUnit distanceUnitFromString(const char* unitName) {
std::pair<double, std::string> simplifyDistance(double meters,
bool forceSingularForm = false);
constexpr double convertDistance(double meters, DistanceUnit requestedUnit) {
constexpr double convertMeters(double meters, DistanceUnit requestedUnit) {
switch (requestedUnit) {
case DistanceUnit::Nanometer:
return meters / 1e-9;
@@ -240,6 +251,10 @@ constexpr double convertDistance(double meters, DistanceUnit requestedUnit) {
return meters / 1e-6;
case DistanceUnit::Millimeter:
return meters / 1e-3;
case DistanceUnit::Centimeter:
return meters / 1e-2;
case DistanceUnit::Decimeter:
return meters / 1e-1;
case DistanceUnit::Meter:
return meters;
case DistanceUnit::Kilometer:
@@ -262,33 +277,90 @@ constexpr double convertDistance(double meters, DistanceUnit requestedUnit) {
return meters / (1e6 * distanceconstants::Parsec);
case DistanceUnit::Gigaparsec:
return meters / (1e9 * distanceconstants::Parsec);
// Such wow, such coefficients
case DistanceUnit::Thou:
return (meters * 1000.0 / 25.4) * 1000.0; // m -> mm -> inch -> thou
return meters / (1e-3 * distanceconstants::Inch);
case DistanceUnit::Inch:
return (meters * 1000.0 / 25.4); // m -> mm -> inch
return meters / distanceconstants::Inch;
case DistanceUnit::Foot:
return (meters * 1000.0 / 25.4) / 12.0; // m -> mm -> inch -> feet
return meters / distanceconstants::Foot;
case DistanceUnit::Yard:
// m -> mm -> inch -> feet -> yard
return (meters * 1000.0 / 25.4) / 12.0 / 3.0;
return meters / distanceconstants::Yard;
case DistanceUnit::Chain:
// m -> mm -> inch -> feet -> yard -> chain
return (meters * 1000.0 / 25.4) / 12.0 / 3.0 / 22.0;
return meters / distanceconstants::Chain;
case DistanceUnit::Furlong:
// m -> mm -> inch -> feet -> yard -> chain -> furlong
return (meters * 1000.0 / 25.4) / 12.0 / 3.0 / 22.0 / 10.0;
return meters / (10.0 * distanceconstants::Chain);
case DistanceUnit::Mile:
// m -> mm -> inch -> feet -> yard -> chain -> furlong -> mile
return (meters * 1000.0 / 25.4) / 12.0 / 3.0 / 22.0 / 10.0 / 8.0;
return meters / distanceconstants::Mile;
case DistanceUnit::League:
// m -> mm -> inch -> feet -> yard -> chain -> furlong -> mile -> league
return (meters * 1000.0 / 25.4) / 12.0 / 3.0 / 22.0 / 10.0 / 8.0 / 3.0;
return meters / (3.0 * distanceconstants::Mile);
default:
throw ghoul::MissingCaseException();
}
}
constexpr double toMeter(DistanceUnit unit) {
switch (unit) {
case DistanceUnit::Nanometer:
return 1e-9;
case DistanceUnit::Micrometer:
return 1e-6;
case DistanceUnit::Millimeter:
return 1e-3;
case DistanceUnit::Centimeter:
return 1e-2;
case DistanceUnit::Decimeter:
return 1e-1;
case DistanceUnit::Meter:
return 1.0;
case DistanceUnit::Kilometer:
return 1000.0;
case DistanceUnit::AU:
return distanceconstants::AstronomicalUnit;
case DistanceUnit::Lighthour:
return distanceconstants::LightHour;
case DistanceUnit::Lightday:
return distanceconstants::LightDay;
case DistanceUnit::Lightmonth:
return distanceconstants::LightMonth;
case DistanceUnit::Lightyear:
return distanceconstants::LightYear;
case DistanceUnit::Parsec:
return distanceconstants::Parsec;
case DistanceUnit::Kiloparsec:
return 1e3 * distanceconstants::Parsec;
case DistanceUnit::Megaparsec:
return 1e6 * distanceconstants::Parsec;
case DistanceUnit::Gigaparsec:
return 1e9 * distanceconstants::Parsec;
case DistanceUnit::Thou:
return 1e-3 * distanceconstants::Inch;
case DistanceUnit::Inch:
return distanceconstants::Inch;
case DistanceUnit::Foot:
return distanceconstants::Foot;
case DistanceUnit::Yard:
return distanceconstants::Yard;
case DistanceUnit::Chain:
return distanceconstants::Chain;
case DistanceUnit::Furlong:
return 10.0 * distanceconstants::Chain;
case DistanceUnit::Mile:
return distanceconstants::Mile;
case DistanceUnit::League:
return 3.0 * distanceconstants::Mile;
default:
throw ghoul::MissingCaseException();
}
}
constexpr double convertUnit(DistanceUnit fromUnit, DistanceUnit toUnit) {
return convertMeters(toMeter(fromUnit), toUnit);
}
constexpr double convertDistance(double distance, DistanceUnit fromUnit, DistanceUnit toUnit) {
return distance * convertUnit(fromUnit, toUnit);
}
float convertMasPerYearToMeterPerSecond(float masPerYear, float parallax);
} // namespace openspace
+1 -1
View File
@@ -50,7 +50,7 @@ struct UpdateData {
struct RenderData {
const Camera& camera;
const Time time;
int renderBinMask = -1;
int8_t renderBinMask = -1;
TransformData modelTransform;
};