Site.py

Go to the documentation of this file.
00001 #***************************************************************************
00002 #*                                                                         *
00003 #*   Copyright (c) 2011                                                    *  
00004 #*   Yorik van Havre <yorik@uncreated.net>                                 *  
00005 #*                                                                         *
00006 #*   This program is free software; you can redistribute it and/or modify  *
00007 #*   it under the terms of the GNU General Public License (GPL)            *
00008 #*   as published by the Free Software Foundation; either version 2 of     *
00009 #*   the License, or (at your option) any later version.                   *
00010 #*   for detail see the LICENCE text file.                                 *
00011 #*                                                                         *
00012 #*   This program is distributed in the hope that it will be useful,       *
00013 #*   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00014 #*   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00015 #*   GNU Library General Public License for more details.                  *
00016 #*                                                                         *
00017 #*   You should have received a copy of the GNU Library General Public     *
00018 #*   License along with this program; if not, write to the Free Software   *
00019 #*   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  *
00020 #*   USA                                                                   *
00021 #*                                                                         *
00022 #***************************************************************************
00023 
00024 import Cell,FreeCAD,FreeCADGui
00025 from PyQt4 import QtCore
00026 
00027 __title__="FreeCAD Site"
00028 __author__ = "Yorik van Havre"
00029 __url__ = "http://free-cad.sourceforge.net"
00030 
00031 def makeSite(objectslist,name="Site"):
00032     '''makeBuilding(objectslist): creates a site including the
00033     objects from the given list.'''
00034     obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
00035     Site(obj)
00036     ViewProviderSite(obj.ViewObject)
00037     obj.Components = objectslist
00038     obj.JoinMode = False
00039     return obj
00040 
00041 class CommandSite:
00042     "the Arch Site command definition"
00043     def GetResources(self):
00044         return {'Pixmap'  : 'Arch_Site',
00045                 'MenuText': QtCore.QT_TRANSLATE_NOOP("Arch_Site","Site"),
00046                 'Accel': "S, I",
00047                 'ToolTip': QtCore.QT_TRANSLATE_NOOP("Arch_Site","Creates a site object including selected objects.")}
00048         
00049     def Activated(self):
00050         FreeCAD.ActiveDocument.openTransaction("Site")
00051         makeSite(FreeCADGui.Selection.getSelection())
00052         FreeCAD.ActiveDocument.commitTransaction()
00053 
00054 class Site(Cell.Cell):
00055     "The Site object"
00056     def __init__(self,obj):
00057         Cell.Cell.__init__(self,obj)
00058         self.Type = "Site"
00059         
00060     def execute(self,obj):
00061         pass
00062         
00063     def onChanged(self,obj,prop):
00064         pass
00065     
00066 class ViewProviderSite(Cell.ViewProviderCell):
00067     "A View Provider for the Site object"
00068     def __init__(self,vobj):
00069         Cell.ViewProviderCell.__init__(self,vobj)
00070 
00071     def getIcon(self):
00072         return """
00073                 /* XPM */
00074                 static char * Arch_Site_xpm[] = {
00075                 "16 16 9 1",
00076                 "       c None",
00077                 ".      c #49370C",
00078                 "+      c #204F0E",
00079                 "@      c #535219",
00080                 "#      c #6F551D",
00081                 "$      c #127210",
00082                 "%      c #049512",
00083                 "&      c #08BD16",
00084                 "*      c #00EB1B",
00085                 "        +$++    ",
00086                 "       $%%%$++++",
00087                 "      $&&%%$$$+@",
00088                 "     $&&&%%$$+@.",
00089                 "     &&&&%%$$+#.",
00090                 "    $*&&&%%$+##.",
00091                 "    &*&&&%%$@##.",
00092                 "   %**&&&%%+###.",
00093                 "  %***&&&%$@###.",
00094                 " %****&&&%+##.  ",
00095                 "+&****&&&$@#.   ",
00096                 ".#+%&*&&$@#.    ",
00097                 " ..#@$%$@#.     ",
00098                 "   ..#@@.       ",
00099                 "      ..        ",
00100                 "                "};
00101                 """
00102 
00103 FreeCADGui.addCommand('Arch_Site',CommandSite())

Generated on Wed Nov 23 19:00:37 2011 for FreeCAD by  doxygen 1.6.1