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
|
||||
|
||||
def updateData(self,obj,prop):
|
||||
#print obj.Name," : updating ",prop
|
||||
if prop == "BaseMaterial":
|
||||
if obj.BaseMaterial:
|
||||
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(",")])
|
||||
if obj.ViewObject:
|
||||
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
|
||||
|
||||
def getIcon(self):
|
||||
|
@ -681,10 +695,22 @@ class ViewProviderComponent:
|
|||
return ":/icons/Arch_Component.svg"
|
||||
|
||||
def onChanged(self,vobj,prop):
|
||||
#print vobj.Object.Name, " : changing ",prop
|
||||
if prop == "Visibility":
|
||||
for obj in vobj.Object.Additions+vobj.Object.Subtractions:
|
||||
if (Draft.getType(obj) == "Window") or (Draft.isClone(obj,"Window",True)):
|
||||
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
|
||||
|
||||
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
|
||||
if length:
|
||||
obj.Length = length
|
||||
obj.ViewObject.ShapeColor = ArchCommands.getDefaultColor("Panel")
|
||||
return obj
|
||||
|
||||
|
||||
|
@ -381,6 +380,7 @@ class _ViewProviderPanel(ArchComponent.ViewProviderComponent):
|
|||
|
||||
def __init__(self,vobj):
|
||||
ArchComponent.ViewProviderComponent.__init__(self,vobj)
|
||||
vobj.ShapeColor = ArchCommands.getDefaultColor("Panel")
|
||||
|
||||
def getIcon(self):
|
||||
import Arch_rc
|
||||
|
|
|
@ -45,7 +45,6 @@ def makeRebar(baseobj,sketch,diameter=None,amount=1,offset=None,name="Rebar"):
|
|||
_Rebar(obj)
|
||||
if FreeCAD.GuiUp:
|
||||
_ViewProviderRebar(obj.ViewObject)
|
||||
obj.ViewObject.ShapeColor = ArchCommands.getDefaultColor("Rebar")
|
||||
if hasattr(sketch,"Support"):
|
||||
if sketch.Support:
|
||||
if isinstance(sketch.Support,tuple):
|
||||
|
@ -248,6 +247,7 @@ class _ViewProviderRebar(ArchComponent.ViewProviderComponent):
|
|||
|
||||
def __init__(self,vobj):
|
||||
ArchComponent.ViewProviderComponent.__init__(self,vobj)
|
||||
vobj.ShapeColor = ArchCommands.getDefaultColor("Rebar")
|
||||
|
||||
def getIcon(self):
|
||||
import Arch_rc
|
||||
|
|
|
@ -298,7 +298,6 @@ def makeStructure(baseobj=None,length=None,width=None,height=None,name="Structur
|
|||
_Structure(obj)
|
||||
if FreeCAD.GuiUp:
|
||||
_ViewProviderStructure(obj.ViewObject)
|
||||
obj.ViewObject.ShapeColor = ArchCommands.getDefaultColor("Structure")
|
||||
if baseobj:
|
||||
obj.Base = baseobj
|
||||
if FreeCAD.GuiUp:
|
||||
|
@ -678,6 +677,7 @@ class _ViewProviderStructure(ArchComponent.ViewProviderComponent):
|
|||
vobj.addProperty("App::PropertyColor","NodeColor","Base","The color of the nodes line")
|
||||
vobj.NodeColor = (1.0,1.0,1.0,1.0)
|
||||
vobj.NodeSize = 6
|
||||
vobj.ShapeColor = ArchCommands.getDefaultColor("Structure")
|
||||
|
||||
def getIcon(self):
|
||||
import Arch_rc
|
||||
|
|
|
@ -49,7 +49,6 @@ def makeWall(baseobj=None,length=None,width=None,height=None,align="Center",face
|
|||
_Wall(obj)
|
||||
if FreeCAD.GuiUp:
|
||||
_ViewProviderWall(obj.ViewObject)
|
||||
obj.ViewObject.ShapeColor = ArchCommands.getDefaultColor("Wall")
|
||||
if baseobj:
|
||||
obj.Base = baseobj
|
||||
if face:
|
||||
|
@ -487,6 +486,7 @@ class _ViewProviderWall(ArchComponent.ViewProviderComponent):
|
|||
|
||||
def __init__(self,vobj):
|
||||
ArchComponent.ViewProviderComponent.__init__(self,vobj)
|
||||
vobj.ShapeColor = ArchCommands.getDefaultColor("Wall")
|
||||
|
||||
def getIcon(self):
|
||||
import Arch_rc
|
||||
|
|
|
@ -781,6 +781,7 @@ class _ViewProviderWindow(ArchComponent.ViewProviderComponent):
|
|||
if obj.Shape:
|
||||
if not obj.Shape.isNull():
|
||||
self.colorize(obj)
|
||||
ArchComponent.ViewProviderComponent.updateData(self,obj,prop)
|
||||
|
||||
def onChanged(self,vobj,prop):
|
||||
if (prop == "DiffuseColor") and vobj.Object:
|
||||
|
@ -788,6 +789,7 @@ class _ViewProviderWindow(ArchComponent.ViewProviderComponent):
|
|||
if vobj.Object.Shape:
|
||||
if not vobj.Object.Shape.isNull():
|
||||
self.colorize(vobj.Object)
|
||||
ArchComponent.ViewProviderComponent.onChanged(self,vobj,prop)
|
||||
|
||||
def setEdit(self,vobj,mode):
|
||||
taskd = _ArchWindowTaskPanel()
|
||||
|
@ -811,10 +813,8 @@ class _ViewProviderWindow(ArchComponent.ViewProviderComponent):
|
|||
|
||||
def colorize(self,obj):
|
||||
"setting different part colors"
|
||||
if hasattr(obj,"CloneOf"):
|
||||
if obj.CloneOf:
|
||||
obj.ViewObject.DiffuseColor = obj.CloneOf.ViewObject.DiffuseColor
|
||||
return
|
||||
if not obj.WindowParts:
|
||||
return
|
||||
solids = obj.Shape.copy().Solids
|
||||
#print "Colorizing ", solids
|
||||
colors = []
|
||||
|
|
Loading…
Reference in New Issue
Block a user