Gui: Use std::numeric_limits and std::numbers instead of defines

This commit is contained in:
Benjamin Nauck
2025-03-27 18:59:58 +01:00
parent 3253f2c2de
commit b625e81a3e
33 changed files with 204 additions and 168 deletions

View File

@@ -25,6 +25,8 @@
#include "NavigationAnimation.h"
#include <Inventor/nodes/SoCamera.h>
#include <numbers>
using namespace Gui;
NavigationAnimation::NavigationAnimation(NavigationStyle* navigation)
@@ -69,8 +71,8 @@ void FixedTimeAnimation::initialize()
SbVec3f rotationAxisPost;
float angle;
SbRotation(navigation->getCamera()->orientation.getValue().inverse() * targetOrientation).getValue(rotationAxisPost, angle);
if (angle > M_PI) {
angle -= float(2 * M_PI);
if (angle > std::numbers::pi) {
angle -= float(2 * std::numbers::pi);
}
// Convert post-multiplication axis to a pre-multiplication axis
@@ -130,9 +132,9 @@ SpinningAnimation::SpinningAnimation(NavigationStyle* navigation, const SbVec3f&
: NavigationAnimation(navigation)
, rotationAxis(axis)
{
setDuration((2 * M_PI / velocity) * 1000.0);
setDuration((2 * std::numbers::pi / velocity) * 1000.0);
setStartValue(0.0);
setEndValue(2 * M_PI);
setEndValue(2 * std::numbers::pi);
setLoopCount(-1);
}

View File

@@ -39,6 +39,9 @@
# include <QMenu>
#endif
#include <cmath>
#include <limits>
#include <Base/Interpreter.h>
#include <App/Application.h>
@@ -719,7 +722,8 @@ void NavigationStyle::zoom(SoCamera * cam, float diffvalue)
const float distorigo = newpos.length();
// sqrt(FLT_MAX) == ~ 1e+19, which should be both safe for further
// calculations and ok for the end-user and app-programmer.
if (distorigo > float(sqrt(FLT_MAX))) {
float maxDistance = std::sqrt(std::numeric_limits<float>::max());
if (distorigo > maxDistance) {
// do nothing here
}
else {