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

- added 2Sided Tool default values in Edit -> Preferences -> Tools

Marius Stanciu 7 лет назад
Родитель
Сommit
369d9256da
4 измененных файлов с 106 добавлено и 20 удалено
  1. 21 5
      FlatCAMApp.py
  2. 65 1
      FlatCAMGUI.py
  3. 1 0
      README.md
  4. 19 14
      flatcamTools/ToolDblSided.py

+ 21 - 5
FlatCAMApp.py

@@ -409,7 +409,11 @@ class App(QtCore.QObject):
             "tools_paintmethod": self.tools_defaults_form.tools_paint_group.paintmethod_combo,
             "tools_paintmethod": self.tools_defaults_form.tools_paint_group.paintmethod_combo,
             "tools_selectmethod": self.tools_defaults_form.tools_paint_group.selectmethod_combo,
             "tools_selectmethod": self.tools_defaults_form.tools_paint_group.selectmethod_combo,
             "tools_pathconnect": self.tools_defaults_form.tools_paint_group.pathconnect_cb,
             "tools_pathconnect": self.tools_defaults_form.tools_paint_group.pathconnect_cb,
-            "tools_paintcontour": self.tools_defaults_form.tools_paint_group.contour_cb
+            "tools_paintcontour": self.tools_defaults_form.tools_paint_group.contour_cb,
+
+            "tools_2sided_mirror_axis": self.tools_defaults_form.tools_2sided_group.mirror_axis_radio,
+            "tools_2sided_axis_loc": self.tools_defaults_form.tools_2sided_group.axis_location_radio,
+            "tools_2sided_drilldia": self.tools_defaults_form.tools_2sided_group.drill_dia_entry,
         }
         }
         # loads postprocessors
         # loads postprocessors
         self.postprocessors = load_postprocessors(self)
         self.postprocessors = load_postprocessors(self)
@@ -570,7 +574,11 @@ class App(QtCore.QObject):
             "tools_paintmethod": "seed",
             "tools_paintmethod": "seed",
             "tools_selectmethod": "single",
             "tools_selectmethod": "single",
             "tools_pathconnect": True,
             "tools_pathconnect": True,
-            "tools_paintcontour": True
+            "tools_paintcontour": True,
+
+            "tools_2sided_mirror_axis": "X",
+            "tools_2sided_axis_loc": "point",
+            "tools_2sided_drilldia": 1,
 
 
         })
         })
 
 
@@ -686,7 +694,7 @@ class App(QtCore.QObject):
             "tools_cutoutmargin": self.tools_options_form.tools_cutout_group.cutout_margin_entry,
             "tools_cutoutmargin": self.tools_options_form.tools_cutout_group.cutout_margin_entry,
             "tools_cutoutgapsize": self.tools_options_form.tools_cutout_group.cutout_gap_entry,
             "tools_cutoutgapsize": self.tools_options_form.tools_cutout_group.cutout_gap_entry,
             "tools_gaps_rect": self.tools_options_form.tools_cutout_group.gaps_radio,
             "tools_gaps_rect": self.tools_options_form.tools_cutout_group.gaps_radio,
-            "tools_gaps_rect": self.tools_options_form.tools_cutout_group.gaps_combo,
+            "tools_gaps_ff": self.tools_options_form.tools_cutout_group.gaps_combo,
 
 
             "tools_painttooldia": self.tools_options_form.tools_paint_group.painttooldia_entry,
             "tools_painttooldia": self.tools_options_form.tools_paint_group.painttooldia_entry,
             "tools_paintoverlap": self.tools_options_form.tools_paint_group.paintoverlap_entry,
             "tools_paintoverlap": self.tools_options_form.tools_paint_group.paintoverlap_entry,
@@ -694,7 +702,11 @@ class App(QtCore.QObject):
             "tools_paintmethod": self.tools_options_form.tools_paint_group.paintmethod_combo,
             "tools_paintmethod": self.tools_options_form.tools_paint_group.paintmethod_combo,
             "tools_selectmethod": self.tools_options_form.tools_paint_group.selectmethod_combo,
             "tools_selectmethod": self.tools_options_form.tools_paint_group.selectmethod_combo,
             "tools_pathconnect": self.tools_options_form.tools_paint_group.pathconnect_cb,
             "tools_pathconnect": self.tools_options_form.tools_paint_group.pathconnect_cb,
