MSVC: fix several compiler warnings

This commit is contained in:
wmayer
2023-09-12 15:46:57 +02:00
committed by wwmayer
parent d793d1c177
commit d9d7bf87ae
11 changed files with 76 additions and 45 deletions

View File

@@ -32,6 +32,7 @@
# else
# include <GL/gl.h>
# endif
# include <boost/math/constants/constants.hpp>
# include <Inventor/nodes/SoOrthographicCamera.h>
# include <Inventor/events/SoEvent.h>
# include <Inventor/events/SoLocation2Event.h>
@@ -170,8 +171,8 @@ public:
double m_BorderWidth = 1.1;
bool m_RotateToNearest = true;
int m_NaviStepByTurn = 8;
float m_FontZoom = 0.3;
float m_Chamfer = 0.12;
float m_FontZoom = 0.3F;
float m_Chamfer = 0.12F;
std::string m_TextFont;
int m_FontWeight = 0;
int m_FontStretch = 0;
@@ -463,9 +464,9 @@ void NaviCubeImplementation::addButtonFace(PickId pickId, const SbVec3f& directi
{
if (m_Faces[pickId].vertexArray.size())
m_Faces[pickId].vertexArray.clear();
float scale = 0.005;
float offx = 0.5;
float offy = 0.5;
float scale = 0.005F;
float offx = 0.5F;
float offy = 0.5F;
vector<float> pointData;
switch (pickId) {
@@ -474,19 +475,19 @@ void NaviCubeImplementation::addButtonFace(PickId pickId, const SbVec3f& directi
case PickId::ArrowRight:
case PickId::ArrowLeft: {
pointData = {
66.6, -66.6,//outer curve
58.3, -74.0,
49.2 ,-80.3,
39.4 ,-85.5,
29. , -89.5,
25.3, -78.1,//inner curve
34.3, -74.3,
42.8, -69.9,
50.8, -64.4,
58.1, -58.1,
53.8, -53.8,//arrowhead
74.7, -46.8,
70.7, -70.4
66.6F, -66.6F,//outer curve
58.3F, -74.0F,
49.2F ,-80.3F,
39.4F ,-85.5F,
29.0F, -89.5F,
25.3F, -78.1F,//inner curve
34.3F, -74.3F,
42.8F, -69.9F,
50.8F, -64.4F,
58.1F, -58.1F,
53.8F, -53.8F,//arrowhead
74.7F, -46.8F,
70.7F, -70.4F
};
break;
}
@@ -502,8 +503,8 @@ void NaviCubeImplementation::addButtonFace(PickId pickId, const SbVec3f& directi
break;
}
case PickId::ViewMenu: {
offx = 0.84;
offy = 0.84;
offx = 0.84F;
offy = 0.84F;
pointData = {
0., 0.,//top rhombus
15., -6.,
@@ -627,7 +628,11 @@ void NaviCubeImplementation::setSize(int size)
m_Prepared = false;
}
void NaviCubeImplementation::prepare() {
void NaviCubeImplementation::prepare()
{
static const float pi = boost::math::constants::pi<float>();
static const float pi1_2 = boost::math::constants::half_pi<float>();
createCubeFaceTextures();
Vector3f x(1, 0, 0);
@@ -643,28 +648,28 @@ void NaviCubeImplementation::prepare() {
addCubeFace( x,-z, ShapeId::Main, PickId::Bottom);
// create corner faces
addCubeFace(-x-y, x-y+z, ShapeId::Corner, PickId::FrontTopRight, M_PI);
addCubeFace(-x+y,-x-y+z, ShapeId::Corner, PickId::FrontTopLeft, M_PI);
addCubeFace(-x-y, x-y+z, ShapeId::Corner, PickId::FrontTopRight, pi);
addCubeFace(-x+y,-x-y+z, ShapeId::Corner, PickId::FrontTopLeft, pi);
addCubeFace(x+y, x-y-z, ShapeId::Corner, PickId::FrontBottomRight);
addCubeFace(x-y,-x-y-z, ShapeId::Corner, PickId::FrontBottomLeft);
addCubeFace(x-y, x+y+z, ShapeId::Corner, PickId::RearTopRight, M_PI);
addCubeFace(x+y,-x+y+z, ShapeId::Corner, PickId::RearTopLeft, M_PI);
addCubeFace(x-y, x+y+z, ShapeId::Corner, PickId::RearTopRight, pi);
addCubeFace(x+y,-x+y+z, ShapeId::Corner, PickId::RearTopLeft, pi);
addCubeFace(-x+y, x+y-z, ShapeId::Corner, PickId::RearBottomRight);
addCubeFace(-x-y,-x+y-z, ShapeId::Corner, PickId::RearBottomLeft);
// create edge faces
addCubeFace(x, z-y, ShapeId::Edge, PickId::FrontTop);
addCubeFace(x,-z-y, ShapeId::Edge, PickId::FrontBottom);
addCubeFace(x, y-z, ShapeId::Edge, PickId::RearBottom, M_PI);
addCubeFace(x, y+z, ShapeId::Edge, PickId::RearTop, M_PI);
addCubeFace(z, x+y, ShapeId::Edge, PickId::RearRight, M_PI_2);
addCubeFace(z, x-y, ShapeId::Edge, PickId::FrontRight, M_PI_2);
addCubeFace(z,-x-y, ShapeId::Edge, PickId::FrontLeft, M_PI_2);
addCubeFace(z, y-x, ShapeId::Edge, PickId::RearLeft, M_PI_2);
addCubeFace(y, z-x, ShapeId::Edge, PickId::TopLeft, M_PI);
addCubeFace(x, y-z, ShapeId::Edge, PickId::RearBottom, pi);
addCubeFace(x, y+z, ShapeId::Edge, PickId::RearTop, pi);
addCubeFace(z, x+y, ShapeId::Edge, PickId::RearRight, pi1_2);
addCubeFace(z, x-y, ShapeId::Edge, PickId::FrontRight, pi1_2);
addCubeFace(z,-x-y, ShapeId::Edge, PickId::FrontLeft, pi1_2);
addCubeFace(z, y-x, ShapeId::Edge, PickId::RearLeft, pi1_2);
addCubeFace(y, z-x, ShapeId::Edge, PickId::TopLeft, pi);
addCubeFace(y, x+z, ShapeId::Edge, PickId::TopRight);
addCubeFace(y, x-z, ShapeId::Edge, PickId::BottomRight);
addCubeFace(y,-z-x, ShapeId::Edge, PickId::BottomLeft, M_PI);
addCubeFace(y,-z-x, ShapeId::Edge, PickId::BottomLeft, pi);
// create the flat buttons
addButtonFace(PickId::ArrowNorth, SbVec3f(-1, 0, 0));
@@ -785,7 +790,7 @@ void NaviCubeImplementation::drawNaviCube(bool pickMode)
SbMatrix mx;
mx = cam->orientation.getValue();
mx = mx.inverse();
mx[3][2] = -5.1;
mx[3][2] = -5.1F;
glLoadMatrixf((float*)mx);
glEnableClientState(GL_VERTEX_ARRAY);
@@ -974,7 +979,10 @@ SbRotation NaviCubeImplementation::getNearestOrientation(PickId pickId) {
return intermediateOrientation * rotation;
}
bool NaviCubeImplementation::mouseReleased(short x, short y) {
bool NaviCubeImplementation::mouseReleased(short x, short y)
{
static const float pi = boost::math::constants::pi<float>();
setHilite(PickId::None);
m_MouseDown = false;
@@ -1007,7 +1015,7 @@ bool NaviCubeImplementation::mouseReleased(short x, short y) {
// Handle the flat buttons
SbRotation rotation = m_Faces[pickId].rotation;
if (pickId == PickId::DotBackside) {
rotation.scaleAngle(M_PI);
rotation.scaleAngle(pi);
}
else {
rotation.scaleAngle(rotStepAngle);

View File

@@ -89,6 +89,7 @@
#include <boost/filesystem/path.hpp>
#include <boost/filesystem/operations.hpp>
#include <boost/interprocess/sync/file_lock.hpp>
#include <boost/math/constants/constants.hpp>
#include <boost/program_options.hpp>
#include <boost/utility.hpp>

View File

@@ -20,6 +20,7 @@
* *
***************************************************************************/
#include "PreCompiled.h"
#include <App/DocumentObjectPy.h>
#include "SelectionFilterPy.h"

View File

@@ -24,6 +24,7 @@
#ifndef _PreComp_
#include <array>
#include <boost/math/constants/constants.hpp>
#ifdef FC_OS_WIN32
#define _USE_MATH_DEFINES
#endif
@@ -38,14 +39,18 @@
#include "SoFCBackgroundGradient.h"
static const std::array <GLfloat[2], 32> big_circle = []{
static const float pi2 = boost::math::constants::two_pi<float>();
std::array <GLfloat[2], 32> result; int c = 0;
for (GLfloat i = 0; i < 2*M_PI; i += 2*M_PI / 32, c++){
result[c][0] = M_SQRT2*cosf(i); result[c][1] = M_SQRT2*sinf(i); }
for (GLfloat i = 0; i < pi2; i += pi2 / 32, c++) {
result[c][0] = M_SQRT2*cosf(i); result[c][1] = M_SQRT2*sinf(i);
}
return result; }();
static const std::array <GLfloat[2], 32> small_oval = []{
static const float pi2 = boost::math::constants::two_pi<float>();
std::array <GLfloat[2], 32> result; int c = 0;
for (GLfloat i = 0; i < 2*M_PI; i += 2*M_PI / 32, c++){
result[c][0] = 0.3*M_SQRT2*cosf(i); result[c][1] = M_SQRT1_2*sinf(i); }
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);
}
return result; }();
using namespace Gui;

View File

@@ -1564,7 +1564,7 @@ void ExpLineEdit::setExpression(std::shared_ptr<Expression> expr)
try {
ExpressionBinding::setExpression(expr);
}
catch (const Base::Exception & e) {
catch (const Base::Exception&) {
setReadOnly(true);
QPalette p(palette());
p.setColor(QPalette::Active, QPalette::Text, Qt::red);
@@ -1631,7 +1631,7 @@ void ExpLineEdit::resizeEvent(QResizeEvent * event)
iconLabel->setExpressionText(QString());
}
}
catch (const Base::Exception & e) {
catch (const Base::Exception&) {
setReadOnly(true);
QPalette p(palette());
p.setColor(QPalette::Active, QPalette::Text, Qt::red);

View File

@@ -154,7 +154,7 @@
<number>0</number>
</property>
<item>
<widget class="QLabel" name="label">
<widget class="QLabel" name="label2">
<property name="text">
<string>Offset</string>
</property>
@@ -185,7 +185,7 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<item>
<widget class="QLabel" name="label">
<widget class="QLabel" name="label3">
<property name="text">
<string>Occurrences</string>
</property>

View File

@@ -25,6 +25,10 @@
#include <FCConfig.h>
#ifdef _MSC_VER
#pragma warning(disable : 4251)
#endif
#ifdef _PreComp_
// standard

View File

@@ -21,6 +21,7 @@
***************************************************************************/
#ifdef _MSC_VER
#pragma warning(disable : 4251)
#pragma warning(disable : 4244)
#pragma warning(disable : 4996)
#endif

View File

@@ -614,7 +614,7 @@ bool addConstraintSafely(SketchObject* obj, std::function<void()> constraintaddi
tryAutoRecompute(obj);
return false;
}
catch (const Base::Exception& e) {
catch (const Base::Exception&) {
Gui::TranslatedUserError(
obj,
QObject::tr("Error"),

View File

@@ -1,4 +1,11 @@
#include "gtest/gtest.h"
#ifdef WIN32
#define WIN32_LEAN_AND_MEAN
#ifndef NOMINMAX
#define NOMINMAX
#endif
#include <Windows.h>
#endif
#include <Base/BoundBox.h>
#include <boost/beast/core/span.hpp>

View File

@@ -2,6 +2,10 @@
#include "gtest/gtest.h"
#ifdef _MSC_VER
#pragma warning(disable : 4996)
#endif
#include "Base/Exception.h"
#include "Base/Reader.h"
#include <array>