Go to the documentation of this file.00001 """
00002 ASAP plotting class based on matplotlib.
00003 """
00004
00005 from asap.asaplotbase import *
00006
00007 import gtk
00008 import matplotlib
00009 from matplotlib.backends.backend_gtkagg import FigureCanvasGTKAgg as FigureCanvas
00010 from matplotlib.backends.backend_gtkagg import FigureManagerGTKAgg
00011 matplotlib.use("GTkAgg")
00012 matplotlib.rcParams['toolbar'] = 'toolbar2'
00013 from matplotlib.backends.backend_gtk import NavigationToolbar2GTK as NavigationToolbar
00014 from matplotlib import _pylab_helpers
00015
00016 class asaplotgui(asaplotbase):
00017 """
00018 ASAP plotting class based on matplotlib.
00019 """
00020
00021 def __init__(self, rows=1, cols=0, title='', size=None, buffering=False):
00022 """
00023 Create a new instance of the ASAPlot plotting class.
00024
00025 If rows < 1 then a separate call to set_panels() is required to define
00026 the panel layout; refer to the doctext for set_panels().
00027 """
00028 v = vars()
00029 del v['self']
00030
00031 asaplotbase.__init__(self, **v)
00032 matplotlib.rcParams['interactive'] = True
00033 matplotlib.interactive = True
00034
00035 _pylab_helpers.Gcf.destroy(0)
00036 self.canvas = FigureCanvas(self.figure)
00037
00038 self.figmgr = FigureManagerGTKAgg(self.canvas, 1)
00039 def dest_callback(val):
00040 self.is_dead = True
00041 self.figmgr.window.destroy()
00042 self.window = self.figmgr.window
00043 self.window.connect("destroy", dest_callback )
00044 self.window.set_title('ASAP Plotter - GTK')
00045
00046 _pylab_helpers.Gcf.figs[self.figmgr.num] = self.figmgr
00047
00048
00049
00050 def map(self):
00051 """
00052 Reveal the ASAPlot graphics window and bring it to the top of the
00053 window stack.
00054 """
00055 if self.is_dead:
00056 raise RuntimeError( "No plotter to show. Not yet plotted or plotter is closed." )
00057 self.window.deiconify()
00058
00059
00060 def quit(self):
00061 """
00062 Destroy the ASAPlot graphics window.
00063 """
00064 self.is_dead = True
00065 if not self.figmgr:
00066 return
00067
00068 _pylab_helpers.Gcf.destroy(self.figmgr.num)
00069 del self.window, self.canvas, self.figmgr
00070 self.window = None
00071 self.canvas = None
00072 self.figmgr = None
00073
00074 def show(self, hardrefresh=True):
00075 """
00076 Show graphics dependent on the current buffering state.
00077 """
00078 if self.is_dead:
00079 raise RuntimeError( "No plotter to show (not yet plotted or closed)." )
00080 if not self.buffering:
00081 if hardrefresh:
00082 asaplotbase.show(self, hardrefresh)
00083 self.window.deiconify()
00084 self.canvas.draw()
00085 self.window.show_all()
00086
00087 def terminate(self):
00088 """
00089 Clear the figure.
00090 """
00091 if not self.window:
00092 asaplog.push( "No plotter window to terminate." )
00093 asaplog.post( "WARN" )
00094 return
00095 self.window.destroy()
00096
00097 def unmap(self):
00098 """
00099 Hide the ASAPlot graphics window.
00100 """
00101 if not self.window:
00102 asaplog.push( "No plotter window to unmap." )
00103 asaplog.post( "WARN" )
00104 return
00105 self.window.wm_withdraw()