-            "tools_paintcontour": self.tools_options_form.tools_paint_group.contour_cb
+            "tools_paintcontour": self.tools_options_form.tools_paint_group.contour_cb,
+
+            "tools_2sided_mirror_axis": self.tools_options_form.tools_2sided_group.mirror_axis_radio,
+            "tools_2sided_axis_loc": self.tools_options_form.tools_2sided_group.axis_location_radio,
+            "tools_2sided_drilldia": self.tools_options_form.tools_2sided_group.drill_dia_entry
         }
         }
 
 
         for name in list(self.postprocessors.keys()):
         for name in list(self.postprocessors.keys()):
@@ -792,7 +804,11 @@ class App(QtCore.QObject):
             "tools_paintmethod": "seed",
             "tools_paintmethod": "seed",
             "tools_selectmethod": "single",
             "tools_selectmethod": "single",
             "tools_pathconnect": True,
             "tools_pathconnect": True,
-            "tools_paintcontour": True
+            "tools_paintcontour": True,
+
+            "tools_2sided_mirror_axis": "X",
+            "tools_2sided_axis_loc": 'point',
+            "tools_2sided_drilldia": 1
 
 
         })
         })
 
 

+ 65 - 1
FlatCAMGUI.py

@@ -978,13 +978,20 @@ class ToolsPreferencesUI(QtWidgets.QWidget):
         self.tools_cutout_group = ToolsCutoutPrefGroupUI()
         self.tools_cutout_group = ToolsCutoutPrefGroupUI()
         self.tools_cutout_group.setFixedWidth(260)
         self.tools_cutout_group.setFixedWidth(260)
 
 
+        self.tools_2sided_group = Tools2sidedPrefGroupUI()
+        self.tools_2sided_group.setFixedWidth(260)
+
         self.vlay = QtWidgets.QVBoxLayout()
         self.vlay = QtWidgets.QVBoxLayout()
         self.vlay.addWidget(self.tools_ncc_group)
         self.vlay.addWidget(self.tools_ncc_group)
         self.vlay.addWidget(self.tools_paint_group)
         self.vlay.addWidget(self.tools_paint_group)
 
 
+        self.vlay1 = QtWidgets.QVBoxLayout()
+        self.vlay1.addWidget(self.tools_cutout_group)
+        self.vlay1.addWidget(self.tools_2sided_group)
+
         self.layout.addLayout(self.vlay)
         self.layout.addLayout(self.vlay)
+        self.layout.addLayout(self.vlay1)
 
 
-        self.layout.addWidget(self.tools_cutout_group)
         self.layout.addStretch()
         self.layout.addStretch()
 
 
 class CNCJobPreferencesUI(QtWidgets.QWidget):
 class CNCJobPreferencesUI(QtWidgets.QWidget):
@@ -2556,6 +2563,63 @@ class ToolsCutoutPrefGroupUI(OptionsGroupUI):
         self.layout.addStretch()
         self.layout.addStretch()
 
 
 
 
+class Tools2sidedPrefGroupUI(OptionsGroupUI):
+    def __init__(self, parent=None):
+        # OptionsGroupUI.__init__(self, "2sided Tool Options", parent=parent)
+        super(Tools2sidedPrefGroupUI, self).__init__(self)
+
+        self.setTitle(str("2Sided Tool Options"))
+
+        ## Board cuttout
+        self.dblsided_label = QtWidgets.QLabel("<b>Double Sided:</b>")
+        self.dblsided_label.setToolTip(
+            "A tool to help in creating a double sided\n"
+            "PCB using alignment holes."
+        )
+        self.layout.addWidget(self.dblsided_label)
+
+        grid0 = QtWidgets.QGridLayout()
+        self.layout.addLayout(grid0)
+
+        ## Drill diameter for alignment holes
+        self.drill_dia_entry = LengthEntry()
+        self.dd_label = QtWidgets.QLabel("Drill diam.:")
+        self.dd_label.setToolTip(
+            "Diameter of the drill for the "
+            "alignment holes."
+        )
+        grid0.addWidget(self.dd_label, 0, 0)
+        grid0.addWidget(self.drill_dia_entry, 0, 1)
+
+        ## Axis
+        self.mirror_axis_radio = RadioSet([{'label': 'X', 'value': 'X'},
+                                     {'label': 'Y', 'value': 'Y'}])
+        self.mirax_label = QtWidgets.QLabel("Mirror Axis:")
+        self.mirax_label.setToolTip(
+            "Mirror vertically (X) or horizontally (Y)."
+        )
+        # grid_lay.addRow("Mirror Axis:", self.mirror_axis)
+        self.empty_lb1 = QtWidgets.QLabel("")
+        grid0.addWidget(self.empty_lb1, 1, 0)
+        grid0.addWidget(self.mirax_label, 2, 0)
+        grid0.addWidget(self.mirror_axis_radio, 2, 1)
+
+        ## Axis Location
+        self.axis_location_radio = RadioSet([{'label': 'Point', 'value': 'point'},
+                                       {'label': 'Box', 'value': 'box'}])
+        self.axloc_label = QtWidgets.QLabel("Axis Ref:")
+        self.axloc_label.setToolTip(
+            "The axis should pass through a <b>point</b> or cut\n "
+            "a specified <b>box</b> (in a Geometry object) in \n"
+            "the middle."
+        )
+        # grid_lay.addRow("Axis Location:", self.axis_location)
+        grid0.addWidget(self.axloc_label, 3, 0)
+        grid0.addWidget(self.axis_location_radio, 3, 1)
+
+        self.layout.addStretch()
+
+
 class ToolsPaintPrefGroupUI(OptionsGroupUI):
 class ToolsPaintPrefGroupUI(OptionsGroupUI):
     def __init__(self, parent=None):
     def __init__(self, parent=None):
         # OptionsGroupUI.__init__(self, "Paint Area Tool Options", parent=parent)
         # OptionsGroupUI.__init__(self, "Paint Area Tool Options", parent=parent)

