def save_visualization(self, file_or_fname): """Given a file or a file name, this saves the current visualization to the file. """ # Save the state of VTK's global warning display. o = vtk.vtkObject w = o.GetGlobalWarningDisplay() o.SetGlobalWarningDisplay(0) # Turn it off. try: #FIXME: This is for streamline seed point widget position which #does not get serialized correctly if is_old_pipeline(): state_pickler.dump(self, file_or_fname) else: state = state_pickler.get_state(self) st = state.scenes[0].children[0].children[0].children[4] l_pos = st.seed.widget.position st.seed.widget.position = [pos.item() for pos in l_pos] saved_state = state_pickler.dumps(state) file_or_fname.write(saved_state) except (IndexError, AttributeError): state_pickler.dump(self, file_or_fname) finally: # Reset the warning state. o.SetGlobalWarningDisplay(w)
def __getstate__(self): """Allows standard pickle to work via the state_pickler. """ return state_pickler.dumps(self)
def __getstate__(self): return state_pickler.dumps(self)