def draw(self, current_y_lims): if (self.y_lims != current_y_lims): self.re_init_axis_tics(current_y_lims) glPushMatrix() glLineWidth(2.0) glBegin(GL_LINES) glColor3f(1, 1, 1) if self.direction == 1: # y axis ticks pos_ticks, neg_ticks = self.return_pos_and_neg_tick_locations() self.draw_tic_lines(pos_ticks) self.draw_tic_lines(neg_ticks) glEnd() glPopMatrix() # TODO: this is a little messy, but I need to do this so that the axex # labels don't get distorted. # the size of the current window win_height = float(self.settings_main_app.WINDOW_HEIGHT_CURRENT) win_width = float(self.settings_main_app.WINDOW_WIDTH_CURRENT) # the abs size of the current projection view x_diff_abs, y_diff_abs = gl_calc_x_y_extend_from_current_glOrthoMatrix( self.settings_main_app) # draw the labels for j in range(len(self.labels)): glPushMatrix() # scale text in x & y direction. with x-scaling we will have to also move the label away from the tic marks. # glScalef(x_diff_abs/win_width, y_diff_abs/win_height, 1) # scale text in y direction only. glScalef(1, y_diff_abs / win_height, 1) # move text y_translate = float(self.labels[j].y) * ( (win_height / y_diff_abs) - 1.0) glTranslatef(0, y_translate, 0) #print 'moving %s by %s' % (self.labels[j].text, y_translate) self.labels[j].draw() glPopMatrix()
def line_default_horizontal(main_app): # how much to the left and right should the line extend? hor_min_x = -20 # set the initial position to half of the current y extent. x_diff_abs, y_diff_abs = gl_calc_x_y_extend_from_current_glOrthoMatrix(main_app.SETTINGS) hor_line_initial_y = y_diff_abs / 2 line_hor = gl_line(main_app) line_hor.setup_horizontal_line(hor_min_x, main_app.SETTINGS.WINDOW_WIDTH_DEFAULT + hor_min_x, hor_line_initial_y, [0, 1, 0]) line_hor.curr_pos = hor_line_initial_y line_hor.delta = 1 # register the key press function that is associated with the the horizontal line. main_app.window.push_handlers(on_key_press = line_hor.kpf_change_horizontal_line) return line_hor
def draw(self, current_y_lims): if (self.y_lims != current_y_lims): self.re_init_axis_tics(current_y_lims) glPushMatrix() glLineWidth(2.0) glBegin(GL_LINES) glColor3f(1, 1, 1) if self.direction == 1: # y axis ticks pos_ticks, neg_ticks = self.return_pos_and_neg_tick_locations() self.draw_tic_lines(pos_ticks) self.draw_tic_lines(neg_ticks) glEnd() glPopMatrix() # TODO: this is a little messy, but I need to do this so that the axex # labels don't get distorted. # the size of the current window win_height = float(self.settings_main_app.WINDOW_HEIGHT_CURRENT) win_width = float(self.settings_main_app.WINDOW_WIDTH_CURRENT) # the abs size of the current projection view x_diff_abs, y_diff_abs = gl_calc_x_y_extend_from_current_glOrthoMatrix(self.settings_main_app) # draw the labels for j in range(len(self.labels)): glPushMatrix() # scale text in x & y direction. with x-scaling we will have to also move the label away from the tic marks. # glScalef(x_diff_abs/win_width, y_diff_abs/win_height, 1) # scale text in y direction only. glScalef(1, y_diff_abs/win_height, 1) # move text y_translate = float(self.labels[j].y) * ((win_height/y_diff_abs) - 1.0) glTranslatef(0, y_translate, 0) #print 'moving %s by %s' % (self.labels[j].text, y_translate) self.labels[j].draw() glPopMatrix()