Gui: Use std::numeric_limits and std::numbers instead of defines
This commit is contained in:
@@ -748,7 +748,7 @@ QString CallTipsList::stripWhiteSpace(const QString& str) const
|
||||
{
|
||||
QString stripped = str;
|
||||
QStringList lines = str.split(QLatin1String("\n"));
|
||||
int minspace=INT_MAX;
|
||||
int minspace=std::numeric_limits<int>::max();
|
||||
int line=0;
|
||||
for (QStringList::iterator it = lines.begin(); it != lines.end(); ++it, ++line) {
|
||||
if (it->size() > 0 && line > 0) {
|
||||
@@ -766,7 +766,7 @@ QString CallTipsList::stripWhiteSpace(const QString& str) const
|
||||
}
|
||||
|
||||
// remove all leading tabs from each line
|
||||
if (minspace > 0 && minspace < INT_MAX) {
|
||||
if (minspace > 0 && minspace < std::numeric_limits<int>::max()) {
|
||||
int line=0;
|
||||
QStringList strippedlines;
|
||||
for (QStringList::iterator it = lines.begin(); it != lines.end(); ++it, ++line) {
|
||||
|
||||
@@ -109,20 +109,21 @@ Clipping::Clipping(Gui::View3DInventor* view, QWidget* parent)
|
||||
d->ui.setupUi(this);
|
||||
setupConnections();
|
||||
|
||||
d->ui.clipView->setRange(-INT_MAX, INT_MAX);
|
||||
constexpr int max = std::numeric_limits<int>::max();
|
||||
d->ui.clipView->setRange(-max, max);
|
||||
d->ui.clipView->setSingleStep(0.1f);
|
||||
d->ui.clipX->setRange(-INT_MAX, INT_MAX);
|
||||
d->ui.clipX->setRange(-max, max);
|
||||
d->ui.clipX->setSingleStep(0.1f);
|
||||
d->ui.clipY->setRange(-INT_MAX, INT_MAX);
|
||||
d->ui.clipY->setRange(-max, max);
|
||||
d->ui.clipY->setSingleStep(0.1f);
|
||||
d->ui.clipZ->setRange(-INT_MAX, INT_MAX);
|
||||
d->ui.clipZ->setRange(-max, max);
|
||||
d->ui.clipZ->setSingleStep(0.1f);
|
||||
|
||||
d->ui.dirX->setRange(-INT_MAX, INT_MAX);
|
||||
d->ui.dirX->setRange(-max, max);
|
||||
d->ui.dirX->setSingleStep(0.1f);
|
||||
d->ui.dirY->setRange(-INT_MAX, INT_MAX);
|
||||
d->ui.dirY->setRange(-max, max);
|
||||
d->ui.dirY->setSingleStep(0.1f);
|
||||
d->ui.dirZ->setRange(-INT_MAX, INT_MAX);
|
||||
d->ui.dirZ->setRange(-max, max);
|
||||
d->ui.dirZ->setSingleStep(0.1f);
|
||||
d->ui.dirZ->setValue(1.0f);
|
||||
|
||||
|
||||
@@ -166,7 +166,7 @@ SbVec3f DemoMode::getDirection(Gui::View3DInventor* view) const
|
||||
SbRotation inv = rot.inverse();
|
||||
SbVec3f vec(this->viewAxis);
|
||||
inv.multVec(vec, vec);
|
||||
if (vec.length() < FLT_EPSILON) {
|
||||
if (vec.length() < std::numeric_limits<float>::epsilon()) {
|
||||
vec = this->viewAxis;
|
||||
}
|
||||
vec.normalize();
|
||||
|
||||
@@ -905,7 +905,7 @@ void ParameterValue::onCreateUIntItem()
|
||||
DlgInputDialogImp::UIntBox);
|
||||
dlg.setWindowTitle(QObject::tr("New unsigned item"));
|
||||
UIntSpinBox* edit = dlg.getUIntBox();
|
||||
edit->setRange(0, UINT_MAX);
|
||||
edit->setRange(0, std::numeric_limits<unsigned>::max());
|
||||
if (dlg.exec() == QDialog::Accepted) {
|
||||
QString value = edit->text();
|
||||
unsigned long val = value.toULong(&ok);
|
||||
@@ -1249,7 +1249,7 @@ void ParameterUInt::changeValue()
|
||||
DlgInputDialogImp::UIntBox);
|
||||
dlg.setWindowTitle(QObject::tr("Change value"));
|
||||
UIntSpinBox* edit = dlg.getUIntBox();
|
||||
edit->setRange(0, UINT_MAX);
|
||||
edit->setRange(0, std::numeric_limits<unsigned>::max());
|
||||
edit->setValue(text(2).toULong());
|
||||
if (dlg.exec() == QDialog::Accepted) {
|
||||
QString value = edit->text();
|
||||
|
||||
@@ -152,8 +152,8 @@ void EditableDatumLabel::startEdit(double val, QObject* eventFilteringObj, bool
|
||||
|
||||
spinBox = new QuantitySpinBox(mdi);
|
||||
spinBox->setUnit(Base::Unit::Length);
|
||||
spinBox->setMinimum(-INT_MAX);
|
||||
spinBox->setMaximum(INT_MAX);
|
||||
spinBox->setMinimum(-std::numeric_limits<int>::max());
|
||||
spinBox->setMaximum(std::numeric_limits<int>::max());
|
||||
spinBox->setButtonSymbols(QAbstractSpinBox::NoButtons);
|
||||
spinBox->setKeyboardTracking(false);
|
||||
spinBox->setFocusPolicy(Qt::ClickFocus); // prevent passing focus with tab.
|
||||
|
||||
@@ -71,8 +71,8 @@ InputField::InputField(QWidget * parent)
|
||||
ExpressionWidget(),
|
||||
validInput(true),
|
||||
actUnitValue(0),
|
||||
Maximum(DOUBLE_MAX),
|
||||
Minimum(-DOUBLE_MAX),
|
||||
Maximum(std::numeric_limits<double>::max()),
|
||||
Minimum(-std::numeric_limits<double>::max()),
|
||||
StepSize(1.0),
|
||||
HistorySize(5),
|
||||
SaveSize(5)
|
||||
|
||||
@@ -25,10 +25,8 @@
|
||||
#ifndef _PreComp_
|
||||
#include <array>
|
||||
#include <boost/math/constants/constants.hpp>
|
||||
#ifdef FC_OS_WIN32
|
||||
#define _USE_MATH_DEFINES
|
||||
#endif
|
||||
#include <cmath>
|
||||
#include <numbers>
|
||||
#ifdef FC_OS_MACOSX
|
||||
#include <OpenGL/gl.h>
|
||||
#else
|
||||
@@ -39,17 +37,23 @@
|
||||
#include "SoFCBackgroundGradient.h"
|
||||
|
||||
static const std::array <GLfloat[2], 32> big_circle = []{
|
||||
static const float pi2 = boost::math::constants::two_pi<float>();
|
||||
constexpr float pi = std::numbers::pi_v<float>;
|
||||
constexpr float sqrt2 = std::numbers::sqrt2_v<float>;
|
||||
std::array <GLfloat[2], 32> result; int c = 0;
|
||||
for (GLfloat i = 0; i < pi2; i += pi2 / 32, c++) {
|
||||
result[c][0] = M_SQRT2*cosf(i); result[c][1] = M_SQRT2*sinf(i);
|
||||
for (GLfloat i = 0; i < 2 * pi; i += 2 * pi / 32, c++) {
|
||||
result[c][0] = sqrt2 * cosf(i);
|
||||
result[c][1] = sqrt2 * sinf(i);
|
||||
}
|
||||
return result; }();
|
||||
static const std::array <GLfloat[2], 32> small_oval = []{
|
||||
static const float pi2 = boost::math::constants::two_pi<float>();
|
||||
constexpr float pi = std::numbers::pi_v<float>;
|
||||
constexpr float sqrt2 = std::numbers::sqrt2_v<float>;
|
||||
static const float sqrt1_2 = std::sqrt(1 / 2.F);
|
||||
|
||||
std::array <GLfloat[2], 32> result; int c = 0;
|
||||
for (GLfloat i = 0; i < pi2; i += pi2 / 32, c++) {
|
||||
result[c][0] = 0.3*M_SQRT2*cosf(i); result[c][1] = M_SQRT1_2*sinf(i);
|
||||
for (GLfloat i = 0; i < 2 * pi; i += 2 * pi / 32, c++) {
|
||||
result[c][0] = 0.3 * sqrt2 * cosf(i);
|
||||
result[c][1] = sqrt1_2 * sinf(i);
|
||||
}
|
||||
return result; }();
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
# include <algorithm>
|
||||
# include <cfloat>
|
||||
# include <numbers>
|
||||
# ifdef FC_OS_WIN32
|
||||
# include <windows.h>
|
||||
# endif
|
||||
@@ -553,7 +553,7 @@ void NaviCubeImplementation::addButtonFace(PickId pickId, const SbVec3f& directi
|
||||
case PickId::DotBackside: {
|
||||
int steps = 16;
|
||||
for (int i = 0; i < steps; i++) {
|
||||
float angle = 2.0f * M_PI * ((float)i+0.5) / (float)steps;
|
||||
float angle = 2.0f * std::numbers::pi_v<float> * ((float)i+0.5) / (float)steps;
|
||||
pointData.emplace_back(10. * cos(angle) + 87.);
|
||||
pointData.emplace_back(10. * sin(angle) - 87.);
|
||||
}
|
||||
@@ -659,8 +659,8 @@ void NaviCubeImplementation::setSize(int size)
|
||||
|
||||
void NaviCubeImplementation::prepare()
|
||||
{
|
||||
static const float pi = boost::math::constants::pi<float>();
|
||||
static const float pi1_2 = boost::math::constants::half_pi<float>();
|
||||
constexpr float pi = std::numbers::pi_v<float>;
|
||||
constexpr float pi1_2 = pi / 2;
|
||||
|
||||
createCubeFaceTextures();
|
||||
|
||||
@@ -817,7 +817,7 @@ void NaviCubeImplementation::drawNaviCube(bool pickMode, float opacity)
|
||||
glOrtho(-2.1, 2.1, -2.1, 2.1, NEARVAL, FARVAL);
|
||||
}
|
||||
else {
|
||||
const float dim = NEARVAL * float(tan(M_PI / 8.0)) * 1.1;
|
||||
const float dim = NEARVAL * float(tan(std::numbers::pi / 8.0)) * 1.1;
|
||||
glFrustum(-dim, dim, -dim, dim, NEARVAL, FARVAL);
|
||||
}
|
||||
glMatrixMode(GL_MODELVIEW);
|
||||
@@ -1010,15 +1010,11 @@ SbRotation NaviCubeImplementation::getNearestOrientation(PickId pickId) {
|
||||
angle *= -1;
|
||||
}
|
||||
|
||||
static const float pi = boost::math::constants::pi<float>();
|
||||
static const float pi2 = boost::math::constants::two_pi<float>();
|
||||
static const float pi1_2 = boost::math::constants::half_pi<float>();
|
||||
static const float pi1_3 = boost::math::constants::third_pi<float>();
|
||||
static const float pi2_3 = boost::math::constants::two_thirds_pi<float>();
|
||||
constexpr float pi = std::numbers::pi_v<float>;
|
||||
|
||||
// Make angle positive
|
||||
if (angle < 0) {
|
||||
angle += pi2;
|
||||
angle += 2 * pi;
|
||||
}
|
||||
|
||||
// f is a small value used to control orientation priority when the camera is almost exactly between two
|
||||
@@ -1030,23 +1026,23 @@ SbRotation NaviCubeImplementation::getNearestOrientation(PickId pickId) {
|
||||
// Find the angle to rotate to the nearest orientation
|
||||
if (m_Faces[pickId].type == ShapeId::Corner) {
|
||||
// 6 possible orientations for the corners
|
||||
if (angle <= (M_PI / 6 + f)) {
|
||||
if (angle <= (pi / 6 + f)) {
|
||||
angle = 0;
|
||||
}
|
||||
else if (angle <= (M_PI_2 + f)) {
|
||||
angle = pi1_3;
|
||||
else if (angle <= (pi / 2 + f)) {
|
||||
angle = pi / 3;
|
||||
}
|
||||
else if (angle < (5 * M_PI / 6 - f)) {
|
||||
angle = pi2_3;
|
||||
else if (angle < (5 * pi / 6 - f)) {
|
||||
angle = 2 * pi / 3;
|
||||
}
|
||||
else if (angle <= (M_PI + M_PI / 6 + f)) {
|
||||
else if (angle <= (pi + pi / 6 + f)) {
|
||||
angle = pi;
|
||||
}
|
||||
else if (angle < (M_PI + M_PI_2 - f)) {
|
||||
angle = pi + pi1_3;
|
||||
else if (angle < (pi + pi / 2 - f)) {
|
||||
angle = pi + pi / 3;
|
||||
}
|
||||
else if (angle < (M_PI + 5 * M_PI / 6 - f)) {
|
||||
angle = pi + pi2_3;
|
||||
else if (angle < (pi + 5 * pi / 6 - f)) {
|
||||
angle = pi + 2 * pi / 3;
|
||||
}
|
||||
else {
|
||||
angle = 0;
|
||||
@@ -1054,17 +1050,17 @@ SbRotation NaviCubeImplementation::getNearestOrientation(PickId pickId) {
|
||||
}
|
||||
else {
|
||||
// 4 possible orientations for the main and edge faces
|
||||
if (angle <= (M_PI_4 + f)) {
|
||||
if (angle <= (pi / 4 + f)) {
|
||||
angle = 0;
|
||||
}
|
||||
else if (angle <= (3 * M_PI_4 + f)) {
|
||||
angle = pi1_2;
|
||||
else if (angle <= (3 * pi / 4 + f)) {
|
||||
angle = pi / 2;
|
||||
}
|
||||
else if (angle < (M_PI + M_PI_4 - f)) {
|
||||
else if (angle < (pi + pi / 4 - f)) {
|
||||
angle = pi;
|
||||
}
|
||||
else if (angle < (M_PI + 3 * M_PI_4 - f)) {
|
||||
angle = pi + pi1_2;
|
||||
else if (angle < (pi + 3 * pi / 4 - f)) {
|
||||
angle = pi + pi / 2;
|
||||
}
|
||||
else {
|
||||
angle = 0;
|
||||
@@ -1089,7 +1085,7 @@ bool NaviCubeImplementation::mouseReleased(short x, short y)
|
||||
} else {
|
||||
PickId pickId = pickFace(x, y);
|
||||
long step = Base::clamp(long(m_NaviStepByTurn), 4L, 36L);
|
||||
float rotStepAngle = (2 * M_PI) / step;
|
||||
float rotStepAngle = (2 * std::numbers::pi) / step;
|
||||
|
||||
if (m_Faces[pickId].type == ShapeId::Main || m_Faces[pickId].type == ShapeId::Edge || m_Faces[pickId].type == ShapeId::Corner) {
|
||||
// Handle the cube faces
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -1819,7 +1819,7 @@ bool OverlayManager::eventFilter(QObject *o, QEvent *ev)
|
||||
}
|
||||
|
||||
if (hit <= 0) {
|
||||
d->_lastPos.setX(INT_MAX);
|
||||
d->_lastPos.setX(std::numeric_limits<int>::max());
|
||||
if (ev->type() == QEvent::Wheel) {
|
||||
d->wheelDelay = QTime::currentTime().addMSecs(OverlayParams::getDockOverlayWheelDelay());
|
||||
d->wheelPos = pos;
|
||||
|
||||
@@ -50,8 +50,6 @@
|
||||
#include <fcntl.h>
|
||||
#include <cctype>
|
||||
#include <typeinfo>
|
||||
#include <cfloat>
|
||||
#include <climits>
|
||||
|
||||
#ifdef FC_OS_WIN32
|
||||
#include <Windows.h>
|
||||
@@ -69,6 +67,7 @@
|
||||
#include <bitset>
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <numbers>
|
||||
#include <queue>
|
||||
#include <random>
|
||||
#include <set>
|
||||
|
||||
@@ -182,7 +182,7 @@ void ApplicationCache::setPeriod(ApplicationCache::Period period)
|
||||
numDays = 365;
|
||||
break;
|
||||
case Period::Never:
|
||||
numDays = INT_MAX;
|
||||
numDays = std::numeric_limits<int>::max();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,7 +60,7 @@ DlgSettingsDocumentImp::DlgSettingsDocumentImp(QWidget* parent)
|
||||
ui->prefSaveBackupDateFormat->setToolTip(tip);
|
||||
ui->FormatTimeDocsLabel->setText(link);
|
||||
|
||||
ui->prefCountBackupFiles->setMaximum(INT_MAX);
|
||||
ui->prefCountBackupFiles->setMaximum(std::numeric_limits<int>::max());
|
||||
ui->prefCompression->setMinimum(Z_NO_COMPRESSION);
|
||||
ui->prefCompression->setMaximum(Z_BEST_COMPRESSION);
|
||||
connect(ui->prefLicenseType, qOverload<int>(&QComboBox::currentIndexChanged),
|
||||
|
||||
@@ -66,8 +66,8 @@ public:
|
||||
pendingEmit(false),
|
||||
checkRangeInExpression(false),
|
||||
unitValue(0),
|
||||
maximum(DOUBLE_MAX),
|
||||
minimum(-DOUBLE_MAX),
|
||||
maximum(std::numeric_limits<double>::max()),
|
||||
minimum(-std::numeric_limits<double>::max()),
|
||||
singleStep(1.0),
|
||||
q_ptr(q)
|
||||
{
|
||||
|
||||
@@ -20,6 +20,8 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#include <numbers>
|
||||
|
||||
#include <Base/Console.h>
|
||||
#include <Inventor/SbLine.h>
|
||||
#include <Inventor/SbPlane.h>
|
||||
@@ -303,7 +305,7 @@ void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::convertOrtho2Perspective(const So
|
||||
|
||||
SbRotation camrot = in->orientation.getValue();
|
||||
|
||||
float focaldist = float(in->height.getValue() / (2.0*tan(M_PI / 8.0))); // NOLINT
|
||||
float focaldist = float(in->height.getValue() / (2.0*tan(std::numbers::pi / 8.0))); // NOLINT
|
||||
|
||||
SbVec3f offset(0,0,focaldist-in->focalDistance.getValue());
|
||||
|
||||
@@ -313,7 +315,7 @@ void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::convertOrtho2Perspective(const So
|
||||
out->focalDistance.setValue(focaldist);
|
||||
|
||||
// 45° is the default value of this field in SoPerspectiveCamera.
|
||||
out->heightAngle = (float)(M_PI / 4.0); // NOLINT
|
||||
out->heightAngle = (float)(std::numbers::pi / 4.0); // NOLINT
|
||||
}
|
||||
|
||||
void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::convertPerspective2Ortho(const SoPerspectiveCamera* in,
|
||||
@@ -568,7 +570,7 @@ void SIM::Coin3D::Quarter::SoQTQuarterAdaptor::seeksensorCB(void* data, SoSensor
|
||||
|
||||
bool end = (par == 1.0F);
|
||||
|
||||
par = (float)((1.0 - cos(M_PI * par)) * 0.5); // NOLINT
|
||||
par = (float)((1.0 - cos(std::numbers::pi * par)) * 0.5); // NOLINT
|
||||
|
||||
thisp->getSoRenderManager()->getCamera()->position = thisp->m_camerastartposition +
|
||||
(thisp->m_cameraendposition - thisp->m_camerastartposition) * par;
|
||||
|
||||
@@ -172,8 +172,9 @@ private:
|
||||
|
||||
struct Node_Slice
|
||||
{
|
||||
explicit Node_Slice(int min=1,int max=INT_MAX):Min(min),Max(max){}
|
||||
int Min,Max;
|
||||
explicit Node_Slice(int min = 1, int max = std::numeric_limits<int>::max())
|
||||
: Min(min), Max(max) {}
|
||||
int Min, Max;
|
||||
|
||||
};
|
||||
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#ifndef GUI_SOFCSELECTIONCONTEXT_H
|
||||
#define GUI_SOFCSELECTIONCONTEXT_H
|
||||
|
||||
#include <climits>
|
||||
#include <map>
|
||||
#include <memory>
|
||||
#include <set>
|
||||
@@ -79,11 +78,11 @@ struct GuiExport SoFCSelectionContext : SoFCSelectionContextBase
|
||||
}
|
||||
|
||||
bool isHighlightAll() const{
|
||||
return highlightIndex==INT_MAX && (selectionIndex.empty() || isSelectAll());
|
||||
return highlightIndex == std::numeric_limits<int>::max() && (selectionIndex.empty() || isSelectAll());
|
||||
}
|
||||
|
||||
void highlightAll() {
|
||||
highlightIndex = INT_MAX;
|
||||
highlightIndex = std::numeric_limits<int>::max();
|
||||
}
|
||||
|
||||
void removeHighlight() {
|
||||
|
||||
@@ -409,7 +409,7 @@ void ShortcutManager::onTimer()
|
||||
timer.stop();
|
||||
|
||||
QAction *found = nullptr;
|
||||
int priority = -INT_MAX;
|
||||
int priority = -std::numeric_limits<int>::max();
|
||||
int seq_length = 0;
|
||||
for (const auto &info : pendingActions) {
|
||||
if (info.action) {
|
||||
|
||||
@@ -34,8 +34,8 @@
|
||||
# endif
|
||||
|
||||
# include <algorithm>
|
||||
# include <cfloat>
|
||||
# include <cmath>
|
||||
# include <numbers>
|
||||
# include <QFontMetrics>
|
||||
# include <QPainter>
|
||||
|
||||
@@ -78,11 +78,12 @@ void glDrawLine(const SbVec3f& p1, const SbVec3f& p2){
|
||||
glEnd();
|
||||
}
|
||||
|
||||
void glDrawArc(const SbVec3f& center, float radius, float startAngle=0., float endAngle=2.0*M_PI, int countSegments=0){
|
||||
void glDrawArc(const SbVec3f& center, float radius, float startAngle=0.,
|
||||
float endAngle=2.0*std::numbers::pi, int countSegments=0){
|
||||
float range = endAngle - startAngle;
|
||||
|
||||
if (countSegments == 0){
|
||||
countSegments = std::max(6, abs(int(25.0 * range / M_PI)));
|
||||
countSegments = std::max(6, abs(int(25.0 * range / std::numbers::pi)));
|
||||
}
|
||||
|
||||
float segment = range / (countSegments-1);
|
||||
@@ -238,11 +239,12 @@ public:
|
||||
private:
|
||||
void getBBox(const std::vector<SbVec3f>& corners, SbBox3f& box, SbVec3f& center) const
|
||||
{
|
||||
constexpr float floatMax = std::numeric_limits<float>::max();
|
||||
if (corners.size() > 1) {
|
||||
float minX = FLT_MAX;
|
||||
float minY = FLT_MAX;
|
||||
float maxX = -FLT_MAX;
|
||||
float maxY = -FLT_MAX;
|
||||
float minX = floatMax;
|
||||
float minY = floatMax;
|
||||
float maxX = -floatMax;
|
||||
float maxY = -floatMax;
|
||||
for (SbVec3f it : corners) {
|
||||
minX = (it[0] < minX) ? it[0] : minX;
|
||||
minY = (it[1] < minY) ? it[1] : minY;
|
||||
@@ -288,14 +290,15 @@ private:
|
||||
|
||||
SbVec3f dir;
|
||||
SbVec3f normal;
|
||||
constexpr float floatEpsilon = std::numeric_limits<float>::epsilon();
|
||||
if (label->datumtype.getValue() == SoDatumLabel::DISTANCE) {
|
||||
dir = (p2-p1);
|
||||
}
|
||||
else if (label->datumtype.getValue() == SoDatumLabel::DISTANCEX) {
|
||||
dir = SbVec3f( (p2[0] - p1[0] >= FLT_EPSILON) ? 1 : -1, 0, 0);
|
||||
dir = SbVec3f( (p2[0] - p1[0] >= floatEpsilon) ? 1 : -1, 0, 0);
|
||||
}
|
||||
else if (label->datumtype.getValue() == SoDatumLabel::DISTANCEY) {
|
||||
dir = SbVec3f(0, (p2[1] - p1[1] >= FLT_EPSILON) ? 1 : -1, 0);
|
||||
dir = SbVec3f(0, (p2[1] - p1[1] >= floatEpsilon) ? 1 : -1, 0);
|
||||
}
|
||||
|
||||
dir.normalize();
|
||||
@@ -546,11 +549,11 @@ private:
|
||||
float startangle = atan2f(vc1[1], vc1[0]);
|
||||
float endangle = atan2f(vc2[1], vc2[0]);
|
||||
if (endangle < startangle) {
|
||||
endangle += 2. * M_PI;
|
||||
endangle += 2. * std::numbers::pi;
|
||||
}
|
||||
|
||||
SbVec3f textCenter;
|
||||
if (endangle - startangle <= M_PI) {
|
||||
if (endangle - startangle <= std::numbers::pi) {
|
||||
textCenter = ctr + vm * (length + imgHeight);
|
||||
} else {
|
||||
textCenter = ctr - vm * (length + 2. * imgHeight);
|
||||
@@ -628,14 +631,16 @@ SbVec3f SoDatumLabel::getLabelTextCenterDistance(const SbVec3f& p1, const SbVec3
|
||||
|
||||
SbVec3f dir;
|
||||
SbVec3f normal;
|
||||
|
||||
constexpr float floatEpsilon = std::numeric_limits<float>::epsilon();
|
||||
if (datumtype.getValue() == SoDatumLabel::DISTANCE) {
|
||||
dir = (p2 - p1);
|
||||
}
|
||||
else if (datumtype.getValue() == SoDatumLabel::DISTANCEX) {
|
||||
dir = SbVec3f((p2[0] - p1[0] >= FLT_EPSILON) ? 1 : -1, 0, 0);
|
||||
dir = SbVec3f((p2[0] - p1[0] >= floatEpsilon) ? 1 : -1, 0, 0);
|
||||
}
|
||||
else if (datumtype.getValue() == SoDatumLabel::DISTANCEY) {
|
||||
dir = SbVec3f(0, (p2[1] - p1[1] >= FLT_EPSILON) ? 1 : -1, 0);
|
||||
dir = SbVec3f(0, (p2[1] - p1[1] >= floatEpsilon) ? 1 : -1, 0);
|
||||
}
|
||||
|
||||
dir.normalize();
|
||||
@@ -689,7 +694,7 @@ SbVec3f SoDatumLabel::getLabelTextCenterArcLength(const SbVec3f& ctr, const SbVe
|
||||
float endangle = atan2f(vc2[1], vc2[0]);
|
||||
|
||||
if (endangle < startangle) {
|
||||
endangle += 2. * M_PI;
|
||||
endangle += 2. * std::numbers::pi;
|
||||
}
|
||||
|
||||
// Text location
|
||||
@@ -697,7 +702,7 @@ SbVec3f SoDatumLabel::getLabelTextCenterArcLength(const SbVec3f& ctr, const SbVe
|
||||
vm.normalize();
|
||||
|
||||
SbVec3f textCenter;
|
||||
if (endangle - startangle <= M_PI) {
|
||||
if (endangle - startangle <= std::numbers::pi) {
|
||||
textCenter = ctr + vm * (length + this->imgHeight);
|
||||
} else {
|
||||
textCenter = ctr - vm * (length + 2. * this->imgHeight);
|
||||
@@ -709,12 +714,13 @@ SbVec3f SoDatumLabel::getLabelTextCenterArcLength(const SbVec3f& ctr, const SbVe
|
||||
void SoDatumLabel::generateDistancePrimitives(SoAction * action, const SbVec3f& p1, const SbVec3f& p2)
|
||||
{
|
||||
SbVec3f dir;
|
||||
constexpr float floatEpsilon = std::numeric_limits<float>::epsilon();
|
||||
if (this->datumtype.getValue() == DISTANCE) {
|
||||
dir = (p2-p1);
|
||||
} else if (this->datumtype.getValue() == DISTANCEX) {
|
||||
dir = SbVec3f( (p2[0] - p1[0] >= FLT_EPSILON) ? 1 : -1, 0, 0);
|
||||
dir = SbVec3f( (p2[0] - p1[0] >= floatEpsilon) ? 1 : -1, 0, 0);
|
||||
} else if (this->datumtype.getValue() == DISTANCEY) {
|
||||
dir = SbVec3f(0, (p2[1] - p1[1] >= FLT_EPSILON) ? 1 : -1, 0);
|
||||
dir = SbVec3f(0, (p2[1] - p1[1] >= floatEpsilon) ? 1 : -1, 0);
|
||||
}
|
||||
|
||||
dir.normalize();
|
||||
@@ -957,7 +963,8 @@ void SoDatumLabel::generateArcLengthPrimitives(SoAction * action, const SbVec3f&
|
||||
void SoDatumLabel::generatePrimitives(SoAction * action)
|
||||
{
|
||||
// Initialisation check (needs something more sensible) prevents an infinite loop bug
|
||||
if (this->imgHeight <= FLT_EPSILON || this->imgWidth <= FLT_EPSILON) {
|
||||
constexpr float floatEpsilon = std::numeric_limits<float>::epsilon();
|
||||
if (this->imgHeight <= floatEpsilon | this->imgWidth <= floatEpsilon) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1161,6 +1168,8 @@ void SoDatumLabel::getDimension(float scale, int& srcw, int& srch)
|
||||
|
||||
void SoDatumLabel::drawDistance(const SbVec3f* points, float scale, int srch, float& angle, SbVec3f& textOffset)
|
||||
{
|
||||
using std::numbers::pi;
|
||||
|
||||
float length = this->param1.getValue();
|
||||
float length2 = this->param2.getValue();
|
||||
|
||||
@@ -1168,12 +1177,13 @@ void SoDatumLabel::drawDistance(const SbVec3f* points, float scale, int srch, fl
|
||||
SbVec3f p2 = points[1];
|
||||
|
||||
SbVec3f dir;
|
||||
constexpr float floatEpsilon = std::numeric_limits<float>::epsilon();
|
||||
if (this->datumtype.getValue() == DISTANCE) {
|
||||
dir = (p2-p1);
|
||||
} else if (this->datumtype.getValue() == DISTANCEX) {
|
||||
dir = SbVec3f( (p2[0] - p1[0] >= FLT_EPSILON) ? 1 : -1, 0, 0);
|
||||
dir = SbVec3f( (p2[0] - p1[0] >= floatEpsilon) ? 1 : -1, 0, 0);
|
||||
} else if (this->datumtype.getValue() == DISTANCEY) {
|
||||
dir = SbVec3f(0, (p2[1] - p1[1] >= FLT_EPSILON) ? 1 : -1, 0);
|
||||
dir = SbVec3f(0, (p2[1] - p1[1] >= floatEpsilon) ? 1 : -1, 0);
|
||||
}
|
||||
|
||||
dir.normalize();
|
||||
@@ -1192,10 +1202,10 @@ void SoDatumLabel::drawDistance(const SbVec3f* points, float scale, int srch, fl
|
||||
|
||||
// Get magnitude of angle between horizontal
|
||||
angle = atan2f(dir[1],dir[0]);
|
||||
if (angle > M_PI_2+M_PI/12) {
|
||||
angle -= (float)M_PI;
|
||||
} else if (angle <= -M_PI_2+M_PI/12) {
|
||||
angle += (float)M_PI;
|
||||
if (angle > pi/2 + pi/12) {
|
||||
angle -= (float)pi;
|
||||
} else if (angle <= -pi/2 + pi/12) {
|
||||
angle += (float)pi;
|
||||
}
|
||||
|
||||
textOffset = midpos + normal * length + dir * length2;
|
||||
@@ -1291,7 +1301,7 @@ void SoDatumLabel::drawDistance(const SbVec3f* points)
|
||||
float startangle1 = this->param3.getValue();
|
||||
float radius1 = this->param5.getValue();
|
||||
SbVec3f center = points[2];
|
||||
int countSegments = std::max(6, abs(int(50.0 * range1 / (2 * M_PI))));
|
||||
int countSegments = std::max(6, abs(int(50.0 * range1 / (2 * std::numbers::pi))));
|
||||
double segment = range1 / (countSegments - 1);
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
@@ -1307,7 +1317,7 @@ void SoDatumLabel::drawDistance(const SbVec3f* points)
|
||||
float startangle2 = this->param6.getValue();
|
||||
float radius2 = this->param8.getValue();
|
||||
SbVec3f center = points[3];
|
||||
int countSegments = std::max(6, abs(int(50.0 * range2 / (2 * M_PI))));
|
||||
int countSegments = std::max(6, abs(int(50.0 * range2 / (2 * std::numbers::pi))));
|
||||
double segment = range2 / (countSegments - 1);
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
@@ -1342,10 +1352,10 @@ void SoDatumLabel::drawRadiusOrDiameter(const SbVec3f* points, float& angle, SbV
|
||||
|
||||
// Get magnitude of angle between horizontal
|
||||
angle = atan2f(dir[1],dir[0]);
|
||||
if (angle > M_PI_2+M_PI/12) {
|
||||
angle -= (float)M_PI;
|
||||
} else if (angle <= -M_PI_2+M_PI/12) {
|
||||
angle += (float)M_PI;
|
||||
if (angle > std::numbers::pi/2 + std::numbers::pi/12) {
|
||||
angle -= (float)std::numbers::pi;
|
||||
} else if (angle <= -std::numbers::pi/2 + std::numbers::pi/12) {
|
||||
angle += (float)std::numbers::pi;
|
||||
}
|
||||
|
||||
textOffset = pos;
|
||||
@@ -1401,7 +1411,7 @@ void SoDatumLabel::drawRadiusOrDiameter(const SbVec3f* points, float& angle, SbV
|
||||
float startangle = this->param3.getValue();
|
||||
float range = this->param4.getValue();
|
||||
if (range != 0.0) {
|
||||
int countSegments = std::max(6, abs(int(50.0 * range / (2 * M_PI))));
|
||||
int countSegments = std::max(6, abs(int(50.0 * range / (2 * std::numbers::pi))));
|
||||
double segment = range / (countSegments - 1);
|
||||
|
||||
glBegin(GL_LINE_STRIP);
|
||||
@@ -1521,6 +1531,8 @@ void SoDatumLabel::drawSymmetric(const SbVec3f* points)
|
||||
|
||||
void SoDatumLabel::drawArcLength(const SbVec3f* points, float& angle, SbVec3f& textOffset)
|
||||
{
|
||||
using std::numbers::pi;
|
||||
|
||||
SbVec3f ctr = points[0];
|
||||
SbVec3f p1 = points[1];
|
||||
SbVec3f p2 = points[2];
|
||||
@@ -1535,7 +1547,7 @@ void SoDatumLabel::drawArcLength(const SbVec3f* points, float& angle, SbVec3f& t
|
||||
float startangle = atan2f(vc1[1], vc1[0]);
|
||||
float endangle = atan2f(vc2[1], vc2[0]);
|
||||
if (endangle < startangle) {
|
||||
endangle += 2.0F * (float)M_PI;
|
||||
endangle += 2.0F * (float)pi;
|
||||
}
|
||||
|
||||
float range = endangle - startangle;
|
||||
@@ -1547,10 +1559,10 @@ void SoDatumLabel::drawArcLength(const SbVec3f* points, float& angle, SbVec3f& t
|
||||
dir.normalize();
|
||||
// Get magnitude of angle between horizontal
|
||||
angle = atan2f(dir[1],dir[0]);
|
||||
if (angle > M_PI_2+M_PI/12) {
|
||||
angle -= (float)M_PI;
|
||||
} else if (angle <= -M_PI_2+M_PI/12) {
|
||||
angle += (float)M_PI;
|
||||
if (angle > pi/2 + pi/12) {
|
||||
angle -= (float)pi;
|
||||
} else if (angle <= -pi/2 + pi/12) {
|
||||
angle += (float)pi;
|
||||
}
|
||||
// Text location
|
||||
textOffset = getLabelTextCenterArcLength(ctr, p1, p2);
|
||||
@@ -1566,7 +1578,7 @@ void SoDatumLabel::drawArcLength(const SbVec3f* points, float& angle, SbVec3f& t
|
||||
SbVec3f pnt4 = p2 + (length-radius) * vm;
|
||||
|
||||
// Draw arc
|
||||
if (range <= M_PI) {
|
||||
if (range <= pi) {
|
||||
glDrawArc(ctr + (length-radius)*vm, radius, startangle, endangle);
|
||||
}
|
||||
else {
|
||||
@@ -1606,7 +1618,7 @@ void SoDatumLabel::drawText(SoState *state, int srcw, int srch, float angle, con
|
||||
const SbViewVolume & vv = SoViewVolumeElement::get(state);
|
||||
SbVec3f z = vv.zVector();
|
||||
|
||||
bool flip = norm.getValue().dot(z) > FLT_EPSILON;
|
||||
bool flip = norm.getValue().dot(z) > std::numeric_limits<float>::epsilon();
|
||||
|
||||
static bool init = false;
|
||||
static bool npot = false;
|
||||
@@ -1678,7 +1690,7 @@ void SoDatumLabel::drawText(SoState *state, int srcw, int srch, float angle, con
|
||||
|
||||
// Apply a rotation and translation matrix
|
||||
glTranslatef(textOffset[0], textOffset[1], textOffset[2]);
|
||||
glRotatef((GLfloat) angle * 180 / M_PI, 0,0,1);
|
||||
glRotatef((GLfloat) angle * 180 / std::numbers::pi, 0,0,1);
|
||||
glBegin(GL_QUADS);
|
||||
|
||||
glColor3f(1.F, 1.F, 1.F);
|
||||
|
||||
@@ -23,6 +23,7 @@
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
#include <cassert>
|
||||
#include <numbers>
|
||||
|
||||
#include <Inventor/SbRotation.h>
|
||||
#include <Inventor/actions/SoGLRenderAction.h>
|
||||
@@ -743,7 +744,7 @@ RDragger::RDragger()
|
||||
}
|
||||
|
||||
SO_KIT_ADD_FIELD(rotation, (SbVec3f(0.0, 0.0, 1.0), 0.0));
|
||||
SO_KIT_ADD_FIELD(rotationIncrement, (M_PI / 8.0));
|
||||
SO_KIT_ADD_FIELD(rotationIncrement, (std::numbers::pi / 8.0));
|
||||
SO_KIT_ADD_FIELD(rotationIncrementCount, (0));
|
||||
|
||||
SO_KIT_INIT_INSTANCE();
|
||||
@@ -808,7 +809,7 @@ SoGroup* RDragger::buildGeometry()
|
||||
|
||||
unsigned int segments = 15;
|
||||
|
||||
float angleIncrement = static_cast<float>(M_PI / 2.0) / static_cast<float>(segments);
|
||||
float angleIncrement = (std::numbers::pi_v<float> / 2.f) / static_cast<float>(segments);
|
||||
SbRotation rotation(SbVec3f(0.0, 0.0, 1.0), angleIncrement);
|
||||
SbVec3f point(arcRadius, 0.0, 0.0);
|
||||
for (unsigned int index = 0; index <= segments; ++index) {
|
||||
@@ -965,9 +966,10 @@ void RDragger::drag()
|
||||
appendRotation(getStartMotionMatrix(), localRotation, SbVec3f(0.0, 0.0, 0.0)));
|
||||
}
|
||||
|
||||
Base::Quantity quantity(static_cast<double>(rotationIncrementCount.getValue()) * (180.0 / M_PI)
|
||||
* rotationIncrement.getValue(),
|
||||
Base::Unit::Angle);
|
||||
Base::Quantity quantity(
|
||||
static_cast<double>(rotationIncrementCount.getValue())
|
||||
* (180.0 / std::numbers::pi)* rotationIncrement.getValue(),
|
||||
Base::Unit::Angle);
|
||||
|
||||
QString message =
|
||||
QStringLiteral("%1 %2").arg(QObject::tr("Rotation:"), QString::fromStdString(quantity.getUserString()));
|
||||
@@ -1179,7 +1181,7 @@ SoFCCSysDragger::SoFCCSysDragger()
|
||||
SO_KIT_ADD_FIELD(translationIncrementCountZ, (0));
|
||||
|
||||
SO_KIT_ADD_FIELD(rotation, (SbVec3f(0.0, 0.0, 1.0), 0.0));
|
||||
SO_KIT_ADD_FIELD(rotationIncrement, (M_PI / 8.0));
|
||||
SO_KIT_ADD_FIELD(rotationIncrement, (std::numbers::pi / 8.0));
|
||||
SO_KIT_ADD_FIELD(rotationIncrementCountX, (0));
|
||||
SO_KIT_ADD_FIELD(rotationIncrementCountY, (0));
|
||||
SO_KIT_ADD_FIELD(rotationIncrementCountZ, (0));
|
||||
@@ -1272,7 +1274,7 @@ SoFCCSysDragger::SoFCCSysDragger()
|
||||
|
||||
SoRotation* localRotation;
|
||||
SbRotation tempRotation;
|
||||
auto angle = static_cast<float>(M_PI / 2.0);
|
||||
auto angle = static_cast<float>(std::numbers::pi / 2.0);
|
||||
// Translator
|
||||
localRotation = SO_GET_ANY_PART(this, "xTranslatorRotation", SoRotation);
|
||||
localRotation->rotation.setValue(SbVec3f(0.0, 0.0, -1.0), angle);
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
# else
|
||||
# include <GL/gl.h>
|
||||
# endif
|
||||
# include <cfloat>
|
||||
# include <QFontMetrics>
|
||||
# include <QPainter>
|
||||
# include <QPen>
|
||||
|
||||
@@ -22,6 +22,8 @@
|
||||
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#include <numbers>
|
||||
|
||||
#include <QApplication>
|
||||
#include <QGestureEvent>
|
||||
#include <QWidget>
|
||||
@@ -86,8 +88,8 @@ SoGesturePinchEvent::SoGesturePinchEvent(QPinchGesture* qpinch, QWidget *widget)
|
||||
deltaZoom = qpinch->scaleFactor();
|
||||
totalZoom = qpinch->totalScaleFactor();
|
||||
|
||||
deltaAngle = -unbranchAngle((qpinch->rotationAngle()-qpinch->lastRotationAngle()) / 180.0 * M_PI);
|
||||
totalAngle = -qpinch->totalRotationAngle() / 180 * M_PI;
|
||||
deltaAngle = -unbranchAngle((qpinch->rotationAngle()-qpinch->lastRotationAngle()) / 180.0 * std::numbers::pi);
|
||||
totalAngle = -qpinch->totalRotationAngle() / 180 * std::numbers::pi;
|
||||
|
||||
state = SbGestureState(qpinch->state());
|
||||
|
||||
@@ -111,7 +113,9 @@ SbBool SoGesturePinchEvent::isSoGesturePinchEvent(const SoEvent *ev) const
|
||||
*/
|
||||
double SoGesturePinchEvent::unbranchAngle(double ang)
|
||||
{
|
||||
return ang - 2.0 * M_PI * floor((ang + M_PI) / (2.0 * M_PI));
|
||||
using std::numbers::pi;
|
||||
|
||||
return ang - 2.0 * pi * floor((ang + pi) / (2.0 * pi));
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -238,7 +238,7 @@ UnsignedValidator::UnsignedValidator( QObject * parent )
|
||||
: QValidator( parent )
|
||||
{
|
||||
b = 0;
|
||||
t = UINT_MAX;
|
||||
t = std::numeric_limits<unsigned>::max();
|
||||
}
|
||||
|
||||
UnsignedValidator::UnsignedValidator( uint minimum, uint maximum, QObject * parent )
|
||||
@@ -295,27 +295,31 @@ public:
|
||||
uint mapToUInt( int v ) const
|
||||
{
|
||||
uint ui;
|
||||
if ( v == INT_MIN ) {
|
||||
if ( v == std::numeric_limits<int>::min() ) {
|
||||
ui = 0;
|
||||
} else if ( v == INT_MAX ) {
|
||||
ui = UINT_MAX;
|
||||
} else if ( v == std::numeric_limits<int>::max() ) {
|
||||
ui = std::numeric_limits<unsigned>::max();
|
||||
} else if ( v < 0 ) {
|
||||
v -= INT_MIN; ui = (uint)v;
|
||||
v -= std::numeric_limits<int>::min();
|
||||
ui = static_cast<uint>(v);
|
||||
} else {
|
||||
ui = (uint)v; ui -= INT_MIN;
|
||||
ui = static_cast<uint>(v);
|
||||
ui -= std::numeric_limits<int>::min();
|
||||
} return ui;
|
||||
}
|
||||
int mapToInt( uint v ) const
|
||||
{
|
||||
int in;
|
||||
if ( v == UINT_MAX ) {
|
||||
in = INT_MAX;
|
||||
if ( v == std::numeric_limits<unsigned>::max() ) {
|
||||
in = std::numeric_limits<int>::max();
|
||||
} else if ( v == 0 ) {
|
||||
in = INT_MIN;
|
||||
} else if ( v > INT_MAX ) {
|
||||
v += INT_MIN; in = (int)v;
|
||||
in = std::numeric_limits<int>::min();
|
||||
} else if ( v > std::numeric_limits<int>::max() ) {
|
||||
v += std::numeric_limits<int>::min();
|
||||
in = static_cast<int>(v);
|
||||
} else {
|
||||
in = v; in += INT_MIN;
|
||||
in = v;
|
||||
in += std::numeric_limits<int>::min();
|
||||
} return in;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -378,6 +378,7 @@ Base::Vector3d Transform::getDirection() const
|
||||
|
||||
Base::Placement Transform::getPlacementData() const
|
||||
{
|
||||
using std::numbers::pi;
|
||||
int index = ui->rotationInput->currentIndex();
|
||||
Base::Rotation rot;
|
||||
Base::Vector3d pos;
|
||||
@@ -388,7 +389,7 @@ Base::Placement Transform::getPlacementData() const
|
||||
|
||||
if (index == 0) {
|
||||
Base::Vector3d dir = getDirection();
|
||||
rot.setValue(Base::Vector3d(dir.x,dir.y,dir.z),ui->angle->value().getValue()*D_PI/180.0);
|
||||
rot.setValue(Base::Vector3d(dir.x,dir.y,dir.z),ui->angle->value().getValue()*pi/180.0);
|
||||
}
|
||||
else if (index == 1) {
|
||||
rot.setYawPitchRoll(
|
||||
|
||||
@@ -255,8 +255,8 @@ QWidget *VectorTableDelegate::createEditor(QWidget *parent, const QStyleOptionVi
|
||||
{
|
||||
auto editor = new QDoubleSpinBox(parent);
|
||||
editor->setDecimals(decimals);
|
||||
editor->setMinimum(INT_MIN);
|
||||
editor->setMaximum(INT_MAX);
|
||||
editor->setMinimum(std::numeric_limits<int>::min());
|
||||
editor->setMaximum(std::numeric_limits<int>::max());
|
||||
editor->setSingleStep(0.1);
|
||||
|
||||
return editor;
|
||||
@@ -299,11 +299,14 @@ VectorListEditor::VectorListEditor(int decimals, QWidget* parent)
|
||||
ui->tableWidget->setModel(model);
|
||||
ui->widget->hide();
|
||||
|
||||
ui->coordX->setRange(INT_MIN, INT_MAX);
|
||||
ui->coordX->setRange(std::numeric_limits<int>::min(),
|
||||
std::numeric_limits<int>::max());
|
||||
ui->coordX->setDecimals(decimals);
|
||||
ui->coordY->setRange(INT_MIN, INT_MAX);
|
||||
ui->coordY->setRange(std::numeric_limits<int>::min(),
|
||||
std::numeric_limits<int>::max());
|
||||
ui->coordY->setDecimals(decimals);
|
||||
ui->coordZ->setRange(INT_MIN, INT_MAX);
|
||||
ui->coordZ->setRange(std::numeric_limits<int>::min(),
|
||||
std::numeric_limits<int>::max());
|
||||
ui->coordZ->setDecimals(decimals);
|
||||
|
||||
ui->toolButtonMouse->setDisabled(true);
|
||||
|
||||
@@ -43,7 +43,7 @@ View3DInventorRiftViewer::View3DInventorRiftViewer() : CoinRiftWidget()
|
||||
|
||||
rotation1 = new SoRotationXYZ ;
|
||||
rotation1->axis.setValue(SoRotationXYZ::X);
|
||||
rotation1->angle.setValue(-M_PI/2);
|
||||
rotation1->angle.setValue(-std::numbers::pi/2);
|
||||
workplace->addChild(rotation1);
|
||||
|
||||
rotation2 = new SoRotationXYZ ;
|
||||
@@ -104,7 +104,7 @@ void View3DInventorRiftViewer::setSceneGraph(SoNode *sceneGraph)
|
||||
void View3DInventorRiftViewer::keyPressEvent(QKeyEvent *event)
|
||||
{
|
||||
static const float increment = 0.02; // move two centimeter per key
|
||||
static const float rotIncrement = M_PI/4; // move two 90° per key
|
||||
static const float rotIncrement = std::numbers::pi / 4; // move two 90° per key
|
||||
|
||||
|
||||
if (event->key() == Qt::Key_Plus) {
|
||||
|
||||
@@ -23,7 +23,6 @@
|
||||
#include "PreCompiled.h"
|
||||
|
||||
#ifndef _PreComp_
|
||||
# include <cfloat>
|
||||
# ifdef FC_OS_WIN32
|
||||
# include <windows.h>
|
||||
# endif
|
||||
@@ -3267,7 +3266,7 @@ void View3DInventorViewer::setCameraType(SoType type)
|
||||
// heightAngle. Setting it to 45 deg also causes an issue with a too
|
||||
// close camera but we don't have this other ugly effect.
|
||||
|
||||
static_cast<SoPerspectiveCamera*>(cam)->heightAngle = (float)(M_PI / 4.0); // NOLINT
|
||||
static_cast<SoPerspectiveCamera*>(cam)->heightAngle = (float)(std::numbers::pi / 4.0); // NOLINT
|
||||
}
|
||||
|
||||
lightRotation->rotation.connectFrom(&cam->orientation);
|
||||
@@ -3426,7 +3425,7 @@ void View3DInventorViewer::viewAll()
|
||||
SoCamera* cam = this->getSoRenderManager()->getCamera();
|
||||
|
||||
if (cam && cam->getTypeId().isDerivedFrom(SoPerspectiveCamera::getClassTypeId())) {
|
||||
static_cast<SoPerspectiveCamera*>(cam)->heightAngle = (float)(M_PI / 4.0); // NOLINT
|
||||
static_cast<SoPerspectiveCamera*>(cam)->heightAngle = (float)(std::numbers::pi / 4.0); // NOLINT
|
||||
}
|
||||
|
||||
if (isAnimationEnabled()) {
|
||||
@@ -3632,26 +3631,28 @@ void View3DInventorViewer::alignToSelection()
|
||||
angle *= -1;
|
||||
}
|
||||
|
||||
using std::numbers::pi;
|
||||
|
||||
// Make angle positive
|
||||
if (angle < 0) {
|
||||
angle += 2 * M_PI;
|
||||
angle += 2 * pi;
|
||||
}
|
||||
|
||||
// Find the angle to rotate to the nearest horizontal or vertical alignment with directionX.
|
||||
// f is a small value used to get more deterministic behavior when the camera is at directionX +- 45 degrees.
|
||||
const float f = 0.00001F;
|
||||
|
||||
if (angle <= M_PI_4 + f) {
|
||||
if (angle <= pi/4 + f) {
|
||||
angle = 0;
|
||||
}
|
||||
else if (angle <= 3 * M_PI_4 + f) {
|
||||
angle = M_PI_2;
|
||||
else if (angle <= 3 * pi/4 + f) {
|
||||
angle = pi/2;
|
||||
}
|
||||
else if (angle < M_PI + M_PI_4 - f) {
|
||||
angle = M_PI;
|
||||
else if (angle < pi + pi/4 - f) {
|
||||
angle = pi;
|
||||
}
|
||||
else if (angle < M_PI + 3 * M_PI_4 - f) {
|
||||
angle = M_PI + M_PI_2;
|
||||
else if (angle < pi + 3 * pi/4 - f) {
|
||||
angle = pi + pi/2;
|
||||
}
|
||||
else {
|
||||
angle = 0;
|
||||
@@ -3960,7 +3961,7 @@ void View3DInventorViewer::drawAxisCross()
|
||||
|
||||
const float NEARVAL = 0.1F;
|
||||
const float FARVAL = 10.0F;
|
||||
const float dim = NEARVAL * float(tan(M_PI / 8.0)); // FOV is 45 deg (45/360 = 1/8)
|
||||
const float dim = NEARVAL * float(tan(std::numbers::pi / 8.0)); // FOV is 45 deg (45/360 = 1/8)
|
||||
glFrustum(-dim, dim, -dim, dim, NEARVAL, FARVAL);
|
||||
|
||||
|
||||
|
||||
@@ -658,7 +658,7 @@ Py::Object View3DInventorPy::viewRotateLeft()
|
||||
SbRotation rot = cam->orientation.getValue();
|
||||
SbVec3f vdir(0, 0, -1);
|
||||
rot.multVec(vdir, vdir);
|
||||
SbRotation nrot(vdir, (float)M_PI/2);
|
||||
SbRotation nrot(vdir, (float)std::numbers::pi/2);
|
||||
cam->orientation.setValue(rot*nrot);
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
@@ -681,7 +681,7 @@ Py::Object View3DInventorPy::viewRotateRight()
|
||||
SbRotation rot = cam->orientation.getValue();
|
||||
SbVec3f vdir(0, 0, -1);
|
||||
rot.multVec(vdir, vdir);
|
||||
SbRotation nrot(vdir, (float)-M_PI/2);
|
||||
SbRotation nrot(vdir, (float)-std::numbers::pi/2);
|
||||
cam->orientation.setValue(rot*nrot);
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
|
||||
@@ -155,7 +155,7 @@ void ViewProviderAnnotation::onChanged(const App::Property* prop)
|
||||
}
|
||||
}
|
||||
else if (prop == &Rotation) {
|
||||
pRotationXYZ->angle = (Rotation.getValue()/360)*(2*M_PI);
|
||||
pRotationXYZ->angle = (Rotation.getValue()/360)*(2*std::numbers::pi);
|
||||
}
|
||||
else {
|
||||
ViewProviderDocumentObject::onChanged(prop);
|
||||
|
||||
@@ -968,7 +968,8 @@ QWidget* PropertyIntegerItem::createEditor(QWidget* parent,
|
||||
void PropertyIntegerItem::setEditorData(QWidget* editor, const QVariant& data) const
|
||||
{
|
||||
auto sb = qobject_cast<QSpinBox*>(editor);
|
||||
sb->setRange(INT_MIN, INT_MAX);
|
||||
sb->setRange(std::numeric_limits<int>::min(),
|
||||
std::numeric_limits<int>::max());
|
||||
sb->setValue(data.toInt());
|
||||
}
|
||||
|
||||
@@ -1128,7 +1129,8 @@ QWidget* PropertyFloatItem::createEditor(QWidget* parent, const std::function<vo
|
||||
void PropertyFloatItem::setEditorData(QWidget* editor, const QVariant& data) const
|
||||
{
|
||||
auto sb = qobject_cast<QDoubleSpinBox*>(editor);
|
||||
sb->setRange((double)INT_MIN, (double)INT_MAX);
|
||||
sb->setRange(static_cast<double>(std::numeric_limits<int>::min()),
|
||||
static_cast<double>(std::numeric_limits<int>::max()));
|
||||
sb->setValue(data.toDouble());
|
||||
}
|
||||
|
||||
|
||||
@@ -360,8 +360,8 @@ protected:
|
||||
PropertyIntegerConstraintItem();
|
||||
|
||||
private:
|
||||
int min = INT_MIN;
|
||||
int max = INT_MAX;
|
||||
int min = std::numeric_limits<int>::min();
|
||||
int max = std::numeric_limits<int>::max();
|
||||
int steps = 1;
|
||||
};
|
||||
|
||||
@@ -434,8 +434,8 @@ protected:
|
||||
PropertyUnitConstraintItem();
|
||||
|
||||
private:
|
||||
double min = double(INT_MIN);
|
||||
double max = double(INT_MAX);
|
||||
double min = static_cast<double>(std::numeric_limits<int>::min());
|
||||
double max = static_cast<double>(std::numeric_limits<int>::max());
|
||||
double steps = 0.1;
|
||||
};
|
||||
|
||||
@@ -472,8 +472,8 @@ protected:
|
||||
PropertyFloatConstraintItem();
|
||||
|
||||
private:
|
||||
double min = double(INT_MIN);
|
||||
double max = double(INT_MAX);
|
||||
double min = static_cast<double>(std::numeric_limits<int>::min());
|
||||
double max = static_cast<double>(std::numeric_limits<int>::max());
|
||||
double steps = 0.1;
|
||||
};
|
||||
|
||||
|
||||
@@ -96,7 +96,7 @@ bool PropertyModel::setData(const QModelIndex& index, const QVariant& value, int
|
||||
// now?
|
||||
double d = data.toDouble();
|
||||
double v = value.toDouble();
|
||||
if (fabs(d - v) > DBL_EPSILON) {
|
||||
if (fabs(d - v) > std::numeric_limits<double>::epsilon()) {
|
||||
return item->setData(value);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user