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

jpcgt/flatcam/Beta слито с Beta

Camellan 6 лет назад
Родитель
Сommit
3a31e12003

+ 10 - 3
FlatCAMApp.py

@@ -1830,7 +1830,7 @@ class App(QtCore.QObject):
         # signal for displaying messages in status bar
         self.inform.connect(self.info)
         # signal to be called when the app is quiting
-        self.app_quit.connect(self.quit_application)
+        self.app_quit.connect(self.quit_application, type=Qt.QueuedConnection)
         self.message.connect(self.message_dialog)
         self.progress.connect(self.set_progress_bar)
 
@@ -5104,7 +5104,7 @@ class App(QtCore.QObject):
 
         :return: None
         """
-        self.save_defaults()
+        self.save_defaults(silent=True)
         log.debug("App.final_save() --> App Defaults saved.")
 
         if self.cmd_line_headless != 1:
@@ -5138,7 +5138,14 @@ class App(QtCore.QObject):
             del stgs
 
         log.debug("App.final_save() --> App UI state saved.")
-        QtWidgets.qApp.quit()
+
+        # QtWidgets.qApp.quit()
+        QtCore.QCoreApplication.exit()
+        if sys.platform != 'win32':
+            try:
+                sys.exit()
+            except Exception:
+                pass
 
     def on_portable_checked(self, state):
         """

+ 9 - 10
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:

+ 6 - 0
README.md

@@ -15,6 +15,12 @@ CAD program, and create G-Code for Isolation routing.
 - in Transform Tool adjusted the GUI
 - 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
+- attempt to make TclCommand quit_flatcam work under Linux
+- some fixes in the NCC Tcl command (using the bool() method on some params)
+- another attempt to make TclCommand quit_flatcam work under Linux
 
 29.12.2019
 

+ 2 - 2
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?

+ 1 - 1
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"

+ 4 - 1
flatcamGUI/GUIElements.py

@@ -367,12 +367,15 @@ class IntEntry(QtWidgets.QLineEdit):
 
 
 class FCEntry(QtWidgets.QLineEdit):
-    def __init__(self, decimals=None, alignment=None, parent=None):
+    def __init__(self, decimals=None, alignment=None, border_color=None, parent=None):
         super(FCEntry, self).__init__(parent)
         self.readyToEdit = True
         self.editingFinished.connect(self.on_edit_finished)
         self.decimals = decimals if decimals is not None else 4
 
+        if border_color:
+            self.setStyleSheet("QLineEdit {border: 1px solid %s;}" % border_color)
+
         if alignment:
             if alignment == 'center':
                 align_val = QtCore.Qt.AlignHCenter

+ 1 - 1
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='%')

+ 10 - 7
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)
@@ -5034,7 +5034,8 @@ class ToolsNCCPrefGroupUI(OptionsGroupUI):
               "Valid values: 0.3, 1.0")
         )
         grid0.addWidget(ncctdlabel, 0, 0)
-        self.ncc_tool_dia_entry = FCEntry()
+        self.ncc_tool_dia_entry = FCEntry(border_color='#0069A9')
+        self.ncc_tool_dia_entry.setPlaceholderText(_("Comma separated values"))
         grid0.addWidget(self.ncc_tool_dia_entry, 0, 1)
 
         # Tool Type Radio Button
@@ -5156,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"
@@ -5545,7 +5546,8 @@ class ToolsPaintPrefGroupUI(OptionsGroupUI):
         )
         grid0.addWidget(ptdlabel, 0, 0)
 
-        self.painttooldia_entry = FCEntry()
+        self.painttooldia_entry = FCEntry(border_color='#0069A9')
+        self.painttooldia_entry.setPlaceholderText(_("Comma separated values"))
 
         grid0.addWidget(self.painttooldia_entry, 0, 1)
 
@@ -5572,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"
@@ -6416,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='%')

+ 2 - 2
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"]

+ 4 - 4
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()

+ 3 - 2
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='%')

+ 9 - 8
tclCommands/TclCommandCopperClear.py

@@ -55,7 +55,8 @@ 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 tool diameter to overlap current pass over previous pass. Float [0, 99.9999]\n'
+                        'E.g: for a 25% from tool diameter overlap use -overlap 25'),
             ('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.'
@@ -68,13 +69,13 @@ class TclCommandCopperClear(TclCommand):
             ('rest', 'Use rest-machining. True or False'),
             ('has_offset', 'The offset will used only if this is set True or present in args. True or False.'),
             ('offset', 'The copper clearing will finish to a distance from copper features. Float number.'),
-            ('all', 'Will copper clear the whole object. 1 = enabled, anything else = disabled'),
+            ('all', 'Will copper clear the whole object. 1 or True = enabled, anything else = disabled'),
             ('ref', 'Will clear of extra copper all polygons within a specified object with the name in "box" '
-                    'parameter. 1 = enabled, anything else = disabled'),
+                    'parameter. 1 or True = enabled, anything else = disabled'),
             ('box', 'Name of the object to be used as reference. Required when selecting "ref" = 1. String.'),
             ('outname', 'Name of the resulting Geometry object. String.'),
         ]),
-        'examples': []
+        'examples': ["ncc obj_name -tooldia 0.3,1 -overlap 10 -margin 1.0 -method 'lines' -all True"]
     }
 
     def execute(self, args, unnamed_args):
@@ -106,9 +107,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']
@@ -217,7 +218,7 @@ class TclCommandCopperClear(TclCommand):
                 outname = name + "_ncc_rm"
 
         # Non-Copper clear all polygons in the non-copper clear object
-        if 'all' in args and args['all'] == 1:
+        if 'all' in args and bool(args['all']):
             self.app.ncclear_tool.clear_copper(ncc_obj=obj,
                                                select_method='itself',
                                                ncctooldia=tooldia,
@@ -237,7 +238,7 @@ class TclCommandCopperClear(TclCommand):
             return
 
         # Non-Copper clear all polygons found within the box object from the the non_copper cleared object
-        elif 'ref' in args and args['ref'] == 1:
+        elif 'ref' in args and bool(args['ref']):
             if 'box' not in args:
                 self.raise_tcl_error('%s' % _("Expected -box <value>."))
             else:

+ 3 - 1
tclCommands/TclCommandIsolate.py

@@ -3,6 +3,7 @@ from FlatCAMObj import FlatCAMGerber
 
 import collections
 
+
 class TclCommandIsolate(TclCommandSignaled):
     """
     Tcl shell command to Creates isolation routing geometry for the given Gerber.
@@ -45,7 +46,8 @@ 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 current pass over previous pass. Float [0, 99.9999]\n'
+                        'E.g: for a 25% from tool diameter overlap use -overlap 25'),
             ('combine', 'Combine all passes into one geometry.'),
             ('outname', 'Name of the resulting Geometry object.'),
             ('follow', 'Create a Geometry that follows the Gerber path.'),

+ 5 - 4
tclCommands/TclCommandPaint.py

@@ -56,7 +56,8 @@ 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 tool diameter to overlap current pass over previous pass. Float [0, 99.9999]\n'
+                        'E.g: for a 25% from tool diameter overlap use -overlap 25'),
             ('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 +75,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 +104,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']