Giter Site home page Giter Site logo

pyvistaqt's Introduction

PyVistaQt

PyPI

conda-forge

GitHub Actions

MIT License

Codecov

isort

pylint

mypy

black

pyvistaqt is a helper module for pyvista to enable you to plot using Qt by placing a vtk-widget into a background renderer. This can be quite useful when you desire to update your plot in real-time.

Documentation

For the installation and usage of this package, please visit the PyVistaQt documentation.

Refer to the PyVista documentation for detailed installation and usage details of the core package which is used alongside this package.

For general questions about the project, its applications, or about software usage, please create a discussion in pyvista/discussions where the community can collectively address your questions. You are also welcome to join us on Slack or send one of the developers an email. The project support team can be reached at [email protected].

Installation

Installation using pip is:

$ pip install pyvistaqt

To install this package with conda run:

$ conda install -c conda-forge pyvistaqt

You can also visit PyPI or GitHub to download the source.

Once installed, use the pyvistaqt.BackgroundPlotter like any PyVista plotter.

Contributing

We absolutely welcome contributions. pyvistaqt is maintained on a volunteer basis and thus we need to foster a community that can support user questions and develop new features to make this software a useful tool for all users while encouraging every member of the community to share their ideas. To learn more about contributing to PyVista, please see the pyvista Contributing Guide and Code of Conduct.

pyvistaqt's People

Contributors

adam-grant-hendry avatar akaszynski avatar banesullivan avatar charlessillett avatar dependabot[bot] avatar github-actions[bot] avatar guillaumefavelier avatar hoechenberger avatar larsoner avatar nicobako avatar pre-commit-ci[bot] avatar rodrigomologni avatar tkoyama010 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pyvistaqt's Issues

How to set "off_screen" totally?

I have a project depending on this wonderful project. Now I want to add some tests to my project. They are supposed to run automatically without a screen. I tried to set off_screen of BackGroundPlotter to True. But I found that this line

self.view_isometric()

always gets running. Is it a bug or feature? If it is a feature, is there any workaround? Thanks.

Please publish sdist on PyPI

Currently, only binary wheels are published on PyPI. Could you please also publish the source distribution? This is relevant for users trying to build pyvistaqt themselves, or for creating conda-forge packages.

Thank you!

Code style

I think the same question can be asked in this repo. And eventually the same solution could be applied.

BUG: Reference cycle problem with multiple windows open

This code:

import gc
import time
from pyvistaqt import BackgroundPlotter

plotters = list()
time.sleep(1)
for _ in range(20):
    plotter = BackgroundPlotter()
    plotter.show()
    plotters.append(plotter)
    #for plotter in plotters:
    plotter.close()
    plotter.deep_clean()
del plotter, plotters
gc.collect()
time.sleep(2)

Run with:

mprof run mem.py; mprof plot

Seems fine:

Screenshot from 2020-09-18 09-18-31

But when you uncomment the for plotter in plotters line and unindent it so that all plots are created, then all plots closed (rather than one created, one closed, repeating) we get:

Screenshot from 2020-09-18 09-18-06

In other words, there is ~150 MB in residual memory that cannot be cleared. I've spent some time trying to figure it out, no luck so far.

I know this seems like a minor problem, but when you have real plots and data it matters. Over in MNE we have an example that opens about 20 windows at a time, and it causes a permanent ~1GB memory jump in a sphinx-gallery build -- it's the 1 GB step function around 1600 seconds here (I suspect most of our step jumps in doc builds are due to this):

Here is a MNE-specfic example with real data and 10 plots, individual create-and-close:

Screenshot from 2020-09-18 09-28-16

Create-all, close-all:

Screenshot from 2020-09-18 09-26-18

Even mayavi seems to have the problem, though:

Screenshot from 2020-09-18 09-27-31

This makes me wonder if this is under the hood a problem with VTK's interactor class or something. Still, it would be nice to figure out what attributes could be deleted or tweaked to make it so that these can actually get garbage collected.

Coverage?

I think it would be nice to have visibility on the project coverage with a badge.

Also it seems that coverage is uploaded to codecov but what about codecov integration with the PRs?

FEAT: PRE job

I think that #83 is a step in the right direction but it might not be enough. I think a PRE job that test against PyVista master instead of the latest release version would be good to have. Especially, to have a bit of leeway to digest any API changes etc.

Support for PySide2 (qt)

I would like to use pyvista in a qt qui application. In this application we use the pyside2 library instead of the pyqt5. Going over the source in qt_plotting it seems that adding support for pyside2 is not too much work. Willing to give it a go and create a merge request when finished.

However, I do not want to interfere withe pyvista/pyvista#614 which seems to propose massive reduction of the qt-related code in pyvista (which I think is a good idea).

