Monday 15 May 2023

Python VTKPlotLib how to remove existing mesh

I am running into an issue with the code below. When the button is hit the code should grab the next model and display it, however, the old mesh is still present in the image and doesn't go away. In VTKPlotLib how do you erase the previous mesh, without destroying the qtfigure and messing up the flow of gui application?

Example of the problem

'''

    vbox = QtWidgets.QVBoxLayout()
    self.setLayout(vbox)

    # Create the figure
    self.figure = vpl.QtFigure2()
    self.figure.add_preset_views()

    # Create a button and attach a callback.
    self.button = QtWidgets.QPushButton("Load Next Model")
    self.button.released.connect(self.button_pressed_cb)


    # Create a button and attach a callback.
    self.button2 = QtWidgets.QPushButton("Save Current Data")
    self.button2.released.connect(self.button_pressed_save)

    # QtFigures are QWidgets and are added to layouts with `addWidget`
    vbox.addWidget(self.figure)
    vbox.addWidget(self.button)

def button_pressed_cb(self):
    mesh = Mesh.from_file(self.modelid)
    vpl.mesh_plot(mesh_data=mesh, color="#94b1ff")

    # Reposition the camera to better fit to the balls.
    vpl.reset_camera(self.figure)

    # Without this the figure will not redraw unless you click on it.
    self.figure.update()

'''



from Python VTKPlotLib how to remove existing mesh

No comments:

Post a Comment