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

- the Jump To function reference is now saving it's last used value
- added the ability to use the Jump To method in the Gerber Editor

Marius Stanciu 6 лет назад
Родитель
Сommit
1f33220bab
5 измененных файлов с 60 добавлено и 22 удалено
  1. 7 2
      FlatCAMApp.py
  2. 2 0
      README.md
  3. 0 1
      flatcamEditors/FlatCAMGeoEditor.py
  4. 43 11
      flatcamEditors/FlatCAMGrbEditor.py
  5. 8 8
      flatcamGUI/GUIElements.py

+ 7 - 2
FlatCAMApp.py

@@ -415,6 +415,9 @@ class App(QtCore.QObject):
             "global_serial": 0,
             "global_stats": dict(),
             "global_tabs_detachable": True,
+            "global_jump_ref": 'abs',
+
+            # General
             "global_graphic_engine": '3D',
             "global_app_level": 'b',
             "global_portable": False,
@@ -1678,6 +1681,7 @@ class App(QtCore.QObject):
         self.mr = None
         self.mdc = None
         self.mp_zc = None
+        self.kp = None
 
         # Matplotlib axis
         self.axes = None
@@ -7384,7 +7388,8 @@ class App(QtCore.QObject):
             dia_box = DialogBoxRadio(title=_("Jump to ..."),
                                      label=_("Enter the coordinates in format X,Y:"),
                                      icon=QtGui.QIcon(self.resource_location + '/jump_to16.png'),
-                                     initial_text=dia_box_location)
+                                     initial_text=dia_box_location,
+                                     reference=self.defaults['global_jump_ref'])
 
             if dia_box.ok is True:
                 try:
@@ -7398,7 +7403,7 @@ class App(QtCore.QObject):
                         rel_x = self.mouse[0] + location[0]
                         rel_y = self.mouse[1] + location[1]
                         location = (rel_x, rel_y)
-
+                    self.defaults['global_jump_ref'] = dia_box.reference
                 except Exception:
                     return
             else:

+ 2 - 0
README.md

@@ -13,6 +13,8 @@ CAD program, and create G-Code for Isolation routing.
 
 - added new parameters to improve Gerber parsing
 - small optimizations in the Preferences UI
+- the Jump To function reference is now saving it's last used value
+- added the ability to use the Jump To method in the Gerber Editor
 
 17.12.2019
 

+ 0 - 1
flatcamEditors/FlatCAMGeoEditor.py

@@ -1880,7 +1880,6 @@ class DrawTool(object):
         return ""
 
     def on_key(self, key):
-
         # Jump to coords
         if key == QtCore.Qt.Key_J or key == 'J':
             self.draw_app.app.on_jump_to()

+ 43 - 11
flatcamEditors/FlatCAMGrbEditor.py

@@ -139,7 +139,9 @@ class DrawTool(object):
         return ""
 
     def on_key(self, key):
-        return None
+        # Jump to coords
+        if key == QtCore.Qt.Key_J or key == 'J':
+            self.draw_app.app.on_jump_to()
 
     def utility_geometry(self, data=None):
         return None
@@ -874,9 +876,11 @@ class FCRegion(FCShapeTool):
         except Exception as e:
             log.debug("FlatCAMGrbEditor.FCRegion --> %s" % str(e))
 
-        self.cursor = QtGui.QCursor(QtGui.QPixmap(self.app.resource_location + '/aero.png'))
+        self.cursor = QtGui.QCursor(QtGui.QPixmap(self.draw_app.app.resource_location + '/aero.png'))
         QtGui.QGuiApplication.setOverrideCursor(self.cursor)
 
+        self.draw_app.app.jump_signal.connect(lambda x: self.draw_app.update_utility_geometry(data=x))
+
         self.draw_app.app.inform.emit(_('Corner Mode 1: 45 degrees ...'))
 
         self.start_msg = _("Click on 1st point ...")
@@ -1064,8 +1068,10 @@ class FCRegion(FCShapeTool):
             self.geometry = DrawToolShape(new_geo_el)
         self.draw_app.in_action = False
         self.complete = True
-        self.draw_app.app.inform.emit('[success] %s' %
-                                      _("Done."))
+
+        self.draw_app.app.jump_signal.disconnect()
+
+        self.draw_app.app.inform.emit('[success] %s' % _("Done."))
 
     def clean_up(self):
         self.draw_app.selected = []
@@ -1073,6 +1079,10 @@ class FCRegion(FCShapeTool):
         self.draw_app.plot_all()
 
     def on_key(self, key):
+        # Jump to coords
+        if key == QtCore.Qt.Key_J or key == 'J':
+            self.draw_app.app.on_jump_to()
+
         if key == 'Backspace' or key == QtCore.Qt.Key_Backspace:
             if len(self.points) > 0:
                 if self.draw_app.bend_mode == 5:
@@ -1148,9 +1158,12 @@ class FCTrack(FCRegion):
         except Exception as e:
             log.debug("FlatCAMGrbEditor.FCTrack.__init__() --> %s" % str(e))
 
-        self.cursor = QtGui.QCursor(QtGui.QPixmap(self.app.resource_location + '/aero_path%s.png' % self.draw_app.bend_mode))
+        self.cursor = QtGui.QCursor(QtGui.QPixmap(self.draw_app.app.resource_location +
+                                                  '/aero_path%s.png' % self.draw_app.bend_mode))
         QtGui.QGuiApplication.setOverrideCursor(self.cursor)
 
+        self.draw_app.app.jump_signal.connect(lambda x: self.draw_app.update_utility_geometry(data=x))
+
         self.draw_app.app.inform.emit(_('Track Mode 1: 45 degrees ...'))
 
     def make(self):
