Building.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 Building"
00028 __author__ = "Yorik van Havre"
00029 __url__ = "http://free-cad.sourceforge.net"
00030 
00031 def makeBuilding(objectslist,join=False,name="Building"):
00032     '''makeBuilding(objectslist,[joinmode]): creates a building including the
00033     objects from the given list. If joinmode is True, components will be joined.'''
00034     obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
00035     Building(obj)
00036     ViewProviderBuilding(obj.ViewObject)
00037     obj.Components = objectslist
00038     for comp in obj.Components:
00039         comp.ViewObject.hide()
00040     obj.JoinMode = join
00041     return obj
00042 
00043 class CommandBuilding:
00044     "the Arch Building command definition"
00045     def GetResources(self):
00046         return {'Pixmap'  : 'Arch_Building',
00047                 'MenuText': QtCore.QT_TRANSLATE_NOOP("Arch_Building","Building"),
00048                 'Accel': "B, U",
00049                 'ToolTip': QtCore.QT_TRANSLATE_NOOP("Arch_Building","Creates a building object including selected objects.")}
00050         
00051     def Activated(self):
00052         FreeCAD.ActiveDocument.openTransaction("Building")
00053         makeBuilding(FreeCADGui.Selection.getSelection())
00054         FreeCAD.ActiveDocument.commitTransaction()
00055 
00056 class Building(Cell.Cell):
00057     "The Building object"
00058     def __init__(self,obj):
00059         Cell.Cell.__init__(self,obj)
00060         self.Type = "Building"
00061         
00062 class ViewProviderBuilding(Cell.ViewProviderCell):
00063     "A View Provider for the Building object"
00064     def __init__(self,vobj):
00065         Cell.ViewProviderCell.__init__(self,vobj)
00066 
00067     def getIcon(self):
00068         return """
00069                 /* XPM */
00070                 static char * Arch_Building_xpm[] = {
00071                 "16 16 9 1",
00072                 "       c None",
00073                 ".      c #160E0A",
00074                 "+      c #C10007",
00075                 "@      c #FF0006",
00076                 "#      c #8F3F00",
00077                 "$      c #5E5F5D",
00078                 "%      c #7F817E",
00079                 "&      c #A0A29F",
00080                 "*      c #F4F6F3",
00081                 "                ",
00082                 "     ........   ",
00083                 "    ..#@@@@@.   ",
00084                 "   .&&.+@@@@@.  ",
00085                 "  .&**%.@@@@@+. ",
00086                 " .&****..@@@+...",
00087                 ".%******.##..$$.",
00088                 ".&******&.$&**%.",
00089                 ".%*...$**.****% ",
00090                 ".%*..#.**.****% ",
00091                 " %*..#.**.****$ ",
00092                 " $*..#.**.***$. ",
00093                 " $*..#$**.**..  ",
00094                 " .$...$**.&.    ",
00095                 "   .  .$%..     ",
00096                 "        ..      "};
00097                 """
00098 
00099 FreeCADGui.addCommand('Arch_Building',CommandBuilding())

Generated on Wed Nov 23 18:59:59 2011 for FreeCAD by  doxygen 1.6.1