- fixed mouse cursor to work for all objects

- fixed event signals to work in both graphic engines: 2D and 3D
This commit is contained in:
Marius Stanciu 2019-09-21 01:10:32 +03:00 committed by Marius
parent 14bc9f2dfc
commit 01e2755676
16 changed files with 470 additions and 176 deletions

View File

@ -1605,7 +1605,10 @@ class App(QtCore.QObject):
color=QtGui.QColor("gray"))
start_plot_time = time.time() # debug
self.plotcanvas = None
self.app_cursor = None
# this is a list just because when in legacy it is needed to add multiple cursors
# each gets deleted when the axes are deleted therefore there is a need of one for each
self.app_cursor = []
self.hover_shapes = None
self.on_plotcanvas_setup()
@ -6679,10 +6682,17 @@ class App(QtCore.QObject):
try:
sel_obj = self.collection.get_active()
name = sel_obj.options["name"]
isPlotted = sel_obj.options["plot"]
except AttributeError:
self.log.debug("Nothing selected for deletion")
return
if self.is_legacy is True:
# Remove plot only if the object was plotted otherwise delaxes will fail
if isPlotted:
self.plotcanvas.figure.delaxes(self.collection.get_active().axes)
self.plotcanvas.auto_adjust_axes()
# Remove from dictionary
self.collection.delete_active()
@ -6710,12 +6720,15 @@ class App(QtCore.QObject):
for obj in self.collection.get_list():
obj.plot()
self.plotcanvas.fit_view()
self.plotcanvas.graph_event_disconnect('mouse_press', self.on_set_zero_click)
if self.is_legacy:
self.plotcanvas.graph_event_disconnect(self.mp_zc)
else:
self.plotcanvas.graph_event_disconnect('mouse_press', self.on_set_zero_click)
self.worker_task.emit({'fcn': worker_task, 'params': []})
self.inform.emit(_('Click to set the origin ...'))
self.plotcanvas.graph_event_connect('mouse_press', self.on_set_zero_click)
self.mp_zc = self.plotcanvas.graph_event_connect('mouse_press', self.on_set_zero_click)
# first disconnect it as it may have been used by something else
try:
@ -7368,7 +7381,11 @@ class App(QtCore.QObject):
:return: None
"""
self.plotcanvas.update() # TODO: Need update canvas?
if self.is_legacy is False:
self.plotcanvas.update() # TODO: Need update canvas?
else:
self.plotcanvas.auto_adjust_axes()
self.on_zoom_fit(None)
self.collection.update_view()
# self.inform.emit(_("Plots updated ..."))
@ -10959,13 +10976,13 @@ class App(QtCore.QObject):
# So it can receive key presses
self.plotcanvas.native.setFocus()
self.plotcanvas.graph_event_connect('mouse_move', self.on_mouse_move_over_plot)
self.plotcanvas.graph_event_connect('mouse_press', self.on_mouse_click_over_plot)
self.plotcanvas.graph_event_connect('mouse_release', self.on_mouse_click_release_over_plot)
self.plotcanvas.graph_event_connect('mouse_double_click', self.on_double_click_over_plot)
self.mm = self.plotcanvas.graph_event_connect('mouse_move', self.on_mouse_move_over_plot)
self.mp = self.plotcanvas.graph_event_connect('mouse_press', self.on_mouse_click_over_plot)
self.mr = self.plotcanvas.graph_event_connect('mouse_release', self.on_mouse_click_release_over_plot)
self.mdc = self.plotcanvas.graph_event_connect('mouse_double_click', self.on_double_click_over_plot)
# Keys over plot enabled
self.plotcanvas.graph_event_connect('key_press', self.ui.keyPressEvent)
self.kp = self.plotcanvas.graph_event_connect('key_press', self.ui.keyPressEvent)
self.app_cursor = self.plotcanvas.new_cursor()
if self.ui.grid_snap_btn.isChecked():
@ -10988,8 +11005,17 @@ class App(QtCore.QObject):
:param event: Ignored.
:return: None
"""
self.plotcanvas.fit_view()
if self.is_legacy is False:
self.plotcanvas.fit_view()
else:
xmin, ymin, xmax, ymax = self.collection.get_bounds()
width = xmax - xmin
height = ymax - ymin
xmin -= 0.05 * width
xmax += 0.05 * width
ymin -= 0.05 * height
ymax += 0.05 * height
self.plotcanvas.adjust_axes(xmin, ymin, xmax, ymax)
def on_zoom_in(self):
self.plotcanvas.zoom(1 / float(self.defaults['global_zoom_ratio']))

View File

@ -3131,22 +3131,42 @@ class FlatCAMExcellon(FlatCAMObj, Excellon):
visible = visible if visible else self.options['plot']
try:
# Plot Excellon (All polygons?)
if self.app.is_legacy is False:
try:
# Plot Excellon (All polygons?)
if self.options["solid"]:
for geo in self.solid_geometry:
self.add_shape(shape=geo, color='#750000BF', face_color='#C40000BF',
visible=visible,
layer=2)
else:
for geo in self.solid_geometry:
self.add_shape(shape=geo.exterior, color='red', visible=visible)
for ints in geo.interiors:
self.add_shape(shape=ints, color='orange', visible=visible)
self.shapes.redraw()
except (ObjectDeleted, AttributeError):
self.shapes.clear(update=True)
else:
# Plot excellon (All polygons?)
if self.options["solid"]:
for geo in self.solid_geometry:
self.add_shape(shape=geo, color='#750000BF', face_color='#C40000BF',
visible=visible,
layer=2)
patch = PolygonPatch(geo,
facecolor="#C40000",
edgecolor="#750000",
alpha=0.75,
zorder=3)
self.axes.add_patch(patch)
else:
for geo in self.solid_geometry:
self.add_shape(shape=geo.exterior, color='red', visible=visible)
x, y = geo.exterior.coords.xy
self.axes.plot(x, y, 'r-')
for ints in geo.interiors:
self.add_shape(shape=ints, color='orange', visible=visible)
x, y = ints.coords.xy
self.axes.plot(x, y, 'g-')
self.shapes.redraw()
except (ObjectDeleted, AttributeError):
self.shapes.clear(update=True)
self.app.plotcanvas.auto_adjust_axes()
class FlatCAMGeometry(FlatCAMObj, Geometry):

View File

@ -588,8 +588,8 @@ class ObjectCollection(QtCore.QAbstractItemModel):
self.app.all_objects_list = self.get_list()
self.endRemoveRows()
self.app.plotcanvas.redraw()
if self.app.is_legacy is False:
self.app.plotcanvas.redraw()
if select_project:
# always go to the Project Tab after object deletion as it may be done with a shortcut key

View File

@ -18,6 +18,8 @@ CAD program, and create G-Code for Isolation routing.
- made the mouse cursor snap to the grid when grid snapping is active
- changed the axis color to the one used in the OpenGL graphic engine
- work on ShapeCollectionLegacy
- fixed mouse cursor to work for all objects
- fixed event signals to work in both graphic engines: 2D and 3D
19.09.2019

View File

@ -36,6 +36,10 @@ from shapely.wkt import dumps as sdumps
from shapely.geometry.base import BaseGeometry
from shapely.geometry import shape
# needed for legacy mode
# Used for solid polygons in Matplotlib
from descartes.patch import PolygonPatch
import collections
from collections import Iterable

4
descartes/__init__.py Normal file
View File

@ -0,0 +1,4 @@
"""Turn geometric objects into matplotlib patches"""
from descartes.patch import PolygonPatch

66
descartes/patch.py Normal file
View File

@ -0,0 +1,66 @@
"""Paths and patches"""
from matplotlib.patches import PathPatch
from matplotlib.path import Path
from numpy import asarray, concatenate, ones
class Polygon(object):
# Adapt Shapely or GeoJSON/geo_interface polygons to a common interface
def __init__(self, context):
if hasattr(context, 'interiors'):
self.context = context
else:
self.context = getattr(context, '__geo_interface__', context)
@property
def geom_type(self):
return (getattr(self.context, 'geom_type', None)
or self.context['type'])
@property
def exterior(self):
return (getattr(self.context, 'exterior', None)
or self.context['coordinates'][0])
@property
def interiors(self):
value = getattr(self.context, 'interiors', None)
if value is None:
value = self.context['coordinates'][1:]
return value
def PolygonPath(polygon):
"""Constructs a compound matplotlib path from a Shapely or GeoJSON-like
geometric object"""
this = Polygon(polygon)
assert this.geom_type == 'Polygon'
def coding(ob):
# The codes will be all "LINETO" commands, except for "MOVETO"s at the
# beginning of each subpath
n = len(getattr(ob, 'coords', None) or ob)
vals = ones(n, dtype=Path.code_type) * Path.LINETO
vals[0] = Path.MOVETO
return vals
vertices = concatenate(
[asarray(this.exterior)]
+ [asarray(r) for r in this.interiors])
codes = concatenate(
[coding(this.exterior)]
+ [coding(r) for r in this.interiors])
return Path(vertices, codes)
def PolygonPatch(polygon, **kwargs):
"""Constructs a matplotlib patch from a geometric object
The `polygon` may be a Shapely or GeoJSON-like object with or without holes.
The `kwargs` are those supported by the matplotlib.patches.Polygon class
constructor. Returns an instance of matplotlib.patches.PathPatch.
Example (using Shapely Point and a matplotlib axes):
>>> b = Point(0, 0).buffer(1.0)
>>> patch = PolygonPatch(b, fc='blue', ec='blue', alpha=0.5)
>>> axis.add_patch(patch)
"""
return PathPatch(PolygonPath(polygon), **kwargs)

View File

@ -2797,16 +2797,23 @@ class FlatCAMExcEditor(QtCore.QObject):
# first connect to new, then disconnect the old handlers
# don't ask why but if there is nothing connected I've seen issues
self.canvas.graph_event_connect('mouse_press', self.on_canvas_click)
self.canvas.graph_event_connect('mouse_move', self.on_canvas_move)
self.canvas.graph_event_connect('mouse_release', self.on_exc_click_release)
self.mp = self.canvas.graph_event_connect('mouse_press', self.on_canvas_click)
self.mm = self.canvas.graph_event_connect('mouse_move', self.on_canvas_move)
self.mr = self.canvas.graph_event_connect('mouse_release', self.on_exc_click_release)
# make sure that the shortcuts key and mouse events will no longer be linked to the methods from FlatCAMApp
# but those from FlatCAMGeoEditor
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.graph_event_disconnect('mouse_double_click', self.app.on_double_click_over_plot)
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)
self.app.plotcanvas.graph_event_disconnect('mouse_release', self.app.on_mouse_click_release_over_plot)
self.app.plotcanvas.graph_event_disconnect('mouse_double_click', self.app.on_double_click_over_plot)
else:
self.app.plotcanvas.graph_event_disconnect(self.app.mp)
self.app.plotcanvas.graph_event_disconnect(self.app.mm)
self.app.plotcanvas.graph_event_disconnect(self.app.mr)
self.app.plotcanvas.graph_event_disconnect(self.app.mdc)
self.app.collection.view.clicked.disconnect()
self.app.ui.popmenu_copy.triggered.disconnect()
@ -2825,15 +2832,22 @@ class FlatCAMExcEditor(QtCore.QObject):
# we restore the key and mouse control to FlatCAMApp method
# first connect to new, then disconnect the old handlers
# don't ask why but if there is nothing connected I've seen issues
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)
self.app.plotcanvas.graph_event_connect('mouse_double_click', self.app.on_double_click_over_plot)
self.app.mp = self.app.plotcanvas.graph_event_connect('mouse_press', self.app.on_mouse_click_over_plot)
self.app.mm = self.app.plotcanvas.graph_event_connect('mouse_move', self.app.on_mouse_move_over_plot)
self.app.mr = self.app.plotcanvas.graph_event_connect('mouse_release',
self.app.on_mouse_click_release_over_plot)
self.app.mdc = self.app.plotcanvas.graph_event_connect('mouse_double_click',
self.app.on_double_click_over_plot)
self.app.collection.view.clicked.connect(self.app.collection.on_mouse_down)
self.canvas.graph_event_disconnect('mouse_press', self.on_canvas_click)
self.canvas.graph_event_disconnect('mouse_move', self.on_canvas_move)
self.canvas.graph_event_disconnect('mouse_release', self.on_exc_click_release)
if self.app.is_legacy is False:
self.canvas.graph_event_disconnect('mouse_press', self.on_canvas_click)
self.canvas.graph_event_disconnect('mouse_move', self.on_canvas_move)
self.canvas.graph_event_disconnect('mouse_release', self.on_exc_click_release)
else:
self.canvas.graph_event_disconnect(self.mp)
self.canvas.graph_event_disconnect(self.mm)
self.canvas.graph_event_disconnect(self.mr)
try:
self.app.ui.popmenu_copy.triggered.disconnect(self.exc_copy_drills)

