Draft: Added direction vector to dimensions

This commit is contained in:
Yorik van Havre 2014-01-16 17:13:21 -02:00
parent 13bccea8a1
commit 47d5c615d9

View File

@ -1536,7 +1536,7 @@ def getSVG(obj,scale=1,linewidth=0.35,fontsize=12,fillstyle="shape color",direct
svg += 'L '+ str(v.x) +' '+ str(v.y) + ' '
else:
bspline=e.Curve.toBSpline()
if bspline.Degree <= 3:
if bspline.Degree <= 3 and not bspline.isRational():
for bezierseg in bspline.toBezier():
if bezierseg.Degree>3: #should not happen
raise AssertionError
@ -2857,6 +2857,8 @@ class _Dimension(_DraftObject):
"Endpoint of dimension")
obj.addProperty("App::PropertyVector","Normal","Draft",
"the normal direction of this dimension")
obj.addProperty("App::PropertyVector","Direction","Draft",
"the normal direction of this dimension")
obj.addProperty("App::PropertyVector","Dimline","Draft",
"Point through which the dimension line passes")
obj.addProperty("App::PropertyLink","Support","Draft",
@ -2979,7 +2981,7 @@ class _ViewProviderDimension(_ViewProviderDraft):
def updateData(self, obj, prop):
"called when the base object is changed"
if prop in ["Start","End","Dimline"]:
if prop in ["Start","End","Dimline","Direction"]:
if obj.Start == obj.End:
return
@ -2993,6 +2995,18 @@ class _ViewProviderDimension(_ViewProviderDraft):
# calculate the 4 points
self.p1 = obj.Start
self.p4 = obj.End
base = None
if hasattr(obj,"Direction"):
if not DraftVecUtils.isNull(obj.Direction):
v2 = self.p1.sub(obj.Dimline)
v3 = self.p4.sub(obj.Dimline)
v2 = DraftVecUtils.project(v2,obj.Direction)
v3 = DraftVecUtils.project(v3,obj.Direction)
self.p2 = obj.Dimline.add(v2)
self.p3 = obj.Dimline.add(v3)
base = Part.Line(self.p2,self.p3).toShape()
proj = DraftGeomUtils.findDistance(self.p1,base)
if not base:
base = Part.Line(self.p1,self.p4).toShape()
proj = DraftGeomUtils.findDistance(obj.Dimline,base)
if proj: