From 357a4474358cecd653d99027530de8bb05692548 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 23 Nov 2016 18:35:02 +0100 Subject: [PATCH 1/9] Update ghoul reference Wrap OpenSpace main with an exception handler that logs exceptions --- apps/OpenSpace/main.cpp | 22 +++++++++++++++++++++- ext/ghoul | 2 +- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/apps/OpenSpace/main.cpp b/apps/OpenSpace/main.cpp index 70c13faca8..c2a93a5262 100644 --- a/apps/OpenSpace/main.cpp +++ b/apps/OpenSpace/main.cpp @@ -170,7 +170,27 @@ int main(int argc, char** argv) { // Main loop LDEBUG("Starting rendering loop"); - _sgctEngine->render(); + try { + _sgctEngine->render(); + } + catch (const ghoul::RuntimeError& e) { + // Write out all of the information about the exception, flush the logs, and throw + LFATALC(e.component, e.message); + LogMgr.flushLogs(); + throw; + } + catch (const std::exception& e) { + // Write out all of the information about the exception, flush the logs, and throw + LFATALC("Exception", e.what()); + LogMgr.flushLogs(); + throw; + } + catch (...) { + // Write out all of the information about the exception, flush the logs, and throw + LFATALC("Exception", "Unknown exception"); + LogMgr.flushLogs(); + throw; + } //clear function bindings to avoid crash after destroying the OpenSpace Engine sgct::MessageHandler::instance()->setLogToCallback(false); diff --git a/ext/ghoul b/ext/ghoul index 919e753f8d..4301855146 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 919e753f8de763f28b9088f6bf2fc97c7c376c2c +Subproject commit 4301855146b5aaaeed7960e628839d59cd4d5f06 From 7ffcf81235b77543a706219c5bc79199a8f2530e Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 23 Nov 2016 23:24:07 +0100 Subject: [PATCH 2/9] Add visibility setting to the property classes (closing #166) --- .../openspace/properties/numericalproperty.h | 11 ++-- .../properties/numericalproperty.inl | 58 +++++++++++-------- include/openspace/properties/optionproperty.h | 6 +- include/openspace/properties/property.h | 32 ++++++---- .../openspace/properties/selectionproperty.h | 3 +- .../openspace/properties/templateproperty.h | 6 +- .../openspace/properties/templateproperty.inl | 11 ++-- .../openspace/properties/triggerproperty.h | 3 +- modules/base/rendering/renderablestars.cpp | 6 +- modules/onscreengui/include/gui.h | 7 +++ .../include/guipropertycomponent.h | 6 ++ modules/onscreengui/src/gui.cpp | 19 ++++++ .../onscreengui/src/guipropertycomponent.cpp | 54 +++++++++++++---- src/properties/optionproperty.cpp | 10 ++-- src/properties/property.cpp | 41 ++++++++----- src/properties/selectionproperty.cpp | 6 +- src/properties/triggerproperty.cpp | 5 +- 17 files changed, 200 insertions(+), 84 deletions(-) diff --git a/include/openspace/properties/numericalproperty.h b/include/openspace/properties/numericalproperty.h index ffa257a16c..6fee2638c3 100644 --- a/include/openspace/properties/numericalproperty.h +++ b/include/openspace/properties/numericalproperty.h @@ -33,12 +33,15 @@ namespace properties { template class NumericalProperty : public TemplateProperty { public: - NumericalProperty(std::string identifier, std::string guiName); - NumericalProperty(std::string identifier, std::string guiName, T value); + NumericalProperty(std::string identifier, std::string guiName, + Visibility visibility = Visibility::User); NumericalProperty(std::string identifier, std::string guiName, T value, - T minimumValue, T maximumValue); + Visibility visibility = Visibility::User); NumericalProperty(std::string identifier, std::string guiName, T value, - T minimumValue, T maximumValue, T steppingValue); + T minimumValue, T maximumValue, Visibility visibility = Visibility::User); + NumericalProperty(std::string identifier, std::string guiName, T value, + T minimumValue, T maximumValue, T steppingValue, + Visibility visibility = Visibility::User); bool getLuaValue(lua_State* state) const override; bool setLuaValue(lua_State* state) override; diff --git a/include/openspace/properties/numericalproperty.inl b/include/openspace/properties/numericalproperty.inl index 86f04e8f62..a16ba6a2c5 100644 --- a/include/openspace/properties/numericalproperty.inl +++ b/include/openspace/properties/numericalproperty.inl @@ -233,42 +233,50 @@ const std::string NumericalProperty::SteppingValueKey = "SteppingValue"; // a single constructor template -NumericalProperty::NumericalProperty(std::string identifier, std::string guiName) +NumericalProperty::NumericalProperty(std::string identifier, std::string guiName, + Visibility visibility) : NumericalProperty( std::move(identifier), std::move(guiName), PropertyDelegate>::template defaultValue(), PropertyDelegate>::template defaultMinimumValue(), PropertyDelegate>::template defaultMaximumValue(), - PropertyDelegate>::template defaultSteppingValue() - ) -{} - -template -NumericalProperty::NumericalProperty(std::string identifier, - std::string guiName, T value) - : NumericalProperty( - std::move(identifier), std::move(guiName), std::move(value), - PropertyDelegate>::template defaultMinimumValue(), - PropertyDelegate>::template defaultMaximumValue(), - PropertyDelegate>::template defaultSteppingValue() - ) -{} - -template -NumericalProperty::NumericalProperty(std::string identifier, std::string guiName, - T value, T minimumValue, T maximumValue) - : NumericalProperty( - std::move(identifier) , std::move(guiName), std::move(value), - std::move(minimumValue), std::move(maximumValue), - PropertyDelegate>::template defaultSteppingValue() + PropertyDelegate>::template defaultSteppingValue(), + visibility ) {} template NumericalProperty::NumericalProperty(std::string identifier, std::string guiName, T value, - T minimumValue, T maximumValue, T steppingValue) - : TemplateProperty(std::move(identifier), std::move(guiName), std::move(value)) + Visibility visibility) + : NumericalProperty( + std::move(identifier), std::move(guiName), std::move(value), + PropertyDelegate>::template defaultMinimumValue(), + PropertyDelegate>::template defaultMaximumValue(), + PropertyDelegate>::template defaultSteppingValue(), + visibility + ) +{} + +template +NumericalProperty::NumericalProperty(std::string identifier, std::string guiName, + T value, T minimumValue, T maximumValue, + Visibility visibility) + : NumericalProperty( + std::move(identifier) , std::move(guiName), std::move(value), + std::move(minimumValue), std::move(maximumValue), + PropertyDelegate>::template defaultSteppingValue(), + visibility + ) +{} + +template +NumericalProperty::NumericalProperty(std::string identifier, + std::string guiName, T value, + T minimumValue, T maximumValue, T steppingValue, + Visibility visibility) + : TemplateProperty(std::move(identifier), std::move(guiName), std::move(value), + visibility) , _minimumValue(std::move(minimumValue)) , _maximumValue(std::move(maximumValue)) , _stepping(std::move(steppingValue)) diff --git a/include/openspace/properties/optionproperty.h b/include/openspace/properties/optionproperty.h index d811807aa5..19d831cd22 100644 --- a/include/openspace/properties/optionproperty.h +++ b/include/openspace/properties/optionproperty.h @@ -61,7 +61,8 @@ public: * \param identifier A unique identifier for this property * \param guiName The GUI name that should be used to represent this property */ - OptionProperty(std::string identifier, std::string guiName); + OptionProperty(std::string identifier, std::string guiName, + Visibility visibility = Visibility::User); /** * The constructor delegating the identifier and the guiName @@ -70,7 +71,8 @@ public: * \param guiName The GUI name that should be used to represent this property * \param displayType Optional DisplayType for GUI (default RADIO) */ - OptionProperty(std::string identifier, std::string guiName, DisplayType displayType); + OptionProperty(std::string identifier, std::string guiName, DisplayType displayType, + Visibility visibility = Visibility::User); /** * Returns the name of the class for reflection purposes. diff --git a/include/openspace/properties/property.h b/include/openspace/properties/property.h index c3cdb71572..ec8011bdcb 100644 --- a/include/openspace/properties/property.h +++ b/include/openspace/properties/property.h @@ -62,6 +62,17 @@ class PropertyOwner; */ class Property { public: + /** + * The visibility classes for Property%s. The classes are strictly ordered as + * All > Developer > User > None + */ + enum class Visibility { + All = 3, ///< Visible for all types, no matter what + Developer = 2, ///< Visible in Developer mode + User = 1, ///< Visible in User mode + None = 0 ///< Never visible + }; + /** * The constructor for the property. The identifier needs to be unique * for each PropertyOwner. The guiName will be stored in the metaData @@ -74,7 +85,8 @@ public: * \pre \p identifier must not be empty * \pre \p guiName must not be empty */ - Property(std::string identifier, std::string guiName); + Property(std::string identifier, std::string guiName, + Visibility visibility = Visibility::All); /** * The destructor taking care of deallocating all unused memory. This method will not @@ -255,20 +267,18 @@ public: std::string groupIdentifier() const; /** - * Determines a hint if this Property should be visible, or hidden. Each application - * accessing the properties is free to ignore this hint. It is stored in the metaData - * Dictionary with the key: isVisible. The default value is - * true. - * \param state true if the Property should be visible, - * false otherwise. + * Sets a hint about the visibility of the Property. Each application accessing the + * properties is free to ignore this hint. It is stored in the metaData Dictionary + * with the key: Visibility. + * \param visibility The new visibility of the Property */ - void setVisible(bool state); + void setVisibility(Visibility visibility); /** - * Returns whether this Property is visible or not. - * \return Whether this Property is visible or hidden + * Returns this Property%'s visibility setting + * \return This Property%'s visibility setting */ - bool isVisible() const; + Visibility visibility() const; /** * This method determines if this Property should be read-only in external diff --git a/include/openspace/properties/selectionproperty.h b/include/openspace/properties/selectionproperty.h index b86aea9870..dedcab1544 100644 --- a/include/openspace/properties/selectionproperty.h +++ b/include/openspace/properties/selectionproperty.h @@ -39,7 +39,8 @@ public: std::string description; }; - SelectionProperty(std::string identifier, std::string guiName); + SelectionProperty(std::string identifier, std::string guiName, + Visibility visibility = Visibility::User); void addOption(Option option); void removeOptions(); diff --git a/include/openspace/properties/templateproperty.h b/include/openspace/properties/templateproperty.h index c2d364540a..3e0970d1aa 100644 --- a/include/openspace/properties/templateproperty.h +++ b/include/openspace/properties/templateproperty.h @@ -63,14 +63,16 @@ public: * \param identifier The identifier that is used for this TemplateProperty * \param guiName The human-readable GUI name for this TemplateProperty */ - TemplateProperty(std::string identifier, std::string guiName); + TemplateProperty(std::string identifier, std::string guiName, + Visibility visibility = Visibility::User); /** * The constructor initializing the TemplateProperty with the provided * identifier, human-readable guiName and provided * value. */ - TemplateProperty(std::string identifier, std::string guiName, T value); + TemplateProperty(std::string identifier, std::string guiName, T value, + Visibility visibility = Visibility::User); /** * Returns the class name for this TemplateProperty. The default implementation makes diff --git a/include/openspace/properties/templateproperty.inl b/include/openspace/properties/templateproperty.inl index ec8f8509a6..02e8de3e9e 100644 --- a/include/openspace/properties/templateproperty.inl +++ b/include/openspace/properties/templateproperty.inl @@ -149,17 +149,20 @@ namespace properties { // a single constructor template -TemplateProperty::TemplateProperty(std::string identifier, std::string guiName) +TemplateProperty::TemplateProperty(std::string identifier, std::string guiName, + Visibility visibility) : TemplateProperty( std::move(identifier), std::move(guiName), - PropertyDelegate>::template defaultValue()) + PropertyDelegate>::template defaultValue(), + visibility) + { } template TemplateProperty::TemplateProperty(std::string identifier, std::string guiName, - T value) - : Property(std::move(identifier), std::move(guiName)) + T value, Visibility visibility) + : Property(std::move(identifier), std::move(guiName), visibility) , _value(std::move(value)) { } diff --git a/include/openspace/properties/triggerproperty.h b/include/openspace/properties/triggerproperty.h index dd43f58fc4..904039784b 100644 --- a/include/openspace/properties/triggerproperty.h +++ b/include/openspace/properties/triggerproperty.h @@ -42,7 +42,8 @@ public: * \param identifier The unique identifier used for this Property * \param guiName The human-readable name of this Property */ - TriggerProperty(std::string identifier, std::string guiName); + TriggerProperty(std::string identifier, std::string guiName, + Visibility visibility = Visibility::User); /** * Returns the class name TriggerProperty. diff --git a/modules/base/rendering/renderablestars.cpp b/modules/base/rendering/renderablestars.cpp index c5ed2f2ccf..a4a3c6b882 100644 --- a/modules/base/rendering/renderablestars.cpp +++ b/modules/base/rendering/renderablestars.cpp @@ -130,7 +130,11 @@ RenderableStars::RenderableStars(const ghoul::Dictionary& dictionary) , _colorTexturePath("colorTexture", "ColorBV Texture") , _colorTexture(nullptr) , _colorTextureIsDirty(true) - , _colorOption("colorOption", "Color Option") + , _colorOption( + "colorOption", + "Color Option", + properties::OptionProperty::DisplayType::Dropdown + ) , _dataIsDirty(true) , _alphaValue("alphaValue", "Transparency", 1.f, 0.f, 1.f) , _scaleFactor("scaleFactor", "Scale Factor", 1.f, 0.f, 10.f) diff --git a/modules/onscreengui/include/gui.h b/modules/onscreengui/include/gui.h index 7f696a609e..83822d00cf 100644 --- a/modules/onscreengui/include/gui.h +++ b/modules/onscreengui/include/gui.h @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -70,6 +71,12 @@ public: GuiPropertyComponent _screenSpaceProperty; GuiTimeComponent _time; GuiIswaComponent _iswa; + +private: + void renderAndUpdatePropertyVisibility(); + + properties::Property::Visibility _currentVisibility; + }; } // namespace gui diff --git a/modules/onscreengui/include/guipropertycomponent.h b/modules/onscreengui/include/guipropertycomponent.h index bf836660a2..c6dd289482 100644 --- a/modules/onscreengui/include/guipropertycomponent.h +++ b/modules/onscreengui/include/guipropertycomponent.h @@ -27,6 +27,8 @@ #include +#include + #include #include #include @@ -50,12 +52,16 @@ public: // component should render void setSource(SourceFunction func); + void setVisibility(properties::Property::Visibility visibility); + void render(); protected: void renderPropertyOwner(properties::PropertyOwner* owner); void renderProperty(properties::Property* prop, properties::PropertyOwner* owner); + properties::Property::Visibility _visibility; + SourceFunction _function; }; diff --git a/modules/onscreengui/src/gui.cpp b/modules/onscreengui/src/gui.cpp index 8f99bf744d..f84877c944 100644 --- a/modules/onscreengui/src/gui.cpp +++ b/modules/onscreengui/src/gui.cpp @@ -225,6 +225,7 @@ GUI::GUI() , _globalProperty("Global") , _property("Properties") , _screenSpaceProperty("ScreenSpace Properties") + , _currentVisibility(properties::Property::Visibility::All) { addPropertySubOwner(_help); addPropertySubOwner(_origin); @@ -546,6 +547,8 @@ void GUI::render() { ImGui::Checkbox("Help", &help); _help.setEnabled(help); + renderAndUpdatePropertyVisibility(); + static const int addImageBufferSize = 256; static char addImageBuffer[addImageBufferSize]; @@ -576,5 +579,21 @@ void GUI::render() { ImGui::End(); } +void GUI::renderAndUpdatePropertyVisibility() { + // Fragile! Keep this in sync with properties::Property::Visibility + using V = properties::Property::Visibility; + int t = static_cast>(_currentVisibility); + + // Array is sorted by importance + std::array items = { "None", "User", "Developer", "All"}; + ImGui::Combo("PropertyVisibility", &t, items.data(), items.size()); + + _currentVisibility = static_cast(t); + _globalProperty.setVisibility(_currentVisibility); + _property.setVisibility(_currentVisibility); + _screenSpaceProperty.setVisibility(_currentVisibility); +} + + } // namespace gui } // namespace openspace diff --git a/modules/onscreengui/src/guipropertycomponent.cpp b/modules/onscreengui/src/guipropertycomponent.cpp index 85c0de774f..7e247045c7 100644 --- a/modules/onscreengui/src/guipropertycomponent.cpp +++ b/modules/onscreengui/src/guipropertycomponent.cpp @@ -28,6 +28,7 @@ #include +#include #include "imgui.h" namespace { @@ -36,6 +37,24 @@ namespace { } namespace openspace { + +namespace { +int nVisibleProperties(const std::vector& properties, + properties::Property::Visibility visibility) +{ + return std::count_if( + properties.begin(), + properties.end(), + [visibility](properties::Property* p) { + using V = properties::Property::Visibility; + return + static_cast>(visibility) >= + static_cast>(p->visibility()); + } + ); +} +} + namespace gui { GuiPropertyComponent::GuiPropertyComponent(std::string name) @@ -46,6 +65,10 @@ void GuiPropertyComponent::setSource(SourceFunction function) { _function = std::move(function); } +void GuiPropertyComponent::setVisibility(properties::Property::Visibility visibility) { + _visibility = visibility; +} + void GuiPropertyComponent::renderPropertyOwner(properties::PropertyOwner* owner) { if (owner->propertiesRecursive().empty()) { return; @@ -54,7 +77,9 @@ void GuiPropertyComponent::renderPropertyOwner(properties::PropertyOwner* owner) ImGui::PushID(owner->name().c_str()); const auto& subOwners = owner->propertySubOwners(); for (properties::PropertyOwner* subOwner : subOwners) { - if (subOwner->propertiesRecursive().empty()) { + std::vector properties = subOwner->propertiesRecursive(); + int count = nVisibleProperties(properties, _visibility); + if (count == 0) { continue; } if (subOwners.size() == 1) { @@ -96,9 +121,7 @@ void GuiPropertyComponent::renderPropertyOwner(properties::PropertyOwner* owner) ImGui::Spacing(); for (properties::Property* prop : remainingProperies) { - if (prop->isVisible()) { - renderProperty(prop, owner); - } + renderProperty(prop, owner); } ImGui::PopID(); } @@ -121,8 +144,11 @@ void GuiPropertyComponent::render() { ); for (properties::PropertyOwner* pOwner : owners) { - if (pOwner->propertiesRecursive().empty()) + int count = nVisibleProperties(pOwner->propertiesRecursive(), _visibility); + + if (count == 0) { continue; + } auto header = [&]() -> bool { if (owners.size() > 1) { @@ -146,9 +172,11 @@ void GuiPropertyComponent::render() { ImGui::End(); } -void GuiPropertyComponent::renderProperty(properties::Property* prop, properties::PropertyOwner* owner) { +void GuiPropertyComponent::renderProperty(properties::Property* prop, + properties::PropertyOwner* owner) +{ using Func = std::function; - static std::map FunctionMapping = { + static const std::map FunctionMapping = { { "BoolProperty", &renderBoolProperty }, { "DoubleProperty", &renderDoubleProperty}, { "IntProperty", &renderIntProperty }, @@ -165,9 +193,15 @@ void GuiPropertyComponent::renderProperty(properties::Property* prop, properties { "SelectionProperty", &renderSelectionProperty } }; - auto it = FunctionMapping.find(prop->className()); - if (it != FunctionMapping.end()) { - it->second(prop, owner->name()); + // Check if the visibility of the property is high enough to be displayed + using V = properties::Property::Visibility; + auto v = static_cast>(_visibility); + auto propV = static_cast>(prop->visibility()); + if (v >= propV) { + auto it = FunctionMapping.find(prop->className()); + if (it != FunctionMapping.end()) { + it->second(prop, owner->name()); + } } } diff --git a/src/properties/optionproperty.cpp b/src/properties/optionproperty.cpp index c1629544d9..84b33373c3 100644 --- a/src/properties/optionproperty.cpp +++ b/src/properties/optionproperty.cpp @@ -33,13 +33,15 @@ namespace properties { const std::string OptionProperty::OptionsKey = "Options"; -OptionProperty::OptionProperty(std::string identifier, std::string guiName) - : IntProperty(std::move(identifier), std::move(guiName)) +OptionProperty::OptionProperty(std::string identifier, std::string guiName, + Visibility visibility) + : IntProperty(std::move(identifier), std::move(guiName), visibility) , _displayType(DisplayType::Radio) {} -OptionProperty::OptionProperty(std::string identifier, std::string guiName, DisplayType displayType) - : IntProperty(std::move(identifier), std::move(guiName)) +OptionProperty::OptionProperty(std::string identifier, std::string guiName, + DisplayType displayType, Visibility visibility) + : IntProperty(std::move(identifier), std::move(guiName), visibility) , _displayType(displayType) {} diff --git a/src/properties/property.cpp b/src/properties/property.cpp index 265789fadb..aee0f405a8 100644 --- a/src/properties/property.cpp +++ b/src/properties/property.cpp @@ -35,7 +35,7 @@ namespace { const std::string _loggerCat = "Property"; const std::string MetaDataKeyGuiName = "guiName"; const std::string MetaDataKeyGroup = "Group"; - const std::string MetaDataKeyVisible = "isVisible"; + const std::string MetaDataKeyVisibility = "Visibility"; const std::string MetaDataKeyReadOnly = "isReadOnly"; const std::string _metaDataKeyViewPrefix = "view."; @@ -51,14 +51,14 @@ const std::string Property::NameKey = "Name"; const std::string Property::TypeKey = "Type"; const std::string Property::MetaDataKey = "MetaData"; -Property::Property(std::string identifier, std::string guiName) +Property::Property(std::string identifier, std::string guiName, Visibility visibility) : _owner(nullptr) , _identifier(std::move(identifier)) { ghoul_assert(!_identifier.empty(), "Identifier must not be empty"); ghoul_assert(!guiName.empty(), "guiName must not be empty"); - setVisible(true); + setVisibility(visibility); _metaData.setValue(MetaDataKeyGuiName, std::move(guiName)); } @@ -131,14 +131,18 @@ std::string Property::groupIdentifier() const { return result; } -void Property::setVisible(bool state) { - _metaData.setValue(MetaDataKeyVisible, state); +void Property::setVisibility(Visibility visibility) { + _metaData.setValue( + MetaDataKeyVisibility, + static_cast>(visibility) + ); } -bool Property::isVisible() const { - bool visible = true; - _metaData.getValue(MetaDataKeyVisible, visible); - return visible; +Property::Visibility Property::visibility() const { + return + static_cast( + _metaData.value>(MetaDataKeyVisibility) + ); } void Property::setReadOnly(bool state) { @@ -185,15 +189,22 @@ std::string Property::generateBaseDescription() const { } std::string Property::generateMetaDataDescription() const { - bool isVisible, isReadOnly; - _metaData.getValue(MetaDataKeyVisible, isVisible); - _metaData.getValue(MetaDataKeyReadOnly, isReadOnly); + static const std::map VisibilityConverter = { + { Visibility::All, "All" }, + { Visibility::Developer, "Developer" }, + { Visibility::User, "User" }, + { Visibility::None, "None" } + }; + Visibility visibility = _metaData.value(MetaDataKeyVisibility); + bool isReadOnly = _metaData.value(MetaDataKeyReadOnly); + + std::string vis = VisibilityConverter.at(visibility); return MetaDataKey + " = {" + - MetaDataKeyGroup + " = '" + groupIdentifier() + "'," + - MetaDataKeyVisible + " = " + (isVisible ? "true" : "false") + "," + - MetaDataKeyReadOnly +" = " + (isReadOnly ? "true" : "false") + "}"; + MetaDataKeyGroup + " = '" + groupIdentifier() + "'," + + MetaDataKeyVisibility + " = " + vis + "," + + MetaDataKeyReadOnly +" = " + (isReadOnly ? "true" : "false") + "}"; } std::string Property::generateAdditionalDescription() const { diff --git a/src/properties/selectionproperty.cpp b/src/properties/selectionproperty.cpp index 601176f440..486aa35506 100644 --- a/src/properties/selectionproperty.cpp +++ b/src/properties/selectionproperty.cpp @@ -35,8 +35,10 @@ namespace properties { const std::string SelectionProperty::OptionsKey = "Options"; -SelectionProperty::SelectionProperty(std::string identifier, std::string guiName) - : TemplateProperty(std::move(identifier), std::move(guiName), std::vector()) +SelectionProperty::SelectionProperty(std::string identifier, std::string guiName, + Visibility visibility) + : TemplateProperty(std::move(identifier), std::move(guiName), std::vector(), + visibility) {} void SelectionProperty::addOption(Option option) { diff --git a/src/properties/triggerproperty.cpp b/src/properties/triggerproperty.cpp index e0f024f522..75ec76c376 100644 --- a/src/properties/triggerproperty.cpp +++ b/src/properties/triggerproperty.cpp @@ -27,8 +27,9 @@ namespace openspace { namespace properties { -TriggerProperty::TriggerProperty(std::string identifier, std::string guiName) - : Property(std::move(identifier), std::move(guiName)) +TriggerProperty::TriggerProperty(std::string identifier, std::string guiName, + Visibility visibility) + : Property(std::move(identifier), std::move(guiName), visibility) {} std::string TriggerProperty::className() const { From b00595af40508c9269a46595b9899104cdb57e64 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 23 Nov 2016 23:52:16 +0100 Subject: [PATCH 3/9] Replacing const std::string with const char* to reduce binary size and initialization costs --- modules/base/rendering/modelgeometry.cpp | 4 +- modules/base/rendering/multimodelgeometry.cpp | 89 ++++++++----------- modules/base/rendering/planetgeometry.cpp | 2 +- .../renderableconstellationbounds.cpp | 8 +- .../base/rendering/renderablecrawlingline.cpp | 10 +-- modules/base/rendering/renderablemodel.cpp | 12 +-- modules/base/rendering/renderablepath.cpp | 20 ++--- modules/base/rendering/renderableplane.cpp | 14 +-- modules/base/rendering/renderableplanet.cpp | 20 ++--- modules/base/rendering/renderablerings.cpp | 6 +- modules/base/rendering/renderablesphere.cpp | 10 +-- .../rendering/renderablesphericalgrid.cpp | 14 +-- modules/base/rendering/renderablestars.cpp | 8 +- modules/base/rendering/renderabletrail.cpp | 14 +-- .../base/rendering/screenspaceframebuffer.cpp | 7 +- modules/base/rendering/screenspaceimage.cpp | 6 +- .../base/rendering/simplespheregeometry.cpp | 4 +- modules/base/rendering/wavefrontgeometry.cpp | 2 +- modules/base/rotation/spicerotation.cpp | 6 +- modules/base/rotation/staticrotation.cpp | 2 +- modules/base/scale/staticscale.cpp | 4 +- .../base/translation/statictranslation.cpp | 2 +- modules/globebrowsing/chunk/chunkrenderer.cpp | 8 +- modules/globebrowsing/chunk/culling.cpp | 4 - modules/globebrowsing/geometry/aabb.cpp | 1 - modules/globebrowsing/geometry/geodetic2.cpp | 2 - .../globebrowsing/globes/renderableglobe.cpp | 23 ++--- .../tile/tileprovider/cachingtileprovider.cpp | 12 +-- .../tile/tileprovider/singleimageprovider.cpp | 4 +- .../tileprovider/temporaltileprovider.cpp | 12 +-- .../tile/tileprovider/tileprovider.cpp | 2 +- .../rendering/renderablecrawlingline.cpp | 18 ++-- .../newhorizons/rendering/renderablefov.cpp | 18 ++-- .../rendering/renderablemodelprojection.cpp | 14 +-- .../rendering/renderableplaneprojection.cpp | 14 +-- .../rendering/renderableplanetprojection.cpp | 15 ++-- .../rendering/renderableshadowcylinder.cpp | 14 +-- modules/newhorizons/util/decoder.cpp | 2 +- modules/newhorizons/util/hongkangparser.cpp | 2 +- modules/newhorizons/util/imagesequencer.cpp | 2 +- .../newhorizons/util/instrumentdecoder.cpp | 6 +- .../util/instrumenttimesparser.cpp | 10 +-- modules/newhorizons/util/labelparser.cpp | 7 +- .../newhorizons/util/projectioncomponent.cpp | 38 ++++---- modules/newhorizons/util/sequenceparser.cpp | 6 +- modules/onscreengui/src/gui.cpp | 4 +- .../rendering/toyvolumeraycaster.cpp | 6 +- 47 files changed, 242 insertions(+), 266 deletions(-) diff --git a/modules/base/rendering/modelgeometry.cpp b/modules/base/rendering/modelgeometry.cpp index 38288d425e..28e90ed083 100644 --- a/modules/base/rendering/modelgeometry.cpp +++ b/modules/base/rendering/modelgeometry.cpp @@ -35,8 +35,8 @@ namespace { const std::string _loggerCat = "ModelGeometry"; const std::string keyGeomModelFile = "GeometryFile"; const int8_t CurrentCacheVersion = 3; - const std::string keyType = "Type"; - const std::string keyName = "Name"; + const char* keyType = "Type"; + const char* keyName = "Name"; } namespace openspace { diff --git a/modules/base/rendering/multimodelgeometry.cpp b/modules/base/rendering/multimodelgeometry.cpp index fd05e38772..7d427edf46 100644 --- a/modules/base/rendering/multimodelgeometry.cpp +++ b/modules/base/rendering/multimodelgeometry.cpp @@ -35,66 +35,53 @@ namespace { } namespace openspace { - namespace modelgeometry { +namespace modelgeometry { - MultiModelGeometry::MultiModelGeometry(const ghoul::Dictionary& dictionary) - : ModelGeometry(dictionary) - { - loadObj(_file); - } +MultiModelGeometry::MultiModelGeometry(const ghoul::Dictionary& dictionary) + : ModelGeometry(dictionary) +{ + loadObj(_file); +} - bool MultiModelGeometry::initialize(Renderable* parent) - { - bool success = ModelGeometry::initialize(parent); - return success; - } +bool MultiModelGeometry::initialize(Renderable* parent) { + bool success = ModelGeometry::initialize(parent); + return success; +} - void MultiModelGeometry::deinitialize() - { - ModelGeometry::deinitialize(); - } +void MultiModelGeometry::deinitialize() { + ModelGeometry::deinitialize(); +} - bool MultiModelGeometry::loadModel(const std::string& filename) - { - try { - ghoul::io::ModelReaderMultiFormat modelReader; +bool MultiModelGeometry::loadModel(const std::string& filename) { + ghoul::io::ModelReaderMultiFormat modelReader; - std::vector vertices; - std::vector indices; + std::vector vertices; + std::vector indices; - modelReader.loadModel(filename, vertices, indices); + modelReader.loadModel(filename, vertices, indices); - _vertices.reserve(vertices.size()); - for (const auto & v : vertices) - { - psc p = PowerScaledCoordinate::CreatePowerScaledCoordinate( - v.location[0], - v.location[1], - v.location[2] - ); + _vertices.reserve(vertices.size()); + for (const auto & v : vertices) { + psc p = PowerScaledCoordinate::CreatePowerScaledCoordinate( + v.location[0], + v.location[1], + v.location[2] + ); - Vertex vv; - memcpy(vv.location, v.location, sizeof(GLfloat) * 3); - vv.location[3] = 1.0; - //memcpy(vv.location, glm::value_ptr(p.vec4()), sizeof(GLfloat) * 4); - memcpy(vv.tex, v.tex, sizeof(GLfloat) * 2); - memcpy(vv.normal, v.normal, sizeof(GLfloat) * 3); - _vertices.push_back(vv); - } + Vertex vv; + memcpy(vv.location, v.location, sizeof(GLfloat) * 3); + vv.location[3] = 1.0; + //memcpy(vv.location, glm::value_ptr(p.vec4()), sizeof(GLfloat) * 4); + memcpy(vv.tex, v.tex, sizeof(GLfloat) * 2); + memcpy(vv.normal, v.normal, sizeof(GLfloat) * 3); + _vertices.push_back(vv); + } - _indices.resize(indices.size()); - std::copy(indices.begin(), indices.end(), _indices.begin()); - } - catch (ghoul::io::ModelReaderBase::ModelReaderException & e) - { - // Log error reading geometry file. - LERROR(e.message); - return false; - } + _indices.resize(indices.size()); + std::copy(indices.begin(), indices.end(), _indices.begin()); - return true; - } + return true; +} - - } // namespace modelgeometry +} // namespace modelgeometry } // namespace openspace diff --git a/modules/base/rendering/planetgeometry.cpp b/modules/base/rendering/planetgeometry.cpp index a876bbf041..0065e91703 100644 --- a/modules/base/rendering/planetgeometry.cpp +++ b/modules/base/rendering/planetgeometry.cpp @@ -29,7 +29,7 @@ namespace { const std::string _loggerCat = "PlanetGeometry"; - const std::string KeyType = "Type"; + const char* KeyType = "Type"; } namespace openspace { diff --git a/modules/base/rendering/renderableconstellationbounds.cpp b/modules/base/rendering/renderableconstellationbounds.cpp index ea7b07c85c..735bac4408 100644 --- a/modules/base/rendering/renderableconstellationbounds.cpp +++ b/modules/base/rendering/renderableconstellationbounds.cpp @@ -40,11 +40,11 @@ namespace { const std::string _loggerCat = "RenderableConstellationBounds"; - const std::string keyVertexFile = "File"; - const std::string keyConstellationFile = "ConstellationFile"; - const std::string keyReferenceFrame = "ReferenceFrame"; + const char* keyVertexFile = "File"; + const char* keyConstellationFile = "ConstellationFile"; + const char* keyReferenceFrame = "ReferenceFrame"; - const std::string defaultReferenceFrame = "J2000"; + const char* defaultReferenceFrame = "J2000"; float deg2rad(float deg) { return static_cast((deg / 360.f) * 2.f * M_PI); diff --git a/modules/base/rendering/renderablecrawlingline.cpp b/modules/base/rendering/renderablecrawlingline.cpp index 0500781d21..15866f580f 100644 --- a/modules/base/rendering/renderablecrawlingline.cpp +++ b/modules/base/rendering/renderablecrawlingline.cpp @@ -33,11 +33,11 @@ namespace { const std::string _loggerCat = "RenderableCrawlingLine"; - const std::string KeySource = "Source"; - const std::string KeyTarget = "Target"; - const std::string KeyInstrument = "Instrument"; - const std::string KeyReferenceFrame = "Frame"; - const std::string keyColor = "RGB"; + const char* KeySource = "Source"; + const char* KeyTarget = "Target"; + const char* KeyInstrument = "Instrument"; + const char* KeyReferenceFrame = "Frame"; + const char* keyColor = "RGB"; static const int SourcePosition = 0; static const int TargetPosition = 1; diff --git a/modules/base/rendering/renderablemodel.cpp b/modules/base/rendering/renderablemodel.cpp index 1c908c5299..aab085b9ae 100644 --- a/modules/base/rendering/renderablemodel.cpp +++ b/modules/base/rendering/renderablemodel.cpp @@ -42,13 +42,13 @@ namespace { const std::string _loggerCat = "RenderableModel"; - const std::string keyGeometry = "Geometry"; - const std::string keyBody = "Body"; - const std::string keyStart = "StartTime"; - const std::string keyEnd = "EndTime"; - const std::string keyFading = "Shading.Fadeable"; + const char* keyGeometry = "Geometry"; + const char* keyBody = "Body"; + const char* keyStart = "StartTime"; + const char* keyEnd = "EndTime"; + const char* keyFading = "Shading.Fadeable"; - const std::string keyModelTransform = "Rotation.ModelTransform"; + const char* keyModelTransform = "Rotation.ModelTransform"; //const std::string keyGhosting = "Shading.Ghosting"; } diff --git a/modules/base/rendering/renderablepath.cpp b/modules/base/rendering/renderablepath.cpp index be5547aefd..b94d02f178 100644 --- a/modules/base/rendering/renderablepath.cpp +++ b/modules/base/rendering/renderablepath.cpp @@ -42,16 +42,16 @@ namespace { const std::string _loggerCat = "RenderableTrail"; //constants - const std::string keyName = "Name"; - const std::string keyBody = "Body"; - const std::string keyObserver = "Observer"; - const std::string keyFrame = "Frame"; - const std::string keyPathModule = "ModulePath"; - const std::string keyColor = "RGB"; - const std::string keyTimeSteps = "TimeSteps"; - const std::string keyPointSteps = "PointSteps"; - const std::string keyDrawLine = "DrawLine"; - const std::string keRenderDistanceInterval = "RenderDistanceInterval"; + const char* keyName = "Name"; + const char* keyBody = "Body"; + const char* keyObserver = "Observer"; + const char* keyFrame = "Frame"; + const char* keyPathModule = "ModulePath"; + const char* keyColor = "RGB"; + const char* keyTimeSteps = "TimeSteps"; + const char* keyPointSteps = "PointSteps"; + const char* keyDrawLine = "DrawLine"; + const char* keRenderDistanceInterval = "RenderDistanceInterval"; } diff --git a/modules/base/rendering/renderableplane.cpp b/modules/base/rendering/renderableplane.cpp index 3d43ee6c66..3c88efce3a 100644 --- a/modules/base/rendering/renderableplane.cpp +++ b/modules/base/rendering/renderableplane.cpp @@ -38,14 +38,14 @@ #include namespace { - const std::string _loggerCat = "RenderablePlane"; + static const std::string _loggerCat = "RenderablePlane"; - const std::string keyFieldlines = "Fieldlines"; - const std::string keyFilename = "File"; - const std::string keyHints = "Hints"; - const std::string keyShaders = "Shaders"; - const std::string keyVertexShader = "VertexShader"; - const std::string keyFragmentShader = "FragmentShader"; + const char* keyFieldlines = "Fieldlines"; + const char* keyFilename = "File"; + const char* keyHints = "Hints"; + const char* keyShaders = "Shaders"; + const char* keyVertexShader = "VertexShader"; + const char* keyFragmentShader = "FragmentShader"; } namespace openspace { diff --git a/modules/base/rendering/renderableplanet.cpp b/modules/base/rendering/renderableplanet.cpp index bedd4ca84b..1a4ae0d7a9 100644 --- a/modules/base/rendering/renderableplanet.cpp +++ b/modules/base/rendering/renderableplanet.cpp @@ -48,17 +48,17 @@ namespace { - const std::string _loggerCat = "RenderablePlanet"; + static const std::string _loggerCat = "RenderablePlanet"; - const std::string keyFrame = "Frame"; - const std::string keyGeometry = "Geometry"; - const std::string keyRadius = "Radius"; - const std::string keyShading = "PerformShading"; - const std::string keyShadowGroup = "Shadow_Group"; - const std::string keyShadowSource = "Source"; - const std::string keyShadowCaster = "Caster"; - const std::string keyPlanetRadius = "PlanetRadius"; - const std::string keyBody = "Body"; + const char* keyFrame = "Frame"; + const char* keyGeometry = "Geometry"; + const char* keyRadius = "Radius"; + const char* keyShading = "PerformShading"; + const char* keyShadowGroup = "Shadow_Group"; + const char* keyShadowSource = "Source"; + const char* keyShadowCaster = "Caster"; + const char* keyPlanetRadius = "PlanetRadius"; + const char* keyBody = "Body"; } namespace openspace { diff --git a/modules/base/rendering/renderablerings.cpp b/modules/base/rendering/renderablerings.cpp index 6ee8ed363f..c225968011 100644 --- a/modules/base/rendering/renderablerings.cpp +++ b/modules/base/rendering/renderablerings.cpp @@ -36,9 +36,9 @@ #include namespace { - const std::string KeyTexture = "Texture"; - const std::string KeySize = "Size"; - const std::string KeyOffset = "Offset"; + const char* KeyTexture = "Texture"; + const char* KeySize = "Size"; + const char* KeyOffset = "Offset"; } namespace openspace { diff --git a/modules/base/rendering/renderablesphere.cpp b/modules/base/rendering/renderablesphere.cpp index fb619e8255..ce5049df5a 100644 --- a/modules/base/rendering/renderablesphere.cpp +++ b/modules/base/rendering/renderablesphere.cpp @@ -36,12 +36,12 @@ #include namespace { - const std::string _loggerCat = "RenderableSphere"; + static const std::string _loggerCat = "RenderableSphere"; - const std::string keySize = "Size"; - const std::string keySegments = "Segments"; - const std::string keyTexture = "Texture"; - const std::string keyOrientation = "Orientation"; + const char* keySize = "Size"; + const char* keySegments = "Segments"; + const char* keyTexture = "Texture"; + const char* keyOrientation = "Orientation"; enum Orientation { Outside = 1, diff --git a/modules/base/rendering/renderablesphericalgrid.cpp b/modules/base/rendering/renderablesphericalgrid.cpp index b1f62cdb87..6fc2743814 100644 --- a/modules/base/rendering/renderablesphericalgrid.cpp +++ b/modules/base/rendering/renderablesphericalgrid.cpp @@ -32,13 +32,13 @@ #include namespace { - const std::string _loggerCat = "RenderableSphericalGrid"; - const std::string KeyGridType = "GridType"; - const std::string KeyGridColor = "GridColor"; - const std::string KeyGridMatrix = "GridMatrix"; - const std::string KeyGridSegments = "GridSegments"; - const std::string KeyGridRadius = "GridRadius"; - const std::string KeyGridParentsRotation = "ParentsRotation"; + static const std::string _loggerCat = "RenderableSphericalGrid"; + const char* KeyGridType = "GridType"; + const char* KeyGridColor = "GridColor"; + const char* KeyGridMatrix = "GridMatrix"; + const char* KeyGridSegments = "GridSegments"; + const char* KeyGridRadius = "GridRadius"; + const char* KeyGridParentsRotation = "ParentsRotation"; } namespace openspace { diff --git a/modules/base/rendering/renderablestars.cpp b/modules/base/rendering/renderablestars.cpp index a4a3c6b882..60d999b5a3 100644 --- a/modules/base/rendering/renderablestars.cpp +++ b/modules/base/rendering/renderablestars.cpp @@ -41,11 +41,11 @@ #include namespace { - const std::string _loggerCat = "RenderableStars"; + static const std::string _loggerCat = "RenderableStars"; - const std::string KeyFile = "File"; - const std::string KeyTexture = "Texture"; - const std::string KeyColorMap = "ColorMap"; + const char* KeyFile = "File"; + const char* KeyTexture = "Texture"; + const char* KeyColorMap = "ColorMap"; const int8_t CurrentCacheVersion = 1; diff --git a/modules/base/rendering/renderabletrail.cpp b/modules/base/rendering/renderabletrail.cpp index 9ca1e97652..b150cbb871 100644 --- a/modules/base/rendering/renderabletrail.cpp +++ b/modules/base/rendering/renderabletrail.cpp @@ -30,13 +30,13 @@ #include namespace { - static const char* KeyTranslation = "Translation"; - static const char* KeyColor = "Color"; - static const char* KeyEnableFade = "EnableFade"; - static const char* KeyFade = "Fade"; - static const char* KeyLineWidth = "LineWidth"; - static const char* KeyPointSize = "PointSize"; - static const char* KeyRendering = "Rendering"; + const char* KeyTranslation = "Translation"; + const char* KeyColor = "Color"; + const char* KeyEnableFade = "EnableFade"; + const char* KeyFade = "Fade"; + const char* KeyLineWidth = "LineWidth"; + const char* KeyPointSize = "PointSize"; + const char* KeyRendering = "Rendering"; // The possible values for the _renderingModes property enum RenderingMode { diff --git a/modules/base/rendering/screenspaceframebuffer.cpp b/modules/base/rendering/screenspaceframebuffer.cpp index e2a8fa1a9d..812a1831a4 100644 --- a/modules/base/rendering/screenspaceframebuffer.cpp +++ b/modules/base/rendering/screenspaceframebuffer.cpp @@ -33,10 +33,11 @@ #include namespace openspace { + ScreenSpaceFramebuffer::ScreenSpaceFramebuffer(const ghoul::Dictionary& dictionary) - :ScreenSpaceRenderable(dictionary) - ,_size("size", "Size", glm::vec4(0), glm::vec4(0), glm::vec4(2000)) - ,_framebuffer(nullptr) + : ScreenSpaceRenderable(dictionary) + , _size("size", "Size", glm::vec4(0), glm::vec4(0), glm::vec4(2000)) + , _framebuffer(nullptr) { _id = id(); setName("ScreenSpaceFramebuffer" + std::to_string(_id)); diff --git a/modules/base/rendering/screenspaceimage.cpp b/modules/base/rendering/screenspaceimage.cpp index fa208ee104..d68bd151c0 100644 --- a/modules/base/rendering/screenspaceimage.cpp +++ b/modules/base/rendering/screenspaceimage.cpp @@ -35,9 +35,9 @@ namespace { const std::string _loggerCat = "ScreenSpaceImage"; - const std::string KeyName = "Name"; - const std::string KeyTexturePath = "TexturePath"; - const std::string KeyUrl = "URL"; + const char* KeyName = "Name"; + const char* KeyTexturePath = "TexturePath"; + const char* KeyUrl = "URL"; } namespace openspace { diff --git a/modules/base/rendering/simplespheregeometry.cpp b/modules/base/rendering/simplespheregeometry.cpp index 36ac52afb5..3bb4358f03 100644 --- a/modules/base/rendering/simplespheregeometry.cpp +++ b/modules/base/rendering/simplespheregeometry.cpp @@ -34,8 +34,8 @@ namespace openspace { namespace constants { namespace simplespheregeometry { -const std::string keyRadius = "Radius"; -const std::string keySegments = "Segments"; + const char* keyRadius = "Radius"; + const char* keySegments = "Segments"; } // namespace simplespheregeometry } diff --git a/modules/base/rendering/wavefrontgeometry.cpp b/modules/base/rendering/wavefrontgeometry.cpp index 8125e73dd2..c24014f7ee 100644 --- a/modules/base/rendering/wavefrontgeometry.cpp +++ b/modules/base/rendering/wavefrontgeometry.cpp @@ -28,7 +28,7 @@ #include namespace { - const std::string _loggerCat = "WavefrontGeometry"; + static const std::string _loggerCat = "WavefrontGeometry"; } namespace openspace { diff --git a/modules/base/rotation/spicerotation.cpp b/modules/base/rotation/spicerotation.cpp index d671f76d6c..76aaf6dbf3 100644 --- a/modules/base/rotation/spicerotation.cpp +++ b/modules/base/rotation/spicerotation.cpp @@ -33,9 +33,9 @@ namespace { const std::string _loggerCat = "SpiceRotation"; //const std::string keyGhosting = "EphmerisGhosting"; - const std::string KeySourceFrame = "SourceFrame"; - const std::string KeyDestinationFrame = "DestinationFrame"; - const std::string KeyKernels = "Kernels"; + const char* KeySourceFrame = "SourceFrame"; + const char* KeyDestinationFrame = "DestinationFrame"; + const char* KeyKernels = "Kernels"; } namespace openspace { diff --git a/modules/base/rotation/staticrotation.cpp b/modules/base/rotation/staticrotation.cpp index 85e528060b..5c645d4143 100644 --- a/modules/base/rotation/staticrotation.cpp +++ b/modules/base/rotation/staticrotation.cpp @@ -27,7 +27,7 @@ #include namespace { - const std::string KeyRotation = "Rotation"; + const char* KeyRotation = "Rotation"; } namespace openspace { diff --git a/modules/base/scale/staticscale.cpp b/modules/base/scale/staticscale.cpp index c80a27f992..b868291e43 100644 --- a/modules/base/scale/staticscale.cpp +++ b/modules/base/scale/staticscale.cpp @@ -27,8 +27,8 @@ #include namespace { - const std::string _loggerCat = "StaticScale"; - const std::string KeyValue = "Scale"; + const char* _loggerCat = "StaticScale"; + const char* KeyValue = "Scale"; } namespace openspace { diff --git a/modules/base/translation/statictranslation.cpp b/modules/base/translation/statictranslation.cpp index 1b6bb288ce..e0e3e85b42 100644 --- a/modules/base/translation/statictranslation.cpp +++ b/modules/base/translation/statictranslation.cpp @@ -27,7 +27,7 @@ #include namespace { - const std::string KeyPosition = "Position"; + const char* KeyPosition = "Position"; } namespace openspace { diff --git a/modules/globebrowsing/chunk/chunkrenderer.cpp b/modules/globebrowsing/chunk/chunkrenderer.cpp index 7d7cc560fe..8696ecf39d 100644 --- a/modules/globebrowsing/chunk/chunkrenderer.cpp +++ b/modules/globebrowsing/chunk/chunkrenderer.cpp @@ -47,11 +47,11 @@ namespace { const std::string _loggerCat = "PatchRenderer"; - const std::string keyFrame = "Frame"; - const std::string keyGeometry = "Geometry"; - const std::string keyShading = "PerformShading"; + const char* keyFrame = "Frame"; + const char* keyGeometry = "Geometry"; + const char* keyShading = "PerformShading"; - const std::string keyBody = "Body"; + const char* keyBody = "Body"; } namespace openspace { diff --git a/modules/globebrowsing/chunk/culling.cpp b/modules/globebrowsing/chunk/culling.cpp index c281f6d7cb..33bf13a7c4 100644 --- a/modules/globebrowsing/chunk/culling.cpp +++ b/modules/globebrowsing/chunk/culling.cpp @@ -22,10 +22,6 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ - - - - #include #include #include diff --git a/modules/globebrowsing/geometry/aabb.cpp b/modules/globebrowsing/geometry/aabb.cpp index 43fe4154fd..a572969bd3 100644 --- a/modules/globebrowsing/geometry/aabb.cpp +++ b/modules/globebrowsing/geometry/aabb.cpp @@ -22,7 +22,6 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ - #include #include diff --git a/modules/globebrowsing/geometry/geodetic2.cpp b/modules/globebrowsing/geometry/geodetic2.cpp index 4b0eb79519..abceb33ab7 100644 --- a/modules/globebrowsing/geometry/geodetic2.cpp +++ b/modules/globebrowsing/geometry/geodetic2.cpp @@ -28,8 +28,6 @@ #include - - namespace { const std::string _loggerCat = "Geodetic2"; } diff --git a/modules/globebrowsing/globes/renderableglobe.cpp b/modules/globebrowsing/globes/renderableglobe.cpp index 52b5f012b0..362c1832aa 100644 --- a/modules/globebrowsing/globes/renderableglobe.cpp +++ b/modules/globebrowsing/globes/renderableglobe.cpp @@ -39,27 +39,22 @@ // ghoul includes #include - namespace { const std::string _loggerCat = "RenderableGlobe"; // Keys for the dictionary - const std::string keyFrame = "Frame"; - const std::string keyRadii = "Radii"; - const std::string keyInteractionDepthBelowEllipsoid = "InteractionDepthBelowEllipsoid"; - const std::string keyCameraMinHeight = "CameraMinHeight"; - const std::string keySegmentsPerPatch = "SegmentsPerPatch"; - const std::string keyTextureInitData = "TextureInitData"; - const std::string keyTextures = "Textures"; - const std::string keyColorTextures = "ColorTextures"; - const std::string keyHeightMaps = "HeightMaps"; + const char* keyFrame = "Frame"; + const char* keyRadii = "Radii"; + const char* keyInteractionDepthBelowEllipsoid = "InteractionDepthBelowEllipsoid"; + const char* keyCameraMinHeight = "CameraMinHeight"; + const char* keySegmentsPerPatch = "SegmentsPerPatch"; + const char* keyTextureInitData = "TextureInitData"; + const char* keyTextures = "Textures"; + const char* keyColorTextures = "ColorTextures"; + const char* keyHeightMaps = "HeightMaps"; } - - namespace openspace { - - RenderableGlobe::RenderableGlobe(const ghoul::Dictionary& dictionary) : _isEnabled(properties::BoolProperty("Enabled", "Enabled", true)) , _toggleEnabledEveryFrame(properties::BoolProperty("Toggle enabled every frame", "Toggle enabled every frame", false)) diff --git a/modules/globebrowsing/tile/tileprovider/cachingtileprovider.cpp b/modules/globebrowsing/tile/tileprovider/cachingtileprovider.cpp index 377d34c924..34966599a8 100644 --- a/modules/globebrowsing/tile/tileprovider/cachingtileprovider.cpp +++ b/modules/globebrowsing/tile/tileprovider/cachingtileprovider.cpp @@ -35,11 +35,11 @@ namespace { const std::string _loggerCat = "CachingTileProvider"; - const std::string KeyDoPreProcessing = "DoPreProcessing"; - const std::string KeyMinimumPixelSize = "MinimumPixelSize"; - const std::string KeyFilePath = "FilePath"; - const std::string KeyCacheSize = "CacheSize"; - const std::string KeyFlushInterval = "FlushInterval"; + const char* KeyDoPreProcessing = "DoPreProcessing"; + const char* KeyMinimumPixelSize = "MinimumPixelSize"; + const char* KeyFilePath = "FilePath"; + const char* KeyCacheSize = "CacheSize"; + const char* KeyFlushInterval = "FlushInterval"; } namespace openspace { @@ -54,7 +54,7 @@ namespace openspace { // 1. Get required Keys std::string filePath; if (!dictionary.getValue(KeyFilePath, filePath)) { - throw std::runtime_error("Must define key '" + KeyFilePath + "'"); + throw std::runtime_error(std::string("Must define key '") + KeyFilePath + "'"); } // 2. Initialize default values for any optional Keys diff --git a/modules/globebrowsing/tile/tileprovider/singleimageprovider.cpp b/modules/globebrowsing/tile/tileprovider/singleimageprovider.cpp index e88464c5c0..f20837db84 100644 --- a/modules/globebrowsing/tile/tileprovider/singleimageprovider.cpp +++ b/modules/globebrowsing/tile/tileprovider/singleimageprovider.cpp @@ -35,7 +35,7 @@ namespace { const std::string _loggerCat = "SingleImageProvider"; - const std::string KeyFilePath = "FilePath"; + const char* KeyFilePath = "FilePath"; } namespace openspace { @@ -43,7 +43,7 @@ namespace openspace { SingleImageProvider::SingleImageProvider(const ghoul::Dictionary& dictionary) { // Required input if (!dictionary.getValue(KeyFilePath, _imagePath)) { - throw std::runtime_error("Must define key '" + KeyFilePath + "'"); + throw std::runtime_error(std::string("Must define key '") + KeyFilePath + "'"); } reset(); diff --git a/modules/globebrowsing/tile/tileprovider/temporaltileprovider.cpp b/modules/globebrowsing/tile/tileprovider/temporaltileprovider.cpp index 2cdbefd741..3dca224978 100644 --- a/modules/globebrowsing/tile/tileprovider/temporaltileprovider.cpp +++ b/modules/globebrowsing/tile/tileprovider/temporaltileprovider.cpp @@ -48,11 +48,11 @@ namespace { const std::string _loggerCat = "TemporalTileProvider"; - const std::string KeyDoPreProcessing = "DoPreProcessing"; - const std::string KeyMinimumPixelSize = "MinimumPixelSize"; - const std::string KeyFilePath = "FilePath"; - const std::string KeyCacheSize = "CacheSize"; - const std::string KeyFlushInterval = "FlushInterval"; + const char* KeyDoPreProcessing = "DoPreProcessing"; + const char* KeyMinimumPixelSize = "MinimumPixelSize"; + const char* KeyFilePath = "FilePath"; + const char* KeyCacheSize = "CacheSize"; + const char* KeyFlushInterval = "FlushInterval"; } @@ -71,7 +71,7 @@ namespace openspace { { if (!dictionary.getValue(KeyFilePath, _datasetFile)) { - throw std::runtime_error("Must define key '" + KeyFilePath + "'"); + throw std::runtime_error(std::string("Must define key '") + KeyFilePath + "'"); } diff --git a/modules/globebrowsing/tile/tileprovider/tileprovider.cpp b/modules/globebrowsing/tile/tileprovider/tileprovider.cpp index f47121ec71..09fea2169a 100644 --- a/modules/globebrowsing/tile/tileprovider/tileprovider.cpp +++ b/modules/globebrowsing/tile/tileprovider/tileprovider.cpp @@ -32,7 +32,7 @@ namespace { const std::string _loggerCat = "TileProvider"; - const std::string KeyType = "Type"; + const char* KeyType = "Type"; } diff --git a/modules/newhorizons/rendering/renderablecrawlingline.cpp b/modules/newhorizons/rendering/renderablecrawlingline.cpp index 1c0035e086..7a78fa451c 100644 --- a/modules/newhorizons/rendering/renderablecrawlingline.cpp +++ b/modules/newhorizons/rendering/renderablecrawlingline.cpp @@ -32,11 +32,11 @@ namespace { const std::string _loggerCat = "RenderableCrawlingLine"; - const std::string KeySource = "Source"; - const std::string KeyTarget = "Target"; - const std::string KeyInstrument = "Instrument"; - const std::string KeyReferenceFrame = "Frame"; - const std::string keyColor = "RGB"; + const char* KeySource = "Source"; + const char* KeyTarget = "Target"; + const char* KeyInstrument = "Instrument"; + const char* KeyReferenceFrame = "Frame"; + const char* KeyColor = "RGB"; static const int SourcePosition = 0; static const int TargetPosition = 1; @@ -59,10 +59,12 @@ RenderableCrawlingLine::RenderableCrawlingLine(const ghoul::Dictionary& dictiona dictionary.getValue(KeyReferenceFrame, _referenceFrame); - if (dictionary.hasKeyAndValue(keyColor)) - dictionary.getValue(keyColor, _lineColor); - else + if (dictionary.hasKeyAndValue(KeyColor)) { + dictionary.getValue(KeyColor, _lineColor); + } + else { _lineColor = glm::vec3(1); + } } bool RenderableCrawlingLine::isReady() const { diff --git a/modules/newhorizons/rendering/renderablefov.cpp b/modules/newhorizons/rendering/renderablefov.cpp index eb7d419780..1ecf156eeb 100644 --- a/modules/newhorizons/rendering/renderablefov.cpp +++ b/modules/newhorizons/rendering/renderablefov.cpp @@ -38,15 +38,15 @@ namespace { const std::string _loggerCat = "RenderableFov"; - const std::string keyBody = "Body"; - const std::string keyFrame = "Frame"; - const std::string keyPathModule = "ModulePath"; - const std::string keyColor = "RGB"; - const std::string keyInstrument = "Instrument.Name"; - const std::string keyInstrumentMethod = "Instrument.Method"; - const std::string keyInstrumentAberration = "Instrument.Aberration"; - const std::string keyPotentialTargets = "PotentialTargets"; - const std::string keyFrameConversions = "FrameConversions"; + const char* keyBody = "Body"; + const char* keyFrame = "Frame"; + const char* keyPathModule = "ModulePath"; + const char* keyColor = "RGB"; + const char* keyInstrument = "Instrument.Name"; + const char* keyInstrumentMethod = "Instrument.Method"; + const char* keyInstrumentAberration = "Instrument.Aberration"; + const char* keyPotentialTargets = "PotentialTargets"; + const char* keyFrameConversions = "FrameConversions"; const int InterpolationSteps = 10; const int Stride = 8; diff --git a/modules/newhorizons/rendering/renderablemodelprojection.cpp b/modules/newhorizons/rendering/renderablemodelprojection.cpp index 76dc7dd40a..383eb707f5 100644 --- a/modules/newhorizons/rendering/renderablemodelprojection.cpp +++ b/modules/newhorizons/rendering/renderablemodelprojection.cpp @@ -37,15 +37,15 @@ namespace { const std::string _loggerCat = "RenderableModelProjection"; - const std::string keySource = "Rotation.Source"; - const std::string keyDestination = "Rotation.Destination"; - const std::string keyGeometry = "Geometry"; - const std::string keyProjection = "Projection"; - const std::string keyBoundingSphereRadius = "BoundingSphereRadius"; + const char* keySource = "Rotation.Source"; + const char* keyDestination = "Rotation.Destination"; + const char* keyGeometry = "Geometry"; + const char* keyProjection = "Projection"; + const char* keyBoundingSphereRadius = "BoundingSphereRadius"; - const std::string keyTextureColor = "Textures.Color"; + const char* keyTextureColor = "Textures.Color"; - const std::string _destination = "GALACTIC"; + const char* _destination = "GALACTIC"; } namespace openspace { diff --git a/modules/newhorizons/rendering/renderableplaneprojection.cpp b/modules/newhorizons/rendering/renderableplaneprojection.cpp index aebafda854..cdbd805b26 100644 --- a/modules/newhorizons/rendering/renderableplaneprojection.cpp +++ b/modules/newhorizons/rendering/renderableplaneprojection.cpp @@ -41,13 +41,13 @@ namespace { const std::string _loggerCat = "RenderablePlaneProjection"; - const std::string KeySpacecraft = "Spacecraft"; - const std::string KeyInstrument = "Instrument"; - const std::string KeyMoving = "Moving"; - const std::string KeyTexture = "Texture"; - const std::string KeyName = "Name"; - const std::string KeyTarget = "DefaultTarget"; - const std::string GalacticFrame = "GALACTIC"; + const char* KeySpacecraft = "Spacecraft"; + const char* KeyInstrument = "Instrument"; + const char* KeyMoving = "Moving"; + const char* KeyTexture = "Texture"; + const char* KeyName = "Name"; + const char* KeyTarget = "DefaultTarget"; + const char* GalacticFrame = "GALACTIC"; const double REALLY_FAR = 99999999999; } diff --git a/modules/newhorizons/rendering/renderableplanetprojection.cpp b/modules/newhorizons/rendering/renderableplanetprojection.cpp index 7c23587503..56c82c0c4e 100644 --- a/modules/newhorizons/rendering/renderableplanetprojection.cpp +++ b/modules/newhorizons/rendering/renderableplanetprojection.cpp @@ -46,15 +46,14 @@ namespace { const std::string _loggerCat = "RenderablePlanetProjection"; - const std::string keyGeometry = "Geometry"; - const std::string keyProjection = "Projection"; - const std::string keyColorTexture = "Textures.Color"; - const std::string keyHeightTexture = "Textures.Height"; + const char* keyGeometry = "Geometry"; + const char* keyProjection = "Projection"; + const char* keyColorTexture = "Textures.Color"; + const char* keyHeightTexture = "Textures.Height"; - - const std::string keyRadius = "Geometry.Radius"; - const std::string keyShading = "PerformShading"; - const std::string _mainFrame = "GALACTIC"; + const char* keyRadius = "Geometry.Radius"; + const char* keyShading = "PerformShading"; + const char* _mainFrame = "GALACTIC"; } namespace openspace { diff --git a/modules/newhorizons/rendering/renderableshadowcylinder.cpp b/modules/newhorizons/rendering/renderableshadowcylinder.cpp index 6e4b9930cd..1064230acf 100644 --- a/modules/newhorizons/rendering/renderableshadowcylinder.cpp +++ b/modules/newhorizons/rendering/renderableshadowcylinder.cpp @@ -35,13 +35,13 @@ namespace { const std::string _loggerCat = "RenderablePlane"; - const std::string KeyType = "TerminatorType"; - const std::string KeyLightSource = "LightSource"; - const std::string KeyObserver = "Observer"; - const std::string KeyBody = "Body"; - const std::string KeyBodyFrame = "BodyFrame"; - const std::string KeyMainFrame = "MainFrame"; - const std::string KeyAberration = "Aberration"; + const char* KeyType = "TerminatorType"; + const char* KeyLightSource = "LightSource"; + const char* KeyObserver = "Observer"; + const char* KeyBody = "Body"; + const char* KeyBodyFrame = "BodyFrame"; + const char* KeyMainFrame = "MainFrame"; + const char* KeyAberration = "Aberration"; } namespace openspace { diff --git a/modules/newhorizons/util/decoder.cpp b/modules/newhorizons/util/decoder.cpp index 74e1c9b87a..c6a7a600f2 100644 --- a/modules/newhorizons/util/decoder.cpp +++ b/modules/newhorizons/util/decoder.cpp @@ -30,7 +30,7 @@ #include namespace { -const std::string _loggerCat = "Decoder"; + const std::string _loggerCat = "Decoder"; } namespace openspace { diff --git a/modules/newhorizons/util/hongkangparser.cpp b/modules/newhorizons/util/hongkangparser.cpp index bd8a20b7ac..bc2fa7dd73 100644 --- a/modules/newhorizons/util/hongkangparser.cpp +++ b/modules/newhorizons/util/hongkangparser.cpp @@ -42,7 +42,7 @@ namespace { const std::string _loggerCat = "HongKangParser"; - const std::string keyTranslation = "DataInputTranslation"; + const char* keyTranslation = "DataInputTranslation"; const std::string PlaybookIdentifierName = "HongKang"; } diff --git a/modules/newhorizons/util/imagesequencer.cpp b/modules/newhorizons/util/imagesequencer.cpp index e5e1f5233e..dd83e9f2dc 100644 --- a/modules/newhorizons/util/imagesequencer.cpp +++ b/modules/newhorizons/util/imagesequencer.cpp @@ -37,7 +37,7 @@ #include namespace { -const std::string _loggerCat = "ImageSequencer"; + const std::string _loggerCat = "ImageSequencer"; } namespace openspace { diff --git a/modules/newhorizons/util/instrumentdecoder.cpp b/modules/newhorizons/util/instrumentdecoder.cpp index b575f0cf32..e4cc9d07eb 100644 --- a/modules/newhorizons/util/instrumentdecoder.cpp +++ b/modules/newhorizons/util/instrumentdecoder.cpp @@ -29,9 +29,9 @@ namespace { const std::string _loggerCat = "InstrumentDecoder"; - const std::string keyDetector = "DetectorType"; - const std::string keySpice = "Spice"; - const std::string keyStopCommand = "StopCommand"; + const char* keyDetector = "DetectorType"; + const char* keySpice = "Spice"; + const char* keyStopCommand = "StopCommand"; } namespace openspace { diff --git a/modules/newhorizons/util/instrumenttimesparser.cpp b/modules/newhorizons/util/instrumenttimesparser.cpp index 92765eb190..973c7c425c 100644 --- a/modules/newhorizons/util/instrumenttimesparser.cpp +++ b/modules/newhorizons/util/instrumenttimesparser.cpp @@ -39,11 +39,11 @@ namespace { const std::string _loggerCat = "InstrumentTimesParser"; - const std::string PlaybookIdentifierName = "InstrumentTimesParser"; - const std::string KeyTargetBody = "Target.Body"; - const std::string KeyInstruments = "Instruments"; - const std::string KeyInstrument = "Instrument"; - const std::string KeyInstrumentFiles = "Files"; + const char* PlaybookIdentifierName = "InstrumentTimesParser"; + const char* KeyTargetBody = "Target.Body"; + const char* KeyInstruments = "Instruments"; + const char* KeyInstrument = "Instrument"; + const char* KeyInstrumentFiles = "Files"; } namespace openspace { diff --git a/modules/newhorizons/util/labelparser.cpp b/modules/newhorizons/util/labelparser.cpp index bccdb49ff6..a3f9279cee 100644 --- a/modules/newhorizons/util/labelparser.cpp +++ b/modules/newhorizons/util/labelparser.cpp @@ -39,13 +39,12 @@ #include #include - namespace { const std::string _loggerCat = "LabelParser"; - const std::string keySpecs = "Read"; - const std::string keyConvert = "Convert"; + const char* keySpecs = "Read"; + const char* keyConvert = "Convert"; - const std::string PlaybookIdentifierName = "LabelParser"; + const char* PlaybookIdentifierName = "LabelParser"; } namespace openspace { diff --git a/modules/newhorizons/util/projectioncomponent.cpp b/modules/newhorizons/util/projectioncomponent.cpp index e8ee1be4b2..e013c2c7e8 100644 --- a/modules/newhorizons/util/projectioncomponent.cpp +++ b/modules/newhorizons/util/projectioncomponent.cpp @@ -40,34 +40,34 @@ #include namespace { - const std::string keyPotentialTargets = "PotentialTargets"; + const char* keyPotentialTargets = "PotentialTargets"; - const std::string keyInstrument = "Instrument.Name"; - const std::string keyInstrumentFovy = "Instrument.Fovy"; - const std::string keyInstrumentAspect = "Instrument.Aspect"; + const char* keyInstrument = "Instrument.Name"; + const char* keyInstrumentFovy = "Instrument.Fovy"; + const char* keyInstrumentAspect = "Instrument.Aspect"; - const std::string keyTranslation = "DataInputTranslation"; + const char* keyTranslation = "DataInputTranslation"; - const std::string keyProjObserver = "Observer"; - const std::string keyProjTarget = "Target"; - const std::string keyProjAberration = "Aberration"; + const char* keyProjObserver = "Observer"; + const char* keyProjTarget = "Target"; + const char* keyProjAberration = "Aberration"; - const std::string keySequenceDir = "Sequence"; - const std::string keySequenceType = "SequenceType"; + const char* keySequenceDir = "Sequence"; + const char* keySequenceType = "SequenceType"; - const std::string keyNeedsTextureMapDilation = "TextureMap"; - const std::string keyNeedsShadowing = "ShadowMap"; - const std::string keyTextureMapAspectRatio = "AspectRatio"; + const char* keyNeedsTextureMapDilation = "TextureMap"; + const char* keyNeedsShadowing = "ShadowMap"; + const char* keyTextureMapAspectRatio = "AspectRatio"; - const std::string sequenceTypeImage = "image-sequence"; - const std::string sequenceTypePlaybook = "playbook"; - const std::string sequenceTypeHybrid = "hybrid"; - const std::string sequenceTypeInstrumentTimes = "instrument-times"; + const char* sequenceTypeImage = "image-sequence"; + const char* sequenceTypePlaybook = "playbook"; + const char* sequenceTypeHybrid = "hybrid"; + const char* sequenceTypeInstrumentTimes = "instrument-times"; - const std::string placeholderFile = + const char* placeholderFile = "${OPENSPACE_DATA}/scene/common/textures/placeholder.png"; - const std::string _loggerCat = "ProjectionComponent"; + const char* _loggerCat = "ProjectionComponent"; } namespace openspace { diff --git a/modules/newhorizons/util/sequenceparser.cpp b/modules/newhorizons/util/sequenceparser.cpp index 6e36361fa6..9ed8e0f95f 100644 --- a/modules/newhorizons/util/sequenceparser.cpp +++ b/modules/newhorizons/util/sequenceparser.cpp @@ -32,9 +32,9 @@ namespace { const std::string _loggerCat = "SequenceParser"; - const std::string keyTranslation = "DataInputTranslation"; + const char* keyTranslation = "DataInputTranslation"; - const std::string PlaybookIdentifierName = "Playbook"; + const char* PlaybookIdentifierName = "Playbook"; } namespace openspace { @@ -79,7 +79,7 @@ void writeToBuffer(std::vector& buffer, size_t& currentWriteL } void SequenceParser::sendPlaybookInformation(const std::string& name) { - std::string fullName = PlaybookIdentifierName + "_" + name; + std::string fullName = std::string(PlaybookIdentifierName) + "_" + name; _messageIdentifier = OsEng.networkEngine().identifier(fullName); std::vector buffer(1024); diff --git a/modules/onscreengui/src/gui.cpp b/modules/onscreengui/src/gui.cpp index f84877c944..d0802a4a9d 100644 --- a/modules/onscreengui/src/gui.cpp +++ b/modules/onscreengui/src/gui.cpp @@ -44,8 +44,8 @@ namespace { const std::string _loggerCat = "GUI"; -const std::string configurationFile = "imgui.ini"; -const std::string GuiFont = "${FONTS}/Roboto/Roboto-Regular.ttf"; +const char* configurationFile = "imgui.ini"; +const char* GuiFont = "${FONTS}/Roboto/Roboto-Regular.ttf"; const ImVec2 size = ImVec2(350, 500); //GLuint fontTex = 0; diff --git a/modules/toyvolume/rendering/toyvolumeraycaster.cpp b/modules/toyvolume/rendering/toyvolumeraycaster.cpp index ef4c46fea8..66944a1fbe 100644 --- a/modules/toyvolume/rendering/toyvolumeraycaster.cpp +++ b/modules/toyvolume/rendering/toyvolumeraycaster.cpp @@ -33,9 +33,9 @@ #include namespace { - const std::string GlslRaycastPath = "${MODULES}/toyvolume/shaders/raycast.glsl"; - const std::string GlslBoundsVsPath = "${MODULES}/toyvolume/shaders/boundsvs.glsl"; - const std::string GlslBoundsFsPath = "${MODULES}/toyvolume/shaders/boundsfs.glsl"; + const char* GlslRaycastPath = "${MODULES}/toyvolume/shaders/raycast.glsl"; + const char* GlslBoundsVsPath = "${MODULES}/toyvolume/shaders/boundsvs.glsl"; + const char* GlslBoundsFsPath = "${MODULES}/toyvolume/shaders/boundsfs.glsl"; } namespace openspace { From 6fad08dfda505106440adedee68611bd4eea3d34 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 24 Nov 2016 08:54:42 +0100 Subject: [PATCH 4/9] Jenkins compile fix --- include/openspace/properties/numericalproperty.h | 9 +++++---- include/openspace/properties/numericalproperty.inl | 8 ++++---- include/openspace/properties/optionproperty.h | 4 ++-- include/openspace/properties/selectionproperty.h | 2 +- include/openspace/properties/templateproperty.h | 4 ++-- include/openspace/properties/templateproperty.inl | 9 ++++----- include/openspace/properties/triggerproperty.h | 2 +- src/properties/optionproperty.cpp | 4 ++-- src/properties/selectionproperty.cpp | 2 +- src/properties/triggerproperty.cpp | 2 +- 10 files changed, 23 insertions(+), 23 deletions(-) diff --git a/include/openspace/properties/numericalproperty.h b/include/openspace/properties/numericalproperty.h index 6fee2638c3..b386c9d4b7 100644 --- a/include/openspace/properties/numericalproperty.h +++ b/include/openspace/properties/numericalproperty.h @@ -34,14 +34,15 @@ template class NumericalProperty : public TemplateProperty { public: NumericalProperty(std::string identifier, std::string guiName, - Visibility visibility = Visibility::User); + Property::Visibility visibility = Property::Visibility::User); NumericalProperty(std::string identifier, std::string guiName, T value, - Visibility visibility = Visibility::User); + Property::Visibility visibility = Property::Visibility::User); NumericalProperty(std::string identifier, std::string guiName, T value, - T minimumValue, T maximumValue, Visibility visibility = Visibility::User); + T minimumValue, T maximumValue, + Property::Visibility visibility = Property::Visibility::User); NumericalProperty(std::string identifier, std::string guiName, T value, T minimumValue, T maximumValue, T steppingValue, - Visibility visibility = Visibility::User); + Property::Visibility visibility = Property::Visibility::User); bool getLuaValue(lua_State* state) const override; bool setLuaValue(lua_State* state) override; diff --git a/include/openspace/properties/numericalproperty.inl b/include/openspace/properties/numericalproperty.inl index a16ba6a2c5..89a47f9b66 100644 --- a/include/openspace/properties/numericalproperty.inl +++ b/include/openspace/properties/numericalproperty.inl @@ -234,7 +234,7 @@ const std::string NumericalProperty::SteppingValueKey = "SteppingValue"; template NumericalProperty::NumericalProperty(std::string identifier, std::string guiName, - Visibility visibility) + Property::Visibility visibility) : NumericalProperty( std::move(identifier), std::move(guiName), PropertyDelegate>::template defaultValue(), @@ -248,7 +248,7 @@ NumericalProperty::NumericalProperty(std::string identifier, std::string guiN template NumericalProperty::NumericalProperty(std::string identifier, std::string guiName, T value, - Visibility visibility) + Property::Visibility visibility) : NumericalProperty( std::move(identifier), std::move(guiName), std::move(value), PropertyDelegate>::template defaultMinimumValue(), @@ -261,7 +261,7 @@ NumericalProperty::NumericalProperty(std::string identifier, template NumericalProperty::NumericalProperty(std::string identifier, std::string guiName, T value, T minimumValue, T maximumValue, - Visibility visibility) + Property::Visibility visibility) : NumericalProperty( std::move(identifier) , std::move(guiName), std::move(value), std::move(minimumValue), std::move(maximumValue), @@ -274,7 +274,7 @@ template NumericalProperty::NumericalProperty(std::string identifier, std::string guiName, T value, T minimumValue, T maximumValue, T steppingValue, - Visibility visibility) + Property::Visibility visibility) : TemplateProperty(std::move(identifier), std::move(guiName), std::move(value), visibility) , _minimumValue(std::move(minimumValue)) diff --git a/include/openspace/properties/optionproperty.h b/include/openspace/properties/optionproperty.h index 19d831cd22..2a1ae50d4d 100644 --- a/include/openspace/properties/optionproperty.h +++ b/include/openspace/properties/optionproperty.h @@ -62,7 +62,7 @@ public: * \param guiName The GUI name that should be used to represent this property */ OptionProperty(std::string identifier, std::string guiName, - Visibility visibility = Visibility::User); + Property::Visibility visibility = Property::Visibility::User); /** * The constructor delegating the identifier and the guiName @@ -72,7 +72,7 @@ public: * \param displayType Optional DisplayType for GUI (default RADIO) */ OptionProperty(std::string identifier, std::string guiName, DisplayType displayType, - Visibility visibility = Visibility::User); + Property::Visibility visibility = Property::Visibility::User); /** * Returns the name of the class for reflection purposes. diff --git a/include/openspace/properties/selectionproperty.h b/include/openspace/properties/selectionproperty.h index dedcab1544..ad2cafc4f4 100644 --- a/include/openspace/properties/selectionproperty.h +++ b/include/openspace/properties/selectionproperty.h @@ -40,7 +40,7 @@ public: }; SelectionProperty(std::string identifier, std::string guiName, - Visibility visibility = Visibility::User); + Property::Visibility visibility = Property::Visibility::User); void addOption(Option option); void removeOptions(); diff --git a/include/openspace/properties/templateproperty.h b/include/openspace/properties/templateproperty.h index 3e0970d1aa..efc8423e28 100644 --- a/include/openspace/properties/templateproperty.h +++ b/include/openspace/properties/templateproperty.h @@ -64,7 +64,7 @@ public: * \param guiName The human-readable GUI name for this TemplateProperty */ TemplateProperty(std::string identifier, std::string guiName, - Visibility visibility = Visibility::User); + Property::Visibility visibility = Visibility::User); /** * The constructor initializing the TemplateProperty with the provided @@ -72,7 +72,7 @@ public: * value. */ TemplateProperty(std::string identifier, std::string guiName, T value, - Visibility visibility = Visibility::User); + Property::Visibility visibility = Visibility::User); /** * Returns the class name for this TemplateProperty. The default implementation makes diff --git a/include/openspace/properties/templateproperty.inl b/include/openspace/properties/templateproperty.inl index 02e8de3e9e..bacccfafe6 100644 --- a/include/openspace/properties/templateproperty.inl +++ b/include/openspace/properties/templateproperty.inl @@ -150,21 +150,20 @@ namespace properties { template TemplateProperty::TemplateProperty(std::string identifier, std::string guiName, - Visibility visibility) + Property::Visibility visibility) : TemplateProperty( std::move(identifier), std::move(guiName), PropertyDelegate>::template defaultValue(), visibility) - { } template TemplateProperty::TemplateProperty(std::string identifier, std::string guiName, - T value, Visibility visibility) + T value, Property::Visibility visibility) : Property(std::move(identifier), std::move(guiName), visibility) - , _value(std::move(value)) { -} + , _value(std::move(value)) +{} template std::string TemplateProperty::className() const { diff --git a/include/openspace/properties/triggerproperty.h b/include/openspace/properties/triggerproperty.h index 904039784b..f7f1aa4594 100644 --- a/include/openspace/properties/triggerproperty.h +++ b/include/openspace/properties/triggerproperty.h @@ -43,7 +43,7 @@ public: * \param guiName The human-readable name of this Property */ TriggerProperty(std::string identifier, std::string guiName, - Visibility visibility = Visibility::User); + Property::Visibility visibility = Property::Visibility::User); /** * Returns the class name TriggerProperty. diff --git a/src/properties/optionproperty.cpp b/src/properties/optionproperty.cpp index 84b33373c3..8c24ba9036 100644 --- a/src/properties/optionproperty.cpp +++ b/src/properties/optionproperty.cpp @@ -34,13 +34,13 @@ namespace properties { const std::string OptionProperty::OptionsKey = "Options"; OptionProperty::OptionProperty(std::string identifier, std::string guiName, - Visibility visibility) + Property::Visibility visibility) : IntProperty(std::move(identifier), std::move(guiName), visibility) , _displayType(DisplayType::Radio) {} OptionProperty::OptionProperty(std::string identifier, std::string guiName, - DisplayType displayType, Visibility visibility) + DisplayType displayType, Property::Visibility visibility) : IntProperty(std::move(identifier), std::move(guiName), visibility) , _displayType(displayType) {} diff --git a/src/properties/selectionproperty.cpp b/src/properties/selectionproperty.cpp index 486aa35506..1049d62e77 100644 --- a/src/properties/selectionproperty.cpp +++ b/src/properties/selectionproperty.cpp @@ -36,7 +36,7 @@ namespace properties { const std::string SelectionProperty::OptionsKey = "Options"; SelectionProperty::SelectionProperty(std::string identifier, std::string guiName, - Visibility visibility) + Property::Visibility visibility) : TemplateProperty(std::move(identifier), std::move(guiName), std::vector(), visibility) {} diff --git a/src/properties/triggerproperty.cpp b/src/properties/triggerproperty.cpp index 75ec76c376..9f40a36345 100644 --- a/src/properties/triggerproperty.cpp +++ b/src/properties/triggerproperty.cpp @@ -28,7 +28,7 @@ namespace openspace { namespace properties { TriggerProperty::TriggerProperty(std::string identifier, std::string guiName, - Visibility visibility) + Property::Visibility visibility) : Property(std::move(identifier), std::move(guiName), visibility) {} From c199d38aac2351c4ef92408e84166c497fb5e9a4 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 24 Nov 2016 10:57:53 +0100 Subject: [PATCH 5/9] Add setting to SpiceManager that disables exceptions (closing #142) Disable exceptions on default --- include/openspace/engine/settingsengine.h | 1 + include/openspace/util/spicemanager.h | 30 ++++++++---- .../renderableconstellationbounds.cpp | 5 +- src/engine/settingsengine.cpp | 16 +++++-- src/util/spicemanager.cpp | 48 +++++++++++++------ tests/test_spicemanager.inl | 7 ++- 6 files changed, 78 insertions(+), 29 deletions(-) diff --git a/include/openspace/engine/settingsengine.h b/include/openspace/engine/settingsengine.h index a3a962eac6..623d262d96 100644 --- a/include/openspace/engine/settingsengine.h +++ b/include/openspace/engine/settingsengine.h @@ -61,6 +61,7 @@ private: properties::BoolProperty _busyWaitForDecode; properties::BoolProperty _logSGCTOutOfOrderErrors; properties::BoolProperty _useDoubleBuffering; + properties::BoolProperty _spiceUseExceptions; }; diff --git a/include/openspace/util/spicemanager.h b/include/openspace/util/spicemanager.h index b5597f9149..10a2309dbe 100644 --- a/include/openspace/util/spicemanager.h +++ b/include/openspace/util/spicemanager.h @@ -25,31 +25,27 @@ #ifndef __SPICEMANAGER_H__ #define __SPICEMANAGER_H__ +#include + #include -#include #include -#include +#include #include -#include - #include -#include #include #include #include #include -#include "SpiceUsr.h" -#include "SpiceZpr.h" - namespace openspace { class SpiceManager : public ghoul::Singleton { friend class ghoul::Singleton; public: using TransformMatrix = std::array; + using UseException = ghoul::Boolean; using KernelHandle = unsigned int; struct SpiceException : public ghoul::RuntimeError { @@ -808,6 +804,21 @@ public: * \todo I think this function should die ---abock */ std::string frameFromBody(const std::string& body) const; + + /** + * Sets the SpiceManager's exception handling. If UseException::No is passed to this + * function, all subsequent calls will not throw an error, but fail silently instead. + * If set to UseException::Yes, a SpiceException is thrown whenever an error occurs. + * \param useException The new exeception handling method that the SpiceManager should + * use + */ + void setExceptionHandling(UseException useException); + + /** + * Returns the current SpiceManager's exception strategy. See setExceptionHandling + * \return The current exception handling strategy. + */ + UseException exceptionHandling() const; static scripting::LuaLibrary luaLibrary(); @@ -910,6 +921,9 @@ private: std::map> _spkCoverageTimes; // Vector of pairs: Body, Frame std::vector> _frameByBody; + + /// Stores whether the SpiceManager throws exceptions (Yes) or fails silently (No) + UseException _useExceptions; /// The last assigned kernel-id, used to determine the next free kernel id KernelHandle _lastAssignedKernel = KernelHandle(0); diff --git a/modules/base/rendering/renderableconstellationbounds.cpp b/modules/base/rendering/renderableconstellationbounds.cpp index 735bac4408..66c279f4d3 100644 --- a/modules/base/rendering/renderableconstellationbounds.cpp +++ b/modules/base/rendering/renderableconstellationbounds.cpp @@ -37,6 +37,9 @@ #define _USE_MATH_DEFINES #include +#include "SpiceUsr.h" +#include "SpiceZpr.h" + namespace { const std::string _loggerCat = "RenderableConstellationBounds"; @@ -211,7 +214,7 @@ bool RenderableConstellationBounds::loadVertexFile() { float ra; float dec; std::string constellationName; - SpiceDouble rectangularValues[3]; + double rectangularValues[3]; // Overview of the reading algorithm: // We keep an active ConstellationBound (currentBound) and update it until we read diff --git a/src/engine/settingsengine.cpp b/src/engine/settingsengine.cpp index f0564efc68..587f3e037d 100644 --- a/src/engine/settingsengine.cpp +++ b/src/engine/settingsengine.cpp @@ -28,8 +28,10 @@ #include #include #include +#include #include + #include #include #include @@ -41,11 +43,8 @@ namespace { const std::string _loggerCat = "SettingsEngine"; } - namespace openspace { - - SettingsEngine::SettingsEngine() : _eyeSeparation("eyeSeparation", "Eye Separation" , 0.f, 0.f, 10.f) , _scenes("scenes", "Scene", properties::OptionProperty::DisplayType::Dropdown) @@ -53,8 +52,19 @@ SettingsEngine::SettingsEngine() , _busyWaitForDecode("busyWaitForDecode", "Busy Wait for decode", false) , _logSGCTOutOfOrderErrors("logSGCTOutOfOrderErrors", "Log SGCT out-of-order", false) , _useDoubleBuffering("useDoubleBuffering", "Use double buffering", false) + , _spiceUseExceptions("enableSpiceExceptions", "Enable Spice Exceptions", false) { setName("Global Properties"); + + _spiceUseExceptions.onChange([this]{ + if (_spiceUseExceptions) { + SpiceManager::ref().setExceptionHandling(SpiceManager::UseException::Yes); + } + else { + SpiceManager::ref().setExceptionHandling(SpiceManager::UseException::No); + } + }); + addProperty(_spiceUseExceptions); } void SettingsEngine::initialize() { diff --git a/src/util/spicemanager.cpp b/src/util/spicemanager.cpp index 2740c66e85..0df0a1d8ff 100644 --- a/src/util/spicemanager.cpp +++ b/src/util/spicemanager.cpp @@ -34,6 +34,9 @@ #include #include +#include "SpiceUsr.h" +#include "SpiceZpr.h" + namespace { const std::string _loggerCat = "SpiceManager"; @@ -45,14 +48,16 @@ namespace { // This method checks if one of the previous SPICE methods has failed. If it has, an // exception with the SPICE error message is thrown void throwOnSpiceError(std::string errorMessage) { - SpiceBoolean failed = failed_c(); - if (failed) { - char buffer[SpiceErrorBufferSize]; - getmsg_c("LONG", SpiceErrorBufferSize, buffer); - reset_c(); - throw openspace::SpiceManager::SpiceException( - errorMessage + ": " + buffer - ); + if (openspace::SpiceManager::ref().exceptionHandling()) { + SpiceBoolean failed = failed_c(); + if (failed) { + char buffer[SpiceErrorBufferSize]; + getmsg_c("LONG", SpiceErrorBufferSize, buffer); + reset_c(); + throw openspace::SpiceManager::SpiceException( + errorMessage + ": " + buffer + ); + } } } @@ -85,9 +90,12 @@ namespace openspace { SpiceManager::SpiceException::SpiceException(const string& msg) : ghoul::RuntimeError(msg, "Spice") -{} - - +{ + ghoul_assert( + SpiceManager::ref().exceptionHandling() == SpiceManager::UseException::Yes, + "No exceptions should be thrown when UseException is No" + ); +} SpiceManager::AberrationCorrection::AberrationCorrection(Type t, Direction d) : type(t) @@ -155,7 +163,9 @@ SpiceManager::TerminatorType SpiceManager::terminatorTypeFromString( const strin return Mapping.at(type); } -SpiceManager::SpiceManager() { +SpiceManager::SpiceManager() + : _useExceptions(UseException::No) +{ // Set the SPICE library to not exit the program if an error occurs erract_c("SET", 0, const_cast("REPORT")); // But we do not want SPICE to print the errors, we will fetch them ourselves @@ -473,7 +483,7 @@ glm::dvec3 SpiceManager::targetPosition(const std::string& target, bool targetHasCoverage = hasSpkCoverage(target, ephemerisTime); bool observerHasCoverage = hasSpkCoverage(observer, ephemerisTime); - if (!targetHasCoverage && !observerHasCoverage){ + if (!targetHasCoverage && !observerHasCoverage && _useExceptions) { throw SpiceException( format("Neither target '{}' nor observer '{}' has SPK coverage at time {}", target, @@ -945,7 +955,7 @@ glm::dvec3 SpiceManager::getEstimatedPosition(const std::string& target, return glm::dvec3(0.0); } - if (_spkCoverageTimes.find(targetId) == _spkCoverageTimes.end()) { + if (_spkCoverageTimes.find(targetId) == _spkCoverageTimes.end() && _useExceptions) { // no coverage throw SpiceException(format("No position for '{}' at any time", target)); } @@ -1034,7 +1044,7 @@ glm::dmat3 SpiceManager::getEstimatedTransformMatrix(const std::string& fromFram glm::dmat3 result; int idFrame = frameId(fromFrame); - if (_ckCoverageTimes.find(idFrame) == _ckCoverageTimes.end()) { + if (_ckCoverageTimes.find(idFrame) == _ckCoverageTimes.end() && _useExceptions) { // no coverage throw SpiceException(format( "No data available for the transform matrix from '{}' to '{}' at any time", @@ -1107,6 +1117,14 @@ glm::dmat3 SpiceManager::getEstimatedTransformMatrix(const std::string& fromFram return result; } +void SpiceManager::setExceptionHandling(UseException useException) { + _useExceptions = useException; +} + +SpiceManager::UseException SpiceManager::exceptionHandling() const { + return _useExceptions; +} + scripting::LuaLibrary SpiceManager::luaLibrary() { return { "spice", diff --git a/tests/test_spicemanager.inl b/tests/test_spicemanager.inl index c488c0c51c..8fd60a96a8 100644 --- a/tests/test_spicemanager.inl +++ b/tests/test_spicemanager.inl @@ -22,10 +22,13 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#include -#include "gtest/gtest.h" #include +#include + +#include "SpiceUsr.h" +#include "SpiceZpr.h" + class SpiceManagerTest : public testing::Test { protected: void SetUp() override { From af21e40074eed22d2a0a4a40499e2ad392d886a0 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Sun, 27 Nov 2016 01:17:38 +0100 Subject: [PATCH 6/9] Split up scalar, vector, and matrix properties into their own files for improved compile times --- include/openspace/engine/settingsengine.h | 4 +- .../interaction/interactionhandler.h | 2 + .../properties/matrix/dmat2property.h | 40 + .../properties/matrix/dmat2x3property.h | 40 + .../properties/matrix/dmat2x4property.h | 40 + .../properties/matrix/dmat3property.h | 40 + .../properties/matrix/dmat3x2property.h | 40 + .../properties/matrix/dmat3x4property.h | 40 + .../properties/matrix/dmat4property.h | 40 + .../properties/matrix/dmat4x2property.h | 40 + .../properties/matrix/dmat4x3property.h | 40 + .../properties/matrix/mat2property.h | 40 + .../properties/matrix/mat2x3property.h | 40 + .../properties/matrix/mat2x4property.h | 40 + .../properties/matrix/mat3property.h | 40 + .../properties/matrix/mat3x2property.h | 40 + .../properties/matrix/mat3x4property.h | 40 + .../properties/matrix/mat4property.h | 40 + .../properties/matrix/mat4x2property.h | 40 + .../properties/matrix/mat4x3property.h | 40 + include/openspace/properties/matrixproperty.h | 43 +- include/openspace/properties/optionproperty.h | 2 +- .../properties/scalar/boolproperty.h | 53 ++ .../properties/scalar/charproperty.h | 53 ++ .../properties/scalar/doubleproperty.h | 53 ++ .../properties/scalar/floatproperty.h | 53 ++ .../openspace/properties/scalar/intproperty.h | 53 ++ .../properties/scalar/longdoubleproperty.h | 53 ++ .../properties/scalar/longlongproperty.h | 53 ++ .../properties/scalar/longproperty.h | 53 ++ .../properties/scalar/shortproperty.h | 53 ++ .../properties/scalar/signedcharproperty.h | 53 ++ .../properties/scalar/ucharproperty.h | 53 ++ .../properties/scalar/uintproperty.h | 53 ++ .../properties/scalar/ulonglongproperty.h | 53 ++ .../properties/scalar/ulongproperty.h | 53 ++ .../properties/scalar/ushortproperty.h | 53 ++ .../properties/scalar/wcharproperty.h | 53 ++ include/openspace/properties/scalarproperty.h | 111 +-- .../openspace/properties/selectionproperty.h | 2 +- include/openspace/properties/ucharproperty.h | 53 ++ include/openspace/properties/uintproperty.h | 53 ++ .../properties/vector/bvec2property.h | 40 + .../properties/vector/bvec3property.h | 40 + .../properties/vector/bvec4property.h | 40 + .../properties/vector/dvec2property.h | 40 + .../properties/vector/dvec3property.h | 40 + .../properties/vector/dvec4property.h | 40 + .../properties/vector/ivec2property.h | 40 + .../properties/vector/ivec3property.h | 40 + .../properties/vector/ivec4property.h | 40 + .../properties/vector/uvec2property.h | 40 + .../properties/vector/uvec3property.h | 40 + .../properties/vector/uvec4property.h | 40 + .../properties/vector/vec2property.h | 40 + .../properties/vector/vec3property.h | 40 + .../properties/vector/vec4property.h | 40 + include/openspace/properties/vectorproperty.h | 37 +- include/openspace/properties/wcharproperty.h | 53 ++ include/openspace/rendering/renderable.h | 3 +- include/openspace/rendering/renderengine.h | 2 +- .../rendering/screenspacerenderable.h | 5 +- include/openspace/util/powerscaledsphere.h | 2 +- modules/base/rendering/modelgeometry.h | 1 - .../renderableconstellationbounds.cpp | 5 +- .../rendering/renderableconstellationbounds.h | 2 +- modules/base/rendering/renderablemodel.h | 4 +- modules/base/rendering/renderablepath.cpp | 1 - modules/base/rendering/renderablepath.h | 4 +- modules/base/rendering/renderableplane.h | 3 +- modules/base/rendering/renderableplanet.h | 3 + modules/base/rendering/renderablerings.h | 3 +- modules/base/rendering/renderablesphere.h | 4 +- modules/base/rendering/renderablestars.h | 2 +- modules/base/rendering/renderabletrail.h | 6 +- modules/base/rendering/renderabletrailorbit.h | 3 +- .../rendering/renderabletrailtrajectory.h | 4 +- .../base/rendering/screenspaceframebuffer.h | 3 + modules/base/rendering/simplespheregeometry.h | 5 +- modules/base/rotation/staticrotation.h | 2 +- modules/base/scale/staticscale.h | 1 + modules/base/translation/statictranslation.h | 2 +- .../rendering/renderabledebugplane.h | 2 +- .../globebrowsing/globes/renderableglobe.h | 3 + modules/newhorizons/rendering/renderablefov.h | 2 + .../rendering/renderablemodelprojection.h | 2 +- .../rendering/renderableplaneprojection.h | 1 - .../rendering/renderableshadowcylinder.h | 4 +- .../newhorizons/util/projectioncomponent.h | 6 +- modules/onscreengui/include/guicomponent.h | 2 +- .../include/guiperformancecomponent.h | 3 + .../toyvolume/rendering/renderabletoyvolume.h | 11 +- src/CMakeLists.txt | 101 ++- src/properties/matrix/dmat2property.cpp | 140 ++++ src/properties/matrix/dmat2x3property.cpp | 144 ++++ src/properties/matrix/dmat2x4property.cpp | 148 ++++ src/properties/matrix/dmat3property.cpp | 151 ++++ src/properties/matrix/dmat3x2property.cpp | 144 ++++ src/properties/matrix/dmat3x4property.cpp | 157 ++++ src/properties/matrix/dmat4property.cpp | 166 ++++ src/properties/matrix/dmat4x2property.cpp | 148 ++++ src/properties/matrix/dmat4x3property.cpp | 157 ++++ src/properties/matrix/mat2property.cpp | 140 ++++ src/properties/matrix/mat2x3property.cpp | 144 ++++ src/properties/matrix/mat2x4property.cpp | 148 ++++ src/properties/matrix/mat3property.cpp | 151 ++++ src/properties/matrix/mat3x2property.cpp | 144 ++++ src/properties/matrix/mat3x4property.cpp | 157 ++++ src/properties/matrix/mat4property.cpp | 166 ++++ src/properties/matrix/mat4x2property.cpp | 148 ++++ src/properties/matrix/mat4x3property.cpp | 157 ++++ src/properties/matrixproperty.cpp | 721 ------------------ src/properties/scalar/boolproperty.cpp | 67 ++ src/properties/scalar/charproperty.cpp | 81 ++ src/properties/scalar/doubleproperty.cpp | 81 ++ src/properties/scalar/floatproperty.cpp | 81 ++ src/properties/scalar/intproperty.cpp | 80 ++ src/properties/scalar/longdoubleproperty.cpp | 82 ++ src/properties/scalar/longlongproperty.cpp | 82 ++ src/properties/scalar/longproperty.cpp | 81 ++ src/properties/scalar/shortproperty.cpp | 81 ++ src/properties/scalar/signedcharproperty.cpp | 81 ++ src/properties/scalar/ucharproperty.cpp | 80 ++ src/properties/scalar/uintproperty.cpp | 80 ++ src/properties/scalar/ulonglongproperty.cpp | 85 +++ src/properties/scalar/ulongproperty.cpp | 83 ++ src/properties/scalar/ushortproperty.cpp | 84 ++ src/properties/scalar/wcharproperty.cpp | 75 ++ src/properties/scalarproperty.cpp | 247 ------ src/properties/selectionproperty.cpp | 2 + src/properties/vector/bvec2property.cpp | 125 +++ src/properties/vector/bvec3property.cpp | 124 +++ src/properties/vector/bvec4property.cpp | 124 +++ src/properties/vector/dvec2property.cpp | 117 +++ src/properties/vector/dvec3property.cpp | 117 +++ src/properties/vector/dvec4property.cpp | 117 +++ src/properties/vector/ivec2property.cpp | 116 +++ src/properties/vector/ivec3property.cpp | 116 +++ src/properties/vector/ivec4property.cpp | 116 +++ src/properties/vector/uvec2property.cpp | 117 +++ src/properties/vector/uvec3property.cpp | 117 +++ src/properties/vector/uvec4property.cpp | 117 +++ src/properties/vector/vec2property.cpp | 117 +++ src/properties/vector/vec3property.cpp | 117 +++ src/properties/vector/vec4property.cpp | 117 +++ src/properties/vectorproperty.cpp | 271 ------- 146 files changed, 8321 insertions(+), 1423 deletions(-) create mode 100644 include/openspace/properties/matrix/dmat2property.h create mode 100644 include/openspace/properties/matrix/dmat2x3property.h create mode 100644 include/openspace/properties/matrix/dmat2x4property.h create mode 100644 include/openspace/properties/matrix/dmat3property.h create mode 100644 include/openspace/properties/matrix/dmat3x2property.h create mode 100644 include/openspace/properties/matrix/dmat3x4property.h create mode 100644 include/openspace/properties/matrix/dmat4property.h create mode 100644 include/openspace/properties/matrix/dmat4x2property.h create mode 100644 include/openspace/properties/matrix/dmat4x3property.h create mode 100644 include/openspace/properties/matrix/mat2property.h create mode 100644 include/openspace/properties/matrix/mat2x3property.h create mode 100644 include/openspace/properties/matrix/mat2x4property.h create mode 100644 include/openspace/properties/matrix/mat3property.h create mode 100644 include/openspace/properties/matrix/mat3x2property.h create mode 100644 include/openspace/properties/matrix/mat3x4property.h create mode 100644 include/openspace/properties/matrix/mat4property.h create mode 100644 include/openspace/properties/matrix/mat4x2property.h create mode 100644 include/openspace/properties/matrix/mat4x3property.h create mode 100644 include/openspace/properties/scalar/boolproperty.h create mode 100644 include/openspace/properties/scalar/charproperty.h create mode 100644 include/openspace/properties/scalar/doubleproperty.h create mode 100644 include/openspace/properties/scalar/floatproperty.h create mode 100644 include/openspace/properties/scalar/intproperty.h create mode 100644 include/openspace/properties/scalar/longdoubleproperty.h create mode 100644 include/openspace/properties/scalar/longlongproperty.h create mode 100644 include/openspace/properties/scalar/longproperty.h create mode 100644 include/openspace/properties/scalar/shortproperty.h create mode 100644 include/openspace/properties/scalar/signedcharproperty.h create mode 100644 include/openspace/properties/scalar/ucharproperty.h create mode 100644 include/openspace/properties/scalar/uintproperty.h create mode 100644 include/openspace/properties/scalar/ulonglongproperty.h create mode 100644 include/openspace/properties/scalar/ulongproperty.h create mode 100644 include/openspace/properties/scalar/ushortproperty.h create mode 100644 include/openspace/properties/scalar/wcharproperty.h create mode 100644 include/openspace/properties/ucharproperty.h create mode 100644 include/openspace/properties/uintproperty.h create mode 100644 include/openspace/properties/vector/bvec2property.h create mode 100644 include/openspace/properties/vector/bvec3property.h create mode 100644 include/openspace/properties/vector/bvec4property.h create mode 100644 include/openspace/properties/vector/dvec2property.h create mode 100644 include/openspace/properties/vector/dvec3property.h create mode 100644 include/openspace/properties/vector/dvec4property.h create mode 100644 include/openspace/properties/vector/ivec2property.h create mode 100644 include/openspace/properties/vector/ivec3property.h create mode 100644 include/openspace/properties/vector/ivec4property.h create mode 100644 include/openspace/properties/vector/uvec2property.h create mode 100644 include/openspace/properties/vector/uvec3property.h create mode 100644 include/openspace/properties/vector/uvec4property.h create mode 100644 include/openspace/properties/vector/vec2property.h create mode 100644 include/openspace/properties/vector/vec3property.h create mode 100644 include/openspace/properties/vector/vec4property.h create mode 100644 include/openspace/properties/wcharproperty.h create mode 100644 src/properties/matrix/dmat2property.cpp create mode 100644 src/properties/matrix/dmat2x3property.cpp create mode 100644 src/properties/matrix/dmat2x4property.cpp create mode 100644 src/properties/matrix/dmat3property.cpp create mode 100644 src/properties/matrix/dmat3x2property.cpp create mode 100644 src/properties/matrix/dmat3x4property.cpp create mode 100644 src/properties/matrix/dmat4property.cpp create mode 100644 src/properties/matrix/dmat4x2property.cpp create mode 100644 src/properties/matrix/dmat4x3property.cpp create mode 100644 src/properties/matrix/mat2property.cpp create mode 100644 src/properties/matrix/mat2x3property.cpp create mode 100644 src/properties/matrix/mat2x4property.cpp create mode 100644 src/properties/matrix/mat3property.cpp create mode 100644 src/properties/matrix/mat3x2property.cpp create mode 100644 src/properties/matrix/mat3x4property.cpp create mode 100644 src/properties/matrix/mat4property.cpp create mode 100644 src/properties/matrix/mat4x2property.cpp create mode 100644 src/properties/matrix/mat4x3property.cpp delete mode 100644 src/properties/matrixproperty.cpp create mode 100644 src/properties/scalar/boolproperty.cpp create mode 100644 src/properties/scalar/charproperty.cpp create mode 100644 src/properties/scalar/doubleproperty.cpp create mode 100644 src/properties/scalar/floatproperty.cpp create mode 100644 src/properties/scalar/intproperty.cpp create mode 100644 src/properties/scalar/longdoubleproperty.cpp create mode 100644 src/properties/scalar/longlongproperty.cpp create mode 100644 src/properties/scalar/longproperty.cpp create mode 100644 src/properties/scalar/shortproperty.cpp create mode 100644 src/properties/scalar/signedcharproperty.cpp create mode 100644 src/properties/scalar/ucharproperty.cpp create mode 100644 src/properties/scalar/uintproperty.cpp create mode 100644 src/properties/scalar/ulonglongproperty.cpp create mode 100644 src/properties/scalar/ulongproperty.cpp create mode 100644 src/properties/scalar/ushortproperty.cpp create mode 100644 src/properties/scalar/wcharproperty.cpp delete mode 100644 src/properties/scalarproperty.cpp create mode 100644 src/properties/vector/bvec2property.cpp create mode 100644 src/properties/vector/bvec3property.cpp create mode 100644 src/properties/vector/bvec4property.cpp create mode 100644 src/properties/vector/dvec2property.cpp create mode 100644 src/properties/vector/dvec3property.cpp create mode 100644 src/properties/vector/dvec4property.cpp create mode 100644 src/properties/vector/ivec2property.cpp create mode 100644 src/properties/vector/ivec3property.cpp create mode 100644 src/properties/vector/ivec4property.cpp create mode 100644 src/properties/vector/uvec2property.cpp create mode 100644 src/properties/vector/uvec3property.cpp create mode 100644 src/properties/vector/uvec4property.cpp create mode 100644 src/properties/vector/vec2property.cpp create mode 100644 src/properties/vector/vec3property.cpp create mode 100644 src/properties/vector/vec4property.cpp delete mode 100644 src/properties/vectorproperty.cpp diff --git a/include/openspace/engine/settingsengine.h b/include/openspace/engine/settingsengine.h index 623d262d96..c7098725f0 100644 --- a/include/openspace/engine/settingsengine.h +++ b/include/openspace/engine/settingsengine.h @@ -26,8 +26,10 @@ #define __SETTINGSENGINE_H__ #include -#include + #include +#include +#include #include diff --git a/include/openspace/interaction/interactionhandler.h b/include/openspace/interaction/interactionhandler.h index 88a8cc688e..0dba068b19 100644 --- a/include/openspace/interaction/interactionhandler.h +++ b/include/openspace/interaction/interactionhandler.h @@ -31,6 +31,8 @@ #include #include #include +#include +#include #include #include diff --git a/include/openspace/properties/matrix/dmat2property.h b/include/openspace/properties/matrix/dmat2property.h new file mode 100644 index 0000000000..068262e95e --- /dev/null +++ b/include/openspace/properties/matrix/dmat2property.h @@ -0,0 +1,40 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __DMAT2PROPERTY_H__ +#define __DMAT2PROPERTY_H__ + +#include + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(DMat2Property, glm::dmat2x2); + +} // namespace properties +} // namespace openspace + +#endif // __DMAT2PROPERTY_H__ diff --git a/include/openspace/properties/matrix/dmat2x3property.h b/include/openspace/properties/matrix/dmat2x3property.h new file mode 100644 index 0000000000..93b788a467 --- /dev/null +++ b/include/openspace/properties/matrix/dmat2x3property.h @@ -0,0 +1,40 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __DMAT2x3PROPERTY_H__ +#define __DMAT2x3PROPERTY_H__ + +#include + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(DMat2x3Property, glm::dmat2x3); + +} // namespace properties +} // namespace openspace + +#endif // __DMAT2x3PROPERTY_H__ diff --git a/include/openspace/properties/matrix/dmat2x4property.h b/include/openspace/properties/matrix/dmat2x4property.h new file mode 100644 index 0000000000..6eadff129a --- /dev/null +++ b/include/openspace/properties/matrix/dmat2x4property.h @@ -0,0 +1,40 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __DMAT2x4PROPERTY_H__ +#define __DMAT2x4PROPERTY_H__ + +#include + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(DMat2x4Property, glm::dmat2x4); + +} // namespace properties +} // namespace openspace + +#endif // __DMAT2x4PROPERTY_H__ diff --git a/include/openspace/properties/matrix/dmat3property.h b/include/openspace/properties/matrix/dmat3property.h new file mode 100644 index 0000000000..1ddb7c33e4 --- /dev/null +++ b/include/openspace/properties/matrix/dmat3property.h @@ -0,0 +1,40 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __DMAT3PROPERTY_H__ +#define __DMAT3PROPERTY_H__ + +#include + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(DMat3Property, glm::dmat3x3); + +} // namespace properties +} // namespace openspace + +#endif // __DMAT3PROPERTY_H__ diff --git a/include/openspace/properties/matrix/dmat3x2property.h b/include/openspace/properties/matrix/dmat3x2property.h new file mode 100644 index 0000000000..df77be19bd --- /dev/null +++ b/include/openspace/properties/matrix/dmat3x2property.h @@ -0,0 +1,40 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __DMAT3x2PROPERTY_H__ +#define __DMAT3x2PROPERTY_H__ + +#include + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(DMat3x2Property, glm::dmat3x2); + +} // namespace properties +} // namespace openspace + +#endif // __DMAT3x2PROPERTY_H__ diff --git a/include/openspace/properties/matrix/dmat3x4property.h b/include/openspace/properties/matrix/dmat3x4property.h new file mode 100644 index 0000000000..2bd147a1e2 --- /dev/null +++ b/include/openspace/properties/matrix/dmat3x4property.h @@ -0,0 +1,40 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __DMAT3x4PROPERTY_H__ +#define __DMAT3x4PROPERTY_H__ + +#include + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(DMat3x4Property, glm::dmat3x4); + +} // namespace properties +} // namespace openspace + +#endif // __DMAT3x4PROPERTY_H__ diff --git a/include/openspace/properties/matrix/dmat4property.h b/include/openspace/properties/matrix/dmat4property.h new file mode 100644 index 0000000000..d94a034d59 --- /dev/null +++ b/include/openspace/properties/matrix/dmat4property.h @@ -0,0 +1,40 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __DMAT4PROPERTY_H__ +#define __DMAT4PROPERTY_H__ + +#include + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(DMat4Property, glm::dmat4x4); + +} // namespace properties +} // namespace openspace + +#endif // __DMAT4PROPERTY_H__ diff --git a/include/openspace/properties/matrix/dmat4x2property.h b/include/openspace/properties/matrix/dmat4x2property.h new file mode 100644 index 0000000000..c494207d06 --- /dev/null +++ b/include/openspace/properties/matrix/dmat4x2property.h @@ -0,0 +1,40 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __DMAT4x2PROPERTY_H__ +#define __DMAT4x2PROPERTY_H__ + +#include + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(DMat4x2Property, glm::dmat4x2); + +} // namespace properties +} // namespace openspace + +#endif // __DMAT4x2PROPERTY_H__ diff --git a/include/openspace/properties/matrix/dmat4x3property.h b/include/openspace/properties/matrix/dmat4x3property.h new file mode 100644 index 0000000000..2445c505a6 --- /dev/null +++ b/include/openspace/properties/matrix/dmat4x3property.h @@ -0,0 +1,40 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __DMAT4x3PROPERTY_H__ +#define __DMAT4x3PROPERTY_H__ + +#include + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(DMat4x3Property, glm::dmat4x3); + +} // namespace properties +} // namespace openspace + +#endif // __DMAT4x3PROPERTY_H__ diff --git a/include/openspace/properties/matrix/mat2property.h b/include/openspace/properties/matrix/mat2property.h new file mode 100644 index 0000000000..9f33108218 --- /dev/null +++ b/include/openspace/properties/matrix/mat2property.h @@ -0,0 +1,40 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __MAT2PROPERTY_H__ +#define __MAT2PROPERTY_H__ + +#include + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(Mat2Property, glm::mat2x2); + +} // namespace properties +} // namespace openspace + +#endif // __MAT2PROPERTY_H__ diff --git a/include/openspace/properties/matrix/mat2x3property.h b/include/openspace/properties/matrix/mat2x3property.h new file mode 100644 index 0000000000..4e7058b19c --- /dev/null +++ b/include/openspace/properties/matrix/mat2x3property.h @@ -0,0 +1,40 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __MAT2x3PROPERTY_H__ +#define __MAT2x3PROPERTY_H__ + +#include + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(Mat2x3Property, glm::mat2x3); + +} // namespace properties +} // namespace openspace + +#endif // __MAT2x3PROPERTY_H__ diff --git a/include/openspace/properties/matrix/mat2x4property.h b/include/openspace/properties/matrix/mat2x4property.h new file mode 100644 index 0000000000..2c6472ec39 --- /dev/null +++ b/include/openspace/properties/matrix/mat2x4property.h @@ -0,0 +1,40 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __MAT2x4PROPERTY_H__ +#define __MAT2x4PROPERTY_H__ + +#include + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(Mat2x4Property, glm::mat2x4); + +} // namespace properties +} // namespace openspace + +#endif // __MAT2x4PROPERTY_H__ diff --git a/include/openspace/properties/matrix/mat3property.h b/include/openspace/properties/matrix/mat3property.h new file mode 100644 index 0000000000..d722340c78 --- /dev/null +++ b/include/openspace/properties/matrix/mat3property.h @@ -0,0 +1,40 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __MAT3PROPERTY_H__ +#define __MAT3PROPERTY_H__ + +#include + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(Mat3Property, glm::mat3x3); + +} // namespace properties +} // namespace openspace + +#endif // __MAT3PROPERTY_H__ diff --git a/include/openspace/properties/matrix/mat3x2property.h b/include/openspace/properties/matrix/mat3x2property.h new file mode 100644 index 0000000000..880998f3c1 --- /dev/null +++ b/include/openspace/properties/matrix/mat3x2property.h @@ -0,0 +1,40 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __MAT3x2PROPERTY_H__ +#define __MAT3x2PROPERTY_H__ + +#include + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(Mat3x2Property, glm::mat3x2); + +} // namespace properties +} // namespace openspace + +#endif // __MAT3x2PROPERTY_H__ diff --git a/include/openspace/properties/matrix/mat3x4property.h b/include/openspace/properties/matrix/mat3x4property.h new file mode 100644 index 0000000000..f204e8a612 --- /dev/null +++ b/include/openspace/properties/matrix/mat3x4property.h @@ -0,0 +1,40 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __MAT3x4PROPERTY_H__ +#define __MAT3x4PROPERTY_H__ + +#include + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(Mat3x4Property, glm::mat3x4); + +} // namespace properties +} // namespace openspace + +#endif // __MAT3x4PROPERTY_H__ diff --git a/include/openspace/properties/matrix/mat4property.h b/include/openspace/properties/matrix/mat4property.h new file mode 100644 index 0000000000..174e653f6e --- /dev/null +++ b/include/openspace/properties/matrix/mat4property.h @@ -0,0 +1,40 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __MAT4PROPERTY_H__ +#define __MAT4PROPERTY_H__ + +#include + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(Mat4Property, glm::mat4x4); + +} // namespace properties +} // namespace openspace + +#endif // __MAT4PROPERTY_H__ diff --git a/include/openspace/properties/matrix/mat4x2property.h b/include/openspace/properties/matrix/mat4x2property.h new file mode 100644 index 0000000000..1ba992b3c1 --- /dev/null +++ b/include/openspace/properties/matrix/mat4x2property.h @@ -0,0 +1,40 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __MAT4x2PROPERTY_H__ +#define __MAT4x2PROPERTY_H__ + +#include + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(Mat4x2Property, glm::mat4x2); + +} // namespace properties +} // namespace openspace + +#endif // __MAT4x2PROPERTY_H__ diff --git a/include/openspace/properties/matrix/mat4x3property.h b/include/openspace/properties/matrix/mat4x3property.h new file mode 100644 index 0000000000..5c98761f22 --- /dev/null +++ b/include/openspace/properties/matrix/mat4x3property.h @@ -0,0 +1,40 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __MAT4x3PROPERTY_H__ +#define __MAT4x3PROPERTY_H__ + +#include + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(Mat4x3Property, glm::mat4x3); + +} // namespace properties +} // namespace openspace + +#endif // __MAT4x3PROPERTY_H__ diff --git a/include/openspace/properties/matrixproperty.h b/include/openspace/properties/matrixproperty.h index 572d840933..fdce58f3be 100644 --- a/include/openspace/properties/matrixproperty.h +++ b/include/openspace/properties/matrixproperty.h @@ -27,31 +27,24 @@ #include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include -namespace openspace { -namespace properties { - -REGISTER_NUMERICALPROPERTY_HEADER(Mat2Property, glm::mat2x2); -REGISTER_NUMERICALPROPERTY_HEADER(Mat2x3Property, glm::mat2x3); -REGISTER_NUMERICALPROPERTY_HEADER(Mat2x4Property, glm::mat2x4); -REGISTER_NUMERICALPROPERTY_HEADER(Mat3x2Property, glm::mat3x2); -REGISTER_NUMERICALPROPERTY_HEADER(Mat3Property, glm::mat3x3); -REGISTER_NUMERICALPROPERTY_HEADER(Mat3x4Property, glm::mat3x4); -REGISTER_NUMERICALPROPERTY_HEADER(Mat4x2Property, glm::mat4x2); -REGISTER_NUMERICALPROPERTY_HEADER(Mat4x3Property, glm::mat4x3); -REGISTER_NUMERICALPROPERTY_HEADER(Mat4Property, glm::mat4x4); -REGISTER_NUMERICALPROPERTY_HEADER(DMat2Property, glm::dmat2x2); -REGISTER_NUMERICALPROPERTY_HEADER(DMat2x3Property, glm::dmat2x3); -REGISTER_NUMERICALPROPERTY_HEADER(DMat2x4Property, glm::dmat2x4); -REGISTER_NUMERICALPROPERTY_HEADER(DMat3x2Property, glm::dmat3x2); -REGISTER_NUMERICALPROPERTY_HEADER(DMat3Property, glm::dmat3x3); -REGISTER_NUMERICALPROPERTY_HEADER(DMat3x4Property, glm::dmat3x4); -REGISTER_NUMERICALPROPERTY_HEADER(DMat4x2Property, glm::dmat4x2); -REGISTER_NUMERICALPROPERTY_HEADER(DMat4x3Property, glm::dmat4x3); -REGISTER_NUMERICALPROPERTY_HEADER(DMat4Property, glm::dmat4x4); - -} // namespace properties -} // namespace openspace +#include +#include +#include +#include +#include +#include +#include +#include +#include #endif // __MATRIXPROPERTY_H__ diff --git a/include/openspace/properties/optionproperty.h b/include/openspace/properties/optionproperty.h index 2a1ae50d4d..78c0630c37 100644 --- a/include/openspace/properties/optionproperty.h +++ b/include/openspace/properties/optionproperty.h @@ -25,7 +25,7 @@ #ifndef __OPTIONPROPERTY_H__ #define __OPTIONPROPERTY_H__ -#include +#include #include diff --git a/include/openspace/properties/scalar/boolproperty.h b/include/openspace/properties/scalar/boolproperty.h new file mode 100644 index 0000000000..e3766ccce0 --- /dev/null +++ b/include/openspace/properties/scalar/boolproperty.h @@ -0,0 +1,53 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __BOOLPROPERTY_H__ +#define __BOOLPROPERTY_H__ + + /** + * \file boolproperty.h + * + * \addtogroup openspace + * @{ + * \addtogroup properties + * @{ + + * \class BoolProperty + * This class is a concrete implementation of openspace::properties::TemplateProperty with + * the type bool. + + * @} @} + */ + +#include + +namespace openspace { +namespace properties { + +REGISTER_TEMPLATEPROPERTY_HEADER(BoolProperty, bool); + +} // namespace properties +} // namespace openspace + +#endif // __BOOLPROPERTY_H__ diff --git a/include/openspace/properties/scalar/charproperty.h b/include/openspace/properties/scalar/charproperty.h new file mode 100644 index 0000000000..bf8c4037c6 --- /dev/null +++ b/include/openspace/properties/scalar/charproperty.h @@ -0,0 +1,53 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __CHARPROPERTY_H__ +#define __CHARPROPERTY_H__ + + /** + * \file charproperty.h + * + * \addtogroup openspace + * @{ + * \addtogroup properties + * @{ + + * \class CharProperty + * This class is a concrete implementation of openspace::properties::TemplateProperty with + * the type char. + + * @} @} + */ + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(CharProperty, char); + +} // namespace properties +} // namespace openspace + +#endif // __CHARPROPERTY_H__ diff --git a/include/openspace/properties/scalar/doubleproperty.h b/include/openspace/properties/scalar/doubleproperty.h new file mode 100644 index 0000000000..244612cc38 --- /dev/null +++ b/include/openspace/properties/scalar/doubleproperty.h @@ -0,0 +1,53 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __DOUBLEPROPERTY_H__ +#define __DOUBLEPROPERTY_H__ + + /** + * \file doubleproperty.h + * + * \addtogroup openspace + * @{ + * \addtogroup properties + * @{ + + * \class DoubleProperty + * This class is a concrete implementation of openspace::properties::TemplateProperty with + * the type double. + + * @} @} + */ + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(DoubleProperty, double); + +} // namespace properties +} // namespace openspace + +#endif // __DOUBLEPROPERTY_H__ diff --git a/include/openspace/properties/scalar/floatproperty.h b/include/openspace/properties/scalar/floatproperty.h new file mode 100644 index 0000000000..5a72f238eb --- /dev/null +++ b/include/openspace/properties/scalar/floatproperty.h @@ -0,0 +1,53 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __FLOATPROPERTY_H__ +#define __FLOATPROPERTY_H__ + + /** + * \file floatproperty.h + * + * \addtogroup openspace + * @{ + * \addtogroup properties + * @{ + + * \class FloatProperty + * This class is a concrete implementation of openspace::properties::TemplateProperty with + * the type float. + + * @} @} + */ + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(FloatProperty, float); + +} // namespace properties +} // namespace openspace + +#endif // __FLOATPROPERTY_H__ diff --git a/include/openspace/properties/scalar/intproperty.h b/include/openspace/properties/scalar/intproperty.h new file mode 100644 index 0000000000..83317d89d4 --- /dev/null +++ b/include/openspace/properties/scalar/intproperty.h @@ -0,0 +1,53 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __INTPROPERTY_H__ +#define __INTPROPERTY_H__ + + /** + * \file intproperty.h + * + * \addtogroup openspace + * @{ + * \addtogroup properties + * @{ + + * \class IntProperty + * This class is a concrete implementation of openspace::properties::TemplateProperty with + * the type int. + + * @} @} + */ + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(IntProperty, int); + +} // namespace properties +} // namespace openspace + +#endif // __INTPROPERTY_H__ diff --git a/include/openspace/properties/scalar/longdoubleproperty.h b/include/openspace/properties/scalar/longdoubleproperty.h new file mode 100644 index 0000000000..74c154caa3 --- /dev/null +++ b/include/openspace/properties/scalar/longdoubleproperty.h @@ -0,0 +1,53 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __LONGDOUBLEPROPERTY_H__ +#define __LONGDOUBLEPROPERTY_H__ + + /** + * \file longdoubleproperty.h + * + * \addtogroup openspace + * @{ + * \addtogroup properties + * @{ + + * \class LongDoubleProperty + * This class is a concrete implementation of openspace::properties::TemplateProperty with + * the type long double. + + * @} @} + */ + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(LongDoubleProperty, long double); + +} // namespace properties +} // namespace openspace + +#endif // __LONGDOUBLEPROPERTY_H__ diff --git a/include/openspace/properties/scalar/longlongproperty.h b/include/openspace/properties/scalar/longlongproperty.h new file mode 100644 index 0000000000..f9544ee2b3 --- /dev/null +++ b/include/openspace/properties/scalar/longlongproperty.h @@ -0,0 +1,53 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __LONGLONGPROPERTY_H__ +#define __LONGLONGPROPERTY_H__ + + /** + * \file longlongproperty.h + * + * \addtogroup openspace + * @{ + * \addtogroup properties + * @{ + + * \class LongLongProperty + * This class is a concrete implementation of openspace::properties::TemplateProperty with + * the type long long. + + * @} @} + */ + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(LongLongProperty, long long); + +} // namespace properties +} // namespace openspace + +#endif // __LONGLONGPROPERTY_H__ diff --git a/include/openspace/properties/scalar/longproperty.h b/include/openspace/properties/scalar/longproperty.h new file mode 100644 index 0000000000..5a8b8a273c --- /dev/null +++ b/include/openspace/properties/scalar/longproperty.h @@ -0,0 +1,53 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __LONGPROPERTY_H__ +#define __LONGPROPERTY_H__ + + /** + * \file longproperty.h + * + * \addtogroup openspace + * @{ + * \addtogroup properties + * @{ + + * \class LongProperty + * This class is a concrete implementation of openspace::properties::TemplateProperty with + * the type long. + + * @} @} + */ + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(LongProperty, long); + +} // namespace properties +} // namespace openspace + +#endif // __LONGPROPERTY_H__ diff --git a/include/openspace/properties/scalar/shortproperty.h b/include/openspace/properties/scalar/shortproperty.h new file mode 100644 index 0000000000..8f862e9f13 --- /dev/null +++ b/include/openspace/properties/scalar/shortproperty.h @@ -0,0 +1,53 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __SHORTPROPERTY_H__ +#define __SHORTPROPERTY_H__ + + /** + * \file shortproperty.h + * + * \addtogroup openspace + * @{ + * \addtogroup properties + * @{ + + * \class ShortProperty + * This class is a concrete implementation of openspace::properties::TemplateProperty with + * the type short. + + * @} @} + */ + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(ShortProperty, short); + +} // namespace properties +} // namespace openspace + +#endif // __SHORTPROPERTY_H__ diff --git a/include/openspace/properties/scalar/signedcharproperty.h b/include/openspace/properties/scalar/signedcharproperty.h new file mode 100644 index 0000000000..c3aacd600f --- /dev/null +++ b/include/openspace/properties/scalar/signedcharproperty.h @@ -0,0 +1,53 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __SIGNEDCHARPROPERTY_H__ +#define __SIGNEDCHARPROPERTY_H__ + + /** + * \file signedcharproperty.h + * + * \addtogroup openspace + * @{ + * \addtogroup properties + * @{ + + * \class SignedCharProperty + * This class is a concrete implementation of openspace::properties::TemplateProperty with + * the type signed char. + + * @} @} + */ + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(SignedCharProperty, signed char); + +} // namespace properties +} // namespace openspace + +#endif // __SIGNEDCHARPROPERTY_H__ diff --git a/include/openspace/properties/scalar/ucharproperty.h b/include/openspace/properties/scalar/ucharproperty.h new file mode 100644 index 0000000000..c22e4abeec --- /dev/null +++ b/include/openspace/properties/scalar/ucharproperty.h @@ -0,0 +1,53 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __UCHARPROPERTY_H__ +#define __UCHARPROPERTY_H__ + + /** + * \file ucharproperty.h + * + * \addtogroup openspace + * @{ + * \addtogroup properties + * @{ + + * \class UCharProperty + * This class is a concrete implementation of openspace::properties::TemplateProperty with + * the type unsigned char. + + * @} @} + */ + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(UCharProperty, unsigned char); + +} // namespace properties +} // namespace openspace + +#endif // __UCHARPROPERTY_H__ diff --git a/include/openspace/properties/scalar/uintproperty.h b/include/openspace/properties/scalar/uintproperty.h new file mode 100644 index 0000000000..4aa70035d0 --- /dev/null +++ b/include/openspace/properties/scalar/uintproperty.h @@ -0,0 +1,53 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __UINTPROPERTY_H__ +#define __UINTPROPERTY_H__ + + /** + * \file uintproperty.h + * + * \addtogroup openspace + * @{ + * \addtogroup properties + * @{ + + * \class UIntProperty + * This class is a concrete implementation of openspace::properties::TemplateProperty with + * the type unsigned int. + + * @} @} + */ + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(UIntProperty, unsigned int); + +} // namespace properties +} // namespace openspace + +#endif // __UINTPROPERTY_H__ diff --git a/include/openspace/properties/scalar/ulonglongproperty.h b/include/openspace/properties/scalar/ulonglongproperty.h new file mode 100644 index 0000000000..7fd7c7f980 --- /dev/null +++ b/include/openspace/properties/scalar/ulonglongproperty.h @@ -0,0 +1,53 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __ULONGLONGPROPERTY_H__ +#define __ULONGLONGPROPERTY_H__ + + /** + * \file ulonglongproperty.h + * + * \addtogroup openspace + * @{ + * \addtogroup properties + * @{ + + * \class ULongLongProperty + * This class is a concrete implementation of openspace::properties::TemplateProperty with + * the type unsigned long long. + + * @} @} + */ + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(ULongLongProperty, unsigned long long); + +} // namespace properties +} // namespace openspace + +#endif // __ULONGLONGPROPERTY_H__ diff --git a/include/openspace/properties/scalar/ulongproperty.h b/include/openspace/properties/scalar/ulongproperty.h new file mode 100644 index 0000000000..a346551618 --- /dev/null +++ b/include/openspace/properties/scalar/ulongproperty.h @@ -0,0 +1,53 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __ULONGPROPERTY_H__ +#define __ULONGPROPERTY_H__ + + /** + * \file ulongproperty.h + * + * \addtogroup openspace + * @{ + * \addtogroup properties + * @{ + + * \class ULongProperty + * This class is a concrete implementation of openspace::properties::TemplateProperty with + * the type unsigned long. + + * @} @} + */ + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(ULongProperty, unsigned long); + +} // namespace properties +} // namespace openspace + +#endif // __ULONGPROPERTY_H__ diff --git a/include/openspace/properties/scalar/ushortproperty.h b/include/openspace/properties/scalar/ushortproperty.h new file mode 100644 index 0000000000..8e9b7ea882 --- /dev/null +++ b/include/openspace/properties/scalar/ushortproperty.h @@ -0,0 +1,53 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __USHORTPROPERTY_H__ +#define __USHORTPROPERTY_H__ + + /** + * \file ushortproperty.h + * + * \addtogroup openspace + * @{ + * \addtogroup properties + * @{ + + * \class UShortProperty + * This class is a concrete implementation of openspace::properties::TemplateProperty with + * the type unsigned short. + + * @} @} + */ + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(UShortProperty, unsigned short); + +} // namespace properties +} // namespace openspace + +#endif // __USHORTPROPERTY_H__ diff --git a/include/openspace/properties/scalar/wcharproperty.h b/include/openspace/properties/scalar/wcharproperty.h new file mode 100644 index 0000000000..f6b91d4766 --- /dev/null +++ b/include/openspace/properties/scalar/wcharproperty.h @@ -0,0 +1,53 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __WCHARPROPERTY_H__ +#define __WCHARPROPERTY_H__ + + /** + * \file wcharproperty.h + * + * \addtogroup openspace + * @{ + * \addtogroup properties + * @{ + + * \class WCharProperty + * This class is a concrete implementation of openspace::properties::TemplateProperty with + * the type wchar_t. + + * @} @} + */ + +#include + +namespace openspace { +namespace properties { + +//REGISTER_NUMERICALPROPERTY_HEADER(WCharProperty, wchar_t); + +} // namespace properties +} // namespace openspace + +#endif // __WCHARPROPERTY_H__ diff --git a/include/openspace/properties/scalarproperty.h b/include/openspace/properties/scalarproperty.h index 7576edd37d..8127b83077 100644 --- a/include/openspace/properties/scalarproperty.h +++ b/include/openspace/properties/scalarproperty.h @@ -25,100 +25,23 @@ #ifndef __SCALARPROPERTY_H__ #define __SCALARPROPERTY_H__ - /** - * \file scalarproperty.h - * - * \addtogroup openspace - * @{ - * \addtogroup properties - * @{ - - * \class BoolProperty - * This class is a concrete implementation of openspace::properties::TemplateProperty with - * the type bool. +#include - * \class CharProperty - * This class is a concrete implementation of openspace::properties::TemplateProperty with - * the type char. - - * \class SignedCharProperty - * This class is a concrete implementation of openspace::properties::TemplateProperty with - * the type signed char. - - * \class UCharProperty - * This class is a concrete implementation of openspace::properties::TemplateProperty with - * the type unsigned char. - - * \class ShortProperty - * This class is a concrete implementation of openspace::properties::TemplateProperty with - * the type short. - - * \class UShortProperty - * This class is a concrete implementation of openspace::properties::TemplateProperty with - * the type unsigned short. - - * \class IntProperty - * This class is a concrete implementation of openspace::properties::TemplateProperty with - * the type int. - - * \class UIntProperty - * This class is a concrete implementation of openspace::properties::TemplateProperty with - * the type unsigned int. - - * \class LongProperty - * This class is a concrete implementation of openspace::properties::TemplateProperty with - * the type long. - - * \class ULongProperty - * This class is a concrete implementation of openspace::properties::TemplateProperty with - * the type unsigned long. - - * \class LongLongProperty - * This class is a concrete implementation of openspace::properties::TemplateProperty with - * the type long long. - - * \class ULongLongProperty - * This class is a concrete implementation of openspace::properties::TemplateProperty with - * the type unsigned long long. - - * \class FloatProperty - * This class is a concrete implementation of openspace::properties::TemplateProperty with - * the type float. - - * \class DoubleProperty - * This class is a concrete implementation of openspace::properties::TemplateProperty with - * the type double. - - * \class LongDoubleProperty - * This class is a concrete implementation of openspace::properties::TemplateProperty with - * the type long double. - - * @} @} - */ - -#include "openspace/properties/numericalproperty.h" - -namespace openspace { -namespace properties { - -REGISTER_TEMPLATEPROPERTY_HEADER(BoolProperty, bool); -REGISTER_NUMERICALPROPERTY_HEADER(CharProperty, char); -//REGISTER_NUMERICALPROPERTY_HEADER(WCharProperty, wchar_t); -REGISTER_NUMERICALPROPERTY_HEADER(SignedCharProperty, signed char); -REGISTER_NUMERICALPROPERTY_HEADER(UCharProperty, unsigned char); -REGISTER_NUMERICALPROPERTY_HEADER(ShortProperty, short); -REGISTER_NUMERICALPROPERTY_HEADER(UShortProperty, unsigned short); -REGISTER_NUMERICALPROPERTY_HEADER(IntProperty, int); -REGISTER_NUMERICALPROPERTY_HEADER(UIntProperty, unsigned int); -REGISTER_NUMERICALPROPERTY_HEADER(LongProperty, long); -REGISTER_NUMERICALPROPERTY_HEADER(ULongProperty, unsigned long); -REGISTER_NUMERICALPROPERTY_HEADER(LongLongProperty, long long); -REGISTER_NUMERICALPROPERTY_HEADER(ULongLongProperty, unsigned long long); -REGISTER_NUMERICALPROPERTY_HEADER(FloatProperty, float); -REGISTER_NUMERICALPROPERTY_HEADER(DoubleProperty, double); -REGISTER_NUMERICALPROPERTY_HEADER(LongDoubleProperty, long double); - -} // namespace properties -} // namespace openspace +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #endif // __SCALARPROPERTY_H__ diff --git a/include/openspace/properties/selectionproperty.h b/include/openspace/properties/selectionproperty.h index ad2cafc4f4..3eefe59b31 100644 --- a/include/openspace/properties/selectionproperty.h +++ b/include/openspace/properties/selectionproperty.h @@ -25,7 +25,7 @@ #ifndef __SELECTIONPROPERTY_H__ #define __SELECTIONPROPERTY_H__ -#include +#include #include diff --git a/include/openspace/properties/ucharproperty.h b/include/openspace/properties/ucharproperty.h new file mode 100644 index 0000000000..f0d7de59ef --- /dev/null +++ b/include/openspace/properties/ucharproperty.h @@ -0,0 +1,53 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __UCHARPROPERTY_H__ +#define __UCHARPROPERTY_H__ + + /** + * \file ucharproperty.h + * + * \addtogroup openspace + * @{ + * \addtogroup properties + * @{ + + * \class UCharProperty + * This class is a concrete implementation of openspace::properties::TemplateProperty with + * the type unsigned char. + + * @} @} + */ + +#include "openspace/properties/numericalproperty.h" + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(UCharProperty, unsigned char); + +} // namespace properties +} // namespace openspace + +#endif // __UCHARPROPERTY_H__ diff --git a/include/openspace/properties/uintproperty.h b/include/openspace/properties/uintproperty.h new file mode 100644 index 0000000000..2e4b50b103 --- /dev/null +++ b/include/openspace/properties/uintproperty.h @@ -0,0 +1,53 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __UINTPROPERTY_H__ +#define __UINTPROPERTY_H__ + + /** + * \file uintproperty.h + * + * \addtogroup openspace + * @{ + * \addtogroup properties + * @{ + + * \class UIntProperty + * This class is a concrete implementation of openspace::properties::TemplateProperty with + * the type unsigned int. + + * @} @} + */ + +#include "openspace/properties/numericalproperty.h" + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(UIntProperty, unsigned int); + +} // namespace properties +} // namespace openspace + +#endif // __UINTPROPERTY_H__ diff --git a/include/openspace/properties/vector/bvec2property.h b/include/openspace/properties/vector/bvec2property.h new file mode 100644 index 0000000000..ba2c6f607e --- /dev/null +++ b/include/openspace/properties/vector/bvec2property.h @@ -0,0 +1,40 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __BVEC2PROPERTY_H__ +#define __BVEC2PROPERTY_H__ + +#include + +#include + +namespace openspace { +namespace properties { + +REGISTER_TEMPLATEPROPERTY_HEADER(BVec2Property, glm::bvec2); + +} // namespace properties +} // namespace openspace + +#endif // __BVEC2PROPERTY_H__ diff --git a/include/openspace/properties/vector/bvec3property.h b/include/openspace/properties/vector/bvec3property.h new file mode 100644 index 0000000000..482b573871 --- /dev/null +++ b/include/openspace/properties/vector/bvec3property.h @@ -0,0 +1,40 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __BVEC3PROPERTY_H__ +#define __BVEC3PROPERTY_H__ + +#include + +#include + +namespace openspace { +namespace properties { + +REGISTER_TEMPLATEPROPERTY_HEADER(BVec3Property, glm::bvec3); + +} // namespace properties +} // namespace openspace + +#endif // __BVEC3PROPERTY_H__ diff --git a/include/openspace/properties/vector/bvec4property.h b/include/openspace/properties/vector/bvec4property.h new file mode 100644 index 0000000000..971e323d95 --- /dev/null +++ b/include/openspace/properties/vector/bvec4property.h @@ -0,0 +1,40 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __BVEC4PROPERTY_H__ +#define __BVEC4PROPERTY_H__ + +#include + +#include + +namespace openspace { +namespace properties { + +REGISTER_TEMPLATEPROPERTY_HEADER(BVec4Property, glm::bvec4); + +} // namespace properties +} // namespace openspace + +#endif // __BVEC4PROPERTY_H__ diff --git a/include/openspace/properties/vector/dvec2property.h b/include/openspace/properties/vector/dvec2property.h new file mode 100644 index 0000000000..eb42825526 --- /dev/null +++ b/include/openspace/properties/vector/dvec2property.h @@ -0,0 +1,40 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __DVEC2PROPERTY_H__ +#define __DVEC2PROPERTY_H__ + +#include + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(DVec2Property, glm::dvec2); + +} // namespace properties +} // namespace openspace + +#endif // __DVEC2PROPERTY_H__ diff --git a/include/openspace/properties/vector/dvec3property.h b/include/openspace/properties/vector/dvec3property.h new file mode 100644 index 0000000000..01d9c1a51a --- /dev/null +++ b/include/openspace/properties/vector/dvec3property.h @@ -0,0 +1,40 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __DVEC3PROPERTY_H__ +#define __DVEC3PROPERTY_H__ + +#include + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(DVec3Property, glm::dvec3); + +} // namespace properties +} // namespace openspace + +#endif // __DVEC3PROPERTY_H__ diff --git a/include/openspace/properties/vector/dvec4property.h b/include/openspace/properties/vector/dvec4property.h new file mode 100644 index 0000000000..21ec5ef4bc --- /dev/null +++ b/include/openspace/properties/vector/dvec4property.h @@ -0,0 +1,40 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __DVEC4PROPERTY_H__ +#define __DVEC4PROPERTY_H__ + +#include + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(DVec4Property, glm::dvec4); + +} // namespace properties +} // namespace openspace + +#endif // __DVEC4PROPERTY_H__ diff --git a/include/openspace/properties/vector/ivec2property.h b/include/openspace/properties/vector/ivec2property.h new file mode 100644 index 0000000000..b0b1864127 --- /dev/null +++ b/include/openspace/properties/vector/ivec2property.h @@ -0,0 +1,40 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __IVEC2PROPERTY_H__ +#define __IVEC2PROPERTY_H__ + +#include + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(IVec2Property, glm::ivec2); + +} // namespace properties +} // namespace openspace + +#endif // __IVEC2PROPERTY_H__ diff --git a/include/openspace/properties/vector/ivec3property.h b/include/openspace/properties/vector/ivec3property.h new file mode 100644 index 0000000000..423c807de9 --- /dev/null +++ b/include/openspace/properties/vector/ivec3property.h @@ -0,0 +1,40 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __IVEC3PROPERTY_H__ +#define __IVEC3PROPERTY_H__ + +#include + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(IVec3Property, glm::ivec3); + +} // namespace properties +} // namespace openspace + +#endif // __IVEC3PROPERTY_H__ diff --git a/include/openspace/properties/vector/ivec4property.h b/include/openspace/properties/vector/ivec4property.h new file mode 100644 index 0000000000..8d23b78d56 --- /dev/null +++ b/include/openspace/properties/vector/ivec4property.h @@ -0,0 +1,40 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __IVEC4PROPERTY_H__ +#define __IVEC4PROPERTY_H__ + +#include + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(IVec4Property, glm::ivec4); + +} // namespace properties +} // namespace openspace + +#endif // __IVEC4PROPERTY_H__ diff --git a/include/openspace/properties/vector/uvec2property.h b/include/openspace/properties/vector/uvec2property.h new file mode 100644 index 0000000000..1d3ea09f92 --- /dev/null +++ b/include/openspace/properties/vector/uvec2property.h @@ -0,0 +1,40 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __UVEC2PROPERTY_H__ +#define __UVEC2PROPERTY_H__ + +#include + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(UVec2Property, glm::uvec2); + +} // namespace properties +} // namespace openspace + +#endif // __UVEC2PROPERTY_H__ diff --git a/include/openspace/properties/vector/uvec3property.h b/include/openspace/properties/vector/uvec3property.h new file mode 100644 index 0000000000..c189e7e2b6 --- /dev/null +++ b/include/openspace/properties/vector/uvec3property.h @@ -0,0 +1,40 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __UVEC3PROPERTY_H__ +#define __UVEC3PROPERTY_H__ + +#include + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(UVec3Property, glm::uvec3); + +} // namespace properties +} // namespace openspace + +#endif // __UVEC3PROPERTY_H__ diff --git a/include/openspace/properties/vector/uvec4property.h b/include/openspace/properties/vector/uvec4property.h new file mode 100644 index 0000000000..24a77157c1 --- /dev/null +++ b/include/openspace/properties/vector/uvec4property.h @@ -0,0 +1,40 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __UVEC4PROPERTY_H__ +#define __UVEC4PROPERTY_H__ + +#include + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(UVec4Property, glm::uvec4); + +} // namespace properties +} // namespace openspace + +#endif // __UVEC4PROPERTY_H__ diff --git a/include/openspace/properties/vector/vec2property.h b/include/openspace/properties/vector/vec2property.h new file mode 100644 index 0000000000..40a112abfa --- /dev/null +++ b/include/openspace/properties/vector/vec2property.h @@ -0,0 +1,40 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __VEC2PROPERTY_H__ +#define __VEC2PROPERTY_H__ + +#include + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(Vec2Property, glm::vec2); + +} // namespace properties +} // namespace openspace + +#endif // __VEC2PROPERTY_H__ diff --git a/include/openspace/properties/vector/vec3property.h b/include/openspace/properties/vector/vec3property.h new file mode 100644 index 0000000000..11416f467b --- /dev/null +++ b/include/openspace/properties/vector/vec3property.h @@ -0,0 +1,40 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __VEC3PROPERTY_H__ +#define __VEC3PROPERTY_H__ + +#include + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(Vec3Property, glm::vec3); + +} // namespace properties +} // namespace openspace + +#endif // __VEC3PROPERTY_H__ diff --git a/include/openspace/properties/vector/vec4property.h b/include/openspace/properties/vector/vec4property.h new file mode 100644 index 0000000000..0ee753b33b --- /dev/null +++ b/include/openspace/properties/vector/vec4property.h @@ -0,0 +1,40 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __VEC4PROPERTY_H__ +#define __VEC4PROPERTY_H__ + +#include + +#include + +namespace openspace { +namespace properties { + +REGISTER_NUMERICALPROPERTY_HEADER(Vec4Property, glm::vec4); + +} // namespace properties +} // namespace openspace + +#endif // __VEC4PROPERTY_H__ diff --git a/include/openspace/properties/vectorproperty.h b/include/openspace/properties/vectorproperty.h index a1307037ba..6c13d195d5 100644 --- a/include/openspace/properties/vectorproperty.h +++ b/include/openspace/properties/vectorproperty.h @@ -25,31 +25,26 @@ #ifndef __VECTORPROPERTY_H__ #define __VECTORPROPERTY_H__ -#include "openspace/properties/numericalproperty.h" +#include -#include +#include +#include +#include -namespace openspace { -namespace properties { +#include +#include +#include -REGISTER_TEMPLATEPROPERTY_HEADER(BVec2Property, glm::bvec2); -REGISTER_TEMPLATEPROPERTY_HEADER(BVec3Property, glm::bvec3); -REGISTER_TEMPLATEPROPERTY_HEADER(BVec4Property, glm::bvec4); +#include +#include +#include -REGISTER_NUMERICALPROPERTY_HEADER(Vec2Property, glm::vec2); -REGISTER_NUMERICALPROPERTY_HEADER(Vec3Property, glm::vec3); -REGISTER_NUMERICALPROPERTY_HEADER(Vec4Property, glm::vec4); -REGISTER_NUMERICALPROPERTY_HEADER(DVec2Property, glm::dvec2); -REGISTER_NUMERICALPROPERTY_HEADER(DVec3Property, glm::dvec3); -REGISTER_NUMERICALPROPERTY_HEADER(DVec4Property, glm::dvec4); -REGISTER_NUMERICALPROPERTY_HEADER(IVec2Property, glm::ivec2); -REGISTER_NUMERICALPROPERTY_HEADER(IVec3Property, glm::ivec3); -REGISTER_NUMERICALPROPERTY_HEADER(IVec4Property, glm::ivec4); -REGISTER_NUMERICALPROPERTY_HEADER(UVec2Property, glm::uvec2); -REGISTER_NUMERICALPROPERTY_HEADER(UVec3Property, glm::uvec3); -REGISTER_NUMERICALPROPERTY_HEADER(UVec4Property, glm::uvec4); +#include +#include +#include -} // namespace properties -} // namespace openspace +#include +#include +#include #endif // __INTPROPERTY_H__ diff --git a/include/openspace/properties/wcharproperty.h b/include/openspace/properties/wcharproperty.h new file mode 100644 index 0000000000..38d12030ce --- /dev/null +++ b/include/openspace/properties/wcharproperty.h @@ -0,0 +1,53 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __WCHARPROPERTY_H__ +#define __WCHARPROPERTY_H__ + + /** + * \file wcharproperty.h + * + * \addtogroup openspace + * @{ + * \addtogroup properties + * @{ + + * \class WCharProperty + * This class is a concrete implementation of openspace::properties::TemplateProperty with + * the type wchar_t. + + * @} @} + */ + +#include "openspace/properties/numericalproperty.h" + +namespace openspace { +namespace properties { + +//REGISTER_NUMERICALPROPERTY_HEADER(WCharProperty, wchar_t); + +} // namespace properties +} // namespace openspace + +#endif // __WCHARPROPERTY_H__ diff --git a/include/openspace/rendering/renderable.h b/include/openspace/rendering/renderable.h index de1934821d..4ecd81f97a 100644 --- a/include/openspace/rendering/renderable.h +++ b/include/openspace/rendering/renderable.h @@ -26,7 +26,8 @@ #define __RENDERABLE_H__ #include -#include + +#include #include #include diff --git a/include/openspace/rendering/renderengine.h b/include/openspace/rendering/renderengine.h index 2120554775..6ec9765c4b 100644 --- a/include/openspace/rendering/renderengine.h +++ b/include/openspace/rendering/renderengine.h @@ -29,7 +29,7 @@ #include #include -#include +#include #include diff --git a/include/openspace/rendering/screenspacerenderable.h b/include/openspace/rendering/screenspacerenderable.h index 46cea14e32..adc6633787 100644 --- a/include/openspace/rendering/screenspacerenderable.h +++ b/include/openspace/rendering/screenspacerenderable.h @@ -27,9 +27,10 @@ #include -#include #include -#include +#include +#include +#include #include #include diff --git a/include/openspace/util/powerscaledsphere.h b/include/openspace/util/powerscaledsphere.h index 26d36eb2ce..c7e6bd8576 100644 --- a/include/openspace/util/powerscaledsphere.h +++ b/include/openspace/util/powerscaledsphere.h @@ -29,7 +29,7 @@ #include #include #include -#include +#include namespace openspace { diff --git a/modules/base/rendering/modelgeometry.h b/modules/base/rendering/modelgeometry.h index edfbada197..f01989799a 100644 --- a/modules/base/rendering/modelgeometry.h +++ b/modules/base/rendering/modelgeometry.h @@ -28,7 +28,6 @@ #include #include -#include #include #include diff --git a/modules/base/rendering/renderableconstellationbounds.cpp b/modules/base/rendering/renderableconstellationbounds.cpp index 66c279f4d3..b75c5fdbc7 100644 --- a/modules/base/rendering/renderableconstellationbounds.cpp +++ b/modules/base/rendering/renderableconstellationbounds.cpp @@ -61,7 +61,7 @@ namespace { namespace openspace { RenderableConstellationBounds::RenderableConstellationBounds( - const ghoul::Dictionary& dictionary) + const ghoul::Dictionary& dictionary) : Renderable(dictionary) , _vertexFilename("") , _constellationFilename("") @@ -91,9 +91,6 @@ RenderableConstellationBounds::RenderableConstellationBounds( ); } -RenderableConstellationBounds::~RenderableConstellationBounds() { -} - bool RenderableConstellationBounds::initialize() { RenderEngine& renderEngine = OsEng.renderEngine(); _program = renderEngine.buildRenderProgram("ConstellationBounds", diff --git a/modules/base/rendering/renderableconstellationbounds.h b/modules/base/rendering/renderableconstellationbounds.h index b4b7774c0f..2a6ab74a04 100644 --- a/modules/base/rendering/renderableconstellationbounds.h +++ b/modules/base/rendering/renderableconstellationbounds.h @@ -26,6 +26,7 @@ #define __RENDERABLECONSTELLATIONBOUNDS_H__ #include + #include #include #include @@ -53,7 +54,6 @@ namespace openspace { class RenderableConstellationBounds : public Renderable { public: RenderableConstellationBounds(const ghoul::Dictionary& dictionary); - ~RenderableConstellationBounds(); bool initialize() override; bool deinitialize() override; diff --git a/modules/base/rendering/renderablemodel.h b/modules/base/rendering/renderablemodel.h index 5f842336ca..a476562be9 100644 --- a/modules/base/rendering/renderablemodel.h +++ b/modules/base/rendering/renderablemodel.h @@ -28,7 +28,9 @@ #include #include -#include +#include +#include +#include #include #include diff --git a/modules/base/rendering/renderablepath.cpp b/modules/base/rendering/renderablepath.cpp index b94d02f178..f0e3623950 100644 --- a/modules/base/rendering/renderablepath.cpp +++ b/modules/base/rendering/renderablepath.cpp @@ -52,7 +52,6 @@ namespace { const char* keyPointSteps = "PointSteps"; const char* keyDrawLine = "DrawLine"; const char* keRenderDistanceInterval = "RenderDistanceInterval"; - } namespace openspace { diff --git a/modules/base/rendering/renderablepath.h b/modules/base/rendering/renderablepath.h index 4e8cdeefb7..5627363162 100644 --- a/modules/base/rendering/renderablepath.h +++ b/modules/base/rendering/renderablepath.h @@ -26,8 +26,8 @@ #define __RENDERABLEPATH_H__ #include -#include -#include +#include +#include #include diff --git a/modules/base/rendering/renderableplane.h b/modules/base/rendering/renderableplane.h index fc4e8f795c..8057895d52 100644 --- a/modules/base/rendering/renderableplane.h +++ b/modules/base/rendering/renderableplane.h @@ -28,7 +28,8 @@ #include #include -#include +#include +#include #include namespace ghoul { diff --git a/modules/base/rendering/renderableplanet.h b/modules/base/rendering/renderableplanet.h index 9080b60fd4..47f26ea491 100644 --- a/modules/base/rendering/renderableplanet.h +++ b/modules/base/rendering/renderableplanet.h @@ -29,6 +29,9 @@ #include #include +#include +#include +#include #include #include diff --git a/modules/base/rendering/renderablerings.h b/modules/base/rendering/renderablerings.h index 75aa28a8c8..f6319ceece 100644 --- a/modules/base/rendering/renderablerings.h +++ b/modules/base/rendering/renderablerings.h @@ -29,7 +29,8 @@ #include #include -#include +#include +#include #include namespace ghoul { diff --git a/modules/base/rendering/renderablesphere.h b/modules/base/rendering/renderablesphere.h index 2a2d49c1b0..8b82e0f8b0 100644 --- a/modules/base/rendering/renderablesphere.h +++ b/modules/base/rendering/renderablesphere.h @@ -30,7 +30,9 @@ #include #include -#include +#include +#include +#include #include #include diff --git a/modules/base/rendering/renderablestars.h b/modules/base/rendering/renderablestars.h index a40a732d3a..b1c309d3c4 100644 --- a/modules/base/rendering/renderablestars.h +++ b/modules/base/rendering/renderablestars.h @@ -30,7 +30,7 @@ #include #include #include -#include +#include namespace ghoul { namespace filesystem { diff --git a/modules/base/rendering/renderabletrail.h b/modules/base/rendering/renderabletrail.h index a43dc7974f..fac2259f49 100644 --- a/modules/base/rendering/renderabletrail.h +++ b/modules/base/rendering/renderabletrail.h @@ -29,9 +29,11 @@ #include #include -#include +#include +#include +#include #include -#include +#include #include diff --git a/modules/base/rendering/renderabletrailorbit.h b/modules/base/rendering/renderabletrailorbit.h index 68ec1ca7f1..2b8f5a4712 100644 --- a/modules/base/rendering/renderabletrailorbit.h +++ b/modules/base/rendering/renderabletrailorbit.h @@ -28,7 +28,8 @@ #include #include -#include +#include +#include namespace openspace { diff --git a/modules/base/rendering/renderabletrailtrajectory.h b/modules/base/rendering/renderabletrailtrajectory.h index b913d40118..bba77cfa68 100644 --- a/modules/base/rendering/renderabletrailtrajectory.h +++ b/modules/base/rendering/renderabletrailtrajectory.h @@ -28,7 +28,9 @@ #include #include -#include +#include +#include +#include #include namespace openspace { diff --git a/modules/base/rendering/screenspaceframebuffer.h b/modules/base/rendering/screenspaceframebuffer.h index e9f6586bb1..6bce0a9ab5 100644 --- a/modules/base/rendering/screenspaceframebuffer.h +++ b/modules/base/rendering/screenspaceframebuffer.h @@ -21,10 +21,13 @@ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ + #ifndef __SCREENSPACEFRAMEBUFFER_H__ #define __SCREENSPACEFRAMEBUFFER_H__ #include + +#include #include #include diff --git a/modules/base/rendering/simplespheregeometry.h b/modules/base/rendering/simplespheregeometry.h index 1b752a2b48..0d7fa3de9a 100644 --- a/modules/base/rendering/simplespheregeometry.h +++ b/modules/base/rendering/simplespheregeometry.h @@ -26,8 +26,9 @@ #define __SIMPLESPHEREGEOMETRY_H__ #include -#include -#include + +#include +#include namespace openspace { diff --git a/modules/base/rotation/staticrotation.h b/modules/base/rotation/staticrotation.h index 8df5c8637e..95490dd186 100644 --- a/modules/base/rotation/staticrotation.h +++ b/modules/base/rotation/staticrotation.h @@ -28,7 +28,7 @@ #include #include -#include +#include namespace openspace { diff --git a/modules/base/scale/staticscale.h b/modules/base/scale/staticscale.h index e99e07fd60..29db57acd3 100644 --- a/modules/base/scale/staticscale.h +++ b/modules/base/scale/staticscale.h @@ -28,6 +28,7 @@ #include #include +#include namespace openspace { diff --git a/modules/base/translation/statictranslation.h b/modules/base/translation/statictranslation.h index 3a71266c28..f753e92202 100644 --- a/modules/base/translation/statictranslation.h +++ b/modules/base/translation/statictranslation.h @@ -28,7 +28,7 @@ #include #include -#include +#include namespace openspace { diff --git a/modules/debugging/rendering/renderabledebugplane.h b/modules/debugging/rendering/renderabledebugplane.h index 40b2621aba..2afeadab05 100644 --- a/modules/debugging/rendering/renderabledebugplane.h +++ b/modules/debugging/rendering/renderabledebugplane.h @@ -28,7 +28,7 @@ #include #include -#include +#include #include namespace ghoul { diff --git a/modules/globebrowsing/globes/renderableglobe.h b/modules/globebrowsing/globes/renderableglobe.h index f854a94156..78ac016114 100644 --- a/modules/globebrowsing/globes/renderableglobe.h +++ b/modules/globebrowsing/globes/renderableglobe.h @@ -34,6 +34,9 @@ #include #include +#include +#include + #include #include diff --git a/modules/newhorizons/rendering/renderablefov.h b/modules/newhorizons/rendering/renderablefov.h index c752f49d9d..eb8750ac88 100644 --- a/modules/newhorizons/rendering/renderablefov.h +++ b/modules/newhorizons/rendering/renderablefov.h @@ -27,6 +27,8 @@ #include +#include +#include #include #include diff --git a/modules/newhorizons/rendering/renderablemodelprojection.h b/modules/newhorizons/rendering/renderablemodelprojection.h index 60349f5033..317b486781 100644 --- a/modules/newhorizons/rendering/renderablemodelprojection.h +++ b/modules/newhorizons/rendering/renderablemodelprojection.h @@ -34,7 +34,7 @@ #include #include -#include +#include #include #include diff --git a/modules/newhorizons/rendering/renderableplaneprojection.h b/modules/newhorizons/rendering/renderableplaneprojection.h index 7c2ee5b6ac..8981bdc5c0 100644 --- a/modules/newhorizons/rendering/renderableplaneprojection.h +++ b/modules/newhorizons/rendering/renderableplaneprojection.h @@ -29,7 +29,6 @@ #include #include -#include #include #include diff --git a/modules/newhorizons/rendering/renderableshadowcylinder.h b/modules/newhorizons/rendering/renderableshadowcylinder.h index bd05fda49a..09f1b9d188 100644 --- a/modules/newhorizons/rendering/renderableshadowcylinder.h +++ b/modules/newhorizons/rendering/renderableshadowcylinder.h @@ -28,7 +28,9 @@ #include #include -#include +#include +#include +#include #include #include diff --git a/modules/newhorizons/util/projectioncomponent.h b/modules/newhorizons/util/projectioncomponent.h index ef6b57cd4e..3e027cb7f4 100644 --- a/modules/newhorizons/util/projectioncomponent.h +++ b/modules/newhorizons/util/projectioncomponent.h @@ -28,9 +28,11 @@ #include #include -#include #include -#include +#include +#include +#include +#include #include #include diff --git a/modules/onscreengui/include/guicomponent.h b/modules/onscreengui/include/guicomponent.h index dd4baeba70..585870ba4d 100644 --- a/modules/onscreengui/include/guicomponent.h +++ b/modules/onscreengui/include/guicomponent.h @@ -26,7 +26,7 @@ #define __GUICOMPONENT_H__ #include -#include +#include namespace openspace { namespace gui { diff --git a/modules/onscreengui/include/guiperformancecomponent.h b/modules/onscreengui/include/guiperformancecomponent.h index 20e06f137c..33a7ac5667 100644 --- a/modules/onscreengui/include/guiperformancecomponent.h +++ b/modules/onscreengui/include/guiperformancecomponent.h @@ -27,6 +27,9 @@ #include +#include +#include + #include #include diff --git a/modules/toyvolume/rendering/renderabletoyvolume.h b/modules/toyvolume/rendering/renderabletoyvolume.h index 9c08f1af14..59f4dacf65 100644 --- a/modules/toyvolume/rendering/renderabletoyvolume.h +++ b/modules/toyvolume/rendering/renderabletoyvolume.h @@ -25,15 +25,18 @@ #ifndef __RENDERABLETOYVOLUME_H__ #define __RENDERABLETOYVOLUME_H__ -#include +#include + +#include +#include +#include +#include #include #include -#include -#include - namespace openspace { +class ToyVolumeRaycaster; struct RenderData; class RenderableToyVolume : public Renderable { diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 7d65f2e49f..2a6220dd90 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -65,15 +65,61 @@ set(OPENSPACE_SOURCE ${OPENSPACE_BASE_DIR}/src/performance/performancemeasurement.cpp ${OPENSPACE_BASE_DIR}/src/performance/performancelayout.cpp ${OPENSPACE_BASE_DIR}/src/performance/performancemanager.cpp - ${OPENSPACE_BASE_DIR}/src/properties/matrixproperty.cpp ${OPENSPACE_BASE_DIR}/src/properties/optionproperty.cpp ${OPENSPACE_BASE_DIR}/src/properties/property.cpp ${OPENSPACE_BASE_DIR}/src/properties/propertyowner.cpp - ${OPENSPACE_BASE_DIR}/src/properties/scalarproperty.cpp ${OPENSPACE_BASE_DIR}/src/properties/selectionproperty.cpp ${OPENSPACE_BASE_DIR}/src/properties/stringproperty.cpp ${OPENSPACE_BASE_DIR}/src/properties/triggerproperty.cpp - ${OPENSPACE_BASE_DIR}/src/properties/vectorproperty.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 + ${OPENSPACE_BASE_DIR}/src/properties/vector/ivec2property.cpp + ${OPENSPACE_BASE_DIR}/src/properties/vector/ivec3property.cpp + ${OPENSPACE_BASE_DIR}/src/properties/vector/ivec4property.cpp + ${OPENSPACE_BASE_DIR}/src/properties/vector/uvec2property.cpp + ${OPENSPACE_BASE_DIR}/src/properties/vector/uvec3property.cpp + ${OPENSPACE_BASE_DIR}/src/properties/vector/uvec4property.cpp + ${OPENSPACE_BASE_DIR}/src/properties/vector/vec2property.cpp + ${OPENSPACE_BASE_DIR}/src/properties/vector/vec3property.cpp + ${OPENSPACE_BASE_DIR}/src/properties/vector/vec4property.cpp ${OPENSPACE_BASE_DIR}/src/query/query.cpp ${OPENSPACE_BASE_DIR}/src/rendering/abufferrenderer.cpp ${OPENSPACE_BASE_DIR}/src/rendering/framebufferrenderer.cpp @@ -172,6 +218,55 @@ set(OPENSPACE_HEADER ${OPENSPACE_BASE_DIR}/include/openspace/properties/templateproperty.inl ${OPENSPACE_BASE_DIR}/include/openspace/properties/triggerproperty.h ${OPENSPACE_BASE_DIR}/include/openspace/properties/vectorproperty.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 + ${OPENSPACE_BASE_DIR}/include/openspace/properties/vector/ivec2property.h + ${OPENSPACE_BASE_DIR}/include/openspace/properties/vector/ivec3property.h + ${OPENSPACE_BASE_DIR}/include/openspace/properties/vector/ivec4property.h + ${OPENSPACE_BASE_DIR}/include/openspace/properties/vector/uvec2property.h + ${OPENSPACE_BASE_DIR}/include/openspace/properties/vector/uvec3property.h + ${OPENSPACE_BASE_DIR}/include/openspace/properties/vector/uvec4property.h + ${OPENSPACE_BASE_DIR}/include/openspace/properties/vector/vec2property.h + ${OPENSPACE_BASE_DIR}/include/openspace/properties/vector/vec3property.h + ${OPENSPACE_BASE_DIR}/include/openspace/properties/vector/vec4property.h ${OPENSPACE_BASE_DIR}/include/openspace/query/query.h ${OPENSPACE_BASE_DIR}/include/openspace/rendering/abufferrenderer.h ${OPENSPACE_BASE_DIR}/include/openspace/rendering/framebufferrenderer.h diff --git a/src/properties/matrix/dmat2property.cpp b/src/properties/matrix/dmat2property.cpp new file mode 100644 index 0000000000..5803a22efa --- /dev/null +++ b/src/properties/matrix/dmat2property.cpp @@ -0,0 +1,140 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include + +#include +#include +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(__TYPE__) \ + [](lua_State* state, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + lua_getfield(state, -1, std::to_string(number).c_str()); \ + if (lua_isnumber(state, -1) != 1) { \ + success = false; \ + return __TYPE__(0); \ + } else { \ + result[i][j] \ + = static_cast<__TYPE__::value_type>(lua_tonumber(state, -1)); \ + lua_pop(state, 1); \ + ++number; \ + } \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_LUA_LAMBDA(__TYPE__) \ + [](lua_State* state, __TYPE__ value) -> bool { \ + lua_newtable(state); \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + lua_pushnumber(state, static_cast(value[i][j])); \ + lua_setfield(state, -2, std::to_string(number).c_str()); \ + ++number; \ + } \ + } \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(__TYPE__) \ + [](std::string value, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + std::vector tokens = ghoul::tokenizeString(value, ','); \ + if (tokens.size() != \ + (ghoul::glm_rows<__TYPE__>::value * ghoul::glm_cols<__TYPE__>::value)) \ + { \ + success = false; \ + return result; \ + } \ + int number = 0; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + std::stringstream s(tokens[number]); \ + __TYPE__::value_type v; \ + s >> v; \ + if (s.fail()) { \ + success = false; \ + return result; \ + } \ + else { \ + result[i][j] = v; \ + ++number; \ + } \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ + [](std::string& outValue, __TYPE__ inValue) -> bool { \ + outValue = ""; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + outValue += std::to_string(inValue[i][j]) + ","; \ + } \ + outValue.pop_back(); \ + } \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(DMat2Property, glm::dmat2x2, glm::dmat2x2(0), + glm::dmat2x2( + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest() + ), + glm::dmat2x2( + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max() + ), + glm::dmat2x2( + 0.01, 0.01, + 0.01, 0.01 + ), + DEFAULT_FROM_LUA_LAMBDA(glm::dmat2x2), + DEFAULT_TO_LUA_LAMBDA(glm::dmat2x2), + DEFAULT_FROM_STRING_LAMBDA(glm::dmat2x2), + DEFAULT_TO_STRING_LAMBDA(glm::dmat2x2), + LUA_TTABLE); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/matrix/dmat2x3property.cpp b/src/properties/matrix/dmat2x3property.cpp new file mode 100644 index 0000000000..d19e4c2ab5 --- /dev/null +++ b/src/properties/matrix/dmat2x3property.cpp @@ -0,0 +1,144 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include + +#include +#include +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(__TYPE__) \ + [](lua_State* state, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + lua_getfield(state, -1, std::to_string(number).c_str()); \ + if (lua_isnumber(state, -1) != 1) { \ + success = false; \ + return __TYPE__(0); \ + } else { \ + result[i][j] \ + = static_cast<__TYPE__::value_type>(lua_tonumber(state, -1)); \ + lua_pop(state, 1); \ + ++number; \ + } \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_LUA_LAMBDA(__TYPE__) \ + [](lua_State* state, __TYPE__ value) -> bool { \ + lua_newtable(state); \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + lua_pushnumber(state, static_cast(value[i][j])); \ + lua_setfield(state, -2, std::to_string(number).c_str()); \ + ++number; \ + } \ + } \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(__TYPE__) \ + [](std::string value, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + std::vector tokens = ghoul::tokenizeString(value, ','); \ + if (tokens.size() != \ + (ghoul::glm_rows<__TYPE__>::value * ghoul::glm_cols<__TYPE__>::value)) \ + { \ + success = false; \ + return result; \ + } \ + int number = 0; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + std::stringstream s(tokens[number]); \ + __TYPE__::value_type v; \ + s >> v; \ + if (s.fail()) { \ + success = false; \ + return result; \ + } \ + else { \ + result[i][j] = v; \ + ++number; \ + } \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ + [](std::string& outValue, __TYPE__ inValue) -> bool { \ + outValue = ""; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + outValue += std::to_string(inValue[i][j]) + ","; \ + } \ + outValue.pop_back(); \ + } \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(DMat2x3Property, glm::dmat2x3, glm::dmat2x3(0), + glm::dmat2x3( + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest() + ), + glm::dmat2x3( + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max() + ), + glm::dmat2x3( + 0.01, 0.01, 0.01, + 0.01, 0.01, 0.01 + ), + DEFAULT_FROM_LUA_LAMBDA(glm::dmat2x3), + DEFAULT_TO_LUA_LAMBDA(glm::dmat2x3), + DEFAULT_FROM_STRING_LAMBDA(glm::dmat2x3), + DEFAULT_TO_STRING_LAMBDA(glm::dmat2x3), + LUA_TTABLE); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/matrix/dmat2x4property.cpp b/src/properties/matrix/dmat2x4property.cpp new file mode 100644 index 0000000000..c98c3c6457 --- /dev/null +++ b/src/properties/matrix/dmat2x4property.cpp @@ -0,0 +1,148 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include + +#include +#include +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(__TYPE__) \ + [](lua_State* state, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + lua_getfield(state, -1, std::to_string(number).c_str()); \ + if (lua_isnumber(state, -1) != 1) { \ + success = false; \ + return __TYPE__(0); \ + } else { \ + result[i][j] \ + = static_cast<__TYPE__::value_type>(lua_tonumber(state, -1)); \ + lua_pop(state, 1); \ + ++number; \ + } \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_LUA_LAMBDA(__TYPE__) \ + [](lua_State* state, __TYPE__ value) -> bool { \ + lua_newtable(state); \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + lua_pushnumber(state, static_cast(value[i][j])); \ + lua_setfield(state, -2, std::to_string(number).c_str()); \ + ++number; \ + } \ + } \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(__TYPE__) \ + [](std::string value, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + std::vector tokens = ghoul::tokenizeString(value, ','); \ + if (tokens.size() != \ + (ghoul::glm_rows<__TYPE__>::value * ghoul::glm_cols<__TYPE__>::value)) \ + { \ + success = false; \ + return result; \ + } \ + int number = 0; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + std::stringstream s(tokens[number]); \ + __TYPE__::value_type v; \ + s >> v; \ + if (s.fail()) { \ + success = false; \ + return result; \ + } \ + else { \ + result[i][j] = v; \ + ++number; \ + } \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ + [](std::string& outValue, __TYPE__ inValue) -> bool { \ + outValue = ""; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + outValue += std::to_string(inValue[i][j]) + ","; \ + } \ + outValue.pop_back(); \ + } \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(DMat2x4Property, glm::dmat2x4, glm::dmat2x4(0), + glm::dmat2x4( + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest() + ), + glm::dmat2x4( + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max() + ), + glm::dmat2x4( + 0.01, 0.01, 0.01, 0.01, + 0.01, 0.01, 0.01, 0.01 + ), + DEFAULT_FROM_LUA_LAMBDA(glm::dmat2x4), + DEFAULT_TO_LUA_LAMBDA(glm::dmat2x4), + DEFAULT_FROM_STRING_LAMBDA(glm::dmat2x4), + DEFAULT_TO_STRING_LAMBDA(glm::dmat2x4), + LUA_TTABLE); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/matrix/dmat3property.cpp b/src/properties/matrix/dmat3property.cpp new file mode 100644 index 0000000000..5b5bed6e59 --- /dev/null +++ b/src/properties/matrix/dmat3property.cpp @@ -0,0 +1,151 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include + +#include +#include +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(__TYPE__) \ + [](lua_State* state, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + lua_getfield(state, -1, std::to_string(number).c_str()); \ + if (lua_isnumber(state, -1) != 1) { \ + success = false; \ + return __TYPE__(0); \ + } else { \ + result[i][j] \ + = static_cast<__TYPE__::value_type>(lua_tonumber(state, -1)); \ + lua_pop(state, 1); \ + ++number; \ + } \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_LUA_LAMBDA(__TYPE__) \ + [](lua_State* state, __TYPE__ value) -> bool { \ + lua_newtable(state); \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + lua_pushnumber(state, static_cast(value[i][j])); \ + lua_setfield(state, -2, std::to_string(number).c_str()); \ + ++number; \ + } \ + } \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(__TYPE__) \ + [](std::string value, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + std::vector tokens = ghoul::tokenizeString(value, ','); \ + if (tokens.size() != \ + (ghoul::glm_rows<__TYPE__>::value * ghoul::glm_cols<__TYPE__>::value)) \ + { \ + success = false; \ + return result; \ + } \ + int number = 0; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + std::stringstream s(tokens[number]); \ + __TYPE__::value_type v; \ + s >> v; \ + if (s.fail()) { \ + success = false; \ + return result; \ + } \ + else { \ + result[i][j] = v; \ + ++number; \ + } \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ + [](std::string& outValue, __TYPE__ inValue) -> bool { \ + outValue = ""; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + outValue += std::to_string(inValue[i][j]) + ","; \ + } \ + outValue.pop_back(); \ + } \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(DMat3Property, glm::dmat3x3, glm::dmat3x3(0), + glm::dmat3x3( + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest() + ), + glm::dmat3x3( + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max() + ), + glm::dmat3x3( + 0.01, 0.01, 0.01, + 0.01, 0.01, 0.01, + 0.01, 0.01, 0.01 + ), + DEFAULT_FROM_LUA_LAMBDA(glm::dmat3x3), + DEFAULT_TO_LUA_LAMBDA(glm::dmat3x3), + DEFAULT_FROM_STRING_LAMBDA(glm::dmat3x3), + DEFAULT_TO_STRING_LAMBDA(glm::dmat3x3), + LUA_TTABLE); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/matrix/dmat3x2property.cpp b/src/properties/matrix/dmat3x2property.cpp new file mode 100644 index 0000000000..1bd04eb146 --- /dev/null +++ b/src/properties/matrix/dmat3x2property.cpp @@ -0,0 +1,144 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include + +#include +#include +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(__TYPE__) \ + [](lua_State* state, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + lua_getfield(state, -1, std::to_string(number).c_str()); \ + if (lua_isnumber(state, -1) != 1) { \ + success = false; \ + return __TYPE__(0); \ + } else { \ + result[i][j] \ + = static_cast<__TYPE__::value_type>(lua_tonumber(state, -1)); \ + lua_pop(state, 1); \ + ++number; \ + } \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_LUA_LAMBDA(__TYPE__) \ + [](lua_State* state, __TYPE__ value) -> bool { \ + lua_newtable(state); \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + lua_pushnumber(state, static_cast(value[i][j])); \ + lua_setfield(state, -2, std::to_string(number).c_str()); \ + ++number; \ + } \ + } \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(__TYPE__) \ + [](std::string value, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + std::vector tokens = ghoul::tokenizeString(value, ','); \ + if (tokens.size() != \ + (ghoul::glm_rows<__TYPE__>::value * ghoul::glm_cols<__TYPE__>::value)) \ + { \ + success = false; \ + return result; \ + } \ + int number = 0; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + std::stringstream s(tokens[number]); \ + __TYPE__::value_type v; \ + s >> v; \ + if (s.fail()) { \ + success = false; \ + return result; \ + } \ + else { \ + result[i][j] = v; \ + ++number; \ + } \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ + [](std::string& outValue, __TYPE__ inValue) -> bool { \ + outValue = ""; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + outValue += std::to_string(inValue[i][j]) + ","; \ + } \ + outValue.pop_back(); \ + } \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(DMat3x2Property, glm::dmat3x2, glm::dmat3x2(0), + glm::dmat3x2( + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest() + ), + glm::dmat3x2( + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max() + ), + glm::dmat3x2( + 0.01, 0.01, 0.01, + 0.01, 0.01, 0.01 + ), + DEFAULT_FROM_LUA_LAMBDA(glm::dmat3x2), + DEFAULT_TO_LUA_LAMBDA(glm::dmat3x2), + DEFAULT_FROM_STRING_LAMBDA(glm::dmat3x2), + DEFAULT_TO_STRING_LAMBDA(glm::dmat3x2), + LUA_TTABLE); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/matrix/dmat3x4property.cpp b/src/properties/matrix/dmat3x4property.cpp new file mode 100644 index 0000000000..99dfe5283a --- /dev/null +++ b/src/properties/matrix/dmat3x4property.cpp @@ -0,0 +1,157 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include + +#include +#include +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(__TYPE__) \ + [](lua_State* state, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + lua_getfield(state, -1, std::to_string(number).c_str()); \ + if (lua_isnumber(state, -1) != 1) { \ + success = false; \ + return __TYPE__(0); \ + } else { \ + result[i][j] \ + = static_cast<__TYPE__::value_type>(lua_tonumber(state, -1)); \ + lua_pop(state, 1); \ + ++number; \ + } \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_LUA_LAMBDA(__TYPE__) \ + [](lua_State* state, __TYPE__ value) -> bool { \ + lua_newtable(state); \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + lua_pushnumber(state, static_cast(value[i][j])); \ + lua_setfield(state, -2, std::to_string(number).c_str()); \ + ++number; \ + } \ + } \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(__TYPE__) \ + [](std::string value, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + std::vector tokens = ghoul::tokenizeString(value, ','); \ + if (tokens.size() != \ + (ghoul::glm_rows<__TYPE__>::value * ghoul::glm_cols<__TYPE__>::value)) \ + { \ + success = false; \ + return result; \ + } \ + int number = 0; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + std::stringstream s(tokens[number]); \ + __TYPE__::value_type v; \ + s >> v; \ + if (s.fail()) { \ + success = false; \ + return result; \ + } \ + else { \ + result[i][j] = v; \ + ++number; \ + } \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ + [](std::string& outValue, __TYPE__ inValue) -> bool { \ + outValue = ""; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + outValue += std::to_string(inValue[i][j]) + ","; \ + } \ + outValue.pop_back(); \ + } \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(DMat3x4Property, glm::dmat3x4, glm::dmat3x4(0), + glm::dmat3x4( + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest() + ), + glm::dmat3x4( + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::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 + ), + DEFAULT_FROM_LUA_LAMBDA(glm::dmat3x4), + DEFAULT_TO_LUA_LAMBDA(glm::dmat3x4), + DEFAULT_FROM_STRING_LAMBDA(glm::dmat3x4), + DEFAULT_TO_STRING_LAMBDA(glm::dmat3x4), + LUA_TTABLE); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/matrix/dmat4property.cpp b/src/properties/matrix/dmat4property.cpp new file mode 100644 index 0000000000..2d9c24003c --- /dev/null +++ b/src/properties/matrix/dmat4property.cpp @@ -0,0 +1,166 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include + +#include +#include +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(__TYPE__) \ + [](lua_State* state, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + lua_getfield(state, -1, std::to_string(number).c_str()); \ + if (lua_isnumber(state, -1) != 1) { \ + success = false; \ + return __TYPE__(0); \ + } else { \ + result[i][j] \ + = static_cast<__TYPE__::value_type>(lua_tonumber(state, -1)); \ + lua_pop(state, 1); \ + ++number; \ + } \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_LUA_LAMBDA(__TYPE__) \ + [](lua_State* state, __TYPE__ value) -> bool { \ + lua_newtable(state); \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + lua_pushnumber(state, static_cast(value[i][j])); \ + lua_setfield(state, -2, std::to_string(number).c_str()); \ + ++number; \ + } \ + } \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(__TYPE__) \ + [](std::string value, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + std::vector tokens = ghoul::tokenizeString(value, ','); \ + if (tokens.size() != \ + (ghoul::glm_rows<__TYPE__>::value * ghoul::glm_cols<__TYPE__>::value)) \ + { \ + success = false; \ + return result; \ + } \ + int number = 0; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + std::stringstream s(tokens[number]); \ + __TYPE__::value_type v; \ + s >> v; \ + if (s.fail()) { \ + success = false; \ + return result; \ + } \ + else { \ + result[i][j] = v; \ + ++number; \ + } \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ + [](std::string& outValue, __TYPE__ inValue) -> bool { \ + outValue = ""; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + outValue += std::to_string(inValue[i][j]) + ","; \ + } \ + outValue.pop_back(); \ + } \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(DMat4Property, glm::dmat4x4, glm::dmat4x4(0), + glm::dmat4x4( + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest() + ), + glm::dmat4x4( + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::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 + ), + DEFAULT_FROM_LUA_LAMBDA(glm::dmat4x4), + DEFAULT_TO_LUA_LAMBDA(glm::dmat4x4), + DEFAULT_FROM_STRING_LAMBDA(glm::dmat4x4), + DEFAULT_TO_STRING_LAMBDA(glm::dmat4x4), + LUA_TTABLE); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/matrix/dmat4x2property.cpp b/src/properties/matrix/dmat4x2property.cpp new file mode 100644 index 0000000000..b4b132d47b --- /dev/null +++ b/src/properties/matrix/dmat4x2property.cpp @@ -0,0 +1,148 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include + +#include +#include +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(__TYPE__) \ + [](lua_State* state, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + lua_getfield(state, -1, std::to_string(number).c_str()); \ + if (lua_isnumber(state, -1) != 1) { \ + success = false; \ + return __TYPE__(0); \ + } else { \ + result[i][j] \ + = static_cast<__TYPE__::value_type>(lua_tonumber(state, -1)); \ + lua_pop(state, 1); \ + ++number; \ + } \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_LUA_LAMBDA(__TYPE__) \ + [](lua_State* state, __TYPE__ value) -> bool { \ + lua_newtable(state); \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + lua_pushnumber(state, static_cast(value[i][j])); \ + lua_setfield(state, -2, std::to_string(number).c_str()); \ + ++number; \ + } \ + } \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(__TYPE__) \ + [](std::string value, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + std::vector tokens = ghoul::tokenizeString(value, ','); \ + if (tokens.size() != \ + (ghoul::glm_rows<__TYPE__>::value * ghoul::glm_cols<__TYPE__>::value)) \ + { \ + success = false; \ + return result; \ + } \ + int number = 0; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + std::stringstream s(tokens[number]); \ + __TYPE__::value_type v; \ + s >> v; \ + if (s.fail()) { \ + success = false; \ + return result; \ + } \ + else { \ + result[i][j] = v; \ + ++number; \ + } \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ + [](std::string& outValue, __TYPE__ inValue) -> bool { \ + outValue = ""; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + outValue += std::to_string(inValue[i][j]) + ","; \ + } \ + outValue.pop_back(); \ + } \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(DMat4x2Property, glm::dmat4x2, glm::dmat4x2(0), + glm::dmat4x2( + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest() + ), + glm::dmat4x2( + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max() + ), + glm::dmat4x2( + 0.01, 0.01, 0.01, 0.01, + 0.01, 0.01, 0.01, 0.01 + ), + DEFAULT_FROM_LUA_LAMBDA(glm::dmat4x2), + DEFAULT_TO_LUA_LAMBDA(glm::dmat4x2), + DEFAULT_FROM_STRING_LAMBDA(glm::dmat4x2), + DEFAULT_TO_STRING_LAMBDA(glm::dmat4x2), + LUA_TTABLE); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/matrix/dmat4x3property.cpp b/src/properties/matrix/dmat4x3property.cpp new file mode 100644 index 0000000000..306e259976 --- /dev/null +++ b/src/properties/matrix/dmat4x3property.cpp @@ -0,0 +1,157 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include + +#include +#include +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(__TYPE__) \ + [](lua_State* state, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + lua_getfield(state, -1, std::to_string(number).c_str()); \ + if (lua_isnumber(state, -1) != 1) { \ + success = false; \ + return __TYPE__(0); \ + } else { \ + result[i][j] \ + = static_cast<__TYPE__::value_type>(lua_tonumber(state, -1)); \ + lua_pop(state, 1); \ + ++number; \ + } \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_LUA_LAMBDA(__TYPE__) \ + [](lua_State* state, __TYPE__ value) -> bool { \ + lua_newtable(state); \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + lua_pushnumber(state, static_cast(value[i][j])); \ + lua_setfield(state, -2, std::to_string(number).c_str()); \ + ++number; \ + } \ + } \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(__TYPE__) \ + [](std::string value, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + std::vector tokens = ghoul::tokenizeString(value, ','); \ + if (tokens.size() != \ + (ghoul::glm_rows<__TYPE__>::value * ghoul::glm_cols<__TYPE__>::value)) \ + { \ + success = false; \ + return result; \ + } \ + int number = 0; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + std::stringstream s(tokens[number]); \ + __TYPE__::value_type v; \ + s >> v; \ + if (s.fail()) { \ + success = false; \ + return result; \ + } \ + else { \ + result[i][j] = v; \ + ++number; \ + } \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ + [](std::string& outValue, __TYPE__ inValue) -> bool { \ + outValue = ""; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + outValue += std::to_string(inValue[i][j]) + ","; \ + } \ + outValue.pop_back(); \ + } \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(DMat4x3Property, glm::dmat4x3, glm::dmat4x3(0), + glm::dmat4x3( + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest() + ), + glm::dmat4x3( + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::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 + ), + DEFAULT_FROM_LUA_LAMBDA(glm::dmat4x3), + DEFAULT_TO_LUA_LAMBDA(glm::dmat4x3), + DEFAULT_FROM_STRING_LAMBDA(glm::dmat4x3), + DEFAULT_TO_STRING_LAMBDA(glm::dmat4x3), + LUA_TTABLE); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/matrix/mat2property.cpp b/src/properties/matrix/mat2property.cpp new file mode 100644 index 0000000000..f2736c6a9e --- /dev/null +++ b/src/properties/matrix/mat2property.cpp @@ -0,0 +1,140 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include + +#include +#include +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(__TYPE__) \ + [](lua_State* state, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + lua_getfield(state, -1, std::to_string(number).c_str()); \ + if (lua_isnumber(state, -1) != 1) { \ + success = false; \ + return __TYPE__(0); \ + } else { \ + result[i][j] \ + = static_cast<__TYPE__::value_type>(lua_tonumber(state, -1)); \ + lua_pop(state, 1); \ + ++number; \ + } \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_LUA_LAMBDA(__TYPE__) \ + [](lua_State* state, __TYPE__ value) -> bool { \ + lua_newtable(state); \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + lua_pushnumber(state, static_cast(value[i][j])); \ + lua_setfield(state, -2, std::to_string(number).c_str()); \ + ++number; \ + } \ + } \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(__TYPE__) \ + [](std::string value, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + std::vector tokens = ghoul::tokenizeString(value, ','); \ + if (tokens.size() != \ + (ghoul::glm_rows<__TYPE__>::value * ghoul::glm_cols<__TYPE__>::value)) \ + { \ + success = false; \ + return result; \ + } \ + int number = 0; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + std::stringstream s(tokens[number]); \ + __TYPE__::value_type v; \ + s >> v; \ + if (s.fail()) { \ + success = false; \ + return result; \ + } \ + else { \ + result[i][j] = v; \ + ++number; \ + } \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ + [](std::string& outValue, __TYPE__ inValue) -> bool { \ + outValue = ""; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + outValue += std::to_string(inValue[i][j]) + ","; \ + } \ + outValue.pop_back(); \ + } \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(Mat2Property, glm::mat2x2, glm::mat2x2(0), + glm::mat2x2( + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest() + ), + glm::mat2x2( + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max() + ), + glm::mat2x2( + 0.01f, 0.01f, + 0.01f, 0.01f + ), + DEFAULT_FROM_LUA_LAMBDA(glm::mat2x2), + DEFAULT_TO_LUA_LAMBDA(glm::mat2x2), + DEFAULT_FROM_STRING_LAMBDA(glm::mat2x2), + DEFAULT_TO_STRING_LAMBDA(glm::mat2x2), + LUA_TTABLE); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/matrix/mat2x3property.cpp b/src/properties/matrix/mat2x3property.cpp new file mode 100644 index 0000000000..cf42b7261a --- /dev/null +++ b/src/properties/matrix/mat2x3property.cpp @@ -0,0 +1,144 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include + +#include +#include +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(__TYPE__) \ + [](lua_State* state, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + lua_getfield(state, -1, std::to_string(number).c_str()); \ + if (lua_isnumber(state, -1) != 1) { \ + success = false; \ + return __TYPE__(0); \ + } else { \ + result[i][j] \ + = static_cast<__TYPE__::value_type>(lua_tonumber(state, -1)); \ + lua_pop(state, 1); \ + ++number; \ + } \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_LUA_LAMBDA(__TYPE__) \ + [](lua_State* state, __TYPE__ value) -> bool { \ + lua_newtable(state); \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + lua_pushnumber(state, static_cast(value[i][j])); \ + lua_setfield(state, -2, std::to_string(number).c_str()); \ + ++number; \ + } \ + } \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(__TYPE__) \ + [](std::string value, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + std::vector tokens = ghoul::tokenizeString(value, ','); \ + if (tokens.size() != \ + (ghoul::glm_rows<__TYPE__>::value * ghoul::glm_cols<__TYPE__>::value)) \ + { \ + success = false; \ + return result; \ + } \ + int number = 0; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + std::stringstream s(tokens[number]); \ + __TYPE__::value_type v; \ + s >> v; \ + if (s.fail()) { \ + success = false; \ + return result; \ + } \ + else { \ + result[i][j] = v; \ + ++number; \ + } \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ + [](std::string& outValue, __TYPE__ inValue) -> bool { \ + outValue = ""; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + outValue += std::to_string(inValue[i][j]) + ","; \ + } \ + outValue.pop_back(); \ + } \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(Mat2x3Property, glm::mat2x3, glm::mat2x3(0), + glm::mat2x3( + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest() + ), + glm::mat2x3( + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max() + ), + glm::mat2x3( + 0.01f, 0.01f, 0.01f, + 0.01f, 0.01f, 0.01f + ), + DEFAULT_FROM_LUA_LAMBDA(glm::mat2x3), + DEFAULT_TO_LUA_LAMBDA(glm::mat2x3), + DEFAULT_FROM_STRING_LAMBDA(glm::mat2x3), + DEFAULT_TO_STRING_LAMBDA(glm::mat2x3), + LUA_TTABLE); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/matrix/mat2x4property.cpp b/src/properties/matrix/mat2x4property.cpp new file mode 100644 index 0000000000..fac1405f6a --- /dev/null +++ b/src/properties/matrix/mat2x4property.cpp @@ -0,0 +1,148 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include + +#include +#include +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(__TYPE__) \ + [](lua_State* state, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + lua_getfield(state, -1, std::to_string(number).c_str()); \ + if (lua_isnumber(state, -1) != 1) { \ + success = false; \ + return __TYPE__(0); \ + } else { \ + result[i][j] \ + = static_cast<__TYPE__::value_type>(lua_tonumber(state, -1)); \ + lua_pop(state, 1); \ + ++number; \ + } \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_LUA_LAMBDA(__TYPE__) \ + [](lua_State* state, __TYPE__ value) -> bool { \ + lua_newtable(state); \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + lua_pushnumber(state, static_cast(value[i][j])); \ + lua_setfield(state, -2, std::to_string(number).c_str()); \ + ++number; \ + } \ + } \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(__TYPE__) \ + [](std::string value, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + std::vector tokens = ghoul::tokenizeString(value, ','); \ + if (tokens.size() != \ + (ghoul::glm_rows<__TYPE__>::value * ghoul::glm_cols<__TYPE__>::value)) \ + { \ + success = false; \ + return result; \ + } \ + int number = 0; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + std::stringstream s(tokens[number]); \ + __TYPE__::value_type v; \ + s >> v; \ + if (s.fail()) { \ + success = false; \ + return result; \ + } \ + else { \ + result[i][j] = v; \ + ++number; \ + } \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ + [](std::string& outValue, __TYPE__ inValue) -> bool { \ + outValue = ""; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + outValue += std::to_string(inValue[i][j]) + ","; \ + } \ + outValue.pop_back(); \ + } \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(Mat2x4Property, glm::mat2x4, glm::mat2x4(0), + glm::mat2x4( + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest() + ), + glm::mat2x4( + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max() + ), + glm::mat2x4( + 0.01f, 0.01f, 0.01f, 0.01f, + 0.01f, 0.01f, 0.01f, 0.01f + ), + DEFAULT_FROM_LUA_LAMBDA(glm::mat2x4), + DEFAULT_TO_LUA_LAMBDA(glm::mat2x4), + DEFAULT_FROM_STRING_LAMBDA(glm::mat2x4), + DEFAULT_TO_STRING_LAMBDA(glm::mat2x4), + LUA_TTABLE); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/matrix/mat3property.cpp b/src/properties/matrix/mat3property.cpp new file mode 100644 index 0000000000..fb8f473434 --- /dev/null +++ b/src/properties/matrix/mat3property.cpp @@ -0,0 +1,151 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include + +#include +#include +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(__TYPE__) \ + [](lua_State* state, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + lua_getfield(state, -1, std::to_string(number).c_str()); \ + if (lua_isnumber(state, -1) != 1) { \ + success = false; \ + return __TYPE__(0); \ + } else { \ + result[i][j] \ + = static_cast<__TYPE__::value_type>(lua_tonumber(state, -1)); \ + lua_pop(state, 1); \ + ++number; \ + } \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_LUA_LAMBDA(__TYPE__) \ + [](lua_State* state, __TYPE__ value) -> bool { \ + lua_newtable(state); \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + lua_pushnumber(state, static_cast(value[i][j])); \ + lua_setfield(state, -2, std::to_string(number).c_str()); \ + ++number; \ + } \ + } \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(__TYPE__) \ + [](std::string value, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + std::vector tokens = ghoul::tokenizeString(value, ','); \ + if (tokens.size() != \ + (ghoul::glm_rows<__TYPE__>::value * ghoul::glm_cols<__TYPE__>::value)) \ + { \ + success = false; \ + return result; \ + } \ + int number = 0; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + std::stringstream s(tokens[number]); \ + __TYPE__::value_type v; \ + s >> v; \ + if (s.fail()) { \ + success = false; \ + return result; \ + } \ + else { \ + result[i][j] = v; \ + ++number; \ + } \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ + [](std::string& outValue, __TYPE__ inValue) -> bool { \ + outValue = ""; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + outValue += std::to_string(inValue[i][j]) + ","; \ + } \ + outValue.pop_back(); \ + } \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(Mat3Property, glm::mat3x3, glm::mat3x3(0), + glm::mat3x3( + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest() + ), + glm::mat3x3( + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max() + ), + glm::mat3x3( + 0.01f, 0.01f, 0.01f, + 0.01f, 0.01f, 0.01f, + 0.01f, 0.01f, 0.01f + ), + DEFAULT_FROM_LUA_LAMBDA(glm::mat3x3), + DEFAULT_TO_LUA_LAMBDA(glm::mat3x3), + DEFAULT_FROM_STRING_LAMBDA(glm::mat3x3), + DEFAULT_TO_STRING_LAMBDA(glm::mat3x3), + LUA_TTABLE); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/matrix/mat3x2property.cpp b/src/properties/matrix/mat3x2property.cpp new file mode 100644 index 0000000000..e230b7904d --- /dev/null +++ b/src/properties/matrix/mat3x2property.cpp @@ -0,0 +1,144 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include + +#include +#include +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(__TYPE__) \ + [](lua_State* state, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + lua_getfield(state, -1, std::to_string(number).c_str()); \ + if (lua_isnumber(state, -1) != 1) { \ + success = false; \ + return __TYPE__(0); \ + } else { \ + result[i][j] \ + = static_cast<__TYPE__::value_type>(lua_tonumber(state, -1)); \ + lua_pop(state, 1); \ + ++number; \ + } \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_LUA_LAMBDA(__TYPE__) \ + [](lua_State* state, __TYPE__ value) -> bool { \ + lua_newtable(state); \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + lua_pushnumber(state, static_cast(value[i][j])); \ + lua_setfield(state, -2, std::to_string(number).c_str()); \ + ++number; \ + } \ + } \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(__TYPE__) \ + [](std::string value, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + std::vector tokens = ghoul::tokenizeString(value, ','); \ + if (tokens.size() != \ + (ghoul::glm_rows<__TYPE__>::value * ghoul::glm_cols<__TYPE__>::value)) \ + { \ + success = false; \ + return result; \ + } \ + int number = 0; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + std::stringstream s(tokens[number]); \ + __TYPE__::value_type v; \ + s >> v; \ + if (s.fail()) { \ + success = false; \ + return result; \ + } \ + else { \ + result[i][j] = v; \ + ++number; \ + } \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ + [](std::string& outValue, __TYPE__ inValue) -> bool { \ + outValue = ""; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + outValue += std::to_string(inValue[i][j]) + ","; \ + } \ + outValue.pop_back(); \ + } \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(Mat3x2Property, glm::mat3x2, glm::mat3x2(0), + glm::mat3x2( + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest() + ), + glm::mat3x2( + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max() + ), + glm::mat3x2( + 0.01f, 0.01f, 0.01f, + 0.01f, 0.01f, 0.01f + ), + DEFAULT_FROM_LUA_LAMBDA(glm::mat3x2), + DEFAULT_TO_LUA_LAMBDA(glm::mat3x2), + DEFAULT_FROM_STRING_LAMBDA(glm::mat3x2), + DEFAULT_TO_STRING_LAMBDA(glm::mat3x2), + LUA_TTABLE); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/matrix/mat3x4property.cpp b/src/properties/matrix/mat3x4property.cpp new file mode 100644 index 0000000000..f17c44d825 --- /dev/null +++ b/src/properties/matrix/mat3x4property.cpp @@ -0,0 +1,157 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include + +#include +#include +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(__TYPE__) \ + [](lua_State* state, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + lua_getfield(state, -1, std::to_string(number).c_str()); \ + if (lua_isnumber(state, -1) != 1) { \ + success = false; \ + return __TYPE__(0); \ + } else { \ + result[i][j] \ + = static_cast<__TYPE__::value_type>(lua_tonumber(state, -1)); \ + lua_pop(state, 1); \ + ++number; \ + } \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_LUA_LAMBDA(__TYPE__) \ + [](lua_State* state, __TYPE__ value) -> bool { \ + lua_newtable(state); \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + lua_pushnumber(state, static_cast(value[i][j])); \ + lua_setfield(state, -2, std::to_string(number).c_str()); \ + ++number; \ + } \ + } \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(__TYPE__) \ + [](std::string value, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + std::vector tokens = ghoul::tokenizeString(value, ','); \ + if (tokens.size() != \ + (ghoul::glm_rows<__TYPE__>::value * ghoul::glm_cols<__TYPE__>::value)) \ + { \ + success = false; \ + return result; \ + } \ + int number = 0; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + std::stringstream s(tokens[number]); \ + __TYPE__::value_type v; \ + s >> v; \ + if (s.fail()) { \ + success = false; \ + return result; \ + } \ + else { \ + result[i][j] = v; \ + ++number; \ + } \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ + [](std::string& outValue, __TYPE__ inValue) -> bool { \ + outValue = ""; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + outValue += std::to_string(inValue[i][j]) + ","; \ + } \ + outValue.pop_back(); \ + } \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(Mat3x4Property, glm::mat3x4, glm::mat3x4(0), + glm::mat3x4( + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest() + ), + glm::mat3x4( + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::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 + ), + DEFAULT_FROM_LUA_LAMBDA(glm::mat3x4), + DEFAULT_TO_LUA_LAMBDA(glm::mat3x4), + DEFAULT_FROM_STRING_LAMBDA(glm::mat3x4), + DEFAULT_TO_STRING_LAMBDA(glm::mat3x4), + LUA_TTABLE); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/matrix/mat4property.cpp b/src/properties/matrix/mat4property.cpp new file mode 100644 index 0000000000..1d7ff0b614 --- /dev/null +++ b/src/properties/matrix/mat4property.cpp @@ -0,0 +1,166 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include + +#include +#include +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(__TYPE__) \ + [](lua_State* state, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + lua_getfield(state, -1, std::to_string(number).c_str()); \ + if (lua_isnumber(state, -1) != 1) { \ + success = false; \ + return __TYPE__(0); \ + } else { \ + result[i][j] \ + = static_cast<__TYPE__::value_type>(lua_tonumber(state, -1)); \ + lua_pop(state, 1); \ + ++number; \ + } \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_LUA_LAMBDA(__TYPE__) \ + [](lua_State* state, __TYPE__ value) -> bool { \ + lua_newtable(state); \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + lua_pushnumber(state, static_cast(value[i][j])); \ + lua_setfield(state, -2, std::to_string(number).c_str()); \ + ++number; \ + } \ + } \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(__TYPE__) \ + [](std::string value, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + std::vector tokens = ghoul::tokenizeString(value, ','); \ + if (tokens.size() != \ + (ghoul::glm_rows<__TYPE__>::value * ghoul::glm_cols<__TYPE__>::value)) \ + { \ + success = false; \ + return result; \ + } \ + int number = 0; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + std::stringstream s(tokens[number]); \ + __TYPE__::value_type v; \ + s >> v; \ + if (s.fail()) { \ + success = false; \ + return result; \ + } \ + else { \ + result[i][j] = v; \ + ++number; \ + } \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ + [](std::string& outValue, __TYPE__ inValue) -> bool { \ + outValue = ""; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + outValue += std::to_string(inValue[i][j]) + ","; \ + } \ + outValue.pop_back(); \ + } \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(Mat4Property, glm::mat4x4, glm::mat4x4(0), + glm::mat4x4( + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest() + ), + glm::mat4x4( + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::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 + ), + DEFAULT_FROM_LUA_LAMBDA(glm::mat4x4), + DEFAULT_TO_LUA_LAMBDA(glm::mat4x4), + DEFAULT_FROM_STRING_LAMBDA(glm::mat4x4), + DEFAULT_TO_STRING_LAMBDA(glm::mat4x4), + LUA_TTABLE); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/matrix/mat4x2property.cpp b/src/properties/matrix/mat4x2property.cpp new file mode 100644 index 0000000000..ca90cf41f6 --- /dev/null +++ b/src/properties/matrix/mat4x2property.cpp @@ -0,0 +1,148 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include + +#include +#include +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(__TYPE__) \ + [](lua_State* state, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + lua_getfield(state, -1, std::to_string(number).c_str()); \ + if (lua_isnumber(state, -1) != 1) { \ + success = false; \ + return __TYPE__(0); \ + } else { \ + result[i][j] \ + = static_cast<__TYPE__::value_type>(lua_tonumber(state, -1)); \ + lua_pop(state, 1); \ + ++number; \ + } \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_LUA_LAMBDA(__TYPE__) \ + [](lua_State* state, __TYPE__ value) -> bool { \ + lua_newtable(state); \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + lua_pushnumber(state, static_cast(value[i][j])); \ + lua_setfield(state, -2, std::to_string(number).c_str()); \ + ++number; \ + } \ + } \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(__TYPE__) \ + [](std::string value, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + std::vector tokens = ghoul::tokenizeString(value, ','); \ + if (tokens.size() != \ + (ghoul::glm_rows<__TYPE__>::value * ghoul::glm_cols<__TYPE__>::value)) \ + { \ + success = false; \ + return result; \ + } \ + int number = 0; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + std::stringstream s(tokens[number]); \ + __TYPE__::value_type v; \ + s >> v; \ + if (s.fail()) { \ + success = false; \ + return result; \ + } \ + else { \ + result[i][j] = v; \ + ++number; \ + } \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ + [](std::string& outValue, __TYPE__ inValue) -> bool { \ + outValue = ""; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + outValue += std::to_string(inValue[i][j]) + ","; \ + } \ + outValue.pop_back(); \ + } \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(Mat4x2Property, glm::mat4x2, glm::mat4x2(0), + glm::mat4x2( + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest() + ), + glm::mat4x2( + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max() + ), + glm::mat4x2( + 0.01f, 0.01f, 0.01f, 0.01f, + 0.01f, 0.01f, 0.01f, 0.01f + ), + DEFAULT_FROM_LUA_LAMBDA(glm::mat4x2), + DEFAULT_TO_LUA_LAMBDA(glm::mat4x2), + DEFAULT_FROM_STRING_LAMBDA(glm::mat4x2), + DEFAULT_TO_STRING_LAMBDA(glm::mat4x2), + LUA_TTABLE); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/matrix/mat4x3property.cpp b/src/properties/matrix/mat4x3property.cpp new file mode 100644 index 0000000000..bdc1fecb21 --- /dev/null +++ b/src/properties/matrix/mat4x3property.cpp @@ -0,0 +1,157 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include + +#include +#include +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(__TYPE__) \ + [](lua_State* state, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + lua_getfield(state, -1, std::to_string(number).c_str()); \ + if (lua_isnumber(state, -1) != 1) { \ + success = false; \ + return __TYPE__(0); \ + } else { \ + result[i][j] \ + = static_cast<__TYPE__::value_type>(lua_tonumber(state, -1)); \ + lua_pop(state, 1); \ + ++number; \ + } \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_LUA_LAMBDA(__TYPE__) \ + [](lua_State* state, __TYPE__ value) -> bool { \ + lua_newtable(state); \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + lua_pushnumber(state, static_cast(value[i][j])); \ + lua_setfield(state, -2, std::to_string(number).c_str()); \ + ++number; \ + } \ + } \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(__TYPE__) \ + [](std::string value, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + std::vector tokens = ghoul::tokenizeString(value, ','); \ + if (tokens.size() != \ + (ghoul::glm_rows<__TYPE__>::value * ghoul::glm_cols<__TYPE__>::value)) \ + { \ + success = false; \ + return result; \ + } \ + int number = 0; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + std::stringstream s(tokens[number]); \ + __TYPE__::value_type v; \ + s >> v; \ + if (s.fail()) { \ + success = false; \ + return result; \ + } \ + else { \ + result[i][j] = v; \ + ++number; \ + } \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ + [](std::string& outValue, __TYPE__ inValue) -> bool { \ + outValue = ""; \ + for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ + for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ + outValue += std::to_string(inValue[i][j]) + ","; \ + } \ + outValue.pop_back(); \ + } \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(Mat4x3Property, glm::mat4x3, glm::mat4x3(0), + glm::mat4x3( + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest(), + numeric_limits::lowest() + ), + glm::mat4x3( + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::max(), + numeric_limits::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 + ), + DEFAULT_FROM_LUA_LAMBDA(glm::mat4x3), + DEFAULT_TO_LUA_LAMBDA(glm::mat4x3), + DEFAULT_FROM_STRING_LAMBDA(glm::mat4x3), + DEFAULT_TO_STRING_LAMBDA(glm::mat4x3), + LUA_TTABLE); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/matrixproperty.cpp b/src/properties/matrixproperty.cpp deleted file mode 100644 index ca33757247..0000000000 --- a/src/properties/matrixproperty.cpp +++ /dev/null @@ -1,721 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2016 * - * * - * 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 - -#include - -#include -#include -#include - -using std::numeric_limits; - -namespace openspace { -namespace properties { - -#define DEFAULT_FROM_LUA_LAMBDA(__TYPE__) \ - [](lua_State* state, bool& success) -> __TYPE__ { \ - __TYPE__ result; \ - int number = 1; \ - for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ - for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ - lua_getfield(state, -1, std::to_string(number).c_str()); \ - if (lua_isnumber(state, -1) != 1) { \ - success = false; \ - return __TYPE__(0); \ - } else { \ - result[i][j] \ - = static_cast<__TYPE__::value_type>(lua_tonumber(state, -1)); \ - lua_pop(state, 1); \ - ++number; \ - } \ - } \ - } \ - success = true; \ - return result; \ - } - -#define DEFAULT_TO_LUA_LAMBDA(__TYPE__) \ - [](lua_State* state, __TYPE__ value) -> bool { \ - lua_newtable(state); \ - int number = 1; \ - for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ - for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ - lua_pushnumber(state, static_cast(value[i][j])); \ - lua_setfield(state, -2, std::to_string(number).c_str()); \ - ++number; \ - } \ - } \ - return true; \ - } - -#define DEFAULT_FROM_STRING_LAMBDA(__TYPE__) \ - [](std::string value, bool& success) -> __TYPE__ { \ - __TYPE__ result; \ - std::vector tokens = ghoul::tokenizeString(value, ','); \ - if (tokens.size() != \ - (ghoul::glm_rows<__TYPE__>::value * ghoul::glm_cols<__TYPE__>::value)) \ - { \ - success = false; \ - return result; \ - } \ - int number = 0; \ - for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ - for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ - std::stringstream s(tokens[number]); \ - __TYPE__::value_type v; \ - s >> v; \ - if (s.fail()) { \ - success = false; \ - return result; \ - } \ - else { \ - result[i][j] = v; \ - ++number; \ - } \ - } \ - } \ - success = true; \ - return result; \ - } - -#define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ - [](std::string& outValue, __TYPE__ inValue) -> bool { \ - outValue = ""; \ - for (glm::length_t i = 0; i < ghoul::glm_cols<__TYPE__>::value; ++i) { \ - for (glm::length_t j = 0; j < ghoul::glm_rows<__TYPE__>::value; ++j) { \ - outValue += std::to_string(inValue[i][j]) + ","; \ - } \ - outValue.pop_back(); \ - } \ - return true; \ - } - -REGISTER_NUMERICALPROPERTY_SOURCE(Mat2Property, glm::mat2x2, glm::mat2x2(0), - glm::mat2x2( - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest() - ), - glm::mat2x2( - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max() - ), - glm::mat2x2( - 0.01f, 0.01f, - 0.01f, 0.01f - ), - DEFAULT_FROM_LUA_LAMBDA(glm::mat2x2), - DEFAULT_TO_LUA_LAMBDA(glm::mat2x2), - DEFAULT_FROM_STRING_LAMBDA(glm::mat2x2), - DEFAULT_TO_STRING_LAMBDA(glm::mat2x2), - LUA_TTABLE); - -REGISTER_NUMERICALPROPERTY_SOURCE(Mat2x3Property, glm::mat2x3, glm::mat2x3(0), - glm::mat2x3( - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest() - ), - glm::mat2x3( - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max() - ), - glm::mat2x3( - 0.01f, 0.01f, 0.01f, - 0.01f, 0.01f, 0.01f - ), - DEFAULT_FROM_LUA_LAMBDA(glm::mat2x3), - DEFAULT_TO_LUA_LAMBDA(glm::mat2x3), - DEFAULT_FROM_STRING_LAMBDA(glm::mat2x3), - DEFAULT_TO_STRING_LAMBDA(glm::mat2x3), - LUA_TTABLE); - -REGISTER_NUMERICALPROPERTY_SOURCE(Mat2x4Property, glm::mat2x4, glm::mat2x4(0), - glm::mat2x4( - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest() - ), - glm::mat2x4( - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max() - ), - glm::mat2x4( - 0.01f, 0.01f, 0.01f, 0.01f, - 0.01f, 0.01f, 0.01f, 0.01f - ), - DEFAULT_FROM_LUA_LAMBDA(glm::mat2x4), - DEFAULT_TO_LUA_LAMBDA(glm::mat2x4), - DEFAULT_FROM_STRING_LAMBDA(glm::mat2x4), - DEFAULT_TO_STRING_LAMBDA(glm::mat2x4), - LUA_TTABLE); - -REGISTER_NUMERICALPROPERTY_SOURCE(Mat3x2Property, glm::mat3x2, glm::mat3x2(0), - glm::mat3x2( - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest() - ), - glm::mat3x2( - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max() - ), - glm::mat3x2( - 0.01f, 0.01f, 0.01f, - 0.01f, 0.01f, 0.01f - ), - DEFAULT_FROM_LUA_LAMBDA(glm::mat3x2), - DEFAULT_TO_LUA_LAMBDA(glm::mat3x2), - DEFAULT_FROM_STRING_LAMBDA(glm::mat3x2), - DEFAULT_TO_STRING_LAMBDA(glm::mat3x2), - LUA_TTABLE); - -REGISTER_NUMERICALPROPERTY_SOURCE(Mat3Property, glm::mat3x3, glm::mat3x3(0), - glm::mat3x3( - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest() - ), - glm::mat3x3( - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max() - ), - glm::mat3x3( - 0.01f, 0.01f, 0.01f, - 0.01f, 0.01f, 0.01f, - 0.01f, 0.01f, 0.01f - ), - DEFAULT_FROM_LUA_LAMBDA(glm::mat3x3), - DEFAULT_TO_LUA_LAMBDA(glm::mat3x3), - DEFAULT_FROM_STRING_LAMBDA(glm::mat3x3), - DEFAULT_TO_STRING_LAMBDA(glm::mat3x3), - LUA_TTABLE); - -REGISTER_NUMERICALPROPERTY_SOURCE(Mat3x4Property, glm::mat3x4, glm::mat3x4(0), - glm::mat3x4( - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest() - ), - glm::mat3x4( - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::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 - ), - DEFAULT_FROM_LUA_LAMBDA(glm::mat3x4), - DEFAULT_TO_LUA_LAMBDA(glm::mat3x4), - DEFAULT_FROM_STRING_LAMBDA(glm::mat3x4), - DEFAULT_TO_STRING_LAMBDA(glm::mat3x4), - LUA_TTABLE); - -REGISTER_NUMERICALPROPERTY_SOURCE(Mat4x2Property, glm::mat4x2, glm::mat4x2(0), - glm::mat4x2( - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest() - ), - glm::mat4x2( - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max() - ), - glm::mat4x2( - 0.01f, 0.01f, 0.01f, 0.01f, - 0.01f, 0.01f, 0.01f, 0.01f - ), - DEFAULT_FROM_LUA_LAMBDA(glm::mat4x2), - DEFAULT_TO_LUA_LAMBDA(glm::mat4x2), - DEFAULT_FROM_STRING_LAMBDA(glm::mat4x2), - DEFAULT_TO_STRING_LAMBDA(glm::mat4x2), - LUA_TTABLE); - -REGISTER_NUMERICALPROPERTY_SOURCE(Mat4x3Property, glm::mat4x3, glm::mat4x3(0), - glm::mat4x3( - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest() - ), - glm::mat4x3( - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::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 - ), - DEFAULT_FROM_LUA_LAMBDA(glm::mat4x3), - DEFAULT_TO_LUA_LAMBDA(glm::mat4x3), - DEFAULT_FROM_STRING_LAMBDA(glm::mat4x3), - DEFAULT_TO_STRING_LAMBDA(glm::mat4x3), - LUA_TTABLE); - -REGISTER_NUMERICALPROPERTY_SOURCE(Mat4Property, glm::mat4x4, glm::mat4x4(0), - glm::mat4x4( - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest() - ), - glm::mat4x4( - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::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 - ), - DEFAULT_FROM_LUA_LAMBDA(glm::mat4x4), - DEFAULT_TO_LUA_LAMBDA(glm::mat4x4), - DEFAULT_FROM_STRING_LAMBDA(glm::mat4x4), - DEFAULT_TO_STRING_LAMBDA(glm::mat4x4), - LUA_TTABLE); - -REGISTER_NUMERICALPROPERTY_SOURCE(DMat2Property, glm::dmat2x2, glm::dmat2x2(0), - glm::dmat2x2( - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest() - ), - glm::dmat2x2( - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max() - ), - glm::dmat2x2( - 0.01, 0.01, - 0.01, 0.01 - ), - DEFAULT_FROM_LUA_LAMBDA(glm::dmat2x2), - DEFAULT_TO_LUA_LAMBDA(glm::dmat2x2), - DEFAULT_FROM_STRING_LAMBDA(glm::dmat2x2), - DEFAULT_TO_STRING_LAMBDA(glm::dmat2x2), - LUA_TTABLE); - -REGISTER_NUMERICALPROPERTY_SOURCE(DMat2x3Property, glm::dmat2x3, glm::dmat2x3(0), - glm::dmat2x3( - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest() - ), - glm::dmat2x3( - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max() - ), - glm::dmat2x3( - 0.01, 0.01, 0.01, - 0.01, 0.01, 0.01 - ), - DEFAULT_FROM_LUA_LAMBDA(glm::dmat2x3), - DEFAULT_TO_LUA_LAMBDA(glm::dmat2x3), - DEFAULT_FROM_STRING_LAMBDA(glm::dmat2x3), - DEFAULT_TO_STRING_LAMBDA(glm::dmat2x3), - LUA_TTABLE); - -REGISTER_NUMERICALPROPERTY_SOURCE(DMat2x4Property, glm::dmat2x4, glm::dmat2x4(0), - glm::dmat2x4( - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest() - ), - glm::dmat2x4( - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max() - ), - glm::dmat2x4( - 0.01, 0.01, 0.01, 0.01, - 0.01, 0.01, 0.01, 0.01 - ), - DEFAULT_FROM_LUA_LAMBDA(glm::dmat2x4), - DEFAULT_TO_LUA_LAMBDA(glm::dmat2x4), - DEFAULT_FROM_STRING_LAMBDA(glm::dmat2x4), - DEFAULT_TO_STRING_LAMBDA(glm::dmat2x4), - LUA_TTABLE); - -REGISTER_NUMERICALPROPERTY_SOURCE(DMat3x2Property, glm::dmat3x2, glm::dmat3x2(0), - glm::dmat3x2( - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest() - ), - glm::dmat3x2( - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max() - ), - glm::dmat3x2( - 0.01, 0.01, 0.01, - 0.01, 0.01, 0.01 - ), - DEFAULT_FROM_LUA_LAMBDA(glm::dmat3x2), - DEFAULT_TO_LUA_LAMBDA(glm::dmat3x2), - DEFAULT_FROM_STRING_LAMBDA(glm::dmat3x2), - DEFAULT_TO_STRING_LAMBDA(glm::dmat3x2), - LUA_TTABLE); - -REGISTER_NUMERICALPROPERTY_SOURCE(DMat3Property, glm::dmat3x3, glm::dmat3x3(0), - glm::dmat3x3( - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest() - ), - glm::dmat3x3( - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max() - ), - glm::dmat3x3( - 0.01, 0.01, 0.01, - 0.01, 0.01, 0.01, - 0.01, 0.01, 0.01 - ), - DEFAULT_FROM_LUA_LAMBDA(glm::dmat3x3), - DEFAULT_TO_LUA_LAMBDA(glm::dmat3x3), - DEFAULT_FROM_STRING_LAMBDA(glm::dmat3x3), - DEFAULT_TO_STRING_LAMBDA(glm::dmat3x3), - LUA_TTABLE); - -REGISTER_NUMERICALPROPERTY_SOURCE(DMat3x4Property, glm::dmat3x4, glm::dmat3x4(0), - glm::dmat3x4( - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest() - ), - glm::dmat3x4( - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::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 - ), - DEFAULT_FROM_LUA_LAMBDA(glm::dmat3x4), - DEFAULT_TO_LUA_LAMBDA(glm::dmat3x4), - DEFAULT_FROM_STRING_LAMBDA(glm::dmat3x4), - DEFAULT_TO_STRING_LAMBDA(glm::dmat3x4), - LUA_TTABLE); - -REGISTER_NUMERICALPROPERTY_SOURCE(DMat4x2Property, glm::dmat4x2, glm::dmat4x2(0), - glm::dmat4x2( - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest() - ), - glm::dmat4x2( - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max() - ), - glm::dmat4x2( - 0.01, 0.01, 0.01, 0.01, - 0.01, 0.01, 0.01, 0.01 - ), - DEFAULT_FROM_LUA_LAMBDA(glm::dmat4x2), - DEFAULT_TO_LUA_LAMBDA(glm::dmat4x2), - DEFAULT_FROM_STRING_LAMBDA(glm::dmat4x2), - DEFAULT_TO_STRING_LAMBDA(glm::dmat4x2), - LUA_TTABLE); - -REGISTER_NUMERICALPROPERTY_SOURCE(DMat4x3Property, glm::dmat4x3, glm::dmat4x3(0), - glm::dmat4x3( - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest() - ), - glm::dmat4x3( - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::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 - ), - DEFAULT_FROM_LUA_LAMBDA(glm::dmat4x3), - DEFAULT_TO_LUA_LAMBDA(glm::dmat4x3), - DEFAULT_FROM_STRING_LAMBDA(glm::dmat4x3), - DEFAULT_TO_STRING_LAMBDA(glm::dmat4x3), - LUA_TTABLE); - -REGISTER_NUMERICALPROPERTY_SOURCE(DMat4Property, glm::dmat4x4, glm::dmat4x4(0), - glm::dmat4x4( - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest(), - numeric_limits::lowest() - ), - glm::dmat4x4( - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::max(), - numeric_limits::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 - ), - DEFAULT_FROM_LUA_LAMBDA(glm::dmat4x4), - DEFAULT_TO_LUA_LAMBDA(glm::dmat4x4), - DEFAULT_FROM_STRING_LAMBDA(glm::dmat4x4), - DEFAULT_TO_STRING_LAMBDA(glm::dmat4x4), - LUA_TTABLE); - -} // namespace properties -} // namespace openspace diff --git a/src/properties/scalar/boolproperty.cpp b/src/properties/scalar/boolproperty.cpp new file mode 100644 index 0000000000..c150cf276b --- /dev/null +++ b/src/properties/scalar/boolproperty.cpp @@ -0,0 +1,67 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include + +#include +#include + +namespace openspace { +namespace properties { + +REGISTER_TEMPLATEPROPERTY_SOURCE(BoolProperty, bool, false, + [](lua_State* state, bool& success) -> bool { + success = (lua_isboolean(state, -1) == 1); + if (success) { + return lua_toboolean(state, -1) == 1; + } + else { + return false; + } + }, + [](lua_State* state, bool value) -> bool { + lua_pushboolean(state, value); + return true; + }, + [](std::string value, bool& success) -> bool { + std::stringstream s(value); + bool v; + s >> v; + success = !s.fail(); + if (success) { + return v; + } + }, + [](std::string& outValue, bool inValue) -> bool { + outValue = inValue ? "true" : "false"; + return true; + }, + LUA_TBOOLEAN +); + + +} // namespace properties +} // namespace openspace diff --git a/src/properties/scalar/charproperty.cpp b/src/properties/scalar/charproperty.cpp new file mode 100644 index 0000000000..57e3b78ff0 --- /dev/null +++ b/src/properties/scalar/charproperty.cpp @@ -0,0 +1,81 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include + +#include +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(TYPE, DEFAULT_VALUE) \ + [](lua_State* state, bool& success) -> TYPE { \ + success = (lua_isnumber(state, -1) == 1); \ + if (success) { \ + return static_cast(lua_tonumber(state, -1)); \ + } \ + else { \ + return DEFAULT_VALUE; \ + } \ + } + +#define DEFAULT_TO_LUA_LAMBDA(TYPE) \ + [](lua_State* state, TYPE value) -> bool { \ + lua_pushnumber(state, static_cast(value)); \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(TYPE, DEFAULT_VALUE) \ + [](std::string value, bool& success) -> TYPE { \ + std::stringstream s(value); \ + TYPE v; \ + s >> v; \ + success = !s.fail(); \ + if (success) { \ + return v; \ + } \ + } + +#define DEFAULT_TO_STRING_LAMBDA(TYPE) \ + [](std::string& outValue, TYPE inValue) -> bool { \ + outValue = std::to_string(inValue); \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(CharProperty, char, char(0), + numeric_limits::lowest(), + numeric_limits::max(), char(1), + DEFAULT_FROM_LUA_LAMBDA(char, char(0)), + DEFAULT_TO_LUA_LAMBDA(char), + DEFAULT_FROM_STRING_LAMBDA(char, char(0)), + DEFAULT_TO_STRING_LAMBDA(char), + LUA_TNUMBER); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/scalar/doubleproperty.cpp b/src/properties/scalar/doubleproperty.cpp new file mode 100644 index 0000000000..0e6d97eb5b --- /dev/null +++ b/src/properties/scalar/doubleproperty.cpp @@ -0,0 +1,81 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include + +#include +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(TYPE, DEFAULT_VALUE) \ + [](lua_State* state, bool& success) -> TYPE { \ + success = (lua_isnumber(state, -1) == 1); \ + if (success) { \ + return static_cast(lua_tonumber(state, -1)); \ + } \ + else { \ + return DEFAULT_VALUE; \ + } \ + } + +#define DEFAULT_TO_LUA_LAMBDA(TYPE) \ + [](lua_State* state, TYPE value) -> bool { \ + lua_pushnumber(state, static_cast(value)); \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(TYPE, DEFAULT_VALUE) \ + [](std::string value, bool& success) -> TYPE { \ + std::stringstream s(value); \ + TYPE v; \ + s >> v; \ + success = !s.fail(); \ + if (success) { \ + return v; \ + } \ + } + +#define DEFAULT_TO_STRING_LAMBDA(TYPE) \ + [](std::string& outValue, TYPE inValue) -> bool { \ + outValue = std::to_string(inValue); \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(DoubleProperty, double, 0.0, + numeric_limits::lowest(), + numeric_limits::max(), 0.01, + DEFAULT_FROM_LUA_LAMBDA(double, double(0)), + DEFAULT_TO_LUA_LAMBDA(double), + DEFAULT_FROM_STRING_LAMBDA(double, double(0)), + DEFAULT_TO_STRING_LAMBDA(double), + LUA_TNUMBER); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/scalar/floatproperty.cpp b/src/properties/scalar/floatproperty.cpp new file mode 100644 index 0000000000..c42df70e76 --- /dev/null +++ b/src/properties/scalar/floatproperty.cpp @@ -0,0 +1,81 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include + +#include +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(TYPE, DEFAULT_VALUE) \ + [](lua_State* state, bool& success) -> TYPE { \ + success = (lua_isnumber(state, -1) == 1); \ + if (success) { \ + return static_cast(lua_tonumber(state, -1)); \ + } \ + else { \ + return DEFAULT_VALUE; \ + } \ + } + +#define DEFAULT_TO_LUA_LAMBDA(TYPE) \ + [](lua_State* state, TYPE value) -> bool { \ + lua_pushnumber(state, static_cast(value)); \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(TYPE, DEFAULT_VALUE) \ + [](std::string value, bool& success) -> TYPE { \ + std::stringstream s(value); \ + TYPE v; \ + s >> v; \ + success = !s.fail(); \ + if (success) { \ + return v; \ + } \ + } + +#define DEFAULT_TO_STRING_LAMBDA(TYPE) \ + [](std::string& outValue, TYPE inValue) -> bool { \ + outValue = std::to_string(inValue); \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(FloatProperty, float, 0.f, + numeric_limits::lowest(), + numeric_limits::max(), 0.01f, + DEFAULT_FROM_LUA_LAMBDA(float, float(0)), + DEFAULT_TO_LUA_LAMBDA(float), + DEFAULT_FROM_STRING_LAMBDA(float, float(0)), + DEFAULT_TO_STRING_LAMBDA(float), + LUA_TNUMBER); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/scalar/intproperty.cpp b/src/properties/scalar/intproperty.cpp new file mode 100644 index 0000000000..43ac9a85f2 --- /dev/null +++ b/src/properties/scalar/intproperty.cpp @@ -0,0 +1,80 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include + +#include +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(TYPE, DEFAULT_VALUE) \ + [](lua_State* state, bool& success) -> TYPE { \ + success = (lua_isnumber(state, -1) == 1); \ + if (success) { \ + return static_cast(lua_tonumber(state, -1)); \ + } \ + else { \ + return DEFAULT_VALUE; \ + } \ + } + +#define DEFAULT_TO_LUA_LAMBDA(TYPE) \ + [](lua_State* state, TYPE value) -> bool { \ + lua_pushnumber(state, static_cast(value)); \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(TYPE, DEFAULT_VALUE) \ + [](std::string value, bool& success) -> TYPE { \ + std::stringstream s(value); \ + TYPE v; \ + s >> v; \ + success = !s.fail(); \ + if (success) { \ + return v; \ + } \ + } + +#define DEFAULT_TO_STRING_LAMBDA(TYPE) \ + [](std::string& outValue, TYPE inValue) -> bool { \ + outValue = std::to_string(inValue); \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(IntProperty, int, int(0), numeric_limits::lowest(), + numeric_limits::max(), int(1), + DEFAULT_FROM_LUA_LAMBDA(int, int(0)), + DEFAULT_TO_LUA_LAMBDA(int), + DEFAULT_FROM_STRING_LAMBDA(int, int(0)), + DEFAULT_TO_STRING_LAMBDA(int), + LUA_TNUMBER); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/scalar/longdoubleproperty.cpp b/src/properties/scalar/longdoubleproperty.cpp new file mode 100644 index 0000000000..2917978abd --- /dev/null +++ b/src/properties/scalar/longdoubleproperty.cpp @@ -0,0 +1,82 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include + +#include +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(TYPE, DEFAULT_VALUE) \ + [](lua_State* state, bool& success) -> TYPE { \ + success = (lua_isnumber(state, -1) == 1); \ + if (success) { \ + return static_cast(lua_tonumber(state, -1)); \ + } \ + else { \ + return DEFAULT_VALUE; \ + } \ + } + +#define DEFAULT_TO_LUA_LAMBDA(TYPE) \ + [](lua_State* state, TYPE value) -> bool { \ + lua_pushnumber(state, static_cast(value)); \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(TYPE, DEFAULT_VALUE) \ + [](std::string value, bool& success) -> TYPE { \ + std::stringstream s(value); \ + TYPE v; \ + s >> v; \ + success = !s.fail(); \ + if (success) { \ + return v; \ + } \ + } + +#define DEFAULT_TO_STRING_LAMBDA(TYPE) \ + [](std::string& outValue, TYPE inValue) -> bool { \ + outValue = std::to_string(inValue); \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(LongDoubleProperty, long double, (long double)0, + numeric_limits::lowest(), + numeric_limits::max(), (long double)0.01f, + DEFAULT_FROM_LUA_LAMBDA(long double, (long double)(0)), + DEFAULT_TO_LUA_LAMBDA(long double), + DEFAULT_FROM_STRING_LAMBDA(long double, + (long double)(0)), + DEFAULT_TO_STRING_LAMBDA(long double), + LUA_TNUMBER); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/scalar/longlongproperty.cpp b/src/properties/scalar/longlongproperty.cpp new file mode 100644 index 0000000000..706ed6cba2 --- /dev/null +++ b/src/properties/scalar/longlongproperty.cpp @@ -0,0 +1,82 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include + +#include +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(TYPE, DEFAULT_VALUE) \ + [](lua_State* state, bool& success) -> TYPE { \ + success = (lua_isnumber(state, -1) == 1); \ + if (success) { \ + return static_cast(lua_tonumber(state, -1)); \ + } \ + else { \ + return DEFAULT_VALUE; \ + } \ + } + +#define DEFAULT_TO_LUA_LAMBDA(TYPE) \ + [](lua_State* state, TYPE value) -> bool { \ + lua_pushnumber(state, static_cast(value)); \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(TYPE, DEFAULT_VALUE) \ + [](std::string value, bool& success) -> TYPE { \ + std::stringstream s(value); \ + TYPE v; \ + s >> v; \ + success = !s.fail(); \ + if (success) { \ + return v; \ + } \ + } + +#define DEFAULT_TO_STRING_LAMBDA(TYPE) \ + [](std::string& outValue, TYPE inValue) -> bool { \ + outValue = std::to_string(inValue); \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(LongLongProperty, long long, (long long)0, + numeric_limits::lowest(), + numeric_limits::max(), (long long)1, + DEFAULT_FROM_LUA_LAMBDA(long long, (long long)(0)), + DEFAULT_TO_LUA_LAMBDA(long long), + DEFAULT_FROM_STRING_LAMBDA(long long, + (long long)(0)), + DEFAULT_TO_STRING_LAMBDA(long long), + LUA_TNUMBER); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/scalar/longproperty.cpp b/src/properties/scalar/longproperty.cpp new file mode 100644 index 0000000000..2e3ddf76f9 --- /dev/null +++ b/src/properties/scalar/longproperty.cpp @@ -0,0 +1,81 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include + +#include +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(TYPE, DEFAULT_VALUE) \ + [](lua_State* state, bool& success) -> TYPE { \ + success = (lua_isnumber(state, -1) == 1); \ + if (success) { \ + return static_cast(lua_tonumber(state, -1)); \ + } \ + else { \ + return DEFAULT_VALUE; \ + } \ + } + +#define DEFAULT_TO_LUA_LAMBDA(TYPE) \ + [](lua_State* state, TYPE value) -> bool { \ + lua_pushnumber(state, static_cast(value)); \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(TYPE, DEFAULT_VALUE) \ + [](std::string value, bool& success) -> TYPE { \ + std::stringstream s(value); \ + TYPE v; \ + s >> v; \ + success = !s.fail(); \ + if (success) { \ + return v; \ + } \ + } + +#define DEFAULT_TO_STRING_LAMBDA(TYPE) \ + [](std::string& outValue, TYPE inValue) -> bool { \ + outValue = std::to_string(inValue); \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(LongProperty, long, long(0), + numeric_limits::lowest(), + numeric_limits::max(), long(1), + DEFAULT_FROM_LUA_LAMBDA(long, long(0)), + DEFAULT_TO_LUA_LAMBDA(long), + DEFAULT_FROM_STRING_LAMBDA(long, long(0)), + DEFAULT_TO_STRING_LAMBDA(long), + LUA_TNUMBER); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/scalar/shortproperty.cpp b/src/properties/scalar/shortproperty.cpp new file mode 100644 index 0000000000..d95b09bbee --- /dev/null +++ b/src/properties/scalar/shortproperty.cpp @@ -0,0 +1,81 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include + +#include +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(TYPE, DEFAULT_VALUE) \ + [](lua_State* state, bool& success) -> TYPE { \ + success = (lua_isnumber(state, -1) == 1); \ + if (success) { \ + return static_cast(lua_tonumber(state, -1)); \ + } \ + else { \ + return DEFAULT_VALUE; \ + } \ + } + +#define DEFAULT_TO_LUA_LAMBDA(TYPE) \ + [](lua_State* state, TYPE value) -> bool { \ + lua_pushnumber(state, static_cast(value)); \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(TYPE, DEFAULT_VALUE) \ + [](std::string value, bool& success) -> TYPE { \ + std::stringstream s(value); \ + TYPE v; \ + s >> v; \ + success = !s.fail(); \ + if (success) { \ + return v; \ + } \ + } + +#define DEFAULT_TO_STRING_LAMBDA(TYPE) \ + [](std::string& outValue, TYPE inValue) -> bool { \ + outValue = std::to_string(inValue); \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(ShortProperty, short, short(0), + numeric_limits::lowest(), + numeric_limits::max(), short(1), + DEFAULT_FROM_LUA_LAMBDA(short, short(0)), + DEFAULT_TO_LUA_LAMBDA(short), + DEFAULT_FROM_STRING_LAMBDA(short, short(0)), + DEFAULT_TO_STRING_LAMBDA(short), + LUA_TNUMBER); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/scalar/signedcharproperty.cpp b/src/properties/scalar/signedcharproperty.cpp new file mode 100644 index 0000000000..3f0e7e068a --- /dev/null +++ b/src/properties/scalar/signedcharproperty.cpp @@ -0,0 +1,81 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include + +#include +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(TYPE, DEFAULT_VALUE) \ + [](lua_State* state, bool& success) -> TYPE { \ + success = (lua_isnumber(state, -1) == 1); \ + if (success) { \ + return static_cast(lua_tonumber(state, -1)); \ + } \ + else { \ + return DEFAULT_VALUE; \ + } \ + } + +#define DEFAULT_TO_LUA_LAMBDA(TYPE) \ + [](lua_State* state, TYPE value) -> bool { \ + lua_pushnumber(state, static_cast(value)); \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(TYPE, DEFAULT_VALUE) \ + [](std::string value, bool& success) -> TYPE { \ + std::stringstream s(value); \ + TYPE v; \ + s >> v; \ + success = !s.fail(); \ + if (success) { \ + return v; \ + } \ + } + +#define DEFAULT_TO_STRING_LAMBDA(TYPE) \ + [](std::string& outValue, TYPE inValue) -> bool { \ + outValue = std::to_string(inValue); \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(SignedCharProperty, signed char, (signed char)(0), + numeric_limits::lowest(), + numeric_limits::max(), (signed char)0, + DEFAULT_FROM_LUA_LAMBDA(signed char, (signed char)(0)), + DEFAULT_TO_LUA_LAMBDA(signed char), + DEFAULT_FROM_STRING_LAMBDA(signed char, (signed char)(0)), + DEFAULT_TO_STRING_LAMBDA(signed char), + LUA_TNUMBER); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/scalar/ucharproperty.cpp b/src/properties/scalar/ucharproperty.cpp new file mode 100644 index 0000000000..17ecca1c52 --- /dev/null +++ b/src/properties/scalar/ucharproperty.cpp @@ -0,0 +1,80 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include + +#include +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(TYPE, DEFAULT_VALUE) \ + [](lua_State* state, bool& success) -> TYPE { \ + success = (lua_isnumber(state, -1) == 1); \ + if (success) \ + return static_cast(lua_tonumber(state, -1)); \ + else \ + return DEFAULT_VALUE; \ + } + +#define DEFAULT_TO_LUA_LAMBDA(TYPE) \ + [](lua_State* state, TYPE value) -> bool { \ + lua_pushnumber(state, static_cast(value)); \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(TYPE, DEFAULT_VALUE) \ + [](std::string value, bool& success) -> TYPE { \ + std::stringstream s(value); \ + TYPE v; \ + s >> v; \ + success = !s.fail(); \ + if (success) \ + return v; \ + } + +#define DEFAULT_TO_STRING_LAMBDA(TYPE) \ + [](std::string& outValue, TYPE inValue) -> bool { \ + outValue = std::to_string(inValue); \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(UCharProperty, unsigned char, (unsigned char)0, + numeric_limits::lowest(), + numeric_limits::max(), (unsigned char)1, + DEFAULT_FROM_LUA_LAMBDA(unsigned char, + (unsigned char)(0)), + DEFAULT_TO_LUA_LAMBDA(unsigned char), + DEFAULT_FROM_STRING_LAMBDA(unsigned char, + (unsigned char)(0)), + DEFAULT_TO_STRING_LAMBDA(unsigned char), + LUA_TNUMBER); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/scalar/uintproperty.cpp b/src/properties/scalar/uintproperty.cpp new file mode 100644 index 0000000000..f60782cbd8 --- /dev/null +++ b/src/properties/scalar/uintproperty.cpp @@ -0,0 +1,80 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include + +#include +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(TYPE, DEFAULT_VALUE) \ + [](lua_State* state, bool& success) -> TYPE { \ + success = (lua_isnumber(state, -1) == 1); \ + if (success) \ + return static_cast(lua_tonumber(state, -1)); \ + else \ + return DEFAULT_VALUE; \ + } + +#define DEFAULT_TO_LUA_LAMBDA(TYPE) \ + [](lua_State* state, TYPE value) -> bool { \ + lua_pushnumber(state, static_cast(value)); \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(TYPE, DEFAULT_VALUE) \ + [](std::string value, bool& success) -> TYPE { \ + std::stringstream s(value); \ + TYPE v; \ + s >> v; \ + success = !s.fail(); \ + if (success) \ + return v; \ + } + +#define DEFAULT_TO_STRING_LAMBDA(TYPE) \ + [](std::string& outValue, TYPE inValue) -> bool { \ + outValue = std::to_string(inValue); \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(UCharProperty, unsigned int, (unsigned int)0, + numeric_limits::lowest(), + numeric_limits::max(), (unsigned int)1, + DEFAULT_FROM_LUA_LAMBDA(unsigned int, + (unsigned int)(0)), + DEFAULT_TO_LUA_LAMBDA(unsigned int), + DEFAULT_FROM_STRING_LAMBDA(unsigned int, + (unsigned int)(0)), + DEFAULT_TO_STRING_LAMBDA(unsigned int), + LUA_TNUMBER); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/scalar/ulonglongproperty.cpp b/src/properties/scalar/ulonglongproperty.cpp new file mode 100644 index 0000000000..6dc195639c --- /dev/null +++ b/src/properties/scalar/ulonglongproperty.cpp @@ -0,0 +1,85 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include + +#include +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(TYPE, DEFAULT_VALUE) \ + [](lua_State* state, bool& success) -> TYPE { \ + success = (lua_isnumber(state, -1) == 1); \ + if (success) { \ + return static_cast(lua_tonumber(state, -1)); \ + } \ + else { \ + return DEFAULT_VALUE; \ + } \ + } + +#define DEFAULT_TO_LUA_LAMBDA(TYPE) \ + [](lua_State* state, TYPE value) -> bool { \ + lua_pushnumber(state, static_cast(value)); \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(TYPE, DEFAULT_VALUE) \ + [](std::string value, bool& success) -> TYPE { \ + std::stringstream s(value); \ + TYPE v; \ + s >> v; \ + success = !s.fail(); \ + if (success) { \ + return v; \ + } \ + } + +#define DEFAULT_TO_STRING_LAMBDA(TYPE) \ + [](std::string& outValue, TYPE inValue) -> bool { \ + outValue = std::to_string(inValue); \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(ULongLongProperty, unsigned long long, + (unsigned long long)1, + numeric_limits::lowest(), + numeric_limits::max(), + (unsigned long long)1, + DEFAULT_FROM_LUA_LAMBDA(unsigned long long, + (unsigned long long)(0)), + DEFAULT_TO_LUA_LAMBDA(unsigned long long), + DEFAULT_FROM_STRING_LAMBDA(unsigned long long, + (unsigned long long)(0)), + DEFAULT_TO_STRING_LAMBDA(unsigned long long), + LUA_TNUMBER); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/scalar/ulongproperty.cpp b/src/properties/scalar/ulongproperty.cpp new file mode 100644 index 0000000000..974204164d --- /dev/null +++ b/src/properties/scalar/ulongproperty.cpp @@ -0,0 +1,83 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include + +#include +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(TYPE, DEFAULT_VALUE) \ + [](lua_State* state, bool& success) -> TYPE { \ + success = (lua_isnumber(state, -1) == 1); \ + if (success) { \ + return static_cast(lua_tonumber(state, -1)); \ + } \ + else { \ + return DEFAULT_VALUE; \ + } \ + } + +#define DEFAULT_TO_LUA_LAMBDA(TYPE) \ + [](lua_State* state, TYPE value) -> bool { \ + lua_pushnumber(state, static_cast(value)); \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(TYPE, DEFAULT_VALUE) \ + [](std::string value, bool& success) -> TYPE { \ + std::stringstream s(value); \ + TYPE v; \ + s >> v; \ + success = !s.fail(); \ + if (success) { \ + return v; \ + } \ + } + +#define DEFAULT_TO_STRING_LAMBDA(TYPE) \ + [](std::string& outValue, TYPE inValue) -> bool { \ + outValue = std::to_string(inValue); \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(ULongProperty, unsigned long, (unsigned long)0, + numeric_limits::lowest(), + numeric_limits::max(), (unsigned long)1, + DEFAULT_FROM_LUA_LAMBDA(unsigned long, + (unsigned long)(0)), + DEFAULT_TO_LUA_LAMBDA(unsigned long), + DEFAULT_FROM_STRING_LAMBDA(unsigned long, + (unsigned long)(0)), + DEFAULT_TO_STRING_LAMBDA(unsigned long), + LUA_TNUMBER); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/scalar/ushortproperty.cpp b/src/properties/scalar/ushortproperty.cpp new file mode 100644 index 0000000000..3369f51f44 --- /dev/null +++ b/src/properties/scalar/ushortproperty.cpp @@ -0,0 +1,84 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include + +#include +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(TYPE, DEFAULT_VALUE) \ + [](lua_State* state, bool& success) -> TYPE { \ + success = (lua_isnumber(state, -1) == 1); \ + if (success) { \ + return static_cast(lua_tonumber(state, -1)); \ + } \ + else { \ + return DEFAULT_VALUE; \ + } \ + } + +#define DEFAULT_TO_LUA_LAMBDA(TYPE) \ + [](lua_State* state, TYPE value) -> bool { \ + lua_pushnumber(state, static_cast(value)); \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(TYPE, DEFAULT_VALUE) \ + [](std::string value, bool& success) -> TYPE { \ + std::stringstream s(value); \ + TYPE v; \ + s >> v; \ + success = !s.fail(); \ + if (success) { \ + return v; \ + } \ + } + +#define DEFAULT_TO_STRING_LAMBDA(TYPE) \ + [](std::string& outValue, TYPE inValue) -> bool { \ + outValue = std::to_string(inValue); \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(UShortProperty, unsigned short, (unsigned short)(0), + numeric_limits::lowest(), + numeric_limits::max(), + (unsigned short)1, + DEFAULT_FROM_LUA_LAMBDA(unsigned short, + (unsigned short)(0)), + DEFAULT_TO_LUA_LAMBDA(unsigned short), + DEFAULT_FROM_STRING_LAMBDA(unsigned short, + (unsigned short)(0)), + DEFAULT_TO_STRING_LAMBDA(unsigned short), + LUA_TNUMBER); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/scalar/wcharproperty.cpp b/src/properties/scalar/wcharproperty.cpp new file mode 100644 index 0000000000..9a8c60b1a3 --- /dev/null +++ b/src/properties/scalar/wcharproperty.cpp @@ -0,0 +1,75 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include + +#include +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(TYPE, DEFAULT_VALUE) \ + [](lua_State* state, bool& success) -> TYPE { \ + success = (lua_isnumber(state, -1) == 1); \ + if (success) { \ + return static_cast(lua_tonumber(state, -1)); \ + } \ + else { \ + return DEFAULT_VALUE; \ + } \ + } + +#define DEFAULT_TO_LUA_LAMBDA(TYPE) \ + [](lua_State* state, TYPE value) -> bool { \ + lua_pushnumber(state, static_cast(value)); \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(TYPE, DEFAULT_VALUE) \ + [](std::string value, bool& success) -> TYPE { \ + std::stringstream s(value); \ + TYPE v; \ + s >> v; \ + success = !s.fail(); \ + if (success) { \ + return v; \ + } \ + } + +//REGISTER_NUMERICALPROPERTY_SOURCE(WCharProperty, wchar_t, wchar_t(0), +// numeric_limits::lowest(), +// numeric_limits::max(), wchar_t(1), +// DEFAULT_FROM_LUA_LAMBDA(wchar_t, wchar_t(0)), +// DEFAULT_TO_LUA_LAMBDA(wchar_t), +// DEFAULT_FROM_STRING_LAMBDA(wchar_t, wchar_t(0)), +// DEFAULT_TO_STRING_LAMBDA(wchar_t), +// LUA_TNUMBER); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/scalarproperty.cpp b/src/properties/scalarproperty.cpp deleted file mode 100644 index d21ba5b5b6..0000000000 --- a/src/properties/scalarproperty.cpp +++ /dev/null @@ -1,247 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2016 * - * * - * 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/scalarproperty.h" - -#include - -#include -#include - -using std::numeric_limits; - -namespace openspace { -namespace properties { - -#define DEFAULT_FROM_LUA_LAMBDA(TYPE, DEFAULT_VALUE) \ - [](lua_State* state, bool& success) -> TYPE { \ - success = (lua_isnumber(state, -1) == 1); \ - if (success) \ - return static_cast(lua_tonumber(state, -1)); \ - else \ - return DEFAULT_VALUE; \ - } - -#define DEFAULT_TO_LUA_LAMBDA(TYPE) \ - [](lua_State* state, TYPE value) -> bool { \ - lua_pushnumber(state, static_cast(value)); \ - return true; \ - } - -#define DEFAULT_FROM_STRING_LAMBDA(TYPE, DEFAULT_VALUE) \ - [](std::string value, bool& success) -> TYPE { \ - std::stringstream s(value); \ - TYPE v; \ - s >> v; \ - success = !s.fail(); \ - if (success) \ - return v; \ - } - -#define DEFAULT_TO_STRING_LAMBDA(TYPE) \ - [](std::string& outValue, TYPE inValue) -> bool { \ - outValue = std::to_string(inValue); \ - return true; \ - } - -// char16_t and char32_t are not supported on Visual Studio 2013 and are defined to -// be equal to unsigned short and unsigned int which causes a compile error - -REGISTER_TEMPLATEPROPERTY_SOURCE(BoolProperty, bool, false, - [](lua_State* state, bool& success) -> bool { - success = (lua_isboolean(state, -1) == 1); - if (success) - return lua_toboolean(state, -1) == 1; - else - return false; - }, - [](lua_State* state, bool value) -> bool { - lua_pushboolean(state, value); - return true; - }, - DEFAULT_FROM_STRING_LAMBDA(bool, false), - [](std::string& outValue, bool inValue) -> bool { - outValue = inValue ? "true" : "false"; - return true; - }, - LUA_TBOOLEAN - ); - -REGISTER_NUMERICALPROPERTY_SOURCE(CharProperty, char, char(0), - numeric_limits::lowest(), - numeric_limits::max(), char(1), - DEFAULT_FROM_LUA_LAMBDA(char, char(0)), - DEFAULT_TO_LUA_LAMBDA(char), - DEFAULT_FROM_STRING_LAMBDA(char, char(0)), - DEFAULT_TO_STRING_LAMBDA(char), - LUA_TNUMBER); - -// REGISTER_NUMERICALPROPERTY_SOURCE(Char16Property, char16_t, char16_t(0), -// numeric_limits::lowest(), numeric_limits::max(), char16_t(1)); - -// REGISTER_NUMERICALPROPERTY_SOURCE(Char32Property, char32_t, char32_t(0), -// numeric_limits::lowest(), numeric_limits::max(), char32_t(1)); - -//REGISTER_NUMERICALPROPERTY_SOURCE(WCharProperty, wchar_t, wchar_t(0), -// numeric_limits::lowest(), -// numeric_limits::max(), wchar_t(1), -// DEFAULT_FROM_LUA_LAMBDA(wchar_t, wchar_t(0)), -// DEFAULT_TO_LUA_LAMBDA(wchar_t), -// DEFAULT_FROM_STRING_LAMBDA(wchar_t, wchar_t(0)), -// DEFAULT_TO_STRING_LAMBDA(wchar_t), -// LUA_TNUMBER); - -REGISTER_NUMERICALPROPERTY_SOURCE(SignedCharProperty, signed char, (signed char)(0), - numeric_limits::lowest(), - numeric_limits::max(), (signed char)0, - DEFAULT_FROM_LUA_LAMBDA(signed char, (signed char)(0)), - DEFAULT_TO_LUA_LAMBDA(signed char), - DEFAULT_FROM_STRING_LAMBDA(signed char, (signed char)(0)), - DEFAULT_TO_STRING_LAMBDA(signed char), - LUA_TNUMBER); - -REGISTER_NUMERICALPROPERTY_SOURCE(UCharProperty, unsigned char, (unsigned char)0, - numeric_limits::lowest(), - numeric_limits::max(), (unsigned char)1, - DEFAULT_FROM_LUA_LAMBDA(unsigned char, - (unsigned char)(0)), - DEFAULT_TO_LUA_LAMBDA(unsigned char), - DEFAULT_FROM_STRING_LAMBDA(unsigned char, - (unsigned char)(0)), - DEFAULT_TO_STRING_LAMBDA(unsigned char), - LUA_TNUMBER); - -REGISTER_NUMERICALPROPERTY_SOURCE(ShortProperty, short, short(0), - numeric_limits::lowest(), - numeric_limits::max(), short(1), - DEFAULT_FROM_LUA_LAMBDA(short, short(0)), - DEFAULT_TO_LUA_LAMBDA(short), - DEFAULT_FROM_STRING_LAMBDA(short, short(0)), - DEFAULT_TO_STRING_LAMBDA(short), - LUA_TNUMBER); - -REGISTER_NUMERICALPROPERTY_SOURCE(UShortProperty, unsigned short, (unsigned short)(0), - numeric_limits::lowest(), - numeric_limits::max(), - (unsigned short)1, - DEFAULT_FROM_LUA_LAMBDA(unsigned short, - (unsigned short)(0)), - DEFAULT_TO_LUA_LAMBDA(unsigned short), - DEFAULT_FROM_STRING_LAMBDA(unsigned short, - (unsigned short)(0)), - DEFAULT_TO_STRING_LAMBDA(unsigned short), - LUA_TNUMBER); - -REGISTER_NUMERICALPROPERTY_SOURCE(IntProperty, int, int(0), numeric_limits::lowest(), - numeric_limits::max(), int(1), - DEFAULT_FROM_LUA_LAMBDA(int, int(0)), - DEFAULT_TO_LUA_LAMBDA(int), - DEFAULT_FROM_STRING_LAMBDA(int, int(0)), - DEFAULT_TO_STRING_LAMBDA(int), - LUA_TNUMBER); - -REGISTER_NUMERICALPROPERTY_SOURCE(UIntProperty, unsigned int, (unsigned int)0, - numeric_limits::lowest(), - numeric_limits::max(), (unsigned int)1, - DEFAULT_FROM_LUA_LAMBDA(unsigned int, - (unsigned int)(0)), - DEFAULT_TO_LUA_LAMBDA(unsigned int), - DEFAULT_FROM_STRING_LAMBDA(unsigned int, - (unsigned int)(0)), - DEFAULT_TO_STRING_LAMBDA(unsigned int), - LUA_TNUMBER); - -REGISTER_NUMERICALPROPERTY_SOURCE(LongProperty, long, long(0), - numeric_limits::lowest(), - numeric_limits::max(), long(1), - DEFAULT_FROM_LUA_LAMBDA(long, long(0)), - DEFAULT_TO_LUA_LAMBDA(long), - DEFAULT_FROM_STRING_LAMBDA(long, long(0)), - DEFAULT_TO_STRING_LAMBDA(long), - LUA_TNUMBER); - -REGISTER_NUMERICALPROPERTY_SOURCE(ULongProperty, unsigned long, (unsigned long)0, - numeric_limits::lowest(), - numeric_limits::max(), (unsigned long)1, - DEFAULT_FROM_LUA_LAMBDA(unsigned long, - (unsigned long)(0)), - DEFAULT_TO_LUA_LAMBDA(unsigned long), - DEFAULT_FROM_STRING_LAMBDA(unsigned long, - (unsigned long)(0)), - DEFAULT_TO_STRING_LAMBDA(unsigned long), - LUA_TNUMBER); - -REGISTER_NUMERICALPROPERTY_SOURCE(LongLongProperty, long long, (long long)0, - numeric_limits::lowest(), - numeric_limits::max(), (long long)1, - DEFAULT_FROM_LUA_LAMBDA(long long, (long long)(0)), - DEFAULT_TO_LUA_LAMBDA(long long), - DEFAULT_FROM_STRING_LAMBDA(long long, - (long long)(0)), - DEFAULT_TO_STRING_LAMBDA(long long), - LUA_TNUMBER); - -REGISTER_NUMERICALPROPERTY_SOURCE(ULongLongProperty, unsigned long long, - (unsigned long long)1, - numeric_limits::lowest(), - numeric_limits::max(), - (unsigned long long)1, - DEFAULT_FROM_LUA_LAMBDA(unsigned long long, - (unsigned long long)(0)), - DEFAULT_TO_LUA_LAMBDA(unsigned long long), - DEFAULT_FROM_STRING_LAMBDA(unsigned long long, - (unsigned long long)(0)), - DEFAULT_TO_STRING_LAMBDA(unsigned long long), - LUA_TNUMBER); - -REGISTER_NUMERICALPROPERTY_SOURCE(FloatProperty, float, 0.f, - numeric_limits::lowest(), - numeric_limits::max(), 0.01f, - DEFAULT_FROM_LUA_LAMBDA(float, float(0)), - DEFAULT_TO_LUA_LAMBDA(float), - DEFAULT_FROM_STRING_LAMBDA(float, float(0)), - DEFAULT_TO_STRING_LAMBDA(float), - LUA_TNUMBER); - -REGISTER_NUMERICALPROPERTY_SOURCE(DoubleProperty, double, 0.0, - numeric_limits::lowest(), - numeric_limits::max(), 0.01, - DEFAULT_FROM_LUA_LAMBDA(double, double(0)), - DEFAULT_TO_LUA_LAMBDA(double), - DEFAULT_FROM_STRING_LAMBDA(double, double(0)), - DEFAULT_TO_STRING_LAMBDA(double), - LUA_TNUMBER); - -REGISTER_NUMERICALPROPERTY_SOURCE(LongDoubleProperty, long double, (long double)0, - numeric_limits::lowest(), - numeric_limits::max(), (long double)0.01f, - DEFAULT_FROM_LUA_LAMBDA(long double, (long double)(0)), - DEFAULT_TO_LUA_LAMBDA(long double), - DEFAULT_FROM_STRING_LAMBDA(long double, - (long double)(0)), - DEFAULT_TO_STRING_LAMBDA(long double), - LUA_TNUMBER); - -} // namespace properties -} // namespace openspace diff --git a/src/properties/selectionproperty.cpp b/src/properties/selectionproperty.cpp index 1049d62e77..adeefb3f5b 100644 --- a/src/properties/selectionproperty.cpp +++ b/src/properties/selectionproperty.cpp @@ -24,6 +24,8 @@ #include +#include + namespace { const std::string _loggerCat = "SelectionProperty"; diff --git a/src/properties/vector/bvec2property.cpp b/src/properties/vector/bvec2property.cpp new file mode 100644 index 0000000000..4e48dd1de5 --- /dev/null +++ b/src/properties/vector/bvec2property.cpp @@ -0,0 +1,125 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include +#include +#include + +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(__TYPE__, __CONVFUNC__, __TESTFUNC__) \ + [](lua_State * state, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + lua_pushnil(state); \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + int success = lua_next(state, -2); \ + if (success != 1) { \ + success = false; \ + return __TYPE__(0); \ + } \ + if (__TESTFUNC__(state, -1) != 1) { \ + success = false; \ + return __TYPE__(0); \ + } else { \ + result[i] = static_cast<__TYPE__::value_type>(__CONVFUNC__(state, -1)); \ + lua_pop(state, 1); \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_LUA_LAMBDA(__TYPE__) \ + [](lua_State * state, __TYPE__ value) -> bool { \ + lua_newtable(state); \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + lua_pushnumber(state, static_cast(value[i])); \ + lua_setfield(state, -2, std::to_string(number).c_str()); \ + ++number; \ + } \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(__TYPE__) \ + [](std::string value, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + std::vector tokens = ghoul::tokenizeString(value, ','); \ + if (tokens.size() != result.length()) { \ + success = false; \ + return result; \ + } \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + std::stringstream s(tokens[i]); \ + __TYPE__::value_type v; \ + s >> v; \ + if (s.fail()) { \ + success = false; \ + return result; \ + } \ + else \ + result[i] = v; \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ + [](std::string& outValue, __TYPE__ inValue) -> bool { \ + outValue = "{"; \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) \ + outValue += std::to_string(inValue[i]) + ","; \ + outValue.pop_back(); \ + outValue += "}"; \ + return true; \ + } + + +// Forcing value from int to bool is acceptable here (line 48) +#ifdef WIN32 +#pragma warning(disable : 4800) +#endif + + +REGISTER_TEMPLATEPROPERTY_SOURCE(BVec2Property, glm::bvec2, glm::bvec2(false), + DEFAULT_FROM_LUA_LAMBDA(glm::bvec2, lua_toboolean, + lua_isboolean), + DEFAULT_TO_LUA_LAMBDA(glm::bvec2), + DEFAULT_FROM_STRING_LAMBDA(glm::bvec2), + DEFAULT_TO_STRING_LAMBDA(glm::bvec2), + LUA_TTABLE); + +#ifdef WIN32 +#pragma warning(default : 4800) +#endif + +} // namespace properties +} // namespace openspace diff --git a/src/properties/vector/bvec3property.cpp b/src/properties/vector/bvec3property.cpp new file mode 100644 index 0000000000..9891b42f2f --- /dev/null +++ b/src/properties/vector/bvec3property.cpp @@ -0,0 +1,124 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include +#include +#include + +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(__TYPE__, __CONVFUNC__, __TESTFUNC__) \ + [](lua_State * state, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + lua_pushnil(state); \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + int success = lua_next(state, -2); \ + if (success != 1) { \ + success = false; \ + return __TYPE__(0); \ + } \ + if (__TESTFUNC__(state, -1) != 1) { \ + success = false; \ + return __TYPE__(0); \ + } else { \ + result[i] = static_cast<__TYPE__::value_type>(__CONVFUNC__(state, -1)); \ + lua_pop(state, 1); \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_LUA_LAMBDA(__TYPE__) \ + [](lua_State * state, __TYPE__ value) -> bool { \ + lua_newtable(state); \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + lua_pushnumber(state, static_cast(value[i])); \ + lua_setfield(state, -2, std::to_string(number).c_str()); \ + ++number; \ + } \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(__TYPE__) \ + [](std::string value, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + std::vector tokens = ghoul::tokenizeString(value, ','); \ + if (tokens.size() != result.length()) { \ + success = false; \ + return result; \ + } \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + std::stringstream s(tokens[i]); \ + __TYPE__::value_type v; \ + s >> v; \ + if (s.fail()) { \ + success = false; \ + return result; \ + } \ + else \ + result[i] = v; \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ + [](std::string& outValue, __TYPE__ inValue) -> bool { \ + outValue = "{"; \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) \ + outValue += std::to_string(inValue[i]) + ","; \ + outValue.pop_back(); \ + outValue += "}"; \ + return true; \ + } + + +// Forcing value from int to bool is acceptable here (line 48) +#ifdef WIN32 +#pragma warning(disable : 4800) +#endif + +REGISTER_TEMPLATEPROPERTY_SOURCE(BVec3Property, glm::bvec3, glm::bvec3(false), + DEFAULT_FROM_LUA_LAMBDA(glm::bvec3, lua_toboolean, + lua_isboolean), + DEFAULT_TO_LUA_LAMBDA(glm::bvec3), + DEFAULT_FROM_STRING_LAMBDA(glm::bvec3), + DEFAULT_TO_STRING_LAMBDA(glm::bvec3), + LUA_TTABLE); + +#ifdef WIN32 +#pragma warning(default : 4800) +#endif + +} // namespace properties +} // namespace openspace diff --git a/src/properties/vector/bvec4property.cpp b/src/properties/vector/bvec4property.cpp new file mode 100644 index 0000000000..9ec01527e2 --- /dev/null +++ b/src/properties/vector/bvec4property.cpp @@ -0,0 +1,124 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include +#include +#include + +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(__TYPE__, __CONVFUNC__, __TESTFUNC__) \ + [](lua_State * state, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + lua_pushnil(state); \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + int success = lua_next(state, -2); \ + if (success != 1) { \ + success = false; \ + return __TYPE__(0); \ + } \ + if (__TESTFUNC__(state, -1) != 1) { \ + success = false; \ + return __TYPE__(0); \ + } else { \ + result[i] = static_cast<__TYPE__::value_type>(__CONVFUNC__(state, -1)); \ + lua_pop(state, 1); \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_LUA_LAMBDA(__TYPE__) \ + [](lua_State * state, __TYPE__ value) -> bool { \ + lua_newtable(state); \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + lua_pushnumber(state, static_cast(value[i])); \ + lua_setfield(state, -2, std::to_string(number).c_str()); \ + ++number; \ + } \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(__TYPE__) \ + [](std::string value, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + std::vector tokens = ghoul::tokenizeString(value, ','); \ + if (tokens.size() != result.length()) { \ + success = false; \ + return result; \ + } \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + std::stringstream s(tokens[i]); \ + __TYPE__::value_type v; \ + s >> v; \ + if (s.fail()) { \ + success = false; \ + return result; \ + } \ + else \ + result[i] = v; \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ + [](std::string& outValue, __TYPE__ inValue) -> bool { \ + outValue = "{"; \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) \ + outValue += std::to_string(inValue[i]) + ","; \ + outValue.pop_back(); \ + outValue += "}"; \ + return true; \ + } + + +// Forcing value from int to bool is acceptable here (line 48) +#ifdef WIN32 +#pragma warning(disable : 4800) +#endif + +REGISTER_TEMPLATEPROPERTY_SOURCE(BVec4Property, glm::bvec4, glm::bvec4(false), + DEFAULT_FROM_LUA_LAMBDA(glm::bvec4, lua_toboolean, + lua_isboolean), + DEFAULT_TO_LUA_LAMBDA(glm::bvec4), + DEFAULT_FROM_STRING_LAMBDA(glm::bvec4), + DEFAULT_TO_STRING_LAMBDA(glm::bvec4), + LUA_TTABLE); + +#ifdef WIN32 +#pragma warning(default : 4800) +#endif + +} // namespace properties +} // namespace openspace diff --git a/src/properties/vector/dvec2property.cpp b/src/properties/vector/dvec2property.cpp new file mode 100644 index 0000000000..2c70902f22 --- /dev/null +++ b/src/properties/vector/dvec2property.cpp @@ -0,0 +1,117 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include +#include +#include + +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(__TYPE__, __CONVFUNC__, __TESTFUNC__) \ + [](lua_State * state, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + lua_pushnil(state); \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + int success = lua_next(state, -2); \ + if (success != 1) { \ + success = false; \ + return __TYPE__(0); \ + } \ + if (__TESTFUNC__(state, -1) != 1) { \ + success = false; \ + return __TYPE__(0); \ + } else { \ + result[i] = static_cast<__TYPE__::value_type>(__CONVFUNC__(state, -1)); \ + lua_pop(state, 1); \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_LUA_LAMBDA(__TYPE__) \ + [](lua_State * state, __TYPE__ value) -> bool { \ + lua_newtable(state); \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + lua_pushnumber(state, static_cast(value[i])); \ + lua_setfield(state, -2, std::to_string(number).c_str()); \ + ++number; \ + } \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(__TYPE__) \ + [](std::string value, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + std::vector tokens = ghoul::tokenizeString(value, ','); \ + if (tokens.size() != result.length()) { \ + success = false; \ + return result; \ + } \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + std::stringstream s(tokens[i]); \ + __TYPE__::value_type v; \ + s >> v; \ + if (s.fail()) { \ + success = false; \ + return result; \ + } \ + else \ + result[i] = v; \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ + [](std::string& outValue, __TYPE__ inValue) -> bool { \ + outValue = "{"; \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) \ + outValue += std::to_string(inValue[i]) + ","; \ + outValue.pop_back(); \ + outValue += "}"; \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(DVec2Property, glm::dvec2, glm::dvec2(0), + glm::dvec2(numeric_limits::lowest()), + glm::dvec2(numeric_limits::max()), + glm::dvec2(0.01), + DEFAULT_FROM_LUA_LAMBDA(glm::dvec2, lua_tonumber, + lua_isnumber), + DEFAULT_TO_LUA_LAMBDA(glm::dvec2), + DEFAULT_FROM_STRING_LAMBDA(glm::dvec2), + DEFAULT_TO_STRING_LAMBDA(glm::dvec2), + LUA_TTABLE); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/vector/dvec3property.cpp b/src/properties/vector/dvec3property.cpp new file mode 100644 index 0000000000..80d9b4db3f --- /dev/null +++ b/src/properties/vector/dvec3property.cpp @@ -0,0 +1,117 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include +#include +#include + +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(__TYPE__, __CONVFUNC__, __TESTFUNC__) \ + [](lua_State * state, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + lua_pushnil(state); \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + int success = lua_next(state, -2); \ + if (success != 1) { \ + success = false; \ + return __TYPE__(0); \ + } \ + if (__TESTFUNC__(state, -1) != 1) { \ + success = false; \ + return __TYPE__(0); \ + } else { \ + result[i] = static_cast<__TYPE__::value_type>(__CONVFUNC__(state, -1)); \ + lua_pop(state, 1); \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_LUA_LAMBDA(__TYPE__) \ + [](lua_State * state, __TYPE__ value) -> bool { \ + lua_newtable(state); \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + lua_pushnumber(state, static_cast(value[i])); \ + lua_setfield(state, -2, std::to_string(number).c_str()); \ + ++number; \ + } \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(__TYPE__) \ + [](std::string value, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + std::vector tokens = ghoul::tokenizeString(value, ','); \ + if (tokens.size() != result.length()) { \ + success = false; \ + return result; \ + } \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + std::stringstream s(tokens[i]); \ + __TYPE__::value_type v; \ + s >> v; \ + if (s.fail()) { \ + success = false; \ + return result; \ + } \ + else \ + result[i] = v; \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ + [](std::string& outValue, __TYPE__ inValue) -> bool { \ + outValue = "{"; \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) \ + outValue += std::to_string(inValue[i]) + ","; \ + outValue.pop_back(); \ + outValue += "}"; \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(DVec3Property, glm::dvec3, glm::dvec3(0), + glm::dvec3(numeric_limits::lowest()), + glm::dvec3(numeric_limits::max()), + glm::dvec3(0.01), + DEFAULT_FROM_LUA_LAMBDA(glm::dvec3, lua_tonumber, + lua_isnumber), + DEFAULT_TO_LUA_LAMBDA(glm::dvec3), + DEFAULT_FROM_STRING_LAMBDA(glm::dvec3), + DEFAULT_TO_STRING_LAMBDA(glm::dvec3), + LUA_TTABLE); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/vector/dvec4property.cpp b/src/properties/vector/dvec4property.cpp new file mode 100644 index 0000000000..2a8393437b --- /dev/null +++ b/src/properties/vector/dvec4property.cpp @@ -0,0 +1,117 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include +#include +#include + +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(__TYPE__, __CONVFUNC__, __TESTFUNC__) \ + [](lua_State * state, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + lua_pushnil(state); \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + int success = lua_next(state, -2); \ + if (success != 1) { \ + success = false; \ + return __TYPE__(0); \ + } \ + if (__TESTFUNC__(state, -1) != 1) { \ + success = false; \ + return __TYPE__(0); \ + } else { \ + result[i] = static_cast<__TYPE__::value_type>(__CONVFUNC__(state, -1)); \ + lua_pop(state, 1); \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_LUA_LAMBDA(__TYPE__) \ + [](lua_State * state, __TYPE__ value) -> bool { \ + lua_newtable(state); \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + lua_pushnumber(state, static_cast(value[i])); \ + lua_setfield(state, -2, std::to_string(number).c_str()); \ + ++number; \ + } \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(__TYPE__) \ + [](std::string value, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + std::vector tokens = ghoul::tokenizeString(value, ','); \ + if (tokens.size() != result.length()) { \ + success = false; \ + return result; \ + } \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + std::stringstream s(tokens[i]); \ + __TYPE__::value_type v; \ + s >> v; \ + if (s.fail()) { \ + success = false; \ + return result; \ + } \ + else \ + result[i] = v; \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ + [](std::string& outValue, __TYPE__ inValue) -> bool { \ + outValue = "{"; \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) \ + outValue += std::to_string(inValue[i]) + ","; \ + outValue.pop_back(); \ + outValue += "}"; \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(DVec4Property, glm::dvec4, glm::dvec4(0), + glm::dvec4(numeric_limits::lowest()), + glm::dvec4(numeric_limits::max()), + glm::dvec4(0.01), + DEFAULT_FROM_LUA_LAMBDA(glm::dvec4, lua_tonumber, + lua_isnumber), + DEFAULT_TO_LUA_LAMBDA(glm::dvec4), + DEFAULT_FROM_STRING_LAMBDA(glm::dvec4), + DEFAULT_TO_STRING_LAMBDA(glm::dvec4), + LUA_TTABLE); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/vector/ivec2property.cpp b/src/properties/vector/ivec2property.cpp new file mode 100644 index 0000000000..3949a09bb1 --- /dev/null +++ b/src/properties/vector/ivec2property.cpp @@ -0,0 +1,116 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include +#include +#include + +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(__TYPE__, __CONVFUNC__, __TESTFUNC__) \ + [](lua_State * state, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + lua_pushnil(state); \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + int success = lua_next(state, -2); \ + if (success != 1) { \ + success = false; \ + return __TYPE__(0); \ + } \ + if (__TESTFUNC__(state, -1) != 1) { \ + success = false; \ + return __TYPE__(0); \ + } else { \ + result[i] = static_cast<__TYPE__::value_type>(__CONVFUNC__(state, -1)); \ + lua_pop(state, 1); \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_LUA_LAMBDA(__TYPE__) \ + [](lua_State * state, __TYPE__ value) -> bool { \ + lua_newtable(state); \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + lua_pushnumber(state, static_cast(value[i])); \ + lua_setfield(state, -2, std::to_string(number).c_str()); \ + ++number; \ + } \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(__TYPE__) \ + [](std::string value, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + std::vector tokens = ghoul::tokenizeString(value, ','); \ + if (tokens.size() != result.length()) { \ + success = false; \ + return result; \ + } \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + std::stringstream s(tokens[i]); \ + __TYPE__::value_type v; \ + s >> v; \ + if (s.fail()) { \ + success = false; \ + return result; \ + } \ + else \ + result[i] = v; \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ + [](std::string& outValue, __TYPE__ inValue) -> bool { \ + outValue = "{"; \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) \ + outValue += std::to_string(inValue[i]) + ","; \ + outValue.pop_back(); \ + outValue += "}"; \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(IVec2Property, glm::ivec2, glm::ivec2(0), + glm::ivec2(numeric_limits::lowest()), + glm::ivec2(numeric_limits::max()), glm::ivec2(1), + DEFAULT_FROM_LUA_LAMBDA(glm::ivec2, lua_tonumber, + lua_isnumber), + DEFAULT_TO_LUA_LAMBDA(glm::ivec2), + DEFAULT_FROM_STRING_LAMBDA(glm::ivec2), + DEFAULT_TO_STRING_LAMBDA(glm::ivec2), + LUA_TTABLE); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/vector/ivec3property.cpp b/src/properties/vector/ivec3property.cpp new file mode 100644 index 0000000000..f7e4207e87 --- /dev/null +++ b/src/properties/vector/ivec3property.cpp @@ -0,0 +1,116 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include +#include +#include + +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(__TYPE__, __CONVFUNC__, __TESTFUNC__) \ + [](lua_State * state, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + lua_pushnil(state); \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + int success = lua_next(state, -2); \ + if (success != 1) { \ + success = false; \ + return __TYPE__(0); \ + } \ + if (__TESTFUNC__(state, -1) != 1) { \ + success = false; \ + return __TYPE__(0); \ + } else { \ + result[i] = static_cast<__TYPE__::value_type>(__CONVFUNC__(state, -1)); \ + lua_pop(state, 1); \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_LUA_LAMBDA(__TYPE__) \ + [](lua_State * state, __TYPE__ value) -> bool { \ + lua_newtable(state); \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + lua_pushnumber(state, static_cast(value[i])); \ + lua_setfield(state, -2, std::to_string(number).c_str()); \ + ++number; \ + } \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(__TYPE__) \ + [](std::string value, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + std::vector tokens = ghoul::tokenizeString(value, ','); \ + if (tokens.size() != result.length()) { \ + success = false; \ + return result; \ + } \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + std::stringstream s(tokens[i]); \ + __TYPE__::value_type v; \ + s >> v; \ + if (s.fail()) { \ + success = false; \ + return result; \ + } \ + else \ + result[i] = v; \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ + [](std::string& outValue, __TYPE__ inValue) -> bool { \ + outValue = "{"; \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) \ + outValue += std::to_string(inValue[i]) + ","; \ + outValue.pop_back(); \ + outValue += "}"; \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(IVec3Property, glm::ivec3, glm::ivec3(0), + glm::ivec3(numeric_limits::lowest()), + glm::ivec3(numeric_limits::max()), glm::ivec3(1), + DEFAULT_FROM_LUA_LAMBDA(glm::ivec3, lua_tonumber, + lua_isnumber), + DEFAULT_TO_LUA_LAMBDA(glm::ivec3), + DEFAULT_FROM_STRING_LAMBDA(glm::ivec3), + DEFAULT_TO_STRING_LAMBDA(glm::ivec3), + LUA_TTABLE); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/vector/ivec4property.cpp b/src/properties/vector/ivec4property.cpp new file mode 100644 index 0000000000..2c357001d6 --- /dev/null +++ b/src/properties/vector/ivec4property.cpp @@ -0,0 +1,116 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include +#include +#include + +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(__TYPE__, __CONVFUNC__, __TESTFUNC__) \ + [](lua_State * state, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + lua_pushnil(state); \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + int success = lua_next(state, -2); \ + if (success != 1) { \ + success = false; \ + return __TYPE__(0); \ + } \ + if (__TESTFUNC__(state, -1) != 1) { \ + success = false; \ + return __TYPE__(0); \ + } else { \ + result[i] = static_cast<__TYPE__::value_type>(__CONVFUNC__(state, -1)); \ + lua_pop(state, 1); \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_LUA_LAMBDA(__TYPE__) \ + [](lua_State * state, __TYPE__ value) -> bool { \ + lua_newtable(state); \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + lua_pushnumber(state, static_cast(value[i])); \ + lua_setfield(state, -2, std::to_string(number).c_str()); \ + ++number; \ + } \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(__TYPE__) \ + [](std::string value, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + std::vector tokens = ghoul::tokenizeString(value, ','); \ + if (tokens.size() != result.length()) { \ + success = false; \ + return result; \ + } \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + std::stringstream s(tokens[i]); \ + __TYPE__::value_type v; \ + s >> v; \ + if (s.fail()) { \ + success = false; \ + return result; \ + } \ + else \ + result[i] = v; \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ + [](std::string& outValue, __TYPE__ inValue) -> bool { \ + outValue = "{"; \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) \ + outValue += std::to_string(inValue[i]) + ","; \ + outValue.pop_back(); \ + outValue += "}"; \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(IVec4Property, glm::ivec4, glm::ivec4(0), + glm::ivec4(numeric_limits::lowest()), + glm::ivec4(numeric_limits::max()), glm::ivec4(1), + DEFAULT_FROM_LUA_LAMBDA(glm::ivec4, lua_tonumber, + lua_isnumber), + DEFAULT_TO_LUA_LAMBDA(glm::ivec4), + DEFAULT_FROM_STRING_LAMBDA(glm::ivec4), + DEFAULT_TO_STRING_LAMBDA(glm::ivec4), + LUA_TTABLE); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/vector/uvec2property.cpp b/src/properties/vector/uvec2property.cpp new file mode 100644 index 0000000000..50bc166cba --- /dev/null +++ b/src/properties/vector/uvec2property.cpp @@ -0,0 +1,117 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include +#include +#include + +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(__TYPE__, __CONVFUNC__, __TESTFUNC__) \ + [](lua_State * state, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + lua_pushnil(state); \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + int success = lua_next(state, -2); \ + if (success != 1) { \ + success = false; \ + return __TYPE__(0); \ + } \ + if (__TESTFUNC__(state, -1) != 1) { \ + success = false; \ + return __TYPE__(0); \ + } else { \ + result[i] = static_cast<__TYPE__::value_type>(__CONVFUNC__(state, -1)); \ + lua_pop(state, 1); \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_LUA_LAMBDA(__TYPE__) \ + [](lua_State * state, __TYPE__ value) -> bool { \ + lua_newtable(state); \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + lua_pushnumber(state, static_cast(value[i])); \ + lua_setfield(state, -2, std::to_string(number).c_str()); \ + ++number; \ + } \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(__TYPE__) \ + [](std::string value, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + std::vector tokens = ghoul::tokenizeString(value, ','); \ + if (tokens.size() != result.length()) { \ + success = false; \ + return result; \ + } \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + std::stringstream s(tokens[i]); \ + __TYPE__::value_type v; \ + s >> v; \ + if (s.fail()) { \ + success = false; \ + return result; \ + } \ + else \ + result[i] = v; \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ + [](std::string& outValue, __TYPE__ inValue) -> bool { \ + outValue = "{"; \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) \ + outValue += std::to_string(inValue[i]) + ","; \ + outValue.pop_back(); \ + outValue += "}"; \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(UVec2Property, glm::uvec2, glm::uvec2(0), + glm::uvec2(numeric_limits::lowest()), + glm::uvec2(numeric_limits::max()), + glm::uvec2(1), + DEFAULT_FROM_LUA_LAMBDA(glm::uvec2, lua_tonumber, + lua_isnumber), + DEFAULT_TO_LUA_LAMBDA(glm::uvec2), + DEFAULT_FROM_STRING_LAMBDA(glm::uvec2), + DEFAULT_TO_STRING_LAMBDA(glm::uvec2), + LUA_TTABLE); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/vector/uvec3property.cpp b/src/properties/vector/uvec3property.cpp new file mode 100644 index 0000000000..0feb1188e8 --- /dev/null +++ b/src/properties/vector/uvec3property.cpp @@ -0,0 +1,117 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include +#include +#include + +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(__TYPE__, __CONVFUNC__, __TESTFUNC__) \ + [](lua_State * state, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + lua_pushnil(state); \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + int success = lua_next(state, -2); \ + if (success != 1) { \ + success = false; \ + return __TYPE__(0); \ + } \ + if (__TESTFUNC__(state, -1) != 1) { \ + success = false; \ + return __TYPE__(0); \ + } else { \ + result[i] = static_cast<__TYPE__::value_type>(__CONVFUNC__(state, -1)); \ + lua_pop(state, 1); \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_LUA_LAMBDA(__TYPE__) \ + [](lua_State * state, __TYPE__ value) -> bool { \ + lua_newtable(state); \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + lua_pushnumber(state, static_cast(value[i])); \ + lua_setfield(state, -2, std::to_string(number).c_str()); \ + ++number; \ + } \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(__TYPE__) \ + [](std::string value, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + std::vector tokens = ghoul::tokenizeString(value, ','); \ + if (tokens.size() != result.length()) { \ + success = false; \ + return result; \ + } \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + std::stringstream s(tokens[i]); \ + __TYPE__::value_type v; \ + s >> v; \ + if (s.fail()) { \ + success = false; \ + return result; \ + } \ + else \ + result[i] = v; \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ + [](std::string& outValue, __TYPE__ inValue) -> bool { \ + outValue = "{"; \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) \ + outValue += std::to_string(inValue[i]) + ","; \ + outValue.pop_back(); \ + outValue += "}"; \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(UVec3Property, glm::uvec3, glm::uvec3(0), + glm::uvec3(numeric_limits::lowest()), + glm::uvec3(numeric_limits::max()), + glm::uvec3(1), + DEFAULT_FROM_LUA_LAMBDA(glm::uvec3, lua_tonumber, + lua_isnumber), + DEFAULT_TO_LUA_LAMBDA(glm::uvec3), + DEFAULT_FROM_STRING_LAMBDA(glm::uvec3), + DEFAULT_TO_STRING_LAMBDA(glm::uvec3), + LUA_TTABLE); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/vector/uvec4property.cpp b/src/properties/vector/uvec4property.cpp new file mode 100644 index 0000000000..333907eb7c --- /dev/null +++ b/src/properties/vector/uvec4property.cpp @@ -0,0 +1,117 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include +#include +#include + +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(__TYPE__, __CONVFUNC__, __TESTFUNC__) \ + [](lua_State * state, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + lua_pushnil(state); \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + int success = lua_next(state, -2); \ + if (success != 1) { \ + success = false; \ + return __TYPE__(0); \ + } \ + if (__TESTFUNC__(state, -1) != 1) { \ + success = false; \ + return __TYPE__(0); \ + } else { \ + result[i] = static_cast<__TYPE__::value_type>(__CONVFUNC__(state, -1)); \ + lua_pop(state, 1); \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_LUA_LAMBDA(__TYPE__) \ + [](lua_State * state, __TYPE__ value) -> bool { \ + lua_newtable(state); \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + lua_pushnumber(state, static_cast(value[i])); \ + lua_setfield(state, -2, std::to_string(number).c_str()); \ + ++number; \ + } \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(__TYPE__) \ + [](std::string value, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + std::vector tokens = ghoul::tokenizeString(value, ','); \ + if (tokens.size() != result.length()) { \ + success = false; \ + return result; \ + } \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + std::stringstream s(tokens[i]); \ + __TYPE__::value_type v; \ + s >> v; \ + if (s.fail()) { \ + success = false; \ + return result; \ + } \ + else \ + result[i] = v; \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ + [](std::string& outValue, __TYPE__ inValue) -> bool { \ + outValue = "{"; \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) \ + outValue += std::to_string(inValue[i]) + ","; \ + outValue.pop_back(); \ + outValue += "}"; \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(UVec4Property, glm::uvec4, glm::uvec4(0), + glm::uvec4(numeric_limits::lowest()), + glm::uvec4(numeric_limits::max()), + glm::uvec4(1), + DEFAULT_FROM_LUA_LAMBDA(glm::uvec4, lua_tonumber, + lua_isnumber), + DEFAULT_TO_LUA_LAMBDA(glm::uvec4), + DEFAULT_FROM_STRING_LAMBDA(glm::uvec4), + DEFAULT_TO_STRING_LAMBDA(glm::uvec4), + LUA_TTABLE); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/vector/vec2property.cpp b/src/properties/vector/vec2property.cpp new file mode 100644 index 0000000000..4cef6f2c28 --- /dev/null +++ b/src/properties/vector/vec2property.cpp @@ -0,0 +1,117 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include +#include +#include + +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(__TYPE__, __CONVFUNC__, __TESTFUNC__) \ + [](lua_State * state, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + lua_pushnil(state); \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + int success = lua_next(state, -2); \ + if (success != 1) { \ + success = false; \ + return __TYPE__(0); \ + } \ + if (__TESTFUNC__(state, -1) != 1) { \ + success = false; \ + return __TYPE__(0); \ + } else { \ + result[i] = static_cast<__TYPE__::value_type>(__CONVFUNC__(state, -1)); \ + lua_pop(state, 1); \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_LUA_LAMBDA(__TYPE__) \ + [](lua_State * state, __TYPE__ value) -> bool { \ + lua_newtable(state); \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + lua_pushnumber(state, static_cast(value[i])); \ + lua_setfield(state, -2, std::to_string(number).c_str()); \ + ++number; \ + } \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(__TYPE__) \ + [](std::string value, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + std::vector tokens = ghoul::tokenizeString(value, ','); \ + if (tokens.size() != result.length()) { \ + success = false; \ + return result; \ + } \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + std::stringstream s(tokens[i]); \ + __TYPE__::value_type v; \ + s >> v; \ + if (s.fail()) { \ + success = false; \ + return result; \ + } \ + else \ + result[i] = v; \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ + [](std::string& outValue, __TYPE__ inValue) -> bool { \ + outValue = "{"; \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) \ + outValue += std::to_string(inValue[i]) + ","; \ + outValue.pop_back(); \ + outValue += "}"; \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(Vec2Property, glm::vec2, glm::vec2(0), + glm::vec2(numeric_limits::lowest()), + glm::vec2(numeric_limits::max()), + glm::vec2(0.01f), + DEFAULT_FROM_LUA_LAMBDA(glm::vec2, lua_tonumber, + lua_isnumber), + DEFAULT_TO_LUA_LAMBDA(glm::vec2), + DEFAULT_FROM_STRING_LAMBDA(glm::vec2), + DEFAULT_TO_STRING_LAMBDA(glm::vec2), + LUA_TTABLE); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/vector/vec3property.cpp b/src/properties/vector/vec3property.cpp new file mode 100644 index 0000000000..3c237bea2a --- /dev/null +++ b/src/properties/vector/vec3property.cpp @@ -0,0 +1,117 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include +#include +#include + +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(__TYPE__, __CONVFUNC__, __TESTFUNC__) \ + [](lua_State * state, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + lua_pushnil(state); \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + int success = lua_next(state, -2); \ + if (success != 1) { \ + success = false; \ + return __TYPE__(0); \ + } \ + if (__TESTFUNC__(state, -1) != 1) { \ + success = false; \ + return __TYPE__(0); \ + } else { \ + result[i] = static_cast<__TYPE__::value_type>(__CONVFUNC__(state, -1)); \ + lua_pop(state, 1); \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_LUA_LAMBDA(__TYPE__) \ + [](lua_State * state, __TYPE__ value) -> bool { \ + lua_newtable(state); \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + lua_pushnumber(state, static_cast(value[i])); \ + lua_setfield(state, -2, std::to_string(number).c_str()); \ + ++number; \ + } \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(__TYPE__) \ + [](std::string value, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + std::vector tokens = ghoul::tokenizeString(value, ','); \ + if (tokens.size() != result.length()) { \ + success = false; \ + return result; \ + } \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + std::stringstream s(tokens[i]); \ + __TYPE__::value_type v; \ + s >> v; \ + if (s.fail()) { \ + success = false; \ + return result; \ + } \ + else \ + result[i] = v; \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ + [](std::string& outValue, __TYPE__ inValue) -> bool { \ + outValue = "{"; \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) \ + outValue += std::to_string(inValue[i]) + ","; \ + outValue.pop_back(); \ + outValue += "}"; \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(Vec3Property, glm::vec3, glm::vec3(0), + glm::vec3(numeric_limits::lowest()), + glm::vec3(numeric_limits::max()), + glm::vec3(0.01f), + DEFAULT_FROM_LUA_LAMBDA(glm::vec3, lua_tonumber, + lua_isnumber), + DEFAULT_TO_LUA_LAMBDA(glm::vec3), + DEFAULT_FROM_STRING_LAMBDA(glm::vec3), + DEFAULT_TO_STRING_LAMBDA(glm::vec3), + LUA_TTABLE); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/vector/vec4property.cpp b/src/properties/vector/vec4property.cpp new file mode 100644 index 0000000000..196fc28036 --- /dev/null +++ b/src/properties/vector/vec4property.cpp @@ -0,0 +1,117 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include +#include +#include + +#include + +using std::numeric_limits; + +namespace openspace { +namespace properties { + +#define DEFAULT_FROM_LUA_LAMBDA(__TYPE__, __CONVFUNC__, __TESTFUNC__) \ + [](lua_State * state, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + lua_pushnil(state); \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + int success = lua_next(state, -2); \ + if (success != 1) { \ + success = false; \ + return __TYPE__(0); \ + } \ + if (__TESTFUNC__(state, -1) != 1) { \ + success = false; \ + return __TYPE__(0); \ + } else { \ + result[i] = static_cast<__TYPE__::value_type>(__CONVFUNC__(state, -1)); \ + lua_pop(state, 1); \ + } \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_LUA_LAMBDA(__TYPE__) \ + [](lua_State * state, __TYPE__ value) -> bool { \ + lua_newtable(state); \ + int number = 1; \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + lua_pushnumber(state, static_cast(value[i])); \ + lua_setfield(state, -2, std::to_string(number).c_str()); \ + ++number; \ + } \ + return true; \ + } + +#define DEFAULT_FROM_STRING_LAMBDA(__TYPE__) \ + [](std::string value, bool& success) -> __TYPE__ { \ + __TYPE__ result; \ + std::vector tokens = ghoul::tokenizeString(value, ','); \ + if (tokens.size() != result.length()) { \ + success = false; \ + return result; \ + } \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ + std::stringstream s(tokens[i]); \ + __TYPE__::value_type v; \ + s >> v; \ + if (s.fail()) { \ + success = false; \ + return result; \ + } \ + else \ + result[i] = v; \ + } \ + success = true; \ + return result; \ + } + +#define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ + [](std::string& outValue, __TYPE__ inValue) -> bool { \ + outValue = "{"; \ + for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) \ + outValue += std::to_string(inValue[i]) + ","; \ + outValue.pop_back(); \ + outValue += "}"; \ + return true; \ + } + +REGISTER_NUMERICALPROPERTY_SOURCE(Vec4Property, glm::vec4, glm::vec4(0), + glm::vec4(numeric_limits::lowest()), + glm::vec4(numeric_limits::max()), + glm::vec4(0.01f), + DEFAULT_FROM_LUA_LAMBDA(glm::vec4, lua_tonumber, + lua_isnumber), + DEFAULT_TO_LUA_LAMBDA(glm::vec4), + DEFAULT_FROM_STRING_LAMBDA(glm::vec4), + DEFAULT_TO_STRING_LAMBDA(glm::vec4), + LUA_TTABLE); + +} // namespace properties +} // namespace openspace diff --git a/src/properties/vectorproperty.cpp b/src/properties/vectorproperty.cpp deleted file mode 100644 index 22ce875f6b..0000000000 --- a/src/properties/vectorproperty.cpp +++ /dev/null @@ -1,271 +0,0 @@ -/***************************************************************************************** - * * - * OpenSpace * - * * - * Copyright (c) 2014-2016 * - * * - * 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/vectorproperty.h" - -#include -#include -#include - -#include - -using std::numeric_limits; - -namespace openspace { -namespace properties { - -#define DEFAULT_FROM_LUA_LAMBDA(__TYPE__, __CONVFUNC__, __TESTFUNC__) \ - [](lua_State * state, bool& success) -> __TYPE__ { \ - __TYPE__ result; \ - lua_pushnil(state); \ - for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ - int success = lua_next(state, -2); \ - if (success != 1) { \ - success = false; \ - return __TYPE__(0); \ - } \ - if (__TESTFUNC__(state, -1) != 1) { \ - success = false; \ - return __TYPE__(0); \ - } else { \ - result[i] = static_cast<__TYPE__::value_type>(__CONVFUNC__(state, -1)); \ - lua_pop(state, 1); \ - } \ - } \ - success = true; \ - return result; \ - } - -#define DEFAULT_TO_LUA_LAMBDA(__TYPE__) \ - [](lua_State * state, __TYPE__ value) -> bool { \ - lua_newtable(state); \ - int number = 1; \ - for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ - lua_pushnumber(state, static_cast(value[i])); \ - lua_setfield(state, -2, std::to_string(number).c_str()); \ - ++number; \ - } \ - return true; \ - } - -#define DEFAULT_FROM_STRING_LAMBDA(__TYPE__) \ - [](std::string value, bool& success) -> __TYPE__ { \ - __TYPE__ result; \ - std::vector tokens = ghoul::tokenizeString(value, ','); \ - if (tokens.size() != result.length()) { \ - success = false; \ - return result; \ - } \ - for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) { \ - std::stringstream s(tokens[i]); \ - __TYPE__::value_type v; \ - s >> v; \ - if (s.fail()) { \ - success = false; \ - return result; \ - } \ - else \ - result[i] = v; \ - } \ - success = true; \ - return result; \ - } - -#define DEFAULT_TO_STRING_LAMBDA(__TYPE__) \ - [](std::string& outValue, __TYPE__ inValue) -> bool { \ - outValue = "{"; \ - for (glm::length_t i = 0; i < ghoul::glm_components<__TYPE__>::value; ++i) \ - outValue += std::to_string(inValue[i]) + ","; \ - outValue.pop_back(); \ - outValue += "}"; \ - return true; \ - } - - -// Forcing value from int to bool is acceptable here (line 48) -#ifdef WIN32 -#pragma warning(disable : 4800) -#endif - - -REGISTER_TEMPLATEPROPERTY_SOURCE(BVec2Property, glm::bvec2, glm::bvec2(false), - DEFAULT_FROM_LUA_LAMBDA(glm::bvec2, lua_toboolean, - lua_isboolean), - DEFAULT_TO_LUA_LAMBDA(glm::bvec2), - DEFAULT_FROM_STRING_LAMBDA(glm::bvec2), - DEFAULT_TO_STRING_LAMBDA(glm::bvec2), - LUA_TTABLE); - -REGISTER_TEMPLATEPROPERTY_SOURCE(BVec3Property, glm::bvec3, glm::bvec3(false), - DEFAULT_FROM_LUA_LAMBDA(glm::bvec3, lua_toboolean, - lua_isboolean), - DEFAULT_TO_LUA_LAMBDA(glm::bvec3), - DEFAULT_FROM_STRING_LAMBDA(glm::bvec3), - DEFAULT_TO_STRING_LAMBDA(glm::bvec3), - LUA_TTABLE); - -REGISTER_TEMPLATEPROPERTY_SOURCE(BVec4Property, glm::bvec4, glm::bvec4(false), - DEFAULT_FROM_LUA_LAMBDA(glm::bvec4, lua_toboolean, - lua_isboolean), - DEFAULT_TO_LUA_LAMBDA(glm::bvec4), - DEFAULT_FROM_STRING_LAMBDA(glm::bvec4), - DEFAULT_TO_STRING_LAMBDA(glm::bvec4), - LUA_TTABLE); - -#ifdef WIN32 -#pragma warning(default : 4800) -#endif - - -REGISTER_NUMERICALPROPERTY_SOURCE(Vec2Property, glm::vec2, glm::vec2(0), - glm::vec2(numeric_limits::lowest()), - glm::vec2(numeric_limits::max()), - glm::vec2(0.01f), - DEFAULT_FROM_LUA_LAMBDA(glm::vec2, lua_tonumber, - lua_isnumber), - DEFAULT_TO_LUA_LAMBDA(glm::vec2), - DEFAULT_FROM_STRING_LAMBDA(glm::vec2), - DEFAULT_TO_STRING_LAMBDA(glm::vec2), - LUA_TTABLE); - -REGISTER_NUMERICALPROPERTY_SOURCE(Vec3Property, glm::vec3, glm::vec3(0), - glm::vec3(numeric_limits::lowest()), - glm::vec3(numeric_limits::max()), - glm::vec3(0.01f), - DEFAULT_FROM_LUA_LAMBDA(glm::vec3, lua_tonumber, - lua_isnumber), - DEFAULT_TO_LUA_LAMBDA(glm::vec3), - DEFAULT_FROM_STRING_LAMBDA(glm::vec3), - DEFAULT_TO_STRING_LAMBDA(glm::vec3), - LUA_TTABLE); - -REGISTER_NUMERICALPROPERTY_SOURCE(Vec4Property, glm::vec4, glm::vec4(0), - glm::vec4(numeric_limits::lowest()), - glm::vec4(numeric_limits::max()), - glm::vec4(0.01f), - DEFAULT_FROM_LUA_LAMBDA(glm::vec4, lua_tonumber, - lua_isnumber), - DEFAULT_TO_LUA_LAMBDA(glm::vec4), - DEFAULT_FROM_STRING_LAMBDA(glm::vec4), - DEFAULT_TO_STRING_LAMBDA(glm::vec4), - LUA_TTABLE); - -REGISTER_NUMERICALPROPERTY_SOURCE(DVec2Property, glm::dvec2, glm::dvec2(0), - glm::dvec2(numeric_limits::lowest()), - glm::dvec2(numeric_limits::max()), - glm::dvec2(0.01), - DEFAULT_FROM_LUA_LAMBDA(glm::dvec2, lua_tonumber, - lua_isnumber), - DEFAULT_TO_LUA_LAMBDA(glm::dvec2), - DEFAULT_FROM_STRING_LAMBDA(glm::dvec2), - DEFAULT_TO_STRING_LAMBDA(glm::dvec2), - LUA_TTABLE); - -REGISTER_NUMERICALPROPERTY_SOURCE(DVec3Property, glm::dvec3, glm::dvec3(0), - glm::dvec3(numeric_limits::lowest()), - glm::dvec3(numeric_limits::max()), - glm::dvec3(0.01), - DEFAULT_FROM_LUA_LAMBDA(glm::dvec3, lua_tonumber, - lua_isnumber), - DEFAULT_TO_LUA_LAMBDA(glm::dvec3), - DEFAULT_FROM_STRING_LAMBDA(glm::dvec3), - DEFAULT_TO_STRING_LAMBDA(glm::dvec3), - LUA_TTABLE); - -REGISTER_NUMERICALPROPERTY_SOURCE(DVec4Property, glm::dvec4, glm::dvec4(0), - glm::dvec4(numeric_limits::lowest()), - glm::dvec4(numeric_limits::max()), - glm::dvec4(0.01), - DEFAULT_FROM_LUA_LAMBDA(glm::dvec4, lua_tonumber, - lua_isnumber), - DEFAULT_TO_LUA_LAMBDA(glm::dvec4), - DEFAULT_FROM_STRING_LAMBDA(glm::dvec4), - DEFAULT_TO_STRING_LAMBDA(glm::dvec4), - LUA_TTABLE); - -REGISTER_NUMERICALPROPERTY_SOURCE(IVec2Property, glm::ivec2, glm::ivec2(0), - glm::ivec2(numeric_limits::lowest()), - glm::ivec2(numeric_limits::max()), glm::ivec2(1), - DEFAULT_FROM_LUA_LAMBDA(glm::ivec2, lua_tonumber, - lua_isnumber), - DEFAULT_TO_LUA_LAMBDA(glm::ivec2), - DEFAULT_FROM_STRING_LAMBDA(glm::ivec2), - DEFAULT_TO_STRING_LAMBDA(glm::ivec2), - LUA_TTABLE); - -REGISTER_NUMERICALPROPERTY_SOURCE(IVec3Property, glm::ivec3, glm::ivec3(0), - glm::ivec3(numeric_limits::lowest()), - glm::ivec3(numeric_limits::max()), glm::ivec3(1), - DEFAULT_FROM_LUA_LAMBDA(glm::ivec3, lua_tonumber, - lua_isnumber), - DEFAULT_TO_LUA_LAMBDA(glm::ivec3), - DEFAULT_FROM_STRING_LAMBDA(glm::ivec3), - DEFAULT_TO_STRING_LAMBDA(glm::ivec3), - LUA_TTABLE); - -REGISTER_NUMERICALPROPERTY_SOURCE(IVec4Property, glm::ivec4, glm::ivec4(0), - glm::ivec4(numeric_limits::lowest()), - glm::ivec4(numeric_limits::max()), glm::ivec4(1), - DEFAULT_FROM_LUA_LAMBDA(glm::ivec4, lua_tonumber, - lua_isnumber), - DEFAULT_TO_LUA_LAMBDA(glm::ivec4), - DEFAULT_FROM_STRING_LAMBDA(glm::ivec4), - DEFAULT_TO_STRING_LAMBDA(glm::ivec4), - LUA_TTABLE); - -REGISTER_NUMERICALPROPERTY_SOURCE(UVec2Property, glm::uvec2, glm::uvec2(0), - glm::uvec2(numeric_limits::lowest()), - glm::uvec2(numeric_limits::max()), - glm::uvec2(1), - DEFAULT_FROM_LUA_LAMBDA(glm::uvec2, lua_tonumber, - lua_isnumber), - DEFAULT_TO_LUA_LAMBDA(glm::uvec2), - DEFAULT_FROM_STRING_LAMBDA(glm::uvec2), - DEFAULT_TO_STRING_LAMBDA(glm::uvec2), - LUA_TTABLE); - -REGISTER_NUMERICALPROPERTY_SOURCE(UVec3Property, glm::uvec3, glm::uvec3(0), - glm::uvec3(numeric_limits::lowest()), - glm::uvec3(numeric_limits::max()), - glm::uvec3(1), - DEFAULT_FROM_LUA_LAMBDA(glm::uvec3, lua_tonumber, - lua_isnumber), - DEFAULT_TO_LUA_LAMBDA(glm::uvec3), - DEFAULT_FROM_STRING_LAMBDA(glm::uvec3), - DEFAULT_TO_STRING_LAMBDA(glm::uvec3), - LUA_TTABLE); - -REGISTER_NUMERICALPROPERTY_SOURCE(UVec4Property, glm::uvec4, glm::uvec4(0), - glm::uvec4(numeric_limits::lowest()), - glm::uvec4(numeric_limits::max()), - glm::uvec4(1), - DEFAULT_FROM_LUA_LAMBDA(glm::uvec4, lua_tonumber, - lua_isnumber), - DEFAULT_TO_LUA_LAMBDA(glm::uvec4), - DEFAULT_FROM_STRING_LAMBDA(glm::uvec4), - DEFAULT_TO_STRING_LAMBDA(glm::uvec4), - LUA_TTABLE); - -} // namespace properties -} // namespace openspace From ee8d129da6469aeb653f8bff86ad8f52fcd5dcf0 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Mon, 28 Nov 2016 14:20:32 +0100 Subject: [PATCH 7/9] Update Ghoul and SGCT repository --- ext/ghoul | 2 +- ext/sgct | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ext/ghoul b/ext/ghoul index 4301855146..722704f61d 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 4301855146b5aaaeed7960e628839d59cd4d5f06 +Subproject commit 722704f61d3750161936ebb41c36d96282e7f662 diff --git a/ext/sgct b/ext/sgct index c7f321dd50..d47e9d6d1d 160000 --- a/ext/sgct +++ b/ext/sgct @@ -1 +1 @@ -Subproject commit c7f321dd504c184e6ac65d26b33aec2f7699c476 +Subproject commit d47e9d6d1d55a1730a6f3a8f58abee4a4a0b95de From fe436748bfb5c4a3241e2e65b779a34b2e21c7fd Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Fri, 2 Dec 2016 15:05:49 +0100 Subject: [PATCH 8/9] Implementing Translation classes for Keplerian elements as well as two-line element formats (#172) --- apps/Launcher/CMakeLists.txt | 2 +- data/scene/earth/earth.mod | 11 + include/openspace/scene/translation.h | 9 + modules/base/CMakeLists.txt | 4 + modules/base/basemodule.cpp | 4 + modules/base/rendering/renderableplanet.cpp | 2 +- modules/base/rendering/renderabletrail.cpp | 1 + .../base/rendering/renderabletrailorbit.cpp | 12 +- .../rendering/renderabletrailtrajectory.cpp | 4 + modules/base/rotation/spicerotation.cpp | 16 +- .../base/translation/keplertranslation.cpp | 378 ++++++++++++++++++ modules/base/translation/keplertranslation.h | 177 ++++++++ modules/base/translation/spicetranslation.cpp | 10 + modules/base/translation/tletranslation.cpp | 374 +++++++++++++++++ modules/base/translation/tletranslation.h | 75 ++++ .../onscreengui/src/guipropertycomponent.cpp | 3 +- src/scene/translation.cpp | 9 + 17 files changed, 1070 insertions(+), 21 deletions(-) create mode 100644 modules/base/translation/keplertranslation.cpp create mode 100644 modules/base/translation/keplertranslation.h create mode 100644 modules/base/translation/tletranslation.cpp create mode 100644 modules/base/translation/tletranslation.h diff --git a/apps/Launcher/CMakeLists.txt b/apps/Launcher/CMakeLists.txt index 34affa1004..a17a8dbe36 100644 --- a/apps/Launcher/CMakeLists.txt +++ b/apps/Launcher/CMakeLists.txt @@ -74,4 +74,4 @@ endif () # Libtorrent include_external_library(${APPLICATION_NAME} libtorrent ${application_path}/ext/libtorrent) -target_include_directories(${APPLICATION_NAME} PUBLIC SYSTEM ${application_path}/ext/libtorrent/include) +target_include_directories(${APPLICATION_NAME} SYSTEM PUBLIC ${application_path}/ext/libtorrent/include) diff --git a/data/scene/earth/earth.mod b/data/scene/earth/earth.mod index 902eefcdfc..f3dbe2bd77 100644 --- a/data/scene/earth/earth.mod +++ b/data/scene/earth/earth.mod @@ -12,6 +12,17 @@ return { } } }, + -- The default reference frame for Earth-orbiting satellites + Name = "EarthInertial", + Parent = "EarthBarycenter", + Transform = { + Rotation = { + Type = "SpiceRotation", + SourceFrame = "J2000", + DestinationFrame = "GALACTIC", + } + }, + }, -- Earth module { Name = "Earth", diff --git a/include/openspace/scene/translation.h b/include/openspace/scene/translation.h index 2fba7f86e8..7d7809e65f 100644 --- a/include/openspace/scene/translation.h +++ b/include/openspace/scene/translation.h @@ -46,7 +46,16 @@ public: glm::dvec3 position(double time); + // Registers a callback that gets called when a significant change has been made that + // invalidates potentially stored points, for example in trails + void onParameterChange(std::function callback); + static openspace::Documentation Documentation(); + +protected: + void notifyObservers(); + + std::function _onParameterChangeCallback; }; } // namespace openspace diff --git a/modules/base/CMakeLists.txt b/modules/base/CMakeLists.txt index 3218c1352d..2a0a2f4f1a 100644 --- a/modules/base/CMakeLists.txt +++ b/modules/base/CMakeLists.txt @@ -43,8 +43,10 @@ set(HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/rendering/simplespheregeometry.h ${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceframebuffer.h ${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceimage.h + ${CMAKE_CURRENT_SOURCE_DIR}/translation/keplertranslation.h ${CMAKE_CURRENT_SOURCE_DIR}/translation/spicetranslation.h ${CMAKE_CURRENT_SOURCE_DIR}/translation/statictranslation.h + ${CMAKE_CURRENT_SOURCE_DIR}/translation/tletranslation.h ${CMAKE_CURRENT_SOURCE_DIR}/rotation/spicerotation.h ${CMAKE_CURRENT_SOURCE_DIR}/rotation/staticrotation.h ${CMAKE_CURRENT_SOURCE_DIR}/scale/staticscale.h @@ -70,8 +72,10 @@ set(SOURCE_FILES ${CMAKE_CURRENT_SOURCE_DIR}/rendering/simplespheregeometry.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceframebuffer.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rendering/screenspaceimage.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/translation/keplertranslation.cpp ${CMAKE_CURRENT_SOURCE_DIR}/translation/spicetranslation.cpp ${CMAKE_CURRENT_SOURCE_DIR}/translation/statictranslation.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/translation/tletranslation.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rotation/spicerotation.cpp ${CMAKE_CURRENT_SOURCE_DIR}/rotation/staticrotation.cpp ${CMAKE_CURRENT_SOURCE_DIR}/scale/staticscale.cpp diff --git a/modules/base/basemodule.cpp b/modules/base/basemodule.cpp index 7db855fb09..535a8daa24 100644 --- a/modules/base/basemodule.cpp +++ b/modules/base/basemodule.cpp @@ -48,8 +48,10 @@ #include #include +#include #include #include +#include #include #include @@ -111,8 +113,10 @@ void BaseModule::internalInitialize() { auto fTranslation = FactoryManager::ref().factory(); ghoul_assert(fTranslation, "Ephemeris factory was not created"); + fTranslation->registerClass("KeplerTranslation"); fTranslation->registerClass("StaticTranslation"); fTranslation->registerClass("SpiceTranslation"); + fTranslation->registerClass("TLETranslation"); auto fRotation = FactoryManager::ref().factory(); ghoul_assert(fRotation, "Rotation factory was not created"); diff --git a/modules/base/rendering/renderableplanet.cpp b/modules/base/rendering/renderableplanet.cpp index 1a4ae0d7a9..fdccd9920e 100644 --- a/modules/base/rendering/renderableplanet.cpp +++ b/modules/base/rendering/renderableplanet.cpp @@ -349,7 +349,7 @@ void RenderablePlanet::render(const RenderData& data) { glm::dmat4 rot = glm::rotate(glm::dmat4(1.0), M_PI_2, glm::dvec3(1, 0, 0)); glm::dmat4 roty = glm::rotate(glm::dmat4(1.0), M_PI_2, glm::dvec3(0, -1, 0)); //glm::dmat4 rotProp = glm::rotate(glm::dmat4(1.0), glm::radians(static_cast(_rotation)), glm::dvec3(0, 1, 0)); - modelTransform = modelTransform * rot /** roty*/ /** rotProp*/; + modelTransform = modelTransform * rot * roty /** rotProp*/; glm::dmat4 modelViewTransform = data.camera.combinedViewMatrix() * modelTransform; diff --git a/modules/base/rendering/renderabletrail.cpp b/modules/base/rendering/renderabletrail.cpp index b150cbb871..181a05ce9a 100644 --- a/modules/base/rendering/renderabletrail.cpp +++ b/modules/base/rendering/renderabletrail.cpp @@ -143,6 +143,7 @@ RenderableTrail::RenderableTrail(const ghoul::Dictionary& dictionary) _translation = std::unique_ptr(Translation::createFromDictionary( dictionary.value(KeyTranslation) )); + addPropertySubOwner(_translation.get()); _lineColor = dictionary.value(KeyColor); addProperty(_lineColor); diff --git a/modules/base/rendering/renderabletrailorbit.cpp b/modules/base/rendering/renderabletrailorbit.cpp index ca154b3607..7215c17ab0 100644 --- a/modules/base/rendering/renderabletrailorbit.cpp +++ b/modules/base/rendering/renderabletrailorbit.cpp @@ -131,7 +131,7 @@ openspace::Documentation RenderableTrailOrbit::Documentation() { RenderableTrailOrbit::RenderableTrailOrbit(const ghoul::Dictionary& dictionary) : RenderableTrail(dictionary) , _period("period", "Period in days", 0.0, 0.0, 1e9) - , _resolution("resoluion", "Number of Samples along Orbit", 10000, 1, 1e6) + , _resolution("resolution", "Number of Samples along Orbit", 10000, 1, 1e6) , _needsFullSweep(true) , _indexBufferDirty(true) { @@ -141,6 +141,10 @@ RenderableTrailOrbit::RenderableTrailOrbit(const ghoul::Dictionary& dictionary) "RenderableTrailOrbit" ); + _translation->onParameterChange([this](){ + _needsFullSweep = true; + }); + // Period is in days using namespace std::chrono; int factor = duration_cast(hours(24)).count(); @@ -180,12 +184,6 @@ void RenderableTrailOrbit::update(const UpdateData& data) { // 2. Update floating position // 3. Determine which parts of the array to upload and upload the data - // Early bailout when we don't move in time - if (data.timePaused || data.delta == 0.0) { - return; - } - - // 1 // Update the trails; the report contains whether any of the other values has been // touched and if so, how many diff --git a/modules/base/rendering/renderabletrailtrajectory.cpp b/modules/base/rendering/renderabletrailtrajectory.cpp index 9aa9d1606e..1cbf3e830d 100644 --- a/modules/base/rendering/renderabletrailtrajectory.cpp +++ b/modules/base/rendering/renderabletrailtrajectory.cpp @@ -140,6 +140,10 @@ RenderableTrailTrajectory::RenderableTrailTrajectory(const ghoul::Dictionary& di "RenderableTrailTrajectory" ); + _translation->onParameterChange([this]() { + _needsFullSweep = true; + }); + _startTime = dictionary.value(KeyStartTime); _startTime.onChange([this] { _needsFullSweep = true; }); addProperty(_startTime); diff --git a/modules/base/rotation/spicerotation.cpp b/modules/base/rotation/spicerotation.cpp index 76aaf6dbf3..e1179820d8 100644 --- a/modules/base/rotation/spicerotation.cpp +++ b/modules/base/rotation/spicerotation.cpp @@ -116,17 +116,11 @@ SpiceRotation::SpiceRotation(const ghoul::Dictionary& dictionary) } void SpiceRotation::update(const UpdateData& data) { - try { - _matrix = SpiceManager::ref().positionTransformMatrix( - _sourceFrame, - _destinationFrame, - data.time - ); - } - catch (const ghoul::RuntimeError&) { - // In case of missing coverage - _matrix = glm::dmat3(1); - } + _matrix = SpiceManager::ref().positionTransformMatrix( + _sourceFrame, + _destinationFrame, + data.time + ); } } // namespace openspace diff --git a/modules/base/translation/keplertranslation.cpp b/modules/base/translation/keplertranslation.cpp new file mode 100644 index 0000000000..4e3616f789 --- /dev/null +++ b/modules/base/translation/keplertranslation.cpp @@ -0,0 +1,378 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include +#include + +#include + +namespace { + + const char* KeyEccentricity = "Eccentricity"; + const char* KeySemiMajorAxis = "SemiMajorAxis"; + const char* KeyInclination = "Inclination"; + const char* KeyAscendingNode = "AscendingNode"; + const char* KeyArgumentOfPeriapsis = "ArgumentOfPeriapsis"; + const char* KeyMeanAnomaly = "MeanAnomaly"; + const char* KeyEpoch = "Epoch"; + const char* KeyPeriod = "Period"; + + +template +T solveIteration(Func function, T x0, const T& err = 0.0, int maxIterations = 100) { + T x = 0; + T x2 = x0; + + for (int i = 0; i < maxIterations; ++i) { + x = x2; + x2 = function(x); + if (abs(x2 - x) < err) { + return x2; + } + } + + return x2; +} +} // namespace + +namespace openspace { + +KeplerTranslation::RangeError::RangeError(std::string offender) + : ghoul::RuntimeError("Value '" + offender + "' out of range", "KeplerTranslation") + , offender(std::move(offender)) +{} + +Documentation KeplerTranslation::Documentation() { + using namespace openspace::documentation; + return{ + "Kepler Translation", + "base_transform_kepler", + { + { + "Type", + new StringEqualVerifier("KeplerTranslation"), + "", + Optional::No + }, + { + KeyEccentricity, + new DoubleInRangeVerifier(0.0, 1.0), + "Specifies the eccentricity of the orbit; currently, OpenSpace does not " + "support hyperbolic orbits using Keplerian elements.", + Optional::No + }, + { + KeySemiMajorAxis, + new DoubleVerifier, + "Specifies the semi-major axis of the orbit in kilometers (semi-major " + "axis = average of periapsis and apoapsis).", + Optional::No + }, + { + KeyInclination, + new DoubleInRangeVerifier(0.0, 360.0), + "Specifies the inclination angle (degrees) of the orbit relative to the " + "reference plane (in the case of Earth, the equatorial plane.", + Optional::No + }, + { + KeyAscendingNode, + new DoubleInRangeVerifier(0.0, 360.0), + "Specifies the right ascension of the ascending node (in degrees!) " + "relative to the vernal equinox.", + Optional::No + }, + { + KeyArgumentOfPeriapsis, + new DoubleInRangeVerifier(0.0, 360.0), + "Specifies the argument of periapsis as angle (in degrees) from the " + "ascending.", + Optional::No + }, + { + KeyMeanAnomaly, + new DoubleInRangeVerifier(0.0, 360.0), + "Specifies the position of the orbiting body (in degrees) along the " + "elliptical orbit at epoch time.", + Optional::No + }, + { + KeyEpoch, + new StringVerifier, + "Specifies the epoch time used for position as a string of the form: " + "YYYY MM DD HH:mm:ss", + Optional::No + }, + { + KeyPeriod, + new DoubleGreaterVerifier(0.0), + "Specifies the orbital period (in seconds).", + Optional::No + }, + }, + Exhaustive::Yes + }; +} + +KeplerTranslation::KeplerTranslation() + : Translation() + , _eccentricity("eccentricity", "Eccentricity", 0.0, 0.0, 1.0) + , _semiMajorAxis("semimajorAxis", "Semi-major axis", 0.0, 0.0, 1e6) + , _inclination("inclination", "Inclination", 0.0, 0.0, 360.0) + , _ascendingNode( + "ascendingNode", + "Right ascension of ascending Node", + 0.0, + 0.0, + 360.0 + ) + , _argumentOfPeriapsis( + "argumentOfPeriapsis", + "Argument of Periapsis", + 0.0, + 0.0, + 360.0 + ) + , _meanAnomalyAtEpoch("meanAnomalyAtEpoch", "Mean anomaly at epoch", 0.0, 0.0, 360.0) + , _epoch("epoch", "Epoch", 0.0, 0.0, 1e9) + , _period("period", "Orbit period", 0.0, 0.0, 1e6) + , _orbitPlaneDirty(true) +{ + auto update = [this]() { + _orbitPlaneDirty = true; + }; + + // Only the eccentricity, semimajor axis, inclination, and location of ascending node + // invalidate the shape of the orbit. The other parameters only determine the location + // the spacecraft on that orbit + _eccentricity.onChange(update); + addProperty(_eccentricity); + + _semiMajorAxis.onChange(update); + addProperty(_semiMajorAxis); + + _inclination.onChange(update); + addProperty(_inclination); + + _ascendingNode.onChange(update); + addProperty(_ascendingNode); + + _argumentOfPeriapsis.onChange(update); + addProperty(_argumentOfPeriapsis); + + addProperty(_meanAnomalyAtEpoch); + addProperty(_epoch); + addProperty(_period); +} + +KeplerTranslation::KeplerTranslation(const ghoul::Dictionary& dictionary) + : KeplerTranslation() +{ + documentation::testSpecificationAndThrow( + Documentation(), + dictionary, + "KeplerTranslation" + ); + + setKeplerElements( + dictionary.value(KeyEccentricity), + dictionary.value(KeySemiMajorAxis), + dictionary.value(KeyInclination), + dictionary.value(KeyAscendingNode), + dictionary.value(KeyArgumentOfPeriapsis), + dictionary.value(KeyMeanAnomaly), + dictionary.value(KeyPeriod), + dictionary.value(KeyEpoch) + ); +} + +glm::dvec3 KeplerTranslation::position() const { + return _position; +} + +double KeplerTranslation::eccentricAnomaly(double meanAnomaly) const { + // Compute the eccentric anomaly (the location of the spacecraft taking the + // eccentricity of the orbit into account) using different solves for the regimes in + // which they are most efficient + + if (_eccentricity == 0.0) { + // In a circular orbit, the eccentric anomaly = mean anomaly + return meanAnomaly; + } + else if (_eccentricity < 0.2) { + auto solver = [this, &meanAnomaly](double x) -> double { + // For low eccentricity, using a first order solver sufficient + return meanAnomaly + _eccentricity * sin(x); + }; + return solveIteration(solver, meanAnomaly, 0.0, 5); + } + else if (_eccentricity < 0.9) { + auto solver = [this, &meanAnomaly](double x) -> double { + double e = _eccentricity; + return x + (meanAnomaly + e * sin(x) - x) / (1.0 - e * cos(x)); + }; + return solveIteration(solver, meanAnomaly, 0.0, 6); + } + else if (_eccentricity < 1.0) { + auto sign = [](double val) -> double { + return val > 0.0 ? 1.0 : ((val < 0.0) ? -1.0 : 0.0); + }; + double e = meanAnomaly + 0.85 * _eccentricity * sign(sin(meanAnomaly)); + + auto solver = [this, &meanAnomaly, &sign](double x) -> double { + double e = _eccentricity; + double s = e * sin(x); + double c = e * cos(x); + double f = x - s - meanAnomaly; + double f1 = 1 - c; + double f2 = s; + return x + (-5 * f / (f1 + sign(f1) * sqrt(abs(16 * f1 * f1 - 20 * f * f2)))); + }; + return solveIteration(solver, e, 0.0, 8); + } +} + +void KeplerTranslation::update(const UpdateData& data) { + if (_orbitPlaneDirty) { + computeOrbitPlane(); + _orbitPlaneDirty = false; + } + + double t = data.time - _epoch; + double meanMotion = 2.0 * glm::pi() / _period; + double meanAnomaly = glm::radians(_meanAnomalyAtEpoch.value()) + t * meanMotion; + double e = eccentricAnomaly(meanAnomaly); + + // Use the eccentric anomaly to compute the actual location + double a = _semiMajorAxis / (1.0 - _eccentricity) * 1000.0; + glm::dvec3 p = { + a * (cos(e) - _eccentricity), + a * sqrt(1.0 - _eccentricity * _eccentricity) * sin(e), + 0.0 + }; + _position = _orbitPlaneRotation * p; +} + +void KeplerTranslation::computeOrbitPlane() { + // We assume the following coordinate system: + // z = axis of rotation + // x = pointing towards the first point of Aries + // y completes the righthanded coordinate system + + // Perform three rotations: + // 1. Around the z axis to place the location of the ascending node + // 2. Around the x axis (now aligned with the ascending node) to get the correct + // inclination + // 3. Around the new z axis to place the closest approach to the correct location + + const glm::vec3 ascendingNodeAxisRot = { 0.f, 0.f, 1.f }; + const glm::vec3 inclinationAxisRot = { 1.f, 0.f, 0.f }; + const glm::vec3 argPeriapsisAxisRot = { 0.f, 0.f, 1.f }; + + const double asc = glm::radians(_ascendingNode.value()); + const double inc = glm::radians(_inclination.value()); + const double per = glm::radians(_argumentOfPeriapsis.value()); + + _orbitPlaneRotation = + glm::rotate(asc, glm::dvec3(ascendingNodeAxisRot)) * + glm::rotate(inc, glm::dvec3(inclinationAxisRot)) * + glm::rotate(per, glm::dvec3(argPeriapsisAxisRot)); + + notifyObservers(); + _orbitPlaneDirty = false; +} + +void KeplerTranslation::setKeplerElements(double eccentricity, double semiMajorAxis, + double inclination, double ascendingNode, + double argumentOfPeriapsis, + double meanAnomalyAtEpoch, + double orbitalPeriod, const std::string& epoch) +{ + setKeplerElements( + eccentricity, + semiMajorAxis, + inclination, + ascendingNode, + argumentOfPeriapsis, + meanAnomalyAtEpoch, + orbitalPeriod, + SpiceManager::ref().ephemerisTimeFromDate(epoch) + ); +} + +void KeplerTranslation::setKeplerElements(double eccentricity, double semiMajorAxis, + double inclination, double ascendingNode, + double argumentOfPeriapsis, + double meanAnomalyAtEpoch, + double orbitalPeriod, double epoch) +{ + auto isInRange = [](double val, double min, double max) -> bool { + return val >= min && val <= max; + }; + + if (isInRange(eccentricity, 0.0, 1.0)) { + _eccentricity = eccentricity; + } + else { + throw RangeError("Eccentricity"); + } + + _semiMajorAxis = semiMajorAxis; + + if (isInRange(inclination, 0.0, 360.0)) { + _inclination = inclination; + } + else { + throw RangeError("Inclination"); + } + + if (isInRange(_ascendingNode, 0.0, 360.0)) { + _ascendingNode = ascendingNode; + } + else { + throw RangeError("Ascending Node"); + } + if (isInRange(_argumentOfPeriapsis, 0.0, 360.0)) { + _argumentOfPeriapsis = argumentOfPeriapsis; + } + else { + throw RangeError("Argument of Periapsis"); + } + + if (isInRange(_meanAnomalyAtEpoch, 0.0, 360.0)) { + _meanAnomalyAtEpoch = meanAnomalyAtEpoch; + } + else { + throw RangeError("Mean anomaly at epoch"); + } + + _period = orbitalPeriod; + _epoch = epoch; + + computeOrbitPlane(); +} + +} // namespace openspace diff --git a/modules/base/translation/keplertranslation.h b/modules/base/translation/keplertranslation.h new file mode 100644 index 0000000000..09c84c8dae --- /dev/null +++ b/modules/base/translation/keplertranslation.h @@ -0,0 +1,177 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __KEPLERTRANSLATION_H__ +#define __KEPLERTRANSLATION_H__ + +#include + +#include + +#include +#include + +namespace openspace { + +/** + * The KeplerTranslation is a concrete Translation implementation that uses the 6 + * Keplerian elements (eccentricity, semi-major axis, inclination, right ascension of the + * ascending node, argument of periapsis, and mean anomaly at epoch) for computing the + * position of a space craft. So far, only eccentricities between [0, 1) are supoorted. + */ +class KeplerTranslation : public Translation { +public: + struct RangeError : public ghoul::RuntimeError { + explicit RangeError(std::string offender); + + std::string offender; + }; + + /** + * The constructor that retrieves the required Keplerian elements from the passed + * \p dictionary. These values are then apssed to the setKeplerElements method for + * further processing. + * The \p dictionary is tested against the Documentation for conformance. + * \param dictionary The ghoul::Dictionary containing all the information about the + * Keplerian elements (see Documentation) + */ + KeplerTranslation(const ghoul::Dictionary& dictionary); + + /// Default destructor + virtual ~KeplerTranslation() = default; + + /** + * This method returns the position of the object at the time that was passed to the + * last call of the #update method. The KeplerTranslation caches its position, thus + * repeated calls to this function are cheap. + * \return The position of the object at the time of last call to the #update method + */ + virtual glm::dvec3 position() const override; + + /** + * Updates the cached position of the object to correspond to the time passed in the + * \p data. + * \param data The UpdateData struct that contains all information necessary to update + * this Translation + */ + void update(const UpdateData& data) override; + + /** + * Method returning the openspace::Documentation that describes the ghoul::Dictinoary + * that can be passed to the constructor. + * \return The openspace::Documentation that describes the ghoul::Dicitonary that can + * be passed to the constructor + */ + static openspace::Documentation Documentation(); + +protected: + /// Default construct that initializes all the properties and member variables + KeplerTranslation(); + + /** + * Sets the internal values for the Keplerian elements and the epoch as a string of + * the form YYYY MM DD HH:mm:ss. + * \param eccentricity The eccentricity of the orbit + * \param semiMajorAxis The semi-major axis of the orbit + * \param inclination The inclination of the orbit relative to the (x-y) reference + * plane (in the case of J2000, the equator) + * \param ascendingNode The right ascension of the ascending node computed relative + * to the x axis (in the case of J2000, the first point of Aries) + * \param argumentOfPeriapsis The location on the orbit with the closes approach + * \param meanAnomalyAtEpoch The location of the space craft on the orbit at the time + * of the \p epoch + * \param orbitalPeriod The period of the orbit in seconds + * \param epoch The epoch to which the orbit is defined as a string of the form: + * YYYY MM DD HH:mm::ss + */ + void setKeplerElements(double eccentricity, double semiMajorAxis, double inclination, + double ascendingNode, double argumentOfPeriapsis, double meanAnomalyAtEpoch, + double orbitalPeriod, const std::string& epoch + ); + + /** + * Sets the internal values for the Keplerian elements and the epoch as seconds past + * J2000 epoch. + * \param eccentricity The eccentricity of the orbit + * \param semiMajorAxis The semi-major axis of the orbit + * \param inclination The inclination of the orbit relative to the (x-y) reference + * plane (in the case of J2000, the equator) + * \param ascendingNode The right ascension of the ascending node computed relative + * to the x axis (in the case of J2000, the first point of Aries) + * \param argumentOfPeriapsis The location on the orbit with the closes approach + * \param meanAnomalyAtEpoch The location of the space craft on the orbit at the time + * of the \p epoch + * \param orbitalPeriod The period of the orbit in seconds + * \param epoch The epoch to which the orbit is defined as number of seconds past the + * J2000 epoch + */ + void setKeplerElements(double eccentricity, double semiMajorAxis, double inclination, + double ascendingNode, double argumentOfPeriapsis, double meanAnomalyAtEpoch, + double orbitalPeriod, double epoch + ); + +private: + /// Recombutes the rotation matrix used in the update method + void computeOrbitPlane(); + + /** + * This method computes the eccentric anomaly (location of the space craft taking the + * eccentricity into acount) based on the mean anomaly (location of the space craft + * assuming an eccentricity of 0.0) + * \param meanAnomaly The mean anomaly for which the eccentric anomaly shall be + * computed + * \return The eccentric anomaly for the provided \p meanAnomaly + */ + double eccentricAnomaly(double meanAnomaly) const; + + /// The eccentricity of the orbit in [0, 1) + properties::DoubleProperty _eccentricity; + /// The semi-major axis in km + properties::DoubleProperty _semiMajorAxis; + /// The inclination of the orbit in [0, 360] + properties::DoubleProperty _inclination; + /// The right ascension of the ascending node in [0, 360] + properties::DoubleProperty _ascendingNode; + /// The argument of periapsis in [0, 360] + properties::DoubleProperty _argumentOfPeriapsis; + /// The mean anomaly at the epoch in [0, 360] + properties::DoubleProperty _meanAnomalyAtEpoch; + + /// The epoch in seconds relative to the J2000 epoch + properties::DoubleProperty _epoch; + /// The period of the orbit in seconds + properties::DoubleProperty _period; + + /// Dirty flag for the _orbitPlaneRotation parameters + bool _orbitPlaneDirty; + /// The rotation matrix that defines the plane of the orbit + glm::dmat3 _orbitPlaneRotation; + + /// The cached position for the last time with which the update method was called + glm::dvec3 _position; +}; + +} // namespace openspace + +#endif // __KEPLERTRANSLATION_H__ diff --git a/modules/base/translation/spicetranslation.cpp b/modules/base/translation/spicetranslation.cpp index 9f3ce6b2c9..5d8a8be05b 100644 --- a/modules/base/translation/spicetranslation.cpp +++ b/modules/base/translation/spicetranslation.cpp @@ -144,8 +144,18 @@ SpiceTranslation::SpiceTranslation(const ghoul::Dictionary& dictionary) } } + auto update = [this](){ + notifyObservers(); + }; + + _target.onChange(update); addProperty(_target); + + _origin.onChange(update); addProperty(_origin); + + _frame.onChange(update); + addProperty(_frame); } glm::dvec3 SpiceTranslation::position() const { diff --git a/modules/base/translation/tletranslation.cpp b/modules/base/translation/tletranslation.cpp new file mode 100644 index 0000000000..13a8f20c0f --- /dev/null +++ b/modules/base/translation/tletranslation.cpp @@ -0,0 +1,374 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 + +#include +#include +#include + +#include +#include +#include + +namespace { + const char* KeyFile = "File"; + + // The list of leap years only goes until 2056 as we need to touch this file then + // again anyway ;) + static const std::vector LeapYears = { + 1956, 1960, 1964, 1968, 1972, 1976, 1980, 1984, 1988, 1992, 1996, + 2000, 2004, 2008, 2012, 2016, 2020, 2024, 2028, 2032, 2036, 2040, + 2044, 2048, 2052, 2056 + }; + + // Count the number of full days since the beginning of 2000 to the beginning of + // the parameter 'year' + int countDays(int year) { + // Find the position of the current year in the vector, the difference + // between its position and the position of 2000 (for J2000) gives the + // number of leap years + const int Epoch = 2000; + const int DaysRegularYear = 365; + const int DaysLeapYear = 366; + + if (year == Epoch) { + return 0; + } + + // Get the position of the most recent leap year + auto lb = std::lower_bound(LeapYears.begin(), LeapYears.end(), year); + + // Get the position of the epoch + auto y2000 = std::find(LeapYears.begin(), LeapYears.end(), Epoch); + + // The distance between the two iterators gives us the number of leap years + int nLeapYears = std::abs(std::distance(y2000, lb)); + + int nYears = std::abs(year - Epoch); + int nRegularYears = nYears - nLeapYears; + + // Get the total number of days as the sum of leap years + non leap years + int result = nRegularYears * DaysRegularYear + nLeapYears * DaysLeapYear; + return result; + }; + + // Returns the number of leap seconds that lie between the {year, dayOfYear} + // time point and { 2000, 1 } + int countLeapSeconds(int year, int dayOfYear) { + // Find the position of the current year in the vector; its position in + // the vector gives the number of leap seconds + struct LeapSecond { + int year; + int dayOfYear; + bool operator<(const LeapSecond& rhs) const { + return + std::tie(year, dayOfYear) < std::tie(rhs.year, rhs.dayOfYear); + } + }; + + const LeapSecond Epoch = { 2000, 1}; + + // List taken from: https://www.ietf.org/timezones/data/leap-seconds.list + static const std::vector LeapSeconds = { + { 1972, 1 }, + { 1972, 183 }, + { 1973, 1 }, + { 1974, 1 }, + { 1975, 1 }, + { 1976, 1 }, + { 1977, 1 }, + { 1978, 1 }, + { 1979, 1 }, + { 1980, 1 }, + { 1981, 182 }, + { 1982, 182 }, + { 1983, 182 }, + { 1985, 182 }, + { 1988, 1 }, + { 1990, 1 }, + { 1991, 1 }, + { 1992, 183 }, + { 1993, 182 }, + { 1994, 182 }, + { 1996, 1 }, + { 1997, 182 }, + { 1999, 1 }, + { 2006, 1 }, + { 2009, 1 }, + { 2012, 183 }, + { 2015, 182 }, + { 2017, 1 } + }; + + // Get the position of the last leap second before the desired date + LeapSecond date { year, dayOfYear }; + auto it = std::lower_bound(LeapSeconds.begin(), LeapSeconds.end(), date); + + // Get the position of the Epoch + auto y2000 = std::lower_bound(LeapSeconds.begin(), LeapSeconds.end(), Epoch); + + // The distance between the two iterators gives us the number of leap years + int nLeapSeconds = std::abs(std::distance(y2000, it)); + return nLeapSeconds; + }; + + double epochFromSubstring(const std::string& epochString) { + // The epochString is in the form: + // YYDDD.DDDDDDDD + // With YY being the last two years of the launch epoch, the first DDD the day + // of the year and the remaning a fractional part of the day + + // The main overview of this function: + // 1. Reconstruct the full year from the YY part + // 2. Calculate the number of seconds since the beginning of the year + // 2.a Get the number of full days since the beginning of the year + // 2.b If the year is a leap year, modify the number of days + // 3. Convert the number of days to a number of seconds + // 4. Get the number of leap seconds since January 1st, 2000 and remove them + // 5. Adjust for the fact the epoch starts on 1st Januaray at 12:00:00, not + // midnight + + // According to https://celestrak.com/columns/v04n03/ + // Apparently, US Space Command sees no need to change the two-line element + // set format yet since no artificial earth satellites existed prior to 1957. + // By their reasoning, two-digit years from 57-99 correspond to 1957-1999 and + // those from 00-56 correspond to 2000-2056. We'll see each other again in 2057! + + // 1. Get the full year + std::string yearPrefix = [y = epochString.substr(0, 2)](){ + int year = std::atoi(y.c_str()); + return year >= 57 ? "19" : "20"; + }(); + int year = std::atoi((yearPrefix + epochString.substr(0, 2)).c_str()); + int daysSince2000 = countDays(year); + + // 2. + // 2.a + double daysInYear = std::atof(epochString.substr(2).c_str()); + + // 2.b + bool isInLeapYear = std::find( + LeapYears.begin(), + LeapYears.end(), + year + ) != LeapYears.end(); + if (isInLeapYear && daysInYear >= 60) { + // We are in a leap year, so we have an effective day more if we are + // beyond the end of february (= 31+29 days) + --daysInYear; + } + + // 3 + using namespace std::chrono; + int SecondsPerDay = seconds(hours(24)).count(); + double nSecondsSince2000 = (daysSince2000 + daysInYear) * SecondsPerDay; + + // 4 + // We need to remove additionbal leap seconds past 2000 and add them prior to + // 2000 to sync up the time zones + double nLeapSecondsOffset = -countLeapSeconds(year, std::floor(daysInYear)); + + // 5 + double nSecondsEpochOffset = seconds(hours(12)).count(); + + // Combine all of the values + double epoch = nSecondsSince2000 + nLeapSecondsOffset - nSecondsEpochOffset; + return epoch; + } + + double calculateSemiMajorAxis(double meanMotion) { + using namespace std::chrono; + const double GravitationalConstant = 6.6740831e-11; + const double MassEarth = 5.9721986e24; + const double muEarth = GravitationalConstant * MassEarth; + + // Use Kepler's 3rd law to calculate semimajor axis + // a^3 / P^2 = mu / (2pi)^2 + // <=> a = ((mu * P^2) / (2pi^2))^(1/3) + // with a = semimajor axis + // P = period in seconds + // mu = G*M_earth + using namespace std::chrono; + double period = seconds(hours(24)).count() / meanMotion; + + const double pisq = glm::pi() * glm::pi(); + double semiMajorAxis = pow((muEarth * period*period) / (4 * pisq), 1.0 / 3.0); + + // We need the semi major axis in km instead of m + return semiMajorAxis / 1000.0; + } +} + + +namespace openspace { + +Documentation TLETranslation::Documentation() { + using namespace openspace::documentation; + return { + "TLE Translation", + "base_transform_tle", + { + { + "Type", + new StringEqualVerifier("TLETranslation"), + "", + Optional::No + }, + { + KeyFile, + new StringVerifier, + "Specifies the filename of the Two-Line-Element file", + Optional::No + } + }, + Exhaustive::No + }; +} + + +TLETranslation::TLETranslation(const ghoul::Dictionary& dictionary) + : KeplerTranslation() +{ + documentation::testSpecificationAndThrow( + Documentation(), + dictionary, + "TLETranslation" + ); + + std::string file = dictionary.value(KeyFile); + readTLEFile(file); +} + +void TLETranslation::readTLEFile(const std::string& filename) { + ghoul_assert(FileSys.fileExists(filename), "The filename must exist"); + + std::ifstream file; + file.exceptions(std::ofstream::failbit | std::ofstream::badbit); + file.open(filename); + + // All of the Kepler element information + struct { + double inclination; + double semiMajorAxis; + double ascendingNode; + double eccentricity; + double argumentOfPeriapsis; + double meanAnomaly; + double meanMotion; + double epoch; + } keplerElements; + + std::string line; + while (std::getline(file, line)) { + if (line[0] == '1') { + // First line + // Field Columns Content + // 1 01-01 Line number + // 2 03-07 Satellite number + // 3 08-08 Classification (U = Unclassified) + // 4 10-11 International Designator (Last two digits of launch year) + // 5 12-14 International Designator (Launch number of the year) + // 6 15-17 International Designator(piece of the launch) A + // 7 19-20 Epoch Year(last two digits of year) + // 8 21-32 Epoch(day of the year and fractional portion of the day) + // 9 34-43 First Time Derivative of the Mean Motion divided by two + // 10 45-52 Second Time Derivative of Mean Motion divided by six + // 11 54-61 BSTAR drag term(decimal point assumed)[10] - 11606 - 4 + // 12 63-63 The "Ephemeris type" + // 13 65-68 Element set number.Incremented when a new TLE is generated + // 14 69-69 Checksum (modulo 10) + + keplerElements.epoch = epochFromSubstring(line.substr(18, 14)); + } + else if (line[0] == '2') { + // Second line + //Field Columns Content + // 1 01-01 Line number + // 2 03-07 Satellite number + // 3 09-16 Inclination (degrees) + // 4 18-25 Right ascension of the ascending node (degrees) + // 5 27-33 Eccentricity (decimal point assumed) + // 6 35-42 Argument of perigee (degrees) + // 7 44-51 Mean Anomaly (degrees) + // 8 53-63 Mean Motion (revolutions per day) + // 9 64-68 Revolution number at epoch (revolutions) + // 10 69-69 Checksum (modulo 10) + + std::stringstream stream; + stream.exceptions(std::ios::failbit); + + // Get inclination + stream.str(line.substr(8, 8)); + stream >> keplerElements.inclination; + stream.clear(); + + // Get Right ascension of the ascending node + stream.str(line.substr(17, 8)); + stream >> keplerElements.ascendingNode; + stream.clear(); + + // Get Eccentricity + stream.str("0." + line.substr(26, 7)); + stream >> keplerElements.eccentricity; + stream.clear(); + + // Get argument of periapsis + stream.str(line.substr(34, 8)); + stream >> keplerElements.argumentOfPeriapsis; + stream.clear(); + + // Get mean anomaly + stream.str(line.substr(43, 8)); + stream >> keplerElements.meanAnomaly; + stream.clear(); + + // Get mean motion + stream.str(line.substr(52, 11)); + stream >> keplerElements.meanMotion; + + break; + } + } + + // Calculate the semi major axis based on the mean motion using kepler's laws + keplerElements.semiMajorAxis = calculateSemiMajorAxis(keplerElements.meanMotion); + + // Converting the mean motion (revolutions per day) to period (seconds per revolution) + using namespace std::chrono; + double period = seconds(hours(24)).count() / keplerElements.meanMotion; + + setKeplerElements( + keplerElements.eccentricity, + keplerElements.semiMajorAxis, + keplerElements.inclination, + keplerElements.ascendingNode, + keplerElements.argumentOfPeriapsis, + keplerElements.meanAnomaly, + period, + keplerElements.epoch + ); +} + +} // namespace openspace diff --git a/modules/base/translation/tletranslation.h b/modules/base/translation/tletranslation.h new file mode 100644 index 0000000000..e7df9bb721 --- /dev/null +++ b/modules/base/translation/tletranslation.h @@ -0,0 +1,75 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 __TLETRANSLATION_H__ +#define __TLETRANSLATION_H__ + +#include + +namespace openspace { + +/** + * A specialization of the KeplerTranslation that extracts the Keplerian elements from a + * two-line element as described by the US Space Command + * https://celestrak.com/columns/v04n03 + * The ghoul::Dictionary passed to the constructor must contain the pointer to a file that + * will be read. + */ +class TLETranslation : public KeplerTranslation { +public: + /** + * Constructor for the TLETranslation class. The \p dictionary must contain a key for + * the file that contains the TLE information. The ghoul::Dictionary will be tested + * against the openspace::Documentation returned by Documentation. + * \param The ghoul::Dictionary that contains the information for this TLETranslation + (*/ + TLETranslation(const ghoul::Dictionary& dictionary = ghoul::Dictionary()); + + /** + * Method returning the openspace::Documentation that describes the ghoul::Dictinoary + * that can be passed to the constructor. + * \return The openspace::Documentation that describes the ghoul::Dicitonary that can + * be passed to the constructor + */ + static openspace::Documentation Documentation(); + +private: + /** + * Reads the provided TLE file and calles the KeplerTranslation::setKeplerElments + * method with the correct values. If \p filename is a valid TLE file but contains + * disallowed values (see KeplerTranslation::setKeplerElements), a + * KeplerTranslation::RangeError is thrown. + * \param filename The path to the file that contains the TLE file. + * \throw std::system_error if the TLE file is malformed (does not contain at least + * two lines that start with \c 1 and \c 2. + * \throw KeplerTranslation::RangeError If the Keplerian elements are outside of + * the valid range supported by Kepler::setKeplerElements + * \pre The \p filename must exist + */ + void readTLEFile(const std::string& filename); +}; + +} // namespace openspace + +#endif // __TLETRANSLATION_H__ diff --git a/modules/onscreengui/src/guipropertycomponent.cpp b/modules/onscreengui/src/guipropertycomponent.cpp index 7e247045c7..4093f87573 100644 --- a/modules/onscreengui/src/guipropertycomponent.cpp +++ b/modules/onscreengui/src/guipropertycomponent.cpp @@ -74,6 +74,7 @@ void GuiPropertyComponent::renderPropertyOwner(properties::PropertyOwner* owner) return; } + int nThisProperty = nVisibleProperties(owner->properties(), _visibility); ImGui::PushID(owner->name().c_str()); const auto& subOwners = owner->propertySubOwners(); for (properties::PropertyOwner* subOwner : subOwners) { @@ -82,7 +83,7 @@ void GuiPropertyComponent::renderPropertyOwner(properties::PropertyOwner* owner) if (count == 0) { continue; } - if (subOwners.size() == 1) { + if (subOwners.size() == 1 && (nThisProperty == 0)) { renderPropertyOwner(subOwner); } else { diff --git a/src/scene/translation.cpp b/src/scene/translation.cpp index 8fe9513bce..0f0c19fefd 100644 --- a/src/scene/translation.cpp +++ b/src/scene/translation.cpp @@ -97,5 +97,14 @@ glm::dvec3 Translation::position(double time) { return position(); } +void Translation::notifyObservers() { + if (_onParameterChangeCallback) { + _onParameterChangeCallback(); + } +} + +void Translation::onParameterChange(std::function callback) { + _onParameterChangeCallback = std::move(callback); +} } // namespace openspace From c515bbfd0f640a7b1d1f3d6624534d0bd0a419d2 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Sat, 3 Dec 2016 00:51:32 +0100 Subject: [PATCH 9/9] Redesign the ScriptScheduler to not copy scripts on return Fix earth.mod file --- data/scene/earth/earth.mod | 3 +- include/openspace/scripting/scriptscheduler.h | 75 +- include/openspace/util/time.h | 12 +- src/CMakeLists.txt | 3 +- src/engine/openspaceengine.cpp | 9 +- src/scripting/scriptscheduler.cpp | 320 ++++--- src/scripting/scriptscheduler_lua.inl | 101 +++ src/util/time.cpp | 9 +- tests/main.cpp | 6 +- tests/test_scriptscheduler.inl | 806 ++++++++++++++++++ 10 files changed, 1182 insertions(+), 162 deletions(-) create mode 100644 src/scripting/scriptscheduler_lua.inl create mode 100644 tests/test_scriptscheduler.inl diff --git a/data/scene/earth/earth.mod b/data/scene/earth/earth.mod index f3dbe2bd77..2c1afa8a85 100644 --- a/data/scene/earth/earth.mod +++ b/data/scene/earth/earth.mod @@ -12,8 +12,9 @@ return { } } }, + { -- The default reference frame for Earth-orbiting satellites - Name = "EarthInertial", + Name = "EarthInertial", Parent = "EarthBarycenter", Transform = { Rotation = { diff --git a/include/openspace/scripting/scriptscheduler.h b/include/openspace/scripting/scriptscheduler.h index b8b5630c07..b5450d7996 100644 --- a/include/openspace/scripting/scriptscheduler.h +++ b/include/openspace/scripting/scriptscheduler.h @@ -25,55 +25,43 @@ #ifndef __SCRIPTSCHEDULER_H__ #define __SCRIPTSCHEDULER_H__ -#include - +#include #include #include #include +namespace ghoul { +class Dictionary; +} // namespace ghoul + namespace openspace { - namespace scripting { - - -struct ReversibleLuaScript { - std::string forwardScript; - std::string backwardScript; -}; - -struct ScheduledScript { - ScheduledScript() : time(-DBL_MAX) { } - ScheduledScript(const ghoul::Dictionary& dict); - - double time; - ReversibleLuaScript script; - - static bool CompareByTime(const ScheduledScript& s1, const ScheduledScript& s2); -}; - - /** * Maintains an ordered list of ScheduledScripts and provides a simple * interface for retrieveing scheduled scripts */ class ScriptScheduler { public: + struct ScheduledScript { + ScheduledScript() = default; + ScheduledScript(const ghoul::Dictionary& dict); + + double time; + std::string forwardScript; + std::string backwardScript; + }; + /** - * Load a schedule from a Lua-file - * \param filename Lua file to load - * \param L an optional lua_State defining variables that may be used - * in the Lua-file. + * Load a schedule from a ghoul::Dictionary \p dictionary and adds the + * ScheduledScript%s to the list of stored scripts. + * \param dictionary Dictionary to read + * \throw SpecificationError If the dictionary does not adhere to the Documentation as + * specified in the openspace::Documentation function */ - void loadScripts(const std::string& filename, lua_State* L = nullptr); - - /** - * Load a schedule from a ghoul::Dictionary - * \param dict Dictionary to read - */ - void loadScripts(const ghoul::Dictionary& dict); + void loadScripts(const ghoul::Dictionary& dictionary); /** @@ -96,7 +84,7 @@ public: * * \returns the ordered queue of scripts . */ - std::queue progressTo(double newTime); +// std::queue progressTo(double newTime); /** * See progressTo(double newTime). @@ -104,10 +92,12 @@ public: * \param timeStr A string specifying the a new time stamp that the * scripts scheduler should progress to. */ - std::queue progressTo(const std::string& timeStr); - - +// std::queue progressTo(const std::string& timeStr); + std::pair< + std::vector::const_iterator, std::vector::const_iterator + > progressTo(double newTime); + /** * Returns the the j2000 time value that the script scheduler is currently at */ @@ -116,16 +106,19 @@ public: /** * \returns a vector of all scripts that has been loaded */ - const std::vector& allScripts() const; + std::vector allScripts() const; static LuaLibrary luaLibrary(); + + static openspace::Documentation Documentation(); private: - - std::vector _scheduledScripts; - - size_t _currentIndex = 0; + std::vector _timings; + std::vector _forwardScripts; + std::vector _backwardScripts; + + int _currentIndex = 0; double _currentTime; }; diff --git a/include/openspace/util/time.h b/include/openspace/util/time.h index 2275c95eec..9657b71dcb 100644 --- a/include/openspace/util/time.h +++ b/include/openspace/util/time.h @@ -59,10 +59,20 @@ class SyncBuffer; class Time { public: + /** + * Converts the \p timeString representing a date to a double precision + * value representing the ephemeris time; that is the number of TDB + * seconds past the J2000 epoch. + * \param timeString A string representing the time to be converted + * \return The converted time; the number of TDB seconds past the J2000 epoch, + * representing the passed \p timeString + * \pre \p timeString must not be empty + */ + static double convertTime(const std::string& time); + Time(double secondsJ2000 = -1); Time(const Time& other); - /** * Initializes the Time singleton. * \return true if the initialization succeeded, false diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2a6220dd90..5d2c4f25b5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -140,8 +140,9 @@ set(OPENSPACE_SOURCE ${OPENSPACE_BASE_DIR}/src/scene/scenegraphnode_doc.inl ${OPENSPACE_BASE_DIR}/src/scripting/lualibrary.cpp ${OPENSPACE_BASE_DIR}/src/scripting/scriptengine.cpp - ${OPENSPACE_BASE_DIR}/src/scripting/scriptscheduler.cpp ${OPENSPACE_BASE_DIR}/src/scripting/scriptengine_lua.inl + ${OPENSPACE_BASE_DIR}/src/scripting/scriptscheduler.cpp + ${OPENSPACE_BASE_DIR}/src/scripting/scriptscheduler_lua.inl ${OPENSPACE_BASE_DIR}/src/util/blockplaneintersectiongeometry.cpp ${OPENSPACE_BASE_DIR}/src/util/boxgeometry.cpp ${OPENSPACE_BASE_DIR}/src/util/camera.cpp diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index 4a96a5a2f3..2f20708ab0 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -867,11 +867,10 @@ void OpenSpaceEngine::preSynchronization() { _timeManager->preSynchronization(dt); auto scheduledScripts = _scriptScheduler->progressTo(Time::ref().j2000Seconds()); - while(scheduledScripts.size()){ - auto scheduledScript = scheduledScripts.front(); - LINFO(scheduledScript); - _scriptEngine->queueScript(scheduledScript, ScriptEngine::RemoteScripting::Yes); - scheduledScripts.pop(); + for (auto it = scheduledScripts.first; it != scheduledScripts.second; ++it) { + _scriptEngine->queueScript( + *it, ScriptEngine::RemoteScripting::Yes + ); } _interactionHandler->updateInputStates(dt); diff --git a/src/scripting/scriptscheduler.cpp b/src/scripting/scriptscheduler.cpp index a49f68dc03..05eb6fb76e 100644 --- a/src/scripting/scriptscheduler.cpp +++ b/src/scripting/scriptscheduler.cpp @@ -27,74 +27,154 @@ #include #include -#include // parse time +#include #include #include - -namespace openspace { -namespace scripting { +#include namespace { - const std::string _loggerCat = "ScriptScheduler"; - - const std::string KEY_TIME = "Time"; - const std::string KEY_FORWARD_SCRIPT = "ReversibleLuaScript.Forward"; - const std::string KEY_BACKWARD_SCRIPT = "ReversibleLuaScript.Backward"; + const char* KeyTime = "Time"; + const char* KeyForwardScript = "ForwardScript"; + const char* KeyBackwardScript = "BackwardScript"; + const char* KeyUniversalScript = "Script"; } +namespace openspace { -ScheduledScript::ScheduledScript(const ghoul::Dictionary& dict) - : ScheduledScript() // default init first +#include "scriptscheduler_lua.inl" + +namespace scripting { + +openspace::Documentation ScriptScheduler::Documentation() { + using namespace openspace::documentation; + + using TimeVerifier = StringVerifier; + using LuaScriptVerifier = StringVerifier; + + return{ + "Scheduled Scripts", + "core_scheduledscript", + { + { + "*", + new TableVerifier({ + { + KeyTime, + new TimeVerifier, + "The time at which, when the in game time passes it, the two " + "scripts will be executed. If the traversal is forwards (towards " + "+ infinity), the ForwardScript will be executed, otherwise the " + "BackwardScript will be executed instead.", + Optional::No + }, + { + KeyUniversalScript, + new LuaScriptVerifier, + "The Lua script that will be executed when the specified time is " + "passed independent of its direction. This script will be " + "executed before the specific scripts if both versions are " + "specified", + Optional::Yes + }, + { + KeyForwardScript, + new LuaScriptVerifier, + "The Lua script that is executed when OpenSpace passes the time " + "in a forward direction.", + Optional::Yes + }, + { + KeyBackwardScript, + new LuaScriptVerifier, + "The Lua script that is executed when OpenSpace passes the time " + "in a backward direction.", + Optional::Yes + } + }) + } + }, + Exhaustive::Yes + }; +} + +ScriptScheduler::ScheduledScript::ScheduledScript(const ghoul::Dictionary& dictionary) + : time(-std::numeric_limits::max()) { - std::string timeStr; - if (dict.getValue(KEY_TIME, timeStr)) { - time = SpiceManager::ref().ephemerisTimeFromDate(timeStr); + std::string timeStr = dictionary.value(KeyTime); + time = Time::ref().convertTime(timeStr); + + // If a universal script is specified, retrieve it and add a ; as a separator so that + // it can be added to the other scripts + std::string universal; + dictionary.getValue(KeyUniversalScript, universal); + if (!universal.empty()) { + universal += ";"; + } + + if (dictionary.hasKeyAndValue(KeyForwardScript)) { + forwardScript = + universal + dictionary.value(KeyForwardScript); + } + + if (dictionary.hasKeyAndValue(KeyBackwardScript)) { + backwardScript = + universal + dictionary.value(KeyBackwardScript); + } +} - if (!dict.getValue(KEY_FORWARD_SCRIPT, script.forwardScript)) { - LERROR("Unable to read " << KEY_FORWARD_SCRIPT); - } - if (!dict.getValue(KEY_BACKWARD_SCRIPT, script.backwardScript)) { - LERROR("Unable to read " << KEY_BACKWARD_SCRIPT); +void ScriptScheduler::loadScripts(const ghoul::Dictionary& dictionary) { + // Check if all of the scheduled scripts are formed correctly + documentation::testSpecificationAndThrow( + Documentation(), + dictionary, + "ScriptScheduler" + ); + + // Create all the scheduled script first + std::vector scheduledScripts; + for (size_t i = 1; i <= dictionary.size(); ++i) { + const ghoul::Dictionary& timedScriptDict = dictionary.value( + std::to_string(i) + ); + scheduledScripts.emplace_back(timedScriptDict); + } + + // Sort scripts by time; use a stable_sort as the user might have had an intention + // specifying multiple scripts for the same time in a specific order + std::stable_sort( + scheduledScripts.begin(), + scheduledScripts.end(), + [](const ScheduledScript& lhs, const ScheduledScript& rhs) { + return lhs.time < rhs.time; } + ); + + // Move the scheduled scripts into their SOA alignment + // For the forward scripts, this is the forwards direction + // For the backward scripts, we insert them in the opposite order so that we can still + // return forward iterators to them in the progressTo method + for (ScheduledScript& script : scheduledScripts) { + _timings.push_back(script.time); + + _forwardScripts.push_back(std::move(script.forwardScript)); + + _backwardScripts.insert( + _backwardScripts.begin(), + std::move(script.backwardScript) + ); } - else { - LERROR("Unable to read " << KEY_TIME); - } -} - -bool ScheduledScript::CompareByTime(const ScheduledScript& s1, const ScheduledScript& s2){ - return s1.time < s2.time; -} - - - -void ScriptScheduler::loadScripts(const std::string& filepath, lua_State* L) { - ghoul::Dictionary timedScriptsDict; - try { - ghoul::lua::loadDictionaryFromFile(absPath(filepath), timedScriptsDict, L); - } - catch (const ghoul::RuntimeError& e) { - LERROR(e.what()); - return; - } - loadScripts(timedScriptsDict); -} - -void ScriptScheduler::loadScripts(const ghoul::Dictionary& dict) { - for (size_t i = 0; i < dict.size(); ++i) { - std::string id = std::to_string(i + 1); - const ghoul::Dictionary& timedScriptDict = dict.value(id); - _scheduledScripts.push_back(ScheduledScript(timedScriptDict)); - } - - // Sort scripts by time - std::stable_sort(_scheduledScripts.begin(), _scheduledScripts.end(), &ScheduledScript::CompareByTime); // Ensure _currentIndex and _currentTime is accurate after new scripts was added double lastTime = _currentTime; rewind(); progressTo(lastTime); + + ghoul_assert( + (_timings.size() == _forwardScripts.size()) && + (_timings.size() == _backwardScripts.size()), + "The SOA data structure has been mistreated and has different number of values" + ); } void ScriptScheduler::rewind() { @@ -102,91 +182,113 @@ void ScriptScheduler::rewind() { _currentTime = -DBL_MAX; } - void ScriptScheduler::clearSchedule() { rewind(); - _scheduledScripts.clear(); + _timings.clear(); + _forwardScripts.clear(); + _backwardScripts.clear(); } -std::queue ScriptScheduler::progressTo(double newTime) { - std::queue triggeredScripts; +std::pair< + std::vector::const_iterator, std::vector::const_iterator +> +ScriptScheduler::progressTo(double newTime) +{ + if (newTime == _currentTime) { + return { _forwardScripts.end(), _forwardScripts.end() }; + } + if (newTime > _currentTime) { - while(_currentIndex < _scheduledScripts.size() && _scheduledScripts[_currentIndex].time <= newTime){ - triggeredScripts.push(_scheduledScripts[_currentIndex].script.forwardScript); - _currentIndex++; - } + // Moving forward in time; we need to find the highest entry in the timings + // vector that is still smaller than the newTime + size_t prevIndex = _currentIndex; + auto it = std::upper_bound( + _timings.begin() + prevIndex, // We only need to start at the previous time + _timings.end(), + newTime + ); + + // How many values did we pass over? + int n = std::distance(_timings.begin() + prevIndex, it); + _currentIndex = prevIndex + n; + + // Update the new time + _currentTime = newTime; + + return { + _forwardScripts.begin() + prevIndex, + _forwardScripts.begin() + _currentIndex + }; } else { - while (0 < _currentIndex && _scheduledScripts[_currentIndex - 1].time > newTime) { - triggeredScripts.push(_scheduledScripts[_currentIndex - 1].script.backwardScript); - _currentIndex--; - } + // Moving backward in time; the need to find the lowest entry that is still bigger + // than the newTime + size_t prevIndex = _currentIndex; + auto it = std::lower_bound( + _timings.begin(), + _timings.begin() + prevIndex, // We can stop at the previous time + newTime + ); + + // How many values did we pass over? + int n = std::distance(it, _timings.begin() + prevIndex); + _currentIndex = prevIndex - n; + + // Update the new time + _currentTime = newTime; + + int size = _timings.size(); + return { + _backwardScripts.begin() + (size - prevIndex), + _backwardScripts.begin() + (size - _currentIndex) + }; } - - _currentTime = newTime; - return triggeredScripts; } -std::queue ScriptScheduler::progressTo(const std::string& timeStr) { - return std::move(progressTo(SpiceManager::ref().ephemerisTimeFromDate(timeStr))); -} - -double ScriptScheduler::currentTime() const { +double ScriptScheduler::currentTime() const { return _currentTime; }; -const std::vector& ScriptScheduler::allScripts() const { - return _scheduledScripts; -}; - - - -///////////////////////////////////////////////////////////////////// -// Lua library functions // -///////////////////////////////////////////////////////////////////// - -namespace luascriptfunctions { - int loadTimedScripts(lua_State* L) { - using ghoul::lua::luaTypeToString; - int nArguments = lua_gettop(L); - if (nArguments != 1) - return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); - - std::string missionFileName = luaL_checkstring(L, -1); - if (missionFileName.empty()) { - return luaL_error(L, "filepath string is empty"); - } +std::vector ScriptScheduler::allScripts() const { + std::vector result; + for (size_t i = 0; i < _timings.size(); ++i) { + ScheduledScript script; + script.time = _timings[i]; + script.forwardScript = _forwardScripts[i]; + script.backwardScript = _backwardScripts[i]; - OsEng.scriptScheduler().loadScripts(missionFileName, L); + result.push_back(std::move(script)); } - - int clear(lua_State* L) { - using ghoul::lua::luaTypeToString; - int nArguments = lua_gettop(L); - if (nArguments != 0) - return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments); - - OsEng.scriptScheduler().clearSchedule(); - } -} // namespace luascriptfunction - - + return result; +}; LuaLibrary ScriptScheduler::luaLibrary() { return { "scriptScheduler", { { - "load", - &luascriptfunctions::loadTimedScripts, + "loadFile", + &luascriptfunctions::loadFile, "string", - "Load timed scripts from file" + "Load timed scripts from a Lua script file that returns a list of " + "scheduled scripts." + }, + { + "loadScheduledScript", + &luascriptfunctions::loadScheduledScript, + "string, string, (string, string)", + "Load a single scheduled script. The first argument is the time at which " + "the scheduled script is triggered, the second argument is the script " + "that is executed in the forward direction, the optional third argument " + "is the script executed in the backwards direction, and the optional " + "last argument is the universal script, executed in either direction." + }, { "clear", &luascriptfunctions::clear, "", - "clears all scheduled scripts" + "Clears all scheduled scripts." }, } }; diff --git a/src/scripting/scriptscheduler_lua.inl b/src/scripting/scriptscheduler_lua.inl new file mode 100644 index 0000000000..a041e8a172 --- /dev/null +++ b/src/scripting/scriptscheduler_lua.inl @@ -0,0 +1,101 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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. * + ****************************************************************************************/ + +namespace luascriptfunctions { + +int loadFile(lua_State* L) { + int nArguments = lua_gettop(L); + if (nArguments != 1) { + return luaL_error(L, "Expected %i arguments, got %i", 1, nArguments); + } + + std::string missionFileName = luaL_checkstring(L, -1); + if (missionFileName.empty()) { + return luaL_error(L, "filepath string is empty"); + } + + OsEng.scriptScheduler().loadScripts( + ghoul::lua::loadDictionaryFromFile(missionFileName, L) + ); + + return 0; +} + +int loadScheduledScript(lua_State* L) { + int nArguments = lua_gettop(L); + if (nArguments == 2) { + OsEng.scriptScheduler().loadScripts({ + { + "1", + ghoul::Dictionary { + { KeyTime, std::string(luaL_checkstring(L, -2)) }, + { KeyForwardScript, std::string(luaL_checkstring(L, -1)) } + } + } + }); + } + else if (nArguments == 3) { + OsEng.scriptScheduler().loadScripts({ + { + "1", + ghoul::Dictionary { + { KeyTime, std::string(luaL_checkstring(L, -3)) }, + { KeyForwardScript, std::string(luaL_checkstring(L, -2)) }, + { KeyBackwardScript, std::string(luaL_checkstring(L, -1)) } + } + } + }); + } + else if (nArguments == 4) { + OsEng.scriptScheduler().loadScripts({ + { + "1", + ghoul::Dictionary { + { KeyTime, std::string(luaL_checkstring(L, -4)) }, + { KeyForwardScript, std::string(luaL_checkstring(L, -3)) }, + { KeyBackwardScript, std::string(luaL_checkstring(L, -2)) }, + { KeyUniversalScript, std::string(luaL_checkstring(L, -1)) } + } + } + }); + } + else { + return luaL_error(L, "Expected %i-%i arguments, got %i", 2, 4, nArguments); + } + + return 0; +} + +int clear(lua_State* L) { + int nArguments = lua_gettop(L); + if (nArguments != 0) { + return luaL_error(L, "Expected %i arguments, got %i", 0, nArguments); + } + + OsEng.scriptScheduler().clearSchedule(); + + return 0; +} + +} // namespace luascriptfunction diff --git a/src/util/time.cpp b/src/util/time.cpp index 5f4f142323..89204ab623 100644 --- a/src/util/time.cpp +++ b/src/util/time.cpp @@ -34,12 +34,15 @@ #include #include - - - namespace openspace { Time* Time::_instance = nullptr; + + +double Time::convertTime(const std::string& time) { + ghoul_assert(!time.empty(), "timeString must not be empty"); + return SpiceManager::ref().ephemerisTimeFromDate(time); +} Time::Time(double secondsJ2000) : _time(secondsJ2000) diff --git a/tests/main.cpp b/tests/main.cpp index 354d923c9c..a0c491f33b 100644 --- a/tests/main.cpp +++ b/tests/main.cpp @@ -58,12 +58,16 @@ //#include #endif +#include + #include #include #include #include + #include +#include #include #include @@ -88,7 +92,7 @@ int main(int argc, char** argv) { testing::internal::CaptureStdout(); testing::internal::CaptureStderr(); #endif - + openspace::SpiceManager::deinitialize(); bool b = RUN_ALL_TESTS(); diff --git a/tests/test_scriptscheduler.inl b/tests/test_scriptscheduler.inl new file mode 100644 index 0000000000..1dee4d8cc8 --- /dev/null +++ b/tests/test_scriptscheduler.inl @@ -0,0 +1,806 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2016 * + * * + * 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 "gtest/gtest.h" + +#include + +// This include should be removed after the time class is not dependent on +// Spice anymore +#include +#include +#include + +#include + +class ScriptSchedulerTest : public testing::Test { +protected: + void SetUp() override { + openspace::SpiceManager::initialize(); + openspace::SpiceManager::ref().loadKernel( + "${TESTDIR}/SpiceTest/spicekernels/naif0008.tls" + ); + } + + void TearDown() override { + openspace::SpiceManager::deinitialize(); + } +}; + +TEST_F(ScriptSchedulerTest, SimpleForward) { + using namespace openspace::scripting; + using namespace std::string_literals; + + ScriptScheduler scheduler; + + ghoul::Dictionary testDictionary = { + { "Time", "2000 JAN 03"s }, + { "ForwardScript", "ForwardScript1"s }, + { "BackwardScript", "BackwardScript1"s } + }; + + scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 01")); + scheduler.loadScripts({ + { "1", testDictionary } + }); + + auto res = scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 02")); + ASSERT_EQ(res.first, res.second); + + res = scheduler.progressTo( + openspace::Time::ref().convertTime("2000 JAN 03") + ); + ASSERT_EQ(1, std::distance(res.first, res.second)); + EXPECT_EQ("ForwardScript1", *(res.first)); +} + +TEST_F(ScriptSchedulerTest, MultipleForwardSingleJump) { + using namespace openspace::scripting; + using namespace std::string_literals; + + ghoul::Dictionary testDictionary1 = { + { "Time", "2000 JAN 03"s }, + { "ForwardScript", "ForwardScript1"s }, + { "BackwardScript", "BackwardScript1"s } + }; + + ghoul::Dictionary testDictionary2 = { + { "Time", "2000 JAN 05"s }, + { "ForwardScript", "ForwardScript2"s }, + { "BackwardScript", "BackwardScript2"s } + + }; + + ScriptScheduler scheduler; + + scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 01")); + scheduler.loadScripts({ + { "1", testDictionary1 }, + { "2", testDictionary2 } + }); + + auto res = scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 02")); + ASSERT_EQ(res.first, res.second); + + res = scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 04")); + ASSERT_EQ(1, std::distance(res.first, res.second)); + EXPECT_EQ("ForwardScript1", *(res.first)); + + res = scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 06")); + ASSERT_EQ(1, std::distance(res.first, res.second)); + EXPECT_EQ("ForwardScript2", *(res.first)); +} + +TEST_F(ScriptSchedulerTest, MultipleForwardOrdering) { + using namespace openspace::scripting; + using namespace std::string_literals; + + ghoul::Dictionary testDictionary1 = { + { "Time", "2000 JAN 03"s }, + { "ForwardScript", "ForwardScript1"s }, + { "BackwardScript", "BackwardScript1"s } + }; + + ghoul::Dictionary testDictionary2 = { + { "Time", "2000 JAN 05"s }, + { "ForwardScript", "ForwardScript2"s }, + { "BackwardScript", "BackwardScript2"s } + }; + + ScriptScheduler scheduler; + + scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 01")); + scheduler.loadScripts({ + { "1", testDictionary1 }, + { "2", testDictionary2 } + }); + + auto res = scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 02")); + ASSERT_EQ(res.first, res.second); + + res = scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 06")); + ASSERT_EQ(2, std::distance(res.first, res.second)); + EXPECT_EQ("ForwardScript1", *(res.first)); + EXPECT_EQ("ForwardScript2", *(std::next(res.first))); +} + +TEST_F(ScriptSchedulerTest, SimpleBackward) { + using namespace openspace::scripting; + using namespace std::string_literals; + + ScriptScheduler scheduler; + + ghoul::Dictionary testDictionary = { + { "Time", "2000 JAN 03"s }, + { "ForwardScript", "ForwardScript1"s }, + { "BackwardScript", "BackwardScript1"s } + }; + + scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 05")); + scheduler.loadScripts({ + { "1", testDictionary } + }); + + auto res = scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 04")); + ASSERT_EQ(res.first, res.second); + + res = scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 02")); + ASSERT_EQ(1, std::distance(res.first, res.second)); + EXPECT_EQ("BackwardScript1", *(res.first)); +} + +TEST_F(ScriptSchedulerTest, MultipleBackwardSingleJump) { + using namespace openspace::scripting; + using namespace std::string_literals; + + ScriptScheduler scheduler; + + ghoul::Dictionary testDictionary1 = { + { "Time", "2000 JAN 03"s }, + { "ForwardScript", "ForwardScript1"s }, + { "BackwardScript", "BackwardScript1"s } + }; + + ghoul::Dictionary testDictionary2 = { + { "Time", "2000 JAN 05"s }, + { "ForwardScript", "ForwardScript2"s }, + { "BackwardScript", "BackwardScript2"s } + }; + + scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 07")); + scheduler.loadScripts({ + { "1", testDictionary1 }, + { "2", testDictionary2 } + }); + + auto res = scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 06")); + ASSERT_EQ(res.first, res.second); + + res = scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 04")); + ASSERT_EQ(1, std::distance(res.first, res.second)); + EXPECT_EQ("BackwardScript2", *(res.first)); + + res = scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 01")); + ASSERT_EQ(1, std::distance(res.first, res.second)); + EXPECT_EQ("BackwardScript1", *(res.first)); +} + +TEST_F(ScriptSchedulerTest, MultipleBackwardOrdering) { + using namespace openspace::scripting; + using namespace std::string_literals; + + ScriptScheduler scheduler; + + ghoul::Dictionary testDictionary1 = { + { "Time", "2000 JAN 03"s }, + { "ForwardScript", "ForwardScript1"s }, + { "BackwardScript", "BackwardScript1"s } + }; + + ghoul::Dictionary testDictionary2 = { + { "Time", "2000 JAN 05"s }, + { "ForwardScript", "ForwardScript2"s }, + { "BackwardScript", "BackwardScript2"s } + }; + + scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 07")); + scheduler.loadScripts({ + { "1", testDictionary1 }, + { "2", testDictionary2 } + }); + + auto res = scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 06")); + ASSERT_EQ(res.first, res.second); + + res = scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 01")); + ASSERT_EQ(2, std::distance(res.first, res.second)); + EXPECT_EQ("BackwardScript2", *(res.first)); + EXPECT_EQ("BackwardScript1", *(std::next(res.first))); +} + +TEST_F(ScriptSchedulerTest, Empty) { + using namespace openspace::scripting; + + static const std::vector TestTimes = { + 0.0, 1.0, -1.0, std::numeric_limits::min(), + -std::numeric_limits::max(), std::numeric_limits::max() + }; + + // First test if a new ScriptScheduler will return an empty list + for (double t : TestTimes) { + ScriptScheduler scheduler; + auto res = scheduler.progressTo(t); + EXPECT_EQ(res.first, res.second); + } + + // Then test the same thing but keeping the same ScriptScheduler + ScriptScheduler scheduler; + for (double t : TestTimes) { + auto res = scheduler.progressTo(t); + EXPECT_EQ(res.first, res.second); + } +} + +TEST_F(ScriptSchedulerTest, ForwardBackwards) { + using namespace openspace::scripting; + using namespace std::string_literals; + + ScriptScheduler scheduler; + + ghoul::Dictionary testDictionary1 = { + { "Time", "2000 JAN 03"s }, + { "ForwardScript", "ForwardScript1"s }, + { "BackwardScript", "BackwardScript1"s } + }; + + ghoul::Dictionary testDictionary2 = { + { "Time", "2000 JAN 05"s }, + { "ForwardScript", "ForwardScript2"s }, + { "BackwardScript", "BackwardScript2"s } + }; + + scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 01")); + scheduler.loadScripts({ + { "1", testDictionary1 }, + { "2", testDictionary2 } + }); + + auto res = scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 04")); + ASSERT_EQ(1, std::distance(res.first, res.second)); + EXPECT_EQ("ForwardScript1", *(res.first)); + + res = scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 01")); + ASSERT_EQ(1, std::distance(res.first, res.second)); + EXPECT_EQ("BackwardScript1", *(res.first)); + + res = scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 07")); + ASSERT_EQ(2, std::distance(res.first, res.second)); + + res = scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 04")); + ASSERT_EQ(1, std::distance(res.first, res.second)); + EXPECT_EQ("BackwardScript2", *(res.first)); +} + +TEST_F(ScriptSchedulerTest, Rewind) { + using namespace openspace::scripting; + using namespace std::string_literals; + + ScriptScheduler scheduler; + + ghoul::Dictionary testDictionary1 = { + { "Time", "2000 JAN 03"s }, + { "ForwardScript", "ForwardScript1"s }, + { "BackwardScript", "BackwardScript1"s } + }; + + ghoul::Dictionary testDictionary2 = { + { "Time", "2000 JAN 05"s }, + { "ForwardScript", "ForwardScript2"s }, + { "BackwardScript", "BackwardScript2"s } + }; + + scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 01")); + scheduler.loadScripts({ + { "1", testDictionary1 }, + { "2", testDictionary2 } + }); + + auto res = scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 07")); + ASSERT_EQ(2, std::distance(res.first, res.second)); + + scheduler.rewind(); + + res = scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 04")); + ASSERT_EQ(1, std::distance(res.first, res.second)); + EXPECT_EQ("ForwardScript1", *(res.first)); +} + +TEST_F(ScriptSchedulerTest, CurrentTime) { + using namespace openspace::scripting; + + static const std::vector TestValues = { + 0.0, 1.0, 42.0, std::numeric_limits::min(), + -std::numeric_limits::max(), std::numeric_limits::max() + }; + + for (double t : TestValues) { + ScriptScheduler scheduler; + scheduler.progressTo(t); + EXPECT_EQ(t, scheduler.currentTime()); + } +} + +TEST_F(ScriptSchedulerTest, AllScripts) { + using namespace openspace::scripting; + using namespace std::string_literals; + + ScriptScheduler scheduler; + + + ghoul::Dictionary testDictionary1 = { + { "Time", "2000 JAN 03"s }, + { "ForwardScript", "ForwardScript1"s }, + { "BackwardScript", "BackwardScript1"s } + }; + + ghoul::Dictionary testDictionary2 = { + { "Time", "2000 JAN 05"s }, + { "ForwardScript", "ForwardScript2"s }, + { "BackwardScript", "BackwardScript2"s } + }; + + ghoul::Dictionary testDictionary3 = { + { "Time", "2000 JAN 10"s }, + { "ForwardScript", "ForwardScript3"s }, + { "BackwardScript", "BackwardScript3"s } + }; + + scheduler.loadScripts({ + { "1", testDictionary1 }, + { "2", testDictionary2 }, + { "3", testDictionary3 } + }); + + auto allScripts = scheduler.allScripts(); + ASSERT_EQ(3, allScripts.size()); + + EXPECT_LE(allScripts[0].time, allScripts[1].time); + EXPECT_LE(allScripts[1].time, allScripts[2].time); +} + +TEST_F(ScriptSchedulerTest, JumpEqual) { + using namespace openspace::scripting; + using namespace std::string_literals; + + ScriptScheduler scheduler; + + ghoul::Dictionary testDictionary1 = { + { "Time", "2000 JAN 03 12:00:00"s }, + { "ForwardScript", "ForwardScript1"s }, + { "BackwardScript", "BackwardScript1"s } + }; + + scheduler.loadScripts({ + { "1", testDictionary1 } + }); + + auto res = scheduler.progressTo( + openspace::Time::ref().convertTime("2000 JAN 03 11:00:00") + ); + ASSERT_EQ(res.first, res.second); + + res = scheduler.progressTo( + openspace::Time::ref().convertTime("2000 JAN 03 12:00:00") + ); + ASSERT_EQ(1, std::distance(res.first, res.second)); + EXPECT_EQ("ForwardScript1", *(res.first)); + + res = scheduler.progressTo( + openspace::Time::ref().convertTime("2000 JAN 03 12:01:00") + ); + ASSERT_EQ(res.first, res.second); + + res = scheduler.progressTo( + openspace::Time::ref().convertTime("2000 JAN 03 12:00:00") + ); + ASSERT_EQ(1, std::distance(res.first, res.second)); + EXPECT_EQ("BackwardScript1", *(res.first)); +} + +TEST_F(ScriptSchedulerTest, SameTime) { + using namespace openspace::scripting; + using namespace std::string_literals; + + ScriptScheduler scheduler; + + ghoul::Dictionary testDictionary1 = { + { "Time", "2000 JAN 03 12:00:00"s }, + { "ForwardScript", "ForwardScript1"s }, + { "BackwardScript", "BackwardScript1"s } + }; + + scheduler.loadScripts({ + { "1", testDictionary1 } + }); + + auto res = scheduler.progressTo( + openspace::Time::ref().convertTime("2000 JAN 03 12:00:00") + ); + ASSERT_EQ(1, std::distance(res.first, res.second)); + EXPECT_EQ("ForwardScript1", *(res.first)); + + res = scheduler.progressTo( + openspace::Time::ref().convertTime("2000 JAN 03 12:00:00") + ); + ASSERT_EQ(res.first, res.second); +} + +TEST_F(ScriptSchedulerTest, MultiInnerJump) { + using namespace openspace::scripting; + using namespace std::string_literals; + + ScriptScheduler scheduler; + + ghoul::Dictionary testDictionary1 = { + { "Time", "2000 JAN 03 12:00:00"s }, + { "ForwardScript", "ForwardScript1"s }, + { "BackwardScript", "BackwardScript1"s } + }; + + scheduler.loadScripts({ + { "1", testDictionary1 } + }); + + auto res = scheduler.progressTo( + openspace::Time::ref().convertTime("2000 JAN 03 10:00:00") + ); + ASSERT_EQ(res.first, res.second); + + res = scheduler.progressTo( + openspace::Time::ref().convertTime("2000 JAN 03 11:00:00") + ); + ASSERT_EQ(res.first, res.second); + + res = scheduler.progressTo( + openspace::Time::ref().convertTime("2000 JAN 03 13:00:00") + ); + ASSERT_EQ(1, std::distance(res.first, res.second)); + EXPECT_EQ("ForwardScript1", *(res.first)); + + res = scheduler.progressTo( + openspace::Time::ref().convertTime("2000 JAN 03 12:30:00") + ); + ASSERT_EQ(res.first, res.second); +} + +TEST_F(ScriptSchedulerTest, MultipleForwardSingleJumpMultipleLoad) { + using namespace openspace::scripting; + using namespace std::string_literals; + + ghoul::Dictionary testDictionary1 = { + { "Time", "2000 JAN 03"s }, + { "ForwardScript", "ForwardScript1"s }, + { "BackwardScript", "BackwardScript1"s } + }; + + ghoul::Dictionary testDictionary2 = { + { "Time", "2000 JAN 05"s }, + { "ForwardScript", "ForwardScript2"s }, + { "BackwardScript", "BackwardScript2"s } + + }; + + ScriptScheduler scheduler; + + scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 01")); + scheduler.loadScripts({ + { "1", testDictionary1 } + }); + + scheduler.loadScripts({ + { "1", testDictionary2 } + }); + + auto res = scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 02")); + ASSERT_EQ(res.first, res.second); + + res = scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 04")); + ASSERT_EQ(1, std::distance(res.first, res.second)); + EXPECT_EQ("ForwardScript1", *(res.first)); + + res = scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 06")); + ASSERT_EQ(1, std::distance(res.first, res.second)); + EXPECT_EQ("ForwardScript2", *(res.first)); +} + +TEST_F(ScriptSchedulerTest, MultipleForwardOrderingMultipleLoad) { + using namespace openspace::scripting; + using namespace std::string_literals; + + ghoul::Dictionary testDictionary1 = { + { "Time", "2000 JAN 03"s }, + { "ForwardScript", "ForwardScript1"s }, + { "BackwardScript", "BackwardScript1"s } + }; + + ghoul::Dictionary testDictionary2 = { + { "Time", "2000 JAN 05"s }, + { "ForwardScript", "ForwardScript2"s }, + { "BackwardScript", "BackwardScript2"s } + }; + + ScriptScheduler scheduler; + + scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 01")); + scheduler.loadScripts({ + { "1", testDictionary1 } + }); + scheduler.loadScripts({ + { "1", testDictionary2 } + }); + + auto res = scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 02")); + ASSERT_EQ(res.first, res.second); + + res = scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 06")); + ASSERT_EQ(2, std::distance(res.first, res.second)); + EXPECT_EQ("ForwardScript1", *(res.first)); + EXPECT_EQ("ForwardScript2", *(std::next(res.first))); +} + +TEST_F(ScriptSchedulerTest, MultipleBackwardSingleJumpMultipleLoad) { + using namespace openspace::scripting; + using namespace std::string_literals; + + ScriptScheduler scheduler; + + ghoul::Dictionary testDictionary1 = { + { "Time", "2000 JAN 03"s }, + { "ForwardScript", "ForwardScript1"s }, + { "BackwardScript", "BackwardScript1"s } + }; + + ghoul::Dictionary testDictionary2 = { + { "Time", "2000 JAN 05"s }, + { "ForwardScript", "ForwardScript2"s }, + { "BackwardScript", "BackwardScript2"s } + }; + + scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 07")); + scheduler.loadScripts({ + { "1", testDictionary1 } + }); + scheduler.loadScripts({ + { "1", testDictionary2 } + }); + + auto res = scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 06")); + ASSERT_EQ(res.first, res.second); + + res = scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 04")); + ASSERT_EQ(1, std::distance(res.first, res.second)); + EXPECT_EQ("BackwardScript2", *(res.first)); + + res = scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 01")); + ASSERT_EQ(1, std::distance(res.first, res.second)); + EXPECT_EQ("BackwardScript1", *(res.first)); +} + +TEST_F(ScriptSchedulerTest, MultipleBackwardOrderingMultipleLoad) { + using namespace openspace::scripting; + using namespace std::string_literals; + + ScriptScheduler scheduler; + + ghoul::Dictionary testDictionary1 = { + { "Time", "2000 JAN 03"s }, + { "ForwardScript", "ForwardScript1"s }, + { "BackwardScript", "BackwardScript1"s } + }; + + ghoul::Dictionary testDictionary2 = { + { "Time", "2000 JAN 05"s }, + { "ForwardScript", "ForwardScript2"s }, + { "BackwardScript", "BackwardScript2"s } + }; + + scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 07")); + scheduler.loadScripts({ + { "1", testDictionary1 } + }); + scheduler.loadScripts({ + { "1", testDictionary2 } + }); + + auto res = scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 06")); + ASSERT_EQ(res.first, res.second); + + res = scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 01")); + ASSERT_EQ(2, std::distance(res.first, res.second)); + EXPECT_EQ("BackwardScript2", *(res.first)); + EXPECT_EQ("BackwardScript1", *(std::next(res.first))); +} + +TEST_F(ScriptSchedulerTest, ForwardBackwardsMultipleLoad) { + using namespace openspace::scripting; + using namespace std::string_literals; + + ScriptScheduler scheduler; + + ghoul::Dictionary testDictionary1 = { + { "Time", "2000 JAN 03"s }, + { "ForwardScript", "ForwardScript1"s }, + { "BackwardScript", "BackwardScript1"s } + }; + + ghoul::Dictionary testDictionary2 = { + { "Time", "2000 JAN 05"s }, + { "ForwardScript", "ForwardScript2"s }, + { "BackwardScript", "BackwardScript2"s } + }; + + scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 01")); + scheduler.loadScripts({ + { "1", testDictionary1 } + }); + scheduler.loadScripts({ + { "1", testDictionary2 } + }); + + auto res = scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 04")); + ASSERT_EQ(1, std::distance(res.first, res.second)); + EXPECT_EQ("ForwardScript1", *(res.first)); + + res = scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 01")); + ASSERT_EQ(1, std::distance(res.first, res.second)); + EXPECT_EQ("BackwardScript1", *(res.first)); + + res = scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 07")); + ASSERT_EQ(2, std::distance(res.first, res.second)); + + res = scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 04")); + ASSERT_EQ(1, std::distance(res.first, res.second)); + EXPECT_EQ("BackwardScript2", *(res.first)); +} + +TEST_F(ScriptSchedulerTest, RewindMultipleLoad) { + using namespace openspace::scripting; + using namespace std::string_literals; + + ScriptScheduler scheduler; + + ghoul::Dictionary testDictionary1 = { + { "Time", "2000 JAN 03"s }, + { "ForwardScript", "ForwardScript1"s }, + { "BackwardScript", "BackwardScript1"s } + }; + + ghoul::Dictionary testDictionary2 = { + { "Time", "2000 JAN 05"s }, + { "ForwardScript", "ForwardScript2"s }, + { "BackwardScript", "BackwardScript2"s } + }; + + scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 01")); + scheduler.loadScripts({ + { "1", testDictionary1 } + }); + scheduler.loadScripts({ + { "1", testDictionary2 } + }); + + auto res = scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 07")); + ASSERT_EQ(2, std::distance(res.first, res.second)); + + scheduler.rewind(); + + res = scheduler.progressTo(openspace::Time::ref().convertTime("2000 JAN 04")); + ASSERT_EQ(1, std::distance(res.first, res.second)); + EXPECT_EQ("ForwardScript1", *(res.first)); +} + +TEST_F(ScriptSchedulerTest, AllScriptsMultipleLoad) { + using namespace openspace::scripting; + using namespace std::string_literals; + + ScriptScheduler scheduler; + + + ghoul::Dictionary testDictionary1 = { + { "Time", "2000 JAN 03"s }, + { "ForwardScript", "ForwardScript1"s }, + { "BackwardScript", "BackwardScript1"s } + }; + + ghoul::Dictionary testDictionary2 = { + { "Time", "2000 JAN 05"s }, + { "ForwardScript", "ForwardScript2"s }, + { "BackwardScript", "BackwardScript2"s } + }; + + ghoul::Dictionary testDictionary3 = { + { "Time", "2000 JAN 10"s }, + { "ForwardScript", "ForwardScript3"s }, + { "BackwardScript", "BackwardScript3"s } + }; + + scheduler.loadScripts({ + { "1", testDictionary1 } + }); + + scheduler.loadScripts({ + { "1", testDictionary2 } + }); + + scheduler.loadScripts({ + { "1", testDictionary3 } + }); + + auto allScripts = scheduler.allScripts(); + ASSERT_EQ(3, allScripts.size()); + + EXPECT_LE(allScripts[0].time, allScripts[1].time); + EXPECT_LE(allScripts[1].time, allScripts[2].time); +} + +TEST_F(ScriptSchedulerTest, AllScriptsMixedLoad) { + using namespace openspace::scripting; + using namespace std::string_literals; + + ScriptScheduler scheduler; + + + ghoul::Dictionary testDictionary1 = { + { "Time", "2000 JAN 03"s }, + { "ForwardScript", "ForwardScript1"s }, + { "BackwardScript", "BackwardScript1"s } + }; + + ghoul::Dictionary testDictionary2 = { + { "Time", "2000 JAN 05"s }, + { "ForwardScript", "ForwardScript2"s }, + { "BackwardScript", "BackwardScript2"s } + }; + + ghoul::Dictionary testDictionary3 = { + { "Time", "2000 JAN 10"s }, + { "ForwardScript", "ForwardScript3"s }, + { "BackwardScript", "BackwardScript3"s } + }; + + scheduler.loadScripts({ + { "1", testDictionary1 } + }); + + scheduler.loadScripts({ + { "1", testDictionary2 }, + { "2", testDictionary3 } + }); + + auto allScripts = scheduler.allScripts(); + ASSERT_EQ(3, allScripts.size()); + + EXPECT_LE(allScripts[0].time, allScripts[1].time); + EXPECT_LE(allScripts[1].time, allScripts[2].time); +}