FreeCAD

Форк
0
/
AppTechDrawGui.cpp 
183 строки · 7.5 Кб
1
/***************************************************************************
2
 *   Copyright (c) 2007 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
#ifndef _PreComp_
25
#include <QFontDatabase>
26
#endif
27

28
#include <Base/Console.h>
29
#include <Base/Interpreter.h>
30
#include <Base/Tools.h>
31
#include <Gui/Application.h>
32
#include <Gui/Language/Translator.h>
33
#include <Gui/WidgetFactory.h>
34

35
#include "DlgPrefsTechDrawAdvancedImp.h"
36
#include "DlgPrefsTechDrawAnnotationImp.h"
37
#include "DlgPrefsTechDrawColorsImp.h"
38
#include "DlgPrefsTechDrawDimensionsImp.h"
39
#include "DlgPrefsTechDrawGeneralImp.h"
40
#include "DlgPrefsTechDrawHLRImp.h"
41
#include "DlgPrefsTechDrawScaleImp.h"
42
#include "MDIViewPage.h"
43
#include "ViewProviderAnnotation.h"
44
#include "ViewProviderBalloon.h"
45
#include "ViewProviderCosmeticExtension.h"
46
#include "ViewProviderDimension.h"
47
#include "ViewProviderDrawingView.h"
48
#include "ViewProviderDrawingViewExtension.h"
49
#include "ViewProviderGeomHatch.h"
50
#include "ViewProviderHatch.h"
51
#include "ViewProviderImage.h"
52
#include "ViewProviderLeader.h"
53
#include "ViewProviderPage.h"
54
#include "ViewProviderPageExtension.h"
55
#include "ViewProviderProjGroup.h"
56
#include "ViewProviderProjGroupItem.h"
57
#include "ViewProviderRichAnno.h"
58
#include "ViewProviderSpreadsheet.h"
59
#include "ViewProviderSymbol.h"
60
#include "ViewProviderTemplate.h"
61
#include "ViewProviderTemplateExtension.h"
62
#include "ViewProviderTile.h"
63
#include "ViewProviderViewClip.h"
64
#include "ViewProviderViewPart.h"
65
#include "ViewProviderViewSection.h"
66
#include "ViewProviderWeld.h"
67
#include "Workbench.h"
68

69

70
// use a different name to CreateCommand()
71
void CreateTechDrawCommands();
72
void CreateTechDrawCommandsDims();
73
void CreateTechDrawCommandsDecorate();
74
void CreateTechDrawCommandsAnnotate();
75
void CreateTechDrawCommandsExtensionDims();
76
void CreateTechDrawCommandsExtensions();
77
void CreateTechDrawCommandsStack();
78

79
void loadTechDrawResource()
80
{
81
    // add resources and reloads the translators
82
    Q_INIT_RESOURCE(TechDraw);
83
    Q_INIT_RESOURCE(TechDraw_translation);
84
    Gui::Translator::instance()->refresh();
85

86
    // add fonts
87
    std::string fontDir = App::Application::getResourceDir() + "Mod/TechDraw/Resources/fonts/";
88

89
    std::vector<std::string> fontsAll(
90
        {"osifont-lgpl3fe.ttf", "osifont-italic.ttf", "Y14.5-2018.ttf", "Y14.5-FreeCAD.ttf"});
91

92
    for (auto& font : fontsAll) {
93
        QString fontFile = Base::Tools::fromStdString(fontDir + font);
94
        int rc = QFontDatabase::addApplicationFont(fontFile);
95
        if (rc < 0) {
96
            Base::Console().Warning(
97
                "TechDraw failed to load font file: %d from: %s\n", rc, qPrintable(fontFile));
98
        }
99
    }
100
}
101

102
namespace TechDrawGui
103
{
104
extern PyObject* initModule();
105
}
106

107
/* Python entry */
108
PyMOD_INIT_FUNC(TechDrawGui)
109
{
110
    if (!Gui::Application::Instance) {
111
        PyErr_SetString(PyExc_ImportError, "Cannot load Gui module in console application.");
112
        PyMOD_Return(nullptr);
113
    }
114
    // load dependent module
115
    try {
116
        Base::Interpreter().loadModule("TechDraw");
117
    }
118
    catch (const Base::Exception& e) {
119
        PyErr_SetString(PyExc_ImportError, e.what());
120
        PyMOD_Return(nullptr);
121
    }
122
    PyObject* mod = TechDrawGui::initModule();
123

124
    Base::Console().Log("Loading TechDrawGui module... done\n");
125

126
    // instantiating the commands
127
    CreateTechDrawCommands();
128
    CreateTechDrawCommandsDims();
129
    CreateTechDrawCommandsDecorate();
130
    CreateTechDrawCommandsAnnotate();
131
    CreateTechDrawCommandsExtensionDims();
132
    CreateTechDrawCommandsExtensions();
133
    CreateTechDrawCommandsStack();
134

135
    TechDrawGui::Workbench::init();
136
    TechDrawGui::MDIViewPage::init();
137
    TechDrawGui::MDIViewPagePy::init_type();
138

139
    TechDrawGui::ViewProviderPage::init();
140
    TechDrawGui::ViewProviderDrawingView::init();
141

142
    TechDrawGui::ViewProviderTemplate::init();
143
    TechDrawGui::ViewProviderDimension::init();
144
    TechDrawGui::ViewProviderBalloon::init();
145
    TechDrawGui::ViewProviderViewPart::init();
146
    TechDrawGui::ViewProviderProjGroupItem::init();
147
    TechDrawGui::ViewProviderProjGroup::init();
148
    TechDrawGui::ViewProviderViewSection::init();
149
    TechDrawGui::ViewProviderViewClip::init();
150
    TechDrawGui::ViewProviderAnnotation::init();
151
    TechDrawGui::ViewProviderSymbol::init();
152
    TechDrawGui::ViewProviderDraft::init();
153
    TechDrawGui::ViewProviderArch::init();
154
    TechDrawGui::ViewProviderHatch::init();
155
    TechDrawGui::ViewProviderGeomHatch::init();
156
    TechDrawGui::ViewProviderSpreadsheet::init();
157
    TechDrawGui::ViewProviderImage::init();
158
    TechDrawGui::ViewProviderLeader::init();
159
    TechDrawGui::ViewProviderRichAnno::init();
160
    TechDrawGui::ViewProviderTile::init();
161
    TechDrawGui::ViewProviderWeld::init();
162

163
    TechDrawGui::ViewProviderPageExtension ::init();
164
    //    TechDrawGui::ViewProviderPageExtensionPython::init();
165
    TechDrawGui::ViewProviderDrawingViewExtension::init();
166
    TechDrawGui::ViewProviderTemplateExtension::init();
167

168
    TechDrawGui::ViewProviderCosmeticExtension::init();
169

170
    // register preferences pages
171
    new Gui::PrefPageProducer<TechDrawGui::DlgPrefsTechDrawGeneralImp>(QT_TRANSLATE_NOOP("QObject", "TechDraw"));   //General
172
    new Gui::PrefPageProducer<TechDrawGui::DlgPrefsTechDrawScaleImp>(QT_TRANSLATE_NOOP("QObject", "TechDraw"));     //Scale
173
    new Gui::PrefPageProducer<TechDrawGui::DlgPrefsTechDrawDimensionsImp>(QT_TRANSLATE_NOOP("QObject", "TechDraw"));//Dimensions
174
    new Gui::PrefPageProducer<TechDrawGui::DlgPrefsTechDrawAnnotationImp>(QT_TRANSLATE_NOOP("QObject", "TechDraw"));//Annotation
175
    new Gui::PrefPageProducer<TechDrawGui::DlgPrefsTechDrawColorsImp>(QT_TRANSLATE_NOOP("QObject", "TechDraw"));    //Colors
176
    new Gui::PrefPageProducer<TechDrawGui::DlgPrefsTechDrawHLRImp>(QT_TRANSLATE_NOOP("QObject", "TechDraw"));       //HLR
177
    new Gui::PrefPageProducer<TechDrawGui::DlgPrefsTechDrawAdvancedImp>(QT_TRANSLATE_NOOP("QObject", "TechDraw"));  //Advanced
178

179
    // add resources and reloads the translators
180
    loadTechDrawResource();
181

182
    PyMOD_Return(mod);
183
}
184

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

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

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

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