diff --git a/apps/Wormhole/main.cpp b/apps/Wormhole/main.cpp index a688f80a13..92ab97ea96 100644 --- a/apps/Wormhole/main.cpp +++ b/apps/Wormhole/main.cpp @@ -62,7 +62,7 @@ int main(int argc, char** argv) { ); std::stringstream defaultPassword; - defaultPassword << std::hex << std::setfill('0') << std::setw(6) << + defaultPassword << std::hex << std::setfill('0') << std::setw(6) << (std::hash{}( std::chrono::system_clock::now().time_since_epoch().count() ) % 0xffffff); diff --git a/ext/ghoul b/ext/ghoul index fd1187437c..f0e8a06c9a 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit fd1187437c59553f2dba74684b791220cbb8d7fc +Subproject commit f0e8a06c9a92a282d2c7197c9388db1301d797ce diff --git a/ext/sgct b/ext/sgct index 52e2943cd7..03a8cd877e 160000 --- a/ext/sgct +++ b/ext/sgct @@ -1 +1 @@ -Subproject commit 52e2943cd74bb8346db0411bf17ed3dab4245e03 +Subproject commit 03a8cd877e540beb2e4762be6036cf895ee77647 diff --git a/include/openspace/engine/configurationmanager.h b/include/openspace/engine/configurationmanager.h index ac7c325e27..63881b2dd3 100644 --- a/include/openspace/engine/configurationmanager.h +++ b/include/openspace/engine/configurationmanager.h @@ -86,9 +86,10 @@ public: /// The key that stores the factory documentation values static constexpr const char* KeyFactoryDocumentation = "FactoryDocumentation"; - /// The key that decides whether or not we should require incoming web socket connections - /// to authorize or not - static constexpr const char* KeyRequireSocketAuthentication = "RequireSocketAuthentication"; + /// The key that decides whether or not we should require incoming web socket + /// connections to authorize or not + static constexpr const char* KeyRequireSocketAuthentication = + "RequireSocketAuthentication"; /// The key that stores the location of the asset file that is initially loaded static constexpr const char* KeyConfigAsset = "Asset"; diff --git a/include/openspace/network/messagestructures.h b/include/openspace/network/messagestructures.h index e677f1f306..d542d99d68 100644 --- a/include/openspace/network/messagestructures.h +++ b/include/openspace/network/messagestructures.h @@ -206,7 +206,7 @@ struct TimeKeyframe { // Timestamp size = sizeof(_timestamp); memcpy(&_timestamp, buffer.data() + offset, size); - offset += size; + // offset += size; }; }; diff --git a/include/openspace/properties/binaryproperty.h b/include/openspace/properties/binaryproperty.h index d810a8b8b7..443216c6c3 100644 --- a/include/openspace/properties/binaryproperty.h +++ b/include/openspace/properties/binaryproperty.h @@ -1,26 +1,26 @@ /***************************************************************************************** -* * -* OpenSpace * -* * -* Copyright (c) 2014-2017 * -* * -* 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. * -****************************************************************************************/ + * * + * OpenSpace * + * * + * Copyright (c) 2014-2018 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ #ifndef __OPENSPACE_CORE___BINARYPROPERTY___H__ #define __OPENSPACE_CORE___BINARYPROPERTY___H__ diff --git a/include/openspace/properties/numericalproperty.h b/include/openspace/properties/numericalproperty.h index 1be4a3a5d9..fb6c75d271 100644 --- a/include/openspace/properties/numericalproperty.h +++ b/include/openspace/properties/numericalproperty.h @@ -70,7 +70,7 @@ public: void setInterpolationTarget(ghoul::any value) override; void setLuaInterpolationTarget(lua_State* state) override; void setStringInterpolationTarget(std::string value) override; - + void interpolateValue(float t, ghoul::EasingFunc easingFunc = nullptr) override; diff --git a/include/openspace/properties/numericalproperty.inl b/include/openspace/properties/numericalproperty.inl index 91fe0ddee6..d4bfc6d9be 100644 --- a/include/openspace/properties/numericalproperty.inl +++ b/include/openspace/properties/numericalproperty.inl @@ -388,10 +388,14 @@ void NumericalProperty::setExponent(float exponent) { template std::string NumericalProperty::generateAdditionalJsonDescription() const { std::string result = "{ "; - result += "\"" + MinimumValueKey + "\": " + luaToJson(std::to_string(_minimumValue)) + ","; - result += "\"" + MaximumValueKey + "\": " + luaToJson(std::to_string(_maximumValue)) + ","; - result += "\"" + SteppingValueKey + "\": " + luaToJson(std::to_string(_stepping)) + ","; - result += "\"" + ExponentValueKey + "\": " + luaToJson(std::to_string(_exponent)); + result += + "\"" + MinimumValueKey + "\": " + luaToJson(std::to_string(_minimumValue)) + ","; + result += + "\"" + MaximumValueKey + "\": " + luaToJson(std::to_string(_maximumValue)) + ","; + result += + "\"" + SteppingValueKey + "\": " + luaToJson(std::to_string(_stepping)) + ","; + result += + "\"" + ExponentValueKey + "\": " + luaToJson(std::to_string(_exponent)); result += " }"; return result; } diff --git a/include/openspace/properties/property.h b/include/openspace/properties/property.h index 4e51e5e740..c90d7b53e3 100644 --- a/include/openspace/properties/property.h +++ b/include/openspace/properties/property.h @@ -396,8 +396,8 @@ public: const ghoul::Dictionary& metaData() const; /** - * Convert the Property into a string containing a JSON representation of the Property. - * Includes description of the object. + * Convert the Property into a string containing a JSON representation of the + * Property. Includes description of the object. * @return the JSON string */ virtual std::string toJson() const; @@ -412,7 +412,7 @@ public: virtual void setInterpolationTarget(ghoul::any value); virtual void setLuaInterpolationTarget(lua_State* state); virtual void setStringInterpolationTarget(std::string value); - + virtual void interpolateValue(float t, ghoul::EasingFunc easingFunction = nullptr); diff --git a/include/openspace/properties/propertyowner.h b/include/openspace/properties/propertyowner.h index fe0d367795..6be2ea0c19 100644 --- a/include/openspace/properties/propertyowner.h +++ b/include/openspace/properties/propertyowner.h @@ -83,8 +83,8 @@ public: /** * Sets the identifier for this PropertyOwner. If the PropertyOwner does not have an * owner itself, the identifier must be globally unique. If the PropertyOwner has an - * owner, the identifier must be unique to the owner (including the owner's - * properties). No uniqueness check will be preformed here, but rather in the + * owner, the identifier must be unique to the owner (including the owner's + * properties). No uniqueness check will be preformed here, but rather in the * PropertyOwner::addProperty and PropertyOwner::addPropertySubOwner methods). * * \param identifier The identifier of this PropertyOwner. It must not contain any @@ -102,7 +102,7 @@ public: std::string identifier() const; /** - * Sets the user-facing name of this PropertyOwner. This name does not have to be + * Sets the user-facing name of this PropertyOwner. This name does not have to be * unique, but it is recommended to be. * * \param guiName The new user-facing name for this PropertyOwner diff --git a/include/openspace/rendering/renderable.h b/include/openspace/rendering/renderable.h index 575045be36..3b6817ed9f 100644 --- a/include/openspace/rendering/renderable.h +++ b/include/openspace/rendering/renderable.h @@ -101,7 +101,7 @@ public: protected: properties::BoolProperty _enabled; properties::FloatProperty _opacity; - + void registerUpdateRenderBinFromOpacity(); private: diff --git a/include/openspace/scene/scene.h b/include/openspace/scene/scene.h index 5321349519..b07c8c3029 100644 --- a/include/openspace/scene/scene.h +++ b/include/openspace/scene/scene.h @@ -176,7 +176,7 @@ public: * Adds an interpolation request for the passed \p prop that will run for * \p durationSeconds seconds. Every time the #updateInterpolations method is called * the Property will be notified that it has to update itself using the stored - * interpolation values. If an interpolation record already exists for the passed + * interpolation values. If an interpolation record already exists for the passed * \p prop, the previous record will be overwritten and the remaining time of the old * interpolation is ignored. * @@ -186,7 +186,7 @@ public: * * \pre \p prop must not be \c nullptr * \pre \p durationSeconds must be positive and not 0 - * \post A new interpolation record exists for \p that is not expired + * \post A new interpolation record exists for \p that is not expired */ void addInterpolation(properties::Property* prop, float durationSeconds, ghoul::EasingFunction easingFunction = ghoul::EasingFunction::Linear); diff --git a/modules/atmosphere/atmospheremodule.cpp b/modules/atmosphere/atmospheremodule.cpp index 226c36ffab..82c50072b9 100644 --- a/modules/atmosphere/atmospheremodule.cpp +++ b/modules/atmosphere/atmospheremodule.cpp @@ -23,16 +23,15 @@ ****************************************************************************************/ #include + +#include +#include #include #include -#include - -#include - namespace openspace { -AtmosphereModule::AtmosphereModule() : OpenSpaceModule("Atmosphere") {} +AtmosphereModule::AtmosphereModule() : OpenSpaceModule(Name) {} void AtmosphereModule::internalInitialize(const ghoul::Dictionary&) { auto fRenderable = FactoryManager::ref().factory(); diff --git a/modules/atmosphere/atmospheremodule.h b/modules/atmosphere/atmospheremodule.h index 3553d9f3e6..e66485f29e 100644 --- a/modules/atmosphere/atmospheremodule.h +++ b/modules/atmosphere/atmospheremodule.h @@ -26,12 +26,13 @@ #define __OPENSPACE_MODULE_ATMOSPHERE___ATMOSPHERE_MODULE___H__ #include -#include namespace openspace { class AtmosphereModule : public OpenSpaceModule { public: + constexpr static const char* Name = "Atmosphere"; + AtmosphereModule(); private: diff --git a/modules/atmosphere/rendering/atmospheredeferredcaster.cpp b/modules/atmosphere/rendering/atmospheredeferredcaster.cpp index 21692091ec..fb44789aad 100644 --- a/modules/atmosphere/rendering/atmospheredeferredcaster.cpp +++ b/modules/atmosphere/rendering/atmospheredeferredcaster.cpp @@ -59,14 +59,8 @@ */ #include -#include -#include -#include -#include -#include -#include -#include +#include #include #include #include @@ -74,12 +68,17 @@ #include #include #include +#include +#include +#include +#include +#include +#include #include #include #include #include #include - #include #include @@ -90,16 +89,16 @@ namespace { - const char* _loggerCat = "AtmosphereDeferredcaster"; - const char* GlslDeferredcastPath = + constexpr const char* _loggerCat = "AtmosphereDeferredcaster"; + constexpr const char* GlslDeferredcastPath = "${MODULES}/atmosphere/shaders/atmosphere_deferred_fs.glsl"; - const char* GlslDeferredcastFSPath = + constexpr const char* GlslDeferredcastFSPath = "${MODULES}/atmosphere/shaders/atmosphere_deferred_fs.glsl"; - const char* GlslDeferredcastVsPath = + constexpr const char* GlslDeferredcastVsPath = "${MODULES}/atmosphere/shaders/atmosphere_deferred_vs.glsl"; - const float ATM_EPS = 2.0; - const double KM_TO_M = 1000.0; + constexpr const float ATM_EPS = 2.f; + constexpr const float KM_TO_M = 1000.f; } // namespace namespace openspace { diff --git a/modules/atmosphere/shaders/atmosphere_deferred_vs.glsl b/modules/atmosphere/shaders/atmosphere_deferred_vs.glsl index 9568c60136..76fae77721 100644 --- a/modules/atmosphere/shaders/atmosphere_deferred_vs.glsl +++ b/modules/atmosphere/shaders/atmosphere_deferred_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/deltaE_calc_fs.glsl b/modules/atmosphere/shaders/deltaE_calc_fs.glsl index bacc9e0734..ce445632c9 100644 --- a/modules/atmosphere/shaders/deltaE_calc_fs.glsl +++ b/modules/atmosphere/shaders/deltaE_calc_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/deltaE_calc_vs.glsl b/modules/atmosphere/shaders/deltaE_calc_vs.glsl index 578d7ab02f..b379e97bfe 100644 --- a/modules/atmosphere/shaders/deltaE_calc_vs.glsl +++ b/modules/atmosphere/shaders/deltaE_calc_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/deltaJ_calc_fs.glsl b/modules/atmosphere/shaders/deltaJ_calc_fs.glsl index 9598e4d5c9..80f02f1862 100644 --- a/modules/atmosphere/shaders/deltaJ_calc_fs.glsl +++ b/modules/atmosphere/shaders/deltaJ_calc_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/deltaJ_calc_gs.glsl b/modules/atmosphere/shaders/deltaJ_calc_gs.glsl index a4dd2d50b5..eb98fa1059 100644 --- a/modules/atmosphere/shaders/deltaJ_calc_gs.glsl +++ b/modules/atmosphere/shaders/deltaJ_calc_gs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/deltaJ_calc_vs.glsl b/modules/atmosphere/shaders/deltaJ_calc_vs.glsl index 578d7ab02f..b379e97bfe 100644 --- a/modules/atmosphere/shaders/deltaJ_calc_vs.glsl +++ b/modules/atmosphere/shaders/deltaJ_calc_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/deltaS_calc_fs.glsl b/modules/atmosphere/shaders/deltaS_calc_fs.glsl index 014cd535fb..1f66741387 100644 --- a/modules/atmosphere/shaders/deltaS_calc_fs.glsl +++ b/modules/atmosphere/shaders/deltaS_calc_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -21,7 +21,7 @@ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ - + #version __CONTEXT__ #include "atmosphere_common.glsl" diff --git a/modules/atmosphere/shaders/deltaS_calc_gs.glsl b/modules/atmosphere/shaders/deltaS_calc_gs.glsl index a4dd2d50b5..eb98fa1059 100644 --- a/modules/atmosphere/shaders/deltaS_calc_gs.glsl +++ b/modules/atmosphere/shaders/deltaS_calc_gs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/deltaS_calc_vs.glsl b/modules/atmosphere/shaders/deltaS_calc_vs.glsl index 578d7ab02f..b379e97bfe 100644 --- a/modules/atmosphere/shaders/deltaS_calc_vs.glsl +++ b/modules/atmosphere/shaders/deltaS_calc_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/deltaS_sup_calc_fs.glsl b/modules/atmosphere/shaders/deltaS_sup_calc_fs.glsl index 09cf5026b3..0fc114328c 100644 --- a/modules/atmosphere/shaders/deltaS_sup_calc_fs.glsl +++ b/modules/atmosphere/shaders/deltaS_sup_calc_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/deltaS_sup_calc_gs.glsl b/modules/atmosphere/shaders/deltaS_sup_calc_gs.glsl index 8ca6044fd1..15b4964390 100644 --- a/modules/atmosphere/shaders/deltaS_sup_calc_gs.glsl +++ b/modules/atmosphere/shaders/deltaS_sup_calc_gs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/deltaS_sup_calc_vs.glsl b/modules/atmosphere/shaders/deltaS_sup_calc_vs.glsl index 7e3574bd9d..7cb84d0439 100644 --- a/modules/atmosphere/shaders/deltaS_sup_calc_vs.glsl +++ b/modules/atmosphere/shaders/deltaS_sup_calc_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/inScattering_calc_fs.glsl b/modules/atmosphere/shaders/inScattering_calc_fs.glsl index a55cbc78e1..f93fd6c304 100644 --- a/modules/atmosphere/shaders/inScattering_calc_fs.glsl +++ b/modules/atmosphere/shaders/inScattering_calc_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/inScattering_calc_gs.glsl b/modules/atmosphere/shaders/inScattering_calc_gs.glsl index aed3744bd2..93935134c4 100644 --- a/modules/atmosphere/shaders/inScattering_calc_gs.glsl +++ b/modules/atmosphere/shaders/inScattering_calc_gs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/inScattering_calc_vs.glsl b/modules/atmosphere/shaders/inScattering_calc_vs.glsl index 578d7ab02f..b379e97bfe 100644 --- a/modules/atmosphere/shaders/inScattering_calc_vs.glsl +++ b/modules/atmosphere/shaders/inScattering_calc_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/inScattering_sup_calc_fs.glsl b/modules/atmosphere/shaders/inScattering_sup_calc_fs.glsl index c7c4f09561..e07de3be1d 100644 --- a/modules/atmosphere/shaders/inScattering_sup_calc_fs.glsl +++ b/modules/atmosphere/shaders/inScattering_sup_calc_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/inScattering_sup_calc_gs.glsl b/modules/atmosphere/shaders/inScattering_sup_calc_gs.glsl index 8ca6044fd1..15b4964390 100644 --- a/modules/atmosphere/shaders/inScattering_sup_calc_gs.glsl +++ b/modules/atmosphere/shaders/inScattering_sup_calc_gs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/inScattering_sup_calc_vs.glsl b/modules/atmosphere/shaders/inScattering_sup_calc_vs.glsl index 7e3574bd9d..7cb84d0439 100644 --- a/modules/atmosphere/shaders/inScattering_sup_calc_vs.glsl +++ b/modules/atmosphere/shaders/inScattering_sup_calc_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/irradiance_calc_fs.glsl b/modules/atmosphere/shaders/irradiance_calc_fs.glsl index 48cc7ce40f..7042c6bddd 100644 --- a/modules/atmosphere/shaders/irradiance_calc_fs.glsl +++ b/modules/atmosphere/shaders/irradiance_calc_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/irradiance_calc_vs.glsl b/modules/atmosphere/shaders/irradiance_calc_vs.glsl index 578d7ab02f..b379e97bfe 100644 --- a/modules/atmosphere/shaders/irradiance_calc_vs.glsl +++ b/modules/atmosphere/shaders/irradiance_calc_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/irradiance_final_fs.glsl b/modules/atmosphere/shaders/irradiance_final_fs.glsl index 47771e8898..a0800fc507 100644 --- a/modules/atmosphere/shaders/irradiance_final_fs.glsl +++ b/modules/atmosphere/shaders/irradiance_final_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -21,6 +21,7 @@ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ + #version __CONTEXT__ #include "atmosphere_common.glsl" diff --git a/modules/atmosphere/shaders/irradiance_final_vs.glsl b/modules/atmosphere/shaders/irradiance_final_vs.glsl index f55a966566..e266156549 100644 --- a/modules/atmosphere/shaders/irradiance_final_vs.glsl +++ b/modules/atmosphere/shaders/irradiance_final_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/irradiance_sup_calc_fs.glsl b/modules/atmosphere/shaders/irradiance_sup_calc_fs.glsl index 005e1db59a..cdf31ca38c 100644 --- a/modules/atmosphere/shaders/irradiance_sup_calc_fs.glsl +++ b/modules/atmosphere/shaders/irradiance_sup_calc_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/irradiance_sup_calc_vs.glsl b/modules/atmosphere/shaders/irradiance_sup_calc_vs.glsl index 578d7ab02f..b379e97bfe 100644 --- a/modules/atmosphere/shaders/irradiance_sup_calc_vs.glsl +++ b/modules/atmosphere/shaders/irradiance_sup_calc_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/transmittance_calc_fs.glsl b/modules/atmosphere/shaders/transmittance_calc_fs.glsl index 7f57a7e0b2..411565b06c 100644 --- a/modules/atmosphere/shaders/transmittance_calc_fs.glsl +++ b/modules/atmosphere/shaders/transmittance_calc_fs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/atmosphere/shaders/transmittance_calc_vs.glsl b/modules/atmosphere/shaders/transmittance_calc_vs.glsl index d9ea954427..6e457a03e6 100644 --- a/modules/atmosphere/shaders/transmittance_calc_vs.glsl +++ b/modules/atmosphere/shaders/transmittance_calc_vs.glsl @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2016 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/base/dashboard/dashboarditemangle.cpp b/modules/base/dashboard/dashboarditemangle.cpp index 181956704a..56843babde 100644 --- a/modules/base/dashboard/dashboarditemangle.cpp +++ b/modules/base/dashboard/dashboarditemangle.cpp @@ -32,15 +32,14 @@ #include #include #include - #include #include #include namespace { - const char* KeyFontMono = "Mono"; + constexpr const char* KeyFontMono = "Mono"; - const float DefaultFontSize = 10.f; + constexpr const float DefaultFontSize = 10.f; static const openspace::properties::Property::PropertyInfo FontNameInfo = { "FontName", @@ -106,6 +105,7 @@ namespace openspace { documentation::Documentation DashboardItemAngle::Documentation() { using namespace documentation; + return { "DashboardItem Angle", "base_dashboarditem_angle", diff --git a/modules/base/dashboard/dashboarditemangle.h b/modules/base/dashboard/dashboarditemangle.h index f61a23fbcf..34fdbdabee 100644 --- a/modules/base/dashboard/dashboarditemangle.h +++ b/modules/base/dashboard/dashboarditemangle.h @@ -30,7 +30,6 @@ #include #include #include - #include namespace ghoul::fontrendering { class Font; } diff --git a/modules/base/dashboard/dashboarditemdate.h b/modules/base/dashboard/dashboarditemdate.h index 8698948475..37e3f9b95b 100644 --- a/modules/base/dashboard/dashboarditemdate.h +++ b/modules/base/dashboard/dashboarditemdate.h @@ -30,9 +30,7 @@ #include #include -namespace ghoul::fontrendering { - class Font; -} // namespace ghoul::fontrendering +namespace ghoul::fontrendering { class Font; } namespace openspace { diff --git a/modules/base/rendering/renderableplane.cpp b/modules/base/rendering/renderableplane.cpp index 3562b480b1..7e4911415b 100644 --- a/modules/base/rendering/renderableplane.cpp +++ b/modules/base/rendering/renderableplane.cpp @@ -176,7 +176,7 @@ void RenderablePlane::initializeGL() { absPath("${MODULE_BASE}/shaders/plane_fs.glsl") ); } - ); + ); } void RenderablePlane::deinitializeGL() { diff --git a/modules/base/rendering/screenspacedashboard.cpp b/modules/base/rendering/screenspacedashboard.cpp index 5f9ea9e638..33730c82e2 100644 --- a/modules/base/rendering/screenspacedashboard.cpp +++ b/modules/base/rendering/screenspacedashboard.cpp @@ -42,8 +42,6 @@ #include namespace { - const char* KeyName = "Name"; - static const openspace::properties::Property::PropertyInfo UseMainInfo = { "UseMainDashboard", "Use main dashboard", diff --git a/modules/base/rendering/screenspaceimagelocal.cpp b/modules/base/rendering/screenspaceimagelocal.cpp index e42c33db64..86d6705918 100644 --- a/modules/base/rendering/screenspaceimagelocal.cpp +++ b/modules/base/rendering/screenspaceimagelocal.cpp @@ -37,8 +37,6 @@ #include namespace { - const char* KeyName = "Name"; - static const openspace::properties::Property::PropertyInfo TexturePathInfo = { "TexturePath", "Texture path", diff --git a/modules/base/rendering/screenspaceimageonline.cpp b/modules/base/rendering/screenspaceimageonline.cpp index 4df3149a8e..8940ec8fa1 100644 --- a/modules/base/rendering/screenspaceimageonline.cpp +++ b/modules/base/rendering/screenspaceimageonline.cpp @@ -36,8 +36,6 @@ #include namespace { - constexpr const char* KeyName = "Name"; - static const openspace::properties::Property::PropertyInfo TextureInfo = { "URL", "Image URL", diff --git a/modules/base/rotation/fixedrotation.cpp b/modules/base/rotation/fixedrotation.cpp index fdcb009971..bba3dc1566 100644 --- a/modules/base/rotation/fixedrotation.cpp +++ b/modules/base/rotation/fixedrotation.cpp @@ -335,7 +335,7 @@ FixedRotation::FixedRotation(const ghoul::Dictionary& dictionary) _attachedNode = sceneGraphNode(_attachedObject); }); - auto setPropertyVisibility = [this](Axis& axis) { + auto setPropertyVisibility = [](Axis& axis) { using Visibility = properties::Property::Visibility; switch (axis.type) { case Axis::Type::Object: diff --git a/modules/cefwebgui/CMakeLists.txt b/modules/cefwebgui/CMakeLists.txt index 32f763226c..d61943247a 100644 --- a/modules/cefwebgui/CMakeLists.txt +++ b/modules/cefwebgui/CMakeLists.txt @@ -2,7 +2,7 @@ # # # OpenSpace # # # -# Copyright (c) 2014-2017 # +# Copyright (c) 2014-2018 # # # # 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 # diff --git a/modules/cefwebgui/cefwebguimodule.cpp b/modules/cefwebgui/cefwebguimodule.cpp index 123b69cd34..3186b1d326 100644 --- a/modules/cefwebgui/cefwebguimodule.cpp +++ b/modules/cefwebgui/cefwebguimodule.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/cefwebgui/cefwebguimodule.h b/modules/cefwebgui/cefwebguimodule.h index 576bc39927..7c0bc93584 100644 --- a/modules/cefwebgui/cefwebguimodule.h +++ b/modules/cefwebgui/cefwebguimodule.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef OPENSPACE_CEFWEBGUIMODULE_H -#define OPENSPACE_CEFWEBGUIMODULE_H +#ifndef __OPENSPACE_MODULE_CEFWEBGUI___CEFWEBGUIMODULE___H__ +#define __OPENSPACE_MODULE_CEFWEBGUI___CEFWEBGUIMODULE___H__ #include #include @@ -45,4 +45,4 @@ private: } -#endif //OPENSPACE_WEBGUIMODULE_H +#endif // __OPENSPACE_MODULE_CEFWEBGUI___CEFWEBGUIMODULE___H__ diff --git a/modules/cefwebgui/include/guirenderhandler.h b/modules/cefwebgui/include/guirenderhandler.h index 88da19389e..659a5e5184 100644 --- a/modules/cefwebgui/include/guirenderhandler.h +++ b/modules/cefwebgui/include/guirenderhandler.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_MODULE_WEBBROWSER___GUI_RENDER_HANDLER___H__ -#define __OPENSPACE_MODULE_WEBBROWSER___GUI_RENDER_HANDLER___H__ +#ifndef __OPENSPACE_MODULE_CEFWEBGUI___GUI_RENDER_HANDLER___H__ +#define __OPENSPACE_MODULE_CEFWEBGUI___GUI_RENDER_HANDLER___H__ #include #include @@ -41,14 +41,16 @@ public: GUIRenderHandler(); void initializeGL(); - void draw(void); + void draw(); void render() {}; private: std::unique_ptr _programObject; - GLuint _program, _vao, _vbo; + GLuint _program; + GLuint _vao; + GLuint _vbo; }; } // namespace openspace -#endif // __OPENSPACE_MODULE_WEBBROWSER___GUI_RENDER_HANDLER___H__ +#endif // __OPENSPACE_MODULE_CEFWEBGUI___GUI_RENDER_HANDLER___H__ diff --git a/modules/cefwebgui/src/guirenderhandler.cpp b/modules/cefwebgui/src/guirenderhandler.cpp index 047c632e0e..d4de455ab2 100644 --- a/modules/cefwebgui/src/guirenderhandler.cpp +++ b/modules/cefwebgui/src/guirenderhandler.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp b/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp index 81583ee16f..70b487955a 100644 --- a/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp +++ b/modules/fieldlinessequence/rendering/renderablefieldlinessequence.cpp @@ -452,7 +452,9 @@ bool RenderableFieldlinesSequence::extractMandatoryInfoFromDictionary( } else { LERROR(fmt::format( - "{}: FieldlinesSequence {} is not a valid directory", _identifier, sourceFolderPath + "{}: FieldlinesSequence {} is not a valid directory", + _identifier, + sourceFolderPath )); return false; } diff --git a/modules/globebrowsing/rendering/layershadermanager.cpp b/modules/globebrowsing/rendering/layershadermanager.cpp index 9108e4f814..cbe2ea6588 100644 --- a/modules/globebrowsing/rendering/layershadermanager.cpp +++ b/modules/globebrowsing/rendering/layershadermanager.cpp @@ -219,7 +219,10 @@ void LayerShaderManager::recompileShaderProgram( ghoul::Dictionary layerGroupNames; for (int i = 0; i < layergroupid::NUM_LAYER_GROUPS; ++i) { - layerGroupNames.setValue(std::to_string(i), layergroupid::LAYER_GROUP_IDENTIFIERS[i]); + layerGroupNames.setValue( + std::to_string(i), + layergroupid::LAYER_GROUP_IDENTIFIERS[i] + ); } shaderDictionary.setValue("layerGroups", layerGroupNames); diff --git a/modules/imgui/src/guiglobebrowsingcomponent.cpp b/modules/imgui/src/guiglobebrowsingcomponent.cpp index 83e2a12f5d..a2606ba5a2 100644 --- a/modules/imgui/src/guiglobebrowsingcomponent.cpp +++ b/modules/imgui/src/guiglobebrowsingcomponent.cpp @@ -79,7 +79,7 @@ void GuiGlobeBrowsingComponent::render() { std::remove_if( nodes.begin(), nodes.end(), - [module](SceneGraphNode* n) { + [](SceneGraphNode* n) { Renderable* r = n->renderable(); return !r || r->identifier() != "RenderableGlobe"; } diff --git a/modules/kameleon/src/kameleonwrapper.cpp b/modules/kameleon/src/kameleonwrapper.cpp index 621a6c45ae..befdf6a92a 100644 --- a/modules/kameleon/src/kameleonwrapper.cpp +++ b/modules/kameleon/src/kameleonwrapper.cpp @@ -226,15 +226,15 @@ float* KameleonWrapper::getUniformSampledValues( LDEBUG(fmt::format("{} Max: {}", var, varMax)); // HISTOGRAM - const int bins = 200; + constexpr const int NBins = 200; const float truncLim = 0.9f; - std::vector histogram (bins,0); - auto mapToHistogram = [varMin, varMax, bins](double val) { + std::vector histogram (NBins, 0); + auto mapToHistogram = [NBins, varMin, varMax](double val) { double zeroToOne = (val-varMin)/(varMax-varMin); - zeroToOne *= static_cast(bins); + zeroToOne *= static_cast(NBins); int izerotoone = static_cast(zeroToOne); - return glm::clamp(izerotoone, 0, bins-1); + return glm::clamp(izerotoone, 0, NBins - 1); }; //ProgressBar pb(static_cast(outDimensions.x)); @@ -332,7 +332,7 @@ float* KameleonWrapper::getUniformSampledValues( // std::cout << std::endl; //} // - // for(int i = 0; i < bins-1; ++i) { + // for(int i = 0; i < NBins-1; ++i) { // // sum += histogram[i]; // // if(sum + histogram[i+1] > sumuntil) { // // stop = i; @@ -345,7 +345,7 @@ float* KameleonWrapper::getUniformSampledValues( int sum = 0; int stop = 0; const int sumuntil = static_cast(static_cast(size) * truncLim); - for(int i = 0; i < bins; ++i) { + for(int i = 0; i < NBins; ++i) { sum += histogram[i]; if(sum > sumuntil) { stop = i; @@ -356,7 +356,7 @@ float* KameleonWrapper::getUniformSampledValues( } double dist = varMax - varMin; - dist = (dist / static_cast(bins)) * static_cast(stop); + dist = (dist / static_cast(NBins)) * static_cast(stop); varMax = varMin + dist; //LDEBUG(var << "Min: " << varMin); diff --git a/modules/kameleonvolume/kameleonvolumereader.cpp b/modules/kameleonvolume/kameleonvolumereader.cpp index bbf9b30caa..1f547b303b 100644 --- a/modules/kameleonvolume/kameleonvolumereader.cpp +++ b/modules/kameleonvolume/kameleonvolumereader.cpp @@ -114,7 +114,7 @@ std::unique_ptr> KameleonVolumeReader::readFloatVolume( volumeCoords[2]); }; - auto sample = [this, &variable, &interpolate](glm::vec3 volumeCoords) { + auto sample = [&variable, &interpolate](glm::vec3 volumeCoords) { return interpolate(variable, volumeCoords); }; diff --git a/modules/kameleonvolume/kameleonvolumereader.h b/modules/kameleonvolume/kameleonvolumereader.h index 96d49b1931..0ff6011639 100644 --- a/modules/kameleonvolume/kameleonvolumereader.h +++ b/modules/kameleonvolume/kameleonvolumereader.h @@ -74,7 +74,7 @@ public: std::string simulationEnd() const; std::string getVisUnit(const std::string& variable) const; float elapsedTime() const; - + double minValue(const std::string& variable) const; double maxValue(const std::string& variable) const; diff --git a/modules/kameleonvolume/rendering/renderablekameleonvolume.cpp b/modules/kameleonvolume/rendering/renderablekameleonvolume.cpp index c0c16da95a..90367eaa51 100644 --- a/modules/kameleonvolume/rendering/renderablekameleonvolume.cpp +++ b/modules/kameleonvolume/rendering/renderablekameleonvolume.cpp @@ -172,7 +172,9 @@ RenderableKameleonVolume::RenderableKameleonVolume(const ghoul::Dictionary& dict std::string transferFunctionPath; if (dictionary.getValue(KeyTransferFunction, transferFunctionPath)) { _transferFunctionPath = transferFunctionPath; - _transferFunctionHandler = std::make_shared(_transferFunctionPath); + _transferFunctionHandler = std::make_shared( + _transferFunctionPath + ); } std::string sourcePath; @@ -263,7 +265,11 @@ void RenderableKameleonVolume::initializeGL() { _volumeTexture->uploadTexture(); _transferFunctionHandler->initialize(); - _raycaster = std::make_unique(_volumeTexture, _transferFunctionHandler, _clipPlanes); + _raycaster = std::make_unique( + _volumeTexture, + _transferFunctionHandler, + _clipPlanes + ); _raycaster->setStepSize(_stepSize); _gridType.onChange([this] { diff --git a/modules/kameleonvolume/tasks/kameleonvolumetorawtask.cpp b/modules/kameleonvolume/tasks/kameleonvolumetorawtask.cpp index 2fdd160b73..92cb361e8f 100644 --- a/modules/kameleonvolume/tasks/kameleonvolumetorawtask.cpp +++ b/modules/kameleonvolume/tasks/kameleonvolumetorawtask.cpp @@ -51,8 +51,6 @@ namespace { constexpr const char* KeyMaxValue = "MaxValue"; constexpr const char* KeyVisUnit = "VisUnit"; - constexpr const char* _loggerCat = "KameleonVolumeToRawTask"; - } // namespace namespace openspace { diff --git a/modules/server/CMakeLists.txt b/modules/server/CMakeLists.txt index 848a3001a7..f5755ab4ac 100644 --- a/modules/server/CMakeLists.txt +++ b/modules/server/CMakeLists.txt @@ -2,7 +2,7 @@ # # # OpenSpace # # # -# Copyright (c) 2014-2017 # +# Copyright (c) 2014-2018 # # # # 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 # diff --git a/modules/server/include/authorizationtopic.h b/modules/server/include/authorizationtopic.h index edd6b83951..7c666a0039 100644 --- a/modules/server/include/authorizationtopic.h +++ b/modules/server/include/authorizationtopic.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef OPENSPACE_MODULES_SERVER__AUTHENTICATION_TOPIC_H -#define OPENSPACE_MODULES_SERVER__AUTHENTICATION_TOPIC_H +#ifndef __OPENSPACE_MODULE_SERVER___AUTHORIZATION_TOPIC___H__ +#define __OPENSPACE_MODULE_SERVER___AUTHORIZATION_TOPIC___H__ #include #include @@ -38,7 +38,6 @@ namespace openspace { class AuthorizationTopic : public Topic { public: AuthorizationTopic(); - ~AuthorizationTopic() {}; void handleJson(nlohmann::json json); bool isDone(); @@ -53,14 +52,16 @@ public: NotImplemented = 501 }; + private: bool _isAuthenticated; const std::string getKey() const; bool authorize(const std::string key); - nlohmann::json message(const std::string &message, StatusCode statusCode = StatusCode::NotImplemented); + nlohmann::json message(const std::string &message, + StatusCode statusCode = StatusCode::NotImplemented); }; -} +} // namespace openspace -#endif //OPENSPACE_MODULES_SERVER__AUTHENTICATION_TOPIC_H +#endif // __OPENSPACE_MODULE_SERVER___AUTHORIZATION_TOPIC___H__ diff --git a/modules/server/include/connection.h b/modules/server/include/connection.h index 9c9097ddb6..3cc26508f2 100644 --- a/modules/server/include/connection.h +++ b/modules/server/include/connection.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef OPENSPACE_MODOULES_SERVER__CONNECTION_H -#define OPENSPACE_MODOULES_SERVER__CONNECTION_H +#ifndef __OPENSPACE_MODULE_SERVER___CONNECTION___H__ +#define __OPENSPACE_MODULE_SERVER___CONNECTION___H__ #include #include @@ -53,8 +53,7 @@ public: void setAuthorized(const bool status); bool isAuthorized(); - - + std::shared_ptr socket(); std::thread& thread(); void setThread(std::thread&& thread); @@ -74,6 +73,6 @@ private: bool isWhitelisted(); }; -} +} // namespace openspace -#endif //OPENSPACE_MODOULES_SERVER__CONNECTION_H +#endif // __OPENSPACE_MODULE_SERVER___CONNECTION___H__ diff --git a/modules/server/include/connectionpool.h b/modules/server/include/connectionpool.h index f040cc9ff5..3f5ce55a21 100644 --- a/modules/server/include/connectionpool.h +++ b/modules/server/include/connectionpool.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -27,7 +27,6 @@ #include - #include #include #include @@ -36,25 +35,25 @@ #include #include - namespace openspace { class ConnectionPool { public: - ConnectionPool(std::function socket)> handleSocket); + ConnectionPool( + std::function socket)> handleSocket); ~ConnectionPool(); + void addServer(std::shared_ptr server); void removeServer(ghoul::io::SocketServer* server); void clearServers(); void updateConnections(); - -private: +private: void disconnectAllConnections(); std::mutex _connectionMutex; void removeDisconnectedSockets(); void acceptNewSockets(); - + std::function)> _handleSocket; std::vector> _socketServers; std::vector> _sockets; diff --git a/modules/server/include/getpropertytopic.h b/modules/server/include/getpropertytopic.h index fe00c2dcec..c8190577b8 100644 --- a/modules/server/include/getpropertytopic.h +++ b/modules/server/include/getpropertytopic.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef OPENSPACE_MODULES_SERVER__GETPROPERTY_TOPIC_H -#define OPENSPACE_MODULES_SERVER__GETPROPERTY_TOPIC_H +#ifndef __OPENSPACE_MODULE_SERVER___GETPROPERTY_TOPIC___H__ +#define __OPENSPACE_MODULE_SERVER___GETPROPERTY_TOPIC___H__ #include #include "topic.h" @@ -43,6 +43,6 @@ private: nlohmann::json getPropertyFromKey(const std::string& key); }; -} +} // namespace openspace -#endif //OPENSPACE_MODULES_SERVER__GETPROPERTY_TOPIC_H +#endif // __OPENSPACE_MODULE_SERVER___GETPROPERTY_TOPIC___H__ diff --git a/modules/server/include/jsonconverters.h b/modules/server/include/jsonconverters.h index b3009ddefb..0b7a4e2aec 100644 --- a/modules/server/include/jsonconverters.h +++ b/modules/server/include/jsonconverters.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef OPENSPACE_MODULES_SERVER__JSON_CONVERTERS_INL -#define OPENSPACE_MODULES_SERVER__JSON_CONVERTERS_INL +#ifndef __OPENSPACE_MODULE_SERVER___JSON_CONVERTERS___H__ +#define __OPENSPACE_MODULE_SERVER___JSON_CONVERTERS___H__ #include #include @@ -56,6 +56,6 @@ namespace glm { void to_json(json &j, const dvec3 &v); -} +} // namespace glm -#endif +#endif // __OPENSPACE_MODULE_SERVER___JSON_CONVERTERS___H__ diff --git a/modules/server/include/luascripttopic.h b/modules/server/include/luascripttopic.h index 0312259d17..0c45bcc305 100644 --- a/modules/server/include/luascripttopic.h +++ b/modules/server/include/luascripttopic.h @@ -1,29 +1,29 @@ /***************************************************************************************** -* * -* OpenSpace * -* * -* Copyright (c) 2014-2017 * -* * -* 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. * -****************************************************************************************/ + * * + * OpenSpace * + * * + * Copyright (c) 2014-2018 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ -#ifndef OPENSPACE_MODULES_SERVER__LUASCRIPTTOPIC_H -#define OPENSPACE_MODULES_SERVER__LUASCRIPTTOPIC_H +#ifndef __OPENSPACE_MODULE_SERVER___LUASCRIPTTOPIC___H__ +#define __OPENSPACE_MODULE_SERVER___LUASCRIPTTOPIC___H__ #include #include @@ -38,6 +38,6 @@ public: bool isDone() { return true; }; }; -} +} // namespace openspace -#endif //OPENSPACE_MODULES_SERVER__LUASCRIPTTOPIC_H +#endif // __OPENSPACE_MODULE_SERVER___LUASCRIPTTOPIC___H__ diff --git a/modules/server/include/setpropertytopic.h b/modules/server/include/setpropertytopic.h index 45d760a50e..0ccd39da3e 100644 --- a/modules/server/include/setpropertytopic.h +++ b/modules/server/include/setpropertytopic.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef OPENSPACE_MODULES_SERVER__SETPROPERTYTOPIC_H -#define OPENSPACE_MODULES_SERVER__SETPROPERTYTOPIC_H +#ifndef __OPENSPACE_MODULE_SERVER___SETPROPERTYTOPIC___H__ +#define __OPENSPACE_MODULE_SERVER___SETPROPERTYTOPIC___H__ #include #include @@ -41,6 +41,6 @@ private: void setTime(const std::string& value); }; -} +} // namespace -#endif //OPENSPACE_MODULES_SERVER__SETPROPERTYTOPIC_H +#endif // __OPENSPACE_MODULE_SERVER___SETPROPERTYTOPIC___H__ diff --git a/modules/server/include/subscriptiontopic.h b/modules/server/include/subscriptiontopic.h index ec7190887b..f805ee6cad 100644 --- a/modules/server/include/subscriptiontopic.h +++ b/modules/server/include/subscriptiontopic.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef OPENSPACE_MODULES_SERVER__SUBSCRIPTION_TOPIC_H -#define OPENSPACE_MODULES_SERVER__SUBSCRIPTION_TOPIC_H +#ifndef __OPENSPACE_MODULE_SERVER___SUBSCRIPTION_TOPIC___H__ +#define __OPENSPACE_MODULE_SERVER___SUBSCRIPTION_TOPIC___H__ #include #include @@ -47,6 +47,6 @@ private: properties::Property* _prop; }; -} +} // namespace openspace -#endif //OPENSPACE_MODULES_SERVER__SUBSCRIPTION_TOPIC_H +#endif // __OPENSPACE_MODULE_SERVER___SUBSCRIPTION_TOPIC___H__ diff --git a/modules/server/include/timetopic.h b/modules/server/include/timetopic.h index 884223380d..00d314984d 100644 --- a/modules/server/include/timetopic.h +++ b/modules/server/include/timetopic.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef OPENSPACE_MODULES_SERVER__TIME_TOPIC_H -#define OPENSPACE_MODULES_SERVER__TIME_TOPIC_H +#ifndef __OPENSPACE_MODULE_SERVER___TIME_TOPIC___H__ +#define __OPENSPACE_MODULE_SERVER___TIME_TOPIC___H__ #include #include "topic.h" @@ -36,7 +36,8 @@ public: ~TimeTopic(); void handleJson(nlohmann::json json); bool isDone(); -private: + +private: nlohmann::json currentTime(); nlohmann::json deltaTime(); @@ -45,6 +46,6 @@ private: std::chrono::system_clock::time_point _lastUpdateTime; }; -} +} // namespace openspace -#endif //OPENSPACE_MODULES_SERVER__TIME_TOPIC_H +#endif // __OPENSPACE_MODULE_SERVER___TIME_TOPIC___H__ diff --git a/modules/server/include/topic.h b/modules/server/include/topic.h index 7f233ef0a1..f3ed19938b 100644 --- a/modules/server/include/topic.h +++ b/modules/server/include/topic.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef OPENSPACE_MODULES_SERVER__TOPIC_H -#define OPENSPACE_MODULES_SERVER__TOPIC_H +#ifndef __OPENSPACE_MODULE_SERVER___TOPIC___H__ +#define __OPENSPACE_MODULE_SERVER___TOPIC___H__ #include @@ -34,10 +34,12 @@ class Connection; class Topic { public: Topic() {}; - virtual ~Topic() {}; + virtual ~Topic() = default; + void initialize(Connection* connection, size_t topicId); nlohmann::json wrappedPayload(const nlohmann::json &payload) const; - nlohmann::json wrappedError(std::string message = "Could not complete request.", int code = 500); + nlohmann::json wrappedError(std::string message = "Could not complete request.", + int code = 500); virtual void handleJson(nlohmann::json json) = 0; virtual bool isDone() = 0; @@ -54,6 +56,6 @@ public: bool isDone() { return false; } }; -} +} // namespace openspace -#endif //OPENSPACE_MODULES_SERVER__TOPIC_H +#endif // __OPENSPACE_MODULE_SERVER___TOPIC___H__ diff --git a/modules/server/include/triggerpropertytopic.h b/modules/server/include/triggerpropertytopic.h index 67ebc74e1b..f8deb135e5 100644 --- a/modules/server/include/triggerpropertytopic.h +++ b/modules/server/include/triggerpropertytopic.h @@ -1,29 +1,29 @@ /***************************************************************************************** -* * -* OpenSpace * -* * -* Copyright (c) 2014-2017 * -* * -* 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. * -****************************************************************************************/ + * * + * OpenSpace * + * * + * Copyright (c) 2014-2018 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ -#ifndef OPENSPACE_MODULES_SERVER__TRIGGERPROPERTYTOPIC_H -#define OPENSPACE_MODULES_SERVER__TRIGGERPROPERTYTOPIC_H +#ifndef __OPENSPACE_MODULE_SERVER___TRIGGERPROPERTYTOPIC___H__ +#define __OPENSPACE_MODULE_SERVER___TRIGGERPROPERTYTOPIC___H__ #include #include @@ -38,6 +38,6 @@ public: bool isDone() { return true; }; }; -} +} // namespace -#endif //OPENSPACE_MODULES_SERVER__TRIGGERPROPERTYTOPIC_H +#endif // __OPENSPACE_MODULE_SERVER___TRIGGERPROPERTYTOPIC___H__ diff --git a/modules/server/servermodule.cpp b/modules/server/servermodule.cpp index 7e2882e884..d1ef4b59d9 100644 --- a/modules/server/servermodule.cpp +++ b/modules/server/servermodule.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -87,7 +87,7 @@ void ServerModule::preSync() { // Join threads for sockets that disconnected. cleanUpFinishedThreads(); } - + void ServerModule::cleanUpFinishedThreads() { for (auto& connectionData : _connections) { std::shared_ptr& connection = connectionData.connection; @@ -106,7 +106,7 @@ void ServerModule::cleanUpFinishedThreads() { } ), _connections.end()); } - + void ServerModule::disconnectAll() { for (auto& connectionData : _connections) { std::shared_ptr& connection = connectionData.connection; @@ -117,7 +117,7 @@ void ServerModule::disconnectAll() { } } } - + void ServerModule::handleConnection(std::shared_ptr connection) { std::string messageString; while (connection->socket()->getMessage(messageString)) { diff --git a/modules/server/servermodule.h b/modules/server/servermodule.h index 2996e7fa5f..0c19ef95d5 100644 --- a/modules/server/servermodule.h +++ b/modules/server/servermodule.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/server/src/connection.cpp b/modules/server/src/connection.cpp index b584d245dc..e6e4e7a0fb 100644 --- a/modules/server/src/connection.cpp +++ b/modules/server/src/connection.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -32,23 +32,23 @@ #include namespace { -const char* _loggerCat = "ServerModule: Connection"; + constexpr const char* _loggerCat = "ServerModule: Connection"; -const char* MessageKeyType = "type"; -const char* MessageKeyPayload = "payload"; -const char* MessageKeyTopic = "topic"; + constexpr const char* MessageKeyType = "type"; + constexpr const char* MessageKeyPayload = "payload"; + constexpr const char* MessageKeyTopic = "topic"; -const char* AuthenticationTopicKey = "authorize"; -const char* GetPropertyTopicKey = "get"; -const char* LuaScriptTopicKey = "luascript"; -const char* SetPropertyTopicKey = "set"; -const char* SubscriptionTopicKey = "subscribe"; -const char* TimeTopicKey = "time"; -const char* TriggerPropertyTopicKey = "trigger"; -const char* BounceTopicKey = "bounce"; + constexpr const char* AuthenticationTopicKey = "authorize"; + constexpr const char* GetPropertyTopicKey = "get"; + constexpr const char* LuaScriptTopicKey = "luascript"; + constexpr const char* SetPropertyTopicKey = "set"; + constexpr const char* SubscriptionTopicKey = "subscribe"; + constexpr const char* TimeTopicKey = "time"; + constexpr const char* TriggerPropertyTopicKey = "trigger"; + constexpr const char* BounceTopicKey = "bounce"; -const int ThrottleMessageWaitInMs = 100; -} + constexpr const int ThrottleMessageWaitInMs = 100; +} // namespace namespace openspace { @@ -67,9 +67,10 @@ Connection::Connection(std::shared_ptr s, const std::string & _topicFactory.registerClass(BounceTopicKey); // see if the default config for requiring auth (on) is overwritten - const bool hasAuthenticationConfiguration = OsEng.configurationManager().hasKeyAndValue( - ConfigurationManager::KeyRequireSocketAuthentication); - if (hasAuthenticationConfiguration) { + const bool hasAuthConfiguration = OsEng.configurationManager().hasKeyAndValue( + ConfigurationManager::KeyRequireSocketAuthentication + ); + if (hasAuthConfiguration) { _requireAuthorization = OsEng.configurationManager().value( ConfigurationManager::KeyRequireSocketAuthentication); } else { diff --git a/modules/server/src/connectionpool.cpp b/modules/server/src/connectionpool.cpp index 28db0f4d00..413f373dde 100644 --- a/modules/server/src/connectionpool.cpp +++ b/modules/server/src/connectionpool.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -31,7 +31,8 @@ namespace openspace { -ConnectionPool::ConnectionPool(std::function socket)> handleSocket) +ConnectionPool::ConnectionPool( + std::function socket)> handleSocket) : _handleSocket(std::move(handleSocket)) {} @@ -69,9 +70,13 @@ void ConnectionPool::acceptNewSockets() { } void ConnectionPool::removeDisconnectedSockets() { - std::remove_if(_sockets.begin(), _sockets.end(), [](const std::shared_ptr socket) { - return !socket || !socket->isConnected(); - }); + std::remove_if( + _sockets.begin(), + _sockets.end(), + [](const std::shared_ptr socket) { + return !socket || !socket->isConnected(); + } + ); } void ConnectionPool::disconnectAllConnections() { diff --git a/modules/server/src/jsonconverters.cpp b/modules/server/src/jsonconverters.cpp index 72d355647a..e899af496c 100644 --- a/modules/server/src/jsonconverters.cpp +++ b/modules/server/src/jsonconverters.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/server/src/topics/authorizationtopic.cpp b/modules/server/src/topics/authorizationtopic.cpp index bc000989c3..c693dad79c 100644 --- a/modules/server/src/topics/authorizationtopic.cpp +++ b/modules/server/src/topics/authorizationtopic.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -52,9 +52,13 @@ void AuthorizationTopic::handleJson(nlohmann::json json) { _connection->sendJson(message("Invalid key", StatusCode::NotAcceptable)); } } catch (const std::out_of_range& e) { - _connection->sendJson(message("Invalid request, key must be provided.", StatusCode::BadRequest)); + _connection->sendJson( + message("Invalid request, key must be provided.", StatusCode::BadRequest) + ); } catch (const std::domain_error& e) { - _connection->sendJson(message("Invalid request, invalid key format.", StatusCode::BadRequest)); + _connection->sendJson( + message("Invalid request, invalid key format.", StatusCode::BadRequest) + ); } } }; @@ -65,7 +69,7 @@ bool AuthorizationTopic::authorize(const std::string key) { } const std::string AuthorizationTopic::getKey() const { - const bool hasConfigPassword = OsEng.configurationManager().hasKeyAndValue( + bool hasConfigPassword = OsEng.configurationManager().hasKeyAndValue( ConfigurationManager::KeyServerPasskey); if (hasConfigPassword) { return OsEng.configurationManager().value( @@ -75,9 +79,13 @@ const std::string AuthorizationTopic::getKey() const { return "17308"; } -nlohmann::json AuthorizationTopic::message(const std::string &message, StatusCode statusCode) { - nlohmann::json error = {{"message", message}, {"code", static_cast(statusCode)}}; - return error; +nlohmann::json AuthorizationTopic::message(const std::string& message, + StatusCode statusCode) +{ + return { + { "message", message }, + { "code", static_cast(statusCode) } + }; } -} +} // namespace openspace diff --git a/modules/server/src/topics/getpropertytopic.cpp b/modules/server/src/topics/getpropertytopic.cpp index 1297e9e422..d9e1c2387f 100644 --- a/modules/server/src/topics/getpropertytopic.cpp +++ b/modules/server/src/topics/getpropertytopic.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -65,7 +65,9 @@ void GetPropertyTopic::handleJson(json j) { response = wrappedPayload(sceneGraph()->allSceneGraphNodes()); } else if (requestedKey == AllScreenSpaceRenderablesValue) { - response = wrappedPayload({ { "value", OsEng.renderEngine().screenSpaceRenderables() } }); + response = wrappedPayload({ + { "value", OsEng.renderEngine().screenSpaceRenderables() } + }); } else if (requestedKey == RootPropertyOwner) { response = wrappedPayload(OsEng.rootPropertyOwner()); diff --git a/modules/server/src/topics/luascripttopic.cpp b/modules/server/src/topics/luascripttopic.cpp index 21c4bb3d9a..96c0c28e6a 100644 --- a/modules/server/src/topics/luascripttopic.cpp +++ b/modules/server/src/topics/luascripttopic.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -38,10 +38,13 @@ void LuaScriptTopic::handleJson(nlohmann::json json) { try { auto script = json.at(ScriptKey).get(); LDEBUG("Queueing Lua script: " + script); - OsEng.scriptEngine().queueScript(script, scripting::ScriptEngine::RemoteScripting::No); + OsEng.scriptEngine().queueScript( + script, + scripting::ScriptEngine::RemoteScripting::No + ); } - catch (std::out_of_range& e) { - LERROR("Could run script -- key or value is missing in payload"); + catch (const std::out_of_range& e) { + LERROR("Could not run script -- key or value is missing in payload"); LERROR(e.what()); } } diff --git a/modules/server/src/topics/setpropertytopic.cpp b/modules/server/src/topics/setpropertytopic.cpp index a371afcaed..9239e5f842 100644 --- a/modules/server/src/topics/setpropertytopic.cpp +++ b/modules/server/src/topics/setpropertytopic.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/server/src/topics/subscriptiontopic.cpp b/modules/server/src/topics/subscriptiontopic.cpp index bc1bd1845b..1860a22570 100644 --- a/modules/server/src/topics/subscriptiontopic.cpp +++ b/modules/server/src/topics/subscriptiontopic.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/server/src/topics/timetopic.cpp b/modules/server/src/topics/timetopic.cpp index 2f0f7419b2..31f3a713a3 100644 --- a/modules/server/src/topics/timetopic.cpp +++ b/modules/server/src/topics/timetopic.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/server/src/topics/topic.cpp b/modules/server/src/topics/topic.cpp index 6be5b7349b..dd84de279f 100644 --- a/modules/server/src/topics/topic.cpp +++ b/modules/server/src/topics/topic.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/server/src/topics/triggerpropertytopic.cpp b/modules/server/src/topics/triggerpropertytopic.cpp index 144414a6a6..ad5b5a672d 100644 --- a/modules/server/src/topics/triggerpropertytopic.cpp +++ b/modules/server/src/topics/triggerpropertytopic.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -45,16 +45,16 @@ void TriggerPropertyTopic::handleJson(nlohmann::json json) { if (prop != nullptr) { LDEBUG("Triggering " + propertyKey); prop->set("poke"); - } + } else { LWARNING("Could not find property " + propertyKey); } } - catch (std::out_of_range& e) { + catch (const std::out_of_range& e) { LERROR("Could not poke property -- key or value is missing in payload"); LERROR(e.what()); } - catch (ghoul::RuntimeError e) { + catch (const ghoul::RuntimeError& e) { LERROR("Could not poke property -- runtime error:"); LERROR(e.what()); } diff --git a/modules/spacecraftinstruments/rendering/renderableshadowcylinder.cpp b/modules/spacecraftinstruments/rendering/renderableshadowcylinder.cpp index 97a7099c0f..0280b9e11a 100644 --- a/modules/spacecraftinstruments/rendering/renderableshadowcylinder.cpp +++ b/modules/spacecraftinstruments/rendering/renderableshadowcylinder.cpp @@ -297,7 +297,7 @@ void RenderableShadowCylinder::deinitializeGL() { } ); _shader = nullptr; - + glDeleteVertexArrays(1, &_vao); _vao = 0; glDeleteBuffers(1, &_vbo); diff --git a/modules/sync/syncs/urlsynchronization.cpp b/modules/sync/syncs/urlsynchronization.cpp index 51a06cfe4b..365aa0523b 100644 --- a/modules/sync/syncs/urlsynchronization.cpp +++ b/modules/sync/syncs/urlsynchronization.cpp @@ -203,7 +203,7 @@ void UrlSynchronization::start() { // If we are forcing the override, we download to a temporary file first, // so when we are done here, we need to rename the file to the original // name - + const std::string& tempName = d->destination(); std::string originalName = tempName.substr( 0, diff --git a/modules/touch/ext/levmarq.cpp b/modules/touch/ext/levmarq.cpp index 2fecba156b..657ebef839 100644 --- a/modules/touch/ext/levmarq.cpp +++ b/modules/touch/ext/levmarq.cpp @@ -1,4 +1,4 @@ -/* +/* 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 @@ -26,6 +26,7 @@ OTHER DEALINGS IN THE SOFTWARE. #include #include #include +#include namespace { std::chrono::milliseconds TimeLimit(200); @@ -82,6 +83,20 @@ bool levmarq(int npar, double *par, int ny, double *dysq, double* d = new double[npar]; double* delta = new double[npar]; double* newpar = new double[npar]; + + defer { + // deallocate the arrays + for (i = 0; i < npar; i++) { + delete[] h[i]; + delete[] ch[i]; + } + delete[] h; + delete[] ch; + delete[] g; + delete[] d; + delete[] delta; + delete[] newpar; + }; verbose = lmstat->verbose; nit = lmstat->max_it; @@ -216,18 +231,6 @@ bool levmarq(int npar, double *par, int ny, double *dysq, lmstat->final_derr = derr; lmstat->data = data; - // deallocate the arrays - for (i = 0; i < npar; i++) { - delete[] h[i]; - delete[] ch[i]; - } - delete[] h; - delete[] ch; - delete[] g; - delete[] d; - delete[] delta; - delete[] newpar; - return (it != lmstat->max_it); } diff --git a/modules/touch/include/touchmarker.h b/modules/touch/include/touchmarker.h index b3aa625576..653284c8ab 100644 --- a/modules/touch/include/touchmarker.h +++ b/modules/touch/include/touchmarker.h @@ -70,7 +70,6 @@ private: std::vector _vertexData; GLuint _quad = 0; GLuint _vertexPositionBuffer = 0; - int _numFingers = 0; }; } // openspace namespace diff --git a/modules/touch/src/touchinteraction.cpp b/modules/touch/src/touchinteraction.cpp index e694c39505..9246f28462 100644 --- a/modules/touch/src/touchinteraction.cpp +++ b/modules/touch/src/touchinteraction.cpp @@ -607,7 +607,7 @@ void TouchInteraction::directControl(const std::vector& list) { _lmSuccess = levmarq( nDOF, par.data(), - screenPoints.size(), + static_cast(screenPoints.size()), nullptr, distToMinimize, gradient, @@ -905,11 +905,9 @@ int TouchInteraction::interpretInteraction(const std::vector& list, return ROT; } else { - float avgDistance = static_cast( - std::abs(dist - lastDist) / list.at(0).getMotionSpeed() - ); + float avgDistance = std::abs(dist - lastDist) / list.at(0).getMotionSpeed(); // if average distance between 3 fingers are constant we have panning - if (_panEnabled && (std::abs(dist - lastDist) / list.at(0).getMotionSpeed() < _interpretPan && list.size() == 3)) { + if (_panEnabled && (avgDistance < _interpretPan && list.size() == 3)) { return PAN; } @@ -917,9 +915,9 @@ int TouchInteraction::interpretInteraction(const std::vector& list, // centroid is over _rollAngleThreshold (_centroidStillThreshold is used to void // misinterpretations) else if (std::abs(minDiff) < _inputStillThreshold || - (std::abs(rollOn) < 100.0 && - normalizedCentroidDistance < _centroidStillThreshold)) { - + (std::abs(rollOn) < 100.0 && + normalizedCentroidDistance < _centroidStillThreshold)) + { return ROLL; } else { @@ -997,7 +995,10 @@ void TouchInteraction::computeVelocities(const std::vector& list, pinchConsecZoomFactor += zoomFactor; #endif if ((length(currDistanceToFocusNode) / distanceFromFocusSurface) > _zoomSensitivityDistanceThreshold) { - zoomFactor *= pow(distanceFromFocusSurface, (float)_zoomSensitivity); + zoomFactor *= pow( + distanceFromFocusSurface, + static_cast(_zoomSensitivity) + ); } _vel.zoom += zoomFactor * _sensitivity.zoom * std::max(_touchScreenSize.value() * 0.1, 1.0); diff --git a/modules/touch/src/touchmarker.cpp b/modules/touch/src/touchmarker.cpp index dfa5ebf227..5da6eaf0a8 100644 --- a/modules/touch/src/touchmarker.cpp +++ b/modules/touch/src/touchmarker.cpp @@ -33,7 +33,6 @@ namespace { const std::string _loggerCat = "TouchMarker"; - const int MAX_FINGERS = 20; static const openspace::properties::Property::PropertyInfo VisibilityInfo = { "Visibility", @@ -134,7 +133,7 @@ void TouchMarker::render(const std::vector& list) { glEnable(GL_PROGRAM_POINT_SIZE); // Enable gl_PointSize in vertex shader glPolygonMode(GL_FRONT_AND_BACK, GL_POINT); glBindVertexArray(_quad); - glDrawArrays(GL_POINTS, 0, _vertexData.size() / 2); + glDrawArrays(GL_POINTS, 0, static_cast(_vertexData.size() / 2)); _shader->deactivate(); } @@ -152,7 +151,12 @@ void TouchMarker::createVertexList(const std::vector& list) { glBindVertexArray(_quad); glBindBuffer(GL_ARRAY_BUFFER, _vertexPositionBuffer); - glBufferData(GL_ARRAY_BUFFER, _vertexData.size() * sizeof(GLfloat), _vertexData.data(), GL_STATIC_DRAW); + glBufferData( + GL_ARRAY_BUFFER, + _vertexData.size() * sizeof(GLfloat), + _vertexData.data(), + GL_STATIC_DRAW + ); glEnableVertexAttribArray(0); glVertexAttribPointer( 0, diff --git a/modules/volume/envelope.cpp b/modules/volume/envelope.cpp index e4db69a95b..8b74f5091a 100644 --- a/modules/volume/envelope.cpp +++ b/modules/volume/envelope.cpp @@ -1,176 +1,223 @@ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2018 * + * * + * 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 -namespace openspace { - namespace volume { - Envelope::Envelope() { } +namespace openspace::volume { - Envelope::Envelope(std::vector vec) { - _points = vec; - } +EnvelopePoint::EnvelopePoint(glm::vec3 c, float x, float y) + : color(c) + , colorHex(getHexadecimalFromVec3(c)) + , position(std::make_pair(x, y)) +{} - bool Envelope::operator!=(const Envelope& env) const { - const double minDist = 0.0001; +EnvelopePoint::EnvelopePoint(std::string c, float x, float y) + : color(hexadecimalToRGBConversion(c)) + , colorHex(c) + , position(std::make_pair(x, y)) +{} - if (_points.size() != env._points.size()) - return true; +Envelope::Envelope() {} - auto iter = _points.begin(); - auto envIter = env._points.begin(); - for (; iter != _points.end(); ++iter, ++envIter) { - if (abs(iter->position.first - envIter->position.first) > minDist || - abs(iter->position.second - envIter->position.second) > minDist || - iter->color != envIter->color) - return true; - } - return false; - } +Envelope::Envelope(std::vector vec) { + _points = vec; +} +bool Envelope::operator!=(const Envelope& env) const { + const double minDist = 0.0001; - void Envelope::setPoints(std::vector vec) { - this->_points = vec; - } + if (_points.size() != env._points.size()) { + return true; + } - std::vector Envelope::getPoints() { - return _points; - } - - bool Envelope::isValueInEnvelope(float pos) const { - if (!_points.empty()) { - if (_points.front().position.first <= pos && _points.back().position.first >= pos) - return true; - } - return false; - } - - bool Envelope::isEnvelopeValid() const { - auto currentIter = _points.begin(); - auto nextIter = currentIter + 1; - for (; nextIter != _points.end(); ++currentIter, ++nextIter) { - if (currentIter->position.first > nextIter->position.first) - return false; - } + auto iter = _points.begin(); + auto envIter = env._points.begin(); + for (; iter != _points.end(); ++iter, ++envIter) { + if (abs(iter->position.first - envIter->position.first) > minDist || + abs(iter->position.second - envIter->position.second) > minDist || + iter->color != envIter->color) return true; - } + } + return false; +} - glm::vec3 Envelope::normalizeColor(glm::vec3 vec) const{ - return glm::vec3{ vec.r / 255.f, vec.g / 255.f , vec.b / 255.f }; - } - - glm::vec4 Envelope::getValueAtPosition(float pos) const { - auto afterIter = _points.begin(); - glm::vec4 color{ 0.f, 0.f , 0.f , 0.f }; - while (afterIter->position.first < pos ) { - if(afterIter == _points.end()) - return color; - ++afterIter; - } - if (afterIter->position.first == pos) { - return glm::vec4{ afterIter->color, afterIter->position.second }; - } - auto beforeIter = afterIter -1; +void Envelope::setPoints(std::vector vec) { + this->_points = vec; +} - float dist = afterIter->position.first - beforeIter->position.first; - float alpha; - if(dist < 0.0001) - color = { normalizeColor((beforeIter->color + afterIter->color) / 2.f), - std::max(beforeIter->position.second, afterIter->position.second) }; - else - color = { normalizeColor(beforeIter->color *(abs(pos - afterIter->position.first) / dist) + afterIter->color *(abs(pos - beforeIter->position.first) / dist)), - beforeIter->position.second *(abs(pos - afterIter->position.first) / dist) + afterIter->position.second *(abs(pos - beforeIter->position.first) / dist) }; +std::vector Envelope::getPoints() { + return _points; +} +bool Envelope::isValueInEnvelope(float pos) const { + if (!_points.empty()) { + if (_points.front().position.first <= pos && _points.back().position.first >= pos) + return true; + } + return false; +} + +bool Envelope::isEnvelopeValid() const { + auto currentIter = _points.begin(); + auto nextIter = currentIter + 1; + for (; nextIter != _points.end(); ++currentIter, ++nextIter) { + if (currentIter->position.first > nextIter->position.first) + return false; + } + return true; +} + +glm::vec3 Envelope::normalizeColor(glm::vec3 vec) const{ + + return glm::vec3{ vec.r / 255.f, vec.g / 255.f , vec.b / 255.f }; +} + +glm::vec4 Envelope::getValueAtPosition(float pos) const { + auto afterIter = _points.begin(); + glm::vec4 color{ 0.f, 0.f , 0.f , 0.f }; + while (afterIter->position.first < pos ) { + if(afterIter == _points.end()) return color; - } + ++afterIter; + } + if (afterIter->position.first == pos) { + return glm::vec4{ afterIter->color, afterIter->position.second }; + } + auto beforeIter = afterIter -1; - int EnvelopePoint::HexadecimalToDecimal(std::string hex) const { - int hexLength = hex.length(); - double dec = 0; - for (int i = 0; i < hexLength; ++i) - { - char b = hex[i]; + float dist = afterIter->position.first - beforeIter->position.first; + float alpha; + if(dist < 0.0001) + color = { normalizeColor((beforeIter->color + afterIter->color) / 2.f), + std::max(beforeIter->position.second, afterIter->position.second) }; + else + color = { + normalizeColor( + beforeIter->color * (abs(pos - afterIter->position.first) / dist) + + afterIter->color * (abs(pos - beforeIter->position.first) / dist) + ), + beforeIter->position.second * (abs(pos - afterIter->position.first) / dist) + + afterIter->position.second * + (abs(pos - beforeIter->position.first) / dist) + }; - if (b >= 48 && b <= 57) - b -= 48; - else if (b >= 65 && b <= 70) - b -= 55; - else if (b >= 97 && b <= 102) - b -= 87; - dec += b * pow(16, ((hexLength - i) - 1)); + return color; +} + +int EnvelopePoint::HexadecimalToDecimal(std::string hex) const { + int hexLength = hex.length(); + double dec = 0; + for (int i = 0; i < hexLength; ++i) + { + char b = hex[i]; + + if (b >= 48 && b <= 57) + b -= 48; + else if (b >= 65 && b <= 70) + b -= 55; + else if (b >= 97 && b <= 102) + b -= 87; + dec += b * pow(16, ((hexLength - i) - 1)); + } + return (int)dec; +} + +std::string EnvelopePoint::DecimalToHexadecimal(int dec) const { + if (dec < 1) return "00"; + + int hex = dec; + std::string hexStr = ""; + + while (dec > 0) + { + hex = dec % 16; + + if (hex < 10) + hexStr = hexStr.insert(0, std::string(1, (hex + 48))); + else + hexStr = hexStr.insert(0, std::string(1, (hex + 55))); + dec /= 16; + } + return hexStr; +} + +glm::vec3 EnvelopePoint::hexadecimalToRGBConversion(std::string hex) const { + float r = static_cast(HexadecimalToDecimal(hex.substr(1, 2))); + float g = static_cast(HexadecimalToDecimal(hex.substr(3, 2))); + float b = static_cast(HexadecimalToDecimal(hex.substr(5, 2))); + + return glm::vec3(r, g, b); +} + +std::string EnvelopePoint::getHexadecimalFromVec3(glm::vec3 vec) const { + + std::string r = DecimalToHexadecimal(static_cast(vec.r)); + std::string g = DecimalToHexadecimal(static_cast(vec.g)); + std::string b = DecimalToHexadecimal(static_cast(vec.b)); + + return ("#" + r + g + b); +} + +json Envelope::getJSONPoints() const { + json j; + for (int i = 0; i < _points.size(); i++) { + j[i] = { + { "color", _points.at(i).colorHex }, + { "position",{ + { "x", _points.at(i).position.first }, + { "y", _points.at(i).position.second }, + }, } - return (int)dec; - } + }; + } + return j; +} - std::string EnvelopePoint::DecimalToHexadecimal(int dec) const { - if (dec < 1) return "00"; +json Envelope::getJSONEnvelope() const { + json j; + j["points"] = getJSONPoints(); + return j; +} - int hex = dec; - std::string hexStr = ""; +void Envelope::setEnvelopeLuaTable(lua_State* state) const { + for (auto iter = _points.begin(); iter != _points.end(); ++iter) { + lua_newtable(state); + lua_pushstring(state, iter->colorHex.c_str()); + lua_setfield(state, -2, "color"); + lua_newtable(state); + lua_pushnumber(state, static_cast(iter->position.first)); + lua_setfield(state, -2, "x"); + lua_pushnumber(state, static_cast(iter->position.second)); + lua_setfield(state, -2, "y"); + lua_setfield(state, -2, "position"); + lua_setfield( + state, + -2, + ("[\"" + std::to_string(iter - _points.begin() + 1) + "\"]").c_str() + ); + } +} - while (dec > 0) - { - hex = dec % 16; - - if (hex < 10) - hexStr = hexStr.insert(0, std::string(1, (hex + 48))); - else - hexStr = hexStr.insert(0, std::string(1, (hex + 55))); - dec /= 16; - } - return hexStr; - } - - glm::vec3 EnvelopePoint::hexadecimalToRGBConversion(std::string hex) const { - float r = static_cast(HexadecimalToDecimal(hex.substr(1, 2))); - float g = static_cast(HexadecimalToDecimal(hex.substr(3, 2))); - float b = static_cast(HexadecimalToDecimal(hex.substr(5, 2))); - - return glm::vec3(r, g, b); - } - - std::string EnvelopePoint::getHexadecimalFromVec3(glm::vec3 vec) const { - - std::string r = DecimalToHexadecimal(static_cast(vec.r)); - std::string g = DecimalToHexadecimal(static_cast(vec.g)); - std::string b = DecimalToHexadecimal(static_cast(vec.b)); - - return ("#" + r + g + b); - } - - json Envelope::getJSONPoints() const { - json j; - for (int i = 0; i < _points.size(); i++) { - j[i] = { - { "color", _points.at(i).colorHex }, - { "position",{ - { "x", _points.at(i).position.first }, - { "y", _points.at(i).position.second }, - }, - } - }; - } - return j; - } - - json Envelope::getJSONEnvelope() const { - json j; - j["points"] = getJSONPoints(); - return j; - } - - void Envelope::setEnvelopeLuaTable(lua_State* state) const { - for (auto iter = _points.begin(); iter != _points.end(); ++iter) { - lua_newtable(state); - lua_pushstring(state, iter->colorHex.c_str()); - lua_setfield(state, -2, "color"); - lua_newtable(state); - lua_pushnumber(state, static_cast(iter->position.first)); - lua_setfield(state, -2, "x"); - lua_pushnumber(state, static_cast(iter->position.second)); - lua_setfield(state, -2, "y"); - lua_setfield(state, -2, "position"); - lua_setfield(state, -2, ("[\"" + std::to_string(iter - _points.begin() + 1) + "\"]").c_str()); - } - } - - }//namespace volume -}//namespace openspace +} //namespace openspace::volume diff --git a/modules/volume/envelope.h b/modules/volume/envelope.h index 5a251ed917..d9b98e1120 100644 --- a/modules/volume/envelope.h +++ b/modules/volume/envelope.h @@ -1,26 +1,26 @@ /***************************************************************************************** -* * -* OpenSpace * -* * -* Copyright (c) 2014-2017 * -* * -* 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. * -****************************************************************************************/ + * * + * OpenSpace * + * * + * Copyright (c) 2014-2018 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ #ifndef __OPENSPACE_MODULE_VOLUME___ENVELOPE___H__ #define __OPENSPACE_MODULE_VOLUME___ENVELOPE___H__ @@ -32,46 +32,46 @@ using json = nlohmann::json; -namespace openspace { - namespace volume { - class EnvelopePoint { - public: - EnvelopePoint(glm::vec3 c, float x, float y) : color(c), colorHex(getHexadecimalFromVec3(c)), position(std::make_pair(x, y)) {} - EnvelopePoint(std::string c, float x, float y) : color(hexadecimalToRGBConversion(c)), colorHex(c), position(std::make_pair(x, y)) {} +namespace openspace::volume { - int HexadecimalToDecimal(std::string hex) const; - std::string DecimalToHexadecimal(int dec) const; - glm::vec3 hexadecimalToRGBConversion(std::string hex) const; - std::string getHexadecimalFromVec3(glm::vec3 vec) const; +class EnvelopePoint { +public: + EnvelopePoint(glm::vec3 c, float x, float y); + EnvelopePoint(std::string c, float x, float y); - glm::vec3 color; - std::string colorHex; - std::pair position; - }; - class Envelope { - public: - Envelope(); - Envelope(std::vector vec); + int HexadecimalToDecimal(std::string hex) const; + std::string DecimalToHexadecimal(int dec) const; + glm::vec3 hexadecimalToRGBConversion(std::string hex) const; + std::string getHexadecimalFromVec3(glm::vec3 vec) const; - void setPoints(std::vector vec); - std::vector getPoints(); + glm::vec3 color; + std::string colorHex; + std::pair position; +}; - glm::vec4 getValueAtPosition(float pos) const; - glm::vec3 normalizeColor(glm::vec3 vec) const; - json getJSONPoints() const; - json getJSONEnvelope() const; - void setEnvelopeLuaTable(lua_State* state) const; +class Envelope { +public: + Envelope(); + Envelope(std::vector vec); - bool isValueInEnvelope(float pos) const; - bool isEnvelopeValid() const; + void setPoints(std::vector vec); + std::vector getPoints(); - bool operator!=(const Envelope& env) const; + glm::vec4 getValueAtPosition(float pos) const; + glm::vec3 normalizeColor(glm::vec3 vec) const; + json getJSONPoints() const; + json getJSONEnvelope() const; + void setEnvelopeLuaTable(lua_State* state) const; - private: - - std::vector _points; - }; + bool isValueInEnvelope(float pos) const; + bool isEnvelopeValid() const; - }//namespace volume -}//namespace openspace -#endif __OPENSPACE_MODULE_VOLUME___ENVELOPE___H__ + bool operator!=(const Envelope& env) const; + +private: + std::vector _points; +}; + +} //namespace openspace::volume + +#endif // __OPENSPACE_MODULE_VOLUME___ENVELOPE___H__ diff --git a/modules/volume/rendering/basicvolumeraycaster.h b/modules/volume/rendering/basicvolumeraycaster.h index d15c3c8bd0..9c691ed68d 100644 --- a/modules/volume/rendering/basicvolumeraycaster.h +++ b/modules/volume/rendering/basicvolumeraycaster.h @@ -80,7 +80,8 @@ public: void setVolumeTexture(std::shared_ptr texture); std::shared_ptr volumeTexture() const; - void setTransferFunctionHandler(std::shared_ptr transferFunctionHandler); + void setTransferFunctionHandler( + std::shared_ptr transferFunctionHandler); void setStepSize(float stepSize); float opacity() const; diff --git a/modules/volume/transferfunction.cpp b/modules/volume/transferfunction.cpp index f6d4ff7c19..f4bdffca6b 100644 --- a/modules/volume/transferfunction.cpp +++ b/modules/volume/transferfunction.cpp @@ -1,28 +1,29 @@ -/**************************************************************************************** -* * -* OpenSpace * -* * -* Copyright (c) 2014-2017 * -* * -* 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. * -****************************************************************************************/ +/***************************************************************************************** + * * + * OpenSpace * + * * + * Copyright (c) 2014-2018 * + * * + * 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 diff --git a/modules/volume/transferfunction.h b/modules/volume/transferfunction.h index 9f807788de..34327329db 100644 --- a/modules/volume/transferfunction.h +++ b/modules/volume/transferfunction.h @@ -1,26 +1,26 @@ /***************************************************************************************** -* * -* OpenSpace * -* * -* Copyright (c) 2014-2017 * -* * -* 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. * -****************************************************************************************/ + * * + * OpenSpace * + * * + * Copyright (c) 2014-2018 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ #ifndef __OPENSPACE_MODULE_VOLUME___TRANSFERFUNCTION___H__ #define __OPENSPACE_MODULE_VOLUME___TRANSFERFUNCTION___H__ @@ -30,40 +30,39 @@ namespace ghoul { class Dictionary; } -namespace openspace { - namespace volume { - class TransferFunction { - public: - TransferFunction(); - TransferFunction(int s); - TransferFunction(std::string); - TransferFunction(const TransferFunction& tf); - TransferFunction(TransferFunction&& tf); +namespace openspace::volume { +class TransferFunction { +public: + TransferFunction(); + TransferFunction(int s); + TransferFunction(std::string); + TransferFunction(const TransferFunction& tf); + TransferFunction(TransferFunction&& tf); - bool getEnvelopesToLua(lua_State* state); - - bool setEnvelopesFromString(std::string s); - bool setEnvelopesFromLua(lua_State* lua); + bool getEnvelopesToLua(lua_State* state); - void loadEnvelopesFromFile(const std::string& path); - void saveEnvelopesToFile(const std::string& path); + bool setEnvelopesFromString(std::string s); + bool setEnvelopesFromLua(lua_State* lua); - TransferFunction& operator=(const TransferFunction& tf); - TransferFunction& operator=(TransferFunction&& tf); - bool operator!=(const TransferFunction& tf); - bool hasEnvelopes() const; + void loadEnvelopesFromFile(const std::string& path); + void saveEnvelopesToFile(const std::string& path); - bool createTexture(std::shared_ptr ptr); - std::string getSerializedToString() const; + TransferFunction& operator=(const TransferFunction& tf); + TransferFunction& operator=(TransferFunction&& tf); + bool operator!=(const TransferFunction& tf); + bool hasEnvelopes() const; - private: - int _width = 1024; - double lower = 0.0; - double upper = 1.0; - std::string _loadableFilePath; - std::vector _envelopes; - }; + bool createTexture(std::shared_ptr ptr); + std::string getSerializedToString() const; - }//namespace volume -}//namespace openspace -#endif __OPENSPACE_MODULE_VOLUME___TRANSFERFUNCTION___H__ +private: + int _width = 1024; + double lower = 0.0; + double upper = 1.0; + std::string _loadableFilePath; + std::vector _envelopes; +}; + +} // namespace openspace::volume + +#endif // __OPENSPACE_MODULE_VOLUME___TRANSFERFUNCTION___H__ diff --git a/modules/volume/transferfunctionhandler.cpp b/modules/volume/transferfunctionhandler.cpp index 82b75ae4d5..4e30c6c35b 100644 --- a/modules/volume/transferfunctionhandler.cpp +++ b/modules/volume/transferfunctionhandler.cpp @@ -1,26 +1,26 @@ /***************************************************************************************** -* * -* OpenSpace * -* * -* Copyright (c) 2014-2017 * -* * -* 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. * -****************************************************************************************/ + * * + * OpenSpace * + * * + * Copyright (c) 2014-2018 * + * * + * 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 diff --git a/modules/volume/transferfunctionhandler.h b/modules/volume/transferfunctionhandler.h index f526c61d21..cdfaaa567e 100644 --- a/modules/volume/transferfunctionhandler.h +++ b/modules/volume/transferfunctionhandler.h @@ -1,26 +1,26 @@ /***************************************************************************************** -* * -* OpenSpace * -* * -* Copyright (c) 2014-2017 * -* * -* 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. * -****************************************************************************************/ + * * + * OpenSpace * + * * + * Copyright (c) 2014-2018 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ #ifndef __OPENSPACE_MODULE_VOLUME___TRANSFERFUNCTIONHANDLER___H__ #define __OPENSPACE_MODULE_VOLUME___TRANSFERFUNCTIONHANDLER___H__ @@ -41,17 +41,16 @@ #include #include -namespace openspace { -namespace volume { +namespace openspace::volume { class Envelope; - + class TransferFunctionHandler : public properties::PropertyOwner{ public: TransferFunctionHandler(const properties::StringProperty& prop); - + void initialize(); - + void setHistogramProperty(std::shared_ptr histogram); void setTexture(); @@ -81,6 +80,6 @@ private: std::shared_ptr _texture = nullptr; }; -}//namespace volume -}//namespace openspace -#endif __OPENSPACE_MODULE_VOLUME___TRANSFERFUNCTIONHANDLER___H__ +} //namespace openspace::volume + +#endif // __OPENSPACE_MODULE_VOLUME___TRANSFERFUNCTIONHANDLER___H__ diff --git a/modules/volume/transferfunctionproperty.cpp b/modules/volume/transferfunctionproperty.cpp index 6c6a84d043..dbd8ab5b6c 100644 --- a/modules/volume/transferfunctionproperty.cpp +++ b/modules/volume/transferfunctionproperty.cpp @@ -1,26 +1,26 @@ /***************************************************************************************** -* * -* OpenSpace * -* * -* Copyright (c) 2014-2017 * -* * -* 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. * -****************************************************************************************/ + * * + * OpenSpace * + * * + * Copyright (c) 2014-2018 * + * * + * 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 diff --git a/modules/volume/transferfunctionproperty.h b/modules/volume/transferfunctionproperty.h index ccd981b23f..9754e4ee6b 100644 --- a/modules/volume/transferfunctionproperty.h +++ b/modules/volume/transferfunctionproperty.h @@ -1,37 +1,37 @@ /***************************************************************************************** -* * -* OpenSpace * -* * -* Copyright (c) 2014-2017 * -* * -* 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. * -****************************************************************************************/ + * * + * OpenSpace * + * * + * Copyright (c) 2014-2018 * + * * + * Permission is hereby granted, free of charge, to any person obtaining a copy of this * + * software and associated documentation files (the "Software"), to deal in the Software * + * without restriction, including without limitation the rights to use, copy, modify, * + * merge, publish, distribute, sublicense, and/or sell copies of the Software, and to * + * permit persons to whom the Software is furnished to do so, subject to the following * + * conditions: * + * * + * The above copyright notice and this permission notice shall be included in all copies * + * or substantial portions of the Software. * + * * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, * + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A * + * PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT * + * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF * + * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE * + * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * + ****************************************************************************************/ -#ifndef __OPENSPACE_CORE___TRANSFERFUNCTIONPROPERTY___H__ -#define __OPENSPACE_CORE___TRANSFERFUNCTIONPROPERTY___H__ +#ifndef __OPENSPACE_MODULE_VOLUME___TRANSFERFUNCTIONPROPERTY___H__ +#define __OPENSPACE_MODULE_VOLUME___TRANSFERFUNCTIONPROPERTY___H__ #include #include namespace openspace::properties { - REGISTER_TEMPLATEPROPERTY_HEADER(TransferFunctionProperty, volume::TransferFunction) +REGISTER_TEMPLATEPROPERTY_HEADER(TransferFunctionProperty, volume::TransferFunction) } // namespace openspace::properties -#endif // __OPENSPACE_CORE___TRANSFERFUNCTIONPROPERTY___H__ +#endif // __OPENSPACE_MODULE_VOLUME___TRANSFERFUNCTIONPROPERTY___H__ diff --git a/modules/volume/volumegridtype.cpp b/modules/volume/volumegridtype.cpp index 9c2d6f29e9..87fe622a12 100644 --- a/modules/volume/volumegridtype.cpp +++ b/modules/volume/volumegridtype.cpp @@ -26,8 +26,7 @@ #include -namespace openspace { -namespace volume { +namespace openspace::volume { VolumeGridType parseGridType(const std::string& gridType) { if (gridType == "Cartesian") { @@ -44,5 +43,4 @@ InvalidGridTypeError::InvalidGridTypeError(std::string gt) , gridType(std::move(gt)) {} -} // namespace volume -} // namespace openspace +} // namespace openspace::volume diff --git a/modules/volume/volumegridtype.h b/modules/volume/volumegridtype.h index 7993cadb4a..8997d699db 100644 --- a/modules/volume/volumegridtype.h +++ b/modules/volume/volumegridtype.h @@ -22,13 +22,12 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_MODULE_VOLUME___VOLUMEGRIDTYPE_H__ -#define __OPENSPACE_MODULE_VOLUME___VOLUMEGRIDTYPE_H__ +#ifndef __OPENSPACE_MODULE_VOLUME___VOLUMEGRIDTYPE___H__ +#define __OPENSPACE_MODULE_VOLUME___VOLUMEGRIDTYPE___H__ #include -namespace openspace { -namespace volume { +namespace openspace::volume { enum class VolumeGridType : int { Cartesian = 0, @@ -36,13 +35,12 @@ enum class VolumeGridType : int { }; struct InvalidGridTypeError : public ghoul::RuntimeError { - explicit InvalidGridTypeError(std::string gridType); - std::string gridType; + explicit InvalidGridTypeError(std::string gridType); + std::string gridType; }; VolumeGridType parseGridType(const std::string& gridType); -} // namespace volume -} // namespace openspace +} // namespace openspace::volume -#endif // __OPENSPACE_MODULE_VOLUME___VOLUMEGRIDTYPE_H__ +#endif // __OPENSPACE_MODULE_VOLUME___VOLUMEGRIDTYPE___H__ diff --git a/modules/webbrowser/CMakeLists.txt b/modules/webbrowser/CMakeLists.txt index fcbd21acde..6bfd9f485c 100644 --- a/modules/webbrowser/CMakeLists.txt +++ b/modules/webbrowser/CMakeLists.txt @@ -2,7 +2,7 @@ # # # OpenSpace # # # -# Copyright (c) 2014-2017 # +# Copyright (c) 2014-2018 # # # # 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 # @@ -152,7 +152,7 @@ if(OS_MACOSX) target_link_libraries(${CEF_HELPER_TARGET} libcef_lib libcef_dll_wrapper ${CEF_STANDARD_LIBS}) set_target_properties(${CEF_HELPER_TARGET} PROPERTIES MACOSX_BUNDLE_INFO_PLIST ${CMAKE_CURRENT_SOURCE_DIR}/mac/helper-Info.plist - ) + ) # Fix the framework rpath in the helper executable. FIX_MACOSX_HELPER_FRAMEWORK_RPATH(${CEF_HELPER_TARGET}) diff --git a/modules/webbrowser/include/browserclient.h b/modules/webbrowser/include/browserclient.h index 1a2ed9937b..be1922626e 100644 --- a/modules/webbrowser/include/browserclient.h +++ b/modules/webbrowser/include/browserclient.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -51,4 +51,4 @@ private: } // namespace openspace -#endif // __OPENSPACE_MODULE_WEBBROWSER___BROWSER_CLIENT___H__ +#endif // __OPENSPACE_MODULE_WEBBROWSER___BROWSER_CLIENT___H__ diff --git a/modules/webbrowser/include/browserinstance.h b/modules/webbrowser/include/browserinstance.h index 0c9247df27..fc3f472e7e 100644 --- a/modules/webbrowser/include/browserinstance.h +++ b/modules/webbrowser/include/browserinstance.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -47,8 +47,9 @@ public: void close(bool force = false); bool sendKeyEvent(const CefKeyEvent &event); - bool sendMouseClickEvent(const CefMouseEvent &event, CefBrowserHost::MouseButtonType button, - bool mouseUp, int clickCount = SINGLE_CLICK); + bool sendMouseClickEvent(const CefMouseEvent &event, + CefBrowserHost::MouseButtonType button, bool mouseUp, + int clickCount = SINGLE_CLICK); bool sendMouseMoveEvent(const CefMouseEvent &event); bool sendMouseWheelEvent(const CefMouseEvent &event, glm::ivec2 delta); void reloadBrowser(); @@ -66,6 +67,6 @@ private: bool _isInitialized; }; -} +} // namespace openspace -#endif //__OPENSPACE_MODULE_WEBBROWSER__BROWSER_INSTANCE_H +#endif // __OPENSPACE_MODULE_WEBBROWSER__BROWSER_INSTANCE_H diff --git a/modules/webbrowser/include/cefhost.h b/modules/webbrowser/include/cefhost.h index 886d3f70d4..cbede7013c 100644 --- a/modules/webbrowser/include/cefhost.h +++ b/modules/webbrowser/include/cefhost.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_MODULE_WEBBROWSER__CEF_HOST_H -#define __OPENSPACE_MODULE_WEBBROWSER__CEF_HOST_H +#ifndef __OPENSPACE_MODULE_WEBBROWSER___CEF_HOST___H__ +#define __OPENSPACE_MODULE_WEBBROWSER___CEF_HOST___H__ #include #include @@ -46,4 +46,4 @@ private: } // namespace openspace -#endif //__OPENSPACE_MODULE_WEBBROWSER__CEF_HOST_H +#endif // __OPENSPACE_MODULE_WEBBROWSER___CEF_HOST___H__ diff --git a/modules/webbrowser/include/defaultbrowserlauncher.h b/modules/webbrowser/include/defaultbrowserlauncher.h index 6b37809c74..436caa399c 100644 --- a/modules/webbrowser/include/defaultbrowserlauncher.h +++ b/modules/webbrowser/include/defaultbrowserlauncher.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -33,17 +33,13 @@ namespace openspace { class DefaultBrowserLauncher : public CefLifeSpanHandler, public CefRequestHandler { public: - bool OnBeforePopup(CefRefPtr parentBrowser, - const CefPopupFeatures& popupFeatures, - CefWindowInfo& windowInfo, - const CefString& url, - CefRefPtr& client, - CefBrowserSettings& settings); - bool OnOpenURLFromTab(CefRefPtr browser, - CefRefPtr frame, - const CefString& target_url, - CefRequestHandler::WindowOpenDisposition target_disposition, - bool user_gesture); + bool OnBeforePopup(CefRefPtr parentBrowser, + const CefPopupFeatures& popupFeatures, CefWindowInfo& windowInfo, + const CefString& url, CefRefPtr& client, CefBrowserSettings& settings); + + bool OnOpenURLFromTab(CefRefPtr browser, CefRefPtr frame, + const CefString& target_url, + CefRequestHandler::WindowOpenDisposition target_disposition, bool userGesture); private: void launchBrowser(const std::string &url) const; @@ -52,4 +48,4 @@ private: } // namespace openspace -#endif // __OPENSPACE_MODULE_WEBBROWSER___DEFAULT_BROWSER_LAUNCHER___H__ +#endif // __OPENSPACE_MODULE_WEBBROWSER___DEFAULT_BROWSER_LAUNCHER___H__ diff --git a/modules/webbrowser/include/eventhandler.h b/modules/webbrowser/include/eventhandler.h index 75813a3880..658810c80a 100644 --- a/modules/webbrowser/include/eventhandler.h +++ b/modules/webbrowser/include/eventhandler.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -22,7 +22,6 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ - #ifndef __OPENSPACE_MODULE_WEBBROWSER___EVENT_HANDLER___H__ #define __OPENSPACE_MODULE_WEBBROWSER___EVENT_HANDLER___H__ @@ -37,8 +36,6 @@ namespace openspace { class EventHandler { public: - EventHandler() : _mousePosition(0, 0), _browserInstance(nullptr), _lastClickPosition(0, 0) {}; - void initialize(); void setBrowser(const CefRefPtr &browser); void setBrowserInstance(const std::shared_ptr & browserInstance); @@ -62,8 +59,9 @@ private: bool _leftMouseDown = false; - std::shared_ptr _browserInstance; - glm::vec2 _mousePosition, _lastClickPosition; + std::shared_ptr _browserInstance = nullptr; + glm::vec2 _mousePosition = { 0.f, 0.f }; + glm::vec2 _lastClickPosition = { 0.f, 0.f }; std::chrono::high_resolution_clock::time_point _lastClickTime; /** @@ -73,19 +71,21 @@ private: bool isDoubleClick() const; /** - * get the number of milliseconds that is allowed between two clicks for it to count as a double click + * get the number of milliseconds that is allowed between two clicks for it to count + * as a double click * @return */ static int doubleClickTime(); /** - * get the rectangle width around the first click in a double click that the second click has to be _within_ + * get the rectangle width around the first click in a double click that the second + * click has to be _within_ * @return */ static int maxDoubleClickDistance(); }; -} +} // namespace openspace -#endif //__OPENSPACE_MODULE_WEBBROWSER___EVENT_HANDLER___H__ +#endif // __OPENSPACE_MODULE_WEBBROWSER___EVENT_HANDLER___H__ diff --git a/modules/webbrowser/include/screenspacebrowser.h b/modules/webbrowser/include/screenspacebrowser.h index a02d39c89c..359ff6a78d 100644 --- a/modules/webbrowser/include/screenspacebrowser.h +++ b/modules/webbrowser/include/screenspacebrowser.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_MODULE_WEBBROWSER__SCREEN_SPACE_BROWSER_H -#define __OPENSPACE_MODULE_WEBBROWSER__SCREEN_SPACE_BROWSER_H +#ifndef __OPENSPACE_MODULE_WEBBROWSER___SCREEN_SPACE_BROWSER___H__ +#define __OPENSPACE_MODULE_WEBBROWSER___SCREEN_SPACE_BROWSER___H__ #include #include @@ -36,19 +36,6 @@ #include "include/screenspacerenderhandler.h" #include "include/browserinstance.h" -namespace { -static const openspace::properties::Property::PropertyInfo BrowserDimensionsInfo = { - "Dimensions", - "Browser Dimensions", - "Set the dimensions of the web browser windows." -}; -static const openspace::properties::Property::PropertyInfo UrlInfo = { - "URL", - "url", - "The URL to load" -}; -} - namespace openspace { class ScreenSpaceBrowser : public ScreenSpaceRenderable { @@ -72,6 +59,6 @@ private: bool _dimensionsAreDirty; }; -}; +} // namespace openspace -#endif //__OPENSPACE_MODULE_WEBBROWSER__SCREEN_SPACE_BROWSER_H +#endif // __OPENSPACE_MODULE_WEBBROWSER___SCREEN_SPACE_BROWSER___H__ diff --git a/modules/webbrowser/include/screenspacerenderhandler.h b/modules/webbrowser/include/screenspacerenderhandler.h index f1de964115..28b8dffbc5 100644 --- a/modules/webbrowser/include/screenspacerenderhandler.h +++ b/modules/webbrowser/include/screenspacerenderhandler.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_MODULE_WEBBROWSER___SCREEN_SPACE_RENDER_HANDLER_H -#define __OPENSPACE_MODULE_WEBBROWSER___SCREEN_SPACE_RENDER_HANDLER_H +#ifndef __OPENSPACE_MODULE_WEBBROWSER___SCREEN_SPACE_RENDER_HANDLER___H__ +#define __OPENSPACE_MODULE_WEBBROWSER___SCREEN_SPACE_RENDER_HANDLER___H__ #include "include/webrenderhandler.h" @@ -31,14 +31,12 @@ namespace openspace { class ScreenSpaceRenderHandler : public WebRenderHandler { public: - ScreenSpaceRenderHandler() {}; - - void draw(void); + void draw(); void render(); void setTexture(const GLuint&); }; -} +} // namespace openspace -#endif //__OPENSPACE_MODULE_WEBBROWSER___SCREEN_SPACE_RENDER_HANDLER_H +#endif // __OPENSPACE_MODULE_WEBBROWSER___SCREEN_SPACE_RENDER_HANDLER___H__ diff --git a/modules/webbrowser/include/webbrowserapp.h b/modules/webbrowser/include/webbrowserapp.h index 0a84373e2a..7c8544135f 100644 --- a/modules/webbrowser/include/webbrowserapp.h +++ b/modules/webbrowser/include/webbrowserapp.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_MODULE_WEBBROWSER__WEBBROWSERAPP_H -#define __OPENSPACE_MODULE_WEBBROWSER__WEBBROWSERAPP_H +#ifndef __OPENSPACE_MODULE_WEBBROWSER___WEBBROWSERAPP___H__ +#define __OPENSPACE_MODULE_WEBBROWSER___WEBBROWSERAPP___H__ #include #include @@ -39,11 +39,13 @@ public: WebBrowserApp(); CefRefPtr GetRenderProcessHandler() override; - void OnContextCreated(CefRefPtr, CefRefPtr, CefRefPtr) override; + void OnContextCreated(CefRefPtr, CefRefPtr, + CefRefPtr) override; private: IMPLEMENT_REFCOUNTING(WebBrowserApp); }; -}; -#endif // __OPENSPACE_MODULE_WEBBROWSER__WEBBROWSERAPP_H +} // namespace openspace + +#endif // __OPENSPACE_MODULE_WEBBROWSER___WEBBROWSERAPP___H__ diff --git a/modules/webbrowser/include/webrenderhandler.h b/modules/webbrowser/include/webrenderhandler.h index 8e489d9bbc..e883465e9f 100644 --- a/modules/webbrowser/include/webrenderhandler.h +++ b/modules/webbrowser/include/webrenderhandler.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -47,8 +47,8 @@ public: void reshape(int, int); bool GetViewRect(CefRefPtr browser, CefRect &rect) override; - void OnPaint(CefRefPtr browser, PaintElementType type, const RectList &dirtyRects, const void *buffer, - int width, int height) override; + void OnPaint(CefRefPtr browser, PaintElementType type, + const RectList &dirtyRects, const void* buffer, int width, int height) override; bool hasContent(int x, int y); protected: @@ -73,4 +73,4 @@ protected: } // namespace openspace -#endif //__OPENSPACE_MODULE_WEBBROWSER__WEB_RENDER_HANDLER_H +#endif // __OPENSPACE_MODULE_WEBBROWSER__WEB_RENDER_HANDLER_H diff --git a/modules/webbrowser/src/browserclient.cpp b/modules/webbrowser/src/browserclient.cpp index 040021a160..ad9a17e113 100644 --- a/modules/webbrowser/src/browserclient.cpp +++ b/modules/webbrowser/src/browserclient.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/webbrowser/src/browserinstance.cpp b/modules/webbrowser/src/browserinstance.cpp index 1b8434e335..bd84354f45 100644 --- a/modules/webbrowser/src/browserinstance.cpp +++ b/modules/webbrowser/src/browserinstance.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -32,7 +32,9 @@ const bool DID_NOT_LEAVE_WINDOW = false; namespace openspace { -BrowserInstance::BrowserInstance(WebRenderHandler* renderer) : _isInitialized(false) { +BrowserInstance::BrowserInstance(WebRenderHandler* renderer) + : _isInitialized(false) +{ _renderHandler = renderer; _client = new BrowserClient(_renderHandler); @@ -44,7 +46,13 @@ BrowserInstance::BrowserInstance(WebRenderHandler* renderer) : _isInitialized(fa browserSettings.windowless_frame_rate = 60; std::string url = ""; - _browser = CefBrowserHost::CreateBrowserSync(windowInfo, _client.get(), url, browserSettings, NULL); + _browser = CefBrowserHost::CreateBrowserSync( + windowInfo, + _client.get(), + url, + browserSettings, + nullptr + ); } BrowserInstance::~BrowserInstance() { @@ -52,7 +60,7 @@ BrowserInstance::~BrowserInstance() { } void BrowserInstance::initialize() { - auto &wrapper = OsEng.windowWrapper(); + auto& wrapper = OsEng.windowWrapper(); reshape(wrapper.currentWindowSize()); _isInitialized = true; @@ -112,8 +120,10 @@ bool BrowserInstance::sendKeyEvent(const CefKeyEvent &event) { return false; } -bool BrowserInstance::sendMouseClickEvent(const CefMouseEvent &event, CefBrowserHost::MouseButtonType button, - bool mouseUp, int clickCount) { +bool BrowserInstance::sendMouseClickEvent(const CefMouseEvent &event, + CefBrowserHost::MouseButtonType button, + bool mouseUp, int clickCount) +{ _browser->GetHost()->SendMouseClickEvent(event, button, mouseUp, clickCount); return hasContent(event.x, event.y); } diff --git a/modules/webbrowser/src/cefhost.cpp b/modules/webbrowser/src/cefhost.cpp index 3ddee68ec8..d24434a35f 100644 --- a/modules/webbrowser/src/cefhost.cpp +++ b/modules/webbrowser/src/cefhost.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -35,7 +35,10 @@ CefHost::CefHost(std::string helperLocation) { CefMainArgs args; CefSettings settings; - CefString(&settings.browser_subprocess_path).FromASCII((char*) helperLocation.c_str()); + CefString(&settings.browser_subprocess_path).FromASCII( + // This is bad as it casts away the const + (char*) helperLocation.c_str() + ); attachDebugSettings(settings); #ifdef WIN32 @@ -55,7 +58,10 @@ CefHost::~CefHost() { void CefHost::attachDebugSettings(CefSettings &settings) { settings.remote_debugging_port = 8088; - LDEBUG(fmt::format("Remote WebBrowser debugging available on http://localhost:{}", settings.remote_debugging_port)); + LDEBUG(fmt::format( + "Remote WebBrowser debugging available on http://localhost:{}", + settings.remote_debugging_port + )); // settings.single_process = true; } diff --git a/modules/webbrowser/src/defaultbrowserlauncher.cpp b/modules/webbrowser/src/defaultbrowserlauncher.cpp index 87233d9f9a..229ff51a95 100644 --- a/modules/webbrowser/src/defaultbrowserlauncher.cpp +++ b/modules/webbrowser/src/defaultbrowserlauncher.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/webbrowser/src/eventhandler.cpp b/modules/webbrowser/src/eventhandler.cpp index 174dd24109..62b3b35211 100644 --- a/modules/webbrowser/src/eventhandler.cpp +++ b/modules/webbrowser/src/eventhandler.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -28,10 +28,11 @@ #include "include/eventhandler.h" namespace { -const std::string _loggerCat = "WebBrowser:EventHandler"; -} + const std::string _loggerCat = "WebBrowser:EventHandler"; +} // namespace namespace openspace { + void EventHandler::initialize() { OsEng.registerModuleCharCallback( [this](unsigned int charCode, KeyModifier mod) -> bool { @@ -96,7 +97,12 @@ bool EventHandler::mouseButtonCallback(MouseButton button, MouseAction action) { _lastClickPosition = _mousePosition; } - return _browserInstance->sendMouseClickEvent(mouseEvent(), MBT_LEFT, !_leftMouseDown, clickCount); + return _browserInstance->sendMouseClickEvent( + mouseEvent(), + MBT_LEFT, + !_leftMouseDown, + clickCount + ); } bool EventHandler::isDoubleClick() const { @@ -159,7 +165,8 @@ bool EventHandler::keyboardCallback(Key key, KeyModifier modifier, KeyAction act } /** - * Detect if there is a special event that should be caught by the GUI before it is sent to CEF + * Detect if there is a special event that should be caught by the GUI before it is sent + * to CEF. * @param key the pressed key * @return true if event found, false otherwise */ @@ -222,14 +229,18 @@ CefMouseEvent EventHandler::mouseEvent() { return event; } -void EventHandler::setBrowserInstance(const std::shared_ptr &browserInstance) { +void EventHandler::setBrowserInstance( + const std::shared_ptr& browserInstance) +{ LDEBUG("Setting browser instance."); _browserInstance = browserInstance; } void EventHandler::detachBrowser() { if (_browserInstance) { - LDEBUG(fmt::format("Detaching browser instance with use count {}", _browserInstance.use_count())); + LDEBUG(fmt::format( + "Detaching browser instance with use count {}", _browserInstance.use_count() + )); } _browserInstance = nullptr; } diff --git a/modules/webbrowser/src/processhelpermac.cpp b/modules/webbrowser/src/processhelpermac.cpp index a1e5f189f1..e4b013c8ca 100644 --- a/modules/webbrowser/src/processhelpermac.cpp +++ b/modules/webbrowser/src/processhelpermac.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/webbrowser/src/processhelperwindows.cpp b/modules/webbrowser/src/processhelperwindows.cpp index f64f323975..98c7cce615 100644 --- a/modules/webbrowser/src/processhelperwindows.cpp +++ b/modules/webbrowser/src/processhelperwindows.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -30,15 +30,12 @@ #include "include/webbrowserapp.h" // Entry point function for sub-processes. -int main(HINSTANCE hInstance, - HINSTANCE hPrevInstance, - LPTSTR lpCmdLine, - int nCmdShow) { - // Provide CEF with command-line arguments. - CefMainArgs main_args(hInstance); +int main(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { + // Provide CEF with command-line arguments. + CefMainArgs main_args(hInstance); - CefRefPtr app(new openspace::WebBrowserApp); + CefRefPtr app(new openspace::WebBrowserApp); - // Execute the sub-process. - return CefExecuteProcess(main_args, app.get(), NULL); + // Execute the sub-process. + return CefExecuteProcess(main_args, app.get(), NULL); } diff --git a/modules/webbrowser/src/screenspacebrowser.cpp b/modules/webbrowser/src/screenspacebrowser.cpp index 7ae604f5e3..05c85f7578 100644 --- a/modules/webbrowser/src/screenspacebrowser.cpp +++ b/modules/webbrowser/src/screenspacebrowser.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -30,6 +30,18 @@ namespace { const char* KeyIdentifier = "Indentifier"; const char* KeyUrl = "URL"; const std::string _loggerCat = "ScreenSpaceBrowser"; + +static const openspace::properties::Property::PropertyInfo BrowserDimensionsInfo = { + "Dimensions", + "Browser Dimensions", + "Set the dimensions of the web browser windows." +}; +static const openspace::properties::Property::PropertyInfo UrlInfo = { + "URL", + "url", + "The URL to load" +}; + } // namespace namespace openspace { @@ -60,7 +72,9 @@ ScreenSpaceBrowser::ScreenSpaceBrowser(const ghoul::Dictionary &dictionary) glm::vec2 windowDimensions = OsEng.windowWrapper().currentWindowSize(); _dimensions = windowDimensions; - _texture = std::make_unique(glm::uvec3(windowDimensions, 1.0f)); + _texture = std::make_unique( + glm::uvec3(windowDimensions, 1.0f) + ); _renderHandler = new ScreenSpaceRenderHandler(); _browserInstance = std::make_shared(_renderHandler); diff --git a/modules/webbrowser/src/screenspacerenderhandler.cpp b/modules/webbrowser/src/screenspacerenderhandler.cpp index 24162c3bfd..79d14c9d02 100644 --- a/modules/webbrowser/src/screenspacerenderhandler.cpp +++ b/modules/webbrowser/src/screenspacerenderhandler.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/webbrowser/src/webbrowserapp.cpp b/modules/webbrowser/src/webbrowserapp.cpp index 202bae5621..8846417322 100644 --- a/modules/webbrowser/src/webbrowserapp.cpp +++ b/modules/webbrowser/src/webbrowserapp.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/webbrowser/src/webrenderhandler.cpp b/modules/webbrowser/src/webrenderhandler.cpp index bd8165299d..d16a5c0b69 100644 --- a/modules/webbrowser/src/webrenderhandler.cpp +++ b/modules/webbrowser/src/webrenderhandler.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -28,23 +28,34 @@ namespace openspace { void WebRenderHandler::reshape(int w, int h) { -// LDEBUGC("WebRenderHandler", fmt::format("Reshaping browser window. Width: {}, height: {}", w, h)); _width = w; _height = h; _alphaMask.clear(); _alphaMask.resize(w * h); } -bool WebRenderHandler::GetViewRect(CefRefPtr browser, CefRect &rect) { +bool WebRenderHandler::GetViewRect(CefRefPtr browser, CefRect& rect) { rect = CefRect(0, 0, _width, _height); return true; } -void WebRenderHandler::OnPaint(CefRefPtr browser, CefRenderHandler::PaintElementType type, - const CefRenderHandler::RectList &dirtyRects, const void *buffer, - int w, int h) { +void WebRenderHandler::OnPaint(CefRefPtr browser, + CefRenderHandler::PaintElementType type, + const CefRenderHandler::RectList& dirtyRects, + const void* buffer, int w, int h) +{ glBindTexture(GL_TEXTURE_2D, _texture); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, _width, _height, 0, GL_BGRA_EXT, GL_UNSIGNED_BYTE, (unsigned char*) buffer); + glTexImage2D( + GL_TEXTURE_2D, + 0, + GL_RGBA, + _width, + _height, + 0, + GL_BGRA_EXT, + GL_UNSIGNED_BYTE, + buffer + ); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); @@ -66,4 +77,4 @@ bool WebRenderHandler::hasContent(int x, int y) { return _alphaMask[index]; } -} +} // namespace openspace diff --git a/modules/webbrowser/webbrowsermodule.cpp b/modules/webbrowser/webbrowsermodule.cpp index 575b6b02d9..9ef6cbc859 100644 --- a/modules/webbrowser/webbrowsermodule.cpp +++ b/modules/webbrowser/webbrowsermodule.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -68,7 +68,9 @@ std::string WebBrowserModule::findHelperExecutable() { auto execLocation = absPath(OsEng.configurationManager().value( ConfigurationManager::KeyWebHelperLocation) + SUBPROCESS_ENDING); if (!FileSys.fileExists(execLocation)) { - LERROR(fmt::format("Could not find web helper executable at location: {}" , execLocation)); + LERROR(fmt::format( + "Could not find web helper executable at location: {}" , execLocation + )); } return execLocation; } @@ -78,19 +80,29 @@ std::string WebBrowserModule::findHelperExecutable() { LWARNING(fmt::format("Assuming web helper name is {}", subprocessName)); auto subLength = (int)subprocessName.length(); - Directory binDir("${BASE}/bin/openspace", Directory::AbsolutePath::No); - std::vector foundFiles = binDir.readFiles(Directory::Recursive::Yes, Directory::Sort::Yes); + Directory binDir("${BASE}/bin/openspace", Directory::RawPath::No); + std::vector foundFiles = binDir.readFiles( + Directory::Recursive::Yes, + Directory::Sort::Yes + ); // find files matching the given file name std::vector matchingFiles; - std::copy_if(foundFiles.begin(), foundFiles.end(), std::back_inserter(matchingFiles), + std::copy_if( + foundFiles.begin(), + foundFiles.end(), + std::back_inserter(matchingFiles), [subprocessName, subLength](std::string s) { - s = s.substr(s.size() - subLength); - return s == subprocessName; - }); + s = s.substr(s.size() - subLength); + return s == subprocessName; + } + ); if (matchingFiles.empty()) { - LERROR(fmt::format("Could not find requested sub process executable file name: {}", subprocessName)); + LERROR(fmt::format( + "Could not find requested sub process executable file name: {}", + subprocessName + )); } return matchingFiles.back(); @@ -125,7 +137,9 @@ void WebBrowserModule::removeBrowser(std::shared_ptr browser) { LDEBUG(fmt::format("Number of browsers stored: {}", _browsers.size())); } -void WebBrowserModule::attachEventHandler(std::shared_ptr browserInstance) { +void WebBrowserModule::attachEventHandler( + std::shared_ptr browserInstance) +{ _eventHandler.setBrowserInstance(browserInstance); } diff --git a/modules/webbrowser/webbrowsermodule.h b/modules/webbrowser/webbrowsermodule.h index 85c74902cf..319e4a88e3 100644 --- a/modules/webbrowser/webbrowsermodule.h +++ b/modules/webbrowser/webbrowsermodule.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/webgui/CMakeLists.txt b/modules/webgui/CMakeLists.txt index 114b209408..b602c87287 100644 --- a/modules/webgui/CMakeLists.txt +++ b/modules/webgui/CMakeLists.txt @@ -2,7 +2,7 @@ # # # OpenSpace # # # -# Copyright (c) 2014-2017 # +# Copyright (c) 2014-2018 # # # # 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 # diff --git a/modules/webgui/webguimodule.cpp b/modules/webgui/webguimodule.cpp index 768944cc63..5dd1ebbd34 100644 --- a/modules/webgui/webguimodule.cpp +++ b/modules/webgui/webguimodule.cpp @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * diff --git a/modules/webgui/webguimodule.h b/modules/webgui/webguimodule.h index f5f3f06dcc..141551682e 100644 --- a/modules/webgui/webguimodule.h +++ b/modules/webgui/webguimodule.h @@ -2,7 +2,7 @@ * * * OpenSpace * * * - * Copyright (c) 2014-2017 * + * Copyright (c) 2014-2018 * * * * 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 * @@ -22,11 +22,10 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef OPENSPACE_WEBGUIMODULE_H -#define OPENSPACE_WEBGUIMODULE_H +#ifndef __OPENSPACE_MODULE_WEBGUI___WEBGUIMODULE___H__ +#define __OPENSPACE_MODULE_WEBGUI___WEBGUIMODULE___H__ #include -#include namespace openspace { @@ -36,6 +35,6 @@ public: WebGuiModule(); }; -} +} // namespace openspace -#endif //OPENSPACE_WEBGUIMODULE_H +#endif // __OPENSPACE_MODULE_WEBGUI___WEBGUIMODULE___H__ diff --git a/src/engine/configurationmanager.cpp b/src/engine/configurationmanager.cpp index 6f62e808d7..9db7940a23 100644 --- a/src/engine/configurationmanager.cpp +++ b/src/engine/configurationmanager.cpp @@ -47,81 +47,6 @@ namespace { namespace openspace { -// static constexpr const char* ConfigurationManager::KeyPaths = "Paths"; -// const string ConfigurationManager::KeyCache = "CACHE"; -// const string ConfigurationManager::KeyFonts = "Fonts"; -// const string ConfigurationManager::KeyConfigSgct = "SGCTConfig"; -// const string ConfigurationManager::KeyGlobalCustomizationScripts = - // "GlobalCustomizationScripts"; - -// const string ConfigurationManager::PartType = "Type"; -// const string ConfigurationManager::PartFile = "File"; - -// const string ConfigurationManager::KeyLuaDocumentation = "LuaDocumentation"; -// const string ConfigurationManager::KeyScriptLog = "ScriptLog"; -// const string ConfigurationManager::KeyPropertyDocumentation = "PropertyDocumentation"; -// const string ConfigurationManager::KeyScenePropertyDocumentation = - // "ScenePropertyDocumentation"; -// const string ConfigurationManager::KeyKeyboardShortcuts = "KeyboardShortcuts"; -// const string ConfigurationManager::KeyDocumentation = "Documentation"; -// const string ConfigurationManager::KeyFactoryDocumentation = "FactoryDocumentation"; - -// const string ConfigurationManager::KeyConfigAsset = "Asset"; -// const string ConfigurationManager::KeySceneLicenseDocumentation = "LicenseDocumentation"; - -// const string ConfigurationManager::KeyLogging = "Logging"; -// const string ConfigurationManager::PartLogDir = "LogDir"; -// const string ConfigurationManager::PartLogLevel = "LogLevel"; -// const string ConfigurationManager::PartImmediateFlush = "ImmediateFlush"; -// const string ConfigurationManager::PartLogPerformancePrefix = "PerformancePrefix"; - -// const string ConfigurationManager::PartLogs = "Logs"; -// const string ConfigurationManager::PartAppend = "Append"; -// const string ConfigurationManager::PartCapabilitiesVerbosity = "CapabilitiesVerbosity"; - -// const string ConfigurationManager::KeyLauncher = "Launcher"; - -// const string ConfigurationManager::KeyCapabilitiesVerbosity = - // KeyLogging + "." + PartCapabilitiesVerbosity; - -// const string ConfigurationManager::KeyShutdownCountdown = "ShutdownCountdown"; -// const string ConfigurationManager::KeyDisableMasterRendering = "DisableRenderingOnMaster"; -// const string ConfigurationManager::KeyDisableSceneOnMaster = "DisableSceneOnMaster"; -// const string ConfigurationManager::KeyPerSceneCache = "PerSceneCache"; -// const string ConfigurationManager::KeyRenderingMethod = "RenderingMethod"; - -// const string ConfigurationManager::KeyOnScreenTextScaling = "OnScreenTextScaling"; - -// const string ConfigurationManager::KeyHttpProxy = "HttpProxy"; -// const string ConfigurationManager::PartHttpProxyAddress = "Address"; -// const string ConfigurationManager::PartHttpProxyPort = "Port"; -// const string ConfigurationManager::PartHttpProxyAuthentication = "Authentication"; -// const string ConfigurationManager::PartHttpProxyUser = "User"; -// const string ConfigurationManager::PartHttpProxyPassword = "Password"; - -// const string ConfigurationManager::KeyOpenGLDebugContext = "OpenGLDebugContext"; -// const string ConfigurationManager::PartActivate = "Activate"; -// const string ConfigurationManager::PartSynchronous = "Synchronous"; -// const string ConfigurationManager::PartFilterIdentifier = "FilterIdentifier"; -// const string ConfigurationManager::PartFilterIdentifierSource = "Source"; -// const string ConfigurationManager::PartFilterIdentifierType = "Type"; -// const string ConfigurationManager::PartFilterIdentifierIdentifier = "Identifier"; -// const string ConfigurationManager::PartFilterSeverity = "PartFilterSeverity"; -// const string ConfigurationManager::KeyCheckOpenGLState = "CheckOpenGLState"; -// const string ConfigurationManager::KeyLogEachOpenGLCall = "LogEachOpenGLCall"; - -// const string ConfigurationManager::KeyUseMultithreadedInitialization = - // "UseMultithreadedInitialization"; - -// const string ConfigurationManager::KeyLoadingScreen = "LoadingScreen"; -// const string ConfigurationManager::PartShowMessage = "ShowMessage"; -// const string ConfigurationManager::PartShowNodeNames = "ShowNodeNames"; -// const string ConfigurationManager::PartShowProgressbar = "ShowProgressbar"; - -// const string ConfigurationManager::KeyScreenshotUseDate = "ScreenshotUseDate"; - -// const string ConfigurationManager::KeyModuleConfigurations = "ModuleConfigurations"; - string ConfigurationManager::findConfiguration(const string& filename) { using ghoul::filesystem::Directory; diff --git a/src/engine/configurationmanager_doc.inl b/src/engine/configurationmanager_doc.inl index 3650da9157..a365448508 100644 --- a/src/engine/configurationmanager_doc.inl +++ b/src/engine/configurationmanager_doc.inl @@ -69,7 +69,6 @@ documentation::Documentation ConfigurationManager::Documentation() { "in all other configuration files or scripts." }, { - ConfigurationManager::KeyCachePath, new StringVerifier, Optional::No, @@ -205,21 +204,21 @@ documentation::Documentation ConfigurationManager::Documentation() { ConfigurationManager::KeyRequireSocketAuthentication, new BoolVerifier, Optional::Yes, - "If socket connections should be authenticated or not before they are allowed to " - "get or set information. Defaults to `true`." + "If socket connections should be authenticated or not before they are " + "allowed to get or set information. Defaults to 'true'." }, { ConfigurationManager::KeyServerPasskey, - new StringVerifier, - Optional::Yes, - "Passkey to limit server access. Used to authorize incoming connections." + new StringVerifier, + Optional::Yes, + "Passkey to limit server access. Used to authorize incoming connections." }, { ConfigurationManager::KeyServerClientAddressWhitelist, - new StringVerifier, - Optional::Yes, - "String containing white listed client IP addresses that won't need to be" - "authorized with the server. Space separated" + new StringVerifier, + Optional::Yes, + "String containing white listed client IP addresses that won't need to be " + "authorized with the server. Space separated" }, { ConfigurationManager::KeySceneLicenseDocumentation, @@ -368,8 +367,8 @@ documentation::Documentation ConfigurationManager::Documentation() { new BoolVerifier, Optional::Yes, "Determines whether the OpenGL debug callbacks are performed " - "synchronously. If set to the callbacks are in the same thread " - "as the context and in the scope of the OpenGL function that " + "synchronously. If set to the callbacks are in the same " + "thread as the context and in the scope of the OpenGL function that " "triggered the message. The default value is ." }, { diff --git a/src/engine/downloadmanager.cpp b/src/engine/downloadmanager.cpp index d594a0218d..9f87dd24e0 100644 --- a/src/engine/downloadmanager.cpp +++ b/src/engine/downloadmanager.cpp @@ -91,8 +91,8 @@ namespace { ghoul_assert(p, "Passed progress information is nullptr"); ProgressInformation* i = static_cast(p); ghoul_assert(i, "Passed pointer is not a ProgressInformation"); - ghoul_assert(i->future, "FileFuture is not initialized"); - ghoul_assert(i->callback, "Callback pointer is nullptr"); + ghoul_assert(i && i->future, "FileFuture is not initialized"); + ghoul_assert(i && i->callback, "Callback pointer is nullptr"); if (i->future->abortDownload) { i->future->isAborted = true; diff --git a/src/engine/openspaceengine.cpp b/src/engine/openspaceengine.cpp index b9e1d2946c..a34b2252ac 100644 --- a/src/engine/openspaceengine.cpp +++ b/src/engine/openspaceengine.cpp @@ -293,7 +293,7 @@ void OpenSpaceEngine::create(int argc, char** argv, // Parse commandline arguments std::vector args(argv, argv + argc); - std::shared_ptr> arguments = + const std::vector& arguments = _engine->_commandlineParser->setCommandLine(args); bool showHelp = _engine->_commandlineParser->execute(); @@ -302,7 +302,8 @@ void OpenSpaceEngine::create(int argc, char** argv, requestClose = true; return; } - sgctArguments = *arguments; + std::vector argumentsCopy = arguments; + sgctArguments = std::move(argumentsCopy); // Find configuration std::string configurationFilePath = commandlineArgumentPlaceholders.configurationName; @@ -1476,7 +1477,7 @@ void OpenSpaceEngine::mouseButtonCallback(MouseButton button, MouseAction action if (consumed) { // If the mouse was released, we still want to forward it to the navigation // handler in order to reliably terminate a rotation or zoom. Accidentally - // moving the cursor over a UI window is easy to miss and leads to weird + // moving the cursor over a UI window is easy to miss and leads to weird // continuing movement if (action == MouseAction::Release) { break; diff --git a/src/engine/virtualpropertymanager.cpp b/src/engine/virtualpropertymanager.cpp index 124f5bc96c..516b334c02 100644 --- a/src/engine/virtualpropertymanager.cpp +++ b/src/engine/virtualpropertymanager.cpp @@ -28,7 +28,9 @@ namespace openspace { -VirtualPropertyManager::VirtualPropertyManager() : properties::PropertyOwner({ "VirtualPropertyManager" }) {} +VirtualPropertyManager::VirtualPropertyManager() + : properties::PropertyOwner({ "VirtualPropertyManager" }) +{} void VirtualPropertyManager::addProperty(std::unique_ptr prop) { // PropertyOwner does not take the ownership of the pointer diff --git a/src/engine/wrapper/sgctwindowwrapper.cpp b/src/engine/wrapper/sgctwindowwrapper.cpp index fef3b7b9ff..f635b96bd7 100644 --- a/src/engine/wrapper/sgctwindowwrapper.cpp +++ b/src/engine/wrapper/sgctwindowwrapper.cpp @@ -176,9 +176,10 @@ int SGCTWindowWrapper::currentNumberOfAaSamples() const { bool SGCTWindowWrapper::isRegularRendering() const { sgct::SGCTWindow* w = sgct::Engine::instance()->getCurrentWindowPtr(); - std::size_t nViewports = w->getNumberOfViewports(); - (void)nViewports; // Unused in Release mode - ghoul_assert(nViewports > 0, "At least one viewport must exist at this time"); + ghoul_assert( + w->getNumberOfViewports() > 0, + "At least one viewport must exist at this time" + ); sgct_core::Viewport* vp = w->getViewport(0); sgct_core::NonLinearProjection* nlp = vp->getNonLinearProjectionPtr(); return nlp == nullptr; diff --git a/src/interaction/keybindingmanager_lua.inl b/src/interaction/keybindingmanager_lua.inl index 33f7edf830..0e3f6a27c9 100644 --- a/src/interaction/keybindingmanager_lua.inl +++ b/src/interaction/keybindingmanager_lua.inl @@ -172,7 +172,7 @@ int clearKey(lua_State* L) { // The user provided a list of keys ghoul::Dictionary d; ghoul::lua::luaDictionaryFromState(L, d); - for (int i = 1; i <= d.size(); ++i) { + for (size_t i = 1; i <= d.size(); ++i) { std::string k = d.value(std::to_string(i)); OsEng.keyBindingManager().removeKeyBinding(k); } diff --git a/src/interaction/touchbar.mm b/src/interaction/touchbar.mm index a1461a879b..813d0a1aa6 100644 --- a/src/interaction/touchbar.mm +++ b/src/interaction/touchbar.mm @@ -78,6 +78,8 @@ NSArray* focusIdentifiers; - (NSTouchBarItem *)touchBar:(NSTouchBar *)touchBar makeItemForIdentifier:(NSTouchBarItemIdentifier)identifier { + // @TODO(abock): Potential memory leak here by returning an alloc? + // Remove the unused variable warning (void)touchBar; diff --git a/src/network/parallelconnection.cpp b/src/network/parallelconnection.cpp index fb5694f308..516853901d 100644 --- a/src/network/parallelconnection.cpp +++ b/src/network/parallelconnection.cpp @@ -45,7 +45,9 @@ bool ParallelConnection::isConnectedOrConnecting() { return _socket->isConnected() || _socket->isConnecting(); } -void ParallelConnection::sendDataMessage(const ParallelConnection::DataMessage& dataMessage) { +void ParallelConnection::sendDataMessage( + const ParallelConnection::DataMessage& dataMessage) +{ uint32_t dataMessageTypeOut = static_cast(dataMessage.type); std::vector messageContent; @@ -57,7 +59,10 @@ void ParallelConnection::sendDataMessage(const ParallelConnection::DataMessage& dataMessage.content.begin(), dataMessage.content.end()); - sendMessage(ParallelConnection::Message(ParallelConnection::MessageType::Data, messageContent)); + sendMessage(ParallelConnection::Message( + ParallelConnection::MessageType::Data, + messageContent + )); } bool ParallelConnection::sendMessage(const ParallelConnection::Message& message) { @@ -112,7 +117,6 @@ ParallelConnection::Message ParallelConnection::receiveMessage() { std::vector headerBuffer(headerSize); std::vector messageBuffer; - // Receive the header data if (!_socket->get(headerBuffer.data(), headerSize)) { LERROR("Failed to read header from socket. Disconencting."); @@ -150,7 +154,10 @@ ParallelConnection::Message ParallelConnection::receiveMessage() { } // And delegate decoding depending on type - return ParallelConnection::Message(static_cast(messageTypeIn), messageBuffer); + return ParallelConnection::Message( + static_cast(messageTypeIn), + messageBuffer + ); } } // namespace openspace diff --git a/src/network/parallelpeer.cpp b/src/network/parallelpeer.cpp index e388914926..45fcf4102a 100644 --- a/src/network/parallelpeer.cpp +++ b/src/network/parallelpeer.cpp @@ -205,7 +205,10 @@ void ParallelPeer::sendAuthentication() { buffer.insert(buffer.end(), name.begin(), name.end()); // Send message - _connection.sendMessage(ParallelConnection::Message(ParallelConnection::MessageType::Authentication, buffer)); + _connection.sendMessage(ParallelConnection::Message( + ParallelConnection::MessageType::Authentication, + buffer + )); } void ParallelPeer::queueInMessage(const ParallelConnection::Message& message) { @@ -414,12 +417,18 @@ void ParallelPeer::requestHostship() { reinterpret_cast(&passwordHash), reinterpret_cast(&passwordHash) + sizeof(uint64_t) ); - _connection.sendMessage(ParallelConnection::Message(ParallelConnection::MessageType::HostshipRequest, buffer)); + _connection.sendMessage(ParallelConnection::Message( + ParallelConnection::MessageType::HostshipRequest, + buffer + )); } void ParallelPeer::resignHostship() { std::vector buffer; - _connection.sendMessage(ParallelConnection::Message(ParallelConnection::MessageType::HostshipResignation, buffer)); + _connection.sendMessage(ParallelConnection::Message( + ParallelConnection::MessageType::HostshipResignation, + buffer + )); } void ParallelPeer::setPassword(std::string pwd) { @@ -441,7 +450,10 @@ void ParallelPeer::sendScript(std::string script) { std::vector buffer; sm.serialize(buffer); - ParallelConnection::DataMessage message(datamessagestructures::Type::ScriptData, buffer); + ParallelConnection::DataMessage message( + datamessagestructures::Type::ScriptData, + buffer + ); _connection.sendDataMessage(message); } @@ -550,7 +562,10 @@ void ParallelPeer::sendCameraKeyframe() { kf.serialize(buffer); // Send message - _connection.sendDataMessage(ParallelConnection::DataMessage(datamessagestructures::Type::CameraData, buffer)); + _connection.sendDataMessage(ParallelConnection::DataMessage( + datamessagestructures::Type::CameraData, + buffer + )); } void ParallelPeer::sendTimeKeyframe() { @@ -574,7 +589,10 @@ void ParallelPeer::sendTimeKeyframe() { kf.serialize(buffer); // Send message - _connection.sendDataMessage(ParallelConnection::DataMessage(datamessagestructures::Type::TimeData, buffer)); + _connection.sendDataMessage(ParallelConnection::DataMessage( + datamessagestructures::Type::TimeData, + buffer + )); _timeJumped = false; } diff --git a/src/network/parallelserver.cpp b/src/network/parallelserver.cpp index bb9281d374..0f76f1348d 100644 --- a/src/network/parallelserver.cpp +++ b/src/network/parallelserver.cpp @@ -52,7 +52,7 @@ void ParallelServer::start( } void ParallelServer::setDefaultHostAddress(std::string defaultHostAddress) { - std::lock_guard lock(_hostInfoMutex); + std::lock_guard lock(_hostInfoMutex); _defaultHostAddress = std::move(defaultHostAddress); } @@ -89,7 +89,7 @@ void ParallelServer::handleNewPeers() { }); } } - + std::shared_ptr ParallelServer::peer(size_t id) { std::lock_guard lock(_peerListMutex); const auto& it = _peers.find(id); @@ -142,7 +142,7 @@ void ParallelServer::handlePeerMessage(PeerMessage peerMessage) { } std::shared_ptr& peer = it->second; - + switch (messageType) { case ParallelConnection::MessageType::Authentication: handleAuthentication(peer, std::move(data)); @@ -165,7 +165,7 @@ void ParallelServer::handlePeerMessage(PeerMessage peerMessage) { break; } } - + void ParallelServer::handleAuthentication(std::shared_ptr peer, std::vector message) { @@ -219,7 +219,7 @@ void ParallelServer::handleAuthentication(std::shared_ptr peer, setNConnections(nConnections() + 1); } - + void ParallelServer::handleData(std::shared_ptr peer, std::vector data) { if (peer->id != _hostPeerId) { LINFO(fmt::format( @@ -259,7 +259,7 @@ void ParallelServer::handleHostshipRequest(std::shared_ptr peer, assignHost(peer); LINFO(fmt::format("Switched host from {} to {}.", oldHostPeerId, peer->id)); } - + void ParallelServer::handleHostshipResignation(std::shared_ptr peer, std::vector data) { diff --git a/src/properties/binaryproperty.cpp b/src/properties/binaryproperty.cpp index 4c78a37d16..3ebb294761 100644 --- a/src/properties/binaryproperty.cpp +++ b/src/properties/binaryproperty.cpp @@ -1,26 +1,26 @@ /***************************************************************************************** -* * -* OpenSpace * -* * -* Copyright (c) 2014-2017 * -* * -* 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. * -****************************************************************************************/ + * * + * OpenSpace * + * * + * Copyright (c) 2014-2018 * + * * + * 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 @@ -49,7 +49,7 @@ REGISTER_TEMPLATEPROPERTY_SOURCE( return result; }, [](std::string& outValue, std::vector inValue) -> bool { - // TODO: To json conversion + // TODO: To json conversion outValue = ""; return true; }, diff --git a/src/properties/property.cpp b/src/properties/property.cpp index 6fa6a8f80d..4678dc16ca 100644 --- a/src/properties/property.cpp +++ b/src/properties/property.cpp @@ -191,8 +191,11 @@ const ghoul::Dictionary& Property::metaData() const { std::string Property::toJson() const { std::string result = "{"; - result += "\"" + std::string(DescriptionKey) + "\": " + generateBaseJsonDescription() + ", "; - result += "\"" + std::string(JsonValueKey) + "\": " + jsonValue(); + result += + "\"" + std::string(DescriptionKey) + "\": " + + generateBaseJsonDescription() + ", "; + result += + "\"" + std::string(JsonValueKey) + "\": " + jsonValue(); result += "}"; return result; } @@ -280,13 +283,15 @@ void Property::notifyDeleteListeners() { } std::string Property::generateBaseJsonDescription() const { - return + return "{ \"" + std::string(TypeKey) + "\": \"" + className() + "\", " + - "\"" + std::string(IdentifierKey) + "\": \"" + fullyQualifiedIdentifier() + "\", " + + "\"" + std::string(IdentifierKey) + "\": \"" + + fullyQualifiedIdentifier() + "\", " + "\"" + std::string(NameKey) + "\": \"" + guiName() + "\", " + - "\"" + std::string(MetaDataKey) + "\": " + generateMetaDataJsonDescription() + ", " + - "\"" + std::string(AdditionalDataKey) + "\": " + generateAdditionalJsonDescription() + - " }"; + "\"" + std::string(MetaDataKey) + "\": " + + generateMetaDataJsonDescription() + ", " + + "\"" + std::string(AdditionalDataKey) + "\": " + + generateAdditionalJsonDescription() + " }"; } std::string Property::generateMetaDataJsonDescription() const { @@ -306,9 +311,13 @@ std::string Property::generateMetaDataJsonDescription() const { } std::string result = "{ "; - result += "\"" + std::string(MetaDataKeyGroup) + "\": \"" + groupIdentifier() + "\", "; - result += "\"" + std::string(MetaDataKeyVisibility) + "\": \"" + vis + "\", "; - result += "\"" + std::string(MetaDataKeyReadOnly) + "\": " + (isReadOnly ? "true" : "false"); + result += + "\"" + std::string(MetaDataKeyGroup) + "\": \"" + groupIdentifier() + "\", "; + result += + "\"" + std::string(MetaDataKeyVisibility) + "\": \"" + vis + "\", "; + result += + "\"" + std::string(MetaDataKeyReadOnly) + "\": " + + (isReadOnly ? "true" : "false"); result += " }"; return result; } diff --git a/src/properties/scalar/ucharproperty.cpp b/src/properties/scalar/ucharproperty.cpp index d8e34420a2..75f4fce161 100644 --- a/src/properties/scalar/ucharproperty.cpp +++ b/src/properties/scalar/ucharproperty.cpp @@ -50,7 +50,7 @@ bool toLuaConversion(lua_State* state, unsigned char value) { unsigned char fromStringConversion(std::string val, bool& success) { std::stringstream s(val); - unsigned char v; + unsigned char v = 0; s >> v; success = !s.fail(); if (success) { diff --git a/src/rendering/framebufferrenderer.cpp b/src/rendering/framebufferrenderer.cpp index 7984166b24..aedd04ed1a 100644 --- a/src/rendering/framebufferrenderer.cpp +++ b/src/rendering/framebufferrenderer.cpp @@ -539,7 +539,7 @@ void FramebufferRenderer::updateDeferredcastData() { absPath(vsPath), absPath(deferredShaderPath), deferredDict); - + using IgnoreError = ghoul::opengl::ProgramObject::IgnoreError; _deferredcastPrograms[caster]->setIgnoreSubroutineUniformLocationError( IgnoreError::Yes @@ -547,7 +547,7 @@ void FramebufferRenderer::updateDeferredcastData() { _deferredcastPrograms[caster]->setIgnoreUniformLocationError( IgnoreError::Yes ); - + caster->initializeCachedVariables(*_deferredcastPrograms[caster]); } catch (ghoul::RuntimeError& e) { diff --git a/src/rendering/renderengine.cpp b/src/rendering/renderengine.cpp index 8c95ec06ca..c6d1dc46ad 100644 --- a/src/rendering/renderengine.cpp +++ b/src/rendering/renderengine.cpp @@ -410,7 +410,7 @@ void RenderEngine::initialize() { #ifdef GHOUL_USE_STB_IMAGE ghoul::io::TextureReader::ref().addReader( std::make_shared() - ); + ); #endif // GHOUL_USE_STB_IMAGE ghoul::io::TextureReader::ref().addReader( @@ -596,8 +596,8 @@ void RenderEngine::render(const glm::mat4& sceneMatrix, const glm::mat4& viewMat _camera->sgctInternal.setViewMatrix(viewMatrix * sceneMatrix); _camera->sgctInternal.setSceneMatrix(sceneMatrix); } + _camera->sgctInternal.setProjectionMatrix(projectionMatrix); } - _camera->sgctInternal.setProjectionMatrix(projectionMatrix); bool masterEnabled = wrapper.isMaster() ? !_disableMasterRendering : true; if (masterEnabled && !wrapper.isGuiWindow() && _globalBlackOutFactor > 0.f) { diff --git a/src/scene/scene.cpp b/src/scene/scene.cpp index a3361b0907..b4a4f25e7c 100644 --- a/src/scene/scene.cpp +++ b/src/scene/scene.cpp @@ -60,7 +60,6 @@ namespace { constexpr const char* _loggerCat = "Scene"; - constexpr const char* KeyName = "Name"; constexpr const char* KeyIdentifier = "Identifier"; constexpr const char* KeyParent = "Parent"; } // namespace diff --git a/src/scene/scenegraphnode.cpp b/src/scene/scenegraphnode.cpp index 6396222e34..d883056eed 100644 --- a/src/scene/scenegraphnode.cpp +++ b/src/scene/scenegraphnode.cpp @@ -627,7 +627,7 @@ Scene* SceneGraphNode::scene() { void SceneGraphNode::setScene(Scene* scene) { // Unregister from previous scene, bottom up - traversePostOrder([scene](SceneGraphNode* node) { + traversePostOrder([](SceneGraphNode* node) { if (node->_scene) { node->_scene->unregisterNode(node); } diff --git a/src/util/httprequest.cpp b/src/util/httprequest.cpp index 86a8765ad9..04b83213e8 100644 --- a/src/util/httprequest.cpp +++ b/src/util/httprequest.cpp @@ -362,7 +362,9 @@ bool HttpFileDownload::initDownload() { std::string message(Buffer, size); - LERROR(fmt::format("Cannot open file {}: {}", std::string(destinationFile), message)); + LERROR(fmt::format( + "Cannot open file {}: {}", std::string(destinationFile), message) + ); return false; } diff --git a/support/coding/check_style_guide.py b/support/coding/check_style_guide.py index 715b45632d..c53290df47 100644 --- a/support/coding/check_style_guide.py +++ b/support/coding/check_style_guide.py @@ -44,6 +44,7 @@ guards for correctness. At the moment this includes: * Checking whether a file as empty-only lines * Checking whether the default assert macros are used anywhere instead of the ghoul_assert macro + * Checking whether there are TABs in the file If this script is executed from the base directory of OpenSpace, no arguments need to be passed, otherwise the first and only argument has to point to the base directory. @@ -58,6 +59,7 @@ import sys current_year = '2018' is_strict_mode = False +is_silent_mode = False def get_ifndef_symbol(lines): index = [i for i,s in enumerate(lines) if '#ifndef ' in s] @@ -332,6 +334,12 @@ def check_empty_character_at_end(lines): return '' +def check_for_tab(lines): + index = [i + 1 for i, s in enumerate(lines) if '\t' in s] + if len(index) > 0: + return index + else: + return '' previousSymbols = {} def check_header_file(file, component): @@ -425,6 +433,10 @@ def check_header_file(file, component): if assert_usage: print(file, '\t', 'Wrong assert usage: ', assert_usage) + tabs = check_for_tab(lines) + if tabs: + print(file, '\t', 'TABs found: ', tabs) + def check_inline_file(file, component): @@ -479,6 +491,11 @@ def check_inline_file(file, component): if assert_usage: print(file, '\t', 'Wrong assert usage: ', assert_usage) + tabs = check_for_tab(lines) + if tabs: + print(file, '\t', 'TABs found: ', tabs) + + def check_source_file(file, component): @@ -522,11 +539,23 @@ def check_source_file(file, component): if assert_usage: print(file, '\t', 'Wrong assert usage: ', assert_usage) + tabs = check_for_tab(lines) + if tabs: + print(file, '\t', 'TABs found: ', tabs) + + def check_files(positiveList, negativeList, component, check_function): - files = glob.glob(positiveList, recursive=True) - negativeFiles = glob.glob(negativeList, recursive=True) + files = [] + for p in positiveList: + f = glob.glob(p, recursive=True) + files.extend(f) + + negativeFiles = [] + for n in negativeList: + f = glob.glob(n, recursive=True) + negativeFiles.extend(f) files = [f for f in files if f not in negativeFiles] @@ -545,28 +574,106 @@ if len(sys.argv) > 1: for a in sys.argv: if a == "strict": is_strict_mode = True + if a == "silent": + is_silent_mode = True + # Check header files -print("Checking header files") -print("=====================") -check_files(basePath + 'include/**/*.h', '', 'openspace_core', check_header_file) -check_files(basePath + 'apps/**/*.h', basePath + 'apps/**/ext/**/*.h', 'openspace_app', check_header_file) -check_files(basePath + 'modules/**/*.h', basePath + 'modules/**/ext/**/*.h', 'openspace_module', check_header_file) -check_files(basePath + 'ext/ghoul/include/**/*.h', '', 'ghoul', check_header_file) -print("") +if not is_silent_mode: + print("Checking header files") + print("=====================") -print("Checking inline files") -print("=====================") -check_files(basePath + 'include/**/*.inl', '', 'openspace_core', check_inline_file) -check_files(basePath + 'src/**/*.inl', '', 'openspace_core', check_inline_file) -check_files(basePath + 'apps/**/*.inl', basePath + 'apps/**/ext/**/*.h', 'openspace_app', check_inline_file) -check_files(basePath + 'modules/**/*.inl', basePath + 'modules/**/ext/**/*.h', 'openspace_module', check_inline_file) -check_files(basePath + 'ext/ghoul/include/**/*.inl', '', 'ghoul', check_inline_file) -print("") +check_files( + [basePath + 'include/**/*.h'], + [], + 'openspace_core', + check_header_file +) +check_files( + [basePath + 'apps/**/*.h'], + [basePath + 'apps/**/ext/**/*.h'], + 'openspace_app', + check_header_file +) +check_files( + [basePath + 'modules/**/*.h'], + [ + basePath + 'modules/**/ext/**/*.h', + basePath + 'modules/**/node_modules/**/*.h', + basePath + 'modules/webbrowser/resource.h' + ], + 'openspace_module', + check_header_file +) +check_files( + [basePath + 'ext/ghoul/include/**/*.h'], + [], + 'ghoul', + check_header_file +) -print("Checking source files") -print("=====================") -check_files(basePath + 'src/**/*.cpp', '', 'openspace_core', check_source_file) -check_files(basePath + 'apps/**/*.cpp', basePath + 'apps/**/ext/**/*.cpp', 'openspace_app', check_source_file) -check_files(basePath + 'modules/**/*.cpp', basePath + 'modules/**/ext/**/*.cpp', 'openspace_module', check_source_file) -check_files(basePath + 'ext/ghoul/src/**/*.cpp', '', 'ghoul', check_source_file) +if not is_silent_mode: + print("") + print("Checking inline files") + print("=====================") + +check_files( + [basePath + 'include/**/*.inl'], + [], + 'openspace_core', + check_inline_file +) +check_files( + [basePath + 'src/**/*.inl'], + [], + 'openspace_core', + check_inline_file +) +check_files( + [basePath + 'apps/**/*.inl'], + [basePath + 'apps/**/ext/**/*.h'], + 'openspace_app', + check_inline_file +) +check_files( + [basePath + 'modules/**/*.inl'], + [basePath + 'modules/**/ext/**/*.h'], + 'openspace_module', + check_inline_file +) +check_files( + [basePath + 'ext/ghoul/include/**/*.inl'], + [], + 'ghoul', + check_inline_file +) + +if not is_silent_mode: + print("") + print("Checking source files") + print("=====================") + +check_files( + [basePath + 'src/**/*.cpp'], + [], + 'openspace_core', + check_source_file +) +check_files( + [basePath + 'apps/**/*.cpp'], + [basePath + 'apps/**/ext/**/*.cpp'], + 'openspace_app', + check_source_file +) +check_files( + [basePath + 'modules/**/*.cpp'], + [basePath + 'modules/**/ext/**/*.cpp', basePath + 'modules/**/node_modules/**/*.cpp'], + 'openspace_module', + check_source_file +) +check_files( + [basePath + 'ext/ghoul/src/**/*.cpp'], + [], + 'ghoul', + check_source_file +) diff --git a/tests/test_rawvolumeio.inl b/tests/test_rawvolumeio.inl index cacb18b60d..0450543e02 100644 --- a/tests/test_rawvolumeio.inl +++ b/tests/test_rawvolumeio.inl @@ -64,7 +64,7 @@ TEST_F(RawVolumeIoTest, BasicInputOutput) { glm::uvec3 dims{ 2, 4, 8 }; auto value = [dims](glm::uvec3 v) { - return v.z * 8 * 4 + v.y * 4 + v.x; + return v.z * dims.z * dims.y + v.y * dims.y + v.x; }; RawVolume vol(dims);