View File

@ -3314,16 +3314,22 @@ class FlatCAMGeoEditor(QtCore.QObject):
# first connect to new, then disconnect the old handlers
# don't ask why but if there is nothing connected I've seen issues
self.canvas.graph_event_connect('mouse_press', self.on_canvas_click)
self.canvas.graph_event_connect('mouse_move', self.on_canvas_move)
self.canvas.graph_event_connect('mouse_release', self.on_geo_click_release)
self.mp = self.canvas.graph_event_connect('mouse_press', self.on_canvas_click)
self.mm = self.canvas.graph_event_connect('mouse_move', self.on_canvas_move)
self.mr = self.canvas.graph_event_connect('mouse_release', self.on_geo_click_release)
# make sure that the shortcuts key and mouse events will no longer be linked to the methods from FlatCAMApp
# but those from FlatCAMGeoEditor
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.graph_event_disconnect('mouse_double_click', self.app.on_double_click_over_plot)
if self.app.is_legacy is False:
# make sure that the shortcuts key and mouse events will no longer be linked to the methods from FlatCAMApp
# but those from FlatCAMGeoEditor
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.graph_event_disconnect('mouse_double_click', self.app.on_double_click_over_plot)
else:
self.app.plotcanvas.graph_event_disconnect(self.app.mp)
self.app.plotcanvas.graph_event_disconnect(self.app.mm)
self.app.plotcanvas.graph_event_disconnect(self.app.mr)
self.app.plotcanvas.graph_event_disconnect(self.app.mdc)
# self.app.collection.view.clicked.disconnect()
self.app.ui.popmenu_copy.triggered.disconnect()
@ -3359,15 +3365,22 @@ class FlatCAMGeoEditor(QtCore.QObject):
# we restore the key and mouse control to FlatCAMApp method
# first connect to new, then disconnect the old handlers
# don't ask why but if there is nothing connected I've seen issues
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)
self.app.plotcanvas.graph_event_connect('mouse_double_click', self.app.on_double_click_over_plot)
self.app.mp = self.app.plotcanvas.graph_event_connect('mouse_press', self.app.on_mouse_click_over_plot)
self.app.mm = self.app.plotcanvas.graph_event_connect('mouse_move', self.app.on_mouse_move_over_plot)
self.app.mr = self.app.plotcanvas.graph_event_connect('mouse_release',
self.app.on_mouse_click_release_over_plot)
self.app.mdc = self.app.plotcanvas.graph_event_connect('mouse_double_click',
self.app.on_double_click_over_plot)
# self.app.collection.view.clicked.connect(self.app.collection.on_mouse_down)
self.canvas.graph_event_disconnect('mouse_press', self.on_canvas_click)
self.canvas.graph_event_disconnect('mouse_move', self.on_canvas_move)
self.canvas.graph_event_disconnect('mouse_release', self.on_geo_click_release)
if self.app.is_legacy is False:
self.canvas.graph_event_disconnect('mouse_press', self.on_canvas_click)
self.canvas.graph_event_disconnect('mouse_move', self.on_canvas_move)
self.canvas.graph_event_disconnect('mouse_release', self.on_geo_click_release)
else:
self.canvas.graph_event_disconnect(self.mp)
self.canvas.graph_event_disconnect(self.mm)
self.canvas.graph_event_disconnect(self.mr)
try:
self.app.ui.popmenu_copy.triggered.disconnect(lambda: self.select_tool('copy'))

View File

