- made the mouse cursor (big, small) change in real time for both graphic engines

This commit is contained in:
Marius Stanciu
2019-09-27 17:19:44 +03:00
parent 7b9907fa1d
commit 537b843a04
4 changed files with 41 additions and 6 deletions

View File

@@ -6428,13 +6428,21 @@ class App(QtCore.QObject):
:param val: type of mouse cursor, set in Preferences ('small' or 'big') :param val: type of mouse cursor, set in Preferences ('small' or 'big')
:return: None :return: None
""" """
self.app_cursor.enabled = False
if val == 'small': if val == 'small':
self.ui.general_defaults_form.general_gui_set_group.cursor_size_entry.setDisabled(False) self.ui.general_defaults_form.general_gui_set_group.cursor_size_entry.setDisabled(False)
self.ui.general_defaults_form.general_gui_set_group.cursor_size_lbl.setDisabled(False) self.ui.general_defaults_form.general_gui_set_group.cursor_size_lbl.setDisabled(False)
self.app_cursor = self.plotcanvas.new_cursor()
else: else:
self.ui.general_defaults_form.general_gui_set_group.cursor_size_entry.setDisabled(True) self.ui.general_defaults_form.general_gui_set_group.cursor_size_entry.setDisabled(True)
self.ui.general_defaults_form.general_gui_set_group.cursor_size_lbl.setDisabled(True) self.ui.general_defaults_form.general_gui_set_group.cursor_size_lbl.setDisabled(True)
self.app_cursor = self.plotcanvas.new_cursor(big=True)
if self.ui.grid_snap_btn.isChecked():
self.app_cursor.enabled = True
else:
self.app_cursor.enabled = False
def on_cnc_custom_parameters(self, signal_text): def on_cnc_custom_parameters(self, signal_text):
if signal_text == 'Parameters': if signal_text == 'Parameters':

View File

@@ -17,6 +17,7 @@ CAD program, and create G-Code for Isolation routing.
- removed the line that remove the spaces from the path parameter in the Tcl commands that open something (Gerber, Gcode, Excellon) - removed the line that remove the spaces from the path parameter in the Tcl commands that open something (Gerber, Gcode, Excellon)
- fixed issue with the old SysTray icon not hidden when the application is restarted programmatically - fixed issue with the old SysTray icon not hidden when the application is restarted programmatically
- if an object is edited but the result is not saved, the app will reload the edited object UI and set the Selected tab as active - if an object is edited but the result is not saved, the app will reload the edited object UI and set the Selected tab as active
- made the mouse cursor (big, small) change in real time for both graphic engines
27.09.2019 27.09.2019

View File

@@ -196,13 +196,31 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas):
return ShapeCollection(parent=self.view.scene, pool=self.fcapp.pool, **kwargs) return ShapeCollection(parent=self.view.scene, pool=self.fcapp.pool, **kwargs)
def new_cursor(self, big=None): def new_cursor(self, big=None):
"""
Will create a mouse cursor pointer on canvas
:param big: if True will create a mouse cursor made out of infinite lines
:return: the mouse cursor object
"""
if big is True: if big is True:
self.c = CursorBig() self.c = CursorBig()
# in case there are multiple new_cursor calls, best to disconnect first the signals
try:
self.c.mouse_state_updated.disconnect(self.on_mouse_state)
except (TypeError, AttributeError):
pass
try:
self.c.mouse_position_updated.disconnect(self.on_mouse_position)
except (TypeError, AttributeError):
pass
self.c.mouse_state_updated.connect(self.on_mouse_state) self.c.mouse_state_updated.connect(self.on_mouse_state)
self.c.mouse_position_updated.connect(self.on_mouse_position) self.c.mouse_position_updated.connect(self.on_mouse_position)
else: else:
self.c = Cursor(pos=np.empty((0, 2)), parent=self.view.scene) self.c = Cursor(pos=np.empty((0, 2)), parent=self.view.scene)
self.c.antialias = 0 self.c.antialias = 0
return self.c return self.c
def on_mouse_state(self, state): def on_mouse_state(self, state):

View File

@@ -268,6 +268,9 @@ class PlotCanvasLegacy(QtCore.QObject):
self.big_cursor = True self.big_cursor = True
self.ch_line = self.axes.axhline(color=(0.0, 0.0, 0.0), linewidth=1) self.ch_line = self.axes.axhline(color=(0.0, 0.0, 0.0), linewidth=1)
self.cv_line = self.axes.axvline(color=(0.0, 0.0, 0.0), linewidth=1) self.cv_line = self.axes.axvline(color=(0.0, 0.0, 0.0), linewidth=1)
else:
self.big_cursor = False
c = FakeCursor() c = FakeCursor()
c.mouse_state_updated.connect(self.clear_cursor) c.mouse_state_updated.connect(self.clear_cursor)
@@ -311,6 +314,11 @@ class PlotCanvasLegacy(QtCore.QObject):
if state is True: if state is True:
self.draw_cursor(x_pos=self.mouse[0], y_pos=self.mouse[1]) self.draw_cursor(x_pos=self.mouse[0], y_pos=self.mouse[1])
else: else:
if self.big_cursor is True:
self.ch_line.remove()
self.cv_line.remove()
self.canvas.draw_idle()
self.canvas.restore_region(self.background) self.canvas.restore_region(self.background)
self.canvas.blit(self.axes.bbox) self.canvas.blit(self.axes.bbox)