diff --git a/FlatCAMApp.py b/FlatCAMApp.py index a9d4cbca..285e8315 100644 --- a/FlatCAMApp.py +++ b/FlatCAMApp.py @@ -779,13 +779,13 @@ class App(QtCore.QObject): "tools_nccoperation": 'clear', "tools_nccoverlap": 40, "tools_nccmargin": 1.0, - "tools_nccmethod": "seed", + "tools_nccmethod": _("Seed"), "tools_nccconnect": True, "tools_ncccontour": True, "tools_nccrest": False, "tools_ncc_offset_choice": False, "tools_ncc_offset_value": 0.0000, - "tools_nccref": 'itself', + "tools_nccref": _('Itself'), "tools_ncc_plotting": 'normal', "tools_nccmilling_type": 'cl', "tools_ncctool_type": 'C1', @@ -1461,13 +1461,13 @@ class App(QtCore.QObject): "tools_nccorder": self.ui.tools_defaults_form.tools_ncc_group.ncc_order_radio, "tools_nccoverlap": self.ui.tools_defaults_form.tools_ncc_group.ncc_overlap_entry, "tools_nccmargin": self.ui.tools_defaults_form.tools_ncc_group.ncc_margin_entry, - "tools_nccmethod": self.ui.tools_defaults_form.tools_ncc_group.ncc_method_radio, + "tools_nccmethod": self.ui.tools_defaults_form.tools_ncc_group.ncc_method_combo, "tools_nccconnect": self.ui.tools_defaults_form.tools_ncc_group.ncc_connect_cb, "tools_ncccontour": self.ui.tools_defaults_form.tools_ncc_group.ncc_contour_cb, "tools_nccrest": self.ui.tools_defaults_form.tools_ncc_group.ncc_rest_cb, "tools_ncc_offset_choice": self.ui.tools_defaults_form.tools_ncc_group.ncc_choice_offset_cb, "tools_ncc_offset_value": self.ui.tools_defaults_form.tools_ncc_group.ncc_offset_spinner, - "tools_nccref": self.ui.tools_defaults_form.tools_ncc_group.reference_radio, + "tools_nccref": self.ui.tools_defaults_form.tools_ncc_group.select_combo, "tools_ncc_plotting": self.ui.tools_defaults_form.tools_ncc_group.ncc_plotting_radio, "tools_nccmilling_type": self.ui.tools_defaults_form.tools_ncc_group.milling_type_radio, "tools_ncctool_type": self.ui.tools_defaults_form.tools_ncc_group.tool_type_radio, diff --git a/README.md b/README.md index b0e69180..28be59a2 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,10 @@ CAD program, and create G-Code for Isolation routing. ================================================= +29.02.2020 + +- compacted the NCC Tool UI by replacing some Radio buttons with Combo boxes due of too many elements + 28.02.2020 - some small changes in preprocessors diff --git a/flatcamEditors/FlatCAMGeoEditor.py b/flatcamEditors/FlatCAMGeoEditor.py index 26fb2615..17027775 100644 --- a/flatcamEditors/FlatCAMGeoEditor.py +++ b/flatcamEditors/FlatCAMGeoEditor.py @@ -487,15 +487,20 @@ class PaintOptionsTool(FlatCAMTool): # Method methodlabel = QtWidgets.QLabel('%s:' % _('Method')) methodlabel.setToolTip( - _("Algorithm to paint the polygon:
" - "Standard: Fixed step inwards.
" - "Seed-based: Outwards from seed.") + _("Algorithm to paint the polygons:\n" + "- Standard: Fixed step inwards.\n" + "- Seed-based: Outwards from seed.\n" + "- Line-based: Parallel lines.") + ) + # self.paintmethod_combo = RadioSet([ + # {"label": _("Standard"), "value": "standard"}, + # {"label": _("Seed-based"), "value": "seed"}, + # {"label": _("Straight lines"), "value": "lines"} + # ], orientation='vertical', stretch=False) + self.paintmethod_combo = FCComboBox() + self.paintmethod_combo.addItems( + [_("Standard"), _("Seed"), _("Lines")] ) - self.paintmethod_combo = RadioSet([ - {"label": _("Standard"), "value": "standard"}, - {"label": _("Seed-based"), "value": "seed"}, - {"label": _("Straight lines"), "value": "lines"} - ], orientation='vertical', stretch=False) grid.addWidget(methodlabel, 3, 0) grid.addWidget(self.paintmethod_combo, 3, 1) @@ -564,7 +569,7 @@ class PaintOptionsTool(FlatCAMTool): if self.app.defaults["tools_paintmethod"]: self.paintmethod_combo.set_value(self.app.defaults["tools_paintmethod"]) else: - self.paintmethod_combo.set_value("seed") + self.paintmethod_combo.set_value(_("Seed")) if self.app.defaults["tools_pathconnect"]: self.pathconnect_cb.set_value(self.app.defaults["tools_pathconnect"]) @@ -578,8 +583,7 @@ class PaintOptionsTool(FlatCAMTool): def on_paint(self): if not self.fcdraw.selected: - self.app.inform.emit('[WARNING_NOTCL] %s' % - _("Paint cancelled. No shape selected.")) + self.app.inform.emit('[WARNING_NOTCL] %s' % _("Paint cancelled. No shape selected.")) return tooldia = self.painttooldia_entry.get_value() @@ -5037,11 +5041,11 @@ class FlatCAMGeoEditor(QtCore.QObject): else: poly_buf = Polygon(geo_obj).buffer(-margin) - if method == "seed": + if method == _("Seed"): cp = Geometry.clear_polygon2(self, polygon_to_clear=poly_buf, tooldia=tooldia, steps_per_circle=self.app.defaults["geometry_circle_steps"], overlap=overlap, contour=contour, connect=connect) - elif method == "lines": + elif method == _("Lines"): cp = Geometry.clear_polygon3(self, polygon=poly_buf, tooldia=tooldia, steps_per_circle=self.app.defaults["geometry_circle_steps"], overlap=overlap, contour=contour, connect=connect) @@ -5054,12 +5058,10 @@ class FlatCAMGeoEditor(QtCore.QObject): local_results += list(cp.get_objects()) except Exception as e: log.debug("Could not Paint the polygons. %s" % str(e)) - self.app.inform.emit('[ERROR] %s\n%s' % - (_("Could not do Paint. Try a different combination of" - " parameters. Or a different method of Paint"), - str(e) - ) - ) + self.app.inform.emit( + '[ERROR] %s\n%s' % (_("Could not do Paint. Try a different combination of parameters. " + "Or a different method of Paint"), str(e)) + ) return # add the result to the results list @@ -5068,8 +5070,7 @@ class FlatCAMGeoEditor(QtCore.QObject): # This is a dirty patch: for r in results: self.add_shape(DrawToolShape(r)) - self.app.inform.emit( - '[success] %s' % _("Paint done.")) + self.app.inform.emit('[success] %s' % _("Paint done.")) self.replot() def flatten(self, geometry, orient_val=1, reset=True, pathonly=False): diff --git a/flatcamGUI/PreferencesUI.py b/flatcamGUI/PreferencesUI.py index fdd29b3b..7d6767cd 100644 --- a/flatcamGUI/PreferencesUI.py +++ b/flatcamGUI/PreferencesUI.py @@ -5313,20 +5313,24 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI): # Method methodlabel = QtWidgets.QLabel('%s:' % _('Method')) methodlabel.setToolTip( - _("Algorithm for non-copper clearing:
" - "Standard: Fixed step inwards.
" - "Seed-based: Outwards from seed.
" - "Line-based: Parallel lines.") + _("Algorithm for copper clearing:\n" + "- Standard: Fixed step inwards.\n" + "- Seed-based: Outwards from seed.\n" + "- Line-based: Parallel lines.") ) - self.ncc_method_radio = RadioSet([ - {"label": _("Standard"), "value": "standard"}, - {"label": _("Seed-based"), "value": "seed"}, - {"label": _("Straight lines"), "value": "lines"} - ], orientation='vertical', stretch=False) + # self.ncc_method_radio = RadioSet([ + # {"label": _("Standard"), "value": "standard"}, + # {"label": _("Seed-based"), "value": "seed"}, + # {"label": _("Straight lines"), "value": "lines"} + # ], orientation='vertical', stretch=False) + self.ncc_method_combo = FCComboBox() + self.ncc_method_combo.addItems( + [_("Standard"), _("Seed"), _("Lines")] + ) grid0.addWidget(methodlabel, 12, 0) - grid0.addWidget(self.ncc_method_radio, 12, 1) + grid0.addWidget(self.ncc_method_combo, 12, 1) # Connect lines self.ncc_connect_cb = FCCheckBox('%s' % _("Connect")) @@ -5394,23 +5398,25 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI): grid0.addWidget(self.ncc_rest_cb, 17, 0, 1, 2) # ## Reference - self.reference_radio = RadioSet([{'label': _('Itself'), 'value': 'itself'}, - {"label": _("Area Selection"), "value": "area"}, - {'label': _('Reference Object'), 'value': 'box'}], - orientation='vertical', - stretch=None) - reference_label = QtWidgets.QLabel('%s:' % _("Reference")) - reference_label.setToolTip( - _("- 'Itself' - the non copper clearing extent\n" - "is based on the object that is copper cleared.\n " + # self.reference_radio = RadioSet([{'label': _('Itself'), 'value': 'itself'}, + # {"label": _("Area Selection"), "value": "area"}, + # {'label': _('Reference Object'), 'value': 'box'}], + # orientation='vertical', + # stretch=None) + self.select_combo = FCComboBox() + self.select_combo.addItems( + [_("Itself"), _("Area Selection"), _("Reference Object")] + ) + select_label = QtWidgets.QLabel('%s:' % _("Reference")) + select_label.setToolTip( + _("Selection of area to be cleared of copper." + "- 'Itself' - the non copper clearing extent is based on the object that is copper cleared.\n " "- 'Area Selection' - left mouse click to start selection of the area to be painted.\n" - "Keeping a modifier key pressed (CTRL or SHIFT) will allow to add multiple areas.\n" - "- 'Reference Object' - will do non copper clearing within the area\n" - "specified by another object.") + "- 'Reference Object' - will do non copper clearing within the area specified by another object.") ) - grid0.addWidget(reference_label, 18, 0) - grid0.addWidget(self.reference_radio, 18, 1) + grid0.addWidget(select_label, 18, 0) + grid0.addWidget(self.select_combo, 18, 1) separator_line = QtWidgets.QFrame() separator_line.setFrameShape(QtWidgets.QFrame.HLine) diff --git a/flatcamTools/ToolNonCopperClear.py b/flatcamTools/ToolNCC.py similarity index 98% rename from flatcamTools/ToolNonCopperClear.py rename to flatcamTools/ToolNCC.py index 45ea96e8..9caddcc3 100644 --- a/flatcamTools/ToolNonCopperClear.py +++ b/flatcamTools/ToolNCC.py @@ -411,20 +411,25 @@ class NonCopperClear(FlatCAMTool, Gerber): # Method methodlabel = QtWidgets.QLabel('%s:' % _('Method')) methodlabel.setToolTip( - _("Algorithm for non-copper clearing:
" - "Standard: Fixed step inwards.
" - "Seed-based: Outwards from seed.
" - "Line-based: Parallel lines.") + _("Algorithm for copper clearing:\n" + "- Standard: Fixed step inwards.\n" + "- Seed-based: Outwards from seed.\n" + "- Line-based: Parallel lines.") ) - self.ncc_method_radio = RadioSet([ - {"label": _("Standard"), "value": "standard"}, - {"label": _("Seed-based"), "value": "seed"}, - {"label": _("Straight lines"), "value": "lines"} - ], orientation='vertical', stretch=False) - self.ncc_method_radio.setObjectName("n_method") + # self.ncc_method_radio = RadioSet([ + # {"label": _("Standard"), "value": "standard"}, + # {"label": _("Seed-based"), "value": "seed"}, + # {"label": _("Straight lines"), "value": "lines"} + # ], orientation='vertical', stretch=False) + + self.ncc_method_combo = FCComboBox() + self.ncc_method_combo.addItems( + [_("Standard"), _("Seed"), _("Lines")] + ) + self.ncc_method_combo.setObjectName("n_method") self.grid3.addWidget(methodlabel, 17, 0) - self.grid3.addWidget(self.ncc_method_radio, 17, 1) + self.grid3.addWidget(self.ncc_method_combo, 17, 1) # Connect lines self.ncc_connect_cb = FCCheckBox('%s' % _("Connect")) @@ -516,21 +521,26 @@ class NonCopperClear(FlatCAMTool, Gerber): self.grid3.addWidget(self.ncc_rest_cb, 25, 0, 1, 2) # ## 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_radio.setObjectName("n_reference") + # self.select_radio = RadioSet([ + # {'label': _('Itself'), 'value': 'itself'}, + # {"label": _("Area Selection"), "value": "area"}, + # {'label': _("Reference Object"), 'value': 'box'} + # ], orientation='vertical', stretch=False) + self.select_combo = FCComboBox() + self.select_combo.addItems( + [_("Itself"), _("Area Selection"), _("Reference Object")] + ) + self.select_combo.setObjectName("n_selection") - self.reference_label = QtWidgets.QLabel('%s:' % _("Reference")) - self.reference_label.setToolTip( - _("- 'Itself' - the non copper clearing extent is based on the object that is copper cleared.\n " + self.select_label = QtWidgets.QLabel('%s:' % _("Selection")) + self.select_label.setToolTip( + _("Selection of area to be cleared of copper." + "- 'Itself' - the non copper clearing extent is based on the object that is copper cleared.\n " "- 'Area Selection' - left mouse click to start selection of the area to be painted.\n" "- 'Reference Object' - will do non copper clearing within the area specified by another object.") ) - self.grid3.addWidget(self.reference_label, 26, 0, 1, 2) - self.grid3.addWidget(self.reference_radio, 27, 0, 1, 2) + self.grid3.addWidget(self.select_label, 26, 0,) + self.grid3.addWidget(self.select_combo, 26, 1) form1 = QtWidgets.QFormLayout() self.grid3.addLayout(form1, 28, 0, 1, 2) @@ -659,7 +669,7 @@ class NonCopperClear(FlatCAMTool, Gerber): "nccoperation":self.op_radio, "nccoverlap": self.ncc_overlap_entry, "nccmargin": self.ncc_margin_entry, - "nccmethod": self.ncc_method_radio, + "nccmethod": self.ncc_method_combo, "nccconnect": self.ncc_connect_cb, "ncccontour": self.ncc_contour_cb, "nccoffset": self.ncc_choice_offset_cb, @@ -696,7 +706,7 @@ class NonCopperClear(FlatCAMTool, Gerber): self.op_radio.activated_custom.connect(self.on_operation_change) self.box_combo_type.currentIndexChanged.connect(self.on_combo_box_type) - self.reference_radio.group_toggle_fn = self.on_toggle_reference + self.select_combo.group_toggle_fn = self.on_toggle_reference self.ncc_rest_cb.stateChanged.connect(self.on_rest_machining_check) self.ncc_order_radio.activated_custom[str].connect(self.on_order_changed) @@ -943,14 +953,14 @@ class NonCopperClear(FlatCAMTool, Gerber): self.ncc_order_radio.set_value(self.app.defaults["tools_nccorder"]) self.ncc_overlap_entry.set_value(self.app.defaults["tools_nccoverlap"]) self.ncc_margin_entry.set_value(self.app.defaults["tools_nccmargin"]) - self.ncc_method_radio.set_value(self.app.defaults["tools_nccmethod"]) + self.ncc_method_combo.set_value(self.app.defaults["tools_nccmethod"]) self.ncc_connect_cb.set_value(self.app.defaults["tools_nccconnect"]) self.ncc_contour_cb.set_value(self.app.defaults["tools_ncccontour"]) self.ncc_rest_cb.set_value(self.app.defaults["tools_nccrest"]) self.ncc_choice_offset_cb.set_value(self.app.defaults["tools_ncc_offset_choice"]) self.ncc_offset_spinner.set_value(self.app.defaults["tools_ncc_offset_value"]) - self.reference_radio.set_value(self.app.defaults["tools_nccref"]) + self.select_combo.set_value(self.app.defaults["tools_nccref"]) self.milling_type_radio.set_value(self.app.defaults["tools_nccmilling_type"]) self.cutz_entry.set_value(self.app.defaults["tools_ncccutz"]) self.tool_type_radio.set_value(self.app.defaults["tools_ncctool_type"]) @@ -1249,7 +1259,7 @@ class NonCopperClear(FlatCAMTool, Gerber): self.box_combo.setCurrentIndex(0) def on_toggle_reference(self): - if self.reference_radio.get_value() == "itself" or self.reference_radio.get_value() == "area": + if self.select_combo.get_value() == _("Itself") or self.select_combo.get_value() == _("Area Selection"): self.box_combo.hide() self.box_combo_label.hide() self.box_combo_type.hide() @@ -1566,8 +1576,8 @@ class NonCopperClear(FlatCAMTool, Gerber): self.o_name = '%s_ncc' % self.obj_name - self.select_method = self.reference_radio.get_value() - if self.select_method == 'itself': + self.select_method = self.select_combo.get_value() + if self.select_method == _('Itself'): self.bound_obj_name = self.object_combo.currentText() # Get source object. try: @@ -1580,7 +1590,7 @@ class NonCopperClear(FlatCAMTool, Gerber): ncctooldia=self.ncc_dia_list, isotooldia=self.iso_dia_list, outname=self.o_name) - elif self.select_method == 'area': + elif self.select_method == _("Area Selection"): self.app.inform.emit('[WARNING_NOTCL] %s' % _("Click the start point of the area.")) if self.app.is_legacy is False: @@ -1743,7 +1753,7 @@ class NonCopperClear(FlatCAMTool, Gerber): box_kind = box_obj.kind if box_obj is not None else None env_obj = None - if ncc_select == 'itself': + if ncc_select == _('Itself'): geo_n = ncc_obj.solid_geometry try: @@ -1759,13 +1769,13 @@ class NonCopperClear(FlatCAMTool, Gerber): log.debug("NonCopperClear.envelope_object() 'itself' --> %s" % str(e)) self.app.inform.emit('[ERROR_NOTCL] %s' % _("No object available.")) return None - elif ncc_select == 'area': + elif ncc_select == _("Area Selection"): env_obj = cascaded_union(self.sel_rect) try: __ = iter(env_obj) except Exception: env_obj = [env_obj] - elif ncc_select == 'box': + elif ncc_select == _("Reference Object"): if box_obj is None: return None, None @@ -1807,14 +1817,14 @@ class NonCopperClear(FlatCAMTool, Gerber): return 'fail' bounding_box = None - if ncc_select == 'itself': + if ncc_select == _('Itself'): try: bounding_box = env_obj.buffer(distance=ncc_margin, join_style=base.JOIN_STYLE.mitre) except Exception as e: log.debug("NonCopperClear.envelope_object_to_tool_bounding_box() 'itself' --> %s" % str(e)) self.app.inform.emit('[ERROR_NOTCL] %s' % _("No object available.")) return 'fail' - elif ncc_select == 'area': + elif ncc_select == _("Area Selection"): geo_buff_list = [] for poly in env_obj: if self.app.abort_flag: @@ -1822,7 +1832,7 @@ class NonCopperClear(FlatCAMTool, Gerber): raise FlatCAMApp.GracefulException geo_buff_list.append(poly.buffer(distance=ncc_margin, join_style=base.JOIN_STYLE.mitre)) bounding_box = cascaded_union(geo_buff_list) - elif ncc_select == 'box': + elif ncc_select == _("Reference Object"): if box_kind == 'geometry': geo_buff_list = list() for poly in env_obj: @@ -2055,7 +2065,7 @@ class NonCopperClear(FlatCAMTool, Gerber): units = self.app.defaults['units'] order = order if order else self.ncc_order_radio.get_value() - ncc_select = self.reference_radio.get_value() + ncc_select = self.select_combo.get_value() rest_machining_choice = self.ncc_rest_cb.get_value() # determine if to use the progressive plotting @@ -2217,13 +2227,13 @@ class NonCopperClear(FlatCAMTool, Gerber): try: for pol in p: if pol is not None and isinstance(pol, Polygon): - if ncc_method == 'standard': + if ncc_method == _("Standard"): cp = self.clear_polygon(pol, tool, self.grb_circle_steps, overlap=ncc_overlap, contour=ncc_contour, connect=ncc_connect, prog_plot=prog_plot) - elif ncc_method == 'seed': + elif ncc_method == _("Seed"): cp = self.clear_polygon2(pol, tool, self.grb_circle_steps, overlap=ncc_overlap, contour=ncc_contour, @@ -2246,12 +2256,12 @@ class NonCopperClear(FlatCAMTool, Gerber): "It is: %s" % str(type(pol))) except TypeError: if isinstance(p, Polygon): - if ncc_method == 'standard': + if ncc_method == _("Standard"): cp = self.clear_polygon(p, tool, self.grb_circle_steps, overlap=ncc_overlap, contour=ncc_contour, connect=ncc_connect, prog_plot=prog_plot) - elif ncc_method == 'seed': + elif ncc_method == _("Seed"): cp = self.clear_polygon2(p, tool, self.grb_circle_steps, overlap=ncc_overlap, contour=ncc_contour, connect=ncc_connect, @@ -2515,13 +2525,13 @@ class NonCopperClear(FlatCAMTool, Gerber): if isinstance(p, Polygon): try: - if ncc_method == 'standard': + if ncc_method == _("Standard"): cp = self.clear_polygon(p, tool_used, self.grb_circle_steps, overlap=ncc_overlap, contour=ncc_contour, connect=ncc_connect, prog_plot=prog_plot) - elif ncc_method == 'seed': + elif ncc_method == _("Seed"): cp = self.clear_polygon2(p, tool_used, self.grb_circle_steps, overlap=ncc_overlap, contour=ncc_contour, @@ -2547,13 +2557,13 @@ class NonCopperClear(FlatCAMTool, Gerber): QtWidgets.QApplication.processEvents() try: - if ncc_method == 'standard': + if ncc_method == _("Standard"): cp = self.clear_polygon(poly, tool_used, self.grb_circle_steps, overlap=ncc_overlap, contour=ncc_contour, connect=ncc_connect, prog_plot=prog_plot) - elif ncc_method == 'seed': + elif ncc_method == _("Seed"): cp = self.clear_polygon2(poly, tool_used, self.grb_circle_steps, overlap=ncc_overlap, contour=ncc_contour, @@ -2789,7 +2799,7 @@ class NonCopperClear(FlatCAMTool, Gerber): self.app.inform.emit(_("NCC Tool. Preparing non-copper polygons.")) try: - if sel_obj is None or sel_obj == 'itself': + if sel_obj is None or sel_obj == _('Itself'): ncc_sel_obj = ncc_obj else: ncc_sel_obj = sel_obj @@ -2798,7 +2808,7 @@ class NonCopperClear(FlatCAMTool, Gerber): return 'fail' bounding_box = None - if ncc_select == 'itself': + if ncc_select == _('Itself'): geo_n = ncc_sel_obj.solid_geometry try: @@ -2951,7 +2961,7 @@ class NonCopperClear(FlatCAMTool, Gerber): milling_type = self.app.defaults["tools_nccmilling_type"] for tool_iso in isotooldia: - new_geometry = [] + new_geometry = list() if milling_type == 'cl': isolated_geo = self.generate_envelope(tool_iso / 2, 1) diff --git a/flatcamTools/__init__.py b/flatcamTools/__init__.py index 74d1aff5..bdd7e58b 100644 --- a/flatcamTools/__init__.py +++ b/flatcamTools/__init__.py @@ -17,7 +17,7 @@ from flatcamTools.ToolDistanceMin import DistanceMin from flatcamTools.ToolMove import ToolMove -from flatcamTools.ToolNonCopperClear import NonCopperClear +from flatcamTools.ToolNCC import NonCopperClear from flatcamTools.ToolPaint import ToolPaint from flatcamTools.ToolOptimal import ToolOptimal