Exemple #1
0
 def on_routes_set(self, df_routes):
     if not self.canvas_slave.df_routes.equals(df_routes):
         self.canvas_slave.df_routes = df_routes
         self.canvas_slave.set_surface('routes',
                                       self.canvas_slave.render_routes())
         self.canvas_slave.cairo_surface = flatten_surfaces(
             self.canvas_slave.df_surfaces)
         gtk.idle_add(self.canvas_slave.draw)
Exemple #2
0
 def on_electrode_states_set(self, states):
     if not (self.canvas_slave.electrode_states.equals(
             states['electrode_states'])):
         self.canvas_slave.electrode_states = states['electrode_states']
         self.canvas_slave.set_surface(
             'actuated_shapes', self.canvas_slave.render_actuated_shapes())
         self.canvas_slave.cairo_surface = flatten_surfaces(
             self.canvas_slave.df_surfaces)
         gtk.idle_add(self.canvas_slave.draw)
 def render(self):
     # Render each layer and update data frame with new content for each
     # surface.
     surface_names = ('background', 'shapes', 'connections', 'routes',
                      'channel_labels', 'actuated_shapes', 'registration')
     for k in surface_names:
         self.set_surface(k, getattr(self, 'render_' + k)())
     self.emit('surfaces-reset', self.df_surfaces)
     self.cairo_surface = flatten_surfaces(self.df_surfaces)
Exemple #4
0
 def on_canvas_slave__routes_set(self, slave, df_routes):
     '''
     .. versionadded:: 0.11.3
     '''
     self.canvas_slave.set_surface('routes',
                                   self.canvas_slave.render_routes())
     self.canvas_slave.cairo_surface = flatten_surfaces(self.canvas_slave
                                                        .df_surfaces)
     gtk.idle_add(self.canvas_slave.draw)
Exemple #5
0
 def render(self):
     # Render each layer and update data frame with new content for each
     # surface.
     surface_names = ('background', 'shapes', 'connections', 'routes',
                      'channel_labels', 'actuated_shapes', 'registration')
     for k in surface_names:
         self.set_surface(k, getattr(self, 'render_' + k)())
     self.emit('surfaces-reset', self.df_surfaces)
     self.cairo_surface = flatten_surfaces(self.df_surfaces)
Exemple #6
0
 def on_routes_set(self, df_routes):
     if not self.canvas_slave.df_routes.equals(df_routes):
         self.canvas_slave.df_routes = df_routes
         self.canvas_slave.set_surface('routes',
                                       self.canvas_slave.render_routes())
         self.canvas_slave.cairo_surface = flatten_surfaces(self
                                                            .canvas_slave
                                                            .df_surfaces)
         gtk.idle_add(self.canvas_slave.draw)
Exemple #7
0
 def on_electrode_states_set(self, states):
     if not (self.canvas_slave.electrode_states
             .equals(states['electrode_states'])):
         self.canvas_slave.electrode_states = states['electrode_states']
         self.canvas_slave.set_surface('actuated_shapes',
                                       self.canvas_slave
                                       .render_actuated_shapes())
         self.canvas_slave.cairo_surface = flatten_surfaces(self
                                                            .canvas_slave
                                                            .df_surfaces)
         gtk.idle_add(self.canvas_slave.draw)
Exemple #8
0
 def on_electrode_states_updated(self, states):
     updated_electrode_states = \
         states['electrode_states'].combine_first(self.canvas_slave
                                                  .electrode_states)
     if not (self.canvas_slave.electrode_states.equals(
             updated_electrode_states)):
         self.canvas_slave.electrode_states = updated_electrode_states
         self.canvas_slave.set_surface(
             'actuated_shapes', self.canvas_slave.render_actuated_shapes())
         self.canvas_slave.cairo_surface = flatten_surfaces(
             self.canvas_slave.df_surfaces)
         gtk.idle_add(self.canvas_slave.draw)
Exemple #9
0
 def on_electrode_states_updated(self, states):
     updated_electrode_states = \
         states['electrode_states'].combine_first(self.canvas_slave
                                                  .electrode_states)
     if not (self.canvas_slave.electrode_states
             .equals(updated_electrode_states)):
         self.canvas_slave.electrode_states = updated_electrode_states
         self.canvas_slave.set_surface('actuated_shapes',
                                       self.canvas_slave
                                       .render_actuated_shapes())
         self.canvas_slave.cairo_surface = flatten_surfaces(self
                                                            .canvas_slave
                                                            .df_surfaces)
         gtk.idle_add(self.canvas_slave.draw)
