Skip to content

Commit

Permalink
Arch: fixed rotation of space labels in techdraw
Browse files Browse the repository at this point in the history
  • Loading branch information
yorikvanhavre committed Nov 1, 2016
1 parent 7338398 commit 195ea42
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
10 changes: 6 additions & 4 deletions src/Mod/Arch/ArchSectionPlane.py
Expand Up @@ -75,7 +75,7 @@ def makeSectionView(section,name="View"):
return view


def getSVG(section,allOn=False,renderMode="Wireframe",showHidden=False,showFill=False,scale=1,linewidth=1,fontsize=1,techdraw=False):
def getSVG(section,allOn=False,renderMode="Wireframe",showHidden=False,showFill=False,scale=1,linewidth=1,fontsize=1,techdraw=False,rotation=0):
"""getSVG(section,[allOn,renderMode,showHidden,showFill,scale,linewidth,fontsize]) :
returns an SVG fragment from an Arch section plane. If
allOn is True, all cut objects are shown, regardless if they are visible or not.
Expand Down Expand Up @@ -214,7 +214,6 @@ def getSVG(section,allOn=False,renderMode="Wireframe",showHidden=False,showFill=
svgs = svgs.replace('stroke-width="0.35 px"','stroke-width="SWPlaceholder"')
svgs = svgs.replace('stroke-width:0.35','stroke-width:SWPlaceholder')
svg += svgs

scaledlinewidth = linewidth/scale
st = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch").GetFloat("CutLineThickness",2)
da = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Arch").GetString("archHiddenPattern","30,10")
Expand All @@ -226,14 +225,17 @@ def getSVG(section,allOn=False,renderMode="Wireframe",showHidden=False,showFill=
if not techdraw:
svg += '<g transform="scale(1,-1)">'
for d in drafts:
svg += Draft.getSVG(d,scale=scale,linewidth=linewidth,fontsize=fontsize,direction=direction,techdraw=techdraw)
svg += Draft.getSVG(d,scale=scale,linewidth=linewidth,fontsize=fontsize,direction=direction,techdraw=techdraw,rotation=rotation)
if not techdraw:
svg += '</g>'
# filter out spaces not cut by the section plane
if cutface and spaces:
spaces = [s for s in spaces if s.Shape.BoundBox.intersect(cutface.BoundBox)]
if spaces:
if not techdraw:
svg += '<g transform="scale(1,-1)">'
for s in spaces:
svg += Draft.getSVG(s,scale=scale,linewidth=linewidth,fontsize=fontsize,direction=direction,techdraw=techdraw)
svg += Draft.getSVG(s,scale=scale,linewidth=linewidth,fontsize=fontsize,direction=direction,techdraw=techdraw,rotation=rotation)
if not techdraw:
svg += '</g>'
#print "complete node:",svg
Expand Down
9 changes: 7 additions & 2 deletions src/Mod/Draft/Draft.py
Expand Up @@ -1723,7 +1723,7 @@ def getProj(vec):
return result


def getSVG(obj,scale=1,linewidth=0.35,fontsize=12,fillstyle="shape color",direction=None,linestyle=None,color=None,linespacing=None,techdraw=False):
def getSVG(obj,scale=1,linewidth=0.35,fontsize=12,fillstyle="shape color",direction=None,linestyle=None,color=None,linespacing=None,techdraw=False,rotation=0):
'''getSVG(object,[scale], [linewidth],[fontsize],[fillstyle],[direction],[linestyle],[color],[linespacing]):
returns a string containing a SVG representation of the given object,
with the given linewidth and fontsize (used if the given object contains
Expand Down Expand Up @@ -2253,6 +2253,8 @@ def getText(color,fontsize,fontname,angle,base,text,linespacing=0.5,align="cente
c = getrgb(obj.ViewObject.TextColor)
n = obj.ViewObject.FontName
a = 0
if rotation != 0:
a = -math.radians(rotation)
t1 = obj.ViewObject.Proxy.text1.string.getValues()
t2 = obj.ViewObject.Proxy.text2.string.getValues()
scale = obj.ViewObject.FirstLine.Value/obj.ViewObject.FontSize.Value
Expand All @@ -2263,7 +2265,10 @@ def getText(color,fontsize,fontname,angle,base,text,linespacing=0.5,align="cente
j = obj.ViewObject.TextAlign
svg += getText(c,f1,n,a,getProj(p1),t1,linespacing,j,flip=True)
if t2:
svg += getText(c,fontsize,n,a,getProj(p1).add(FreeCAD.Vector(0,lspc.Length,0)),t2,linespacing,j,flip=True)
ofs = FreeCAD.Vector(0,lspc.Length,0)
if a:
ofs = FreeCAD.Rotation(FreeCAD.Vector(0,0,1),-rotation).multVec(ofs)
svg += getText(c,fontsize,n,a,getProj(p1).add(ofs),t2,linespacing,j,flip=True)

elif obj.isDerivedFrom('Part::Feature'):
if obj.Shape.isNull():
Expand Down
3 changes: 2 additions & 1 deletion src/Mod/TechDraw/App/DrawViewArch.cpp
Expand Up @@ -109,7 +109,8 @@ App::DocumentObjectExecReturn *DrawViewArch::execute(void)
<< ",scale=" << Scale.getValue()
<< ",linewidth=" << LineWidth.getValue()
<< ",fontsize=" << FontSize.getValue()
<< ",techdraw=True";
<< ",techdraw=True"
<< ",rotation=" << Rotation.getValue();

Base::Interpreter().runString("import ArchSectionPlane");
Base::Interpreter().runStringArg("svgBody = ArchSectionPlane.getSVG(App.activeDocument().%s %s)",
Expand Down

0 comments on commit 195ea42

Please sign in to comment.