def kpf_change_horizontal_line(self, symbol, modifiers, mod_offset):

        key_matched = False

        if symbol == key.T:  # set new position for horizontal line
            key_matched = True
            if modifiers == key.MOD_CTRL + mod_offset:
                # toggle display of horizontal line.
                if not self.SHOW_HORIZONTAL_LINE:
                    self.line_hor = line_default_horizontal(self.SETTINGS)
                self.SHOW_HORIZONTAL_LINE = not self.SHOW_HORIZONTAL_LINE
            elif modifiers == key.MOD_SHIFT + mod_offset:
                if self.SHOW_HORIZONTAL_LINE:
                    print "current threshold = %d" % self.line_hor.curr_pos
            else:
                if self.SHOW_HORIZONTAL_LINE:
                    self.line_hor.set_position_horizontal_line(
                        self.SETTINGS, 'Set new threshold',
                        'Threshold (currently %d) ' % self.line_hor.curr_pos)

        elif symbol == key.UP:  # move horizontal line up
            key_matched = True
            self.line_hor.move_horizontal_line_up(self.SETTINGS, modifiers,
                                                  key, mod_offset)

        elif symbol == key.DOWN:  # move horizontal line down
            key_matched = True
            self.line_hor.move_horizontal_line_down(self.SETTINGS, modifiers,
                                                    key, mod_offset)

        return key_matched
    def kpf_change_horizontal_line(self, symbol, modifiers, mod_offset):

        key_matched = False

        if symbol == key.T:  # set new position for horizontal line
            key_matched = True
            if modifiers == key.MOD_CTRL + mod_offset:
                # toggle display of horizontal line.
                if not self.SHOW_HORIZONTAL_LINE:
                    self.line_hor = line_default_horizontal(self.SETTINGS)
                self.SHOW_HORIZONTAL_LINE = not self.SHOW_HORIZONTAL_LINE
            elif modifiers == key.MOD_SHIFT + mod_offset:
                if self.SHOW_HORIZONTAL_LINE:
                    print "current threshold = %d" % self.line_hor.curr_pos
            else:
                if self.SHOW_HORIZONTAL_LINE:
                    self.line_hor.set_position_horizontal_line(
                        self.SETTINGS, "Set new threshold", "Threshold (currently %d) " % self.line_hor.curr_pos
                    )

        elif symbol == key.UP:  # move horizontal line up
            key_matched = True
            self.line_hor.move_horizontal_line_up(self.SETTINGS, modifiers, key, mod_offset)

        elif symbol == key.DOWN:  # move horizontal line down
            key_matched = True
            self.line_hor.move_horizontal_line_down(self.SETTINGS, modifiers, key, mod_offset)

        return key_matched
