Draft: Fix alignment of angular dimension arrows
This commit is contained in:
@@ -32,6 +32,7 @@ They inherit their behavior from the base Annotation viewprovider.
|
||||
# \ingroup draftviewproviders
|
||||
# \brief Provides the viewprovider code for the Dimension objects.
|
||||
|
||||
import math
|
||||
import pivy.coin as coin
|
||||
import lazy_loader.lazy_loader as lz
|
||||
from PySide.QtCore import QT_TRANSLATE_NOOP
|
||||
@@ -1117,27 +1118,32 @@ class ViewProviderAngularDimension(ViewProviderDimensionBase):
|
||||
self.coord2.point.setValue(p3)
|
||||
|
||||
# Calculate small chords to make arrows look better
|
||||
arrowlength = 4 * vobj.ArrowSize.Value
|
||||
u1 = (self.circle.valueAt(first + arrowlength)
|
||||
- self.circle.valueAt(first)).normalize()
|
||||
u2 = (self.circle.valueAt(last)
|
||||
- self.circle.valueAt(last - arrowlength)).normalize()
|
||||
if hasattr(vobj, "FlipArrows") and vobj.FlipArrows:
|
||||
u1 = u1.negative()
|
||||
u2 = u2.negative()
|
||||
if vobj.ArrowSize.Value !=0 \
|
||||
and hasattr(vobj, "ScaleMultiplier") \
|
||||
and vobj.ScaleMultiplier != 0:
|
||||
halfarrowlength = 2 * vobj.ArrowSize.Value * vobj.ScaleMultiplier
|
||||
arrowangle = 2 * math.asin(halfarrowlength / radius)
|
||||
|
||||
w2 = self.circle.Curve.Axis
|
||||
w1 = w2.negative()
|
||||
u1 = (self.circle.valueAt(first + arrowangle)
|
||||
- self.circle.valueAt(first)).normalize()
|
||||
u2 = (self.circle.valueAt(last)
|
||||
- self.circle.valueAt(last - arrowangle)).normalize()
|
||||
if hasattr(vobj, "FlipArrows") and vobj.FlipArrows:
|
||||
u1 = u1.negative()
|
||||
u2 = u2.negative()
|
||||
|
||||
v1 = w1.cross(u1)
|
||||
v2 = w2.cross(u2)
|
||||
_plane_rot_1 = DraftVecUtils.getPlaneRotation(u1, v1, w1)
|
||||
_plane_rot_2 = DraftVecUtils.getPlaneRotation(u2, v2, w2)
|
||||
q1 = App.Placement(_plane_rot_1).Rotation.Q
|
||||
q2 = App.Placement(_plane_rot_2).Rotation.Q
|
||||
w2 = self.circle.Curve.Axis
|
||||
w1 = w2.negative()
|
||||
|
||||
self.trans1.rotation.setValue((q1[0], q1[1], q1[2], q1[3]))
|
||||
self.trans2.rotation.setValue((q2[0], q2[1], q2[2], q2[3]))
|
||||
v1 = w1.cross(u1)
|
||||
v2 = w2.cross(u2)
|
||||
_plane_rot_1 = DraftVecUtils.getPlaneRotation(u1, v1, w1)
|
||||
_plane_rot_2 = DraftVecUtils.getPlaneRotation(u2, v2, w2)
|
||||
q1 = App.Placement(_plane_rot_1).Rotation.Q
|
||||
q2 = App.Placement(_plane_rot_2).Rotation.Q
|
||||
|
||||
self.trans1.rotation.setValue((q1[0], q1[1], q1[2], q1[3]))
|
||||
self.trans2.rotation.setValue((q2[0], q2[1], q2[2], q2[3]))
|
||||
|
||||
# Set text position and rotation
|
||||
self.tbase = midp
|
||||
@@ -1194,7 +1200,7 @@ class ViewProviderAngularDimension(ViewProviderDimensionBase):
|
||||
self.remove_dim_arrows()
|
||||
self.draw_dim_arrows(vobj)
|
||||
|
||||
self.updateData(obj, "Start")
|
||||
self.updateData(obj, None)
|
||||
# obj.touch()
|
||||
|
||||
elif prop == "FontSize" and "ScaleMultiplier" in properties:
|
||||
@@ -1222,9 +1228,11 @@ class ViewProviderAngularDimension(ViewProviderDimensionBase):
|
||||
elif (prop in ("ArrowSize", "ArrowType")
|
||||
and "ScaleMultiplier" in properties
|
||||
and hasattr(self, "node") and hasattr(self, "p2")):
|
||||
self.updateData(obj, None)
|
||||
self.remove_dim_arrows()
|
||||
self.draw_dim_arrows(vobj)
|
||||
# obj.touch()
|
||||
|
||||
else:
|
||||
self.updateData(obj, None)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user