diff --git a/src/Mod/Sketcher/Gui/CommandConstraints.cpp b/src/Mod/Sketcher/Gui/CommandConstraints.cpp index 1f05e07ebb..d398b63a48 100644 --- a/src/Mod/Sketcher/Gui/CommandConstraints.cpp +++ b/src/Mod/Sketcher/Gui/CommandConstraints.cpp @@ -1187,7 +1187,7 @@ protected: void CmdSketcherConstraint::activated(int /*iMsg*/) { - ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerGenConstraint(this)); + ActivateHandler(getActiveGuiDocument(), std::make_unique(this)); getSelection().clearSelection(); } @@ -2751,7 +2751,7 @@ void CmdSketcherDimension::activated(int iMsg) SubNames = selection[0].getSubNames(); } - ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerDimension(SubNames)); + ActivateHandler(getActiveGuiDocument(), std::make_unique(SubNames)); } void CmdSketcherDimension::updateAction(int mode) @@ -2857,7 +2857,7 @@ void horVerActivated(CmdSketcherConstraint* cmd, std::string type) bool constraintMode = hGrp->GetBool("ContinuousConstraintMode", true); if (constraintMode) { - ActivateHandler(cmd->getActiveGuiDocument(), new DrawSketchHandlerGenConstraint(cmd)); + ActivateHandler(cmd->getActiveGuiDocument(), std::make_unique(cmd)); Gui::Command::getSelection().clearSelection(); } else { @@ -3266,7 +3266,7 @@ void CmdSketcherConstrainLock::activated(int iMsg) bool constraintMode = hGrp->GetBool("ContinuousConstraintMode", true); if (constraintMode) { - ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerGenConstraint(this)); + ActivateHandler(getActiveGuiDocument(), std::make_unique(this)); getSelection().clearSelection(); } else { @@ -3551,7 +3551,7 @@ void CmdSketcherConstrainBlock::activated(int iMsg) bool constraintMode = hGrp->GetBool("ContinuousConstraintMode", true); if (constraintMode) { - ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerGenConstraint(this)); + ActivateHandler(getActiveGuiDocument(), std::make_unique(this)); getSelection().clearSelection(); } else { @@ -3877,7 +3877,7 @@ void CmdSketcherConstrainCoincidentUnified::onActivated(CoincicenceType type) bool constraintMode = hGrp->GetBool("ContinuousConstraintMode", true); if (constraintMode) { - ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerGenConstraint(this)); + ActivateHandler(getActiveGuiDocument(), std::make_unique(this)); getSelection().clearSelection(); } else { @@ -4376,7 +4376,7 @@ void CmdSketcherConstrainDistance::activated(int iMsg) bool constraintMode = hGrp->GetBool("ContinuousConstraintMode", true); if (constraintMode) { - ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerGenConstraint(this)); + ActivateHandler(getActiveGuiDocument(), std::make_unique(this)); getSelection().clearSelection(); } @@ -5024,7 +5024,7 @@ void CmdSketcherConstrainDistanceX::activated(int iMsg) bool constraintMode = hGrp->GetBool("ContinuousConstraintMode", true); if (constraintMode) { - ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerGenConstraint(this)); + ActivateHandler(getActiveGuiDocument(), std::make_unique(this)); getSelection().clearSelection(); } else { @@ -5327,7 +5327,7 @@ void CmdSketcherConstrainDistanceY::activated(int iMsg) bool constraintMode = hGrp->GetBool("ContinuousConstraintMode", true); if (constraintMode) { - ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerGenConstraint(this)); + ActivateHandler(getActiveGuiDocument(), std::make_unique(this)); getSelection().clearSelection(); } else { @@ -5625,7 +5625,7 @@ void CmdSketcherConstrainParallel::activated(int iMsg) bool constraintMode = hGrp->GetBool("ContinuousConstraintMode", true); if (constraintMode) { - ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerGenConstraint(this)); + ActivateHandler(getActiveGuiDocument(), std::make_unique(this)); getSelection().clearSelection(); } else { @@ -5798,7 +5798,7 @@ void CmdSketcherConstrainPerpendicular::activated(int iMsg) bool constraintMode = hGrp->GetBool("ContinuousConstraintMode", true); if (constraintMode) { - ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerGenConstraint(this)); + ActivateHandler(getActiveGuiDocument(), std::make_unique(this)); getSelection().clearSelection(); } else { @@ -6631,7 +6631,7 @@ void CmdSketcherConstrainTangent::activated(int iMsg) bool constraintMode = hGrp->GetBool("ContinuousConstraintMode", true); if (constraintMode) { - ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerGenConstraint(this)); + ActivateHandler(getActiveGuiDocument(), std::make_unique(this)); getSelection().clearSelection(); } else { @@ -7420,7 +7420,7 @@ void CmdSketcherConstrainRadius::activated(int iMsg) bool constraintMode = hGrp->GetBool("ContinuousConstraintMode", true); if (constraintMode) { - ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerGenConstraint(this)); + ActivateHandler(getActiveGuiDocument(), std::make_unique(this)); getSelection().clearSelection(); } else { @@ -7783,7 +7783,7 @@ void CmdSketcherConstrainDiameter::activated(int iMsg) bool constraintMode = hGrp->GetBool("ContinuousConstraintMode", true); if (constraintMode) { - ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerGenConstraint(this)); + ActivateHandler(getActiveGuiDocument(), std::make_unique(this)); getSelection().clearSelection(); } else { @@ -8102,7 +8102,7 @@ void CmdSketcherConstrainRadiam::activated(int iMsg) bool constraintMode = hGrp->GetBool("ContinuousConstraintMode", true); if (constraintMode) { - ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerGenConstraint(this)); + ActivateHandler(getActiveGuiDocument(), std::make_unique(this)); getSelection().clearSelection(); } else { @@ -8645,7 +8645,7 @@ void CmdSketcherConstrainAngle::activated(int iMsg) bool constraintMode = hGrp->GetBool("ContinuousConstraintMode", true); if (constraintMode) { - ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerGenConstraint(this)); + ActivateHandler(getActiveGuiDocument(), std::make_unique(this)); getSelection().clearSelection(); } else { @@ -9086,7 +9086,7 @@ void CmdSketcherConstrainEqual::activated(int iMsg) bool constraintMode = hGrp->GetBool("ContinuousConstraintMode", true); if (constraintMode) { - ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerGenConstraint(this)); + ActivateHandler(getActiveGuiDocument(), std::make_unique(this)); getSelection().clearSelection(); } else { @@ -9341,7 +9341,7 @@ void CmdSketcherConstrainSymmetric::activated(int iMsg) bool constraintMode = hGrp->GetBool("ContinuousConstraintMode", true); if (constraintMode) { - ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerGenConstraint(this)); + ActivateHandler(getActiveGuiDocument(), std::make_unique(this)); getSelection().clearSelection(); } else { diff --git a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp index 0f2b60309f..2fb6b8b295 100644 --- a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp +++ b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp @@ -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()); } 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()); } 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( + 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( 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( + 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( ConstructionMethods::RectangleConstructionMethod::Diagonal)); } else if (iMsg == 1) { ActivateHandler(getActiveGuiDocument(), - new DrawSketchHandlerRectangle( + std::make_unique( ConstructionMethods::RectangleConstructionMethod::CenterAndCorner)); } else if (iMsg == 2) { ActivateHandler(getActiveGuiDocument(), - new DrawSketchHandlerRectangle( + std::make_unique( 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()); } 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( + 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()); } 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()); } bool CmdSketcherCreateEllipseByCenter::isActive() @@ -676,7 +676,7 @@ void CmdSketcherCreateEllipseBy3Points::activated(int iMsg) { Q_UNUSED(iMsg); ActivateHandler(getActiveGuiDocument(), - new DrawSketchHandlerEllipse( + std::make_unique( 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()); } 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()); } 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()); } bool CmdSketcherCreateArcOfParabola::isActive() @@ -860,7 +860,7 @@ void CmdSketcherCreateBSpline::activated(int iMsg) { Q_UNUSED(iMsg); ActivateHandler(getActiveGuiDocument(), - new DrawSketchHandlerBSpline( + std::make_unique( 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( + 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( + 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( + 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( ConstructionMethods::BSplineConstructionMethod::ControlPoints)); } else if (iMsg == 1) { ActivateHandler(getActiveGuiDocument(), - new DrawSketchHandlerBSpline( + std::make_unique( ConstructionMethods::BSplineConstructionMethod::ControlPoints, true)); } else if (iMsg == 2) { - ActivateHandler( - getActiveGuiDocument(), - new DrawSketchHandlerBSpline(ConstructionMethods::BSplineConstructionMethod::Knots)); + ActivateHandler(getActiveGuiDocument(), + std::make_unique( + ConstructionMethods::BSplineConstructionMethod::Knots)); } else if (iMsg == 3) { - ActivateHandler( - getActiveGuiDocument(), - new DrawSketchHandlerBSpline(ConstructionMethods::BSplineConstructionMethod::Knots, - true)); + ActivateHandler(getActiveGuiDocument(), + std::make_unique( + 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( 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()); } 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( + 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( + 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()); } 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()); } 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()); } 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()); } 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()); } 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()); } 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()); } 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(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(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(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(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(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(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(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(3)); break; case 1: - ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerPolygon(4)); + ActivateHandler(getActiveGuiDocument(), std::make_unique(4)); break; case 2: - ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerPolygon(5)); + ActivateHandler(getActiveGuiDocument(), std::make_unique(5)); break; case 3: - ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerPolygon(6)); + ActivateHandler(getActiveGuiDocument(), std::make_unique(6)); break; case 4: - ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerPolygon(7)); + ActivateHandler(getActiveGuiDocument(), std::make_unique(7)); break; case 5: - ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerPolygon(8)); + ActivateHandler(getActiveGuiDocument(), std::make_unique(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(srpd.sides)); } } break; default: diff --git a/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp b/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp index 4ea62843f2..f2405e6df7 100644 --- a/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp +++ b/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp @@ -58,7 +58,7 @@ void ActivateBSplineHandler(Gui::Document* doc, DrawSketchHandler* handler) SketcherGui::ViewProviderSketch* vp = static_cast(doc->getInEdit()); vp->purgeHandler(); - vp->activateHandler(ptr.release()); + vp->activateHandler(std::move(ptr)); } } } diff --git a/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp b/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp index 79dfb45b0b..d79e9e6876 100644 --- a/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp +++ b/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp @@ -1107,7 +1107,7 @@ void CmdSketcherSymmetry::activated(int iMsg) std::vector listOfGeoIds = getListOfSelectedGeoIds(true); if (!listOfGeoIds.empty()) { - ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerSymmetry(listOfGeoIds)); + ActivateHandler(getActiveGuiDocument(), std::make_unique(listOfGeoIds)); } getSelection().clearSelection(); } @@ -1440,7 +1440,7 @@ void SketcherCopy::activate(SketcherCopy::Op op) */ ActivateHandler(getActiveGuiDocument(), - new DrawSketchHandlerCopy(geoIdList, LastGeoId, LastPointPos, geoids, op)); + std::make_unique(geoIdList, LastGeoId, LastPointPos, geoids, op)); } @@ -2031,7 +2031,7 @@ void CmdSketcherRectangularArray::activated(int iMsg) if (slad.exec() == QDialog::Accepted) { ActivateHandler(getActiveGuiDocument(), - new DrawSketchHandlerRectangularArray(geoIdList, + std::make_unique(geoIdList, LastGeoId, LastPointPos, geoids, @@ -2363,7 +2363,7 @@ void CmdSketcherOffset::activated(int iMsg) } if (listOfGeoIds.size() != 0) { - ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerOffset(listOfGeoIds)); + ActivateHandler(getActiveGuiDocument(), std::make_unique(listOfGeoIds)); } else { getSelection().clearSelection(); @@ -2402,7 +2402,7 @@ void CmdSketcherRotate::activated(int iMsg) std::vector listOfGeoIds = getListOfSelectedGeoIds(true); if (!listOfGeoIds.empty()) { - ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerRotate(listOfGeoIds)); + ActivateHandler(getActiveGuiDocument(), std::make_unique(listOfGeoIds)); } getSelection().clearSelection(); } @@ -2436,7 +2436,7 @@ void CmdSketcherScale::activated(int iMsg) std::vector listOfGeoIds = getListOfSelectedGeoIds(true); if (!listOfGeoIds.empty()) { - ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerScale(listOfGeoIds)); + ActivateHandler(getActiveGuiDocument(), std::make_unique(listOfGeoIds)); } getSelection().clearSelection(); } @@ -2470,7 +2470,7 @@ void CmdSketcherTranslate::activated(int iMsg) std::vector listOfGeoIds = getListOfSelectedGeoIds(true); if (!listOfGeoIds.empty()) { - ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerTranslate(listOfGeoIds)); + ActivateHandler(getActiveGuiDocument(), std::make_unique(listOfGeoIds)); } getSelection().clearSelection(); } diff --git a/src/Mod/Sketcher/Gui/CommandSketcherVirtualSpace.cpp b/src/Mod/Sketcher/Gui/CommandSketcherVirtualSpace.cpp index f1651b5667..9907a4c090 100644 --- a/src/Mod/Sketcher/Gui/CommandSketcherVirtualSpace.cpp +++ b/src/Mod/Sketcher/Gui/CommandSketcherVirtualSpace.cpp @@ -74,13 +74,14 @@ bool isSketcherVirtualSpaceActive(Gui::Document* doc, bool actsOnSelection) void ActivateVirtualSpaceHandler(Gui::Document* doc, DrawSketchHandler* handler) { + std::unique_ptr ptr(handler); if (doc) { if (doc->getInEdit() && doc->getInEdit()->isDerivedFrom(SketcherGui::ViewProviderSketch::getClassTypeId())) { SketcherGui::ViewProviderSketch* vp = static_cast(doc->getInEdit()); vp->purgeHandler(); - vp->activateHandler(handler); + vp->activateHandler(std::move(ptr)); } } } diff --git a/src/Mod/Sketcher/Gui/DrawSketchDefaultHandler.h b/src/Mod/Sketcher/Gui/DrawSketchDefaultHandler.h index 52cc2d77a7..dbe4eeca71 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchDefaultHandler.h +++ b/src/Mod/Sketcher/Gui/DrawSketchDefaultHandler.h @@ -41,8 +41,6 @@ #include "Utils.h" -namespace bp = boost::placeholders; - namespace SketcherGui { diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandlerCircle.h b/src/Mod/Sketcher/Gui/DrawSketchHandlerCircle.h index e7a5310acc..aa1c706612 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandlerCircle.h +++ b/src/Mod/Sketcher/Gui/DrawSketchHandlerCircle.h @@ -35,10 +35,6 @@ #include "DrawSketchDefaultWidgetController.h" #include "DrawSketchControllableHandler.h" -#include "GeometryCreationMode.h" -#include "Utils.h" -#include "ViewProviderSketch.h" - #include "GeometryCreationMode.h" #include "Utils.h" diff --git a/src/Mod/Sketcher/Gui/Utils.cpp b/src/Mod/Sketcher/Gui/Utils.cpp index 912df46057..65e90db69d 100644 --- a/src/Mod/Sketcher/Gui/Utils.cpp +++ b/src/Mod/Sketcher/Gui/Utils.cpp @@ -476,16 +476,15 @@ void SketcherGui::GetCirclesMinimalDistance(const Part::Geometry* geom1, } } -void SketcherGui::ActivateHandler(Gui::Document* doc, DrawSketchHandler* handler) +void SketcherGui::ActivateHandler(Gui::Document* doc, std::unique_ptr handler) { - std::unique_ptr ptr(handler); if (doc) { if (doc->getInEdit() && doc->getInEdit()->isDerivedFrom(SketcherGui::ViewProviderSketch::getClassTypeId())) { SketcherGui::ViewProviderSketch* vp = static_cast(doc->getInEdit()); vp->purgeHandler(); - vp->activateHandler(ptr.release()); + vp->activateHandler(std::move(handler)); } } } diff --git a/src/Mod/Sketcher/Gui/Utils.h b/src/Mod/Sketcher/Gui/Utils.h index 0266857f59..e5b38ecaa3 100644 --- a/src/Mod/Sketcher/Gui/Utils.h +++ b/src/Mod/Sketcher/Gui/Utils.h @@ -175,7 +175,7 @@ void GetCirclesMinimalDistance(const Part::Geometry* geom1, Base::Vector3d& point1, Base::Vector3d& point2); -void ActivateHandler(Gui::Document* doc, DrawSketchHandler* handler); +void ActivateHandler(Gui::Document* doc, std::unique_ptr handler); /// Returns if a sketch is in edit mode bool isSketchInEdit(Gui::Document* doc); diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp index 81328f727a..3cd0ccbf95 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -620,12 +620,12 @@ void ViewProviderSketch::forceUpdateData() /***************************** handler management ************************************/ -void ViewProviderSketch::activateHandler(DrawSketchHandler* newHandler) +void ViewProviderSketch::activateHandler(std::unique_ptr newHandler) { assert(editCoinManager); assert(!sketchHandler); - sketchHandler = std::unique_ptr(newHandler); + sketchHandler = std::move(newHandler); Mode = STATUS_SKETCH_UseHandler; sketchHandler->activate(this); diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.h b/src/Mod/Sketcher/Gui/ViewProviderSketch.h index 886151c305..90d8372cd2 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.h +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.h @@ -529,7 +529,7 @@ public: /** @name handler control */ //@{ /// sets an DrawSketchHandler in control - void activateHandler(DrawSketchHandler* newHandler); + void activateHandler(std::unique_ptr newHandler); /// removes the active handler void purgeHandler(); //@}