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 9d2c34a1c7
commit 12e8fb1695
11 changed files with 110 additions and 112 deletions

View File

@@ -1187,7 +1187,7 @@ protected:
void CmdSketcherConstraint::activated(int /*iMsg*/)
{
ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerGenConstraint(this));
ActivateHandler(getActiveGuiDocument(), std::make_unique<DrawSketchHandlerGenConstraint>(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<DrawSketchHandlerDimension>(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<DrawSketchHandlerGenConstraint>(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<DrawSketchHandlerGenConstraint>(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<DrawSketchHandlerGenConstraint>(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<DrawSketchHandlerGenConstraint>(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<DrawSketchHandlerGenConstraint>(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<DrawSketchHandlerGenConstraint>(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<DrawSketchHandlerGenConstraint>(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<DrawSketchHandlerGenConstraint>(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<DrawSketchHandlerGenConstraint>(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<DrawSketchHandlerGenConstraint>(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<DrawSketchHandlerGenConstraint>(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<DrawSketchHandlerGenConstraint>(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<DrawSketchHandlerGenConstraint>(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<DrawSketchHandlerGenConstraint>(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<DrawSketchHandlerGenConstraint>(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<DrawSketchHandlerGenConstraint>(this));
getSelection().clearSelection();
}
else {

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:

View File

@@ -58,7 +58,7 @@ void ActivateBSplineHandler(Gui::Document* doc, DrawSketchHandler* handler)
SketcherGui::ViewProviderSketch* vp =
static_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit());
vp->purgeHandler();
vp->activateHandler(ptr.release());
vp->activateHandler(std::move(ptr));
}
}
}

View File

@@ -1107,7 +1107,7 @@ void CmdSketcherSymmetry::activated(int iMsg)
std::vector<int> listOfGeoIds = getListOfSelectedGeoIds(true);
if (!listOfGeoIds.empty()) {
ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerSymmetry(listOfGeoIds));
ActivateHandler(getActiveGuiDocument(), std::make_unique<DrawSketchHandlerSymmetry>(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<DrawSketchHandlerCopy>(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<DrawSketchHandlerRectangularArray>(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<DrawSketchHandlerOffset>(listOfGeoIds));
}
else {
getSelection().clearSelection();
@@ -2402,7 +2402,7 @@ void CmdSketcherRotate::activated(int iMsg)
std::vector<int> listOfGeoIds = getListOfSelectedGeoIds(true);
if (!listOfGeoIds.empty()) {
ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerRotate(listOfGeoIds));
ActivateHandler(getActiveGuiDocument(), std::make_unique<DrawSketchHandlerRotate>(listOfGeoIds));
}
getSelection().clearSelection();
}
@@ -2436,7 +2436,7 @@ void CmdSketcherScale::activated(int iMsg)
std::vector<int> listOfGeoIds = getListOfSelectedGeoIds(true);
if (!listOfGeoIds.empty()) {
ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerScale(listOfGeoIds));
ActivateHandler(getActiveGuiDocument(), std::make_unique<DrawSketchHandlerScale>(listOfGeoIds));
}
getSelection().clearSelection();
}
@@ -2470,7 +2470,7 @@ void CmdSketcherTranslate::activated(int iMsg)
std::vector<int> listOfGeoIds = getListOfSelectedGeoIds(true);
if (!listOfGeoIds.empty()) {
ActivateHandler(getActiveGuiDocument(), new DrawSketchHandlerTranslate(listOfGeoIds));
ActivateHandler(getActiveGuiDocument(), std::make_unique<DrawSketchHandlerTranslate>(listOfGeoIds));
}
getSelection().clearSelection();
}

View File

@@ -74,13 +74,14 @@ bool isSketcherVirtualSpaceActive(Gui::Document* doc, bool actsOnSelection)
void ActivateVirtualSpaceHandler(Gui::Document* doc, DrawSketchHandler* handler)
{
std::unique_ptr<DrawSketchHandler> ptr(handler);
if (doc) {
if (doc->getInEdit()
&& doc->getInEdit()->isDerivedFrom(SketcherGui::ViewProviderSketch::getClassTypeId())) {
SketcherGui::ViewProviderSketch* vp =
static_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit());
vp->purgeHandler();
vp->activateHandler(handler);
vp->activateHandler(std::move(ptr));
}
}
}

View File

@@ -41,8 +41,6 @@
#include "Utils.h"
namespace bp = boost::placeholders;
namespace SketcherGui
{

View File

@@ -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"

View File

@@ -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<DrawSketchHandler> handler)
{
std::unique_ptr<DrawSketchHandler> ptr(handler);
if (doc) {
if (doc->getInEdit()
&& doc->getInEdit()->isDerivedFrom(SketcherGui::ViewProviderSketch::getClassTypeId())) {
SketcherGui::ViewProviderSketch* vp =
static_cast<SketcherGui::ViewProviderSketch*>(doc->getInEdit());
vp->purgeHandler();
vp->activateHandler(ptr.release());
vp->activateHandler(std::move(handler));
}
}
}

View File

@@ -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<DrawSketchHandler> handler);
/// Returns if a sketch is in edit mode
bool isSketchInEdit(Gui::Document* doc);

View File

@@ -620,12 +620,12 @@ void ViewProviderSketch::forceUpdateData()
/***************************** handler management ************************************/
void ViewProviderSketch::activateHandler(DrawSketchHandler* newHandler)
void ViewProviderSketch::activateHandler(std::unique_ptr<DrawSketchHandler> newHandler)
{
assert(editCoinManager);
assert(!sketchHandler);
sketchHandler = std::unique_ptr<DrawSketchHandler>(newHandler);
sketchHandler = std::move(newHandler);
Mode = STATUS_SKETCH_UseHandler;
sketchHandler->activate(this);

View File

@@ -529,7 +529,7 @@ public:
/** @name handler control */
//@{
/// sets an DrawSketchHandler in control
void activateHandler(DrawSketchHandler* newHandler);
void activateHandler(std::unique_ptr<DrawSketchHandler> newHandler);
/// removes the active handler
void purgeHandler();
//@}