Cannot show Volume on Plotter in qtwindow
See original GitHub issueI am following the code given in the examples but i could not get the volume view in qtwindow. I get a blank screen when i try to show Volume derived from ndarray but works fine on predefined shapes.
import sys
from PyQt5 import Qt
import numpy as np
from vtk.qt.QVTKRenderWindowInteractor import QVTKRenderWindowInteractor
from vtkplotter import Plotter, Volume, Cube, Sphere
class MainWindow(Qt.QMainWindow):
def __init__(self, parent=None):
Qt.QMainWindow.__init__(self, parent)
self.frame = Qt.QFrame()
self.vl = Qt.QVBoxLayout()
self.vtkWidget = QVTKRenderWindowInteractor(self.frame)
self.vl.addWidget(self.vtkWidget)
vp = Plotter(qtWidget=self.vtkWidget, bg='black')
c = Cube(side=30)
s = Sphere(r=15)
X, Y, Z = np.mgrid[:30, :30, :30]
scalar_field = ((X-15)**2 + (Y-15)**2 + (Z-15)**2)/225
vol = Volume(scalar_field)
vol.alpha([0, 0, 0.4, 0.9, 0.9])
# vp.show(c)
# vp.show(s)
vp.show(vol)
self.frame.setLayout(self.vl)
self.setCentralWidget(self.frame)
self.show() # <--- show the Qt Window
def onClose(self):
print("Disable the interactor before closing to prevent it from trying to act on a already deleted items")
self.vtkWidget.close()
if __name__ == "__main__":
app = Qt.QApplication(sys.argv)
window = MainWindow()
app.aboutToQuit.connect(window.onClose) # <-- connect the onClose event
app.exec_()
The same Volume can be rendered without Plotter
import numpy as np
from vtkplotter import Volume
def main():
X, Y, Z = np.mgrid[:30, :30, :30]
scalar_field = ((X-15)**2 + (Y-15)**2 + (Z-15)**2)/225
vol = Volume(scalar_field)
vol.alpha([0, 0, 0.4, 0.9, 0.9])
vol.show(bg="black")
if __name__ == '__main__':
main()
Issue Analytics
- State:
- Created 4 years ago
- Comments:8 (4 by maintainers)
Top Results From Across the Web
Cannot show Volume on Plotter in qtwindow · Issue #79 - GitHub
I get a blank screen when i try to show Volume derived from ndarray but works fine on predefined shapes. import sys from...
Read more >Plot an audio waveform in C++/Qt - Stack Overflow
This is a rough guide to how loud this area might sound, but there is no way to extract or use this RMS...
Read more >Qt Data Visualization Overview
Qt Data Visualization offers ready-made data proxies that can be used to visualize data from Qt item models and height maps. Each graph...
Read more >Comments/Forum - Qt Plotting Widget QCustomPlot
When i spawn multiple windows without plot widget resources are freed correctly. No matter if qcustomplot is added in qtcreator, staticly added ...
Read more >Clickable ROOT histograms in QT - ROOT Forum
Specifically I'd like to present the user with a TH2 COLZ type histogram and have each bin in the plot be click-able. ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Thanks @pasha009 ! I will add a comment in the example.
This workaround is functioning for me. But no idea why. Just added
before any vtk imports