fix unique ptr usage in sketch (#15008)

* fix unique ptr usage in sketch

* [pre-commit.ci] auto fixes from pre-commit.com hooks
This commit is contained in:
ppphp
2024-07-08 23:53:49 +08:00
committed by GitHub
parent 24c7d3ef25
commit 51c6dbd3e3
11 changed files with 110 additions and 112 deletions

View File

@@ -181,7 +181,7 @@ CONSTRUCTION_UPDATE_ACTION(CmdSketcherCreateLine, "Sketcher_CreateLine")
void CmdSketcherCreateLine::activated(int iMsg)
{
Q_UNUSED(iMsg);
ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerLine());
ActivateHandler(getActiveGuiDocument(), std::make_unique<DrawSketchHandlerLine>());
}
bool CmdSketcherCreateLine::isActive()
@@ -212,7 +212,7 @@ CONSTRUCTION_UPDATE_ACTION(CmdSketcherCreatePolyline, "Sketcher_CreatePolyline")
void CmdSketcherCreatePolyline::activated(int iMsg)
{
Q_UNUSED(iMsg);
ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerLineSet());
ActivateHandler(getActiveGuiDocument(), std::make_unique<DrawSketchHandlerLineSet>());
}
bool CmdSketcherCreatePolyline::isActive()
@@ -244,9 +244,9 @@ CONSTRUCTION_UPDATE_ACTION(CmdSketcherCreateRectangle, "Sketcher_CreateRectangle
void CmdSketcherCreateRectangle::activated(int iMsg)
{
Q_UNUSED(iMsg);
ActivateHandler(
getActiveGuiDocument(),
new DrawSketchHandlerRectangle(ConstructionMethods::RectangleConstructionMethod::Diagonal));
ActivateHandler(getActiveGuiDocument(),
std::make_unique<DrawSketchHandlerRectangle>(
ConstructionMethods::RectangleConstructionMethod::Diagonal));
}
bool CmdSketcherCreateRectangle::isActive()
@@ -276,7 +276,7 @@ void CmdSketcherCreateRectangleCenter::activated(int iMsg)
{
Q_UNUSED(iMsg);
ActivateHandler(getActiveGuiDocument(),
new DrawSketchHandlerRectangle(
std::make_unique<DrawSketchHandlerRectangle>(
ConstructionMethods::RectangleConstructionMethod::CenterAndCorner));
}
@@ -309,10 +309,10 @@ CONSTRUCTION_UPDATE_ACTION(CmdSketcherCreateOblong, "Sketcher_CreateOblong")
void CmdSketcherCreateOblong::activated(int iMsg)
{
Q_UNUSED(iMsg);
ActivateHandler(
getActiveGuiDocument(),
new DrawSketchHandlerRectangle(ConstructionMethods::RectangleConstructionMethod::Diagonal,
true));
ActivateHandler(getActiveGuiDocument(),
std::make_unique<DrawSketchHandlerRectangle>(
ConstructionMethods::RectangleConstructionMethod::Diagonal,
true));
}
bool CmdSketcherCreateOblong::isActive()
@@ -340,17 +340,17 @@ void CmdSketcherCompCreateRectangles::activated(int iMsg)
{
if (iMsg == 0) {
ActivateHandler(getActiveGuiDocument(),
new DrawSketchHandlerRectangle(
std::make_unique<DrawSketchHandlerRectangle>(
ConstructionMethods::RectangleConstructionMethod::Diagonal));
}
else if (iMsg == 1) {
ActivateHandler(getActiveGuiDocument(),
new DrawSketchHandlerRectangle(
std::make_unique<DrawSketchHandlerRectangle>(
ConstructionMethods::RectangleConstructionMethod::CenterAndCorner));
}
else if (iMsg == 2) {
ActivateHandler(getActiveGuiDocument(),
new DrawSketchHandlerRectangle(
std::make_unique<DrawSketchHandlerRectangle>(
ConstructionMethods::RectangleConstructionMethod::Diagonal,
true));
}
@@ -473,7 +473,7 @@ CONSTRUCTION_UPDATE_ACTION(CmdSketcherCreateArc, "Sketcher_CreateArc")
void CmdSketcherCreateArc::activated(int iMsg)
{
Q_UNUSED(iMsg);
ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerArc());
ActivateHandler(getActiveGuiDocument(), std::make_unique<DrawSketchHandlerArc>());
}
bool CmdSketcherCreateArc::isActive()
@@ -505,9 +505,9 @@ CONSTRUCTION_UPDATE_ACTION(CmdSketcherCreate3PointArc, "Sketcher_Create3PointArc
void CmdSketcherCreate3PointArc::activated(int iMsg)
{
Q_UNUSED(iMsg);
ActivateHandler(
getActiveGuiDocument(),
new DrawSketchHandlerArc(ConstructionMethods::CircleEllipseConstructionMethod::ThreeRim));
ActivateHandler(getActiveGuiDocument(),
std::make_unique<DrawSketchHandlerArc>(
ConstructionMethods::CircleEllipseConstructionMethod::ThreeRim));
}
bool CmdSketcherCreate3PointArc::isActive()
@@ -608,7 +608,7 @@ CONSTRUCTION_UPDATE_ACTION(CmdSketcherCreateCircle, "Sketcher_CreateCircle")
void CmdSketcherCreateCircle::activated(int iMsg)
{
Q_UNUSED(iMsg);
ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerCircle());
ActivateHandler(getActiveGuiDocument(), std::make_unique<DrawSketchHandlerCircle>());
}
bool CmdSketcherCreateCircle::isActive()
@@ -642,7 +642,7 @@ CONSTRUCTION_UPDATE_ACTION(CmdSketcherCreateEllipseByCenter, "Sketcher_CreateEll
void CmdSketcherCreateEllipseByCenter::activated(int iMsg)
{
Q_UNUSED(iMsg);
ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerEllipse());
ActivateHandler(getActiveGuiDocument(), std::make_unique<DrawSketchHandlerEllipse>());
}
bool CmdSketcherCreateEllipseByCenter::isActive()
@@ -676,7 +676,7 @@ void CmdSketcherCreateEllipseBy3Points::activated(int iMsg)
{
Q_UNUSED(iMsg);
ActivateHandler(getActiveGuiDocument(),
new DrawSketchHandlerEllipse(
std::make_unique<DrawSketchHandlerEllipse>(
ConstructionMethods::CircleEllipseConstructionMethod::ThreeRim));
}
@@ -706,7 +706,7 @@ CONSTRUCTION_UPDATE_ACTION(CmdSketcherCreateArcOfEllipse, "Sketcher_CreateEllipt
void CmdSketcherCreateArcOfEllipse::activated(int iMsg)
{
Q_UNUSED(iMsg);
ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerArcOfEllipse());
ActivateHandler(getActiveGuiDocument(), std::make_unique<DrawSketchHandlerArcOfEllipse>());
}
bool CmdSketcherCreateArcOfEllipse::isActive()
@@ -734,7 +734,7 @@ CONSTRUCTION_UPDATE_ACTION(CmdSketcherCreateArcOfHyperbola, "Sketcher_CreateHype
void CmdSketcherCreateArcOfHyperbola::activated(int /*iMsg*/)
{
ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerArcOfHyperbola());
ActivateHandler(getActiveGuiDocument(), std::make_unique<DrawSketchHandlerArcOfHyperbola>());
}
bool CmdSketcherCreateArcOfHyperbola::isActive()
@@ -762,7 +762,7 @@ CONSTRUCTION_UPDATE_ACTION(CmdSketcherCreateArcOfParabola, "Sketcher_CreateParab
void CmdSketcherCreateArcOfParabola::activated(int /*iMsg*/)
{
ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerArcOfParabola());
ActivateHandler(getActiveGuiDocument(), std::make_unique<DrawSketchHandlerArcOfParabola>());
}
bool CmdSketcherCreateArcOfParabola::isActive()
@@ -860,7 +860,7 @@ void CmdSketcherCreateBSpline::activated(int iMsg)
{
Q_UNUSED(iMsg);
ActivateHandler(getActiveGuiDocument(),
new DrawSketchHandlerBSpline(
std::make_unique<DrawSketchHandlerBSpline>(
ConstructionMethods::BSplineConstructionMethod::ControlPoints));
}
@@ -894,10 +894,10 @@ CONSTRUCTION_UPDATE_ACTION(CmdSketcherCreatePeriodicBSpline, "Sketcher_Create_Pe
void CmdSketcherCreatePeriodicBSpline::activated(int iMsg)
{
Q_UNUSED(iMsg);
ActivateHandler(
getActiveGuiDocument(),
new DrawSketchHandlerBSpline(ConstructionMethods::BSplineConstructionMethod::ControlPoints,
true));
ActivateHandler(getActiveGuiDocument(),
std::make_unique<DrawSketchHandlerBSpline>(
ConstructionMethods::BSplineConstructionMethod::ControlPoints,
true));
}
bool CmdSketcherCreatePeriodicBSpline::isActive()
@@ -929,9 +929,9 @@ CONSTRUCTION_UPDATE_ACTION(CmdSketcherCreateBSplineByInterpolation,
void CmdSketcherCreateBSplineByInterpolation::activated(int iMsg)
{
Q_UNUSED(iMsg);
ActivateHandler(
getActiveGuiDocument(),
new DrawSketchHandlerBSpline(ConstructionMethods::BSplineConstructionMethod::Knots));
ActivateHandler(getActiveGuiDocument(),
std::make_unique<DrawSketchHandlerBSpline>(
ConstructionMethods::BSplineConstructionMethod::Knots));
}
bool CmdSketcherCreateBSplineByInterpolation::isActive()
@@ -964,9 +964,11 @@ CONSTRUCTION_UPDATE_ACTION(CmdSketcherCreatePeriodicBSplineByInterpolation,
void CmdSketcherCreatePeriodicBSplineByInterpolation::activated(int iMsg)
{
Q_UNUSED(iMsg);
ActivateHandler(
getActiveGuiDocument(),
new DrawSketchHandlerBSpline(ConstructionMethods::BSplineConstructionMethod::Knots, true));
ActivateHandler(getActiveGuiDocument(),
std::make_unique<DrawSketchHandlerBSpline>(
ConstructionMethods::BSplineConstructionMethod::Knots,
true));
}
bool CmdSketcherCreatePeriodicBSplineByInterpolation::isActive()
@@ -1001,25 +1003,25 @@ void CmdSketcherCompCreateBSpline::activated(int iMsg)
{
if (iMsg == 0) {
ActivateHandler(getActiveGuiDocument(),
new DrawSketchHandlerBSpline(
std::make_unique<DrawSketchHandlerBSpline>(
ConstructionMethods::BSplineConstructionMethod::ControlPoints));
}
else if (iMsg == 1) {
ActivateHandler(getActiveGuiDocument(),
new DrawSketchHandlerBSpline(
std::make_unique<DrawSketchHandlerBSpline>(
ConstructionMethods::BSplineConstructionMethod::ControlPoints,
true));
}
else if (iMsg == 2) {
ActivateHandler(
getActiveGuiDocument(),
new DrawSketchHandlerBSpline(ConstructionMethods::BSplineConstructionMethod::Knots));
ActivateHandler(getActiveGuiDocument(),
std::make_unique<DrawSketchHandlerBSpline>(
ConstructionMethods::BSplineConstructionMethod::Knots));
}
else if (iMsg == 3) {
ActivateHandler(
getActiveGuiDocument(),
new DrawSketchHandlerBSpline(ConstructionMethods::BSplineConstructionMethod::Knots,
true));
ActivateHandler(getActiveGuiDocument(),
std::make_unique<DrawSketchHandlerBSpline>(
ConstructionMethods::BSplineConstructionMethod::Knots,
true));
}
else {
return;
@@ -1173,7 +1175,7 @@ void CmdSketcherCreate3PointCircle::activated(int iMsg)
{
Q_UNUSED(iMsg);
ActivateHandler(getActiveGuiDocument(),
new DrawSketchHandlerCircle(
std::make_unique<DrawSketchHandlerCircle>(
ConstructionMethods::CircleEllipseConstructionMethod::ThreeRim));
}
@@ -1204,7 +1206,7 @@ CmdSketcherCreatePoint::CmdSketcherCreatePoint()
void CmdSketcherCreatePoint::activated(int iMsg)
{
Q_UNUSED(iMsg);
ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerPoint());
ActivateHandler(getActiveGuiDocument(), std::make_unique<DrawSketchHandlerPoint>());
}
bool CmdSketcherCreatePoint::isActive()
@@ -1233,9 +1235,9 @@ CmdSketcherCreateFillet::CmdSketcherCreateFillet()
void CmdSketcherCreateFillet::activated(int iMsg)
{
Q_UNUSED(iMsg);
ActivateHandler(
getActiveGuiDocument(),
new DrawSketchHandlerFillet(ConstructionMethods::FilletConstructionMethod::Fillet));
ActivateHandler(getActiveGuiDocument(),
std::make_unique<DrawSketchHandlerFillet>(
ConstructionMethods::FilletConstructionMethod::Fillet));
}
bool CmdSketcherCreateFillet::isActive()
@@ -1264,9 +1266,9 @@ CmdSketcherCreateChamfer::CmdSketcherCreateChamfer()
void CmdSketcherCreateChamfer::activated(int iMsg)
{
Q_UNUSED(iMsg);
ActivateHandler(
getActiveGuiDocument(),
new DrawSketchHandlerFillet(ConstructionMethods::FilletConstructionMethod::Chamfer));
ActivateHandler(getActiveGuiDocument(),
std::make_unique<DrawSketchHandlerFillet>(
ConstructionMethods::FilletConstructionMethod::Chamfer));
}
bool CmdSketcherCreateChamfer::isActive()
@@ -1328,7 +1330,7 @@ CmdSketcherTrimming::CmdSketcherTrimming()
void CmdSketcherTrimming::activated(int iMsg)
{
Q_UNUSED(iMsg);
ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerTrimming());
ActivateHandler(getActiveGuiDocument(), std::make_unique<DrawSketchHandlerTrimming>());
}
bool CmdSketcherTrimming::isActive()
@@ -1359,7 +1361,7 @@ CmdSketcherExtend::CmdSketcherExtend()
void CmdSketcherExtend::activated(int iMsg)
{
Q_UNUSED(iMsg);
ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerExtend());
ActivateHandler(getActiveGuiDocument(), std::make_unique<DrawSketchHandlerExtend>());
}
bool CmdSketcherExtend::isActive()
@@ -1390,7 +1392,7 @@ CmdSketcherSplit::CmdSketcherSplit()
void CmdSketcherSplit::activated(int iMsg)
{
Q_UNUSED(iMsg);
ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerSplitting());
ActivateHandler(getActiveGuiDocument(), std::make_unique<DrawSketchHandlerSplitting>());
}
bool CmdSketcherSplit::isActive()
@@ -1453,7 +1455,7 @@ CmdSketcherExternal::CmdSketcherExternal()
void CmdSketcherExternal::activated(int iMsg)
{
Q_UNUSED(iMsg);
ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerExternal());
ActivateHandler(getActiveGuiDocument(), std::make_unique<DrawSketchHandlerExternal>());
}
bool CmdSketcherExternal::isActive()
@@ -1484,7 +1486,7 @@ CONSTRUCTION_UPDATE_ACTION(CmdSketcherCarbonCopy, "Sketcher_CarbonCopy")
void CmdSketcherCarbonCopy::activated(int iMsg)
{
Q_UNUSED(iMsg);
ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerCarbonCopy());
ActivateHandler(getActiveGuiDocument(), std::make_unique<DrawSketchHandlerCarbonCopy>());
}
bool CmdSketcherCarbonCopy::isActive()
@@ -1571,7 +1573,7 @@ CONSTRUCTION_UPDATE_ACTION(CmdSketcherCreateSlot, "Sketcher_CreateSlot")
void CmdSketcherCreateSlot::activated(int iMsg)
{
Q_UNUSED(iMsg);
ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerSlot());
ActivateHandler(getActiveGuiDocument(), std::make_unique<DrawSketchHandlerSlot>());
}
bool CmdSketcherCreateSlot::isActive()
@@ -1602,7 +1604,7 @@ CONSTRUCTION_UPDATE_ACTION(CmdSketcherCreateArcSlot, "Sketcher_CreateArcSlot")
void CmdSketcherCreateArcSlot::activated(int iMsg)
{
Q_UNUSED(iMsg);
ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerArcSlot());
ActivateHandler(getActiveGuiDocument(), std::make_unique<DrawSketchHandlerArcSlot>());
}
bool CmdSketcherCreateArcSlot::isActive(void)
@@ -1633,7 +1635,7 @@ CONSTRUCTION_UPDATE_ACTION(CmdSketcherCreateTriangle, "Sketcher_CreateTriangle")
void CmdSketcherCreateTriangle::activated(int iMsg)
{
Q_UNUSED(iMsg);
ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerPolygon(3));
ActivateHandler(getActiveGuiDocument(), std::make_unique<DrawSketchHandlerPolygon>(3));
}
bool CmdSketcherCreateTriangle::isActive()
@@ -1662,7 +1664,7 @@ CONSTRUCTION_UPDATE_ACTION(CmdSketcherCreateSquare, "Sketcher_CreateSquare")
void CmdSketcherCreateSquare::activated(int iMsg)
{
Q_UNUSED(iMsg);
ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerPolygon(4));
ActivateHandler(getActiveGuiDocument(), std::make_unique<DrawSketchHandlerPolygon>(4));
}
bool CmdSketcherCreateSquare::isActive()
@@ -1691,7 +1693,7 @@ CONSTRUCTION_UPDATE_ACTION(CmdSketcherCreatePentagon, "Sketcher_CreatePentagon")
void CmdSketcherCreatePentagon::activated(int iMsg)
{
Q_UNUSED(iMsg);
ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerPolygon(5));
ActivateHandler(getActiveGuiDocument(), std::make_unique<DrawSketchHandlerPolygon>(5));
}
bool CmdSketcherCreatePentagon::isActive()
@@ -1721,7 +1723,7 @@ CONSTRUCTION_UPDATE_ACTION(CmdSketcherCreateHexagon, "Sketcher_CreateHexagon")
void CmdSketcherCreateHexagon::activated(int iMsg)
{
Q_UNUSED(iMsg);
ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerPolygon(6));
ActivateHandler(getActiveGuiDocument(), std::make_unique<DrawSketchHandlerPolygon>(6));
}
bool CmdSketcherCreateHexagon::isActive()
@@ -1750,7 +1752,7 @@ CONSTRUCTION_UPDATE_ACTION(CmdSketcherCreateHeptagon, "Sketcher_CreateHeptagon")
void CmdSketcherCreateHeptagon::activated(int iMsg)
{
Q_UNUSED(iMsg);
ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerPolygon(7));
ActivateHandler(getActiveGuiDocument(), std::make_unique<DrawSketchHandlerPolygon>(7));
}
bool CmdSketcherCreateHeptagon::isActive()
@@ -1779,7 +1781,7 @@ CONSTRUCTION_UPDATE_ACTION(CmdSketcherCreateOctagon, "Sketcher_CreateOctagon")
void CmdSketcherCreateOctagon::activated(int iMsg)
{
Q_UNUSED(iMsg);
ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerPolygon(8));
ActivateHandler(getActiveGuiDocument(), std::make_unique<DrawSketchHandlerPolygon>(8));
}
bool CmdSketcherCreateOctagon::isActive()
@@ -1812,7 +1814,8 @@ void CmdSketcherCreateRegularPolygon::activated(int iMsg)
// Pop-up asking for values
SketcherRegularPolygonDialog srpd;
if (srpd.exec() == QDialog::Accepted) {
ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerPolygon(srpd.sides));
ActivateHandler(getActiveGuiDocument(),
std::make_unique<DrawSketchHandlerPolygon>(srpd.sides));
}
}
@@ -1840,28 +1843,29 @@ void CmdSketcherCompCreateRegularPolygon::activated(int iMsg)
{
switch (iMsg) {
case 0:
ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerPolygon(3));
ActivateHandler(getActiveGuiDocument(), std::make_unique<DrawSketchHandlerPolygon>(3));
break;
case 1:
ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerPolygon(4));
ActivateHandler(getActiveGuiDocument(), std::make_unique<DrawSketchHandlerPolygon>(4));
break;
case 2:
ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerPolygon(5));
ActivateHandler(getActiveGuiDocument(), std::make_unique<DrawSketchHandlerPolygon>(5));
break;
case 3:
ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerPolygon(6));
ActivateHandler(getActiveGuiDocument(), std::make_unique<DrawSketchHandlerPolygon>(6));
break;
case 4:
ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerPolygon(7));
ActivateHandler(getActiveGuiDocument(), std::make_unique<DrawSketchHandlerPolygon>(7));
break;
case 5:
ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerPolygon(8));
ActivateHandler(getActiveGuiDocument(), std::make_unique<DrawSketchHandlerPolygon>(8));
break;
case 6: {
// Pop-up asking for values
SketcherRegularPolygonDialog srpd;
if (srpd.exec() == QDialog::Accepted) {
ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerPolygon(srpd.sides));
ActivateHandler(getActiveGuiDocument(),
std::make_unique<DrawSketchHandlerPolygon>(srpd.sides));
}
} break;
default: