- fixed Gerber Editor to work in legacy graphic engine

- fixed NCC tool to work in egacy graphic engine
This commit is contained in:
Marius Stanciu
2019-09-22 02:03:19 +03:00
committed by Marius
parent 63b261685d
commit e8109d2007
4 changed files with 134 additions and 70 deletions

View File

@@ -474,6 +474,8 @@ class NonCopperClear(FlatCAMTool, Gerber):
self.cursor_pos = None
self.mouse_is_dragging = False
self.mm = None
self.mr = None
# store here solid_geometry when there are tool with isolation job
self.solid_geometry = []
@@ -1145,20 +1147,36 @@ class NonCopperClear(FlatCAMTool, Gerber):
# To be called after clicking on the plot.
def on_mouse_release(event):
if self.app.is_legacy is False:
event_pos = event.pos
event_is_dragging = event.is_dragging
right_button = 2
else:
event_pos = (event.xdata, event.ydata)
event_is_dragging = self.app.plotcanvas.is_dragging
right_button = 3
try:
x = float(event_pos[0])
y = float(event_pos[1])
except TypeError:
return
event_pos = self.app.plotcanvas.translate_coords((x, y))
# do clear area only for left mouse clicks
if event.button == 1:
if self.first_click is False:
self.first_click = True
self.app.inform.emit('[WARNING_NOTCL] %s' % _("Click the end point of the paint area."))
self.cursor_pos = self.app.plotcanvas.translate_coords(event.pos)
self.cursor_pos = self.app.plotcanvas.translate_coords(event_pos)
if self.app.grid_status() == True:
self.cursor_pos = self.app.geo_editor.snap(self.cursor_pos[0], self.cursor_pos[1])
else:
self.app.inform.emit(_("Zone added. Click to start adding next zone or right click to finish."))
self.app.delete_selection_shape()
curr_pos = self.app.plotcanvas.translate_coords(event.pos)
curr_pos = self.app.plotcanvas.translate_coords(event_pos)
if self.app.grid_status() == True:
curr_pos = self.app.geo_editor.snap(curr_pos[0], curr_pos[1])
@@ -1204,7 +1222,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
# self.app.plotcanvas.graph_event_connect('mouse_move', self.app.on_mouse_move_over_plot)
# self.app.plotcanvas.graph_event_connect('mouse_release',
# self.app.on_mouse_click_release_over_plot)
elif event.button == 2 and self.mouse_is_dragging == False:
elif event.button == right_button and self.mouse_is_dragging == False:
self.first_click = False
if self.app.is_legacy is False:
@@ -1225,6 +1243,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
return
self.sel_rect = cascaded_union(self.sel_rect)
self.clear_copper(ncc_obj=self.ncc_obj,
sel_obj=self.bound_obj,
ncctooldia=ncc_dia_list,
@@ -1238,10 +1257,24 @@ class NonCopperClear(FlatCAMTool, Gerber):
# called on mouse move
def on_mouse_move(event):
curr_pos = self.app.plotcanvas.translate_coords(event.pos)
if self.app.is_legacy is False:
event_pos = event.pos
event_is_dragging = event.is_dragging
right_button = 2
else:
event_pos = (event.xdata, event.ydata)
event_is_dragging = self.app.plotcanvas.is_dragging
right_button = 3
try:
x = float(event_pos[0])
y = float(event_pos[1])
except TypeError:
return
curr_pos = self.app.plotcanvas.translate_coords((x, y))
# detect mouse dragging motion
if event.is_dragging is True:
if event_is_dragging is True:
self.mouse_is_dragging = True
else:
self.mouse_is_dragging = False
@@ -1250,15 +1283,15 @@ class NonCopperClear(FlatCAMTool, Gerber):
if self.app.grid_status() == True:
# Update cursor
curr_pos = self.app.geo_editor.snap(curr_pos[0], curr_pos[1])
self.app.app_cursor.set_data(np.asarray([(curr_pos[0], curr_pos[1])]),
symbol='++', edge_color='black', size=20)
if self.app.is_legacy is False:
self.app.app_cursor.set_data(np.asarray([(curr_pos[0], curr_pos[1])]),
symbol='++', edge_color='black', size=20)
# draw the utility geometry
if self.first_click:
self.app.delete_selection_shape()
self.app.draw_moving_selection_shape(old_coords=(self.cursor_pos[0], self.cursor_pos[1]),
coords=(curr_pos[0], curr_pos[1]),
face_alpha=0.0)
coords=(curr_pos[0], curr_pos[1]))
if self.app.is_legacy is False:
self.app.plotcanvas.graph_event_disconnect('mouse_press', self.app.on_mouse_click_over_plot)
self.app.plotcanvas.graph_event_disconnect('mouse_move', self.app.on_mouse_move_over_plot)