From 0ff9c935128afd665f4af42eb558b11e48cd19ab Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 16 Nov 2017 09:06:17 -0500 Subject: [PATCH 01/14] Enable the disabling of Tooltips in ImGUI --- modules/imgui/include/gui.h | 2 + modules/imgui/include/guipropertycomponent.h | 2 + modules/imgui/include/renderproperties.h | 52 ++++++--- modules/imgui/src/gui.cpp | 16 +++ modules/imgui/src/guipropertycomponent.cpp | 12 ++- modules/imgui/src/renderproperties.cpp | 106 ++++++++++++------- 6 files changed, 132 insertions(+), 58 deletions(-) diff --git a/modules/imgui/include/gui.h b/modules/imgui/include/gui.h index 4981eda208..41daff5d83 100644 --- a/modules/imgui/include/gui.h +++ b/modules/imgui/include/gui.h @@ -85,6 +85,8 @@ public: bool _showInternals; + properties::BoolProperty _showHelpText; + private: void renderAndUpdatePropertyVisibility(); diff --git a/modules/imgui/include/guipropertycomponent.h b/modules/imgui/include/guipropertycomponent.h index ca55b8404d..1a7078d898 100644 --- a/modules/imgui/include/guipropertycomponent.h +++ b/modules/imgui/include/guipropertycomponent.h @@ -59,6 +59,7 @@ public: void setVisibility(properties::Property::Visibility visibility); void setHasRegularProperties(bool hasOnlyRegularProperties); + void setShowHelpTooltip(bool showHelpTooltip); void render() override; @@ -76,6 +77,7 @@ protected: UseTreeLayout _useTreeLayout; bool _currentUseTreeLayout; IsTopLevelWindow _isTopLevel; + bool _showHelpTooltip; }; } // namespace openspace::gui diff --git a/modules/imgui/include/renderproperties.h b/modules/imgui/include/renderproperties.h index ce0408cc64..3ab234ba53 100644 --- a/modules/imgui/include/renderproperties.h +++ b/modules/imgui/include/renderproperties.h @@ -36,60 +36,78 @@ namespace openspace::properties { namespace openspace { using IsRegularProperty = ghoul::Boolean; +using ShowToolTip = ghoul::Boolean; void executeScript(const std::string& id, const std::string& value, IsRegularProperty isRegular = IsRegularProperty::Yes); void renderBoolProperty(properties::Property* prop, const std::string& ownerName, - IsRegularProperty isRegular = IsRegularProperty::Yes); + IsRegularProperty isRegular = IsRegularProperty::Yes, + ShowToolTip showTooltip = ShowToolTip::Yes); void renderOptionProperty(properties::Property* prop, const std::string& ownerName, - IsRegularProperty isRegular = IsRegularProperty::Yes); + IsRegularProperty isRegular = IsRegularProperty::Yes, + ShowToolTip showTooltip = ShowToolTip::Yes); void renderSelectionProperty(properties::Property* prop, const std::string& ownerName, - IsRegularProperty isRegular = IsRegularProperty::Yes); + IsRegularProperty isRegular = IsRegularProperty::Yes, + ShowToolTip showTooltip = ShowToolTip::Yes); void renderStringProperty(properties::Property* prop, const std::string& ownerName, - IsRegularProperty isRegular = IsRegularProperty::Yes); + IsRegularProperty isRegular = IsRegularProperty::Yes, + ShowToolTip showTooltip = ShowToolTip::Yes); void renderDoubleProperty(properties::Property* prop, const std::string& ownerName, - IsRegularProperty isRegular = IsRegularProperty::Yes); + IsRegularProperty isRegular = IsRegularProperty::Yes, + ShowToolTip showTooltip = ShowToolTip::Yes); void renderIntProperty(properties::Property* prop, const std::string& ownerName, - IsRegularProperty isRegular = IsRegularProperty::Yes); + IsRegularProperty isRegular = IsRegularProperty::Yes, + ShowToolTip showTooltip = ShowToolTip::Yes); void renderIVec2Property(properties::Property* prop, const std::string& ownerName, - IsRegularProperty isRegular = IsRegularProperty::Yes); + IsRegularProperty isRegular = IsRegularProperty::Yes, + ShowToolTip showTooltip = ShowToolTip::Yes); void renderIVec3Property(properties::Property* prop, const std::string& ownerName, - IsRegularProperty isRegular = IsRegularProperty::Yes); + IsRegularProperty isRegular = IsRegularProperty::Yes, + ShowToolTip showTooltip = ShowToolTip::Yes); void renderIVec4Property(properties::Property* prop, const std::string& ownerName, - IsRegularProperty isRegular = IsRegularProperty::Yes); + IsRegularProperty isRegular = IsRegularProperty::Yes, + ShowToolTip showTooltip = ShowToolTip::Yes); void renderFloatProperty(properties::Property* prop, const std::string& ownerName, - IsRegularProperty isRegular = IsRegularProperty::Yes); + IsRegularProperty isRegular = IsRegularProperty::Yes, + ShowToolTip showTooltip = ShowToolTip::Yes); void renderVec2Property(properties::Property* prop, const std::string& ownerName, - IsRegularProperty isRegular = IsRegularProperty::Yes); + IsRegularProperty isRegular = IsRegularProperty::Yes, + ShowToolTip showTooltip = ShowToolTip::Yes); void renderVec3Property(properties::Property* prop, const std::string& ownerName, - IsRegularProperty isRegular = IsRegularProperty::Yes); + IsRegularProperty isRegular = IsRegularProperty::Yes, + ShowToolTip showTooltip = ShowToolTip::Yes); void renderVec4Property(properties::Property* prop, const std::string& ownerName, - IsRegularProperty isRegular = IsRegularProperty::Yes); + IsRegularProperty isRegular = IsRegularProperty::Yes, + ShowToolTip showTooltip = ShowToolTip::Yes); void renderDVec2Property(properties::Property* prop, const std::string& ownerName, - IsRegularProperty isRegular = IsRegularProperty::Yes); + IsRegularProperty isRegular = IsRegularProperty::Yes, + ShowToolTip showTooltip = ShowToolTip::Yes); void renderDVec3Property(properties::Property* prop, const std::string& ownerName, - IsRegularProperty isRegular = IsRegularProperty::Yes); + IsRegularProperty isRegular = IsRegularProperty::Yes, + ShowToolTip showTooltip = ShowToolTip::Yes); void renderDVec4Property(properties::Property* prop, const std::string& ownerName, - IsRegularProperty isRegular = IsRegularProperty::Yes); + IsRegularProperty isRegular = IsRegularProperty::Yes, + ShowToolTip showTooltip = ShowToolTip::Yes); void renderTriggerProperty(properties::Property* prop, const std::string& ownerName, - IsRegularProperty isRegular = IsRegularProperty::Yes); + IsRegularProperty isRegular = IsRegularProperty::Yes, + ShowToolTip showTooltip = ShowToolTip::Yes); } // namespace openspace diff --git a/modules/imgui/src/gui.cpp b/modules/imgui/src/gui.cpp index 6db4244e94..0f8f74576e 100644 --- a/modules/imgui/src/gui.cpp +++ b/modules/imgui/src/gui.cpp @@ -245,6 +245,13 @@ void addScreenSpaceRenderableOnline(std::string texturePath) { ); } +static const openspace::properties::Property::PropertyInfo ShowHelpInfo = { + "ShowHelpText", + "Show tooltip help", + "If this value is enabled these kinds of tooltips are shown for most properties " + "explaining what impact they have on the visuals." +}; + } // namespace namespace openspace::gui { @@ -268,6 +275,7 @@ GUI::GUI() GuiPropertyComponent::UseTreeLayout::No, GuiPropertyComponent::IsTopLevelWindow::Yes) , _showInternals(false) + , _showHelpText(ShowHelpInfo, true) , _currentVisibility(properties::Property::Visibility::Developer) { addPropertySubOwner(_help); @@ -285,6 +293,14 @@ GUI::GUI() #ifdef OPENSPACE_MODULE_ISWA_ENABLED addPropertySubOwner(_iswa); #endif // OPENSPACE_MODULE_ISWA_ENABLED + + addProperty(_showHelpText); + _showHelpText.onChange([this](){ + _globalProperty.setShowHelpTooltip(_showHelpText); + _property.setShowHelpTooltip(_showHelpText); + _screenSpaceProperty.setShowHelpTooltip(_showHelpText); + _virtualProperty.setShowHelpTooltip(_showHelpText); + }); } void GUI::initialize() { diff --git a/modules/imgui/src/guipropertycomponent.cpp b/modules/imgui/src/guipropertycomponent.cpp index acdf57952e..143da4826c 100644 --- a/modules/imgui/src/guipropertycomponent.cpp +++ b/modules/imgui/src/guipropertycomponent.cpp @@ -166,6 +166,10 @@ void GuiPropertyComponent::setHasRegularProperties(bool hasOnlyRegularProperties _hasOnlyRegularProperties = hasOnlyRegularProperties; } +void GuiPropertyComponent::setShowHelpTooltip(bool showHelpTooltip) { + _showHelpTooltip = showHelpTooltip; +} + void GuiPropertyComponent::renderPropertyOwner(properties::PropertyOwner* owner) { if (owner->propertiesRecursive().empty()) { return; @@ -373,7 +377,7 @@ void GuiPropertyComponent::renderProperty(properties::Property* prop, properties::PropertyOwner* owner) { using Func = std::function< - void(properties::Property*, const std::string&, IsRegularProperty) + void(properties::Property*, const std::string&, IsRegularProperty, ShowToolTip) >; static const std::map FunctionMapping = { { "BoolProperty", &renderBoolProperty }, @@ -406,14 +410,16 @@ void GuiPropertyComponent::renderProperty(properties::Property* prop, it->second( prop, owner->name(), - IsRegularProperty(_hasOnlyRegularProperties) + IsRegularProperty(_hasOnlyRegularProperties), + ShowToolTip(_showHelpTooltip) ); } else { it->second( prop, "", - IsRegularProperty(_hasOnlyRegularProperties) + IsRegularProperty(_hasOnlyRegularProperties), + ShowToolTip(_showHelpTooltip) ); } } diff --git a/modules/imgui/src/renderproperties.cpp b/modules/imgui/src/renderproperties.cpp index ecf12e5b92..b166a673c2 100644 --- a/modules/imgui/src/renderproperties.cpp +++ b/modules/imgui/src/renderproperties.cpp @@ -85,7 +85,7 @@ void executeScript(const std::string& id, const std::string& value, } void renderBoolProperty(Property* prop, const std::string& ownerName, - IsRegularProperty isRegular) + IsRegularProperty isRegular, ShowToolTip showTooltip) { ghoul_assert(prop, "prop must not be nullptr"); BoolProperty* p = static_cast(prop); @@ -94,7 +94,9 @@ void renderBoolProperty(Property* prop, const std::string& ownerName, BoolProperty::ValueType value = *p; ImGui::Checkbox(name.c_str(), &value); - renderTooltip(prop); + if (showTooltip) { + renderTooltip(prop); + } if (value != p->value()) { executeScript(p->fullyQualifiedIdentifier(), value ? "true" : "false", isRegular); @@ -103,7 +105,7 @@ void renderBoolProperty(Property* prop, const std::string& ownerName, } void renderOptionProperty(Property* prop, const std::string& ownerName, - IsRegularProperty isRegular) + IsRegularProperty isRegular, ShowToolTip showTooltip) { ghoul_assert(prop, "prop must not be nullptr"); OptionProperty* p = static_cast(prop); @@ -120,7 +122,9 @@ void renderOptionProperty(Property* prop, const std::string& ownerName, ImGui::Separator(); for (const OptionProperty::Option& o : options) { ImGui::RadioButton(o.description.c_str(), &value, o.value); - renderTooltip(prop); + if (showTooltip) { + renderTooltip(prop); + } } ImGui::Separator(); break; @@ -159,7 +163,7 @@ void renderOptionProperty(Property* prop, const std::string& ownerName, } void renderSelectionProperty(Property* prop, const std::string& ownerName, - IsRegularProperty isRegular) + IsRegularProperty isRegular, ShowToolTip showTooltip) { ghoul_assert(prop, "prop must not be nullptr"); SelectionProperty* p = static_cast(prop); @@ -179,7 +183,9 @@ void renderSelectionProperty(Property* prop, const std::string& ownerName, ) != selectedIndices.end(); ImGui::Checkbox(description.c_str(), &selected); - renderTooltip(prop); + if (showTooltip) { + renderTooltip(prop); + } if (selected) { newSelectedIndices.push_back(i); @@ -200,7 +206,7 @@ void renderSelectionProperty(Property* prop, const std::string& ownerName, } void renderStringProperty(Property* prop, const std::string& ownerName, - IsRegularProperty isRegular) + IsRegularProperty isRegular, ShowToolTip showTooltip) { ghoul_assert(prop, "prop must not be nullptr"); StringProperty* p = static_cast(prop); @@ -222,8 +228,9 @@ void renderStringProperty(Property* prop, const std::string& ownerName, bufferSize, ImGuiInputTextFlags_EnterReturnsTrue ); - renderTooltip(prop); - + if (showTooltip) { + renderTooltip(prop); + } if (hasNewValue) { executeScript( @@ -237,7 +244,7 @@ void renderStringProperty(Property* prop, const std::string& ownerName, } void renderDoubleProperty(properties::Property* prop, const std::string& ownerName, - IsRegularProperty isRegular) + IsRegularProperty isRegular, ShowToolTip showTooltip) { ghoul_assert(prop, "prop must not be nullptr"); DoubleProperty* p = static_cast(prop); @@ -249,7 +256,9 @@ void renderDoubleProperty(properties::Property* prop, const std::string& ownerNa float max = static_cast(p->maxValue()); ImGui::SliderFloat(name.c_str(), &value, min, max, "%.5f"); - renderTooltip(prop); + if (showTooltip) { + renderTooltip(prop); + } if (value != static_cast(p->value())) { executeScript(p->fullyQualifiedIdentifier(), std::to_string(value), isRegular); @@ -259,7 +268,7 @@ void renderDoubleProperty(properties::Property* prop, const std::string& ownerNa } void renderIntProperty(Property* prop, const std::string& ownerName, - IsRegularProperty isRegular) + IsRegularProperty isRegular, ShowToolTip showTooltip) { ghoul_assert(prop, "prop must not be nullptr"); IntProperty* p = static_cast(prop); @@ -271,7 +280,9 @@ void renderIntProperty(Property* prop, const std::string& ownerName, int max = p->maxValue(); ImGui::SliderInt(name.c_str(), &value, min, max); - renderTooltip(prop); + if (showTooltip) { + renderTooltip(prop); + } if (value != p->value()) { executeScript(p->fullyQualifiedIdentifier(), std::to_string(value), isRegular); @@ -281,7 +292,7 @@ void renderIntProperty(Property* prop, const std::string& ownerName, } void renderIVec2Property(Property* prop, const std::string& ownerName, - IsRegularProperty isRegular) + IsRegularProperty isRegular, ShowToolTip showTooltip) { ghoul_assert(prop, "prop must not be nullptr"); IVec2Property* p = static_cast(prop); @@ -297,7 +308,9 @@ void renderIVec2Property(Property* prop, const std::string& ownerName, min, max ); - renderTooltip(prop); + if (showTooltip) { + renderTooltip(prop); + } if (value != p->value()) { executeScript( @@ -311,7 +324,7 @@ void renderIVec2Property(Property* prop, const std::string& ownerName, } void renderIVec3Property(Property* prop, const std::string& ownerName, - IsRegularProperty isRegular) + IsRegularProperty isRegular, ShowToolTip showTooltip) { ghoul_assert(prop, "prop must not be nullptr"); IVec3Property* p = static_cast(prop); @@ -328,7 +341,9 @@ void renderIVec3Property(Property* prop, const std::string& ownerName, min, max ); - renderTooltip(prop); + if (showTooltip) { + renderTooltip(prop); + } if (value != p->value()) { executeScript( @@ -342,7 +357,7 @@ void renderIVec3Property(Property* prop, const std::string& ownerName, } void renderIVec4Property(Property* prop, const std::string& ownerName, - IsRegularProperty isRegular) + IsRegularProperty isRegular, ShowToolTip showTooltip) { ghoul_assert(prop, "prop must not be nullptr"); IVec4Property* p = static_cast(prop); @@ -363,7 +378,9 @@ void renderIVec4Property(Property* prop, const std::string& ownerName, min, max ); - renderTooltip(prop); + if (showTooltip) { + renderTooltip(prop); + } if (value != p->value()) { executeScript( @@ -379,7 +396,7 @@ void renderIVec4Property(Property* prop, const std::string& ownerName, } void renderFloatProperty(Property* prop, const std::string& ownerName, - IsRegularProperty isRegular) + IsRegularProperty isRegular, ShowToolTip showTooltip) { ghoul_assert(prop, "prop must not be nullptr"); FloatProperty* p = static_cast(prop); @@ -390,7 +407,9 @@ void renderFloatProperty(Property* prop, const std::string& ownerName, float min = p->minValue(); float max = p->maxValue(); ImGui::SliderFloat(name.c_str(), &value, min, max, "%.5f"); - renderTooltip(prop); + if (showTooltip) { + renderTooltip(prop); + } if (value != p->value()) { executeScript(p->fullyQualifiedIdentifier(), std::to_string(value), isRegular); @@ -400,7 +419,7 @@ void renderFloatProperty(Property* prop, const std::string& ownerName, } void renderVec2Property(Property* prop, const std::string& ownerName, - IsRegularProperty isRegular) + IsRegularProperty isRegular, ShowToolTip showTooltip) { ghoul_assert(prop, "prop must not be nullptr"); Vec2Property* p = static_cast(prop); @@ -417,7 +436,9 @@ void renderVec2Property(Property* prop, const std::string& ownerName, max, "%.5f" ); - renderTooltip(prop); + if (showTooltip) { + renderTooltip(prop); + } if (value != p->value()) { executeScript( @@ -431,7 +452,7 @@ void renderVec2Property(Property* prop, const std::string& ownerName, } void renderVec3Property(Property* prop, const std::string& ownerName, - IsRegularProperty isRegular) + IsRegularProperty isRegular, ShowToolTip showTooltip) { ghoul_assert(prop, "prop must not be nullptr"); Vec3Property* p = static_cast(prop); @@ -442,8 +463,6 @@ void renderVec3Property(Property* prop, const std::string& ownerName, float min = std::min(std::min(p->minValue().x, p->minValue().y), p->minValue().z); float max = std::max(std::max(p->maxValue().x, p->maxValue().y), p->maxValue().z); - - if (prop->viewOption(Property::ViewOptions::Color)) { ImGui::ColorEdit3( name.c_str(), @@ -459,7 +478,9 @@ void renderVec3Property(Property* prop, const std::string& ownerName, "%.5f" ); } - renderTooltip(prop); + if (showTooltip) { + renderTooltip(prop); + } if (value != p->value()) { executeScript( @@ -475,7 +496,7 @@ void renderVec3Property(Property* prop, const std::string& ownerName, } void renderVec4Property(Property* prop, const std::string& ownerName, - IsRegularProperty isRegular) + IsRegularProperty isRegular, ShowToolTip showTooltip) { ghoul_assert(prop, "prop must not be nullptr"); Vec4Property* p = static_cast(prop); @@ -503,8 +524,9 @@ void renderVec4Property(Property* prop, const std::string& ownerName, "%.5f" ); } - - renderTooltip(prop); + if (showTooltip) { + renderTooltip(prop); + } if (value != p->value()) { executeScript( @@ -521,7 +543,7 @@ void renderVec4Property(Property* prop, const std::string& ownerName, } void renderDVec2Property(Property* prop, const std::string& ownerName, - IsRegularProperty isRegular) + IsRegularProperty isRegular, ShowToolTip showTooltip) { ghoul_assert(prop, "prop must not be nullptr"); DVec2Property* p = static_cast(prop); @@ -538,7 +560,9 @@ void renderDVec2Property(Property* prop, const std::string& ownerName, max, "%.5f" ); - renderTooltip(prop); + if (showTooltip) { + renderTooltip(prop); + } if (glm::dvec2(value) != p->value()) { executeScript( @@ -552,7 +576,7 @@ void renderDVec2Property(Property* prop, const std::string& ownerName, } void renderDVec3Property(Property* prop, const std::string& ownerName, - IsRegularProperty isRegular) + IsRegularProperty isRegular, ShowToolTip showTooltip) { ghoul_assert(prop, "prop must not be nullptr"); DVec3Property* p = static_cast(prop); @@ -574,7 +598,9 @@ void renderDVec3Property(Property* prop, const std::string& ownerName, max, "%.5f" ); - renderTooltip(prop); + if (showTooltip) { + renderTooltip(prop); + } if (changed) { executeScript( @@ -590,7 +616,7 @@ void renderDVec3Property(Property* prop, const std::string& ownerName, } void renderDVec4Property(Property* prop, const std::string& ownerName, - IsRegularProperty isRegular) + IsRegularProperty isRegular, ShowToolTip showTooltip) { ghoul_assert(prop, "prop must not be nullptr"); DVec4Property* p = static_cast(prop); @@ -616,7 +642,9 @@ void renderDVec4Property(Property* prop, const std::string& ownerName, max, "%.5f" ); - renderTooltip(prop); + if (showTooltip) { + renderTooltip(prop); + } if (glm::dvec4(value) != p->value()) { executeScript( @@ -633,7 +661,7 @@ void renderDVec4Property(Property* prop, const std::string& ownerName, } void renderTriggerProperty(Property* prop, const std::string& ownerName, - IsRegularProperty isRegular) + IsRegularProperty isRegular, ShowToolTip showTooltip) { ghoul_assert(prop, "prop must not be nullptr"); std::string name = prop->guiName(); @@ -643,7 +671,9 @@ void renderTriggerProperty(Property* prop, const std::string& ownerName, if (pressed) { executeScript(prop->fullyQualifiedIdentifier(), "nil", isRegular); } - renderTooltip(prop); + if (showTooltip) { + renderTooltip(prop); + } ImGui::PopID(); } From 669078201ab36f1bb8c250c4acd3789688c2f489 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 16 Nov 2017 16:12:54 -0500 Subject: [PATCH 02/14] Add check for usage of ghoul_assert instead of plain old assert Update Ghoul --- ext/ghoul | 2 +- modules/kameleon/src/kameleonwrapper.cpp | 30 +++++++++---------- .../multiresvolume/rendering/atlasmanager.cpp | 2 +- .../rendering/localtfbrickselector.cpp | 8 ++--- .../rendering/renderablemultiresvolume.cpp | 2 -- .../rendering/simpletfbrickselector.cpp | 2 +- .../rendering/tfbrickselector.cpp | 4 +-- .../rendering/renderabletimevaryingvolume.h | 6 ++-- src/util/histogram.cpp | 2 +- support/coding/check_style_guide.py | 25 ++++++++++++++++ 10 files changed, 52 insertions(+), 31 deletions(-) diff --git a/ext/ghoul b/ext/ghoul index 79a336b773..6944475ee6 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 79a336b7731ca64e00ab82769c93bc799d041ed5 +Subproject commit 6944475ee6293e4dd6671800cb28953e877e1cb7 diff --git a/modules/kameleon/src/kameleonwrapper.cpp b/modules/kameleon/src/kameleonwrapper.cpp index cbd4fd1e67..253870f426 100644 --- a/modules/kameleon/src/kameleonwrapper.cpp +++ b/modules/kameleon/src/kameleonwrapper.cpp @@ -184,12 +184,12 @@ bool KameleonWrapper::open(const std::string& filename) { } void KameleonWrapper::close() { - if (_kameleon) + if (_kameleon) { _kameleon->close(); - if (_interpolator) - delete _interpolator; - if (_kameleon) - delete _kameleon; + } + + delete _interpolator; + delete _kameleon; _kameleon = nullptr; _interpolator = nullptr; @@ -202,8 +202,7 @@ float* KameleonWrapper::getUniformSampledValues( const std::string& var, const glm::size3_t& outDimensions) { - assert(_model && _interpolator); - assert(outDimensions.x > 0 && outDimensions.y > 0 && outDimensions.z > 0); + ghoul_assert(_model && _interpolator, "Model and interpolator must exist"); LINFO("Loading variable " << var << " from CDF data with a uniform sampling"); unsigned int size = static_cast( @@ -384,8 +383,7 @@ float* KameleonWrapper::getUniformSliceValues(const std::string& var, const glm::size3_t& outDimensions, const float& slice) { - assert(_model && _interpolator); - assert(outDimensions.x > 0 && outDimensions.y > 0 && outDimensions.z > 0); + ghoul_assert(_model && _interpolator, "Model and interpolator must exist"); LINFO("Loading variable " << var << " from CDF data with a uniform sampling"); unsigned int size = static_cast( @@ -517,8 +515,7 @@ float* KameleonWrapper::getUniformSampledVectorValues(const std::string& xVar, const std::string& zVar, const glm::size3_t& outDimensions) { - assert(_model && _interpolator); - assert(outDimensions.x > 0 && outDimensions.y > 0 && outDimensions.z > 0); + ghoul_assert(_model && _interpolator, "Model and interpolator must exist"); LINFO( "Loading variables " << xVar << " " << yVar << " " << zVar << " from CDF data with a uniform sampling" @@ -597,7 +594,7 @@ KameleonWrapper::Fieldlines KameleonWrapper::getClassifiedFieldLines( const std::vector& seedPoints, float stepSize ) { - assert(_model && _interpolator); + ghoul_assert(_model && _interpolator, "Model and interpolator must exist"); LINFO( "Creating " << seedPoints.size() << " fieldlines from variables " << xVar << " " << yVar << " " << zVar @@ -654,7 +651,7 @@ KameleonWrapper::Fieldlines KameleonWrapper::getFieldLines(const std::string& xV const std::string& yVar, const std::string& zVar, const std::vector& seedPoints, float stepSize, const glm::vec4& color) { - assert(_model && _interpolator); + ghoul_assert(_model && _interpolator, "Model and interpolator must exist"); LINFO( "Creating " << seedPoints.size() << " fieldlines from variables " << xVar << " " << yVar << " " << zVar @@ -744,7 +741,7 @@ KameleonWrapper::Fieldlines KameleonWrapper::getLorentzTrajectories( glm::vec3 KameleonWrapper::getModelBarycenterOffset() { // ENLIL is centered, no need for offset if (_type == Model::ENLIL) { - return glm::vec3(0,0,0); + return glm::vec3(0.f); } glm::vec3 offset; @@ -770,8 +767,9 @@ glm::vec4 KameleonWrapper::getModelBarycenterOffsetScaled() { } glm::vec3 KameleonWrapper::getModelScale() { - if (_type == Model::ENLIL) - return glm::vec3(1.0f, 1.0f, 1.0f); + if (_type == Model::ENLIL) { + return glm::vec3(1.f); + } glm::vec3 scale; scale.x = _xMax - _xMin; diff --git a/modules/multiresvolume/rendering/atlasmanager.cpp b/modules/multiresvolume/rendering/atlasmanager.cpp index 83fa9646e5..389951a69b 100644 --- a/modules/multiresvolume/rendering/atlasmanager.cpp +++ b/modules/multiresvolume/rendering/atlasmanager.cpp @@ -170,7 +170,7 @@ void AtlasManager::addToAtlas(int firstBrickIndex, int lastBrickIndex, float* ma unsigned int atlasCoords = _freeAtlasCoords.back(); _freeAtlasCoords.pop_back(); int level = _nOtLevels - floor(log((7.0 * (float(brickIndex % _nOtNodes)) + 1.0))/log(8)) - 1; - assert(atlasCoords <= 0x0FFFFFFF); + ghoul_assert(atlasCoords <= 0x0FFFFFFF, "@MISSING"); unsigned int atlasData = (level << 28) + atlasCoords; _brickMap.insert(std::pair(brickIndex, atlasData)); _nStreamedBricks++; diff --git a/modules/multiresvolume/rendering/localtfbrickselector.cpp b/modules/multiresvolume/rendering/localtfbrickselector.cpp index 39f3abe12e..c5426f95a5 100644 --- a/modules/multiresvolume/rendering/localtfbrickselector.cpp +++ b/modules/multiresvolume/rendering/localtfbrickselector.cpp @@ -358,8 +358,8 @@ bool LocalTfBrickSelector::calculateBrickErrors() { for (int i = 0; i < gradients.size(); i++) { float x = (i + 0.5f) / tfWidth; float sample = histogram->interpolate(x); - assert(sample >= 0); - assert(gradients[i] >= 0); + ghoul_assert(sample >= 0, "@MISSING"); + ghoul_assert(gradients[i] >= 0, "@MISSING"); error += sample * gradients[i]; } _brickErrors[brickIndex].spatial = error; @@ -375,8 +375,8 @@ bool LocalTfBrickSelector::calculateBrickErrors() { for (int i = 0; i < gradients.size(); i++) { float x = (i + 0.5f) / tfWidth; float sample = histogram->interpolate(x); - assert(sample >= 0); - assert(gradients[i] >= 0); + ghoul_assert(sample >= 0, "@MISSING"); + ghoul_assert(gradients[i] >= 0, "@MISSING"); error += sample * gradients[i]; } _brickErrors[brickIndex].temporal = error; diff --git a/modules/multiresvolume/rendering/renderablemultiresvolume.cpp b/modules/multiresvolume/rendering/renderablemultiresvolume.cpp index f563ee5485..a524ac362c 100644 --- a/modules/multiresvolume/rendering/renderablemultiresvolume.cpp +++ b/modules/multiresvolume/rendering/renderablemultiresvolume.cpp @@ -187,8 +187,6 @@ RenderableMultiresVolume::RenderableMultiresVolume (const ghoul::Dictionary& dic , _rotation(RotationInfo, glm::vec3(0.f, 0.f, 0.f), glm::vec3(0.f), glm::vec3(6.28f)) { std::string name; - //bool success = dictionary.getValue(constants::scenegraphnode::keyName, name); - //assert(success); _filename = ""; bool success = dictionary.getValue(KeyDataSource, _filename); diff --git a/modules/multiresvolume/rendering/simpletfbrickselector.cpp b/modules/multiresvolume/rendering/simpletfbrickselector.cpp index 9c797fc50a..6e20188591 100644 --- a/modules/multiresvolume/rendering/simpletfbrickselector.cpp +++ b/modules/multiresvolume/rendering/simpletfbrickselector.cpp @@ -311,7 +311,7 @@ bool SimpleTfBrickSelector::calculateBrickImportances() { float x = static_cast(i) / static_cast(tfWidth); float sample = histogram->interpolate(x); - assert(sample >= 0); + ghoul_assert(sample >= 0, "@MISSING"); dotProduct += sample * tf->sample(i).w; } _brickImportances[brickIndex] = dotProduct; diff --git a/modules/multiresvolume/rendering/tfbrickselector.cpp b/modules/multiresvolume/rendering/tfbrickselector.cpp index 3ee23994a9..4406e88f17 100644 --- a/modules/multiresvolume/rendering/tfbrickselector.cpp +++ b/modules/multiresvolume/rendering/tfbrickselector.cpp @@ -367,8 +367,8 @@ bool TfBrickSelector::calculateBrickErrors() { for (int i = 0; i < gradients.size(); i++) { float x = (i + 0.5f) / tfWidth; float sample = histogram->interpolate(x); - assert(sample >= 0); - assert(gradients[i] >= 0); + ghoul_assert(sample >= 0, "@MISSING"); + ghoul_assert(gradients[i] >= 0, "@MISSING"); error += sample * gradients[i]; } _brickErrors[brickIndex] = error; diff --git a/modules/volume/rendering/renderabletimevaryingvolume.h b/modules/volume/rendering/renderabletimevaryingvolume.h index 30fd980c78..67f2b44269 100644 --- a/modules/volume/rendering/renderabletimevaryingvolume.h +++ b/modules/volume/rendering/renderabletimevaryingvolume.h @@ -22,8 +22,8 @@ * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * ****************************************************************************************/ -#ifndef __OPENSPACE_MODULE_VOLUME___RENDERABLEKAMELEONVOLUME___H__ -#define __OPENSPACE_MODULE_VOLUME___RENDERABLEKAMELEONVOLUME___H__ +#ifndef __OPENSPACE_MODULE_VOLUME___RENDERABLETIMEVARYINGVOLUME___H__ +#define __OPENSPACE_MODULE_VOLUME___RENDERABLETIMEVARYINGVOLUME___H__ #include @@ -106,4 +106,4 @@ private: } // namespace volume } // namespace openspace -#endif // __OPENSPACE_MODULE_KAMELEONVOLUME___RENDERABLEKAMELEONVOLUME___H__ +#endif // __OPENSPACE_MODULE_VOLUME___RENDERABLETIMEVARYINGVOLUME___H__ diff --git a/src/util/histogram.cpp b/src/util/histogram.cpp index ca3410c070..ea98fc0b3b 100644 --- a/src/util/histogram.cpp +++ b/src/util/histogram.cpp @@ -223,7 +223,7 @@ float Histogram::interpolate(float bin) const { } float Histogram::sample(int binIndex) const { - assert(binIndex >= 0 && binIndex < _numBins); + ghoul_assert(binIndex >= 0 && binIndex < _numBins, "@MISSING"); return _data[binIndex]; } diff --git a/support/coding/check_style_guide.py b/support/coding/check_style_guide.py index c91bc80d6e..a2c73df3b7 100644 --- a/support/coding/check_style_guide.py +++ b/support/coding/check_style_guide.py @@ -42,6 +42,8 @@ guards for correctness. At the moment this includes: * Checking that no file includes glm header directly * Checking whether any files starts with the UTF-8 Byte-order mark * Checking whether a file as empty-only lines + * Checking whether the default assert macros are used anywhere instead of the + ghoul_assert macro 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. @@ -308,6 +310,16 @@ def check_line_length(lines): +def check_assert_usage(lines): + # _assert checks for both ghoul_assert and static_assert, which are both reasonable + index = [i + 1 for i,s in enumerate(lines) if ('assert(' in s and not '_assert(' in s) and s.strip()[0:2] != '//'] + if len(index) > 0: + return index + else: + return ''; + + + def check_line_length(lines): # Disable this check in non-strict mode if not is_strict_mode: @@ -422,6 +434,11 @@ def check_header_file(file, component): if empty_character_at_end: print(file, '\t', 'Empty character at end: ', empty_character_at_end) + assert_usage = check_assert_usage(lines) + if assert_usage: + print(file, '\t', 'Wrong assert usage: ', assert_usage) + + def check_inline_file(file, component): with open(file, 'r+', encoding="utf8") as f: @@ -471,6 +488,10 @@ def check_inline_file(file, component): if empty_character_at_end: print(file, '\t', 'Empty character at end: ', empty_character_at_end) + assert_usage = check_assert_usage(lines) + if assert_usage: + print(file, '\t', 'Wrong assert usage: ', assert_usage) + def check_source_file(file, component): @@ -510,6 +531,10 @@ def check_source_file(file, component): if empty_character_at_end: print(file, '\t', 'Empty character at end: ', empty_character_at_end) + assert_usage = check_assert_usage(lines) + if assert_usage: + print(file, '\t', 'Wrong assert usage: ', assert_usage) + def check_files(positiveList, negativeList, component, check_function): From 719130b6b77dbd041b0d09f0c5d36e0582e9d4b0 Mon Sep 17 00:00:00 2001 From: Alexander Bock Date: Thu, 16 Nov 2017 21:19:28 -0500 Subject: [PATCH 03/14] Jenkinswarnings (#419) * Remove more warnings * Removing more warnings * More warning fixes * More warnings * More warnings * Update ghoul --- ext/ghoul | 2 +- .../properties/numericalproperty.inl | 8 +- .../openspace/properties/templateproperty.inl | 15 ++-- modules/base/rendering/renderablesphere.cpp | 2 +- modules/base/rotation/fixedrotation.cpp | 2 +- modules/base/rotation/luarotation.cpp | 4 +- modules/base/scale/luascale.cpp | 4 +- modules/base/translation/luatranslation.cpp | 4 +- .../renderablefieldlinessequencesetup.cpp | 8 +- .../util/fieldlinesstate.cpp | 2 +- .../fieldlinessequence/util/fieldlinesstate.h | 2 +- modules/galaxy/rendering/galaxyraycaster.cpp | 4 +- modules/galaxy/rendering/renderablegalaxy.cpp | 18 ++-- .../cache/memoryawaretilecache.cpp | 6 +- .../globebrowsing/globebrowsingmodule_lua.inl | 4 +- modules/globebrowsing/meshes/trianglesoup.cpp | 6 +- modules/globebrowsing/other/pixelbuffer.cpp | 2 +- .../globebrowsing/rendering/chunkrenderer.cpp | 2 +- modules/globebrowsing/tile/pixelregion.cpp | 8 +- .../gdalrawtiledatareader.cpp | 19 ++-- .../rawtiledatareader/rawtiledatareader.cpp | 2 +- .../simplerawtiledatareader.cpp | 12 +-- .../tile/rawtiledatareader/tiledatatype.cpp | 58 ++++++++----- modules/globebrowsing/tile/tileindex.cpp | 8 +- .../tileprovider/temporaltileprovider.cpp | 2 +- .../tile/tileprovider/tileproviderbylevel.cpp | 2 +- modules/imgui/src/guimissioncomponent.cpp | 4 +- modules/imgui/src/guispacetimecomponent.cpp | 4 +- modules/imgui/src/renderproperties.cpp | 4 +- modules/iswa/util/dataprocessor.cpp | 16 ++-- modules/iswa/util/dataprocessorjson.cpp | 19 ++-- modules/iswa/util/dataprocessorkameleon.cpp | 21 ++--- modules/iswa/util/dataprocessortext.cpp | 19 ++-- modules/kameleon/src/kameleonwrapper.cpp | 4 +- .../rendering/renderablekameleonvolume.cpp | 4 +- .../tasks/kameleonvolumetorawtask.cpp | 10 ++- .../rendering/renderablemultiresvolume.cpp | 14 ++- modules/touch/src/touchinteraction.cpp | 65 +++++++++----- modules/volume/rawvolumewriter.inl | 2 +- .../rendering/renderabletimevaryingvolume.cpp | 20 ++--- modules/volume/textureslicevolumereader.h | 2 + modules/volume/volumesampler.inl | 8 +- src/interaction/touchbar.mm | 7 +- src/properties/matrix/dmat2property.cpp | 9 +- src/properties/matrix/dmat2x3property.cpp | 9 +- src/properties/matrix/dmat2x4property.cpp | 9 +- src/properties/matrix/dmat3property.cpp | 9 +- src/properties/matrix/dmat3x2property.cpp | 9 +- src/properties/matrix/dmat3x4property.cpp | 9 +- src/properties/matrix/dmat4property.cpp | 9 +- src/properties/matrix/dmat4x2property.cpp | 9 +- src/properties/matrix/dmat4x3property.cpp | 9 +- src/properties/matrix/mat2property.cpp | 4 +- src/properties/matrix/mat2x3property.cpp | 4 +- src/properties/matrix/mat2x4property.cpp | 4 +- src/properties/matrix/mat3property.cpp | 4 +- src/properties/matrix/mat3x2property.cpp | 4 +- src/properties/matrix/mat3x4property.cpp | 4 +- src/properties/matrix/mat4property.cpp | 4 +- src/properties/matrix/mat4x2property.cpp | 4 +- src/properties/matrix/mat4x3property.cpp | 4 +- src/properties/scalar/boolproperty.cpp | 6 +- src/properties/scalar/doubleproperty.cpp | 4 +- src/properties/scalar/intproperty.cpp | 8 +- src/properties/stringproperty.cpp | 12 +-- src/properties/vector/bvec2property.cpp | 6 +- src/properties/vector/bvec3property.cpp | 6 +- src/properties/vector/bvec4property.cpp | 6 +- src/properties/vector/dvec2property.cpp | 6 +- src/properties/vector/dvec3property.cpp | 6 +- src/properties/vector/dvec4property.cpp | 6 +- src/properties/vector/ivec2property.cpp | 4 +- src/rendering/loadingscreen.cpp | 4 +- src/scene/sceneloader.cpp | 7 +- src/util/blockplaneintersectiongeometry.cpp | 2 - src/util/boxgeometry.cpp | 2 +- src/util/factorymanager.cpp | 10 +-- src/util/histogram.cpp | 86 ++++++++++--------- src/util/keys.cpp | 12 +-- tests/test_gdalwms.inl | 16 ++-- tests/test_luaconversions.inl | 15 +++- 81 files changed, 422 insertions(+), 348 deletions(-) diff --git a/ext/ghoul b/ext/ghoul index 6944475ee6..d7aec4688b 160000 --- a/ext/ghoul +++ b/ext/ghoul @@ -1 +1 @@ -Subproject commit 6944475ee6293e4dd6671800cb28953e877e1cb7 +Subproject commit d7aec4688b9673d61e8885f3ce7a0d569b54b614 diff --git a/include/openspace/properties/numericalproperty.inl b/include/openspace/properties/numericalproperty.inl index c0a07e3127..95b027b692 100644 --- a/include/openspace/properties/numericalproperty.inl +++ b/include/openspace/properties/numericalproperty.inl @@ -159,17 +159,17 @@ namespace openspace::properties { template <> \ template <> \ bool PropertyDelegate>::toLuaValue(lua_State* lua, \ - TYPE value) \ + TYPE val) \ { \ - return TO_LUA_LAMBDA_EXPRESSION(lua, value); \ + return TO_LUA_LAMBDA_EXPRESSION(lua, val); \ } \ \ template <> \ template <> \ bool PropertyDelegate>::toLuaValue(lua_State* state, \ - TYPE value) \ + TYPE val) \ { \ - return PropertyDelegate>::toLuaValue(state, value); \ + return PropertyDelegate>::toLuaValue(state, val); \ } \ \ template <> \ diff --git a/include/openspace/properties/templateproperty.inl b/include/openspace/properties/templateproperty.inl index 32ecffb1ab..b21ff70211 100644 --- a/include/openspace/properties/templateproperty.inl +++ b/include/openspace/properties/templateproperty.inl @@ -106,16 +106,17 @@ namespace openspace::properties { template <> \ template <> \ TYPE PropertyDelegate>::fromLuaValue(lua_State* l, \ - bool& s) \ + bool& successful) \ { \ - return FROM_LUA_LAMBDA_EXPRESSION(l, s); \ + return FROM_LUA_LAMBDA_EXPRESSION(l, successful); \ } \ \ template <> \ template <> \ - bool PropertyDelegate>::toLuaValue(lua_State* l, TYPE v)\ + bool PropertyDelegate>::toLuaValue(lua_State* l, \ + TYPE value) \ { \ - return TO_LUA_LAMBDA_EXPRESSION(l, v); \ + return TO_LUA_LAMBDA_EXPRESSION(l, value); \ } \ \ template <> \ @@ -125,10 +126,10 @@ namespace openspace::properties { \ template <> \ template <> \ - TYPE PropertyDelegate>::fromString(std::string v, \ - bool& s) \ + TYPE PropertyDelegate>::fromString(std::string value, \ + bool& successful) \ { \ - return FROM_STRING_LAMBDA_EXPRESSION(v, s); \ + return FROM_STRING_LAMBDA_EXPRESSION(value, successful); \ } \ \ template <> \ diff --git a/modules/base/rendering/renderablesphere.cpp b/modules/base/rendering/renderablesphere.cpp index 1f6a28e4e7..9ba2a62fcc 100644 --- a/modules/base/rendering/renderablesphere.cpp +++ b/modules/base/rendering/renderablesphere.cpp @@ -259,7 +259,7 @@ void RenderableSphere::render(const RenderData& data, RendererTasks&) { setPscUniforms(*_shader.get(), data.camera, data.position); if (_fadeOutThreshold > -1.0) { - float distCamera = glm::distance( + double distCamera = glm::distance( data.camera.positionVec3(), data.position.dvec3() ); diff --git a/modules/base/rotation/fixedrotation.cpp b/modules/base/rotation/fixedrotation.cpp index df05dbb397..4719adbfee 100644 --- a/modules/base/rotation/fixedrotation.cpp +++ b/modules/base/rotation/fixedrotation.cpp @@ -544,7 +544,7 @@ void FixedRotation::update(const UpdateData&) { glm::vec3 y = yAxis(); glm::vec3 z = zAxis(); - static const float Epsilon = 1e-3; + static const float Epsilon = 1e-3f; if (glm::dot(x, y) > 1.f - Epsilon || glm::dot(y, z) > 1.f - Epsilon || diff --git a/modules/base/rotation/luarotation.cpp b/modules/base/rotation/luarotation.cpp index 03ff884a7d..4840de00b5 100644 --- a/modules/base/rotation/luarotation.cpp +++ b/modules/base/rotation/luarotation.cpp @@ -110,7 +110,9 @@ void LuaRotation::update(const UpdateData& data) { auto now = high_resolution_clock::now(); lua_pushnumber( _state, - duration_cast(now.time_since_epoch()).count() + static_cast( + duration_cast(now.time_since_epoch()).count() + ) ); // Execute the scaling function diff --git a/modules/base/scale/luascale.cpp b/modules/base/scale/luascale.cpp index a688351003..eb3194303a 100644 --- a/modules/base/scale/luascale.cpp +++ b/modules/base/scale/luascale.cpp @@ -101,7 +101,9 @@ void LuaScale::update(const UpdateData& data) { auto now = high_resolution_clock::now(); lua_pushnumber( _state, - duration_cast(now.time_since_epoch()).count() + static_cast( + duration_cast(now.time_since_epoch()).count() + ) ); // Execute the scaling function diff --git a/modules/base/translation/luatranslation.cpp b/modules/base/translation/luatranslation.cpp index 7dd8353d9e..bb5e3ddcc3 100644 --- a/modules/base/translation/luatranslation.cpp +++ b/modules/base/translation/luatranslation.cpp @@ -118,7 +118,9 @@ void LuaTranslation::update(const UpdateData& data) { auto now = high_resolution_clock::now(); lua_pushnumber( _state, - duration_cast(now.time_since_epoch()).count() + static_cast( + duration_cast(now.time_since_epoch()).count() + ) ); // Execute the scaling function diff --git a/modules/fieldlinessequence/rendering/renderablefieldlinessequencesetup.cpp b/modules/fieldlinessequence/rendering/renderablefieldlinessequencesetup.cpp index 538186e5e0..4547f444f2 100644 --- a/modules/fieldlinessequence/rendering/renderablefieldlinessequencesetup.cpp +++ b/modules/fieldlinessequence/rendering/renderablefieldlinessequencesetup.cpp @@ -303,8 +303,12 @@ bool RenderableFieldlinesSequence::extractMandatoryInfoFromDictionary( LERROR(_name << ": The field " << std::string(KeyInputFileType) << " is missing!"); return false; } else { - std::transform(inputFileTypeString.begin(), inputFileTypeString.end(), - inputFileTypeString.begin(), ::tolower); + std::transform( + inputFileTypeString.begin(), + inputFileTypeString.end(), + inputFileTypeString.begin(), + [](char c) { return static_cast(tolower(c)); } + ); // Verify that the input type is correct if (inputFileTypeString == ValueInputFileTypeCdf) { sourceFileType = SourceFileType::Cdf; diff --git a/modules/fieldlinessequence/util/fieldlinesstate.cpp b/modules/fieldlinessequence/util/fieldlinesstate.cpp index 51c8b7b0d9..d55ba96569 100644 --- a/modules/fieldlinessequence/util/fieldlinesstate.cpp +++ b/modules/fieldlinessequence/util/fieldlinesstate.cpp @@ -373,7 +373,7 @@ void FieldlinesState::saveStateToJson(const std::string& absPath) { // Returns one of the extra quantity vectors, _extraQuantities[index]. // If index is out of scope an empty vector is returned and the referenced bool is false. -const std::vector& FieldlinesState::extraQuantity(const size_t index, +std::vector FieldlinesState::extraQuantity(const size_t index, bool& isSuccessful) const { if (index < _extraQuantities.size()) { isSuccessful = true; diff --git a/modules/fieldlinessequence/util/fieldlinesstate.h b/modules/fieldlinessequence/util/fieldlinesstate.h index 66d417deff..10a1faa4ae 100644 --- a/modules/fieldlinessequence/util/fieldlinesstate.h +++ b/modules/fieldlinessequence/util/fieldlinesstate.h @@ -64,7 +64,7 @@ public: const std::vector& vertexPositions() const; // Special getter. Returns extraQuantities[INDEX]. - const std::vector& extraQuantity(const size_t INDEX, bool& isSuccesful) const; + std::vector extraQuantity(const size_t INDEX, bool& isSuccesful) const; void setModel(const fls::Model m) { _model = m; } void setTriggerTime(const double t) { _triggerTime = t; } diff --git a/modules/galaxy/rendering/galaxyraycaster.cpp b/modules/galaxy/rendering/galaxyraycaster.cpp index 1c3ed1d186..f5f7fc83a3 100644 --- a/modules/galaxy/rendering/galaxyraycaster.cpp +++ b/modules/galaxy/rendering/galaxyraycaster.cpp @@ -115,9 +115,7 @@ void GalaxyRaycaster::preRaycast(const RaycastData& data, program.setUniform(galaxyTextureUniformName, *_textureUnit); } -void GalaxyRaycaster::postRaycast(const RaycastData& data, - ghoul::opengl::ProgramObject& program) -{ +void GalaxyRaycaster::postRaycast(const RaycastData&, ghoul::opengl::ProgramObject&) { _textureUnit = nullptr; // release texture unit. } diff --git a/modules/galaxy/rendering/renderablegalaxy.cpp b/modules/galaxy/rendering/renderablegalaxy.cpp index 6ef4b4c635..39e7432dcd 100644 --- a/modules/galaxy/rendering/renderablegalaxy.cpp +++ b/modules/galaxy/rendering/renderablegalaxy.cpp @@ -340,22 +340,22 @@ void RenderableGalaxy::render(const RenderData& data, RendererTasks& tasks) { float maxDim = std::max(std::max(galaxySize.x, galaxySize.y), galaxySize.z); - float lowerRampStart = maxDim * 0.02; - float lowerRampEnd = maxDim * 0.5; + float lowerRampStart = maxDim * 0.02f; + float lowerRampEnd = maxDim * 0.5f; - float upperRampStart = maxDim * 2.0; - float upperRampEnd = maxDim * 10; + float upperRampStart = maxDim * 2.f; + float upperRampEnd = maxDim * 10.f; - float opacityCoefficient = 1.0; + float opacityCoefficient = 1.f; if (length < lowerRampStart) { - opacityCoefficient = 0; // camera really close + opacityCoefficient = 0.f; // camera really close } else if (length < lowerRampEnd) { opacityCoefficient = (length - lowerRampStart) / (lowerRampEnd - lowerRampStart); } else if (length < upperRampStart) { - opacityCoefficient = 1.0; // sweet spot (max) + opacityCoefficient = 1.f; // sweet spot (max) } else if (length < upperRampEnd) { - opacityCoefficient = 1.0 - (length - upperRampStart) / + opacityCoefficient = 1.f - (length - upperRampStart) / (upperRampEnd - upperRampStart); //fade out } else { opacityCoefficient = 0; @@ -363,7 +363,7 @@ void RenderableGalaxy::render(const RenderData& data, RendererTasks& tasks) { _opacityCoefficient = opacityCoefficient; ghoul_assert( - _opacityCoefficient >= 0.0 && _opacityCoefficient <= 1.0, + _opacityCoefficient >= 0.f && _opacityCoefficient <= 1.f, "Opacity coefficient was not between 0 and 1" ); if (opacityCoefficient > 0) { diff --git a/modules/globebrowsing/cache/memoryawaretilecache.cpp b/modules/globebrowsing/cache/memoryawaretilecache.cpp index 6cc13be786..ab4cf6ec52 100644 --- a/modules/globebrowsing/cache/memoryawaretilecache.cpp +++ b/modules/globebrowsing/cache/memoryawaretilecache.cpp @@ -301,7 +301,8 @@ void MemoryAwareTileCache::update() { size_t MemoryAwareTileCache::getGPUAllocatedDataSize() const { return std::accumulate( _textureContainerMap.cbegin(), - _textureContainerMap.cend(), 0, + _textureContainerMap.cend(), + size_t(0), [](size_t s, const std::pair& p) { @@ -316,7 +317,8 @@ size_t MemoryAwareTileCache::getGPUAllocatedDataSize() const { size_t MemoryAwareTileCache::getCPUAllocatedDataSize() const { size_t dataSize = std::accumulate( _textureContainerMap.cbegin(), - _textureContainerMap.cend(), 0, + _textureContainerMap.cend(), + size_t(0), [](size_t s, const std::pair& p) { diff --git a/modules/globebrowsing/globebrowsingmodule_lua.inl b/modules/globebrowsing/globebrowsingmodule_lua.inl index 85c6e6d040..b217d08138 100644 --- a/modules/globebrowsing/globebrowsingmodule_lua.inl +++ b/modules/globebrowsing/globebrowsingmodule_lua.inl @@ -162,8 +162,8 @@ int goToGeo(lua_State* L) { return luaL_error(L, "Expected 2 or 3 arguments."); } - double latitude = static_cast(lua_tonumber(L, 1)); - double longitude = static_cast(lua_tonumber(L, 2)); + double latitude = lua_tonumber(L, 1); + double longitude = lua_tonumber(L, 2); if (nArguments == 2) { OsEng.moduleEngine().module()->goToGeo(latitude, longitude); diff --git a/modules/globebrowsing/meshes/trianglesoup.cpp b/modules/globebrowsing/meshes/trianglesoup.cpp index 428aa3ed98..7ae355db65 100644 --- a/modules/globebrowsing/meshes/trianglesoup.cpp +++ b/modules/globebrowsing/meshes/trianglesoup.cpp @@ -87,7 +87,7 @@ void TriangleSoup::setElements(std::vector elements) { _elementData.resize(elements.size()); _gpuDataNeedUpdate = true; for (size_t i = 0; i < elements.size(); i++) { - _elementData[i] = static_cast(elements[i]); + _elementData[i] = elements[i]; } } @@ -128,8 +128,8 @@ bool TriangleSoup::updateDataOnGPU() { // Positions at location 0 if (_useVertexPositions) { glEnableVertexAttribArray(0); - glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), - reinterpret_cast(offsetof(Vertex, position))); + glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(Vertex), nullptr); + //reinterpret_cast(offsetof(Vertex, position))); } // Textures at location 1 if (_useTextureCoordinates) { diff --git a/modules/globebrowsing/other/pixelbuffer.cpp b/modules/globebrowsing/other/pixelbuffer.cpp index c34050495a..001a2a8018 100644 --- a/modules/globebrowsing/other/pixelbuffer.cpp +++ b/modules/globebrowsing/other/pixelbuffer.cpp @@ -38,7 +38,7 @@ PixelBuffer::PixelBuffer(size_t numBytes, Usage usage) { glGenBuffers(1, &_id); bind(); - glBufferData(GL_PIXEL_UNPACK_BUFFER, _numBytes, 0, static_cast(_usage)); + glBufferData(GL_PIXEL_UNPACK_BUFFER, _numBytes, nullptr, static_cast(_usage)); unbind(); } diff --git a/modules/globebrowsing/rendering/chunkrenderer.cpp b/modules/globebrowsing/rendering/chunkrenderer.cpp index b420caa61f..bb712a6fee 100644 --- a/modules/globebrowsing/rendering/chunkrenderer.cpp +++ b/modules/globebrowsing/rendering/chunkrenderer.cpp @@ -293,7 +293,7 @@ void ChunkRenderer::renderChunkLocally(const Chunk& chunk, const RenderData& dat Geodetic2 corner = chunk.surfacePatch().getCorner(q); glm::dvec3 cornerModelSpace = ellipsoid.cartesianSurfacePosition(corner); glm::dvec3 cornerCameraSpace = - glm::dvec3(dmat4(modelViewTransform) * glm::dvec4(cornerModelSpace, 1)); + glm::dvec3(modelViewTransform * glm::dvec4(cornerModelSpace, 1)); cornersCameraSpace[i] = cornerCameraSpace; programObject->setUniform(cornerNames[i], vec3(cornerCameraSpace)); } diff --git a/modules/globebrowsing/tile/pixelregion.cpp b/modules/globebrowsing/tile/pixelregion.cpp index fabd02f3a7..6e884e4c50 100644 --- a/modules/globebrowsing/tile/pixelregion.cpp +++ b/modules/globebrowsing/tile/pixelregion.cpp @@ -118,12 +118,12 @@ void PixelRegion::scale(double s) { void PixelRegion::downscalePow2(int exponent, PixelCoordinate wrt) { start += wrt; - start.x = ceil(start.x / static_cast(pow(2, exponent)));// >>= exponent; - start.y = ceil(start.y / static_cast(pow(2, exponent)));// >>= exponent; + start.x = static_cast(ceil(start.x / static_cast(pow(2, exponent)))); + start.y = static_cast(ceil(start.y / static_cast(pow(2, exponent)))); numPixels.x = - ceil(numPixels.x / static_cast(pow(2, exponent)));// >>= exponent; + static_cast(ceil(numPixels.x / static_cast(pow(2, exponent)))); numPixels.y = - ceil(numPixels.y / static_cast(pow(2, exponent)));// >>= exponent; + static_cast(ceil(numPixels.y / static_cast(pow(2, exponent)))); start -= wrt; } diff --git a/modules/globebrowsing/tile/rawtiledatareader/gdalrawtiledatareader.cpp b/modules/globebrowsing/tile/rawtiledatareader/gdalrawtiledatareader.cpp index 38b1198d33..8c02c7ddb7 100644 --- a/modules/globebrowsing/tile/rawtiledatareader/gdalrawtiledatareader.cpp +++ b/modules/globebrowsing/tile/rawtiledatareader/gdalrawtiledatareader.cpp @@ -126,12 +126,17 @@ void GdalRawTileDataReader::initialize() { // Assume all raster bands have the same data type _gdalDatasetMetaDataCached.rasterCount = _dataset->GetRasterCount(); - _gdalDatasetMetaDataCached.scale = _dataset->GetRasterBand(1)->GetScale(); - _gdalDatasetMetaDataCached.offset = _dataset->GetRasterBand(1)->GetOffset(); + _gdalDatasetMetaDataCached.scale = static_cast( + _dataset->GetRasterBand(1)->GetScale() + ); + _gdalDatasetMetaDataCached.offset = static_cast( + _dataset->GetRasterBand(1)->GetOffset() + ); _gdalDatasetMetaDataCached.rasterXSize = _dataset->GetRasterXSize(); _gdalDatasetMetaDataCached.rasterYSize = _dataset->GetRasterYSize(); - _gdalDatasetMetaDataCached.noDataValue = - _dataset->GetRasterBand(1)->GetNoDataValue(); + _gdalDatasetMetaDataCached.noDataValue = static_cast( + _dataset->GetRasterBand(1)->GetNoDataValue() + ); _gdalDatasetMetaDataCached.dataType = tiledatatype::getGdalDataType(_initData.glType()); @@ -145,7 +150,7 @@ void GdalRawTileDataReader::initialize() { calculateTileLevelDifference(_initData.dimensions().x); int numOverviews = _dataset->GetRasterBand(1)->GetOverviewCount(); - _cached._maxLevel = -_cached._tileLevelDifference; + _cached._maxLevel = static_cast(-_cached._tileLevelDifference); if (numOverviews > 0) { _cached._maxLevel += numOverviews - 1; } @@ -191,7 +196,7 @@ RawTile::ReadError GdalRawTileDataReader::rasterRead( io.write.region.numPixels.y, // width to write y in destination _gdalDatasetMetaDataCached.dataType, // Type static_cast(_initData.bytesPerPixel()), // Pixel spacing - static_cast(-io.write.bytesPerLine) // Line spacing + -static_cast(io.write.bytesPerLine) // Line spacing ); // Convert error to RawTile::ReadError @@ -236,7 +241,7 @@ int GdalRawTileDataReader::calculateTileLevelDifference(int minimumPixelSize) co } int sizeLevel0 = maxOverview->GetXSize(); double diff = log2(minimumPixelSize) - log2(sizeLevel0); - return diff; + return static_cast(diff); } } // namespace openspace::globebrowsing diff --git a/modules/globebrowsing/tile/rawtiledatareader/rawtiledatareader.cpp b/modules/globebrowsing/tile/rawtiledatareader/rawtiledatareader.cpp index ed49aa1620..062b4cfc4b 100644 --- a/modules/globebrowsing/tile/rawtiledatareader/rawtiledatareader.cpp +++ b/modules/globebrowsing/tile/rawtiledatareader/rawtiledatareader.cpp @@ -577,7 +577,7 @@ TileDepthTransform RawTileDataReader::calculateTileDepthTransform() { TileDepthTransform transform; transform.depthOffset = depthOffset(); - transform.depthScale = depthScale() * maximumValue; + transform.depthScale = static_cast(depthScale() * maximumValue); return transform; } diff --git a/modules/globebrowsing/tile/rawtiledatareader/simplerawtiledatareader.cpp b/modules/globebrowsing/tile/rawtiledatareader/simplerawtiledatareader.cpp index 46d8c6052d..596e24b9c2 100644 --- a/modules/globebrowsing/tile/rawtiledatareader/simplerawtiledatareader.cpp +++ b/modules/globebrowsing/tile/rawtiledatareader/simplerawtiledatareader.cpp @@ -115,14 +115,16 @@ RawTile::ReadError SimpleRawTileDataReader::rasterRead( y * _initData.bytesPerLine() + x * _initData.bytesPerPixel(); - int xInSource = + int xInSource = static_cast( io.read.region.start.x + static_cast(x) / io.write.region.numPixels.x * - io.read.region.numPixels.x; - int yInSource = + io.read.region.numPixels.x + ); + int yInSource = static_cast( io.read.region.start.y + static_cast(y) / io.write.region.numPixels.y * - io.read.region.numPixels.y; + io.read.region.numPixels.y + ); glm::vec4 sourceTexel = _dataTexture->texelAsFloat(xInSource, yInSource); @@ -141,7 +143,7 @@ RawTile::ReadError SimpleRawTileDataReader::rasterRead( char value = static_cast( sourceTexel[rasterBand - 1] * 255 ); - *reinterpret_cast(pixelWriteDestination) = value; + *pixelWriteDestination = value; break; } case GL_UNSIGNED_SHORT: { diff --git a/modules/globebrowsing/tile/rawtiledatareader/tiledatatype.cpp b/modules/globebrowsing/tile/rawtiledatareader/tiledatatype.cpp index ff2811e1ab..ae7b55fe98 100644 --- a/modules/globebrowsing/tile/rawtiledatareader/tiledatatype.cpp +++ b/modules/globebrowsing/tile/rawtiledatareader/tiledatatype.cpp @@ -141,6 +141,7 @@ TextureFormat getTextureFormat(int rasterCount, GDALDataType gdalType) { // break; default: LERROR("GDAL data type unknown to OpenGL: " << gdalType); + throw ghoul::MissingCaseException(); } break; case 2: @@ -169,6 +170,7 @@ TextureFormat getTextureFormat(int rasterCount, GDALDataType gdalType) { break; default: LERROR("GDAL data type unknown to OpenGL: " << gdalType); + throw ghoul::MissingCaseException(); } break; case 3: @@ -198,6 +200,7 @@ TextureFormat getTextureFormat(int rasterCount, GDALDataType gdalType) { // break; default: LERROR("GDAL data type unknown to OpenGL: " << gdalType); + throw ghoul::MissingCaseException(); } break; case 4: @@ -227,11 +230,12 @@ TextureFormat getTextureFormat(int rasterCount, GDALDataType gdalType) { // break; default: LERROR("GDAL data type unknown to OpenGL: " << gdalType); + throw ghoul::MissingCaseException(); } break; default: LERROR("Unknown number of channels for OpenGL texture: " << rasterCount); - break; + throw ghoul::MissingCaseException(); } return format; } @@ -267,6 +271,7 @@ TextureFormat getTextureFormatOptimized(int rasterCount, GDALDataType gdalType) // break; default: LERROR("GDAL data type unknown to OpenGL: " << gdalType); + throw ghoul::MissingCaseException(); } break; case 2: @@ -295,6 +300,7 @@ TextureFormat getTextureFormatOptimized(int rasterCount, GDALDataType gdalType) break; default: LERROR("GDAL data type unknown to OpenGL: " << gdalType); + throw ghoul::MissingCaseException(); } break; case 3: @@ -324,6 +330,7 @@ TextureFormat getTextureFormatOptimized(int rasterCount, GDALDataType gdalType) // break; default: LERROR("GDAL data type unknown to OpenGL: " << gdalType); + throw ghoul::MissingCaseException(); } break; case 4: @@ -353,11 +360,12 @@ TextureFormat getTextureFormatOptimized(int rasterCount, GDALDataType gdalType) // break; default: LERROR("GDAL data type unknown to OpenGL: " << gdalType); + throw ghoul::MissingCaseException(); } break; default: LERROR("Unknown number of channels for OpenGL texture: " << rasterCount); - break; + throw ghoul::MissingCaseException(); } return format; } @@ -380,7 +388,7 @@ GLenum getOpenGLDataType(GDALDataType gdalType) { return GL_DOUBLE; default: LERROR("GDAL data type unknown to OpenGL: " << gdalType); - return GL_UNSIGNED_BYTE; + throw ghoul::MissingCaseException(); } } @@ -402,7 +410,7 @@ GDALDataType getGdalDataType(GLenum glType) { return GDT_Float64; default: LERROR("OpenGL data type unknown to GDAL: " << glType); - return GDT_Unknown; + throw ghoul::MissingCaseException(); } } @@ -410,12 +418,16 @@ GDALDataType getGdalDataType(GLenum glType) { size_t numberOfRasters(ghoul::opengl::Texture::Format format) { switch (format) { - case ghoul::opengl::Texture::Format::Red: return 1; - case ghoul::opengl::Texture::Format::RG: return 2; - case ghoul::opengl::Texture::Format::RGB:; - [[fallthrough]]; case ghoul::opengl::Texture::Format::BGR: return 3; - case ghoul::opengl::Texture::Format::RGBA:; - [[fallthrough]]; case ghoul::opengl::Texture::Format::BGRA: return 4; + case ghoul::opengl::Texture::Format::Red: + return 1; + case ghoul::opengl::Texture::Format::RG: + return 2; + case ghoul::opengl::Texture::Format::RGB: + case ghoul::opengl::Texture::Format::BGR: + return 3; + case ghoul::opengl::Texture::Format::RGBA: + case ghoul::opengl::Texture::Format::BGRA: + return 4; default: { ghoul_assert(false, "Unknown format"); return 0; @@ -436,7 +448,7 @@ size_t numberOfBytes(GLenum glType) { case GL_DOUBLE: return sizeof(GLdouble); default: { ghoul_assert(false, "Unknown data type"); - return 0; + throw ghoul::MissingCaseException(); } } } @@ -455,7 +467,7 @@ size_t getMaximumValue(GLenum glType) { return 1ULL << 31ULL; default: { ghoul_assert(false, "Unknown data type"); - return 0ULL; + throw ghoul::MissingCaseException(); } } } @@ -480,7 +492,7 @@ float interpretFloat(GLenum glType, const char* src) { return static_cast(*reinterpret_cast(src)); default: { ghoul_assert(false, "Unknown data type"); - return 0; + throw ghoul::MissingCaseException(); } } } @@ -504,7 +516,7 @@ GLenum glTextureFormat(GLenum glType, ghoul::opengl::Texture::Format format) { default: ghoul_assert(false, "glType data type unknown"); LERROR("glType data type unknown: " << glType); - return GLenum(0); + throw ghoul::MissingCaseException(); } case ghoul::opengl::Texture::Format::RG: switch (glType) { @@ -523,7 +535,7 @@ GLenum glTextureFormat(GLenum glType, ghoul::opengl::Texture::Format format) { default: ghoul_assert(false, "glType data type unknown"); LERROR("glType data type unknown: " << glType); - return GLenum(0); + throw ghoul::MissingCaseException(); } case ghoul::opengl::Texture::Format::RGB: switch (glType) { @@ -542,7 +554,7 @@ GLenum glTextureFormat(GLenum glType, ghoul::opengl::Texture::Format format) { default: ghoul_assert(false, "glType data type unknown"); LERROR("glType data type unknown: " << glType); - return GLenum(0); + throw ghoul::MissingCaseException(); } case ghoul::opengl::Texture::Format::RGBA: switch (glType) { @@ -561,7 +573,7 @@ GLenum glTextureFormat(GLenum glType, ghoul::opengl::Texture::Format format) { default: ghoul_assert(false, "glType data type unknown"); LERROR("glType data type unknown: " << glType); - return GLenum(0); + throw ghoul::MissingCaseException(); } case ghoul::opengl::Texture::Format::BGR: switch (glType) { @@ -580,7 +592,7 @@ GLenum glTextureFormat(GLenum glType, ghoul::opengl::Texture::Format format) { default: ghoul_assert(false, "glType data type unknown"); LERROR("glType data type unknown: " << glType); - return GLenum(0); + throw ghoul::MissingCaseException(); } case ghoul::opengl::Texture::Format::BGRA: switch (glType) { @@ -599,16 +611,16 @@ GLenum glTextureFormat(GLenum glType, ghoul::opengl::Texture::Format format) { default: ghoul_assert(false, "glType data type unknown"); LERROR("glType data type unknown: " << glType); - return GLenum(0); + throw ghoul::MissingCaseException(); } default: LERROR( "Unknown format for OpenGL texture: " << - static_cast - >(format) + static_cast>( + format + ) ); - return GLenum(0); + throw ghoul::MissingCaseException(); } } diff --git a/modules/globebrowsing/tile/tileindex.cpp b/modules/globebrowsing/tile/tileindex.cpp index 72f66bb578..01c35b01fa 100644 --- a/modules/globebrowsing/tile/tileindex.cpp +++ b/modules/globebrowsing/tile/tileindex.cpp @@ -46,8 +46,8 @@ TileIndex::TileIndex(const TileIndex& other) : x(other.x), y(other.y), level(other.level) {} -TileIndex::TileIndex(const Geodetic2& point, int level) - : level(level) +TileIndex::TileIndex(const Geodetic2& point, int level_) + : level(level_) { int numIndicesAtLevel = 1 << level; double u = 0.5 + point.lon / (2 * glm::pi()); @@ -55,8 +55,8 @@ TileIndex::TileIndex(const Geodetic2& point, int level) double xIndexSpace = u * numIndicesAtLevel; double yIndexSpace = v * numIndicesAtLevel; - x = floor(xIndexSpace); - y = floor(yIndexSpace); + x = static_cast(floor(xIndexSpace)); + y = static_cast(floor(yIndexSpace)); } TileIndex::TileIndex(const ghoul::Dictionary& dict) { diff --git a/modules/globebrowsing/tile/tileprovider/temporaltileprovider.cpp b/modules/globebrowsing/tile/tileprovider/temporaltileprovider.cpp index af24cfbc68..60a3eeb5d2 100644 --- a/modules/globebrowsing/tile/tileprovider/temporaltileprovider.cpp +++ b/modules/globebrowsing/tile/tileprovider/temporaltileprovider.cpp @@ -500,7 +500,7 @@ std::vector