diff --git a/src/Mod/Arch/ArchComponent.py b/src/Mod/Arch/ArchComponent.py index ca1d448be807..901afab05a48 100644 --- a/src/Mod/Arch/ArchComponent.py +++ b/src/Mod/Arch/ArchComponent.py @@ -1,7 +1,7 @@ #*************************************************************************** #* * -#* Copyright (c) 2011 * -#* Yorik van Havre * +#* Copyright (c) 2011 * +#* Yorik van Havre * #* * #* This program is free software; you can redistribute it and/or modify * #* it under the terms of the GNU Lesser General Public License (LGPL) * @@ -27,7 +27,7 @@ # Possible roles for IFC objects Roles = ['Undefined','Beam','Chimney','Column','Covering','Curtain Wall', - 'Door','Foundation','Furniture','Hydro Equipment','Electric Equipment', + 'Door','Foundation','Furniture','Hydro Equipment','Electric Equipment', 'Member','Plate','Railing','Ramp','Ramp Flight','Rebar','Pile','Roof','Shading Device','Slab','Space', 'Stair','Stair Flight','Tendon','Wall','Wall Layer','Window'] @@ -40,7 +40,7 @@ else: def translate(ctxt,txt): return txt - + def addToComponent(compobject,addobject,mod=None): '''addToComponent(compobject,addobject,mod): adds addobject @@ -117,31 +117,31 @@ def removeFromComponent(compobject,subobject): compobject.Subtractions = l if (Draft.getType(subobject) != "Window") and (not Draft.isClone(subobject,"Window",True)): subobject.ViewObject.hide() - - + + class SelectionTaskPanel: """A temp taks panel to wait for a selection""" def __init__(self): self.form = QtGui.QLabel() self.form.setText(QtGui.QApplication.translate("Arch", "Please select a base object", None, QtGui.QApplication.UnicodeUTF8)) - + def getStandardButtons(self): return int(QtGui.QDialogButtonBox.Cancel) - + def reject(self): if hasattr(FreeCAD,"ArchObserver"): FreeCADGui.Selection.removeObserver(FreeCAD.ArchObserver) del FreeCAD.ArchObserver return True - - + + class ComponentTaskPanel: '''The default TaskPanel for all Arch components''' def __init__(self): # the panel has a tree widget that contains categories # for the subcomponents, such as additions, subtractions. # the categories are shown only if they are not empty. - + self.obj = None self.attribs = ["Base","Additions","Subtractions","Objects","Components","Axes","Fixtures","Armatures"] self.form = QtGui.QWidget() @@ -156,8 +156,8 @@ def __init__(self): self.grid.addWidget(self.tree, 1, 0, 1, 2) self.tree.setColumnCount(1) self.tree.header().hide() - - # buttons + + # buttons self.addButton = QtGui.QPushButton(self.form) self.addButton.setObjectName("addButton") self.addButton.setIcon(QtGui.QIcon(":/icons/Arch_Add.svg")) @@ -184,7 +184,7 @@ def isAllowedAlterView(self): def getStandardButtons(self): return int(QtGui.QDialogButtonBox.Ok) - + def check(self,wid,col): if not wid.parent(): self.delButton.setEnabled(False) @@ -282,10 +282,10 @@ def retranslateUi(self, TaskPanel): self.treeSubtractions.setText(0,QtGui.QApplication.translate("Arch", "Subtractions", None, QtGui.QApplication.UnicodeUTF8)) self.treeObjects.setText(0,QtGui.QApplication.translate("Arch", "Objects", None, QtGui.QApplication.UnicodeUTF8)) self.treeAxes.setText(0,QtGui.QApplication.translate("Arch", "Axes", None, QtGui.QApplication.UnicodeUTF8)) - self.treeComponents.setText(0,QtGui.QApplication.translate("Arch", "Components", None, QtGui.QApplication.UnicodeUTF8)) + self.treeComponents.setText(0,QtGui.QApplication.translate("Arch", "Components", None, QtGui.QApplication.UnicodeUTF8)) self.treeFixtures.setText(0,QtGui.QApplication.translate("Arch", "Fixtures", None, QtGui.QApplication.UnicodeUTF8)) self.treeArmatures.setText(0,QtGui.QApplication.translate("Arch", "Armatures", None, QtGui.QApplication.UnicodeUTF8)) - + class Component: "The default Arch Component object" def __init__(self,obj): @@ -315,10 +315,10 @@ def __getstate__(self): def __setstate__(self,state): if state: self.Type = state - + def onChanged(self,obj,prop): pass - + def clone(self,obj): "if this object is a clone, sets the shape. Returns True if this is the case" if hasattr(obj,"CloneOf"): @@ -332,7 +332,7 @@ def clone(self,obj): obj.BaseMaterial = obj.CloneOf.BaseMaterial return True return False - + def getSiblings(self,obj): "returns a list of objects with the same type and same base as this object" if not hasattr(obj,"Base"): @@ -396,7 +396,7 @@ def getProfiles(self,obj,noplacement=False): if not DraftGeomUtils.isCoplanar(base.Faces): return [] return [base] - + basewires = [] if not base.Wires: if len(base.Edges) == 1: @@ -519,7 +519,7 @@ def getDefaultValues(self,obj): else: normal = default return normal,length,width,height - + def getPlacement(self,obj): "returns a total placement for the profile of this component" p = FreeCAD.Placement() @@ -548,7 +548,7 @@ def processSubShapes(self,obj,base,placement=None): "Adds additions and subtractions to a base shape" import Draft,Part #print "Processing subshapes of ",obj.Label, " : ",obj.Additions - + if placement: if placement.isNull(): placement = None @@ -558,15 +558,15 @@ def processSubShapes(self,obj,base,placement=None): # treat additions for o in obj.Additions: - + if not base: if o.isDerivedFrom("Part::Feature"): base = o.Shape - else: + else: if base.isNull(): if o.isDerivedFrom("Part::Feature"): base = o.Shape - else: + else: # special case, both walls with coinciding endpoints import ArchWall js = ArchWall.mergeShapes(o,obj) @@ -583,7 +583,7 @@ def processSubShapes(self,obj,base,placement=None): if placement: f.Placement = f.Placement.multiply(placement) base = base.cut(f) - + elif o.isDerivedFrom("Part::Feature"): if o.Shape: if not o.Shape.isNull(): @@ -599,14 +599,14 @@ def processSubShapes(self,obj,base,placement=None): print "Arch: unable to fuse object ",obj.Name, " with ", o.Name else: base = s - + # treat subtractions for o in obj.Subtractions: - + if base: if base.isNull(): base = None - + if base: if (Draft.getType(o) == "Window") or (Draft.isClone(o,"Window",True)): # windows can be additions or subtractions, treated the same way @@ -623,7 +623,7 @@ def processSubShapes(self,obj,base,placement=None): if f: if base.Solids and f.Solids: base = base.cut(f) - + elif o.isDerivedFrom("Part::Feature"): if o.Shape: if not o.Shape.isNull(): @@ -636,7 +636,7 @@ def processSubShapes(self,obj,base,placement=None): except Part.OCCError: print "Arch: unable to cut object ",o.Name, " from ", obj.Name return base - + def applyShape(self,obj,shape,placement): "checks and cleans the given shape, and apply it to the object" if shape: @@ -665,7 +665,7 @@ class ViewProviderComponent: def __init__(self,vobj): vobj.Proxy = self self.Object = vobj.Object - + def updateData(self,obj,prop): #print obj.Name," : updating ",prop if prop == "BaseMaterial": @@ -689,7 +689,7 @@ def updateData(self,obj,prop): obj.ViewObject.update() self.onChanged(obj.ViewObject,"ShapeColor") return - + def getIcon(self): import Arch_rc return ":/icons/Arch_Component.svg" @@ -709,9 +709,10 @@ def onChanged(self,vobj,prop): vobj.update() elif prop == "ShapeColor": # restore DiffuseColor after overridden by ShapeColor - if len(vobj.DiffuseColor) > 1: - d = vobj.DiffuseColor - vobj.DiffuseColor = d + if hasattr(vobj.Object,"DiffuseColor"): + if len(vobj.DiffuseColor) > 1: + d = vobj.DiffuseColor + vobj.DiffuseColor = d return def attach(self,vobj): @@ -767,26 +768,26 @@ def setEdit(self,vobj,mode): taskd.update() FreeCADGui.Control.showDialog(taskd) return True - + def unsetEdit(self,vobj,mode): FreeCADGui.Control.closeDialog() return False - - + + class ArchSelectionObserver: - """ArchSelectionObserver([origin,watched,hide,nextCommand]): The ArchSelectionObserver + """ArchSelectionObserver([origin,watched,hide,nextCommand]): The ArchSelectionObserver object can be added as a selection observer to the FreeCAD Gui. If watched is given (a document object), the observer will be triggered only when that object is selected/unselected. If hide is True, the watched object will be hidden. If origin is given (a document object), that object will have its visibility/selectability restored. If nextCommand is given (a FreeCAD command), it will be executed on leave.""" - + def __init__(self,origin=None,watched=None,hide=True,nextCommand=None): self.origin = origin self.watched = watched self.hide = hide self.nextCommand = nextCommand - + def addSelection(self,document, object, element, position): if not self.watched: FreeCADGui.Selection.removeObserver(FreeCAD.ArchObserver) diff --git a/src/Mod/Arch/ArchEquipment.py b/src/Mod/Arch/ArchEquipment.py index 4b8914f66035..0839f269c584 100644 --- a/src/Mod/Arch/ArchEquipment.py +++ b/src/Mod/Arch/ArchEquipment.py @@ -235,9 +235,9 @@ class _Equipment(ArchComponent.Component): "The Equipment object" def __init__(self,obj): ArchComponent.Component.__init__(self,obj) - obj.addProperty("Part::PropertyPartShape","TopView","Arch",translate("Arch","an optional 2D shape representing a top view of this equipment")) - obj.addProperty("Part::PropertyPartShape","FrontView","Arch",translate("Arch","an optional 2D shape representing a front view of this equipment")) - obj.addProperty("Part::PropertyPartShape","SideView","Arch",translate("Arch","an optional 2D shape representing a side view of this equipment")) + #obj.addProperty("Part::PropertyPartShape","TopView","Arch",translate("Arch","an optional 2D shape representing a top view of this equipment")) + #obj.addProperty("Part::PropertyPartShape","FrontView","Arch",translate("Arch","an optional 2D shape representing a front view of this equipment")) + #obj.addProperty("Part::PropertyPartShape","SideView","Arch",translate("Arch","an optional 2D shape representing a side view of this equipment")) obj.addProperty("App::PropertyString","Model","Arch",translate("Arch","The model description of this equipment")) obj.addProperty("App::PropertyString","Url","Arch",translate("Arch","The url of the product page of this equipment")) self.Type = "Equipment" @@ -248,10 +248,10 @@ def onChanged(self,obj,prop): self.hideSubobjects(obj,prop) def execute(self,obj): - + if self.clone(obj): return - + pl = obj.Placement if obj.Base: if obj.isDerivedFrom("Mesh::Feature"):