Exemplo n.º 1
0
    def set_state_from_snapshot(self, session, data):
        self.name = data['name']
        self.id = data['id']
        p = data['parent']
        if p:
            p.add([self])

        pa = data['positions']
        from numpy import float32, float64
        if pa.dtype == float32:
            # Fix old sessions that saved array as float32
            pa = pa.astype(float64)
        from chimerax.geometry import Places
        self.positions = Places(place_array=pa)
        self.display_positions = data['display_positions']
        for d in self.all_drawings():
            for attr in [
                    'allow_depth_cue', 'accept_shadow', 'accept_multishadow'
            ]:
                if attr in data:
                    setattr(d, attr, data[attr])

        if 'clip_cap' in data:
            self.clip_cap = data['clip_cap']

        if 'drawing state' in data:
            from chimerax.graphics.gsession import DrawingState
            DrawingState.set_state_from_snapshot(self, session,
                                                 data['drawing state'])
            self.SESSION_SAVE_DRAWING = True
Exemplo n.º 2
0
 def restore_geometry(self, session, data):
     '''
     Restore model and drawing state saved with save_geometry().
     '''
     from chimerax.graphics.gsession import DrawingState
     Model.set_state_from_snapshot(self, session, data['model state'])
     DrawingState.set_state_from_snapshot(self, session,
                                          data['drawing state'])
     return self
Exemplo n.º 3
0
    def restore_snapshot(cls, session, data):
        from chimerax.graphics.gsession import DrawingState
        d = AtomicShapeDrawing('')
        DrawingState.set_state_from_snapshot(d, session, data['drawing'])
        d._shapes = [_AtomicShape(*args) for args in data['shapes']]
        d._selected_shapes.update([d._shapes[i] for i in data['selected']])
        if any(s.atoms for s in d._shapes):
            # After drawing is added to parent, add back the selection handler
            def post_shape_handler(trigger, trigger_data, drawing=d):
                from chimerax.core.triggerset import DEREGISTER
                drawing._add_handler_if_needed()
                return DEREGISTER

            session.triggers.add_handler("end restore session",
                                         post_shape_handler)
        return d