@@ -1168,8 +1181,10 @@ class FCTrack(FCRegion):
 
         self.draw_app.in_action = False
         self.complete = True
-        self.draw_app.app.inform.emit('[success] %s' %
-                                      _("Done."))
+
+        self.draw_app.app.jump_signal.disconnect()
+
+        self.draw_app.app.inform.emit('[success] %s' % _("Done."))
 
     def clean_up(self):
         self.draw_app.selected = []
@@ -1287,6 +1302,10 @@ class FCTrack(FCRegion):
                 self.draw_app.draw_utility_geometry(geo=geo)
                 return _("Backtracked one point ...")
 
+        # Jump to coords
+        if key == QtCore.Qt.Key_J or key == 'J':
+            self.draw_app.app.on_jump_to()
+
         if key == 'T' or key == QtCore.Qt.Key_T:
             try:
                 QtGui.QGuiApplication.restoreOverrideCursor()
@@ -1396,6 +1415,8 @@ class FCDisc(FCShapeTool):
 
         self.draw_app.app.inform.emit(_("Click on Center point ..."))
 
+        self.draw_app.app.jump_signal.connect(lambda x: self.draw_app.update_utility_geometry(data=x))
+
         self.steps_per_circ = self.draw_app.app.defaults["gerber_circle_steps"]
 
     def click(self, point):
@@ -1442,8 +1463,10 @@ class FCDisc(FCShapeTool):
 
         self.draw_app.in_action = False
         self.complete = True
-        self.draw_app.app.inform.emit('[success] %s' %
-                                      _("Done."))
+
+        self.draw_app.app.jump_signal.disconnect()
+
+        self.draw_app.app.inform.emit('[success] %s' % _("Done."))
 
     def clean_up(self):
         self.draw_app.selected = []
@@ -1490,6 +1513,7 @@ class FCSemiDisc(FCShapeTool):
             self.storage_obj = self.draw_app.storage_dict['0']['geometry']
 
         self.steps_per_circ = self.draw_app.app.defaults["gerber_circle_steps"]
+        self.draw_app.app.jump_signal.connect(lambda x: self.draw_app.update_utility_geometry(data=x))
 
     def click(self, point):
         self.points.append(point)
@@ -1523,6 +1547,10 @@ class FCSemiDisc(FCShapeTool):
             self.direction = 'cw' if self.direction == 'ccw' else 'ccw'
             return '%s: %s' % (_('Direction'), self.direction.upper())
 
+        # Jump to coords
+        if key == QtCore.Qt.Key_J or key == 'J':
+            self.draw_app.app.on_jump_to()
+
         if key == 'M' or key == QtCore.Qt.Key_M:
             # delete the possible points made before this action; we want to start anew
             self.points = []
@@ -1700,8 +1728,10 @@ class FCSemiDisc(FCShapeTool):
 
         self.draw_app.in_action = False
         self.complete = True
-        self.draw_app.app.inform.emit('[success] %s' %
-                                      _("Done."))
+
+        self.draw_app.app.jump_signal.disconnect()
+
+        self.draw_app.app.inform.emit('[success] %s' % _("Done."))
 
     def clean_up(self):
         self.draw_app.selected = []
@@ -4517,6 +4547,8 @@ class FlatCAMGrbEditor(QtCore.QObject):
         self.snap_x = x
         self.snap_y = y
 
+        self.app.mouse = [x, y]
+
         # update the position label in the infobar since the APP mouse event handlers are disconnected
         self.app.ui.position_label.setText("&nbsp;&nbsp;&nbsp;&nbsp;<b>X</b>: %.4f&nbsp;&nbsp;   " 
                                            "<b>Y</b>: %.4f" % (x, y))

+ 8 - 8
flatcamGUI/GUIElements.py

@@ -2239,7 +2239,7 @@ class Dialog_box(QtWidgets.QWidget):
 
 
 class DialogBoxRadio(QtWidgets.QDialog):
-    def __init__(self, title=None, label=None, icon=None, initial_text=None):
+    def __init__(self, title=None, label=None, icon=None, initial_text=None, reference='abs'):
         """
 
         :param title: string with the window title
@@ -2258,11 +2258,6 @@ class DialogBoxRadio(QtWidgets.QDialog):
 
         self.form = QtWidgets.QFormLayout(self)
 
-        self.form.addRow(QtWidgets.QLabel(''))
-
-        self.wdg_label = QtWidgets.QLabel('<b>%s</b>' % str(label))
-        self.form.addRow(self.wdg_label)
-
         self.ref_label = QtWidgets.QLabel('%s:' % _("Reference"))
         self.ref_label.setToolTip(
             _("The reference can be:\n"
@@ -2273,10 +2268,15 @@ class DialogBoxRadio(QtWidgets.QDialog):
             {"label": _("Abs"), "value": "abs"},
             {"label": _("Relative"), "value": "rel"}
         ], orientation='horizontal', stretch=False)
-        self.ref_radio.set_value('abs')
+        self.ref_radio.set_value(reference)
         self.form.addRow(self.ref_label, self.ref_radio)
 
-        self.loc_label = QtWidgets.QLabel('<b>%s:</b>' % _("Location"))
+        self.form.addRow(QtWidgets.QLabel(''))
+
+        self.wdg_label = QtWidgets.QLabel('<b>%s</b>' % str(label))
+        self.form.addRow(self.wdg_label)
+
+        self.loc_label = QtWidgets.QLabel('%s:' % _("Location"))
         self.loc_label.setToolTip(
             _("The Location value is a tuple (x,y).\n"
               "If the reference is Absolute then the Jump will be at the position (x,y).\n"