Arch: Enabled section filling in Arch drawing views
This commit is contained in:
parent
2afea6c661
commit
77f6684dfe
|
@ -292,6 +292,7 @@ class _ArchDrawingView:
|
||||||
obj.addProperty("App::PropertyLink","Source","Base","The linked object")
|
obj.addProperty("App::PropertyLink","Source","Base","The linked object")
|
||||||
obj.addProperty("App::PropertyEnumeration","RenderingMode","Drawing view","The rendering mode to use")
|
obj.addProperty("App::PropertyEnumeration","RenderingMode","Drawing view","The rendering mode to use")
|
||||||
obj.addProperty("App::PropertyBool","ShowCut","Drawing view","If cut geometry is shown or not")
|
obj.addProperty("App::PropertyBool","ShowCut","Drawing view","If cut geometry is shown or not")
|
||||||
|
obj.addProperty("App::PropertyBool","ShowFill","Drawing view","If cut geometry is filled or not")
|
||||||
obj.addProperty("App::PropertyFloat","LineWidth","Drawing view","The line width of the rendered objects")
|
obj.addProperty("App::PropertyFloat","LineWidth","Drawing view","The line width of the rendered objects")
|
||||||
obj.addProperty("App::PropertyLength","FontSize","Drawing view","The size of the texts inside this object")
|
obj.addProperty("App::PropertyLength","FontSize","Drawing view","The size of the texts inside this object")
|
||||||
obj.RenderingMode = ["Solid","Wireframe"]
|
obj.RenderingMode = ["Solid","Wireframe"]
|
||||||
|
@ -408,12 +409,17 @@ class _ArchDrawingView:
|
||||||
c = sol.cut(cutvolume)
|
c = sol.cut(cutvolume)
|
||||||
s = sol.section(cutface)
|
s = sol.section(cutface)
|
||||||
try:
|
try:
|
||||||
s = Part.Wire(s.Edges)
|
wires = DraftGeomUtils.findWires(s.Edges)
|
||||||
s = Part.Face(s)
|
for w in wires:
|
||||||
|
f = Part.Face(w)
|
||||||
|
sshapes.append(f)
|
||||||
|
#s = Part.Wire(s.Edges)
|
||||||
|
#s = Part.Face(s)
|
||||||
except Part.OCCError:
|
except Part.OCCError:
|
||||||
pass
|
#print "ArchDrawingView: unable to get a face"
|
||||||
nsh.extend(c.Solids)
|
|
||||||
sshapes.append(s)
|
sshapes.append(s)
|
||||||
|
nsh.extend(c.Solids)
|
||||||
|
#sshapes.append(s)
|
||||||
if hasattr(obj,"ShowCut"):
|
if hasattr(obj,"ShowCut"):
|
||||||
if obj.ShowCut:
|
if obj.ShowCut:
|
||||||
c = sol.cut(invcutvolume)
|
c = sol.cut(invcutvolume)
|
||||||
|
@ -439,13 +445,28 @@ class _ArchDrawingView:
|
||||||
svgh = svgh.replace('fill="none"','fill="none"\nstroke-dasharray="DAPlaceholder"')
|
svgh = svgh.replace('fill="none"','fill="none"\nstroke-dasharray="DAPlaceholder"')
|
||||||
self.svg += svgh
|
self.svg += svgh
|
||||||
if sshapes:
|
if sshapes:
|
||||||
|
svgs = ""
|
||||||
|
if hasattr(obj,"ShowFill"):
|
||||||
|
if obj.ShowFill:
|
||||||
|
svgs += '<g transform="rotate(180)">\n'
|
||||||
|
svgs += '<pattern id="sectionfill" patternUnits="userSpaceOnUse" patternTransform="matrix(5,0,0,5,0,0)"'
|
||||||
|
svgs += ' x="0" y="0" width="10" height="10">'
|
||||||
|
svgs += '<g style="fill:none; stroke:#000000; stroke-width:1">'
|
||||||
|
svgs += '<path d="M0,0 l10,10" /></g></pattern>'
|
||||||
|
for s in sshapes:
|
||||||
|
if s.Edges:
|
||||||
|
f = Draft.getSVG(s,direction=self.direction.negative(),linewidth=0,fillstyle="sectionfill",color=(0,0,0))
|
||||||
|
svgs += f
|
||||||
|
svgs += "</g>\n"
|
||||||
sshapes = Part.makeCompound(sshapes)
|
sshapes = Part.makeCompound(sshapes)
|
||||||
self.sectionshape = sshapes
|
self.sectionshape = sshapes
|
||||||
svgs = Drawing.projectToSVG(sshapes,self.direction)
|
svgs += Drawing.projectToSVG(sshapes,self.direction)
|
||||||
if svgs:
|
if svgs:
|
||||||
svgs = svgs.replace('stroke-width="0.35"','stroke-width="SWPlaceholder"')
|
svgs = svgs.replace('stroke-width="0.35"','stroke-width="SWPlaceholder"')
|
||||||
svgs = svgs.replace('stroke-width="1"','stroke-width="SWPlaceholder"')
|
svgs = svgs.replace('stroke-width="1"','stroke-width="SWPlaceholder"')
|
||||||
svgs = svgs.replace('stroke-width:0.01','stroke-width:SWPlaceholder')
|
svgs = svgs.replace('stroke-width:0.01','stroke-width:SWPlaceholder')
|
||||||
|
svgs = svgs.replace('stroke-width="0.35 px"','stroke-width="SWPlaceholder"')
|
||||||
|
svgs = svgs.replace('stroke-width:0.35','stroke-width:SWPlaceholder')
|
||||||
self.svg += svgs
|
self.svg += svgs
|
||||||
|
|
||||||
def __getstate__(self):
|
def __getstate__(self):
|
||||||
|
|
|
@ -1742,9 +1742,12 @@ def getSVG(obj,scale=1,linewidth=0.35,fontsize=12,fillstyle="shape color",direct
|
||||||
|
|
||||||
def getPath(edges=[],wires=[],pathname=None):
|
def getPath(edges=[],wires=[],pathname=None):
|
||||||
import DraftGeomUtils
|
import DraftGeomUtils
|
||||||
|
svg = "<path "
|
||||||
if pathname is None:
|
if pathname is None:
|
||||||
pathname = obj.Name
|
svg += 'id="%s" ' % obj.Name
|
||||||
svg ='<path id="%s" d="' % pathname
|
elif pathname != "":
|
||||||
|
svg += 'id="%s" ' % pathname
|
||||||
|
svg += ' d="'
|
||||||
if not wires:
|
if not wires:
|
||||||
egroups = (DraftGeomUtils.sortEdges(edges),)
|
egroups = (DraftGeomUtils.sortEdges(edges),)
|
||||||
else:
|
else:
|
||||||
|
@ -1813,6 +1816,7 @@ def getSVG(obj,scale=1,linewidth=0.35,fontsize=12,fillstyle="shape color",direct
|
||||||
(str(rx),str(ry),str(rot),\
|
(str(rx),str(ry),str(rot),\
|
||||||
str(int(flag_large_arc)),\
|
str(int(flag_large_arc)),\
|
||||||
str(int(flag_sweep)),str(v.x),str(v.y))
|
str(int(flag_sweep)),str(v.x),str(v.y))
|
||||||
|
print svg
|
||||||
elif DraftGeomUtils.geomType(e) == "Line":
|
elif DraftGeomUtils.geomType(e) == "Line":
|
||||||
v = getProj(vs[-1].Point)
|
v = getProj(vs[-1].Point)
|
||||||
svg += 'L '+ str(v.x) +' '+ str(v.y) + ' '
|
svg += 'L '+ str(v.x) +' '+ str(v.y) + ' '
|
||||||
|
@ -1964,6 +1968,12 @@ def getSVG(obj,scale=1,linewidth=0.35,fontsize=12,fillstyle="shape color",direct
|
||||||
if not obj:
|
if not obj:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
elif isinstance(obj,Part.Shape):
|
||||||
|
fill = 'url(#'+fillstyle+')'
|
||||||
|
lstyle = getLineStyle()
|
||||||
|
svg += getPath(obj.Edges,pathname="")
|
||||||
|
|
||||||
|
|
||||||
elif getType(obj) == "Dimension":
|
elif getType(obj) == "Dimension":
|
||||||
if obj.ViewObject.Proxy:
|
if obj.ViewObject.Proxy:
|
||||||
if hasattr(obj.ViewObject.Proxy,"p1"):
|
if hasattr(obj.ViewObject.Proxy,"p1"):
|
||||||
|
|
|
@ -662,6 +662,8 @@ def sortEdges(edges):
|
||||||
# Build a dictionary of edges according to their end points.
|
# Build a dictionary of edges according to their end points.
|
||||||
# Each entry is a set of edges that starts, or ends, at the
|
# Each entry is a set of edges that starts, or ends, at the
|
||||||
# given vertex hash.
|
# given vertex hash.
|
||||||
|
if len(edges) < 2:
|
||||||
|
return edges
|
||||||
sdict = dict()
|
sdict = dict()
|
||||||
edict = dict()
|
edict = dict()
|
||||||
nedges = []
|
nedges = []
|
||||||
|
@ -670,6 +672,9 @@ def sortEdges(edges):
|
||||||
sdict.setdefault( e.Vertexes[0].hashCode(), [] ).append(e)
|
sdict.setdefault( e.Vertexes[0].hashCode(), [] ).append(e)
|
||||||
edict.setdefault( e.Vertexes[-1].hashCode(),[] ).append(e)
|
edict.setdefault( e.Vertexes[-1].hashCode(),[] ).append(e)
|
||||||
nedges.append(e)
|
nedges.append(e)
|
||||||
|
if not nedges:
|
||||||
|
print "DraftGeomUtils.sortEdges: zero-length edges"
|
||||||
|
return edges
|
||||||
# Find the start of the path. The start is the vertex that appears
|
# Find the start of the path. The start is the vertex that appears
|
||||||
# in the sdict dictionary but not in the edict dictionary, and has
|
# in the sdict dictionary but not in the edict dictionary, and has
|
||||||
# only one edge ending there.
|
# only one edge ending there.
|
||||||
|
@ -719,7 +724,7 @@ def sortEdges(edges):
|
||||||
eh = e.hashCode()
|
eh = e.hashCode()
|
||||||
e = invert(e)
|
e = invert(e)
|
||||||
except KeyError:
|
except KeyError:
|
||||||
print("DraftGeomUtils.sortEdges failed - running old version:")
|
print("DraftGeomUtils.sortEdges failed - running old version")
|
||||||
return sortEdgesOld(edges)
|
return sortEdgesOld(edges)
|
||||||
ret.append(e)
|
ret.append(e)
|
||||||
# All done.
|
# All done.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user