enthought / mayavi

3D visualization of scientific data in Python
http://docs.enthought.com/mayavi/mayavi/
Other
1.3k stars 284 forks source link

Circle Cursor shape when work with pyqt #1150

Open ZhengXinyue opened 2 years ago

ZhengXinyue commented 2 years ago

Hi, I have built an app using mayavi and pyqt to visualize point cloud. I have an event loop(Qt Timer) to update the point cloud sources(In this code it updates with the same point cloud just as an example). It works well. The problem is that when updating data sources or adding new objects, the cursor shape changes to a circle, showing that the program is busy. The data update frequency is high so it affects user experience.(It will have an affect on the whole Qt program, not only the mayavi widget) Can I have the cursor shape fixed when updating and adding data?

https://user-images.githubusercontent.com/46396478/168440850-6c592c4c-bc16-4fa4-9aef-bac082b12e7b.mp4

class Visualization(HasTraits):
    scene = Instance(MlabSceneModel, ())

    view = View(Item('scene', editor=SceneEditor(scene_class=MayaviScene),
                     height=250, width=300, show_label=False),
                resizable=True)  # We need this to resize with the parent widget

class MyMainWindow(QMainWindow):
    def __init__(self):
        super(MyMainWindow, self).__init__()
        # self.ui = Ui_my_ui()
        # self.ui.setupUi(self)
        widget = QtWidgets.QWidget()
        self.setCentralWidget(widget)
        self.layout = QtWidgets.QVBoxLayout(widget)
        self.setWindowTitle('Test')

        self.vis = Visualization()
        m = self.vis.edit_traits(parent=self, kind='subpanel').control
        self.layout.addWidget(m)
        points = read_bin('../data_example/3d_detection/velodyne/000003.bin')
        self.current_point_clouds = points
        self.lidar_points = self.vis.scene.mlab.points3d(points[:, 0], points[:, 1], points[:, 2], points[:, 2],
                                                         mode='point', colormap='rainbow')

        timer = QtCore.QTimer(self)
        timer.timeout.connect(self.update_vis)
        timer.start(100)  # 10Hz, high frequency

    def update_vis(self):
        # update the data source and the cursor shape changes
        self.lidar_points.mlab_source.set(x=self.current_point_clouds[:, 0],
                                          y=self.current_point_clouds[:, 1],
                                          z=self.current_point_clouds[:, 2],
                                          scalars=self.current_point_clouds[:, 2])