- remade the Snap Toolbar presence; now it is always active and situated in the Status Bar
This commit is contained in:
@@ -819,15 +819,13 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
|
||||
|
||||
self.snap_toolbar = QtWidgets.QToolBar(_('Grid Toolbar'))
|
||||
self.snap_toolbar.setObjectName('Snap_TB')
|
||||
self.addToolBar(self.snap_toolbar)
|
||||
|
||||
flat_settings = QSettings("Open Source", "FlatCAM")
|
||||
if flat_settings.contains("layout"):
|
||||
layout = flat_settings.value('layout', type=str)
|
||||
if layout == 'compact':
|
||||
self.removeToolBar(self.snap_toolbar)
|
||||
self.snap_toolbar.setMaximumHeight(30)
|
||||
self.splitter_left.addWidget(self.snap_toolbar)
|
||||
# self.addToolBar(self.snap_toolbar)
|
||||
self.snap_toolbar.setStyleSheet(
|
||||
"""
|
||||
QToolBar { padding: 0; }
|
||||
QToolBar QToolButton { padding: -2; margin: -2; }
|
||||
"""
|
||||
)
|
||||
|
||||
# ########################################################################
|
||||
# ########################## File Toolbar# ###############################
|
||||
@@ -2302,10 +2300,6 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
|
||||
self.fcinfo = FlatCAMInfoBar(app=self.app)
|
||||
self.infobar.addWidget(self.fcinfo, stretch=1)
|
||||
|
||||
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)
|
||||
|
||||
# self.rel_position_label = QtWidgets.QLabel(
|
||||
# "<b>Dx</b>: 0.0000 <b>Dy</b>: 0.0000 ")
|
||||
# self.rel_position_label.setMinimumWidth(110)
|
||||
@@ -2318,6 +2312,9 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
|
||||
# self.position_label.setToolTip(_("Absolute measurement.\nReference is (X=0, Y= 0) position"))
|
||||
# self.infobar.addWidget(self.position_label)
|
||||
|
||||
self.snap_toolbar.setMaximumHeight(24)
|
||||
self.infobar.addWidget(self.snap_toolbar)
|
||||
|
||||
self.units_label = QtWidgets.QLabel("[in]")
|
||||
self.units_label.setMargin(2)
|
||||
self.infobar.addWidget(self.units_label)
|
||||
@@ -2438,14 +2435,11 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
|
||||
del qsettings
|
||||
|
||||
self.lock_toolbar(lock=lock_state)
|
||||
self.on_grid_snap_triggered(state=True)
|
||||
|
||||
self.lock_action.triggered[bool].connect(self.lock_toolbar)
|
||||
|
||||
self.pref_open_button.clicked.connect(self.on_preferences_open_folder)
|
||||
self.clear_btn.clicked.connect(self.on_gui_clear)
|
||||
self.grid_snap_btn.triggered.connect(self.on_grid_snap_triggered)
|
||||
self.snap_infobar_label.clicked.connect(self.on_grid_icon_snap_clicked)
|
||||
|
||||
# to be used in the future
|
||||
# self.plot_tab_area.tab_attached.connect(lambda x: print(x))
|
||||
@@ -2455,29 +2449,6 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
|
||||
# %%%%%%%%%%%%%%%%% GUI Building FINISHED %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
# %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
|
||||
def on_grid_snap_triggered(self, state):
|
||||
"""
|
||||
|
||||
:param state: A parameter with the state of the grid, boolean
|
||||
|
||||
:return:
|
||||
"""
|
||||
if state:
|
||||
self.snap_infobar_label.setPixmap(QtGui.QPixmap(self.app.resource_location + '/snap_filled_16.png'))
|
||||
else:
|
||||
self.snap_infobar_label.setPixmap(QtGui.QPixmap(self.app.resource_location + '/snap_16.png'))
|
||||
|
||||
self.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.grid_snap_btn.trigger()
|
||||
|
||||
def eventFilter(self, obj, event):
|
||||
"""
|
||||
Filter the ToolTips display based on a Preferences setting
|
||||
@@ -2786,52 +2757,11 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
|
||||
self.aperture_move_btn = self.grb_edit_toolbar.addAction(
|
||||
QtGui.QIcon(self.app.resource_location + '/move32.png'), _("Move"))
|
||||
|
||||
# ########################################################################
|
||||
# ## Snap Toolbar # ##
|
||||
# ########################################################################
|
||||
|
||||
# Snap GRID toolbar is always active to facilitate usage of measurements done on GRID
|
||||
# self.addToolBar(self.snap_toolbar)
|
||||
self.grid_snap_btn = self.snap_toolbar.addAction(
|
||||
QtGui.QIcon(self.app.resource_location + '/grid32.png'), _('Snap to grid'))
|
||||
self.grid_gap_x_entry = FCEntry2()
|
||||
self.grid_gap_x_entry.setMaximumWidth(70)
|
||||
self.grid_gap_x_entry.setToolTip(_("Grid X snapping distance"))
|
||||
self.snap_toolbar.addWidget(self.grid_gap_x_entry)
|
||||
|
||||
self.grid_gap_y_entry = FCEntry2()
|
||||
self.grid_gap_y_entry.setMaximumWidth(70)
|
||||
self.grid_gap_y_entry.setToolTip(_("Grid Y snapping distance"))
|
||||
self.snap_toolbar.addWidget(self.grid_gap_y_entry)
|
||||
|
||||
self.grid_space_label = QtWidgets.QLabel(" ")
|
||||
self.snap_toolbar.addWidget(self.grid_space_label)
|
||||
self.grid_gap_link_cb = FCCheckBox()
|
||||
self.grid_gap_link_cb.setToolTip(_("When active, value on Grid_X\n"
|
||||
"is copied to the Grid_Y value."))
|
||||
self.snap_toolbar.addWidget(self.grid_gap_link_cb)
|
||||
|
||||
self.ois_grid = OptionalInputSection(self.grid_gap_link_cb, [self.grid_gap_y_entry], logic=False)
|
||||
|
||||
self.corner_snap_btn = self.snap_toolbar.addAction(
|
||||
QtGui.QIcon(self.app.resource_location + '/corner32.png'), _('Snap to corner'))
|
||||
|
||||
self.snap_max_dist_entry = FCEntry()
|
||||
self.snap_max_dist_entry.setMaximumWidth(70)
|
||||
self.snap_max_dist_entry.setToolTip(_("Max. magnet distance"))
|
||||
self.snap_magnet = self.snap_toolbar.addWidget(self.snap_max_dist_entry)
|
||||
|
||||
self.grid_snap_btn.setCheckable(True)
|
||||
self.corner_snap_btn.setCheckable(True)
|
||||
self.update_obj_btn.setEnabled(False)
|
||||
# start with GRID activated
|
||||
self.grid_snap_btn.trigger()
|
||||
|
||||
qsettings = QSettings("Open Source", "FlatCAM")
|
||||
if qsettings.contains("layout"):
|
||||
layout = qsettings.value('layout', type=str)
|
||||
|
||||
if layout == 'standard':
|
||||
if layout == 'standard' or layout == 'minimal':
|
||||
self.corner_snap_btn.setVisible(False)
|
||||
self.snap_magnet.setVisible(False)
|
||||
else:
|
||||
|
||||
@@ -150,17 +150,17 @@ class PlotCanvas(QtCore.QObject, VisPyCanvas):
|
||||
self.cursor_h_line = InfiniteLine(pos=None, color=c_color, vertical=False,
|
||||
parent=self.line_parent)
|
||||
|
||||
self.rect_hud = Rectangle(center=(90,45), color=self.rect_hud_color, border_color=self.rect_hud_color,
|
||||
width=170, height=80, radius=[5, 5, 5, 5], parent=None)
|
||||
self.rect_hud = Rectangle(center=(95,50), color=self.rect_hud_color, border_color=self.rect_hud_color,
|
||||
width=180, height=90, radius=[5, 5, 5, 5], parent=None)
|
||||
self.rect_hud.set_gl_state(depth_test=False)
|
||||
|
||||
# HUD Display
|
||||
self.hud_enabled = False
|
||||
|
||||
self.text_hud = Text('', color=self.text_hud_color, pos=(8, 45), method='gpu', anchor_x='left', parent=None)
|
||||
self.text_hud = Text('', color=self.text_hud_color, pos=(10, 50), method='gpu', anchor_x='left', parent=None)
|
||||
self.text_hud.font_size = 8
|
||||
units = self.fcapp.defaults["units"].lower()
|
||||
self.text_hud.text = 'Dx:\t%s [%s]\nDy:\t%s [%s]\nX: \t%s [%s]\nY: \t%s [%s]' % \
|
||||
self.text_hud.text = 'Dx:\t%s [%s]\nDy:\t%s [%s]\n\nX: \t%s [%s]\nY: \t%s [%s]' % \
|
||||
('0.0000', units, '0.0000', units, '0.0000', units, '0.0000', units)
|
||||
|
||||
if self.fcapp.defaults['global_hud'] is True:
|
||||
|
||||
@@ -654,7 +654,6 @@ class GeneralGUIPrefGroupUI(OptionsGroupUI):
|
||||
self.app.ui.removeToolBar(self.app.ui.exc_edit_toolbar)
|
||||
self.app.ui.removeToolBar(self.app.ui.geo_edit_toolbar)
|
||||
self.app.ui.removeToolBar(self.app.ui.grb_edit_toolbar)
|
||||
self.app.ui.removeToolBar(self.app.ui.snap_toolbar)
|
||||
self.app.ui.removeToolBar(self.app.ui.toolbarshell)
|
||||
except Exception:
|
||||
pass
|
||||
@@ -697,11 +696,6 @@ class GeneralGUIPrefGroupUI(OptionsGroupUI):
|
||||
self.app.ui.exc_edit_toolbar.setObjectName('ExcEditor_TB')
|
||||
self.app.ui.addToolBar(Qt.RightToolBarArea, self.app.ui.exc_edit_toolbar)
|
||||
|
||||
self.app.ui.snap_toolbar = QtWidgets.QToolBar('Grid Toolbar')
|
||||
self.app.ui.snap_toolbar.setObjectName('Snap_TB')
|
||||
self.app.ui.snap_toolbar.setMaximumHeight(30)
|
||||
self.app.ui.splitter_left.addWidget(self.app.ui.snap_toolbar)
|
||||
|
||||
self.app.ui.corner_snap_btn.setVisible(True)
|
||||
self.app.ui.snap_magnet.setVisible(True)
|
||||
else:
|
||||
@@ -743,18 +737,12 @@ class GeneralGUIPrefGroupUI(OptionsGroupUI):
|
||||
self.app.ui.grb_edit_toolbar.setObjectName('GrbEditor_TB')
|
||||
self.app.ui.addToolBar(self.app.ui.grb_edit_toolbar)
|
||||
|
||||
self.app.ui.snap_toolbar = QtWidgets.QToolBar('Grid Toolbar')
|
||||
self.app.ui.snap_toolbar.setObjectName('Snap_TB')
|
||||
# self.app.ui.snap_toolbar.setMaximumHeight(30)
|
||||
self.app.ui.addToolBar(self.app.ui.snap_toolbar)
|
||||
|
||||
self.app.ui.corner_snap_btn.setVisible(False)
|
||||
self.app.ui.snap_magnet.setVisible(False)
|
||||
|
||||
if current_layout == 'minimal':
|
||||
self.app.ui.toolbarview.setVisible(False)
|
||||
self.app.ui.toolbarshell.setVisible(False)
|
||||
self.app.ui.snap_toolbar.setVisible(False)
|
||||
self.app.ui.geo_edit_toolbar.setVisible(False)
|
||||
self.app.ui.grb_edit_toolbar.setVisible(False)
|
||||
self.app.ui.exc_edit_toolbar.setVisible(False)
|
||||
@@ -767,7 +755,6 @@ class GeneralGUIPrefGroupUI(OptionsGroupUI):
|
||||
self.app.connect_toolbar_signals()
|
||||
|
||||
self.app.ui.grid_snap_btn.setChecked(True)
|
||||
self.app.ui.on_grid_snap_triggered(state=True)
|
||||
|
||||
self.app.ui.grid_gap_x_entry.setText(str(self.app.defaults["global_gridx"]))
|
||||
self.app.ui.grid_gap_y_entry.setText(str(self.app.defaults["global_gridy"]))
|
||||
|
||||
Reference in New Issue
Block a user