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

- in Gerber isolation added the option to selectively isolate only certain polygons - made it to work for Legacy(2D) graphic mode

Marius Stanciu 6 лет назад
Родитель
Сommit
07fb663e7b
5 измененных файлов с 35 добавлено и 22 удалено
  1. 11 11
      FlatCAMApp.py
  2. 12 8
      FlatCAMObj.py
  3. 1 0
      README.md
  4. 8 0
      flatcamGUI/PlotCanvasLegacy.py
  5. 3 3
      flatcamTools/ToolCopperThieving.py

+ 11 - 11
FlatCAMApp.py

@@ -1602,6 +1602,13 @@ class App(QtCore.QObject):
         else:
         else:
             self.is_legacy = True
             self.is_legacy = True
 
 
+        # Event signals disconnect id holders
+        self.mp = None
+        self.mm = None
+        self.mr = None
+        self.mdc = None
+        self.mp_zc = None
+
         # Matplotlib axis
         # Matplotlib axis
         self.axes = None
         self.axes = None
 
 
@@ -2511,12 +2518,6 @@ class App(QtCore.QObject):
         self.width = None
         self.width = None
         self.height = None
         self.height = None
 
 
-        # Event signals disconnect id holders
-        self.mp = None
-        self.mm = None
-        self.mr = None
-        self.mp_zc = None
-
         # when True, the app has to return from any thread
         # when True, the app has to return from any thread
         self.abort_flag = False
         self.abort_flag = False
 
 
@@ -8462,11 +8463,10 @@ class App(QtCore.QObject):
 
 
         # if the released mouse button was RMB then test if it was a panning motion or not, if not it was a context
         # if the released mouse button was RMB then test if it was a panning motion or not, if not it was a context
         # canvas menu
         # canvas menu
-        if event.button == right_button:  # right click
-            if self.ui.popMenu.mouse_is_panning is False:
-                self.cursor = QtGui.QCursor()
-                self.populate_cmenu_grids()
-                self.ui.popMenu.popup(self.cursor.pos())
+        if event.button == right_button and self.ui.popMenu.mouse_is_panning is False:  # right click
+            self.cursor = QtGui.QCursor()
+            self.populate_cmenu_grids()
+            self.ui.popMenu.popup(self.cursor.pos())
 
 
         # if the released mouse button was LMB then test if we had a right-to-left selection or a left-to-right
         # if the released mouse button was LMB then test if we had a right-to-left selection or a left-to-right
         # selection and then select a type of selection ("enclosing" or "touching")
         # selection and then select a type of selection ("enclosing" or "touching")

+ 12 - 8
FlatCAMObj.py

@@ -621,11 +621,14 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
         self.decimals = 4
         self.decimals = 4
 
 
         # Mouse events
         # Mouse events
-        self.mr = self.app.mr
+        self.mr = None
 
 
         # dict to store the polygons selected for isolation; key is the shape added to be ploted and value is the poly
         # dict to store the polygons selected for isolation; key is the shape added to be ploted and value is the poly
         self.poly_dict = dict()
         self.poly_dict = dict()
 
 
+        # store the status of grid snapping
+        self.grid_status_memory = None
+
         # Attributes to be included in serialization
         # Attributes to be included in serialization
         # Always append to it because it carries contents
         # Always append to it because it carries contents
         # from predecessors.
         # from predecessors.
@@ -1061,12 +1064,12 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
     def on_mouse_click_release(self, event):
     def on_mouse_click_release(self, event):
         if self.app.is_legacy is False:
         if self.app.is_legacy is False:
             event_pos = event.pos
             event_pos = event.pos
-            event_is_dragging = event.is_dragging
             right_button = 2
             right_button = 2
+            event_is_dragging = self.app.event_is_dragging
         else:
         else:
             event_pos = (event.xdata, event.ydata)
             event_pos = (event.xdata, event.ydata)
-            event_is_dragging = self.app.plotcanvas.is_dragging
             right_button = 3
             right_button = 3
+            event_is_dragging = self.app.ui.popMenu.mouse_is_panning
 
 
         try:
         try:
             x = float(event_pos[0])
             x = float(event_pos[0])
