From e64a9efc92da65ab8319b08b0ffefc260ed43160 Mon Sep 17 00:00:00 2001 From: yorikvanhavre Date: Sat, 5 Nov 2011 14:28:29 +0000 Subject: [PATCH] + fixed bug #473 - Precision value in Draft git-svn-id: https://free-cad.svn.sourceforge.net/svnroot/free-cad/trunk@5092 e8eeb9e2-ec13-0410-a4a9-efa5cf37419d --- src/Mod/Draft/Draft_rc.py | 6 ++--- src/Mod/Draft/Resources/ui/userprefs-base.ui | 4 ++-- src/Mod/Draft/importDXF.py | 23 +++++++++++--------- 3 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/Mod/Draft/Draft_rc.py b/src/Mod/Draft/Draft_rc.py index b3ec7d0fe..f8d5deb05 100644 --- a/src/Mod/Draft/Draft_rc.py +++ b/src/Mod/Draft/Draft_rc.py @@ -2,7 +2,7 @@ # Resource object code # -# Created: Fri Oct 14 17:10:38 2011 +# Created: Sat Nov 5 12:13:05 2011 # by: The Resource Compiler for PyQt (Qt v4.7.3) # # WARNING! All changes made in this file will be lost! @@ -30418,7 +30418,7 @@ qt_resource_data = "\ \x22\x3e\x0a\x20\x20\x20\x3c\x72\x65\x63\x74\x3e\x0a\x20\x20\x20\ \x20\x3c\x78\x3e\x30\x3c\x2f\x78\x3e\x0a\x20\x20\x20\x20\x3c\x79\ \x3e\x30\x3c\x2f\x79\x3e\x0a\x20\x20\x20\x20\x3c\x77\x69\x64\x74\ -\x68\x3e\x35\x37\x35\x3c\x2f\x77\x69\x64\x74\x68\x3e\x0a\x20\x20\ +\x68\x3e\x35\x39\x30\x3c\x2f\x77\x69\x64\x74\x68\x3e\x0a\x20\x20\ \x20\x20\x3c\x68\x65\x69\x67\x68\x74\x3e\x36\x32\x39\x3c\x2f\x68\ \x65\x69\x67\x68\x74\x3e\x0a\x20\x20\x20\x3c\x2f\x72\x65\x63\x74\ \x3e\x0a\x20\x20\x3c\x2f\x70\x72\x6f\x70\x65\x72\x74\x79\x3e\x0a\ @@ -31592,7 +31592,7 @@ qt_resource_data = "\ \x20\x20\x20\x20\x20\x20\x3c\x70\x72\x6f\x70\x65\x72\x74\x79\x20\ \x6e\x61\x6d\x65\x3d\x22\x76\x61\x6c\x75\x65\x22\x3e\x0a\x20\x20\ \x20\x20\x20\x20\x20\x20\x20\x20\x20\x3c\x6e\x75\x6d\x62\x65\x72\ -\x3e\x33\x3c\x2f\x6e\x75\x6d\x62\x65\x72\x3e\x0a\x20\x20\x20\x20\ +\x3e\x36\x3c\x2f\x6e\x75\x6d\x62\x65\x72\x3e\x0a\x20\x20\x20\x20\ \x20\x20\x20\x20\x20\x20\x3c\x2f\x70\x72\x6f\x70\x65\x72\x74\x79\ \x3e\x0a\x20\x20\x20\x20\x20\x20\x20\x20\x20\x20\x3c\x70\x72\x6f\ \x70\x65\x72\x74\x79\x20\x6e\x61\x6d\x65\x3d\x22\x70\x72\x65\x66\ diff --git a/src/Mod/Draft/Resources/ui/userprefs-base.ui b/src/Mod/Draft/Resources/ui/userprefs-base.ui index 60d77731d..8a7a52e24 100755 --- a/src/Mod/Draft/Resources/ui/userprefs-base.ui +++ b/src/Mod/Draft/Resources/ui/userprefs-base.ui @@ -6,7 +6,7 @@ 0 0 - 575 + 590 629 @@ -583,7 +583,7 @@ The number of decimals in internal coordinates operations (for ex. 3 = 0.001) - 3 + 6 precision diff --git a/src/Mod/Draft/importDXF.py b/src/Mod/Draft/importDXF.py index fdce8b985..cd25634da 100644 --- a/src/Mod/Draft/importDXF.py +++ b/src/Mod/Draft/importDXF.py @@ -53,7 +53,10 @@ try: draftui = FreeCADGui.draftToolBar except: draftui = None pythonopen = open # to distinguish python built-in open function from the one declared here -prec = FreeCAD.ParamGet("User parameter:BaseApp/Preferences/Mod/Draft").GetInt("precision") + +def prec(): + "returns the current Draft precision level" + return Draft.getParam("precision") def decodeName(name): "decodes encoded strings" @@ -270,7 +273,7 @@ class fcformat: def vec(pt): "returns a rounded Vector from a dxf point" - return FreeCAD.Vector(round(pt[0],prec),round(pt[1],prec),round(pt[2],prec)) + return FreeCAD.Vector(round(pt[0],prec()),round(pt[1],prec()),round(pt[2],prec())) def drawLine(line,shapemode=False): "returns a Part shape from a dxf line" @@ -296,8 +299,8 @@ def drawPolyline(polyline,shapemode=False): for p in range(len(polyline.points)-1): p1 = polyline.points[p] p2 = polyline.points[p+1] - v1 = FreeCAD.Vector(round(p1[0],prec),round(p1[1],prec),round(p2[2],prec)) - v2 = FreeCAD.Vector(round(p2[0],prec),round(p2[1],prec),round(p2[2],prec)) + v1 = vec(p1) + v2 = vec(p2) verts.append(v1) if not fcvec.equals(v1,v2): if polyline.points[p].bulge: @@ -316,8 +319,8 @@ def drawPolyline(polyline,shapemode=False): if polyline.closed: p1 = polyline.points[len(polyline.points)-1] p2 = polyline.points[0] - v1 = FreeCAD.Vector(round(p1[0],prec),round(p1[1],prec),round(p1[2],prec)) - v2 = FreeCAD.Vector(round(p2[0],prec),round(p2[1],prec),round(p2[2],prec)) + v1 = vec(p1) + v2 = vec(p2) cv = calcBulge(v1,polyline.points[-1].bulge,v2) if not fcvec.equals(v1,v2): if fcvec.isColinear([v1,cv,v2]): @@ -345,11 +348,11 @@ def drawPolyline(polyline,shapemode=False): def drawArc(arc,shapemode=False): "returns a Part shape from a dxf arc" v=vec(arc.loc) - firstangle=round(arc.start_angle,prec) - lastangle=round(arc.end_angle,prec) + firstangle=round(arc.start_angle,prec()) + lastangle=round(arc.end_angle,prec()) circle=Part.Circle() circle.Center=v - circle.Radius=round(arc.radius,prec) + circle.Radius=round(arc.radius,prec()) try: if (fmt.paramstyle == 4) and (not fmt.makeBlocks) and (not shapemode): pl = FreeCAD.Placement() @@ -365,7 +368,7 @@ def drawCircle(circle,shapemode=False): "returns a Part shape from a dxf circle" v = vec(circle.loc) curve = Part.Circle() - curve.Radius = round(circle.radius,prec) + curve.Radius = round(circle.radius,prec()) curve.Center = v try: if (fmt.paramstyle == 4) and (not fmt.makeBlocks) and (not shapemode):