Arch/TechDraw: TD Arch views now have a 'fillSpaces' property to show Arch spaces as color-filled areas
This commit is contained in:
@@ -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>'
|
||||
|
||||
|
||||
@@ -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):
|
||||
|
||||
@@ -68,7 +68,7 @@ def getPattern(pat):
|
||||
return ''
|
||||
|
||||
|
||||
def getSVG(obj,scale=1,linewidth=0.35,fontsize=12,fillstyle="shape color",direction=None,linestyle=None,color=None,linespacing=None,techdraw=False,rotation=0):
|
||||
def getSVG(obj,scale=1,linewidth=0.35,fontsize=12,fillstyle="shape color",direction=None,linestyle=None,color=None,linespacing=None,techdraw=False,rotation=0,fillSpaces=False):
|
||||
'''getSVG(object,[scale], [linewidth],[fontsize],[fillstyle],[direction],[linestyle],[color],[linespacing]):
|
||||
returns a string containing a SVG representation of the given object,
|
||||
with the given linewidth and fontsize (used if the given object contains
|
||||
@@ -732,6 +732,19 @@ def getSVG(obj,scale=1,linewidth=0.35,fontsize=12,fillstyle="shape color",direct
|
||||
if not obj.ViewObject:
|
||||
print ("export of spaces to SVG is only available in GUI mode")
|
||||
else:
|
||||
if fillSpaces:
|
||||
if hasattr(obj,"Proxy"):
|
||||
if not hasattr(obj.Proxy,"face"):
|
||||
obj.Proxy.getArea(obj,notouch=True)
|
||||
if hasattr(obj.Proxy,"face"):
|
||||
# setting fill
|
||||
if gui:
|
||||
fill = getrgb(obj.ViewObject.ShapeColor,testbw=False)
|
||||
fill_opacity = 1 - (obj.ViewObject.Transparency / 100.0)
|
||||
else:
|
||||
fill = "#888888"
|
||||
lstyle = getLineStyle(linestyle, scale)
|
||||
svg += getPath(wires=[obj.Proxy.face.OuterWire])
|
||||
c = getrgb(obj.ViewObject.TextColor)
|
||||
n = obj.ViewObject.FontName
|
||||
a = 0
|
||||
@@ -741,16 +754,18 @@ def getSVG(obj,scale=1,linewidth=0.35,fontsize=12,fillstyle="shape color",direct
|
||||
t2 = obj.ViewObject.Proxy.text2.string.getValues()
|
||||
scale = obj.ViewObject.FirstLine.Value/obj.ViewObject.FontSize.Value
|
||||
f1 = fontsize*scale
|
||||
p2 = FreeCAD.Vector(obj.ViewObject.Proxy.coords.translation.getValue().getValue())
|
||||
p2 = obj.Placement.multVec(FreeCAD.Vector(obj.ViewObject.Proxy.coords.translation.getValue().getValue()))
|
||||
lspc = FreeCAD.Vector(obj.ViewObject.Proxy.header.translation.getValue().getValue())
|
||||
p1 = p2.add(lspc)
|
||||
j = obj.ViewObject.TextAlign
|
||||
svg += getText(c,f1,n,a,getProj(p1, plane),t1,linespacing,j,flip=True)
|
||||
t3 = getText(c,f1,n,a,getProj(p1, plane),t1,linespacing,j,flip=True)
|
||||
svg += t3
|
||||
if t2:
|
||||
ofs = FreeCAD.Vector(0,lspc.Length,0)
|
||||
ofs = FreeCAD.Vector(0,-lspc.Length,0)
|
||||
if a:
|
||||
ofs = FreeCAD.Rotation(FreeCAD.Vector(0,0,1),-rotation).multVec(ofs)
|
||||
svg += getText(c,fontsize,n,a,getProj(p1, plane).add(ofs),t2,linespacing,j,flip=True)
|
||||
t4 = getText(c,fontsize,n,a,getProj(p1, plane).add(ofs),t2,linespacing,j,flip=True)
|
||||
svg += t4
|
||||
|
||||
elif obj.isDerivedFrom('Part::Feature'):
|
||||
if obj.Shape.isNull():
|
||||
|
||||
@@ -59,6 +59,7 @@ DrawViewArch::DrawViewArch(void)
|
||||
ADD_PROPERTY_TYPE(AllOn ,(false),group,App::Prop_None,"If hidden objects must be shown or not");
|
||||
RenderMode.setEnums(RenderModeEnums);
|
||||
ADD_PROPERTY_TYPE(RenderMode, ((long)0),group,App::Prop_None,"The render mode to use");
|
||||
ADD_PROPERTY_TYPE(FillSpaces ,(false),group,App::Prop_None,"If True, Arch Spaces are shown as a colored area");
|
||||
ADD_PROPERTY_TYPE(ShowHidden ,(false),group,App::Prop_None,"If the hidden geometry behind the section plane is shown or not");
|
||||
ADD_PROPERTY_TYPE(ShowFill ,(false),group,App::Prop_None,"If cut areas must be filled with a hatch pattern or not");
|
||||
ADD_PROPERTY_TYPE(LineWidth,(0.35),group,App::Prop_None,"Line width of this view");
|
||||
@@ -113,7 +114,8 @@ App::DocumentObjectExecReturn *DrawViewArch::execute(void)
|
||||
<< ",linewidth=" << LineWidth.getValue()
|
||||
<< ",fontsize=" << FontSize.getValue()
|
||||
<< ",techdraw=True"
|
||||
<< ",rotation=" << Rotation.getValue();
|
||||
<< ",rotation=" << Rotation.getValue()
|
||||
<< ",fillSpaces=" << (FillSpaces.getValue() ? "True" : "False");
|
||||
|
||||
Base::Interpreter().runString("import ArchSectionPlane");
|
||||
Base::Interpreter().runStringArg("svgBody = ArchSectionPlane.getSVG(App.activeDocument().%s %s)",
|
||||
|
||||
@@ -45,6 +45,7 @@ public:
|
||||
App::PropertyLink Source;
|
||||
App::PropertyBool AllOn;
|
||||
App::PropertyEnumeration RenderMode; // "Wireframe","Solid"
|
||||
App::PropertyBool FillSpaces;
|
||||
App::PropertyBool ShowHidden;
|
||||
App::PropertyBool ShowFill;
|
||||
App::PropertyFloat LineWidth;
|
||||
|
||||
Reference in New Issue
Block a user