You can subscribe to this list here.
2005 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
(32) |
Sep
|
Oct
|
Nov
|
Dec
|
---|
From: Tero K. <te...@us...> - 2005-08-14 22:47:11
|
Update of /cvsroot/openexvis/openexvis In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11620 Modified Files: oevt_python.py openexvis.py visualizer.py Log Message: Visualization now graphical, but only for few things. Many internal changes here and there. Index: oevt_python.py =================================================================== RCS file: /cvsroot/openexvis/openexvis/oevt_python.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- oevt_python.py 12 Aug 2005 23:01:45 -0000 1.2 +++ oevt_python.py 14 Aug 2005 22:46:59 -0000 1.3 @@ -48,43 +48,48 @@ def to_oevdata(self, data): # We return strings, since what the translator gives to the visualizer # should be language-independent. + #print "DEBUG: data == ", data viscommands = str(data.pop(0)) + ';' # The visualization commands lastconst = None # Track the last loaded constant olderconst = None # Track the constant loaded before lastconst - for opcode in data: + for op in data: #print "DEBUG: opcode == ", opcode['opcode'] - if opcode['opcode'] == 'LOAD_CONST': + if op['opcode'] == 'LOAD_CONST': # Loading a constant. - viscommands += 'GET_CONSTANT:' + opcode['oparg2'] + ';' + viscommands += 'GET_CONSTANT:' + op['oparg2'] + ';' # Load the given constant to lastconst. olderconst = lastconst - lastconst = opcode['oparg2'] - elif opcode['opcode'] == 'STORE_NAME': + lastconst = op['oparg2'] + elif op['opcode'] == 'STORE_NAME': + # TODO: I'm afraid this could be inadequate information to + # pass forward. # Storing the last constant in the given variable. - self.variables[opcode['oparg2']] = lastconst - print "DEBUG: variables == ", self.variables - viscommands += 'STORE_VARIABLE:' + opcode['oparg2'] + ':' +\ + self.variables[op['oparg2']] = lastconst + #print "DEBUG: variables == ", self.variables + viscommands += 'STORE_VARIABLE:' + op['oparg2'] + ':' + \ + str(self.variables[op['oparg2']]) + ':' + \ str(lastconst) + ';' - elif opcode['opcode'] == 'SETUP_LOOP': + elif op['opcode'] == 'SETUP_LOOP': viscommands += 'BEGIN_LOOP;' - elif opcode['opcode'] == 'LOAD_NAME': + elif op['opcode'] == 'LOAD_NAME': # Loading the given variable. - viscommands += 'LOAD:' + opcode['oparg2'] + ';' + viscommands += 'LOAD:' + op['oparg2'] + ':' + \ + str(self.variables[op['oparg2']]) + ';' olderconst = lastconst - lastconst = self.variables[opcode['oparg2']] - elif opcode['opcode'] == 'COMPARE_OP': - viscommands += 'COMPARE:' + opcode['oparg2'] + ':' + \ + lastconst = self.variables[op['oparg2']] + elif op['opcode'] == 'COMPARE_OP': + viscommands += 'COMPARE:' + op['oparg2'] + ':' + \ str(olderconst) + ':' + str(lastconst) + ';' - elif opcode['opcode'] == 'INPLACE_ADD': + elif op['opcode'] == 'INPLACE_ADD': viscommands += 'ADD:' + str(lastconst) + ':' + str(olderconst)\ + ';' lastconst = int(lastconst) + int(olderconst) olderconst = None - elif opcode['opcode'] == 'PRINT_ITEM': + elif op['opcode'] == 'PRINT_ITEM': viscommands += 'OUTPUT:' + str(lastconst) + ';' - elif opcode['opcode'] == 'PRINT_NEWLINE': + elif op['opcode'] == 'PRINT_NEWLINE': viscommands += 'OUTPUT:\n;' - elif opcode['opcode'] == 'RETURN_VALUE': + elif op['opcode'] == 'RETURN_VALUE': viscommands += 'RETURN;' #elif opcode['opcode'] == : # pass @@ -92,16 +97,16 @@ # pass #elif opcode['opcode'] == : # pass - elif opcode['opcode'] == 'JUMP_IF_FALSE': + elif op['opcode'] == 'JUMP_IF_FALSE': # Not visualized in visualization area. pass - elif opcode['opcode'] == 'JUMP_ABSOLUTE': + elif op['opcode'] == 'JUMP_ABSOLUTE': # Not visualized in visualization area. pass - elif opcode['opcode'] == 'POP_TOP': + elif op['opcode'] == 'POP_TOP': # XXX Needed? pass - elif opcode['opcode'] == 'POP_BLOCK': + elif op['opcode'] == 'POP_BLOCK': # XXX Needed? pass else: Index: openexvis.py =================================================================== RCS file: /cvsroot/openexvis/openexvis/openexvis.py,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- openexvis.py 12 Aug 2005 23:01:45 -0000 1.5 +++ openexvis.py 14 Aug 2005 22:46:59 -0000 1.6 @@ -18,7 +18,7 @@ def __init__(self): visualizer.OevVisualizer.__init__(self) - self.version = "0.1.0" + self.version = "0.2.0-pre" # Build the UI self.build_gui() @@ -28,9 +28,6 @@ self.do_steps = False self.step_fwd = False - # Usually OpenExVis needs the space, so start maximized. - self.oevWindow.maximize() - def build_gui(self): """Create the widgets and set up the GUI.""" @@ -46,6 +43,9 @@ # Create simple names for the important widgets. self.name_widgets() + # Usually OpenExVis needs the space, so start maximized. + self.oevWindow.maximize() + # Set up the code area. self.clear_code_buffer() self.cArea.set_show_line_numbers(True) @@ -56,11 +56,18 @@ def init_visualization_area(self): """Initialize the visualization area.""" self.gc = self.vDraw.new_gc() - # These are later updated in vArea signal handlers when necessary. - self.vis_width, self.vis_height = self.vDraw.get_size() - self.vis_split_x = self.vis_width/2 - self.const_split = self.vis_height/2 - self.eval_split = int(self.vis_height/1.5) + # Create the colors for different elements. They must be allocated + # colors. + self.colormap = self.vDraw.get_colormap() + self.color_white = self.colormap.alloc_color('#FFFFFF') + self.static_const_color = self.colormap.alloc_color('#DDAA88') + self.const_color = self.colormap.alloc_color('#FFCCAA') + self.var_color = self.colormap.alloc_color('#CCFFAA') + self.bool_true_color = self.colormap.alloc_color('#33FF33') + self.bool_false_color = self.colormap.alloc_color('#FF5555') + # Make sure the visualization area doesn't get too small. + self.vArea.set_size_request(200, 300) + self.set_positions() # Clear the area and create some initial text to place in them. self.clear_visualization_area() @@ -70,6 +77,36 @@ self.const_layout = self.vArea.create_pango_layout("Constantly empty.") self.eval_layout = self.vArea.create_pango_layout("Non-evaluation.") + def set_positions(self): + """Set some important positions in the visualization area.""" + self.vis_width, self.vis_height = self.vDraw.get_size() + # We divide the visualization area to a 20x20 grid. + self.gridw = self.vis_width/20 + self.gridh = self.vis_height/20 + while self.gridw > 50: + self.gridw = self.gridw/2 + while self.gridh > 50: + self.gridh = self.gridh/2 + # Divide the visualization area into subareas. + self.vis_split_x = self.gridw * 10 + self.const_split = self.gridh * 9 + self.eval_split = self.gridh * 12 + # Some important locations for drawing the visualization. + self.const_start = (self.vis_split_x - self.gridw * 3, \ + self.const_split + self.gridh * 1) + self.const_end = (self.vis_split_x + self.gridw * 8, \ + self.eval_split - self.gridh * 3) + self.var_pos = (self.vis_split_x + self.gridw * 1, \ + self.eval_split - self.gridh * 3) + self.bool_pos = (self.vis_split_x + self.gridw * 3, \ + self.eval_split + self.gridh * 3) + self.eval_left_pos = (self.vis_split_x + self.gridw, \ + self.eval_split + self.gridh * 1) + self.eval_sign_pos = (self.vis_split_x + self.gridw * 4, \ + self.eval_split + self.gridh * 1) + self.eval_right_pos = (self.vis_split_x + self.gridw * 6, \ + self.eval_split + self.gridh * 1) + def name_widgets(self): """Give all important UI widgets easy names.""" self.oevWindow = self.widgets.get_widget('oevWindow') # Main window. @@ -77,7 +114,7 @@ self.cArea = self.widgets.get_widget('codeArea') self.vArea = self.widgets.get_widget('visualizationArea') self.oArea = self.widgets.get_widget('outputArea') - self.vDraw = self.vArea.window # Drawing surface of the visualization area. + self.vDraw = self.vArea.window # Drawing surface for the vArea. def clear_code_buffer(self): """Clear the code buffer.""" @@ -119,19 +156,23 @@ def draw_step(self, lineno, viscommands): """Draw one visualization step.""" + self.vis_pixmaps = [] # Mark the line we're visualizing on the code area. vis_code = self.mark_line(lineno) # Update the visualization area. - self.update_pixmap(vis_code, viscommands) - self.refresh_screen() - # This gives us a responsive window while visualizing. - for i in range(int((11-self.speed)*2)): + self.update_pixmaps(vis_code, viscommands) + moresteps = True + while moresteps: while not self.speed: # We are paused. gtk.main_iteration() while gtk.events_pending(): gtk.main_iteration() - time.sleep(0.05) + moresteps = self.draw_anim_frame() + # Higher speed setting gives higher speed like this. + # TODO: This should be improved so slowest and fastest differ more. + # FIXME: Also, this seems to cause a lot of speed alteration. + time.sleep((11-self.speed)/100) if self.do_steps: while self.do_steps and not self.step_fwd: # Loop until we are told to step forward or to start running @@ -142,43 +183,184 @@ self.step_fwd = False return True - def update_pixmap(self, vis_code, visinfo): - """Update the pixmap to draw on the visualization area.""" + def update_pixmaps(self, vis_code, visinfo): + """Update the pixmaps to draw on the visualization area.""" self.oevWindow.queue_draw() #print "\nDEBUG: The data:\n", visinfo - # For now, we just write this string on the visualization area. - # In the future, it will have pretty pictures, animation and stuff. - struct_text = vis_code + '\n' - var_text = '' - const_text = '' - eval_text = '' + self.clear_visualization_area() for cmd in visinfo: #print "DEBUG: cmd == ", cmd if cmd[0] == 'OUTPUT': + # cmd[1] is the string to output. ei = self.oArea.get_buffer().get_end_iter() self.oArea.get_buffer().insert(ei, cmd[1]) elif cmd[0] == 'SHOW_CONSTANT': - const_text += '\nLoading constant ' + cmd[1] + # cmd[1] is the constant to show as string. + self.draw_show_constant(cmd[1]) elif cmd[0] == 'SHOW_VARIABLE': - var_text += '\nVariable ' + cmd[1] + # cmd[1] is the variable name. + # cmd[2] is the variable value. + self.draw_show_variable(cmd[1], cmd[2]) elif cmd[0] == 'SHOW_STORING': - eval_text += '\nStoring ' + cmd[1] + ' to ' + cmd[2] + # cmd[1] is a constant to store to last shown variable. + self.draw_show_storing(cmd[1]) elif cmd[0] == 'SHOW_COMPARISON': - eval_text += '\nComparing: ' + cmd[2] + ' ' + cmd[1] + ' ' + \ - cmd[3] + # cmd[1] is the comparison sign (==,<,>) + # cmd[2] is the left side of comparison. + # cmd[3] is the right side of comparison. + self.draw_show_eval(cmd[2], cmd[1], cmd[3]) + # Could there be an easier way to do the following? + if cmd[1] == '==': + if cmd[2] == cmd[3]: + self.draw_show_bool(True) + else: + self.draw_show_bool(False) + elif cmd[1] == '<': + if cmd[2] < cmd[3]: + self.draw_show_bool(True) + else: + self.draw_show_bool(False) + elif cmd[1] == '>': + if cmd[2] > cmd[3]: + self.draw_show_bool(True) + else: + self.draw_show_bool(False) + else: + print "Unsupported comparison: ", cmd[1] else: - struct_text += "\nVisualizing " + cmd[0] + " not supported." \ - + " Whole command was: " + str(cmd) - - # Set the text of the visualization area. - self.struct_layout.set_text(struct_text) - self.var_layout.set_text(var_text) - self.const_layout.set_text(const_text) - self.eval_layout.set_text(eval_text) - # Drawing stuff on the pixmap. - self.clear_visualization_area() + print "Visualizing ", cmd[0], " not supported." return True + def draw_anim_frame(self): + """Draw one animation frame. + + In self.vispixmaps[i]: + i[0] is current x, i[1] is x to move to + i[2] is current y, i[3] is y to move to + i[4] is the pixmap to draw on main pixmap + + """ + # This is now so that horizontal movement always comes before vertical. + # It might not be desireable in all cases. Figure that out when such a + # situation arises. + moresteps = False + for i in self.vis_pixmaps: + #print "DEBUG: vispixmaps[i] ", i + # Move the element if needed. + prevx = i[0] + prevy = i[2] + if i[0] < i[1]: + i[0] += self.gridw + moresteps = True + elif i[0] > i[1]: + i[0] -= self.gridw + moresteps = True + elif i[2] < i[3]: + i[2] += self.gridh + moresteps = True + elif i[2] > i[3]: + i[2] -= self.gridh + moresteps = True + # Clear the last position of the element. + pmw, pmh = i[4].get_size() + self.pixmap.draw_rectangle(self.vArea.get_style().white_gc, True, \ + prevx, prevy, pmw, pmh) + # Draw the element. + self.pixmap.draw_drawable(self.gc, i[4], 0, 0, i[0], i[2], -1, -1) + self.refresh_screen() + return moresteps + + # NOTE: To grok the following draw_show_* methods, see do_frame_pixmap. + def draw_show_eval(self, left, sign, right): + """Store an evaluation in the visualization pixmap.""" + # The left side of evaluation. + lx = self.eval_left_pos[0] + ly = self.eval_left_pos[1] + lw = self.gridw * 3 + ltxt = self.vArea.create_pango_layout(left) + # The sign. + sx = self.eval_sign_pos[0] + sy = self.eval_sign_pos[1] + sw = self.gridw * 2 + stxt = self.vArea.create_pango_layout(sign) + # The right side of evaluation. + rx = self.eval_right_pos[0] + ry = self.eval_right_pos[1] + rw = self.gridw * 3 + rtxt = self.vArea.create_pango_layout(right) + # Height is same for all. + h = self.gridh + # Create the pixmaps to display the evaluation. + self.do_frame_pixmap(self.var_color, lw, h, lx, lx, ly, ly, ltxt) + self.do_frame_pixmap(self.const_color, sw, h, sx, sx, sy, sy, stxt) + self.do_frame_pixmap(self.var_color, rw, h, rx, rx, ry, ry, rtxt) + + def draw_show_bool(self, bool): + """Store displaying a boolean in the visualization pixmap.""" + # TODO: ex and mod to x are for DEBUG purposes. Without them, + # currently, the boolean just flashes for a short time. A better + # solution is needed to keep it visible for a while. Should be done + # when revisiting the more general speed issues. + x = self.bool_pos[0] - self.gridw * 2 + ex = self.bool_pos[0] + self.gridw * 2 + y = self.bool_pos[1] + w = self.gridw * 2 + h = self.gridh + if bool: + fg = self.bool_true_color + text = 'TRUE' + else: + fg = self.bool_false_color + text = 'FALSE' + txt = self.vArea.create_pango_layout(text) + self.do_frame_pixmap(fg, w, h, x, ex, y, y, txt) + + def draw_show_variable(self, varname, varvalue): + """Store displaying a variable in the visualization pixmap.""" + x = self.var_pos[0] + y = self.var_pos[1] + w = self.gridw * 6 + h = self.gridh + txt = self.vArea.create_pango_layout(varname) + self.do_frame_pixmap(self.var_color, w, h, x, x, y, y, txt) + + def draw_show_constant(self, constant): + """Store displaying a constant in the visualization pixmap.""" + x = self.const_start[0] + y = self.const_start[1] + w = self.gridw * 2 + h = self.gridh + txt = self.vArea.create_pango_layout(constant[:8]) + self.do_frame_pixmap(self.static_const_color, w, h, x, x, y, y, txt) + + def draw_show_storing(self, constant): + """Store a constant moved to a variable in the visualization pixmap.""" + startx = self.const_start[0] + starty = self.const_start[1] + endx = self.const_end[0] + endy = self.const_end[1] + w = self.gridw * 2 + h = self.gridh + txt = self.vArea.create_pango_layout(constant[:8]) + self.do_frame_pixmap(self.const_color, w, h, startx, endx, \ + starty, endy, txt) + + def do_frame_pixmap(self, fgc, w, h, startx, endx, starty, endy, txt): + """Build a pixmap for an element of an animation frame. + + This method gathers together everything needed from one item for the + draw_anim_frame() method from a pixmap and stores it in the + visualization pixmap list. + """ + gc = self.vDraw.new_gc() + pm = gtk.gdk.Pixmap(self.vDraw, w, h) + gc.set_foreground(self.color_white) + pm.draw_rectangle(gc, True, 0, 0, w, h) + gc.set_foreground(fgc) + pm.draw_rectangle(gc, True, 1, 1, w - 2, h - 2) + pm.draw_layout(self.gc, 2, 2, txt) + self.vis_pixmaps.append([startx, endx, starty, endy, pm]) + def refresh_screen(self): """Refresh the OpenExVis window.""" w = self.oevWindow.window @@ -255,6 +437,14 @@ ei = self.cBuf.get_end_iter() return self.cBuf.get_text(si, ei) + def do_visualization(self): + # Make sure the UI only calls visualize() once for one + # visualization. + self.cArea.set_sensitive(False) + self.visualize(self.get_code()) + self.cArea.set_sensitive(True) + + def oev(self): """Begin the main loop.""" gtk.main() @@ -300,11 +490,7 @@ self.do_steps = False else: if not self.visualizing: - # Make sure the UI only calls visualize() once for one - # visualization. - self.cArea.set_sensitive(False) - self.visualize(self.get_code()) - self.cArea.set_sensitive(True) + self.do_visualization() def on_stepButton_clicked(self, obj): """Start running the visualization one step at a time. @@ -323,11 +509,7 @@ else: self.do_steps = True if not self.visualizing: - # Make sure the UI only calls visualize() once for one - # visualization. - self.cArea.set_sensitive(False) - self.visualize(self.get_code()) - self.cArea.set_sensitive(True) + self.do_visualization() self.do_steps = False def on_pauseButton_clicked(self, obj): @@ -389,37 +571,16 @@ d.show() def on_visualizationArea_size_allocate(self, obj, event): - """Set the width and height of vDraw.""" - self.vis_width = event.width - self.vis_height = event.height - # These variables are used in various places to tell the position of - # different subareas in the visualization area. - self.vis_split_x = event.width/2 - self.const_split = event.height/2 - self.eval_split = int(event.height/1.5) + """Update the grid.""" + self.set_positions() + self.clear_visualization_area() def on_visualizationArea_expose_event(self, obj, event): """Draw the visualization area contents.""" - self.clear_visualization_area() x , y, width, height = event.area # The image is a pixmap we build behind the scenes. self.vDraw.draw_drawable(self.vArea.get_style().fg_gc[gtk.STATE_NORMAL],\ self.pixmap, x, y, x, y, width, height) - # Make sure the texts don't flow over their designated subarea. - leftwidth = (self.vis_split_x - 10) * pango.SCALE - rightwidth = (width - self.vis_split_x - 10) * pango.SCALE - self.struct_layout.set_width(leftwidth) - self.var_layout.set_width(rightwidth) - self.const_layout.set_width(leftwidth) - self.eval_layout.set_width(rightwidth) - # Draw the text of each subarea. - self.vDraw.draw_layout(self.gc, 10, 25, self.struct_layout) - self.vDraw.draw_layout(self.gc, self.vis_split_x + 10, 25, \ - self.var_layout) - self.vDraw.draw_layout(self.gc, 10, self.const_split + 25, \ - self.const_layout) - self.vDraw.draw_layout(self.gc, self.vis_split_x + 10, \ - self.eval_split + 25, self.eval_layout) def main(): Index: visualizer.py =================================================================== RCS file: /cvsroot/openexvis/openexvis/visualizer.py,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- visualizer.py 12 Aug 2005 23:01:45 -0000 1.3 +++ visualizer.py 14 Aug 2005 22:46:59 -0000 1.4 @@ -30,7 +30,7 @@ """Create commands for one visualization step. The translator calls this function giving the visualization data as an - argument. The data is changed to lists containing the line number and + argument. The data is changed to lists containing the line number and commands for drawing the visualization and these lists are sent forward to the draw_step function implemented in the UI. @@ -60,13 +60,13 @@ cmd.append(['SHOW_CONSTANT', c[1]]) elif c[0] == 'STORE_VARIABLE': # TODO: This, especially, requires some more thought. - cmd.append(['SHOW_VARIABLE', c[1]]) - cmd.append(['SHOW_VARIABLE', c[2]]) - cmd.append(['SHOW_STORING', c[2], c[1]]) + cmd.append(['SHOW_VARIABLE', c[1], c[2]]) + cmd.append(['SHOW_CONSTANT', c[3]]) + cmd.append(['SHOW_STORING', c[3], c[1]]) elif c[0] == 'LOAD': - cmd.append(['SHOW_VARIABLE', c[1]]) + cmd.append(['SHOW_VARIABLE', c[1], c[2]]) elif c[0] == 'BEGIN_LOOP': - pass + cmd.append(['SHOW_LOOP']) elif c[0] == 'COMPARE': cmd.append(['SHOW_COMPARISON', c[1], c[2], c[3]]) elif c[0] == 'INPLACE_ADD': @@ -74,7 +74,7 @@ elif c[0] == 'OUTPUT': cmd.append(['OUTPUT', c[1]]) elif c[0] == 'RETURN': - pass + cmd.append(['RETURN']) return cmd def visualize(self, code): |
From: Tero K. <te...@us...> - 2005-08-12 23:01:55
|
Update of /cvsroot/openexvis/openexvis In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31453 Modified Files: ChangeLog oevt_python.py openexvis.py visualizer.py Log Message: Things are still heavily evolving, but there seem to be no big problems in the current code. Thus, I'm commiting now as the diffs are getting big and there have been many major changes. Index: oevt_python.py =================================================================== RCS file: /cvsroot/openexvis/openexvis/oevt_python.py,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- oevt_python.py 8 Aug 2005 21:30:39 -0000 1.1.1.1 +++ oevt_python.py 12 Aug 2005 23:01:45 -0000 1.2 @@ -33,8 +33,9 @@ from mydis. """ - visdata = oev_dis.disassemble(frame.f_code, frame.f_lineno) - print "\nDEBUG: In user_line we have:\n",visdata + data = oev_dis.disassemble(frame.f_code, frame.f_lineno) + #print "\nDEBUG: In user_line we have:\n",visdata + visdata = self.to_oevdata(data) self.vis.vis_step(visdata) return self.trace_dispatch @@ -44,6 +45,70 @@ #def user_exception(self, frame, arg): # pass + def to_oevdata(self, data): + # We return strings, since what the translator gives to the visualizer + # should be language-independent. + viscommands = str(data.pop(0)) + ';' # The visualization commands + lastconst = None # Track the last loaded constant + olderconst = None # Track the constant loaded before lastconst + for opcode in data: + #print "DEBUG: opcode == ", opcode['opcode'] + if opcode['opcode'] == 'LOAD_CONST': + # Loading a constant. + viscommands += 'GET_CONSTANT:' + opcode['oparg2'] + ';' + # Load the given constant to lastconst. + olderconst = lastconst + lastconst = opcode['oparg2'] + elif opcode['opcode'] == 'STORE_NAME': + # Storing the last constant in the given variable. + self.variables[opcode['oparg2']] = lastconst + print "DEBUG: variables == ", self.variables + viscommands += 'STORE_VARIABLE:' + opcode['oparg2'] + ':' +\ + str(lastconst) + ';' + elif opcode['opcode'] == 'SETUP_LOOP': + viscommands += 'BEGIN_LOOP;' + elif opcode['opcode'] == 'LOAD_NAME': + # Loading the given variable. + viscommands += 'LOAD:' + opcode['oparg2'] + ';' + olderconst = lastconst + lastconst = self.variables[opcode['oparg2']] + elif opcode['opcode'] == 'COMPARE_OP': + viscommands += 'COMPARE:' + opcode['oparg2'] + ':' + \ + str(olderconst) + ':' + str(lastconst) + ';' + elif opcode['opcode'] == 'INPLACE_ADD': + viscommands += 'ADD:' + str(lastconst) + ':' + str(olderconst)\ + + ';' + lastconst = int(lastconst) + int(olderconst) + olderconst = None + elif opcode['opcode'] == 'PRINT_ITEM': + viscommands += 'OUTPUT:' + str(lastconst) + ';' + elif opcode['opcode'] == 'PRINT_NEWLINE': + viscommands += 'OUTPUT:\n;' + elif opcode['opcode'] == 'RETURN_VALUE': + viscommands += 'RETURN;' + #elif opcode['opcode'] == : + # pass + #elif opcode['opcode'] == : + # pass + #elif opcode['opcode'] == : + # pass + elif opcode['opcode'] == 'JUMP_IF_FALSE': + # Not visualized in visualization area. + pass + elif opcode['opcode'] == 'JUMP_ABSOLUTE': + # Not visualized in visualization area. + pass + elif opcode['opcode'] == 'POP_TOP': + # XXX Needed? + pass + elif opcode['opcode'] == 'POP_BLOCK': + # XXX Needed? + pass + else: + pass + #print "DEBUG: vc == ", viscommands + return viscommands + def translate(self, code): """Translate Python code to OpenExVis visualization data. @@ -57,6 +122,8 @@ """ globals_ = {"__name__" : "__main__"} locals_ = globals_ + # The variables we need to track during the visualization. + self.variables = {} statement = compile(code, "", 'exec') self.run(statement, globals=globals_, locals=locals_) Index: openexvis.py =================================================================== RCS file: /cvsroot/openexvis/openexvis/openexvis.py,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- openexvis.py 11 Aug 2005 13:01:28 -0000 1.4 +++ openexvis.py 12 Aug 2005 23:01:45 -0000 1.5 @@ -7,6 +7,7 @@ import gtksourceview import mimetypes import os +import pango import sys import time @@ -18,11 +19,17 @@ def __init__(self): visualizer.OevVisualizer.__init__(self) self.version = "0.1.0" + + # Build the UI self.build_gui() + + # These are used to control the visualization self.speed = self.sSlider.get_value() self.do_steps = False self.step_fwd = False - self.visualizing = False + + # Usually OpenExVis needs the space, so start maximized. + self.oevWindow.maximize() def build_gui(self): """Create the widgets and set up the GUI.""" @@ -44,7 +51,24 @@ self.cArea.set_show_line_numbers(True) # Set up the visualization area. + self.init_visualization_area() + + def init_visualization_area(self): + """Initialize the visualization area.""" + self.gc = self.vDraw.new_gc() + # These are later updated in vArea signal handlers when necessary. + self.vis_width, self.vis_height = self.vDraw.get_size() + self.vis_split_x = self.vis_width/2 + self.const_split = self.vis_height/2 + self.eval_split = int(self.vis_height/1.5) + + # Clear the area and create some initial text to place in them. self.clear_visualization_area() + self.struct_layout = self.vArea.create_pango_layout("There is no code.") + self.var_layout = self.vArea.create_pango_layout("Nothing to see " + \ + "here.") + self.const_layout = self.vArea.create_pango_layout("Constantly empty.") + self.eval_layout = self.vArea.create_pango_layout("Non-evaluation.") def name_widgets(self): """Give all important UI widgets easy names.""" @@ -65,21 +89,43 @@ def clear_visualization_area(self): """Clear the visualization area.""" - self.gc = self.vDraw.new_gc() - x, y, width, height = self.vArea.get_allocation() - # The image we store is built as a pixmap. Here we just fill it with - # white. - self.pixmap = gtk.gdk.Pixmap(self.vDraw, width, height) + # The image we store is a pixmap. Here we draw the visualization area + # on it. + self.pixmap = gtk.gdk.Pixmap(self.vDraw, self.vis_width, self.vis_height) + # Fill the background with white. self.pixmap.draw_rectangle(self.vArea.get_style().white_gc, True, 0, \ - 0, width, height) - self.pangolayout = self.vArea.create_pango_layout("There is no code.") + 0, self.vis_width, self.vis_height) + # Draw the lines that separate the subareas. + self.pixmap.draw_line(self.gc, self.vis_split_x, 0, \ + self.vis_split_x, self.vis_height) + self.pixmap.draw_line(self.gc, 0, self.const_split, \ + self.vis_split_x, self.const_split) + self.pixmap.draw_line(self.gc, self.vis_split_x, self.eval_split, \ + self.vis_width, self.eval_split) + # Draw the subarea titles. + struct_title = self.vArea.create_pango_layout('') + var_title = self.vArea.create_pango_layout('') + const_title = self.vArea.create_pango_layout('') + eval_title = self.vArea.create_pango_layout('') + struct_title.set_markup('<b><u>Structure Area</u></b>') + var_title.set_markup('<b><u>Variable Area</u></b>') + const_title.set_markup('<b><u>Constant Area</u></b>') + eval_title.set_markup('<b><u>Evaluation Area</u></b>') + self.pixmap.draw_layout(self.gc, 10, 5, struct_title) + self.pixmap.draw_layout(self.gc, self.vis_split_x + 10, 5, var_title) + self.pixmap.draw_layout(self.gc, 10, self.const_split + 5, const_title) + self.pixmap.draw_layout(self.gc, self.vis_split_x + 10, \ + self.eval_split + 5, eval_title) - def draw_step(self, viscommands, speed): + def draw_step(self, lineno, viscommands): """Draw one visualization step.""" - self.update_pixmap(viscommands) + # Mark the line we're visualizing on the code area. + vis_code = self.mark_line(lineno) + # Update the visualization area. + self.update_pixmap(vis_code, viscommands) self.refresh_screen() # This gives us a responsive window while visualizing. - for i in range((11-speed)*2): + for i in range(int((11-self.speed)*2)): while not self.speed: # We are paused. gtk.main_iteration() @@ -88,7 +134,7 @@ time.sleep(0.05) if self.do_steps: while self.do_steps and not self.step_fwd: - # Loop until we are told to step forward or start running + # Loop until we are told to step forward or to start running # continuously. gtk.main_iteration() # We will visualize one step during the next draw_step call, make @@ -96,28 +142,41 @@ self.step_fwd = False return True - def update_pixmap(self, visinfo): + def update_pixmap(self, vis_code, visinfo): """Update the pixmap to draw on the visualization area.""" - # TODO: This is, of course, not how it will be. We are now just - # parsing the data given by the translator into something just a bit - # more comprehensible - something I wouldn't have needed to code at - # all but it was a nice exercise. self.oevWindow.queue_draw() #print "\nDEBUG: The data:\n", visinfo - # Store the line number and remove it from the list. - lineno = visinfo.pop(0) # For now, we just write this string on the visualization area. # In the future, it will have pretty pictures, animation and stuff. - s = '\nLineno: ' + str(lineno) - for d in visinfo: - print "Current entry: ", d - s += '\nAddr: ' + d['addr'] - s += '\nOpcode: ' + d['opcode'] - s += '\nParam: ' + d['oparg1'] + " " + d['oparg2'] - # Mark the line we're visualizing on the code area. - self.mark_line(lineno) + struct_text = vis_code + '\n' + var_text = '' + const_text = '' + eval_text = '' + for cmd in visinfo: + #print "DEBUG: cmd == ", cmd + if cmd[0] == 'OUTPUT': + ei = self.oArea.get_buffer().get_end_iter() + self.oArea.get_buffer().insert(ei, cmd[1]) + elif cmd[0] == 'SHOW_CONSTANT': + const_text += '\nLoading constant ' + cmd[1] + elif cmd[0] == 'SHOW_VARIABLE': + var_text += '\nVariable ' + cmd[1] + elif cmd[0] == 'SHOW_STORING': + eval_text += '\nStoring ' + cmd[1] + ' to ' + cmd[2] + elif cmd[0] == 'SHOW_COMPARISON': + eval_text += '\nComparing: ' + cmd[2] + ' ' + cmd[1] + ' ' + \ + cmd[3] + else: + struct_text += "\nVisualizing " + cmd[0] + " not supported." \ + + " Whole command was: " + str(cmd) + # Set the text of the visualization area. - self.pangolayout.set_text(s) + self.struct_layout.set_text(struct_text) + self.var_layout.set_text(var_text) + self.const_layout.set_text(const_text) + self.eval_layout.set_text(eval_text) + # Drawing stuff on the pixmap. + self.clear_visualization_area() return True def refresh_screen(self): @@ -142,6 +201,7 @@ ei = si.copy() ei.forward_line() self.cBuf.apply_tag_by_name('visualize', si, ei) + return self.cBuf.get_text(si, ei) def prepare_file_load(self, filename): """Prepare the code buffer for new file. @@ -206,6 +266,9 @@ def gtk_main_quit(self, obj): """Quit OpenExVis.""" gtk.main_quit() + # This is an easy solution to make Quit button respond when the + # visualization is running. This is not necessarily the Right Way(tm). + sys.exit(0) def on_openButton_clicked(self, obj): """Open a file chooser dialog to load a new file to the code buffer.""" @@ -239,9 +302,9 @@ if not self.visualizing: # Make sure the UI only calls visualize() once for one # visualization. - self.visualizing = True + self.cArea.set_sensitive(False) self.visualize(self.get_code()) - self.visualizing = False + self.cArea.set_sensitive(True) def on_stepButton_clicked(self, obj): """Start running the visualization one step at a time. @@ -262,9 +325,9 @@ if not self.visualizing: # Make sure the UI only calls visualize() once for one # visualization. - self.visualizing = True + self.cArea.set_sensitive(False) self.visualize(self.get_code()) - self.visualizing = False + self.cArea.set_sensitive(True) self.do_steps = False def on_pauseButton_clicked(self, obj): @@ -325,17 +388,38 @@ + "It is mostly meant for educational purposes.") d.show() - def on_visualizationArea_configure_event(self, obj, event): - """Clear the visualization area.""" - self.clear_visualization_area() + def on_visualizationArea_size_allocate(self, obj, event): + """Set the width and height of vDraw.""" + self.vis_width = event.width + self.vis_height = event.height + # These variables are used in various places to tell the position of + # different subareas in the visualization area. + self.vis_split_x = event.width/2 + self.const_split = event.height/2 + self.eval_split = int(event.height/1.5) def on_visualizationArea_expose_event(self, obj, event): """Draw the visualization area contents.""" + self.clear_visualization_area() x , y, width, height = event.area # The image is a pixmap we build behind the scenes. - self.vDraw.draw_drawable(self.vArea.get_style().fg_gc[gtk.STATE_NORMAL], self.pixmap, x, y, x, y, width, height) - # The text is a pango layout. - self.vDraw.draw_layout(self.gc, 20, 20, self.pangolayout) + self.vDraw.draw_drawable(self.vArea.get_style().fg_gc[gtk.STATE_NORMAL],\ + self.pixmap, x, y, x, y, width, height) + # Make sure the texts don't flow over their designated subarea. + leftwidth = (self.vis_split_x - 10) * pango.SCALE + rightwidth = (width - self.vis_split_x - 10) * pango.SCALE + self.struct_layout.set_width(leftwidth) + self.var_layout.set_width(rightwidth) + self.const_layout.set_width(leftwidth) + self.eval_layout.set_width(rightwidth) + # Draw the text of each subarea. + self.vDraw.draw_layout(self.gc, 10, 25, self.struct_layout) + self.vDraw.draw_layout(self.gc, self.vis_split_x + 10, 25, \ + self.var_layout) + self.vDraw.draw_layout(self.gc, 10, self.const_split + 25, \ + self.const_layout) + self.vDraw.draw_layout(self.gc, self.vis_split_x + 10, \ + self.eval_split + 25, self.eval_layout) def main(): Index: visualizer.py =================================================================== RCS file: /cvsroot/openexvis/openexvis/visualizer.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- visualizer.py 11 Aug 2005 13:01:28 -0000 1.2 +++ visualizer.py 12 Aug 2005 23:01:45 -0000 1.3 @@ -23,27 +23,60 @@ # We feed this visualizer to the oevt constructor to tell it to send # the data back to us. self.translator = oevt_python.OevTranslator(self) + # Control entry to the visualization loop. + self.visualizing = False def vis_step(self, visdata): """Create commands for one visualization step. The translator calls this function giving the visualization data as an - argument. The data is used for making the visualization. For now, we - simply send it forward without converting it to commands. - - The visualization data for one line is a list that contains the line - number as item 0 and for every operation a dictionary with the - following data: + argument. The data is changed to lists containing the line number and + commands for drawing the visualization and these lists are sent forward + to the draw_step function implemented in the UI. - instruction's address - instruction's opcode - instruction's argument1 - instruction's argument2 + The visualization data for one line is a string containing the line + number as it's first item and a substring for every item on the line. + The delimiter between line number and substrings is ';' and in the + substrings ':'. The substrings each have an action and it's parameters. """ - self.draw_step(visdata, self.speed) + splitdata = visdata.split(';') + #print "DEBUG: splitdata == ", splitdata + lineno = int(splitdata.pop(0)) + cmd = self.to_drawcommands(splitdata) + self.draw_step(lineno, cmd) return True + def to_drawcommands(self, data): + """Change data given by a translator to visualization commands.""" + # TODO: Obviously, the data format and the visualization commands + # should be documented well somewhere. Now they're not as they're still + # evolving. + cmd = [] + for item in data: + c = item.split(':') + #print "DEBUG: c == ", c + if c[0] == 'GET_CONSTANT': + cmd.append(['SHOW_CONSTANT', c[1]]) + elif c[0] == 'STORE_VARIABLE': + # TODO: This, especially, requires some more thought. + cmd.append(['SHOW_VARIABLE', c[1]]) + cmd.append(['SHOW_VARIABLE', c[2]]) + cmd.append(['SHOW_STORING', c[2], c[1]]) + elif c[0] == 'LOAD': + cmd.append(['SHOW_VARIABLE', c[1]]) + elif c[0] == 'BEGIN_LOOP': + pass + elif c[0] == 'COMPARE': + cmd.append(['SHOW_COMPARISON', c[1], c[2], c[3]]) + elif c[0] == 'INPLACE_ADD': + cmd.append(['SHOW_OPERATION', '+', c[1], c[2]]) + elif c[0] == 'OUTPUT': + cmd.append(['OUTPUT', c[1]]) + elif c[0] == 'RETURN': + pass + return cmd + def visualize(self, code): """Visualize execution of code. @@ -51,7 +84,9 @@ associated with this visualizer. """ + self.visualizing = True self.translator.translate(code) + self.visualizing = False return True def set_speed(self, speed): Index: ChangeLog =================================================================== RCS file: /cvsroot/openexvis/openexvis/ChangeLog,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- ChangeLog 11 Aug 2005 13:01:28 -0000 1.4 +++ ChangeLog 12 Aug 2005 23:01:44 -0000 1.5 @@ -3,8 +3,11 @@ CVS - * Better handling of line number in openexvis.py - * Changes in passing the visualization data + * Major changes to the code handling visualization data + * Major changes to visualization area + * Code area is now insensitive while visualizing + * Start in a maximized window + * Quit button is now resposive while visualizing * The Step button now works * Can load a file given as an argument at startup |
From: Tero K. <te...@us...> - 2005-08-12 23:01:54
|
Update of /cvsroot/openexvis/openexvis/gui_openexvis In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31453/gui_openexvis Modified Files: gui_openexvis.glade Log Message: Things are still heavily evolving, but there seem to be no big problems in the current code. Thus, I'm commiting now as the diffs are getting big and there have been many major changes. Index: gui_openexvis.glade =================================================================== RCS file: /cvsroot/openexvis/openexvis/gui_openexvis/gui_openexvis.glade,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- gui_openexvis.glade 8 Aug 2005 21:30:39 -0000 1.1.1.1 +++ gui_openexvis.glade 12 Aug 2005 23:01:46 -0000 1.2 @@ -625,8 +625,8 @@ <child> <widget class="GtkDrawingArea" id="visualizationArea"> <property name="visible">True</property> - <signal name="configure_event" handler="on_visualizationArea_configure_event" last_modification_time="Sun, 07 Aug 2005 18:41:43 GMT"/> <signal name="expose_event" handler="on_visualizationArea_expose_event" last_modification_time="Sun, 07 Aug 2005 18:41:48 GMT"/> + <signal name="size_allocate" handler="on_visualizationArea_size_allocate" last_modification_time="Thu, 11 Aug 2005 14:23:47 GMT"/> </widget> <packing> <property name="padding">0</property> |
From: Tero K. <te...@us...> - 2005-08-11 13:01:44
|
Update of /cvsroot/openexvis/openexvis In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18175 Modified Files: ChangeLog oev_dis.py openexvis.py visualizer.py Log Message: Changes to passing of visualization data. Better line number handling in openexvis.py. Index: openexvis.py =================================================================== RCS file: /cvsroot/openexvis/openexvis/openexvis.py,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- openexvis.py 10 Aug 2005 17:43:45 -0000 1.3 +++ openexvis.py 11 Aug 2005 13:01:28 -0000 1.4 @@ -103,20 +103,17 @@ # more comprehensible - something I wouldn't have needed to code at # all but it was a nice exercise. self.oevWindow.queue_draw() - # Split the data. - print "\nDEBUG: The List: ", visinfo - # The line number is a special case. - lineno = int(visinfo[0])-1 + #print "\nDEBUG: The data:\n", visinfo + # Store the line number and remove it from the list. + lineno = visinfo.pop(0) # For now, we just write this string on the visualization area. # In the future, it will have pretty pictures, animation and stuff. - s = '' - i = 1 - while i < len(visinfo) - 3: - # Everything after the line number is in groups of four items. - s += '\nAddr: ' + visinfo[i] - s += '\nOpcode: ' + visinfo[i+1] - s += '\nParam: ' + visinfo[i+2] + " " + visinfo[i+3] - i += 4 + s = '\nLineno: ' + str(lineno) + for d in visinfo: + print "Current entry: ", d + s += '\nAddr: ' + d['addr'] + s += '\nOpcode: ' + d['opcode'] + s += '\nParam: ' + d['oparg1'] + " " + d['oparg2'] # Mark the line we're visualizing on the code area. self.mark_line(lineno) # Set the text of the visualization area. @@ -141,7 +138,7 @@ self.cBuf.get_start_iter(), \ self.cBuf.get_end_iter()) # Highlight the line currently visualized. - si = self.cBuf.get_iter_at_line(lineno) + si = self.cBuf.get_iter_at_line(lineno-1) ei = si.copy() ei.forward_line() self.cBuf.apply_tag_by_name('visualize', si, ei) @@ -343,8 +340,8 @@ def main(): oev = OevGUI() - if len(sys.argv) > 1: - if len(sys.argv) > 2: + if sys.argv[1:]: + if sys.argv[2:]: print "Usage: openexvis.py [filename]" sys.exit(2) oev.prepare_file_load(sys.argv[1]) Index: oev_dis.py =================================================================== RCS file: /cvsroot/openexvis/openexvis/oev_dis.py,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- oev_dis.py 8 Aug 2005 21:30:39 -0000 1.1.1.1 +++ oev_dis.py 11 Aug 2005 13:01:28 -0000 1.2 @@ -17,18 +17,17 @@ def disassemble(co, lineno, lasti=-1): """Disassemble a code object. - This function will return a string containing the pieces of information - needed to visualize a certain bit of code and using ';' as a delimeter - between fields. The string consists of the following fields: + This function will return a list containing the data that's needed to + visualize the given code. The list consists of the following data: line number instruction address operating code name - operation parameters - operation parameters in natural language + operation argument1 + operation argument2 - Line number is given once for each line, others are given four at a time - as many times as needed to disassemble the whole line. + Line number is given once at index 0 of the list. Other information is + given once for each instruction as a dictionary. """ @@ -39,11 +38,11 @@ extended_arg = 0 free = None - # This is the string we will return. - s = '' - # We only want to build the string for the current line. This is used to - # control the concatenation of s. - docat = False + # This is the list we will return. + s = [] + # We only want to build the list for the current line. This is used to + # control building s. + do_appends = False while i < n: c = code[i] @@ -52,54 +51,63 @@ # This is the first operation on a line. if linestarts[i] is lineno: # This is the line we currently want to disassemble. - docat = True + do_appends = True + # Start s with the line number. + s.append(linestarts[i]) else: # We don't care of this line right now. - docat = False - if docat: - # Start s with the line number. - s = s + str(linestarts[i]) + ";" - else: - if docat: - s = s + ';' - - if docat: + do_appends = False + i = i+1 + if op >= HAVE_ARGUMENT: + i = i+2 + continue + if do_appends: + # We have another opcode from this line, create a new dictionary + # for it. We can overwrite the one for previous opcode if it + # exists, since it's already stored in s. + d = {} # The instruction address. - s = s + repr(i) + ';' + d['addr'] = repr(i) # The operating code name. - s = s + opname[op] + ';' - i = i+1 - if op >= HAVE_ARGUMENT: - # Print the arguments if the operation had them. - oparg = ord(code[i]) + ord(code[i+1])*256 + extended_arg - extended_arg = 0 - i = i+2 - if op == EXTENDED_ARG: - extended_arg = oparg*65536L - if docat: - s = s + repr(oparg) + ';' + d['opcode'] = opname[op] + i = i+1 + if op >= HAVE_ARGUMENT: + # Add the arguments if the operation had any. + oparg = ord(code[i]) + ord(code[i+1])*256 + extended_arg + extended_arg = 0 + i = i+2 + if op == EXTENDED_ARG: + extended_arg = oparg*65536L + d['oparg1'] = repr(oparg) if op in hasconst: - s = s + repr(co.co_consts[oparg]) + d['oparg2'] = repr(co.co_consts[oparg]) elif op in hasname: - s = s + co.co_names[oparg] + d['oparg2'] = co.co_names[oparg] elif op in hasjrel: - s = s + 'to ' + repr(i + oparg) + d['oparg2'] = repr(i + oparg) elif op in haslocal: - s = s + co.co_varnames[oparg] + d['oparg2'] = co.co_varnames[oparg] elif op in hascompare: - s = s + cmp_op[oparg] + d['oparg2'] = cmp_op[oparg] elif op in hasfree: if free is None: free = co.co_cellvars + co.co_freevars - s = s + free[oparg] + d['oparg2'] = free[oparg] + # If the operation didn't have two arguments, we store empty + # strings in the place of the inexistant ones. + if not d.has_key('oparg1'): + d['oparg1'] = '' + if not d.has_key('oparg2'): + d['oparg2'] = '' + s.append(d) else: - if docat: - # If the operation had no arguments, we put an empty string - # here to make parsing in the translator easier. - s = s + '' + ';' - # Return the string. + i = i+1 + if op >= HAVE_ARGUMENT: + i = i+2 + # Return the list. return s + ## # This is directly from dis.py ## Index: visualizer.py =================================================================== RCS file: /cvsroot/openexvis/openexvis/visualizer.py,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- visualizer.py 8 Aug 2005 21:30:39 -0000 1.1.1.1 +++ visualizer.py 11 Aug 2005 13:01:28 -0000 1.2 @@ -29,11 +29,19 @@ The translator calls this function giving the visualization data as an argument. The data is used for making the visualization. For now, we - simply split it to a list without converting it to commands. + simply send it forward without converting it to commands. + + The visualization data for one line is a list that contains the line + number as item 0 and for every operation a dictionary with the + following data: + + instruction's address + instruction's opcode + instruction's argument1 + instruction's argument2 """ - viscommands = visdata.split(';') - self.draw_step(viscommands, self.speed) + self.draw_step(visdata, self.speed) return True def visualize(self, code): Index: ChangeLog =================================================================== RCS file: /cvsroot/openexvis/openexvis/ChangeLog,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ChangeLog 10 Aug 2005 17:43:45 -0000 1.3 +++ ChangeLog 11 Aug 2005 13:01:28 -0000 1.4 @@ -3,6 +3,8 @@ CVS + * Better handling of line number in openexvis.py + * Changes in passing the visualization data * The Step button now works * Can load a file given as an argument at startup |
From: Tero K. <te...@us...> - 2005-08-10 17:43:54
|
Update of /cvsroot/openexvis/openexvis In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6917 Modified Files: ChangeLog openexvis.py Log Message: The step button now works. Index: openexvis.py =================================================================== RCS file: /cvsroot/openexvis/openexvis/openexvis.py,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- openexvis.py 10 Aug 2005 16:11:52 -0000 1.2 +++ openexvis.py 10 Aug 2005 17:43:45 -0000 1.3 @@ -20,6 +20,9 @@ self.version = "0.1.0" self.build_gui() self.speed = self.sSlider.get_value() + self.do_steps = False + self.step_fwd = False + self.visualizing = False def build_gui(self): """Create the widgets and set up the GUI.""" @@ -73,18 +76,24 @@ def draw_step(self, viscommands, speed): """Draw one visualization step.""" - # TODO: This isn't the final solution yet, naturally. self.update_pixmap(viscommands) self.refresh_screen() # This gives us a responsive window while visualizing. for i in range((11-speed)*2): - if self.speed == False: + while not self.speed: # We are paused. - while not self.speed: - gtk.main_iteration() + gtk.main_iteration() while gtk.events_pending(): gtk.main_iteration() time.sleep(0.05) + if self.do_steps: + while self.do_steps and not self.step_fwd: + # Loop until we are told to step forward or start running + # continuously. + gtk.main_iteration() + # We will visualize one step during the next draw_step call, make + # sure we stop to the above loop after it. + self.step_fwd = False return True def update_pixmap(self, visinfo): @@ -223,20 +232,43 @@ visualizing the code in the code buffer from the beginning. """ - if self.speed == 0: + if not self.speed: + # We are paused, set the speed so we proceed again. self.speed = self.sSlider.get_value() - return - self.visualize(self.get_code()) + if self.do_steps: + # We are stepping, start running continuously instead. + self.do_steps = False + else: + if not self.visualizing: + # Make sure the UI only calls visualize() once for one + # visualization. + self.visualizing = True + self.visualize(self.get_code()) + self.visualizing = False def on_stepButton_clicked(self, obj): """Start running the visualization one step at a time. - If we are paused, continue from where we left. Otherwise start + If we are paused, continue from where we left. If we are running a + visualization, change to running step by step. Otherwise, start visualizing the code in the code buffer from the beginning. """ - # TODO: Not implemented yet. - pass + if not self.speed: + # We are paused, set the speed so we can proceed. + self.speed = self.sSlider.get_value() + if self.do_steps: + # Give permission to proceed one step forward. + self.step_fwd = True + else: + self.do_steps = True + if not self.visualizing: + # Make sure the UI only calls visualize() once for one + # visualization. + self.visualizing = True + self.visualize(self.get_code()) + self.visualizing = False + self.do_steps = False def on_pauseButton_clicked(self, obj): """Pause the visualization to the line where we are.""" Index: ChangeLog =================================================================== RCS file: /cvsroot/openexvis/openexvis/ChangeLog,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- ChangeLog 10 Aug 2005 16:11:52 -0000 1.2 +++ ChangeLog 10 Aug 2005 17:43:45 -0000 1.3 @@ -3,6 +3,7 @@ CVS + * The Step button now works * Can load a file given as an argument at startup 0.1.0 |
From: Tero K. <te...@us...> - 2005-08-10 16:12:28
|
Update of /cvsroot/openexvis/openexvis In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17813 Modified Files: ChangeLog openexvis.py Log Message: Can load a file given as an argument at startup. Index: openexvis.py =================================================================== RCS file: /cvsroot/openexvis/openexvis/openexvis.py,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -u -d -r1.1.1.1 -r1.2 --- openexvis.py 8 Aug 2005 21:30:39 -0000 1.1.1.1 +++ openexvis.py 10 Aug 2005 16:11:52 -0000 1.2 @@ -7,6 +7,7 @@ import gtksourceview import mimetypes import os +import sys import time import visualizer @@ -167,12 +168,14 @@ try: code = open(path).read() except: + print "Failed to load file ", filename return False self.cBuf.set_text(code) self.cBuf.set_data('filename', path) self.cBuf.end_not_undoable_action() self.cBuf.set_modified(False) self.cBuf.place_cursor(self.cBuf.get_start_iter()) + print "Loaded ", filename def save_file(self, filename): """Save the current code buffer to given file.""" @@ -272,7 +275,7 @@ self.save_file(filename) print 'Saved as ', filename elif response == gtk.RESPONSE_CANCEL: - print 'Closed, not saved' + print 'Not saved' dialog.destroy() on_menuRun_activate = on_runButton_clicked @@ -308,6 +311,12 @@ def main(): oev = OevGUI() + if len(sys.argv) > 1: + if len(sys.argv) > 2: + print "Usage: openexvis.py [filename]" + sys.exit(2) + oev.prepare_file_load(sys.argv[1]) + oev.load_file(sys.argv[1]) oev.oev() if __name__=='__main__': Index: ChangeLog =================================================================== RCS file: /cvsroot/openexvis/openexvis/ChangeLog,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- ChangeLog 8 Aug 2005 22:42:01 -0000 1.1 +++ ChangeLog 10 Aug 2005 16:11:52 -0000 1.2 @@ -1,6 +1,10 @@ OpenExVis Changelog =================== +CVS + + * Can load a file given as an argument at startup + 0.1.0 * First public release |
From: Tero K. <te...@us...> - 2005-08-10 03:02:30
|
Update of /cvsroot/openexvis/openexvis In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6199 Added Files: ChangeLog Log Message: Add a changelog. --- NEW FILE: ChangeLog --- OpenExVis Changelog =================== 0.1.0 * First public release |