Arch: Better output of ArchVRM renderer
This commit is contained in:
parent
01480a174a
commit
bab894b775
|
@ -219,6 +219,7 @@ class _ArchMaterialTaskPanel:
|
|||
self.obj.Material = self.material
|
||||
self.obj.Label = self.material['Name']
|
||||
FreeCADGui.ActiveDocument.resetEdit()
|
||||
FreeCADGui.Control.closeDialog()
|
||||
|
||||
def chooseMat(self, card):
|
||||
"sets self.material from a card"
|
||||
|
@ -247,7 +248,7 @@ class _ArchMaterialTaskPanel:
|
|||
if e.upper() == ".FCMAT":
|
||||
self.cards[b] = p + os.sep + f
|
||||
if self.cards:
|
||||
for k,i in self.cards.items():
|
||||
for k in sorted(self.cards.keys()):
|
||||
self.form.comboBox_MaterialsInDir.addItem(k)
|
||||
|
||||
def openEditor(self):
|
||||
|
|
|
@ -357,20 +357,28 @@ class _ArchDrawingView:
|
|||
os.append(o)
|
||||
objs = os
|
||||
self.svg = ''
|
||||
fillpattern = '<pattern id="sectionfill" patternUnits="userSpaceOnUse" patternTransform="matrix(5,0,0,5,0,0)"'
|
||||
fillpattern += ' x="0" y="0" width="10" height="10">'
|
||||
fillpattern += '<g>'
|
||||
fillpattern += '<rect width="10" height="10" style="stroke:none; fill:#ffffff" /><path style="stroke:#000000; stroke-width:1" d="M0,0 l10,10" /></g></pattern>'
|
||||
|
||||
# generating SVG
|
||||
if obj.RenderingMode == "Solid":
|
||||
# render using the Arch Vector Renderer
|
||||
import ArchVRM
|
||||
import ArchVRM, WorkingPlane
|
||||
wp = WorkingPlane.plane()
|
||||
wp.setFromPlacement(obj.Source.Placement)
|
||||
wp.inverse()
|
||||
render = ArchVRM.Renderer()
|
||||
render.setWorkingPlane(obj.Source.Placement)
|
||||
render.setWorkingPlane(wp)
|
||||
render.addObjects(objs)
|
||||
if hasattr(obj,"ShowCut"):
|
||||
render.cut(obj.Source.Shape,obj.ShowCut)
|
||||
else:
|
||||
render.cut(obj.Source.Shape)
|
||||
self.svg += render.getViewSVG(linewidth="LWPlaceholder")
|
||||
self.svg += render.getSectionSVG(linewidth="SWPLaceholder")
|
||||
self.svg += fillpattern
|
||||
self.svg += render.getSectionSVG(linewidth="SWPlaceholder",fillpattern="sectionfill")
|
||||
if hasattr(obj,"ShowCut"):
|
||||
if obj.ShowCut:
|
||||
self.svg += render.getHiddenSVG(linewidth="LWPlaceholder")
|
||||
|
@ -448,11 +456,8 @@ class _ArchDrawingView:
|
|||
svgs = ""
|
||||
if hasattr(obj,"ShowFill"):
|
||||
if obj.ShowFill:
|
||||
svgs += fillpattern
|
||||
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))
|
||||
|
|
|
@ -521,13 +521,16 @@ class Renderer:
|
|||
notfoundstack = 0
|
||||
break
|
||||
elif r == 31:
|
||||
faces.remove(f1)
|
||||
if f1 in faces:
|
||||
faces.remove(f1)
|
||||
elif r == 32:
|
||||
faces.remove(f2)
|
||||
if f2 in faces:
|
||||
faces.remove(f2)
|
||||
else:
|
||||
# nothing found, move the face to the end of the pile
|
||||
faces.remove(f1)
|
||||
faces.append(f1)
|
||||
if f1 in faces:
|
||||
faces.remove(f1)
|
||||
faces.append(f1)
|
||||
loopcount += 1
|
||||
if loopcount == MAXLOOP * len(self.faces):
|
||||
if DEBUG: print "Too many loops, aborting."
|
||||
|
@ -586,50 +589,42 @@ class Renderer:
|
|||
if DEBUG: print "Printing ", len(self.faces), " faces"
|
||||
if not self.sorted:
|
||||
self.sort()
|
||||
svg = ''
|
||||
svg = '<g stroke="#000000" stroke-width="' + str(linewidth) + '" style="stroke-width:' + str(linewidth)
|
||||
svg += ';stroke-miterlimit:1;stroke-linejoin:round;stroke-dasharray:none;">\n'
|
||||
for f in self.faces:
|
||||
if f:
|
||||
fill = self.getFill(f[1])
|
||||
svg +='<path '
|
||||
svg +=' <path '
|
||||
svg += 'd="'
|
||||
for w in f[0].Wires:
|
||||
svg += self.getPathData(w)
|
||||
svg += '" '
|
||||
svg += 'stroke="#000000" '
|
||||
svg += 'stroke-width="' + str(linewidth) + '" '
|
||||
svg += 'style="stroke-width:' + str(linewidth) + ';'
|
||||
svg += 'stroke-miterlimit:1;'
|
||||
svg += 'stroke-linejoin:round;'
|
||||
svg += 'stroke-dasharray:none;'
|
||||
svg += 'fill:' + fill + ';'
|
||||
svg += 'fill-rule: evenodd'
|
||||
svg += '"/>\n'
|
||||
svg += '" style="fill:' + fill + ';fill-rule: evenodd;"/>\n'
|
||||
svg += '</g>\n'
|
||||
return svg
|
||||
|
||||
def getSectionSVG(self,linewidth=0.02):
|
||||
def getSectionSVG(self,linewidth=0.02,fillpattern=None):
|
||||
"Returns a SVG fragment from cut faces"
|
||||
if DEBUG: print "Printing ", len(self.sections), " sections"
|
||||
if not self.oriented:
|
||||
self.reorient()
|
||||
svg = ''
|
||||
svg = '<g stroke="#000000" stroke-width="' + str(linewidth) + '" style="stroke-width:' + str(linewidth)
|
||||
svg += ';stroke-miterlimit:1;stroke-linejoin:round;stroke-dasharray:none;">\n'
|
||||
for f in self.sections:
|
||||
if f:
|
||||
fill = self.getFill(f[1])
|
||||
if fillpattern:
|
||||
if "#" in fillpattern: # color
|
||||
fill = fillpattern
|
||||
else:
|
||||
fill="url(#"+fillpattern+")" # pattern name
|
||||
else:
|
||||
fill = 'none' # none
|
||||
svg +='<path '
|
||||
svg += 'd="'
|
||||
for w in f[0].Wires:
|
||||
#print "wire with ",len(w.Vertexes)," verts"
|
||||
svg += self.getPathData(w)
|
||||
svg += '" '
|
||||
svg += 'stroke="#000000" '
|
||||
svg += 'stroke-width="' + str(linewidth) + '" '
|
||||
svg += 'style="stroke-width:' + str(linewidth) + ';'
|
||||
svg += 'stroke-miterlimit:1;'
|
||||
svg += 'stroke-linejoin:round;'
|
||||
svg += 'stroke-dasharray:none;'
|
||||
svg += 'fill:' + fill + ';'
|
||||
svg += 'fill-rule: evenodd'
|
||||
svg += '"/>\n'
|
||||
svg += '" style="fill:' + fill + ';fill-rule: evenodd;"/>\n'
|
||||
svg += '</g>\n'
|
||||
return svg
|
||||
|
||||
def getHiddenSVG(self,linewidth=0.02):
|
||||
|
@ -637,19 +632,13 @@ class Renderer:
|
|||
if DEBUG: print "Printing ", len(self.sections), " hidden faces"
|
||||
if not self.oriented:
|
||||
self.reorient()
|
||||
svg = ''
|
||||
svg = '<g stroke="#000000" stroke-width="' + str(linewidth) + '" style="stroke-width:' + str(linewidth)
|
||||
svg += ';stroke-miterlimit:1;stroke-linejoin:round;stroke-dasharray:0.09,0.05;fill:none;">\n'
|
||||
for e in self.hiddenEdges:
|
||||
svg +='<path '
|
||||
svg += 'd="'
|
||||
svg += self.getPathData(e)
|
||||
svg += '" '
|
||||
svg += 'stroke="#000000" '
|
||||
svg += 'stroke-width="' + str(linewidth) + '" '
|
||||
svg += 'style="stroke-width:' + str(linewidth) + ';'
|
||||
svg += 'stroke-miterlimit:1;'
|
||||
svg += 'stroke-linejoin:round;'
|
||||
svg += 'stroke-dasharray:0.09,0.05;'
|
||||
svg += 'fill:none;'
|
||||
svg += '"/>\n'
|
||||
svg += '</g>\n'
|
||||
return svg
|
||||
|
||||
|
|
|
@ -4237,7 +4237,8 @@ class _Wire(_DraftObject):
|
|||
if len(obj.Points) > 2:
|
||||
obj.setEditorMode('Start',2)
|
||||
obj.setEditorMode('End',2)
|
||||
obj.setEditorMode('Length',2)
|
||||
if hasattr(obj,"Length"):
|
||||
obj.setEditorMode('Length',2)
|
||||
|
||||
|
||||
class _ViewProviderWire(_ViewProviderDraft):
|
||||
|
|
|
@ -302,6 +302,11 @@ class plane:
|
|||
self.u = rot.multVec(FreeCAD.Vector(1,0,0))
|
||||
self.v = rot.multVec(FreeCAD.Vector(0,1,0))
|
||||
self.axis = rot.multVec(FreeCAD.Vector(0,0,1))
|
||||
|
||||
def inverse(self):
|
||||
"inverts the direction of the working plane"
|
||||
self.u = self.u.negative()
|
||||
self.axis = self.axis.negative()
|
||||
|
||||
def save(self):
|
||||
"stores the current plane state"
|
||||
|
|
Loading…
Reference in New Issue
Block a user