Explorar o código

- in Paint Tool added ability to add multiple zones to paint when Area option is checked and the modifier key is pressed (either CTRL or SHIFT as set in Preferences). Right click of the mouse is an additional way to finish the job.
- in Paint Tool and NCC Tool, for the Area option, now mouse panning is allowed while adding areas to process

Marius Stanciu %!s(int64=6) %!d(string=hai) anos
pai
achega
23f85b71e9
Modificáronse 3 ficheiros con 66 adicións e 13 borrados
  1. 2 0
      README.md
  2. 12 5
      flatcamTools/ToolNonCopperClear.py
  3. 52 8
      flatcamTools/ToolPaint.py

+ 2 - 0
README.md

@@ -15,6 +15,8 @@ CAD program, and create G-Code for Isolation routing.
 - in Tool Cutout tool I've added the possibility to create a cutout without bridge gaps; added the 'None' option in the Gaps combobox
 - in Tool Cutout tool I've added the possibility to create a cutout without bridge gaps; added the 'None' option in the Gaps combobox
 - in NCC Tool added ability to add multiple zones to clear when Area option is checked and the modifier key is pressed (either CTRL or SHIFT as set in Preferences). Right click of the mouse is an additional way to finish the job.
 - in NCC Tool added ability to add multiple zones to clear when Area option is checked and the modifier key is pressed (either CTRL or SHIFT as set in Preferences). Right click of the mouse is an additional way to finish the job.
 - fixed a bug in Excellon Editor that made that the selection of drills is always cumulative
 - fixed a bug in Excellon Editor that made that the selection of drills is always cumulative
+- in Paint Tool added ability to add multiple zones to paint when Area option is checked and the modifier key is pressed (either CTRL or SHIFT as set in Preferences). Right click of the mouse is an additional way to finish the job.
+- in Paint Tool and NCC Tool, for the Area option, now mouse panning is allowed while adding areas to process
 
 
 22.08.2019
 22.08.2019
 
 

+ 12 - 5
flatcamTools/ToolNonCopperClear.py

@@ -378,6 +378,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
 
 
         self.first_click = False
         self.first_click = False
         self.cursor_pos = None
         self.cursor_pos = None
+        self.mouse_is_dragging = False
 
 
         self.addtool_btn.clicked.connect(self.on_tool_add)
         self.addtool_btn.clicked.connect(self.on_tool_add)
         self.addtool_entry.returnPressed.connect(self.on_tool_add)
         self.addtool_entry.returnPressed.connect(self.on_tool_add)
@@ -845,7 +846,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
             tooldia = float('%.4f' % float(self.tools_table.item(0, 1).text()))
             tooldia = float('%.4f' % float(self.tools_table.item(0, 1).text()))
 
 
             # To be called after clicking on the plot.
             # To be called after clicking on the plot.
-            def on_mouse_press(event):
+            def on_mouse_release(event):
                 # do paint single only for left mouse clicks
                 # do paint single only for left mouse clicks
                 if event.button == 1:
                 if event.button == 1:
                     if self.first_click is False:
                     if self.first_click is False:
@@ -884,7 +885,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
                             self.first_click = False
                             self.first_click = False
                             return
                             return
 
 
-                        self.app.plotcanvas.vis_disconnect('mouse_press', on_mouse_press)
+                        self.app.plotcanvas.vis_disconnect('mouse_release', on_mouse_release)
                         self.app.plotcanvas.vis_disconnect('mouse_move', on_mouse_move)
                         self.app.plotcanvas.vis_disconnect('mouse_move', on_mouse_move)
 
 
                         self.app.plotcanvas.vis_connect('mouse_press', self.app.on_mouse_click_over_plot)
                         self.app.plotcanvas.vis_connect('mouse_press', self.app.on_mouse_click_over_plot)
@@ -892,9 +893,9 @@ class NonCopperClear(FlatCAMTool, Gerber):
                         self.app.plotcanvas.vis_connect('mouse_release', self.app.on_mouse_click_release_over_plot)
                         self.app.plotcanvas.vis_connect('mouse_release', self.app.on_mouse_click_release_over_plot)
 
 
                         self.on_ncc()
                         self.on_ncc()
-                elif event.button == 2:
+                elif event.button == 2 and self.first_click is False and self.mouse_is_dragging is False:
                     self.first_click = False
                     self.first_click = False
-                    self.app.plotcanvas.vis_disconnect('mouse_press', on_mouse_press)
+                    self.app.plotcanvas.vis_disconnect('mouse_release', on_mouse_release)
                     self.app.plotcanvas.vis_disconnect('mouse_move', on_mouse_move)
                     self.app.plotcanvas.vis_disconnect('mouse_move', on_mouse_move)
 
 
                     self.app.plotcanvas.vis_connect('mouse_press', self.app.on_mouse_click_over_plot)
                     self.app.plotcanvas.vis_connect('mouse_press', self.app.on_mouse_click_over_plot)
