-
Notifications
You must be signed in to change notification settings - Fork 34
/
InitGui.py
147 lines (131 loc) · 4.57 KB
/
InitGui.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# ***************************************************************************
# * *
# * Copyright (c) 2017 Yorik van Havre <[email protected]> *
# * *
# * 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.1 of *
# * the License, or (at your option) any later version. *
# * for detail see the LICENCE text file. *
# * *
# * This program 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 Library General Public License for more details. *
# * *
# * You should have received a copy of the GNU Library General Public *
# * License along with this program; if not, write to the Free Software *
# * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *
# * USA *
# * *
# ***************************************************************************
"""Gui initialization module for Render Workbench."""
import FreeCAD as App
import FreeCADGui as Gui
# Caveat: do not import Render here (too early, will slow down global startup)
class RenderWorkbench(Gui.Workbench):
"""The Render Workbench."""
def __init__(self):
"""Initialize object."""
# Caveat: do not import Render here
# (too early, will slow down global startup)
# pylint: disable=import-outside-toplevel
import FreeCAD
try:
translate = FreeCAD.Qt.translate
except AttributeError:
translate = lambda _, x: x
self.__class__.MenuText = "Render"
self.__class__.ToolTip = translate(
"Workbench",
"The Render workbench is a modern replacement for "
"the Raytracing workbench",
)
self.__class__.Icon = """
/* XPM */
static char * Render_xpm[] = {
"16 16 33 1",
" c None",
". c #103F06",
"+ c #224702",
"@ c #1A580E",
"# c #2F5600",
"$ c #386402",
"% c #297014",
"& c #416B00",
"* c #537200",
"= c #3C7B0F",
"- c #4B880D",
"; c #579310",
"> c #609702",
", c #858B13",
"' c #6AA20A",
") c #92A709",
"! c #9EA610",
"~ c #ACA137",
"{ c #86B208",
"] c #B6A94A",
"^ c #9DC400",
"/ c #ADC50F",
"( c #B4C31F",
"_ c #C8BD71",
": c #C2C731",
"< c #CAD51A",
"[ c #D7D736",
"} c #E9CD77",
"| c #DCDA50",
"1 c #E5DF6D",
"2 c #EBE581",
"3 c #F4EFA8",
"4 c #F8F4C7",
" ",
" ",
" #*)!~] ",
" &^^<[|2_} ",
" ${{/(|243_ ",
" +;'{{(|2431~ ",
" #->'{(:|11[, ",
" @--;')(::[<, ",
" @==-;'{)(//* ",
" .%%=-;>'{^^# ",
" .@%%=-;>'{; ",
" .@%%=-;>>+ ",
" .@%%=-&+ ",
" .... ",
" ",
" "};
"""
def Initialize(self):
"""Initialize GUI when the workbench is first loaded (callback).
This method is called by FreeCAD framework when the workbench is first
loaded.
"""
# pylint: disable=import-outside-toplevel
from PySide.QtCore import QT_TRANSLATE_NOOP
from Render.utils import translate
from FreeCAD import Console
from FreeCADGui import (
addIconPath,
addPreferencePage,
addLanguagePath,
updateLocale,
)
from Render import RENDER_COMMANDS, ICONDIR, TRANSDIR, PreferencesPage
# Translations
addLanguagePath(TRANSDIR)
updateLocale()
# GUI
self.appendToolbar(
QT_TRANSLATE_NOOP("Workbench", "Render"), RENDER_COMMANDS
)
self.appendMenu(
QT_TRANSLATE_NOOP("Workbench", "&Render"), RENDER_COMMANDS
)
addIconPath(ICONDIR)
addPreferencePage(PreferencesPage, "Render")
msg = translate("Workbench", "Loading Render module... done") + "\n"
Console.PrintLog(msg)
def GetClassName(self): # pylint: disable=no-self-use
"""Provide type of workbench."""
return "Gui::PythonWorkbench"
Gui.addWorkbench(RenderWorkbench)