From: Tero K. <te...@us...> - 2005-08-15 14:12:18
|
Update of /cvsroot/openexvis/openexvis In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3545 Modified Files: oevt_python.py openexvis.py visualizer.py Log Message: Smoother animation. Constant visualization improved. Index: oevt_python.py =================================================================== RCS file: /cvsroot/openexvis/openexvis/oevt_python.py,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- oevt_python.py 15 Aug 2005 13:35:35 -0000 1.4 +++ oevt_python.py 15 Aug 2005 14:12:09 -0000 1.5 @@ -62,8 +62,6 @@ olderconst = lastconst lastconst = op['oparg2'] elif op['opcode'] == 'STORE_NAME' or op['opcode'] == 'STORE_ATTR': - # TODO: I'm afraid this could be inadequate information to - # pass forward. # Storing the last constant in the given variable. self.variables[op['oparg2']] = lastconst #print "DEBUG: variables == ", self.variables Index: openexvis.py =================================================================== RCS file: /cvsroot/openexvis/openexvis/openexvis.py,v retrieving revision 1.8 retrieving revision 1.9 diff -u -d -r1.8 -r1.9 --- openexvis.py 15 Aug 2005 13:35:35 -0000 1.8 +++ openexvis.py 15 Aug 2005 14:12:09 -0000 1.9 @@ -181,10 +181,6 @@ while gtk.events_pending(): gtk.main_iteration() 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 @@ -206,10 +202,9 @@ # 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': - # cmd[1] is the constant to show. - if cmd[1] != 'None': - self.draw_show_constant(cmd[1]) + elif cmd[0] == 'SHOW_CONSTANTS': + # cmd[1] is the constant list. + self.draw_show_constants(cmd[1]) elif cmd[0] == 'SHOW_VARIABLES': # cmd[1] is the variable list. self.draw_show_variables(cmd[1]) @@ -299,6 +294,8 @@ # Draw the element. self.pixmap.draw_drawable(self.gc, i[4], 0, 0, i[0], i[2], -1, -1) self.refresh_screen() + # Higher speed setting gives higher speed like this. + time.sleep((11-self.speed) * 0.05) return moresteps # NOTE: To grok the following draw_show_* methods, see do_frame_pixmap. @@ -344,7 +341,6 @@ def draw_show_variables(self, cur_vars): """Store displaying the variables in the visualization pixmap.""" - #print "DEBUG: cur_vars == ", cur_vars pos = 0 for v in cur_vars: x = self.var_pos[0] @@ -355,14 +351,22 @@ self.do_frame_pixmap(self.var_color, w, h, x, x, y, y, txt) pos += 1 - 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_constants(self, cur_consts): + """Store displaying the constants in the visualization pixmap.""" + pos = 0 + for c in cur_consts: + print "DEBUG: c == ", c + if c == 'None': + continue + # We draw the static constants one column left from where moving + # ones start. + x = self.const_start[0] - self.gridw + y = self.const_start[1] + (self.gridh * pos) + w = self.gridw * 2 + h = self.gridh + txt = self.vArea.create_pango_layout(c[:8]) + self.do_frame_pixmap(self.static_const_color, w, h, x, x, y, y, txt) + pos += 1 def draw_show_storing(self, constant): """Store a constant moved to a variable in the visualization pixmap.""" Index: visualizer.py =================================================================== RCS file: /cvsroot/openexvis/openexvis/visualizer.py,v retrieving revision 1.5 retrieving revision 1.6 diff -u -d -r1.5 -r1.6 --- visualizer.py 15 Aug 2005 13:35:35 -0000 1.5 +++ visualizer.py 15 Aug 2005 14:12:09 -0000 1.6 @@ -53,28 +53,30 @@ # should be documented well somewhere. Now they're not as they're still # evolving. cmd = [] - cur_vars = [] # TODO: Use to separate multiple vars. + cur_vars = [] + cur_consts = [] for item in data: c = item.split(':') #print "DEBUG: c == ", c if c[0] == 'GET_CONSTANT': # c[1] is the constant to show. - cmd.append(['SHOW_CONSTANT', c[1]]) + cur_consts.append(c[1]) + print "DEBUG: cur_consts == ", cur_consts + cmd.append(['SHOW_CONSTANTS', cur_consts]) elif c[0] == 'STORE_VARIABLE': # c[1] is the variable name to store to. # c[2] is the variable value. # c[3] is the constant to store. # TODO: This, especially, requires some more thought. cur_vars.append([c[1], c[2]]) - print "DEBUG: vis cur_vars == ", cur_vars + #cur_consts.append(c[3]) cmd.append(['SHOW_VARIABLES', cur_vars]) - cmd.append(['SHOW_CONSTANT', c[3]]) + #cmd.append(['SHOW_CONSTANTS', cur_consts]) cmd.append(['SHOW_STORING', c[3], c[1]]) elif c[0] == 'LOAD': # c[1] is the variable name. # c[2] is the variable value. cur_vars.append([c[1], c[2]]) - print "DEBUG: vis cur_vars == ", cur_vars cmd.append(['SHOW_VARIABLES', cur_vars]) elif c[0] == 'BEGIN_LOOP': cmd.append(['SHOW_LOOP']) @@ -92,6 +94,8 @@ cmd.append(['OUTPUT', c[1]]) elif c[0] == 'RETURN': cmd.append(['RETURN']) + else: + print "No drawing command for ", c[0], ". Whole list was: ", c return cmd def visualize(self, code): |