@@ -908,6 +909,12 @@ class NonCopperClear(FlatCAMTool, Gerber):
                 curr_pos = self.app.plotcanvas.vispy_canvas.translate_coords(event.pos)
                 curr_pos = self.app.plotcanvas.vispy_canvas.translate_coords(event.pos)
                 self.app.app_cursor.enabled = False
                 self.app.app_cursor.enabled = False
 
 
+                if event.button == 2:
+                    if event.is_dragging is True:
+                        self.mouse_is_dragging = True
+                    else:
+                        self.mouse_is_dragging = False
+
                 if self.app.grid_status() == True:
                 if self.app.grid_status() == True:
                     self.app.app_cursor.enabled = True
                     self.app.app_cursor.enabled = True
                     # Update cursor
                     # Update cursor
@@ -925,7 +932,7 @@ class NonCopperClear(FlatCAMTool, Gerber):
             self.app.plotcanvas.vis_disconnect('mouse_move', self.app.on_mouse_move_over_plot)
             self.app.plotcanvas.vis_disconnect('mouse_move', self.app.on_mouse_move_over_plot)
             self.app.plotcanvas.vis_disconnect('mouse_release', self.app.on_mouse_click_release_over_plot)
             self.app.plotcanvas.vis_disconnect('mouse_release', self.app.on_mouse_click_release_over_plot)
 
 
-            self.app.plotcanvas.vis_connect('mouse_press', on_mouse_press)
+            self.app.plotcanvas.vis_connect('mouse_release', on_mouse_release)
             self.app.plotcanvas.vis_connect('mouse_move', on_mouse_move)
             self.app.plotcanvas.vis_connect('mouse_move', on_mouse_move)
 
 
     def on_ncc(self):
     def on_ncc(self):

+ 52 - 8
flatcamTools/ToolPaint.py

@@ -360,6 +360,9 @@ class ToolPaint(FlatCAMTool, Gerber):
         self.tooluid = 0
         self.tooluid = 0
         self.first_click = False
         self.first_click = False
         self.cursor_pos = None
         self.cursor_pos = None
+        self.mouse_is_dragging = False
+
+        self.sel_rect = []
 
 
         # store here the default data for Geometry Data
         # store here the default data for Geometry Data
         self.default_data = {}
         self.default_data = {}
@@ -964,7 +967,7 @@ class ToolPaint(FlatCAMTool, Gerber):
             tooldia = float('%.4f' % float(self.tools_table.item(0, 1).text()))
             tooldia = float('%.4f' % float(self.tools_table.item(0, 1).text()))
 
 
             # To be called after clicking on the plot.
             # To be called after clicking on the plot.
-            def on_mouse_press(event):
+            def on_mouse_release(event):
                 # do paint single only for left mouse clicks
                 # do paint single only for left mouse clicks
                 if event.button == 1:
                 if event.button == 1:
                     if not self.first_click:
                     if not self.first_click:
@@ -975,8 +978,7 @@ class ToolPaint(FlatCAMTool, Gerber):
                         if self.app.grid_status() == True:
                         if self.app.grid_status() == True:
                             self.cursor_pos = self.app.geo_editor.snap(self.cursor_pos[0], self.cursor_pos[1])
                             self.cursor_pos = self.app.geo_editor.snap(self.cursor_pos[0], self.cursor_pos[1])
                     else:
                     else:
-                        self.app.inform.emit(_("Done."))
-                        self.first_click = False
+                        self.app.inform.emit(_("Zone added. Right click to finish."))
                         self.app.delete_selection_shape()
                         self.app.delete_selection_shape()
 
 
                         curr_pos = self.app.plotcanvas.vispy_canvas.translate_coords(event.pos)
                         curr_pos = self.app.plotcanvas.vispy_canvas.translate_coords(event.pos)
@@ -989,27 +991,63 @@ class ToolPaint(FlatCAMTool, Gerber):
                         pt2 = (x1, y0)
                         pt2 = (x1, y0)
                         pt3 = (x1, y1)
                         pt3 = (x1, y1)
                         pt4 = (x0, y1)
                         pt4 = (x0, y1)
-                        sel_rect = Polygon([pt1, pt2, pt3, pt4])
+                        self.sel_rect.append(Polygon([pt1, pt2, pt3, pt4]))
+
+                        modifiers = QtWidgets.QApplication.keyboardModifiers()
+
+                        if modifiers == QtCore.Qt.ShiftModifier:
+                            mod_key = 'Shift'
+                        elif modifiers == QtCore.Qt.ControlModifier:
+                            mod_key = 'Control'
+                        else:
+                            mod_key = None
+
+                        if mod_key == self.app.defaults["global_mselect_key"]:
+                            self.first_click = False
+                            return
 
 
+                        self.sel_rect = cascaded_union(self.sel_rect)
                         self.paint_poly_area(obj=self.paint_obj,
                         self.paint_poly_area(obj=self.paint_obj,
-                                             sel_obj= sel_rect,
+                                             sel_obj= self.sel_rect,
                                              outname=o_name,
                                              outname=o_name,
                                              overlap=overlap,
                                              overlap=overlap,
                                              connect=connect,
                                              connect=connect,
                                              contour=contour)
                                              contour=contour)
 
 
