Subversion Repositories Projects

Rev

Rev 584 | Rev 586 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 584 Rev 585
Line 1... Line 1...
1
#!/usr/bin/env python
1
#!/usr/bin/env python
2
# -*- coding: iso-8859-15 -*-
2
# -*- coding: iso-8859-15 -*-
3
# generated by wxGlade 0.6.3 on Thu Sep 24 15:46:36 2009
3
# generated by wxGlade 0.6.3 on Thu Sep 24 15:46:36 2009
Line 4... Line 4...
4
 
4
 
-
 
5
import wx
-
 
6
import wx.lib
-
 
7
import wx.lib.plot
-
 
8
 
-
 
9
# Needs Numeric or numarray or NumPy
-
 
10
try:
-
 
11
    import numpy.oldnumeric as _Numeric
-
 
12
except:
-
 
13
    try:
-
 
14
        import numarray as _Numeric  #if numarray is used it is renamed Numeric
-
 
15
    except:
-
 
16
        try:
-
 
17
            import Numeric as _Numeric
-
 
18
        except:
-
 
19
            msg= """
-
 
20
            This module requires the Numeric/numarray or NumPy module,
-
 
21
            which could not be imported.  It probably is not installed
-
 
22
            (it's not part of the standard Python distribution). See the
-
 
23
            Numeric Python site (http://numpy.scipy.org) for information on
-
 
24
            downloading source or binaries."""
Line 5... Line 25...
5
import wx
25
            raise ImportError, "Numeric,numarray or NumPy not found. \n" + msg
6
 
26
 
Line -... Line 27...
-
 
27
# begin wxGlade: extracode
-
 
28
# end wxGlade
-
 
29
 
-
 
30
 
-
 
31
 
-
 
32
class wxFrame(wx.Panel):
-
 
33
    def __init__(self, *args, **kwds):
-
 
34
        # begin wxGlade: wxFrame.__init__
-
 
35
        kwds["style"] = wx.TAB_TRAVERSAL
-
 
36
        wx.Panel.__init__(self, *args, **kwds)
-
 
37
 
-
 
38
        self.__set_properties()
-
 
39
        self.__do_layout()
-
 
40
        # end wxGlade
-
 
41
 
-
 
42
    def __set_properties(self):
-
 
43
        # begin wxGlade: wxFrame.__set_properties
-
 
44
        pass
-
 
45
        # end wxGlade
-
 
46
 
-
 
47
    def __do_layout(self):
-
 
48
        # begin wxGlade: wxFrame.__do_layout
-
 
49
        pass
-
 
50
        # end wxGlade
-
 
51
 
-
 
52
# end of class wxFrame
-
 
53
 
-
 
54
 
-
 
55
class MyFrame(wx.Frame):
-
 
56
    def __init__(self, *args, **kwds):
-
 
57
        # content of this block not found: did you rename this class?
-
 
58
        pass
-
 
59
 
-
 
60
    def __set_properties(self):
-
 
61
        # content of this block not found: did you rename this class?
-
 
62
        pass
-
 
63
 
-
 
64
    def __do_layout(self):
-
 
65
        # content of this block not found: did you rename this class?
7
# begin wxGlade: extracode
66
        pass
8
# end wxGlade
67
 
9
 
68
# end of class MyFrame
10
 
69
 
11
 
70
 
Line 29... Line 88...
29
        self.label_4 = wx.StaticText(self, -1, "Speed(s)")
88
        self.label_4 = wx.StaticText(self, -1, "Speed(s)")
30
        self.text_ctrl_4 = wx.TextCtrl(self, -1, "")
89
        self.text_ctrl_4 = wx.TextCtrl(self, -1, "")
31
        self.label_8 = wx.StaticText(self, -1, "label_8")
90
        self.label_8 = wx.StaticText(self, -1, "label_8")
32
        self.text_ctrl_8 = wx.TextCtrl(self, -1, "")
91
        self.text_ctrl_8 = wx.TextCtrl(self, -1, "")
33
        self.button_1 = wx.Button(self, -1, "button_1")
92
        self.button_1 = wx.Button(self, -1, "button_1")
-
 
93
        self.GraphFanel = wx.Panel(self, -1)
-
 
94
        self.panel_1 = wxFrame(self, -1)
Line 34... Line 95...
34
 
95
 
35
        self.__set_properties()
96
        self.__set_properties()
36
        self.__do_layout()
97
        self.__do_layout()
Line -... Line 98...
-
 
98
        # end wxGlade
-
 
99
 
37
        # end wxGlade
100
       
38
 
101
 
39
    def __set_properties(self):
102
    def __set_properties(self):
-
 
103
        # begin wxGlade: MainFrame.__set_properties
40
        # begin wxGlade: MainFrame.__set_properties
104
        self.SetTitle("frame_1")
Line 41... Line 105...
41
        self.SetTitle("frame_1")
