Material: Material appearance
Uses new material system for appearance Each feature object now has a property called ShapeMaterial that describes its physical properties. If it has a shape, it has a material. The ShapeColor attribute is replaced by a ShapeAppearance attribute. This is a material list that describes all appearance properties, not just diffuse color. As a list in can be used for all elements of a shape, such as edges and faces. A new widget is provided to allow the user to select materials in a consistent fashion. It can also launch the material editor with its more advanced capabilities.
This commit is contained in:
committed by
Chris Hennes
parent
37c38acd19
commit
ba20441935
@@ -607,7 +607,7 @@ class ViewProviderBuildingPart:
|
||||
vobj.addProperty("App::PropertyColor","ChildrenLineColor","Children",QT_TRANSLATE_NOOP("App::Property","The line color of child objects"))
|
||||
vobj.ChildrenLineColor = params.get_param_view("DefaultShapeLineColor") & 0xFFFFFF00
|
||||
if not "ChildrenShapeColor" in pl:
|
||||
vobj.addProperty("App::PropertyColor","ChildrenShapeColor","Children",QT_TRANSLATE_NOOP("App::Property","The shape color of child objects"))
|
||||
vobj.addProperty("App::PropertyMaterial","ChildrenShapeColor","Children",QT_TRANSLATE_NOOP("App::Property","The shape appearance of child objects"))
|
||||
vobj.ChildrenShapeColor = params.get_param_view("DefaultShapeColor") & 0xFFFFFF00
|
||||
if not "ChildrenTransparency" in pl:
|
||||
vobj.addProperty("App::PropertyPercent","ChildrenTransparency","Children",QT_TRANSLATE_NOOP("App::Property","The transparency of child objects"))
|
||||
|
||||
@@ -1217,7 +1217,6 @@ class ViewProviderComponent:
|
||||
if len(obj.Base.ViewObject.DiffuseColor) > 1:
|
||||
obj.ViewObject.DiffuseColor = obj.Base.ViewObject.DiffuseColor
|
||||
obj.ViewObject.update()
|
||||
#self.onChanged(obj.ViewObject,"ShapeColor")
|
||||
elif prop == "CloneOf":
|
||||
if obj.CloneOf:
|
||||
mat = None
|
||||
@@ -1229,7 +1228,6 @@ class ViewProviderComponent:
|
||||
if len(obj.CloneOf.ViewObject.DiffuseColor) > 1:
|
||||
obj.ViewObject.DiffuseColor = obj.CloneOf.ViewObject.DiffuseColor
|
||||
obj.ViewObject.update()
|
||||
#self.onChanged(obj.ViewObject,"ShapeColor")
|
||||
return
|
||||
|
||||
def getIcon(self):
|
||||
|
||||
@@ -302,7 +302,7 @@ class _ViewProviderFence(ArchComponent.ViewProviderComponent):
|
||||
|
||||
def applyColors(self, obj):
|
||||
if not hasattr(obj.ViewObject, "UseOriginalColors") or not obj.ViewObject.UseOriginalColors:
|
||||
obj.ViewObject.DiffuseColor = [obj.ViewObject.ShapeColor]
|
||||
obj.ViewObject.DiffuseColor = [obj.ViewObject.ShapeAppeaarance.DiffuseColor]
|
||||
else:
|
||||
post = obj.Post
|
||||
section = obj.Section
|
||||
|
||||
@@ -458,7 +458,7 @@ class ViewProviderArchReference:
|
||||
def onChanged(self,vobj,prop):
|
||||
|
||||
if prop == "ShapeColor":
|
||||
# prevent ShapeColor to override DiffuseColor
|
||||
# prevent ShapeColor from overriding DiffuseColor
|
||||
if hasattr(vobj,"DiffuseColor") and hasattr(vobj,"UpdateColors"):
|
||||
if vobj.DiffuseColor and vobj.UpdateColors:
|
||||
vobj.DiffuseColor = vobj.DiffuseColor
|
||||
|
||||
@@ -727,7 +727,7 @@ class _ViewProviderSpace(ArchComponent.ViewProviderComponent):
|
||||
|
||||
elif prop == "ShapeColor":
|
||||
if hasattr(vobj,"ShapeColor"):
|
||||
self.fmat.diffuseColor.setValue((vobj.ShapeColor[0],vobj.ShapeColor[1],vobj.ShapeColor[2]))
|
||||
self.fmat = vobj.ShapeColor.getValue()
|
||||
|
||||
elif prop == "Transparency":
|
||||
if hasattr(vobj,"Transparency"):
|
||||
|
||||
@@ -200,7 +200,7 @@ def getGuiData(filename):
|
||||
|
||||
"""getGuiData(filename): Extract visual data from a saved FreeCAD file.
|
||||
Returns a dictionary ["objectName:dict] where dict contains properties
|
||||
keys like ShapeColor, Transparency, DiffuseColor or Visibility. If found,
|
||||
keys like ShapeAppearaance, Transparency, DiffuseColor or Visibility. If found,
|
||||
also contains a GuiCameraSettings key with an iv repr of a coin camera"""
|
||||
|
||||
guidata = {}
|
||||
@@ -310,7 +310,7 @@ def getStepData(objects,colors):
|
||||
if obj.Name in colors:
|
||||
color = colors[obj.Name]
|
||||
if isinstance(color,tuple):
|
||||
# this is a ShapeColor. We reformat as a list so it works as a DiffuseColor,
|
||||
# this is a ShapeAppeaaraance. We reformat as a list so it works as a DiffuseColor,
|
||||
# which is what the exporter expects. DiffuseColor can have either one color,
|
||||
# or the same number of colors as the number of faces
|
||||
color = [color]
|
||||
|
||||
@@ -242,7 +242,7 @@ def export(exportList,filename,colors=None):
|
||||
outfile.write("usemtl color_" + mn + "\n")
|
||||
materials.append(("color_" + mn,color,0))
|
||||
elif FreeCAD.GuiUp:
|
||||
if hasattr(obj.ViewObject,"ShapeColor") and hasattr(obj.ViewObject,"Transparency"):
|
||||
if hasattr(obj.ViewObject,"ShapeAppearnce") and hasattr(obj.ViewObject,"Transparency"):
|
||||
mn = Draft.getrgb(obj.ViewObject.ShapeColor,testbw=False)[1:]
|
||||
outfile.write("usemtl color_" + mn + "\n")
|
||||
materials.append(("color_" + mn,obj.ViewObject.ShapeColor,obj.ViewObject.Transparency))
|
||||
|
||||
Reference in New Issue
Block a user