-                        self.app.plotcanvas.vis_disconnect('mouse_press', on_mouse_press)
+                        self.app.plotcanvas.vis_disconnect('mouse_release', on_mouse_release)
                         self.app.plotcanvas.vis_disconnect('mouse_move', on_mouse_move)
                         self.app.plotcanvas.vis_disconnect('mouse_move', on_mouse_move)
 
 
                         self.app.plotcanvas.vis_connect('mouse_press', self.app.on_mouse_click_over_plot)
                         self.app.plotcanvas.vis_connect('mouse_press', self.app.on_mouse_click_over_plot)
                         self.app.plotcanvas.vis_connect('mouse_move', self.app.on_mouse_move_over_plot)
                         self.app.plotcanvas.vis_connect('mouse_move', self.app.on_mouse_move_over_plot)
                         self.app.plotcanvas.vis_connect('mouse_release', self.app.on_mouse_click_release_over_plot)
                         self.app.plotcanvas.vis_connect('mouse_release', self.app.on_mouse_click_release_over_plot)
+                elif event.button == 2 and self.first_click is False and self.mouse_is_dragging is False:
+                    self.first_click = False
+                    self.app.plotcanvas.vis_disconnect('mouse_release', on_mouse_release)
+                    self.app.plotcanvas.vis_disconnect('mouse_move', on_mouse_move)
+
+                    self.app.plotcanvas.vis_connect('mouse_press', self.app.on_mouse_click_over_plot)
+                    self.app.plotcanvas.vis_connect('mouse_move', self.app.on_mouse_move_over_plot)
+                    self.app.plotcanvas.vis_connect('mouse_release', self.app.on_mouse_click_release_over_plot)
+
+                    self.sel_rect = cascaded_union(self.sel_rect)
+                    self.paint_poly_area(obj=self.paint_obj,
+                                         sel_obj=self.sel_rect,
+                                         outname=o_name,
+                                         overlap=overlap,
+                                         connect=connect,
+                                         contour=contour)
 
 
             # called on mouse move
             # called on mouse move
             def on_mouse_move(event):
             def on_mouse_move(event):
                 curr_pos = self.app.plotcanvas.vispy_canvas.translate_coords(event.pos)
                 curr_pos = self.app.plotcanvas.vispy_canvas.translate_coords(event.pos)
                 self.app.app_cursor.enabled = False
                 self.app.app_cursor.enabled = False
 
 
+                if event.button == 2:
+                    if event.is_dragging is True:
+                        self.mouse_is_dragging = True
+                    else:
+                        self.mouse_is_dragging = False
+
                 if self.app.grid_status() == True:
                 if self.app.grid_status() == True:
                     self.app.app_cursor.enabled = True
                     self.app.app_cursor.enabled = True
                     # Update cursor
                     # Update cursor
@@ -1027,7 +1065,7 @@ class ToolPaint(FlatCAMTool, Gerber):
             self.app.plotcanvas.vis_disconnect('mouse_move', self.app.on_mouse_move_over_plot)
             self.app.plotcanvas.vis_disconnect('mouse_move', self.app.on_mouse_move_over_plot)
             self.app.plotcanvas.vis_disconnect('mouse_release', self.app.on_mouse_click_release_over_plot)
             self.app.plotcanvas.vis_disconnect('mouse_release', self.app.on_mouse_click_release_over_plot)
 
 
-            self.app.plotcanvas.vis_connect('mouse_press', on_mouse_press)
+            self.app.plotcanvas.vis_connect('mouse_release', on_mouse_release)
             self.app.plotcanvas.vis_connect('mouse_move', on_mouse_move)
             self.app.plotcanvas.vis_connect('mouse_move', on_mouse_move)
 
 
         elif select_method == 'ref':
         elif select_method == 'ref':
@@ -1611,7 +1649,13 @@ class ToolPaint(FlatCAMTool, Gerber):
                 pass
                 pass
 
 
             geo_to_paint = []
             geo_to_paint = []
-            for poly in obj.solid_geometry:
+            if not isinstance(obj.solid_geometry, list):
+                target_geo = [obj.solid_geometry]
+            else:
+                target_geo = obj.solid_geometry
+            print(target_geo)
+            print(sel_obj)
+            for poly in target_geo:
                 new_pol = poly.intersection(sel_obj)
                 new_pol = poly.intersection(sel_obj)
                 geo_to_paint.append(new_pol)
                 geo_to_paint.append(new_pol)