Arch: Allow to build Arch objects from Part Compounds - fixes #2095
Arch objects can now be based on a Part Compound and will take its DiffuseColor property. Arch objects that are clones of such objects will also copy that property.
This commit is contained in:
parent
d0d98b8775
commit
d0cfe4b010
|
@ -667,6 +667,7 @@ class ViewProviderComponent:
|
||||||
self.Object = vobj.Object
|
self.Object = vobj.Object
|
||||||
|
|
||||||
def updateData(self,obj,prop):
|
def updateData(self,obj,prop):
|
||||||
|
#print obj.Name," : updating ",prop
|
||||||
if prop == "BaseMaterial":
|
if prop == "BaseMaterial":
|
||||||
if obj.BaseMaterial:
|
if obj.BaseMaterial:
|
||||||
if 'Color' in obj.BaseMaterial.Material:
|
if 'Color' in obj.BaseMaterial.Material:
|
||||||
|
@ -674,6 +675,19 @@ class ViewProviderComponent:
|
||||||
c = tuple([float(f) for f in obj.BaseMaterial.Material['Color'].strip("()").split(",")])
|
c = tuple([float(f) for f in obj.BaseMaterial.Material['Color'].strip("()").split(",")])
|
||||||
if obj.ViewObject:
|
if obj.ViewObject:
|
||||||
obj.ViewObject.ShapeColor = c
|
obj.ViewObject.ShapeColor = c
|
||||||
|
elif prop == "Shape":
|
||||||
|
if obj.Base:
|
||||||
|
if obj.Base.isDerivedFrom("Part::Compound"):
|
||||||
|
if obj.ViewObject.DiffuseColor != obj.Base.ViewObject.DiffuseColor:
|
||||||
|
obj.ViewObject.DiffuseColor = obj.Base.ViewObject.DiffuseColor
|
||||||
|
obj.ViewObject.update()
|
||||||
|
self.onChanged(obj.ViewObject,"ShapeColor")
|
||||||
|
elif prop == "CloneOf":
|
||||||
|
if obj.CloneOf:
|
||||||
|
if obj.ViewObject.DiffuseColor != obj.CloneOf.ViewObject.DiffuseColor:
|
||||||
|
obj.ViewObject.DiffuseColor = obj.CloneOf.ViewObject.DiffuseColor
|
||||||
|
obj.ViewObject.update()
|
||||||
|
self.onChanged(obj.ViewObject,"ShapeColor")
|
||||||
return
|
return
|
||||||
|
|
||||||
def getIcon(self):
|
def getIcon(self):
|
||||||
|
@ -681,10 +695,22 @@ class ViewProviderComponent:
|
||||||
return ":/icons/Arch_Component.svg"
|
return ":/icons/Arch_Component.svg"
|
||||||
|
|
||||||
def onChanged(self,vobj,prop):
|
def onChanged(self,vobj,prop):
|
||||||
|
#print vobj.Object.Name, " : changing ",prop
|
||||||
if prop == "Visibility":
|
if prop == "Visibility":
|
||||||
for obj in vobj.Object.Additions+vobj.Object.Subtractions:
|
for obj in vobj.Object.Additions+vobj.Object.Subtractions:
|
||||||
if (Draft.getType(obj) == "Window") or (Draft.isClone(obj,"Window",True)):
|
if (Draft.getType(obj) == "Window") or (Draft.isClone(obj,"Window",True)):
|
||||||
obj.ViewObject.Visibility = vobj.Visibility
|
obj.ViewObject.Visibility = vobj.Visibility
|
||||||
|
elif prop == "DiffuseColor":
|
||||||
|
if hasattr(vobj.Object,"CloneOf"):
|
||||||
|
if vobj.Object.CloneOf:
|
||||||
|
if vobj.DiffuseColor != vobj.Object.CloneOf.ViewObject.DiffuseColor:
|
||||||
|
vobj.DiffuseColor = vobj.Object.CloneOf.ViewObject.DiffuseColor
|
||||||
|
vobj.update()
|
||||||
|
elif prop == "ShapeColor":
|
||||||
|
# restore DiffuseColor after overridden by ShapeColor
|
||||||
|
if len(vobj.DiffuseColor) > 1:
|
||||||
|
d = vobj.DiffuseColor
|
||||||
|
vobj.DiffuseColor = d
|
||||||
return
|
return
|
||||||
|
|
||||||
def attach(self,vobj):
|
def attach(self,vobj):
|
||||||
|
|
|
@ -63,7 +63,6 @@ def makePanel(baseobj=None,length=0,width=0,thickness=0,placement=None,name="Pan
|
||||||
obj.Thickness = thickness
|
obj.Thickness = thickness
|
||||||
if length:
|
if length:
|
||||||
obj.Length = length
|
obj.Length = length
|
||||||
obj.ViewObject.ShapeColor = ArchCommands.getDefaultColor("Panel")
|
|
||||||
return obj
|
return obj
|
||||||
|
|
||||||
|
|
||||||
|
@ -381,6 +380,7 @@ class _ViewProviderPanel(ArchComponent.ViewProviderComponent):
|
||||||
|
|
||||||
def __init__(self,vobj):
|
def __init__(self,vobj):
|
||||||
ArchComponent.ViewProviderComponent.__init__(self,vobj)
|
ArchComponent.ViewProviderComponent.__init__(self,vobj)
|
||||||
|
vobj.ShapeColor = ArchCommands.getDefaultColor("Panel")
|
||||||
|
|
||||||
def getIcon(self):
|
def getIcon(self):
|
||||||
import Arch_rc
|
import Arch_rc
|
||||||
|
|
|
@ -45,7 +45,6 @@ def makeRebar(baseobj,sketch,diameter=None,amount=1,offset=None,name="Rebar"):
|
||||||
_Rebar(obj)
|
_Rebar(obj)
|
||||||
if FreeCAD.GuiUp:
|
if FreeCAD.GuiUp:
|
||||||
_ViewProviderRebar(obj.ViewObject)
|
_ViewProviderRebar(obj.ViewObject)
|
||||||
obj.ViewObject.ShapeColor = ArchCommands.getDefaultColor("Rebar")
|
|
||||||
if hasattr(sketch,"Support"):
|
if hasattr(sketch,"Support"):
|
||||||
if sketch.Support:
|
if sketch.Support:
|
||||||
if isinstance(sketch.Support,tuple):
|
if isinstance(sketch.Support,tuple):
|
||||||
|
@ -248,6 +247,7 @@ class _ViewProviderRebar(ArchComponent.ViewProviderComponent):
|
||||||
|
|
||||||
def __init__(self,vobj):
|
def __init__(self,vobj):
|
||||||
ArchComponent.ViewProviderComponent.__init__(self,vobj)
|
ArchComponent.ViewProviderComponent.__init__(self,vobj)
|
||||||
|
vobj.ShapeColor = ArchCommands.getDefaultColor("Rebar")
|
||||||
|
|
||||||
def getIcon(self):
|
def getIcon(self):
|
||||||
import Arch_rc
|
import Arch_rc
|
||||||
|
|
|
@ -298,7 +298,6 @@ def makeStructure(baseobj=None,length=None,width=None,height=None,name="Structur
|
||||||
_Structure(obj)
|
_Structure(obj)
|
||||||
if FreeCAD.GuiUp:
|
if FreeCAD.GuiUp:
|
||||||
_ViewProviderStructure(obj.ViewObject)
|
_ViewProviderStructure(obj.ViewObject)
|
||||||
obj.ViewObject.ShapeColor = ArchCommands.getDefaultColor("Structure")
|
|
||||||
if baseobj:
|
if baseobj:
|
||||||
obj.Base = baseobj
|
obj.Base = baseobj
|
||||||
if FreeCAD.GuiUp:
|
if FreeCAD.GuiUp:
|
||||||
|
@ -678,6 +677,7 @@ class _ViewProviderStructure(ArchComponent.ViewProviderComponent):
|
||||||
vobj.addProperty("App::PropertyColor","NodeColor","Base","The color of the nodes line")
|
vobj.addProperty("App::PropertyColor","NodeColor","Base","The color of the nodes line")
|
||||||
vobj.NodeColor = (1.0,1.0,1.0,1.0)
|
vobj.NodeColor = (1.0,1.0,1.0,1.0)
|
||||||
vobj.NodeSize = 6
|
vobj.NodeSize = 6
|
||||||
|
vobj.ShapeColor = ArchCommands.getDefaultColor("Structure")
|
||||||
|
|
||||||
def getIcon(self):
|
def getIcon(self):
|
||||||
import Arch_rc
|
import Arch_rc
|
||||||
|
|
|
@ -49,7 +49,6 @@ def makeWall(baseobj=None,length=None,width=None,height=None,align="Center",face
|
||||||
_Wall(obj)
|
_Wall(obj)
|
||||||
if FreeCAD.GuiUp:
|
if FreeCAD.GuiUp:
|
||||||
_ViewProviderWall(obj.ViewObject)
|
_ViewProviderWall(obj.ViewObject)
|
||||||
obj.ViewObject.ShapeColor = ArchCommands.getDefaultColor("Wall")
|
|
||||||
if baseobj:
|
if baseobj:
|
||||||
obj.Base = baseobj
|
obj.Base = baseobj
|
||||||
if face:
|
if face:
|
||||||
|
@ -487,6 +486,7 @@ class _ViewProviderWall(ArchComponent.ViewProviderComponent):
|
||||||
|
|
||||||
def __init__(self,vobj):
|
def __init__(self,vobj):
|
||||||
ArchComponent.ViewProviderComponent.__init__(self,vobj)
|
ArchComponent.ViewProviderComponent.__init__(self,vobj)
|
||||||
|
vobj.ShapeColor = ArchCommands.getDefaultColor("Wall")
|
||||||
|
|
||||||
def getIcon(self):
|
def getIcon(self):
|
||||||
import Arch_rc
|
import Arch_rc
|
||||||
|
|
|
@ -781,6 +781,7 @@ class _ViewProviderWindow(ArchComponent.ViewProviderComponent):
|
||||||
if obj.Shape:
|
if obj.Shape:
|
||||||
if not obj.Shape.isNull():
|
if not obj.Shape.isNull():
|
||||||
self.colorize(obj)
|
self.colorize(obj)
|
||||||
|
ArchComponent.ViewProviderComponent.updateData(self,obj,prop)
|
||||||
|
|
||||||
def onChanged(self,vobj,prop):
|
def onChanged(self,vobj,prop):
|
||||||
if (prop == "DiffuseColor") and vobj.Object:
|
if (prop == "DiffuseColor") and vobj.Object:
|
||||||
|
@ -788,6 +789,7 @@ class _ViewProviderWindow(ArchComponent.ViewProviderComponent):
|
||||||
if vobj.Object.Shape:
|
if vobj.Object.Shape:
|
||||||
if not vobj.Object.Shape.isNull():
|
if not vobj.Object.Shape.isNull():
|
||||||
self.colorize(vobj.Object)
|
self.colorize(vobj.Object)
|
||||||
|
ArchComponent.ViewProviderComponent.onChanged(self,vobj,prop)
|
||||||
|
|
||||||
def setEdit(self,vobj,mode):
|
def setEdit(self,vobj,mode):
|
||||||
taskd = _ArchWindowTaskPanel()
|
taskd = _ArchWindowTaskPanel()
|
||||||
|
@ -811,10 +813,8 @@ class _ViewProviderWindow(ArchComponent.ViewProviderComponent):
|
||||||
|
|
||||||
def colorize(self,obj):
|
def colorize(self,obj):
|
||||||
"setting different part colors"
|
"setting different part colors"
|
||||||
if hasattr(obj,"CloneOf"):
|
if not obj.WindowParts:
|
||||||
if obj.CloneOf:
|
return
|
||||||
obj.ViewObject.DiffuseColor = obj.CloneOf.ViewObject.DiffuseColor
|
|
||||||
return
|
|
||||||
solids = obj.Shape.copy().Solids
|
solids = obj.Shape.copy().Solids
|
||||||
#print "Colorizing ", solids
|
#print "Colorizing ", solids
|
||||||
colors = []
|
colors = []
|
||||||
|
|
Loading…
Reference in New Issue
Block a user