Draft: Draft_Trimex: Fix wrong angle units in taskpanel

The redraw function was changed to return a list [dist, ang] if the real argument is not True. With this list the action function 'knows' which units to display. This also made it possible to move the "self.ui." related stuff that was in the redraw function to the the action function.
I have also changed to tooltip texts by removing the article "The". This more in keeping with other tooltips.
This commit is contained in:
Roy-043
2021-07-02 11:32:51 +02:00
committed by GitHub
parent 909dfa7036
commit 1db692e38b

View File

@@ -203,9 +203,21 @@ class Trimex(gui_base_original.Modifier):
if self.extrudeMode:
dist = self.extrude(self.shift)
else:
dist = self.redraw(self.point, self.snapped,
self.shift, self.alt)
self.ui.setRadiusValue(dist, unit="Length")
# If the geomType of the edge is "Line" ang will be None,
# else dist will be None.
dist, ang = self.redraw(self.point, self.snapped,
self.shift, self.alt)
if dist:
self.ui.labelRadius.setText(translate("draft", "Distance"))
self.ui.radiusValue.setToolTip(translate("draft",
"Offset distance"))
self.ui.setRadiusValue(dist, unit="Length")
else:
self.ui.labelRadius.setText(translate("draft", "Angle"))
self.ui.radiusValue.setToolTip(translate("draft",
"Offset angle"))
self.ui.setRadiusValue(ang, unit="Angle")
self.ui.radiusValue.setFocus()
self.ui.radiusValue.selectAll()
gui_tool_utils.redraw3DView()
@@ -301,6 +313,7 @@ class Trimex(gui_base_original.Modifier):
# modifying active edge
if DraftGeomUtils.geomType(edge) == "Line":
ang = None
ve = DraftGeomUtils.vec(edge)
chord = v1.sub(point)
n = ve.cross(chord)
@@ -313,9 +326,6 @@ class Trimex(gui_base_original.Modifier):
dist = v1.sub(self.newpoint).Length
ghost.p1(self.newpoint)
ghost.p2(v2)
self.ui.labelRadius.setText(translate("draft", "Distance"))
self.ui.radiusValue.setToolTip(translate("draft",
"The offset distance"))
if real:
if self.force:
ray = self.newpoint.sub(v1)
@@ -323,16 +333,14 @@ class Trimex(gui_base_original.Modifier):
self.newpoint = App.Vector.add(v1, ray)
newedges.append(Part.LineSegment(self.newpoint, v2).toShape())
else:
dist = None
center = edge.Curve.Center
rad = edge.Curve.Radius
ang1 = DraftVecUtils.angle(v2.sub(center))
ang2 = DraftVecUtils.angle(point.sub(center))
_rot_rad = DraftVecUtils.rotate(App.Vector(rad, 0, 0), -ang2)
self.newpoint = App.Vector.add(center, _rot_rad)
self.ui.labelRadius.setText(translate("draft", "Angle"))
self.ui.radiusValue.setToolTip(translate("draft",
"The offset angle"))
dist = math.degrees(-ang2)
ang = math.degrees(-ang2)
# if ang1 > ang2:
# ang1, ang2 = ang2, ang1
# print("last calculated:",
@@ -384,7 +392,7 @@ class Trimex(gui_base_original.Modifier):
if real:
return newedges
else:
return dist
return [dist, ang]
def trimObject(self):
"""Trim the actual object."""