From 48c12c2a5c489a20a49fef354024f463bac728f6 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Tue, 10 Nov 2020 21:08:00 +0200 Subject: [PATCH] - fixed Paint Tcl command; fixes issue #437 --- CHANGELOG.md | 1 + appTools/ToolPaint.py | 5 +++-- tclCommands/TclCommandCopperClear.py | 9 +++++--- tclCommands/TclCommandPaint.py | 33 +++++++++++++++------------- 4 files changed, 28 insertions(+), 20 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 26a5d18c..afb72892 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,7 @@ CHANGELOG for FlatCAM beta - updated the Extract Tool - Extract Soldermask functionality, such that the selection of apertures will control the final SolderMask Gerber content - updated the Extract Tool - new functionality added: Extract Cutout Gerber from a given Gerber object; added parameters in Preferences - updated the UI for Cutout Tool +- fixed Paint Tcl command; fixes issue #437 9.11.2020 diff --git a/appTools/ToolPaint.py b/appTools/ToolPaint.py index 0e6ac5b3..73ed5bac 100644 --- a/appTools/ToolPaint.py +++ b/appTools/ToolPaint.py @@ -1700,7 +1700,7 @@ class ToolPaint(AppTool, Gerber): return None def paint_geo(self, obj, geometry, tooldia=None, order=None, method=None, outname=None, - tools_storage=None, plot=True, run_threaded=True): + tools_storage=None, plot=True, rest=None, run_threaded=True): """ Paints a given geometry. @@ -1725,6 +1725,7 @@ class ToolPaint(AppTool, Gerber): name = outname if outname is not None else self.obj_name + "_paint" order = order if order is not None else self.ui.order_radio.get_value() tools_storage = self.paint_tools if tools_storage is None else tools_storage + use_rest_strategy = rest if rest is not None else self.ui.rest_cb.get_value() sorted_tools = [] if tooldia is not None: @@ -2167,7 +2168,7 @@ class ToolPaint(AppTool, Gerber): def job_thread(app_obj): try: - if self.ui.rest_cb.get_value(): + if use_rest_strategy: ret = app_obj.app_obj.new_object("geometry", name, job_rest_clear, plot=plot) else: ret = app_obj.app_obj.new_object("geometry", name, job_normal_clear, plot=plot) diff --git a/tclCommands/TclCommandCopperClear.py b/tclCommands/TclCommandCopperClear.py index 6e0ad3c8..a2246fca 100644 --- a/tclCommands/TclCommandCopperClear.py +++ b/tclCommands/TclCommandCopperClear.py @@ -126,8 +126,11 @@ class TclCommandCopperClear(TclCommand): method_data = 0 elif method == "seed": method_data = 1 - else: + elif method == "lines": method_data = 2 + else: + return "Method not supported or typo.\n" \ + "Supported methods are: 'standard', 'seed' and 'lines'." else: method = str(self.app.defaults["tools_ncc_method"]) method_data = method @@ -250,7 +253,7 @@ class TclCommandCopperClear(TclCommand): ncc_tools[int(tooluid)]['data']['tooldia'] = self.app.dec_format(tool, obj.decimals) # Non-Copper clear all polygons in the non-copper clear object - if 'all' in args: + if select == 0: # 'all' in args self.app.ncclear_tool.clear_copper_tcl(ncc_obj=obj, select_method=0, # ITSELF ncctooldia=tooldia, @@ -270,7 +273,7 @@ class TclCommandCopperClear(TclCommand): return # Non-Copper clear all polygons found within the box object from the the non_copper cleared object - if 'box' in args: # Reference Object + if select == 2: # Reference Object 'box' in args box_name = args['box'] # Get box source object. diff --git a/tclCommands/TclCommandPaint.py b/tclCommands/TclCommandPaint.py index 948fab35..71e6df3c 100644 --- a/tclCommands/TclCommandPaint.py +++ b/tclCommands/TclCommandPaint.py @@ -105,9 +105,9 @@ class TclCommandPaint(TclCommand): tooldia = str(self.app.defaults["tools_paint_tooldia"]) if 'overlap' in args: - overlap = float(args['overlap']) / 100.0 + overlap = float(args['overlap']) else: - overlap = float(self.app.defaults["tools_paint_overlap"]) / 100.0 + overlap = float(self.app.defaults["tools_paint_overlap"]) if 'order' in args: order = args['order'] @@ -122,15 +122,18 @@ class TclCommandPaint(TclCommand): if 'method' in args: method = args['method'] if method == "standard": - method = _("Standard") + method = 0 elif method == "seed": - method = _("Seed") + method = 1 elif method == "lines": - method = _("Lines") + method = 2 elif method == "laser_lines": - method = _("Laser_lines") + method = 3 + elif method == "combo": + method = 4 else: - method = _("Combo") + return "Method not supported or typo.\n" \ + "Supported methods are: 'standard', 'seed', 'lines', 'laser_lines' and 'combo'." else: method = str(self.app.defaults["tools_paint_method"]) @@ -158,12 +161,12 @@ class TclCommandPaint(TclCommand): outname = name + "_paint" # used only to have correct information's in the obj.tools[tool]['data'] dict - if "all" in args: - select = _("All") - elif "single" in args: - select = _("Polygon Selection") + if "single" in args: + select = 1 # _("Polygon Selection") + elif 'box' in args: + select = 3 # _("Reference Object") else: - select = _("Reference Object") + select = 0 # _("All") try: tools = [float(eval(dia)) for dia in tooldia.split(",") if dia != ''] @@ -232,7 +235,7 @@ class TclCommandPaint(TclCommand): return "Object not found: %s" % name # Paint all polygons in the painted object - if 'all' in args: + if select == 0: # 'all' in args self.app.paint_tool.paint_poly_all(obj=obj, tooldia=tooldia, order=order, @@ -244,7 +247,7 @@ class TclCommandPaint(TclCommand): return # Paint single polygon in the painted object - if 'single' in args: + if select == 1: # 'single' in args if not args['single'] or args['single'] == '': self.raise_tcl_error('%s Got: %s' % (_("Expected a tuple value like -single 3.2,0.1."), str(args['single']))) @@ -271,7 +274,7 @@ class TclCommandPaint(TclCommand): return # Paint all polygons found within the box object from the the painted object - if 'box' in args: + if select == 3: # 'box' in args box_name = args['box'] if box_name is None: