/[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 437 by johnpye, Tue Apr 4 11:08:15 2006 UTC
# Line 6  from operator import itemgetter Line 6  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          self.imagescroll = _xml.get_widget("imagescroll")          self.imagescroll = _xml.get_widget("imagescroll")
26          self.image = _xml.get_widget("image")          self.image = _xml.get_widget("image")
27          self.blockentry = _xml.get_widget("blockentry")          self.blockentry = _xml.get_widget("blockentry")
# Line 41  class DiagnoseWindow: Line 45  class DiagnoseWindow:
45          self.relbuf = gtk.TextBuffer()          self.relbuf = gtk.TextBuffer()
46          self.relview.set_buffer(self.relbuf)          self.relview.set_buffer(self.relbuf)
47    
48            self.im = None
49          self.block = 0          self.block = 0
50            self.apply_prefs()
51    
52          self.prepare_data()          self.prepare_data()
53          self.fill_values(block) # block zero          self.fill_values(block) # block zero
54    
# Line 49  class DiagnoseWindow: Line 56  class DiagnoseWindow:
56          self.window.run()          self.window.run()
57          self.window.hide()          self.window.hide()
58    
59        def apply_prefs(self):
60            vc = self.browser.prefs.getBoolPref("Diagnose","varcollapsed",True)
61    
62            print "VARCOLLAPSED =",vc
63            self.varcollapsed.set_active(vc)
64            self.relcollapsed.set_active(self.browser.prefs.getBoolPref("Diagnose","relcollapsed",True))
65    
66      def prepare_data(self):      def prepare_data(self):
67          # convert incidence map to pylab numarray type:          # convert incidence map to pylab numarray type:
68          print "PREPARING DATA"          print "PREPARING DATA"
# Line 59  class DiagnoseWindow: Line 73  class DiagnoseWindow:
73          self.zoom=1;          self.zoom=1;
74            
75      def fill_values(self, block):      def fill_values(self, block):
76            
77          try:          try:
78              rl,cl,rh,ch = self.im.getBlockLocation(block)              rl,cl,rh,ch = self.im.getBlockLocation(block)
79          except IndexError:          except IndexError:
80              self.blockentry.set_text(str(self.block))              if block >= self.im.getNumBlocks():
81              return                  block = self.im.getNumBlocks() - 1
82          except RuntimeError:                  rl,cl,rh,ch = self.im.getBlockLocation(block)
83                else:              
84                    print "BLOCK INDEX ERROR: block =",block
85                    self.blockentry.set_text(str(self.block))
86                    return
87            except RuntimeError,e:
88                print "ERROR GETTING BLOCK LOCATION:",str(e)
89              self.blockentry.set_text(str(self.block))              self.blockentry.set_text(str(self.block))
90              return              return
91    
# Line 235  class DiagnoseWindow: Line 256  class DiagnoseWindow:
256      # GUI EVENT HOOKS-----------------------------------------------------------      # GUI EVENT HOOKS-----------------------------------------------------------
257    
258      def on_varcollapsed_toggled(self,*args):      def on_varcollapsed_toggled(self,*args):
259          print "COLLAPSED-TOGGLED"          vc = self.varcollapsed.get_active()
260          self.fill_var_names()          self.browser.prefs.setBoolPref("Diagnose","varcollapsed",vc)    
261            if self.im:
262                self.fill_var_names()
263    
264      def on_relcollapsed_toggled(self,*args):      def on_relcollapsed_toggled(self,*args):
265          print "COLLAPSED-TOGGLED"          rc = self.varcollapsed.get_active()
266          self.fill_rel_names()          self.browser.prefs.setBoolPref("Diagnose","relcollapsed",rc)    
267            if self.im:
268                self.fill_rel_names()
269    
270      def on_nextbutton_clicked(self,*args):      def on_nextbutton_clicked(self,*args):
271          self.set_block(self.block + 1)          self.set_block(self.block + 1)

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

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