remove method Application::runCommand

This commit is contained in:
wmayer 2016-09-15 19:39:16 +02:00
parent f44df3cdf0
commit 18cc6c1851
4 changed files with 47 additions and 65 deletions

View File

@ -1363,24 +1363,6 @@ CommandManager &Application::commandManager(void)
return d->commandManager;
}
void Application::runCommand(bool bForce, const char* sCmd,...)
{
va_list ap;
va_start(ap, sCmd);
QString s;
const QString cmd = s.vsprintf(sCmd, ap);
va_end(ap);
QByteArray format = cmd.toLatin1();
if (bForce)
d->macroMngr->addLine(MacroManager::App, format.constData());
else
d->macroMngr->addLine(MacroManager::Gui, format.constData());
Base::Interpreter().runString(format.constData());
}
bool Application::runPythonCode(const char* cmd, bool gui, bool pyexc)
{
if (gui)

View File

@ -179,7 +179,6 @@ public:
/// Reference to the command manager
Gui::CommandManager &commandManager(void);
/// Run a Python command
void runCommand(bool bForce, const char* sCmd,...);
bool runPythonCode(const char* cmd, bool gui=false, bool pyexc=true);
/// helper which create the commands
void createStandardOperations();

View File

@ -32,6 +32,7 @@
#include <App/Document.h>
#include <App/DocumentObject.h>
#include <App/Application.h>
#include <Gui/Command.h>
#include <Gui/Document.h>
#include <Gui/ViewProvider.h>
#include <Gui/Application.h>
@ -230,33 +231,33 @@ void VisualInspection::accept()
doc->openCommand("Visual Inspection");
// create a group
Gui::Application::Instance->runCommand(
true, "App_activeDocument___InspectionGroup=App.ActiveDocument.addObject(\"Inspection::Group\",\"Inspection\")");
Gui::Command::runCommand(
Gui::Command::App, "App_activeDocument___InspectionGroup=App.ActiveDocument.addObject(\"Inspection::Group\",\"Inspection\")");
// for each actual geometry create an inspection feature
for (QTreeWidgetItemIterator it(ui->treeWidgetActual); *it; it++) {
SingleSelectionItem* sel = (SingleSelectionItem*)*it;
if (sel->checkState(0) == Qt::Checked) {
QString actualName = sel->data(0, Qt::UserRole).toString();
Gui::Application::Instance->runCommand(
true, "App_activeDocument___InspectionGroup.newObject(\"Inspection::Feature\",\"%s_Inspect\")", (const char*)actualName.toLatin1());
Gui::Application::Instance->runCommand(
true, "App.ActiveDocument.ActiveObject.Actual=App.ActiveDocument.%s\n"
"App_activeDocument___activeObject___Nominals=list()\n"
"App.ActiveDocument.ActiveObject.SearchRadius=%.3f\n"
"App.ActiveDocument.ActiveObject.Thickness=%.3f\n", (const char*)actualName.toLatin1(), searchRadius, thickness);
Gui::Command::doCommand(Gui::Command::App,
"App_activeDocument___InspectionGroup.newObject(\"Inspection::Feature\",\"%s_Inspect\")", (const char*)actualName.toLatin1());
Gui::Command::doCommand(Gui::Command::App,
"App.ActiveDocument.ActiveObject.Actual=App.ActiveDocument.%s\n"
"App_activeDocument___activeObject___Nominals=list()\n"
"App.ActiveDocument.ActiveObject.SearchRadius=%.3f\n"
"App.ActiveDocument.ActiveObject.Thickness=%.3f\n", (const char*)actualName.toLatin1(), searchRadius, thickness);
for (QStringList::Iterator it = nominalNames.begin(); it != nominalNames.end(); ++it) {
Gui::Application::Instance->runCommand(
true, "App_activeDocument___activeObject___Nominals.append(App.ActiveDocument.%s)\n", (const char*)(*it).toLatin1());
Gui::Command::doCommand(Gui::Command::App,
"App_activeDocument___activeObject___Nominals.append(App.ActiveDocument.%s)\n", (const char*)(*it).toLatin1());
}
Gui::Application::Instance->runCommand(
true, "App.ActiveDocument.ActiveObject.Nominals=App_activeDocument___activeObject___Nominals\n"
"del App_activeDocument___activeObject___Nominals\n");
Gui::Command::doCommand(Gui::Command::App,
"App.ActiveDocument.ActiveObject.Nominals=App_activeDocument___activeObject___Nominals\n"
"del App_activeDocument___activeObject___Nominals\n");
}
}
Gui::Application::Instance->runCommand(
true, "del App_activeDocument___InspectionGroup\n");
Gui::Command::runCommand(Gui::Command::App,
"del App_activeDocument___InspectionGroup\n");
doc->commitCommand();
doc->getDocument()->recompute();
@ -265,18 +266,18 @@ void VisualInspection::accept()
for (QTreeWidgetItemIterator it(ui->treeWidgetActual); *it; it++) {
SingleSelectionItem* sel = (SingleSelectionItem*)*it;
if (sel->checkState(0) == Qt::Checked) {
Gui::Application::Instance->runCommand(
true, "Gui.ActiveDocument.getObject(\"%s\").Visibility=False"
, (const char*)sel->data(0, Qt::UserRole).toString().toLatin1());
Gui::Command::doCommand(Gui::Command::App
, "Gui.ActiveDocument.getObject(\"%s\").Visibility=False"
, (const char*)sel->data(0, Qt::UserRole).toString().toLatin1());
}
}
for (QTreeWidgetItemIterator it(ui->treeWidgetNominal); *it; it++) {
SingleSelectionItem* sel = (SingleSelectionItem*)*it;
if (sel->checkState(0) == Qt::Checked) {
Gui::Application::Instance->runCommand(
true, "Gui.ActiveDocument.getObject(\"%s\").Visibility=False"
, (const char*)sel->data(0, Qt::UserRole).toString().toLatin1());
Gui::Command::doCommand(Gui::Command::App
, "Gui.ActiveDocument.getObject(\"%s\").Visibility=False"
, (const char*)sel->data(0, Qt::UserRole).toString().toLatin1());
}
}
}

