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::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","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::PropertyLength","FontSize","Drawing view","The size of the texts inside this object")
|
||||
obj.RenderingMode = ["Solid","Wireframe"]
|
||||
|
@ -408,12 +409,17 @@ class _ArchDrawingView:
|
|||
c = sol.cut(cutvolume)
|
||||
s = sol.section(cutface)
|
||||
try:
|
||||
s = Part.Wire(s.Edges)
|
||||
s = Part.Face(s)
|
||||
wires = DraftGeomUtils.findWires(s.Edges)
|
||||
for w in wires:
|
||||
f = Part.Face(w)
|
||||
sshapes.append(f)
|
||||
#s = Part.Wire(s.Edges)
|
||||
#s = Part.Face(s)
|
||||
except Part.OCCError:
|
||||
pass
|
||||
#print "ArchDrawingView: unable to get a face"
|
||||
sshapes.append(s)
|
||||
nsh.extend(c.Solids)
|
||||
sshapes.append(s)
|
||||
#sshapes.append(s)
|
||||
if hasattr(obj,"ShowCut"):
|
||||
if obj.ShowCut:
|
||||
c = sol.cut(invcutvolume)
|
||||
|
@ -439,13 +445,28 @@ class _ArchDrawingView:
|
|||
svgh = svgh.replace('fill="none"','fill="none"\nstroke-dasharray="DAPlaceholder"')
|
||||
self.svg += svgh
|
||||
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)
|
||||
self.sectionshape = sshapes
|
||||
svgs = Drawing.projectToSVG(sshapes,self.direction)
|
||||
svgs += Drawing.projectToSVG(sshapes,self.direction)
|
||||
if svgs:
|
||||
svgs = svgs.replace('stroke-width="0.35"','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.35 px"','stroke-width="SWPlaceholder"')
|
||||
svgs = svgs.replace('stroke-width:0.35','stroke-width:SWPlaceholder')
|
||||
self.svg += svgs
|
||||
|
||||
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):
|
||||
import DraftGeomUtils
|
||||
svg = "<path "
|
||||
if pathname is None:
|
||||
pathname = obj.Name
|
||||
svg ='<path id="%s" d="' % pathname
|
||||
svg += 'id="%s" ' % obj.Name
|
||||
elif pathname != "":
|
||||
svg += 'id="%s" ' % pathname
|
||||
svg += ' d="'
|
||||
if not wires:
|
||||
egroups = (DraftGeomUtils.sortEdges(edges),)
|
||||
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(int(flag_large_arc)),\
|
||||
str(int(flag_sweep)),str(v.x),str(v.y))
|
||||
print svg
|
||||
elif DraftGeomUtils.geomType(e) == "Line":
|
||||
v = getProj(vs[-1].Point)
|
||||
svg += 'L '+ str(v.x) +' '+ str(v.y) + ' '
|
||||
|
@ -1963,7 +1967,13 @@ def getSVG(obj,scale=1,linewidth=0.35,fontsize=12,fillstyle="shape color",direct
|
|||
|
||||
if not obj:
|
||||
pass
|
||||
|
||||
|
||||
elif isinstance(obj,Part.Shape):
|
||||
fill = 'url(#'+fillstyle+')'
|
||||
lstyle = getLineStyle()
|
||||
svg += getPath(obj.Edges,pathname="")
|
||||
|
||||
|
||||
elif getType(obj) == "Dimension":
|
||||
if obj.ViewObject.Proxy:
|
||||
if hasattr(obj.ViewObject.Proxy,"p1"):
|
||||
|
|
|
@ -662,6 +662,8 @@ def sortEdges(edges):
|
|||
# Build a dictionary of edges according to their end points.
|
||||
# Each entry is a set of edges that starts, or ends, at the
|
||||
# given vertex hash.
|
||||
if len(edges) < 2:
|
||||
return edges
|
||||
sdict = dict()
|
||||
edict = dict()
|
||||
nedges = []
|
||||
|
@ -670,6 +672,9 @@ def sortEdges(edges):
|
|||
sdict.setdefault( e.Vertexes[0].hashCode(), [] ).append(e)
|
||||
edict.setdefault( e.Vertexes[-1].hashCode(),[] ).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
|
||||
# in the sdict dictionary but not in the edict dictionary, and has
|
||||
# only one edge ending there.
|
||||
|
@ -719,7 +724,7 @@ def sortEdges(edges):
|
|||
eh = e.hashCode()
|
||||
e = invert(e)
|
||||
except KeyError:
|
||||
print("DraftGeomUtils.sortEdges failed - running old version:")
|
||||
print("DraftGeomUtils.sortEdges failed - running old version")
|
||||
return sortEdgesOld(edges)
|
||||
ret.append(e)
|
||||
# All done.
|
||||
|
|
Loading…
Reference in New Issue
Block a user