@ -3517,14 +3517,21 @@ class FlatCAMGrbEditor(QtCore.QObject):
# first connect to new, then disconnect the old handlers
# don't ask why but if there is nothing connected I've seen issues
self.canvas.graph_event_connect('mouse_press', self.on_canvas_click)
self.canvas.graph_event_connect('mouse_move', self.on_canvas_move)
self.canvas.graph_event_connect('mouse_release', self.on_grb_click_release)
self.mp = self.canvas.graph_event_connect('mouse_press', self.on_canvas_click)
self.mm = self.canvas.graph_event_connect('mouse_move', self.on_canvas_move)
self.mr = self.canvas.graph_event_connect('mouse_release', self.on_grb_click_release)
if self.app.is_legacy is False:
self.canvas.graph_event_disconnect('mouse_press', self.app.on_mouse_click_over_plot)
self.canvas.graph_event_disconnect('mouse_move', self.app.on_mouse_move_over_plot)
self.canvas.graph_event_disconnect('mouse_release', self.app.on_mouse_click_release_over_plot)
self.canvas.graph_event_disconnect('mouse_double_click', self.app.on_double_click_over_plot)
else:
self.canvas.graph_event_disconnect(self.app.mp)
self.canvas.graph_event_disconnect(self.app.mm)
self.canvas.graph_event_disconnect(self.app.mr)
self.canvas.graph_event_disconnect(self.app.mdc)
self.canvas.graph_event_disconnect('mouse_press', self.app.on_mouse_click_over_plot)
self.canvas.graph_event_disconnect('mouse_move', self.app.on_mouse_move_over_plot)
self.canvas.graph_event_disconnect('mouse_release', self.app.on_mouse_click_release_over_plot)
self.canvas.graph_event_disconnect('mouse_double_click', self.app.on_double_click_over_plot)
self.app.collection.view.clicked.disconnect()
self.app.ui.popmenu_copy.triggered.disconnect()
@ -3556,15 +3563,20 @@ class FlatCAMGrbEditor(QtCore.QObject):
# we restore the key and mouse control to FlatCAMApp method
# first connect to new, then disconnect the old handlers
# don't ask why but if there is nothing connected I've seen issues
self.canvas.graph_event_connect('mouse_press', self.app.on_mouse_click_over_plot)
self.canvas.graph_event_connect('mouse_move', self.app.on_mouse_move_over_plot)
self.canvas.graph_event_connect('mouse_release', self.app.on_mouse_click_release_over_plot)
self.canvas.graph_event_connect('mouse_double_click', self.app.on_double_click_over_plot)
self.app.mp = self.canvas.graph_event_connect('mouse_press', self.app.on_mouse_click_over_plot)
self.app.mm = self.canvas.graph_event_connect('mouse_move', self.app.on_mouse_move_over_plot)
self.app.mr = self.canvas.graph_event_connect('mouse_release', self.app.on_mouse_click_release_over_plot)
self.app.mdc = self.canvas.graph_event_connect('mouse_double_click', self.app.on_double_click_over_plot)
self.app.collection.view.clicked.connect(self.app.collection.on_mouse_down)
self.canvas.graph_event_disconnect('mouse_press', self.on_canvas_click)
self.canvas.graph_event_disconnect('mouse_move', self.on_canvas_move)
self.canvas.graph_event_disconnect('mouse_release', self.on_grb_click_release)
if self.app.is_legacy is False:
self.canvas.graph_event_disconnect('mouse_press', self.on_canvas_click)
self.canvas.graph_event_disconnect('mouse_move', self.on_canvas_move)
self.canvas.graph_event_disconnect('mouse_release', self.on_grb_click_release)
else:
self.canvas.graph_event_disconnect(self.mp)
self.canvas.graph_event_disconnect(self.mm)
self.canvas.graph_event_disconnect(self.mr)
try:
self.app.ui.popmenu_copy.triggered.disconnect(self.on_copy_button)

View File

