/[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 291 by johnpye, Fri Feb 10 03:32:21 2006 UTC revision 463 by johnpye, Sun Apr 16 10:18:16 2006 UTC
# Line 1  Line 1 
1  import gtk  import gtk
2  import gtk.glade  import gtk.glade
3  import ascend  import ascpy
4  from itertools import groupby  from itertools import groupby
5  from operator import itemgetter  from operator import itemgetter
6  import math  import math
7  import re  import re
8    
9    import config
10    
11  ZOOM_RE = re.compile(r"([0-9]+)\s*%?")  ZOOM_RE = re.compile(r"([0-9]+)\s*%?")
12  MAX_ZOOM_SIZE = 2000  MAX_ZOOM_SIZE = 2000
13  MAX_ZOOM_RATIO = 16  MAX_ZOOM_RATIO = 16
14  AT_BOUND_TOL = 0.0001;  AT_BOUND_TOL = 0.0001;
15    
16  class DiagnoseWindow:  class DiagnoseWindow:
17      def __init__(self,GLADE_FILE,browser,block=0):      def __init__(self,browser,block=0):
18          self.browser=browser          self.browser=browser
19          _xml = gtk.glade.XML(GLADE_FILE,"diagnosewin")          _xml = gtk.glade.XML(browser.glade_file,"diagnosewin")
20          _xml.signal_autoconnect(self)            _xml.signal_autoconnect(self)  
21    
22          self.window = _xml.get_widget("diagnosewin")          self.window = _xml.get_widget("diagnosewin")
23            self.window.set_transient_for(self.browser.window)
24    
25            _icon = gtk.Image()
26            _iconpath = browser.assets_dir+'diagnose'+config.ICON_EXTENSION
27            _icon.set_from_file(_iconpath)
28            self.window.set_icon(_icon)
29            
30          self.imagescroll = _xml.get_widget("imagescroll")          self.imagescroll = _xml.get_widget("imagescroll")
31          self.image = _xml.get_widget("image")          self.image = _xml.get_widget("image")
32          self.blockentry = _xml.get_widget("blockentry")          self.blockentry = _xml.get_widget("blockentry")
# Line 41  class DiagnoseWindow: Line 50  class DiagnoseWindow:
50          self.relbuf = gtk.TextBuffer()          self.relbuf = gtk.TextBuffer()
51          self.relview.set_buffer(self.relbuf)          self.relview.set_buffer(self.relbuf)
52    
53            self.im = None
54          self.block = 0          self.block = 0
55            self.apply_prefs()
56    
57          self.prepare_data()          self.prepare_data()
58          self.fill_values(block) # block zero          self.fill_values(block) # block zero
59    
# Line 49  class DiagnoseWindow: Line 61  class DiagnoseWindow:
61          self.window.run()          self.window.run()
62          self.window.hide()          self.window.hide()
63    
64        def apply_prefs(self):
65            vc = self.browser.prefs.getBoolPref("Diagnose","varcollapsed",True)
66    
67            print "VARCOLLAPSED =",vc
68            self.varcollapsed.set_active(vc)
69            self.relcollapsed.set_active(self.browser.prefs.getBoolPref("Diagnose","relcollapsed",True))
70    
71      def prepare_data(self):      def prepare_data(self):
72          # convert incidence map to pylab numarray type:          # convert incidence map to pylab numarray type:
73          print "PREPARING DATA"          print "PREPARING DATA"
# Line 59  class DiagnoseWindow: Line 78  class DiagnoseWindow:
78          self.zoom=1;          self.zoom=1;
79            
80      def fill_values(self, block):      def fill_values(self, block):
81            
82          try:          try:
83              rl,cl,rh,ch = self.im.getBlockLocation(block)              rl,cl,rh,ch = self.im.getBlockLocation(block)
84          except IndexError:          except IndexError:
85              self.blockentry.set_text(str(self.block))              if block >= self.im.getNumBlocks():
86              return                  block = self.im.getNumBlocks() - 1
87          except RuntimeError:                  rl,cl,rh,ch = self.im.getBlockLocation(block)
88                else:              
89                    print "BLOCK INDEX ERROR: block =",block
90                    self.blockentry.set_text(str(self.block))
91                    return
92            except RuntimeError,e:
93                print "ERROR GETTING BLOCK LOCATION:",str(e)
94              self.blockentry.set_text(str(self.block))              self.blockentry.set_text(str(self.block))
95              return              return
96    
# Line 235  class DiagnoseWindow: Line 261  class DiagnoseWindow:
261      # GUI EVENT HOOKS-----------------------------------------------------------      # GUI EVENT HOOKS-----------------------------------------------------------
262    
263      def on_varcollapsed_toggled(self,*args):      def on_varcollapsed_toggled(self,*args):
264          print "COLLAPSED-TOGGLED"          vc = self.varcollapsed.get_active()
265          self.fill_var_names()          self.browser.prefs.setBoolPref("Diagnose","varcollapsed",vc)    
266            if self.im:
267                self.fill_var_names()
268    
269      def on_relcollapsed_toggled(self,*args):      def on_relcollapsed_toggled(self,*args):
270          print "COLLAPSED-TOGGLED"          rc = self.varcollapsed.get_active()
271          self.fill_rel_names()          self.browser.prefs.setBoolPref("Diagnose","relcollapsed",rc)    
272            if self.im:
273                self.fill_rel_names()
274    
275      def on_nextbutton_clicked(self,*args):      def on_nextbutton_clicked(self,*args):
276          self.set_block(self.block + 1)          self.set_block(self.block + 1)

Legend:
Removed from v.291  
changed lines
  Added in v.463

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