@@ -91,68 +91,35 @@ def QT_TRANSLATE_NOOP(context, text):
91
91
"Draft will not work as expected.\n " )
92
92
93
93
# Set up command lists
94
- self .cmdList = ["Draft_Line" , "Draft_Wire" , "Draft_Fillet" , "Draft_ArcTools" ,
95
- "Draft_Circle" , "Draft_Ellipse" , "Draft_Rectangle" , "Draft_Polygon" ,
96
- "Draft_BSpline" , "Draft_BezierTools" , "Draft_Point" ,
97
- "Draft_Facebinder" ]
98
-
99
- self .annotation_tools = ["Draft_Text" , "Draft_ShapeString" , "Draft_Dimension" ,
100
- "Draft_Label" ]
101
-
102
- self .modList = ["Draft_Move" , "Draft_Rotate" , "Draft_Offset" ,
103
- "Draft_Trimex" , "Draft_Join" , "Draft_Split" ,
104
- "Draft_Upgrade" , "Draft_Downgrade" , "Draft_Scale" ,
105
- "Draft_Edit" , "Draft_SubelementHighlight" ,
106
- "Draft_WireToBSpline" , "Draft_AddPoint" ,
107
- "Draft_DelPoint" , "Draft_Shape2DView" ,
108
- "Draft_Draft2Sketch" , "Draft_Array" , "Draft_LinkArray" ,
109
- "Draft_PolarArray" , "Draft_CircularArray" ,
110
- "Draft_PathArray" , "Draft_PathLinkArray" , "Draft_PointArray" , "Draft_Clone" ,
111
- "Draft_Drawing" , "Draft_Mirror" , "Draft_Stretch" ]
112
-
113
- self .treecmdList = ["Draft_ApplyStyle" , "Draft_ToggleDisplayMode" ,
114
- "Draft_AddToGroup" , "Draft_SelectGroup" ,
115
- "Draft_SelectPlane" , "Draft_ShowSnapBar" ,
116
- "Draft_ToggleGrid" , "Draft_AutoGroup" ]
117
-
118
- self .lineList = ["Draft_UndoLine" , "Draft_FinishLine" ,
119
- "Draft_CloseLine" ]
120
-
121
- self .utils = ["Draft_Layer" , "Draft_Heal" , "Draft_FlipDimension" ,
122
- "Draft_ToggleConstructionMode" ,
123
- "Draft_ToggleContinueMode" , "Draft_Edit" ,
124
- "Draft_Slope" , "Draft_SetWorkingPlaneProxy" ,
125
- "Draft_AddConstruction" ]
126
-
127
- self .snapList = ['Draft_Snap_Lock' , 'Draft_Snap_Midpoint' ,
128
- 'Draft_Snap_Perpendicular' ,
129
- 'Draft_Snap_Grid' , 'Draft_Snap_Intersection' ,
130
- 'Draft_Snap_Parallel' ,
131
- 'Draft_Snap_Endpoint' , 'Draft_Snap_Angle' ,
132
- 'Draft_Snap_Center' ,
133
- 'Draft_Snap_Extension' , 'Draft_Snap_Near' ,
134
- 'Draft_Snap_Ortho' , 'Draft_Snap_Special' ,
135
- 'Draft_Snap_Dimensions' , 'Draft_Snap_WorkingPlane' ]
94
+ import draftutils .init_tools as it
95
+ self .drawing_commands = it .get_draft_drawing_commands ()
96
+ self .annotation_commands = it .get_draft_annotation_commands ()
97
+ self .modification_commands = it .get_draft_modification_commands ()
98
+ self .context_commands = it .get_draft_context_commands ()
99
+ self .line_commands = it .get_draft_line_commands ()
100
+ self .utility_commands = it .get_draft_utility_commands ()
136
101
137
102
# Set up toolbars
138
- self .appendToolbar ("Draft creation tools" , self .cmdList )
139
- self .appendToolbar ("Draft annotation tools" , self .annotation_tools )
140
- self .appendToolbar ("Draft modification tools" , self .modList )
103
+ self .appendToolbar (QT_TRANSLATE_NOOP ( "Draft" , "Draft creation tools") , self .drawing_commands )
104
+ self .appendToolbar (QT_TRANSLATE_NOOP ( "Draft" , "Draft annotation tools") , self .annotation_commands )
105
+ self .appendToolbar (QT_TRANSLATE_NOOP ( "Draft" , "Draft modification tools") , self .modification_commands )
141
106
142
- # Set up menu
143
- self .appendMenu (QT_TRANSLATE_NOOP ("draft" , "&2D Drafting" ),self .cmdList )
144
- self .appendMenu (QT_TRANSLATE_NOOP ("draft" , "&Modify " ),self .modList )
145
- self .appendMenu (QT_TRANSLATE_NOOP ("draft" , "&Annotation " ),self .annotation_tools )
146
- self .appendMenu (QT_TRANSLATE_NOOP ("draft " , "&Utilities" ), self .utils + self .treecmdList )
107
+ # Set up menus
108
+ self .appendMenu (QT_TRANSLATE_NOOP ("Draft" , "& Drafting" ), self .drawing_commands )
109
+ self .appendMenu (QT_TRANSLATE_NOOP ("Draft" , "&Annotation " ), self .annotation_commands )
110
+ self .appendMenu (QT_TRANSLATE_NOOP ("Draft" , "&Modification " ), self .modification_commands )
111
+ self .appendMenu (QT_TRANSLATE_NOOP ("Draft " , "&Utilities" ), self .utility_commands + self .context_commands )
147
112
113
+ # Set up preferences pages
148
114
if hasattr (FreeCADGui , "draftToolBar" ):
149
115
if not hasattr (FreeCADGui .draftToolBar , "loadedPreferences" ):
150
- FreeCADGui .addPreferencePage (":/ui/preferences-draft.ui" , QT_TRANSLATE_NOOP ("draft " , "Draft" ))
151
- FreeCADGui .addPreferencePage (":/ui/preferences-draftsnap.ui" , QT_TRANSLATE_NOOP ("draft " , "Draft" ))
152
- FreeCADGui .addPreferencePage (":/ui/preferences-draftvisual.ui" , QT_TRANSLATE_NOOP ("draft " , "Draft" ))
153
- FreeCADGui .addPreferencePage (":/ui/preferences-drafttexts.ui" , QT_TRANSLATE_NOOP ("draft " , "Draft" ))
116
+ FreeCADGui .addPreferencePage (":/ui/preferences-draft.ui" , QT_TRANSLATE_NOOP ("Draft " , "Draft" ))
117
+ FreeCADGui .addPreferencePage (":/ui/preferences-draftsnap.ui" , QT_TRANSLATE_NOOP ("Draft " , "Draft" ))
118
+ FreeCADGui .addPreferencePage (":/ui/preferences-draftvisual.ui" , QT_TRANSLATE_NOOP ("Draft " , "Draft" ))
119
+ FreeCADGui .addPreferencePage (":/ui/preferences-drafttexts.ui" , QT_TRANSLATE_NOOP ("Draft " , "Draft" ))
154
120
FreeCADGui .draftToolBar .loadedPreferences = True
155
- FreeCAD .Console .PrintLog ('Loading Draft module, done.\n ' )
121
+
122
+ FreeCAD .Console .PrintLog ('Loading Draft workbench, done.\n ' )
156
123
157
124
def Activated (self ):
158
125
"""When entering the workbench."""
@@ -176,17 +143,17 @@ def ContextMenu(self, recipient):
176
143
if recipient == "View" :
177
144
if FreeCAD .activeDraftCommand is None :
178
145
if FreeCADGui .Selection .getSelection ():
179
- self .appendContextMenu ("Draft" , self .cmdList + self .modList )
180
- self .appendContextMenu ("Utilities" , self .treecmdList )
146
+ self .appendContextMenu ("Draft" , self .drawing_commands + self .modification_commands )
147
+ self .appendContextMenu ("Utilities" , self .context_commands )
181
148
else :
182
- self .appendContextMenu ("Draft" , self .cmdList )
149
+ self .appendContextMenu ("Draft" , self .drawing_commands )
183
150
else :
184
151
if FreeCAD .activeDraftCommand .featureName == translate ("draft" ,"Line" ):
185
152
# BUG: line subcommands are not usable while another command is active
186
- self .appendContextMenu ("" , self .lineList )
153
+ self .appendContextMenu ("" , self .line_commands )
187
154
else :
188
155
if FreeCADGui .Selection .getSelection ():
189
- self .appendContextMenu ("Utilities" , self .treecmdList )
156
+ self .appendContextMenu ("Utilities" , self .context_commands )
190
157
191
158
def GetClassName (self ):
192
159
"""Type of workbench."""
@@ -198,9 +165,10 @@ def GetClassName(self):
198
165
# Preference pages for importing and exporting various file formats
199
166
# are independent of the loading of the workbench and can be loaded at startup
200
167
import Draft_rc
201
- FreeCADGui .addPreferencePage (":/ui/preferences-dxf.ui" , "Import-Export" )
202
- FreeCADGui .addPreferencePage (":/ui/preferences-dwg.ui" , "Import-Export" )
203
- FreeCADGui .addPreferencePage (":/ui/preferences-svg.ui" , "Import-Export" )
204
- FreeCADGui .addPreferencePage (":/ui/preferences-oca.ui" , "Import-Export" )
168
+ from PySide .QtCore import QT_TRANSLATE_NOOP
169
+ FreeCADGui .addPreferencePage (":/ui/preferences-dxf.ui" , QT_TRANSLATE_NOOP ("Draft" , "Import-Export" ))
170
+ FreeCADGui .addPreferencePage (":/ui/preferences-dwg.ui" , QT_TRANSLATE_NOOP ("Draft" , "Import-Export" ))
171
+ FreeCADGui .addPreferencePage (":/ui/preferences-svg.ui" , QT_TRANSLATE_NOOP ("Draft" , "Import-Export" ))
172
+ FreeCADGui .addPreferencePage (":/ui/preferences-oca.ui" , QT_TRANSLATE_NOOP ("Draft" , "Import-Export" ))
205
173
206
174
FreeCAD .__unit_test__ += ["TestDraft" ]
0 commit comments