the scaling issue is from VisPy, removing the previous changes on this subject and adding a patch until the new release of VisPy
This commit is contained in:
@@ -49,7 +49,7 @@ class MainGUI(QtWidgets.QMainWindow):
|
||||
# Emitted when persistent window geometry needs to be retained
|
||||
geom_update = QtCore.pyqtSignal(int, int, int, int, int, name='geomUpdate')
|
||||
final_save = QtCore.pyqtSignal(name='saveBeforeExit')
|
||||
screenChanged = QtCore.pyqtSignal(QtGui.QScreen, QtGui.QScreen)
|
||||
# screenChanged = QtCore.pyqtSignal(QtGui.QScreen, QtGui.QScreen)
|
||||
|
||||
# https://www.w3.org/TR/SVG11/types.html#ColorKeywords
|
||||
def __init__(self, app):
|
||||
@@ -1988,23 +1988,23 @@ class MainGUI(QtWidgets.QMainWindow):
|
||||
self.infobar.setContextMenuPolicy(QtCore.Qt.ContextMenuPolicy.ActionsContextMenu)
|
||||
self.build_infobar_context_menu()
|
||||
|
||||
self.screenChanged.connect(self.on_screen_change)
|
||||
# self.screenChanged.connect(self.on_screen_change)
|
||||
|
||||
def on_screen_change(self, old_screen, new_screen):
|
||||
"""
|
||||
Handler of a signal that emits when screens are changed in a multi-monitor setup
|
||||
|
||||
:param old_screen: QtGui.QScreen where the app windows was located before move
|
||||
:param new_screen: QtGui.QScreen where the app windows is located after move
|
||||
:return:
|
||||
"""
|
||||
old_pixel_ratio = old_screen.devicePixelRatio()
|
||||
new_pixel_ratio = new_screen.devicePixelRatio()
|
||||
|
||||
if old_pixel_ratio != 1.0 or new_pixel_ratio != 1.0:
|
||||
# update canvas dpi
|
||||
ratio = new_pixel_ratio / old_pixel_ratio
|
||||
self.app.plotcanvas.dpi = self.app.plotcanvas.dpi * ratio
|
||||
# def on_screen_change(self, old_screen, new_screen):
|
||||
# """
|
||||
# Handler of a signal that emits when screens are changed in a multi-monitor setup
|
||||
#
|
||||
# :param old_screen: QtGui.QScreen where the app windows was located before move
|
||||
# :param new_screen: QtGui.QScreen where the app windows is located after move
|
||||
# :return:
|
||||
# """
|
||||
# old_pixel_ratio = old_screen.devicePixelRatio()
|
||||
# new_pixel_ratio = new_screen.devicePixelRatio()
|
||||
#
|
||||
# if old_pixel_ratio != 1.0 or new_pixel_ratio != 1.0:
|
||||
# # update canvas dpi
|
||||
# ratio = new_pixel_ratio / old_pixel_ratio
|
||||
# self.app.plotcanvas.dpi = self.app.plotcanvas.dpi * ratio
|
||||
|
||||
def set_ui_title(self, name):
|
||||
"""
|
||||
@@ -4237,14 +4237,14 @@ class MainGUI(QtWidgets.QMainWindow):
|
||||
# sys.exit(0)
|
||||
event.ignore()
|
||||
|
||||
def moveEvent(self, event):
|
||||
oldScreen = QtWidgets.QApplication.screenAt(event.oldPos())
|
||||
newScreen = QtWidgets.QApplication.screenAt(event.pos())
|
||||
|
||||
if not oldScreen == newScreen:
|
||||
self.screenChanged.emit(oldScreen, newScreen)
|
||||
|
||||
return super().moveEvent(event)
|
||||
# def moveEvent(self, event):
|
||||
# oldScreen = QtWidgets.QApplication.screenAt(event.oldPos())
|
||||
# newScreen = QtWidgets.QApplication.screenAt(event.pos())
|
||||
#
|
||||
# if not oldScreen == newScreen:
|
||||
# self.screenChanged.emit(oldScreen, newScreen)
|
||||
#
|
||||
# return super().moveEvent(event)
|
||||
|
||||
|
||||
class ShortcutsTab(QtWidgets.QWidget):
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
# ##########################################################
|
||||
|
||||
from vispy.visuals import markers, InfiniteLineVisual
|
||||
from vispy.app.backends._pyqt6 import CanvasBackendDesktop
|
||||
from vispy.visuals.axis import Ticker, _get_ticks_talbot
|
||||
from vispy.scene.widgets import Grid
|
||||
import numpy as np
|
||||
@@ -55,7 +56,7 @@ def apply_patches():
|
||||
Grid._prepare_draw = _prepare_draw
|
||||
Grid._update_clipper = _update_clipper
|
||||
|
||||
# Patch InfiniteLine visual to 1px width
|
||||
# Patch InfiniteLine visual to 1.5px width
|
||||
def _prepare_draw(self, view=None):
|
||||
"""This method is called immediately before each draw.
|
||||
The *view* argument indicates which view is about to be drawn.
|
||||
@@ -72,7 +73,7 @@ def apply_patches():
|
||||
|
||||
if GL:
|
||||
GL.glDisable(GL.GL_LINE_SMOOTH)
|
||||
GL.glLineWidth(2.0)
|
||||
GL.glLineWidth(1.5)
|
||||
|
||||
if self._changed['pos']:
|
||||
self.pos_buf.set_data(self._pos)
|
||||
@@ -139,3 +140,19 @@ def apply_patches():
|
||||
return NotImplementedError
|
||||
|
||||
Ticker._get_tick_frac_labels = _get_tick_frac_labels
|
||||
|
||||
def _resizeGL(self, w, h):
|
||||
if self._vispy_canvas is None:
|
||||
return
|
||||
if hasattr(self, 'devicePixelRatio'):
|
||||
# We take into account devicePixelRatio, which is non-unity on
|
||||
# e.g HiDPI displays.
|
||||
# self.devicePixelRatio() is a float and should have been in Qt5 according to the documentation
|
||||
ratio = self.devicePixelRatio()
|
||||
w = int(w * ratio)
|
||||
h = int(h * ratio)
|
||||
self._vispy_set_physical_size(w, h)
|
||||
self._vispy_canvas.events.resize(size=(self.width(), self.height()),
|
||||
physical_size=(w, h))
|
||||
|
||||
CanvasBackendDesktop.resizeGL = _resizeGL
|
||||
|
||||
Reference in New Issue
Block a user