/[ascend]/trunk/pygtk/diagnose.py
ViewVC logotype

Diff of /trunk/pygtk/diagnose.py

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 285 by johnpye, Thu Feb 9 04:21:30 2006 UTC revision 286 by johnpye, Thu Feb 9 07:36:39 2006 UTC
# Line 22  class DiagnoseWindow: Line 22  class DiagnoseWindow:
22          self.blockentry = _xml.get_widget("blockentry")          self.blockentry = _xml.get_widget("blockentry")
23          self.zoomentry = _xml.get_widget("zoomentry")          self.zoomentry = _xml.get_widget("zoomentry")
24    
25            self.varname = _xml.get_widget("varname");
26            self.varval = _xml.get_widget("varval");
27            self.relname = _xml.get_widget("relname");
28            self.relresid = _xml.get_widget("relresid");
29    
30          self.varview = _xml.get_widget("varview")          self.varview = _xml.get_widget("varview")
31          self.varbuf = gtk.TextBuffer()          self.varbuf = gtk.TextBuffer()
32          self.varview.set_buffer(self.varbuf)          self.varview.set_buffer(self.varbuf)
# Line 65  class DiagnoseWindow: Line 70  class DiagnoseWindow:
70          self.block = block          self.block = block
71          self.blockentry.set_text(str(block))          self.blockentry.set_text(str(block))
72    
73            self.rl = rl
74            self.cl = cl
75            self.rh = rh
76            self.ch = ch
77    
78          nr = int(rh-rl+1);          nr = int(rh-rl+1);
79          nc = int(ch-cl+1);          nc = int(ch-cl+1);
80    
# Line 129  class DiagnoseWindow: Line 139  class DiagnoseWindow:
139    
140          self.fill_var_names()          self.fill_var_names()
141          self.fill_rel_names()          self.fill_rel_names()
142        
143            self.varname.set_text("");
144            self.varval.set_text("");
145            self.relname.set_text("");
146            self.relresid.set_text("");
147    
148    
149      def do_zoom(self):      def do_zoom(self):
150          if self.zoom == -1:          if self.zoom == -1:
# Line 189  class DiagnoseWindow: Line 205  class DiagnoseWindow:
205          self.zoom = zoom          self.zoom = zoom
206          self.do_zoom()          self.do_zoom()
207    
208        def show_cursor(self,x,y):
209            c = self.cl + int(x/self.zoom)
210            r = self.rl + int(y / self.zoom)
211            if c > self.ch or r > self.rh:
212                #print "OUT OF RANGE"
213                return
214            var = self.im.getVariable(c)
215            self.varname.set_text(var.getName())
216            self.varval.set_text(str(var.getValue()))
217            rel = self.im.getRelation(r)
218            self.relname.set_text(rel.getName())
219            self.relresid.set_text(str(rel.getResidual()))
220    
221        # GUI EVENT HOOKS-----------------------------------------------------------
222    
223      def on_varcollapsed_toggled(self,*args):      def on_varcollapsed_toggled(self,*args):
224          print "COLLAPSED-TOGGLED"          print "COLLAPSED-TOGGLED"
225          self.fill_var_names()          self.fill_var_names()
# Line 231  class DiagnoseWindow: Line 262  class DiagnoseWindow:
262                  print m                  print m
263              self.set_zoom( int(self.zoomentry.get_text()) )              self.set_zoom( int(self.zoomentry.get_text()) )
264    
265        def on_imageevent_motion_notify_event(self,widget,event):
266            self.show_cursor(event.x, event.y)
267    
268        def on_imageevent_button_press_event(self,widget,event):
269            self.show_cursor(event.x, event.y)
270    
271    
272  # The following is from  # The following is from
273  # http://www.experts-exchange.com/Programming/Programming_Languages/Python/Q_21719649.html  # http://www.experts-exchange.com/Programming/Programming_Languages/Python/Q_21719649.html
274  # it's still buggy.  # it's still buggy.
# Line 264  def collapse(names): Line 302  def collapse(names):
302      for k, g in groupby(data, lambda x: len(x)):      for k, g in groupby(data, lambda x: len(x)):
303          item = g.next()          item = g.next()
304          assert len(item) == k          assert len(item) == k
305          key = '.'.join(item[:-1])          key = '.'.join(item[:-1]) or ''
306          indexed = {}          indexed = {}
307          seq = set(get(indexed, item))          seq = set([get(indexed, item)])
308          for item in g:          for item in g:
309              seq.add(get(indexed, item))              seq.add(get(indexed, item))
310          res[key] = [i+fold(indexed.get(i, [])) for i in sorted(seq)]          res[key] = [i+fold(indexed.get(i, [])) for i in sorted(seq)]

Legend:
Removed from v.285  
changed lines
  Added in v.286

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22