@@ -1083,9 +1086,9 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
             if clicked_poly:
             if clicked_poly:
                 if clicked_poly not in self.poly_dict.values():
                 if clicked_poly not in self.poly_dict.values():
                     shape_id = self.app.tool_shapes.add(tolerance=self.drawing_tolerance, layer=0, shape=clicked_poly,
                     shape_id = self.app.tool_shapes.add(tolerance=self.drawing_tolerance, layer=0, shape=clicked_poly,
-                                             color=self.app.defaults['global_sel_draw_color'] + 'AF',
-                                             face_color=self.app.defaults['global_sel_draw_color'] + 'AF',
-                                             visible=True)
+                                                        color=self.app.defaults['global_sel_draw_color'] + 'AF',
+                                                        face_color=self.app.defaults['global_sel_draw_color'] + 'AF',
+                                                        visible=True)
                     self.poly_dict[shape_id] = clicked_poly
                     self.poly_dict[shape_id] = clicked_poly
                     self.app.inform.emit(
                     self.app.inform.emit(
                         '%s: %d. %s' % (_("Added polygon"),
                         '%s: %d. %s' % (_("Added polygon"),
@@ -1110,7 +1113,7 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
             else:
             else:
                 self.app.inform.emit(_("No polygon detected under click position."))
                 self.app.inform.emit(_("No polygon detected under click position."))
 
 
-        elif event.button == right_button and self.app.event_is_dragging is False:
+        elif event.button == right_button and event_is_dragging is False:
             # restore the Grid snapping if it was active before
             # restore the Grid snapping if it was active before
             if self.grid_status_memory is True:
             if self.grid_status_memory is True:
                 self.app.ui.grid_snap_btn.trigger()
                 self.app.ui.grid_snap_btn.trigger()
@@ -1126,8 +1129,9 @@ class FlatCAMGerber(FlatCAMObj, Gerber):
             self.app.tool_shapes.clear(update=True)
             self.app.tool_shapes.clear(update=True)
 
 
             if self.poly_dict:
             if self.poly_dict:
-                poly_list = self.poly_dict.values()
+                poly_list = deepcopy(list(self.poly_dict.values()))
                 self.isolate(iso_type=self.iso_type, geometry=poly_list)
                 self.isolate(iso_type=self.iso_type, geometry=poly_list)
+                self.poly_dict.clear()
             else:
             else:
                 self.app.inform.emit('[ERROR_NOTCL] %s' % _("List of single polygons is empty. Aborting."))
                 self.app.inform.emit('[ERROR_NOTCL] %s' % _("List of single polygons is empty. Aborting."))
 
 

+ 1 - 0
README.md

@@ -17,6 +17,7 @@ CAD program, and create G-Code for Isolation routing.
 - 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
 - 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
 - clicking to add a polygon when doing Single type isolation will add a blue shape marking the selected polygon, second click will remove that shape
 - clicking to add a polygon when doing Single type isolation will add a blue shape marking the selected polygon, second click will remove that shape
 - fixed bugs in Paint Tool when painting single polygon
 - fixed bugs in Paint Tool when painting single polygon
+- in Gerber isolation added the option to selectively isolate only certain polygons - made it to work for Legacy(2D) graphic mode
 
 
 23.11.2019
 23.11.2019
 
 

+ 8 - 0
flatcamGUI/PlotCanvasLegacy.py

@@ -909,6 +909,14 @@ class ShapeCollectionLegacy:
 
 
         return self.shape_id
         return self.shape_id
 
 
+    def remove(self, shape_id, update=None):
+        for k in list(self._shapes.keys()):
+            if shape_id == k:
+                self._shapes.pop(k, None)
+
+        if update is True:
+            self.redraw()
+
     def clear(self, update=None):
     def clear(self, update=None):
         """
         """
         Clear the canvas of the shapes.
         Clear the canvas of the shapes.

+ 3 - 3
flatcamTools/ToolCopperThieving.py

@@ -1,7 +1,7 @@
 # ##########################################################
 # ##########################################################
 # FlatCAM: 2D Post-processing for Manufacturing            #
 # FlatCAM: 2D Post-processing for Manufacturing            #
 # File Author: Marius Adrian Stanciu (c)                   #
 # File Author: Marius Adrian Stanciu (c)                   #
-# Date: 10/25/2019                                          #
+# Date: 10/25/2019                                         #
 # MIT Licence                                              #
 # MIT Licence                                              #
 # ##########################################################
 # ##########################################################
 
 
@@ -876,7 +876,7 @@ class ToolCopperThieving(FlatCAMTool):
 
 
                     if old_disp_number < disp_number <= 100:
                     if old_disp_number < disp_number <= 100:
                         app_obj.app.proc_container.update_view_text(' %s ... %d%%' %
                         app_obj.app.proc_container.update_view_text(' %s ... %d%%' %
-                                                                 (_("Thieving"), int(disp_number)))
+                                                                    (_("Thieving"), int(disp_number)))
                         old_disp_number = disp_number
                         old_disp_number = disp_number
             except TypeError:
             except TypeError:
                 # taking care of the case when the self.solid_geometry is just a single Polygon, not a list or a
                 # taking care of the case when the self.solid_geometry is just a single Polygon, not a list or a
@@ -1074,7 +1074,7 @@ class ToolCopperThieving(FlatCAMTool):
 
 
                         if old_disp_number < disp_number <= 100:
                         if old_disp_number < disp_number <= 100:
                             app_obj.app.proc_container.update_view_text(' %s ... %d%%' %
                             app_obj.app.proc_container.update_view_text(' %s ... %d%%' %
-                                                                     (_("Buffering"), int(disp_number)))
+                                                                        (_("Buffering"), int(disp_number)))
                             old_disp_number = disp_number
                             old_disp_number = disp_number
                 except TypeError:
                 except TypeError:
                     # taking care of the case when the self.solid_geometry is just a single Polygon, not a list or a
                     # taking care of the case when the self.solid_geometry is just a single Polygon, not a list or a