Procházet zdrojové kódy

- added a toggle Grid button to the canvas context menu in the Grids submenu

Marius Stanciu před 6 roky
rodič
revize
bc3da37e81
5 změnil soubory, kde provedl 24 přidání a 13 odebrání
  1. 9 0
      FlatCAMApp.py
  2. 1 0
      FlatCAMCommon.py
  3. 4 0
      README.md
  4. 1 4
      flatcamEditors/FlatCAMGeoEditor.py
  5. 9 9
      flatcamGUI/FlatCAMGUI.py

+ 9 - 0
FlatCAMApp.py

@@ -5193,6 +5193,14 @@ class App(QtCore.QObject):
         self.ui.cmenu_gridmenu.clear()
         sorted_list = sorted(self.defaults["global_grid_context_menu"][str(units)])
 
+        grid_toggle = self.ui.cmenu_gridmenu.addAction(QtGui.QIcon('share/grid32_menu.png'), _("Grid On/Off"))
+        grid_toggle.setCheckable(True)
+        if self.grid_status():
+            grid_toggle.setChecked(True)
+        else:
+            grid_toggle.setChecked(False)
+
+        self.ui.cmenu_gridmenu.addSeparator()
         for grid in sorted_list:
             action = self.ui.cmenu_gridmenu.addAction(QtGui.QIcon('share/grid32_menu.png'), "%s" % str(grid))
             action.triggered.connect(self.set_grid)
@@ -5202,6 +5210,7 @@ class App(QtCore.QObject):
         grid_delete = self.ui.cmenu_gridmenu.addAction(QtGui.QIcon('share/delete32.png'), _("Delete"))
         grid_add.triggered.connect(self.on_grid_add)
         grid_delete.triggered.connect(self.on_grid_delete)
+        grid_toggle.triggered.connect(lambda: self.ui.grid_snap_btn.trigger())
 
     def set_grid(self):
         self.ui.grid_gap_x_entry.setText(self.sender().text())

+ 1 - 0
FlatCAMCommon.py

@@ -6,6 +6,7 @@
 # MIT Licence                                              #
 ############################################################
 
+
 class LoudDict(dict):
     """
     A Dictionary with a callback for

+ 4 - 0
README.md

@@ -9,6 +9,10 @@ CAD program, and create G-Code for Isolation routing.
 
 =================================================
 
+24.05.2019
+
+- added a toggle Grid button to the canvas context menu in the Grids submenu
+
 23.05.2019
 
 - fixed bug in Gerber editor FCDisk and FCSemiDisc that the resulting geometry was not stored into the '0' aperture where all the solids are stored

+ 1 - 4
flatcamEditors/FlatCAMGeoEditor.py

@@ -3373,10 +3373,7 @@ class FlatCAMGeoEditor(QtCore.QObject):
 
     def toolbar_tool_toggle(self, key):
         self.options[key] = self.sender().isChecked()
-        if self.options[key] == True:
-            return 1
-        else:
-            return 0
+        return 1 if self.options[key] == True else 0
 
     def clear(self):
         self.active_tool = None

+ 9 - 9
flatcamGUI/FlatCAMGUI.py

@@ -516,9 +516,9 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
         self.exc_editor_menu.menuAction().setVisible(False)
         self.exc_editor_menu.setDisabled(True)
 
-        ################################
-        ### Project Tab Context menu ###
-        ################################
+        # ###############################
+        # ## Project Tab Context menu ###
+        # ###############################
 
         self.menuproject = QtWidgets.QMenu()
         self.menuprojectenable = self.menuproject.addAction(QtGui.QIcon('share/replot32.png'), _('Enable Plot'))
@@ -535,9 +535,9 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
 
         self.menuprojectproperties = self.menuproject.addAction(QtGui.QIcon('share/properties32.png'), _('Properties'))
 
-        ################
-        ### Splitter ###
-        ################
+        # ###############
+        # ## Splitter ###
+        # ###############
 
         # IMPORTANT #
         # The order: SPITTER -> NOTEBOOK -> SNAP TOOLBAR is important and without it the GUI will not be initialized as
@@ -1574,9 +1574,9 @@ class FlatCAMGUI(QtWidgets.QMainWindow):
         self.sh_hlay.addWidget(self.sh_editor)
 
 
-        ##############################################################
-        ### HERE WE BUILD THE CONTEXT MENU FOR RMB CLICK ON CANVAS ###
-        ##############################################################
+        # #############################################################
+        # ## HERE WE BUILD THE CONTEXT MENU FOR RMB CLICK ON CANVAS ###
+        # #############################################################
         self.popMenu = FCMenu()
 
         self.popmenu_disable = self.popMenu.addAction(QtGui.QIcon('share/clear_plot32.png'), _("Disable"))