Exemple #10
0
    def on_dynamic_electrode_states_set(self, states):
        '''
        Render and draw updated **dynamic** electrode actuations layer on
        canvas.


        .. versionadded:: 0.12
        '''
        self.canvas_slave._dynamic_electrodes = states

        surface = self.canvas_slave.render_dynamic_electrode_state_shapes()
        self.canvas_slave.set_surface('dynamic_electrode_state_shapes',
                                      surface)
        self.canvas_slave.cairo_surface = flatten_surfaces(self.canvas_slave
                                                           .df_surfaces)
        gobject.idle_add(self.canvas_slave.draw)
Exemple #11
0
    def on_electrode_states_set(self, states):
        '''
        Render and draw updated **static** electrode actuations layer on
        canvas.
        '''
        if (self.canvas_slave.electrode_states
                .equals(states['electrode_states'])):
            return

        self.canvas_slave.electrode_states = states['electrode_states']

        surface = self.canvas_slave.render_static_electrode_state_shapes()
        self.canvas_slave.set_surface('static_electrode_state_shapes', surface)
        self.canvas_slave.cairo_surface = flatten_surfaces(self.canvas_slave
                                                           .df_surfaces)
        gobject.idle_add(self.canvas_slave.draw)
Exemple #12
0
    def on_frame_update(self, slave, np_frame):
        if self.widget.window is None:
            return
        if np_frame is None or not self._enabled:
            if 'video' in self.df_surfaces.index:
                self.df_surfaces.drop('video', axis=0, inplace=True)
                self.reorder_surfaces(self.df_surfaces.index)
        else:
            cr_warped, np_warped_view = np_to_cairo(np_frame)
            self.set_surface('video', cr_warped)
        self.cairo_surface = flatten_surfaces(self.df_surfaces)
        # Execute a few gtk main loop iterations to improve responsiveness when
        # using high video frame rates.
        #
        # N.B., Without doing this, for example, some mouse over events may be
        # missed, leading to problems drawing routes, etc.
        for i in xrange(5):
            if not gtk.events_pending():
                break
            gtk.main_iteration_do()

        self.draw()
    def on_frame_update(self, slave, np_frame):
        if self.widget.window is None:
            return
        if np_frame is None or not self._enabled:
            if 'video' in self.df_surfaces.index:
                self.df_surfaces.drop('video', axis=0, inplace=True)
                self.reorder_surfaces(self.df_surfaces.index)
        else:
            cr_warped, np_warped_view = np_to_cairo(np_frame)
            self.set_surface('video', cr_warped)
        self.cairo_surface = flatten_surfaces(self.df_surfaces)
        # Execute a few gtk main loop iterations to improve responsiveness when
        # using high video frame rates.
        #
        # N.B., Without doing this, for example, some mouse over events may be
        # missed, leading to problems drawing routes, etc.
        for i in xrange(5):
            if not gtk.events_pending():
                break
            gtk.main_iteration_do()

        self.draw()
 def reorder_surfaces(self, surface_names):
     assert(len(surface_names) == self.df_surfaces.shape[0])
     self.df_surfaces = self.df_surfaces.ix[surface_names]
     self.emit('surfaces-reset', self.df_surfaces)
     self.cairo_surface = flatten_surfaces(self.df_surfaces)
 def render(self):
     self.df_surfaces = pd.DataFrame([["shapes", self.render_shapes()]], columns=["name", "surface"])
     self.cairo_surface = flatten_surfaces(self.df_surfaces)
Exemple #16
0
 def on_layer_alpha_slave__alpha_changed(self, slave, name, alpha):
     logger.debug('[alpha changed] %s -> %.2f', name, alpha)
     self.canvas_slave.set_surface_alpha(name, alpha)
     self.canvas_slave.cairo_surface = flatten_surfaces(self.canvas_slave
                                                        .df_surfaces)
     gtk.idle_add(self.canvas_slave.draw)
 def render(self):
     self.df_surfaces = pd.DataFrame([['shapes', self.render_shapes()]],
                                     columns=['name', 'surface'])
     self.cairo_surface = flatten_surfaces(self.df_surfaces)
Exemple #18
0
 def on_layer_alpha_slave__alpha_changed(self, slave, name, alpha):
     logger.debug('[alpha changed] %s -> %.2f', name, alpha)
     self.canvas_slave.set_surface_alpha(name, alpha)
     self.canvas_slave.cairo_surface = flatten_surfaces(self.canvas_slave
                                                        .df_surfaces)
     gtk.idle_add(self.canvas_slave.draw)
Exemple #19
0
 def reorder_surfaces(self, surface_names):
     assert(len(surface_names) == self.df_surfaces.shape[0])
     self.df_surfaces = self.df_surfaces.ix[surface_names]
     self.emit('surfaces-reset', self.df_surfaces)
     self.cairo_surface = flatten_surfaces(self.df_surfaces)