Download src/Mod/Part/Gui/AppPartGui.cpp from AbdulElahGwaith/FreeCAD: direct link, hf CLI and curl.
- Browser
- Download file 12 kB
-
https://huggingface.co/AbdulElahGwaith/FreeCAD/resolve/main/src/Mod/Part/Gui/AppPartGui.cpp
- Command line
-
hf download hf://AbdulElahGwaith/FreeCAD/src/Mod/Part/Gui/AppPartGui.cpp
-
curl -L -o AppPartGui.cpp https://huggingface.co/AbdulElahGwaith/FreeCAD/resolve/main/src/Mod/Part/Gui/AppPartGui.cpp
12 kB
| // SPDX-License-Identifier: LGPL-2.1-or-later | |
| /*************************************************************************** | |
| * Copyright (c) 2002 Juergen Riegel <juergen.riegel@web.de> * | |
| * * | |
| * This file is part of the FreeCAD CAx development system. * | |
| * * | |
| * This program is free software; you can redistribute it and/or modify * | |
| * it under the terms of the GNU Lesser General Public License (LGPL) * | |
| * as published by the Free Software Foundation; either version 2 of * | |
| * the License, or (at your option) any later version. * | |
| * for detail see the LICENCE text file. * | |
| * * | |
| * FreeCAD is distributed in the hope that it will be useful, * | |
| * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
| * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
| * GNU Lesser General Public License for more details. * | |
| * * | |
| * You should have received a copy of the GNU Library General Public * | |
| * License along with FreeCAD; if not, write to the Free Software * | |
| * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 * | |
| * USA * | |
| * * | |
| ***************************************************************************/ | |
| // use a different name to CreateCommand() | |
| void CreatePartCommands(); | |
| void CreateSimplePartCommands(); | |
| void CreateParamPartCommands(); | |
| void CreatePartSelectCommands(); | |
| void loadPartResource() | |
| { | |
| // add resources and reloads the translators | |
| Q_INIT_RESOURCE(Part); | |
| Q_INIT_RESOURCE(Part_translation); | |
| Gui::Translator::instance()->refresh(); | |
| } | |
| namespace PartGui | |
| { | |
| class Module: public Py::ExtensionModule<Module> | |
| { | |
| public: | |
| Module() | |
| : Py::ExtensionModule<Module>("PartGui") | |
| { | |
| initialize("This module is the PartGui module."); // register with Python | |
| } | |
| private: | |
| }; | |
| PyObject* initModule() | |
| { | |
| return Base::Interpreter().addModule(new Module); | |
| } | |
| } // namespace PartGui | |
| PyMOD_INIT_FUNC(PartGui) | |
| { | |
| if (!Gui::Application::Instance) { | |
| PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application."); | |
| PyMOD_Return(nullptr); | |
| } | |
| // load needed modules | |
| try { | |
| Base::Interpreter().runString("import Part"); | |
| Base::Interpreter().runString("import MatGui"); | |
| } | |
| catch (const Base::Exception& e) { | |
| PyErr_SetString(PyExc_ImportError, e.what()); | |
| PyMOD_Return(nullptr); | |
| } | |
| PyObject* partGuiModule = PartGui::initModule(); | |
| Base::Console().log("Loading GUI of Part module… done\n"); | |
| Gui::BitmapFactory().addPath(QStringLiteral(":/icons/booleans")); | |
| Gui::BitmapFactory().addPath(QStringLiteral(":/icons/create")); | |
| Gui::BitmapFactory().addPath(QStringLiteral(":/icons/parametric")); | |
| Gui::BitmapFactory().addPath(QStringLiteral(":/icons/tools")); | |
| // clang-format off | |
| static struct PyModuleDef pAttachEngineTextsModuleDef = { | |
| PyModuleDef_HEAD_INIT, | |
| "AttachEngineResources", | |
| "AttachEngineResources", | |
| -1, | |
| AttacherGui::AttacherGuiPy::Methods, | |
| nullptr, nullptr, nullptr, nullptr | |
| }; | |
| // clang-format on | |
| PyObject* pAttachEngineTextsModule = PyModule_Create(&pAttachEngineTextsModuleDef); | |
| Py_INCREF(pAttachEngineTextsModule); | |
| PyModule_AddObject(partGuiModule, "AttachEngineResources", pAttachEngineTextsModule); | |
| // clang-format off | |
| PartGui::PropertyEnumAttacherItem ::init(); | |
| PartGui::SoBrepFaceSet ::initClass(); | |
| PartGui::SoBrepEdgeSet ::initClass(); | |
| PartGui::SoBrepPointSet ::initClass(); | |
| PartGui::SoFCControlPoints ::initClass(); | |
| PartGui::SoFCShape ::initClass(); | |
| PartGui::SoPreviewShape ::initClass(); | |
| PartGui::ViewProviderAttachExtension ::init(); | |
| PartGui::ViewProviderAttachExtensionPython ::init(); | |
| PartGui::ViewProviderGridExtension ::init(); | |
| PartGui::ViewProviderGridExtensionPython ::init(); | |
| PartGui::ViewProviderPreviewExtension ::init(); | |
| PartGui::ViewProviderPreviewExtensionPython ::init(); | |
| PartGui::ViewProviderSplineExtension ::init(); | |
| PartGui::ViewProviderSplineExtensionPython ::init(); | |
| PartGui::ViewProviderLine ::init(); | |
| PartGui::ViewProviderPlane ::init(); | |
| PartGui::ViewProviderPoint ::init(); | |
| PartGui::ViewProviderLCS ::init(); | |
| PartGui::ViewProviderPartExt ::init(); | |
| PartGui::ViewProviderPart ::init(); | |
| PartGui::ViewProviderPrimitive ::init(); | |
| PartGui::ViewProviderEllipsoid ::init(); | |
| PartGui::ViewProviderPython ::init(); | |
| PartGui::ViewProviderBox ::init(); | |
| PartGui::ViewProviderPrism ::init(); | |
| PartGui::ViewProviderRegularPolygon ::init(); | |
| PartGui::ViewProviderWedge ::init(); | |
| PartGui::ViewProviderImport ::init(); | |
| PartGui::ViewProviderCurveNet ::init(); | |
| PartGui::ViewProviderExtrusion ::init(); | |
| PartGui::ViewProviderScale ::init(); | |
| PartGui::ViewProvider2DObject ::init(); | |
| PartGui::ViewProvider2DObjectPython ::init(); | |
| PartGui::ViewProvider2DObjectGrid ::init(); | |
| PartGui::ViewProviderMirror ::init(); | |
| PartGui::ViewProviderFillet ::init(); | |
| PartGui::ViewProviderChamfer ::init(); | |
| PartGui::ViewProviderRevolution ::init(); | |
| PartGui::ViewProviderLoft ::init(); | |
| PartGui::ViewProviderSweep ::init(); | |
| PartGui::ViewProviderOffset ::init(); | |
| PartGui::ViewProviderOffset2D ::init(); | |
| PartGui::ViewProviderThickness ::init(); | |
| PartGui::ViewProviderRefine ::init(); | |
| PartGui::ViewProviderReverse ::init(); | |
| PartGui::ViewProviderCustom ::init(); | |
| PartGui::ViewProviderCustomPython ::init(); | |
| PartGui::ViewProviderBoolean ::init(); | |
| PartGui::ViewProviderMultiFuse ::init(); | |
| PartGui::ViewProviderMultiCommon ::init(); | |
| PartGui::ViewProviderCompound ::init(); | |
| PartGui::ViewProviderSpline ::init(); | |
| PartGui::ViewProviderCircleParametric ::init(); | |
| PartGui::ViewProviderLineParametric ::init(); | |
| PartGui::ViewProviderPointParametric ::init(); | |
| PartGui::ViewProviderEllipseParametric ::init(); | |
| PartGui::ViewProviderHelixParametric ::init(); | |
| PartGui::ViewProviderSpiralParametric ::init(); | |
| PartGui::ViewProviderPlaneParametric ::init(); | |
| PartGui::ViewProviderSphereParametric ::init(); | |
| PartGui::ViewProviderCylinderParametric ::init(); | |
| PartGui::ViewProviderConeParametric ::init(); | |
| PartGui::ViewProviderTorusParametric ::init(); | |
| PartGui::ViewProviderRuledSurface ::init(); | |
| PartGui::ViewProviderFace ::init(); | |
| PartGui::ViewProviderProjectOnSurface ::init(); | |
| PartGui::Workbench ::init(); | |
| auto manip = std::make_shared<PartGui::WorkbenchManipulator>(); | |
| Gui::WorkbenchManipulator::installManipulator(manip); | |
| Base::registerServiceImplementation<Part::PreviewUpdateScheduler>(new PartGui::QtPreviewUpdateScheduler); | |
| // instantiating the commands | |
| CreatePartCommands(); | |
| CreateSimplePartCommands(); | |
| CreateParamPartCommands(); | |
| CreatePartSelectCommands(); | |
| try { | |
| const char* cmd = "__import__('AttachmentEditor.Commands').Commands"; | |
| Py::Object ae = Base::Interpreter().runStringObject(cmd); | |
| Py::Module(partGuiModule).setAttr(std::string("AttachmentEditor"), ae); | |
| } | |
| catch (Base::PyException& err) { | |
| err.reportException(); | |
| } | |
| // register preferences pages | |
| Gui::Dialog::DlgPreferencesImp::setGroupData("Part/Part Design", "Part design", QObject::tr("Part and Part Design workbench")); | |
| (void)new Gui::PrefPageProducer<PartGui::DlgSettingsGeneral>(QT_TRANSLATE_NOOP("QObject", "Part/Part Design")); | |
| (void)new Gui::PrefPageProducer<PartGui::DlgSettings3DViewPart>(QT_TRANSLATE_NOOP("QObject", "Part/Part Design")); | |
| (void)new Gui::PrefPageProducer<PartGui::DlgSettingsObjectColor>(QT_TRANSLATE_NOOP("QObject", "Part/Part Design")); | |
| (void)new Gui::PrefPageProducer<PartGui::DlgImportExportIges>(QT_TRANSLATE_NOOP("QObject", "Import-Export")); | |
| (void)new Gui::PrefPageProducer<PartGui::DlgImportExportStep>(QT_TRANSLATE_NOOP("QObject", "Import-Export")); | |
| Gui::ViewProviderBuilder::add(Part::PropertyPartShape::getClassTypeId(), | |
| PartGui::ViewProviderPart::getClassTypeId()); | |
| // clang-format on | |
| // add resources and reloads the translators | |
| loadPartResource(); | |
| PyMOD_Return(partGuiModule); | |
| } | |