From 4efc453b841990fca0b393bf40d86fa6316e1db8 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Wed, 18 Dec 2019 17:53:41 +0200 Subject: [PATCH] - fixed a bug in the new feature 'extra buffering' - fixed the creation of CNCJob objects out of multigeo Geometry objects (objects with multiple tools) - optimized the NCC Tool --- FlatCAM.py | 8 +++++++ FlatCAMObj.py | 4 +--- README.md | 3 +++ flatcamParsers/ParseGerber.py | 7 ++++-- flatcamTools/ToolNonCopperClear.py | 37 +++++++++++++++++++----------- 5 files changed, 40 insertions(+), 19 deletions(-) diff --git a/FlatCAM.py b/FlatCAM.py index 191d5fbe..02c56c9d 100644 --- a/FlatCAM.py +++ b/FlatCAM.py @@ -47,6 +47,14 @@ if __name__ == '__main__': else: os.environ["QT_AUTO_SCREEN_SCALE_FACTOR"] = "0" + # if hdpi_support == 2: + # tst_screen = QtWidgets.QApplication(sys.argv) + # if tst_screen.screens()[0].geometry().width() > 1930 or tst_screen.screens()[1].geometry().width() > 1930: + # QGuiApplication.setAttribute(Qt.AA_EnableHighDpiScaling, True) + # del tst_screen + # else: + # QGuiApplication.setAttribute(Qt.AA_EnableHighDpiScaling, False) + app = QtWidgets.QApplication(sys.argv) # apply style diff --git a/FlatCAMObj.py b/FlatCAMObj.py index 671678e4..2574232b 100644 --- a/FlatCAMObj.py +++ b/FlatCAMObj.py @@ -5291,10 +5291,8 @@ class FlatCAMGeometry(FlatCAMObj, Geometry): if use_thread: # To be run in separate thread - # The idea is that if there is a solid_geometry in the file "root" then most likely thare are no - # separate solid_geometry in the self.tools dictionary def job_thread(app_obj): - if self.solid_geometry: + if self.multigeo is False: with self.app.proc_container.new(_("Generating CNC Code")): if app_obj.new_object("cncjob", outname, job_init_single_geometry, plot=plot) != 'fail': app_obj.inform.emit('[success] %s: %s' % (_("CNCjob created"), outname)) diff --git a/README.md b/README.md index 7848c4f0..277cbfdf 100644 --- a/README.md +++ b/README.md @@ -16,6 +16,9 @@ CAD program, and create G-Code for Isolation routing. - the Jump To function reference is now saving it's last used value - added the ability to use the Jump To method in the Gerber Editor - improved the loading of Config File by using the advanced code editor +- fixed a bug in the new feature 'extra buffering' +- fixed the creation of CNCJob objects out of multigeo Geometry objects (objects with multiple tools) +- optimized the NCC Tool 17.12.2019 diff --git a/flatcamParsers/ParseGerber.py b/flatcamParsers/ParseGerber.py index f8829c5c..b9bc504d 100644 --- a/flatcamParsers/ParseGerber.py +++ b/flatcamParsers/ParseGerber.py @@ -1438,8 +1438,11 @@ class Gerber(Geometry): # features if self.app.defaults['gerber_extra_buffering']: candidate_geo = list() - for p in self.solid_geometry: - candidate_geo.append(p.buffer(0.0000001)) + try: + for p in self.solid_geometry: + candidate_geo.append(p.buffer(0.0000001)) + except TypeError: + candidate_geo.append(self.solid_geometry.buffer(0.0000001)) self.solid_geometry = candidate_geo # try: diff --git a/flatcamTools/ToolNonCopperClear.py b/flatcamTools/ToolNonCopperClear.py index a5f874b4..2579169d 100644 --- a/flatcamTools/ToolNonCopperClear.py +++ b/flatcamTools/ToolNonCopperClear.py @@ -1723,11 +1723,9 @@ class NonCopperClear(FlatCAMTool, Gerber): sol_geo = cascaded_union(isolated_geo) if has_offset is True: - app_obj.inform.emit('[WARNING_NOTCL] %s ...' % - _("Buffering")) + app_obj.inform.emit('[WARNING_NOTCL] %s ...' % _("Buffering")) sol_geo = sol_geo.buffer(distance=ncc_offset) - app_obj.inform.emit('[success] %s ...' % - _("Buffering finished")) + app_obj.inform.emit('[success] %s ...' % _("Buffering finished")) empty = self.get_ncc_empty_area(target=sol_geo, boundary=bounding_box) if empty == 'fail': return 'fail' @@ -1760,6 +1758,7 @@ class NonCopperClear(FlatCAMTool, Gerber): log.debug("NCC Tool. Finished calculation of 'empty' area.") self.app.inform.emit(_("NCC Tool. Finished calculation of 'empty' area.")) + # COPPER CLEARING # cp = None for tool in sorted_tools: log.debug("Starting geometry processing for tool: %s" % str(tool)) @@ -1916,17 +1915,27 @@ class NonCopperClear(FlatCAMTool, Gerber): if self.app.defaults["tools_ncc_plotting"] == 'progressive': self.temp_shapes.clear(update=True) - # delete tools with empty geometry - keys_to_delete = [] - # look for keys in the tools_storage dict that have 'solid_geometry' values empty - for uid in tools_storage: - # if the solid_geometry (type=list) is empty - if not tools_storage[uid]['solid_geometry']: - keys_to_delete.append(uid) + # # delete tools with empty geometry + # keys_to_delete = [] + # # look for keys in the tools_storage dict that have 'solid_geometry' values empty + # for uid in tools_storage: + # # if the solid_geometry (type=list) is empty + # if not tools_storage[uid]['solid_geometry']: + # keys_to_delete.append(uid) + # + # # actual delete of keys from the tools_storage dict + # for k in keys_to_delete: + # tools_storage.pop(k, None) - # actual delete of keys from the tools_storage dict - for k in keys_to_delete: - tools_storage.pop(k, None) + # delete tools with empty geometry + # look for keys in the tools_storage dict that have 'solid_geometry' values empty + for uid, uid_val in list(tools_storage.items()): + try: + # if the solid_geometry (type=list) is empty + if not uid_val['solid_geometry']: + tools_storage.pop(uid, None) + except KeyError: + tools_storage.pop(uid, None) geo_obj.options["cnctooldia"] = str(tool)