示例#1
0
文件: axes.py 项目: sjl421/code-2
 def __set_pure_state__(self, state):
     for prop in [
             'axes', '_property', '_title_text_property',
             '_label_text_property'
     ]:
         obj = getattr(self, prop)
         state_pickler.set_state(obj, state[prop])
示例#2
0
 def __set_pure_state__(self, state):
     # The reader has its own file_name which needs to be fixed.
     fname = state._file_path.abs_pth
     # Now call the parent class to setup everything.
     self.initialize(fname)
     # Setup the rest of the state.
     set_state(self, state, ignore=['_file_path'])
    def test_update(self):
        """Test if update method calls the handlers in order."""
        registry = version_registry.registry

        # First an elementary test.
        c = Classic()
        state = state_pickler.get_state(c)
        h = Handler()
        registry.register('Classic', '__main__', h.upgrade)
        c1 = state_pickler.create_instance(state)
        state_pickler.set_state(c1, state)
        self.assertEqual(h.calls, [('upgrade', state, 0)])
        # Remove the handler.
        registry.unregister('Classic', '__main__')

        # Now check to see if this works for inheritance trees.
        t = Test()
        state = state_pickler.get_state(t)
        h = Handler()
        registry.register('Classic', '__main__', h.upgrade)
        registry.register('New', '__main__', h.upgrade)
        registry.register('Test', '__main__', h.upgrade1)
        t1 = state_pickler.create_instance(state)
        state_pickler.set_state(t1, state)
        # This should call New handler, then the Test and then
        # Classic.
        self.assertEqual(h.calls, [('upgrade', state, 0),
                                   ('upgrade1', state, 1),
                                   ('upgrade', state.a, 0)])
示例#4
0
文件: text.py 项目: sjl421/code-2
 def __set_pure_state__(self, state):
     self._updating = True
     state_pickler.set_state(self,
                             state,
                             first=['actor'],
                             ignore=['_updating'])
     self._updating = False
示例#5
0
    def __set_pure_state__(self, state):
        # If we are already running, there is a problem since the
        # components will be started automatically in the module's
        # handle_components even though their state is not yet set call
        # so we disable it here and restart it later.
        running = self.running
        self.running = False

        # Remove the actor states since we don't want these unpickled.
        actor_st = state.pop('actor', None)
        contour_st = state.pop('contour', None)
        # Create and set the components.
        handle_children_state(self.components, state.components)
        components = self.components

        # Restore our state using set_state.
        state_pickler.set_state(self, state)

        # Now set our actor and component by finding the right one to get from
        # the state.
        if actor_st is not None:
            for cst, c in zip(state.components, components):
                actor = find_object_given_state(actor_st, cst, c)
                if actor is not None:
                    self.actor = actor
                    break
        if contour_st is not None:
            for cst, c in zip(state.components, components):
                contour = find_object_given_state(contour_st, cst, c)
                if contour is not None:
                    self.contour = contour
                    break
        # Now start all components if needed.
        self._start_components()
        self.running = running
示例#6
0
    def __set_pure_state__(self, state):
        # If we are already running, there is a problem since the
        # components will be started automatically in the module's
        # handle_components even though their state is not yet set call
        # so we disable it here and restart it later.
        running = self.running
        self.running = False

        # Remove the actor states since we don't want these unpickled.
        actor_st = state.pop('actor', None)
        contour_st = state.pop('contour', None)
        # Create and set the components.
        handle_children_state(self.components, state.components)
        components = self.components

        # Restore our state using set_state.
        state_pickler.set_state(self, state)

        # Now set our actor and component by finding the right one to get from
        # the state.
        if actor_st is not None:
            for cst, c in zip(state.components, components):
                actor = find_object_given_state(actor_st, cst, c)
                if actor is not None:
                    self.actor = actor
                    break
        if contour_st is not None:
            for cst, c in zip(state.components, components):
                contour = find_object_given_state(contour_st, cst, c)
                if contour is not None:
                    self.contour = contour
                    break
        # Now start all components if needed.
        self._start_components()
        self.running = running
示例#7
0
 def __setstate__(self, str_state):
     # This method is unnecessary since this object will almost
     # never be pickled by itself and only via an object that
     # contains it, therefore __init__ will be called when the
     # scene is constructed.  However, setstate is defined just for
     # completeness.
     state_pickler.set_state(self, state_pickler.loads_state(str_state))
