Просмотр исходного кода

- remade the Snap Toolbar presence; now it is always active and situated in the Status Bar

Marius Stanciu 5 лет назад
Родитель
Сommit
d7677b5e08

+ 1 - 0
CHANGELOG.md

@@ -12,6 +12,7 @@ CHANGELOG for FlatCAM beta
 - removed the labels in status bar that display X,Y positions and replaced it with a HUD display on canvas (combo key SHIFT+H) will toggle the display of the HUD
 - made the HUD work in Legacy2D mode
 - fixed situation when the mouse cursor is outside of the canvas and no therefore returning None values
+- remade the Snap Toolbar presence; now it is always active and situated in the Status Bar
 
 10.05.2020
 

+ 8 - 4
FlatCAMApp.py

@@ -2064,18 +2064,22 @@ class App(QtCore.QObject):
         """
 
         # Toolbar
+
+        # File Toolbar Signals
         # self.ui.file_new_btn.triggered.connect(self.on_file_new)
         self.ui.file_open_btn.triggered.connect(self.on_file_openproject)
         self.ui.file_save_btn.triggered.connect(self.on_file_saveproject)
         self.ui.file_open_gerber_btn.triggered.connect(self.on_fileopengerber)
         self.ui.file_open_excellon_btn.triggered.connect(self.on_fileopenexcellon)
 
+        # View Toolbar Signals
         self.ui.clear_plot_btn.triggered.connect(self.clear_plots)
         self.ui.replot_btn.triggered.connect(self.plot_all)
         self.ui.zoom_fit_btn.triggered.connect(self.on_zoom_fit)
         self.ui.zoom_in_btn.triggered.connect(lambda: self.plotcanvas.zoom(1 / 1.5))
         self.ui.zoom_out_btn.triggered.connect(lambda: self.plotcanvas.zoom(1.5))
 
+        # Edit Toolbar Signals
         self.ui.newgeo_btn.triggered.connect(self.new_geometry_object)
         self.ui.newgrb_btn.triggered.connect(self.new_gerber_object)
         self.ui.newexc_btn.triggered.connect(self.new_excellon_object)
@@ -2092,6 +2096,7 @@ class App(QtCore.QObject):
         self.ui.jmp_btn.triggered.connect(self.on_jump_to)
         self.ui.locate_btn.triggered.connect(lambda: self.on_locate(obj=self.collection.get_active()))
 
+        # Scripting Toolbar Signals
         self.ui.shell_btn.triggered.connect(self.toggle_shell)
         self.ui.new_script_btn.triggered.connect(self.on_filenewscript)
         self.ui.open_script_btn.triggered.connect(self.on_fileopenscript)
@@ -4573,7 +4578,6 @@ class App(QtCore.QObject):
         self.defaults.report_usage("on_toggle_grid()")
 
         self.ui.grid_snap_btn.trigger()
-        self.ui.on_grid_snap_triggered(state=True)
 
     def on_toggle_grid_lines(self):
         self.defaults.report_usage("on_toggle_grd_lines()")
@@ -5390,7 +5394,7 @@ class App(QtCore.QObject):
 
         units = self.defaults["units"].lower()
         self.plotcanvas.text_hud.text = \
-            'Dx:\t{:<.4f} [{:s}]\nDy:\t{:<.4f} [{:s}]\nX:  \t{:<.4f} [{:s}]\nY:  \t{:<.4f} [{:s}]'.format(
+            'Dx:\t{:<.4f} [{:s}]\nDy:\t{:<.4f} [{:s}]\n\nX:  \t{:<.4f} [{:s}]\nY:  \t{:<.4f} [{:s}]'.format(
                 dx, units, dy, units, location[0], units, location[1], units)
 
         self.inform.emit('[success] %s' % _("Done."))
@@ -5544,7 +5548,7 @@ class App(QtCore.QObject):
 
         units = self.defaults["units"].lower()
         self.plotcanvas.text_hud.text = \
-            'Dx:\t{:<.4f} [{:s}]\nDy:\t{:<.4f} [{:s}]\nX:  \t{:<.4f} [{:s}]\nY:  \t{:<.4f} [{:s}]'.format(
+            'Dx:\t{:<.4f} [{:s}]\nDy:\t{:<.4f} [{:s}]\n\nX:  \t{:<.4f} [{:s}]\nY:  \t{:<.4f} [{:s}]'.format(
                 self.dx, units, self.dy, units, location[0], units, location[1], units)
 
         self.inform.emit('[success] %s' % _("Done."))
@@ -6773,7 +6777,7 @@ class App(QtCore.QObject):
 
                 units = self.defaults["units"].lower()
                 self.plotcanvas.text_hud.text = \
-                    'Dx:\t{:<.4f} [{:s}]\nDy:\t{:<.4f} [{:s}]\nX:  \t{:<.4f} [{:s}]\nY:  \t{:<.4f} [{:s}]'.format(
+                    'Dx:\t{:<.4f} [{:s}]\nDy:\t{:<.4f} [{:s}]\n\nX:  \t{:<.4f} [{:s}]\nY:  \t{:<.4f} [{:s}]'.format(
                         self.dx, units, self.dy, units, pos[0], units, pos[1], units)
 
                 self.mouse = [pos[0], pos[1]]

+ 1 - 1
FlatCAMCommon.py

@@ -478,7 +478,7 @@ class ExclusionAreas(QtCore.QObject):
 
         units = self.app.defaults["units"].lower()
         self.app.plotcanvas.text_hud.text = \
-            'Dx:\t{:<.4f} [{:s}]\nDy:\t{:<.4f} [{:s}]\nX:  \t{:<.4f} [{:s}]\nY:  \t{:<.4f} [{:s}]'.format(
+            'Dx:\t{:<.4f} [{:s}]\nDy:\t{:<.4f} [{:s}]\n\nX:  \t{:<.4f} [{:s}]\nY:  \t{:<.4f} [{:s}]'.format(
                 self.app.dx, units, self.app.dy, units, curr_pos[0], units, curr_pos[1], units)
 
         if self.obj_type == 'excellon':

+ 1 - 2
flatcamEditors/FlatCAMExcEditor.py

@@ -2837,7 +2837,6 @@ class FlatCAMExcEditor(QtCore.QObject):
         # start with GRID toolbar activated
         if self.app.ui.grid_snap_btn.isChecked() is False:
             self.app.ui.grid_snap_btn.trigger()
-            self.app.ui.on_grid_snap_triggered(state=True)
 
         self.app.ui.popmenu_disable.setVisible(False)
         self.app.ui.cmenu_newmenu.menuAction().setVisible(False)
@@ -3815,7 +3814,7 @@ class FlatCAMExcEditor(QtCore.QObject):
 
         units = self.app.defaults["units"].lower()
         self.plotcanvas.text_hud.text = \
-            'Dx:\t{:<.4f} [{:s}]\nDy:\t{:<.4f} [{:s}]\nX:  \t{:<.4f} [{:s}]\nY:  \t{:<.4f} [{:s}]'.format(
+            'Dx:\t{:<.4f} [{:s}]\nDy:\t{:<.4f} [{:s}]\n\nX:  \t{:<.4f} [{:s}]\nY:  \t{:<.4f} [{:s}]'.format(
                 self.app.dx, units, self.app.dy, units, x, units, y, units)
 
         # ## Utility geometry (animated)

+ 1 - 2
flatcamEditors/FlatCAMGeoEditor.py

@@ -4110,7 +4110,6 @@ class FlatCAMGeoEditor(QtCore.QObject):
         # start with GRID toolbar activated
         if self.app.ui.grid_snap_btn.isChecked() is False:
             self.app.ui.grid_snap_btn.trigger()
-            self.app.ui.on_grid_snap_triggered(state=True)
 
     def on_buffer_tool(self):
         buff_tool = BufferSelectionTool(self.app, self)
@@ -4286,7 +4285,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
 
         units = self.app.defaults["units"].lower()
         self.plotcanvas.text_hud.text = \
-            'Dx:\t{:<.4f} [{:s}]\nDy:\t{:<.4f} [{:s}]\nX:  \t{:<.4f} [{:s}]\nY:  \t{:<.4f} [{:s}]'.format(
+            'Dx:\t{:<.4f} [{:s}]\nDy:\t{:<.4f} [{:s}]\n\nX:  \t{:<.4f} [{:s}]\nY:  \t{:<.4f} [{:s}]'.format(
                 self.app.dx, units, self.app.dy, units, x, units, y, units)
 
         if event.button == 1 and event_is_dragging and isinstance(self.active_tool, FCEraser):

+ 1 - 2
flatcamEditors/FlatCAMGrbEditor.py

@@ -3703,7 +3703,6 @@ class FlatCAMGrbEditor(QtCore.QObject):
         # start with GRID toolbar activated
         if self.app.ui.grid_snap_btn.isChecked() is False:
             self.app.ui.grid_snap_btn.trigger()
-            self.app.ui.on_grid_snap_triggered(state=True)
 
         # adjust the visibility of some of the canvas context menu
         self.app.ui.popmenu_edit.setVisible(False)
@@ -4789,7 +4788,7 @@ class FlatCAMGrbEditor(QtCore.QObject):
 
         units = self.app.defaults["units"].lower()
         self.plotcanvas.text_hud.text = \
-            'Dx:\t{:<.4f} [{:s}]\nDy:\t{:<.4f} [{:s}]\nX:  \t{:<.4f} [{:s}]\nY:  \t{:<.4f} [{:s}]'.format(
+            'Dx:\t{:<.4f} [{:s}]\nDy:\t{:<.4f} [{:s}]\n\nX:  \t{:<.4f} [{:s}]\nY:  \t{:<.4f} [{:s}]'.format(
                 self.app.dx, units, self.app.dy, units, x, units, y, units)
 
         self.update_utility_geometry(data=(x, y))

+ 11 - 81
flatcamGUI/FlatCAMGUI.py

@@ -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&nbsp;&nbsp;   <b>Dy</b>: 0.0000&nbsp;&nbsp;&nbsp;&nbsp;")
         # 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:

+ 4 - 4
flatcamGUI/PlotCanvas.py

@@ -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:

+ 0 - 13
flatcamGUI/preferences/general/GeneralGUIPrefGroupUI.py

@@ -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"]))

+ 1 - 1
flatcamTools/ToolCopperThieving.py

@@ -924,7 +924,7 @@ class ToolCopperThieving(FlatCAMTool):
 
         units = self.app.defaults["units"].lower()
         self.plotcanvas.text_hud.text = \
-            'Dx:\t{:<.4f} [{:s}]\nDy:\t{:<.4f} [{:s}]\nX:  \t{:<.4f} [{:s}]\nY:  \t{:<.4f} [{:s}]'.format(
+            'Dx:\t{:<.4f} [{:s}]\nDy:\t{:<.4f} [{:s}]\n\nX:  \t{:<.4f} [{:s}]\nY:  \t{:<.4f} [{:s}]'.format(
                 self.app.dx, units, self.app.dy, units, curr_pos[0], units, curr_pos[1], units)
 
         # draw the utility geometry

+ 1 - 1
flatcamTools/ToolDistance.py

@@ -552,7 +552,7 @@ class Distance(FlatCAMTool):
 
             units = self.app.defaults["units"].lower()
             self.plotcanvas.text_hud.text = \
-                'Dx:\t{:<.4f} [{:s}]\nDy:\t{:<.4f} [{:s}]\nX:  \t{:<.4f} [{:s}]\nY:  \t{:<.4f} [{:s}]'.format(
+                'Dx:\t{:<.4f} [{:s}]\nDy:\t{:<.4f} [{:s}]\n\nX:  \t{:<.4f} [{:s}]\nY:  \t{:<.4f} [{:s}]'.format(
                     0.0000, units, 0.0000, units, pos[0], units, pos[1], units)
 
             if self.rel_point1 is not None:

+ 1 - 1
flatcamTools/ToolNCC.py

@@ -1839,7 +1839,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
 
         units = self.app.defaults["units"].lower()
         self.plotcanvas.text_hud.text = \
-            'Dx:\t{:<.4f} [{:s}]\nDy:\t{:<.4f} [{:s}]\nX:  \t{:<.4f} [{:s}]\nY:  \t{:<.4f} [{:s}]'.format(
+            'Dx:\t{:<.4f} [{:s}]\nDy:\t{:<.4f} [{:s}]\n\nX:  \t{:<.4f} [{:s}]\nY:  \t{:<.4f} [{:s}]'.format(
                 self.app.dx, units, self.app.dy, units, curr_pos[0], units, curr_pos[1], units)
 
         # draw the utility geometry

+ 1 - 1
flatcamTools/ToolPaint.py

@@ -1738,7 +1738,7 @@ class ToolPaint(FlatCAMTool, Gerber):
 
         units = self.app.defaults["units"].lower()
         self.plotcanvas.text_hud.text = \
-            'Dx:\t{:<.4f} [{:s}]\nDy:\t{:<.4f} [{:s}]\nX:  \t{:<.4f} [{:s}]\nY:  \t{:<.4f} [{:s}]'.format(
+            'Dx:\t{:<.4f} [{:s}]\nDy:\t{:<.4f} [{:s}]\n\nX:  \t{:<.4f} [{:s}]\nY:  \t{:<.4f} [{:s}]'.format(
                 self.app.dx, units, self.app.dy, units, curr_pos[0], units, curr_pos[1], units)
 
         # draw the utility geometry