1
/***************************************************************************
2
* Copyright (c) 2008 Jürgen Riegel <juergen.riegel@web.de> *
4
* This file is part of the FreeCAD CAx development system. *
6
* This library is free software; you can redistribute it and/or *
7
* modify it under the terms of the GNU Library General Public *
8
* License as published by the Free Software Foundation; either *
9
* version 2 of the License, or (at your option) any later version. *
11
* This library is distributed in the hope that it will be useful, *
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14
* GNU Library General Public License for more details. *
16
* You should have received a copy of the GNU Library General Public *
17
* License along with this library; see the file COPYING.LIB. If not, *
18
* write to the Free Software Foundation, Inc., 59 Temple Place, *
19
* Suite 330, Boston, MA 02111-1307, USA *
21
***************************************************************************/
23
#include "PreCompiled.h"
25
#include <Base/Console.h>
26
#include <Base/Interpreter.h>
27
#include <Base/PyObjectBase.h>
28
#include <Gui/Application.h>
29
#include <Gui/BitmapFactory.h>
30
#include <Gui/Language/Translator.h>
31
#include <Gui/WidgetFactory.h>
33
#include "PropertyConstraintListItem.h"
34
#include "SketcherSettings.h"
35
#include "SoZoomTranslation.h"
36
#include "ViewProviderPython.h"
37
#include "ViewProviderSketch.h"
38
#include "ViewProviderSketchGeometryExtension.h"
39
#include "ViewProviderSketchGeometryExtensionPy.h"
44
void CreateSketcherCommands();
45
void CreateSketcherCommandsCreateGeo();
46
void CreateSketcherCommandsConstraints();
47
void CreateSketcherCommandsConstraintAccel();
48
void CreateSketcherCommandsAlterGeo();
49
void CreateSketcherCommandsBSpline();
50
void CreateSketcherCommandsOverlay();
51
void CreateSketcherCommandsVirtualSpace();
53
void loadSketcherResource()
55
// add resources and reloads the translators
56
Q_INIT_RESOURCE(Sketcher);
57
Q_INIT_RESOURCE(Sketcher_translation);
58
Gui::Translator::instance()->refresh();
63
class Module: public Py::ExtensionModule<Module>
67
: Py::ExtensionModule<Module>("SketcherGui")
69
initialize("This module is the SketcherGui module."); // register with Python
80
return Base::Interpreter().addModule(new Module);
83
} // namespace SketcherGui
86
PyMOD_INIT_FUNC(SketcherGui)
88
if (!Gui::Application::Instance) {
89
PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application.");
90
PyMOD_Return(nullptr);
93
Base::Interpreter().runString("import PartGui");
94
Base::Interpreter().runString("import Sketcher");
96
catch (const Base::Exception& e) {
97
PyErr_SetString(PyExc_ImportError, e.what());
98
PyMOD_Return(nullptr);
101
PyObject* sketcherGuiModule = SketcherGui::initModule();
102
Base::Console().Log("Loading GUI of Sketcher module... done\n");
104
Gui::BitmapFactory().addPath(QString::fromLatin1(":/icons/constraints"));
105
Gui::BitmapFactory().addPath(QString::fromLatin1(":/icons/elements"));
106
Gui::BitmapFactory().addPath(QString::fromLatin1(":/icons/general"));
107
Gui::BitmapFactory().addPath(QString::fromLatin1(":/icons/geometry"));
108
// Gui::BitmapFactory().addPath(QString::fromLatin1(":/icons/obsolete"));
109
Gui::BitmapFactory().addPath(QString::fromLatin1(":/icons/pointers"));
110
Gui::BitmapFactory().addPath(QString::fromLatin1(":/icons/splines"));
111
Gui::BitmapFactory().addPath(QString::fromLatin1(":/icons/tools"));
112
Gui::BitmapFactory().addPath(QString::fromLatin1(":/icons/overlay"));
114
// instantiating the commands
115
CreateSketcherCommands();
116
CreateSketcherCommandsCreateGeo();
117
CreateSketcherCommandsConstraints();
118
CreateSketcherCommandsAlterGeo();
119
CreateSketcherCommandsConstraintAccel();
120
CreateSketcherCommandsBSpline();
121
CreateSketcherCommandsOverlay();
122
CreateSketcherCommandsVirtualSpace();
124
SketcherGui::Workbench::init();
126
// Add Types to module
127
Base::Interpreter().addType(&SketcherGui::ViewProviderSketchGeometryExtensionPy ::Type,
129
"ViewProviderSketchGeometryExtension");
132
SketcherGui::ViewProviderSketch ::init();
133
SketcherGui::ViewProviderPython ::init();
134
SketcherGui::ViewProviderCustom ::init();
135
SketcherGui::ViewProviderCustomPython ::init();
136
SketcherGui::SoZoomTranslation ::initClass();
137
SketcherGui::PropertyConstraintListItem ::init();
138
SketcherGui::ViewProviderSketchGeometryExtension ::init();
140
(void)new Gui::PrefPageProducer<SketcherGui::SketcherSettings>(
141
QT_TRANSLATE_NOOP("QObject", "Sketcher"));
142
(void)new Gui::PrefPageProducer<SketcherGui::SketcherSettingsGrid>(
143
QT_TRANSLATE_NOOP("QObject", "Sketcher"));
144
(void)new Gui::PrefPageProducer<SketcherGui::SketcherSettingsDisplay>(
145
QT_TRANSLATE_NOOP("QObject", "Sketcher"));
146
(void)new Gui::PrefPageProducer<SketcherGui::SketcherSettingsAppearance>(
147
QT_TRANSLATE_NOOP("QObject", "Sketcher"));
149
// add resources and reloads the translators
150
loadSketcherResource();
152
PyMOD_Return(sketcherGuiModule);