示例#8
0
    def __set_pure_state__(self, state):
        # Pop the transformation matrix for the box widget.
        mat = state.pop('matrix')
        # Now set their state.
        set_state(self, state, first=['widget_mode'], ignore=['*'])
        # Set state of rest of the attributes ignoring the widget_mode.
        set_state(self, state, ignore=['widget_mode'])

        # Set the transformation for Box widget.
        tfm = tvtk.Transform()
        tfm.set_matrix(cPickle.loads(mat))
        w = self._widget_dict['Box']
        w.set_transform(tfm)

        # Some widgets need some cajoling to get their setup right.
        w = self.widget
        # Set the input.
        if len(self.inputs) > 0:
            w.input = self.inputs[0].outputs[0]
        w.update_traits()
        mode = self.widget_mode
        if mode == 'Plane':
            wd = state._widget_dict[mode]
            w.origin = wd.origin
            w.normal = wd.normal
            w.update_placement()
        self.update_implicit_function()
        # Set the widgets trait so that the widget is rendered if needed.
        self.widgets = [w]
示例#9
0
 def __set_pure_state__(self, state):
     # Do everything but our kids.
     set_state(self, state, ignore=['children'])
     # Setup children.
     handle_children_state(self.children, state.children)
     # Now setup the children.
     set_state(self, state, first=['children'], ignore=['*'])
示例#10
0
    def __set_pure_state__(self, state):
        # Pop the transformation matrix for the box widget.
        mat = state.pop('matrix')
        # Now set their state.
        set_state(self, state, first=['widget_mode'], ignore=['*'])
        # Set state of rest of the attributes ignoring the widget_mode.
        set_state(self, state, ignore=['widget_mode'])

        # Set the transformation for Box widget.
        tfm = tvtk.Transform()
        tfm.set_matrix(cPickle.loads(mat))
        w = self._widget_dict['Box']
        w.set_transform(tfm)

        # Some widgets need some cajoling to get their setup right.
        w = self.widget
        # Set the input.
        if len(self.inputs) > 0:
            w.input = self.inputs[0].outputs[0]
        w.update_traits()
        mode = self.widget_mode
        if mode == 'Plane':
            wd = state._widget_dict[mode]
            w.origin = wd.origin
            w.normal = wd.normal
            w.update_placement()
        self.update_implicit_function()
        # Set the widgets trait so that the widget is rendered if needed.
        self.widgets = [w]
示例#11
0
    def test_state_setter(self):
        """Test some of the features of the set_state method."""
        t = TestClassic()
        self.set_object(t)
        # Get the saved state.
        res = state_pickler.get_state(t)

        # Now create a new instance and test the setter.
        t1 = state_pickler.create_instance(res)

        keys = ['c', 'b', 'f', 'i', 'tuple', 'list', 'l', 'numeric',
                'n', 's', 'u', 'pure_list', 'inst', 'ref', 'dict']
        ignore = list(keys)
        ignore.remove('b')
        first = ['b']
        last = []
        state_pickler.set_state(t1, res, ignore=ignore, first=first, last=last)
        # Only 'b' should have been set.
        self.assertEqual(t1.b, True)
        # Rest are unchanged.
        self.assertEqual(t1.i, 7)
        self.assertEqual(t1.s, 'String')
        self.assertEqual(t1.u, u'Unicode')
        self.assertEqual(t1.inst.a, 'a')
        self.assertEqual(t1.list[0], 1)
        self.assertEqual(t1.tuple[-1].a, 'a')
        self.assertEqual(t1.dict['a'], 1)

        # Check if last works.
        last = ignore
        ignore = []
        first = []
        state_pickler.set_state(t1, res, ignore=ignore, first=first, last=last)
        # Check everything.
        self.verify_unpickled(t1, res)        
示例#12
0
 def __set_pure_state__(self, state):
     # The reader has its own file_name which needs to be fixed.
     fname = state._file_path.abs_pth
     # Now call the parent class to setup everything.
     self.initialize(fname)
     # Setup the rest of the state.
     set_state(self, state, ignore=['_file_path'])
