do not use doCommand without using format string, add overloaded method of runCommand
This commit is contained in:
@@ -1016,7 +1016,7 @@ void CmdPartMakeSolid::activated(int iMsg)
|
||||
{
|
||||
std::vector<App::DocumentObject*> objs = Gui::Selection().getObjectsOfType
|
||||
(Part::Feature::getClassTypeId());
|
||||
doCommand(Doc, "import Part");
|
||||
runCommand(Doc, "import Part");
|
||||
for (std::vector<App::DocumentObject*>::iterator it = objs.begin(); it != objs.end(); ++it) {
|
||||
const TopoDS_Shape& shape = static_cast<Part::Feature*>(*it)->Shape.getValue();
|
||||
if (!shape.IsNull()) {
|
||||
@@ -1057,7 +1057,7 @@ void CmdPartMakeSolid::activated(int iMsg)
|
||||
|
||||
try {
|
||||
if (!str.isEmpty())
|
||||
doCommand(Doc, (const char*)str.toLatin1());
|
||||
runCommand(Doc, str.toLatin1());
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
Base::Console().Error("Cannot convert %s because %s.\n",
|
||||
@@ -1094,7 +1094,7 @@ void CmdPartReverseShape::activated(int iMsg)
|
||||
{
|
||||
std::vector<App::DocumentObject*> objs = Gui::Selection().getObjectsOfType
|
||||
(Part::Feature::getClassTypeId());
|
||||
doCommand(Doc, "import Part");
|
||||
runCommand(Doc, "import Part");
|
||||
for (std::vector<App::DocumentObject*>::iterator it = objs.begin(); it != objs.end(); ++it) {
|
||||
const TopoDS_Shape& shape = static_cast<Part::Feature*>(*it)->Shape.getValue();
|
||||
if (!shape.IsNull()) {
|
||||
@@ -1111,7 +1111,7 @@ void CmdPartReverseShape::activated(int iMsg)
|
||||
|
||||
try {
|
||||
if (!str.isEmpty())
|
||||
doCommand(Doc, (const char*)str.toLatin1());
|
||||
runCommand(Doc, str.toLatin1());
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
Base::Console().Error("Cannot convert %s because %s.\n",
|
||||
@@ -1217,7 +1217,7 @@ void CmdPartMakeFace::activated(int iMsg)
|
||||
|
||||
str << ")";
|
||||
|
||||
doCommand(Doc,str.str().c_str());
|
||||
runCommand(Doc,str.str().c_str());
|
||||
commitCommand();
|
||||
updateActive();
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
# include <QApplication>
|
||||
# include <QDir>
|
||||
# include <QFileInfo>
|
||||
# include <QLineEdit>
|
||||
# include <QLineEdit>
|
||||
#endif
|
||||
|
||||
#include <Gui/Application.h>
|
||||
@@ -57,13 +57,13 @@ void CmdPartCylinder::activated(int iMsg)
|
||||
cmd = qApp->translate("CmdPartCylinder","Cylinder");
|
||||
openCommand((const char*)cmd.toUtf8());
|
||||
|
||||
doCommand(Doc,"App.ActiveDocument.addObject(\"Part::Cylinder\",\"Cylinder\")");
|
||||
runCommand(Doc,"App.ActiveDocument.addObject(\"Part::Cylinder\",\"Cylinder\")");
|
||||
cmd = QString::fromLatin1("App.ActiveDocument.ActiveObject.Label = \"%1\"")
|
||||
.arg(qApp->translate("CmdPartCylinder","Cylinder"));
|
||||
doCommand(Doc,(const char*)cmd.toUtf8());
|
||||
runCommand(Doc,cmd.toUtf8());
|
||||
commitCommand();
|
||||
updateActive();
|
||||
doCommand(Gui, "Gui.SendMsgToActiveView(\"ViewFit\")");
|
||||
runCommand(Gui, "Gui.SendMsgToActiveView(\"ViewFit\")");
|
||||
}
|
||||
|
||||
bool CmdPartCylinder::isActive(void)
|
||||
@@ -97,13 +97,13 @@ void CmdPartBox::activated(int iMsg)
|
||||
cmd = qApp->translate("CmdPartBox","Cube");
|
||||
openCommand((const char*)cmd.toUtf8());
|
||||
|
||||
doCommand(Doc,"App.ActiveDocument.addObject(\"Part::Box\",\"Box\")");
|
||||
runCommand(Doc,"App.ActiveDocument.addObject(\"Part::Box\",\"Box\")");
|
||||
cmd = QString::fromLatin1("App.ActiveDocument.ActiveObject.Label = \"%1\"")
|
||||
.arg(qApp->translate("CmdPartBox","Cube"));
|
||||
doCommand(Doc,(const char*)cmd.toUtf8());
|
||||
runCommand(Doc,cmd.toUtf8());
|
||||
commitCommand();
|
||||
updateActive();
|
||||
doCommand(Gui, "Gui.SendMsgToActiveView(\"ViewFit\")");
|
||||
runCommand(Gui, "Gui.SendMsgToActiveView(\"ViewFit\")");
|
||||
}
|
||||
|
||||
bool CmdPartBox::isActive(void)
|
||||
@@ -137,13 +137,13 @@ void CmdPartSphere::activated(int iMsg)
|
||||
cmd = qApp->translate("CmdPartSphere","Sphere");
|
||||
openCommand((const char*)cmd.toUtf8());
|
||||
|
||||
doCommand(Doc,"App.ActiveDocument.addObject(\"Part::Sphere\",\"Sphere\")");
|
||||
runCommand(Doc,"App.ActiveDocument.addObject(\"Part::Sphere\",\"Sphere\")");
|
||||
cmd = QString::fromLatin1("App.ActiveDocument.ActiveObject.Label = \"%1\"")
|
||||
.arg(qApp->translate("CmdPartSphere","Sphere"));
|
||||
doCommand(Doc,(const char*)cmd.toUtf8());
|
||||
runCommand(Doc,cmd.toUtf8());
|
||||
commitCommand();
|
||||
updateActive();
|
||||
doCommand(Gui, "Gui.SendMsgToActiveView(\"ViewFit\")");
|
||||
runCommand(Gui, "Gui.SendMsgToActiveView(\"ViewFit\")");
|
||||
}
|
||||
|
||||
bool CmdPartSphere::isActive(void)
|
||||
@@ -177,13 +177,13 @@ void CmdPartCone::activated(int iMsg)
|
||||
cmd = qApp->translate("CmdPartCone","Cone");
|
||||
openCommand((const char*)cmd.toUtf8());
|
||||
|
||||
doCommand(Doc,"App.ActiveDocument.addObject(\"Part::Cone\",\"Cone\")");
|
||||
runCommand(Doc,"App.ActiveDocument.addObject(\"Part::Cone\",\"Cone\")");
|
||||
cmd = QString::fromLatin1("App.ActiveDocument.ActiveObject.Label = \"%1\"")
|
||||
.arg(qApp->translate("CmdPartCone","Cone"));
|
||||
doCommand(Doc,(const char*)cmd.toUtf8());
|
||||
runCommand(Doc,cmd.toUtf8());
|
||||
commitCommand();
|
||||
updateActive();
|
||||
doCommand(Gui, "Gui.SendMsgToActiveView(\"ViewFit\")");
|
||||
runCommand(Gui, "Gui.SendMsgToActiveView(\"ViewFit\")");
|
||||
}
|
||||
|
||||
bool CmdPartCone::isActive(void)
|
||||
@@ -217,13 +217,13 @@ void CmdPartTorus::activated(int iMsg)
|
||||
cmd = qApp->translate("CmdPartTorus","Torus");
|
||||
openCommand((const char*)cmd.toUtf8());
|
||||
|
||||
doCommand(Doc,"App.ActiveDocument.addObject(\"Part::Torus\",\"Torus\")");
|
||||
runCommand(Doc,"App.ActiveDocument.addObject(\"Part::Torus\",\"Torus\")");
|
||||
cmd = QString::fromLatin1("App.ActiveDocument.ActiveObject.Label = \"%1\"")
|
||||
.arg(qApp->translate("CmdPartTorus","Torus"));
|
||||
doCommand(Doc,(const char*)cmd.toUtf8());
|
||||
runCommand(Doc,cmd.toUtf8());
|
||||
commitCommand();
|
||||
updateActive();
|
||||
doCommand(Gui, "Gui.SendMsgToActiveView(\"ViewFit\")");
|
||||
runCommand(Gui, "Gui.SendMsgToActiveView(\"ViewFit\")");
|
||||
}
|
||||
|
||||
bool CmdPartTorus::isActive(void)
|
||||
|
||||
@@ -100,10 +100,10 @@ void Picker::createPrimitive(QWidget* widget, const QString& descr, Gui::Documen
|
||||
|
||||
// Execute the Python block
|
||||
doc->openCommand(descr.toUtf8());
|
||||
Gui::Command::doCommand(Gui::Command::Doc, (const char*)cmd.toLatin1());
|
||||
Gui::Command::runCommand(Gui::Command::Doc, cmd.toLatin1());
|
||||
doc->commitCommand();
|
||||
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.recompute()");
|
||||
Gui::Command::doCommand(Gui::Command::Gui, "Gui.SendMsgToActiveView(\"ViewFit\")");
|
||||
Gui::Command::runCommand(Gui::Command::Doc, "App.ActiveDocument.recompute()");
|
||||
Gui::Command::runCommand(Gui::Command::Gui, "Gui.SendMsgToActiveView(\"ViewFit\")");
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
QMessageBox::warning(widget, descr, QString::fromLatin1(e.what()));
|
||||
@@ -666,10 +666,10 @@ void DlgPrimitives::createPrimitive(const QString& placement)
|
||||
// Execute the Python block
|
||||
QString prim = tr("Create %1").arg(ui.comboBox1->currentText());
|
||||
Gui::Application::Instance->activeDocument()->openCommand(prim.toUtf8());
|
||||
Gui::Command::doCommand(Gui::Command::Doc, (const char*)cmd.toUtf8());
|
||||
Gui::Command::runCommand(Gui::Command::Doc, cmd.toUtf8());
|
||||
Gui::Application::Instance->activeDocument()->commitCommand();
|
||||
Gui::Command::doCommand(Gui::Command::Doc, "App.ActiveDocument.recompute()");
|
||||
Gui::Command::doCommand(Gui::Command::Gui, "Gui.SendMsgToActiveView(\"ViewFit\")");
|
||||
Gui::Command::runCommand(Gui::Command::Doc, "App.ActiveDocument.recompute()");
|
||||
Gui::Command::runCommand(Gui::Command::Gui, "Gui.SendMsgToActiveView(\"ViewFit\")");
|
||||
}
|
||||
catch (const Base::PyException& e) {
|
||||
QMessageBox::warning(this, tr("Create %1")
|
||||
|
||||
Reference in New Issue
Block a user