View File

@ -481,8 +481,8 @@ void DlgEvaluateMeshImp::on_repairOrientationButton_clicked()
Gui::Document* doc = Gui::Application::Instance->getDocument(docName);
doc->openCommand("Harmonize normals");
try {
Gui::Application::Instance->runCommand(
true, "App.getDocument(\"%s\").getObject(\"%s\").harmonizeNormals()"
Gui::Command::doCommand(Gui::Command::App
, "App.getDocument(\"%s\").getObject(\"%s\").harmonizeNormals()"
, docName, objName);
}
catch (const Base::Exception& e) {
@ -584,13 +584,13 @@ void DlgEvaluateMeshImp::on_repairNonmanifoldsButton_clicked()
Gui::Document* doc = Gui::Application::Instance->getDocument(docName);
doc->openCommand("Remove non-manifolds");
try {
Gui::Application::Instance->runCommand(
true, "App.getDocument(\"%s\").getObject(\"%s\").removeNonManifolds()"
Gui::Command::doCommand(Gui::Command::App
, "App.getDocument(\"%s\").getObject(\"%s\").removeNonManifolds()"
, docName, objName);
if (d->checkNonManfoldPoints) {
Gui::Application::Instance->runCommand(
true, "App.getDocument(\"%s\").getObject(\"%s\").removeNonManifoldPoints()"
Gui::Command::doCommand(Gui::Command::App
, "App.getDocument(\"%s\").getObject(\"%s\").removeNonManifoldPoints()"
, docName, objName);
}
}
@ -683,8 +683,8 @@ void DlgEvaluateMeshImp::on_repairIndicesButton_clicked()
Gui::Document* doc = Gui::Application::Instance->getDocument(docName);
doc->openCommand("Fix indices");
try {
Gui::Application::Instance->runCommand(
true, "App.getDocument(\"%s\").getObject(\"%s\").fixIndices()"
Gui::Command::doCommand(Gui::Command::App
, "App.getDocument(\"%s\").getObject(\"%s\").fixIndices()"
, docName, objName);
}
catch (const Base::Exception& e) {
@ -749,8 +749,8 @@ void DlgEvaluateMeshImp::on_repairDegeneratedButton_clicked()
Gui::Document* doc = Gui::Application::Instance->getDocument(docName);
doc->openCommand("Remove degenerated faces");
try {
Gui::Application::Instance->runCommand(
true, "App.getDocument(\"%s\").getObject(\"%s\").fixDegenerations(%f)"
Gui::Command::doCommand(Gui::Command::App
, "App.getDocument(\"%s\").getObject(\"%s\").fixDegenerations(%f)"
, docName, objName, d->epsilonDegenerated);
}
catch (const Base::Exception& e) {
@ -816,8 +816,8 @@ void DlgEvaluateMeshImp::on_repairDuplicatedFacesButton_clicked()
Gui::Document* doc = Gui::Application::Instance->getDocument(docName);
doc->openCommand("Remove duplicated faces");
try {
Gui::Application::Instance->runCommand(
true, "App.getDocument(\"%s\").getObject(\"%s\").removeDuplicatedFacets()"
Gui::Command::doCommand(Gui::Command::App
, "App.getDocument(\"%s\").getObject(\"%s\").removeDuplicatedFacets()"
, docName, objName);
}
catch (const Base::Exception& e) {
@ -881,8 +881,8 @@ void DlgEvaluateMeshImp::on_repairDuplicatedPointsButton_clicked()
Gui::Document* doc = Gui::Application::Instance->getDocument(docName);
doc->openCommand("Remove duplicated points");
try {
Gui::Application::Instance->runCommand(
true, "App.getDocument(\"%s\").getObject(\"%s\").removeDuplicatedPoints()"
Gui::Command::doCommand(Gui::Command::App
, "App.getDocument(\"%s\").getObject(\"%s\").removeDuplicatedPoints()"
, docName, objName);
}
catch (const Base::Exception& e) {
@ -1052,8 +1052,8 @@ void DlgEvaluateMeshImp::on_repairFoldsButton_clicked()
qApp->setOverrideCursor(Qt::WaitCursor);
doc->openCommand("Remove folds");
try {
Gui::Application::Instance->runCommand(
true, "App.getDocument(\"%s\").getObject(\"%s\").removeFoldsOnSurface()"
Gui::Command::doCommand(Gui::Command::App
, "App.getDocument(\"%s\").getObject(\"%s\").removeFoldsOnSurface()"
, docName, objName);
}
catch (const Base::Exception& e) {
@ -1102,7 +1102,7 @@ void DlgEvaluateMeshImp::on_repairAllTogether_clicked()
{
MeshEvalSelfIntersection eval(rMesh);
if (self && !eval.Evaluate()) {
Gui::Application::Instance->runCommand(true,
Gui::Command::doCommand(Gui::Command::App,
"App.getDocument(\"%s\").getObject(\"%s\").fixSelfIntersections()",
docName, objName);
run = true;
@ -1117,7 +1117,7 @@ void DlgEvaluateMeshImp::on_repairAllTogether_clicked()
MeshEvalFoldsOnBoundary b_eval(rMesh);
MeshEvalFoldOversOnSurface f_eval(rMesh);
if (!s_eval.Evaluate() || !b_eval.Evaluate() || !f_eval.Evaluate()) {
Gui::Application::Instance->runCommand(true,
Gui::Command::doCommand(Gui::Command::App,
"App.getDocument(\"%s\").getObject(\"%s\").removeFoldsOnSurface()",
docName, objName);
run = true;
@ -1127,7 +1127,7 @@ void DlgEvaluateMeshImp::on_repairAllTogether_clicked()
{
MeshEvalOrientation eval(rMesh);
if (!eval.Evaluate()) {
Gui::Application::Instance->runCommand(true,
Gui::Command::doCommand(Gui::Command::App,
"App.getDocument(\"%s\").getObject(\"%s\").harmonizeNormals()",
docName, objName);
run = true;
@ -1137,7 +1137,7 @@ void DlgEvaluateMeshImp::on_repairAllTogether_clicked()
{
MeshEvalTopology eval(rMesh);
if (!eval.Evaluate()) {
Gui::Application::Instance->runCommand(true,
Gui::Command::doCommand(Gui::Command::App,
"App.getDocument(\"%s\").getObject(\"%s\").removeNonManifolds()",
docName, objName);
run = true;
@ -1150,7 +1150,7 @@ void DlgEvaluateMeshImp::on_repairAllTogether_clicked()
MeshEvalCorruptedFacets cf(rMesh);
MeshEvalNeighbourhood nb(rMesh);
if (!rf.Evaluate() || !rp.Evaluate() || !cf.Evaluate() || !nb.Evaluate()) {
Gui::Application::Instance->runCommand(true,
Gui::Command::doCommand(Gui::Command::App,
"App.getDocument(\"%s\").getObject(\"%s\").fixIndices()",
docName, objName);
run = true;
@ -1159,7 +1159,7 @@ void DlgEvaluateMeshImp::on_repairAllTogether_clicked()
{
MeshEvalDegeneratedFacets eval(rMesh, d->epsilonDegenerated);
if (!eval.Evaluate()) {
Gui::Application::Instance->runCommand(true,
Gui::Command::doCommand(Gui::Command::App,
"App.getDocument(\"%s\").getObject(\"%s\").fixDegenerations(%f)",
docName, objName, d->epsilonDegenerated);
run = true;
@ -1169,7 +1169,7 @@ void DlgEvaluateMeshImp::on_repairAllTogether_clicked()
{
MeshEvalDuplicateFacets eval(rMesh);
if (!eval.Evaluate()) {
Gui::Application::Instance->runCommand(true,
Gui::Command::doCommand(Gui::Command::App,
"App.getDocument(\"%s\").getObject(\"%s\").removeDuplicatedFacets()",
docName, objName);
run = true;
@ -1179,7 +1179,7 @@ void DlgEvaluateMeshImp::on_repairAllTogether_clicked()
{
MeshEvalDuplicatePoints eval(rMesh);
if (!eval.Evaluate()) {
Gui::Application::Instance->runCommand(true,
Gui::Command::doCommand(Gui::Command::App,
"App.getDocument(\"%s\").getObject(\"%s\").removeDuplicatedPoints()",
docName, objName);
run = true;