- modified the Jump To method such that now allows relative jump from the current mouse location

This commit is contained in:
Marius Stanciu 2019-12-16 04:27:32 +02:00 committed by Marius
parent 82c9377a37
commit 414b96015c
3 changed files with 83 additions and 8 deletions

View File

@ -7358,10 +7358,6 @@ class App(QtCore.QObject):
"""
self.report_usage("on_jump_to()")
# if self.is_legacy is True:
# self.inform.emit(_("Not available with the current Graphic Engine Legacy(2D)."))
# return
if not custom_location:
dia_box_location = None
@ -7375,17 +7371,29 @@ class App(QtCore.QObject):
else:
dia_box_location = None
dia_box = Dialog_box(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)
# dia_box = Dialog_box(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)
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)
if dia_box.ok is True:
try:
location = eval(dia_box.location)
if not isinstance(location, tuple):
self.inform.emit(_("Wrong coordinates. Enter coordinates in format: X,Y"))
return
if dia_box.reference == 'rel':
rel_x = self.mouse[0] + location[0]
rel_y = self.mouse[1] + location[1]
location = (rel_x, rel_y)
except Exception:
return
else:

View File

@ -12,6 +12,7 @@ CAD program, and create G-Code for Isolation routing.
16.12.2019
- in Geometry Editor added support for Jump To function such as that it works within the Editor Tools themselves. For now it works only in absolute jumps
- modified the Jump To method such that now allows relative jump from the current mouse location
15.12.2019

View File

@ -2230,6 +2230,72 @@ class Dialog_box(QtWidgets.QWidget):
self.readyToEdit = True
class DialogBoxRadio(QtWidgets.QDialog):
def __init__(self, title=None, label=None, icon=None, initial_text=None):
"""
:param title: string with the window title
:param label: string with the message inside the dialog box
"""
super(DialogBoxRadio, self).__init__()
if initial_text is None:
self.location = str((0, 0))
else:
self.location = initial_text
self.ok = False
self.setWindowIcon(icon)
self.setWindowTitle(str(title))
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"
"- Absolute -> the reference point is point (0,0)\n"
"- Relative -> the reference point is the mouse position before Jump")
)
self.ref_radio = RadioSet([
{"label": _("Abs"), "value": "abs"},
{"label": _("Relative"), "value": "rel"}
], orientation='horizontal', stretch=False)
self.ref_radio.set_value('abs')
self.form.addRow(self.ref_label, self.ref_radio)
self.loc_label = QtWidgets.QLabel('<b>%s:</b>' % _("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"
"If the reference is Relative then the Jump will be at the (x,y) distance\n"
"from the current mouse location point.")
)
self.lineEdit = EvalEntry()
self.lineEdit.setText(str(self.location).replace('(', '').replace(')', ''))
self.form.addRow(self.loc_label, self.lineEdit)
self.button_box = QtWidgets.QDialogButtonBox(QtWidgets.QDialogButtonBox.Ok | QtWidgets.QDialogButtonBox.Cancel,
Qt.Horizontal, parent=self)
self.form.addRow(self.button_box)
self.button_box.accepted.connect(self.accept)
self.button_box.rejected.connect(self.reject)
self.readyToEdit = True
if self.exec_() == QtWidgets.QDialog.Accepted:
self.ok = True
self.location = self.lineEdit.text()
self.reference = self.ref_radio.get_value()
else:
self.ok = False
class _BrowserTextEdit(QTextEdit):
def __init__(self, version):