1
/***************************************************************************
2
* Copyright (c) 2002 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/Language/Translator.h>
30
#include <Mod/Points/App/PropertyPointKernel.h>
32
#include "ViewProvider.h"
36
// use a different name to CreateCommand()
37
void CreatePointsCommands();
39
void loadPointsResource()
41
// add resources and reloads the translators
42
Q_INIT_RESOURCE(Points);
43
Q_INIT_RESOURCE(Points_translation);
44
Gui::Translator::instance()->refresh();
49
class Module: public Py::ExtensionModule<Module>
53
: Py::ExtensionModule<Module>("PointsGui")
55
initialize("This module is the PointsGui module."); // register with Python
61
return Base::Interpreter().addModule(new Module);
64
} // namespace PointsGui
68
PyMOD_INIT_FUNC(PointsGui)
70
if (!Gui::Application::Instance) {
71
PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application.");
72
PyMOD_Return(nullptr);
75
// load dependent module
77
Base::Interpreter().loadModule("Points");
79
catch (const Base::Exception& e) {
80
PyErr_SetString(PyExc_ImportError, e.what());
81
PyMOD_Return(nullptr);
84
Base::Console().Log("Loading GUI of Points module... done\n");
85
PyObject* mod = PointsGui::initModule();
87
// instantiating the commands
88
CreatePointsCommands();
91
PointsGui::ViewProviderPoints ::init();
92
PointsGui::ViewProviderScattered ::init();
93
PointsGui::ViewProviderStructured ::init();
94
PointsGui::ViewProviderPython ::init();
95
PointsGui::Workbench ::init();
97
Gui::ViewProviderBuilder::add(Points::PropertyPointKernel::getClassTypeId(),
98
PointsGui::ViewProviderPoints::getClassTypeId());
100
// add resources and reloads the translators
101
loadPointsResource();