- 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
This commit is contained in:
@@ -7640,7 +7640,7 @@ class App(QtCore.QObject):
|
|||||||
self.app_cursor.set_data(np.asarray([(pos[0], pos[1])]),
|
self.app_cursor.set_data(np.asarray([(pos[0], pos[1])]),
|
||||||
symbol='++', edge_color='black', size=20)
|
symbol='++', edge_color='black', size=20)
|
||||||
else:
|
else:
|
||||||
self.app_cursor.set_data((pos[0], pos[1]))
|
self.app_cursor.set_data(event, (pos[0], pos[1]))
|
||||||
else:
|
else:
|
||||||
pos = (pos_canvas[0], pos_canvas[1])
|
pos = (pos_canvas[0], pos_canvas[1])
|
||||||
|
|
||||||
|
|||||||
@@ -15,6 +15,8 @@ CAD program, and create G-Code for Isolation routing.
|
|||||||
- legacy graphic engine - made the mouse events work (click, release, doubleclick, dragging)
|
- 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 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
|
- legacy graphic engine - made the mouse cursor work (enabled/disabled, position report); snapping is not moving the cursor yet
|
||||||
|
- 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
|
||||||
|
|
||||||
19.09.2019
|
19.09.2019
|
||||||
|
|
||||||
|
|||||||
@@ -138,8 +138,8 @@ class PlotCanvasLegacy(QtCore.QObject):
|
|||||||
self.axes = self.figure.add_axes([0.05, 0.05, 0.9, 0.9], label="base", alpha=0.0)
|
self.axes = self.figure.add_axes([0.05, 0.05, 0.9, 0.9], label="base", alpha=0.0)
|
||||||
self.axes.set_aspect(1)
|
self.axes.set_aspect(1)
|
||||||
self.axes.grid(True)
|
self.axes.grid(True)
|
||||||
self.axes.axhline(color='Black')
|
self.axes.axhline(color=(0.70, 0.3, 0.3), linewidth=2)
|
||||||
self.axes.axvline(color='Black')
|
self.axes.axvline(color=(0.70, 0.3, 0.3), linewidth=2)
|
||||||
|
|
||||||
# The canvas is the top level container (FigureCanvasQTAgg)
|
# The canvas is the top level container (FigureCanvasQTAgg)
|
||||||
self.canvas = FigureCanvas(self.figure)
|
self.canvas = FigureCanvas(self.figure)
|
||||||
@@ -590,15 +590,19 @@ class PlotCanvasLegacy(QtCore.QObject):
|
|||||||
return width / xpx, height / ypx
|
return width / xpx, height / ypx
|
||||||
|
|
||||||
|
|
||||||
class MplCursor():
|
class MplCursor(Cursor):
|
||||||
|
|
||||||
def __init__(self, axes, color='red', linewidth=1):
|
def __init__(self, axes, color='red', linewidth=1):
|
||||||
|
|
||||||
|
super().__init__(ax=axes, useblit=True, color=color, linewidth=linewidth)
|
||||||
self._enabled = True
|
self._enabled = True
|
||||||
|
|
||||||
self.axes = axes
|
self.axes = axes
|
||||||
self.color = color
|
self.color = color
|
||||||
self.linewidth = linewidth
|
self.linewidth = linewidth
|
||||||
self.cursor = Cursor(self.axes, useblit=True, color=self.color, linewidth=self.linewidth)
|
|
||||||
|
self.x = None
|
||||||
|
self.y = None
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def enabled(self):
|
def enabled(self):
|
||||||
@@ -607,12 +611,39 @@ class MplCursor():
|
|||||||
@enabled.setter
|
@enabled.setter
|
||||||
def enabled(self, value):
|
def enabled(self, value):
|
||||||
self._enabled = value
|
self._enabled = value
|
||||||
self.cursor.visible = self._enabled
|
self.visible = self._enabled
|
||||||
self.cursor.canvas.draw()
|
self.canvas.draw()
|
||||||
|
|
||||||
def set_data(self, pos):
|
def onmove(self, event):
|
||||||
self.cursor.linev.set_xdata((pos[0], pos[0]))
|
pass
|
||||||
self.cursor.lineh.set_ydata(([pos[1]], pos[1]))
|
|
||||||
|
def set_data(self, event, pos):
|
||||||
|
"""Internal event handler to draw the cursor when the mouse moves."""
|
||||||
|
self.x = pos[0]
|
||||||
|
self.y = pos[1]
|
||||||
|
|
||||||
|
if self.ignore(event):
|
||||||
|
return
|
||||||
|
if not self.canvas.widgetlock.available(self):
|
||||||
|
return
|
||||||
|
if event.inaxes != self.ax:
|
||||||
|
self.linev.set_visible(False)
|
||||||
|
self.lineh.set_visible(False)
|
||||||
|
|
||||||
|
if self.needclear:
|
||||||
|
self.canvas.draw()
|
||||||
|
self.needclear = False
|
||||||
|
return
|
||||||
|
self.needclear = True
|
||||||
|
if not self.visible:
|
||||||
|
return
|
||||||
|
self.linev.set_xdata((self.x, self.x))
|
||||||
|
|
||||||
|
self.lineh.set_ydata((self.y, self.y))
|
||||||
|
self.linev.set_visible(self.visible and self.vertOn)
|
||||||
|
self.lineh.set_visible(self.visible and self.horizOn)
|
||||||
|
|
||||||
|
self._update()
|
||||||
|
|
||||||
|
|
||||||
class ShapeCollectionLegacy():
|
class ShapeCollectionLegacy():
|
||||||
|
|||||||
Reference in New Issue
Block a user