فهرست منبع

- 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)

Marius Stanciu 6 سال پیش
والد
کامیت
7707baa9b2
2فایلهای تغییر یافته به همراه45 افزوده شده و 3 حذف شده
  1. 1 0
      README.md
  2. 44 3
      flatcamEditors/FlatCAMGrbEditor.py

+ 1 - 0
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: 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: 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: 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
 15.04.2019
 
 

+ 44 - 3
flatcamEditors/FlatCAMGrbEditor.py

@@ -39,10 +39,19 @@ class FCPad(FCShapeTool):
         try:
         try:
             self.radius = float(self.draw_app.storage_dict[self.draw_app.last_aperture_selected]['size']) / 2
             self.radius = float(self.draw_app.storage_dict[self.draw_app.last_aperture_selected]['size']) / 2
         except KeyError:
         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.draw_app.in_action = False
             self.complete = True
             self.complete = True
             return
             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.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"]
         self.steps_per_circ = self.draw_app.app.defaults["geometry_circle_steps"]
 
 
@@ -72,6 +81,10 @@ class FCPad(FCShapeTool):
         return "Done."
         return "Done."
 
 
     def utility_geometry(self, data=None):
     def utility_geometry(self, data=None):
+        if self.dont_execute is True:
+            self.draw_app.select_tool('select')
+            return
+
         self.points = data
         self.points = data
         geo_data = self.util_shape(data)
         geo_data = self.util_shape(data)
         if geo_data:
         if geo_data:
@@ -199,11 +212,20 @@ class FCPadArray(FCShapeTool):
         try:
         try:
             self.radius = float(self.draw_app.storage_dict[self.draw_app.last_aperture_selected]['size']) / 2
             self.radius = float(self.draw_app.storage_dict[self.draw_app.last_aperture_selected]['size']) / 2
         except KeyError:
         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.complete = True
             self.draw_app.in_action = False
             self.draw_app.in_action = False
             self.draw_app.array_frame.hide()
             self.draw_app.array_frame.hide()
             return
             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.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"]
         self.steps_per_circ = self.draw_app.app.defaults["geometry_circle_steps"]
 
 
@@ -274,6 +296,10 @@ class FCPadArray(FCShapeTool):
         self.origin = origin
         self.origin = origin
 
 
     def utility_geometry(self, data=None, static=None):
     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_axis = self.draw_app.pad_axis_radio.get_value()
         self.pad_direction = self.draw_app.pad_direction_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()
         self.pad_array = self.draw_app.array_type_combo.get_value()
@@ -823,6 +849,11 @@ class FCScale(FCShapeTool):
         self.draw_app.on_scale()
         self.draw_app.on_scale()
         self.deactivate_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):
 class FCBuffer(FCShapeTool):
     def __init__(self, draw_app):
     def __init__(self, draw_app):
@@ -860,6 +891,11 @@ class FCBuffer(FCShapeTool):
         self.draw_app.on_buffer()
         self.draw_app.on_buffer()
         self.deactivate_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):
 class FCApertureMove(FCShapeTool):
     def __init__(self, draw_app):
     def __init__(self, draw_app):
@@ -1078,6 +1114,11 @@ class FCTransform(FCShapeTool):
         self.origin = (0, 0)
         self.origin = (0, 0)
         self.draw_app.transform_tool.run()
         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):
 class FlatCAMGrbEditor(QtCore.QObject):
 
 
@@ -2781,8 +2822,8 @@ class FlatCAMGrbEditor(QtCore.QObject):
             self.draw_utility_geometry(geo=geo)
             self.draw_utility_geometry(geo=geo)
 
 
         ### Selection area on canvas section ###
         ### Selection area on canvas section ###
-        dx = pos[0] - self.pos[0]
         if event.is_dragging == 1 and event.button == 1:
         if event.is_dragging == 1 and event.button == 1:
+            dx = pos[0] - self.pos[0]
             self.app.delete_selection_shape()
             self.app.delete_selection_shape()
             if dx < 0:
             if dx < 0:
                 self.app.draw_moving_selection_shape((self.pos[0], self.pos[1]), (x,y),
                 self.app.draw_moving_selection_shape((self.pos[0], self.pos[1]), (x,y),