Skip to content

Commit

Permalink
Draft: DraftGui.py fix displayPoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Roy-043 authored and yorikvanhavre committed Jan 23, 2025
1 parent ee2f327 commit 0768992
Showing 1 changed file with 22 additions and 39 deletions.
61 changes: 22 additions & 39 deletions src/Mod/Draft/DraftGui.py
Original file line number Diff line number Diff line change
Expand Up @@ -1249,51 +1249,40 @@ def sendText(self):
self.sourceCmd.createObject()

def displayPoint(self, point=None, last=None, plane=None, mask=None):
"""this function displays the passed coords in the x, y, and z widgets"""
"""Displays point values in the widgets and updates self."""
if not self.isTaskOn:
return

self.display_point_active = True # prevent cyclic processing of point values

if not plane:
plane = WorkingPlane.get_working_plane(update=False)
# get coords to display
if not last:
if self.globalMode:
last = FreeCAD.Vector(0,0,0)
else:
last = plane.position
dp = None
if point:
dp = point
if self.relativeMode: # and (last is not None):
if not plane:
plane = WorkingPlane.get_working_plane(update=False)
if not last:
if self.globalMode:
dp = point - last
last = FreeCAD.Vector(0,0,0)
else:
dp = plane.get_local_coords(point - last, as_vector=True)
else:
last = plane.position

if self.relativeMode:
if self.globalMode:
dp = point
delta = point - last
else:
dp = plane.get_local_coords(point)
# set widgets
if dp:
if self.mask in ['y','z']:
self.xValue.setText(display_external(dp.x,None,'Length'))
delta = plane.get_local_coords(point - last, as_vector=True)
else:
self.xValue.setText(display_external(dp.x,None,'Length'))
if self.mask in ['x','z']:
self.yValue.setText(display_external(dp.y,None,'Length'))
else:
self.yValue.setText(display_external(dp.y,None,'Length'))
if self.mask in ['x','y']:
self.zValue.setText(display_external(dp.z,None,'Length'))
else:
self.zValue.setText(display_external(dp.z,None,'Length'))
if self.globalMode:
delta = point
else:
delta = plane.get_local_coords(point)

self.x = delta.x
self.y = delta.y
self.z = delta.z
self.xValue.setText(display_external(delta.x,None,'Length'))
self.yValue.setText(display_external(delta.y,None,'Length'))
self.zValue.setText(display_external(delta.z,None,'Length'))

# set length and angle
if last and dp and plane:
length, theta, phi = DraftVecUtils.get_spherical_coords(*dp)
length, theta, phi = DraftVecUtils.get_spherical_coords(*delta)
theta = math.degrees(theta)
phi = math.degrees(phi)
self.lengthValue.setText(display_external(length,None,'Length'))
Expand All @@ -1312,24 +1301,18 @@ def displayPoint(self, point=None, last=None, plane=None, mask=None):
self.xValue.setEnabled(True)
self.yValue.setEnabled(False)
self.zValue.setEnabled(False)
self.yValue.setText("0")
self.zValue.setText("0")
self.angleValue.setEnabled(False)
self.setFocus()
elif (mask == "y") or (self.mask == "y"):
self.xValue.setEnabled(False)
self.yValue.setEnabled(True)
self.zValue.setEnabled(False)
self.xValue.setText("0")
self.zValue.setText("0")
self.angleValue.setEnabled(False)
self.setFocus("y")
elif (mask == "z") or (self.mask == "z"):
self.xValue.setEnabled(False)
self.yValue.setEnabled(False)
self.zValue.setEnabled(True)
self.xValue.setText("0")
self.yValue.setText("0")
self.angleValue.setEnabled(False)
self.setFocus("z")
else:
Expand Down

0 comments on commit 0768992

Please sign in to comment.