diff --git a/README.md b/README.md index 0e83387d..47de23b6 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ CAD program, and create G-Code for Isolation routing. - Gerber Editor: started to add modes of laying a track - Gerber Editor: Add Track Tool: added 5 modes for laying a track: 45-degrees, reverse-45 degrees, 90-degrees, reverse 90-degrees and free angle. Key 'T' will cycle forward through the modes and key 'R' will cycle in reverse through the track laying modes. - Gerber Editor: Add Track Tool: first right click will finish the track. Second right click will exit the Track Tool and return to Select Tool. +- Gerber Editor: added protections for the Pad Array and Pad Tool for the case when the aperture size is zero (the aperture where to store the regions) 15.04.2019 diff --git a/flatcamEditors/FlatCAMGrbEditor.py b/flatcamEditors/FlatCAMGrbEditor.py index 88f9a8f6..4e7c5a2f 100644 --- a/flatcamEditors/FlatCAMGrbEditor.py +++ b/flatcamEditors/FlatCAMGrbEditor.py @@ -39,10 +39,19 @@ class FCPad(FCShapeTool): try: self.radius = float(self.draw_app.storage_dict[self.draw_app.last_aperture_selected]['size']) / 2 except KeyError: - self.draw_app.app.inform.emit(_("[WARNING_NOTCL] To add a Pad, first select a tool in Tool Table")) + self.draw_app.app.inform.emit(_( + "[WARNING_NOTCL] To add an Pad first select a aperture in Aperture Table")) self.draw_app.in_action = False self.complete = True return + + if self.radius == 0: + self.draw_app.app.inform.emit(_("[WARNING_NOTCL] Aperture size is zero. It needs to be greater than zero.")) + self.dont_execute = True + return + else: + self.dont_execute = False + self.storage_obj = self.draw_app.storage_dict[self.draw_app.last_aperture_selected]['solid_geometry'] self.steps_per_circ = self.draw_app.app.defaults["geometry_circle_steps"] @@ -72,6 +81,10 @@ class FCPad(FCShapeTool): return "Done." def utility_geometry(self, data=None): + if self.dont_execute is True: + self.draw_app.select_tool('select') + return + self.points = data geo_data = self.util_shape(data) if geo_data: @@ -199,11 +212,20 @@ class FCPadArray(FCShapeTool): try: self.radius = float(self.draw_app.storage_dict[self.draw_app.last_aperture_selected]['size']) / 2 except KeyError: - self.draw_app.app.inform.emit(_("[WARNING_NOTCL] To add an Pad Array first select a tool in Tool Table")) + self.draw_app.app.inform.emit(_( + "[WARNING_NOTCL] To add an Pad Array first select a aperture in Aperture Table")) self.complete = True self.draw_app.in_action = False self.draw_app.array_frame.hide() return + + if self.radius == 0: + self.draw_app.app.inform.emit(_("[WARNING_NOTCL] Aperture size is zero. It needs to be greater than zero.")) + self.dont_execute = True + return + else: + self.dont_execute = False + self.storage_obj = self.draw_app.storage_dict[self.draw_app.last_aperture_selected]['solid_geometry'] self.steps_per_circ = self.draw_app.app.defaults["geometry_circle_steps"] @@ -274,6 +296,10 @@ class FCPadArray(FCShapeTool): self.origin = origin def utility_geometry(self, data=None, static=None): + if self.dont_execute is True: + self.draw_app.select_tool('select') + return + self.pad_axis = self.draw_app.pad_axis_radio.get_value() self.pad_direction = self.draw_app.pad_direction_radio.get_value() self.pad_array = self.draw_app.array_type_combo.get_value() @@ -823,6 +849,11 @@ class FCScale(FCShapeTool): self.draw_app.on_scale() self.deactivate_scale() + def clean_up(self): + self.draw_app.selected = [] + self.draw_app.apertures_table.clearSelection() + self.draw_app.plot_all() + class FCBuffer(FCShapeTool): def __init__(self, draw_app): @@ -860,6 +891,11 @@ class FCBuffer(FCShapeTool): self.draw_app.on_buffer() self.deactivate_buffer() + def clean_up(self): + self.draw_app.selected = [] + self.draw_app.apertures_table.clearSelection() + self.draw_app.plot_all() + class FCApertureMove(FCShapeTool): def __init__(self, draw_app): @@ -1078,6 +1114,11 @@ class FCTransform(FCShapeTool): self.origin = (0, 0) self.draw_app.transform_tool.run() + def clean_up(self): + self.draw_app.selected = [] + self.draw_app.apertures_table.clearSelection() + self.draw_app.plot_all() + class FlatCAMGrbEditor(QtCore.QObject): @@ -2781,8 +2822,8 @@ class FlatCAMGrbEditor(QtCore.QObject): self.draw_utility_geometry(geo=geo) ### Selection area on canvas section ### - dx = pos[0] - self.pos[0] if event.is_dragging == 1 and event.button == 1: + dx = pos[0] - self.pos[0] self.app.delete_selection_shape() if dx < 0: self.app.draw_moving_selection_shape((self.pos[0], self.pos[1]), (x,y),