فهرست منبع

- modified CutOut Tool so now the manual gaps adding will continue until the user is clicking the RMB
- added ability to turn on/of the grid snapping and to jump to a location while in CutOut Tool manual gap adding action

Marius Stanciu 6 سال پیش
والد
کامیت
3fe31dec59
3فایلهای تغییر یافته به همراه74 افزوده شده و 47 حذف شده
  1. 3 2
      FlatCAMApp.py
  2. 5 0
      README.md
  3. 66 45
      flatcamTools/ToolCutOut.py

+ 3 - 2
FlatCAMApp.py

@@ -98,8 +98,8 @@ class App(QtCore.QObject):
     # ####################################
     # ####################################
     # Version and VERSION DATE ###########
     # Version and VERSION DATE ###########
     # ####################################
     # ####################################
-    version = 8.96
-    version_date = "2019/08/23"
+    version = 8.97
+    version_date = "2019/08/31"
     beta = True
     beta = True
 
 
     # current date now
     # current date now
@@ -5261,6 +5261,7 @@ class App(QtCore.QObject):
 
 
         cursor.setPos(canvas_origin.x() + jump_loc[0], (canvas_origin.y() + jump_loc[1]))
         cursor.setPos(canvas_origin.x() + jump_loc[0], (canvas_origin.y() + jump_loc[1]))
         self.inform.emit(_("[success] Done."))
         self.inform.emit(_("[success] Done."))
+        return location
 
 
     def on_copy_object(self):
     def on_copy_object(self):
         self.report_usage("on_copy_object()")
         self.report_usage("on_copy_object()")

+ 5 - 0
README.md

@@ -9,6 +9,11 @@ CAD program, and create G-Code for Isolation routing.
 
 
 =================================================
 =================================================
 
 
+24.08.2019
+
+- modified CutOut Tool so now the manual gaps adding will continue until the user is clicking the RMB
+- added ability to turn on/of the grid snapping and to jump to a location while in CutOut Tool manual gap adding action
+
 23.08.2019
 23.08.2019
 
 
 - in Tool Cutout for the manual gaps, right mouse button click will exit from the action of adding gaps
 - in Tool Cutout for the manual gaps, right mouse button click will exit from the action of adding gaps

+ 66 - 45
flatcamTools/ToolCutOut.py

@@ -16,7 +16,6 @@ if '_' not in builtins.__dict__:
 class CutOut(FlatCAMTool):
 class CutOut(FlatCAMTool):
 
 
     toolName = _("Cutout PCB")
     toolName = _("Cutout PCB")
-    gapFinished = pyqtSignal()
 
 
     def __init__(self, app):
     def __init__(self, app):
         FlatCAMTool.__init__(self, app)
         FlatCAMTool.__init__(self, app)
@@ -296,6 +295,13 @@ class CutOut(FlatCAMTool):
         # this is the Geometry object generated in this class to be used for adding manual gaps
         # this is the Geometry object generated in this class to be used for adding manual gaps
         self.man_cutout_obj = None
         self.man_cutout_obj = None
 
 
+        # if mouse is dragging set the object True
+        self.mouse_is_dragging = False
+
+        # hold the mouse position here
+        self.x_pos = None
+        self.y_pos = None
+
         # Signals
         # Signals
         self.ff_cutout_object_btn.clicked.connect(self.on_freeform_cutout)
         self.ff_cutout_object_btn.clicked.connect(self.on_freeform_cutout)
         self.rect_cutout_object_btn.clicked.connect(self.on_rectangular_cutout)
         self.rect_cutout_object_btn.clicked.connect(self.on_rectangular_cutout)
@@ -349,8 +355,6 @@ class CutOut(FlatCAMTool):
         self.gaps.set_value(self.app.defaults["tools_gaps_ff"])
         self.gaps.set_value(self.app.defaults["tools_gaps_ff"])
         self.convex_box.set_value(self.app.defaults['tools_cutout_convexshape'])
         self.convex_box.set_value(self.app.defaults['tools_cutout_convexshape'])
 
 
-        self.gapFinished.connect(self.on_gap_finished)
-
     def on_freeform_cutout(self):
     def on_freeform_cutout(self):
 
 
         # def subtract_rectangle(obj_, x0, y0, x1, y1):
         # def subtract_rectangle(obj_, x0, y0, x1, y1):
@@ -774,40 +778,7 @@ class CutOut(FlatCAMTool):
         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_connect('key_press', self.on_key_press)
         self.app.plotcanvas.vis_connect('key_press', self.on_key_press)
         self.app.plotcanvas.vis_connect('mouse_move', self.on_mouse_move)
         self.app.plotcanvas.vis_connect('mouse_move', self.on_mouse_move)
