- Fixed Measurement Tool to show the mouse coordinates on the status bar (it was broken at some point)
This commit is contained in:
parent
49120c088e
commit
5f5b37eb98
|
@ -14,6 +14,7 @@ CAD program, and create G-Code for Isolation routing.
|
||||||
- Gerber Editor: added two new tools: Add Disc and Add SemiDisc (porting of Circle and Arc from Geometry Editor)
|
- Gerber Editor: added two new tools: Add Disc and Add SemiDisc (porting of Circle and Arc from Geometry Editor)
|
||||||
- Gerber Editor: made Add Pad repeat until user exits the Add Pad through either mouse right click, or ESC key or deselecting the Add Pad menu item
|
- Gerber Editor: made Add Pad repeat until user exits the Add Pad through either mouse right click, or ESC key or deselecting the Add Pad menu item
|
||||||
- Gerber and Geometry Editors: fixed some issues with the Add Arc/Add Semidisc; in mode 132, the norm() function was not the one from numpy but from a FlatCAM Class. Also fixed some of the texts and made sure that when changing the mode, the current points are reset to prepare for the newly selected mode.
|
- Gerber and Geometry Editors: fixed some issues with the Add Arc/Add Semidisc; in mode 132, the norm() function was not the one from numpy but from a FlatCAM Class. Also fixed some of the texts and made sure that when changing the mode, the current points are reset to prepare for the newly selected mode.
|
||||||
|
- Fixed Measurement Tool to show the mouse coordinates on the status bar (it was broken at some point)
|
||||||
|
|
||||||
22.04.2019
|
22.04.2019
|
||||||
|
|
||||||
|
|
|
@ -106,6 +106,9 @@ class Measurement(FlatCAMTool):
|
||||||
# store here the first click and second click of the measurement process
|
# store here the first click and second click of the measurement process
|
||||||
self.points = []
|
self.points = []
|
||||||
|
|
||||||
|
self.rel_point1 = None
|
||||||
|
self.rel_point2 = None
|
||||||
|
|
||||||
self.active = False
|
self.active = False
|
||||||
|
|
||||||
self.original_call_source = 'app'
|
self.original_call_source = 'app'
|
||||||
|
@ -120,6 +123,9 @@ class Measurement(FlatCAMTool):
|
||||||
|
|
||||||
self.points[:] = []
|
self.points[:] = []
|
||||||
|
|
||||||
|
self.rel_point1 = None
|
||||||
|
self.rel_point2 = None
|
||||||
|
|
||||||
if self.app.tool_tab_locked is True:
|
if self.app.tool_tab_locked is True:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
@ -244,12 +250,21 @@ class Measurement(FlatCAMTool):
|
||||||
if event.button == 1:
|
if event.button == 1:
|
||||||
pos_canvas = self.canvas.vispy_canvas.translate_coords(event.pos)
|
pos_canvas = self.canvas.vispy_canvas.translate_coords(event.pos)
|
||||||
# if GRID is active we need to get the snapped positions
|
# if GRID is active we need to get the snapped positions
|
||||||
if self.app.grid_status() == True:
|
if self.app.grid_status():
|
||||||
pos = self.app.geo_editor.snap(pos_canvas[0], pos_canvas[1])
|
pos = self.app.geo_editor.snap(pos_canvas[0], pos_canvas[1])
|
||||||
else:
|
else:
|
||||||
pos = pos_canvas[0], pos_canvas[1]
|
pos = pos_canvas[0], pos_canvas[1]
|
||||||
self.points.append(pos)
|
self.points.append(pos)
|
||||||
|
|
||||||
|
# Reset here the relative coordinates so there is a new reference on the click position
|
||||||
|
if self.rel_point1 is None:
|
||||||
|
self.app.ui.rel_position_label.setText("<b>Dx</b>: %.4f <b>Dy</b>: "
|
||||||
|
"%.4f " % (0.0, 0.0))
|
||||||
|
self.rel_point1 = pos
|
||||||
|
else:
|
||||||
|
self.rel_point2 = copy(self.rel_point1)
|
||||||
|
self.rel_point1 = pos
|
||||||
|
|
||||||
if len(self.points) == 1:
|
if len(self.points) == 1:
|
||||||
self.start_entry.set_value("(%.4f, %.4f)" % pos)
|
self.start_entry.set_value("(%.4f, %.4f)" % pos)
|
||||||
self.app.inform.emit(_("MEASURING: Click on the Destination point ..."))
|
self.app.inform.emit(_("MEASURING: Click on the Destination point ..."))
|
||||||
|
@ -258,7 +273,6 @@ class Measurement(FlatCAMTool):
|
||||||
dx = self.points[1][0] - self.points[0][0]
|
dx = self.points[1][0] - self.points[0][0]
|
||||||
dy = self.points[1][1] - self.points[0][1]
|
dy = self.points[1][1] - self.points[0][1]
|
||||||
d = sqrt(dx ** 2 + dy ** 2)
|
d = sqrt(dx ** 2 + dy ** 2)
|
||||||
|
|
||||||
self.stop_entry.set_value("(%.4f, %.4f)" % pos)
|
self.stop_entry.set_value("(%.4f, %.4f)" % pos)
|
||||||
|
|
||||||
self.app.inform.emit(_("MEASURING: Result D(x) = {d_x} | D(y) = {d_y} | Distance = {d_z}").format(
|
self.app.inform.emit(_("MEASURING: Result D(x) = {d_x} | D(y) = {d_y} | Distance = {d_z}").format(
|
||||||
|
@ -267,19 +281,40 @@ class Measurement(FlatCAMTool):
|
||||||
self.distance_x_entry.set_value('%.4f' % abs(dx))
|
self.distance_x_entry.set_value('%.4f' % abs(dx))
|
||||||
self.distance_y_entry.set_value('%.4f' % abs(dy))
|
self.distance_y_entry.set_value('%.4f' % abs(dy))
|
||||||
self.total_distance_entry.set_value('%.4f' % abs(d))
|
self.total_distance_entry.set_value('%.4f' % abs(d))
|
||||||
|
self.app.ui.rel_position_label.setText("<b>Dx</b>: %.4f <b>Dy</b>: "
|
||||||
|
"%.4f " % (pos[0], pos[1]))
|
||||||
self.deactivate_measure_tool()
|
self.deactivate_measure_tool()
|
||||||
|
|
||||||
def on_mouse_move_meas(self, event):
|
def on_mouse_move_meas(self, event):
|
||||||
pos_canvas = self.canvas.vispy_canvas.translate_coords(event.pos)
|
try: # May fail in case mouse not within axes
|
||||||
# Update cursor
|
pos_canvas = self.app.plotcanvas.vispy_canvas.translate_coords(event.pos)
|
||||||
pos = self.app.geo_editor.snap(pos_canvas[0], pos_canvas[1])
|
if self.app.grid_status():
|
||||||
if self.app.grid_status() == True:
|
pos = self.app.geo_editor.snap(pos_canvas[0], pos_canvas[1])
|
||||||
self.app.app_cursor.set_data(np.asarray([(pos[0], pos[1])]), symbol='++', edge_color='black', size=20)
|
self.app.app_cursor.enabled = True
|
||||||
|
# Update cursor
|
||||||
|
self.app.app_cursor.set_data(np.asarray([(pos[0], pos[1])]),
|
||||||
|
symbol='++', edge_color='black', size=20)
|
||||||
|
else:
|
||||||
|
pos = (pos_canvas[0], pos_canvas[1])
|
||||||
|
self.app.app_cursor.enabled = False
|
||||||
|
|
||||||
# update utility geometry
|
if self.rel_point1 is not None:
|
||||||
if len(self.points) == 1:
|
dx = pos[0] - self.rel_point1[0]
|
||||||
self.utility_geometry(pos=pos)
|
dy = pos[1] - self.rel_point1[1]
|
||||||
|
else:
|
||||||
|
dx = pos[0]
|
||||||
|
dy = pos[1]
|
||||||
|
|
||||||
|
self.app.ui.position_label.setText(" <b>X</b>: %.4f "
|
||||||
|
"<b>Y</b>: %.4f" % (pos[0], pos[1]))
|
||||||
|
self.app.ui.rel_position_label.setText("<b>Dx</b>: %.4f <b>Dy</b>: "
|
||||||
|
"%.4f " % (dx, dy))
|
||||||
|
# update utility geometry
|
||||||
|
if len(self.points) == 1:
|
||||||
|
self.utility_geometry(pos=pos)
|
||||||
|
except:
|
||||||
|
self.app.ui.position_label.setText("")
|
||||||
|
self.app.ui.rel_position_label.setText("")
|
||||||
|
|
||||||
def utility_geometry(self, pos):
|
def utility_geometry(self, pos):
|
||||||
# first delete old shape
|
# first delete old shape
|
||||||
|
|
Loading…
Reference in New Issue