source: SHX/trunk/sandbox/traceplotter.py @ 394

Revision 394, 1.6 KB checked in by marcus, 13 years ago (diff)

more plotting tests

  • Property svn:eol-style set to native
Line 
1# -*- coding: utf-8 -*-
2
3import wx
4import wx.lib.scrolledpanel as SP
5from SeismicHandler.core import read
6
7class MyPanel(SP.ScrolledPanel):
8    def __init__(self, parent):
9        SP.ScrolledPanel.__init__(self, parent, style=wx.BORDER_SIMPLE)
10        self.Bind(wx.EVT_PAINT, self.OnPaint)
11#        self.Bind(wx.EVT_RESIZE, self.OnPaint)
12        self.Bind(wx.EVT_IDLE, self.OnIdle)
13        self.refresh = False
14        self.OnPaint(None)
15
16        st = read("/online4/2011/GR/BFO/BHZ.D/GR.BFO..BHZ.D.2011.124")
17        self.tr = st[0]
18
19    def OnIdle(self, evt):
20        if self.refresh:
21            self.Paint()
22            self.refresh = False
23
24    def OnPaint(self, evt):
25        self.refresh = True
26
27    def Paint(self):
28        width, height = self.GetClientSize()
29
30        start = self.tr.stats.starttime - 4
31        end = self.tr.stats.endtime + 4
32
33        self.tr.shxPrepareImageData(width, height, (start, end))
34
35        bitmap = wx.EmptyBitmap(width, height)
36        buffer = wx.MemoryDC(bitmap)
37        buffer.Clear()
38#        dc = wx.GCDC(buffer)
39        dc = buffer
40        dc.BeginDrawing()
41        dc.DrawLineList(self.tr.shxImageData)
42        dc.EndDrawing()
43
44        dc2 = wx.AutoBufferedPaintDCFactory(self)
45        dc2.Blit(0, 0, width, height, buffer, 0, 0, wx.COPY)
46
47class MyFrame(wx.Frame):
48    def __init__(self, parent, title):
49        wx.Frame.__init__(self, parent, title=title, size=(640,480), style=wx.DEFAULT_FRAME_STYLE | wx.FULL_REPAINT_ON_RESIZE)
50        self.canvas = MyPanel(self)
51        self.Show()
52
53def main():
54    app = wx.App(False)
55    frame = MyFrame(None, 'Trace Plotter Test')
56    app.MainLoop()
57
58if __name__ == '__main__':
59    main()
Note: See TracBrowser for help on using the repository browser.