Merge pull request #20559 from hyarion/refactor/add-limits

Add `#include <limits>` in all files where it is used
This commit is contained in:
Kacper Donat
2025-04-01 17:11:50 +02:00
committed by GitHub
166 changed files with 284 additions and 65 deletions

View File

@@ -22,6 +22,10 @@
#include <PreCompiled.h>
#ifndef _PreComp_
#include <limits>
#endif
#include <QImage>
#include <QScreen>
#include <QString>
@@ -48,8 +52,6 @@
#include <Gui/View3DInventorViewer.h>
#include <Gui/ViewProvider.h>
constexpr float MAX_FLOAT = std::numeric_limits<float>::max();
long NavlibInterface::GetSelectionTransform(navlib::matrix_t&) const
{
return navlib::make_result_code(navlib::navlib_errc::no_data_available);
@@ -128,7 +130,7 @@ long NavlibInterface::GetHitLookAt(navlib::point_t& position) const
SoRayPickAction rayPickAction(inventorViewer->getSoRenderManager()->getViewportRegion());
SbMatrix cameraMatrix;
SbVec3f closestHitPoint;
float minLength = MAX_FLOAT;
float minLength = std::numeric_limits<float>::max();
// Get the camera rotation
SoCamera* pCamera = getCamera<SoCamera*>();
@@ -196,7 +198,7 @@ long NavlibInterface::GetHitLookAt(navlib::point_t& position) const
}
}
if (minLength < MAX_FLOAT) {
if (minLength < std::numeric_limits<float>::max()) {
std::copy(closestHitPoint.getValue(), closestHitPoint.getValue() + 3, &position.x);
return 0;
}

View File

@@ -23,6 +23,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <limits>
# include <QApplication>
# include <QKeyEvent>
# include <QLabel>

View File

@@ -23,6 +23,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
#include <limits>
#include <Inventor/actions/SoGetBoundingBoxAction.h>
#include <Inventor/nodes/SoClipPlane.h>
#include <Inventor/nodes/SoGroup.h>

View File

@@ -22,6 +22,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
#include <limits>
#include <QCursor>
#include <QTimer>
#include <Inventor/nodes/SoCamera.h>

View File

@@ -22,6 +22,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
#include <limits>
#include <sstream>
#include <QByteArray>
#include <QContextMenuEvent>

View File

@@ -23,6 +23,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <limits>
# include <Inventor/sensors/SoNodeSensor.h>
# include <Inventor/nodes/SoAnnotation.h>
# include <Inventor/nodes/SoOrthographicCamera.h>

View File

@@ -23,6 +23,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <limits>
# include <QContextMenuEvent>
# include <QMenu>
# include <QPixmapCache>

View File

@@ -23,6 +23,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <limits>
# include <QAction>
# include <QApplication>
# include <QComboBox>

View File

@@ -65,6 +65,7 @@
#include <algorithm>
#include <atomic>
#include <bitset>
#include <limits>
#include <list>
#include <map>
#include <numbers>

View File

@@ -23,6 +23,9 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <cmath>
# include <limits>
# include <vector>
# include <QCoreApplication>
# include <QDate>
# include <QDesktopServices>
@@ -31,8 +34,6 @@
# include <QMessageBox>
# include <QSettings>
# include <QUrl>
# include <cmath>
# include <vector>
#endif
#include <App/Application.h>

View File

@@ -22,6 +22,10 @@
#include "PreCompiled.h"
#ifndef _PreComp_
#include <limits>
#endif
#include <zlib.h>
#include <App/License.h>
#include <Gui/AutoSaver.h>

View File

@@ -23,6 +23,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <limits>
# include <QApplication>
# include <QDebug>
# include <QFocusEvent>

View File

@@ -24,6 +24,7 @@
#ifndef GUI_SelectionFilter_H
#define GUI_SelectionFilter_H
#include <limits>
#include <memory>
#include <string>
#include <CXX/Extensions.hxx>

View File

@@ -23,6 +23,7 @@
#ifndef GUI_SOFCSELECTIONCONTEXT_H
#define GUI_SOFCSELECTIONCONTEXT_H
#include <limits>
#include <map>
#include <memory>
#include <set>

View File

@@ -22,6 +22,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <limits>
# include <QShortcutEvent>
# include <QApplication>
#endif

View File

@@ -35,6 +35,7 @@
# include <algorithm>
# include <cmath>
# include <limits>
# include <numbers>
# include <QFontMetrics>
# include <QPainter>

View File

@@ -23,7 +23,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <climits>
# include <limits>
# include <QKeyEvent>
# include <QLineEdit>
# include <QStyle>
@@ -292,34 +292,40 @@ public:
UnsignedValidator * mValidator{nullptr};
UIntSpinBoxPrivate() = default;
uint mapToUInt( int v ) const
unsigned mapToUInt( int v ) const
{
uint ui;
if ( v == std::numeric_limits<int>::min() ) {
using int_limits = std::numeric_limits<int>;
using uint_limits = std::numeric_limits<unsigned>;
unsigned ui;
if ( v == int_limits::min() ) {
ui = 0;
} else if ( v == std::numeric_limits<int>::max() ) {
ui = std::numeric_limits<unsigned>::max();
} else if ( v == int_limits::max() ) {
ui = uint_limits::max();
} else if ( v < 0 ) {
v -= std::numeric_limits<int>::min();
ui = static_cast<uint>(v);
v -= int_limits::min();
ui = static_cast<unsigned>(v);
} else {
ui = static_cast<uint>(v);
ui -= std::numeric_limits<int>::min();
ui = static_cast<unsigned>(v);
ui -= int_limits::min();
} return ui;
}
int mapToInt( uint v ) const
int mapToInt( unsigned v ) const
{
using int_limits = std::numeric_limits<int>;
using uint_limits = std::numeric_limits<unsigned>;
int in;
if ( v == std::numeric_limits<unsigned>::max() ) {
in = std::numeric_limits<int>::max();
if ( v == uint_limits::max() ) {
in = int_limits::max();
} else if ( v == 0 ) {
in = std::numeric_limits<int>::min();
} else if ( v > std::numeric_limits<int>::max() ) {
v += std::numeric_limits<int>::min();
in = int_limits::min();
} else if ( v > int_limits::max() ) {
v += int_limits::min();
in = static_cast<int>(v);
} else {
in = v;
in += std::numeric_limits<int>::min();
in += int_limits::min();
} return in;
}
};

View File

@@ -22,6 +22,10 @@
#include "PreCompiled.h"
#ifndef _PreComp_
#include <limits>
#endif
#include "VectorListEditor.h"
#include "ui_VectorListEditor.h"
#include "QuantitySpinBox.h"

View File

@@ -26,6 +26,7 @@
#ifndef _PreComp_
#include <algorithm>
#include <iomanip>
#include <limits>
#include <QApplication>
#include <QComboBox>
#include <QFontDatabase>

View File

@@ -23,6 +23,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
#include <limits>
#include <boost/algorithm/string/predicate.hpp>
#endif