From bf1f99c070a51e2fddc6fde0a389920848240f24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Br=C3=A6strup=20Sayoc?= Date: Mon, 24 Feb 2025 17:58:05 +0100 Subject: [PATCH] TechDraw: hard type enums, part 3 (#19418) * Remove magic number and hard type enums in LineNameEnum.h - Remove currently present magic numbers - Hard type enums, so magic numbers can no longer be introduced. We don't want people to introduce magic numbers. * Remove magic number and hard type enums in QGIFace.h - Remove currently present magic numbers - Hard type enums, so magic numbers can no longer be introduced. We don't want people to introduce magic numbers. * Remove magic number and hard type enums in Enums.h - Remove currently present magic numbers - Hard type enums, so magic numbers can no longer be introduced. We don't want people to introduce magic numbers. * Remove magic number and hard type enums in QGVPage.h - Remove currently present magic numbers - Hard type enums, so magic numbers can no longer be introduced. We don't want people to introduce magic numbers. * Remove magic number and hard type enums in TaskSurfaceFinishSymbols.h - Remove currently present magic numbers - Hard type enums, so magic numbers can no longer be introduced. We don't want people to introduce magic numbers. * Remove magic number and hard type enums in QGTracker.h - Remove currently present magic numbers - Hard type enums, so magic numbers can no longer be introduced. We don't want people to introduce magic numbers. --- src/Mod/TechDraw/App/LineNameEnum.h | 51 ++++++++++--------- src/Mod/TechDraw/Gui/Enums.h | 37 ++++++++++++++ src/Mod/TechDraw/Gui/QGIDecoration.cpp | 12 ++--- src/Mod/TechDraw/Gui/QGIDecoration.h | 8 ++- src/Mod/TechDraw/Gui/QGIFace.cpp | 20 ++++---- src/Mod/TechDraw/Gui/QGIFace.h | 6 +-- src/Mod/TechDraw/Gui/QGIViewDimension.cpp | 22 +++----- src/Mod/TechDraw/Gui/QGIViewDimension.h | 3 +- src/Mod/TechDraw/Gui/QGIViewPart.cpp | 9 ++-- src/Mod/TechDraw/Gui/QGIViewSection.cpp | 7 +-- src/Mod/TechDraw/Gui/QGTracker.h | 12 +++-- src/Mod/TechDraw/Gui/QGVPage.cpp | 8 +-- src/Mod/TechDraw/Gui/QGVPage.h | 4 +- src/Mod/TechDraw/Gui/TaskCosVertex.cpp | 2 +- src/Mod/TechDraw/Gui/TaskCosVertex.h | 2 +- src/Mod/TechDraw/Gui/TaskLeaderLine.cpp | 4 +- src/Mod/TechDraw/Gui/TaskLeaderLine.h | 2 +- .../TechDraw/Gui/TaskSurfaceFinishSymbols.cpp | 44 ++++++++-------- .../TechDraw/Gui/TaskSurfaceFinishSymbols.h | 15 ++++-- 19 files changed, 161 insertions(+), 107 deletions(-) create mode 100644 src/Mod/TechDraw/Gui/Enums.h diff --git a/src/Mod/TechDraw/App/LineNameEnum.h b/src/Mod/TechDraw/App/LineNameEnum.h index d3df6c1d1b..3f42676312 100644 --- a/src/Mod/TechDraw/App/LineNameEnum.h +++ b/src/Mod/TechDraw/App/LineNameEnum.h @@ -49,7 +49,8 @@ class TechDrawExport ISOLineName { Q_DECLARE_TR_FUNCTIONS(TechDraw::ISOLineName) public: - enum ISOLineType { NOLINE = 0, + enum class ISOLine { + NOLINE = 0, Continuous, Dashed, DashedSpaced, @@ -64,7 +65,8 @@ public: DashedDoubleDotted, DoubleDashedDoubleDotted, DashedTripleDotted, - DoubleDashedTripleDotted }; + DoubleDashedTripleDotted + }; static const char* ISOLineNameEnums[]; static const int ISOLineNameCount; @@ -77,11 +79,13 @@ class TechDrawExport ANSILineName { Q_DECLARE_TR_FUNCTIONS(TechDraw::ANSILineName) public: - enum ANSILineType { NOLINE = 0, + enum class ANSILineType { + NOLINE = 0, Continuous, Dashed, LongDashedDashed, - LongDashedDoubleDashed }; + LongDashedDoubleDashed + }; static const char* ANSILineNameEnums[]; static const int ANSILineNameCount; @@ -94,25 +98,26 @@ class TechDrawExport ASMELineName { Q_DECLARE_TR_FUNCTIONS(TechDraw::ASMELineName) public: - enum ASMELineType { NOLINE = 0, - Visible, - Hidden, - Section, - Center, - Symmetry, - Dimension, - Extension, - Leader, - CuttingPlane, - ViewingPlane, - OtherPlane, - Break1, - Break2, - Phantom, - Stitch1, - Stitch2, - Chain - }; + enum class ASMELineType { + NOLINE = 0, + Visible, + Hidden, + Section, + Center, + Symmetry, + Dimension, + Extension, + Leader, + CuttingPlane, + ViewingPlane, + OtherPlane, + Break1, + Break2, + Phantom, + Stitch1, + Stitch2, + Chain + }; static const char* ASMELineNameEnums[]; static const int ASMELineNameCount; diff --git a/src/Mod/TechDraw/Gui/Enums.h b/src/Mod/TechDraw/Gui/Enums.h new file mode 100644 index 0000000000..78c5e7c7ec --- /dev/null +++ b/src/Mod/TechDraw/Gui/Enums.h @@ -0,0 +1,37 @@ +/*************************************************************************** + * Copyright (c) 2025 WandererFan * + * Copyright (c) 2025 Benjamin Bræstrup Sayoc * + * * + * This file is part of the FreeCAD CAx development system. * + * * + * This library is free software; you can redistribute it and/or * + * modify it under the terms of the GNU Library General Public * + * License as published by the Free Software Foundation; either * + * version 2 of the License, or (at your option) any later version. * + * * + * This library is distributed in the hope that it will be useful, * + * but WITHOUT ANY WARRANTY; without even the implied warranty of * + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * + * GNU Library General Public License for more details. * + * * + * You should have received a copy of the GNU Library General Public * + * License along with this library; see the file COPYING.LIB. If not, * + * write to the Free Software Foundation, Inc., 59 Temple Place, * + * Suite 330, Boston, MA 02111-1307, USA * + * * + ***************************************************************************/ + +#ifndef TECHDRAW_ENUMS_H +#define TECHDRAW_ENUMS_H + +namespace TechDrawGui { + +enum class DragState : int { + NoDrag, + DragStarted, + Dragging +}; + +} + +#endif diff --git a/src/Mod/TechDraw/Gui/QGIDecoration.cpp b/src/Mod/TechDraw/Gui/QGIDecoration.cpp index 422ad3f7a5..1922a500a7 100644 --- a/src/Mod/TechDraw/Gui/QGIDecoration.cpp +++ b/src/Mod/TechDraw/Gui/QGIDecoration.cpp @@ -41,7 +41,7 @@ QGIDecoration::QGIDecoration() : m_colCurrent(Qt::black), m_styleCurrent(Qt::SolidLine), m_brushCurrent(Qt::SolidPattern), - m_dragState(DECORNODRAG) + m_dragState(DragState::NoDrag) { setCacheMode(QGraphicsItem::NoCache); setAcceptHoverEvents(false); @@ -125,15 +125,15 @@ void QGIDecoration::makeMark(Base::Vector3d v) void QGIDecoration::mousePressEvent(QGraphicsSceneMouseEvent * event) { // Base::Console().Message("QGID::mousePressEvent() - %s\n", getViewName()); - m_dragState = DECORDRAGSTARTED; + m_dragState = DragState::DragStarted; QGraphicsItem::mousePressEvent(event); } void QGIDecoration::mouseMoveEvent(QGraphicsSceneMouseEvent * event) { - if (m_dragState == DECORDRAGSTARTED) { - m_dragState = DECORDRAGGING; + if (m_dragState == DragState::DragStarted) { + m_dragState = DragState::Dragging; } QGraphicsItem::mouseMoveEvent(event); } @@ -141,10 +141,10 @@ void QGIDecoration::mouseMoveEvent(QGraphicsSceneMouseEvent * event) void QGIDecoration::mouseReleaseEvent(QGraphicsSceneMouseEvent * event) { // Base::Console().Message("QGID::mouseReleaseEvent() - %s\n", getViewName()); - if (m_dragState == DECORDRAGGING) { + if (m_dragState == DragState::Dragging) { onDragFinished(); } - m_dragState = DECORNODRAG; + m_dragState = DragState::NoDrag; QGraphicsItem::mouseReleaseEvent(event); } diff --git a/src/Mod/TechDraw/Gui/QGIDecoration.h b/src/Mod/TechDraw/Gui/QGIDecoration.h index 1b9701c605..1f033e48d7 100644 --- a/src/Mod/TechDraw/Gui/QGIDecoration.h +++ b/src/Mod/TechDraw/Gui/QGIDecoration.h @@ -40,13 +40,11 @@ QT_END_NAMESPACE #include #include +#include "Enums.h" + namespace TechDrawGui { -#define DECORNODRAG 0 -#define DECORDRAGSTARTED 1 -#define DECORDRAGGING 2 - class TechDrawGuiExport QGIDecoration : public QGraphicsItemGroup { public: @@ -92,7 +90,7 @@ protected: Qt::PenStyle m_styleCurrent; Qt::BrushStyle m_brushCurrent; - int m_dragState; + DragState m_dragState; private: }; diff --git a/src/Mod/TechDraw/Gui/QGIFace.cpp b/src/Mod/TechDraw/Gui/QGIFace.cpp index cacd8440f6..ec504dd613 100644 --- a/src/Mod/TechDraw/Gui/QGIFace.cpp +++ b/src/Mod/TechDraw/Gui/QGIFace.cpp @@ -87,9 +87,9 @@ QGIFace::QGIFace(int index) : m_fillDef = Qt::SolidPattern; m_fillSelect = Qt::SolidPattern; - setFillMode(NoFill); + setFillMode(FillMode::NoFill); if (m_colDefFill.alpha() > 0) { - setFillMode(PlainFill); + setFillMode(FillMode::PlainFill); } setFill(m_colDefFill, m_fillDef); @@ -113,7 +113,7 @@ void QGIFace::draw() m_imageSvgHatchArea->hide(); if (isHatched()) { - if (m_mode == GeomHatchFill) { + if (m_mode == FillMode::GeomHatchFill) { //GeomHatch does not appear in pdf if clipping is set to true setFlag(QGraphicsItem::ItemClipsChildrenToShape, false); if (!m_lineSets.empty()) { @@ -124,7 +124,7 @@ void QGIFace::draw() lineSetToFillItems(ls); } } - } else if (m_mode == SvgFill) { + } else if (m_mode == FillMode::SvgFill) { m_brush.setTexture(QPixmap()); m_fillNormal = m_fillDef; m_fillStyleCurrent = m_fillNormal; @@ -137,11 +137,11 @@ void QGIFace::draw() buildSvgHatch(); m_svgHatchArea->show(); } - } else if (m_mode == BitmapFill) { + } else if (m_mode == FillMode::BitmapFill) { m_fillStyleCurrent = Qt::TexturePattern; m_texture = textureFromBitmap(m_fileSpec); m_brush.setTexture(m_texture); - } else if (m_mode == PlainFill) { + } else if (m_mode == FillMode::PlainFill) { setFill(m_colNormalFill, m_fillNormal); } } @@ -153,7 +153,7 @@ void QGIFace::draw() void QGIFace::setPrettyNormal() { // Base::Console().Message("QGIF::setPrettyNormal() - hatched: %d\n", isHatched()); if (isHatched() && - (m_mode == BitmapFill) ) { //hatch with bitmap fill + (m_mode == FillMode::BitmapFill) ) { //hatch with bitmap fill m_fillStyleCurrent = Qt::TexturePattern; m_brush.setTexture(m_texture); } else { @@ -216,11 +216,11 @@ void QGIFace::loadSvgHatch(std::string fileSpec) } } -void QGIFace::setFillMode(QGIFace::fillMode mode) +void QGIFace::setFillMode(FillMode mode) { m_mode = mode; - if ((m_mode == NoFill) || - (m_mode == PlainFill)) { + if ((m_mode == FillMode::NoFill) || + (m_mode == FillMode::PlainFill)) { isHatched(false); } else { isHatched(true); diff --git a/src/Mod/TechDraw/Gui/QGIFace.h b/src/Mod/TechDraw/Gui/QGIFace.h index b0c8c3d317..ce481f1720 100644 --- a/src/Mod/TechDraw/Gui/QGIFace.h +++ b/src/Mod/TechDraw/Gui/QGIFace.h @@ -64,7 +64,7 @@ public: QPainterPath shape() const override; public: - enum fillMode { + enum class FillMode { NoFill, FromFile, SvgFill, @@ -85,7 +85,7 @@ public: //shared fill parms void isHatched(bool state) {m_isHatched = state; } bool isHatched() {return m_isHatched;} - void setFillMode(fillMode mode); + void setFillMode(FillMode mode); //general hatch parms & methods void setHatchColor(App::Color color); @@ -163,7 +163,7 @@ private: double m_fillScale{1.0}; bool m_isHatched{false}; - QGIFace::fillMode m_mode; + QGIFace::FillMode m_mode; QPixmap m_texture; // QPainterPath m_outline; // diff --git a/src/Mod/TechDraw/Gui/QGIViewDimension.cpp b/src/Mod/TechDraw/Gui/QGIViewDimension.cpp index f6638c9e07..c4eff8be7f 100644 --- a/src/Mod/TechDraw/Gui/QGIViewDimension.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewDimension.cpp @@ -50,6 +50,7 @@ #include #include +#include "Enums.h" #include "QGIViewDimension.h" #include "PreferencesGui.h" #include "QGIArrow.h" @@ -72,22 +73,15 @@ using namespace TechDraw; using namespace TechDrawGui; using Format = DimensionFormatter::Format; -enum SnapMode +enum class SnapMode { NoSnap, VerticalSnap, HorizontalSnap }; -enum DragState -{ - NoDrag, - DragStarted, - Dragging -}; - -QGIDatumLabel::QGIDatumLabel() : m_dragState(NoDrag) +QGIDatumLabel::QGIDatumLabel() : m_dragState(DragState::NoDrag) { verticalSep = false; posX = 0; @@ -146,9 +140,9 @@ QVariant QGIDatumLabel::itemChange(GraphicsItemChange change, const QVariant& va } else { setPrettyNormal(); - if (m_dragState == Dragging) { + if (m_dragState == DragState::Dragging) { //stop the drag if we are no longer selected. - m_dragState = NoDrag; + m_dragState = DragState::NoDrag; Q_EMIT dragFinished(); } } @@ -160,7 +154,7 @@ QVariant QGIDatumLabel::itemChange(GraphicsItemChange change, const QVariant& va } setLabelCenter(); - m_dragState = Dragging; + m_dragState = DragState::Dragging; Q_EMIT dragging(m_ctrl); } @@ -299,8 +293,8 @@ void QGIDatumLabel::mouseReleaseEvent(QGraphicsSceneMouseEvent* event) { // Base::Console().Message("QGIDL::mouseReleaseEvent()\n"); m_ctrl = false; - if (m_dragState == Dragging) { - m_dragState = NoDrag; + if (m_dragState == DragState::Dragging) { + m_dragState = DragState::NoDrag; Q_EMIT dragFinished(); } diff --git a/src/Mod/TechDraw/Gui/QGIViewDimension.h b/src/Mod/TechDraw/Gui/QGIViewDimension.h index 87f300d724..23179b8dd2 100644 --- a/src/Mod/TechDraw/Gui/QGIViewDimension.h +++ b/src/Mod/TechDraw/Gui/QGIViewDimension.h @@ -56,6 +56,7 @@ class QGIDimLines; class QGIViewDimension; class QGCustomSvg; class ViewProviderDimension; +enum class DragState; class QGIDatumLabel : public QGraphicsObject { @@ -150,7 +151,7 @@ private: double posX; double posY; - int m_dragState; + DragState m_dragState; private: }; diff --git a/src/Mod/TechDraw/Gui/QGIViewPart.cpp b/src/Mod/TechDraw/Gui/QGIViewPart.cpp index 9d9d614c22..b287351d4a 100644 --- a/src/Mod/TechDraw/Gui/QGIViewPart.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewPart.cpp @@ -70,6 +70,7 @@ using namespace TechDraw; using namespace TechDrawGui; using namespace std; using DU = DrawUtil; +using FillMode = QGIFace::FillMode; const float lineScaleFactor = Rez::guiX(1.);// temp fiddle for devel @@ -273,7 +274,7 @@ void QGIViewPart::drawAllFaces(void) QGIFace* newFace = drawFace(face, iFace); if (faceColor.isValid()) { newFace->setFillColor(faceColor); - newFace->setFillMode(faceColor.alpha() ? QGIFace::PlainFill : QGIFace::NoFill); + newFace->setFillMode(faceColor.alpha() ? FillMode::PlainFill : FillMode::NoFill); } TechDraw::DrawHatch* fHatch = faceIsHatched(iFace, regularHatches); @@ -281,7 +282,7 @@ void QGIViewPart::drawAllFaces(void) if (fGeom) { // geometric hatch (from PAT hatch specification) newFace->isHatched(true); - newFace->setFillMode(QGIFace::GeomHatchFill); + newFace->setFillMode(FillMode::GeomHatchFill); std::vector lineSets = fGeom->getTrimmedLines(iFace); if (!lineSets.empty()) { // this face has geometric hatch lines @@ -311,10 +312,10 @@ void QGIViewPart::drawAllFaces(void) } if (fHatch->isSvgHatch()) { // svg tile hatch - newFace->setFillMode(QGIFace::SvgFill); + newFace->setFillMode(FillMode::SvgFill); } else { //bitmap hatch - newFace->setFillMode(QGIFace::BitmapFill); + newFace->setFillMode(FillMode::BitmapFill); } // get the properties from the hatch viewprovider diff --git a/src/Mod/TechDraw/Gui/QGIViewSection.cpp b/src/Mod/TechDraw/Gui/QGIViewSection.cpp index 86a623fb2f..df17ccabcf 100644 --- a/src/Mod/TechDraw/Gui/QGIViewSection.cpp +++ b/src/Mod/TechDraw/Gui/QGIViewSection.cpp @@ -34,6 +34,7 @@ using namespace TechDrawGui; +using FillMode = QGIFace::FillMode; void QGIViewSection::draw() { @@ -91,10 +92,10 @@ void QGIViewSection::drawSectionFace() QColor faceColor = (sectionVp->CutSurfaceColor.getValue()).asValue(); faceColor.setAlpha((100 - sectionVp->CutSurfaceTransparency.getValue())*255/100); newFace->setFillColor(faceColor); - newFace->setFillMode(faceColor.alpha() ? QGIFace::PlainFill : QGIFace::NoFill); + newFace->setFillMode(faceColor.alpha() ? FillMode::PlainFill : FillMode::NoFill); } else if (section->CutSurfaceDisplay.isValue("SvgHatch")) { newFace->isHatched(true); - newFace->setFillMode(QGIFace::SvgFill); + newFace->setFillMode(FillMode::SvgFill); newFace->setHatchColor(sectionVp->HatchColor.getValue()); newFace->setHatchScale(section->HatchScale.getValue()); newFace->setHatchRotation(section->HatchRotation.getValue()); @@ -103,7 +104,7 @@ void QGIViewSection::drawSectionFace() newFace->setHatchFile(hatchSpec); } else if (section->CutSurfaceDisplay.isValue("PatHatch")) { newFace->isHatched(true); - newFace->setFillMode(QGIFace::GeomHatchFill); + newFace->setFillMode(FillMode::GeomHatchFill); newFace->setHatchColor(sectionVp->GeomHatchColor.getValue()); newFace->setHatchScale(section->HatchScale.getValue()); newFace->setHatchRotation(section->HatchRotation.getValue()); diff --git a/src/Mod/TechDraw/Gui/QGTracker.h b/src/Mod/TechDraw/Gui/QGTracker.h index 1a63caa983..453403ccf6 100644 --- a/src/Mod/TechDraw/Gui/QGTracker.h +++ b/src/Mod/TechDraw/Gui/QGTracker.h @@ -44,7 +44,7 @@ namespace TechDrawGui class QGSPage; class QGIView; -enum TrackerAction +enum class TrackerAction { PICK = 0, EDIT = 1, @@ -58,9 +58,15 @@ class TechDrawGuiExport QGTracker : public QObject, public QGIPrimPath { Q_OBJECT public: - enum TrackerMode { None, Line, Circle, Rectangle, Point }; + enum class TrackerMode { + None, + Line, + Circle, + Rectangle, + Point + }; - explicit QGTracker(QGSPage* scene = nullptr, QGTracker::TrackerMode m = QGTracker::TrackerMode::None); + explicit QGTracker(QGSPage* scene = nullptr, TrackerMode m = TrackerMode::None); ~QGTracker() override; diff --git a/src/Mod/TechDraw/Gui/QGVPage.cpp b/src/Mod/TechDraw/Gui/QGVPage.cpp index 9d6048efb9..840deaa174 100644 --- a/src/Mod/TechDraw/Gui/QGVPage.cpp +++ b/src/Mod/TechDraw/Gui/QGVPage.cpp @@ -167,7 +167,7 @@ public: }; QGVPage::QGVPage(ViewProviderPage* vpPage, QGSPage* scenePage, QWidget* parent) - : QGraphicsView(parent), m_renderer(Native), drawBkg(true), m_vpPage(nullptr), + : QGraphicsView(parent), m_renderer(RendererType::Native), drawBkg(true), m_vpPage(nullptr), m_scene(scenePage), balloonPlacing(false), m_showGrid(false), m_navStyle(nullptr), d(new Private(this)), toolHandler(nullptr) { @@ -184,7 +184,7 @@ QGVPage::QGVPage(ViewProviderPage* vpPage, QGSPage* scenePage, QWidget* parent) m_saveContextEvent = nullptr; setCacheMode(QGraphicsView::CacheBackground); - setRenderer(Native); + setRenderer(RendererType::Native); // setRenderer(OpenGL); //gives rotten quality, don't use this setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform); @@ -374,7 +374,7 @@ void QGVPage::setRenderer(RendererType type) { m_renderer = type; - if (m_renderer == OpenGL) { + if (m_renderer == RendererType::OpenGL) { #ifndef QT_NO_OPENGL setViewport(new QOpenGLWidget); setViewportUpdateMode(QGraphicsView::SmartViewportUpdate); @@ -397,7 +397,7 @@ void QGVPage::setHighQualityAntialiasing(bool highQualityAntialiasing) void QGVPage::paintEvent(QPaintEvent* event) { - if (m_renderer == Image) { + if (m_renderer == RendererType::Image) { if (m_image.size() != viewport()->size()) { m_image = QImage(viewport()->size(), QImage::Format_ARGB32_Premultiplied); } diff --git a/src/Mod/TechDraw/Gui/QGVPage.h b/src/Mod/TechDraw/Gui/QGVPage.h index c39a9116e9..7a5b524574 100644 --- a/src/Mod/TechDraw/Gui/QGVPage.h +++ b/src/Mod/TechDraw/Gui/QGVPage.h @@ -78,7 +78,7 @@ class TechDrawGuiExport QGVPage: public QGraphicsView Q_OBJECT public: - enum RendererType + enum class RendererType { Native, OpenGL, @@ -88,7 +88,7 @@ public: QGVPage(ViewProviderPage* vpPage, QGSPage* scenePage, QWidget* parent = nullptr); ~QGVPage() override; - void setRenderer(RendererType type = Native); + void setRenderer(RendererType type = RendererType::Native); void drawBackground(QPainter* painter, const QRectF& rect) override; QGSPage* getScene() { return m_scene; } diff --git a/src/Mod/TechDraw/Gui/TaskCosVertex.cpp b/src/Mod/TechDraw/Gui/TaskCosVertex.cpp index ed692e6e8e..a8033de3f9 100644 --- a/src/Mod/TechDraw/Gui/TaskCosVertex.cpp +++ b/src/Mod/TechDraw/Gui/TaskCosVertex.cpp @@ -64,7 +64,7 @@ TaskCosVertex::TaskCosVertex(TechDraw::DrawViewPart* baseFeat, m_baseFeat(baseFeat), m_basePage(page), m_qgParent(nullptr), - m_trackerMode(QGTracker::None), + m_trackerMode(QGTracker::TrackerMode::None), m_saveContextPolicy(Qt::DefaultContextMenu), m_inProgressLock(false), m_btnOK(nullptr), diff --git a/src/Mod/TechDraw/Gui/TaskCosVertex.h b/src/Mod/TechDraw/Gui/TaskCosVertex.h index 7120472121..1e00c36e72 100644 --- a/src/Mod/TechDraw/Gui/TaskCosVertex.h +++ b/src/Mod/TechDraw/Gui/TaskCosVertex.h @@ -103,7 +103,7 @@ private: QPushButton* m_btnOK; QPushButton* m_btnCancel; - int m_pbTrackerState; + TrackerAction m_pbTrackerState; QPointF m_savePoint; bool pointFromTracker; diff --git a/src/Mod/TechDraw/Gui/TaskLeaderLine.cpp b/src/Mod/TechDraw/Gui/TaskLeaderLine.cpp index 9e3433a3f7..cebae32948 100644 --- a/src/Mod/TechDraw/Gui/TaskLeaderLine.cpp +++ b/src/Mod/TechDraw/Gui/TaskLeaderLine.cpp @@ -72,7 +72,7 @@ TaskLeaderLine::TaskLeaderLine(TechDrawGui::ViewProviderLeader* leadVP) : m_lineFeat(m_lineVP->getFeature()), m_qgParent(nullptr), m_createMode(false), - m_trackerMode(QGTracker::None), + m_trackerMode(QGTracker::TrackerMode::None), m_saveContextPolicy(Qt::DefaultContextMenu), m_inProgressLock(false), m_qgLeader(nullptr), @@ -145,7 +145,7 @@ TaskLeaderLine::TaskLeaderLine(TechDraw::DrawView* baseFeat, m_lineFeat(nullptr), m_qgParent(nullptr), m_createMode(true), - m_trackerMode(QGTracker::None), + m_trackerMode(QGTracker::TrackerMode::None), m_saveContextPolicy(Qt::DefaultContextMenu), m_inProgressLock(false), m_qgLeader(nullptr), diff --git a/src/Mod/TechDraw/Gui/TaskLeaderLine.h b/src/Mod/TechDraw/Gui/TaskLeaderLine.h index d5b4122465..56054c8ee9 100644 --- a/src/Mod/TechDraw/Gui/TaskLeaderLine.h +++ b/src/Mod/TechDraw/Gui/TaskLeaderLine.h @@ -120,7 +120,7 @@ private: QPushButton* m_btnOK; QPushButton* m_btnCancel; - int m_pbTrackerState; + TrackerAction m_pbTrackerState; double m_saveX; double m_saveY; diff --git a/src/Mod/TechDraw/Gui/TaskSurfaceFinishSymbols.cpp b/src/Mod/TechDraw/Gui/TaskSurfaceFinishSymbols.cpp index 671a9dfc6e..9740d3dc65 100644 --- a/src/Mod/TechDraw/Gui/TaskSurfaceFinishSymbols.cpp +++ b/src/Mod/TechDraw/Gui/TaskSurfaceFinishSymbols.cpp @@ -155,7 +155,7 @@ QColor TaskSurfaceFinishSymbols::getPenColor() return Qt::black; } -QPixmap TaskSurfaceFinishSymbols::baseSymbol(symbolType type) +QPixmap TaskSurfaceFinishSymbols::baseSymbol(SymbolType type) // return QPixmap showing a base symbol { QImage img (50, 64, QImage::Format_ARGB32_Premultiplied); @@ -171,11 +171,13 @@ QPixmap TaskSurfaceFinishSymbols::baseSymbol(symbolType type) QPainter::TextAntialiasing); painter.drawLine(QLine(0, 40, 12, 60)); painter.drawLine(QLine(12, 60, 42, 10)); - if (type == removeProhibit || type == removeProhibitAll) + if (type == SymbolType::RemoveProhibit || type == SymbolType::RemoveProhibitAll) painter.drawEllipse(QPoint(12, 42), 9,9); - if (type == removeRequired || type == removeRequiredAll) + if (type == SymbolType::RemoveRequired || type == SymbolType::RemoveRequiredAll) painter.drawLine(QLine(0, 40, 24, 40)); - if (type > removeRequired) + if (type == SymbolType::AnyMethodAll || + type == SymbolType::RemoveProhibitAll || + type == SymbolType::RemoveRequiredAll) painter.drawEllipse(QPoint(42, 10), 6,6); painter.end(); return QPixmap::fromImage(img); @@ -188,11 +190,13 @@ std::string TaskSurfaceFinishSymbols::completeSymbol() symbol.addLine(0, 44, 12, 64); symbol.addLine(12, 64, 42, 14); int moveLeft(0), maxTextLength(0); - if (activeIcon == removeProhibit || activeIcon == removeProhibitAll) + if (activeIcon == SymbolType::RemoveProhibit || activeIcon == SymbolType::RemoveProhibitAll) symbol.addCircle(12, 46, 9); - if (activeIcon == removeRequired || activeIcon == removeRequiredAll) + if (activeIcon == SymbolType::RemoveRequired || activeIcon == SymbolType::RemoveRequiredAll) symbol.addLine(0, 44, 24, 44); - if (activeIcon > removeRequired) + if (activeIcon == SymbolType::AnyMethodAll || + activeIcon == SymbolType::RemoveProhibitAll || + activeIcon == SymbolType::RemoveRequiredAll) { symbol.addCircle(42, 14, 6); moveLeft = 5 ; @@ -245,12 +249,12 @@ void TaskSurfaceFinishSymbols::setUiEdit() { setWindowTitle(tr("Surface Finish Symbols")); // create icon pixmaps of QPushButtons - ui->pbIcon01->setIcon(baseSymbol(anyMethod)); - ui->pbIcon02->setIcon(baseSymbol(removeProhibit)); - ui->pbIcon03->setIcon(baseSymbol(removeRequired)); - ui->pbIcon04->setIcon(baseSymbol(anyMethodAll)); - ui->pbIcon05->setIcon(baseSymbol(removeProhibitAll)); - ui->pbIcon06->setIcon(baseSymbol(removeRequiredAll)); + ui->pbIcon01->setIcon(baseSymbol(SymbolType::AnyMethod)); + ui->pbIcon02->setIcon(baseSymbol(SymbolType::RemoveProhibit)); + ui->pbIcon03->setIcon(baseSymbol(SymbolType::RemoveRequired)); + ui->pbIcon04->setIcon(baseSymbol(SymbolType::AnyMethodAll)); + ui->pbIcon05->setIcon(baseSymbol(SymbolType::RemoveProhibitAll)); + ui->pbIcon06->setIcon(baseSymbol(SymbolType::RemoveRequiredAll)); int w = ui->pbIcon01->width(); int h = ui->pbIcon01->height(); @@ -262,7 +266,7 @@ void TaskSurfaceFinishSymbols::setUiEdit() ui->pbIcon06->setIconSize(QSize(w, h)); - activeIcon = anyMethod ; + activeIcon = SymbolType::AnyMethod ; isISO = true; // Create scene and all items used in the scene @@ -354,12 +358,12 @@ void TaskSurfaceFinishSymbols::onIconChanged() return; } - if (ui->pbIcon01 == pressedButton) activeIcon = anyMethod; - if (ui->pbIcon02 == pressedButton) activeIcon = removeProhibit; - if (ui->pbIcon03 == pressedButton) activeIcon = removeRequired; - if (ui->pbIcon04 == pressedButton) activeIcon = anyMethodAll; - if (ui->pbIcon05 == pressedButton) activeIcon = removeProhibitAll; - if (ui->pbIcon06 == pressedButton) activeIcon = removeRequiredAll; + if (ui->pbIcon01 == pressedButton) activeIcon = SymbolType::AnyMethod; + if (ui->pbIcon02 == pressedButton) activeIcon = SymbolType::RemoveProhibit; + if (ui->pbIcon03 == pressedButton) activeIcon = SymbolType::RemoveRequired; + if (ui->pbIcon04 == pressedButton) activeIcon = SymbolType::AnyMethodAll; + if (ui->pbIcon05 == pressedButton) activeIcon = SymbolType::RemoveProhibitAll; + if (ui->pbIcon06 == pressedButton) activeIcon = SymbolType::RemoveRequiredAll; QIcon symbolIcon = pressedButton->icon(); if(currentIcon) { diff --git a/src/Mod/TechDraw/Gui/TaskSurfaceFinishSymbols.h b/src/Mod/TechDraw/Gui/TaskSurfaceFinishSymbols.h index 890654acdd..69b6f6ac03 100644 --- a/src/Mod/TechDraw/Gui/TaskSurfaceFinishSymbols.h +++ b/src/Mod/TechDraw/Gui/TaskSurfaceFinishSymbols.h @@ -93,9 +93,16 @@ protected: Base::Vector3d placement; private: - enum symbolType {anyMethod=0, removeProhibit, removeRequired, - anyMethodAll, removeProhibitAll, removeRequiredAll}; - QPixmap baseSymbol(symbolType type); + enum class SymbolType { + AnyMethod=0, + RemoveProhibit, + RemoveRequired, + AnyMethodAll, + RemoveProhibitAll, + RemoveRequiredAll + }; + + QPixmap baseSymbol(SymbolType type); std::string completeSymbol(); QGraphicsScene* symbolScene; //note this is not QGSPage, but another scene only used to //display symbols in this task's ui @@ -103,7 +110,7 @@ private: QGraphicsProxyWidget *proxyRA, *proxySamLength, *proxyMinRough, *proxyMaxRough; QLineEdit *leMethod, *leSamLength, *leAddition; QComboBox *cbRA, *cbMinRought, *cbMaxRought, *cbLay; - symbolType activeIcon; + SymbolType activeIcon; bool isISO; QGraphicsPixmapItem* currentIcon; std::unique_ptr ui;