Base/App: fix warnings from code analysers:

* convert old-style-casts to explicit C++ casts where possible
* make some implicit conversions explicit
This commit is contained in:
wmayer
2022-03-06 23:49:30 +01:00
parent 26ece78df4
commit 4a343ab31e
30 changed files with 211 additions and 155 deletions

View File

@@ -25,7 +25,7 @@
#define APP_MATERIAL_H
#ifdef __GNUC__
# include <stdint.h>
# include <cstdint>
#endif
#include <sstream>
@@ -100,10 +100,10 @@ public:
*/
uint32_t getPackedValue() const
{
return ((uint32_t)(r*255.0f + 0.5f) << 24 |
(uint32_t)(g*255.0f + 0.5f) << 16 |
(uint32_t)(b*255.0f + 0.5f) << 8 |
(uint32_t)(a*255.0f + 0.5f));
return (static_cast<uint32_t>(r*255.0f + 0.5f) << 24 |
static_cast<uint32_t>(g*255.0f + 0.5f) << 16 |
static_cast<uint32_t>(b*255.0f + 0.5f) << 8 |
static_cast<uint32_t>(a*255.0f + 0.5f));
}
/**
* creates FC Color from template type, e.g. Qt QColor
@@ -116,8 +116,8 @@ public:
*
*/
template <typename T>
inline T asValue(void) const {
return(T(int(r*255.0),int(g*255.0),int(b*255.0)));
inline T asValue() const {
return(T(int(r*255.0f),int(g*255.0f),int(b*255.0f)));
}
/**
* returns color as hex color "#RRGGBB"
@@ -125,9 +125,9 @@ public:
*/
std::string asHexString() const {
std::stringstream ss;
ss << "#" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << int(r*255.0)
<< std::setw(2) << int(g*255.0)
<< std::setw(2) << int(b*255.0);
ss << "#" << std::hex << std::uppercase << std::setfill('0') << std::setw(2) << int(r*255.0f)
<< std::setw(2) << int(g*255.0f)
<< std::setw(2) << int(b*255.0f);
return ss.str();
}
/**
@@ -223,7 +223,7 @@ public:
*/
//@{
/** Sets the USER_DEFINED material type. The user must set the colors afterwards. */
Material(void);
Material();
/** Defines the colors and shininess for the material \a MatName. If \a MatName isn't defined then USER_DEFINED is
* set and the user must define the colors itself.
*/