From cc1e11482b0ddcc3297df6d8630fd6cbdbbf9df9 Mon Sep 17 00:00:00 2001 From: Abdullah Tahiri Date: Mon, 13 Nov 2023 14:55:06 +0100 Subject: [PATCH] SketcherGui: Fix lints --- src/Mod/Sketcher/Gui/DrawSketchController.h | 8 +- src/Mod/Sketcher/Gui/DrawSketchHandlerArc.h | 36 +- .../Sketcher/Gui/DrawSketchHandlerCircle.h | 13 +- .../Sketcher/Gui/DrawSketchHandlerEllipse.h | 24 +- src/Mod/Sketcher/Gui/DrawSketchHandlerLine.h | 19 +- .../Sketcher/Gui/DrawSketchHandlerPolygon.h | 16 +- .../Sketcher/Gui/DrawSketchHandlerRectangle.h | 376 +++++++++--------- 7 files changed, 259 insertions(+), 233 deletions(-) diff --git a/src/Mod/Sketcher/Gui/DrawSketchController.h b/src/Mod/Sketcher/Gui/DrawSketchController.h index 071e616ede..3cb6f770e3 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchController.h +++ b/src/Mod/Sketcher/Gui/DrawSketchController.h @@ -166,8 +166,8 @@ protected: ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath( "User parameter:BaseApp/Preferences/View"); - dimConstrColor = SbColor(1.0f, 0.149f, 0.0f); - dimConstrDeactivatedColor = SbColor(0.8f, 0.8f, 0.8f); + dimConstrColor = SbColor(1.0f, 0.149f, 0.0f); // NOLINT + dimConstrDeactivatedColor = SbColor(0.8f, 0.8f, 0.8f); // NOLINT float transparency = 0.f; unsigned long color = (unsigned long)(dimConstrColor.getPackedValue()); @@ -626,7 +626,7 @@ protected: else { if (firstOfMode) { - onViewIndexWithFocus = i; + onViewIndexWithFocus = static_cast(i); firstOfMode = false; } @@ -656,7 +656,7 @@ protected: onViewParameters[onviewparameterindex]->setFocusToSpinbox(); } - onViewIndexWithFocus = onviewparameterindex; + onViewIndexWithFocus = static_cast(onviewparameterindex); } } diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerArc.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerArc.h index cbdff01095..7b443bb5d3 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerArc.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerArc.h @@ -24,6 +24,7 @@ #ifndef SKETCHERGUI_DrawSketchHandlerArc_H #define SKETCHERGUI_DrawSketchHandlerArc_H +#include #include #include #include @@ -53,10 +54,10 @@ using DSHArcController = DrawSketchDefaultWidgetController, - /*WidgetParametersT =*/WidgetParameters<0, 0>, - /*WidgetCheckboxesT =*/WidgetCheckboxes<0, 0>, - /*WidgetComboboxesT =*/WidgetComboboxes<1, 1>, + /*OnViewParametersT =*/OnViewParameters<5, 6>, // NOLINT + /*WidgetParametersT =*/WidgetParameters<0, 0>, // NOLINT + /*WidgetCheckboxesT =*/WidgetCheckboxes<0, 0>, // NOLINT + /*WidgetComboboxesT =*/WidgetComboboxes<1, 1>, // NOLINT ConstructionMethods::CircleEllipseConstructionMethod, /*bool PFirstComboboxIsConstructionMethod =*/true>; @@ -72,12 +73,15 @@ class DrawSketchHandlerArc: public DrawSketchHandlerArcBase public: explicit DrawSketchHandlerArc(ConstructionMethod constrMethod = ConstructionMethod::Center) : DrawSketchHandlerArcBase(constrMethod) + , radius(0.0) , startAngle(0.0) , endAngle(0.0) , arcAngle(0.0) + , arcPos1(Sketcher::PointPos::none) + , arcPos2(Sketcher::PointPos::none) {} - ~DrawSketchHandlerArc() = default; + ~DrawSketchHandlerArc() override = default; private: void updateDataAndDrawToPosition(Base::Vector2d onSketchPos) override @@ -390,17 +394,18 @@ private: if (onlyeditoutline) { if (constructionMethod() == ConstructionMethod::Center) { if (state() == SelectMode::SeekThird) { + const double scale = 0.8; addLineToShapeGeometry( toVector3d(centerPoint), - Base::Vector3d(centerPoint.x + cos(startAngle) * 0.8 * radius, - centerPoint.y + sin(startAngle) * 0.8 * radius, + Base::Vector3d(centerPoint.x + cos(startAngle) * scale * radius, + centerPoint.y + sin(startAngle) * scale * radius, 0.), isConstructionMode()); addLineToShapeGeometry( toVector3d(centerPoint), - Base::Vector3d(centerPoint.x + cos(endAngle) * 0.8 * radius, - centerPoint.y + sin(endAngle) * 0.8 * radius, + Base::Vector3d(centerPoint.x + cos(endAngle) * scale * radius, + centerPoint.y + sin(endAngle) * scale * radius, 0.), isConstructionMode()); } @@ -412,16 +417,17 @@ private: isConstructionMode()); } else if (state() == SelectMode::SeekThird) { + const double scale = 0.8; addLineToShapeGeometry(toVector3d(centerPoint), toVector3d(centerPoint) + (toVector3d(secondPoint) - toVector3d(centerPoint)) - * 0.8, + * scale, isConstructionMode()); addLineToShapeGeometry(toVector3d(centerPoint), toVector3d(centerPoint) + (toVector3d(firstPoint) - toVector3d(centerPoint)) - * 0.8, + * scale, isConstructionMode()); } } @@ -540,7 +546,7 @@ void DSHArcControllerBase::doEnforceControlParameters(Base::Vector2d& onSketchPo if (onViewParameters[OnViewParameter::Fourth]->isSet) { double angle = - onViewParameters[OnViewParameter::Fourth]->getValue() * M_PI / 180; + Base::toRadians(onViewParameters[OnViewParameter::Fourth]->getValue()); onSketchPos.x = handler->centerPoint.x + cos(angle) * radius; onSketchPos.y = handler->centerPoint.y + sin(angle) * radius; } @@ -565,7 +571,7 @@ void DSHArcControllerBase::doEnforceControlParameters(Base::Vector2d& onSketchPo if (handler->constructionMethod() == DrawSketchHandlerArc::ConstructionMethod::Center) { if (onViewParameters[OnViewParameter::Fifth]->isSet) { double arcAngle = - onViewParameters[OnViewParameter::Fifth]->getValue() * M_PI / 180; + Base::toRadians(onViewParameters[OnViewParameter::Fifth]->getValue()); if (fmod(fabs(arcAngle), 2 * M_PI) < Precision::Confusion()) { unsetOnViewParameter(onViewParameters[OnViewParameter::Fifth].get()); return; @@ -617,7 +623,7 @@ void DSHArcController::adaptParameters(Base::Vector2d onSketchPos) if (!onViewParameters[OnViewParameter::Third]->isSet) { setOnViewParameterValue(OnViewParameter::Third, handler->radius); } - double range = handler->startAngle * 180 / M_PI; + double range = Base::toDegrees(handler->startAngle); if (!onViewParameters[OnViewParameter::Fourth]->isSet) { setOnViewParameterValue(OnViewParameter::Fourth, range, Base::Unit::Angle); } @@ -649,7 +655,7 @@ void DSHArcController::adaptParameters(Base::Vector2d onSketchPos) } break; case SelectMode::SeekThird: { if (handler->constructionMethod() == DrawSketchHandlerArc::ConstructionMethod::Center) { - double range = handler->arcAngle * 180 / M_PI; + double range = Base::toDegrees(handler->arcAngle); if (!onViewParameters[OnViewParameter::Fifth]->isSet) { setOnViewParameterValue(OnViewParameter::Fifth, range, Base::Unit::Angle); diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerCircle.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerCircle.h index 2b268afbcc..8fa90bd65d 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerCircle.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerCircle.h @@ -55,10 +55,10 @@ using DSHCircleController = DrawSketchDefaultWidgetController, - /*WidgetParametersT =*/WidgetParameters<0, 0>, - /*WidgetCheckboxesT =*/WidgetCheckboxes<0, 0>, - /*WidgetComboboxesT =*/WidgetComboboxes<1, 1>, + /*OnViewParametersT =*/OnViewParameters<3, 6>, // NOLINT + /*WidgetParametersT =*/WidgetParameters<0, 0>, // NOLINT + /*WidgetCheckboxesT =*/WidgetCheckboxes<0, 0>, // NOLINT + /*WidgetComboboxesT =*/WidgetComboboxes<1, 1>, // NOLINT ConstructionMethods::CircleEllipseConstructionMethod, /*bool PFirstComboboxIsConstructionMethod =*/true>; @@ -75,6 +75,7 @@ class DrawSketchHandlerCircle: public DrawSketchHandlerCircleBase public: explicit DrawSketchHandlerCircle(ConstructionMethod constrMethod = ConstructionMethod::Center) : DrawSketchHandlerCircleBase(constrMethod) + , radius(0.0) {} ~DrawSketchHandlerCircle() override = default; @@ -288,7 +289,7 @@ private: } // reimplement because circle is 2 steps while 3rims is 3 steps - virtual void onButtonPressed(Base::Vector2d onSketchPos) override + void onButtonPressed(Base::Vector2d onSketchPos) override { this->updateDataAndDrawToPosition(onSketchPos); if (canGoToNextMode()) { @@ -302,7 +303,7 @@ private: } } - virtual void createShape(bool onlyeditoutline) override + void createShape(bool onlyeditoutline) override { Q_UNUSED(onlyeditoutline); diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerEllipse.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerEllipse.h index b19f8e0378..16dd6e6be7 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerEllipse.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerEllipse.h @@ -34,8 +34,8 @@ #include #include +#include #include - #include "DrawSketchDefaultWidgetController.h" #include "DrawSketchControllableHandler.h" #include "GeometryCreationMode.h" @@ -56,10 +56,10 @@ using DSHEllipseController = DrawSketchDefaultWidgetController, - /*WidgetParametersT =*/WidgetParameters<0, 0>, - /*WidgetCheckboxesT =*/WidgetCheckboxes<0, 0>, - /*WidgetComboboxesT =*/WidgetComboboxes<1, 1>, + /*OnViewParametersT =*/OnViewParameters<5, 6>, // NOLINT + /*WidgetParametersT =*/WidgetParameters<0, 0>, // NOLINT + /*WidgetCheckboxesT =*/WidgetCheckboxes<0, 0>, // NOLINT + /*WidgetComboboxesT =*/WidgetComboboxes<1, 1>, // NOLINT ConstructionMethods::CircleEllipseConstructionMethod, /*bool PFirstComboboxIsConstructionMethod =*/true>; @@ -79,8 +79,9 @@ public: , secondRadius(0.0) , majorRadius(0.0) , minorRadius(0.0) + , ellipseGeoId(Sketcher::GeoEnum::GeoUndef) {} - virtual ~DrawSketchHandlerEllipse() = default; + ~DrawSketchHandlerEllipse() override = default; private: void updateDataAndDrawToPosition(Base::Vector2d onSketchPos) override @@ -346,7 +347,7 @@ private: secondRadius = minorradius; } - virtual void createShape(bool onlyeditoutline) override + void createShape(bool onlyeditoutline) override { Q_UNUSED(onlyeditoutline); @@ -355,7 +356,8 @@ private: Base::Vector2d majorAxis = firstAxis; majorRadius = firstRadius; if (state() == SelectMode::SeekSecond) { - minorRadius = majorRadius * 0.5; + const double scale = 0.5; + minorRadius = majorRadius * scale; } else { // SelectMode::SeekThird or SelectMode::End minorRadius = secondRadius; @@ -506,7 +508,7 @@ void DSHEllipseControllerBase::doEnforceControlParameters(Base::Vector2d& onSket if (onViewParameters[OnViewParameter::Fourth]->isSet) { double angle = - onViewParameters[OnViewParameter::Fourth]->getValue() * M_PI / 180; + Base::toRadians(onViewParameters[OnViewParameter::Fourth]->getValue()); onSketchPos.x = handler->centerPoint.x + cos(angle) * length; onSketchPos.y = handler->centerPoint.y + sin(angle) * length; } @@ -593,7 +595,7 @@ void DSHEllipseController::adaptParameters(Base::Vector2d onSketchPos) } if (!onViewParameters[OnViewParameter::Fourth]->isSet) { - double angle = vec.Length() > 0 ? vec.Angle() * 180 / M_PI : 0; + double angle = vec.Length() > 0 ? Base::toDegrees(vec.Angle()) : 0; setOnViewParameterValue(OnViewParameter::Fourth, angle, Base::Unit::Angle); } @@ -707,7 +709,7 @@ void DSHEllipseController::addConstraints() auto x0 = onViewParameters[OnViewParameter::First]->getValue(); auto y0 = onViewParameters[OnViewParameter::Second]->getValue(); - auto angle = onViewParameters[OnViewParameter::Fourth]->getValue() * M_PI / 180; + auto angle = Base::toRadians(onViewParameters[OnViewParameter::Fourth]->getValue()); auto x0set = onViewParameters[OnViewParameter::First]->isSet; auto y0set = onViewParameters[OnViewParameter::Second]->isSet; diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerLine.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerLine.h index 8b8cc322f0..2080867dc1 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerLine.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerLine.h @@ -61,10 +61,10 @@ using DSHLineController = DrawSketchDefaultWidgetController, - /*WidgetParametersT =*/WidgetParameters<0, 0, 0>, - /*WidgetCheckboxesT =*/WidgetCheckboxes<0, 0, 0>, - /*WidgetComboboxesT =*/WidgetComboboxes<1, 1, 1>, + /*OnViewParametersT =*/OnViewParameters<4, 4, 4>, // NOLINT + /*WidgetParametersT =*/WidgetParameters<0, 0, 0>, // NOLINT + /*WidgetCheckboxesT =*/WidgetCheckboxes<0, 0, 0>, // NOLINT + /*WidgetComboboxesT =*/WidgetComboboxes<1, 1, 1>, // NOLINT ConstructionMethods::LineConstructionMethod, /*bool PFirstComboboxIsConstructionMethod =*/true>; @@ -81,7 +81,8 @@ class DrawSketchHandlerLine: public DrawSketchHandlerLineBase public: explicit DrawSketchHandlerLine( ConstructionMethod constrMethod = ConstructionMethod::OnePointLengthAngle) - : DrawSketchHandlerLineBase(constrMethod) {}; + : DrawSketchHandlerLineBase(constrMethod) + , length(0.0) {}; ~DrawSketchHandlerLine() override = default; private: @@ -200,7 +201,7 @@ private: { ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath( "User parameter:BaseApp/Preferences/Mod/Sketcher/Tools"); - int index = hGrp->GetInt("OnViewParameterVisibility", 1); + auto index = hGrp->GetInt("OnViewParameterVisibility", 1); return index != 0; }; @@ -385,7 +386,7 @@ void DSHLineControllerBase::doEnforceControlParameters(Base::Vector2d& onSketchP if (onViewParameters[OnViewParameter::Fourth]->isSet) { double angle = - onViewParameters[OnViewParameter::Fourth]->getValue() * M_PI / 180; + Base::toRadians(onViewParameters[OnViewParameter::Fourth]->getValue()); onSketchPos.x = handler->startPoint.x + cos(angle) * length; onSketchPos.y = handler->startPoint.y + sin(angle) * length; } @@ -466,7 +467,7 @@ void DSHLineController::adaptParameters(Base::Vector2d onSketchPos) double range = (handler->endPoint - handler->startPoint).Angle(); if (!onViewParameters[OnViewParameter::Fourth]->isSet) { setOnViewParameterValue(OnViewParameter::Fourth, - range * 180 / M_PI, + Base::toDegrees(range), Base::Unit::Angle); } @@ -611,7 +612,7 @@ void DSHLineController::addConstraints() }; auto constraintp4angle = [&]() { - double angle = p4 / 180 * M_PI; + double angle = Base::toRadians(p4); if (fabs(angle - M_PI) < Precision::Confusion() || fabs(angle + M_PI) < Precision::Confusion() || fabs(angle) < Precision::Confusion()) { diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerPolygon.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerPolygon.h index 9e075650f5..e277d73606 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerPolygon.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerPolygon.h @@ -68,8 +68,9 @@ class DrawSketchHandlerPolygon: public DrawSketchHandlerPolygonBase friend DSHPolygonControllerBase; public: - explicit DrawSketchHandlerPolygon(int corners = 6) + explicit DrawSketchHandlerPolygon(int corners = 6) // NOLINT : numberOfCorners(corners) + , radius(0.0) {} ~DrawSketchHandlerPolygon() override = default; @@ -244,7 +245,7 @@ private: return; } - double angleOfSeparation = 2.0 * M_PI / static_cast(numberOfCorners); + double angleOfSeparation = 2.0 * M_PI / static_cast(numberOfCorners); // NOLINT double cos_v = cos(angleOfSeparation); double sin_v = sin(angleOfSeparation); @@ -292,7 +293,7 @@ template<> void DSHPolygonController::secondKeyShortcut() { auto value = toolWidget->getParameter(WParameter::First); - if (value > 3.0) { + if (value > 3.0) { // NOLINT toolWidget->setParameterWithoutPassingFocus(OnViewParameter::First, value - 1); } } @@ -306,9 +307,9 @@ void DSHPolygonController::configureToolWidget() toolWidget->setParameter(OnViewParameter::First, handler->numberOfCorners); // unconditionally set toolWidget->configureParameterUnit(OnViewParameter::First, Base::Unit()); - toolWidget->configureParameterMin(OnViewParameter::First, 3.0); + toolWidget->configureParameterMin(OnViewParameter::First, 3.0); // NOLINT // We set a reasonable max to avoid the spinbox from being very large - toolWidget->configureParameterMax(OnViewParameter::First, 9999.0); + toolWidget->configureParameterMax(OnViewParameter::First, 9999.0); // NOLINT toolWidget->configureParameterDecimals(OnViewParameter::First, 0); onViewParameters[OnViewParameter::First]->setLabelType(Gui::SoDatumLabel::DISTANCEX); @@ -362,7 +363,8 @@ void DSHPolygonControllerBase::doEnforceControlParameters(Base::Vector2d& onSket } if (onViewParameters[OnViewParameter::Fourth]->isSet) { - double angle = onViewParameters[OnViewParameter::Fourth]->getValue() * M_PI / 180; + double angle = + Base::toRadians(onViewParameters[OnViewParameter::Fourth]->getValue()); onSketchPos.x = handler->centerPoint.x + cos(angle) * length; onSketchPos.y = handler->centerPoint.y + sin(angle) * length; } @@ -405,7 +407,7 @@ void DSHPolygonController::adaptParameters(Base::Vector2d onSketchPos) double range = (handler->firstCorner - handler->centerPoint).Angle(); if (!onViewParameters[OnViewParameter::Fourth]->isSet) { setOnViewParameterValue(OnViewParameter::Fourth, - range * 180 / M_PI, + Base::toDegrees(range), Base::Unit::Angle); } diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerRectangle.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerRectangle.h index 54c04b9640..40a2419d44 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerRectangle.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerRectangle.h @@ -60,16 +60,16 @@ enum class RectangleConstructionMethod } -using DSHRectangleController = - DrawSketchDefaultWidgetController, - /*WidgetParametersT =*/WidgetParameters<0, 0, 0, 0>, - /*WidgetCheckboxesT =*/WidgetCheckboxes<2, 2, 2, 2>, - /*WidgetComboboxesT =*/WidgetComboboxes<1, 1, 1, 1>, - ConstructionMethods::RectangleConstructionMethod, - /*bool PFirstComboboxIsConstructionMethod =*/true>; +using DSHRectangleController = DrawSketchDefaultWidgetController< + DrawSketchHandlerRectangle, + StateMachines::FiveSeekEnd, + /*PAutoConstraintSize =*/3, + /*OnViewParametersT =*/OnViewParameters<6, 6, 8, 8>, // NOLINT + /*WidgetParametersT =*/WidgetParameters<0, 0, 0, 0>, // NOLINT + /*WidgetCheckboxesT =*/WidgetCheckboxes<2, 2, 2, 2>, // NOLINT + /*WidgetComboboxesT =*/WidgetComboboxes<1, 1, 1, 1>, // NOLINT + ConstructionMethods::RectangleConstructionMethod, + /*bool PFirstComboboxIsConstructionMethod =*/true>; using DSHRectangleControllerBase = DSHRectangleController::ControllerBase; @@ -91,6 +91,19 @@ public: , makeFrame(frame) , cornersReversed(false) , thickness(0.) + , radius(0.0) + , length(0.0) + , width(0.0) + , radiusFrame(0.0) + , angle(0.0) + , angle123(0.0) + , angle412(0.0) + , firstCurve(Sketcher::GeoEnum::GeoUndef) + , constructionPointOneId(Sketcher::GeoEnum::GeoUndef) + , constructionPointTwoId(Sketcher::GeoEnum::GeoUndef) + , constructionPointThreeId(Sketcher::GeoEnum::GeoUndef) + , centerPointId(Sketcher::GeoEnum::GeoUndef) + , side(0) {} ~DrawSketchHandlerRectangle() override = default; @@ -185,7 +198,7 @@ private: if (roundCorners) { length = (corner2 - corner1).Length(); width = (corner4 - corner1).Length(); - radius = std::min(length, width) / 6; + radius = std::min(length, width) / 6; // NOLINT } else { radius = 0.; @@ -238,7 +251,7 @@ private: } angle412 = M_PI - angle123; if (roundCorners) { - radius = std::min(length, width) / 6 + radius = std::min(length, width) / 6 // NOLINT * std::min(sqrt(1 - cos(angle412) * cos(angle412)), sqrt(1 - cos(angle123) * cos(angle123))); } @@ -267,7 +280,7 @@ private: } angle123 = M_PI - angle412; if (roundCorners) { - radius = std::min(length, width) / 6 + radius = std::min(length, width) / 6 // NOLINT * std::min(sqrt(1 - cos(angle412) * cos(angle412)), sqrt(1 - cos(angle123) * cos(angle123))); } @@ -801,42 +814,42 @@ private: addToShapeConstraints(Sketcher::Tangent, firstCurve, Sketcher::PointPos::start, - firstCurve + 4, + firstCurve + 4, // NOLINT Sketcher::PointPos::end); addToShapeConstraints(Sketcher::Tangent, firstCurve, Sketcher::PointPos::end, - firstCurve + 5, + firstCurve + 5, // NOLINT Sketcher::PointPos::start); addToShapeConstraints(Sketcher::Tangent, - firstCurve + 1, + firstCurve + 1, // NOLINT Sketcher::PointPos::start, - firstCurve + 5, + firstCurve + 5, // NOLINT Sketcher::PointPos::end); addToShapeConstraints(Sketcher::Tangent, - firstCurve + 1, + firstCurve + 1, // NOLINT Sketcher::PointPos::end, - firstCurve + 6, + firstCurve + 6, // NOLINT Sketcher::PointPos::start); addToShapeConstraints(Sketcher::Tangent, - firstCurve + 2, + firstCurve + 2, // NOLINT Sketcher::PointPos::start, - firstCurve + 6, + firstCurve + 6, // NOLINT Sketcher::PointPos::end); addToShapeConstraints(Sketcher::Tangent, - firstCurve + 2, + firstCurve + 2, // NOLINT Sketcher::PointPos::end, - firstCurve + 7, + firstCurve + 7, // NOLINT Sketcher::PointPos::start); addToShapeConstraints(Sketcher::Tangent, - firstCurve + 3, + firstCurve + 3, // NOLINT Sketcher::PointPos::start, - firstCurve + 7, + firstCurve + 7, // NOLINT Sketcher::PointPos::end); addToShapeConstraints(Sketcher::Tangent, - firstCurve + 3, + firstCurve + 3, // NOLINT Sketcher::PointPos::end, - firstCurve + 4, + firstCurve + 4, // NOLINT Sketcher::PointPos::start); if (fabs(angle) < Precision::Confusion() @@ -864,68 +877,68 @@ private: } } addToShapeConstraints(Sketcher::Equal, - firstCurve + 4, + firstCurve + 4, // NOLINT Sketcher::PointPos::none, - firstCurve + 5); + firstCurve + 5); // NOLINT addToShapeConstraints(Sketcher::Equal, - firstCurve + 5, + firstCurve + 5, // NOLINT Sketcher::PointPos::none, - firstCurve + 6); + firstCurve + 6); // NOLINT addToShapeConstraints(Sketcher::Equal, - firstCurve + 6, + firstCurve + 6, // NOLINT Sketcher::PointPos::none, - firstCurve + 7); + firstCurve + 7); // NOLINT if (fabs(thickness) > Precision::Confusion()) { if (radiusFrame < Precision::Confusion()) { // case inner rectangle is normal rectangle addToShapeConstraints(Sketcher::Coincident, - firstCurve + 8, + firstCurve + 8, // NOLINT Sketcher::PointPos::end, - firstCurve + 9, + firstCurve + 9, // NOLINT Sketcher::PointPos::start); addToShapeConstraints(Sketcher::Coincident, - firstCurve + 9, + firstCurve + 9, // NOLINT Sketcher::PointPos::end, - firstCurve + 10, + firstCurve + 10, // NOLINT Sketcher::PointPos::start); addToShapeConstraints(Sketcher::Coincident, - firstCurve + 10, + firstCurve + 10, // NOLINT Sketcher::PointPos::end, - firstCurve + 11, + firstCurve + 11, // NOLINT Sketcher::PointPos::start); addToShapeConstraints(Sketcher::Coincident, - firstCurve + 11, + firstCurve + 11, // NOLINT Sketcher::PointPos::end, - firstCurve + 8, + firstCurve + 8, // NOLINT Sketcher::PointPos::start); if (fabs(angle) < Precision::Confusion() || constructionMethod() == ConstructionMethod::Diagonal || constructionMethod() == ConstructionMethod::CenterAndCorner) { - addToShapeConstraints(typeA, firstCurve + 8); - addToShapeConstraints(typeA, firstCurve + 10); - addToShapeConstraints(typeB, firstCurve + 9); - addToShapeConstraints(typeB, firstCurve + 11); + addToShapeConstraints(typeA, firstCurve + 8); // NOLINT + addToShapeConstraints(typeA, firstCurve + 10); // NOLINT + addToShapeConstraints(typeB, firstCurve + 9); // NOLINT + addToShapeConstraints(typeB, firstCurve + 11); // NOLINT } else { addToShapeConstraints(Sketcher::Parallel, - firstCurve + 8, + firstCurve + 8, // NOLINT Sketcher::PointPos::none, - firstCurve + 10); + firstCurve + 10); // NOLINT addToShapeConstraints(Sketcher::Parallel, - firstCurve + 9, + firstCurve + 9, // NOLINT Sketcher::PointPos::none, - firstCurve + 11); + firstCurve + 11); // NOLINT addToShapeConstraints(Sketcher::Parallel, - firstCurve + 8, + firstCurve + 8, // NOLINT Sketcher::PointPos::none, firstCurve); addToShapeConstraints(Sketcher::Parallel, - firstCurve + 9, + firstCurve + 9, // NOLINT Sketcher::PointPos::none, - firstCurve + 1); + firstCurve + 1); // NOLINT } // add construction lines +12, +13, +14, +15 @@ -947,140 +960,140 @@ private: true); addToShapeConstraints(Sketcher::Coincident, - firstCurve + 12, + firstCurve + 12, // NOLINT Sketcher::PointPos::start, - firstCurve + 4, + firstCurve + 4, // NOLINT Sketcher::PointPos::mid); addToShapeConstraints(Sketcher::Coincident, - firstCurve + 12, + firstCurve + 12, // NOLINT Sketcher::PointPos::end, - firstCurve + 8, + firstCurve + 8, // NOLINT Sketcher::PointPos::start); addToShapeConstraints(Sketcher::Coincident, - firstCurve + 13, + firstCurve + 13, // NOLINT Sketcher::PointPos::start, - firstCurve + 5, + firstCurve + 5, // NOLINT Sketcher::PointPos::mid); addToShapeConstraints(Sketcher::Coincident, - firstCurve + 13, + firstCurve + 13, // NOLINT Sketcher::PointPos::end, - firstCurve + 9, + firstCurve + 9, // NOLINT Sketcher::PointPos::start); addToShapeConstraints(Sketcher::Coincident, - firstCurve + 14, + firstCurve + 14, // NOLINT Sketcher::PointPos::start, - firstCurve + 6, + firstCurve + 6, // NOLINT Sketcher::PointPos::mid); addToShapeConstraints(Sketcher::Coincident, - firstCurve + 14, + firstCurve + 14, // NOLINT Sketcher::PointPos::end, - firstCurve + 10, + firstCurve + 10, // NOLINT Sketcher::PointPos::start); addToShapeConstraints(Sketcher::Coincident, - firstCurve + 15, + firstCurve + 15, // NOLINT Sketcher::PointPos::start, - firstCurve + 7, + firstCurve + 7, // NOLINT Sketcher::PointPos::mid); addToShapeConstraints(Sketcher::Coincident, - firstCurve + 15, + firstCurve + 15, // NOLINT Sketcher::PointPos::end, - firstCurve + 11, + firstCurve + 11, // NOLINT Sketcher::PointPos::start); addToShapeConstraints(Sketcher::Perpendicular, - firstCurve + 12, + firstCurve + 12, // NOLINT Sketcher::PointPos::none, - firstCurve + 13); + firstCurve + 13); // NOLINT addToShapeConstraints(Sketcher::Perpendicular, - firstCurve + 13, + firstCurve + 13, // NOLINT Sketcher::PointPos::none, - firstCurve + 14); + firstCurve + 14); // NOLINT addToShapeConstraints(Sketcher::Perpendicular, - firstCurve + 14, + firstCurve + 14, // NOLINT Sketcher::PointPos::none, - firstCurve + 15); + firstCurve + 15); // NOLINT } else { // case inner rectangle is rounded rectangle addToShapeConstraints(Sketcher::Tangent, - firstCurve + 8, + firstCurve + 8, // NOLINT Sketcher::PointPos::start, - firstCurve + 12, + firstCurve + 12, // NOLINT Sketcher::PointPos::end); addToShapeConstraints(Sketcher::Tangent, - firstCurve + 8, + firstCurve + 8, // NOLINT Sketcher::PointPos::end, - firstCurve + 13, + firstCurve + 13, // NOLINT Sketcher::PointPos::start); addToShapeConstraints(Sketcher::Tangent, - firstCurve + 9, + firstCurve + 9, // NOLINT Sketcher::PointPos::start, - firstCurve + 13, + firstCurve + 13, // NOLINT Sketcher::PointPos::end); addToShapeConstraints(Sketcher::Tangent, - firstCurve + 9, + firstCurve + 9, // NOLINT Sketcher::PointPos::end, - firstCurve + 14, + firstCurve + 14, // NOLINT Sketcher::PointPos::start); addToShapeConstraints(Sketcher::Tangent, - firstCurve + 10, + firstCurve + 10, // NOLINT Sketcher::PointPos::start, - firstCurve + 14, + firstCurve + 14, // NOLINT Sketcher::PointPos::end); addToShapeConstraints(Sketcher::Tangent, - firstCurve + 10, + firstCurve + 10, // NOLINT Sketcher::PointPos::end, - firstCurve + 15, + firstCurve + 15, // NOLINT Sketcher::PointPos::start); addToShapeConstraints(Sketcher::Tangent, - firstCurve + 11, + firstCurve + 11, // NOLINT Sketcher::PointPos::start, - firstCurve + 15, + firstCurve + 15, // NOLINT Sketcher::PointPos::end); addToShapeConstraints(Sketcher::Tangent, - firstCurve + 11, + firstCurve + 11, // NOLINT Sketcher::PointPos::end, - firstCurve + 12, + firstCurve + 12, // NOLINT Sketcher::PointPos::start); addToShapeConstraints(Sketcher::Coincident, - firstCurve + 4, + firstCurve + 4, // NOLINT Sketcher::PointPos::mid, - firstCurve + 12, + firstCurve + 12, // NOLINT Sketcher::PointPos::mid); addToShapeConstraints(Sketcher::Coincident, - firstCurve + 5, + firstCurve + 5, // NOLINT Sketcher::PointPos::mid, - firstCurve + 13, + firstCurve + 13, // NOLINT Sketcher::PointPos::mid); addToShapeConstraints(Sketcher::Coincident, - firstCurve + 6, + firstCurve + 6, // NOLINT Sketcher::PointPos::mid, - firstCurve + 14, + firstCurve + 14, // NOLINT Sketcher::PointPos::mid); addToShapeConstraints(Sketcher::Coincident, - firstCurve + 7, + firstCurve + 7, // NOLINT Sketcher::PointPos::mid, - firstCurve + 15, + firstCurve + 15, // NOLINT Sketcher::PointPos::mid); if (fabs(angle) < Precision::Confusion() || constructionMethod() == ConstructionMethod::Diagonal || constructionMethod() == ConstructionMethod::CenterAndCorner) { - addToShapeConstraints(typeA, firstCurve + 8); - addToShapeConstraints(typeA, firstCurve + 10); - addToShapeConstraints(typeB, firstCurve + 9); + addToShapeConstraints(typeA, firstCurve + 8); // NOLINT + addToShapeConstraints(typeA, firstCurve + 10); // NOLINT + addToShapeConstraints(typeB, firstCurve + 9); // NOLINT } else { addToShapeConstraints(Sketcher::Parallel, - firstCurve + 8, + firstCurve + 8, // NOLINT Sketcher::PointPos::none, - firstCurve + 10); + firstCurve + 10); // NOLINT addToShapeConstraints(Sketcher::Parallel, - firstCurve + 9, + firstCurve + 9, // NOLINT Sketcher::PointPos::none, - firstCurve + 11); + firstCurve + 11); // NOLINT addToShapeConstraints(Sketcher::Parallel, - firstCurve + 8, + firstCurve + 8, // NOLINT Sketcher::PointPos::none, firstCurve); } @@ -1089,14 +1102,14 @@ private: if (constructionMethod() == ConstructionMethod::ThreePoints) { if (fabs(thickness) > Precision::Confusion()) { - constructionPointOneId = firstCurve + 16; - constructionPointTwoId = firstCurve + 17; - constructionPointThreeId = firstCurve + 18; + constructionPointOneId = firstCurve + 16; // NOLINT + constructionPointTwoId = firstCurve + 17; // NOLINT + constructionPointThreeId = firstCurve + 18; // NOLINT } else { - constructionPointOneId = firstCurve + 8; - constructionPointTwoId = firstCurve + 9; - constructionPointThreeId = firstCurve + 10; + constructionPointOneId = firstCurve + 8; // NOLINT + constructionPointTwoId = firstCurve + 9; // NOLINT + constructionPointThreeId = firstCurve + 10; // NOLINT } addPointToShapeGeometry(Base::Vector3d(corner1.x, corner1.y, 0.), true); @@ -1142,14 +1155,14 @@ private: } else if (constructionMethod() == ConstructionMethod::CenterAnd3Points) { if (fabs(thickness) > Precision::Confusion()) { - constructionPointOneId = firstCurve + 16; - constructionPointTwoId = firstCurve + 17; - centerPointId = firstCurve + 18; + constructionPointOneId = firstCurve + 16; // NOLINT + constructionPointTwoId = firstCurve + 17; // NOLINT + centerPointId = firstCurve + 18; // NOLINT } else { - constructionPointOneId = firstCurve + 8; - constructionPointTwoId = firstCurve + 9; - centerPointId = firstCurve + 10; + constructionPointOneId = firstCurve + 8; // NOLINT + constructionPointTwoId = firstCurve + 9; // NOLINT + centerPointId = firstCurve + 10; // NOLINT } addPointToShapeGeometry(Base::Vector3d(corner1.x, corner1.y, 0.), true); @@ -1190,16 +1203,16 @@ private: addToShapeConstraints(Sketcher::PointOnObject, constructionPointOneId, Sketcher::PointPos::start, - firstCurve + 3); + firstCurve + 3); // NOLINT } else if (constructionMethod() == ConstructionMethod::CenterAndCorner) { if (fabs(thickness) > Precision::Confusion()) { - constructionPointOneId = firstCurve + 16; - centerPointId = firstCurve + 17; + constructionPointOneId = firstCurve + 16; // NOLINT + centerPointId = firstCurve + 17; // NOLINT } else { - constructionPointOneId = firstCurve + 8; - centerPointId = firstCurve + 9; + constructionPointOneId = firstCurve + 8; // NOLINT + centerPointId = firstCurve + 9; // NOLINT } addPointToShapeGeometry(Base::Vector3d(corner3.x, corner3.y, 0.), true); @@ -1222,12 +1235,12 @@ private: } else { if (fabs(thickness) > Precision::Confusion()) { - constructionPointOneId = firstCurve + 16; - constructionPointTwoId = firstCurve + 17; + constructionPointOneId = firstCurve + 16; // NOLINT + constructionPointTwoId = firstCurve + 17; // NOLINT } else { - constructionPointOneId = firstCurve + 8; - constructionPointTwoId = firstCurve + 9; + constructionPointOneId = firstCurve + 8; // NOLINT + constructionPointTwoId = firstCurve + 9; // NOLINT } addPointToShapeGeometry(Base::Vector3d(corner1.x, corner1.y, 0.), true); @@ -1298,51 +1311,51 @@ private: if (fabs(thickness) > Precision::Confusion()) { addToShapeConstraints(Sketcher::Coincident, - firstCurve + 4, + firstCurve + 4, // NOLINT Sketcher::PointPos::end, - firstCurve + 5, + firstCurve + 5, // NOLINT Sketcher::PointPos::start); addToShapeConstraints(Sketcher::Coincident, - firstCurve + 5, + firstCurve + 5, // NOLINT Sketcher::PointPos::end, - firstCurve + 6, + firstCurve + 6, // NOLINT Sketcher::PointPos::start); addToShapeConstraints(Sketcher::Coincident, - firstCurve + 6, + firstCurve + 6, // NOLINT Sketcher::PointPos::end, - firstCurve + 7, + firstCurve + 7, // NOLINT Sketcher::PointPos::start); addToShapeConstraints(Sketcher::Coincident, - firstCurve + 7, + firstCurve + 7, // NOLINT Sketcher::PointPos::end, - firstCurve + 4, + firstCurve + 4, // NOLINT Sketcher::PointPos::start); if (fabs(angle) < Precision::Confusion() || constructionMethod() == ConstructionMethod::Diagonal || constructionMethod() == ConstructionMethod::CenterAndCorner) { - addToShapeConstraints(typeA, firstCurve + 4); - addToShapeConstraints(typeA, firstCurve + 6); - addToShapeConstraints(typeB, firstCurve + 5); - addToShapeConstraints(typeB, firstCurve + 7); + addToShapeConstraints(typeA, firstCurve + 4); // NOLINT + addToShapeConstraints(typeA, firstCurve + 6); // NOLINT + addToShapeConstraints(typeB, firstCurve + 5); // NOLINT + addToShapeConstraints(typeB, firstCurve + 7); // NOLINT } else { addToShapeConstraints(Sketcher::Parallel, - firstCurve + 4, + firstCurve + 4, // NOLINT Sketcher::PointPos::none, - firstCurve + 6); + firstCurve + 6); // NOLINT addToShapeConstraints(Sketcher::Parallel, - firstCurve + 5, + firstCurve + 5, // NOLINT Sketcher::PointPos::none, - firstCurve + 7); + firstCurve + 7); // NOLINT addToShapeConstraints(Sketcher::Parallel, firstCurve, Sketcher::PointPos::none, - firstCurve + 4); + firstCurve + 4); // NOLINT addToShapeConstraints(Sketcher::Parallel, - firstCurve + 1, + firstCurve + 1, // NOLINT Sketcher::PointPos::none, - firstCurve + 5); + firstCurve + 5); // NOLINT } // add construction lines @@ -1360,72 +1373,72 @@ private: true); addToShapeConstraints(Sketcher::Coincident, - firstCurve + 8, + firstCurve + 8, // NOLINT Sketcher::PointPos::start, firstCurve, Sketcher::PointPos::start); addToShapeConstraints(Sketcher::Coincident, - firstCurve + 8, + firstCurve + 8, // NOLINT Sketcher::PointPos::end, - firstCurve + 4, + firstCurve + 4, // NOLINT Sketcher::PointPos::start); addToShapeConstraints(Sketcher::Coincident, - firstCurve + 9, + firstCurve + 9, // NOLINT Sketcher::PointPos::start, - firstCurve + 1, + firstCurve + 1, // NOLINT Sketcher::PointPos::start); addToShapeConstraints(Sketcher::Coincident, - firstCurve + 9, + firstCurve + 9, // NOLINT Sketcher::PointPos::end, - firstCurve + 5, + firstCurve + 5, // NOLINT Sketcher::PointPos::start); addToShapeConstraints(Sketcher::Coincident, - firstCurve + 10, + firstCurve + 10, // NOLINT Sketcher::PointPos::start, - firstCurve + 2, + firstCurve + 2, // NOLINT Sketcher::PointPos::start); addToShapeConstraints(Sketcher::Coincident, - firstCurve + 10, + firstCurve + 10, // NOLINT Sketcher::PointPos::end, - firstCurve + 6, + firstCurve + 6, // NOLINT Sketcher::PointPos::start); addToShapeConstraints(Sketcher::Coincident, - firstCurve + 11, + firstCurve + 11, // NOLINT Sketcher::PointPos::start, - firstCurve + 3, + firstCurve + 3, // NOLINT Sketcher::PointPos::start); addToShapeConstraints(Sketcher::Coincident, - firstCurve + 11, + firstCurve + 11, // NOLINT Sketcher::PointPos::end, - firstCurve + 7, + firstCurve + 7, // NOLINT Sketcher::PointPos::start); addToShapeConstraints(Sketcher::Perpendicular, - firstCurve + 8, + firstCurve + 8, // NOLINT Sketcher::PointPos::none, - firstCurve + 9); + firstCurve + 9); // NOLINT addToShapeConstraints(Sketcher::Perpendicular, - firstCurve + 9, + firstCurve + 9, // NOLINT Sketcher::PointPos::none, - firstCurve + 10); + firstCurve + 10); // NOLINT addToShapeConstraints(Sketcher::Perpendicular, - firstCurve + 10, + firstCurve + 10, // NOLINT Sketcher::PointPos::none, - firstCurve + 11); + firstCurve + 11); // NOLINT } if (constructionMethod() == ConstructionMethod::CenterAndCorner || constructionMethod() == ConstructionMethod::CenterAnd3Points) { if (fabs(thickness) > Precision::Confusion()) { - centerPointId = firstCurve + 12; + centerPointId = firstCurve + 12; // NOLINT } else { - centerPointId = firstCurve + 4; + centerPointId = firstCurve + 4; // NOLINT } addPointToShapeGeometry(Base::Vector3d(center.x, center.y, 0.), true); addToShapeConstraints(Sketcher::Symmetric, - firstCurve + 2, + firstCurve + 2, // NOLINT Sketcher::PointPos::start, firstCurve, Sketcher::PointPos::start, @@ -1504,7 +1517,7 @@ private: } radius = std::min( radius, - std::min(length * 0.999, width * 0.999) + std::min(length * 0.999, width * 0.999) // NOLINT / (cos(angle412 / 2) / sqrt(1 - cos(angle412 / 2) * cos(angle412 / 2)) + cos(angle123 / 2) / sqrt(1 - cos(angle123 / 2) * cos(angle123 / 2)))); } @@ -1843,7 +1856,7 @@ void DSHRectangleControllerBase::doEnforceControlParameters(Base::Vector2d& onSk if (onViewParameters[OnViewParameter::Fourth]->isSet) { double angle = - onViewParameters[OnViewParameter::Fourth]->getValue() * M_PI / 180; + Base::toRadians(onViewParameters[OnViewParameter::Fourth]->getValue()); onSketchPos.x = handler->corner1.x + cos(angle) * length; onSketchPos.y = handler->corner1.y + sin(angle) * length; } @@ -1906,7 +1919,7 @@ void DSHRectangleControllerBase::doEnforceControlParameters(Base::Vector2d& onSk } if (onViewParameters[OnViewParameter::Sixth]->isSet) { double angle = - onViewParameters[OnViewParameter::Sixth]->getValue() * M_PI / 180; + Base::toRadians(onViewParameters[OnViewParameter::Sixth]->getValue()); if (fmod(angle, M_PI) < Precision::Confusion()) { unsetOnViewParameter(onViewParameters[OnViewParameter::Sixth].get()); return; @@ -1942,7 +1955,8 @@ void DSHRectangleControllerBase::doEnforceControlParameters(Base::Vector2d& onSk onSketchPos = handler->corner1 + width * dir.Normalize(); } if (onViewParameters[OnViewParameter::Sixth]->isSet) { - double c = onViewParameters[OnViewParameter::Sixth]->getValue() * M_PI / 180; + double c = + Base::toRadians(onViewParameters[OnViewParameter::Sixth]->getValue()); if (fmod(c, M_PI) < Precision::Confusion()) { unsetOnViewParameter(onViewParameters[OnViewParameter::Sixth].get()); return; @@ -2096,7 +2110,7 @@ void DSHRectangleController::adaptParameters(Base::Vector2d onSketchPos) if (!onViewParameters[OnViewParameter::Fourth]->isSet) { setOnViewParameterValue(OnViewParameter::Fourth, - handler->angle * 180 / M_PI, + Base::toDegrees(handler->angle), Base::Unit::Angle); } @@ -2173,11 +2187,11 @@ void DSHRectangleController::adaptParameters(Base::Vector2d onSketchPos) if (!onViewParameters[OnViewParameter::Sixth]->isSet) { if (threePoints) { - double val = handler->angle123 * 180 / M_PI; + double val = Base::toDegrees(handler->angle123); setOnViewParameterValue(OnViewParameter::Sixth, val, Base::Unit::Angle); } else { - double val = handler->angle412 * 180 / M_PI; + double val = Base::toDegrees(handler->angle412); setOnViewParameterValue(OnViewParameter::Sixth, val, Base::Unit::Angle); } } @@ -2366,8 +2380,8 @@ void DSHRectangleController::addConstraints() auto radiusSet = onViewParameters[OnViewParameter::Fifth]->isSet; auto thicknessSet = onViewParameters[OnViewParameter::Sixth]->isSet; - auto angle = onViewParameters[OnViewParameter::Fourth]->getValue() / 180 * M_PI; - auto innerAngle = onViewParameters[OnViewParameter::Sixth]->getValue() / 180 * M_PI; + auto angle = Base::toRadians(onViewParameters[OnViewParameter::Fourth]->getValue()); + auto innerAngle = Base::toRadians(onViewParameters[OnViewParameter::Sixth]->getValue()); auto angleSet = onViewParameters[OnViewParameter::Fourth]->isSet; auto innerAngleSet = onViewParameters[OnViewParameter::Sixth]->isSet; @@ -2560,14 +2574,14 @@ void DSHRectangleController::addConstraints() if (radiusSet && radius > Precision::Confusion()) { Gui::cmdAppObjectArgs(obj, "addConstraint(Sketcher.Constraint('Radius',%d,%f)) ", - firstCurve + 5, + firstCurve + 5, // NOLINT radius); } if (thicknessSet) { Gui::cmdAppObjectArgs(obj, "addConstraint(Sketcher.Constraint('Distance',%d,%d,%d,%f)) ", - firstCurve + (handler->roundCorners == true ? 8 : 4), + firstCurve + (handler->roundCorners == true ? 8 : 4), // NOLINT 1, firstCurve, fabs(thickness));