- fixed the 'Jump To' function to work in legacy graphic engine
- in legacy graphic engine fixed the mouse cursor shape when grid snapping is ON, such that it fits with the shape from the OpenGL graphic engine
This commit is contained in:
parent
36f9b9bd7a
commit
4e8fbaf974
|
@ -6896,9 +6896,9 @@ class App(QtCore.QObject):
|
||||||
"""
|
"""
|
||||||
self.report_usage("on_jump_to()")
|
self.report_usage("on_jump_to()")
|
||||||
|
|
||||||
if self.is_legacy is True:
|
# if self.is_legacy is True:
|
||||||
self.inform.emit(_("Not available with the current Graphic Engine Legacy(2D)."))
|
# self.inform.emit(_("Not available with the current Graphic Engine Legacy(2D)."))
|
||||||
return
|
# return
|
||||||
|
|
||||||
if not custom_location:
|
if not custom_location:
|
||||||
dia_box = Dialog_box(title=_("Jump to ..."),
|
dia_box = Dialog_box(title=_("Jump to ..."),
|
||||||
|
@ -6919,11 +6919,7 @@ class App(QtCore.QObject):
|
||||||
location = custom_location
|
location = custom_location
|
||||||
|
|
||||||
if fit_center:
|
if fit_center:
|
||||||
if self.is_legacy is False:
|
self.plotcanvas.fit_center(loc=location)
|
||||||
self.plotcanvas.fit_center(loc=location)
|
|
||||||
else:
|
|
||||||
pass
|
|
||||||
# self.plotcanvas.fit_view()
|
|
||||||
|
|
||||||
cursor = QtGui.QCursor()
|
cursor = QtGui.QCursor()
|
||||||
|
|
||||||
|
@ -6932,13 +6928,17 @@ class App(QtCore.QObject):
|
||||||
jump_loc = self.plotcanvas.translate_coords_2((location[0], location[1]))
|
jump_loc = self.plotcanvas.translate_coords_2((location[0], location[1]))
|
||||||
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]))
|
||||||
else:
|
else:
|
||||||
# the origin finding works but not mapping the location to pixels
|
# find the canvas origin which is in the top left corner
|
||||||
canvas_origin = self.plotcanvas.native.mapToGlobal(QtCore.QPoint(0, 0))
|
canvas_origin = self.plotcanvas.native.mapToGlobal(QtCore.QPoint(0, 0))
|
||||||
|
# determine the coordinates for the lowest left point of the canvas
|
||||||
x0, y0 = canvas_origin.x(), canvas_origin.y() + self.ui.right_layout.geometry().height()
|
x0, y0 = canvas_origin.x(), canvas_origin.y() + self.ui.right_layout.geometry().height()
|
||||||
x0, y0 = x0 + self.plotcanvas.axes.transData.transform((0, 0))[0], y0 - \
|
|
||||||
self.plotcanvas.axes.transData.transform((0, 0))[1]
|
# transform the given location from data coordinates to display coordinates. THe display coordinates are
|
||||||
loc = self.plotcanvas.axes.transData.transform(location)
|
# in pixels where the origin 0,0 is in the lowest left point of the display window (in our case is the
|
||||||
cursor.setPos(x0 + loc[0]/50, y0 - loc[1]/50)
|
# canvas) and the point (width, height) is in the top-right location
|
||||||
|
loc = self.plotcanvas.axes.transData.transform_point(location)
|
||||||
|
|
||||||
|
cursor.setPos(x0 + loc[0], y0 - loc[1])
|
||||||
|
|
||||||
self.inform.emit('[success] %s' %
|
self.inform.emit('[success] %s' %
|
||||||
_("Done."))
|
_("Done."))
|
||||||
|
|
|
@ -12,6 +12,8 @@ CAD program, and create G-Code for Isolation routing.
|
||||||
25.09.2019
|
25.09.2019
|
||||||
|
|
||||||
- French translation at 33%
|
- French translation at 33%
|
||||||
|
- fixed the 'Jump To' function to work in legacy graphic engine
|
||||||
|
- in legacy graphic engine fixed the mouse cursor shape when grid snapping is ON, such that it fits with the shape from the OpenGL graphic engine
|
||||||
|
|
||||||
24.09.2019
|
24.09.2019
|
||||||
|
|
||||||
|
|
|
@ -281,7 +281,7 @@ class PlotCanvasLegacy(QtCore.QObject):
|
||||||
x, y = self.app.geo_editor.snap(x_pos, y_pos)
|
x, y = self.app.geo_editor.snap(x_pos, y_pos)
|
||||||
|
|
||||||
# Pointer (snapped)
|
# Pointer (snapped)
|
||||||
elements = self.axes.plot(x, y, 'k+', ms=40, mew=2, animated=True)
|
elements = self.axes.plot(x, y, 'k+', ms=33, mew=1, animated=True)
|
||||||
for el in elements:
|
for el in elements:
|
||||||
self.axes.draw_artist(el)
|
self.axes.draw_artist(el)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
@ -443,6 +443,26 @@ class PlotCanvasLegacy(QtCore.QObject):
|
||||||
def fit_view(self):
|
def fit_view(self):
|
||||||
self.auto_adjust_axes()
|
self.auto_adjust_axes()
|
||||||
|
|
||||||
|
def fit_center(self, loc, rect=None):
|
||||||
|
x = loc[0]
|
||||||
|
y = loc[1]
|
||||||
|
|
||||||
|
xmin, xmax = self.axes.get_xlim()
|
||||||
|
ymin, ymax = self.axes.get_ylim()
|
||||||
|
half_width = (xmax - xmin) / 2
|
||||||
|
half_height = (ymax - ymin) / 2
|
||||||
|
|
||||||
|
# Adjust axes
|
||||||
|
for ax in self.figure.get_axes():
|
||||||
|
ax.set_xlim((x - half_width , x + half_width))
|
||||||
|
ax.set_ylim((y - half_height, y + half_height))
|
||||||
|
|
||||||
|
# Re-draw
|
||||||
|
self.canvas.draw()
|
||||||
|
|
||||||
|
# #### Temporary place-holder for cached update #####
|
||||||
|
self.update_screen_request.emit([0, 0, 0, 0, 0])
|
||||||
|
|
||||||
def zoom(self, factor, center=None):
|
def zoom(self, factor, center=None):
|
||||||
"""
|
"""
|
||||||
Zooms the plot by factor around a given
|
Zooms the plot by factor around a given
|
||||||
|
@ -482,14 +502,13 @@ class PlotCanvasLegacy(QtCore.QObject):
|
||||||
for ax in self.figure.get_axes():
|
for ax in self.figure.get_axes():
|
||||||
ax.set_xlim((xmin, xmax))
|
ax.set_xlim((xmin, xmax))
|
||||||
ax.set_ylim((ymin, ymax))
|
ax.set_ylim((ymin, ymax))
|
||||||
|
|
||||||
# Async re-draw
|
# Async re-draw
|
||||||
self.canvas.draw_idle()
|
self.canvas.draw_idle()
|
||||||
|
|
||||||
# #### Temporary place-holder for cached update #####
|
# #### Temporary place-holder for cached update #####
|
||||||
self.update_screen_request.emit([0, 0, 0, 0, 0])
|
self.update_screen_request.emit([0, 0, 0, 0, 0])
|
||||||
|
|
||||||
def pan(self, x, y):
|
def pan(self, x, y, idle=True):
|
||||||
xmin, xmax = self.axes.get_xlim()
|
xmin, xmax = self.axes.get_xlim()
|
||||||
ymin, ymax = self.axes.get_ylim()
|
ymin, ymax = self.axes.get_ylim()
|
||||||
width = xmax - xmin
|
width = xmax - xmin
|
||||||
|
@ -501,7 +520,10 @@ class PlotCanvasLegacy(QtCore.QObject):
|
||||||
ax.set_ylim((ymin + y * height, ymax + y * height))
|
ax.set_ylim((ymin + y * height, ymax + y * height))
|
||||||
|
|
||||||
# Re-draw
|
# Re-draw
|
||||||
self.canvas.draw_idle()
|
if idle:
|
||||||
|
self.canvas.draw_idle()
|
||||||
|
else:
|
||||||
|
self.canvas.draw()
|
||||||
|
|
||||||
# #### Temporary place-holder for cached update #####
|
# #### Temporary place-holder for cached update #####
|
||||||
self.update_screen_request.emit([0, 0, 0, 0, 0])
|
self.update_screen_request.emit([0, 0, 0, 0, 0])
|
||||||
|
@ -514,8 +536,8 @@ class PlotCanvasLegacy(QtCore.QObject):
|
||||||
:return: Axes attached to the figure.
|
:return: Axes attached to the figure.
|
||||||
:rtype: Axes
|
:rtype: Axes
|
||||||
"""
|
"""
|
||||||
|
new_ax = self.figure.add_axes([0.05, 0.05, 0.9, 0.9], label=name)
|
||||||
return self.figure.add_axes([0.05, 0.05, 0.9, 0.9], label=name)
|
return new_ax
|
||||||
|
|
||||||
def remove_current_axes(self):
|
def remove_current_axes(self):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in New Issue