From d1f40c769f83a1337b7f3f6e7c5b3ee85c2305b3 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Sat, 26 Oct 2019 00:08:50 +0300 Subject: [PATCH] - Copper Fill Tool: added GUI category in Edit -> Preferences window - QRCode Tool: added a selection limit parameter to control the selection shape vs utility geo --- FlatCAMApp.py | 16 +++++ README.md | 2 + flatcamGUI/PreferencesUI.py | 116 ++++++++++++++++++++++++++++++++- flatcamTools/ToolCopperFill.py | 14 ++-- flatcamTools/ToolQRCode.py | 4 +- share/qrcode32.png | Bin 1477 -> 445 bytes 6 files changed, 138 insertions(+), 14 deletions(-) diff --git a/FlatCAMApp.py b/FlatCAMApp.py index 1cbb90dc..7a4b6496 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -859,6 +859,14 @@ class App(QtCore.QObject): "tools_qrcode_rounded": self.ui.tools2_defaults_form.tools2_qrcode_group.bb_radio, "tools_qrcode_fill_color": self.ui.tools2_defaults_form.tools2_qrcode_group.fill_color_entry, "tools_qrcode_back_color": self.ui.tools2_defaults_form.tools2_qrcode_group.back_color_entry, + "tools_qrcode_sel_limit": self.ui.tools2_defaults_form.tools2_qrcode_group.sel_limit_entry, + + # Copper Fill Tool + "tools_copperfill_clearance": self.ui.tools2_defaults_form.tools2_cfill_group.clearance_entry, + "tools_copperfill_margin": self.ui.tools2_defaults_form.tools2_cfill_group.margin_entry, + "tools_copperfill_reference": self.ui.tools2_defaults_form.tools2_cfill_group.reference_radio, + "tools_copperfill_box_type": self.ui.tools2_defaults_form.tools2_cfill_group.bbox_type_radio, + "tools_copperfill_circle_steps": self.ui.tools2_defaults_form.tools2_cfill_group.circlesteps_entry, # Utilities # File associations @@ -1329,6 +1337,14 @@ class App(QtCore.QObject): "tools_qrcode_rounded": 's', "tools_qrcode_fill_color": '#000000', "tools_qrcode_back_color": '#FFFFFF', + "tools_qrcode_sel_limit": 330, + + # Copper Fill Tool + "tools_copperfill_clearance": 0.01, + "tools_copperfill_margin": 0.039, + "tools_copperfill_reference": 'itself', + "tools_copperfill_box_type": 'rect', + "tools_copperfill_circle_steps": 128, # Utilities # file associations diff --git a/README.md b/README.md index 6549ab7a..a182ea89 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,8 @@ CAD program, and create G-Code for Isolation routing. - added a new FlatCAM Tool: Copper Fill Tool. It will pour copper into a Gerber filling all empty space with copper, at a clearance distance of the Gerber features - Copper Fill Tool: added possibility to select between a bounding box rectangular or convex hull when the reference is the geometry of the source Gerber object - Copper Fill Tool: cleanup on not regular tool exit +- Copper Fill Tool: added GUI category in Edit -> Preferences window +- QRCode Tool: added a selection limit parameter to control the selection shape vs utility geo 24.10.2019 diff --git a/flatcamGUI/PreferencesUI.py b/flatcamGUI/PreferencesUI.py index 679296fb..e0edfb7a 100644 --- a/flatcamGUI/PreferencesUI.py +++ b/flatcamGUI/PreferencesUI.py @@ -219,6 +219,9 @@ class Tools2PreferencesUI(QtWidgets.QWidget): self.tools2_qrcode_group = Tools2QRCodePrefGroupUI() self.tools2_qrcode_group.setMinimumWidth(220) + self.tools2_cfill_group = Tools2CFillPrefGroupUI() + self.tools2_cfill_group.setMinimumWidth(220) + self.vlay = QtWidgets.QVBoxLayout() self.vlay.addWidget(self.tools2_checkrules_group) self.vlay.addWidget(self.tools2_optimal_group) @@ -226,13 +229,11 @@ class Tools2PreferencesUI(QtWidgets.QWidget): self.vlay1 = QtWidgets.QVBoxLayout() self.vlay1.addWidget(self.tools2_qrcode_group) - self.vlay2 = QtWidgets.QVBoxLayout() - + self.vlay2.addWidget(self.tools2_cfill_group) self.vlay3 = QtWidgets.QVBoxLayout() - self.layout.addLayout(self.vlay) self.layout.addLayout(self.vlay1) self.layout.addLayout(self.vlay2) @@ -5563,6 +5564,115 @@ class Tools2QRCodePrefGroupUI(OptionsGroupUI): grid_lay.addWidget(self.back_color_label, 10, 0) grid_lay.addWidget(back_color_widget, 10, 1) + # Selection Limit + self.sel_limit_label = QtWidgets.QLabel('%s:' % _("Selection limit")) + self.sel_limit_label.setToolTip( + _("Set the number of selected geometry\n" + "items above which the utility geometry\n" + "becomes just a selection rectangle.\n" + "Increases the performance when moving a\n" + "large number of geometric elements.") + ) + self.sel_limit_entry = FCSpinner() + self.sel_limit_entry.set_range(0, 9999) + + grid_lay.addWidget(self.sel_limit_label, 11, 0) + grid_lay.addWidget(self.sel_limit_entry, 11, 1) + # self.layout.addStretch() + + +class Tools2CFillPrefGroupUI(OptionsGroupUI): + def __init__(self, parent=None): + + super(Tools2CFillPrefGroupUI, self).__init__(self) + + self.setTitle(str(_("Copper Fill Tool Options"))) + self.decimals = 4 + + # ## Grid Layout + grid_lay = QtWidgets.QGridLayout() + self.layout.addLayout(grid_lay) + grid_lay.setColumnStretch(0, 0) + grid_lay.setColumnStretch(1, 1) + + # ## Parameters + self.cflabel = QtWidgets.QLabel('%s' % _('Parameters')) + self.cflabel.setToolTip( + _("A tool to generate a Copper fill that can be added\n" + "to a selected Gerber file.") + ) + grid_lay.addWidget(self.cflabel, 0, 0, 1, 2) + + # CIRCLE STEPS - to be used when buffering + self.circle_steps_lbl = QtWidgets.QLabel('%s:' % _("Circle Steps")) + self.circle_steps_lbl.setToolTip( + _("Number of steps (lines) used to interpolate circles.") + ) + + self.circlesteps_entry = FCSpinner() + self.circlesteps_entry.set_range(1, 9999) + + grid_lay.addWidget(self.circle_steps_lbl, 1, 0) + grid_lay.addWidget(self.circlesteps_entry, 1, 1) + + # CLEARANCE # + self.clearance_label = QtWidgets.QLabel('%s:' % _("Clearance")) + self.clearance_label.setToolTip( + _("This set the distance between the copper fill components\n" + "(the polygon fill may be split in multiple polygons)\n" + "and the copper traces in the Gerber file.") + ) + self.clearance_entry = FCDoubleSpinner() + self.clearance_entry.setMinimum(0.00001) + self.clearance_entry.set_precision(self.decimals) + self.clearance_entry.setSingleStep(0.1) + + grid_lay.addWidget(self.clearance_label, 2, 0) + grid_lay.addWidget(self.clearance_entry, 2, 1) + + # MARGIN # + self.margin_label = QtWidgets.QLabel('%s:' % _("Margin")) + self.margin_label.setToolTip( + _("Bounding box margin.") + ) + self.margin_entry = FCDoubleSpinner() + self.margin_entry.setMinimum(0.0) + self.margin_entry.set_precision(self.decimals) + self.margin_entry.setSingleStep(0.1) + + grid_lay.addWidget(self.margin_label, 3, 0) + grid_lay.addWidget(self.margin_entry, 3, 1) + + # Reference # + self.reference_radio = RadioSet([ + {'label': _('Itself'), 'value': 'itself'}, + {"label": _("Area Selection"), "value": "area"}, + {'label': _("Reference Object"), 'value': 'box'} + ], orientation='vertical', stretch=False) + self.reference_label = QtWidgets.QLabel(_("Reference:")) + self.reference_label.setToolTip( + _("- 'Itself' - the copper fill extent is based on the object that is copper cleared.\n " + "- 'Area Selection' - left mouse click to start selection of the area to be filled.\n" + "- 'Reference Object' - will do copper filling within the area specified by another object.") + ) + grid_lay.addWidget(self.reference_label, 4, 0) + grid_lay.addWidget(self.reference_radio, 4, 1) + + # Bounding Box Type # + self.bbox_type_radio = RadioSet([ + {'label': _('Rectangular'), 'value': 'rect'}, + {"label": _("Minimal"), "value": "min"} + ], stretch=False) + self.bbox_type_label = QtWidgets.QLabel(_("Box Type:")) + self.bbox_type_label.setToolTip( + _("- 'Rectangular' - the bounding box will be of rectangular shape.\n " + "- 'Minimal' - the bounding box will be the convex hull shape.") + ) + grid_lay.addWidget(self.bbox_type_label, 5, 0) + grid_lay.addWidget(self.bbox_type_radio, 5, 1) + + self.layout.addStretch() + class FAExcPrefGroupUI(OptionsGroupUI): def __init__(self, parent=None): diff --git a/flatcamTools/ToolCopperFill.py b/flatcamTools/ToolCopperFill.py index 6410a20b..16c52b5f 100644 --- a/flatcamTools/ToolCopperFill.py +++ b/flatcamTools/ToolCopperFill.py @@ -247,16 +247,12 @@ class ToolCopperFill(FlatCAMTool): def set_tool_ui(self): self.units = self.app.ui.general_defaults_form.general_app_group.units_radio.get_value() - # self.clearance_entry.set_value(float(self.app.defaults["tools_copperfill_clearance"])) - # self.margin_entry.set_value(float(self.app.defaults["tools_copperfill_margin"])) - # self.reference_radio.set_value(self.app.defaults["tools_copperfill_reference"]) - # self.geo_steps_per_circle = int(self.app.defaults["tools_copperfill_circle_steps"]) - # self.bbox_type_radio.set_value(self.app.defaults["tools_copperfill_box_type"]) + self.clearance_entry.set_value(float(self.app.defaults["tools_copperfill_clearance"])) + self.margin_entry.set_value(float(self.app.defaults["tools_copperfill_margin"])) + self.reference_radio.set_value(self.app.defaults["tools_copperfill_reference"]) + self.bbox_type_radio.set_value(self.app.defaults["tools_copperfill_box_type"]) - self.clearance_entry.set_value(0.5) - self.margin_entry.set_value(1.0) - self.reference_radio.set_value('itself') - self.bbox_type_radio.set_value('rect') + self.geo_steps_per_circle = int(self.app.defaults["tools_copperfill_circle_steps"]) self.area_method = False diff --git a/flatcamTools/ToolQRCode.py b/flatcamTools/ToolQRCode.py index bfeb7cdf..f4f87dd9 100644 --- a/flatcamTools/ToolQRCode.py +++ b/flatcamTools/ToolQRCode.py @@ -562,8 +562,8 @@ class QRCode(FlatCAMTool): offset_geo = list() # I use the len of self.qrcode_geometry instead of the utility one because the complexity of the polygons is - # better seen in this - if len(self.qrcode_geometry) <= 330: + # better seen in this (bit what if the sel.qrcode_geometry is just one geo element? len will fail ... + if len(self.qrcode_geometry) <= self.app.defaults["tools_qrcode_sel_limit"]: try: for poly in self.qrcode_utility_geometry: offset_geo.append(translate(poly.exterior, xoff=pos[0], yoff=pos[1])) diff --git a/share/qrcode32.png b/share/qrcode32.png index e2856f8c2e33f4f4d66b7d85a2cc7633ab08f265..1c12a716a934d2a05251c9fd1553875a5d5acd21 100644 GIT binary patch delta 412 zcmV;N0b~Bf3%vu77zqRe0001iRAN~R9632T0001SadE1us^jD1R=UZS0003vNklz&p{A0dj;SEt1(uZ;B~SX+gaqYMXXWU$ADNaGz^YVFxbP80@s= z2EB)6o?)eK@{oCO|{#S9F3 z${@^GvDCf{sNhh5Plzi}auf{d5cu4}_6X>KX(d5^!3+)!6%qm-2?YTQYN{3)xa^}g(Y=;hqoSB@%enp`s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