Fixed bug #574 - Draft hatches

svg pattern definitions are now embedded inside the View objects,
since they don't need to be in the defs section.
This commit is contained in:
Yorik van Havre 2012-01-19 20:59:09 -02:00
parent 822308cdde
commit d02c928b4b
2 changed files with 12 additions and 21 deletions

View File

@ -1037,6 +1037,11 @@ def getSVG(obj,modifier=100,textmodifier=100,linestyle="continuous",fillstyle="s
if abs(ny.getAngle(plane.v)) > 0.1: ly = -ly
return Vector(lx,ly,0)
def getPattern(pat):
if pat in FreeCAD.svgpatterns:
return FreeCAD.svgpatterns[pat]
return ''
def getPath(edges):
svg ='<path id="' + name + '" '
edges = fcgeo.sortEdges(edges)
@ -1160,7 +1165,8 @@ def getSVG(obj,modifier=100,textmodifier=100,linestyle="continuous",fillstyle="s
if fillstyle == "shape color":
fill = getrgb(obj.ViewObject.ShapeColor)
else:
fill = 'url(#'+hatch+')'
fill = 'url(#'+fillstyle+')'
svg += getPattern(fillstyle)
else:
fill = 'none'
# setting linetype
@ -1178,6 +1184,7 @@ def getSVG(obj,modifier=100,textmodifier=100,linestyle="continuous",fillstyle="s
else:
stroke = getrgb(obj.ViewObject.LineColor)
width = obj.ViewObject.LineWidth/modifier
if len(obj.Shape.Vertexes) > 1:
wiredEdges = []
if obj.Shape.Faces:
@ -2349,9 +2356,10 @@ class _Shape2DView:
pl = obj.Placement
if obj.Base:
if obj.Base.isDerivedFrom("Part::Feature"):
[visibleG0,visibleG1,hiddenG0,hiddenG1] = Drawing.project(obj.Base.Shape,obj.Projection)
if visibleG0:
obj.Shape = visibleG0
if not fcvec.isNull(obj.Projection):
[visibleG0,visibleG1,hiddenG0,hiddenG1] = Drawing.project(obj.Base.Shape,obj.Projection)
if visibleG0:
obj.Shape = visibleG0
if not fcgeo.isNull(pl):
obj.Placement = pl

View File

@ -3014,7 +3014,6 @@ class Drawing(Modifier):
self.page = self.createDefaultPage()
sel.reverse()
for obj in sel:
self.insertPattern(obj)
if obj.ViewObject.isVisible():
name = 'View'+obj.Name
oldobj = self.page.getObject(name)
@ -3022,22 +3021,6 @@ class Drawing(Modifier):
Draft.makeDrawingView(obj,self.page)
self.doc.recompute()
def insertPattern(self,obj):
"inserts a pattern object on the page"
if 'FillStyle' in obj.ViewObject.PropertiesList:
if obj.ViewObject.FillStyle != 'shape color':
hatch = obj.ViewObject.FillStyle
vobj = self.page.getObject('Pattern'+hatch)
if not vobj:
if hatch in FreeCAD.svgpatterns:
view = self.doc.addObject('Drawing::FeatureView','Pattern'+hatch)
svg = FreeCAD.svgpatterns[hatch]
view.ViewResult = svg
view.X = 0
view.Y = 0
view.Scale = 1
self.page.addObject(view)
def createDefaultPage(self):
"created a default page"
template = Draft.getParam("template")