/[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 281 by johnpye, Wed Feb 8 08:31:56 2006 UTC revision 282 by johnpye, Wed Feb 8 13:51:04 2006 UTC
# Line 18  class DiagnoseWindow: Line 18  class DiagnoseWindow:
18          _xml.signal_autoconnect(self)            _xml.signal_autoconnect(self)  
19    
20          self.window = _xml.get_widget("diagnosewin")          self.window = _xml.get_widget("diagnosewin")
21          self.view = _xml.get_widget("canvasvbox")          self.image = _xml.get_widget("image")
22          self.blockentry = _xml.get_widget("blockentry")          self.blockentry = _xml.get_widget("blockentry")
23    
24          self.varview = _xml.get_widget("varview")          self.varview = _xml.get_widget("varview")
# Line 55  class DiagnoseWindow: Line 55  class DiagnoseWindow:
55          self.block = block          self.block = block
56          self.blockentry.set_text(str(block))          self.blockentry.set_text(str(block))
57                    
58          if self.canvas:          # refer http://pygtk.org/pygtk2tutorial/sec-DrawingMethods.html
59              self.view.remove(self.canvas)          c = chr(255)
60            b = self.im.getNumRows()*self.im.getNumCols()*3*[c]
61          # This is not going to be very efficient at this stage:          rowstride = 3 * self.im.getNumCols()
         mtx = pylab.zeros((self.im.getNumRows(), self.im.getNumCols(), ))*0.  
62          for i in self.data:          for i in self.data:
63              mtx[i.row, i.col] = int(i.type)              pos = rowstride*i.row + 3*i.col
64                b[pos], b[pos+1], b[pos+2] = [chr(0)]*3
65          # prepare colour map          
66          cmapdata = {          d = ''.join(b)
67                        # type = 0     type = 1       type = 2          pb = gtk.gdk.pixbuf_new_from_data(d, gtk.gdk.COLORSPACE_RGB, False, 8 \
68                        # norelation   active fixed   active free                  , self.im.getNumCols(), self.im.getNumRows(), rowstride)
69              'red'  :  ((0., 1., 1.), (0.5, 0., 0.), (1., 0., 0.)),      
70              'green':  ((0., 1., 1.), (0.5, 1., 1.), (1., 0., 0.)),          pb1 = pb.scale_simple(400,400,gtk.gdk.INTERP_BILINEAR)
71              'blue' :  ((0., 1., 1.), (0.5, 0., 0.), (1., 0.3, 0.3))          del pb;
         }  
   
         _im_cmap =  LinearSegmentedColormap('im_cmap',  cmapdata, 4)  
   
         self.figure = pylab.Figure(figsize=(6,4), dpi=72)  
         _axes = self.figure.add_subplot(111)  
         _axes.set_xlabel('Variables')  
         _axes.set_ylabel('Relations')  
         _axes.set_title('Block Incidence Matrix')  
         _axes.grid(True)  
         _axes.imshow(mtx, cmap=_im_cmap, interpolation='nearest')  
   
         self.canvas = FigureCanvasGTK(self.figure) # a gtk.DrawingArea  
         self.canvas.show()  
72    
73          self.view.pack_start(self.canvas, True, True)          self.image.set_from_pixbuf(pb1)
74    
75          self.fill_var_names()          self.fill_var_names()
76          self.fill_rel_names()          self.fill_rel_names()

Legend:
Removed from v.281  
changed lines
  Added in v.282

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