Subversion Repositories Projects

Rev

Rev 584 | Rev 586 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

#!/usr/bin/env python
# -*- coding: iso-8859-15 -*-
# generated by wxGlade 0.6.3 on Thu Sep 24 15:46:36 2009

import wx
import wx.lib
import wx.lib.plot

# Needs Numeric or numarray or NumPy
try:
    import numpy.oldnumeric as _Numeric
except:
    try:
        import numarray as _Numeric  #if numarray is used it is renamed Numeric
    except:
        try:
            import Numeric as _Numeric
        except:
            msg= """
            This module requires the Numeric/numarray or NumPy module,
            which could not be imported.  It probably is not installed
            (it's not part of the standard Python distribution). See the
            Numeric Python site (http://numpy.scipy.org) for information on
            downloading source or binaries."""

            raise ImportError, "Numeric,numarray or NumPy not found. \n" + msg

# begin wxGlade: extracode
# end wxGlade



class wxFrame(wx.Panel):
    def __init__(self, *args, **kwds):
        # begin wxGlade: wxFrame.__init__
        kwds["style"] = wx.TAB_TRAVERSAL
        wx.Panel.__init__(self, *args, **kwds)

        self.__set_properties()
        self.__do_layout()
        # end wxGlade

    def __set_properties(self):
        # begin wxGlade: wxFrame.__set_properties
        pass
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: wxFrame.__do_layout
        pass
        # end wxGlade

# end of class wxFrame


class MyFrame(wx.Frame):
    def __init__(self, *args, **kwds):
        # content of this block not found: did you rename this class?
        pass

    def __set_properties(self):
        # content of this block not found: did you rename this class?
        pass

    def __do_layout(self):
        # content of this block not found: did you rename this class?
        pass

# end of class MyFrame


class MainFrame(wx.Frame):
    def __init__(self, *args, **kwds):
        # begin wxGlade: MainFrame.__init__
        kwds["style"] = wx.DEFAULT_FRAME_STYLE
        wx.Frame.__init__(self, *args, **kwds)
        self.Port = wx.StaticText(self, -1, "Port")
        self.text_ctrl_1 = wx.TextCtrl(self, -1, "")
        self.label_5 = wx.StaticText(self, -1, "label_5")
        self.text_ctrl_5 = wx.TextCtrl(self, -1, "")
        self.label_2 = wx.StaticText(self, -1, "Motor(s)")
        self.text_ctrl_2 = wx.TextCtrl(self, -1, "")
        self.label_6 = wx.StaticText(self, -1, "label_6")
        self.text_ctrl_6 = wx.TextCtrl(self, -1, "")
        self.label_3 = wx.StaticText(self, -1, "Channel(s)")
        self.text_ctrl_3 = wx.TextCtrl(self, -1, "")
        self.label_7 = wx.StaticText(self, -1, "label_7")
        self.text_ctrl_7 = wx.TextCtrl(self, -1, "")
        self.label_4 = wx.StaticText(self, -1, "Speed(s)")
        self.text_ctrl_4 = wx.TextCtrl(self, -1, "")
        self.label_8 = wx.StaticText(self, -1, "label_8")
        self.text_ctrl_8 = wx.TextCtrl(self, -1, "")
        self.button_1 = wx.Button(self, -1, "button_1")
        self.GraphFanel = wx.Panel(self, -1)
        self.panel_1 = wxFrame(self, -1)

        self.__set_properties()
        self.__do_layout()
        # end wxGlade

       

    def __set_properties(self):
        # begin wxGlade: MainFrame.__set_properties
        self.SetTitle("frame_1")
        self.GraphFanel.SetMinSize((800,300))
        # end wxGlade

    def __do_layout(self):
        # begin wxGlade: MainFrame.__do_layout
        sizer_1 = wx.BoxSizer(wx.VERTICAL)
        grid_sizer_1 = wx.GridSizer(5, 4, 4, 4)
        grid_sizer_1.Add(self.Port, 0, wx.ALIGN_RIGHT, 0)
        grid_sizer_1.Add(self.text_ctrl_1, 0, 0, 0)
        grid_sizer_1.Add(self.label_5, 0, wx.ALIGN_RIGHT, 0)
        grid_sizer_1.Add(self.text_ctrl_5, 0, 0, 0)
        grid_sizer_1.Add(self.label_2, 0, wx.ALIGN_RIGHT, 0)
        grid_sizer_1.Add(self.text_ctrl_2, 0, 0, 0)
        grid_sizer_1.Add(self.label_6, 0, wx.ALIGN_RIGHT, 0)
        grid_sizer_1.Add(self.text_ctrl_6, 0, 0, 0)
        grid_sizer_1.Add(self.label_3, 0, wx.ALIGN_RIGHT, 0)
        grid_sizer_1.Add(self.text_ctrl_3, 0, 0, 0)
        grid_sizer_1.Add(self.label_7, 0, wx.ALIGN_RIGHT, 0)
        grid_sizer_1.Add(self.text_ctrl_7, 0, 0, 0)
        grid_sizer_1.Add(self.label_4, 0, wx.ALIGN_RIGHT, 0)
        grid_sizer_1.Add(self.text_ctrl_4, 0, 0, 0)
        grid_sizer_1.Add(self.label_8, 0, wx.ALIGN_RIGHT, 0)
        grid_sizer_1.Add(self.text_ctrl_8, 0, 0, 0)
        grid_sizer_1.Add(self.button_1, 0, 0, 0)
        sizer_1.Add(grid_sizer_1, 0, 0, 2)
        sizer_1.Add(self.GraphFanel, 0, wx.EXPAND, 0)
        sizer_1.Add(self.panel_1, 1, wx.ALL|wx.EXPAND, 0)
        self.SetSizer(sizer_1)
        sizer_1.Fit(self)
        self.Layout()
        # end wxGlade


        self.client = wx.lib.plot.PlotCanvas(self.GraphFanel)
        #define the function for drawing pointLabels
        self.client.SetPointLabelFunc(self.DrawPointLabel)
       
        self.client.SetFont(wx.Font(10,wx.SWISS,wx.NORMAL,wx.NORMAL))
        self.client.SetFontSizeAxis(10)
        self.client.SetFontSizeLegend(7)
        self.client.setLogScale((False,False))
        self.client.SetXSpec('auto')
        self.client.SetYSpec('auto')

        data1 = 2.*_Numeric.pi*_Numeric.arange(200)/200.
        data1.shape = (100, 2)
        data1[:,1] = _Numeric.sin(data1[:,0])
        markers1 = wx.lib.plot.PolyMarker(data1, legend='Green Markers', colour='green', marker='circle',size=1)
        pi = 3.1415
        markers2 = wx.lib.plot.PolyMarker([(0., 0.), (pi/4., 1.), (pi/2, 0.),
                          (3.*pi/4., -1)], legend='Cross Legend', colour='blue',
                          marker='cross')
        self.client.Draw(wx.lib.plot.PlotGraphics([markers1,markers2],"Graph Title", "X Axis", "Y Axis"))
   
    def DrawPointLabel(self, dc, mDataDict):
        """This is the fuction that defines how the pointLabels are plotted
            dc - DC that will be passed
            mDataDict - Dictionary of data that you want to use for the pointLabel

            As an example I have decided I want a box at the curve point
            with some text information about the curve plotted below.
            Any wxDC method can be used.
        """

        # ----------
        dc.SetPen(wx.Pen(wx.BLACK))
        dc.SetBrush(wx.Brush( wx.BLACK, wx.SOLID ) )
       
        sx, sy = mDataDict["scaledXY"] #scaled x,y of closest point
        dc.DrawRectangle( sx-5,sy-5, 10, 10)  #10by10 square centered on point
        px,py = mDataDict["pointXY"]
        cNum = mDataDict["curveNum"]
        pntIn = mDataDict["pIndex"]
        legend = mDataDict["legend"]
        #make a string to display
        s = "Crv# %i, '%s', Pt. (%.2f,%.2f), PtInd %i" %(cNum, legend, px, py, pntIn)
        dc.DrawText(s, sx , sy+1)
        # -----------

# end of class MainFrame


class App(wx.App):
    def OnInit(self):
        wx.InitAllImageHandlers()
        frame_1 = MainFrame(None, -1, "")
        self.SetTopWindow(frame_1)
        frame_1.Show()
        return 1

# end of class App

if __name__ == "__main__":
    VibrationTestGui = App(0)
    VibrationTestGui.MainLoop()