/[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 669 by johnpye, Wed Jun 21 07:00:45 2006 UTC revision 735 by johnpye, Wed Jul 5 02:42:19 2006 UTC
# Line 7  import math Line 7  import math
7  import re  import re
8    
9  import config  import config
10    from infodialog import *
11    
12  ZOOM_RE = re.compile(r"([0-9]+)\s*%?")  ZOOM_RE = re.compile(r"([0-9]+)\s*%?")
13  MAX_ZOOM_SIZE = 2000  MAX_ZOOM_SIZE = 2000
# Line 39  class DiagnoseWindow: Line 40  class DiagnoseWindow:
40    
41          self.varname = _xml.get_widget("varname");          self.varname = _xml.get_widget("varname");
42          self.varval = _xml.get_widget("varval");          self.varval = _xml.get_widget("varval");
43            self.varinfobutton = _xml.get_widget("varinfobutton");
44          self.relname = _xml.get_widget("relname");          self.relname = _xml.get_widget("relname");
45          self.relresid = _xml.get_widget("relresid");          self.relresid = _xml.get_widget("relresid");
46            self.relinfobutton = _xml.get_widget("relinfobutton")
47    
48          self.varview = _xml.get_widget("varview")          self.varview = _xml.get_widget("varview")
49          self.varbuf = gtk.TextBuffer()          self.varbuf = gtk.TextBuffer()
# Line 177  class DiagnoseWindow: Line 180  class DiagnoseWindow:
180          self.fill_var_names()          self.fill_var_names()
181          self.fill_rel_names()          self.fill_rel_names()
182            
183          self.varname.set_text("");          self.fill_selection_info()
         self.varval.set_text("");  
         self.relname.set_text("");  
         self.relresid.set_text("");  
184    
185          print "DONE FILL VALUES"          print "DONE FILL VALUES"
186    
187        def fill_selection_info(self):
188            if self.var:
189                self.varname.set_text(self.var.getName())
190                self.varval.set_text(str(self.var.getValue()))
191                self.varinfobutton.set_sensitive(True)
192            else:
193                self.varname.set_text("")
194                self.varval.set_text("")
195                self.varinfobutton.set_sensitive(False)
196    
197            if self.rel:
198                self.relname.set_text(self.rel.getName())
199                self.relresid.set_text(str(self.rel.getResidual()))
200                self.relinfobutton.set_sensitive(True)
201            else:
202                self.relname.set_text("")
203                self.relresid.set_text("")
204                self.relinfobutton.set_sensitive(False)
205    
206      def do_zoom(self):      def do_zoom(self):
207          if self.zoom == -1:          if self.zoom == -1:
208              w, h = self.imagescroll.size_request()              w, h = self.imagescroll.size_request()
# Line 275  class DiagnoseWindow: Line 294  class DiagnoseWindow:
294          if c > self.ch or r > self.rh:          if c > self.ch or r > self.rh:
295              #print "OUT OF RANGE"              #print "OUT OF RANGE"
296              return              return
297          var = self.im.getVariable(c)          self.var = self.im.getVariable(c)
298          self.varname.set_text(var.getName())          self.rel = self.im.getRelation(r)
299          self.varval.set_text(str(var.getValue()))          self.fill_selection_info()
         rel = self.im.getRelation(r)  
         self.relname.set_text(rel.getName())  
         self.relresid.set_text(str(rel.getResidual()))  
300    
301      # GUI EVENT HOOKS-----------------------------------------------------------      # GUI EVENT HOOKS-----------------------------------------------------------
302    
303        def on_diagnosewin_close(self,*args):
304            self.window.response(gtk.RESPONSE_CLOSE);
305    
306        # incidence data view
307    
308      def on_varcollapsed_toggled(self,*args):      def on_varcollapsed_toggled(self,*args):
309          vc = self.varcollapsed.get_active()          vc = self.varcollapsed.get_active()
310          self.browser.prefs.setBoolPref("Diagnose","varcollapsed",vc)              self.browser.prefs.setBoolPref("Diagnose","varcollapsed",vc)    
# Line 296  class DiagnoseWindow: Line 317  class DiagnoseWindow:
317          if self.im:          if self.im:
318              self.fill_rel_names()              self.fill_rel_names()
319    
320        # detailed information about vars and rels (solver-side information!)
321    
322        def on_varinfobutton_clicked(self,*args):
323            title = "Variable '%s'" % self.var
324            text = "%s\n%s\n" % (title,"(from the solver's view)")
325            text += "\n%-30s%15f" % ("Value", self.var.getValue())
326            text += "\n%-30s%15f" % ("Nominal", self.var.getNominal())
327            text += "\n%-30s%15f" % ("Lower bound", self.var.getLowerBound())
328            text += "\n%-30s%15f" % ("Upper bound", self.var.getUpperBound())
329            
330            text += "\n\nIncidence with %d relations:" % self.var.getNumIncidentRelations()
331            for r in self.var.getIncidentRelations():
332                text += "\n%s" % r.getName()
333    
334            _dialog = InfoDialog(self.browser,self.window,text,title)
335            _dialog.run()
336    
337        def on_relinfobutton_clicked(self,*args):
338            title = "Relation '%s'" % self.rel
339            text = "%s\n%s\n" % (title,"(from the solver's view)")
340            text += "\n%-30s%15f" % ("Residual", self.rel.getResidual())
341    
342            _dialog = InfoDialog(self.browser,self.window,text,title)
343            _dialog.run()
344            
345    
346        # block navigation
347    
348      def on_nextbutton_clicked(self,*args):      def on_nextbutton_clicked(self,*args):
349          self.set_block(self.block + 1)          self.set_block(self.block + 1)
350    
# Line 327  class DiagnoseWindow: Line 376  class DiagnoseWindow:
376          if keyname=="Return":          if keyname=="Return":
377              self.set_block( int(self.blockentry.get_text()) )              self.set_block( int(self.blockentry.get_text()) )
378    
379        # zoom in and out
380    
381      def on_zoominbutton_clicked(self,*args):      def on_zoominbutton_clicked(self,*args):
382          z = int( math.log(self.zoom)/math.log(2) )          z = int( math.log(self.zoom)/math.log(2) )
383          z = pow(2,z + 1);          z = pow(2,z + 1);
# Line 349  class DiagnoseWindow: Line 400  class DiagnoseWindow:
400                  print m                  print m
401              self.set_zoom( int(self.zoomentry.get_text()) )              self.set_zoom( int(self.zoomentry.get_text()) )
402    
403        # clicking in incidence matrix to get updated information at RHS
404    
405      def on_imageevent_motion_notify_event(self,widget,event):      def on_imageevent_motion_notify_event(self,widget,event):
406          self.show_cursor(event.x, event.y)          self.show_cursor(event.x, event.y)
407    

Legend:
Removed from v.669  
changed lines
  Added in v.735

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