本文整理汇总了Python中mayavi.core.common.error函数的典型用法代码示例。如果您正苦于以下问题:Python error函数的具体用法?Python error怎么用?Python error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了error函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: update_pipeline
def update_pipeline(self):
"""Override this method so that it *updates* the tvtk pipeline
when data upstream is known to have changed.
This method is invoked (automatically) when the input fires a
`pipeline_changed` event.
"""
if len(self.inputs) == 0:
return
input = self.inputs[0].get_output_dataset()
plane = None
if input.is_a('vtkStructuredGrid'):
plane = tvtk.StructuredGridGeometryFilter()
elif input.is_a('vtkStructuredPoints') or input.is_a('vtkImageData'):
plane = tvtk.ImageDataGeometryFilter ()
elif input.is_a('vtkRectilinearGrid'):
plane = tvtk.RectilinearGridGeometryFilter ()
else:
msg = "The GridPlane component does not support the %s dataset."\
%(input.class_name)
error(msg)
raise TypeError(msg)
self.configure_connection(plane, self.inputs[0])
self.plane = plane
self._update_limits()
self._update_voi()
self.outputs = [plane]
示例2: update_pipeline
def update_pipeline(self):
inputs = self.inputs
if len(inputs) == 0:
return
input = inputs[0].get_output_dataset()
mapping = {'vtkStructuredGrid': tvtk.ExtractGrid,
'vtkRectilinearGrid': tvtk.ExtractRectilinearGrid,
'vtkImageData': tvtk.ExtractVOI}
for key, klass in mapping.items():
if input.is_a(key):
self.filter = klass()
break
else:
error('This filter does not support %s objects'%\
(input.__class__.__name__))
return
fil = self.filter
self.configure_connection(fil, inputs[0])
fil.update_whole_extent()
fil.update()
self._set_outputs([fil])
self._update_limits()
self._update_voi()
self._update_sample_rate()
示例3: _file_path_changed
def _file_path_changed(self, fpath):
value = fpath.get()
if len(value) == 0:
return
# Extract the file extension
splitname = value.strip().split('.')
extension = splitname[-1].lower()
# Select polydata reader based on file type
old_reader = self.reader
if self._reader_dict.has_key(extension):
self.reader = self._reader_dict[extension]
else:
error('Invalid extension for file: %s'%value)
return
self.reader.file_name = value.strip()
self.reader.update()
self.reader.update_information()
if old_reader is not None:
old_reader.on_trait_change(self.render, remove=True)
self.reader.on_trait_change(self.render)
old_outputs = self.outputs
self.outputs = [self.reader.output]
if self.outputs == old_outputs:
self.data_changed = True
# Change our name on the tree view
self.name = self._get_name()
示例4: update_pipeline
def update_pipeline(self):
"""Override this method so that it *updates* the tvtk pipeline
when data upstream is known to have changed.
This method is invoked (automatically) when any of the inputs
sends a `pipeline_changed` event.
"""
mod_mgr = self.module_manager
if mod_mgr is None:
return
# Data is available, so set the input for the grid plane.
input = mod_mgr.source.get_output_dataset()
if not input.is_a('vtkUnstructuredGrid'):
error('SliceUnstructuredGrid only works with input '\
'unstructured grids')
self.implicit_plane.inputs = [mod_mgr.source]
src = self.module_manager.source
self.configure_connection(self.extract_geometry, src)
# Set the LUT for the mapper.
self.actor.set_lut(self.module_manager.scalar_lut_manager.lut)
# Now flush the pipeline
self.pipeline_changed = True
示例5: _find_input
def _find_input(self):
mm = self.module_manager
if self.object is None:
if self.object_id == -1:
self.input = mm.source
elif self.object_id > -1:
obj = mm.children[self.object_id]
if hasattr(obj, 'actor'):
self.set(object=obj, trait_change_notify=False)
self.input = obj.actor.inputs[0]
else:
self.input = mm.source
else:
o = self.object
if hasattr(o, 'module_manager'):
# A module.
if hasattr(o, 'actor'):
self.input = o.actor.inputs[0]
else:
self.input = o.module_manager.source
if self.input is None:
if self.object_id == -2:
self.input = mm.source
else:
error('No object to label!')
return
示例6: _choose_filter
def _choose_filter(self):
chooser = TVTKFilterChooser()
chooser.edit_traits(kind='livemodal')
obj = chooser.object
if obj is None:
error('Invalid filter chosen! Try again!')
return obj
示例7: perform
def perform(self, event):
""" Performs the action. """
wildcard = 'Python files (*.py)|*.py'
parent = self.window.control
dialog = FileDialog(parent=parent,
title='Open Python file',
action='open', wildcard=wildcard
)
if dialog.open() == OK:
if not isfile(dialog.path):
error("File '%s' does not exist"%dialog.path, parent)
return
# Get the globals.
# The following code is taken from scripts/mayavi2.py.
g = sys.modules['__main__'].__dict__
if 'mayavi' not in g:
mv = get_imayavi(self.window)
g['mayavi'] = mv
g['engine'] = mv.engine
# Do execfile
try:
# If we don't pass globals twice we get NameErrors and nope,
# using exec open(script_name).read() does not fix it.
execfile(dialog.path, g, g)
except Exception, msg:
exception(str(msg))
示例8: perform
def perform(self,event):
"""Perform the Save Phantom Action """
wildcard = 'MagicalPhantom files (*.mp)|*.mp|' + FileDialog.WILDCARD_ALL
parent = self.window.control
dialog = FileDialog(parent=parent,
title = 'Open MagicalPhantom file',
action = 'open',wildcard = wildcard)
if dialog.open()==OK:
if not isfile(dialog.path):
error("File '%s' does not exist"%dialog.path,parent)
return
run_manager = self.window.application.get_service('mphantom.api.RunManager')
phantom = run_manager.model
print dialog.path
phantom.clear_phantom()
phantom.load_phantom(dialog.path)
self.window.active_perspective = self.window.perspectives[1]
示例9: find_file_data_type
def find_file_data_type(file_name):
"Parses the named file to see what type of data there is."
r = tvtk.XMLFileReadTester(file_name=file_name)
if r.test_read_file():
return r.file_data_type
else:
error("File %s is not a valid VTK XML file!"%(file_name))
示例10: convert_to_poly_data
def convert_to_poly_data(data):
"""Given a VTK dataset object, this returns the data as PolyData.
This is primarily used to convert the data suitably for filters
that only work for PolyData.
"""
if data.is_a('vtkPolyData'):
return data
conv = {'vtkStructuredPoints': tvtk.ImageDataGeometryFilter,
'vtkImageData': tvtk.ImageDataGeometryFilter,
'vtkRectilinearGrid': tvtk.RectilinearGridGeometryFilter,
'vtkStructuredGrid': tvtk.StructuredGridGeometryFilter,
'vtkUnstructuredGrid':tvtk.GeometryFilter}
fil = None
for name, fil_class in conv.items():
if data.is_a(name):
fil = fil_class()
break
if fil is not None:
fil.input = data
return fil.output
else:
error('Given object is not a VTK dataset: %s'%data.__class__.__name__)
示例11: update_pipeline
def update_pipeline(self):
# Do nothing if there is no input.
inputs = self.inputs
if len(inputs) == 0:
return
inp = inputs[0].outputs[0]
if inp.is_a('vtkImageData') or inp.is_a('vtkRectilinearGrid'):
error('Transformation not supported for '\
'ImageData/StructuredPoints/RectilinearGrid')
return
# Set the input for the widget and place it if this hasn't
# been done before.
w = self.widget
w.input = inp
if self._first:
w.place_widget()
self._first = False
# By default we set the input to the first output of the first
# input.
fil = self.filter
fil.input = inp
fil.transform = self._transform
fil.update()
self._set_outputs([fil.output])
示例12: convert_to_poly_data
def convert_to_poly_data(obj):
"""Given a VTK dataset object, this returns the data as PolyData.
This is primarily used to convert the data suitably for filters
that only work for PolyData.
"""
if obj.is_a('vtkDataSet'):
data = obj
else:
# FIXME
data = obj.output
if obj.is_a('vtkPolyData') or data.is_a('vtkPolyData'):
return obj
conv = {'vtkStructuredPoints': tvtk.ImageDataGeometryFilter,
'vtkImageData': tvtk.ImageDataGeometryFilter,
'vtkRectilinearGrid': tvtk.RectilinearGridGeometryFilter,
'vtkStructuredGrid': tvtk.StructuredGridGeometryFilter,
'vtkUnstructuredGrid':tvtk.GeometryFilter}
fil = None
for name, fil_class in conv.items():
if data.is_a(name):
fil = fil_class()
break
if fil is not None:
configure_input(fil, obj)
fil.update()
return fil
else:
error('Given object is not a VTK dataset: %s'%data.__class__.__name__)
示例13: update_pipeline
def update_pipeline(self):
"""Override this method so that it *updates* the tvtk pipeline
when data upstream is known to have changed.
This method is invoked (automatically) when any of the inputs
sends a `pipeline_changed` event.
"""
mm = self.module_manager
if mm is None:
return
dataset = mm.source.get_output_dataset()
ug = hasattr(tvtk, 'UnstructuredGridVolumeMapper')
if ug:
if not dataset.is_a('vtkImageData') \
and not dataset.is_a('vtkUnstructuredGrid'):
error('Volume rendering only works with '\
'StructuredPoints/ImageData/UnstructuredGrid datasets')
return
elif not dataset.is_a('vtkImageData'):
error('Volume rendering only works with '\
'StructuredPoints/ImageData datasets')
return
self._setup_mapper_types()
self._setup_current_range()
self._volume_mapper_type_changed(self.volume_mapper_type)
self._update_ctf_fired()
self.pipeline_changed = True
示例14: perform
def perform(self, event):
""" Performs the action. """
mv = get_imayavi(self.window)
s = get_scene(mv)
if s is None:
return
wildcard = 'All files (*.*)|*.*'
for src in registry.sources:
if len(src.extensions) > 0:
if wildcard.endswith('|') or \
src.wildcard.startswith('|'):
wildcard += src.wildcard
else:
wildcard += '|' + src.wildcard
parent = self.window.control
dialog = FileDialog(parent=parent,
title='Open supported data file',
action='open', wildcard=wildcard
)
if dialog.open() == OK:
if not isfile(dialog.path):
error("File '%s' does not exist!"%dialog.path, parent)
return
# FIXME: Ask for user input if a filetype is unknown and
# choose appropriate reader.
src = mv.open(dialog.path)
if src is not None:
mv.engine.current_selection = src
示例15: update_pipeline
def update_pipeline(self):
"""Override this method so that it *updates* the tvtk pipeline
when data upstream is known to have changed.
This method is invoked (automatically) when the input fires a
`pipeline_changed` event.
"""
if len(self.inputs) == 0:
return
input = self.inputs[0].outputs[0]
plane = None
if input.is_a('vtkStructuredGrid'):
plane = tvtk.StructuredGridGeometryFilter()
elif input.is_a('vtkStructuredPoints') or input.is_a('vtkImageData'):
plane = tvtk.ImageDataGeometryFilter ()
elif input.is_a('vtkRectilinearGrid'):
plane = tvtk.RectilinearGridGeometryFilter ()
else:
msg = "The GridPlane component does not support the %s dataset."\
%(input.class_name)
error(msg)
raise TypeError, msg
plane.input = input
self.plane = plane
self.outputs = [plane.output]
self._update_limits()
self._update_extents()
# If the data is 2D make sure that we default to the
# appropriate axis.
extents = list(_get_extent(input))
diff = [y-x for x, y in zip(extents[::2], extents[1::2])]
if diff.count(0) > 0:
self.axis = ['x', 'y', 'z'][diff.index(0)]