105
        self.GraphFanel.SetMinSize((800,300))
42
        # end wxGlade
106
        # end wxGlade
43
 
107
 
Line 61... Line 125...
61
        grid_sizer_1.Add(self.text_ctrl_4, 0, 0, 0)
125
        grid_sizer_1.Add(self.text_ctrl_4, 0, 0, 0)
62
        grid_sizer_1.Add(self.label_8, 0, wx.ALIGN_RIGHT, 0)
126
        grid_sizer_1.Add(self.label_8, 0, wx.ALIGN_RIGHT, 0)
63
        grid_sizer_1.Add(self.text_ctrl_8, 0, 0, 0)
127
        grid_sizer_1.Add(self.text_ctrl_8, 0, 0, 0)
64
        grid_sizer_1.Add(self.button_1, 0, 0, 0)
128
        grid_sizer_1.Add(self.button_1, 0, 0, 0)
65
        sizer_1.Add(grid_sizer_1, 0, 0, 2)
129
        sizer_1.Add(grid_sizer_1, 0, 0, 2)
66
        sizer_1.Add((20, 20), 1, wx.EXPAND, 0)
130
        sizer_1.Add(self.GraphFanel, 0, wx.EXPAND, 0)
-
 
131
        sizer_1.Add(self.panel_1, 1, wx.ALL|wx.EXPAND, 0)
67
        self.SetSizer(sizer_1)
132
        self.SetSizer(sizer_1)
68
        sizer_1.Fit(self)
133
        sizer_1.Fit(self)
69
        self.Layout()
134
        self.Layout()
70
        # end wxGlade
135
        # end wxGlade
Line -... Line 136...
-
 
136
 
-
 
137
 
-
 
138
        self.client = wx.lib.plot.PlotCanvas(self.GraphFanel)
-
 
139
        #define the function for drawing pointLabels
-
 
140
        self.client.SetPointLabelFunc(self.DrawPointLabel)
-
 
141
       
-
 
142
        self.client.SetFont(wx.Font(10,wx.SWISS,wx.NORMAL,wx.NORMAL))
-
 
143
        self.client.SetFontSizeAxis(10)
-
 
144
        self.client.SetFontSizeLegend(7)
-
 
145
        self.client.setLogScale((False,False))
-
 
146
        self.client.SetXSpec('auto')
-
 
147
        self.client.SetYSpec('auto')
-
 
148
 
-
 
149
        data1 = 2.*_Numeric.pi*_Numeric.arange(200)/200.
-
 
150
        data1.shape = (100, 2)
-
 
151
        data1[:,1] = _Numeric.sin(data1[:,0])
-
 
152
        markers1 = wx.lib.plot.PolyMarker(data1, legend='Green Markers', colour='green', marker='circle',size=1)
-
 
153
        pi = 3.1415
-
 
154
        markers2 = wx.lib.plot.PolyMarker([(0., 0.), (pi/4., 1.), (pi/2, 0.),
-
 
155
                          (3.*pi/4., -1)], legend='Cross Legend', colour='blue',
-
 
156
                          marker='cross')
-
 
157
        self.client.Draw(wx.lib.plot.PlotGraphics([markers1,markers2],"Graph Title", "X Axis", "Y Axis"))
-
 
158
   
-
 
159
    def DrawPointLabel(self, dc, mDataDict):
-
 
160
        """This is the fuction that defines how the pointLabels are plotted
-
 
161
            dc - DC that will be passed
-
 
162
            mDataDict - Dictionary of data that you want to use for the pointLabel
-
 
163
 
-
 
164
            As an example I have decided I want a box at the curve point
-
 
165
            with some text information about the curve plotted below.
-
 
166
            Any wxDC method can be used.
-
 
167
        """
-
 
168
        # ----------
-
 
169
        dc.SetPen(wx.Pen(wx.BLACK))
-
 
170
        dc.SetBrush(wx.Brush( wx.BLACK, wx.SOLID ) )
-
 
171
       
-
 
172
        sx, sy = mDataDict["scaledXY"] #scaled x,y of closest point
-
 
173
        dc.DrawRectangle( sx-5,sy-5, 10, 10)  #10by10 square centered on point
-
 
174
        px,py = mDataDict["pointXY"]
-
 
175
        cNum = mDataDict["curveNum"]
-
 
176
        pntIn = mDataDict["pIndex"]
-
 
177
        legend = mDataDict["legend"]
-
 
178
        #make a string to display
-
 
179
        s = "Crv# %i, '%s', Pt. (%.2f,%.2f), PtInd %i" %(cNum, legend, px, py, pntIn)
-
 
180
        dc.DrawText(s, sx , sy+1)
-
 
181
        # -----------
71
 
182
 
Line 72... Line 183...
72
# end of class MainFrame
183
# end of class MainFrame
73
 
184