• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python common.error函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中mayavi.core.common.error函数的典型用法代码示例。如果您正苦于以下问题:Python error函数的具体用法?Python error怎么用?Python error使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了error函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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]
开发者ID:PerryZh,项目名称:mayavi,代码行数:28,代码来源:custom_grid_plane.py


示例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()
开发者ID:PerryZh,项目名称:mayavi,代码行数:27,代码来源:extract_grid.py


示例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()
开发者ID:B-Rich,项目名称:mayavi,代码行数:31,代码来源:poly_data_reader.py


示例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
开发者ID:bergtholdt,项目名称:mayavi,代码行数:25,代码来源:slice_unstructured_grid.py


示例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
开发者ID:GaelVaroquaux,项目名称:mayavi,代码行数:27,代码来源:labels.py


示例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
开发者ID:B-Rich,项目名称:mayavi,代码行数:7,代码来源:user_defined.py


示例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))
开发者ID:B-Rich,项目名称:mayavi,代码行数:27,代码来源:save_load.py


示例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]
开发者ID:zoulianmp,项目名称:mftm,代码行数:26,代码来源:mphantom_actions.py


示例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))
开发者ID:GaelVaroquaux,项目名称:mayavi,代码行数:7,代码来源:vtk_xml_file_reader.py


示例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__)
开发者ID:GaelVaroquaux,项目名称:mayavi,代码行数:25,代码来源:common.py


示例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])
开发者ID:GaelVaroquaux,项目名称:mayavi,代码行数:27,代码来源:transform_data.py


示例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__)
开发者ID:PerryZh,项目名称:mayavi,代码行数:33,代码来源:common.py


示例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
开发者ID:arkyaC,项目名称:mayavi,代码行数:31,代码来源:volume.py


示例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
开发者ID:PerryZh,项目名称:mayavi,代码行数:30,代码来源:sources.py


示例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)]
开发者ID:GaelVaroquaux,项目名称:mayavi,代码行数:34,代码来源:grid_plane.py


示例16: open

 def open(self, filename, scene=None):
     """Open a file given a filename if possible in either the
     current scene or the passed `scene`.
     """
     passed_scene = scene
     reader = registry.get_file_reader(filename)
     if reader is None:
         msg = 'No suitable reader found for the file %s'%filename
         error(msg)
     else:
         src = None
         if scene is None:
             scene = self.current_scene
         if scene is None:
             scene = self.new_scene()
         try:
             sc = scene.scene
             if sc is not None:
                 sc.busy = True
             callable = reader.get_callable()
             if reader.factory is None:
                 src = callable()
                 src.initialize(filename)
             else:
                 # Factory functions are passed the filename and a
                 # reference to the engine.
                 src = callable(filename, self)
             if src is not None:
                 self.add_source(src, passed_scene)
         finally:
             if sc is not None:
                 sc.busy = False
         if src is not None:
             return src
开发者ID:GaelVaroquaux,项目名称:mayavi,代码行数:34,代码来源:engine.py


示例17: _update_reader_output

    def _update_reader_output(self):
        r = self.reader
        r.update()

        if r.error_code != 0:
            try:
                self.reader.i_blanking = True
            except AttributeError:
                pass
            else:
                r.update()

        # Try reading file.
        if r.error_code != 0:
            # No output so the file might be an ASCII file.
            try:
                # Turn off IBlanking.
                r.trait_set(i_blanking=False, binary_file=False)
            except AttributeError:
                pass
            else:
                r.update()

        # Try again this time as ascii and with blanking.
        if r.error_code != 0:
            # No output so the file might be an ASCII file.
            try:
                # Turn on IBlanking.
                r.i_blanking = True
            except AttributeError:
                pass
            else:
                r.update()

        # If there still is an error, ask the user.
        if r.error_code != 0:
            r.edit_traits(kind='livemodal')
            r.update()

        # If there still is an error, ask the user to retry.
        if r.error_code != 0:
            msg = 'Unable to read file properly. '\
                  'Please check the settings of the reader '\
                  'on the UI and press the "Update Reader" button '\
                  'when done and try again!'
            error(msg)
            return

        # Now setup the outputs by resetting self.outputs.  Changing
        # the outputs automatically fires a pipeline_changed event.
        self.outputs = [r]

        # Fire data_changed just in case the outputs are not
        # really changed.  This can happen if the dataset is of
        # the same type as before.
        self.data_changed = True

        # Change our name on the tree view
        self.name = self._get_name()
开发者ID:bergtholdt,项目名称:mayavi,代码行数:59,代码来源:plot3d_reader.py


示例18: save_output

 def save_output(self, fname):
     """Save our output (by default the first of our outputs) to the
     specified filename as a VTK file.  Both old style and new style
     XML files are supported.
     """
     if len(self.outputs) > 0:
         write_data(self.get_output_dataset(), fname)
     else:
         error('Object has no outputs to save!')
开发者ID:bergtholdt,项目名称:mayavi,代码行数:9,代码来源:source.py


示例19: setup_filter

 def setup_filter(self):
     """Setup the filter if none has been set or check it if it
     already has been."""
     obj = self.filter
     if not self._check_object(obj):
         if obj is not None:
             cname = obj.__class__.__name__
             error('Invalid filter %s chosen!  Try again!'%cname)
         obj = self._choose_filter()
         self.filter = obj
开发者ID:B-Rich,项目名称:mayavi,代码行数:10,代码来源:user_defined.py


示例20: open_help_index

def open_help_index():
    """ Open the mayavi user manual index in a browser.
    """
    # If the HTML_DIR was found, bring up the documentation in a
    # web browser.  Otherwise, bring up an error message.
    if HTML_DIR:
        auto_close_message("Opening help in web browser...")
        browser_open(join(HTML_DIR, 'index.html'))
    else:
        error("Could not find the user guide in your installation " \
            "or the source tree.")
开发者ID:B-Rich,项目名称:mayavi,代码行数:11,代码来源:help.py



注:本文中的mayavi.core.common.error函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python null_engine.NullEngine类代码示例发布时间:2022-05-27
下一篇:
Python utils.executeDeferred函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap