- legacy graphic engine - made the mouse events work (click, release, doubleclick, dragging)

- legacy graphic engine - made the key events work (simple or with modifiers)
- legacy graphic engine - made the mouse cursor work (enabled/disabled, position report); snapping is not moving the cursor yet
This commit is contained in:
Marius Stanciu
2019-09-20 17:25:32 +03:00
parent 4f17d6229f
commit 011e80c0ce
16 changed files with 998 additions and 211 deletions

View File

@@ -1005,7 +1005,7 @@ class ToolPaint(FlatCAMTool, Gerber):
# do paint single only for left mouse clicks
if event.button == 1:
self.app.inform.emit(_("Painting polygon..."))
self.app.plotcanvas.vis_disconnect('mouse_press', doit)
self.app.plotcanvas.graph_event_disconnect('mouse_press', doit)
pos = self.app.plotcanvas.translate_coords(event.pos)
if self.app.grid_status() == True:
@@ -1017,12 +1017,12 @@ class ToolPaint(FlatCAMTool, Gerber):
overlap=overlap,
connect=connect,
contour=contour)
self.app.plotcanvas.vis_connect('mouse_press', self.app.on_mouse_click_over_plot)
self.app.plotcanvas.vis_connect('mouse_release', self.app.on_mouse_click_release_over_plot)
self.app.plotcanvas.graph_event_connect('mouse_press', self.app.on_mouse_click_over_plot)
self.app.plotcanvas.graph_event_connect('mouse_release', self.app.on_mouse_click_release_over_plot)
self.app.plotcanvas.vis_disconnect('mouse_release', self.app.on_mouse_click_release_over_plot)
self.app.plotcanvas.vis_disconnect('mouse_press', self.app.on_mouse_click_over_plot)
self.app.plotcanvas.vis_connect('mouse_press', doit)
self.app.plotcanvas.graph_event_disconnect('mouse_release', self.app.on_mouse_click_release_over_plot)
self.app.plotcanvas.graph_event_disconnect('mouse_press', self.app.on_mouse_click_over_plot)
self.app.plotcanvas.graph_event_connect('mouse_press', doit)
elif select_method == "area":
self.app.inform.emit('[WARNING_NOTCL] %s' %
@@ -1082,21 +1082,21 @@ class ToolPaint(FlatCAMTool, Gerber):
# connect=connect,
# contour=contour)
#
# self.app.plotcanvas.vis_disconnect('mouse_release', on_mouse_release)
# self.app.plotcanvas.vis_disconnect('mouse_move', on_mouse_move)
# self.app.plotcanvas.graph_event_disconnect('mouse_release', on_mouse_release)
# self.app.plotcanvas.graph_event_disconnect('mouse_move', on_mouse_move)
#
# self.app.plotcanvas.vis_connect('mouse_press', self.app.on_mouse_click_over_plot)
# self.app.plotcanvas.vis_connect('mouse_move', self.app.on_mouse_move_over_plot)
# self.app.plotcanvas.vis_connect('mouse_release', self.app.on_mouse_click_release_over_plot)
# self.app.plotcanvas.graph_event_connect('mouse_press', self.app.on_mouse_click_over_plot)
# 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 is False:
self.first_click = False
self.app.plotcanvas.vis_disconnect('mouse_release', on_mouse_release)
self.app.plotcanvas.vis_disconnect('mouse_move', on_mouse_move)
self.app.plotcanvas.graph_event_disconnect('mouse_release', on_mouse_release)
self.app.plotcanvas.graph_event_disconnect('mouse_move', on_mouse_move)
self.app.plotcanvas.vis_connect('mouse_press', self.app.on_mouse_click_over_plot)
self.app.plotcanvas.vis_connect('mouse_move', self.app.on_mouse_move_over_plot)
self.app.plotcanvas.vis_connect('mouse_release', self.app.on_mouse_click_release_over_plot)
self.app.plotcanvas.graph_event_connect('mouse_press', self.app.on_mouse_click_over_plot)
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)
if len(self.sel_rect) == 0:
return
@@ -1113,7 +1113,6 @@ class ToolPaint(FlatCAMTool, Gerber):
# called on mouse move
def on_mouse_move(event):
curr_pos = self.app.plotcanvas.translate_coords(event.pos)
self.app.app_cursor.enabled = False
# detect mouse dragging motion
if event.is_dragging is True:
@@ -1123,7 +1122,6 @@ class ToolPaint(FlatCAMTool, Gerber):
# update the cursor position
if self.app.grid_status() == True:
self.app.app_cursor.enabled = 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])]),
@@ -1136,12 +1134,12 @@ class ToolPaint(FlatCAMTool, Gerber):
coords=(curr_pos[0], curr_pos[1]),
face_alpha=0.0)
self.app.plotcanvas.vis_disconnect('mouse_press', self.app.on_mouse_click_over_plot)
self.app.plotcanvas.vis_disconnect('mouse_move', self.app.on_mouse_move_over_plot)
self.app.plotcanvas.vis_disconnect('mouse_release', self.app.on_mouse_click_release_over_plot)
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)
self.app.plotcanvas.graph_event_disconnect('mouse_release', self.app.on_mouse_click_release_over_plot)
self.app.plotcanvas.vis_connect('mouse_release', on_mouse_release)
self.app.plotcanvas.vis_connect('mouse_move', on_mouse_move)
self.app.plotcanvas.graph_event_connect('mouse_release', on_mouse_release)
self.app.plotcanvas.graph_event_connect('mouse_move', on_mouse_move)
elif select_method == 'ref':
self.bound_obj_name = self.box_combo.currentText()