Also, adding functionality to embed a plotter instance in an existing qt gui ( like done here: https://github.com/marcomusy/vtkplotter-examples/blob/master/vtkplotter_examples/other/qt_window.py ) is something I would like to add.

(see: https://www.learnpyqt.com/blog/pyqt5-vs-pyside2/)

Please tell me how and where I can support.

BUG: BackgroundPlotter does not handle HiDPI properly

This code:

import pyvista as pv
from pyvista import Plotter
# from pyvistaqt import BackgroundPlotter as Plotter

def callback(*args, **kwargs):
    print(args, kwargs)


p = Plotter()
p.add_box_widget(callback)
p.add_mesh(pv.Cone())
p.show()

Works just fine for picking and looks like:

Screen Shot 2020-06-29 at 2 41 56 PM

Changing it to use BackgroundPlotter, the window is twice as big (fine), the same number of rendered pixels (I think? if so, bad), and click interactions are off by a factor of 2 (you have to click 50% of the width and 50% of the height to get the right part of the interactor):

Jun-29-2020 14-54-37

There is a lot of code in Mayavi designed to handle this based around _pixel_ratio:

https://github.com/enthought/mayavi/blob/master/tvtk/pyface/ui/qt4/QVTKRenderWindowInteractor.py#L250-L253

Presumably some or all of this needs to be adapted to get HiDPI support working. Does this seem like the best way to go?

Questions about implementing hover and timer functionalities

Hi,

I am trying to implement a simple hover feature that could be used to execute a callback after the mouse is not moving and hover an actor for a certain period of time. My end goal: ray tracing on hover to display a scalar from a dataset on the fly. This could be flexible and work like the vtkBalloonWidget, or this could be a fixed 2D actor in the corner or just getting the result for somewhere else in Qt.

I am currently using pyvista with Qt, but I would prefer to make a solution without Qt and put that in a PR. I based my first tests on this example:
https://lorensen.github.io/VTKExamples/site/Cxx/Widgets/HoverWidget/
But I am getting a very strange effect: every action with the mouse is perpetual unless I release the button. For example, panning is happening without moving the mouse.

Anybody knows if it is possible to do it without Qt if I am using VTK in a Qt widget?
Any idea of what is happening? This simple code set with iren is not printing (no callback) but it seems to overwrite something.

def hover_widget(render_window_interactor):
    widget = vtk.vtkHoverWidget()
    widget.SetTimerDuration(300)
    widget.SetInteractor(render_window_interactor)
    widget.AddObserver(vtk.vtkCommand.TimerEvent, callback)
    widget.AddObserver(vtk.vtkCommand.EndInteractionEvent, callback)
    widget.On()
    return widget


def callback(object, event_id):
    print("hover now")

Edit: okay, I added a return line to save the widget (facepalm here) and I tested with pyvista only. It works! but only without Qt. In my app the callback is firing all the time. I will investigate further what is happening in pyvistaqt.

Automatic Testing with CI

I do not see any automatic unit testing setup in the project, what is the plan @pyvista/developers ?

Import Error 'vtkGenericRenderWindowInteractor' from 'vtkmodules.vtkRenderingCore'

I've done some reading of other issues and it seems like this was an issue with vtk before the update to vtk 9.0.1 but even though I have vtk 9.0.1 I'm still getting this error. It's hard to tell if this was resolved or not. Is PySide2 supported or not...?

I had an issue with PySide2 and my conda env which was fixed by installing the conda Pyside2 package. I also installed the pyvistaqt conda package. vtk package however says it's from pypi. I tried updating this but it remained pypi. Not sure if that makes things clearer.

Full error:

Traceback (most recent call last):
  File "C:/Users/A9HALZZ/OneDrive - 3M/Nexus/Surface Scanner/Visualizer/pyvistaqt_example2.py", line 13, in <module>
    from pyvistaqt import QtInteractor
  File "C:\Users\A9HALZZ\Anaconda3\envs\scanPY38\lib\site-packages\pyvistaqt\__init__.py", line 3, in <module>
    from pyvistaqt.plotting import BackgroundPlotter, MainWindow, QtInteractor
  File "C:\Users\A9HALZZ\Anaconda3\envs\scanPY38\lib\site-packages\pyvistaqt\plotting.py", line 57, in <module>
    from vtk.qt.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor
  File "C:\Users\A9HALZZ\Anaconda3\envs\scanPY38\lib\site-packages\vtkmodules\qt\QVTKRenderWindowInteractor.py", line 62, in <module>
    from vtkmodules.vtkRenderingCore import vtkGenericRenderWindowInteractor, vtkRenderWindow
ImportError: cannot import name 'vtkGenericRenderWindowInteractor' from 'vtkmodules.vtkRenderingCore' (C:\Users\A9HALZZ\Anaconda3\envs\scanPY38\lib\site-packages\vtkmodules\vtkRenderingCore.cp38-win_amd64.pyd)

Closing problem when I use de right_upper X

Hello, I use the pyvistaqt to visualize lidar mobil data. If I use the menu item "exit" the program close without any error, but when I use the X to close the window a list of error appear in loop indefinitly until I press ctrl-break.

Do you have an ideas why this appear?

this is a copy of what I see in the command prompt:

2021-03-30 16:32:36.257 ( 128.087s) [                ]vtkOpenGLFramebufferObj:457    ERR| vtkOpenGLFramebufferObject (0000021292F15F80): Frame buffer object was not initialized correctly.
ERROR:root:Frame buffer object was not initialized correctly.
2021-03-30 16:32:36.272 ( 128.101s) [                ]vtkOpenGLFramebufferObj:1367   ERR| vtkOpenGLFramebufferObject (0000021292F15F80): The framebuffer is incomplete : FRAMEBUFFER_INCOMPLETE_ATTACHMENT
ERROR:root:The framebuffer is incomplete : FRAMEBUFFER_INCOMPLETE_ATTACHMENT
Current framebuffer is bind to framebuffer object 2
color attachment 0:
 this attachment is a texture with name: 10
 its mipmap level is: 0
 this is not a cube map texture.
 this is not 3D texture.
color attachment 1:
 this attachment is empty
.........

Unwanted memory usage by QtInteractor.add_point_labels

Problem

I identified unwanted memory usage by QtInterator.add_point_labels, which is causing serious slowness in the interaction:

image

For reference, QtInterator.add_mesh produces:

image

Testing

I checked the memory use for the following cases using examples.load_uniform as grid:

  1. plotting grid using add_mesh by Plotter
  2. plotting grid using add_mesh by QtInteractor
  3. plotting grid.cell_centers using add_point_labels by Plotter
  4. plotting grid.cell_centers using add_point_labels by QtInteractor

Sources: sources.zip

Result of Case 1:

image

Result of Case 2:

image

Result of Case 3:

image

Result of Case 4:

image

Scooby Report

--------------------------------------------------------------------------------
  Date: Wed Feb 17 16:57:11 2021 Hora oficial do Brasil

                OS : Windows
            CPU(s) : 8
           Machine : AMD64
      Architecture : 64bit
               RAM : 15.9 GB
       Environment : Python

  Python 3.8.7 (tags/v3.8.7:6503f05, Dec 21 2020, 17:59:51) [MSC v.1928 64 bit
  (AMD64)]

           pyvista : 0.27.4
         pyvistaqt : 0.3.0
               vtk : 9.0.1
             numpy : 1.19.5
             scipy : 1.6.0
           IPython : 7.19.0
        matplotlib : 3.3.4
            scooby : 0.5.6
--------------------------------------------------------------------------------

Project is not on PyPI yet

The project is not on PyPI yet, which is probably on purpose. I tried giving pyvista 0.25 a go, but my code uses BackgroundPlotters, and so it tells me to install pyvistaqt from pip. And so does the README :) So right now the latest release of pyvista might lead users into a semi-dead end.

methods of QtInteractor

Hello, I'm testing some methods of QtInteractor from the new spin-off pyvistaqt library.

BTW, it is more clear to have it in a dedicated library. Thanks!

First I create a plotter widget in a Qt QMainWindow created with Qt Designer:

class View3D(QMainWindow, Ui_ThreeDWindow):
    def __init__(self, parent=None, *args, **kwargs):
        super(View3D, self).__init__(parent, *args, **kwargs)
        self.setupUi(self)
        self.plotter = QtInteractor(self.ViewFrame)
        self.ViewFrameLayout.addWidget(self.plotter.interactor)

Then I am able to add some actor and everything works very well!

self.plotter.add_mesh(<vtk_object>, name=<vtk_object_name>)

However some of the methods inherited from BasePlotter() crash the application.

Tested working:
self.plotter.show_axes_all()
self.plotter.hide_axes_all()
self.plotter.add_bounding_box()
self.plotter.show_bounds()
self.plotter.show_grid()
self.plotter.add_floor()
self.plotter.add_scalar_bar()

Tested crashing:
self.plotter.add_orientation_widget()
self.plotter.add_toolbars()
self.plotter.add_menu_bar()
self.plotter.add_legend()
self.plotter.default_camera_tool_bar()

pyvistaqt install

Not sure if this can be classified as an issue.
On a clean windows 10 install I installed Anaconda (Anaconda3-2020.11-Windows-x86_64.exe)
After install, pyvista or pyvistaqt cannot be installed via the anaconda prompt (conda install -c conda-forge pyvistaqt) nor the Anaconda Navigator.
PIP install gives an SSL error.
I can install other packages.
Over the same network, my laptop (which has a previously upgraded anaconda version) installs without problem (same on my work pc on a different network).

Does anyone have any idea what is wrong here,

window_size inconsistent between plotters

This continues the discussion on: pyvista/pyvista#995

In case of Plotter, the main window and render window are the same right? It's not the case for BackgroundPlotter, what should be the right "window" for window_size?:

    @property
    def window_size(self) -> Tuple[int, int]:
        """Return render window size."""
        the_size = self.app_window.baseSize()
        return the_size.width(), the_size.height()

    @window_size.setter
    def window_size(self, window_size: QSize) -> None:
        """Set the render window size."""
        self.app_window.setBaseSize(*window_size)
        self.app_window.resize(*window_size)

Windows fatal exception

Received an email:

Dear PyVistaΒ Team,

I would like to report a supposed bug: the QtInteractor is producing a Windows fatal exception (code 0x8001010d) when the Qt window is moved or clicked.Β I am running the first example code inΒ https://qtdocs.pyvista.org/qt_plotting.html. See the print screen below, please. Congratulations on the PyVista project.

image

Scene editor features

I was thinking about some features that would be good to add in the scene editor.

  • icon for each node of the scene (ideally, the icon could depend on the type of the node e.g. Renderer, PolyData, UnstructuredGrid...etc)

And some more properties could be exposed:

Renderer:

  • 3-lights
  • eye dome lighting
  • interactor style
  • background color (top and bottom)
  • depth peeling
  • anti-aliasing
  • parallel projection
  • bounds, grid and floor

Actor:

  • translucent
  • ambient, diffuse and specular
  • metallic and roughness
  • vertex and edge visibility
  • point size and line width
  • shading
  • front and back face culling

Mapper:

  • interpolate scalar before mapping
  • scalar mode
  • scalar range
  • resolve coincident topology

The list is not complete, maybe some properties are not compatible and probably not everything will be added.

black (blank) plot on ubuntu

on ubuntu, with a recent install of anaconda in a new environment I just get a black screen for the plotting window, if I use the file menu in the background plotter menu to save a screenshot I can view a rendering but otherwise the screen is blank. I installed via the conda-forge, and I can see some differences in the dependencies in the environment yml in this repo and the feedstock, but not sure if that is the issue.

>>> pv.Report()                                                                                                                                            
                                                                                                                                                           
--------------------------------------------------------------------------------                                                                           
  Date: Wed Sep 02 18:32:22 2020 EDT                                                                                                                       
                                                                                                                                                           
                OS : Linux                                                                                                                                 
            CPU(s) : 16                                                                                                                                    
           Machine : x86_64                                                                                                                                
      Architecture : 64bit                                                                                                                                 
               RAM : 62.8 GB                                                                                                                               
       Environment : Python                                                                                                                                
NVIDIA Corporation : GPU Vendor                                                                                                                            
GeForce GTX 1080 Ti/PCIe/SSE2 : GPU Renderer                                                                                                               
4.5.0 NVIDIA 435.21 : GPU Version                                                                                                                          
                                                                                                                                                           
  Python 3.7.8 | packaged by conda-forge | (default, Jul 31 2020, 02:25:08)                                                                                
  [GCC 7.5.0]                                                                                                                                              
                                                                                                                                                           
           pyvista : 0.25.3                                                                                                                                
               vtk : 9.0.1                                                                                                                                 
             numpy : 1.19.1
           imageio : 2.9.0
           appdirs : 1.4.3
            scooby : 0.5.6
            meshio : 4.1.1
        matplotlib : 3.3.1
         pyvistaqt : 0.2.0
             PyQt5 : 5.12.3
           IPython : 7.18.1
             scipy : 1.5.2
              tqdm : 4.48.2

  Intel(R) Math Kernel Library Version 2019.0.5 Product Build 20190808 for
  Intel(R) 64 architecture applications
--------------------------------------------------------------------------------

error when calling disable_eye_dome_lighting()

>>> plotter.disable_eye_dome_lighting()
2020-09-02 18:33:32.815 (  85.569s) [        1750E740]      vtkEDLShading.cxx:97     ERR| vtkEDLShading (0x56159871d580): FrameBufferObject should have been deleted in ReleaseGraphicsResources().
ERROR:root:FrameBufferObject should have been deleted in ReleaseGraphicsResources().
2020-09-02 18:33:32.816 (  85.570s) [        1750E740]      vtkEDLShading.cxx:102    ERR| vtkEDLShading (0x56159871d580): ColorTexture should have been deleted in ReleaseGraphicsResources().
ERROR:root:ColorTexture should have been deleted in ReleaseGraphicsResources().
2020-09-02 18:33:32.816 (  85.570s) [        1750E740]      vtkEDLShading.cxx:107    ERR| vtkEDLShading (0x56159871d580): DepthTexture should have been deleted in ReleaseGraphicsResources().
ERROR:root:DepthTexture should have been deleted in ReleaseGraphicsResources().
2020-09-02 18:33:32.816 (  85.570s) [        1750E740]      vtkEDLShading.cxx:112    ERR| vtkEDLShading (0x56159871d580): FrameBufferObject should have been deleted in ReleaseGraphicsResources().
ERROR:root:FrameBufferObject should have been deleted in ReleaseGraphicsResources().
2020-09-02 18:33:32.816 (  85.570s) [        1750E740]      vtkEDLShading.cxx:117    ERR| vtkEDLShading (0x56159871d580): ColorTexture should have been deleted in ReleaseGraphicsResources().
ERROR:root:ColorTexture should have been deleted in ReleaseGraphicsResources().
2020-09-02 18:33:32.816 (  85.570s) [        1750E740]      vtkEDLShading.cxx:122    ERR| vtkEDLShading (0x56159871d580): FrameBufferObject should have been deleted in ReleaseGraphicsResources().
ERROR:root:FrameBufferObject should have been deleted in ReleaseGraphicsResources().
2020-09-02 18:33:32.817 (  85.570s) [        1750E740]      vtkEDLShading.cxx:127    ERR| vtkEDLShading (0x56159871d580): ColorTexture should have been deleted in ReleaseGraphicsResources().
ERROR:root:ColorTexture should have been deleted in ReleaseGraphicsResources().
2020-09-02 18:33:32.817 (  85.570s) [        1750E740]      vtkEDLShading.cxx:132    ERR| vtkEDLShading (0x56159871d580): ColorTexture should have been deleted in ReleaseGraphicsResources().
ERROR:root:ColorTexture should have been deleted in ReleaseGraphicsResources().

Pyside2 Example Error

Heys guys,

at the moment im trying to implement a 3d tool to extract surfaces from 3d objects. There fore i want to utilize pyvista and pyside2 and integrate pyvistaqt with qml.

I wanted to start by setting up this example from the homepage: http://qtdocs.pyvista.org/usage.html#example-pyqt5-pyvista-qtinteractor, but unfortunaly there's the following error:

"QWidget(parent: QWidget = None, flags: Union[Qt.WindowFlags, Qt.WindowType] = Qt.WindowFlags()): argument 1 has unexpected type 'PySide2.QtWidgets.QFrame'"

There's my code(from the example):

import os
import sys

import vtkmodules.qt
os.environ["QT_API"] = "pyside2"

from PySide2 import QtWidgets
from PySide2.QtWidgets import QMainWindow

import numpy as np

import pyvista as pv
from pyvistaqt import QtInteractor

class MainWindow(QMainWindow):

    def __init__(self, parent=None, show=True):
        QtWidgets.QMainWindow.__init__(self, parent)

        # create the frame
        self.frame = QtWidgets.QFrame()
        vlayout = QtWidgets.QVBoxLayout()

        # add the pyvista interactor object
        self.plotter = QtInteractor(self.frame)
        vlayout.addWidget(self.plotter.interactor)

        self.frame.setLayout(vlayout)
        self.setCentralWidget(self.frame)

        # simple menu to demo functions
        mainMenu = self.menuBar()
        fileMenu = mainMenu.addMenu('File')
        exitButton = QtWidgets.QAction('Exit', self)
        exitButton.setShortcut('Ctrl+Q')
        exitButton.triggered.connect(self.close)
        fileMenu.addAction(exitButton)

        # allow adding a sphere
        meshMenu = mainMenu.addMenu('Mesh')
        self.add_sphere_action = QtWidgets.QAction('Add Sphere', self)
        self.add_sphere_action.triggered.connect(self.add_sphere)
        meshMenu.addAction(self.add_sphere_action)

        if show:
            self.show()

    def add_sphere(self):
        """ add a sphere to the pyqt frame """
        sphere = pv.Sphere()
        self.plotter.add_mesh(sphere, show_edges=True)
        self.plotter.reset_camera()


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

This is my environment:

python: 3.6.7
pyside2: 5.13.2
pyqt: 5.12.3
pyvista: 0.27.2
pyvistaqt: 0.2.0

BUG: conda

Some failures have been detected for the conda jobs. Those use PySide2 by default and the error seems to be related to Qt/QtPy:

Installing collected packages: pyvistaqt
  Running setup.py develop for pyvistaqt
WARNING: Value for scheme.headers does not match. Please report this to <https://github.com/pypa/pip/issues/9617>
distutils: /usr/share/miniconda/envs/pyvistaqt-env/include/python3.8/UNKNOWN
sysconfig: /usr/share/miniconda/envs/pyvistaqt-env/include/python3.8
WARNING: Additional context:
user = False
home = None
root = None
prefix = None
Successfully installed pyvistaqt-0.4.dev0
Traceback (most recent call last):
  File "/usr/share/miniconda/envs/pyvistaqt-env/lib/python3.8/site-packages/qtpy/__init__.py", line 204, in <module>
    from PySide import __version__ as PYSIDE_VERSION  # analysis:ignore
  File "/usr/share/miniconda/envs/pyvistaqt-env/lib/python3.8/site-packages/shiboken2/files.dir/shibokensupport/__feature__.py", line 142, in _import
    return original_import(name, *args, **kwargs)
ModuleNotFoundError: No module named 'PySide'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/share/miniconda/envs/pyvistaqt-env/lib/python3.8/site-packages/pyvista/utilities/errors.py", line 232, in __init__
    scooby.Report.__init__(self, additional=additional, core=core,
  File "/usr/share/miniconda/envs/pyvistaqt-env/lib/python3.8/site-packages/scooby/report.py", line 170, in __init__
    PythonInfo.__init__(self, additional=additional, core=core,
  File "/usr/share/miniconda/envs/pyvistaqt-env/lib/python3.8/site-packages/scooby/report.py", line 84, in __init__
    self._add_packages(optional, optional=True)  # Optional packages
  File "/usr/share/miniconda/envs/pyvistaqt-env/lib/python3.8/site-packages/scooby/report.py", line 99, in _add_packages
    name, version = get_version(pckg)
  File "/usr/share/miniconda/envs/pyvistaqt-env/lib/python3.8/site-packages/scooby/report.py", line 377, in get_version
    module = importlib.import_module(name)
  File "/usr/share/miniconda/envs/pyvistaqt-env/lib/python3.8/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "/home/runner/work/pyvistaqt/pyvistaqt/pyvistaqt/__init__.py", line 3, in <module>
    from pyvistaqt.plotting import BackgroundPlotter, MainWindow, MultiPlotter, QtInteractor
  File "/home/runner/work/pyvistaqt/pyvistaqt/pyvistaqt/plotting.py", line 57, in <module>
    from qtpy import QtCore
  File "/usr/share/miniconda/envs/pyvistaqt-env/lib/python3.8/site-packages/qtpy/__init__.py", line 210, in <module>
    raise PythonQtError('No Qt bindings could be found')
qtpy.PythonQtError: No Qt bindings could be found

Reference: https://github.com/pyvista/pyvistaqt/runs/2466277736?check_suite_focus=true#step:7:30

Bug report: MacOS 10.15.7,PyVista QtInteractor example only works if window is hidden and then exposed

Hi,

Thanks for this code. When I invoke the example code from the command line, the menu is unresponsive until I cover (at least partially) the window with another window and then expose it. After that the app works great.

The "Add Sphere"menu item appears and everything works as it should.

Any ideas? (Note: I don't see this behavior with my other python QT5 codes. However, my other codes use PyQt5 directly and not qtpy. I expect the problem could be in qtpy.)

Thanks!

Murray

The Brief Example in the doc does not work as expected.

The example from the doc does not show anything unless this sentence

plotter.app.exec_()

is added.

Maybe this line is omitted deliberately. But I would love to see some explanatory comments which would help other new people like me a lot.

QT Designer Widget Reference

Gday all

I just thought I would bother you with another little problem for which I cant seem to find a proper resolution.

I have created a QT Designer GUI which accesses a form. In this form, data can be uploaded.
After import, I want to create an image view of the data in a frame (or graphicsview).
I have created a quickframe from the class Qframe for this purpose as shown in the pic below.
image

However, when use the code example, I create a new instance (at the proper location), as shown below
image

some sample code:
Open_File_UWN_Model.txt
.ui has been renamed to .txt to be able to upload
Open_File_UWN_Model.txt

# create the frame
# self.frame = QtWidgets.QFrame()
vlayout = QtWidgets.QVBoxLayout()

     # add the pyvista interactor object
     self.plt = QtInteractor(self.quickframe)
     vlayout.addWidget(self.plt.interactor)
#call definition add_box somewhere

def add_box(self):
    box = pv.Box()
    self.plt.add_mesh(box)
    self.plt.reset_camera()`

As you can see, I've created an new instance overlapping the QT-design widget.
I cant seem to figure out how can I use the QT-design instance without creating a new instance but just using the Widget reference?

BackgroundPlotter segfaults on MacOS when smooth_shading is True

The following snippet fails on MacOS:

import numpy as np
import pyvista as pv
from pyvistaqt import BackgroundPlotter
import vtk
p = BackgroundPlotter()
# sphere
center = np.random.rand(200, 3) * 1000 - 500
sphere = vtk.vtkSphereSource()
sphere.SetThetaResolution(8)
sphere.SetPhiResolution(8)
sphere.SetRadius(10)
sphere.Update()
geom = sphere.GetOutput()
mesh = pv.PolyData(np.array(center))
glyph = mesh.glyph(orient=False, scale=False,
                   factor=1.0, geom=geom)
p.add_mesh(glyph, smooth_shading=True)

And in my experience, adding p.app.processEvents() just before add_mesh() fixes it.

@agramfort feel free to confirm this and share your report when possible:

python -c "import pyvista; print(pyvista.Report())"

Screenshot dimensions inconsistent between plotters

Describe the bug, what's wrong, and what you expect:

The dimensions of screenshot images are different between Plotter and BackgroundPlotter.


To Reproduce

# Insert code here
import pyvista as pv

window_size = (600, 600)
sphere = pv.Sphere()

p = pv.BackgroundPlotter(window_size=window_size)
p.add_mesh(sphere)
img1 = p.screenshot()

p = pv.Plotter(window_size=window_size)
p.add_mesh(sphere)
p.show()
img2 = p.screenshot()

print(img1.shape)
print(img2.shape)

# Result obtained:
# (546, 586, 3)
# (600, 600, 3)

# Result expected:
# (600, 600, 3)
# (600, 600, 3)

System Information:

--------------------------------------------------------------------------------
  Date: Wed Apr 29 14:42:41 2020 CEST

                OS : Linux
            CPU(s) : 4
           Machine : x86_64
      Architecture : 64bit
               RAM : 7.7 GB
       Environment : IPython
        GPU Vendor : NVIDIA Corporation
      GPU Renderer : GeForce GTX 960M/PCIe/SSE2
       GPU Version : 4.5.0 NVIDIA 430.64

  Python 3.7.6 (default, Jan  8 2020, 19:59:22)  [GCC 7.3.0]

           pyvista : 0.24.1
               vtk : 8.1.2
             numpy : 1.18.1
           imageio : 2.6.1
           appdirs : 1.4.3
            scooby : 0.5.2
            meshio : 4.0.9
        matplotlib : 3.1.3
             PyQt5 : 5.14.2
           IPython : 7.13.0
          colorcet : 1.0.0
           cmocean : 2.0
             scipy : 1.4.1
        itkwidgets : 0.26.1
              tqdm : 4.36.1

  Intel(R) Math Kernel Library Version 2020.0.0 Product Build 20191122 for
  Intel(R) 64 architecture applications
--------------------------------------------------------------------------------

Reimplement BackgroundPlotter to have each renderer in its own Qt frame

We should figure out how to reimplement the BackgroundPlotter to place several window interactors/renderers in their own Qt frames rather than as sub-viewports in a single interactor so that subplotting can be more configurable for downstream dependencies

  • Qt frames can be dragged around/rearranged
  • Each frame would have its own toolbar to fix how the "Save Camera" button only works for the last active view

@akaszynski, I think that you originally brought this up to me. Any thoughts?

`QtInteractor` can no longer be used with qt-designer

Before pyvista 0.24.0, I could use qt-designer to design my UI and promote a widget to pv.QtInteractor.

It is probably the expected behaviour, but this version makes it impossible to do that.

Also, If I want to remove/re-add the widget, which I have to do because I dynamically want to change the number of subplots in my app, I must be careful to use the interactor attribute of the pv.QtInteractor instance and not the instance directly.

I do not expect this to change, but since it took me a while to figure out what was happening, I thought I would write it here…

My fix was to create a simple QWidget in qt-designer, and basically call this on window create and every time I want to update the number of subplots.

def update_subplots(main_window):
    # Awful hacks because pv.QtInteractor no longer heritates from QtWidget
    try:
        main_window.vlayout.removeWidget(main_window.pv_plotter.interactor)
    except AttributeError:
        main_window.vlayout.removeWidget(main_window.pv_plotter)
    del main_window.pv_plotter

I am sure there is a better way to do that, but it works…

Adding/removing subplots dynamically would be a great feature BTW.

Resolution issues using QtInteractor

As stated above, I am having some odd resolution issues when adding meshes to a Qtinteractor.

Below you can see a screenshot demonstrating the poor resolution of the object when zoomed out (Most obvious when comparing "arc_length" resolution to the 3rd screenshot).
Screen Shot 2021-04-29 at 5 18 56 PM

In contrast, when zoomed in, the lines become more smooth, but the resolution of "arc length" stays the same...
Screen Shot 2021-04-29 at 5 25 04 PM

This might have something to do with my MacBook Pro monitor, however, because observing the mesh on my external monitor produces a smoother image (and appropriate resolution text for the scalar bar). Loading here doesn't solve anything, as the resolutions don't appear different when when taking a screenshot.

These issues are not present when using the pure PyVista.Plotter() from the command line:
Screen Shot 2021-04-29 at 5 38 12 PM

I am creating the plotter using:
self.plotter = QtInteractor(multi_samples=8,line_smoothing=True, point_smoothing=True, polygon_smoothing=True)
and add meshes to the plotter using:
self.plotter.add_mesh(examplemesh)

Please let me know if there is anything I can do to improve/solve this issue. Any help would be appreciated.

Thanks

Crash at closing when embeded in some Qt application as child widget

Hi all, I'm not sure this is the most relevant place to raise my issue but 'ill take my chances...

I'm trying to use pyvistaqt.QtInteractor as a 3D renderer widget inside a QGIS plugin (Qt based application).
Works like a charm ... untill I close the main app window (which sould trigger deleteLater() on every children), there the QtInteractor closing throws me some exceptions (see later traceback)

I'm creating the renderer as an object derived from QtInteractor

class PvRenderer(QtInteractor):

    instance = None

    def __new__(cls, parent=None):
        if cls.instance is None:
            cls.instance = super(QtInteractor, cls).__new__(cls, parent)
        return cls.instance

    def __init__(self, parent=None):
        super().__init__(
            parent=parent,
            border=True,
            border_color=qsettings.value("border_color", "#b9b9b9"),
        )

   # [...] some stuff

    def destroy(self):
        self.clear()  # tried to clear all plots before
        pv.close_all() # tried to delete all renderers (should be a singleton though)
        self.deleteLater()

but still getting strange error about __crt_seh_guarded_call::operator(), & __ptr64, > during vtkOutputWindowCleanup destruction...

Stack Trace


PyObject_SetItem :
vtkPythonCommand::~vtkPythonCommand :
vtkPythonCommand::operator= :
vtkCommand::UnRegister :
vtkObject::UnRegisterInternal :
vtkOutputWindowCleanup::~vtkOutputWindowCleanup :
::operator() :
__crt_seh_guarded_call::operator(), & __ptr64, > :
execute_onexit_table :
vtkMath::FreeCombination :
vtkMath::FreeCombination :
LdrpCallInitRoutine :
LdrShutdownProcess :
RtlExitUserProcess :
ExitProcessImplementation :
exit_or_terminate_process :
common_exit :
BaseThreadInitThunk :
RtlUserThreadStart :




QGIS Info
QGIS Version: 3.14.1-Pi
QGIS code revision: de08d6b71d
Compiled against Qt: 5.11.2
Running against Qt: 5.11.2
Compiled against GDAL: 3.0.4
Running against GDAL: 3.0.4



System Info
CPU Type: x86_64
Kernel Type: winnt
Kernel Version: 10.0.17763

note that i don't have any problem when running simple plots from python terminal using pyvista.plot

using release 0.2.0 on windows 10 - 64bits

MAINT: Release?

It would be helpful to push out a release to get the latest icon updates (would probably fix this segfault for example). I'm happy to do it if someone gives me permissions on PyPi. I'll just run a standard (for me at least) python setup.py sdist bdist_wheel and twine upload dist/* --repository pyvistaqt --verbose or so, unless there is more to it than that.

Interactive action menu on plotting window

Hi guys,

First thank you for the great work you've done with pyvista. I am quite new to it and I was playing around a bit. One feature that I really miss is the interactive action menu on the plotting window like the one you get in mayavi or in matlab, for example see the images below:

image

image

image

Is this feature applicable and somehow possible to be activated or if not, is it in your plans to include it in future releases?

I think it would a nice feature to be possible to enable/disable axes, grid, set background, interactively on the plotting window rather than only with code.

ENH: Pinch-to-zoom support

We want to implement pinch-to-zoom support in MNE-Python. Would it make sense to add it directly in pyvistaqt in QtInteractor or BackgroundPlotter? From what I (incompletely) understand so far it will probably require something like:

    def __init__(self, ...):  # init of the the window, might work at the widget level, too; TBD
        ...
        self.grabGesture(Qt.PinchGesture)
        ...

    def event(self, event):  # override general event handler
        """Handle events."""
        if event.type() == QtCore.QEvent.Gesture:
            return self.gestureEvent(event)
        return super().event(event)

    def gestureEvent(self, event):
        """Handle gesture events."""
        ...  # actually do the heavy lifting to handle start, during, and stop stages of the gesture

Implementation Question: Qt overlay for pyvistaqt

This is more related to how you implemented an overlay with the vtk widget.

The goal is to have Qt widgets over the pyvistaqt widget, with transparency enabled. Example from an old unresolved vtk thread:
image

If you did it, how did you make things work with pyvistaqt?

I have done a few tests but I can't get a Qt widget to draw over the renderer. This is an empty plotter with the widget over:

image

The plotter works fine but the widget doesn't draw. There is a glitch on that snapshot where it draws the border of another widget when resizing the window.

So far I tried just putting the widget inside, I tried QStackedLayout with QtWidgets.QStackedLayout.StackAll, which works on normal widgets, but there must be some special care necessary to make this possible with the opengl widget.

Errors when disabling eye dome lighting

I'm getting this errors when I disable eye_dome_lighting in my plotter:

2020-11-09 14:18:38.460 (  18.067s) [                ]      vtkEDLShading.cxx:97     ERR| vtkEDLShading (0000021B60885D80): FrameBufferObject should have been deleted in ReleaseGraphicsResources().
2020-11-09 14:18:38.461 (  18.067s) [                ]      vtkEDLShading.cxx:102    ERR| vtkEDLShading (0000021B60885D80): ColorTexture should have been deleted in ReleaseGraphicsResources().
2020-11-09 14:18:38.461 (  18.068s) [                ]      vtkEDLShading.cxx:107    ERR| vtkEDLShading (0000021B60885D80): DepthTexture should have been deleted in ReleaseGraphicsResources().
2020-11-09 14:18:38.462 (  18.069s) [                ]      vtkEDLShading.cxx:112    ERR| vtkEDLShading (0000021B60885D80): FrameBufferObject should have been deleted in ReleaseGraphicsResources().
2020-11-09 14:18:38.463 (  18.070s) [                ]      vtkEDLShading.cxx:117    ERR| vtkEDLShading (0000021B60885D80): ColorTexture should have been deleted in ReleaseGraphicsResources().
2020-11-09 14:18:38.463 (  18.070s) [                ]      vtkEDLShading.cxx:122    ERR| vtkEDLShading (0000021B60885D80): FrameBufferObject should have been deleted in ReleaseGraphicsResources().
2020-11-09 14:18:38.464 (  18.071s) [                ]      vtkEDLShading.cxx:127    ERR| vtkEDLShading (0000021B60885D80): ColorTexture should have been deleted in ReleaseGraphicsResources().
2020-11-09 14:18:38.465 (  18.072s) [                ]      vtkEDLShading.cxx:132    ERR| vtkEDLShading (0000021B60885D80): ColorTexture should have been deleted in ReleaseGraphicsResources().

The program doesn't crash but throws these errors each time eye dome lighting is disabled.

Looking in the renderer code of pyvista this is the code block associated with eye dome lighting:

    def enable_eye_dome_lighting(self):
        """Enable eye dome lighting (EDL)."""
        if hasattr(self, 'edl_pass'):
            return self
        # create the basic VTK render steps
        basic_passes = vtk.vtkRenderStepsPass()
        # blur the resulting image
        # The blur delegates rendering the unblured image to the basic_passes
        self.edl_pass = vtk.vtkEDLShading()
        self.edl_pass.SetDelegatePass(basic_passes)

        # tell the renderer to use our render pass pipeline
        self.glrenderer = vtk.vtkOpenGLRenderer.SafeDownCast(self)
        self.glrenderer.SetPass(self.edl_pass)
        self.Modified()
        return self.glrenderer

    def disable_eye_dome_lighting(self):
        """Disable eye dome lighting (EDL)."""
        if not hasattr(self, 'edl_pass'):
            return
        self.SetPass(None)
        del self.edl_pass
        self.Modified()
        return

Review Me

@pyvista/developers, I'd like you to please take a look at this repo as it's the execution of the other half of pyvista/pyvista#719

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.