示例#13
0
文件: volume.py 项目: sjl421/code-2
 def __set_pure_state__(self, state):
     self.volume_mapper_type = state['_volume_mapper_type']
     state_pickler.set_state(self, state, ignore=['ctf_state'])
     ctf_state = state['ctf_state']
     ctf, otf = load_ctfs(ctf_state, self._volume_property)
     self._ctf = ctf
     self._otf = otf
     self._update_ctf_fired()
示例#14
0
 def __set_pure_state__(self, state):
     # Do everything but our kids.
     set_state(self, state, ignore=['children'])
     # Setup children.
     handle_children_state(self.children, state.children)
     # Now setup the children.
     set_state(self, state, first=['children'], ignore=['*'])
     self.update()
示例#15
0
文件: base.py 项目: sjl421/code-2
 def _load_saved_state(self):
     """Load the saved state (if any) of this object.
     """
     saved_state = self._saved_state
     if len(saved_state) > 0:
         state = cPickle.loads(saved_state)
         if hasattr(self, '__set_pure_state__'):
             self.__set_pure_state__(state)
         else:
             state_pickler.set_state(self, state)
         self._saved_state = ''
示例#16
0
    def test_state_setter_classic(self):
        """Test if classic classes' state can be set."""
        t = TestClassic()
        self.set_object(t)
        # Get the pickled state.
        res = state_pickler.get_state(t)

        # Now create a new instance and set its state.
        t1 = state_pickler.create_instance(res)
        state_pickler.set_state(t1, res)
        # Check each attribute.
        self.verify_unpickled(t1, res)
示例#17
0
    def test_state_setter_classic(self):
        """Test if classic classes' state can be set."""
        t = TestClassic()
        self.set_object(t)
        # Get the pickled state.
        res = state_pickler.get_state(t)

        # Now create a new instance and set its state.
        t1 = state_pickler.create_instance(res)
        state_pickler.set_state(t1, res)
        # Check each attribute.
        self.verify_unpickled(t1, res)
示例#18
0
 def test_reference_cycle(self):
     """Test if reference cycles are handled when setting the state."""
     class A: pass
     class B: pass
     a = A()
     b = B()
     a.a = b
     b.b = a
     state = state_pickler.get_state(a)
     z = A()
     z.a = B()
     z.a.b = z
     state_pickler.set_state(z, state)
示例#19
0
 def __set_pure_state__(self, state):
     # Current number of scenes.
     n_scene = len(self.scenes)
     # Number of scenes in saved state.
     n_saved_scene = len(state.scenes)
     # Remove extra ones.
     for i in range(n_scene - n_saved_scene):
         self.close_scene(self.scenes[-1])
     # Add new ones.
     for i in range(n_saved_scene - n_scene):
         self.new_scene()
     # Set the state.
     state_pickler.set_state(self, state)
示例#20
0
 def __set_pure_state__(self, state):
     # Current number of scenes.
     n_scene = len(self.scenes)
     # Number of scenes in saved state.
     n_saved_scene = len(state.scenes)
     # Remove extra ones.
     for i in range(n_scene - n_saved_scene):
         self.close_scene(self.scenes[-1])
     # Add new ones.
     for i in range(n_saved_scene - n_scene):
         self.new_scene()
     # Set the state.
     state_pickler.set_state(self, state)
示例#21
0
    def __set_pure_state__(self, state):
        # Use the saved path to initialize the file_list and timestep.
        fname = state.file_path.abs_pth
        if not isfile(fname):
            msg = 'Could not find file at %s\n' % fname
            msg += 'Please move the file there and try again.'
            raise IOError, msg

        self.initialize(fname)
        # Now set the remaining state without touching the children.
        set_state(self, state, ignore=['children', 'file_path'])
        # Setup the children.
        handle_children_state(self.children, state.children)
        # Setup the children's state.
        set_state(self, state, first=['children'], ignore=['*'])
示例#22
0
 def __set_pure_state__(self, state):
     # Use the saved path to initialize the file_list and timestep.
     fname = state.file_path.abs_pth
     if not isfile(fname):
         msg = 'Could not find file at %s\n'%fname
         msg += 'Please move the file there and try again.'
         raise IOError, msg
     
     self.initialize(fname)
     # Now set the remaining state without touching the children.
     set_state(self, state, ignore=['children', 'file_path'])
     # Setup the children.
     handle_children_state(self.children, state.children)
     # Setup the children's state.
     set_state(self, state, first=['children'], ignore=['*'])
