Floor.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 Arch Floor"
00028 __author__ = "Yorik van Havre"
00029 __url__ = "http://free-cad.sourceforge.net"
00030 
00031 def makeFloor(objectslist,join=True,name="Floor"):
00032     '''makeFloor(objectslist,[joinmode]): creates a floor including the
00033     objects from the given list. If joinmode is False, components will
00034     not be joined.'''
00035     obj = FreeCAD.ActiveDocument.addObject("Part::FeaturePython",name)
00036     Floor(obj)
00037     ViewProviderFloor(obj.ViewObject)
00038     obj.Components = objectslist
00039     for comp in obj.Components:
00040         comp.ViewObject.hide()
00041     obj.JoinMode = join
00042     return obj
00043 
00044 class CommandFloor:
00045     "the Arch Cell command definition"
00046     def GetResources(self):
00047         return {'Pixmap'  : 'Arch_Floor',
00048                 'MenuText': QtCore.QT_TRANSLATE_NOOP("Arch_Floor","Floor"),
00049                 'Accel': "F, R",
00050                 'ToolTip': QtCore.QT_TRANSLATE_NOOP("Arch_Floor","Creates a floor object including selected objects")}
00051         
00052     def Activated(self):
00053         FreeCAD.ActiveDocument.openTransaction("Floor")
00054         makeFloor(FreeCADGui.Selection.getSelection())
00055         FreeCAD.ActiveDocument.commitTransaction()
00056 
00057 class Floor(Cell.Cell):
00058     "The Cell object"
00059     def __init__(self,obj):
00060         Cell.Cell.__init__(self,obj)
00061         obj.addProperty("App::PropertyLength","Height","Base",
00062                         "The height of this floor")
00063         self.Type = "Floor"
00064         
00065 class ViewProviderFloor(Cell.ViewProviderCell):
00066     "A View Provider for the Cell object"
00067     def __init__(self,vobj):
00068         Cell.ViewProviderCell.__init__(self,vobj)
00069 
00070     def getIcon(self):
00071         return """
00072                 /* XPM */
00073                 static char * Arch_Floor_xpm[] = {
00074                 "16 16 9 1",
00075                 "       c None",
00076                 ".      c #171817",
00077                 "+      c #2E2876",
00078                 "@      c #545653",
00079                 "#      c #605C98",
00080                 "$      c #959794",
00081                 "%      c #9694BC",
00082                 "&      c #C8C9CC",
00083                 "*      c #F9FBFA",
00084                 "                ",
00085                 "                ",
00086                 "............... ",
00087                 ".&&%&*&%%%%%&*. ",
00088                 ".&++#*#+++++#*. ",
00089                 ".&+%****&+*+#*. ",
00090                 ".&+#%%&*&+*+#*. ",
00091                 ".&++++&**+*+#*. ",
00092                 ".&+%***%%**+.$. ",
00093                 ".&++###*#+#.$@. ",
00094                 ".&++++#*+++.&.. ",
00095                 ".&********&..   ",
00096                 ".$$$$$$$$$@.    ",
00097                 " ..........     ",
00098                 "                ",
00099                 "                "};
00100                 """
00101 
00102 FreeCADGui.addCommand('Arch_Floor',CommandFloor())

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