From 841e1f3eebbf72573a4c4393c2f1e4b7dc2ae72e Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Mon, 30 Dec 2019 22:04:39 +0200 Subject: [PATCH] - fixed Tcl commands that use the overlap parameter to switch from fraction to percentage - in Transform Tool mae sure that the buffer sub-tool parameters are better explained in tooltips --- FlatCAMObj.py | 19 +++++++++---------- README.md | 2 ++ camlib.py | 4 ++-- flatcamEditors/FlatCAMGeoEditor.py | 2 +- flatcamGUI/ObjectUI.py | 2 +- flatcamGUI/PreferencesUI.py | 11 ++++++----- flatcamTools/ToolNonCopperClear.py | 4 ++-- flatcamTools/ToolPaint.py | 8 ++++---- flatcamTools/ToolTransform.py | 5 +++-- tclCommands/TclCommandCopperClear.py | 6 +++--- tclCommands/TclCommandIsolate.py | 2 +- tclCommands/TclCommandPaint.py | 8 ++++---- 12 files changed, 38 insertions(+), 35 deletions(-) diff --git a/FlatCAMObj.py b/FlatCAMObj.py index d28e40ab..2458c62a 100644 --- a/FlatCAMObj.py +++ b/FlatCAMObj.py @@ -1269,23 +1269,22 @@ class FlatCAMGerber(FlatCAMObj, Gerber): """ if geometry is None: - if follow: - work_geo = self.follow_geometry - else: - work_geo = self.solid_geometry + work_geo = self.follow_geometry if follow is True else self.solid_geometry else: work_geo = geometry if dia is None: dia = float(self.options["isotooldia"]) + if passes is None: passes = int(self.options["isopasses"]) + if overlap is None: overlap = float(self.options["isooverlap"]) - if combine is None: - combine = self.options["combine_passes"] - else: - combine = bool(combine) + + overlap /= 100.0 + + combine = self.options["combine_passes"] if combine is None else bool(combine) if milling_type is None: milling_type = self.options["milling_type"] @@ -1316,7 +1315,7 @@ class FlatCAMGerber(FlatCAMObj, Gerber): geo_obj.solid_geometry = [] for i in range(passes): - iso_offset = dia * ((2 * i + 1) / 2.0) - (i * (overlap / 100) * dia) + iso_offset = dia * ((2 * i + 1) / 2.0) - (i * overlap * dia) # if milling type is climb then the move is counter-clockwise around features mill_t = 1 if milling_type == 'cl' else 0 @@ -1417,7 +1416,7 @@ class FlatCAMGerber(FlatCAMObj, Gerber): else: for i in range(passes): - offset = dia * ((2 * i + 1) / 2.0) - (i * (overlap / 100) * dia) + offset = dia * ((2 * i + 1) / 2.0) - (i * overlap * dia) if passes > 1: if outname is None: if self.iso_type == 0: diff --git a/README.md b/README.md index 413d5d68..e14f189a 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,8 @@ CAD program, and create G-Code for Isolation routing. - fixed some decimals issues in NCC Tool, Paint Tool and Excellon Editor (they were still using the harcoded values) - some small updates in the NCC Tool - changes in the Preferences UI for NCC and Paint Tool in Tool Dia entry field +- fixed Tcl commands that use the overlap parameter to switch from fraction to percentage +- in Transform Tool mae sure that the buffer sub-tool parameters are better explained in tooltips 29.12.2019 diff --git a/camlib.py b/camlib.py index 7f87351a..df328fed 100644 --- a/camlib.py +++ b/camlib.py @@ -1326,7 +1326,7 @@ class Geometry(object): geoms.get_points = get_pts # Path margin - path_margin = polygon_to_clear.buffer(-tooldia / 2, int(steps_per_circle / 4)) + path_margin = polygon_to_clear.buffer(-tooldia / 2, int(steps_per_circle)) if path_margin.is_empty or path_margin is None: return @@ -1345,7 +1345,7 @@ class Geometry(object): # provide the app with a way to process the GUI events when in a blocking loop QtWidgets.QApplication.processEvents() - path = Point(seedpoint).buffer(radius, int(steps_per_circle / 4)).exterior + path = Point(seedpoint).buffer(radius, int(steps_per_circle)).exterior path = path.intersection(path_margin) # Touches polygon? diff --git a/flatcamEditors/FlatCAMGeoEditor.py b/flatcamEditors/FlatCAMGeoEditor.py index 53bc55e3..cccd2db4 100644 --- a/flatcamEditors/FlatCAMGeoEditor.py +++ b/flatcamEditors/FlatCAMGeoEditor.py @@ -453,7 +453,7 @@ class PaintOptionsTool(FlatCAMTool): # Overlap ovlabel = QtWidgets.QLabel('%s:' % _('Overlap Rate')) ovlabel.setToolTip( - _("How much (fraction) of the tool width to overlap each tool pass.\n" + _("How much (percentage) of the tool width to overlap each tool pass.\n" "Adjust the value starting with lower values\n" "and increasing it if areas that should be painted are still \n" "not painted.\n" diff --git a/flatcamGUI/ObjectUI.py b/flatcamGUI/ObjectUI.py index 3b239b3c..9cadf1ee 100644 --- a/flatcamGUI/ObjectUI.py +++ b/flatcamGUI/ObjectUI.py @@ -388,7 +388,7 @@ class GerberObjectUI(ObjectUI): # Pass overlap overlabel = QtWidgets.QLabel('%s:' % _('Pass overlap')) overlabel.setToolTip( - _("How much (fraction) of the tool width to overlap each tool pass.") + _("How much (percentage) of the tool width to overlap each tool pass.") ) overlabel.setMinimumWidth(90) self.iso_overlap_entry = FCDoubleSpinner(suffix='%') diff --git a/flatcamGUI/PreferencesUI.py b/flatcamGUI/PreferencesUI.py index b0803044..cefc7e9d 100644 --- a/flatcamGUI/PreferencesUI.py +++ b/flatcamGUI/PreferencesUI.py @@ -2048,7 +2048,7 @@ class GerberOptPrefGroupUI(OptionsGroupUI): # Pass overlap overlabel = QtWidgets.QLabel('%s:' % _('Pass overlap')) overlabel.setToolTip( - _("How much (fraction) of the tool width to overlap each tool pass.") + _("How much (percentage) of the tool width to overlap each tool pass.") ) self.iso_overlap_entry = FCDoubleSpinner(suffix='%') self.iso_overlap_entry.set_precision(self.decimals) @@ -5157,7 +5157,7 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI): # Overlap Entry nccoverlabel = QtWidgets.QLabel('%s:' % _('Overlap Rate')) nccoverlabel.setToolTip( - _("How much (fraction) of the tool width to overlap each tool pass.\n" + _("How much (percentage) of the tool width to overlap each tool pass.\n" "Adjust the value starting with lower values\n" "and increasing it if areas that should be cleared are still \n" "not cleared.\n" @@ -5574,7 +5574,7 @@ class ToolsPaintPrefGroupUI(OptionsGroupUI): # Overlap ovlabel = QtWidgets.QLabel('%s:' % _('Overlap Rate')) ovlabel.setToolTip( - _("How much (fraction) of the tool width to overlap each tool pass.\n" + _("How much (percentage) of the tool width to overlap each tool pass.\n" "Adjust the value starting with lower values\n" "and increasing it if areas that should be painted are still \n" "not painted.\n" @@ -6418,12 +6418,13 @@ class ToolsTransformPrefGroupUI(OptionsGroupUI): grid0.addWidget(self.buffer_label, 17, 0) grid0.addWidget(self.buffer_entry, 17, 1) - self.buffer_factor_label = QtWidgets.QLabel('%s:' % _("Factor")) + self.buffer_factor_label = QtWidgets.QLabel('%s:' % _("Value")) self.buffer_factor_label.setToolTip( _("A positive value will create the effect of dilation,\n" "while a negative value will create the effect of erosion.\n" "Each geometry element of the object will be increased\n" - "or decreased by the 'factor'.") + "or decreased to fit the 'Value'. Value is a percentage\n" + "of the initial dimension.") ) self.buffer_factor_entry = FCDoubleSpinner(suffix='%') diff --git a/flatcamTools/ToolNonCopperClear.py b/flatcamTools/ToolNonCopperClear.py index 7b5a51af..4b3560cf 100644 --- a/flatcamTools/ToolNonCopperClear.py +++ b/flatcamTools/ToolNonCopperClear.py @@ -318,7 +318,7 @@ class NonCopperClear(FlatCAMTool, Gerber): # Overlap Entry nccoverlabel = QtWidgets.QLabel('%s:' % _('Overlap Rate')) nccoverlabel.setToolTip( - _("How much (fraction) of the tool width to overlap each tool pass.\n" + _("How much (percentage) of the tool width to overlap each tool pass.\n" "Adjust the value starting with lower values\n" "and increasing it if areas that should be cleared are still \n" "not cleared.\n" @@ -1430,7 +1430,7 @@ class NonCopperClear(FlatCAMTool, Gerber): else: ncc_select = self.reference_radio.get_value() - overlap = overlap if overlap is not None else float(self.app.defaults["tools_nccoverlap"]) + overlap = overlap if overlap is not None else float(self.app.defaults["tools_nccoverlap"]) / 100.0 connect = connect if connect else self.app.defaults["tools_nccconnect"] contour = contour if contour else self.app.defaults["tools_ncccontour"] diff --git a/flatcamTools/ToolPaint.py b/flatcamTools/ToolPaint.py index 8ec87919..91dee46f 100644 --- a/flatcamTools/ToolPaint.py +++ b/flatcamTools/ToolPaint.py @@ -218,7 +218,7 @@ class ToolPaint(FlatCAMTool, Gerber): # Overlap ovlabel = QtWidgets.QLabel('%s:' % _('Overlap Rate')) ovlabel.setToolTip( - _("How much (fraction) of the tool width to overlap each tool pass.\n" + _("How much (percentage) of the tool width to overlap each tool pass.\n" "Adjust the value starting with lower values\n" "and increasing it if areas that should be painted are still \n" "not painted.\n" @@ -1380,7 +1380,7 @@ class ToolPaint(FlatCAMTool, Gerber): prog_plot = True if self.app.defaults["tools_paint_plotting"] == 'progressive' else False name = outname if outname is not None else self.obj_name + "_paint" - over = overlap if overlap is not None else float(self.app.defaults["tools_paintoverlap"]) + over = overlap if overlap is not None else float(self.app.defaults["tools_paintoverlap"]) / 100.0 conn = connect if connect is not None else self.app.defaults["tools_pathconnect"] cont = contour if contour is not None else self.app.defaults["tools_paintcontour"] order = order if order is not None else self.order_radio.get_value() @@ -1630,7 +1630,7 @@ class ToolPaint(FlatCAMTool, Gerber): proc = self.app.proc_container.new(_("Painting polygons...")) name = outname if outname is not None else self.obj_name + "_paint" - over = overlap if overlap is not None else float(self.app.defaults["tools_paintoverlap"]) + over = overlap if overlap is not None else float(self.app.defaults["tools_paintoverlap"]) / 100.0 conn = connect if connect is not None else self.app.defaults["tools_pathconnect"] cont = contour if contour is not None else self.app.defaults["tools_paintcontour"] order = order if order is not None else self.order_radio.get_value() @@ -2214,7 +2214,7 @@ class ToolPaint(FlatCAMTool, Gerber): proc = self.app.proc_container.new(_("Painting polygons...")) name = outname if outname is not None else self.obj_name + "_paint" - over = overlap if overlap is not None else float(self.app.defaults["tools_paintoverlap"]) + over = overlap if overlap is not None else float(self.app.defaults["tools_paintoverlap"]) / 100.0 conn = connect if connect is not None else self.app.defaults["tools_pathconnect"] cont = contour if contour is not None else self.app.defaults["tools_paintcontour"] order = order if order is not None else self.order_radio.get_value() diff --git a/flatcamTools/ToolTransform.py b/flatcamTools/ToolTransform.py index cbfe6f34..821c0d68 100644 --- a/flatcamTools/ToolTransform.py +++ b/flatcamTools/ToolTransform.py @@ -371,12 +371,13 @@ class ToolTransform(FlatCAMTool): grid0.addWidget(self.buffer_entry, 23, 1) grid0.addWidget(self.buffer_button, 23, 2) - self.buffer_factor_label = QtWidgets.QLabel('%s:' % _("Factor")) + self.buffer_factor_label = QtWidgets.QLabel('%s:' % _("Value")) self.buffer_factor_label.setToolTip( _("A positive value will create the effect of dilation,\n" "while a negative value will create the effect of erosion.\n" "Each geometry element of the object will be increased\n" - "or decreased by the 'factor'.") + "or decreased to fit the 'Value'. Value is a percentage\n" + "of the initial dimension.") ) self.buffer_factor_entry = FCDoubleSpinner(suffix='%') diff --git a/tclCommands/TclCommandCopperClear.py b/tclCommands/TclCommandCopperClear.py index b107cf26..ed2e88d4 100644 --- a/tclCommands/TclCommandCopperClear.py +++ b/tclCommands/TclCommandCopperClear.py @@ -55,7 +55,7 @@ class TclCommandCopperClear(TclCommand): ('name', 'Name of the source Geometry object. String.'), ('tooldia', 'Diameter of the tool to be used. Can be a comma separated list of diameters. No space is ' 'allowed between tool diameters. E.g: correct: 0.5,1 / incorrect: 0.5, 1'), - ('overlap', 'Fraction of the tool diameter to overlap cuts. Float number.'), + ('overlap', 'Percentage of the tool diameter to overlap cuts. Float number, [0%, 99.9999%]'), ('margin', 'Bounding box margin. Float number.'), ('order', 'Can have the values: "no", "fwd" and "rev". String.' 'It is useful when there are multiple tools in tooldia parameter.' @@ -106,9 +106,9 @@ class TclCommandCopperClear(TclCommand): tooldia = self.app.defaults["tools_ncctools"] if 'overlap' in args: - overlap = float(args['overlap']) + overlap = float(args['overlap']) / 100.0 else: - overlap = float(self.app.defaults["tools_nccoverlap"]) + overlap = float(self.app.defaults["tools_nccoverlap"]) / 100.0 if 'order' in args: order = args['order'] diff --git a/tclCommands/TclCommandIsolate.py b/tclCommands/TclCommandIsolate.py index 75dd3fec..6816b3e4 100644 --- a/tclCommands/TclCommandIsolate.py +++ b/tclCommands/TclCommandIsolate.py @@ -45,7 +45,7 @@ class TclCommandIsolate(TclCommandSignaled): ('name', 'Name of the source object.'), ('dia', 'Tool diameter.'), ('passes', 'Passes of tool width.'), - ('overlap', 'Fraction of tool diameter to overlap passes.'), + ('overlap', 'Percentage of tool diameter to overlap passes. [0%, 99.9999%'), ('combine', 'Combine all passes into one geometry.'), ('outname', 'Name of the resulting Geometry object.'), ('follow', 'Create a Geometry that follows the Gerber path.'), diff --git a/tclCommands/TclCommandPaint.py b/tclCommands/TclCommandPaint.py index d7675f2c..6305696d 100644 --- a/tclCommands/TclCommandPaint.py +++ b/tclCommands/TclCommandPaint.py @@ -56,7 +56,7 @@ class TclCommandPaint(TclCommand): ('name', 'Name of the source Geometry object. String.'), ('tooldia', 'Diameter of the tool to be used. Can be a comma separated list of diameters. No space is ' 'allowed between tool diameters. E.g: correct: 0.5,1 / incorrect: 0.5, 1'), - ('overlap', 'Fraction of the tool diameter to overlap cuts. Float number.'), + ('overlap', 'Percentage of the tool diameter to overlap cuts. Float number, [0%, 99.9999%]'), ('margin', 'Bounding box margin. Float number.'), ('order', 'Can have the values: "no", "fwd" and "rev". String.' 'It is useful when there are multiple tools in tooldia parameter.' @@ -74,7 +74,7 @@ class TclCommandPaint(TclCommand): ('y', 'Y value of coordinate for the selection of a single polygon. Float number.'), ('outname', 'Name of the resulting Geometry object. String.'), ]), - 'examples': [] + 'examples': ["paint obj_name -tooldia 0.3 -margin 0.1 -method 'seed' -all True"] } def execute(self, args, unnamed_args): @@ -103,9 +103,9 @@ class TclCommandPaint(TclCommand): tooldia = float(self.app.defaults["tools_paintoverlap"]) if 'overlap' in args: - overlap = float(args['overlap']) + overlap = float(args['overlap']) / 100.0 else: - overlap = float(self.app.defaults["tools_paintoverlap"]) + overlap = float(self.app.defaults["tools_paintoverlap"]) / 100.0 if 'order' in args: order = args['order']