Example #3
0
    def setup(self):

        ''' 
            process custom settings that might have been set after initializing
            the object.  
        '''
        # check if these parameters / properties / attributes were actually set!
        self.USE_MMAP = getattr(self, 'receive_data_from_matlab', self.USE_MMAP)
        self.SETTINGS.COLOR_TO_USE = getattr(self, 'COLOR_TO_USE', self.SETTINGS.COLOR_TO_USE)

        # add 'abs_plugin_ID' to plugin name.
        self.PLUGIN_NAME = self.PLUGIN_NAME + '-' + str(self.abs_plugin_ID)


        ''' set variables based on init() values. '''
        self.Y_LIMS = [0, self.SETTINGS.WINDOW_HEIGHT_DEFAULT]
        self.SETTINGS.WINDOW_WIDTH_CURRENT = self.SETTINGS.WINDOW_WIDTH_DEFAULT
        self.SETTINGS.WINDOW_HEIGHT_CURRENT = self.SETTINGS.WINDOW_HEIGHT_DEFAULT

        ''' setup mmap or random data interface '''
        status, self.MMAP, self.RANDOM_DATA = setup_incoming_data_interface(self.USE_MMAP, self.PLUGIN_NAME, self.NBR_CHANNELS, self.nPointsToUpdate, self.nPoints, self.SETTINGS.WINDOW_WIDTH_CURRENT, self.SETTINGS.WINDOW_HEIGHT_CURRENT)
        if not status:
             sys.exit(1)


        ''' setup plot queue '''
        self.plot_queue = setup_plotting_queue()


        ''' generate initial positions & colors, and setup VOBs '''
        self.vbo_data, self.vbo_colors, self.x_coords, self.SETTINGS.COLOR_USED = \
            gl_setup_initial_data_and_color_and_vbos(self.nPoints, n_COORDINATES_PER_COLOR, self.NBR_CHANNELS, self.SETTINGS)


        ''' horizontal and vertical lines - setup even if user doesn't want 
            to see them, because we setup key press functions to en-/disable them. '''
        # horizontal line showing the threshold 
        self.line_hor = line_default_horizontal(self)

        # vertical line showing which data point is going to be update next 
        self.line_ver = line_default_vertical(self)

        ''' axes - setup even it user doesn't want to see it, because of kpf. '''
        self.coord_axes, self.y_axis_tics = axes_default_with_y_ticks(self)


        ''' other stuff '''
        # is Tkinter installed and running?
        self.SETTINGS = tkinter_register_with_settings(self.SETTINGS)

        # set the window caption. Can't do it in 'setup_window' because some parameters
        # are not processed there yet.
        self.setup_window_caption()
    def setup(self):
        ''' set variables based on init() values. '''
        self.Y_LIMS = [0, self.SETTINGS.WINDOW_HEIGHT_DEFAULT]
        self.SETTINGS.WINDOW_WIDTH_CURRENT = self.SETTINGS.WINDOW_WIDTH_DEFAULT
        self.SETTINGS.WINDOW_HEIGHT_CURRENT = self.SETTINGS.WINDOW_HEIGHT_DEFAULT

        # add 'abs_plugin_ID' to plugin name.
        self.PLUGIN_NAME = self.PLUGIN_NAME + '-' + str(self.abs_plugin_ID)
        ''' setup mmap or random data interface '''
        status, self.MMAP, self.DATA = setup_incoming_data_interface(
            self.USE_MMAP, self.PLUGIN_NAME, self.NBR_CHANNELS,
            self.nPointsToUpdate, self.nPoints,
            self.SETTINGS.WINDOW_WIDTH_CURRENT,
            self.SETTINGS.WINDOW_HEIGHT_CURRENT)
        if not status:
            sys.exit(1)
        ''' setup plot queue '''
        self.plot_queue = setup_plotting_queue()
        ''' generate initial positions & colors, and setup VOBs '''
        self.vbo_data, self.vbo_colors, self.x_coords = \
         gl_setup_initial_data_and_color_and_vbos(self.nPoints, n_COORDINATES_PER_COLOR, self.NBR_CHANNELS, self.SETTINGS.WINDOW_WIDTH_DEFAULT, self.SETTINGS.WINDOW_HEIGHT_DEFAULT)
        ''' horizontal and vertical lines '''
        # horizontal line showing the threshold
        if self.SHOW_HORIZONTAL_LINE:
            self.line_hor = line_default_horizontal(self)

        # vertical line showing which data point is going to be update next
        if self.SHOW_VERTICAL_LINE:
            self.line_ver = line_default_vertical(self)
        ''' axes '''
        if self.SHOW_AXES:
            self.coord_axes, self.y_axis_tics = axes_default_with_y_ticks(self)
        ''' other stuff '''
        # is Tkinter installed and running?
        self.SETTINGS = tkinter_register_with_settings(self.SETTINGS)

        # set default gl modes
        set_gl_defaults(self.POINT_SIZE)

        # try to render a smooth line (if supported by driver)
        gl_enable_line_smoothing()

        # set window title
        win_title = 'generating random data'
        if self.USE_MMAP:
            win_title = 'receiving data from matlab'
        nbr_points_shown = ' -- showing %s points per panel.' % self.nPoints
        self.set_caption(self.PLUGIN_NAME + ' -- ' + win_title +
                         nbr_points_shown)

        # hide mouse - disabled.
        # self.set_mouse_visible(False)

        # schedule the 'update()' method to be called each 'update_interval'
        pyglet.clock.schedule_interval(self.update, self.update_interval)

        # Create a font for our FPS clock
        ft = pyglet.font.load('Arial', 28)
        self.fps_display = pyglet.clock.ClockDisplay(font=ft,
                                                     interval=0.125,
                                                     format='FPS %(fps).2f')
    def setup(self):

        """ set variables based on init() values. """
        self.Y_LIMS = [0, self.SETTINGS.WINDOW_HEIGHT_DEFAULT]
        self.SETTINGS.WINDOW_WIDTH_CURRENT = self.SETTINGS.WINDOW_WIDTH_DEFAULT
        self.SETTINGS.WINDOW_HEIGHT_CURRENT = self.SETTINGS.WINDOW_HEIGHT_DEFAULT

        # add 'abs_plugin_ID' to plugin name.
        self.PLUGIN_NAME = self.PLUGIN_NAME + "-" + str(self.abs_plugin_ID)

        """ setup mmap or random data interface """
        status, self.MMAP, self.DATA = setup_incoming_data_interface(
            self.USE_MMAP,
            self.PLUGIN_NAME,
            self.NBR_CHANNELS,
            self.nPointsToUpdate,
            self.nPoints,
            self.SETTINGS.WINDOW_WIDTH_CURRENT,
            self.SETTINGS.WINDOW_HEIGHT_CURRENT,
        )
        if not status:
            sys.exit(1)

        """ setup plot queue """
        self.plot_queue = setup_plotting_queue()

        """ generate initial positions & colors, and setup VOBs """
        self.vbo_data, self.vbo_colors, self.x_coords = gl_setup_initial_data_and_color_and_vbos(
            self.nPoints,
            n_COORDINATES_PER_COLOR,
            self.NBR_CHANNELS,
            self.SETTINGS.WINDOW_WIDTH_DEFAULT,
            self.SETTINGS.WINDOW_HEIGHT_DEFAULT,
        )

        """ horizontal and vertical lines """
        # horizontal line showing the threshold
        if self.SHOW_HORIZONTAL_LINE:
            self.line_hor = line_default_horizontal(self)

            # vertical line showing which data point is going to be update next
        if self.SHOW_VERTICAL_LINE:
            self.line_ver = line_default_vertical(self)

        """ axes """
        if self.SHOW_AXES:
            self.coord_axes, self.y_axis_tics = axes_default_with_y_ticks(self)

        """ other stuff """
        # is Tkinter installed and running?
        self.SETTINGS = tkinter_register_with_settings(self.SETTINGS)

        # set default gl modes
        set_gl_defaults(self.POINT_SIZE)

        # try to render a smooth line (if supported by driver)
        gl_enable_line_smoothing()

        # set window title
        win_title = "generating random data"
        if self.USE_MMAP:
            win_title = "receiving data from matlab"
        nbr_points_shown = " -- showing %s points per panel." % self.nPoints
        self.set_caption(self.PLUGIN_NAME + " -- " + win_title + nbr_points_shown)

        # hide mouse - disabled.
        # self.set_mouse_visible(False)

        # schedule the 'update()' method to be called each 'update_interval'
        pyglet.clock.schedule_interval(self.update, self.update_interval)

        # Create a font for our FPS clock
        ft = pyglet.font.load("Arial", 28)
        self.fps_display = pyglet.clock.ClockDisplay(font=ft, interval=0.125, format="FPS %(fps).2f")