diff --git a/piker/ui/_exec.py b/piker/ui/_exec.py index 9fbb3988..eb0d662c 100644 --- a/piker/ui/_exec.py +++ b/piker/ui/_exec.py @@ -42,6 +42,7 @@ import tractor from outcome import Error from ..log import get_logger +from ._pg_overrides import _do_overrides log = get_logger(__name__) @@ -50,6 +51,10 @@ log = get_logger(__name__) pg.useOpenGL = True pg.enableExperimental = True +# engage core tweaks that give us better response +# latency then the average pg user +_do_overrides() + # singleton app per actor _qt_app: QtGui.QApplication = None diff --git a/piker/ui/_pg_overrides.py b/piker/ui/_pg_overrides.py new file mode 100644 index 00000000..71e5f40a --- /dev/null +++ b/piker/ui/_pg_overrides.py @@ -0,0 +1,48 @@ +# piker: trading gear for hackers +# Copyright (C) Tyler Goodlet (in stewardship for piker0) + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. + +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . + +""" +Customization of ``pyqtgraph`` core routines to speed up our use mostly +based on not requiring "scentific precision" for pixel perfect view +transforms. + +""" +import pyqtgraph as pg + + +def invertQTransform(tr): + """Return a QTransform that is the inverse of *tr*. + Raises an exception if tr is not invertible. + + Note that this function is preferred over QTransform.inverted() due to + bugs in that method. (specifically, Qt has floating-point precision issues + when determining whether a matrix is invertible) + + """ + # see https://doc.qt.io/qt-5/qtransform.html#inverted + + # NOTE: if ``invertable == False``, ``qt_t`` is an identity + qt_t, invertable = tr.inverted() + + return qt_t + + +def _do_overrides() -> None: + """Dooo eeet. + + """ + # we don't care about potential fp issues inside Qt + pg.functions.invertQTransform = invertQTransform