+ 1 - 0
README.md

@@ -22,6 +22,7 @@ CAD program, and create G-Code for Isolation routing.
 - added new option for Cutout Tool Freeform Gaps in Edit -> Preferences -> Tools
 - added new option for Cutout Tool Freeform Gaps in Edit -> Preferences -> Tools
 - fixed Freeform Cutout gaps issue (it was double than the value set)
 - fixed Freeform Cutout gaps issue (it was double than the value set)
 - added protection so the Cutout (either Freeform or Rectangular) cannot be done on a multigeo Geometry
 - added protection so the Cutout (either Freeform or Rectangular) cannot be done on a multigeo Geometry
+- added 2Sided Tool default values in Edit -> Preferences -> Tools
 
 
 28.01.2018
 28.01.2018
 
 

+ 19 - 14
flatcamTools/ToolDblSided.py

@@ -249,14 +249,27 @@ class DblSidedTool(FlatCAMTool):
 
 
         self.drill_values = ""
         self.drill_values = ""
 
 
-        ## Initialize form
-        self.mirror_axis.set_value('X')
-        self.axis_location.set_value('point')
-        self.drill_dia.set_value(1)
+        self.set_ui()
 
 
     def install(self, icon=None, separator=None, **kwargs):
     def install(self, icon=None, separator=None, **kwargs):
         FlatCAMTool.install(self, icon, separator, shortcut='ALT+D', **kwargs)
         FlatCAMTool.install(self, icon, separator, shortcut='ALT+D', **kwargs)
 
 
+    def run(self):
+        FlatCAMTool.run(self)
+
+        self.app.ui.notebook.setTabText(2, "2-Sided Tool")
+        self.reset_fields()
+        self.set_ui()
+
+    def set_ui(self):
+        ## Initialize form
+        self.point_entry.set_value("")
+        self.alignment_holes.set_value("")
+
+        self.mirror_axis.set_value(self.app.defaults["tools_2sided_mirror_axis"])
+        self.axis_location.set_value(self.app.defaults["tools_2sided_axis_loc"])
+        self.drill_dia.set_value(self.app.defaults["tools_2sided_drilldia"])
+
     def on_combo_box_type(self):
     def on_combo_box_type(self):
         obj_type = self.box_combo_type.currentIndex()
         obj_type = self.box_combo_type.currentIndex()
         self.box_combo.setRootModelIndex(self.app.collection.index(obj_type, 0, QtCore.QModelIndex()))
         self.box_combo.setRootModelIndex(self.app.collection.index(obj_type, 0, QtCore.QModelIndex()))
@@ -457,14 +470,6 @@ class DblSidedTool(FlatCAMTool):
 
 
 
 
         self.drill_values = ""
         self.drill_values = ""
-        self.point_entry.set_value("")
-        self.alignment_holes.set_value("")
-        ## Initialize form
-        self.mirror_axis.set_value('X')
-        self.axis_location.set_value('point')
-        self.drill_dia.set_value(1)
 
 
-    def run(self):
-        FlatCAMTool.run(self)
-        self.app.ui.notebook.setTabText(2, "2-Sided Tool")
-        self.reset_fields()
+
+