示例#23
0
 def __set_pure_state__(self, state):
     z = state.data
     if z is not None:
         d = gunzip_string(z)
         r = tvtk.DataSetReader(read_from_input_string=1, input_string=d)
         warn = r.global_warning_display
         r.global_warning_display = 0
         r.update()
         r.global_warning_display = warn
         self.data = r.output
     # Now set the remaining state without touching the children.
     set_state(self, state, ignore=['children', 'data'])
     # Setup the children.
     handle_children_state(self.children, state.children)
     # Setup the children's state.
     set_state(self, state, first=['children'], ignore=['*'])
示例#24
0
    def test_reference_cycle(self):
        """Test if reference cycles are handled when setting the state."""
        class A:
            pass

        class B:
            pass

        a = A()
        b = B()
        a.a = b
        b.b = a
        state = state_pickler.get_state(a)
        z = A()
        z.a = B()
        z.a.b = z
        state_pickler.set_state(z, state)
示例#25
0
 def __set_pure_state__(self, state):
     z = state.data
     if z is not None:
         d = gunzip_string(z)
         r = tvtk.DataSetReader(read_from_input_string=1,
                                input_string=d)
         warn = r.global_warning_display
         r.global_warning_display = 0
         r.update()
         r.global_warning_display = warn
         self.data = r.output
     # Now set the remaining state without touching the children.
     set_state(self, state, ignore=['children', 'data'])
     # Setup the children.
     handle_children_state(self.children, state.children)
     # Setup the children's state.
     set_state(self, state, first=['children'], ignore=['*'])
示例#26
0
    def __set_pure_state__(self):
        # The reader has its own file_name which needs to be fixed.
        state.reader.file_name = state._file_path.abs_path
        # Now call the parent class to setup everything.
        # Use the saved path to initialize the file_list and timestep.
        fname = state._file_path.abs_pth
        if not isfile(fname):
            msg = 'Could not find file at %s\n' % fname
            msg += 'Please move the file there and try again.'
            raise IOError, msg

        self.initialize(fname)
        # Now set the remaining state without touching the children.
        set_state(self, state, ignore=['children', '_file_path'])
        # Setup the children
        handle_children_state(self.children, state.children)
        # Setup the children's state.
        set_state(self, state, first=['children'], ignore=['*'])
示例#27
0
 def __set_pure_state__(self, state):
     self._unpickling = True
     # First create all the allowed widgets in the widget_list attr.
     handle_children_state(self.widget_list, state.widget_list)
     # Now set their state.
     set_state(self, state, first=['widget_list'], ignore=['*'])
     # Set the widget attr depending on value saved.
     m = [x.__class__.__name__ for x in self.widget_list]
     w_c_name = state.widget.__metadata__['class_name']
     w = self.widget = self.widget_list[m.index(w_c_name)]
     # Set the input.
     if len(self.inputs) > 0:
         w.input = self.inputs[0].outputs[0]
     # Fix for the point widget.
     if w_c_name == 'PointWidget':
         w.place_widget()
     # Set state of rest of the attributes ignoring the widget_list.
     set_state(self, state, ignore=['widget_list'])
     # Some widgets need some cajoling to get their setup right.
     w.update_traits()
     if w_c_name == 'PlaneWidget':
         w.origin = state.widget.origin
         w.normal = state.widget.normal
         w.update_placement()
         w.get_poly_data(self.poly_data)
     elif w_c_name == 'SphereWidget':
         # XXX: This hack is necessary because the sphere widget
         # does not update its poly data even when its ivars are
         # set (plus it does not have an update_placement method
         # which is a bug).  So we force this by creating a similar
         # sphere source and copy its output.
         s = tvtk.SphereSource(center=w.center,
                               radius=w.radius,
                               theta_resolution=w.theta_resolution,
                               phi_resolution=w.phi_resolution,
                               lat_long_tessellation=True)
         s.update()
         self.poly_data.shallow_copy(s.output)
     else:
         w.get_poly_data(self.poly_data)
     self._unpickling = False
     # Set the widgets trait so that the widget is rendered if needed.
     self.widgets = [w]