@ -147,8 +147,7 @@ class PlotCanvasLegacy(QtCore.QObject):
self.canvas.setFocus()
self.native = self.canvas
# self.canvas.set_hexpand(1)
# self.canvas.set_vexpand(1)
# self.canvas.set_can_focus(True) # For key press
# Attach to parent
@ -170,17 +169,17 @@ class PlotCanvasLegacy(QtCore.QObject):
self.cache.new_screen.connect(self.on_new_screen)
# Events
self.graph_event_connect('button_press_event', self.on_mouse_press)
self.graph_event_connect('button_release_event', self.on_mouse_release)
self.graph_event_connect('motion_notify_event', self.on_mouse_move)
self.mp = self.graph_event_connect('button_press_event', self.on_mouse_press)
self.mr = self.graph_event_connect('button_release_event', self.on_mouse_release)
self.mm = self.graph_event_connect('motion_notify_event', self.on_mouse_move)
# self.canvas.connect('configure-event', self.auto_adjust_axes)
self.graph_event_connect('resize_event', self.auto_adjust_axes)
self.aaa = self.graph_event_connect('resize_event', self.auto_adjust_axes)
# self.canvas.add_events(Gdk.EventMask.SMOOTH_SCROLL_MASK)
# self.canvas.connect("scroll-event", self.on_scroll)
self.graph_event_connect('scroll_event', self.on_scroll)
self.osc = self.graph_event_connect('scroll_event', self.on_scroll)
# self.graph_event_connect('key_press_event', self.on_key_down)
# self.graph_event_connect('key_release_event', self.on_key_up)
self.graph_event_connect('draw_event', self.on_draw)
self.odr = self.graph_event_connect('draw_event', self.on_draw)
self.mouse = [0, 0]
self.key = None
@ -225,18 +224,8 @@ class PlotCanvasLegacy(QtCore.QObject):
:param cid: Callback id.
:return: None
"""
if cid == 'mouse_move':
cid = 'motion_notify_event'
if cid == 'mouse_press':
cid = 'button_press_event'
if cid == 'mouse_release':
cid = 'button_release_event'
if cid == 'mouse_double_click':
self.double_click.disconnect(cid)
return
if cid == 'key_press':
cid = 'key_press_event'
# self.double_click.disconnect(cid)
self.canvas.mpl_disconnect(cid)
@ -244,8 +233,14 @@ class PlotCanvasLegacy(QtCore.QObject):
pass
# log.debug("Cache updated the screen!")
def new_cursor(self):
c = MplCursor(axes=self.axes, color='black', linewidth=1)
def new_cursor(self, axes=None):
# if axes is None:
# c = MplCursor(axes=self.axes, color='black', linewidth=1)
# else:
# c = MplCursor(axes=axes, color='black', linewidth=1)
c = FakeCursor()
return c
def on_key_down(self, event):
@ -532,10 +527,21 @@ class PlotCanvasLegacy(QtCore.QObject):
:param event: Contains information about the event.
:return: None
"""
try:
x = float(event.xdata)
y = float(event.ydata)
except TypeError:
return
self.mouse = [event.xdata, event.ydata]
self.canvas.restore_region(self.background)
# Update pan view on mouse move
if self.panning is True:
# x_pan, y_pan = self.app.geo_editor.snap(event.xdata, event.ydata)
# self.app.app_cursor.set_data(event, (x_pan, y_pan))
for a in self.pan_axes:
a.drag_pan(1, event.key, event.x, event.y)
@ -545,6 +551,15 @@ class PlotCanvasLegacy(QtCore.QObject):
# #### Temporary place-holder for cached update #####
self.update_screen_request.emit([0, 0, 0, 0, 0])
x, y = self.app.geo_editor.snap(x, y)
if self.app.app_cursor.enabled is True:
# Pointer (snapped)
elements = self.axes.plot(x, y, 'k+', ms=40, mew=2, animated=True)
for el in elements:
self.axes.draw_artist(el)
self.canvas.blit(self.axes.bbox)
def translate_coords(self, position):
"""
This does not do much. It's just for code compatibility
@ -590,6 +605,19 @@ class PlotCanvasLegacy(QtCore.QObject):
return width / xpx, height / ypx
class FakeCursor():
def __init__(self):
self._enabled = True
@property
def enabled(self):
return True if self._enabled else False
@enabled.setter
def enabled(self, value):
self._enabled = value
class MplCursor(Cursor):
def __init__(self, axes, color='red', linewidth=1):
@ -651,13 +679,16 @@ class ShapeCollectionLegacy():
def __init__(self):
self._shapes = []
def add(self, shape):
def add(self, shape=None, color=None, face_color=None, alpha=None, visible=True,
update=False, layer=1, tolerance=0.01):
try:
for sh in shape:
self._shapes.append(sh)
except TypeError:
self._shapes.append(shape)
return len(self._shapes) - 1
def clear(self, update=None):
self._shapes[:] = []

View File

@ -780,13 +780,21 @@ class CutOut(FlatCAMTool):
self.app.inform.emit('[ERROR_NOTCL] %s: %s' % (_("Could not retrieve Geometry object"), name))
return "Could not retrieve object: %s" % name
self.app.plotcanvas.graph_event_disconnect('key_press', self.app.ui.keyPressEvent)
self.app.plotcanvas.graph_event_disconnect('mouse_press', self.app.on_mouse_click_over_plot)
self.app.plotcanvas.graph_event_disconnect('mouse_release', self.app.on_mouse_click_release_over_plot)
self.app.plotcanvas.graph_event_disconnect('mouse_move', self.app.on_mouse_move_over_plot)
self.app.plotcanvas.graph_event_connect('key_press', self.on_key_press)
self.app.plotcanvas.graph_event_connect('mouse_move', self.on_mouse_move)
self.app.plotcanvas.graph_event_connect('mouse_release', self.on_mouse_click_release)
if self.app.is_legacy is False:
self.app.plotcanvas.graph_event_disconnect('key_press', self.app.ui.keyPressEvent)
self.app.plotcanvas.graph_event_disconnect('mouse_press', self.app.on_mouse_click_over_plot)
self.app.plotcanvas.graph_event_disconnect('mouse_release', self.app.on_mouse_click_release_over_plot)
self.app.plotcanvas.graph_event_disconnect('mouse_move', self.app.on_mouse_move_over_plot)
else:
self.app.plotcanvas.graph_event_disconnect(self.app.kp)
self.app.plotcanvas.graph_event_disconnect(self.app.mp)
self.app.plotcanvas.graph_event_disconnect(self.app.mr)
self.app.plotcanvas.graph_event_disconnect(self.app.mm)
self.kp = self.app.plotcanvas.graph_event_connect('key_press', self.on_key_press)
self.mm = self.app.plotcanvas.graph_event_connect('mouse_move', self.on_mouse_move)
self.mr = self.app.plotcanvas.graph_event_connect('mouse_release', self.on_mouse_click_release)
def on_manual_cutout(self, click_pos):
name = self.man_object_combo.currentText()
@ -943,13 +951,20 @@ class CutOut(FlatCAMTool):
# if RMB then we exit
elif event.button == 2 and self.mouse_is_dragging is False:
self.app.plotcanvas.graph_event_disconnect('key_press', self.on_key_press)
self.app.plotcanvas.graph_event_disconnect('mouse_move', self.on_mouse_move)
self.app.plotcanvas.graph_event_disconnect('mouse_release', self.on_mouse_click_release)
self.app.plotcanvas.graph_event_connect('key_press', self.app.ui.keyPressEvent)
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.graph_event_connect('mouse_move', self.app.on_mouse_move_over_plot)
if self.app.is_legacy is False:
self.app.plotcanvas.graph_event_disconnect('key_press', self.on_key_press)
self.app.plotcanvas.graph_event_disconnect('mouse_move', self.on_mouse_move)
self.app.plotcanvas.graph_event_disconnect('mouse_release', self.on_mouse_click_release)
else:
self.app.plotcanvas.graph_event_disconnect(self.kp)
self.app.plotcanvas.graph_event_disconnect(self.mm)
self.app.plotcanvas.graph_event_disconnect(self.mr)
self.app.kp = self.app.plotcanvas.graph_event_connect('key_press', self.app.ui.keyPressEvent)
self.app.mp = self.app.plotcanvas.graph_event_connect('mouse_press', self.app.on_mouse_click_over_plot)
self.app.mr = self.app.plotcanvas.graph_event_connect('mouse_release',
self.app.on_mouse_click_release_over_plot)
self.app.mm = self.app.plotcanvas.graph_event_connect('mouse_move', self.app.on_mouse_move_over_plot)
# Remove any previous utility shape
self.app.geo_editor.tool_shape.clear(update=True)
@ -1064,13 +1079,20 @@ class CutOut(FlatCAMTool):
# Escape = Deselect All
if key == QtCore.Qt.Key_Escape or key == 'Escape':
self.app.plotcanvas.graph_event_disconnect('key_press', self.on_key_press)
self.app.plotcanvas.graph_event_disconnect('mouse_move', self.on_mouse_move)
self.app.plotcanvas.graph_event_disconnect('mouse_release', self.on_mouse_click_release)
self.app.plotcanvas.graph_event_connect('key_press', self.app.ui.keyPressEvent)
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.graph_event_connect('mouse_move', self.app.on_mouse_move_over_plot)
if self.app.is_legacy is False:
self.app.plotcanvas.graph_event_disconnect('key_press', self.on_key_press)
self.app.plotcanvas.graph_event_disconnect('mouse_move', self.on_mouse_move)
self.app.plotcanvas.graph_event_disconnect('mouse_release', self.on_mouse_click_release)
else:
self.app.plotcanvas.graph_event_disconnect(self.kp)
self.app.plotcanvas.graph_event_disconnect(self.mm)
self.app.plotcanvas.graph_event_disconnect(self.mr)
self.app.kp = self.app.plotcanvas.graph_event_connect('key_press', self.app.ui.keyPressEvent)
self.app.mp = self.app.plotcanvas.graph_event_connect('mouse_press', self.app.on_mouse_click_over_plot)
self.app.mr = self.app.plotcanvas.graph_event_connect('mouse_release',
self.app.on_mouse_click_release_over_plot)
self.app.mm = self.app.plotcanvas.graph_event_connect('mouse_move', self.app.on_mouse_move_over_plot)
# Remove any previous utility shape
self.app.geo_editor.tool_shape.clear(update=True)

View File

@ -182,26 +182,49 @@ class Measurement(FlatCAMTool):
# we can connect the app mouse events to the measurement tool
# NEVER DISCONNECT THOSE before connecting some other handlers; it breaks something in VisPy
self.canvas.graph_event_connect('mouse_move', self.on_mouse_move_meas)
self.canvas.graph_event_connect('mouse_release', self.on_mouse_click_release)
self.mm = self.canvas.graph_event_connect('mouse_move', self.on_mouse_move_meas)
self.mr = self.canvas.graph_event_connect('mouse_release', self.on_mouse_click_release)
# we disconnect the mouse/key handlers from wherever the measurement tool was called
if self.app.call_source == 'app':
self.canvas.graph_event_disconnect('mouse_move', self.app.on_mouse_move_over_plot)
self.canvas.graph_event_disconnect('mouse_press', self.app.on_mouse_click_over_plot)
self.canvas.graph_event_disconnect('mouse_release', self.app.on_mouse_click_release_over_plot)
if self.app.is_legacy is False:
self.canvas.graph_event_disconnect('mouse_move', self.app.on_mouse_move_over_plot)
self.canvas.graph_event_disconnect('mouse_press', self.app.on_mouse_click_over_plot)
self.canvas.graph_event_disconnect('mouse_release', self.app.on_mouse_click_release_over_plot)
else:
self.canvas.graph_event_disconnect(self.app.mm)
self.canvas.graph_event_disconnect(self.app.mp)
self.canvas.graph_event_disconnect(self.app.mr)
elif self.app.call_source == 'geo_editor':
self.canvas.graph_event_disconnect('mouse_move', self.app.geo_editor.on_canvas_move)
self.canvas.graph_event_disconnect('mouse_press', self.app.geo_editor.on_canvas_click)
self.canvas.graph_event_disconnect('mouse_release', self.app.geo_editor.on_geo_click_release)
if self.app.is_legacy is False:
self.canvas.graph_event_disconnect('mouse_move', self.app.geo_editor.on_canvas_move)
self.canvas.graph_event_disconnect('mouse_press', self.app.geo_editor.on_canvas_click)
self.canvas.graph_event_disconnect('mouse_release', self.app.geo_editor.on_geo_click_release)
else:
self.canvas.graph_event_disconnect(self.app.geo_editor.mm)
self.canvas.graph_event_disconnect(self.app.geo_editor.mp)
self.canvas.graph_event_disconnect(self.app.geo_editor.mr)
elif self.app.call_source == 'exc_editor':
self.canvas.graph_event_disconnect('mouse_move', self.app.exc_editor.on_canvas_move)
self.canvas.graph_event_disconnect('mouse_press', self.app.exc_editor.on_canvas_click)
self.canvas.graph_event_disconnect('mouse_release', self.app.exc_editor.on_exc_click_release)
if self.app.is_legacy is False:
self.canvas.graph_event_disconnect('mouse_move', self.app.exc_editor.on_canvas_move)
self.canvas.graph_event_disconnect('mouse_press', self.app.exc_editor.on_canvas_click)
self.canvas.graph_event_disconnect('mouse_release', self.app.exc_editor.on_exc_click_release)
else:
self.canvas.graph_event_disconnect(self.app.exc_editor.mm)
self.canvas.graph_event_disconnect(self.app.exc_editor.mp)
self.canvas.graph_event_disconnect(self.app.exc_editor.mr)
elif self.app.call_source == 'grb_editor':
self.canvas.graph_event_disconnect('mouse_move', self.app.grb_editor.on_canvas_move)
self.canvas.graph_event_disconnect('mouse_press', self.app.grb_editor.on_canvas_click)
self.canvas.graph_event_disconnect('mouse_release', self.app.grb_editor.on_grb_click_release)
if self.app.is_legacy is False:
self.canvas.graph_event_disconnect('mouse_move', self.app.grb_editor.on_canvas_move)
self.canvas.graph_event_disconnect('mouse_press', self.app.grb_editor.on_canvas_click)
self.canvas.graph_event_disconnect('mouse_release', self.app.grb_editor.on_grb_click_release)
else:
self.canvas.graph_event_disconnect(self.app.grb_editor.mm)
self.canvas.graph_event_disconnect(self.app.grb_editor.mp)
self.canvas.graph_event_disconnect(self.app.grb_editor.mr)
self.app.call_source = 'measurement'
@ -214,25 +237,35 @@ class Measurement(FlatCAMTool):
self.app.call_source = copy(self.original_call_source)
if self.original_call_source == 'app':
self.canvas.graph_event_connect('mouse_move', self.app.on_mouse_move_over_plot)
self.canvas.graph_event_connect('mouse_press', self.app.on_mouse_click_over_plot)
self.canvas.graph_event_connect('mouse_release', self.app.on_mouse_click_release_over_plot)
self.app.mm = self.canvas.graph_event_connect('mouse_move', self.app.on_mouse_move_over_plot)
self.app.mp = self.canvas.graph_event_connect('mouse_press', self.app.on_mouse_click_over_plot)
self.app.mr = self.canvas.graph_event_connect('mouse_release', self.app.on_mouse_click_release_over_plot)
elif self.original_call_source == 'geo_editor':
self.canvas.graph_event_connect('mouse_move', self.app.geo_editor.on_canvas_move)
self.canvas.graph_event_connect('mouse_press', self.app.geo_editor.on_canvas_click)
self.canvas.graph_event_connect('mouse_release', self.app.geo_editor.on_geo_click_release)
self.app.geo_editor.mm = self.canvas.graph_event_connect('mouse_move', self.app.geo_editor.on_canvas_move)
self.app.geo_editor.mp = self.canvas.graph_event_connect('mouse_press', self.app.geo_editor.on_canvas_click)
self.app.geo_editor.mr = self.canvas.graph_event_connect('mouse_release',
self.app.geo_editor.on_geo_click_release)
elif self.original_call_source == 'exc_editor':
self.canvas.graph_event_connect('mouse_move', self.app.exc_editor.on_canvas_move)
self.canvas.graph_event_connect('mouse_press', self.app.exc_editor.on_canvas_click)
self.canvas.graph_event_connect('mouse_release', self.app.exc_editor.on_exc_click_release)
self.app.exc_editor.mm = self.canvas.graph_event_connect('mouse_move', self.app.exc_editor.on_canvas_move)
self.app.exc_editor.mp = self.canvas.graph_event_connect('mouse_press', self.app.exc_editor.on_canvas_click)
self.app.exc_editor.mr = self.canvas.graph_event_connect('mouse_release',
self.app.exc_editor.on_exc_click_release)
elif self.original_call_source == 'grb_editor':
self.canvas.graph_event_connect('mouse_move', self.app.grb_editor.on_canvas_move)
self.canvas.graph_event_connect('mouse_press', self.app.grb_editor.on_canvas_click)
self.canvas.graph_event_connect('mouse_release', self.app.grb_editor.on_grb_click_release)
self.app.grb_editor.mm = self.canvas.graph_event_connect('mouse_move', self.app.grb_editor.on_canvas_move)
self.app.grb_editor.mp = self.canvas.graph_event_connect('mouse_press', self.app.grb_editor.on_canvas_click)
self.app.grb_editor.mr = self.canvas.graph_event_connect('mouse_release',
self.app.grb_editor.on_grb_click_release)
# disconnect the mouse/key events from functions of measurement tool
self.canvas.graph_event_disconnect('mouse_move', self.on_mouse_move_meas)
self.canvas.graph_event_disconnect('mouse_release', self.on_mouse_click_release)
if self.app.is_legacy is False:
self.canvas.graph_event_disconnect('mouse_move', self.on_mouse_move_meas)
self.canvas.graph_event_disconnect('mouse_release', self.on_mouse_click_release)
else:
self.canvas.graph_event_disconnect(self.mm)
self.canvas.graph_event_disconnect(self.mr)
# self.app.ui.notebook.setTabText(2, _("Tools"))
# self.app.ui.notebook.setCurrentWidget(self.app.ui.project_tab)

View File

@ -66,10 +66,16 @@ class ToolMove(FlatCAMTool):
if self.isVisible():
self.setVisible(False)
self.app.plotcanvas.graph_event_disconnect('mouse_move', self.on_move)
self.app.plotcanvas.graph_event_disconnect('mouse_press', self.on_left_click)
self.app.plotcanvas.graph_event_disconnect('key_release', self.on_key_press)
self.app.plotcanvas.graph_event_connect('key_press', self.app.ui.keyPressEvent)
if self.app.is_legacy is False:
self.app.plotcanvas.graph_event_disconnect('mouse_move', self.on_move)
self.app.plotcanvas.graph_event_disconnect('mouse_press', self.on_left_click)
self.app.plotcanvas.graph_event_disconnect('key_release', self.on_key_press)
self.app.plotcanvas.graph_event_connect('key_press', self.app.ui.keyPressEvent)
else:
self.app.plotcanvas.graph_event_disconnect(self.mm)
self.app.plotcanvas.graph_event_disconnect(self.mp)
self.app.plotcanvas.graph_event_disconnect(self.kr)
self.app.kr = self.app.plotcanvas.graph_event_connect('key_press', self.app.ui.keyPressEvent)
self.clicked_move = 0
@ -99,9 +105,14 @@ class ToolMove(FlatCAMTool):
# this is necessary because right mouse click and middle mouse click
# are used for panning on the canvas
if self.app.is_legacy is False:
event_pos = event.pos
else:
event_pos = (event.xdata, event.ydata)
if event.button == 1:
if self.clicked_move == 0:
pos_canvas = self.app.plotcanvas.translate_coords(event.pos)
pos_canvas = self.app.plotcanvas.translate_coords(event_pos)
# if GRID is active we need to get the snapped positions
if self.app.grid_status() == True:
@ -118,7 +129,7 @@ class ToolMove(FlatCAMTool):
if self.clicked_move == 1:
try:
pos_canvas = self.app.plotcanvas.translate_coords(event.pos)
pos_canvas = self.app.plotcanvas.translate_coords(event_pos)
# delete the selection bounding box
self.delete_shape()
@ -178,7 +189,8 @@ class ToolMove(FlatCAMTool):
self.toggle()
return
except TypeError:
except TypeError as e:
log.debug("ToolMove.on_left_click() --> %s" % str(e))
self.app.inform.emit('[ERROR_NOTCL] %s' %
_('ToolMove.on_left_click() --> Error when mouse left click.'))
return
@ -195,7 +207,12 @@ class ToolMove(FlatCAMTool):
self.app.worker_task.emit({'fcn': worker_task, 'params': []})
def on_move(self, event):
pos_canvas = self.app.plotcanvas.translate_coords(event.pos)
if self.app.is_legacy is False:
event_pos = event.pos
else:
event_pos = (event.xdata, event.ydata)
pos_canvas = self.app.plotcanvas.translate_coords(event_pos)
# if GRID is active we need to get the snapped positions
if self.app.grid_status() == True:
@ -232,9 +249,9 @@ class ToolMove(FlatCAMTool):
self.toggle()
else:
# if we have an object selected then we can safely activate the mouse events
self.app.plotcanvas.graph_event_connect('mouse_move', self.on_move)
self.app.plotcanvas.graph_event_connect('mouse_press', self.on_left_click)
self.app.plotcanvas.graph_event_connect('key_release', self.on_key_press)
self.mm = self.app.plotcanvas.graph_event_connect('mouse_move', self.on_move)
self.mp = self.app.plotcanvas.graph_event_connect('mouse_press', self.on_left_click)
self.kr = self.app.plotcanvas.graph_event_connect('key_release', self.on_key_press)
# first get a bounding box to fit all
for obj in obj_list:
xmin, ymin, xmax, ymax = obj.bounds()

View File

@ -1202,16 +1202,24 @@ class NonCopperClear(FlatCAMTool, Gerber):
#
# 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)
# 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:
self.first_click = False
self.app.plotcanvas.graph_event_disconnect('mouse_release', on_mouse_release)
self.app.plotcanvas.graph_event_disconnect('mouse_move', on_mouse_move)
if self.app.is_legacy is False:
self.app.plotcanvas.graph_event_disconnect('mouse_release', on_mouse_release)
self.app.plotcanvas.graph_event_disconnect('mouse_move', on_mouse_move)
else:
self.app.plotcanvas.graph_event_disconnect(self.mr)
self.app.plotcanvas.graph_event_disconnect(self.mm)
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)
self.app.mp = self.app.plotcanvas.graph_event_connect('mouse_press',
self.app.on_mouse_click_over_plot)
self.app.mm = self.app.plotcanvas.graph_event_connect('mouse_move',
self.app.on_mouse_move_over_plot)
self.app.mr = self.app.plotcanvas.graph_event_connect('mouse_release',
self.app.on_mouse_click_release_over_plot)
if len(self.sel_rect) == 0:
return
@ -1251,13 +1259,17 @@ class NonCopperClear(FlatCAMTool, Gerber):
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)
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)
self.app.plotcanvas.graph_event_disconnect('mouse_release', self.app.on_mouse_click_release_over_plot)
else:
self.app.plotcanvas.graph_event_disconnect(self.app.mp)
self.app.plotcanvas.graph_event_disconnect(self.app.mm)
self.app.plotcanvas.graph_event_disconnect(self.app.mr)
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.graph_event_connect('mouse_release', on_mouse_release)
self.app.plotcanvas.graph_event_connect('mouse_move', on_mouse_move)
self.mr = self.app.plotcanvas.graph_event_connect('mouse_release', on_mouse_release)
self.mm = self.app.plotcanvas.graph_event_connect('mouse_move', on_mouse_move)
elif select_method == 'box':
self.bound_obj_name = self.box_combo.currentText()
# Get source object.

View File

@ -1017,12 +1017,18 @@ class ToolPaint(FlatCAMTool, Gerber):
overlap=overlap,
connect=connect,
contour=contour)
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.mp = self.app.plotcanvas.graph_event_connect('mouse_press',
self.app.on_mouse_click_over_plot)
self.app.mr = self.app.plotcanvas.graph_event_connect('mouse_release',
self.app.on_mouse_click_release_over_plot)
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)
if self.app.is_legacy is False:
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)
else:
self.app.plotcanvas.graph_event_disconnect(self.app.mr)
self.app.plotcanvas.graph_event_disconnect(self.app.mp)
self.mp = self.app.plotcanvas.graph_event_connect('mouse_press', doit)
elif select_method == "area":
self.app.inform.emit('[WARNING_NOTCL] %s' %
@ -1091,12 +1097,19 @@ class ToolPaint(FlatCAMTool, Gerber):
elif event.button == 2 and self.mouse_is_dragging is False:
self.first_click = False
self.app.plotcanvas.graph_event_disconnect('mouse_release', on_mouse_release)
self.app.plotcanvas.graph_event_disconnect('mouse_move', on_mouse_move)
if self.app.is_legacy is False:
self.app.plotcanvas.graph_event_disconnect('mouse_release', on_mouse_release)
self.app.plotcanvas.graph_event_disconnect('mouse_move', on_mouse_move)
else:
self.app.plotcanvas.graph_event_disconnect(self.mr)
self.app.plotcanvas.graph_event_disconnect(self.mm)
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)
self.app.mp = self.app.plotcanvas.graph_event_connect('mouse_press',
self.app.on_mouse_click_over_plot)
self.app.mm = self.app.plotcanvas.graph_event_connect('mouse_move',
self.app.on_mouse_move_over_plot)
self.app.mr = self.app.plotcanvas.graph_event_connect('mouse_release',
self.app.on_mouse_click_release_over_plot)
if len(self.sel_rect) == 0:
return
@ -1134,12 +1147,17 @@ class ToolPaint(FlatCAMTool, Gerber):
coords=(curr_pos[0], curr_pos[1]),
face_alpha=0.0)
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)
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)
self.app.plotcanvas.graph_event_disconnect('mouse_release', self.app.on_mouse_click_release_over_plot)
else:
self.app.plotcanvas.graph_event_disconnect(self.app.mp)
self.app.plotcanvas.graph_event_disconnect(self.app.mm)
self.app.plotcanvas.graph_event_disconnect(self.app.mr)
self.app.plotcanvas.graph_event_connect('mouse_release', on_mouse_release)
self.app.plotcanvas.graph_event_connect('mouse_move', on_mouse_move)
self.mr = self.app.plotcanvas.graph_event_connect('mouse_release', on_mouse_release)
self.mm = self.app.plotcanvas.graph_event_connect('mouse_move', on_mouse_move)
elif select_method == 'ref':
self.bound_obj_name = self.box_combo.currentText()