From 445b4300f5647c9d5b5bdfa8538f1c94337b3764 Mon Sep 17 00:00:00 2001 From: Marius Stanciu Date: Mon, 27 Jul 2020 03:25:38 +0300 Subject: [PATCH] - Gerber parser - a single move with pen up D2 followed by a pen down D1 at the same location is now treated as a Flash; fixed issue #441 --- CHANGELOG.md | 4 ++++ appEditors/appGCodeEditor.py | 4 ++++ appParsers/ParseGerber.py | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 90443124..e98476eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,10 @@ CHANGELOG for FlatCAM beta ================================================= +27.06.2020 + +- Gerber parser - a single move with pen up D2 followed by a pen down D1 at the same location is now treated as a Flash; fixed issue #441 + 25.07.2020 - Tools Tab is hidden when entering into a Editor and showed on exit (this needs to be remade such that the toolbars state should be restored to whatever it was before entering in the Editor) diff --git a/appEditors/appGCodeEditor.py b/appEditors/appGCodeEditor.py index 51a8893e..33c25a93 100644 --- a/appEditors/appGCodeEditor.py +++ b/appEditors/appGCodeEditor.py @@ -39,6 +39,10 @@ class AppGCodeEditor(QtCore.QObject): self.gcode_obj = None self.code_edited = '' + # store the status of the editor so the Delete at object level will not work until the edit is finished + self.editor_active = False + log.debug("Initialization of the GCode Editor is finished ...") + def set_ui(self): """ diff --git a/appParsers/ParseGerber.py b/appParsers/ParseGerber.py index 7be1a31c..ec967140 100644 --- a/appParsers/ParseGerber.py +++ b/appParsers/ParseGerber.py @@ -950,6 +950,41 @@ class Gerber(Geometry): # only add the point if it's a new one otherwise skip it (harder to process) if path[-1] != [current_x, current_y]: path.append([current_x, current_y]) + elif len(path) == 1: + # it's a flash that is done by moving with pen up D2 and then just a pen down D1 + # Reset path starting point + path = [[current_x, current_y]] + + # --- BUFFERED --- + # Draw the flash + # this treats the case when we are storing geometry as paths + geo_dict = {} + geo_flash = Point([current_x, current_y]) + follow_buffer.append(geo_flash) + geo_dict['follow'] = geo_flash + + # this treats the case when we are storing geometry as solids + flash = self.create_flash_geometry( + Point([current_x, current_y]), + self.apertures[current_aperture], + self.steps_per_circle + ) + if not flash.is_empty: + if self.app.defaults['gerber_simplification']: + poly_buffer.append(flash.simplify(s_tol)) + else: + poly_buffer.append(flash) + + if self.is_lpc is True: + geo_dict['clear'] = flash + else: + geo_dict['solid'] = flash + + if current_aperture not in self.apertures: + self.apertures[current_aperture] = {} + if 'geometry' not in self.apertures[current_aperture]: + self.apertures[current_aperture]['geometry'] = [] + self.apertures[current_aperture]['geometry'].append(deepcopy(geo_dict)) if making_region is False: # if the aperture is rectangle then add a rectangular shape having as parameters the