00001 const char FreeCADGuiInit[] ="# FreeCAD gui init module\n" 00002 "# (c) 2003 Jürgen Riegel\n" 00003 "#\n" 00004 "# Gathering all the information to start FreeCAD\n" 00005 "# This is the second one of three init scripts, the third one\n" 00006 "# runs when the gui is up\n" 00007 "\n" 00008 "#***************************************************************************\n" 00009 "#* (c) Jürgen Riegel (juergen.riegel@web.de) 2002 *\n" 00010 "#* *\n" 00011 "#* This file is part of the FreeCAD CAx development system. *\n" 00012 "#* *\n" 00013 "#* This program is free software; you can redistribute it and/or modify *\n" 00014 "#* it under the terms of the GNU General Public License (GPL) *\n" 00015 "#* as published by the Free Software Foundation; either version 2 of *\n" 00016 "#* the License, or (at your option) any later version. *\n" 00017 "#* for detail see the LICENCE text file. *\n" 00018 "#* *\n" 00019 "#* FreeCAD is distributed in the hope that it will be useful, *\n" 00020 "#* but WITHOUT ANY WARRANTY; without even the implied warranty of *\n" 00021 "#* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *\n" 00022 "#* GNU Library General Public License for more details. *\n" 00023 "#* *\n" 00024 "#* You should have received a copy of the GNU Library General Public *\n" 00025 "#* License along with FreeCAD; if not, write to the Free Software *\n" 00026 "#* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *\n" 00027 "#* USA *\n" 00028 "#* *\n" 00029 "#* Juergen Riegel 2002 *\n" 00030 "#***************************************************************************/\n" 00031 "\n" 00032 "\n" 00033 "# imports the one and only\n" 00034 "import FreeCAD, FreeCADGui\n" 00035 "\n" 00036 "# shortcuts\n" 00037 "Gui = FreeCADGui\n" 00038 "\n" 00039 "# Important definitions\n" 00040 "class Workbench:\n" 00041 " \"\"\"The workbench base class.\"\"\"\n" 00042 " Icon = \"\"\"\n" 00043 " /* XPM */\n" 00044 " static const char *FCIcon[]={\n" 00045 " \"16 16 4 1\",\n" 00046 " \". c None\",\n" 00047 " \"# c #000000\",\n" 00048 " \"a c #848284\",\n" 00049 " \"b c #ff0000\",\n" 00050 " \"........#.......\",\n" 00051 " \".......##aaaaaa.\",\n" 00052 " \"........#.....a.\",\n" 00053 " \".#######......a.\",\n" 00054 " \".##...........a.\",\n" 00055 " \".##...bbbb....a.\",\n" 00056 " \".##..bb..bb...a.\",\n" 00057 " \".###bb#...b..###\",\n" 00058 " \".##.bb........#.\",\n" 00059 " \".##.bb..........\",\n" 00060 " \".##.bb..........\",\n" 00061 " \".##.bb..........\",\n" 00062 " \".##.bb....b.....\",\n" 00063 " \".....bb..bb.....\",\n" 00064 " \"......bbbb......\",\n" 00065 " \"................\"};\n" 00066 " \"\"\"\n" 00067 " MenuText = \"\"\n" 00068 " ToolTip = \"\"\n" 00069 "\n" 00070 " def Initialize(self):\n" 00071 " \"\"\"Initializes this workbench.\"\"\"\n" 00072 " App.PrintWarning(str(self) + \": Workbench.Initialize() not implemented in subclass!\")\n" 00073 " def ContextMenu(self, recipient):\n" 00074 " pass\n" 00075 " def appendToolbar(self,name,cmds):\n" 00076 " self.__Workbench__.appendToolbar(name, cmds)\n" 00077 " def removeToolbar(self,name):\n" 00078 " self.__Workbench__.removeToolbar(name)\n" 00079 " def appendCommandbar(self,name,cmds):\n" 00080 " self.__Workbench__.appendCommandbar(name, cmds)\n" 00081 " def removeCommandbar(self,name):\n" 00082 " self.__Workbench__.removeCommandbar(name)\n" 00083 " def appendMenu(self,name,cmds):\n" 00084 " self.__Workbench__.appendMenu(name, cmds)\n" 00085 " def removeMenu(self,name):\n" 00086 " self.__Workbench__.removeMenu(name)\n" 00087 " def listMenus(self):\n" 00088 " return self.__Workbench__.listMenus()\n" 00089 " def appendContextMenu(self,name,cmds):\n" 00090 " self.__Workbench__.appendContextMenu(name, cmds)\n" 00091 " def removeContextMenu(self,name):\n" 00092 " self.__Workbench__.removeContextMenu(name)\n" 00093 " def name(self):\n" 00094 " return self.__Workbench__.name()\n" 00095 " def GetClassName(self):\n" 00096 " \"\"\"Return the name of the associated C++ class.\"\"\"\n" 00097 " # as default use this to simplify writing workbenches in Python\n" 00098 " return \"Gui::PythonWorkbench\"\n" 00099 "\n" 00100 "\n" 00101 "class StandardWorkbench ( Workbench ):\n" 00102 " \"\"\"A workbench defines the tool bars, command bars, menus,\n" 00103 "context menu and dockable windows of the main window.\n" 00104 " \"\"\"\n" 00105 " def Initialize(self):\n" 00106 " \"\"\"Initialize this workbench.\"\"\"\n" 00107 " # load the module\n" 00108 " Log (\'Init: Loading FreeCAD GUI\\n\')\n" 00109 " def GetClassName(self):\n" 00110 " \"\"\"Return the name of the associated C++ class.\"\"\"\n" 00111 " return \"Gui::StdWorkbench\"\n" 00112 "\n" 00113 "class NoneWorkbench ( Workbench ):\n" 00114 " \"\"\"An empty workbench.\"\"\"\n" 00115 " MenuText = \"<none>\"\n" 00116 " ToolTip = \"The default empty workbench\"\n" 00117 " def Initialize(self):\n" 00118 " \"\"\"Initialize this workbench.\"\"\"\n" 00119 " # load the module\n" 00120 " Log (\'Init: Loading FreeCAD GUI\\n\')\n" 00121 " def GetClassName(self):\n" 00122 " \"\"\"Return the name of the associated C++ class.\"\"\"\n" 00123 " return \"Gui::NoneWorkbench\"\n" 00124 "\n" 00125 "def InitApplications():\n" 00126 " import sys,os\n" 00127 " # Searching modules dirs +++++++++++++++++++++++++++++++++++++++++++++++++++\n" 00128 " # (additional module paths are already cached)\n" 00129 " ModDirs = FreeCAD.__path__\n" 00130 " #print ModDirs\n" 00131 " Log(\'Init: Searching modules...\\n\')\n" 00132 " ModPar = FreeCAD.ParamGet(\"System parameter:Modules\")\n" 00133 " for Dir in ModDirs:\n" 00134 " if ((Dir != \'\') & (Dir != \'CVS\') & (Dir != \'__init__.py\')):\n" 00135 " InstallFile = os.path.join(Dir,\"InitGui.py\")\n" 00136 " if (os.path.exists(InstallFile)):\n" 00137 " try:\n" 00138 " execfile(InstallFile)\n" 00139 " except Exception, inst:\n" 00140 " Log(\'Init: Initializing \' + Dir + \'... failed\\n\')\n" 00141 " Err(\'During initialization the error \' + str(inst) + \' occurred in \' + InstallFile + \'\\n\')\n" 00142 " else:\n" 00143 " Log(\'Init: Initializing \' + Dir + \'... done\\n\')\n" 00144 " else:\n" 00145 " Log(\'Init: Initializing \' + Dir + \'(InitGui.py not found)... ignore\\n\')\n" 00146 "\n" 00147 "\n" 00148 "Log (\'Init: Running FreeCADGuiInit.py start script...\\n\')\n" 00149 "\n" 00150 "# init the gui\n" 00151 "\n" 00152 "# signal that the gui is up\n" 00153 "App.GuiUp = 1\n" 00154 "App.Gui = FreeCADGui\n" 00155 "\n" 00156 "Gui.addWorkbench(NoneWorkbench())\n" 00157 "\n" 00158 "# init modules\n" 00159 "InitApplications()\n" 00160 "\n" 00161 "# set standard workbench (needed as fallback)\n" 00162 "Gui.activateWorkbench(\"NoneWorkbench\")\n" 00163 "\n" 00164 "# Register .py, .FCScript and .FCMacro\n" 00165 "FreeCAD.addImportType(\"Inventor V2.1 (*.iv)\",\"FreeCADGui\")\n" 00166 "FreeCAD.addImportType(\"VRML V2.0 (*.wrl *.vrml *.wrz *.wrl.gz)\",\"FreeCADGui\")\n" 00167 "FreeCAD.addImportType(\"Python (*.py *.FCMacro *.FCScript)\",\"FreeCADGui\")\n" 00168 "FreeCAD.addExportType(\"Inventor V2.1 (*.iv)\",\"FreeCADGui\")\n" 00169 "FreeCAD.addExportType(\"VRML V2.0 (*.wrl *.vrml *.wrz *.wrl.gz)\",\"FreeCADGui\")\n" 00170 "#FreeCAD.addExportType(\"IDTF (for 3D PDF) (*.idtf)\",\"FreeCADGui\")\n" 00171 "FreeCAD.addExportType(\"3D View (*.svg)\",\"FreeCADGui\")\n" 00172 "\n" 00173 "del(InitApplications)\n" 00174 "del(NoneWorkbench)\n" 00175 "del(StandardWorkbench)\n" 00176 "\n" 00177 "\n" 00178 "Log (\'Init: Running FreeCADGuiInit.py start script... done\\n\')\n" 00179 ; 00180 00181