-        self.app.plotcanvas.vis_connect('mouse_release', self.doit)
-
-    # To be called after clicking on the plot.
-    def doit(self, event):
-        # do paint single only for left mouse clicks
-        if event.button == 1:
-            self.app.inform.emit(_("Making manual bridge gap..."))
-            pos = self.app.plotcanvas.vispy_canvas.translate_coords(event.pos)
-            self.on_manual_cutout(click_pos=pos)
-
-            self.app.plotcanvas.vis_disconnect('key_press', self.on_key_press)
-            self.app.plotcanvas.vis_disconnect('mouse_move', self.on_mouse_move)
-            self.app.plotcanvas.vis_disconnect('mouse_release', self.doit)
-            self.app.plotcanvas.vis_connect('key_press', self.app.ui.keyPressEvent)
-            self.app.plotcanvas.vis_connect('mouse_press', self.app.on_mouse_click_over_plot)
-            self.app.plotcanvas.vis_connect('mouse_release', self.app.on_mouse_click_release_over_plot)
-            self.app.plotcanvas.vis_connect('mouse_move', self.app.on_mouse_move_over_plot)
-
-            self.app.geo_editor.tool_shape.clear(update=True)
-            self.app.geo_editor.tool_shape.enabled = False
-            self.gapFinished.emit()
-        # if RMB then we exit
-        elif event.button == 2:
-            self.app.plotcanvas.vis_disconnect('key_press', self.on_key_press)
-            self.app.plotcanvas.vis_disconnect('mouse_move', self.on_mouse_move)
-            self.app.plotcanvas.vis_disconnect('mouse_release', self.doit)
-            self.app.plotcanvas.vis_connect('key_press', self.app.ui.keyPressEvent)
-            self.app.plotcanvas.vis_connect('mouse_press', self.app.on_mouse_click_over_plot)
-            self.app.plotcanvas.vis_connect('mouse_release', self.app.on_mouse_click_release_over_plot)
-            self.app.plotcanvas.vis_connect('mouse_move', self.app.on_mouse_move_over_plot)
-
-            # Remove any previous utility shape
-            self.app.geo_editor.tool_shape.clear(update=True)
-            self.app.geo_editor.tool_shape.enabled = False
+        self.app.plotcanvas.vis_connect('mouse_release', self.on_mouse_click_release)
 
 
     def on_manual_cutout(self, click_pos):
     def on_manual_cutout(self, click_pos):
         name = self.man_object_combo.currentText()
         name = self.man_object_combo.currentText()
@@ -836,12 +807,6 @@ class CutOut(FlatCAMTool):
 
 
         self.app.should_we_save = True
         self.app.should_we_save = True
 
 
-    def on_gap_finished(self):
-        # if CTRL key modifier is pressed then repeat the bridge gap cut
-        key_modifier = QtWidgets.QApplication.keyboardModifiers()
-        if key_modifier == Qt.ControlModifier:
-            self.on_manual_gap_click()
-
     def on_manual_geo(self):
     def on_manual_geo(self):
         name = self.obj_combo.currentText()
         name = self.obj_combo.currentText()
 
 
@@ -943,6 +908,41 @@ class CutOut(FlatCAMTool):
         cut_poly = box(xmin, ymin, xmax, ymax)
         cut_poly = box(xmin, ymin, xmax, ymax)
         return cut_poly
         return cut_poly
 
 
