Giter Site home page Giter Site logo

Comments (16)

larsoner avatar larsoner commented on May 25, 2024 2

Just a cross-ref here that we should check if having our own RWI in #149 or moving to PySide6 (or PyQt6 eventually?) magically takes care of this issue.

from pyvistaqt.

larsoner avatar larsoner commented on May 25, 2024 1

I get the same thing on PyQt5 5.12:

Screen Shot 2022-03-10 at 8 19 55 AM

And PyQt6:

Screen Shot 2022-03-10 at 8 31 35 AM

This suggests that the rendering is still not HiDPI (it should be half the size, or the same size but 2x the resolution) :(

I also get this on mouseover:

>>> Traceback (most recent call last):
  File "/Users/larsoner/python/pyvistaqt/pyvistaqt/rwi.py", line 571, in mouseMoveEvent
    self.__saveX = ev.x()
AttributeError: 'QMouseEvent' object has no attribute 'x'
Abort trap: 6

... so I guess we have more work to do after #149 :)

from pyvistaqt.

larsoner avatar larsoner commented on May 25, 2024 1

... and FYI the upstream issue is https://gitlab.kitware.com/vtk/vtk/-/issues/17953. If we do manage to fix this by messing with rwi.py, we should port the changes upstream to Kitware.

from pyvistaqt.

larsoner avatar larsoner commented on May 25, 2024 1

... since it works on Qt6, I'll close this as wontfix, same as in the upstream https://gitlab.kitware.com/vtk/vtk/-/issues/17953

from pyvistaqt.

larsoner avatar larsoner commented on May 25, 2024

Actually it looks like a lot of this should be handled by VTK already:

https://gitlab.kitware.com/vtk/vtk/-/merge_requests/4201/diffs

So I'm confused why it's not for BackgroundPlotter, but is for Plotter. Maybe we need to see if #25 helps by being explicit about parenting or something

from pyvistaqt.

larsoner avatar larsoner commented on May 25, 2024

... #25 does not help, but I still think it's useful for cleaning up inheritance

from pyvistaqt.

larsoner avatar larsoner commented on May 25, 2024

Actually I suspect the problem might be that BasePlotter and vtkRenderWindowInteractor will both create a RenderWindow (!). I think the solution might be to init BasePlotter first, then pass the self.ren_win it creates to vtkRenderWindowInteractor...

from pyvistaqt.

larsoner avatar larsoner commented on May 25, 2024

Okay that's not the problem :(

from pyvistaqt.

larsoner avatar larsoner commented on May 25, 2024

Okay I think this might actually be a VTK problem, since the EmbedPyQt example also has this problem:


import sys
import vtk
from PyQt5.QtWidgets import QApplication
from PyQt5.QtWidgets import QMainWindow, QFrame, QVBoxLayout
from vtk.qt.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor

class MainWindow(QMainWindow):

    def __init__(self, parent=None):
        super().__init__(parent)

        self.frame = QFrame(self)
        self.vl = QVBoxLayout()
        self.frame.setLayout(self.vl)
        self.vtkWidget = QVTKRenderWindowInteractor(self.frame)
        self.vl.addWidget(self.vtkWidget)

        self.ren = vtk.vtkRenderer()
        self.vtkWidget.GetRenderWindow().AddRenderer(self.ren)
        self.iren = self.vtkWidget.GetRenderWindow().GetInteractor()

        # Create source
        source = vtk.vtkSphereSource()
        source.SetCenter(0, 0, 0)
        source.SetRadius(5.0)

        # Create a mapper
        mapper = vtk.vtkPolyDataMapper()
        mapper.SetInputConnection(source.GetOutputPort())

        # Create an actor
        actor = vtk.vtkActor()
        actor.SetMapper(mapper)

        self.ren.AddActor(actor)

        self.ren.ResetCamera()

        self.frame.setLayout(self.vl)
        self.setCentralWidget(self.frame)

        self.show()
        self.iren.Initialize()

    def resizeEvent(self, event):
        super().resizeEvent(event)
        print(event.size().width(), event.size().height())
        ren_win = self.vtkWidget.GetRenderWindow()
        print(ren_win.GetSize())
        print(self.ren.GetSize())


if __name__ == "__main__":
    app = QApplication(sys.argv)
    window = MainWindow()
    sys.exit(app.exec_())

The interaction coordinates are wrong, and the rendering is not full-res. I wonder if we should make our own interactor class like Mayavi does...?

Also maybe I should check that embedding a Mayavi scene also works.

from pyvistaqt.

larsoner avatar larsoner commented on May 25, 2024

Okay filed an upstream bug:

https://gitlab.kitware.com/vtk/vtk/-/issues/17953

@banesullivan if you can try the two code snippets there on a HiDPI machine and comment over there that it's also a problem for you it might help.

from pyvistaqt.

larsoner avatar larsoner commented on May 25, 2024

(mayavi has the same problem, hence why I think it's essentially VTK's problem...)

from pyvistaqt.

larsoner avatar larsoner commented on May 25, 2024

Indeed it appears to be a VTK adapter problem, the workaround for now at my end is to use PyQt5 < 5.14

from pyvistaqt.

banesullivan avatar banesullivan commented on May 25, 2024

Just now looking at this. I can at least reproduce the issue on my laptop

from pyvistaqt.

GuillaumeFavelier avatar GuillaumeFavelier commented on May 25, 2024

Well this is encouraging:

Qt 6 supports high-DPI displays on all platforms, and will automatically account for the display resolution when using higher level APIs such as Qt Widgets or Qt Quick. Applications only need to provide high-resolution assets, such as images and icons. The feature is always enabled.

https://doc.qt.io/qt-6/portingguide.html#high-dpi

from pyvistaqt.

larsoner avatar larsoner commented on May 25, 2024

FYI @GuillaumeFavelier now that we roll our own QVTKRenderWindowInteractor, we can probably use EDIT: some ideas from #21 to try to fix this. I might take a look today to see if I can get anything sensible working

from pyvistaqt.

larsoner avatar larsoner commented on May 25, 2024

This seems to work fine on PySide6 at least, but still not PyQt5. Maybe we can just hope to move to full support for PySide6 (and PyQt6) and just not worry about this at some point...

from pyvistaqt.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.