00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034 import FreeCAD, FreeCADGui
00035
00036
00037 Gui = FreeCADGui
00038
00039
00040 class Workbench:
00041 """The workbench base class."""
00042 Icon = """
00043 /* XPM */
00044 static const char *FCIcon[]={
00045 "16 16 4 1",
00046 ". c None",
00047 "# c #000000",
00048 "a c #848284",
00049 "b c #ff0000",
00050 "........#.......",
00051 ".......##aaaaaa.",
00052 "........#.....a.",
00053 ".#######......a.",
00054 ".##...........a.",
00055 ".##...bbbb....a.",
00056 ".##..bb..bb...a.",
00057 ".###bb#...b..###",
00058 ".##.bb........#.",
00059 ".##.bb..........",
00060 ".##.bb..........",
00061 ".##.bb..........",
00062 ".##.bb....b.....",
00063 ".....bb..bb.....",
00064 "......bbbb......",
00065 "................"};
00066 """
00067 MenuText = ""
00068 ToolTip = ""
00069
00070 def Initialize(self):
00071 """Initializes this workbench."""
00072 App.PrintWarning(str(self) + ": Workbench.Initialize() not implemented in subclass!")
00073 def ContextMenu(self, recipient):
00074 pass
00075 def appendToolbar(self,name,cmds):
00076 self.__Workbench__.appendToolbar(name, cmds)
00077 def removeToolbar(self,name):
00078 self.__Workbench__.removeToolbar(name)
00079 def appendCommandbar(self,name,cmds):
00080 self.__Workbench__.appendCommandbar(name, cmds)
00081 def removeCommandbar(self,name):
00082 self.__Workbench__.removeCommandbar(name)
00083 def appendMenu(self,name,cmds):
00084 self.__Workbench__.appendMenu(name, cmds)
00085 def removeMenu(self,name):
00086 self.__Workbench__.removeMenu(name)
00087 def listMenus(self):
00088 return self.__Workbench__.listMenus()
00089 def appendContextMenu(self,name,cmds):
00090 self.__Workbench__.appendContextMenu(name, cmds)
00091 def removeContextMenu(self,name):
00092 self.__Workbench__.removeContextMenu(name)
00093 def name(self):
00094 return self.__Workbench__.name()
00095 def GetClassName(self):
00096 """Return the name of the associated C++ class."""
00097
00098 return "Gui::PythonWorkbench"
00099
00100
00101 class StandardWorkbench ( Workbench ):
00102 """A workbench defines the tool bars, command bars, menus,
00103 context menu and dockable windows of the main window.
00104 """
00105 def Initialize(self):
00106 """Initialize this workbench."""
00107
00108 Log ('Init: Loading FreeCAD GUI\n')
00109 def GetClassName(self):
00110 """Return the name of the associated C++ class."""
00111 return "Gui::StdWorkbench"
00112
00113 class NoneWorkbench ( Workbench ):
00114 """An empty workbench."""
00115 MenuText = "<none>"
00116 ToolTip = "The default empty workbench"
00117 def Initialize(self):
00118 """Initialize this workbench."""
00119
00120 Log ('Init: Loading FreeCAD GUI\n')
00121 def GetClassName(self):
00122 """Return the name of the associated C++ class."""
00123 return "Gui::NoneWorkbench"
00124
00125 def InitApplications():
00126 import sys,os
00127
00128
00129 ModDirs = FreeCAD.__path__
00130
00131 Log('Init: Searching modules...\n')
00132 ModPar = FreeCAD.ParamGet("System parameter:Modules")
00133 for Dir in ModDirs:
00134 if ((Dir != '') & (Dir != 'CVS') & (Dir != '__init__.py')):
00135 InstallFile = os.path.join(Dir,"InitGui.py")
00136 if (os.path.exists(InstallFile)):
00137 try:
00138 execfile(InstallFile)
00139 except Exception, inst:
00140 Log('Init: Initializing ' + Dir + '... failed\n')
00141 Err('During initialization the error ' + str(inst) + ' occurred in ' + InstallFile + '\n')
00142 else:
00143 Log('Init: Initializing ' + Dir + '... done\n')
00144 else:
00145 Log('Init: Initializing ' + Dir + '(InitGui.py not found)... ignore\n')
00146
00147
00148 Log ('Init: Running FreeCADGuiInit.py start script...\n')
00149
00150
00151
00152
00153 App.GuiUp = 1
00154 App.Gui = FreeCADGui
00155
00156 Gui.addWorkbench(NoneWorkbench())
00157
00158
00159 InitApplications()
00160
00161
00162 Gui.activateWorkbench("NoneWorkbench")
00163
00164
00165 FreeCAD.addImportType("Inventor V2.1 (*.iv)","FreeCADGui")
00166 FreeCAD.addImportType("VRML V2.0 (*.wrl *.vrml *.wrz *.wrl.gz)","FreeCADGui")
00167 FreeCAD.addImportType("Python (*.py *.FCMacro *.FCScript)","FreeCADGui")
00168 FreeCAD.addExportType("Inventor V2.1 (*.iv)","FreeCADGui")
00169 FreeCAD.addExportType("VRML V2.0 (*.wrl *.vrml *.wrz *.wrl.gz)","FreeCADGui")
00170
00171 FreeCAD.addExportType("3D View (*.svg)","FreeCADGui")
00172
00173 del(InitApplications)
00174 del(NoneWorkbench)
00175 del(StandardWorkbench)
00176
00177
00178 Log ('Init: Running FreeCADGuiInit.py start script... done\n')