示例#28
0
    def __set_pure_state__(self, state):
        z = state.data
        if z:
            d = gunzip_string(z)
            m = re.search('(?<=Filename:)\w+', header)
            file_name = m.group(0)
            m = re.search('(?<=NX:)\w+', d)
            self.nx_redu = int(m.group(0))
            m = re.search('(?<=NX:)\w+', d)
            self.ny_redu = int(m.group(0))
            m = re.search('(?<=NX:)\w+', d)
            self.nz_redu = int(m.group(0))

            if not isfile(file_name):
                msg = 'Could not find file at %s\n' % file_name
                msg += 'Please move the file there and try again.'
                raise IOError, msg

            (step, modelname, metafilepath, filepath) = parsemodel(file_name)
            file_name = metafilepath

            self.filename = file_name

            #self.data = self.citcomshdftougrid.initialize(self.filename,0,0,0,0,False,False)
            f = tables.openFile(file_name, 'r')
            self.nx = int(f.root.input._v_attrs.nodex)
            self.ny = int(f.root.input._v_attrs.nodey)
            self.nz = int(f.root.input._v_attrs.nodez)

            #self.timesteps = int(f.root.time.nrows)

            f.close()
            self.data = self.citcomshdftougrid.initialize(
                self.filename, self.current_timestep, self.nx_redu,
                self.ny_redu, self.nz_redu)
            self.data_changed = True
            self._update_data()
            # Now set the remaining state without touching the children.
            set_state(self, state, ignore=['children', '_file_path'])
            # Setup the children.
            handle_children_state(self.children, state.children)
            # Setup the children's state.
            set_state(self, state, first=['children'], ignore=['*'])
示例#29
0
 def __set_pure_state__(self, state):
     self._unpickling = True
     # First create all the allowed widgets in the widget_list attr.
     handle_children_state(self.widget_list, state.widget_list)
     # Now set their state.
     set_state(self, state, first=['widget_list'], ignore=['*'])
     # Set the widget attr depending on value saved.
     m = [x.__class__.__name__ for x in self.widget_list]
     w_c_name = state.widget.__metadata__['class_name']
     w = self.widget = self.widget_list[m.index(w_c_name)]
     # Set the input.
     if len(self.inputs) > 0:
         w.input = self.inputs[0].outputs[0]
     # Fix for the point widget.
     if w_c_name == 'PointWidget':
         w.place_widget()
     # Set state of rest of the attributes ignoring the widget_list.
     set_state(self, state, ignore=['widget_list'])
     # Some widgets need some cajoling to get their setup right.
     w.update_traits()
     if w_c_name == 'PlaneWidget':
         w.origin = state.widget.origin
         w.normal = state.widget.normal
         w.update_placement()
         w.get_poly_data(self.poly_data)
     elif w_c_name == 'SphereWidget':
         # XXX: This hack is necessary because the sphere widget
         # does not update its poly data even when its ivars are
         # set (plus it does not have an update_placement method
         # which is a bug).  So we force this by creating a similar
         # sphere source and copy its output.
         s = tvtk.SphereSource(center=w.center, radius=w.radius,
                               theta_resolution=w.theta_resolution,
                               phi_resolution=w.phi_resolution,
                               lat_long_tessellation=True)
         s.update()
         self.poly_data.shallow_copy(s.output)
     else:
         w.get_poly_data(self.poly_data)
     self._unpickling = False
     # Set the widgets trait so that the widget is rendered if needed.
     self.widgets = [w]
示例#30
0
    def __set_pure_state__(self, state):
        z = state.data
        if z:
            d = gunzip_string(z)
            m = re.search('(?<=Filename:)\w+', header)
            file_name = m.group(0)
            m = re.search('(?<=NX:)\w+', d)
            self.nx_redu = int(m.group(0))
            m = re.search('(?<=NX:)\w+', d)
            self.ny_redu = int(m.group(0))
            m = re.search('(?<=NX:)\w+', d)
            self.nz_redu = int(m.group(0))
        
            if not isfile(file_name):
                msg = 'Could not find file at %s\n'%file_name
                msg += 'Please move the file there and try again.'
                raise IOError, msg
            
            (step, modelname, metafilepath, filepath) = parsemodel(file_name)
            file_name = metafilepath
            
            self.filename = file_name
        
            #self.data = self.citcomshdftougrid.initialize(self.filename,0,0,0,0,False,False)
            f = tables.openFile(file_name,'r')
            self.nx = int(f.root.input._v_attrs.nodex)
            self.ny = int(f.root.input._v_attrs.nodey)
            self.nz = int(f.root.input._v_attrs.nodez)
        
            #self.timesteps = int(f.root.time.nrows)

            f.close()
            self.data = self.citcomshdftougrid.initialize(self.filename,self.current_timestep,self.nx_redu,self.ny_redu,self.nz_redu)
            self.data_changed = True
            self._update_data()
            # Now set the remaining state without touching the children.
            set_state(self, state, ignore=['children', '_file_path'])
            # Setup the children.
            handle_children_state(self.children, state.children)
            # Setup the children's state.
            set_state(self, state, first=['children'], ignore=['*'])
