示例#1
0
 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)
示例#2
0
文件: engine.py 项目: PerryZh/mayavi
 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)
示例#3
0
 def __getstate__(self):
     """Allows standard pickle to work via the state_pickler.
     """
     return state_pickler.dumps(self)
示例#4
0
 def __getstate__(self):
     return state_pickler.dumps(self)
示例#5
0
 def __getstate__(self):
     return state_pickler.dumps(self)
示例#6
0
文件: base.py 项目: B-Rich/mayavi
 def __getstate__(self):
     """Allows standard pickle to work via the state_pickler.
     """
     return state_pickler.dumps(self)