diff --git a/src/Mod/Arch/ArchSectionPlane.py b/src/Mod/Arch/ArchSectionPlane.py index 59173d78d995..570278e1694b 100644 --- a/src/Mod/Arch/ArchSectionPlane.py +++ b/src/Mod/Arch/ArchSectionPlane.py @@ -107,7 +107,8 @@ def __init__(self,obj): def execute(self,obj): import Part - l = obj.ViewObject.DisplaySize.Value + l = obj.ViewObject.DisplayLength.Value + h = obj.ViewObject.DisplayHeight.Value p = Part.makePlane(l,l,Vector(l/2,-l/2,0),Vector(0,0,-1)) # make sure the normal direction is pointing outwards, you never know what OCC will decide... if p.normalAt(0,0).getAngle(obj.Placement.Rotation.multVec(FreeCAD.Vector(0,0,1))) > 1: @@ -131,11 +132,15 @@ def __setstate__(self,state): class _ViewProviderSectionPlane: "A View Provider for Section Planes" def __init__(self,vobj): - vobj.addProperty("App::PropertyLength","DisplaySize","Arch",translate("Arch","The display size of this section plane")) + vobj.addProperty("App::PropertyLength","DisplayLength","Arch",translate("Arch","The display length of this section plane")) + vobj.addProperty("App::PropertyLength","DisplayHeight","Arch",translate("Arch","The display height of this section plane")) + vobj.addProperty("App::PropertyLength","ArrowSize","Arch",translate("Arch","The size of the arrows of this section plane")) vobj.addProperty("App::PropertyPercent","Transparency","Base","") vobj.addProperty("App::PropertyFloat","LineWidth","Base","") vobj.addProperty("App::PropertyColor","LineColor","Base","") - vobj.DisplaySize = 1 + vobj.DisplayLength = 1 + vobj.DisplayHeight = 1 + vobj.ArrowSize = 1 vobj.Transparency = 85 vobj.LineWidth = 1 vobj.LineColor = (0.0,0.0,0.4,1.0) @@ -174,7 +179,7 @@ def attach(self,vobj): sep.addChild(fsep) sep.addChild(psep) vobj.addDisplayMode(sep,"Default") - self.onChanged(vobj,"DisplaySize") + self.onChanged(vobj,"DisplayLength") self.onChanged(vobj,"LineColor") self.onChanged(vobj,"Transparency") @@ -189,7 +194,7 @@ def setDisplayMode(self,mode): def updateData(self,obj,prop): if prop in ["Placement"]: - self.onChanged(obj.ViewObject,"DisplaySize") + self.onChanged(obj.ViewObject,"DisplayLength") return def onChanged(self,vobj,prop): @@ -200,12 +205,13 @@ def onChanged(self,vobj,prop): elif prop == "Transparency": if hasattr(vobj,"Transparency"): self.mat2.transparency.setValue(vobj.Transparency/100.0) - elif prop == "DisplaySize": - hd = vobj.DisplaySize.Value/2 + elif prop in ["DisplayLength","DisplayHeight","ArrowSize"]: + ld = vobj.DisplayLength.Value/2 + hd = vobj.DisplayHeight.Value/2 verts = [] fverts = [] - for v in [[-hd,-hd],[hd,-hd],[hd,hd],[-hd,hd]]: - l1 = hd/3 + for v in [[-ld,-hd],[ld,-hd],[ld,hd],[-ld,hd]]: + l1 = vobj.ArrowSize.Value if vobj.ArrowSize.Value > 0 else 0.1 l2 = l1/3 pl = FreeCAD.Placement(vobj.Object.Placement) p1 = pl.multVec(Vector(v[0],v[1],0)) @@ -234,15 +240,17 @@ def __setstate__(self,state): class _ArchDrawingView: def __init__(self, obj): 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::PropertyFloat","LineWidth","Drawing View","The line width of the rendered objects") + 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::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"] obj.RenderingMode = "Wireframe" obj.LineWidth = 0.35 obj.ShowCut = False obj.Proxy = self self.Type = "ArchSectionView" + obj.FontSize = 12 def execute(self, obj): if obj.Source: @@ -296,6 +304,15 @@ def buildSVG(self, obj,join=False): if obj.Source.Objects: objs = Draft.getGroupContents(obj.Source.Objects,walls=True) objs = Draft.removeHidden(objs) + # separate spaces + spaces = [] + os = [] + for o in objs: + if Draft.getType(o) == "Space": + spaces.append(o) + else: + os.append(o) + objs = os self.svg = '' # generating SVG @@ -348,6 +365,11 @@ def buildSVG(self, obj,join=False): sol.reverse() c = sol.cut(cutvolume) s = sol.section(cutface) + try: + s = Part.Wire(s.Edges) + s = Part.Face(s) + except: + pass nsh.extend(c.Solids) sshapes.append(s) if hasattr(obj,"ShowCut"): @@ -374,21 +396,16 @@ def buildSVG(self, obj,join=False): svgh = svgh.replace('fill="none"','fill="none"\nstroke-dasharray="0.09,0.05"') self.svg += svgh if sshapes: - edges = [] - for s in sshapes: - edges.extend(s.Edges) - wires = DraftGeomUtils.findWires(edges) - faces = [] - for w in wires: - if (w.ShapeType == "Wire") and w.isClosed(): - faces.append(Part.Face(w)) - sshapes = Part.makeCompound(faces) + sshapes = Part.makeCompound(sshapes) 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') self.svg += svgs + + for s in spaces: + self.svg += Draft.getSVG(s,scale=1/obj.Scale,fontsize=obj.FontSize,direction=self.direction) def updateSVG(self, obj): "Formats and places the calculated svg stuff on the page" @@ -400,9 +417,7 @@ def updateSVG(self, obj): if not hasattr(self,"svg"): return '' linewidth = obj.LineWidth/obj.Scale - st = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch").GetFloat("CutLineThickness") - if not st: - st = 2 + st = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch").GetFloat("CutLineThickness",2) svg = self.svg.replace('LWPlaceholder', str(linewidth) + 'px') svg = svg.replace('SWPlaceholder', str(linewidth*st) + 'px') diff --git a/src/Mod/Arch/ArchVRM.py b/src/Mod/Arch/ArchVRM.py index 7039372b8452..4c5c021d3490 100644 --- a/src/Mod/Arch/ArchVRM.py +++ b/src/Mod/Arch/ArchVRM.py @@ -254,7 +254,7 @@ def cut(self,cutplane,hidden=False): shapes.append([c]+sh[1:]) for f in c.Faces: faces.append([f]+sh[1:]) - print "iscoplanar:",f.Vertexes[0].Point,f.normalAt(0,0),cutface.Vertexes[0].Point,cutface.normalAt(0,0) + #print "iscoplanar:",f.Vertexes[0].Point,f.normalAt(0,0),cutface.Vertexes[0].Point,cutface.normalAt(0,0) if DraftGeomUtils.isCoplanar([f,cutface]): print "COPLANAR" sections.append([f,fill]) diff --git a/src/Mod/Draft/Draft.py b/src/Mod/Draft/Draft.py index dc53b9ee3475..f364afa38b32 100644 --- a/src/Mod/Draft/Draft.py +++ b/src/Mod/Draft/Draft.py @@ -1758,7 +1758,7 @@ def getArrow(arrowtype,point,arrowsize,color,linewidth,angle=0): print "getSVG: arrow type not implemented" return svg - def getText(color,fontsize,fontname,angle,base,text,linespacing=0.5,align="center"): + def getText(color,fontsize,fontname,angle,base,text,linespacing=0.5,align="center",flip=True): if not isinstance(text,list): text = text.split("\n") if align.lower() == "center": @@ -1776,7 +1776,10 @@ def getText(color,fontsize,fontname,angle,base,text,linespacing=0.5,align="cente svg += ','+ str(base.x) + ',' + str(base.y) + ') ' svg += 'translate(' + str(base.x) + ',' + str(base.y) + ') ' #svg += 'scale('+str(tmod/2000)+',-'+str(tmod/2000)+') ' - svg += 'scale(1,-1) ' + if flip: + svg += 'scale(1,-1) ' + else: + svg += 'scale(1,1) ' svg += '" freecad:skip="1"' svg += '>\n' if len(text) == 1: @@ -1814,7 +1817,7 @@ def getText(color,fontsize,fontname,angle,base,text,linespacing=0.5,align="cente p2 = getProj(prx.p2) p3 = getProj(prx.p3) p4 = getProj(prx.p4) - tbase = p2.add(p3.sub(p2).multiply(0.5)) + tbase = getProj(prx.tbase) angle = -DraftVecUtils.angle(p3.sub(p2)) # drawing lines @@ -1825,7 +1828,7 @@ def getText(color,fontsize,fontname,angle,base,text,linespacing=0.5,align="cente tangle = tangle-math.pi elif (tangle <= -math.pi/2) or (tangle > math.pi/2): tangle = tangle+math.pi - tbase = tbase.add(DraftVecUtils.rotate(Vector(0,2/scale,0),tangle)) + #tbase = tbase.add(DraftVecUtils.rotate(Vector(0,2/scale,0),tangle)) svg += 'd="M '+str(p1.x)+' '+str(p1.y)+' ' svg += 'L '+str(p2.x)+' '+str(p2.y)+' ' svg += 'L '+str(p3.x)+' '+str(p3.y)+' ' @@ -1947,6 +1950,19 @@ def getText(color,fontsize,fontname,angle,base,text,linespacing=0.5,align="cente svg += '' + obj.ViewObject.Proxy.getNumber(n) + '\n' svg += '\n' n += 1 + + elif getType(obj) == "Space": + "returns an SVG fragment for the text of a space" + c = getrgb(obj.ViewObject.TextColor) + n = obj.ViewObject.FontName + a = 0 + t1 = obj.ViewObject.Proxy.text1.string.getValues() + t2 = obj.ViewObject.Proxy.text2.string.getValues() + t = t1 + t2 + p = FreeCAD.Vector(obj.ViewObject.Proxy.coords.translation.getValue().getValue()) + l = obj.ViewObject.LineSpacing/2 + j = obj.ViewObject.TextAlign + svg += getText(c,fontsize,n,a,getProj(p),t,l,j,flip=False) elif obj.isDerivedFrom('Part::Feature'): if obj.Shape.isNull(): @@ -3244,11 +3260,11 @@ def updateData(self, obj, prop): m = ["2D","3D"][getParam("dimstyle",0)] if m== "3D": offset = offset.negative() - tbase = (self.p2.add((self.p3.sub(self.p2).multiply(0.5)))).add(offset) + self.tbase = (self.p2.add((self.p3.sub(self.p2).multiply(0.5)))).add(offset) if hasattr(obj.ViewObject,"TextPosition"): if not DraftVecUtils.isNull(obj.ViewObject.TextPosition): - tbase = obj.ViewObject.TextPosition - self.textpos.translation.setValue([tbase.x,tbase.y,tbase.z]) + self.tbase = obj.ViewObject.TextPosition + self.textpos.translation.setValue([self.tbase.x,self.tbase.y,self.tbase.z]) self.textpos.rotation = coin.SbRotation(rot1[0],rot1[1],rot1[2],rot1[3]) su = True if hasattr(obj.ViewObject,"ShowUnit"): diff --git a/src/Mod/Draft/DraftGeomUtils.py b/src/Mod/Draft/DraftGeomUtils.py index 71ab40eb185c..ec22ea85af2b 100755 --- a/src/Mod/Draft/DraftGeomUtils.py +++ b/src/Mod/Draft/DraftGeomUtils.py @@ -906,7 +906,7 @@ def offset(edge,vector): elif geomType(edge) == "Circle": rad = edge.Vertexes[0].Point.sub(edge.Curve.Center) newrad = Vector.add(rad,vector).Length - return Part.Circle(edge.Curve.Center,edge.Curve.Axis,newrad).toShape() + return Part.Circle(edge.Curve.Center,NORM,newrad).toShape() else: return None