FreeCAD

Форк
0
/
AppPointsGui.cpp 
104 строки · 3.7 Кб
1
/***************************************************************************
2
 *   Copyright (c) 2002 Jürgen Riegel <juergen.riegel@web.de>              *
3
 *                                                                         *
4
 *   This file is part of the FreeCAD CAx development system.              *
5
 *                                                                         *
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.      *
10
 *                                                                         *
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.                  *
15
 *                                                                         *
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                                *
20
 *                                                                         *
21
 ***************************************************************************/
22

23
#include "PreCompiled.h"
24

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>
31

32
#include "ViewProvider.h"
33
#include "Workbench.h"
34

35

36
// use a different name to CreateCommand()
37
void CreatePointsCommands();
38

39
void loadPointsResource()
40
{
41
    // add resources and reloads the translators
42
    Q_INIT_RESOURCE(Points);
43
    Q_INIT_RESOURCE(Points_translation);
44
    Gui::Translator::instance()->refresh();
45
}
46

47
namespace PointsGui
48
{
49
class Module: public Py::ExtensionModule<Module>
50
{
51
public:
52
    Module()
53
        : Py::ExtensionModule<Module>("PointsGui")
54
    {
55
        initialize("This module is the PointsGui module.");  // register with Python
56
    }
57
};
58

59
PyObject* initModule()
60
{
61
    return Base::Interpreter().addModule(new Module);
62
}
63

64
}  // namespace PointsGui
65

66

67
/* Python entry */
68
PyMOD_INIT_FUNC(PointsGui)
69
{
70
    if (!Gui::Application::Instance) {
71
        PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application.");
72
        PyMOD_Return(nullptr);
73
    }
74

75
    // load dependent module
76
    try {
77
        Base::Interpreter().loadModule("Points");
78
    }
79
    catch (const Base::Exception& e) {
80
        PyErr_SetString(PyExc_ImportError, e.what());
81
        PyMOD_Return(nullptr);
82
    }
83

84
    Base::Console().Log("Loading GUI of Points module... done\n");
85
    PyObject* mod = PointsGui::initModule();
86

87
    // instantiating the commands
88
    CreatePointsCommands();
89

90
    // clang-format off
91
    PointsGui::ViewProviderPoints       ::init();
92
    PointsGui::ViewProviderScattered    ::init();
93
    PointsGui::ViewProviderStructured   ::init();
94
    PointsGui::ViewProviderPython       ::init();
95
    PointsGui::Workbench                ::init();
96
    // clang-format on
97
    Gui::ViewProviderBuilder::add(Points::PropertyPointKernel::getClassTypeId(),
98
                                  PointsGui::ViewProviderPoints::getClassTypeId());
99

100
    // add resources and reloads the translators
101
    loadPointsResource();
102

103
    PyMOD_Return(mod);
104
}
105

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.