From 68889f05ec7c6fd7d242b718b58197db88a84af6 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 23 May 2024 08:51:22 +0200 Subject: [PATCH] PathSimulator: Fix many compiler warnings --- src/Mod/CAM/PathSimulator/AppGL/CAMSimPy.xml | 2 +- .../CAM/PathSimulator/AppGL/CAMSimPyImp.cpp | 2 +- .../PathSimulator/AppGL/DlgCAMSimulator.cpp | 9 ++++-- src/Mod/CAM/PathSimulator/AppGL/EndMill.cpp | 8 ++--- .../CAM/PathSimulator/AppGL/GCodeParser.cpp | 2 +- src/Mod/CAM/PathSimulator/AppGL/GCodeParser.h | 4 +-- .../CAM/PathSimulator/AppGL/GuiDisplay.cpp | 32 ++++++++++--------- .../PathSimulator/AppGL/MillPathSegment.cpp | 23 +++---------- .../PathSimulator/AppGL/MillSimulation.cpp | 15 +++++---- .../CAM/PathSimulator/AppGL/MillSimulation.h | 8 ++--- src/Mod/CAM/PathSimulator/AppGL/Shader.cpp | 3 +- .../CAM/PathSimulator/AppGL/TextureLoader.cpp | 3 +- .../CAM/PathSimulator/AppGL/TextureLoader.h | 4 +-- 13 files changed, 56 insertions(+), 59 deletions(-) diff --git a/src/Mod/CAM/PathSimulator/AppGL/CAMSimPy.xml b/src/Mod/CAM/PathSimulator/AppGL/CAMSimPy.xml index 5010204ffe..85f3e3f382 100644 --- a/src/Mod/CAM/PathSimulator/AppGL/CAMSimPy.xml +++ b/src/Mod/CAM/PathSimulator/AppGL/CAMSimPy.xml @@ -30,7 +30,7 @@ - + ResetSimulation(): diff --git a/src/Mod/CAM/PathSimulator/AppGL/CAMSimPyImp.cpp b/src/Mod/CAM/PathSimulator/AppGL/CAMSimPyImp.cpp index 7618fb13b1..5ce3560537 100644 --- a/src/Mod/CAM/PathSimulator/AppGL/CAMSimPyImp.cpp +++ b/src/Mod/CAM/PathSimulator/AppGL/CAMSimPyImp.cpp @@ -55,7 +55,7 @@ int CAMSimPy::PyInit(PyObject* /*args*/, PyObject* /*kwd*/) } -PyObject* CAMSimPy::ResetSimulation(PyObject* args) +PyObject* CAMSimPy::ResetSimulation() { CAMSim* sim = getCAMSimPtr(); sim->resetSimulation(); diff --git a/src/Mod/CAM/PathSimulator/AppGL/DlgCAMSimulator.cpp b/src/Mod/CAM/PathSimulator/AppGL/DlgCAMSimulator.cpp index 4f3f0e2d66..e72654dd87 100644 --- a/src/Mod/CAM/PathSimulator/AppGL/DlgCAMSimulator.cpp +++ b/src/Mod/CAM/PathSimulator/AppGL/DlgCAMSimulator.cpp @@ -119,6 +119,7 @@ void DlgCAMSimulator::addTool(const std::vector toolProfilePoints, float diameter, float resolution) { + Q_UNUSED(resolution) std::string toolCmd = "T" + std::to_string(toolNumber); mMillSimulator->AddGcodeLine(toolCmd.c_str()); if (!mMillSimulator->ToolExists(toolNumber)) { @@ -128,6 +129,7 @@ void DlgCAMSimulator::addTool(const std::vector toolProfilePoints, void DlgCAMSimulator::hideEvent(QHideEvent* ev) { + Q_UNUSED(ev) mAnimating = false; } @@ -194,6 +196,7 @@ void DlgCAMSimulator::renderNow() if (mAnimating) { renderLater(); } + (void)fps; } void DlgCAMSimulator::setAnimating(bool animating) @@ -232,9 +235,11 @@ SimStock::SimStock(float px, float py, float pz, float lx, float ly, float lz, f , mLx(lx) , mLy(ly) , mLz(1.01 * lz) -{} +{ + (void)res; +} SimStock::~SimStock() {} -} // namespace CAMSimulator \ No newline at end of file +} // namespace CAMSimulator diff --git a/src/Mod/CAM/PathSimulator/AppGL/EndMill.cpp b/src/Mod/CAM/PathSimulator/AppGL/EndMill.cpp index ec39d4cbf3..49932830ec 100644 --- a/src/Mod/CAM/PathSimulator/AppGL/EndMill.cpp +++ b/src/Mod/CAM/PathSimulator/AppGL/EndMill.cpp @@ -45,7 +45,7 @@ EndMill::EndMill(const std::vector& toolProfile, int toolid, float diamet } // make sure last point is at 0,0 else, add it - bool missingCenterPoint = fabs(toolProfile[nPoints * 2 - 2]) > 0.0001f; + bool missingCenterPoint = fabs(toolProfile[nPoints * 2 - 2]) > 0.0001F; if (missingCenterPoint) { nPoints++; } @@ -59,10 +59,10 @@ EndMill::EndMill(const std::vector& toolProfile, int toolid, float diamet // copy profile points mHandleAllocation = true; for (int i = 0; i < srcBuffSize; i++) { - profilePoints[i] = toolProfile[i] + 0.01f; // add some width to reduce simulation artifacts + profilePoints[i] = toolProfile[i] + 0.01F; // add some width to reduce simulation artifacts } if (missingCenterPoint) { - profilePoints[srcBuffSize] = profilePoints[srcBuffSize + 1] = 0.0f; + profilePoints[srcBuffSize] = profilePoints[srcBuffSize + 1] = 0.0F; } MirrorPointBuffer(); @@ -105,7 +105,7 @@ EndMill::GenerateArcSegmentDL(float radius, float angleRad, float zShift, Shape* { int nFullPoints = PROFILE_BUFFER_POINTS(nPoints); retShape->ExtrudeProfileRadial(profilePoints, - PROFILE_BUFFER_POINTS(nPoints), + nFullPoints, radius, angleRad, zShift, diff --git a/src/Mod/CAM/PathSimulator/AppGL/GCodeParser.cpp b/src/Mod/CAM/PathSimulator/AppGL/GCodeParser.cpp index 3868147cce..3cb2f78332 100644 --- a/src/Mod/CAM/PathSimulator/AppGL/GCodeParser.cpp +++ b/src/Mod/CAM/PathSimulator/AppGL/GCodeParser.cpp @@ -43,7 +43,7 @@ GCodeParser::~GCodeParser() bool GCodeParser::Parse(const char* filename) { Operations.clear(); - lastState = {eNop, -1, 0, 0, 0, 0, 0, 0}; + lastState = {eNop, -1, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F}; lastTool = -1; FILE* fl; diff --git a/src/Mod/CAM/PathSimulator/AppGL/GCodeParser.h b/src/Mod/CAM/PathSimulator/AppGL/GCodeParser.h index db494fb131..14ab3b04c3 100644 --- a/src/Mod/CAM/PathSimulator/AppGL/GCodeParser.h +++ b/src/Mod/CAM/PathSimulator/AppGL/GCodeParser.h @@ -45,8 +45,8 @@ public: public: std::vector Operations; - MillMotion lastState = {eNop}; - MillMotion lastLastState = {eNop}; + MillMotion lastState = {eNop, 0, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F}; + MillMotion lastLastState = {eNop, 0, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F}; protected: const char* GetNextToken(const char* ptr, GCToken* token); diff --git a/src/Mod/CAM/PathSimulator/AppGL/GuiDisplay.cpp b/src/Mod/CAM/PathSimulator/AppGL/GuiDisplay.cpp index aa730df6bd..6e2cb43ef7 100644 --- a/src/Mod/CAM/PathSimulator/AppGL/GuiDisplay.cpp +++ b/src/Mod/CAM/PathSimulator/AppGL/GuiDisplay.cpp @@ -30,17 +30,17 @@ using namespace MillSim; GuiItem guiItems[] = { - {0, 0, 360, 554, 0}, - {0, 0, 448, 540, 1}, - {0, 0, 170, 540, 'P', true}, - {0, 0, 170, 540, 'S', false}, - {0, 0, 210, 540, 'T'}, - {0, 0, 250, 540, 'F'}, - {0, 0, 290, 540, ' '}, - {0, 0, 620, 540, 0, false, 0}, - {0, 0, 660, 540, 0, false, 0}, - {0, 0, 645, 540, 0, false, 0}, - {0, 0, 640, 540, 0, true, 0}, + {0, 0, 360, 554, 0, false, false, {}}, + {0, 0, 448, 540, 1, false, false, {}}, + {0, 0, 170, 540, 'P', true, false, {}}, + {0, 0, 170, 540, 'S', false, false, {}}, + {0, 0, 210, 540, 'T', false, false, {}}, + {0, 0, 250, 540, 'F', false, false, {}}, + {0, 0, 290, 540, ' ', false, false, {}}, + {0, 0, 620, 540, 0, false, false, {}}, + {0, 0, 660, 540, 0, false, false, {}}, + {0, 0, 645, 540, 0, false, false, {}}, + {0, 0, 640, 540, 0, true, false, {}}, }; #define NUM_GUI_ITEMS (sizeof(guiItems) / sizeof(GuiItem)) @@ -108,7 +108,7 @@ bool GuiDisplay::InutGui() return false; } mTexture.LoadImage(buffer, TEX_SIZE, TEX_SIZE); - for (int i = 0; i < NUM_GUI_ITEMS; i++) { + for (unsigned long i = 0; i < NUM_GUI_ITEMS; i++) { guiItems[i].texItem = *tLoader.GetTextureItem(i); GenerateGlItem(&(guiItems[i])); } @@ -157,7 +157,7 @@ void GuiDisplay::RenderItem(int itemId) void GuiDisplay::MouseCursorPos(int x, int y) { - for (int i = 0; i < NUM_GUI_ITEMS; i++) { + for (unsigned long i = 0; i < NUM_GUI_ITEMS; i++) { GuiItem* g = &(guiItems[i]); if (g->actionKey == 0) { continue; @@ -172,7 +172,7 @@ void GuiDisplay::MousePressed(int button, bool isPressed, bool isSimRunning) if (button == MS_MOUSE_LEFT) { if (isPressed) { mPressedItem = eGuiItemMax; - for (int i = 1; i < NUM_GUI_ITEMS; i++) { + for (unsigned long i = 1; i < NUM_GUI_ITEMS; i++) { GuiItem* g = &(guiItems[i]); if (g->mouseOver && !g->hidden) { mPressedItem = (eGuiItems)i; @@ -196,6 +196,8 @@ void GuiDisplay::MousePressed(int button, bool isPressed, bool isSimRunning) void GuiDisplay::MouseDrag(int buttons, int dx, int dy) { + (void)buttons; + (void)dy; if (mPressedItem == eGuiItemThumb) { GuiItem* g = &(guiItems[eGuiItemThumb]); int newx = g->sx + dx; @@ -237,7 +239,7 @@ void GuiDisplay::Render(float progress) mShader.UpdateTextureSlot(0); glEnable(GL_BLEND); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - for (int i = 0; i < NUM_GUI_ITEMS; i++) { + for (unsigned long i = 0; i < NUM_GUI_ITEMS; i++) { RenderItem(i); } } diff --git a/src/Mod/CAM/PathSimulator/AppGL/MillPathSegment.cpp b/src/Mod/CAM/PathSimulator/AppGL/MillPathSegment.cpp index b1ea18ba4d..fbd126b851 100644 --- a/src/Mod/CAM/PathSimulator/AppGL/MillPathSegment.cpp +++ b/src/Mod/CAM/PathSimulator/AppGL/MillPathSegment.cpp @@ -56,24 +56,11 @@ float MillPathSegment::mResolution = 1; float MillPathSegment::mSmallRadStep = (PI / 8); MillPathSegment::MillPathSegment(EndMill* _endmill, MillMotion* from, MillMotion* to) - : mShearMat {1.0f, - 0.0f, - 0.0f, - 0.0f, - 0.0f, - 1.0f, - 0.0f, - 0.0f, - 0.0f, - 0.0f, - 1.0f, - 0.0f, - 0.0f, - 0.0f, - 0.0f, - 1.0f} + : mShearMat {{1.0F, 0.0F, 0.0F, 0.0F}, + {0.0F, 1.0F, 0.0F, 0.0F}, + {0.0F, 0.0F, 1.0F, 0.0F}, + {0.0F, 0.0F, 0.0F, 1.0F}} { - MotionPosToVec(mStartPos, from); MotionPosToVec(mDiff, to); vec3_sub(mDiff, mDiff, mStartPos); @@ -239,4 +226,4 @@ float MillPathSegment::SetQuality(float quality, float maxStockDimension) } return mResolution; } -} // namespace MillSim \ No newline at end of file +} // namespace MillSim diff --git a/src/Mod/CAM/PathSimulator/AppGL/MillSimulation.cpp b/src/Mod/CAM/PathSimulator/AppGL/MillSimulation.cpp index be822cc28b..16223c2ae1 100644 --- a/src/Mod/CAM/PathSimulator/AppGL/MillSimulation.cpp +++ b/src/Mod/CAM/PathSimulator/AppGL/MillSimulation.cpp @@ -29,7 +29,7 @@ namespace MillSim { MillSimulation::MillSimulation() { - mCurMotion = { eNop, -1, 0, 0, 0, 0, 0, 0 }; + mCurMotion = { eNop, -1, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F }; guiDisplay.SetMillSimulator(this); } @@ -38,16 +38,18 @@ namespace MillSim { // MillSim::MillPathSegment* p = *i; // delete p; //} - for (int i = 0; i < MillPathSegments.size(); i++) + for (std::size_t i = 0; i < MillPathSegments.size(); i++) { delete MillPathSegments[i]; + } MillPathSegments.clear(); } void MillSimulation::Clear() { mCodeParser.Operations.clear(); - for (int i = 0; i < mToolTable.size(); i++) + for (std::size_t i = 0; i < mToolTable.size(); i++) { delete mToolTable[i]; + } mToolTable.clear(); mCurStep = 0; mPathStep = -1; @@ -103,7 +105,7 @@ namespace MillSim { EndMill* MillSimulation::GetTool(int toolId) { - for (int i = 0; i < mToolTable.size(); i++) + for (std::size_t i = 0; i < mToolTable.size(); i++) { if (mToolTable[i]->toolId == toolId) { @@ -495,8 +497,9 @@ namespace MillSim { // setup light object and generate tools mlightObject.GenerateBoxStock(-0.5f, -0.5f, -0.5f, 1, 1, 1); - for (int i = 0; i < mToolTable.size(); i++) + for (std::size_t i = 0; i < mToolTable.size(); i++) { mToolTable[i]->GenerateDisplayLists(quality); + } // init gui elements guiDisplay.InutGui(); @@ -598,4 +601,4 @@ namespace MillSim { CalcSegmentPositions(); } -} \ No newline at end of file +} diff --git a/src/Mod/CAM/PathSimulator/AppGL/MillSimulation.h b/src/Mod/CAM/PathSimulator/AppGL/MillSimulation.h index 2744f97b7f..765ea8add9 100644 --- a/src/Mod/CAM/PathSimulator/AppGL/MillSimulation.h +++ b/src/Mod/CAM/PathSimulator/AppGL/MillSimulation.h @@ -94,9 +94,9 @@ protected: std::vector MillPathSegments; std::ostringstream mFpsStream; - MillMotion mZeroPos = {eNop, -1, 0, 0, 100, 0, 0, 0}; - MillMotion mCurMotion = {eNop, -1, 0, 0, 0, 0, 0, 0}; - MillMotion mDestMotion = {eNop, -1, 0, 0, 0, 0, 0, 0}; + MillMotion mZeroPos = {eNop, -1, 0.0F, 0.0F, 100.0F, 0.0F, 0.0F, 0.0F, 0.0F}; + MillMotion mCurMotion = {eNop, -1, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F}; + MillMotion mDestMotion = {eNop, -1, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0F}; StockObject mStockObject; StockObject mlightObject; @@ -146,4 +146,4 @@ protected: bool mSingleStep = false; }; } // namespace MillSim -#endif \ No newline at end of file +#endif diff --git a/src/Mod/CAM/PathSimulator/AppGL/Shader.cpp b/src/Mod/CAM/PathSimulator/AppGL/Shader.cpp index 8831bd9fe8..ddaa5acc07 100644 --- a/src/Mod/CAM/PathSimulator/AppGL/Shader.cpp +++ b/src/Mod/CAM/PathSimulator/AppGL/Shader.cpp @@ -85,6 +85,7 @@ void Shader::UpdateTextureSlot(int slot) bool CheckCompileResult(int shader) { #ifdef QT_OPENGL_LIB + (void)shader; return false; #else char log[1024]; @@ -269,4 +270,4 @@ const char* FragShaderFlat = " FragColor = vec4(objectColor, 1.0); \n" "} \n"; -} // namespace MillSim \ No newline at end of file +} // namespace MillSim diff --git a/src/Mod/CAM/PathSimulator/AppGL/TextureLoader.cpp b/src/Mod/CAM/PathSimulator/AppGL/TextureLoader.cpp index cdc0b56e6d..c8ece95397 100644 --- a/src/Mod/CAM/PathSimulator/AppGL/TextureLoader.cpp +++ b/src/Mod/CAM/PathSimulator/AppGL/TextureLoader.cpp @@ -52,7 +52,7 @@ TextureLoader::TextureLoader(std::string imgFolder, std::vector fil return; } memset(mRawData, 0x80, buffsize); - for (int i = 0; i < fileNames.size(); i++) { + for (std::size_t i = 0; i < fileNames.size(); i++) { QImage pixmap((imgFolder + fileNames[i]).c_str()); AddImage(&(texItems[i]), pixmap, mRawData, textureSize); } @@ -66,7 +66,6 @@ bool TextureLoader::AddImage(TextureItem* texItem, { int width = pixmap.width(); int height = pixmap.height(); - int buffLen = width * height; buffPos += stride * texItem->ty + texItem->tx; for (int i = 0; i < height; i++) { unsigned int* line = reinterpret_cast(pixmap.scanLine(i)); diff --git a/src/Mod/CAM/PathSimulator/AppGL/TextureLoader.h b/src/Mod/CAM/PathSimulator/AppGL/TextureLoader.h index 56ea6ab6de..0f74d7106d 100644 --- a/src/Mod/CAM/PathSimulator/AppGL/TextureLoader.h +++ b/src/Mod/CAM/PathSimulator/AppGL/TextureLoader.h @@ -31,8 +31,8 @@ namespace MillSim struct TextureItem { - int tx, ty; // texture location - int w, h; // item size + int tx{}, ty{}; // texture location + int w{}, h{}; // item size }; class TextureLoader