示例#31
0
    def test_state_setter(self):
        """Test some of the features of the set_state method."""
        t = TestClassic()
        self.set_object(t)
        # Get the saved state.
        res = state_pickler.get_state(t)

        # Now create a new instance and test the setter.
        t1 = state_pickler.create_instance(res)

        keys = [
            'c', 'b', 'f', 'i', 'tuple', 'list', 'l', 'numeric', 'n', 's', 'u',
            'pure_list', 'inst', 'ref', 'dict'
        ]
        ignore = list(keys)
        ignore.remove('b')
        first = ['b']
        last = []
        state_pickler.set_state(t1, res, ignore=ignore, first=first, last=last)
        # Only 'b' should have been set.
        self.assertEqual(t1.b, True)
        # Rest are unchanged.
        self.assertEqual(t1.i, 7)
        self.assertEqual(t1.s, 'String')
        self.assertEqual(t1.u, u'Unicode')
        self.assertEqual(t1.inst.a, 'a')
        self.assertEqual(t1.list[0], 1)
        self.assertEqual(t1.tuple[-1].a, 'a')
        self.assertEqual(t1.dict['a'], 1)

        # Check if last works.
        last = ignore
        ignore = []
        first = []
        state_pickler.set_state(t1, res, ignore=ignore, first=first, last=last)
        # Check everything.
        self.verify_unpickled(t1, res)
示例#32
0
 def __set_pure_state__(self, state):
     xyz_fn = state.xyz_file_path.abs_pth
     q_fn = state.q_file_path.abs_pth
     if not isfile(xyz_fn):
         msg = 'Could not find file at %s\n'%xyz_fn
         msg += 'Please move the file there and try again.'
         raise IOError, msg
     
     # Setup the reader state.
     set_state(self, state, first=['reader'], ignore=['*'])
     # Initialize the files.
     self.initialize(xyz_fn, q_fn, configure=False)
     # Now set the remaining state without touching the children.
     set_state(self, state, ignore=['children', 'xyz_file_path', 'q_file_path'])
     # Setup the children.
     handle_children_state(self.children, state.children)
     # Setup the children's state.
     set_state(self, state, first=['children'], ignore=['*'])
示例#33
0
    def __set_pure_state__(self, state):
        xyz_fn = state.xyz_file_path.abs_pth
        q_fn = state.q_file_path.abs_pth
        if not isfile(xyz_fn):
            msg = 'Could not find file at %s\n' % xyz_fn
            msg += 'Please move the file there and try again.'
            raise IOError, msg

        # Setup the reader state.
        set_state(self, state, first=['reader'], ignore=['*'])
        # Initialize the files.
        self.initialize(xyz_fn, q_fn, configure=False)
        # Now set the remaining state without touching the children.
        set_state(self,
                  state,
                  ignore=['children', 'xyz_file_path', 'q_file_path'])
        # Setup the children.
        handle_children_state(self.children, state.children)
        # Setup the children's state.
        set_state(self, state, first=['children'], ignore=['*'])
示例#34
0
 def __set_pure_state__(self, state):
     if 'glyph_dict' in state:
         # Set their state.
         set_state(self, state, first=['glyph_dict'], ignore=['*'])
         ignore = ['glyph_dict']
     else:
         # Set the dict state using the persisted list.
         gd = self.glyph_dict
         gl = self.glyph_list
         handle_children_state(gl, state.glyph_list)
         for g, gs in zip(gl, state.glyph_list):
             name = camel2enthought(g.__class__.__name__)
             if name not in gd:
                 gd[name] = g
             # Set the glyph source's state.
             set_state(g, gs)
         ignore = ['glyph_list']
     g_name = state.glyph_source.__metadata__['class_name']
     name = camel2enthought(g_name)
     # Set the correct glyph_source.
     self.glyph_source = self.glyph_dict[name]
     set_state(self, state, ignore=ignore)
