remove Application::runPythonCode
This commit is contained in:
@@ -51,6 +51,7 @@
|
||||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/ViewProvider.h>
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/View3DInventor.h>
|
||||
#include <Gui/View3DInventorViewer.h>
|
||||
@@ -232,29 +233,28 @@ void CrossSections::apply()
|
||||
section->purgeTouched();
|
||||
}
|
||||
#else
|
||||
Gui::Application* app = Gui::Application::Instance;
|
||||
Base::SequencerLauncher seq("Cross-sections...", obj.size() * (d.size() +1));
|
||||
app->runPythonCode("import Part\n");
|
||||
app->runPythonCode("from FreeCAD import Base\n");
|
||||
Gui::Command::runCommand(Gui::Command::App, "import Part\n");
|
||||
Gui::Command::runCommand(Gui::Command::App, "from FreeCAD import Base\n");
|
||||
for (std::vector<App::DocumentObject*>::iterator it = obj.begin(); it != obj.end(); ++it) {
|
||||
App::Document* doc = (*it)->getDocument();
|
||||
std::string s = (*it)->getNameInDocument();
|
||||
s += "_cs";
|
||||
app->runPythonCode(QString::fromLatin1(
|
||||
Gui::Command::runCommand(Gui::Command::App, QString::fromLatin1(
|
||||
"wires=list()\n"
|
||||
"shape=FreeCAD.getDocument(\"%1\").%2.Shape\n")
|
||||
.arg(QLatin1String(doc->getName()))
|
||||
.arg(QLatin1String((*it)->getNameInDocument())).toLatin1());
|
||||
|
||||
for (std::vector<double>::iterator jt = d.begin(); jt != d.end(); ++jt) {
|
||||
app->runPythonCode(QString::fromLatin1(
|
||||
Gui::Command::runCommand(Gui::Command::App, QString::fromLatin1(
|
||||
"for i in shape.slice(Base.Vector(%1,%2,%3),%4):\n"
|
||||
" wires.append(i)\n"
|
||||
).arg(a).arg(b).arg(c).arg(*jt).toLatin1());
|
||||
seq.next();
|
||||
}
|
||||
|
||||
app->runPythonCode(QString::fromLatin1(
|
||||
Gui::Command::runCommand(Gui::Command::App, QString::fromLatin1(
|
||||
"comp=Part.Compound(wires)\n"
|
||||
"slice=FreeCAD.getDocument(\"%1\").addObject(\"Part::Feature\",\"%2\")\n"
|
||||
"slice.Shape=comp\n"
|
||||
|
||||
@@ -679,7 +679,7 @@ void DlgFilletEdges::changeEvent(QEvent *e)
|
||||
int id = model->data(model->index(i, 0), Qt::UserRole).toInt();
|
||||
model->setData(model->index(i, 0), QVariant(tr("Edge%1").arg(id)));
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
QWidget::changeEvent(e);
|
||||
}
|
||||
@@ -936,7 +936,7 @@ bool DlgFilletEdges::accept()
|
||||
"del __fillets__\n"
|
||||
"FreeCADGui.ActiveDocument.%2.Visibility = False\n")
|
||||
.arg(name).arg(shape);
|
||||
Gui::Application::Instance->runPythonCode((const char*)code.toLatin1());
|
||||
Gui::Command::runCommand(Gui::Command::App, code.toLatin1());
|
||||
activeDoc->commitTransaction();
|
||||
activeDoc->recompute();
|
||||
if (d->fillet) {
|
||||
|
||||
@@ -405,7 +405,7 @@ void DlgRevolution::accept()
|
||||
.arg(strAxisLink) //%12
|
||||
.arg(symmetric) //13
|
||||
;
|
||||
Gui::Application::Instance->runPythonCode((const char*)code.toLatin1());
|
||||
Gui::Command::runCommand(Gui::Command::App, code.toLatin1());
|
||||
QByteArray to = name.toLatin1();
|
||||
QByteArray from = shape.toLatin1();
|
||||
Gui::Command::copyVisual(to, "ShapeColor", from);
|
||||
|
||||
@@ -171,7 +171,7 @@ bool Mirroring::accept()
|
||||
.arg(this->document).arg(shape).arg(label)
|
||||
.arg(normx).arg(normy).arg(normz)
|
||||
.arg(basex).arg(basey).arg(basez);
|
||||
Gui::Application::Instance->runPythonCode((const char*)code.toLatin1());
|
||||
Gui::Command::runCommand(Gui::Command::App, code.toLatin1());
|
||||
QByteArray from = shape.toLatin1();
|
||||
Gui::Command::copyVisual("ActiveObject", "ShapeColor", from);
|
||||
Gui::Command::copyVisual("ActiveObject", "LineColor", from);
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/ViewProvider.h>
|
||||
@@ -66,8 +67,8 @@ public:
|
||||
LoftWidget::LoftWidget(QWidget* parent)
|
||||
: d(new Private())
|
||||
{
|
||||
Gui::Application::Instance->runPythonCode("from FreeCAD import Base");
|
||||
Gui::Application::Instance->runPythonCode("import Part");
|
||||
Gui::Command::runCommand(Gui::Command::App, "from FreeCAD import Base");
|
||||
Gui::Command::runCommand(Gui::Command::App, "import Part");
|
||||
|
||||
d->ui.setupUi(this);
|
||||
d->ui.selector->setAvailableLabel(tr("Vertex/Edge/Wire/Face"));
|
||||
@@ -175,7 +176,7 @@ bool LoftWidget::accept()
|
||||
Gui::Document* doc = Gui::Application::Instance->getDocument(d->document.c_str());
|
||||
if (!doc) throw Base::Exception("Document doesn't exist anymore");
|
||||
doc->openCommand("Loft");
|
||||
Gui::Application::Instance->runPythonCode((const char*)cmd.toLatin1(), false, false);
|
||||
Gui::Command::runCommand(Gui::Command::App, cmd.toLatin1());
|
||||
doc->getDocument()->recompute();
|
||||
App::DocumentObject* obj = doc->getDocument()->getActiveObject();
|
||||
if (obj && !obj->isValid()) {
|
||||
|
||||
@@ -68,8 +68,8 @@ public:
|
||||
OffsetWidget::OffsetWidget(Part::Offset* offset, QWidget* parent)
|
||||
: d(new Private())
|
||||
{
|
||||
Gui::Application::Instance->runPythonCode("from FreeCAD import Base");
|
||||
Gui::Application::Instance->runPythonCode("import Part");
|
||||
Gui::Command::runCommand(Gui::Command::App, "from FreeCAD import Base");
|
||||
Gui::Command::runCommand(Gui::Command::App, "import Part");
|
||||
|
||||
d->offset = offset;
|
||||
d->ui.setupUi(this);
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/SelectionFilter.h>
|
||||
@@ -85,29 +86,28 @@ namespace PartGui {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
class ShapeBuilderWidget::Private
|
||||
{
|
||||
public:
|
||||
|
||||
class ShapeBuilderWidget::Private
|
||||
{
|
||||
public:
|
||||
Ui_TaskShapeBuilder ui;
|
||||
QButtonGroup bg;
|
||||
ShapeSelection* gate;
|
||||
Private()
|
||||
{
|
||||
}
|
||||
~Private()
|
||||
{
|
||||
}
|
||||
};
|
||||
{
|
||||
Gui::Command::runCommand(Gui::Command::App, "from FreeCAD import Base");
|
||||
Gui::Command::runCommand(Gui::Command::App, "import Part");
|
||||
}
|
||||
~Private()
|
||||
{
|
||||
}
|
||||
};
|
||||
|
||||
/* TRANSLATOR PartGui::ShapeBuilderWidget */
|
||||
|
||||
ShapeBuilderWidget::ShapeBuilderWidget(QWidget* parent)
|
||||
: d(new Private())
|
||||
{
|
||||
Gui::Application::Instance->runPythonCode("from FreeCAD import Base");
|
||||
Gui::Application::Instance->runPythonCode("import Part");
|
||||
|
||||
d->ui.setupUi(this);
|
||||
d->ui.label->setText(QString());
|
||||
d->bg.addButton(d->ui.radioButtonEdgeFromVertex, 0);
|
||||
@@ -157,10 +157,10 @@ void ShapeBuilderWidget::on_createButton_clicked()
|
||||
}
|
||||
doc->getDocument()->recompute();
|
||||
Gui::Selection().clearSelection();
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
Base::Console().Error("%s\n", e.what());
|
||||
}
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
Base::Console().Error("%s\n", e.what());
|
||||
}
|
||||
}
|
||||
|
||||
void ShapeBuilderWidget::createEdgeFromVertex()
|
||||
@@ -200,14 +200,14 @@ void ShapeBuilderWidget::createEdgeFromVertex()
|
||||
).arg(elements[0]).arg(elements[1]);
|
||||
|
||||
try {
|
||||
Gui::Application::Instance->activeDocument()->openCommand("Edge");
|
||||
Gui::Application::Instance->runPythonCode((const char*)cmd.toLatin1(), false, false);
|
||||
Gui::Application::Instance->activeDocument()->commitCommand();
|
||||
}
|
||||
catch (const Base::Exception&) {
|
||||
Gui::Application::Instance->activeDocument()->abortCommand();
|
||||
throw;
|
||||
}
|
||||
Gui::Application::Instance->activeDocument()->openCommand("Edge");
|
||||
Gui::Command::runCommand(Gui::Command::App, cmd.toLatin1());
|
||||
Gui::Application::Instance->activeDocument()->commitCommand();
|
||||
}
|
||||
catch (const Base::Exception&) {
|
||||
Gui::Application::Instance->activeDocument()->abortCommand();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void ShapeBuilderWidget::createFaceFromVertex()
|
||||
@@ -252,14 +252,14 @@ void ShapeBuilderWidget::createFaceFromVertex()
|
||||
}
|
||||
|
||||
try {
|
||||
Gui::Application::Instance->activeDocument()->openCommand("Face");
|
||||
Gui::Application::Instance->runPythonCode((const char*)cmd.toLatin1(), false, false);
|
||||
Gui::Application::Instance->activeDocument()->commitCommand();
|
||||
}
|
||||
catch (const Base::Exception&) {
|
||||
Gui::Application::Instance->activeDocument()->abortCommand();
|
||||
throw;
|
||||
}
|
||||
Gui::Application::Instance->activeDocument()->openCommand("Face");
|
||||
Gui::Command::runCommand(Gui::Command::App, cmd.toLatin1());
|
||||
Gui::Application::Instance->activeDocument()->commitCommand();
|
||||
}
|
||||
catch (const Base::Exception&) {
|
||||
Gui::Application::Instance->activeDocument()->abortCommand();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void ShapeBuilderWidget::createFaceFromEdge()
|
||||
@@ -304,14 +304,14 @@ void ShapeBuilderWidget::createFaceFromEdge()
|
||||
}
|
||||
|
||||
try {
|
||||
Gui::Application::Instance->activeDocument()->openCommand("Face");
|
||||
Gui::Application::Instance->runPythonCode((const char*)cmd.toLatin1(), false, false);
|
||||
Gui::Application::Instance->activeDocument()->commitCommand();
|
||||
}
|
||||
catch (const Base::Exception&) {
|
||||
Gui::Application::Instance->activeDocument()->abortCommand();
|
||||
throw;
|
||||
}
|
||||
Gui::Application::Instance->activeDocument()->openCommand("Face");
|
||||
Gui::Command::runCommand(Gui::Command::App, cmd.toLatin1());
|
||||
Gui::Application::Instance->activeDocument()->commitCommand();
|
||||
}
|
||||
catch (const Base::Exception&) {
|
||||
Gui::Application::Instance->activeDocument()->abortCommand();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void ShapeBuilderWidget::createShellFromFace()
|
||||
@@ -367,14 +367,14 @@ void ShapeBuilderWidget::createShellFromFace()
|
||||
}
|
||||
|
||||
try {
|
||||
Gui::Application::Instance->activeDocument()->openCommand("Shell");
|
||||
Gui::Application::Instance->runPythonCode((const char*)cmd.toLatin1(), false, false);
|
||||
Gui::Application::Instance->activeDocument()->commitCommand();
|
||||
}
|
||||
catch (const Base::Exception&) {
|
||||
Gui::Application::Instance->activeDocument()->abortCommand();
|
||||
throw;
|
||||
}
|
||||
Gui::Application::Instance->activeDocument()->openCommand("Shell");
|
||||
Gui::Command::runCommand(Gui::Command::App, cmd.toLatin1());
|
||||
Gui::Application::Instance->activeDocument()->commitCommand();
|
||||
}
|
||||
catch (const Base::Exception&) {
|
||||
Gui::Application::Instance->activeDocument()->abortCommand();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void ShapeBuilderWidget::createSolidFromShell()
|
||||
@@ -419,14 +419,14 @@ void ShapeBuilderWidget::createSolidFromShell()
|
||||
}
|
||||
|
||||
try {
|
||||
Gui::Application::Instance->activeDocument()->openCommand("Solid");
|
||||
Gui::Application::Instance->runPythonCode((const char*)cmd.toLatin1(), false, false);
|
||||
Gui::Application::Instance->activeDocument()->commitCommand();
|
||||
}
|
||||
catch (const Base::Exception&) {
|
||||
Gui::Application::Instance->activeDocument()->abortCommand();
|
||||
throw;
|
||||
}
|
||||
Gui::Application::Instance->activeDocument()->openCommand("Solid");
|
||||
Gui::Command::runCommand(Gui::Command::App, cmd.toLatin1());
|
||||
Gui::Application::Instance->activeDocument()->commitCommand();
|
||||
}
|
||||
catch (const Base::Exception&) {
|
||||
Gui::Application::Instance->activeDocument()->abortCommand();
|
||||
throw;
|
||||
}
|
||||
}
|
||||
|
||||
void ShapeBuilderWidget::switchMode(int mode)
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/Document.h>
|
||||
#include <Gui/Selection.h>
|
||||
#include <Gui/SelectionFilter.h>
|
||||
@@ -127,8 +128,8 @@ public:
|
||||
SweepWidget::SweepWidget(QWidget* parent)
|
||||
: d(new Private())
|
||||
{
|
||||
Gui::Application::Instance->runPythonCode("from FreeCAD import Base");
|
||||
Gui::Application::Instance->runPythonCode("import Part");
|
||||
Gui::Command::runCommand(Gui::Command::App, "from FreeCAD import Base");
|
||||
Gui::Command::runCommand(Gui::Command::App, "import Part");
|
||||
|
||||
d->ui.setupUi(this);
|
||||
d->ui.selector->setAvailableLabel(tr("Vertex/Edge/Wire/Face"));
|
||||
@@ -321,7 +322,7 @@ bool SweepWidget::accept()
|
||||
Gui::Document* doc = Gui::Application::Instance->getDocument(d->document.c_str());
|
||||
if (!doc) throw Base::Exception("Document doesn't exist anymore");
|
||||
doc->openCommand("Sweep");
|
||||
Gui::Application::Instance->runPythonCode((const char*)cmd.toLatin1(), false, false);
|
||||
Gui::Command::runCommand(Gui::Command::App, cmd.toLatin1());
|
||||
doc->getDocument()->recompute();
|
||||
App::DocumentObject* obj = doc->getDocument()->getActiveObject();
|
||||
if (obj && !obj->isValid()) {
|
||||
|
||||
@@ -45,6 +45,7 @@
|
||||
#include <App/Application.h>
|
||||
#include <App/Document.h>
|
||||
#include <App/DocumentObject.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Mod/Part/App/PartFeatures.h>
|
||||
|
||||
|
||||
@@ -90,8 +91,8 @@ public:
|
||||
ThicknessWidget::ThicknessWidget(Part::Thickness* thickness, QWidget* parent)
|
||||
: d(new Private())
|
||||
{
|
||||
Gui::Application::Instance->runPythonCode("from FreeCAD import Base");
|
||||
Gui::Application::Instance->runPythonCode("import Part");
|
||||
Gui::Command::runCommand(Gui::Command::App, "from FreeCAD import Base");
|
||||
Gui::Command::runCommand(Gui::Command::App, "import Part");
|
||||
|
||||
d->thickness = thickness;
|
||||
d->ui.setupUi(this);
|
||||
|
||||
Reference in New Issue
Block a user