From 81fda6c8db43712559e293880d26f01bef31b36e Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Wed, 12 Feb 2020 00:01:24 +0100 Subject: [PATCH] Update Ghoul repository Adapt to changes in Ghoul --- ext/ghoul | 2 +- include/openspace/properties/numericalproperty.h | 2 +- include/openspace/properties/numericalproperty.inl | 6 +++--- include/openspace/properties/property.h | 6 +++--- include/openspace/properties/templateproperty.h | 4 ++-- include/openspace/properties/templateproperty.inl | 12 ++++++------ include/openspace/properties/triggerproperty.h | 2 +- .../tasks/kameleondocumentationtask.cpp | 4 +--- .../tasks/kameleonmetadatatojsontask.cpp | 3 +-- .../kameleonvolume/tasks/kameleonvolumetorawtask.cpp | 3 +-- .../rendering/renderableplanetprojection.cpp | 8 ++++---- modules/volume/tasks/generaterawvolumetask.cpp | 3 +-- modules/volume/transferfunction.cpp | 3 +-- src/interaction/navigationhandler.cpp | 6 +++--- src/properties/property.cpp | 8 ++++---- src/properties/triggerproperty.cpp | 2 +- 16 files changed, 34 insertions(+), 40 deletions(-) diff --git a/ext/ghoul b/ext/ghoul index 423d026fa4..42c4d7e985 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 423d026fa489b0f8b53284be916f3d82bc33d3fd +Subproject commit 42c4d7e9855516510249fa6520e5d62beb679115 diff --git a/include/openspace/properties/numericalproperty.h b/include/openspace/properties/numericalproperty.h index e6fce71478..d66ec0e99c 100644 --- a/include/openspace/properties/numericalproperty.h +++ b/include/openspace/properties/numericalproperty.h @@ -67,7 +67,7 @@ public: using TemplateProperty::operator=; - void setInterpolationTarget(ghoul::any value) override; + void setInterpolationTarget(std::any value) override; void setLuaInterpolationTarget(lua_State* state) override; void setStringInterpolationTarget(std::string value) override; diff --git a/include/openspace/properties/numericalproperty.inl b/include/openspace/properties/numericalproperty.inl index f5badd7e03..eb4504ae84 100644 --- a/include/openspace/properties/numericalproperty.inl +++ b/include/openspace/properties/numericalproperty.inl @@ -343,7 +343,7 @@ bool NumericalProperty::setStringValue(std::string value) { value, success ); if (success) { - TemplateProperty::set(ghoul::any(std::move(thisValue))); + TemplateProperty::set(std::any(std::move(thisValue))); } return success; } @@ -422,8 +422,8 @@ std::string NumericalProperty::jsonValue() const { } template -void NumericalProperty::setInterpolationTarget(ghoul::any value) { - T v = ghoul::any_cast(std::move(value)); +void NumericalProperty::setInterpolationTarget(std::any value) { + T v = std::any_cast(std::move(value)); _interpolationStart = TemplateProperty::_value; _interpolationEnd = std::move(v); diff --git a/include/openspace/properties/property.h b/include/openspace/properties/property.h index 6284597f59..1e5dd5c8b3 100644 --- a/include/openspace/properties/property.h +++ b/include/openspace/properties/property.h @@ -153,7 +153,7 @@ public: * \return The value that is encapsulated by this Property, or an empty ghoul::any * object if the method was not overritten. */ - virtual ghoul::any get() const; + virtual std::any get() const; /** * Sets the value encapsulated by this Property to the \p value passed to this @@ -164,7 +164,7 @@ public: * * \param value The new value that should be stored in this Property */ - virtual void set(ghoul::any value); + virtual void set(std::any value); /** * This method returns the type that is requested by this Property for the set method. @@ -453,7 +453,7 @@ public: virtual std::string jsonValue() const; /// Interpolation methods - virtual void setInterpolationTarget(ghoul::any value); + virtual void setInterpolationTarget(std::any value); virtual void setLuaInterpolationTarget(lua_State* state); virtual void setStringInterpolationTarget(std::string value); diff --git a/include/openspace/properties/templateproperty.h b/include/openspace/properties/templateproperty.h index 2693b48eed..eb55526ee1 100644 --- a/include/openspace/properties/templateproperty.h +++ b/include/openspace/properties/templateproperty.h @@ -86,7 +86,7 @@ public: * * \return The stored value packed into a ghoul::any object */ - virtual ghoul::any get() const override; + virtual std::any get() const override; /** * Sets the value from the provided ghoul::any object. If the types between @@ -95,7 +95,7 @@ public: * * \param value The value that is used to set this Property */ - virtual void set(ghoul::any value) override; + virtual void set(std::any value) override; /** * Returns the std::type_info describing the template parameter diff --git a/include/openspace/properties/templateproperty.inl b/include/openspace/properties/templateproperty.inl index 444270d07d..56fdca6a1a 100644 --- a/include/openspace/properties/templateproperty.inl +++ b/include/openspace/properties/templateproperty.inl @@ -186,13 +186,13 @@ std::ostream& operator<<(std::ostream& os, const TemplateProperty& obj) { } template -ghoul::any TemplateProperty::get() const { - return ghoul::any(_value); +std::any TemplateProperty::get() const { + return std::any(_value); } template -void TemplateProperty::set(ghoul::any value) { - T v = ghoul::any_cast(std::move(value)); +void TemplateProperty::set(std::any value) { + T v = std::any_cast(std::move(value)); if (v != _value) { _value = std::move(v); notifyChangeListeners(); @@ -221,7 +221,7 @@ bool TemplateProperty::setLuaValue(lua_State* state) { success ); if (success) { - set(ghoul::any(thisValue)); + set(std::any(thisValue)); } return success; } @@ -248,7 +248,7 @@ bool TemplateProperty::setStringValue(std::string value) { success ); if (success) { - set(ghoul::any(thisValue)); + set(std::any(thisValue)); } return success; } diff --git a/include/openspace/properties/triggerproperty.h b/include/openspace/properties/triggerproperty.h index fdb6b030c2..cd741a1101 100644 --- a/include/openspace/properties/triggerproperty.h +++ b/include/openspace/properties/triggerproperty.h @@ -64,7 +64,7 @@ public: * listeners regardless of the value * \param value The ignored value */ - void set(ghoul::any value) override; + void set(std::any value) override; std::string toJson() const override; diff --git a/modules/kameleonvolume/tasks/kameleondocumentationtask.cpp b/modules/kameleonvolume/tasks/kameleondocumentationtask.cpp index 0e70a6d23d..f4939a794d 100644 --- a/modules/kameleonvolume/tasks/kameleondocumentationtask.cpp +++ b/modules/kameleonvolume/tasks/kameleondocumentationtask.cpp @@ -67,8 +67,6 @@ void KameleonDocumentationTask::perform(const Task::ProgressCallback & progressC KameleonVolumeReader reader(_inputPath); ghoul::Dictionary kameleonDictionary = reader.readMetaData(); progressCallback(0.33f); - ghoul::DictionaryJsonFormatter formatter; - ghoul::Dictionary dictionary = { { "kameleon", std::move(kameleonDictionary) }, @@ -80,7 +78,7 @@ void KameleonDocumentationTask::perform(const Task::ProgressCallback & progressC { "input", _inputPath } }; - std::string json = formatter.format(dictionary); + std::string json = ghoul::formatJson(dictionary); progressCallback(0.66f); std::ifstream handlebarsInput(absPath(HandlebarsFilename)); diff --git a/modules/kameleonvolume/tasks/kameleonmetadatatojsontask.cpp b/modules/kameleonvolume/tasks/kameleonmetadatatojsontask.cpp index 03fff1122b..c732813161 100644 --- a/modules/kameleonvolume/tasks/kameleonmetadatatojsontask.cpp +++ b/modules/kameleonvolume/tasks/kameleonmetadatatojsontask.cpp @@ -63,8 +63,7 @@ void KameleonMetadataToJsonTask::perform(const Task::ProgressCallback& progressC ghoul::Dictionary dictionary = reader.readMetaData(); progressCallback(0.5f); - ghoul::DictionaryJsonFormatter formatter; - std::string json = formatter.format(dictionary); + std::string json = ghoul::formatJson(dictionary); std::ofstream output(_outputPath); output << std::move(json); progressCallback(1.0f); diff --git a/modules/kameleonvolume/tasks/kameleonvolumetorawtask.cpp b/modules/kameleonvolume/tasks/kameleonvolumetorawtask.cpp index 4446270a76..8f5f9be5b3 100644 --- a/modules/kameleonvolume/tasks/kameleonvolumetorawtask.cpp +++ b/modules/kameleonvolume/tasks/kameleonvolumetorawtask.cpp @@ -197,8 +197,7 @@ void KameleonVolumeToRawTask::perform(const Task::ProgressCallback& progressCall outputMetadata.setValue(KeyMaxValue, static_cast(reader.maxValue(_variable))); outputMetadata.setValue(KeyVisUnit, reader.getVisUnit(_variable)); - ghoul::DictionaryLuaFormatter formatter; - std::string metadataString = formatter.format(outputMetadata); + std::string metadataString = ghoul::formatLua(outputMetadata); std::fstream f(_dictionaryOutputPath, std::ios::out); f << "return " << metadataString; diff --git a/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp b/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp index d65b9f929a..6abdfaaff1 100644 --- a/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp +++ b/modules/spacecraftinstruments/rendering/renderableplanetprojection.cpp @@ -483,16 +483,16 @@ void RenderablePlanetProjection::imageProjectGPU( _fboProgramObject->setUniform(_fboUniformCache.boresight, _boresight); if (_geometry->hasProperty("Radius")) { - ghoul::any r = _geometry->property("Radius")->get(); - if (glm::vec3* radius = ghoul::any_cast(&r)){ + std::any r = _geometry->property("Radius")->get(); + if (glm::vec3* radius = std::any_cast(&r)){ _fboProgramObject->setUniform(_fboUniformCache.radius, radius); } } else { LERROR("Geometry object needs to provide radius"); } if (_geometry->hasProperty("Segments")) { - ghoul::any s = _geometry->property("Segments")->get(); - if (int* segments = ghoul::any_cast(&s)) { + std::any s = _geometry->property("Segments")->get(); + if (int* segments = std::any_cast(&s)) { _fboProgramObject->setUniform(_fboUniformCache.segments, segments[0]); } }else{ diff --git a/modules/volume/tasks/generaterawvolumetask.cpp b/modules/volume/tasks/generaterawvolumetask.cpp index 2a975f6c68..e89bece66b 100644 --- a/modules/volume/tasks/generaterawvolumetask.cpp +++ b/modules/volume/tasks/generaterawvolumetask.cpp @@ -172,8 +172,7 @@ void GenerateRawVolumeTask::perform(const Task::ProgressCallback& progressCallba metadata.maxValue = maxVal; ghoul::Dictionary outputDictionary = metadata.dictionary(); - ghoul::DictionaryLuaFormatter formatter; - std::string metadataString = formatter.format(outputDictionary); + std::string metadataString = ghoul::formatLua(outputDictionary); std::fstream f(_dictionaryOutputPath, std::ios::out); f << "return " << metadataString; diff --git a/modules/volume/transferfunction.cpp b/modules/volume/transferfunction.cpp index b0fbc5386b..b45f9b04fb 100644 --- a/modules/volume/transferfunction.cpp +++ b/modules/volume/transferfunction.cpp @@ -144,11 +144,10 @@ void TransferFunction::saveEnvelopesToFile(const std::string& path) { envelopesToLua(state); ghoul::lua::luaDictionaryFromState(state, dictionary); - ghoul::DictionaryLuaFormatter formatter; std::ofstream tfFile; tfFile.open(path); tfFile << "return {"; - tfFile << formatter.format(dictionary); + tfFile << ghoul::formatLua(dictionary); tfFile << "}"; tfFile.close(); } diff --git a/src/interaction/navigationhandler.cpp b/src/interaction/navigationhandler.cpp index 8b2afb793c..ed57ecea91 100644 --- a/src/interaction/navigationhandler.cpp +++ b/src/interaction/navigationhandler.cpp @@ -411,7 +411,8 @@ void NavigationHandler::saveNavigationState(const std::string& filepath, return; } state = navigationState(*referenceFrame).dictionary(); - } else { + } + else { state = navigationState().dictionary(); } @@ -419,9 +420,8 @@ void NavigationHandler::saveNavigationState(const std::string& filepath, std::string absolutePath = absPath(filepath); LINFO(fmt::format("Saving camera position: {}", absolutePath)); - ghoul::DictionaryLuaFormatter formatter; std::ofstream ofs(absolutePath.c_str()); - ofs << "return " << formatter.format(state.dictionary()); + ofs << "return " << ghoul::formatLua(state.dictionary()); ofs.close(); } } diff --git a/src/properties/property.cpp b/src/properties/property.cpp index d5cef6266f..22812fda89 100644 --- a/src/properties/property.cpp +++ b/src/properties/property.cpp @@ -133,15 +133,15 @@ std::string Property::fullyQualifiedIdentifier() const { return identifier; } -ghoul::any Property::get() const { - return ghoul::any(); +std::any Property::get() const { + return std::any(); } bool Property::getLuaValue(lua_State*) const { return false; } -void Property::set(ghoul::any) {} // NOLINT +void Property::set(std::any) {} // NOLINT bool Property::setLuaValue(lua_State*) { return false; @@ -365,7 +365,7 @@ std::string Property::generateAdditionalJsonDescription() const { return "{}"; } -void Property::setInterpolationTarget(ghoul::any) {} // NOLINT +void Property::setInterpolationTarget(std::any) {} // NOLINT void Property::setLuaInterpolationTarget(lua_State*) {} void Property::setStringInterpolationTarget(std::string) {} // NOLINT void Property::interpolateValue(float, ghoul::EasingFunc) {} diff --git a/src/properties/triggerproperty.cpp b/src/properties/triggerproperty.cpp index 7b3fe235a9..2f101820f5 100644 --- a/src/properties/triggerproperty.cpp +++ b/src/properties/triggerproperty.cpp @@ -39,7 +39,7 @@ bool TriggerProperty::setLuaValue(lua_State*) { return true; } -void TriggerProperty::set(ghoul::any) { +void TriggerProperty::set(std::any) { notifyChangeListeners(); }