- 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()")
|
||||
|
||||
if self.is_legacy is True:
|
||||
self.inform.emit(_("Not available with the current Graphic Engine Legacy(2D)."))
|
||||
return
|
||||
# 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 = Dialog_box(title=_("Jump to ..."),
|
||||
@ -6919,11 +6919,7 @@ class App(QtCore.QObject):
|
||||
location = custom_location
|
||||
|
||||
if fit_center:
|
||||
if self.is_legacy is False:
|
||||
self.plotcanvas.fit_center(loc=location)
|
||||
else:
|
||||
pass
|
||||
# self.plotcanvas.fit_view()
|
||||
self.plotcanvas.fit_center(loc=location)
|
||||
|
||||
cursor = QtGui.QCursor()
|
||||
|
||||
@ -6932,13 +6928,17 @@ class App(QtCore.QObject):
|
||||
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]))
|
||||
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))
|
||||
# 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 = x0 + self.plotcanvas.axes.transData.transform((0, 0))[0], y0 - \
|
||||
self.plotcanvas.axes.transData.transform((0, 0))[1]
|
||||
loc = self.plotcanvas.axes.transData.transform(location)
|
||||
cursor.setPos(x0 + loc[0]/50, y0 - loc[1]/50)
|
||||
|
||||
# transform the given location from data coordinates to display coordinates. THe display coordinates are
|
||||
# in pixels where the origin 0,0 is in the lowest left point of the display window (in our case is the
|
||||
# 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' %
|
||||
_("Done."))
|
||||
|
@ -12,6 +12,8 @@ CAD program, and create G-Code for Isolation routing.
|
||||
25.09.2019
|
||||
|
||||
- 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
|
||||
|
||||
|
@ -281,7 +281,7 @@ class PlotCanvasLegacy(QtCore.QObject):
|
||||
x, y = self.app.geo_editor.snap(x_pos, y_pos)
|
||||
|
||||
# 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:
|
||||
self.axes.draw_artist(el)
|
||||
except Exception as e:
|
||||
@ -443,6 +443,26 @@ class PlotCanvasLegacy(QtCore.QObject):
|
||||
def fit_view(self):
|
||||
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):
|
||||
"""
|
||||
Zooms the plot by factor around a given
|
||||
@ -482,14 +502,13 @@ class PlotCanvasLegacy(QtCore.QObject):
|
||||
for ax in self.figure.get_axes():
|
||||
ax.set_xlim((xmin, xmax))
|
||||
ax.set_ylim((ymin, ymax))
|
||||
|
||||
# Async re-draw
|
||||
self.canvas.draw_idle()
|
||||
|
||||
# #### Temporary place-holder for cached update #####
|
||||
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()
|
||||
ymin, ymax = self.axes.get_ylim()
|
||||
width = xmax - xmin
|
||||
@ -501,7 +520,10 @@ class PlotCanvasLegacy(QtCore.QObject):
|
||||
ax.set_ylim((ymin + y * height, ymax + y * height))
|
||||
|
||||
# Re-draw
|
||||
self.canvas.draw_idle()
|
||||
if idle:
|
||||
self.canvas.draw_idle()
|
||||
else:
|
||||
self.canvas.draw()
|
||||
|
||||
# #### Temporary place-holder for cached update #####
|
||||
self.update_screen_request.emit([0, 0, 0, 0, 0])
|
||||
@ -514,8 +536,8 @@ class PlotCanvasLegacy(QtCore.QObject):
|
||||
:return: Axes attached to the figure.
|
||||
:rtype: Axes
|
||||
"""
|
||||
|
||||
return self.figure.add_axes([0.05, 0.05, 0.9, 0.9], label=name)
|
||||
new_ax = self.figure.add_axes([0.05, 0.05, 0.9, 0.9], label=name)
|
||||
return new_ax
|
||||
|
||||
def remove_current_axes(self):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user