Arch/TechDraw: TD Arch views now have a 'fillSpaces' property to show Arch spaces as color-filled areas

This commit is contained in:
Yorik van Havre
2019-04-19 18:20:33 -03:00
parent 9d296194e8
commit ea0c7694cd
5 changed files with 46 additions and 24 deletions

View File

@@ -180,10 +180,10 @@ def getFillForObject(o, defaultFill, section):
return defaultFill
def getSVG(section, renderMode="Wireframe", allOn=False, showHidden=False, scale=1, rotation=0, linewidth=1, lineColor=(0.0,0.0,0.0), fontsize=1, showFill=False, fillColor=(0.8,0.8,0.8), techdraw=False):
def getSVG(section, renderMode="Wireframe", allOn=False, showHidden=False, scale=1, rotation=0, linewidth=1, lineColor=(0.0,0.0,0.0), fontsize=1, showFill=False, fillColor=(0.8,0.8,0.8), techdraw=False,fillSpaces=False):
"""getSVG(section, [renderMode, allOn, showHidden, scale, rotation,
linewidth, lineColor, fontsize, showFill, fillColor, techdraw]):
linewidth, lineColor, fontsize, showFill, fillColor, techdraw, fillSpaces]):
returns an SVG fragment from an Arch section plane. If
allOn is True, all cut objects are shown, regardless if they are visible or not.
@@ -193,6 +193,7 @@ def getSVG(section, renderMode="Wireframe", allOn=False, showHidden=False, scale
lineColor -- Color of lines for the renderMode "Wireframe".
fillColor -- If showFill is True and renderMode is "Wireframe",
the cut areas are filled with fillColor.
fillSpaces - If True, shows space objects as filled surfaces
"""
if not section.Objects:
@@ -251,6 +252,8 @@ def getSVG(section, renderMode="Wireframe", allOn=False, showHidden=False, scale
svgcache = None
if section.Proxy.svgcache[3] != showFill:
svgcache = None
if section.Proxy.svgcache[4] != fillSpaces:
svgcache = None
# generating SVG
if renderMode in ["Solid",1]:
@@ -327,7 +330,7 @@ def getSVG(section, renderMode="Wireframe", allOn=False, showHidden=False, scale
sshapes, direction,
hStyle=style, h0Style=style, h1Style=style,
vStyle=style, v0Style=style, v1Style=style)
section.Proxy.svgcache = [svgcache,renderMode,showHidden,showFill]
section.Proxy.svgcache = [svgcache,renderMode,showHidden,showFill,fillSpaces]
svgcache = svgcache.replace("SVGLINECOLOR",svgLineColor)
svgcache = svgcache.replace("SVGLINEWIDTH",svgLineWidth)
svgcache = svgcache.replace("SVGHIDDENPATTERN",svgHiddenPattern)
@@ -353,7 +356,7 @@ def getSVG(section, renderMode="Wireframe", allOn=False, showHidden=False, scale
for s in spaces:
svg += Draft.getSVG(s, scale=scale, linewidth=svgSymbolLineWidth,
fontsize=fontsize, direction=direction, color=lineColor,
techdraw=techdraw, rotation=rotation)
techdraw=techdraw, rotation=rotation, fillSpaces=fillSpaces)
if not techdraw:
svg += '</g>'

View File

@@ -429,7 +429,7 @@ class _Space(ArchComponent.Component):
print("Arch: error computing space boundary")
def getArea(self,obj):
def getArea(self,obj,notouch=False):
"returns the horizontal area at the center of the space"
@@ -444,23 +444,24 @@ class _Space(ArchComponent.Component):
e = sh.section(cutplane)
e = Part.__sortEdges__(e.Edges)
w = Part.Wire(e)
f = Part.Face(w)
self.face = Part.Face(w)
except Part.OCCError:
return 0
else:
if hasattr(obj,"PerimeterLength"):
if w.Length != obj.PerimeterLength.Value:
obj.PerimeterLength = w.Length
if hasattr(obj,"VerticalArea"):
a = 0
for f in sh.Faces:
ang = f.normalAt(0,0).getAngle(FreeCAD.Vector(0,0,1))
if (ang > 1.57) and (ang < 1.571):
a += f.Area
if a != obj.VerticalArea.Value:
obj.VerticalArea = a
if not notouch:
if hasattr(obj,"PerimeterLength"):
if w.Length != obj.PerimeterLength.Value:
obj.PerimeterLength = w.Length
if hasattr(obj,"VerticalArea"):
a = 0
for f in sh.Faces:
ang = f.normalAt(0,0).getAngle(FreeCAD.Vector(0,0,1))
if (ang > 1.57) and (ang < 1.571):
a += f.Area
if a != obj.VerticalArea.Value:
obj.VerticalArea = a
#print "area of ",obj.Label," : ",f.Area
return f.Area
return self.face.Area
class _ViewProviderSpace(ArchComponent.ViewProviderComponent):