From c0d58b8f3e4a820f596b1a6ed55ca92bb16cb844 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 17 Nov 2019 19:11:08 +0100 Subject: [PATCH] [skip ci] fix more -Wgnu-zero-variadic-macro-arguments --- src/Gui/CommandT.h | 28 +- src/Mod/Sketcher/Gui/Command.cpp | 20 +- src/Mod/Sketcher/Gui/CommandAlterGeometry.cpp | 4 +- src/Mod/Sketcher/Gui/CommandConstraints.cpp | 750 +++++++++--------- src/Mod/Sketcher/Gui/CommandCreateGeo.cpp | 161 ++-- .../Sketcher/Gui/CommandSketcherBSpline.cpp | 36 +- src/Mod/Sketcher/Gui/CommandSketcherTools.cpp | 43 +- .../Gui/CommandSketcherVirtualSpace.cpp | 4 +- src/Mod/Sketcher/Gui/DrawSketchHandler.cpp | 34 +- src/Mod/Sketcher/Gui/EditDatumDialog.cpp | 12 +- .../Sketcher/Gui/TaskSketcherConstrains.cpp | 30 +- src/Mod/Sketcher/Gui/ViewProviderSketch.cpp | 18 +- 12 files changed, 529 insertions(+), 611 deletions(-) diff --git a/src/Gui/CommandT.h b/src/Gui/CommandT.h index a19cc6a006..4de1b06a91 100644 --- a/src/Gui/CommandT.h +++ b/src/Gui/CommandT.h @@ -77,7 +77,7 @@ public: * @endcode */ template -void _cmdDocument(Gui::Command::DoCmd_Type cmdType, App::Document* doc, const std::string& mod, T&& cmd) { +void _cmdDocument(Gui::Command::DoCmd_Type cmdType, const App::Document* doc, const std::string& mod, T&& cmd) { if (doc && doc->getName()) { std::stringstream str; str << mod << ".getDocument('" << doc->getName() << "')." @@ -105,7 +105,7 @@ void _cmdDocument(Gui::Command::DoCmd_Type cmdType, App::Document* doc, const st * @endcode */ template -inline void cmdAppDocument(App::Document* doc, T&& cmd) { +inline void cmdAppDocument(const App::Document* doc, T&& cmd) { _cmdDocument(Gui::Command::Doc, doc, "App", std::forward(cmd)); } @@ -127,7 +127,7 @@ inline void cmdAppDocument(App::Document* doc, T&& cmd) { * @endcode */ template -inline void cmdGuiDocument(App::Document* doc, T&& cmd) { +inline void cmdGuiDocument(const App::Document* doc, T&& cmd) { _cmdDocument(Gui::Command::Gui, doc, "Gui", std::forward(cmd)); } @@ -138,7 +138,7 @@ inline void cmdGuiDocument(App::Document* doc, T&& cmd) { * @param cmd: command string, streamable */ template -inline void _cmdDocument(Gui::Command::DoCmd_Type cmdType, App::DocumentObject* obj, const std::string& mod, T&& cmd) { +inline void _cmdDocument(Gui::Command::DoCmd_Type cmdType, const App::DocumentObject* obj, const std::string& mod, T&& cmd) { if (obj) _cmdDocument(cmdType, obj->getDocument(), mod, std::forward(cmd)); } @@ -148,7 +148,7 @@ inline void _cmdDocument(Gui::Command::DoCmd_Type cmdType, App::DocumentObject* * @param cmd: command string, streamable */ template -inline void cmdAppDocument(App::DocumentObject* obj, T&& cmd) { +inline void cmdAppDocument(const App::DocumentObject* obj, T&& cmd) { _cmdDocument(Gui::Command::Doc, obj, "App", std::forward(cmd)); } @@ -158,7 +158,7 @@ inline void cmdAppDocument(App::DocumentObject* obj, T&& cmd) { * @param cmd: command string, streamable */ template -inline void cmdGuiDocument(App::DocumentObject* obj, T&& cmd) { +inline void cmdGuiDocument(const App::DocumentObject* obj, T&& cmd) { _cmdDocument(Gui::Command::Gui, obj, "Gui", std::forward(cmd)); } @@ -181,7 +181,7 @@ inline void cmdGuiDocument(App::DocumentObject* obj, T&& cmd) { * @endcode */ template -void _cmdObject(Gui::Command::DoCmd_Type cmdType, App::DocumentObject* obj, const std::string& mod, T&& cmd) { +void _cmdObject(Gui::Command::DoCmd_Type cmdType, const App::DocumentObject* obj, const std::string& mod, T&& cmd) { if (obj && obj->getNameInDocument()) { std::ostringstream str; str << mod << ".getDocument('" << obj->getDocument()->getName() << "')" @@ -198,7 +198,7 @@ void _cmdObject(Gui::Command::DoCmd_Type cmdType, App::DocumentObject* obj, cons * @sa _cmdObject() */ template -inline void cmdAppObject(App::DocumentObject* obj, T&& cmd) { +inline void cmdAppObject(const App::DocumentObject* obj, T&& cmd) { _cmdObject(Gui::Command::Doc, obj, "App", std::forward(cmd)); } @@ -209,17 +209,17 @@ inline void cmdAppObject(App::DocumentObject* obj, T&& cmd) { * @sa _cmdObject() */ template -inline void cmdGuiObject(App::DocumentObject* obj, T&& cmd) { +inline void cmdGuiObject(const App::DocumentObject* obj, T&& cmd) { _cmdObject(Gui::Command::Gui, obj, "Gui", std::forward(cmd)); } /// Hides an object -inline void cmdAppObjectHide(App::DocumentObject* obj) { +inline void cmdAppObjectHide(const App::DocumentObject* obj) { cmdAppObject(obj, "Visibility = False"); } /// Shows an object -inline void cmdAppObjectShow(App::DocumentObject* obj) { +inline void cmdAppObjectShow(const App::DocumentObject* obj) { cmdAppObject(obj, "Visibility = True"); } @@ -232,7 +232,7 @@ inline void cmdAppObjectShow(App::DocumentObject* obj) { * in-place editing an object, which may be brought in through linking to an * external group. */ -inline void cmdSetEdit(App::DocumentObject* obj) { +inline void cmdSetEdit(const App::DocumentObject* obj) { if (obj && obj->getNameInDocument()) { Gui::Command::doCommand(Gui::Command::Gui, "Gui.ActiveDocument.setEdit(App.getDocument('%s').getObject('%s'))", @@ -257,7 +257,7 @@ inline void cmdSetEdit(App::DocumentObject* obj) { * @endcode */ template -void cmdAppObjectArgs(App::DocumentObject* obj, const std::string& cmd, Args&&... args) { +void cmdAppObjectArgs(const App::DocumentObject* obj, const std::string& cmd, Args&&... args) { std::string _cmd; try { boost::format fmt(cmd); @@ -282,7 +282,7 @@ void cmdAppObjectArgs(App::DocumentObject* obj, const std::string& cmd, Args&&.. * @sa cmdAppObjectArgs() */ template -void cmdGuiObjectArgs(App::DocumentObject* obj, const std::string& cmd, Args&&... args) { +void cmdGuiObjectArgs(const App::DocumentObject* obj, const std::string& cmd, Args&&... args) { std::string _cmd; try { boost::format fmt(cmd); diff --git a/src/Mod/Sketcher/Gui/Command.cpp b/src/Mod/Sketcher/Gui/Command.cpp index 6529e32c73..42ffdc967f 100644 --- a/src/Mod/Sketcher/Gui/Command.cpp +++ b/src/Mod/Sketcher/Gui/Command.cpp @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include #include #include @@ -400,8 +400,8 @@ void CmdSketcherReorientSketch::activated(int iMsg) } openCommand("Reorient Sketch"); - FCMD_OBJ_CMD2("Placement = App.Placement(App.Vector(%f,%f,%f),App.Rotation(%f,%f,%f,%f))" - ,sketch,p.x,p.y,p.z,r[0],r[1],r[2],r[3]); + Gui::cmdAppObjectArgs(sketch, "Placement = App.Placement(App.Vector(%f,%f,%f),App.Rotation(%f,%f,%f,%f))" + , p.x,p.y,p.z,r[0],r[1],r[2],r[3]); doCommand(Gui,"Gui.ActiveDocument.setEdit('%s')",sketch->getNameInDocument()); } @@ -456,7 +456,7 @@ void CmdSketcherMapSketch::activated(int iMsg) items, 0, false, &ok); if (!ok) return; int index = items.indexOf(text); - Part2DObject &sketch = *(static_cast(sketches[index])); + Part2DObject* sketch = static_cast(sketches[index]); // check circular dependency @@ -468,7 +468,7 @@ void CmdSketcherMapSketch::activated(int iMsg) throw Base::ValueError("Unexpected null pointer in CmdSketcherMapSketch::activated"); } std::vector input = part->getOutList(); - if (std::find(input.begin(), input.end(), &sketch) != input.end()) { + if (std::find(input.begin(), input.end(), sketch) != input.end()) { throw ExceptionWrongInput(QT_TR_NOOP("Some of the selected objects depend on the sketch to be mapped. Circular dependencies are not allowed!")); } } @@ -485,7 +485,7 @@ void CmdSketcherMapSketch::activated(int iMsg) bool bAttach = true; bool bCurIncompatible = false; // * find out the modes that are compatible with selection. - eMapMode curMapMode = eMapMode(sketch.MapMode.getValue()); + eMapMode curMapMode = eMapMode(sketch->MapMode.getValue()); // * Test if current mode is OK. if (std::find(validModes.begin(), validModes.end(), curMapMode) == validModes.end()) bCurIncompatible = true; @@ -547,13 +547,13 @@ void CmdSketcherMapSketch::activated(int iMsg) std::string supportString = support.getPyReprString(); openCommand("Attach Sketch"); - FCMD_OBJ_CMD2("MapMode = \"%s\"",&sketch,AttachEngine::getModeName(suggMapMode).c_str()); - FCMD_OBJ_CMD2("Support = %s",&sketch,supportString.c_str()); + Gui::cmdAppObjectArgs(sketch, "MapMode = \"%s\"",AttachEngine::getModeName(suggMapMode).c_str()); + Gui::cmdAppObjectArgs(sketch, "Support = %s",supportString.c_str()); commitCommand(); } else { openCommand("Detach Sketch"); - FCMD_OBJ_CMD2("MapMode = \"%s\"",&sketch,AttachEngine::getModeName(suggMapMode).c_str()); - FCMD_OBJ_CMD2("Support = None",&sketch); + Gui::cmdAppObjectArgs(sketch, "MapMode = \"%s\"",AttachEngine::getModeName(suggMapMode).c_str()); + Gui::cmdAppObjectArgs(sketch, "Support = None"); commitCommand(); } } catch (ExceptionWrongInput &e) { diff --git a/src/Mod/Sketcher/Gui/CommandAlterGeometry.cpp b/src/Mod/Sketcher/Gui/CommandAlterGeometry.cpp index 4ee1de74e4..2805b80eb9 100644 --- a/src/Mod/Sketcher/Gui/CommandAlterGeometry.cpp +++ b/src/Mod/Sketcher/Gui/CommandAlterGeometry.cpp @@ -30,7 +30,7 @@ #include #include #include -#include +#include #include #include #include @@ -142,7 +142,7 @@ void CmdSketcherToggleConstruction::activated(int iMsg) if (it->size() > 4 && it->substr(0,4) == "Edge") { int GeoId = std::atoi(it->substr(4,4000).c_str()) - 1; // issue the actual commands to toggle - FCMD_OBJ_CMD2("toggleConstruction(%d) ",selection[0].getObject(),GeoId); + Gui::cmdAppObjectArgs(selection[0].getObject(), "toggleConstruction(%d) ", GeoId); } } // finish the transaction and update diff --git a/src/Mod/Sketcher/Gui/CommandConstraints.cpp b/src/Mod/Sketcher/Gui/CommandConstraints.cpp index c300515e60..22c4e6f442 100644 --- a/src/Mod/Sketcher/Gui/CommandConstraints.cpp +++ b/src/Mod/Sketcher/Gui/CommandConstraints.cpp @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include #include #include @@ -152,16 +152,14 @@ void openEditDatumDialog(Sketcher::SketchObject* sketch, int ConstrNbr) if (ui_ins_datum.labelEdit->hasExpression()) ui_ins_datum.labelEdit->apply(); else - FCMD_OBJ_CMD2("setDatum(%i,App.Units.Quantity('%f %s'))", - sketch, - ConstrNbr, newDatum, (const char*)newQuant.getUnit().getString().toUtf8()); + Gui::cmdAppObjectArgs(sketch, "setDatum(%i,App.Units.Quantity('%f %s'))", + ConstrNbr, newDatum, (const char*)newQuant.getUnit().getString().toUtf8()); QString constraintName = ui_ins_datum.name->text().trimmed(); if (Base::Tools::toStdString(constraintName) != sketch->Constraints[ConstrNbr]->Name) { std::string escapedstr = Base::Tools::escapedUnicodeFromUtf8(constraintName.toUtf8().constData()); - FCMD_OBJ_CMD2("renameConstraint(%d, u'%s')", - sketch, - ConstrNbr, escapedstr.c_str()); + Gui::cmdAppObjectArgs(sketch, "renameConstraint(%d, u'%s')", + ConstrNbr, escapedstr.c_str()); } Gui::Command::commitCommand(); @@ -394,19 +392,19 @@ void SketcherGui::makeTangentToEllipseviaNewPoint(Sketcher::SketchObject* Obj, try { // Add a point - FCMD_OBJ_CMD2("addGeometry(Part.Point(App.Vector(%f,%f,0)))", - Obj, PoE.x,PoE.y); + Gui::cmdAppObjectArgs(Obj, "addGeometry(Part.Point(App.Vector(%f,%f,0)))", + PoE.x,PoE.y); int GeoIdPoint = Obj->getHighestCurveIndex(); // Point on first object - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", - Obj,GeoIdPoint,Sketcher::start,geoId1); // constrain major axis + Gui::cmdAppObjectArgs(Obj, "addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", + GeoIdPoint,Sketcher::start,geoId1); // constrain major axis // Point on second object - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", - Obj,GeoIdPoint,Sketcher::start,geoId2); // constrain major axis + Gui::cmdAppObjectArgs(Obj,"addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", + GeoIdPoint,Sketcher::start,geoId2); // constrain major axis // tangent via point - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('TangentViaPoint',%d,%d,%d,%d))", - Obj, geoId1, geoId2 ,GeoIdPoint, Sketcher::start); + Gui::cmdAppObjectArgs(Obj, "addConstraint(Sketcher.Constraint('TangentViaPoint',%d,%d,%d,%d))", + geoId1, geoId2 ,GeoIdPoint, Sketcher::start); } catch (const Base::Exception& e) { Base::Console().Error("%s\n", e.what()); @@ -458,19 +456,19 @@ void SketcherGui::makeTangentToArcOfEllipseviaNewPoint(Sketcher::SketchObject* O try { // Add a point - FCMD_OBJ_CMD2("addGeometry(Part.Point(App.Vector(%f,%f,0)))", - Obj, PoE.x,PoE.y); + Gui::cmdAppObjectArgs(Obj, "addGeometry(Part.Point(App.Vector(%f,%f,0)))", + PoE.x,PoE.y); int GeoIdPoint = Obj->getHighestCurveIndex(); // Point on first object - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", - Obj,GeoIdPoint,Sketcher::start,geoId1); // constrain major axis + Gui::cmdAppObjectArgs(Obj,"addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", + GeoIdPoint,Sketcher::start,geoId1); // constrain major axis // Point on second object - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", - Obj,GeoIdPoint,Sketcher::start,geoId2); // constrain major axis + Gui::cmdAppObjectArgs(Obj,"addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", + GeoIdPoint,Sketcher::start,geoId2); // constrain major axis // tangent via point - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('TangentViaPoint',%d,%d,%d,%d))", - Obj, geoId1, geoId2 ,GeoIdPoint, Sketcher::start); + Gui::cmdAppObjectArgs(Obj, "addConstraint(Sketcher.Constraint('TangentViaPoint',%d,%d,%d,%d))", + geoId1, geoId2 ,GeoIdPoint, Sketcher::start); } catch (const Base::Exception& e) { Base::Console().Error("%s\n", e.what()); @@ -539,19 +537,19 @@ void SketcherGui::makeTangentToArcOfHyperbolaviaNewPoint(Sketcher::SketchObject* try { // Add a point - FCMD_OBJ_CMD2("addGeometry(Part.Point(App.Vector(%f,%f,0)))", - Obj, PoH.x,PoH.y); + Gui::cmdAppObjectArgs(Obj, "addGeometry(Part.Point(App.Vector(%f,%f,0)))", + PoH.x,PoH.y); int GeoIdPoint = Obj->getHighestCurveIndex(); // Point on first object - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", - Obj,GeoIdPoint,Sketcher::start,geoId1); // constrain major axis + Gui::cmdAppObjectArgs(Obj,"addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", + GeoIdPoint,Sketcher::start,geoId1); // constrain major axis // Point on second object - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", - Obj,GeoIdPoint,Sketcher::start,geoId2); // constrain major axis + Gui::cmdAppObjectArgs(Obj,"addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", + GeoIdPoint,Sketcher::start,geoId2); // constrain major axis // tangent via point - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('TangentViaPoint',%d,%d,%d,%d))", - Obj, geoId1, geoId2 ,GeoIdPoint, Sketcher::start); + Gui::cmdAppObjectArgs(Obj, "addConstraint(Sketcher.Constraint('TangentViaPoint',%d,%d,%d,%d))", + geoId1, geoId2 ,GeoIdPoint, Sketcher::start); } catch (const Base::Exception& e) { Base::Console().Error("%s\n", e.what()); @@ -615,19 +613,19 @@ void SketcherGui::makeTangentToArcOfParabolaviaNewPoint(Sketcher::SketchObject* try { // Add a point - FCMD_OBJ_CMD2("addGeometry(Part.Point(App.Vector(%f,%f,0)))", - Obj, PoP.x,PoP.y); + Gui::cmdAppObjectArgs(Obj, "addGeometry(Part.Point(App.Vector(%f,%f,0)))", + PoP.x,PoP.y); int GeoIdPoint = Obj->getHighestCurveIndex(); // Point on first object - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", - Obj,GeoIdPoint,Sketcher::start,geoId1); // constrain major axis + Gui::cmdAppObjectArgs(Obj,"addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", + GeoIdPoint,Sketcher::start,geoId1); // constrain major axis // Point on second object - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", - Obj,GeoIdPoint,Sketcher::start,geoId2); // constrain major axis + Gui::cmdAppObjectArgs(Obj,"addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", + GeoIdPoint,Sketcher::start,geoId2); // constrain major axis // tangent via point - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('TangentViaPoint',%d,%d,%d,%d))", - Obj, geoId1, geoId2 ,GeoIdPoint, Sketcher::start); + Gui::cmdAppObjectArgs(Obj, "addConstraint(Sketcher.Constraint('TangentViaPoint',%d,%d,%d,%d))", + geoId1, geoId2 ,GeoIdPoint, Sketcher::start); } catch (const Base::Exception& e) { Base::Console().Error("%s\n", e.what()); @@ -723,8 +721,8 @@ void SketcherGui::doEndpointTangency(Sketcher::SketchObject* Obj, Gui::Selection // GeoId1 is the B-spline now } // end of code supports simple B-spline endpoint tangency - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Tangent',%d,%d,%d,%d)) ", - selection.getObject(),GeoId1,PosId1,GeoId2,PosId2); + Gui::cmdAppObjectArgs(selection.getObject(), "addConstraint(Sketcher.Constraint('Tangent',%d,%d,%d,%d)) ", + GeoId1,PosId1,GeoId2,PosId2); } @@ -1285,8 +1283,8 @@ void CmdSketcherConstrainHorizontal::activated(int iMsg) openCommand("add horizontal constraint"); for (std::vector::iterator it=edgegeoids.begin(); it != edgegeoids.end(); it++) { // issue the actual commands to create the constraint - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Horizontal',%d)) " - ,selection[0].getObject(),*it); + Gui::cmdAppObjectArgs(selection[0].getObject(), + "addConstraint(Sketcher.Constraint('Horizontal',%d))", *it); } } else if (fixedpoints <= 1) { // pointgeoids @@ -1296,8 +1294,9 @@ void CmdSketcherConstrainHorizontal::activated(int iMsg) std::vector::iterator itp; for (it=pointgeoids.begin(), itp=pointpos.begin(); it != std::prev(pointgeoids.end()) && itp != std::prev(pointpos.end()); it++,itp++) { // issue the actual commands to create the constraint - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Horizontal',%d,%d,%d,%d)) " - ,selection[0].getObject(),*it,*itp,*std::next(it),*std::next(itp)); + Gui::cmdAppObjectArgs(selection[0].getObject() + ,"addConstraint(Sketcher.Constraint('Horizontal',%d,%d,%d,%d)) " + ,*it,*itp,*std::next(it),*std::next(itp)); } } else { // vertex mode, fixedpoints > 1 @@ -1357,8 +1356,7 @@ void CmdSketcherConstrainHorizontal::applyConstraint(std::vector &sel // undo command open Gui::Command::openCommand("add horizontal constraint"); // issue the actual commands to create the constraint - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Horizontal',%d)) ", - sketchgui->getObject(),CrvId); + Gui::cmdAppObjectArgs(sketchgui->getObject(), "addConstraint(Sketcher.Constraint('Horizontal',%d)) ",CrvId); // finish the transaction and update Gui::Command::commitCommand(); @@ -1531,8 +1529,7 @@ void CmdSketcherConstrainVertical::activated(int iMsg) openCommand("add vertical constraint"); for (std::vector::iterator it=edgegeoids.begin(); it != edgegeoids.end(); it++) { // issue the actual commands to create the constraint - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Vertical',%d)) " - ,selection[0].getObject(),*it); + Gui::cmdAppObjectArgs(selection[0].getObject(),"addConstraint(Sketcher.Constraint('Vertical',%d)) ", *it); } } else if (fixedpoints <= 1) { // vertex mode, maximum one fixed point @@ -1542,8 +1539,8 @@ void CmdSketcherConstrainVertical::activated(int iMsg) std::vector::iterator itp; for (it=pointgeoids.begin(), itp=pointpos.begin(); it != std::prev(pointgeoids.end()) && itp != std::prev(pointpos.end()); it++,itp++) { // issue the actual commands to create the constraint - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Vertical',%d,%d,%d,%d)) " - ,selection[0].getObject(),*it,*itp,*std::next(it),*std::next(itp)); + Gui::cmdAppObjectArgs(selection[0].getObject(), "addConstraint(Sketcher.Constraint('Vertical',%d,%d,%d,%d)) " + ,*it,*itp,*std::next(it),*std::next(itp)); } } else { // vertex mode, fixedpoints > 1 @@ -1604,8 +1601,7 @@ void CmdSketcherConstrainVertical::applyConstraint(std::vector &selSe // undo command open Gui::Command::openCommand("add vertical constraint"); // issue the actual commands to create the constraint - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Vertical',%d)) ", - sketchgui->getObject(),CrvId); + Gui::cmdAppObjectArgs(sketchgui->getObject(), "addConstraint(Sketcher.Constraint('Vertical',%d)) ", CrvId); // finish the transaction and update Gui::Command::commitCommand(); tryAutoRecompute(Obj); @@ -1752,21 +1748,21 @@ void CmdSketcherConstrainLock::activated(int iMsg) // undo command open openCommand("add fixed constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('DistanceX',%d,%d,%f)) ", - selection[0].getObject(),GeoId[0],PosId[0],pnt.x); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('DistanceY',%d,%d,%f)) ", - selection[0].getObject(),GeoId[0],PosId[0],pnt.y); + Gui::cmdAppObjectArgs(selection[0].getObject(), "addConstraint(Sketcher.Constraint('DistanceX',%d,%d,%f)) ", + GeoId[0],PosId[0],pnt.x); + Gui::cmdAppObjectArgs(selection[0].getObject(), "addConstraint(Sketcher.Constraint('DistanceY',%d,%d,%f)) ", + GeoId[0],PosId[0],pnt.y); lastconstraintindex+=2; if (edgeisblocked || GeoId[0] <= Sketcher::GeoEnum::RefExt || isConstructionPoint(Obj,GeoId[0]) || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving - FCMD_OBJ_CMD2("setDriving(%i,%s)", - selection[0].getObject(),lastconstraintindex-2,"False"); + Gui::cmdAppObjectArgs(selection[0].getObject(), "setDriving(%i,%s)", + lastconstraintindex-2,"False"); - FCMD_OBJ_CMD2("setDriving(%i,%s)", - selection[0].getObject(),lastconstraintindex,"False"); + Gui::cmdAppObjectArgs(selection[0].getObject(), "setDriving(%i,%s)", + lastconstraintindex,"False"); } } else { @@ -1791,21 +1787,21 @@ void CmdSketcherConstrainLock::activated(int iMsg) // undo command open openCommand("add relative lock constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('DistanceX',%d,%d,%d,%d,%f)) ", - selection[0].getObject(),*itg,*itp,GeoId.back(),PosId.back(),pntr.x-pnt.x); + Gui::cmdAppObjectArgs(selection[0].getObject(), "addConstraint(Sketcher.Constraint('DistanceX',%d,%d,%d,%d,%f)) ", + *itg,*itp,GeoId.back(),PosId.back(),pntr.x-pnt.x); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('DistanceY',%d,%d,%d,%d,%f)) ", - selection[0].getObject(),*itg,*itp,GeoId.back(),PosId.back(),pntr.y-pnt.y); + Gui::cmdAppObjectArgs(selection[0].getObject(), "addConstraint(Sketcher.Constraint('DistanceY',%d,%d,%d,%d,%f)) ", + *itg,*itp,GeoId.back(),PosId.back(),pntr.y-pnt.y); lastconstraintindex+=2; if ( (refpointfixed && pointfixed) || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving - FCMD_OBJ_CMD2("setDriving(%i,%s)", - selection[0].getObject(),lastconstraintindex-1,"False"); + Gui::cmdAppObjectArgs(selection[0].getObject(), "setDriving(%i,%s)", + lastconstraintindex-1,"False"); - FCMD_OBJ_CMD2("setDriving(%i,%s)", - selection[0].getObject(),lastconstraintindex,"False"); + Gui::cmdAppObjectArgs(selection[0].getObject(), "setDriving(%i,%s)", + lastconstraintindex,"False"); } } } @@ -1836,20 +1832,18 @@ void CmdSketcherConstrainLock::applyConstraint(std::vector &selSeq, i // undo command open Gui::Command::openCommand("add fixed constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('DistanceX', %d, %d, %f)) ", - sketchgui->getObject(), selSeq.front().GeoId, selSeq.front().PosId, pnt.x); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('DistanceY', %d, %d, %f)) ", - sketchgui->getObject(), selSeq.front().GeoId, selSeq.front().PosId, pnt.y); + Gui::cmdAppObjectArgs(sketchgui->getObject(), "addConstraint(Sketcher.Constraint('DistanceX', %d, %d, %f)) ", + selSeq.front().GeoId, selSeq.front().PosId, pnt.x); + Gui::cmdAppObjectArgs(sketchgui->getObject(), "addConstraint(Sketcher.Constraint('DistanceY', %d, %d, %f)) ", + selSeq.front().GeoId, selSeq.front().PosId, pnt.y); if (pointfixed || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving const std::vector &ConStr = Obj->Constraints.getValues(); - FCMD_OBJ_CMD2("setDriving(%i, %s)", - sketchgui->getObject(), ConStr.size()-2, "False"); + Gui::cmdAppObjectArgs(sketchgui->getObject(), "setDriving(%i, %s)", ConStr.size()-2, "False"); - FCMD_OBJ_CMD2("setDriving(%i, %s)", - sketchgui->getObject(), ConStr.size()-1, "False"); + Gui::cmdAppObjectArgs(sketchgui->getObject(), "setDriving(%i, %s)", ConStr.size()-1, "False"); } // finish the transaction and update @@ -2019,7 +2013,7 @@ void CmdSketcherConstrainBlock::activated(int iMsg) try { - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Block',%d)) ", Obj,(*itg)); + Gui::cmdAppObjectArgs(Obj, "addConstraint(Sketcher.Constraint('Block',%d)) ", (*itg)); } catch (const Base::Exception& e) { Base::Console().Error("%s\n", e.what()); @@ -2063,8 +2057,8 @@ void CmdSketcherConstrainBlock::applyConstraint(std::vector &selSeq, try { - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Block',%d)) ", - sketchgui->getObject(),selSeq.front().GeoId); + Gui::cmdAppObjectArgs(sketchgui->getObject(), "addConstraint(Sketcher.Constraint('Block',%d)) ", + selSeq.front().GeoId); } catch (const Base::Exception& e) { Base::Console().Error("%s\n", e.what()); @@ -2208,8 +2202,8 @@ public: // check if this coincidence is already enforced (even indirectly) bool constraintExists = Obj->arePointsCoincident(GeoId1,PosId1,GeoId2,PosId2); if (!constraintExists && (GeoId1 != GeoId2)) { - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Coincident',%d,%d,%d,%d)) ", - sketchgui->getObject(),GeoId1,PosId1,GeoId2,PosId2); + Gui::cmdAppObjectArgs(sketchgui->getObject(), "addConstraint(Sketcher.Constraint('Coincident',%d,%d,%d,%d)) ", + GeoId1,PosId1,GeoId2,PosId2); Gui::Command::commitCommand(); } else { @@ -2332,10 +2326,10 @@ void CmdSketcherConstrainCoincident::activated(int iMsg) if(constraintExists) { // try to remove any pre-existing direct coincident constraints - FCMD_OBJ_CMD2("delConstraintOnPoint(%i,%i)", Obj, GeoId1, PosId1); + Gui::cmdAppObjectArgs(Obj, "delConstraintOnPoint(%i,%i)", GeoId1, PosId1); } - FCMD_OBJ_CMD2("delConstraint(%i)", Obj, j); + Gui::cmdAppObjectArgs(Obj, "delConstraint(%i)", j); doEndpointTangency(Obj, selection[0], GeoId1, GeoId2, PosId1, PosId2); @@ -2356,8 +2350,8 @@ void CmdSketcherConstrainCoincident::activated(int iMsg) if (!constraintExists) { constraintsAdded = true; - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Coincident',%d,%d,%d,%d)) ", - selection[0].getObject(),GeoId1,PosId1,GeoId2,PosId2); + Gui::cmdAppObjectArgs(selection[0].getObject(), "addConstraint(Sketcher.Constraint('Coincident',%d,%d,%d,%d)) ", + GeoId1,PosId1,GeoId2,PosId2); } } @@ -2397,8 +2391,8 @@ void CmdSketcherConstrainCoincident::applyConstraint(std::vector &sel // check if this coincidence is already enforced (even indirectly) bool constraintExists = Obj->arePointsCoincident(GeoId1, PosId1, GeoId2, PosId2); if (!constraintExists && (GeoId1 != GeoId2)) { - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Coincident', %d, %d, %d, %d)) ", - sketchgui->getObject(), GeoId1, PosId1, GeoId2, PosId2); + Gui::cmdAppObjectArgs(sketchgui->getObject(), "addConstraint(Sketcher.Constraint('Coincident', %d, %d, %d, %d)) ", + GeoId1, PosId1, GeoId2, PosId2); Gui::Command::commitCommand(); } else { @@ -2500,29 +2494,33 @@ void CmdSketcherConstrainDistance::activated(int iMsg) PosId1 = Sketcher::start; openCommand("add distance from horizontal axis constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('DistanceY',%d,%d,%d,%d,%f)) ", - selection[0].getObject(),GeoId1,PosId1,GeoId2,PosId2,pnt2.y); + Gui::cmdAppObjectArgs(selection[0].getObject(), + "addConstraint(Sketcher.Constraint('DistanceY',%d,%d,%d,%d,%f)) ", + GeoId1,PosId1,GeoId2,PosId2,pnt2.y); } else if (GeoId1 == Sketcher::GeoEnum::VAxis && PosId1 == Sketcher::none) { PosId1 = Sketcher::start; openCommand("add distance from vertical axis constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('DistanceX',%d,%d,%d,%d,%f)) ", - selection[0].getObject(),GeoId1,PosId1,GeoId2,PosId2,pnt2.x); + Gui::cmdAppObjectArgs(selection[0].getObject(), + "addConstraint(Sketcher.Constraint('DistanceX',%d,%d,%d,%d,%f)) ", + GeoId1,PosId1,GeoId2,PosId2,pnt2.x); } else { Base::Vector3d pnt1 = Obj->getPoint(GeoId1,PosId1); openCommand("add point to point distance constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Distance',%d,%d,%d,%d,%f)) ", - selection[0].getObject(),GeoId1,PosId1,GeoId2,PosId2,(pnt2-pnt1).Length()); + Gui::cmdAppObjectArgs(selection[0].getObject(), + "addConstraint(Sketcher.Constraint('Distance',%d,%d,%d,%d,%f)) ", + GeoId1,PosId1,GeoId2,PosId2,(pnt2-pnt1).Length()); } if (arebothpointsorsegmentsfixed || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving const std::vector &ConStr = Obj->Constraints.getValues(); - FCMD_OBJ_CMD2("setDriving(%i,%s)", - selection[0].getObject(),ConStr.size()-1,"False"); + Gui::cmdAppObjectArgs(selection[0].getObject(), + "setDriving(%i,%s)", + ConStr.size()-1,"False"); finishDistanceConstraint(this, Obj,false); } else @@ -2546,14 +2544,16 @@ void CmdSketcherConstrainDistance::activated(int iMsg) double ActDist = std::abs(-pnt.x*d.y+pnt.y*d.x+pnt1.x*pnt2.y-pnt2.x*pnt1.y) / d.Length(); openCommand("add point to line Distance constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Distance',%d,%d,%d,%f)) ", - selection[0].getObject(),GeoId1,PosId1,GeoId2,ActDist); + Gui::cmdAppObjectArgs(selection[0].getObject(), + "addConstraint(Sketcher.Constraint('Distance',%d,%d,%d,%f)) ", + GeoId1,PosId1,GeoId2,ActDist); if (arebothpointsorsegmentsfixed || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving const std::vector &ConStr = Obj->Constraints.getValues(); - FCMD_OBJ_CMD2("setDriving(%i,%s)", - selection[0].getObject(),ConStr.size()-1,"False"); + Gui::cmdAppObjectArgs(selection[0].getObject(), + "setDriving(%i,%s)", + ConStr.size()-1,"False"); finishDistanceConstraint(this, Obj,false); } else @@ -2578,14 +2578,16 @@ void CmdSketcherConstrainDistance::activated(int iMsg) double ActLength = (lineSeg->getEndPoint()-lineSeg->getStartPoint()).Length(); openCommand("add length constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Distance',%d,%f)) ", - selection[0].getObject(),GeoId1,ActLength); + Gui::cmdAppObjectArgs(selection[0].getObject(), "addConstraint(Sketcher.Constraint('Distance',%d,%f)) ", + GeoId1,ActLength); - if (arebothpointsorsegmentsfixed || GeoId1 <= Sketcher::GeoEnum::RefExt || isConstructionPoint(Obj,GeoId1) || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving + // it is a constraint on a external line, make it non-driving + if (arebothpointsorsegmentsfixed || GeoId1 <= Sketcher::GeoEnum::RefExt || + isConstructionPoint(Obj,GeoId1) || constraintCreationMode==Reference) { const std::vector &ConStr = Obj->Constraints.getValues(); - FCMD_OBJ_CMD2("setDriving(%i,%s)", - selection[0].getObject(),ConStr.size()-1,"False"); + Gui::cmdAppObjectArgs(selection[0].getObject(), "setDriving(%i,%s)", + ConStr.size()-1,"False"); finishDistanceConstraint(this, Obj,false); } else @@ -2623,29 +2625,29 @@ void CmdSketcherConstrainDistance::applyConstraint(std::vector &selSe PosId1 = Sketcher::start; openCommand("add distance from horizontal axis constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('DistanceY',%d,%d,%d,%d,%f)) ", - Obj,GeoId1,PosId1,GeoId2,PosId2,pnt2.y); + Gui::cmdAppObjectArgs(Obj,"addConstraint(Sketcher.Constraint('DistanceY',%d,%d,%d,%d,%f)) ", + GeoId1,PosId1,GeoId2,PosId2,pnt2.y); } else if (GeoId1 == Sketcher::GeoEnum::VAxis && PosId1 == Sketcher::none) { PosId1 = Sketcher::start; openCommand("add distance from vertical axis constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('DistanceX',%d,%d,%d,%d,%f)) ", - Obj,GeoId1,PosId1,GeoId2,PosId2,pnt2.x); + Gui::cmdAppObjectArgs(Obj,"addConstraint(Sketcher.Constraint('DistanceX',%d,%d,%d,%d,%f)) ", + GeoId1,PosId1,GeoId2,PosId2,pnt2.x); } else { Base::Vector3d pnt1 = Obj->getPoint(GeoId1,PosId1); openCommand("add point to point distance constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Distance',%d,%d,%d,%d,%f)) ", - Obj,GeoId1,PosId1,GeoId2,PosId2,(pnt2-pnt1).Length()); + Gui::cmdAppObjectArgs(Obj,"addConstraint(Sketcher.Constraint('Distance',%d,%d,%d,%d,%f)) ", + GeoId1,PosId1,GeoId2,PosId2,(pnt2-pnt1).Length()); } if (arebothpointsorsegmentsfixed || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving const std::vector &ConStr = Obj->Constraints.getValues(); - FCMD_OBJ_CMD2("setDriving(%i,%s)", - Obj,ConStr.size()-1,"False"); + Gui::cmdAppObjectArgs(Obj,"setDriving(%i,%s)", + ConStr.size()-1,"False"); finishDistanceConstraint(this, Obj,false); } else @@ -2668,14 +2670,14 @@ void CmdSketcherConstrainDistance::applyConstraint(std::vector &selSe double ActLength = (lineSeg->getEndPoint()-lineSeg->getStartPoint()).Length(); openCommand("add length constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Distance',%d,%f)) ", - Obj,GeoId1,ActLength); + Gui::cmdAppObjectArgs(Obj,"addConstraint(Sketcher.Constraint('Distance',%d,%f)) ", + GeoId1,ActLength); if (arebothpointsorsegmentsfixed || GeoId1 <= Sketcher::GeoEnum::RefExt || isConstructionPoint(Obj,GeoId1) || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving const std::vector &ConStr = Obj->Constraints.getValues(); - FCMD_OBJ_CMD2("setDriving(%i,%s)", - Obj,ConStr.size()-1,"False"); + Gui::cmdAppObjectArgs(Obj, "setDriving(%i,%s)", + ConStr.size()-1,"False"); finishDistanceConstraint(this, Obj,false); } else @@ -2707,14 +2709,14 @@ void CmdSketcherConstrainDistance::applyConstraint(std::vector &selSe double ActDist = std::abs(-pnt.x*d.y+pnt.y*d.x+pnt1.x*pnt2.y-pnt2.x*pnt1.y) / d.Length(); openCommand("add point to line Distance constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Distance',%d,%d,%d,%f)) ", - Obj,GeoId1,PosId1,GeoId2,ActDist); + Gui::cmdAppObjectArgs(Obj,"addConstraint(Sketcher.Constraint('Distance',%d,%d,%d,%f)) ", + GeoId1,PosId1,GeoId2,ActDist); if (arebothpointsorsegmentsfixed || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving const std::vector &ConStr = Obj->Constraints.getValues(); - FCMD_OBJ_CMD2("setDriving(%i,%s)", - Obj,ConStr.size()-1,"False"); + Gui::cmdAppObjectArgs(Obj,"setDriving(%i,%s)", + ConStr.size()-1,"False"); finishDistanceConstraint(this, Obj,false); } else @@ -2881,8 +2883,8 @@ void CmdSketcherConstrainPointOnObject::activated(int iMsg) } cnt++; - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", - selection[0].getObject(),points[iPnt].GeoId, points[iPnt].PosId, curves[iCrv].GeoId); + Gui::cmdAppObjectArgs(selection[0].getObject(),"addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", + points[iPnt].GeoId, points[iPnt].PosId, curves[iCrv].GeoId); } } if (cnt) { @@ -2952,8 +2954,8 @@ void CmdSketcherConstrainPointOnObject::applyConstraint(std::vector & } if (allOK) { - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", - sketchgui->getObject(), GeoIdVt, PosIdVt, GeoIdCrv); + Gui::cmdAppObjectArgs(sketchgui->getObject(), "addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", + GeoIdVt, PosIdVt, GeoIdCrv); commitCommand(); tryAutoRecompute(Obj); @@ -3086,14 +3088,14 @@ void CmdSketcherConstrainDistanceX::activated(int iMsg) } openCommand("add point to point horizontal distance constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('DistanceX',%d,%d,%d,%d,%f)) ", - selection[0].getObject(),GeoId1,PosId1,GeoId2,PosId2,ActLength); + Gui::cmdAppObjectArgs(selection[0].getObject(), "addConstraint(Sketcher.Constraint('DistanceX',%d,%d,%d,%d,%f)) ", + GeoId1,PosId1,GeoId2,PosId2,ActLength); if (arebothpointsorsegmentsfixed || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving const std::vector &ConStr = Obj->Constraints.getValues(); - FCMD_OBJ_CMD2("setDriving(%i,%s)", - selection[0].getObject(),ConStr.size()-1,"False"); + Gui::cmdAppObjectArgs(selection[0].getObject(), "setDriving(%i,%s)", + ConStr.size()-1,"False"); finishDistanceConstraint(this, Obj,false); } else @@ -3115,15 +3117,15 @@ void CmdSketcherConstrainDistanceX::activated(int iMsg) arebothpointsorsegmentsfixed=isPointOrSegmentFixed(Obj,GeoId1); openCommand("add fixed x-coordinate constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('DistanceX',%d,%d,%f)) ", - selection[0].getObject(),GeoId1,PosId1,ActX); + Gui::cmdAppObjectArgs(selection[0].getObject(), "addConstraint(Sketcher.Constraint('DistanceX',%d,%d,%f)) ", + GeoId1,PosId1,ActX); if (arebothpointsorsegmentsfixed || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving const std::vector &ConStr = Obj->Constraints.getValues(); - FCMD_OBJ_CMD2("setDriving(%i,%s)", - selection[0].getObject(),ConStr.size()-1,"False"); + Gui::cmdAppObjectArgs(selection[0].getObject(),"setDriving(%i,%s)", + ConStr.size()-1,"False"); finishDistanceConstraint(this, Obj,false); } else @@ -3185,14 +3187,14 @@ void CmdSketcherConstrainDistanceX::applyConstraint(std::vector &selS } openCommand("add point to point horizontal distance constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('DistanceX',%d,%d,%d,%d,%f)) ", - Obj,GeoId1,PosId1,GeoId2,PosId2,ActLength); + Gui::cmdAppObjectArgs(Obj,"addConstraint(Sketcher.Constraint('DistanceX',%d,%d,%d,%d,%f)) ", + GeoId1,PosId1,GeoId2,PosId2,ActLength); if (areBothPointsOrSegmentsFixed(Obj,GeoId1, GeoId2) || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving const std::vector &ConStr = Obj->Constraints.getValues(); - FCMD_OBJ_CMD2("setDriving(%i,%s)", - Obj,ConStr.size()-1,"False"); + Gui::cmdAppObjectArgs(Obj,"setDriving(%i,%s)", + ConStr.size()-1,"False"); finishDistanceConstraint(this, Obj, false); } else @@ -3331,14 +3333,14 @@ void CmdSketcherConstrainDistanceY::activated(int iMsg) } openCommand("add point to point vertical distance constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('DistanceY',%d,%d,%d,%d,%f)) ", - selection[0].getObject(),GeoId1,PosId1,GeoId2,PosId2,ActLength); + Gui::cmdAppObjectArgs(selection[0].getObject(),"addConstraint(Sketcher.Constraint('DistanceY',%d,%d,%d,%d,%f)) ", + GeoId1,PosId1,GeoId2,PosId2,ActLength); if (arebothpointsorsegmentsfixed || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving const std::vector &ConStr = Obj->Constraints.getValues(); - FCMD_OBJ_CMD2("setDriving(%i,%s)", - selection[0].getObject(),ConStr.size()-1,"False"); + Gui::cmdAppObjectArgs(selection[0].getObject(), "setDriving(%i,%s)", + ConStr.size()-1,"False"); finishDistanceConstraint(this, Obj,false); } else @@ -3360,14 +3362,14 @@ void CmdSketcherConstrainDistanceY::activated(int iMsg) arebothpointsorsegmentsfixed=isPointOrSegmentFixed(Obj,GeoId1); openCommand("add fixed y-coordinate constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('DistanceY',%d,%d,%f)) ", - selection[0].getObject(),GeoId1,PosId1,ActY); + Gui::cmdAppObjectArgs(selection[0].getObject(), "addConstraint(Sketcher.Constraint('DistanceY',%d,%d,%f)) ", + GeoId1,PosId1,ActY); if (GeoId1 <= Sketcher::GeoEnum::RefExt || isConstructionPoint(Obj,GeoId1) || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving const std::vector &ConStr = Obj->Constraints.getValues(); - FCMD_OBJ_CMD2("setDriving(%i,%s)", - selection[0].getObject(),ConStr.size()-1,"False"); + Gui::cmdAppObjectArgs(selection[0].getObject(), "setDriving(%i,%s)", + ConStr.size()-1,"False"); finishDistanceConstraint(this, Obj,false); } else @@ -3429,14 +3431,14 @@ void CmdSketcherConstrainDistanceY::applyConstraint(std::vector &selS } openCommand("add point to point vertical distance constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('DistanceY',%d,%d,%d,%d,%f)) ", - Obj,GeoId1,PosId1,GeoId2,PosId2,ActLength); + Gui::cmdAppObjectArgs(Obj,"addConstraint(Sketcher.Constraint('DistanceY',%d,%d,%d,%d,%f)) ", + GeoId1,PosId1,GeoId2,PosId2,ActLength); if (areBothPointsOrSegmentsFixed(Obj,GeoId1, GeoId2) || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving const std::vector &ConStr = Obj->Constraints.getValues(); - FCMD_OBJ_CMD2("setDriving(%i,%s)", - Obj,ConStr.size()-1,"False"); + Gui::cmdAppObjectArgs(Obj, "setDriving(%i,%s)", + ConStr.size()-1,"False"); finishDistanceConstraint(this, Obj,false); } else @@ -3599,8 +3601,8 @@ void CmdSketcherConstrainParallel::activated(int iMsg) // undo command open openCommand("add parallel constraint"); for (int i=0; i < int(ids.size()-1); i++) { - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Parallel',%d,%d)) ", - selection[0].getObject(),ids[i],ids[i+1]); + Gui::cmdAppObjectArgs(selection[0].getObject(), "addConstraint(Sketcher.Constraint('Parallel',%d,%d)) ", + ids[i],ids[i+1]); } // finish the transaction and update commitCommand(); @@ -3639,8 +3641,8 @@ void CmdSketcherConstrainParallel::applyConstraint(std::vector &selSe // undo command open openCommand("add parallel constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Parallel',%d,%d)) ", - sketchgui->getObject(), GeoId1, GeoId2); + Gui::cmdAppObjectArgs(sketchgui->getObject(), "addConstraint(Sketcher.Constraint('Parallel',%d,%d)) ", + GeoId1, GeoId2); // finish the transaction and update commitCommand(); tryAutoRecompute(Obj); @@ -3801,22 +3803,22 @@ void CmdSketcherConstrainPerpendicular::activated(int iMsg) try{ //add missing point-on-object constraints if(! IsPointAlreadyOnCurve(GeoId1, GeoId3, PosId3, Obj)){ - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", - selection[0].getObject(),GeoId3,PosId3,GeoId1); + Gui::cmdAppObjectArgs(selection[0].getObject(), "addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", + GeoId3,PosId3,GeoId1); }; if(! IsPointAlreadyOnCurve(GeoId2, GeoId3, PosId3, Obj)){ - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", - selection[0].getObject(),GeoId3,PosId3,GeoId2); + Gui::cmdAppObjectArgs(selection[0].getObject(), "addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", + GeoId3,PosId3,GeoId2); }; if(! IsPointAlreadyOnCurve(GeoId1, GeoId3, PosId3, Obj)){//FIXME: it's a good idea to add a check if the sketch is solved - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", - selection[0].getObject(),GeoId3,PosId3,GeoId1); + Gui::cmdAppObjectArgs(selection[0].getObject(), "addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", + GeoId3,PosId3,GeoId1); }; - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('PerpendicularViaPoint',%d,%d,%d,%d)) ", - selection[0].getObject(),GeoId1,GeoId2,GeoId3,PosId3); + Gui::cmdAppObjectArgs(selection[0].getObject(), "addConstraint(Sketcher.Constraint('PerpendicularViaPoint',%d,%d,%d,%d)) ", + GeoId1,GeoId2,GeoId3,PosId3); } catch (const Base::Exception& e) { Base::Console().Error("%s\n", e.what()); QMessageBox::warning(Gui::getMainWindow(), @@ -3865,8 +3867,8 @@ void CmdSketcherConstrainPerpendicular::activated(int iMsg) } // end of code supports simple B-spline endpoint tangency openCommand("add perpendicular constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Perpendicular',%d,%d,%d,%d)) ", - selection[0].getObject(),GeoId1,PosId1,GeoId2,PosId2); + Gui::cmdAppObjectArgs(selection[0].getObject(), "addConstraint(Sketcher.Constraint('Perpendicular',%d,%d,%d,%d)) ", + GeoId1,PosId1,GeoId2,PosId2); commitCommand(); tryAutoRecompute(Obj); @@ -3896,8 +3898,8 @@ void CmdSketcherConstrainPerpendicular::activated(int iMsg) } openCommand("add perpendicularity constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Perpendicular',%d,%d,%d)) ", - selection[0].getObject(),GeoId1,PosId1,GeoId2); + Gui::cmdAppObjectArgs(selection[0].getObject(), "addConstraint(Sketcher.Constraint('Perpendicular',%d,%d,%d)) ", + GeoId1,PosId1,GeoId2); commitCommand(); tryAutoRecompute(Obj); @@ -4010,20 +4012,20 @@ void CmdSketcherConstrainPerpendicular::activated(int iMsg) try { // Add a point - FCMD_OBJ_CMD2("addGeometry(Part.Point(App.Vector(%f,%f,0)))", - Obj, PoO.x,PoO.y); + Gui::cmdAppObjectArgs(Obj, "addGeometry(Part.Point(App.Vector(%f,%f,0)))", + PoO.x,PoO.y); int GeoIdPoint = Obj->getHighestCurveIndex(); // Point on first object (ellipse, arc of ellipse) - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", - selection[0].getObject(),GeoIdPoint,Sketcher::start,GeoId1); + Gui::cmdAppObjectArgs(selection[0].getObject(), "addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", + GeoIdPoint,Sketcher::start,GeoId1); // Point on second object - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", - selection[0].getObject(),GeoIdPoint,Sketcher::start,GeoId2); + Gui::cmdAppObjectArgs(selection[0].getObject(), "addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", + GeoIdPoint,Sketcher::start,GeoId2); // add constraint: Perpendicular-via-point - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('PerpendicularViaPoint',%d,%d,%d,%d))", - Obj, GeoId1, GeoId2 ,GeoIdPoint, Sketcher::start); + Gui::cmdAppObjectArgs(Obj, "addConstraint(Sketcher.Constraint('PerpendicularViaPoint',%d,%d,%d,%d))", + GeoId1, GeoId2 ,GeoIdPoint, Sketcher::start); } catch (const Base::Exception& e) { @@ -4043,8 +4045,8 @@ void CmdSketcherConstrainPerpendicular::activated(int iMsg) } openCommand("add perpendicular constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Perpendicular',%d,%d)) ", - selection[0].getObject(),GeoId1,GeoId2); + Gui::cmdAppObjectArgs(selection[0].getObject(), "addConstraint(Sketcher.Constraint('Perpendicular',%d,%d)) ", + GeoId1,GeoId2); commitCommand(); tryAutoRecompute(Obj); @@ -4185,20 +4187,20 @@ void CmdSketcherConstrainPerpendicular::applyConstraint(std::vector & try { // Add a point - FCMD_OBJ_CMD2("addGeometry(Part.Point(App.Vector(%f,%f,0)))", - Obj, PoO.x,PoO.y); + Gui::cmdAppObjectArgs(Obj, "addGeometry(Part.Point(App.Vector(%f,%f,0)))", + PoO.x,PoO.y); int GeoIdPoint = Obj->getHighestCurveIndex(); // Point on first object (ellipse, arc of ellipse) - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", - Obj,GeoIdPoint,Sketcher::start,GeoId1); + Gui::cmdAppObjectArgs(Obj, "addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", + GeoIdPoint,Sketcher::start,GeoId1); // Point on second object - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", - Obj,GeoIdPoint,Sketcher::start,GeoId2); + Gui::cmdAppObjectArgs(Obj, "addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", + GeoIdPoint,Sketcher::start,GeoId2); // add constraint: Perpendicular-via-point - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('PerpendicularViaPoint',%d,%d,%d,%d))", - Obj, GeoId1, GeoId2 ,GeoIdPoint, Sketcher::start); + Gui::cmdAppObjectArgs(Obj, "addConstraint(Sketcher.Constraint('PerpendicularViaPoint',%d,%d,%d,%d))", + GeoId1, GeoId2 ,GeoIdPoint, Sketcher::start); commitCommand(); } @@ -4216,8 +4218,8 @@ void CmdSketcherConstrainPerpendicular::applyConstraint(std::vector & } openCommand("add perpendicular constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Perpendicular',%d,%d)) ", - Obj,GeoId1,GeoId2); + Gui::cmdAppObjectArgs(Obj, "addConstraint(Sketcher.Constraint('Perpendicular',%d,%d)) ", + GeoId1,GeoId2); commitCommand(); tryAutoRecompute(Obj); @@ -4256,22 +4258,22 @@ void CmdSketcherConstrainPerpendicular::applyConstraint(std::vector & try{ //add missing point-on-object constraints if(! IsPointAlreadyOnCurve(GeoId1, GeoId3, PosId3, Obj)){ - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", - Obj,GeoId3,PosId3,GeoId1); + Gui::cmdAppObjectArgs(Obj, "addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", + GeoId3,PosId3,GeoId1); }; if(! IsPointAlreadyOnCurve(GeoId2, GeoId3, PosId3, Obj)){ - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", - Obj,GeoId3,PosId3,GeoId2); + Gui::cmdAppObjectArgs(Obj, "addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", + GeoId3,PosId3,GeoId2); }; if(! IsPointAlreadyOnCurve(GeoId1, GeoId3, PosId3, Obj)){//FIXME: it's a good idea to add a check if the sketch is solved - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", - Obj,GeoId3,PosId3,GeoId1); + Gui::cmdAppObjectArgs(Obj, "addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", + GeoId3,PosId3,GeoId1); }; - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('PerpendicularViaPoint',%d,%d,%d,%d)) ", - Obj,GeoId1,GeoId2,GeoId3,PosId3); + Gui::cmdAppObjectArgs(Obj, "addConstraint(Sketcher.Constraint('PerpendicularViaPoint',%d,%d,%d,%d)) ", + GeoId1,GeoId2,GeoId3,PosId3); } catch (const Base::Exception& e) { Base::Console().Error("%s\n", e.what()); QMessageBox::warning(Gui::getMainWindow(), @@ -4406,22 +4408,22 @@ void CmdSketcherConstrainTangent::activated(int iMsg) try{ //add missing point-on-object constraints if(! IsPointAlreadyOnCurve(GeoId1, GeoId3, PosId3, Obj)){ - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", - selection[0].getObject(),GeoId3,PosId3,GeoId1); + Gui::cmdAppObjectArgs(selection[0].getObject(), "addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", + GeoId3,PosId3,GeoId1); }; if(! IsPointAlreadyOnCurve(GeoId2, GeoId3, PosId3, Obj)){ - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", - selection[0].getObject(),GeoId3,PosId3,GeoId2); + Gui::cmdAppObjectArgs(selection[0].getObject(), "addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", + GeoId3,PosId3,GeoId2); }; if(! IsPointAlreadyOnCurve(GeoId1, GeoId3, PosId3, Obj)){//FIXME: it's a good idea to add a check if the sketch is solved - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", - selection[0].getObject(),GeoId3,PosId3,GeoId1); + Gui::cmdAppObjectArgs(selection[0].getObject(), "addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", + GeoId3,PosId3,GeoId1); }; - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('TangentViaPoint',%d,%d,%d,%d)) ", - selection[0].getObject(),GeoId1,GeoId2,GeoId3,PosId3); + Gui::cmdAppObjectArgs(selection[0].getObject(), "addConstraint(Sketcher.Constraint('TangentViaPoint',%d,%d,%d,%d)) ", + GeoId1,GeoId2,GeoId3,PosId3); } catch (const Base::Exception& e) { Base::Console().Error("%s\n", e.what()); QMessageBox::warning(Gui::getMainWindow(), @@ -4484,8 +4486,8 @@ void CmdSketcherConstrainTangent::activated(int iMsg) } openCommand("add tangent constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Tangent',%d,%d,%d)) ", - selection[0].getObject(),GeoId1,PosId1,GeoId2); + Gui::cmdAppObjectArgs(selection[0].getObject(), "addConstraint(Sketcher.Constraint('Tangent',%d,%d,%d)) ", + GeoId1,PosId1,GeoId2); commitCommand(); tryAutoRecompute(Obj); @@ -4524,7 +4526,7 @@ void CmdSketcherConstrainTangent::activated(int iMsg) doEndpointTangency(Obj, selection[0], (*it)->First, (*it)->Second, (*it)->FirstPos, (*it)->SecondPos); - FCMD_OBJ_CMD2("delConstraintOnPoint(%i,%i)", Obj, first, firstpos); + Gui::cmdAppObjectArgs(Obj, "delConstraintOnPoint(%i,%i)", first, firstpos); commitCommand(); tryAutoRecomputeIfNotSolve(Obj); @@ -4671,8 +4673,9 @@ void CmdSketcherConstrainTangent::activated(int iMsg) } openCommand("add tangent constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Tangent',%d,%d)) ", - selection[0].getObject(),GeoId1,GeoId2); + Gui::cmdAppObjectArgs(selection[0].getObject(), + "addConstraint(Sketcher.Constraint('Tangent',%d,%d)) ", + GeoId1,GeoId2); commitCommand(); tryAutoRecompute(Obj); @@ -4821,8 +4824,8 @@ void CmdSketcherConstrainTangent::applyConstraint(std::vector &selSeq } openCommand("add tangent constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Tangent',%d,%d)) ", - Obj,GeoId1,GeoId2); + Gui::cmdAppObjectArgs(Obj, "addConstraint(Sketcher.Constraint('Tangent',%d,%d)) ", + GeoId1,GeoId2); commitCommand(); tryAutoRecompute(Obj); @@ -4879,8 +4882,8 @@ void CmdSketcherConstrainTangent::applyConstraint(std::vector &selSeq } // end of code supports simple B-spline endpoint tangency openCommand("add tangent constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Tangent',%d,%d,%d,%d)) ", - Obj,GeoId1,PosId1,GeoId2,PosId2); + Gui::cmdAppObjectArgs(Obj, "addConstraint(Sketcher.Constraint('Tangent',%d,%d,%d,%d)) ", + GeoId1,PosId1,GeoId2,PosId2); commitCommand(); tryAutoRecompute(Obj); @@ -4898,22 +4901,22 @@ void CmdSketcherConstrainTangent::applyConstraint(std::vector &selSeq try{ //add missing point-on-object constraints if(! IsPointAlreadyOnCurve(GeoId1, GeoId3, PosId3, Obj)){ - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", - Obj,GeoId3,PosId3,GeoId1); + Gui::cmdAppObjectArgs(Obj,"addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", + GeoId3,PosId3,GeoId1); }; if(! IsPointAlreadyOnCurve(GeoId2, GeoId3, PosId3, Obj)){ - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", - Obj,GeoId3,PosId3,GeoId2); + Gui::cmdAppObjectArgs(Obj,"addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", + GeoId3,PosId3,GeoId2); }; if(! IsPointAlreadyOnCurve(GeoId1, GeoId3, PosId3, Obj)){//FIXME: it's a good idea to add a check if the sketch is solved - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", - Obj,GeoId3,PosId3,GeoId1); + Gui::cmdAppObjectArgs(Obj,"addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", + GeoId3,PosId3,GeoId1); }; - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('TangentViaPoint',%d,%d,%d,%d)) ", - Obj, GeoId1,GeoId2,GeoId3,PosId3); + Gui::cmdAppObjectArgs(Obj, "addConstraint(Sketcher.Constraint('TangentViaPoint',%d,%d,%d,%d)) ", + GeoId1,GeoId2,GeoId3,PosId3); } catch (const Base::Exception& e) { Base::Console().Error("%s\n", e.what()); QMessageBox::warning(Gui::getMainWindow(), @@ -5060,15 +5063,14 @@ void CmdSketcherConstrainRadius::activated(int iMsg) unsigned int constrSize = 0; for (std::vector< std::pair >::iterator it = externalGeoIdRadiusMap.begin(); it != externalGeoIdRadiusMap.end(); ++it) { - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Radius',%d,%f)) ", - selection[0].getObject(),it->first,it->second); + Gui::cmdAppObjectArgs(selection[0].getObject(),"addConstraint(Sketcher.Constraint('Radius',%d,%f)) ", + it->first,it->second); const std::vector &ConStr = Obj->Constraints.getValues(); constrSize=ConStr.size(); - FCMD_OBJ_CMD2("setDriving(%i,%s)", - selection[0].getObject(),constrSize-1,"False"); + Gui::cmdAppObjectArgs(selection[0].getObject(),"setDriving(%i,%s)", constrSize-1,"False"); } const std::vector &ConStr = Obj->Constraints.getValues(); @@ -5118,13 +5120,14 @@ void CmdSketcherConstrainRadius::activated(int iMsg) if(!commandopened) openCommand("Add radius constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Radius',%d,%f)) ", - selection[0].getObject(),refGeoId,radius); + Gui::cmdAppObjectArgs(selection[0].getObject(), "addConstraint(Sketcher.Constraint('Radius',%d,%f)) ", + refGeoId,radius); // Add the equality constraints for (std::vector< std::pair >::iterator it = geoIdRadiusMap.begin()+1; it != geoIdRadiusMap.end(); ++it) { - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Equal',%d,%d)) ", - selection[0].getObject(),refGeoId,it->first); + Gui::cmdAppObjectArgs(selection[0].getObject(), + "addConstraint(Sketcher.Constraint('Equal',%d,%d)) ", + refGeoId,it->first); } } else { @@ -5132,18 +5135,13 @@ void CmdSketcherConstrainRadius::activated(int iMsg) if(!commandopened) openCommand("Add radius constraint"); for (std::vector< std::pair >::iterator it = geoIdRadiusMap.begin(); it != geoIdRadiusMap.end(); ++it) { - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Radius',%d,%f)) ", - selection[0].getObject(),it->first,it->second); - - if(constraintCreationMode==Reference) { - - const std::vector &ConStr = Obj->Constraints.getValues(); - - FCMD_OBJ_CMD2("setDriving(%i,%s)", - selection[0].getObject(),ConStr.size()-1,"False"); - - } + Gui::cmdAppObjectArgs(selection[0].getObject(), "addConstraint(Sketcher.Constraint('Radius',%d,%f)) ", + it->first,it->second); + if (constraintCreationMode==Reference) { + const std::vector &ConStr = Obj->Constraints.getValues(); + Gui::cmdAppObjectArgs(selection[0].getObject(), "setDriving(%i,%s)", ConStr.size()-1,"False"); + } } } @@ -5190,22 +5188,19 @@ void CmdSketcherConstrainRadius::activated(int iMsg) try { if (constrainEqual || geoIdRadiusMap.size() == 1) { - FCMD_OBJ_CMD2("setDatum(%i,App.Units.Quantity('%f %s'))", - Obj, + Gui::cmdAppObjectArgs(Obj, "setDatum(%i,App.Units.Quantity('%f %s'))", indexConstr, newRadius, (const char*)newQuant.getUnit().getString().toUtf8()); QString constraintName = ui_Datum.name->text().trimmed(); if (Base::Tools::toStdString(constraintName) != Obj->Constraints[indexConstr]->Name) { std::string escapedstr = Base::Tools::escapedUnicodeFromUtf8(constraintName.toUtf8().constData()); - FCMD_OBJ_CMD2("renameConstraint(%d, u'%s')", - Obj, + Gui::cmdAppObjectArgs(Obj, "renameConstraint(%d, u'%s')", indexConstr, escapedstr.c_str()); } } else { for (std::size_t i=0; i &selSeq, // Create the radius constraint now openCommand("Add radius constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Radius',%d,%f)) ", - Obj, GeoId, radius); + Gui::cmdAppObjectArgs(Obj, "addConstraint(Sketcher.Constraint('Radius',%d,%f)) ", + GeoId, radius); const std::vector &ConStr = Obj->Constraints.getValues(); int indexConstr = ConStr.size() - 1; bool fixed = isPointOrSegmentFixed(Obj,GeoId); if(fixed || constraintCreationMode==Reference) { - FCMD_OBJ_CMD2("setDriving(%i,%s)", - Obj, ConStr.size()-1, "False"); + Gui::cmdAppObjectArgs(Obj, "setDriving(%i,%s)", + ConStr.size()-1, "False"); } // Guess some reasonable distance for placing the datum text @@ -5331,16 +5326,14 @@ void CmdSketcherConstrainRadius::applyConstraint(std::vector &selSeq, double newRadius = newQuant.getValue(); try { - FCMD_OBJ_CMD2("setDatum(%i,App.Units.Quantity('%f %s'))", - Obj, + Gui::cmdAppObjectArgs(Obj, "setDatum(%i,App.Units.Quantity('%f %s'))", indexConstr, newRadius, (const char*)newQuant.getUnit().getString().toUtf8()); QString constraintName = ui_Datum.name->text().trimmed(); if (Base::Tools::toStdString(constraintName) != Obj->Constraints[indexConstr]->Name) { std::string escapedstr = Base::Tools::escapedUnicodeFromUtf8(constraintName.toUtf8().constData()); - FCMD_OBJ_CMD2("renameConstraint(%d, u'%s')", - Obj, - indexConstr, escapedstr.c_str()); + Gui::cmdAppObjectArgs(Obj, "renameConstraint(%d, u'%s')", + indexConstr, escapedstr.c_str()); } commitCommand(); @@ -5527,13 +5520,13 @@ void CmdSketcherConstrainDiameter::activated(int iMsg) unsigned int constrSize = 0; for (std::vector< std::pair >::iterator it = externalGeoIdDiameterMap.begin(); it != externalGeoIdDiameterMap.end(); ++it) { - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Diameter',%d,%f)) ", Obj,it->first,it->second); + Gui::cmdAppObjectArgs(Obj, "addConstraint(Sketcher.Constraint('Diameter',%d,%f)) ", it->first,it->second); const std::vector &ConStr = Obj->Constraints.getValues(); constrSize=ConStr.size(); - FCMD_OBJ_CMD2("setDriving(%i,%s)",Obj,constrSize-1,"False"); + Gui::cmdAppObjectArgs(Obj,"setDriving(%i,%s)",constrSize-1,"False"); } const std::vector &ConStr = Obj->Constraints.getValues(); @@ -5583,11 +5576,11 @@ void CmdSketcherConstrainDiameter::activated(int iMsg) if(!commandopened) openCommand("Add diameter constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Diameter',%d,%f)) ", Obj,refGeoId,diameter); + Gui::cmdAppObjectArgs(Obj, "addConstraint(Sketcher.Constraint('Diameter',%d,%f)) ", refGeoId,diameter); // Add the equality constraints for (std::vector< std::pair >::iterator it = geoIdDiameterMap.begin()+1; it != geoIdDiameterMap.end(); ++it) { - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Equal',%d,%d)) ", Obj,refGeoId,it->first); + Gui::cmdAppObjectArgs(Obj, "addConstraint(Sketcher.Constraint('Equal',%d,%d)) ", refGeoId,it->first); } } else { @@ -5595,14 +5588,14 @@ void CmdSketcherConstrainDiameter::activated(int iMsg) if(!commandopened) openCommand("Add diameter constraint"); for (std::vector< std::pair >::iterator it = geoIdDiameterMap.begin(); it != geoIdDiameterMap.end(); ++it) { - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Diameter',%d,%f)) ", - Obj,it->first,it->second); + Gui::cmdAppObjectArgs(Obj, "addConstraint(Sketcher.Constraint('Diameter',%d,%f)) ", + it->first,it->second); if(constraintCreationMode==Reference) { const std::vector &ConStr = Obj->Constraints.getValues(); - FCMD_OBJ_CMD2("setDriving(%i,%s)", Obj,ConStr.size()-1,"False"); + Gui::cmdAppObjectArgs(Obj, "setDriving(%i,%s)", ConStr.size()-1,"False"); } @@ -5652,18 +5645,18 @@ void CmdSketcherConstrainDiameter::activated(int iMsg) try { if (constrainEqual || geoIdDiameterMap.size() == 1) { - FCMD_OBJ_CMD2("setDatum(%i,App.Units.Quantity('%f %s'))", Obj, + Gui::cmdAppObjectArgs(Obj, "setDatum(%i,App.Units.Quantity('%f %s'))", indexConstr, newDiameter, (const char*)newQuant.getUnit().getString().toUtf8()); QString constraintName = ui_Datum.name->text().trimmed(); if (Base::Tools::toStdString(constraintName) != Obj->Constraints[indexConstr]->Name) { std::string escapedstr = Base::Tools::escapedUnicodeFromUtf8(constraintName.toUtf8().constData()); - FCMD_OBJ_CMD2("renameConstraint(%d, u'%s')", Obj, indexConstr, escapedstr.c_str()); + Gui::cmdAppObjectArgs(Obj, "renameConstraint(%d, u'%s')", indexConstr, escapedstr.c_str()); } } else { for (std::size_t i=0; i &selSe // Create the diameter constraint now openCommand("Add diameter constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Diameter',%d,%f)) ", - Obj, GeoId, diameter); + Gui::cmdAppObjectArgs(Obj, "addConstraint(Sketcher.Constraint('Diameter',%d,%f)) ", + GeoId, diameter); const std::vector &ConStr = Obj->Constraints.getValues(); int indexConstr = ConStr.size() - 1; bool fixed = isPointOrSegmentFixed(Obj,GeoId); if(fixed || constraintCreationMode==Reference) { - FCMD_OBJ_CMD2("setDriving(%i,%s)", Obj, ConStr.size()-1, "False"); + Gui::cmdAppObjectArgs(Obj, "setDriving(%i,%s)", ConStr.size()-1, "False"); } // Guess some reasonable distance for placing the datum text @@ -5788,13 +5781,13 @@ void CmdSketcherConstrainDiameter::applyConstraint(std::vector &selSe double newDiameter = newQuant.getValue(); try { - FCMD_OBJ_CMD2("setDatum(%i,App.Units.Quantity('%f %s'))", Obj, + Gui::cmdAppObjectArgs(Obj, "setDatum(%i,App.Units.Quantity('%f %s'))", indexConstr, newDiameter, (const char*)newQuant.getUnit().getString().toUtf8()); QString constraintName = ui_Datum.name->text().trimmed(); if (Base::Tools::toStdString(constraintName) != Obj->Constraints[indexConstr]->Name) { std::string escapedstr = Base::Tools::escapedUnicodeFromUtf8(constraintName.toUtf8().constData()); - FCMD_OBJ_CMD2("renameConstraint(%d, u'%s')", Obj, indexConstr, escapedstr.c_str()); + Gui::cmdAppObjectArgs(Obj, "renameConstraint(%d, u'%s')", indexConstr, escapedstr.c_str()); } commitCommand(); @@ -6070,18 +6063,18 @@ void CmdSketcherConstrainAngle::activated(int iMsg) openCommand("Add angle constraint"); //add missing point-on-object constraints - if(! IsPointAlreadyOnCurve(GeoId1, GeoId3, PosId3, Obj)){ - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", - selection[0].getObject(),GeoId3,PosId3,GeoId1); - }; - if(! IsPointAlreadyOnCurve(GeoId2, GeoId3, PosId3, Obj)){ - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", - selection[0].getObject(),GeoId3,PosId3,GeoId2); - }; - if(! IsPointAlreadyOnCurve(GeoId1, GeoId3, PosId3, Obj)){//FIXME: it's a good idea to add a check if the sketch is solved - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", - selection[0].getObject(),GeoId3,PosId3,GeoId1); - }; + if (!IsPointAlreadyOnCurve(GeoId1, GeoId3, PosId3, Obj)) { + Gui::cmdAppObjectArgs(selection[0].getObject(), "addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", + GeoId3,PosId3,GeoId1); + } + if (!IsPointAlreadyOnCurve(GeoId2, GeoId3, PosId3, Obj)) { + Gui::cmdAppObjectArgs(selection[0].getObject(), "addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", + GeoId3,PosId3,GeoId2); + } + if (!IsPointAlreadyOnCurve(GeoId1, GeoId3, PosId3, Obj)) {//FIXME: it's a good idea to add a check if the sketch is solved + Gui::cmdAppObjectArgs(selection[0].getObject(), "addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", + GeoId3,PosId3,GeoId1); + } //assuming point-on-curves have been solved, calculate the angle. //DeepSOIC: this may be slow, but I wanted to reuse the conversion from Geometry to GCS shapes that is done in Sketch @@ -6095,14 +6088,14 @@ void CmdSketcherConstrainAngle::activated(int iMsg) ActAngle = -ActAngle; } - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('AngleViaPoint',%d,%d,%d,%d,%f)) ", - selection[0].getObject(),GeoId1,GeoId2,GeoId3,PosId3,ActAngle); + Gui::cmdAppObjectArgs(selection[0].getObject(),"addConstraint(Sketcher.Constraint('AngleViaPoint',%d,%d,%d,%d,%f)) ", + GeoId1,GeoId2,GeoId3,PosId3,ActAngle); if (bothexternal || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving const std::vector &ConStr = Obj->Constraints.getValues(); - FCMD_OBJ_CMD2("setDriving(%i,%s)", - selection[0].getObject(),ConStr.size()-1,"False"); + Gui::cmdAppObjectArgs(selection[0].getObject(),"setDriving(%i,%s)", + ConStr.size()-1,"False"); finishDistanceConstraint(this, Obj,false); } else @@ -6194,14 +6187,14 @@ void CmdSketcherConstrainAngle::activated(int iMsg) } openCommand("Add angle constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Angle',%d,%d,%d,%d,%f)) ", - selection[0].getObject(),GeoId1,PosId1,GeoId2,PosId2,ActAngle); + Gui::cmdAppObjectArgs(selection[0].getObject(),"addConstraint(Sketcher.Constraint('Angle',%d,%d,%d,%d,%f)) ", + GeoId1,PosId1,GeoId2,PosId2,ActAngle); if (bothexternal || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving const std::vector &ConStr = Obj->Constraints.getValues(); - FCMD_OBJ_CMD2("setDriving(%i,%s)", - selection[0].getObject(),ConStr.size()-1,"False"); + Gui::cmdAppObjectArgs(selection[0].getObject(),"setDriving(%i,%s)", + ConStr.size()-1,"False"); finishDistanceConstraint(this, Obj,false); } else @@ -6224,14 +6217,14 @@ void CmdSketcherConstrainAngle::activated(int iMsg) double ActAngle = atan2(dir.y,dir.x); openCommand("Add angle constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Angle',%d,%f)) ", - selection[0].getObject(),GeoId1,ActAngle); + Gui::cmdAppObjectArgs(selection[0].getObject(),"addConstraint(Sketcher.Constraint('Angle',%d,%f)) ", + GeoId1,ActAngle); if (GeoId1 <= Sketcher::GeoEnum::RefExt || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving const std::vector &ConStr = Obj->Constraints.getValues(); - FCMD_OBJ_CMD2("setDriving(%i,%s)", - selection[0].getObject(),ConStr.size()-1,"False"); + Gui::cmdAppObjectArgs(selection[0].getObject(), "setDriving(%i,%s)", + ConStr.size()-1,"False"); finishDistanceConstraint(this, Obj,false); } else @@ -6247,14 +6240,14 @@ void CmdSketcherConstrainAngle::activated(int iMsg) double angle = endangle - startangle; openCommand("Add angle constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Angle',%d,%f)) ", - selection[0].getObject(),GeoId1,angle); + Gui::cmdAppObjectArgs(selection[0].getObject(), "addConstraint(Sketcher.Constraint('Angle',%d,%f)) ", + GeoId1,angle); if (GeoId1 <= Sketcher::GeoEnum::RefExt || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving const std::vector &ConStr = Obj->Constraints.getValues(); - FCMD_OBJ_CMD2("setDriving(%i,%s)", - selection[0].getObject(),ConStr.size()-1,"False"); + Gui::cmdAppObjectArgs(selection[0].getObject(), "setDriving(%i,%s)", + ConStr.size()-1,"False"); finishDistanceConstraint(this, Obj,false); } else @@ -6359,14 +6352,14 @@ void CmdSketcherConstrainAngle::applyConstraint(std::vector &selSeq, } openCommand("Add angle constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Angle',%d,%d,%d,%d,%f)) ", - Obj,GeoId1,PosId1,GeoId2,PosId2,ActAngle); + Gui::cmdAppObjectArgs(Obj, "addConstraint(Sketcher.Constraint('Angle',%d,%d,%d,%d,%f)) ", + GeoId1,PosId1,GeoId2,PosId2,ActAngle); if (areBothPointsOrSegmentsFixed(Obj,GeoId1, GeoId2) || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving const std::vector &ConStr = Obj->Constraints.getValues(); - FCMD_OBJ_CMD2("setDriving(%i,%s)", - Obj,ConStr.size()-1,"False"); + Gui::cmdAppObjectArgs(Obj,"setDriving(%i,%s)", + ConStr.size()-1,"False"); finishDistanceConstraint(this, Obj,false); } else @@ -6408,17 +6401,17 @@ void CmdSketcherConstrainAngle::applyConstraint(std::vector &selSeq, //add missing point-on-object constraints if(! IsPointAlreadyOnCurve(GeoId1, GeoId3, PosId3, Obj)){ - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", - Obj,GeoId3,PosId3,GeoId1); - }; + Gui::cmdAppObjectArgs(Obj,"addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", + GeoId3,PosId3,GeoId1); + } if(! IsPointAlreadyOnCurve(GeoId2, GeoId3, PosId3, Obj)){ - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", - Obj,GeoId3,PosId3,GeoId2); - }; + Gui::cmdAppObjectArgs(Obj,"addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", + GeoId3,PosId3,GeoId2); + } if(! IsPointAlreadyOnCurve(GeoId1, GeoId3, PosId3, Obj)){//FIXME: it's a good idea to add a check if the sketch is solved - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", - Obj,GeoId3,PosId3,GeoId1); - }; + Gui::cmdAppObjectArgs(Obj,"addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", + GeoId3,PosId3,GeoId1); + } //assuming point-on-curves have been solved, calculate the angle. //DeepSOIC: this may be slow, but I wanted to reuse the conversion from Geometry to GCS shapes that is done in Sketch @@ -6432,14 +6425,14 @@ void CmdSketcherConstrainAngle::applyConstraint(std::vector &selSeq, ActAngle = -ActAngle; } - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('AngleViaPoint',%d,%d,%d,%d,%f)) ", - Obj,GeoId1,GeoId2,GeoId3,PosId3,ActAngle); + Gui::cmdAppObjectArgs(Obj,"addConstraint(Sketcher.Constraint('AngleViaPoint',%d,%d,%d,%d,%f)) ", + GeoId1,GeoId2,GeoId3,PosId3,ActAngle); if (bothexternal || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving const std::vector &ConStr = Obj->Constraints.getValues(); - FCMD_OBJ_CMD2("setDriving(%i,%s)", - Obj,ConStr.size()-1,"False"); + Gui::cmdAppObjectArgs(Obj,"setDriving(%i,%s)", + ConStr.size()-1,"False"); finishDistanceConstraint(this, Obj,false); } else @@ -6607,8 +6600,8 @@ void CmdSketcherConstrainEqual::activated(int iMsg) // undo command open openCommand("add equality constraint"); for (int i=0; i < int(ids.size()-1); i++) { - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Equal',%d,%d)) ", - selection[0].getObject(),ids[i],ids[i+1]); + Gui::cmdAppObjectArgs(selection[0].getObject(), "addConstraint(Sketcher.Constraint('Equal',%d,%d)) ", + ids[i],ids[i+1]); } // finish the transaction and update commitCommand(); @@ -6641,8 +6634,8 @@ void CmdSketcherConstrainEqual::applyConstraint(std::vector &selSeq, // undo command open openCommand("add equality constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Equal',%d,%d)) ", - Obj, GeoId1, GeoId2); + Gui::cmdAppObjectArgs(Obj, "addConstraint(Sketcher.Constraint('Equal',%d,%d)) ", + GeoId1, GeoId2); // finish the transaction and update commitCommand(); tryAutoRecompute(Obj); @@ -6753,8 +6746,9 @@ void CmdSketcherConstrainSymmetric::activated(int iMsg) // undo command open openCommand("add symmetric constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Symmetric',%d,%d,%d,%d,%d,%d)) ", - selection[0].getObject(),GeoId1,Sketcher::start,GeoId1,Sketcher::end,GeoId2,PosId2); + Gui::cmdAppObjectArgs(selection[0].getObject(), + "addConstraint(Sketcher.Constraint('Symmetric',%d,%d,%d,%d,%d,%d)) ", + GeoId1,Sketcher::start,GeoId1,Sketcher::end,GeoId2,PosId2); // finish the transaction and update commitCommand(); @@ -6802,8 +6796,9 @@ void CmdSketcherConstrainSymmetric::activated(int iMsg) // undo command open openCommand("add symmetric constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Symmetric',%d,%d,%d,%d,%d)) ", - selection[0].getObject(),GeoId1,PosId1,GeoId2,PosId2,GeoId3); + Gui::cmdAppObjectArgs(selection[0].getObject(), + "addConstraint(Sketcher.Constraint('Symmetric',%d,%d,%d,%d,%d)) ", + GeoId1,PosId1,GeoId2,PosId2,GeoId3); // finish the transaction and update commitCommand(); @@ -6817,8 +6812,9 @@ void CmdSketcherConstrainSymmetric::activated(int iMsg) else if (isVertex(GeoId3,PosId3)) { // undo command open openCommand("add symmetric constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Symmetric',%d,%d,%d,%d,%d,%d)) ", - selection[0].getObject(),GeoId1,PosId1,GeoId2,PosId2,GeoId3,PosId3); + Gui::cmdAppObjectArgs(selection[0].getObject(), + "addConstraint(Sketcher.Constraint('Symmetric',%d,%d,%d,%d,%d,%d)) ", + GeoId1,PosId1,GeoId2,PosId2,GeoId3,PosId3); // finish the transaction and update commitCommand(); @@ -6885,8 +6881,8 @@ void CmdSketcherConstrainSymmetric::applyConstraint(std::vector &selS // undo command open openCommand("add symmetric constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Symmetric',%d,%d,%d,%d,%d)) ", - Obj,GeoId1,PosId1,GeoId2,PosId2,GeoId3); + Gui::cmdAppObjectArgs(Obj,"addConstraint(Sketcher.Constraint('Symmetric',%d,%d,%d,%d,%d)) ", + GeoId1,PosId1,GeoId2,PosId2,GeoId3); // finish the transaction and update commitCommand(); @@ -6919,8 +6915,8 @@ void CmdSketcherConstrainSymmetric::applyConstraint(std::vector &selS // undo command open openCommand("add symmetric constraint"); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Symmetric',%d,%d,%d,%d,%d,%d)) ", - Obj,GeoId1,PosId1,GeoId2,PosId2,GeoId3,PosId3); + Gui::cmdAppObjectArgs(Obj,"addConstraint(Sketcher.Constraint('Symmetric',%d,%d,%d,%d,%d,%d)) ", + GeoId1,PosId1,GeoId2,PosId2,GeoId3,PosId3); // finish the transaction and update commitCommand(); @@ -7048,21 +7044,23 @@ void CmdSketcherConstrainSnellsLaw::activated(int iMsg) openCommand("add Snell's law constraint"); if (! IsPointAlreadyOnCurve(GeoId2,GeoId1,PosId1,Obj)) - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Coincident',%d,%d,%d,%d)) ", - selection[0].getObject(),GeoId1,PosId1,GeoId2,PosId2); + Gui::cmdAppObjectArgs(selection[0].getObject(), + "addConstraint(Sketcher.Constraint('Coincident',%d,%d,%d,%d)) ", + GeoId1,PosId1,GeoId2,PosId2); if (! IsPointAlreadyOnCurve(GeoId3,GeoId1,PosId1,Obj)) - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", - selection[0].getObject(),GeoId1,PosId1,GeoId3); + Gui::cmdAppObjectArgs(selection[0].getObject(), + "addConstraint(Sketcher.Constraint('PointOnObject',%d,%d,%d)) ", + GeoId1,PosId1,GeoId3); - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('SnellsLaw',%d,%d,%d,%d,%d,%.12f)) ", - selection[0].getObject(),GeoId1,PosId1,GeoId2,PosId2,GeoId3,n2divn1); + Gui::cmdAppObjectArgs(selection[0].getObject(), "addConstraint(Sketcher.Constraint('SnellsLaw',%d,%d,%d,%d,%d,%.12f)) ", + GeoId1,PosId1,GeoId2,PosId2,GeoId3,n2divn1); /*if (allexternal || constraintCreationMode==Reference) { // it is a constraint on a external line, make it non-driving const std::vector &ConStr = Obj->Constraints.getValues(); - FCMD_OBJ_CMD2("setDriving(%i,%s)", - selection[0].getObject(),ConStr.size()-1,"False"); + Gui::cmdAppObjectArgs(selection[0].getObject(),"setDriving(%i,%s)", + ConStr.size()-1,"False"); }*/ commitCommand(); @@ -7247,12 +7245,14 @@ void CmdSketcherConstrainInternalAlignment::activated(int iMsg) if(pointids.size()>=1) { if(!focus1) { - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('InternalAlignment:EllipseFocus1',%d,%d,%d)) ", - selection[0].getObject(),pointids[0],Sketcher::start,ellipseids[0]); + Gui::cmdAppObjectArgs(selection[0].getObject(), + "addConstraint(Sketcher.Constraint('InternalAlignment:EllipseFocus1',%d,%d,%d)) ", + pointids[0],Sketcher::start,ellipseids[0]); } else if(!focus2) { - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('InternalAlignment:EllipseFocus2',%d,%d,%d)) ", - selection[0].getObject(),pointids[0],Sketcher::start,ellipseids[0]); + Gui::cmdAppObjectArgs(selection[0].getObject(), + "addConstraint(Sketcher.Constraint('InternalAlignment:EllipseFocus2',%d,%d,%d)) ", + pointids[0],Sketcher::start,ellipseids[0]); focus2=true; } else @@ -7262,8 +7262,9 @@ void CmdSketcherConstrainInternalAlignment::activated(int iMsg) if(pointids.size()==2) { if(!focus2) { - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('InternalAlignment:EllipseFocus2',%d,%d,%d)) ", - selection[0].getObject(),pointids[1],Sketcher::start,ellipseids[0]); + Gui::cmdAppObjectArgs(selection[0].getObject(), + "addConstraint(Sketcher.Constraint('InternalAlignment:EllipseFocus2',%d,%d,%d)) ", + pointids[1],Sketcher::start,ellipseids[0]); } else extra_elements=true; @@ -7272,23 +7273,25 @@ void CmdSketcherConstrainInternalAlignment::activated(int iMsg) if(lineids.size()>=1) { if(!major) { - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('InternalAlignment:EllipseMajorDiameter',%d,%d)) ", - selection[0].getObject(),lineids[0],ellipseids[0]); + Gui::cmdAppObjectArgs(selection[0].getObject(), + "addConstraint(Sketcher.Constraint('InternalAlignment:EllipseMajorDiameter',%d,%d)) ", + lineids[0],ellipseids[0]); const Part::GeomLineSegment *geo = static_cast(Obj->getGeometry(lineids[0])); if(!geo->Construction) - FCMD_OBJ_CMD2("toggleConstruction(%d) ",selection[0].getObject(),lineids[0]); + Gui::cmdAppObjectArgs(selection[0].getObject(),"toggleConstruction(%d) ",lineids[0]); } else if(!minor) { - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('InternalAlignment:EllipseMinorDiameter',%d,%d)) ", - selection[0].getObject(),lineids[0],ellipseids[0]); + Gui::cmdAppObjectArgs(selection[0].getObject(), + "addConstraint(Sketcher.Constraint('InternalAlignment:EllipseMinorDiameter',%d,%d)) ", + lineids[0],ellipseids[0]); const Part::GeomLineSegment *geo = static_cast(Obj->getGeometry(lineids[0])); if(!geo->Construction) - FCMD_OBJ_CMD2("toggleConstruction(%d) ",selection[0].getObject(),lineids[0]); + Gui::cmdAppObjectArgs(selection[0].getObject(),"toggleConstruction(%d) ",lineids[0]); minor=true; } @@ -7298,13 +7301,14 @@ void CmdSketcherConstrainInternalAlignment::activated(int iMsg) if(lineids.size()==2) { if(!minor){ - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('InternalAlignment:EllipseMinorDiameter',%d,%d)) ", - selection[0].getObject(),lineids[1],ellipseids[0]); + Gui::cmdAppObjectArgs(selection[0].getObject(), + "addConstraint(Sketcher.Constraint('InternalAlignment:EllipseMinorDiameter',%d,%d)) ", + lineids[1],ellipseids[0]); const Part::GeomLineSegment *geo = static_cast(Obj->getGeometry(lineids[1])); if(!geo->Construction) - FCMD_OBJ_CMD2("toggleConstruction(%d) ",selection[0].getObject(),lineids[1]); + Gui::cmdAppObjectArgs(selection[0].getObject(),"toggleConstruction(%d) ",lineids[1]); } else extra_elements=true; @@ -7406,12 +7410,14 @@ void CmdSketcherConstrainInternalAlignment::activated(int iMsg) if(pointids.size()>=1) { if(!focus1) { - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('InternalAlignment:EllipseFocus1',%d,%d,%d)) ", - selection[0].getObject(),pointids[0],Sketcher::start,arcsofellipseids[0]); + Gui::cmdAppObjectArgs(selection[0].getObject(), + "addConstraint(Sketcher.Constraint('InternalAlignment:EllipseFocus1',%d,%d,%d)) ", + pointids[0],Sketcher::start,arcsofellipseids[0]); } else if(!focus2) { - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('InternalAlignment:EllipseFocus2',%d,%d,%d)) ", - selection[0].getObject(),pointids[0],Sketcher::start,arcsofellipseids[0]); + Gui::cmdAppObjectArgs(selection[0].getObject(), + "addConstraint(Sketcher.Constraint('InternalAlignment:EllipseFocus2',%d,%d,%d)) ", + pointids[0],Sketcher::start,arcsofellipseids[0]); focus2=true; } else @@ -7421,8 +7427,9 @@ void CmdSketcherConstrainInternalAlignment::activated(int iMsg) if(pointids.size()==2) { if(!focus2) { - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('InternalAlignment:EllipseFocus2',%d,%d,%d)) ", - selection[0].getObject(),pointids[1],Sketcher::start,arcsofellipseids[0]); + Gui::cmdAppObjectArgs(selection[0].getObject(), + "addConstraint(Sketcher.Constraint('InternalAlignment:EllipseFocus2',%d,%d,%d)) ", + pointids[1],Sketcher::start,arcsofellipseids[0]); } else extra_elements=true; @@ -7431,39 +7438,42 @@ void CmdSketcherConstrainInternalAlignment::activated(int iMsg) if(lineids.size()>=1) { if(!major) { - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('InternalAlignment:EllipseMajorDiameter',%d,%d)) ", - selection[0].getObject(),lineids[0],arcsofellipseids[0]); + Gui::cmdAppObjectArgs(selection[0].getObject(), + "addConstraint(Sketcher.Constraint('InternalAlignment:EllipseMajorDiameter',%d,%d)) ", + lineids[0],arcsofellipseids[0]); const Part::GeomLineSegment *geo = static_cast(Obj->getGeometry(lineids[0])); if(!geo->Construction) - FCMD_OBJ_CMD2("toggleConstruction(%d) ",selection[0].getObject(),lineids[0]); + Gui::cmdAppObjectArgs(selection[0].getObject(),"toggleConstruction(%d) ",lineids[0]); } else if(!minor) { - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('InternalAlignment:EllipseMinorDiameter',%d,%d)) ", - selection[0].getObject(),lineids[0],arcsofellipseids[0]); + Gui::cmdAppObjectArgs(selection[0].getObject(), + "addConstraint(Sketcher.Constraint('InternalAlignment:EllipseMinorDiameter',%d,%d)) ", + lineids[0],arcsofellipseids[0]); const Part::GeomLineSegment *geo = static_cast(Obj->getGeometry(lineids[0])); if(!geo->Construction) - FCMD_OBJ_CMD2("toggleConstruction(%d) ",selection[0].getObject(),lineids[0]); + Gui::cmdAppObjectArgs(selection[0].getObject(),"toggleConstruction(%d) ",lineids[0]); minor=true; } else extra_elements=true; } - if(lineids.size()==2) - { - if(!minor){ - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('InternalAlignment:EllipseMinorDiameter',%d,%d)) ", - selection[0].getObject(),lineids[1],arcsofellipseids[0]); + + if(lineids.size()==2) { + if (!minor) { + Gui::cmdAppObjectArgs(selection[0].getObject(), + "addConstraint(Sketcher.Constraint('InternalAlignment:EllipseMinorDiameter',%d,%d)) ", + lineids[1],arcsofellipseids[0]); const Part::GeomLineSegment *geo = static_cast(Obj->getGeometry(lineids[1])); - if(!geo->Construction) - FCMD_OBJ_CMD2("toggleConstruction(%d) ",selection[0].getObject(),lineids[1]); + if (!geo->Construction) + Gui::cmdAppObjectArgs(selection[0].getObject(),"toggleConstruction(%d) ",lineids[1]); } else extra_elements=true; @@ -7599,7 +7609,7 @@ void CmdSketcherToggleDrivingConstraint::activated(int iMsg) int ConstrId = Sketcher::PropertyConstraintList::getIndexFromConstraintName(*it); try { // issue the actual commands to toggle - FCMD_OBJ_CMD2("toggleDriving(%d) ",selection[0].getObject(),ConstrId); + Gui::cmdAppObjectArgs(selection[0].getObject(), "toggleDriving(%d) ", ConstrId); } catch(const Base::Exception&) { successful--; @@ -7680,7 +7690,7 @@ void CmdSketcherToggleActiveConstraint::activated(int iMsg) int ConstrId = Sketcher::PropertyConstraintList::getIndexFromConstraintName(*it); try { // issue the actual commands to toggle - FCMD_OBJ_CMD2("toggleActive(%d) ",selection[0].getObject(),ConstrId); + Gui::cmdAppObjectArgs(selection[0].getObject(), "toggleActive(%d) ",ConstrId); } catch(const Base::Exception&) { successful--; diff --git a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp index 9d5f31312b..fd5d4fad66 100644 --- a/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp +++ b/src/Mod/Sketcher/Gui/CommandCreateGeo.cpp @@ -43,7 +43,7 @@ #include #include #include -#include +#include #include #include #include @@ -350,8 +350,7 @@ public: try { Gui::Command::openCommand("Add sketch line"); - FCMD_OBJ_CMD2("addGeometry(Part.LineSegment(App.Vector(%f,%f,0),App.Vector(%f,%f,0)),%s)", - sketchgui->getObject(), + Gui::cmdAppObjectArgs(sketchgui->getObject(), "addGeometry(Part.LineSegment(App.Vector(%f,%f,0),App.Vector(%f,%f,0)),%s)", EditCurve[0].x,EditCurve[0].y,EditCurve[1].x,EditCurve[1].y, geometryCreationMode==Construction?"True":"False"); @@ -1093,8 +1092,7 @@ public: try { // open the transaction Gui::Command::openCommand("Add line to sketch wire"); - FCMD_OBJ_CMD2("addGeometry(Part.LineSegment(App.Vector(%f,%f,0),App.Vector(%f,%f,0)),%s)", - sketchgui->getObject(), + Gui::cmdAppObjectArgs(sketchgui->getObject(), "addGeometry(Part.LineSegment(App.Vector(%f,%f,0),App.Vector(%f,%f,0)),%s)", EditCurve[0].x,EditCurve[0].y,EditCurve[1].x,EditCurve[1].y, geometryCreationMode==Construction?"True":"False"); } @@ -1114,9 +1112,8 @@ public: try { Gui::Command::openCommand("Add arc to sketch wire"); - FCMD_OBJ_CMD2("addGeometry(Part.ArcOfCircle" + Gui::cmdAppObjectArgs(sketchgui->getObject(), "addGeometry(Part.ArcOfCircle" "(Part.Circle(App.Vector(%f,%f,0),App.Vector(0,0,1),%f),%f,%f),%s)", - sketchgui->getObject(), CenterPoint.x, CenterPoint.y, std::abs(arcRadius), std::min(startAngle,endAngle), std::max(startAngle,endAngle), geometryCreationMode==Construction?"True":"False"); @@ -1146,9 +1143,8 @@ public: TransitionMode == TRANSITION_MODE_Perpendicular_R) constrType = "Perpendicular"; } - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('%s',%i,%i,%i,%i)) ", - sketchgui->getObject(), constrType.c_str(), - previousCurve, previousPosId, lastCurve, lastStartPosId); + Gui::cmdAppObjectArgs(sketchgui->getObject(), "addConstraint(Sketcher.Constraint('%s',%i,%i,%i,%i)) ", + constrType.c_str(), previousCurve, previousPosId, lastCurve, lastStartPosId); if(SnapMode == SNAP_MODE_45Degree && Mode != STATUS_Close) { // -360, -315, -270, -225, -180, -135, -90, -45, 0, 45, 90, 135, 180, 225, 270, 315, 360 @@ -1157,15 +1153,13 @@ public: // #3974: if in radians, the printf %f defaults to six decimals, which leads to loss of precision double arcAngle = abs(round( (endAngle - startAngle) / (M_PI/4)) * 45); // in degrees - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Angle',%i,App.Units.Quantity('%f deg'))) ", - sketchgui->getObject(), - lastCurve, arcAngle); + Gui::cmdAppObjectArgs(sketchgui->getObject(), "addConstraint(Sketcher.Constraint('Angle',%i,App.Units.Quantity('%f deg'))) ", + lastCurve, arcAngle); } if (Mode == STATUS_Close) { // close the loop by constrain to the first curve point - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Coincident',%i,%i,%i,%i)) ", - sketchgui->getObject(), - lastCurve,lastEndPosId,firstCurve,firstPosId); + Gui::cmdAppObjectArgs(sketchgui->getObject(), "addConstraint(Sketcher.Constraint('Coincident',%i,%i,%i,%i)) ", + lastCurve,lastEndPosId,firstCurve,firstPosId); } Gui::Command::commitCommand(); @@ -1601,10 +1595,8 @@ public: try { Gui::Command::openCommand("Add sketch arc"); - FCMD_OBJ_CMD2("addGeometry(Part.ArcOfCircle" - "(Part.Circle(App.Vector(%f,%f,0),App.Vector(0,0,1),%f)," - "%f,%f),%s)", - sketchgui->getObject(), + Gui::cmdAppObjectArgs(sketchgui->getObject(), "addGeometry(Part.ArcOfCircle" + "(Part.Circle(App.Vector(%f,%f,0),App.Vector(0,0,1),%f),%f,%f),%s)", CenterPoint.x, CenterPoint.y, sqrt(rx*rx + ry*ry), startAngle, endAngle, geometryCreationMode==Construction?"True":"False"); //arcAngle > 0 ? 0 : 1); @@ -1912,10 +1904,8 @@ public: try { Gui::Command::openCommand("Add sketch arc"); - FCMD_OBJ_CMD2("addGeometry(Part.ArcOfCircle" - "(Part.Circle(App.Vector(%f,%f,0),App.Vector(0,0,1),%f)," - "%f,%f),%s)", - sketchgui->getObject(), + Gui::cmdAppObjectArgs(sketchgui->getObject(), "addGeometry(Part.ArcOfCircle" + "(Part.Circle(App.Vector(%f,%f,0),App.Vector(0,0,1),%f),%f,%f),%s)", CenterPoint.x, CenterPoint.y, radius, startAngle, endAngle, geometryCreationMode==Construction?"True":"False"); @@ -2223,9 +2213,8 @@ public: try { Gui::Command::openCommand("Add sketch circle"); - FCMD_OBJ_CMD2("addGeometry(Part.Circle" + Gui::cmdAppObjectArgs(sketchgui->getObject(), "addGeometry(Part.Circle" "(App.Vector(%f,%f,0),App.Vector(0,0,1),%f),%s)", - sketchgui->getObject(), EditCurve[0].x, EditCurve[0].y, sqrt(rx*rx + ry*ry), geometryCreationMode==Construction?"True":"False"); @@ -3024,9 +3013,8 @@ private: try { Gui::Command::openCommand("Add sketch ellipse"); - FCMD_OBJ_CMD2("addGeometry(Part.Ellipse" + Gui::cmdAppObjectArgs(sketchgui->getObject(), "addGeometry(Part.Ellipse" "(App.Vector(%f,%f,0),App.Vector(%f,%f,0),App.Vector(%f,%f,0)),%s)", - sketchgui->getObject(), periapsis.x, periapsis.y, positiveB.x, positiveB.y, centroid.x, centroid.y, @@ -3034,9 +3022,7 @@ private: currentgeoid++; - FCMD_OBJ_CMD2("exposeInternalGeometry(%d)", - sketchgui->getObject(), - currentgeoid); + Gui::cmdAppObjectArgs(sketchgui->getObject(), "exposeInternalGeometry(%d)", currentgeoid); } catch (const Base::Exception& e) { Base::Console().Error("%s\n", e.what()); @@ -3437,10 +3423,8 @@ public: try { Gui::Command::openCommand("Add sketch arc of ellipse"); - FCMD_OBJ_CMD2("addGeometry(Part.ArcOfEllipse" - "(Part.Ellipse(App.Vector(%f,%f,0),App.Vector(%f,%f,0),App.Vector(%f,%f,0))," - "%f,%f),%s)", - sketchgui->getObject(), + Gui::cmdAppObjectArgs(sketchgui->getObject(), "addGeometry(Part.ArcOfEllipse" + "(Part.Ellipse(App.Vector(%f,%f,0),App.Vector(%f,%f,0),App.Vector(%f,%f,0)),%f,%f),%s)", majAxisPoint.x, majAxisPoint.y, minAxisPoint.x, minAxisPoint.y, centerPoint.x, centerPoint.y, @@ -3449,9 +3433,7 @@ public: currentgeoid++; - FCMD_OBJ_CMD2("exposeInternalGeometry(%d)", - sketchgui->getObject(), - currentgeoid); + Gui::cmdAppObjectArgs(sketchgui->getObject(), "exposeInternalGeometry(%d)", currentgeoid); } catch (const Base::Exception& e) { Base::Console().Error("%s\n", e.what()); @@ -3817,27 +3799,22 @@ public: try { - Gui::Command::openCommand("Add sketch arc of hyperbola"); + Gui::Command::openCommand("Add sketch arc of hyperbola"); - //Add arc of hyperbola, point and constrain point as focus2. We add focus2 for it to balance - //the intrinsic focus1, in order to balance out the intrinsic invisible focus1 when AOE is - //dragged by its center - FCMD_OBJ_CMD2("addGeometry(Part.ArcOfHyperbola" - "(Part.Hyperbola(App.Vector(%f,%f,0),App.Vector(%f,%f,0),App.Vector(%f,%f,0))," - "%f,%f),%s)", - sketchgui->getObject(), + //Add arc of hyperbola, point and constrain point as focus2. We add focus2 for it to balance + //the intrinsic focus1, in order to balance out the intrinsic invisible focus1 when AOE is + //dragged by its center + Gui::cmdAppObjectArgs(sketchgui->getObject(), "addGeometry(Part.ArcOfHyperbola" + "(Part.Hyperbola(App.Vector(%f,%f,0),App.Vector(%f,%f,0),App.Vector(%f,%f,0)),%f,%f),%s)", majAxisPoint.x, majAxisPoint.y, minAxisPoint.x, minAxisPoint.y, centerPoint.x, centerPoint.y, startAngle, endAngle, geometryCreationMode==Construction?"True":"False"); - currentgeoid++; - - FCMD_OBJ_CMD2("exposeInternalGeometry(%d)", - sketchgui->getObject(), - currentgeoid); + currentgeoid++; + Gui::cmdAppObjectArgs(sketchgui->getObject(), "exposeInternalGeometry(%d)", currentgeoid); } catch (const Base::Exception& e) { Base::Console().Error("%s\n", e.what()); @@ -4167,10 +4144,8 @@ public: Gui::Command::openCommand("Add sketch arc of Parabola"); //Add arc of parabola - FCMD_OBJ_CMD2("addGeometry(Part.ArcOfParabola" - "(Part.Parabola(App.Vector(%f,%f,0),App.Vector(%f,%f,0),App.Vector(0,0,1))," - "%f,%f),%s)", - sketchgui->getObject(), + Gui::cmdAppObjectArgs(sketchgui->getObject(), "addGeometry(Part.ArcOfParabola" + "(Part.Parabola(App.Vector(%f,%f,0),App.Vector(%f,%f,0),App.Vector(0,0,1)),%f,%f),%s)", focusPoint.x, focusPoint.y, axisPoint.x, axisPoint.y, startAngle, endAngle, @@ -4178,10 +4153,7 @@ public: currentgeoid++; - FCMD_OBJ_CMD2("exposeInternalGeometry(%d)", - sketchgui->getObject(), - currentgeoid); - + Gui::cmdAppObjectArgs(sketchgui->getObject(), "exposeInternalGeometry(%d)", currentgeoid); } catch (const Base::Exception& e) { Base::Console().Error("%s\n", e.what()); @@ -4535,9 +4507,8 @@ public: Gui::Command::openCommand("Add Pole circle"); //Add pole - FCMD_OBJ_CMD2("addGeometry(Part.Circle(App.Vector(%f,%f,0),App.Vector(0,0,1),10),True)", - sketchgui->getObject(), - EditCurve[0].x,EditCurve[0].y); + Gui::cmdAppObjectArgs(sketchgui->getObject(), "addGeometry(Part.Circle(App.Vector(%f,%f,0),App.Vector(0,0,1),10),True)", + EditCurve[0].x,EditCurve[0].y); } catch (const Base::Exception& e) { @@ -4618,18 +4589,16 @@ public: guess = normalize(guess); - FCMD_OBJ_CMD2("addGeometry(Part.Circle(App.Vector(%f,%f,0),App.Vector(0,0,1),10),True)", - sketchgui->getObject(), - EditCurve[EditCurve.size()-1].x,EditCurve[EditCurve.size()-1].y); + Gui::cmdAppObjectArgs(sketchgui->getObject(), "addGeometry(Part.Circle(App.Vector(%f,%f,0),App.Vector(0,0,1),10),True)", + EditCurve[EditCurve.size()-1].x,EditCurve[EditCurve.size()-1].y); if(EditCurve.size() == 2) { - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Radius',%d,%f)) ", - sketchgui->getObject(), FirstPoleGeoId, guess ); + Gui::cmdAppObjectArgs(sketchgui->getObject(), "addConstraint(Sketcher.Constraint('Radius',%d,%f)) ", + FirstPoleGeoId, guess ); } - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Equal',%d,%d)) ", - sketchgui->getObject(), FirstPoleGeoId, FirstPoleGeoId+ EditCurve.size()-1); - + Gui::cmdAppObjectArgs(sketchgui->getObject(), "addConstraint(Sketcher.Constraint('Equal',%d,%d)) ", + FirstPoleGeoId, FirstPoleGeoId+ EditCurve.size()-1); } catch (const Base::Exception& e) { Base::Console().Error("%s\n", e.what()); @@ -4690,19 +4659,16 @@ public: //Gui::Command::openCommand("Add B-spline curve"); - /*FCMD_OBJ_CMD2("addGeometry(Part.BSplineCurve" + /*Gui::cmdAppObjectArgs(sketchgui->getObject(), "addGeometry(Part.BSplineCurve" "(%s,%s)," "%s)", - sketchgui->getObject(), controlpoints.c_str(), ConstrMethod == 0 ?"False":"True", geometryCreationMode==Construction?"True":"False"); */ // {"poles", "mults", "knots", "periodic", "degree", "weights", "CheckRational", NULL}; - FCMD_OBJ_CMD2("addGeometry(Part.BSplineCurve" - "(%s,None,None,%s,3,None,False)," - "%s)", - sketchgui->getObject(), + Gui::cmdAppObjectArgs(sketchgui->getObject(), "addGeometry(Part.BSplineCurve" + "(%s,None,None,%s,3,None,False),%s)", controlpoints.c_str(), ConstrMethod == 0 ?"False":"True", geometryCreationMode==Construction?"True":"False"); @@ -4744,10 +4710,7 @@ public: Gui::Command::doCommand(Gui::Command::Doc, cstream.str().c_str()); // for showing the knots on creation - FCMD_OBJ_CMD2("exposeInternalGeometry(%d)", - sketchgui->getObject(), - currentgeoid); - + Gui::cmdAppObjectArgs(sketchgui->getObject(), "exposeInternalGeometry(%d)", currentgeoid); } catch (const Base::Exception& e) { Base::Console().Error("%s\n", e.what()); @@ -5198,9 +5161,8 @@ public: try { Gui::Command::openCommand("Add sketch circle"); - FCMD_OBJ_CMD2("addGeometry(Part.Circle" + Gui::cmdAppObjectArgs(sketchgui->getObject(), "addGeometry(Part.Circle" "(App.Vector(%f,%f,0),App.Vector(0,0,1),%f),%s)", - sketchgui->getObject(), CenterPoint.x, CenterPoint.y, radius, geometryCreationMode==Construction?"True":"False"); @@ -5466,8 +5428,7 @@ public: try { Gui::Command::openCommand("Add sketch point"); - FCMD_OBJ_CMD2("addGeometry(Part.Point(App.Vector(%f,%f,0)))", - sketchgui->getObject(), + Gui::cmdAppObjectArgs(sketchgui->getObject(), "addGeometry(Part.Point(App.Vector(%f,%f,0)))", EditPoint.x,EditPoint.y); Gui::Command::commitCommand(); @@ -5751,14 +5712,10 @@ public: // create fillet at point try { Gui::Command::openCommand("Create fillet"); - FCMD_OBJ_CMD2("fillet(%d,%d,%f)", - sketchgui->getObject(), - GeoId, PosId, radius); + Gui::cmdAppObjectArgs(sketchgui->getObject(), "fillet(%d,%d,%f)", GeoId, PosId, radius); - if(construction) { - FCMD_OBJ_CMD2("toggleConstruction(%d) ", - sketchgui->getObject(), - currentgeoid+1); + if (construction) { + Gui::cmdAppObjectArgs(sketchgui->getObject(), "toggleConstruction(%d) ", currentgeoid+1); } Gui::Command::commitCommand(); @@ -5831,8 +5788,7 @@ public: // create fillet between lines try { Gui::Command::openCommand("Create fillet"); - FCMD_OBJ_CMD2("fillet(%d,%d,App.Vector(%f,%f,0),App.Vector(%f,%f,0),%f)", - sketchgui->getObject(), + Gui::cmdAppObjectArgs(sketchgui->getObject(), "fillet(%d,%d,App.Vector(%f,%f,0),App.Vector(%f,%f,0),%f)", firstCurve, secondCurve, firstPos.x, firstPos.y, secondPos.x, secondPos.y, radius); @@ -5858,8 +5814,7 @@ public: tryAutoRecompute(static_cast(sketchgui->getObject())); if(construction) { - FCMD_OBJ_CMD2("toggleConstruction(%d) ", - sketchgui->getObject(), + Gui::cmdAppObjectArgs(sketchgui->getObject(), "toggleConstruction(%d) ", currentgeoid+1); } @@ -6026,8 +5981,7 @@ public: geom->getTypeId() == Part::GeomEllipse::getClassTypeId()) { try { Gui::Command::openCommand("Trim edge"); - FCMD_OBJ_CMD2("trim(%d,App.Vector(%f,%f,0))", - sketchgui->getObject(), + Gui::cmdAppObjectArgs(sketchgui->getObject(), "trim(%d,App.Vector(%f,%f,0))", GeoId, onSketchPos.x, onSketchPos.y); Gui::Command::commitCommand(); tryAutoRecompute(static_cast(sketchgui->getObject())); @@ -6338,9 +6292,8 @@ public: } else if (Mode == STATUS_SEEK_Second) { try { Gui::Command::openCommand("Extend edge"); - FCMD_OBJ_CMD2("extend(%d, %f, %d)\n", // GeoId, increment, PointPos - sketchgui->getObject(), BaseGeoId, Increment, - ExtendFromStart ? Sketcher::start : Sketcher::end); + Gui::cmdAppObjectArgs(sketchgui->getObject(), "extend(%d, %f, %d)\n", // GeoId, increment, PointPos + BaseGeoId, Increment, ExtendFromStart ? Sketcher::start : Sketcher::end); Gui::Command::commitCommand(); ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/Mod/Sketcher"); @@ -6596,8 +6549,7 @@ public: (subName.size() > 4 && subName.substr(0,4) == "Face")) { try { Gui::Command::openCommand("Add external geometry"); - FCMD_OBJ_CMD2("addExternal(\"%s\",\"%s\")", - sketchgui->getObject(), + Gui::cmdAppObjectArgs(sketchgui->getObject(), "addExternal(\"%s\",\"%s\")", msg.pObjectName, msg.pSubName); Gui::Command::commitCommand(); @@ -6818,9 +6770,8 @@ static const char *cursor_carboncopy[]={ try { Gui::Command::openCommand("Add carbon copy"); - FCMD_OBJ_CMD2("carbonCopy(\"%s\",%s)", - sketchgui->getObject(), - msg.pObjectName, geometryCreationMode==Construction?"True":"False"); + Gui::cmdAppObjectArgs(sketchgui->getObject(), "carbonCopy(\"%s\",%s)", + msg.pObjectName, geometryCreationMode==Construction?"True":"False"); Gui::Command::commitCommand(); diff --git a/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp b/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp index 7b0064a074..03aae5cfd5 100644 --- a/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp +++ b/src/Mod/Sketcher/Gui/CommandSketcherBSpline.cpp @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include #include @@ -380,19 +380,13 @@ void CmdSketcherConvertToNURB::activated(int iMsg) if (SubNames[i].size() > 4 && SubNames[i].substr(0,4) == "Edge") { int GeoId = std::atoi(SubNames[i].substr(4,4000).c_str()) - 1; - - FCMD_OBJ_CMD2("convertToNURBS(%d) ", - selection[0].getObject(),GeoId); - + Gui::cmdAppObjectArgs(selection[0].getObject(), "convertToNURBS(%d) ", GeoId); nurbsized = true; } else if (SubNames[i].size() > 12 && SubNames[i].substr(0,12) == "ExternalEdge") { int GeoId = - (std::atoi(SubNames[i].substr(12,4000).c_str()) + 2); - - FCMD_OBJ_CMD2("convertToNURBS(%d) ", - selection[0].getObject(),GeoId); - + Gui::cmdAppObjectArgs(selection[0].getObject(), "convertToNURBS(%d) ", GeoId); nurbsized = true; } @@ -463,13 +457,10 @@ void CmdSketcherIncreaseDegree::activated(int iMsg) const Part::Geometry * geo = Obj->getGeometry(GeoId); if (geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { - FCMD_OBJ_CMD2("increaseBSplineDegree(%d) ", - selection[0].getObject(),GeoId); + Gui::cmdAppObjectArgs(selection[0].getObject(), "increaseBSplineDegree(%d) ", GeoId); // add new control points - FCMD_OBJ_CMD2("exposeInternalGeometry(%d)", - selection[0].getObject(), - GeoId); + Gui::cmdAppObjectArgs(selection[0].getObject(), "exposeInternalGeometry(%d)", GeoId); } else { ignored=true; @@ -564,8 +555,8 @@ void CmdSketcherIncreaseKnotMultiplicity::activated(int iMsg) notaknot = false; try { - FCMD_OBJ_CMD2("modifyBSplineKnotMultiplicity(%d,%d,%d) ", - selection[0].getObject(),(*it)->Second, (*it)->InternalAlignmentIndex + 1, 1); + Gui::cmdAppObjectArgs(selection[0].getObject(), "modifyBSplineKnotMultiplicity(%d,%d,%d) ", + (*it)->Second, (*it)->InternalAlignmentIndex + 1, 1); applied = true; @@ -623,9 +614,7 @@ void CmdSketcherIncreaseKnotMultiplicity::activated(int iMsg) if(ngfound) { try { // add internalalignment for new pole - FCMD_OBJ_CMD2("exposeInternalGeometry(%d)", - selection[0].getObject(), - ngeoid); + Gui::cmdAppObjectArgs(selection[0].getObject(), "exposeInternalGeometry(%d)", ngeoid); } catch (const Base::Exception& e) { Base::Console().Error("%s\n", e.what()); @@ -723,8 +712,8 @@ void CmdSketcherDecreaseKnotMultiplicity::activated(int iMsg) notaknot = false; try { - FCMD_OBJ_CMD2("modifyBSplineKnotMultiplicity(%d,%d,%d) ", - selection[0].getObject(),(*it)->Second, (*it)->InternalAlignmentIndex + 1, -1); + Gui::cmdAppObjectArgs(selection[0].getObject(), "modifyBSplineKnotMultiplicity(%d,%d,%d) ", + (*it)->Second, (*it)->InternalAlignmentIndex + 1, -1); applied = true; @@ -769,15 +758,12 @@ void CmdSketcherDecreaseKnotMultiplicity::activated(int iMsg) if(ngfound) { try { // add internalalignment for new pole - FCMD_OBJ_CMD2("exposeInternalGeometry(%d)", - selection[0].getObject(), - ngeoid); + Gui::cmdAppObjectArgs(selection[0].getObject(), "exposeInternalGeometry(%d)", ngeoid); } catch (const Base::Exception& e) { Base::Console().Error("%s\n", e.what()); getSelection().clearSelection(); } - } } diff --git a/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp b/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp index eefe8fcd03..230460994d 100644 --- a/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp +++ b/src/Mod/Sketcher/Gui/CommandSketcherTools.cpp @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include #include @@ -169,14 +169,14 @@ void CmdSketcherCloseShape::activated(int iMsg) return; } - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Coincident',%d,%d,%d,%d)) ", - selection[0].getObject(),GeoId1,Sketcher::end,GeoId2,Sketcher::start); + Gui::cmdAppObjectArgs(selection[0].getObject(), "addConstraint(Sketcher.Constraint('Coincident',%d,%d,%d,%d)) ", + GeoId1,Sketcher::end,GeoId2,Sketcher::start); } } // Close Last Edge with First Edge - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Coincident',%d,%d,%d,%d)) ", - selection[0].getObject(),GeoIdLast,Sketcher::end,GeoIdFirst,Sketcher::start); + Gui::cmdAppObjectArgs(selection[0].getObject(),"addConstraint(Sketcher.Constraint('Coincident',%d,%d,%d,%d)) ", + GeoIdLast,Sketcher::end,GeoIdFirst,Sketcher::start); // finish the transaction and update commitCommand(); @@ -257,8 +257,8 @@ void CmdSketcherConnect::activated(int iMsg) return; } - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Coincident',%d,%d,%d,%d)) ", - selection[0].getObject(),GeoId1,Sketcher::end,GeoId2,Sketcher::start); + Gui::cmdAppObjectArgs(selection[0].getObject(),"addConstraint(Sketcher.Constraint('Coincident',%d,%d,%d,%d)) ", + GeoId1,Sketcher::end,GeoId2,Sketcher::start); } } @@ -872,12 +872,12 @@ void CmdSketcherRestoreInternalAlignmentGeometry::activated(int iMsg) try { Gui::Command::openCommand("Exposing Internal Geometry"); - FCMD_OBJ_CMD2("exposeInternalGeometry(%d)", Obj, GeoId); + Gui::cmdAppObjectArgs(Obj, "exposeInternalGeometry(%d)", GeoId); int aftergeoid = Obj->getHighestCurveIndex(); if(aftergeoid == currentgeoid) { // if we did not expose anything, deleteunused - FCMD_OBJ_CMD2("deleteUnusedInternalGeometry(%d)", Obj, GeoId); + Gui::cmdAppObjectArgs(Obj, "deleteUnusedInternalGeometry(%d)", GeoId); } } catch (const Base::Exception& e) { @@ -1076,7 +1076,7 @@ void CmdSketcherSymmetry::activated(int iMsg) Gui::Command::openCommand("Create Symmetric geometry"); try{ - FCMD_OBJ_CMD2("addSymmetric(%s,%d,%d)", Obj, geoIdList.c_str(), LastGeoId, LastPointPos); + Gui::cmdAppObjectArgs(Obj, "addSymmetric(%s,%d,%d)", geoIdList.c_str(), LastGeoId, LastPointPos); Gui::Command::commitCommand(); } @@ -1220,14 +1220,12 @@ static const char *cursor_createcopy[]={ try{ if( Op != SketcherCopy::Move) { - FCMD_OBJ_CMD2("addCopy(%s,App.Vector(%f,%f,0),%s)", - sketchgui->getObject(), + Gui::cmdAppObjectArgs(sketchgui->getObject(), "addCopy(%s,App.Vector(%f,%f,0),%s)", geoIdList.c_str(), vector.x, vector.y, (Op == SketcherCopy::Clone?"True":"False")); } else { - FCMD_OBJ_CMD2("addMove(%s,App.Vector(%f,%f,0))", - sketchgui->getObject(), + Gui::cmdAppObjectArgs(sketchgui->getObject(), "addMove(%s,App.Vector(%f,%f,0))", geoIdList.c_str(), vector.x, vector.y); } @@ -1743,13 +1741,12 @@ static const char *cursor_createrectangulararray[]={ Gui::Command::openCommand("Create copy of geometry"); try { - FCMD_OBJ_CMD2("addRectangularArray(%s, App.Vector(%f,%f,0),%s,%d,%d,%s,%f)", - sketchgui->getObject(), - geoIdList.c_str(), vector.x, vector.y, - (Clone?"True":"False"), - Cols, Rows, - (ConstraintSeparation?"True":"False"), - (EqualVerticalHorizontalSpacing?1.0:0.5)); + Gui::cmdAppObjectArgs(sketchgui->getObject(), "addRectangularArray(%s, App.Vector(%f,%f,0),%s,%d,%d,%s,%f)", + geoIdList.c_str(), vector.x, vector.y, + (Clone?"True":"False"), + Cols, Rows, + (ConstraintSeparation?"True":"False"), + (EqualVerticalHorizontalSpacing?1.0:0.5)); Gui::Command::commitCommand(); } @@ -1965,7 +1962,7 @@ void CmdSketcherDeleteAllGeometry::activated(int iMsg) try { Gui::Command::openCommand("Delete All Geometry"); - FCMD_OBJ_CMD2("deleteAllGeometry()", Obj); + Gui::cmdAppObjectArgs(Obj, "deleteAllGeometry()"); Gui::Command::commitCommand(); } @@ -2028,7 +2025,7 @@ void CmdSketcherDeleteAllConstraints::activated(int iMsg) try { Gui::Command::openCommand("Delete All Constraints"); - FCMD_OBJ_CMD2("deleteAllConstraints()", Obj); + Gui::cmdAppObjectArgs(Obj, "deleteAllConstraints()"); Gui::Command::commitCommand(); } diff --git a/src/Mod/Sketcher/Gui/CommandSketcherVirtualSpace.cpp b/src/Mod/Sketcher/Gui/CommandSketcherVirtualSpace.cpp index 08642e2c1a..c6c8d73cc8 100644 --- a/src/Mod/Sketcher/Gui/CommandSketcherVirtualSpace.cpp +++ b/src/Mod/Sketcher/Gui/CommandSketcherVirtualSpace.cpp @@ -36,7 +36,7 @@ #include #include #include -#include +#include #include #include @@ -169,7 +169,7 @@ void CmdSketcherSwitchVirtualSpace::activated(int iMsg) int ConstrId = Sketcher::PropertyConstraintList::getIndexFromConstraintName(*it); Gui::Command::openCommand("Update constraint's virtual space"); try { - FCMD_OBJ_CMD2("toggleVirtualSpace(%d)", Obj, ConstrId); + Gui::cmdAppObjectArgs(Obj, "toggleVirtualSpace(%d)", ConstrId); } catch(const Base::Exception&) { successful--; diff --git a/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp b/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp index 1bafb31800..fe9a6fe712 100644 --- a/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp +++ b/src/Mod/Sketcher/Gui/DrawSketchHandler.cpp @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #include #include @@ -407,10 +407,8 @@ void DrawSketchHandler::createAutoConstraints(const std::vector if (posId1 == Sketcher::none) continue; // If the auto constraint has a point create a coincident otherwise it is an edge on a point - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Coincident',%i,%i,%i,%i)) " - ,sketchgui->getObject() - ,geoId1, posId1, it->GeoId, it->PosId - ); + Gui::cmdAppObjectArgs(sketchgui->getObject(), "addConstraint(Sketcher.Constraint('Coincident',%i,%i,%i,%i)) " + , geoId1, posId1, it->GeoId, it->PosId); } break; case Sketcher::PointOnObject: { int geoId2 = it->GeoId; @@ -421,26 +419,14 @@ void DrawSketchHandler::createAutoConstraints(const std::vector std::swap(posId1,posId2); } - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('PointOnObject',%i,%i,%i)) " - ,sketchgui->getObject() - ,geoId1, posId1, geoId2 - ); + Gui::cmdAppObjectArgs(sketchgui->getObject(), "addConstraint(Sketcher.Constraint('PointOnObject',%i,%i,%i)) " + , geoId1, posId1, geoId2); } break; case Sketcher::Horizontal: { - - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Horizontal',%i)) " - ,sketchgui->getObject() - ,geoId1 - ); - + Gui::cmdAppObjectArgs(sketchgui->getObject(), "addConstraint(Sketcher.Constraint('Horizontal',%i)) ", geoId1); } break; case Sketcher::Vertical: { - - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Vertical',%i)) " - ,sketchgui->getObject() - ,geoId1 - ); - + Gui::cmdAppObjectArgs(sketchgui->getObject(), "addConstraint(Sketcher.Constraint('Vertical',%i)) ", geoId1); } break; case Sketcher::Tangent: { Sketcher::SketchObject* Obj = static_cast(sketchgui->getObject()); @@ -496,10 +482,8 @@ void DrawSketchHandler::createAutoConstraints(const std::vector } } - FCMD_OBJ_CMD2("addConstraint(Sketcher.Constraint('Tangent',%i, %i)) " - ,sketchgui->getObject() - ,geoId1, it->GeoId - ); + Gui::cmdAppObjectArgs(sketchgui->getObject(), "addConstraint(Sketcher.Constraint('Tangent',%i, %i)) " + , geoId1, it->GeoId); } break; default: break; diff --git a/src/Mod/Sketcher/Gui/EditDatumDialog.cpp b/src/Mod/Sketcher/Gui/EditDatumDialog.cpp index 6bdfef5d4a..a4f4b4a25a 100644 --- a/src/Mod/Sketcher/Gui/EditDatumDialog.cpp +++ b/src/Mod/Sketcher/Gui/EditDatumDialog.cpp @@ -32,7 +32,7 @@ #include #include -#include +#include #include #include #include @@ -153,17 +153,15 @@ void EditDatumDialog::exec(bool atCursor) if (ui_ins_datum.labelEdit->hasExpression()) ui_ins_datum.labelEdit->apply(); else - FCMD_OBJ_CMD2("setDatum(%i,App.Units.Quantity('%f %s'))", - sketch, - ConstrNbr, newDatum, (const char*)newQuant.getUnit().getString().toUtf8()); + Gui::cmdAppObjectArgs(sketch, "setDatum(%i,App.Units.Quantity('%f %s'))", + ConstrNbr, newDatum, (const char*)newQuant.getUnit().getString().toUtf8()); } QString constraintName = ui_ins_datum.name->text().trimmed(); if (Base::Tools::toStdString(constraintName) != sketch->Constraints[ConstrNbr]->Name) { std::string escapedstr = Base::Tools::escapedUnicodeFromUtf8(constraintName.toUtf8().constData()); - FCMD_OBJ_CMD2("renameConstraint(%d, u'%s')", - sketch, - ConstrNbr, escapedstr.c_str()); + Gui::cmdAppObjectArgs(sketch, "renameConstraint(%d, u'%s')", + ConstrNbr, escapedstr.c_str()); } Gui::Command::commitCommand(); diff --git a/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp b/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp index b0464b89ce..4e2a6ca62c 100644 --- a/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp +++ b/src/Mod/Sketcher/Gui/TaskSketcherConstrains.cpp @@ -51,7 +51,7 @@ #include #include #include -#include +#include #include #include @@ -603,15 +603,12 @@ void ConstraintView::swapNamedOfSelectedItems() std::string tmpname = ss.str(); Gui::Command::openCommand("Swap constraint names"); - FCMD_OBJ_CMD2("renameConstraint(%d, u'%s')", - item1->sketch, - item1->ConstraintNbr, tmpname.c_str()); - FCMD_OBJ_CMD2("renameConstraint(%d, u'%s')", - item2->sketch, - item2->ConstraintNbr, escapedstr1.c_str()); - FCMD_OBJ_CMD2("renameConstraint(%d, u'%s')", - item1->sketch, - item1->ConstraintNbr, escapedstr2.c_str()); + Gui::cmdAppObjectArgs(item1->sketch, "renameConstraint(%d, u'%s')", + item1->ConstraintNbr, tmpname.c_str()); + Gui::cmdAppObjectArgs(item2->sketch, "renameConstraint(%d, u'%s')", + item2->ConstraintNbr, escapedstr1.c_str()); + Gui::cmdAppObjectArgs(item1->sketch, "renameConstraint(%d, u'%s')", + item1->ConstraintNbr, escapedstr2.c_str()); Gui::Command::commitCommand(); } @@ -775,7 +772,6 @@ void TaskSketcherConstrains::on_listWidgetConstraints_itemActivated(QListWidgetI // if its the right constraint if (it->isDimensional()) { - EditDatumDialog *editDatumDialog = new EditDatumDialog(this->sketchView, it->ConstraintNbr); editDatumDialog->exec(false); delete editDatumDialog; @@ -831,9 +827,8 @@ void TaskSketcherConstrains::on_listWidgetConstraints_itemChanged(QListWidgetIte Gui::Command::openCommand("Rename sketch constraint"); try { - FCMD_OBJ_CMD2("renameConstraint(%d, u'%s')", - sketch, - it->ConstraintNbr, escapedstr.c_str()); + Gui::cmdAppObjectArgs(sketch ,"renameConstraint(%d, u'%s')", + it->ConstraintNbr, escapedstr.c_str()); Gui::Command::commitCommand(); } catch (const Base::Exception & e) { @@ -847,10 +842,9 @@ void TaskSketcherConstrains::on_listWidgetConstraints_itemChanged(QListWidgetIte // update constraint virtual space status Gui::Command::openCommand("Update constraint's virtual space"); try { - FCMD_OBJ_CMD2("setVirtualSpace(%d, %s)", - sketch, - it->ConstraintNbr, - ((item->checkState() == Qt::Checked) != sketchView->getIsShownVirtualSpace())?"False":"True"); + Gui::cmdAppObjectArgs(sketch, "setVirtualSpace(%d, %s)", + it->ConstraintNbr, + ((item->checkState() == Qt::Checked) != sketchView->getIsShownVirtualSpace())?"False":"True"); Gui::Command::commitCommand(); } catch (const Base::Exception & e) { diff --git a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp index 74eca628de..22e79961d2 100644 --- a/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp +++ b/src/Mod/Sketcher/Gui/ViewProviderSketch.cpp @@ -91,7 +91,7 @@ #include #include #include -#include +#include #include #include #include @@ -789,8 +789,7 @@ bool ViewProviderSketch::mouseButtonPressed(int Button, bool pressed, const SbVe if (GeoId != Sketcher::Constraint::GeoUndef && PosId != Sketcher::none) { getDocument()->openCommand("Drag Point"); try { - FCMD_OBJ_CMD2("movePoint(%i,%i,App.Vector(%f,%f,0),%i)" - ,getObject() + Gui::cmdAppObjectArgs(getObject(), "movePoint(%i,%i,App.Vector(%f,%f,0),%i)" ,GeoId, PosId, x-xInit, y-yInit, 0); getDocument()->commitCommand(); @@ -821,8 +820,7 @@ bool ViewProviderSketch::mouseButtonPressed(int Button, bool pressed, const SbVe geo->getTypeId() == Part::GeomBSplineCurve::getClassTypeId()) { getDocument()->openCommand("Drag Curve"); try { - FCMD_OBJ_CMD2("movePoint(%i,%i,App.Vector(%f,%f,0),%i)" - ,getObject() + Gui::cmdAppObjectArgs(getObject(), "movePoint(%i,%i,App.Vector(%f,%f,0),%i)" ,edit->DragCurve, Sketcher::none, x-xInit, y-yInit, relative ? 1 : 0); getDocument()->commitCommand(); @@ -1019,7 +1017,7 @@ void ViewProviderSketch::editDoubleClicked(void) if (Constr->isDimensional()) { if(!Constr->isDriving) { - FCMD_OBJ_CMD2("setDriving(%i,%s)", getObject(),id,"True"); + Gui::cmdAppObjectArgs(getObject(), "setDriving(%i,%s)", id, "True"); } // Coin's SoIdleSensor causes problems on some platform while Qt seems to work properly (#0001517) @@ -6431,7 +6429,7 @@ bool ViewProviderSketch::onDelete(const std::vector &subList) for (rit = delConstraints.rbegin(); rit != delConstraints.rend(); ++rit) { try { - FCMD_OBJ_CMD2("delConstraint(%i)" ,getObject(), *rit); + Gui::cmdAppObjectArgs(getObject(), "delConstraint(%i)", *rit); } catch (const Base::Exception& e) { Base::Console().Error("%s\n", e.what()); @@ -6454,7 +6452,7 @@ bool ViewProviderSketch::onDelete(const std::vector &subList) if (((*it)->Type == Sketcher::Coincident) && (((*it)->First == GeoId && (*it)->FirstPos == PosId) || ((*it)->Second == GeoId && (*it)->SecondPos == PosId)) ) { try { - FCMD_OBJ_CMD2("delConstraintOnPoint(%i,%i)" ,getObject(), GeoId, (int)PosId); + Gui::cmdAppObjectArgs(getObject(), "delConstraintOnPoint(%i,%i)", GeoId, (int)PosId); } catch (const Base::Exception& e) { Base::Console().Error("%s\n", e.what()); @@ -6467,7 +6465,7 @@ bool ViewProviderSketch::onDelete(const std::vector &subList) for (rit = delInternalGeometries.rbegin(); rit != delInternalGeometries.rend(); ++rit) { try { - FCMD_OBJ_CMD2("delGeometry(%i)" ,getObject(), *rit); + Gui::cmdAppObjectArgs(getObject(), "delGeometry(%i)", *rit); } catch (const Base::Exception& e) { Base::Console().Error("%s\n", e.what()); @@ -6476,7 +6474,7 @@ bool ViewProviderSketch::onDelete(const std::vector &subList) for (rit = delExternalGeometries.rbegin(); rit != delExternalGeometries.rend(); ++rit) { try { - FCMD_OBJ_CMD2("delExternal(%i)",getObject(), *rit); + Gui::cmdAppObjectArgs(getObject(), "delExternal(%i)", *rit); } catch (const Base::Exception& e) { Base::Console().Error("%s\n", e.what());