+    # To be called after clicking on the plot.
+    def on_mouse_click_release(self, event):
+
+        # do paint single only for left mouse clicks
+        if event.button == 1:
+            self.app.inform.emit(_("Making manual bridge gap..."))
+            pos = self.app.plotcanvas.vispy_canvas.translate_coords(event.pos)
+            self.on_manual_cutout(click_pos=pos)
+
+            # self.app.plotcanvas.vis_disconnect('key_press', self.on_key_press)
+            # self.app.plotcanvas.vis_disconnect('mouse_move', self.on_mouse_move)
+            # self.app.plotcanvas.vis_disconnect('mouse_release', self.on_mouse_click_release)
+            # self.app.plotcanvas.vis_connect('key_press', self.app.ui.keyPressEvent)
+            # self.app.plotcanvas.vis_connect('mouse_press', self.app.on_mouse_click_over_plot)
+            # self.app.plotcanvas.vis_connect('mouse_release', self.app.on_mouse_click_release_over_plot)
+            # self.app.plotcanvas.vis_connect('mouse_move', self.app.on_mouse_move_over_plot)
+
+            # self.app.geo_editor.tool_shape.clear(update=True)
+            # self.app.geo_editor.tool_shape.enabled = False
+            # self.gapFinished.emit()
+
+        # if RMB then we exit
+        elif event.button == 2 and self.mouse_is_dragging is False:
+            self.app.plotcanvas.vis_disconnect('key_press', self.on_key_press)
+            self.app.plotcanvas.vis_disconnect('mouse_move', self.on_mouse_move)
+            self.app.plotcanvas.vis_disconnect('mouse_release', self.on_mouse_click_release)
+            self.app.plotcanvas.vis_connect('key_press', self.app.ui.keyPressEvent)
+            self.app.plotcanvas.vis_connect('mouse_press', self.app.on_mouse_click_over_plot)
+            self.app.plotcanvas.vis_connect('mouse_release', self.app.on_mouse_click_release_over_plot)
+            self.app.plotcanvas.vis_connect('mouse_move', self.app.on_mouse_move_over_plot)
+
+            # Remove any previous utility shape
+            self.app.geo_editor.tool_shape.clear(update=True)
+            self.app.geo_editor.tool_shape.enabled = False
+
     def on_mouse_move(self, event):
     def on_mouse_move(self, event):
 
 
         self.app.on_mouse_move_over_plot(event=event)
         self.app.on_mouse_move_over_plot(event=event)
@@ -950,13 +950,23 @@ class CutOut(FlatCAMTool):
         pos = self.canvas.vispy_canvas.translate_coords(event.pos)
         pos = self.canvas.vispy_canvas.translate_coords(event.pos)
         event.xdata, event.ydata = pos[0], pos[1]
         event.xdata, event.ydata = pos[0], pos[1]
 
 
+        if event.is_dragging is True:
+            self.mouse_is_dragging = True
+        else:
+            self.mouse_is_dragging = False
+
         try:
         try:
             x = float(event.xdata)
             x = float(event.xdata)
             y = float(event.ydata)
             y = float(event.ydata)
         except TypeError:
         except TypeError:
             return
             return
 
 
-        snap_x, snap_y = self.app.geo_editor.snap(x, y)
+        if self.app.grid_status() == True:
+            snap_x, snap_y = self.app.geo_editor.snap(x, y)
+        else:
+            snap_x, snap_y = x, y
+
+        self.x_pos, self.y_pos = snap_x, snap_y
 
 
         # #################################################
         # #################################################
         # ### This section makes the cutting geo to #######
         # ### This section makes the cutting geo to #######
@@ -1044,7 +1054,7 @@ class CutOut(FlatCAMTool):
         if key == QtCore.Qt.Key_Escape or key == 'Escape':
         if key == QtCore.Qt.Key_Escape or key == 'Escape':
             self.app.plotcanvas.vis_disconnect('key_press', self.on_key_press)
             self.app.plotcanvas.vis_disconnect('key_press', self.on_key_press)
             self.app.plotcanvas.vis_disconnect('mouse_move', self.on_mouse_move)
             self.app.plotcanvas.vis_disconnect('mouse_move', self.on_mouse_move)
-            self.app.plotcanvas.vis_disconnect('mouse_release', self.doit)
+            self.app.plotcanvas.vis_disconnect('mouse_release', self.on_mouse_click_release)
             self.app.plotcanvas.vis_connect('key_press', self.app.ui.keyPressEvent)
             self.app.plotcanvas.vis_connect('key_press', self.app.ui.keyPressEvent)
             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_release', self.app.on_mouse_click_release_over_plot)
             self.app.plotcanvas.vis_connect('mouse_release', self.app.on_mouse_click_release_over_plot)
@@ -1054,6 +1064,17 @@ class CutOut(FlatCAMTool):
             self.app.geo_editor.tool_shape.clear(update=True)
             self.app.geo_editor.tool_shape.clear(update=True)
             self.app.geo_editor.tool_shape.enabled = False
             self.app.geo_editor.tool_shape.enabled = False
 
 
+        # Grid toggle
+        if key == QtCore.Qt.Key_G or key == 'G':
+            self.app.ui.grid_snap_btn.trigger()
+
+        # Jump to coords
+        if key == QtCore.Qt.Key_J or key == 'J':
+            l_x, l_y = self.app.on_jump_to()
+            self.app.geo_editor.tool_shape.clear(update=True)
+            geo = self.cutting_geo(pos=(l_x, l_y))
+            self.draw_utility_geometry(geo=geo)
+
     def subtract_poly_from_geo(self, solid_geo, x0, y0, x1, y1):
     def subtract_poly_from_geo(self, solid_geo, x0, y0, x1, y1):
         """
         """
         Subtract polygon made from points from the given object.
         Subtract polygon made from points from the given object.