示例#35
0
 def __set_pure_state__(self, state):
     if 'glyph_dict' in state:
         # Set their state.
         set_state(self, state, first=['glyph_dict'], ignore=['*'])
         ignore = ['glyph_dict']
     else:
         # Set the dict state using the persisted list.
         gd = self.glyph_dict
         gl = self.glyph_list
         handle_children_state(gl, state.glyph_list)
         for g, gs in zip(gl, state.glyph_list):
             name = camel2enthought(g.__class__.__name__)
             if name not in gd:
                 gd[name] = g
             # Set the glyph source's state.
             set_state(g, gs)
         ignore = ['glyph_list']
     g_name = state.glyph_source.__metadata__['class_name']
     name = camel2enthought(g_name)
     # Set the correct glyph_source.
     self.glyph_source = self.glyph_dict[name]
     set_state(self, state, ignore=ignore)
示例#36
0
 def __setstate__(self, str_state):
     self.__init__()
     state_pickler.set_state(self, state_pickler.loads_state(str_state))
示例#37
0
文件: scene.py 项目: sjl421/code-2
 def __set_pure_state__(self, state):
     handle_children_state(self.children, state.children)
     # Now set our complete state.  Doing the scene last ensures
     # that the camera view is set right.
     set_state(self, state, last=['scene'])
示例#38
0
 def __set_pure_state__(self, state):
     for prop in ['axes', '_property', '_title_text_property',
                  '_label_text_property']:
         obj = getattr(self, prop)
         state_pickler.set_state(obj, state[prop])
示例#39
0
 def __set_pure_state__(self, state):
     self._updating = True
     state_pickler.set_state(self, state, first=['actor'],
                             ignore=['_updating'])
     self._updating = False
示例#40
0
 def __set_pure_state__(self, state):
     mat = state.pop('matrix')
     super(TransformData, self).__set_pure_state__(state)
     state_pickler.set_state(self, state)
     self._transform.set_matrix(cPickle.loads(mat))
     self.widget.set_transform(self._transform)
示例#41
0
 def __set_pure_state__(self, state):
     state_pickler.set_state(self, state)
     self._position_changed(self.position)
示例#42
0
 def __set_pure_state__(self, state):
     mat = state.pop('matrix')
     super(DataSetClipper, self).__set_pure_state__(state)
     state_pickler.set_state(self, state)
     self._transform.set_matrix(cPickle.loads(mat))
     self.widget.set_transform(self._transform)
示例#43
0
 def __set_pure_state__(self, state):
     handle_children_state(self.children, state.children)
     # Now set our complete state.  Doing the scene last ensures
     # that the camera view is set right.
     set_state(self, state, last=["scene"])
示例#44
0
 def __set_pure_state__(self, state):
     for prop in ["axes", "marker", "_text_property"]:
         obj = getattr(self, prop)
         state_pickler.set_state(obj, state[prop])
示例#45
0
 def __set_pure_state__(self, state):
     first = ['light_mode', 'number_of_lights']
     state_pickler.set_state(self, state, first=first, last=['lights'])
示例#46
0
 def __setstate__(self, str_state):
     self.__init__()
     state_pickler.set_state(self, state_pickler.loads_state(str_state))
示例#47
0
 def __set_pure_state__(self, state):
     first = ['light_mode', 'number_of_lights']
     state_pickler.set_state(self, state, first=first, last=['lights'])
示例#48
0
 def __set_pure_state__(self, state):
     state_pickler.set_state(self, state)
     self._position_changed(self.position)
示例#49
0
 def __set_pure_state__(self, state):
     handle_children_state(self.components, state.components)
     state_pickler.set_state(self, state)
     self.update_pipeline()
示例#50
0
文件: labels.py 项目: sjl421/code-2
 def __set_pure_state__(self, state):
     handle_children_state(self.components, state.components)
     state_pickler.set_state(self, state)
     self.update_pipeline()