- made the Grid icon in the status bar clickable and it will toggle the snap to grid function

This commit is contained in:
Marius Stanciu 2020-04-20 00:57:13 +03:00 committed by Marius
parent 5a5a18ef43
commit ecf61fdf6d
4 changed files with 70 additions and 15 deletions

View File

@ -2276,6 +2276,7 @@ class App(QtCore.QObject):
self.ui.plot_tab_area.tab_closed_signal.connect(self.on_plot_area_tab_closed)
self.ui.grid_snap_btn.triggered.connect(self.on_grid_snap_triggered)
self.ui.snap_infobar_label.clicked.connect(self.on_grid_icon_snap_clicked)
# signal to close the application
self.close_app_signal.connect(self.kill_app)
@ -12489,7 +12490,7 @@ class App(QtCore.QObject):
def on_zoom_fit(self, event):
"""
Callback for zoom-out request. This can be either from the corresponding
Callback for zoom-fit request. This can be either from the corresponding
toolbar button or the '1' key when the canvas is focused. Calls ``self.adjust_axes()``
with axes limits from the geometry bounds of all objects.
@ -12509,9 +12510,18 @@ class App(QtCore.QObject):
self.plotcanvas.adjust_axes(xmin, ymin, xmax, ymax)
def on_zoom_in(self):
"""
Callback for zoom-in request.
:return:
"""
self.plotcanvas.zoom(1 / float(self.defaults['global_zoom_ratio']))
def on_zoom_out(self):
"""
Callback for zoom-out request.
:return:
"""
self.plotcanvas.zoom(float(self.defaults['global_zoom_ratio']))
def disable_all_plots(self):
@ -12551,7 +12561,7 @@ class App(QtCore.QObject):
def enable_plots(self, objects):
"""
Disables plots
Enable plots
:param objects: list of Objects to be enabled
:return:
@ -12679,8 +12689,16 @@ class App(QtCore.QObject):
self.clear_pool()
def on_set_color_action_triggered(self):
"""
This slot gets called by clicking on the menu entry in the Set Color submenu of the context menu in Project Tab
:return:
"""
new_color = self.defaults['gerber_plot_fill']
act_name = self.sender().text()
clicked_action = self.sender()
assert isinstance(clicked_action, QAction), "Expected a QAction, got %s" % isinstance(clicked_action, QAction)
act_name = clicked_action.text()
sel_obj_list = self.collection.get_selected()
if not sel_obj_list:
@ -12783,12 +12801,35 @@ class App(QtCore.QObject):
)
def on_grid_snap_triggered(self, state):
"""
:param state: A parameter with the state of the grid, boolean
:return:
"""
if state:
self.ui.snap_infobar_label.setPixmap(QtGui.QPixmap(self.resource_location + '/snap_filled_16.png'))
else:
self.ui.snap_infobar_label.setPixmap(QtGui.QPixmap(self.resource_location + '/snap_16.png'))
self.ui.snap_infobar_label.clicked_state = state
def on_grid_icon_snap_clicked(self):
"""
Slot called by clicking a GUI element, in this case a FCLabel
:return:
"""
if isinstance(self.sender(), FCLabel):
self.ui.grid_snap_btn.trigger()
def generate_cnc_job(self, objects):
"""
Slot that will be called by clicking an entry in the contextual menu generated in the Project Tab tree
:param objects: Selected objects in the Project Tab
:return:
"""
self.report_usage("generate_cnc_job()")
# for obj in objects:

View File

@ -9,6 +9,10 @@ CAD program, and create G-Code for Isolation routing.
=================================================
20.04.2020
- made the Grid icon in the status bar clickable and it will toggle the snap to grid function
19.04.2020
- fixed a bug that did not allow to edit GUI elements of type FCDoubleSpinner if it contained the percent symbol

View File

@ -2268,7 +2268,7 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
self.fcinfo = FlatCAMInfoBar(app=self.app)
self.infobar.addWidget(self.fcinfo, stretch=1)
self.snap_infobar_label = QtWidgets.QLabel()
self.snap_infobar_label = FCLabel()
self.snap_infobar_label.setPixmap(QtGui.QPixmap(self.app.resource_location + '/snap_16.png'))
self.infobar.addWidget(self.snap_infobar_label)

View File

@ -1417,9 +1417,19 @@ class FCButton(QtWidgets.QPushButton):
class FCLabel(QtWidgets.QLabel):
clicked = QtCore.pyqtSignal(bool)
def __init__(self, parent=None):
super(FCLabel, self).__init__(parent)
# for the usage of this label as a clickable label, to know that current state
self.clicked_state = False
def mousePressEvent(self, ev: QtGui.QMouseEvent) -> None:
self.clicked_state = not self.clicked_state
self.clicked.emit(self.clicked_state)
def get_value(self):
return self.text()