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

- updated the 'single' isolation of Gerber polygons to remove the polygon if clicked on it and it is already in the list of single polygons to be isolated

Marius Stanciu 6 лет назад
Родитель
Сommit
9715fba5eb
2 измененных файлов с 22 добавлено и 8 удалено
  1. 21 8
      FlatCAMObj.py
  2. 1 0
      README.md

+ 21 - 8
FlatCAMObj.py

@@ -1081,14 +1081,24 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
             clicked_poly = self.find_polygon(point=(curr_pos[0], curr_pos[1]))
 
             if clicked_poly:
-                self.poly_list.append(clicked_poly)
-                self.app.inform.emit(
-                    '%s: %d. %s' % (_("Added polygon"),
-                                    int(len(self.poly_list)),
-                                    _("Click to start adding next polygon or right click to start isolation."))
-                )
+                if clicked_poly not in self.poly_list:
+                    self.poly_list.append(clicked_poly)
+                    self.app.inform.emit(
+                        '%s: %d. %s' % (_("Added polygon"),
+                                        int(len(self.poly_list)),
+                                        _("Click to add next polygon or right click to start isolation."))
+                    )
+                else:
+                    try:
+                        self.poly_list.remove(clicked_poly)
+                    except TypeError:
+                        return
+                    self.app.inform.emit(
+                        '%s. %s' % (_("Removed polygon"),
+                                    _("Click to add/remove next polygon or right click to start isolation."))
+                    )
             else:
-                self.app.inform.emit(_("No polygon detected under click position. Try again."))
+                self.app.inform.emit(_("No polygon detected under click position."))
 
         elif event.button == right_button and self.app.event_is_dragging is False:
             # restore the Grid snapping if it was active before
@@ -1103,7 +1113,10 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
             self.app.mr = self.app.plotcanvas.graph_event_connect('mouse_release',
                                                                   self.app.on_mouse_click_release_over_plot)
 
-            self.isolate(iso_type=self.iso_type, geometry=self.poly_list)
+            if self.poly_list:
+                self.isolate(iso_type=self.iso_type, geometry=self.poly_list)
+            else:
+                self.app.inform.emit('[ERROR_NOTCL] %s' % _("List of single polygons is empty. Aborting."))
 
     def isolate(self, iso_type=None, geometry=None, dia=None, passes=None, overlap=None, outname=None, combine=None,
                 milling_type=None, follow=None, plot=True):

+ 1 - 0
README.md

@@ -14,6 +14,7 @@ CAD program, and create G-Code for Isolation routing.
 - In Gerber isolation changed the UI
 - in Gerber isolation added the option to selectively isolate only certain polygons
 - made some optimizations in FlatCAMGerber.isolate() method
+- updated the 'single' isolation of Gerber polygons to remove the polygon if clicked on it and it is already in the list of single polygons to be isolated
 
 23.11.2019