def set_colourmap_use(self, on): self.set_bar(on) if on: colourMap = self.settings.colourMap else: colourMap = get_colours()[0] self.set_colourmap(colourMap)
def set_colourmap(self, colourMap): self.settings.colourMap = colourMap for collection in self.axes.collections: collection.set_cmap(colourMap) if get_colours().index(colourMap) < 4: self.set_bar(False) else: self.set_bar(True) self.barBase.set_cmap(colourMap) try: self.barBase.draw_all() except: pass
def __add_colourmap(self, useMapButton=True): if useMapButton: self.__add_check_tool('colourmap', 'Use colour maps', self.__on_colour_use, self.settings.colourMapUse) colours = get_colours() colourId = wx.NewId() self.colourId = wx.Choice(self, id=colourId, choices=colours) self.colourId.SetSelection(colours.index(self.settings.colourMap)) self.AddControl(self.colourId) self.colourId.Enable(self.settings.colourMapUse) self.Bind(wx.EVT_CHOICE, self.__on_colour, self.colourId) self.extraTools.append(colourId)
def __init__(self, parent, settings, axes, data, extent, barBase, annotate): threading.Thread.__init__(self) self.name = "Plot" self.parent = parent self.settings = settings self.axes = axes self.data = data self.extent = extent if self.settings.colourMapUse: self.colourMap = settings.colourMap else: self.colourMap = get_colours()[0] self.lineWidth = settings.lineWidth self.barBase = barBase self.annotate = annotate
def __init__(self, parent, settings): self.settings = settings self.index = 0 wx.Dialog.__init__(self, parent=parent, title="Preferences") self.colours = get_colours() self.winFunc = settings.winFunc self.background = settings.background self.checkSaved = wx.CheckBox(self, wx.ID_ANY, "Save warning") self.checkSaved.SetValue(settings.saveWarn) self.checkBackup = wx.CheckBox(self, wx.ID_ANY, "Backup") self.checkBackup.SetValue(settings.backup) self.checkBackup.SetToolTipString('Backup data after crash') self.checkAlert = wx.CheckBox(self, wx.ID_ANY, "Level alert (dB)") self.checkAlert.SetValue(settings.alert) self.checkAlert.SetToolTipString('Play alert when level exceeded') self.Bind(wx.EVT_CHECKBOX, self.__on_alert, self.checkAlert) self.spinLevel = wx.SpinCtrl(self, wx.ID_ANY, min=-100, max=20) self.spinLevel.SetValue(settings.alertLevel) self.spinLevel.Enable(settings.alert) self.spinLevel.SetToolTipString('Alert threshold') textBackground = wx.StaticText(self, label='Background colour') self.buttonBackground = wx.Button(self, wx.ID_ANY) self.buttonBackground.SetBackgroundColour(self.background) self.Bind(wx.EVT_BUTTON, self.__on_background, self.buttonBackground) textColour = wx.StaticText(self, label="Colour map") self.choiceColour = wx.Choice(self, choices=self.colours) self.choiceColour.SetSelection(self.colours.index(settings.colourMap)) self.Bind(wx.EVT_CHOICE, self.__on_choice, self.choiceColour) self.colourBar = PanelColourBar(self, settings.colourMap) self.checkPoints = wx.CheckBox(self, wx.ID_ANY, "Limit points") self.checkPoints.SetValue(settings.pointsLimit) self.checkPoints.SetToolTipString('Limit the resolution of plots') self.Bind(wx.EVT_CHECKBOX, self.__on_points, self.checkPoints) self.spinPoints = wx.SpinCtrl(self, wx.ID_ANY, min=1000, max=100000) self.spinPoints.Enable(settings.pointsLimit) self.spinPoints.SetValue(settings.pointsMax) self.spinPoints.SetToolTipString('Maximum number of points to plot_line') textDpi = wx.StaticText(self, label='Export DPI') self.spinDpi = wx.SpinCtrl(self, wx.ID_ANY, min=72, max=6000) self.spinDpi.SetValue(settings.exportDpi) self.spinDpi.SetToolTipString('DPI of exported images') self.checkTune = wx.CheckBox(self, wx.ID_ANY, "Tune SDR#") self.checkTune.SetValue(settings.clickTune) self.checkTune.SetToolTipString('Double click plot_line to tune SDR#') textPlugin = wx.HyperlinkCtrl(self, wx.ID_ANY, label="(Requires plugin)", url="http://eartoearoak.com/software/sdrsharp-net-remote") self.radioAvg = wx.RadioButton(self, wx.ID_ANY, 'Average Scans', style=wx.RB_GROUP) self.radioAvg.SetToolTipString('Average level with each scan') self.Bind(wx.EVT_RADIOBUTTON, self.__on_radio, self.radioAvg) self.radioRetain = wx.RadioButton(self, wx.ID_ANY, 'Retain previous scans') self.radioRetain.SetToolTipString('Can be slow') self.Bind(wx.EVT_RADIOBUTTON, self.__on_radio, self.radioRetain) self.radioRetain.SetValue(settings.retainScans) textMaxScans = wx.StaticText(self, label="Max scans") self.spinCtrlMaxScans = wx.SpinCtrl(self) self.spinCtrlMaxScans.SetRange(1, 5000) self.spinCtrlMaxScans.SetValue(settings.retainMax) self.spinCtrlMaxScans.SetToolTipString('Maximum previous scans' ' to display') textWidth = wx.StaticText(self, label="Line width") self.ctrlWidth = NumCtrl(self, integerWidth=2, fractionWidth=1) self.ctrlWidth.SetValue(settings.lineWidth) self.__on_radio(None) sizerButtons = wx.StdDialogButtonSizer() buttonOk = wx.Button(self, wx.ID_OK) buttonCancel = wx.Button(self, wx.ID_CANCEL) sizerButtons.AddButton(buttonOk) sizerButtons.AddButton(buttonCancel) sizerButtons.Realize() self.Bind(wx.EVT_BUTTON, self.__on_ok, buttonOk) gengrid = wx.GridBagSizer(10, 10) gengrid.Add(self.checkSaved, pos=(0, 0)) gengrid.Add(self.checkBackup, pos=(1, 0)) gengrid.Add(self.checkAlert, pos=(2, 0), flag=wx.ALIGN_CENTRE) gengrid.Add(self.spinLevel, pos=(2, 1)) gengrid.Add(textBackground, pos=(3, 0), flag=wx.ALIGN_CENTRE) gengrid.Add(self.buttonBackground, pos=(3, 1)) gengrid.Add(textColour, pos=(4, 0)) gengrid.Add(self.choiceColour, pos=(4, 1)) gengrid.Add(self.colourBar, pos=(4, 2)) gengrid.Add(self.checkPoints, pos=(5, 0)) gengrid.Add(self.spinPoints, pos=(5, 1)) gengrid.Add(textDpi, pos=(6, 0)) gengrid.Add(self.spinDpi, pos=(6, 1)) gengrid.Add(self.checkTune, pos=(7, 0)) gengrid.Add(textPlugin, pos=(7, 1)) genbox = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "General")) genbox.Add(gengrid, 0, wx.ALL | wx.ALIGN_CENTRE_VERTICAL, 10) congrid = wx.GridBagSizer(10, 10) congrid.Add(self.radioAvg, pos=(0, 0)) congrid.Add(self.radioRetain, pos=(1, 0)) congrid.Add(textMaxScans, pos=(2, 0), flag=wx.ALIGN_CENTRE_VERTICAL) congrid.Add(self.spinCtrlMaxScans, pos=(2, 1)) conbox = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Continuous Scans"), wx.VERTICAL) conbox.Add(congrid, 0, wx.ALL | wx.EXPAND, 10) plotgrid = wx.GridBagSizer(10, 10) plotgrid.Add(textWidth, pos=(0, 0)) plotgrid.Add(self.ctrlWidth, pos=(0, 1)) plotbox = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Plot View"), wx.HORIZONTAL) plotbox.Add(plotgrid, 0, wx.ALL | wx.EXPAND, 10) grid = wx.GridBagSizer(10, 10) grid.Add(genbox, pos=(0, 0), span=(1, 2), flag=wx.EXPAND) grid.Add(conbox, pos=(1, 0), span=(1, 2), flag=wx.EXPAND) grid.Add(plotbox, pos=(2, 0), span=(1, 2), flag=wx.EXPAND) grid.Add(sizerButtons, pos=(3, 1), flag=wx.EXPAND) box = wx.BoxSizer() box.Add(grid, flag=wx.ALL | wx.ALIGN_CENTRE, border=10) self.SetSizerAndFit(box)
def __init__(self, parent, spectrum, location, settings): self.spectrum = spectrum self.location = location self.settings = settings self.directory = settings.dirExport self.colourMap = settings.colourMap self.colourHeat = settings.colourMap self.canvas = None self.extent = None self.xyz = None self.plotAxes = False self.plotMesh = True self.plotCont = True self.plotPoint = False self.plotHeat = False self.plot = None wx.Dialog.__init__(self, parent=parent, title='Export Map') colours = get_colours() freqMin = min(spectrum[min(spectrum)]) * 1000 freqMax = max(spectrum[min(spectrum)]) * 1000 bw = freqMax - freqMin self.figure = matplotlib.figure.Figure(facecolor='white') self.figure.set_size_inches((6, 6)) self.canvas = FigureCanvas(self, -1, self.figure) self.axes = self.figure.add_subplot(111) if matplotlib.__version__ >= '1.2': self.figure.tight_layout() self.figure.subplots_adjust(left=0, right=1, top=1, bottom=0) textPlot = wx.StaticText(self, label='Plot') self.checkAxes = wx.CheckBox(self, label='Axes') self.checkAxes.SetValue(self.plotAxes) self.Bind(wx.EVT_CHECKBOX, self.__on_axes, self.checkAxes) self.checkCont = wx.CheckBox(self, label='Contour lines') self.checkCont.SetValue(self.plotCont) self.Bind(wx.EVT_CHECKBOX, self.__on_cont, self.checkCont) self.checkPoint = wx.CheckBox(self, label='Locations') self.checkPoint.SetValue(self.plotPoint) self.Bind(wx.EVT_CHECKBOX, self.__on_point, self.checkPoint) sizerPlotCheck = wx.BoxSizer(wx.HORIZONTAL) sizerPlotCheck.Add(self.checkAxes, flag=wx.ALL, border=5) sizerPlotCheck.Add(self.checkCont, flag=wx.ALL, border=5) sizerPlotCheck.Add(self.checkPoint, flag=wx.ALL, border=5) sizerPlot = wx.BoxSizer(wx.VERTICAL) sizerPlot.Add(textPlot, flag=wx.ALL, border=5) sizerPlot.Add(sizerPlotCheck, flag=wx.ALL, border=5) textMesh = wx.StaticText(self, label='Mesh') self.checkMesh = wx.CheckBox(self, label='On') self.checkMesh.SetToolTipString('Signal level mesh') self.checkMesh.SetValue(self.plotMesh) self.Bind(wx.EVT_CHECKBOX, self.__on_mesh, self.checkMesh) self.choiceMapMesh = wx.Choice(self, choices=colours) self.choiceMapMesh.SetSelection(colours.index(self.colourMap)) self.Bind(wx.EVT_CHOICE, self.__on_colour_mesh, self.choiceMapMesh) self.barMesh = PanelColourBar(self, self.colourMap) sizerMapMesh = wx.BoxSizer(wx.HORIZONTAL) sizerMapMesh.Add(self.choiceMapMesh, flag=wx.ALL, border=5) sizerMapMesh.Add(self.barMesh, flag=wx.ALL, border=5) sizerMesh = wx.BoxSizer(wx.VERTICAL) sizerMesh.Add(textMesh, flag=wx.ALL, border=5) sizerMesh.Add(self.checkMesh, flag=wx.ALL, border=5) sizerMesh.Add(sizerMapMesh, flag=wx.ALL, border=5) colours = get_colours() textHeat = wx.StaticText(self, label='Heat map') self.checkHeat = wx.CheckBox(self, label='On') self.checkHeat.SetToolTipString('GPS location heatmap') self.checkHeat.SetValue(self.plotHeat) self.Bind(wx.EVT_CHECKBOX, self.__on_heat, self.checkHeat) self.choiceMapHeat = wx.Choice(self, choices=colours) self.choiceMapHeat.SetSelection(colours.index(self.colourHeat)) self.Bind(wx.EVT_CHOICE, self.__on_colour_heat, self.choiceMapHeat) self.barHeat = PanelColourBar(self, self.colourHeat) sizerMapHeat = wx.BoxSizer(wx.HORIZONTAL) sizerMapHeat.Add(self.choiceMapHeat, flag=wx.ALL, border=5) sizerMapHeat.Add(self.barHeat, flag=wx.ALL, border=5) sizerHeat = wx.BoxSizer(wx.VERTICAL) sizerHeat.Add(textHeat, flag=wx.ALL, border=5) sizerHeat.Add(self.checkHeat, flag=wx.ALL, border=5) sizerHeat.Add(sizerMapHeat, flag=wx.ALL, border=5) textRange = wx.StaticText(self, label='Range') textCentre = wx.StaticText(self, label='Centre') self.spinCentre = wx.SpinCtrl(self) self.spinCentre.SetToolTipString('Centre frequency (kHz)') self.spinCentre.SetRange(freqMin, freqMax) self.spinCentre.SetValue(freqMin + bw / 2) sizerCentre = wx.BoxSizer(wx.HORIZONTAL) sizerCentre.Add(textCentre, flag=wx.ALL, border=5) sizerCentre.Add(self.spinCentre, flag=wx.ALL, border=5) textBw = wx.StaticText(self, label='Bandwidth') self.spinBw = wx.SpinCtrl(self) self.spinBw.SetToolTipString('Bandwidth (kHz)') self.spinBw.SetRange(1, bw) self.spinBw.SetValue(bw / 10) sizerBw = wx.BoxSizer(wx.HORIZONTAL) sizerBw.Add(textBw, flag=wx.ALL, border=5) sizerBw.Add(self.spinBw, flag=wx.ALL, border=5) buttonUpdate = wx.Button(self, label='Update') self.Bind(wx.EVT_BUTTON, self.__on_update, buttonUpdate) sizerRange = wx.BoxSizer(wx.VERTICAL) sizerRange.Add(textRange, flag=wx.ALL, border=5) sizerRange.Add(sizerCentre, flag=wx.ALL, border=5) sizerRange.Add(sizerBw, flag=wx.ALL, border=5) sizerRange.Add(buttonUpdate, flag=wx.ALL, border=5) textOutput = wx.StaticText(self, label='Output') self.textRes = wx.StaticText(self) buttonRes = wx.Button(self, label='Change...') buttonRes.SetToolTipString('Change output resolution') self.Bind(wx.EVT_BUTTON, self.__on_imageres, buttonRes) sizerRes = wx.BoxSizer(wx.HORIZONTAL) sizerRes.Add(self.textRes, flag=wx.ALL, border=5) sizerRes.Add(buttonRes, flag=wx.ALL, border=5) sizerOutput = wx.BoxSizer(wx.VERTICAL) sizerOutput.Add(textOutput, flag=wx.ALL, border=5) sizerOutput.Add(sizerRes, flag=wx.ALL, border=5) self.__show_image_res() font = textPlot.GetFont() fontSize = font.GetPointSize() font.SetPointSize(fontSize + 4) textPlot.SetFont(font) textMesh.SetFont(font) textHeat.SetFont(font) textRange.SetFont(font) textOutput.SetFont(font) sizerButtons = wx.StdDialogButtonSizer() buttonOk = wx.Button(self, wx.ID_OK) buttonCancel = wx.Button(self, wx.ID_CANCEL) sizerButtons.AddButton(buttonOk) sizerButtons.AddButton(buttonCancel) sizerButtons.Realize() self.Bind(wx.EVT_BUTTON, self.__on_ok, buttonOk) self.__setup_plot() sizerGrid = wx.GridBagSizer(5, 5) sizerGrid.Add(self.canvas, pos=(0, 0), span=(5, 6), flag=wx.EXPAND | wx.ALL, border=5) sizerGrid.Add(sizerPlot, pos=(0, 7), flag=wx.EXPAND | wx.ALL, border=5) sizerGrid.Add(sizerMesh, pos=(1, 7), flag=wx.EXPAND | wx.ALL, border=5) sizerGrid.Add(sizerHeat, pos=(2, 7), flag=wx.EXPAND | wx.ALL, border=5) sizerGrid.Add(sizerRange, pos=(3, 7), flag=wx.EXPAND | wx.ALL, border=5) sizerGrid.Add(sizerOutput, pos=(4, 7), flag=wx.EXPAND | wx.ALL, border=5) sizerGrid.Add(sizerButtons, pos=(5, 7), span=(1, 2), flag=wx.ALIGN_RIGHT | wx.ALL, border=5) self.SetSizerAndFit(sizerGrid) self.__draw_plot()
def __init__(self, parent, settings): self.settings = settings self.index = 0 wx.Dialog.__init__(self, parent=parent, title="Preferences") self.colours = get_colours() self.winFunc = settings.winFunc self.background = settings.background self.checkSaved = wx.CheckBox(self, wx.ID_ANY, "Save warning") self.checkSaved.SetValue(settings.saveWarn) self.checkBackup = wx.CheckBox(self, wx.ID_ANY, "Backup") self.checkBackup.SetValue(settings.backup) self.checkBackup.SetToolTipString('Backup data after crash') self.checkAlert = wx.CheckBox(self, wx.ID_ANY, "Level alert (dB)") self.checkAlert.SetValue(settings.alert) self.checkAlert.SetToolTipString('Play alert when level exceeded') self.Bind(wx.EVT_CHECKBOX, self.__on_alert, self.checkAlert) self.spinLevel = wx.SpinCtrl(self, wx.ID_ANY, min=-100, max=20) self.spinLevel.SetValue(settings.alertLevel) self.spinLevel.Enable(settings.alert) self.spinLevel.SetToolTipString('Alert threshold') textBackground = wx.StaticText(self, label='Background colour') self.buttonBackground = wx.Button(self, wx.ID_ANY) self.buttonBackground.SetBackgroundColour(self.background) self.Bind(wx.EVT_BUTTON, self.__on_background, self.buttonBackground) textColour = wx.StaticText(self, label="Colour map") self.choiceColour = wx.Choice(self, choices=self.colours) self.choiceColour.SetSelection(self.colours.index(settings.colourMap)) self.Bind(wx.EVT_CHOICE, self.__on_choice, self.choiceColour) self.colourBar = PanelColourBar(self, settings.colourMap) self.checkPoints = wx.CheckBox(self, wx.ID_ANY, "Limit points") self.checkPoints.SetValue(settings.pointsLimit) self.checkPoints.SetToolTipString('Limit the resolution of plots') self.Bind(wx.EVT_CHECKBOX, self.__on_points, self.checkPoints) self.spinPoints = wx.SpinCtrl(self, wx.ID_ANY, min=1000, max=100000) self.spinPoints.Enable(settings.pointsLimit) self.spinPoints.SetValue(settings.pointsMax) self.spinPoints.SetToolTipString( 'Maximum number of points to plot_line') textDpi = wx.StaticText(self, label='Export DPI') self.spinDpi = wx.SpinCtrl(self, wx.ID_ANY, min=72, max=6000) self.spinDpi.SetValue(settings.exportDpi) self.spinDpi.SetToolTipString('DPI of exported images') self.checkTune = wx.CheckBox(self, wx.ID_ANY, "Tune SDR#") self.checkTune.SetValue(settings.clickTune) self.checkTune.SetToolTipString('Double click plot_line to tune SDR#') textPlugin = wx.HyperlinkCtrl( self, wx.ID_ANY, label="(Requires plugin)", url="http://eartoearoak.com/software/sdrsharp-net-remote") self.radioAvg = wx.RadioButton(self, wx.ID_ANY, 'Average Scans', style=wx.RB_GROUP) self.radioAvg.SetToolTipString('Average level with each scan') self.Bind(wx.EVT_RADIOBUTTON, self.__on_radio, self.radioAvg) self.radioRetain = wx.RadioButton(self, wx.ID_ANY, 'Retain previous scans') self.radioRetain.SetToolTipString('Can be slow') self.Bind(wx.EVT_RADIOBUTTON, self.__on_radio, self.radioRetain) self.radioRetain.SetValue(settings.retainScans) textMaxScans = wx.StaticText(self, label="Max scans") self.spinCtrlMaxScans = wx.SpinCtrl(self) self.spinCtrlMaxScans.SetRange(1, 5000) self.spinCtrlMaxScans.SetValue(settings.retainMax) self.spinCtrlMaxScans.SetToolTipString('Maximum previous scans' ' to display') textWidth = wx.StaticText(self, label="Line width") self.ctrlWidth = NumCtrl(self, integerWidth=2, fractionWidth=1) self.ctrlWidth.SetValue(settings.lineWidth) self.__on_radio(None) sizerButtons = wx.StdDialogButtonSizer() buttonOk = wx.Button(self, wx.ID_OK) buttonCancel = wx.Button(self, wx.ID_CANCEL) sizerButtons.AddButton(buttonOk) sizerButtons.AddButton(buttonCancel) sizerButtons.Realize() self.Bind(wx.EVT_BUTTON, self.__on_ok, buttonOk) gengrid = wx.GridBagSizer(10, 10) gengrid.Add(self.checkSaved, pos=(0, 0)) gengrid.Add(self.checkBackup, pos=(1, 0)) gengrid.Add(self.checkAlert, pos=(2, 0), flag=wx.ALIGN_CENTRE) gengrid.Add(self.spinLevel, pos=(2, 1)) gengrid.Add(textBackground, pos=(3, 0), flag=wx.ALIGN_CENTRE) gengrid.Add(self.buttonBackground, pos=(3, 1)) gengrid.Add(textColour, pos=(4, 0)) gengrid.Add(self.choiceColour, pos=(4, 1)) gengrid.Add(self.colourBar, pos=(4, 2)) gengrid.Add(self.checkPoints, pos=(5, 0)) gengrid.Add(self.spinPoints, pos=(5, 1)) gengrid.Add(textDpi, pos=(6, 0)) gengrid.Add(self.spinDpi, pos=(6, 1)) gengrid.Add(self.checkTune, pos=(7, 0)) gengrid.Add(textPlugin, pos=(7, 1)) genbox = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "General")) genbox.Add(gengrid, 0, wx.ALL | wx.ALIGN_CENTRE_VERTICAL, 10) congrid = wx.GridBagSizer(10, 10) congrid.Add(self.radioAvg, pos=(0, 0)) congrid.Add(self.radioRetain, pos=(1, 0)) congrid.Add(textMaxScans, pos=(2, 0), flag=wx.ALIGN_CENTRE_VERTICAL) congrid.Add(self.spinCtrlMaxScans, pos=(2, 1)) conbox = wx.StaticBoxSizer( wx.StaticBox(self, wx.ID_ANY, "Continuous Scans"), wx.VERTICAL) conbox.Add(congrid, 0, wx.ALL | wx.EXPAND, 10) plotgrid = wx.GridBagSizer(10, 10) plotgrid.Add(textWidth, pos=(0, 0)) plotgrid.Add(self.ctrlWidth, pos=(0, 1)) plotbox = wx.StaticBoxSizer(wx.StaticBox(self, wx.ID_ANY, "Plot View"), wx.HORIZONTAL) plotbox.Add(plotgrid, 0, wx.ALL | wx.EXPAND, 10) grid = wx.GridBagSizer(10, 10) grid.Add(genbox, pos=(0, 0), span=(1, 2), flag=wx.EXPAND) grid.Add(conbox, pos=(1, 0), span=(1, 2), flag=wx.EXPAND) grid.Add(plotbox, pos=(2, 0), span=(1, 2), flag=wx.EXPAND) grid.Add(sizerButtons, pos=(3, 1), flag=wx.EXPAND) box = wx.BoxSizer() box.Add(grid, flag=wx.ALL | wx.ALIGN_CENTRE, border=10) self.SetSizerAndFit(box)
def __init__(self, parent, spectrum, location, settings): self.spectrum = spectrum self.location = location self.settings = settings self.directory = settings.dirExport self.colourMap = settings.colourMap self.canvas = None self.extent = None self.xyz = None self.plotAxes = False self.plotHeat = True self.plotCont = True self.plotPoint = False self.plot = None wx.Dialog.__init__(self, parent=parent, title='Export Map') self.figure = matplotlib.figure.Figure(facecolor='white') self.figure.set_size_inches((6, 6)) self.canvas = FigureCanvas(self, -1, self.figure) self.axes = self.figure.add_subplot(111) textPlot = wx.StaticText(self, label='Plot') self.checkAxes = wx.CheckBox(self, label='Axes') self.checkAxes.SetValue(self.plotAxes) self.Bind(wx.EVT_CHECKBOX, self.__on_axes, self.checkAxes) self.checkHeat = wx.CheckBox(self, label='Heat Map') self.checkHeat.SetValue(self.plotHeat) self.Bind(wx.EVT_CHECKBOX, self.__on_heat, self.checkHeat) self.checkCont = wx.CheckBox(self, label='Contour Lines') self.checkCont.SetValue(self.plotCont) self.Bind(wx.EVT_CHECKBOX, self.__on_cont, self.checkCont) self.checkPoint = wx.CheckBox(self, label='Locations') self.checkPoint.SetValue(self.plotPoint) self.Bind(wx.EVT_CHECKBOX, self.__on_point, self.checkPoint) sizerCheck = wx.BoxSizer(wx.HORIZONTAL) sizerCheck.Add(self.checkAxes, flag=wx.ALL, border=5) sizerCheck.Add(self.checkHeat, flag=wx.ALL, border=5) sizerCheck.Add(self.checkCont, flag=wx.ALL, border=5) sizerCheck.Add(self.checkPoint, flag=wx.ALL, border=5) colours = get_colours() self.choiceColour = wx.Choice(self, choices=colours) self.choiceColour.SetSelection(colours.index(self.colourMap)) self.Bind(wx.EVT_CHOICE, self.__on_colour, self.choiceColour) self.colourBar = PanelColourBar(self, settings.colourMap) freqMin = min(spectrum[min(spectrum)]) * 1000 freqMax = max(spectrum[min(spectrum)]) * 1000 bw = freqMax - freqMin textRange = wx.StaticText(self, label='Range') textCentre = wx.StaticText(self, label='Centre') self.spinCentre = wx.SpinCtrl(self) self.spinCentre.SetToolTipString('Centre frequency (kHz)') self.spinCentre.SetRange(freqMin, freqMax) self.spinCentre.SetValue(freqMin + bw / 2) textBw = wx.StaticText(self, label='Bandwidth') self.spinBw = wx.SpinCtrl(self) self.spinBw.SetToolTipString('Bandwidth (kHz)') self.spinBw.SetRange(1, bw) self.spinBw.SetValue(bw / 10) buttonUpdate = wx.Button(self, label='Update') self.Bind(wx.EVT_BUTTON, self.__on_update, buttonUpdate) textOutput = wx.StaticText(self, label='Output') self.textRes = wx.StaticText(self) buttonRes = wx.Button(self, label='Change...') buttonRes.SetToolTipString('Change output resolution') self.Bind(wx.EVT_BUTTON, self.__on_imageres, buttonRes) self.__show_image_res() font = textPlot.GetFont() fontSize = font.GetPointSize() font.SetPointSize(fontSize + 4) textPlot.SetFont(font) textRange.SetFont(font) textOutput.SetFont(font) sizerButtons = wx.StdDialogButtonSizer() buttonOk = wx.Button(self, wx.ID_OK) buttonCancel = wx.Button(self, wx.ID_CANCEL) sizerButtons.AddButton(buttonOk) sizerButtons.AddButton(buttonCancel) sizerButtons.Realize() self.Bind(wx.EVT_BUTTON, self.__on_ok, buttonOk) self.__setup_plot() sizerGrid = wx.GridBagSizer(5, 5) sizerGrid.Add(self.canvas, pos=(0, 0), span=(9, 6), flag=wx.EXPAND | wx.ALL, border=5) sizerGrid.Add(textPlot, pos=(0, 7), flag=wx.TOP | wx.BOTTOM, border=5) sizerGrid.Add(self.choiceColour, pos=(1, 7), flag=wx.ALL, border=5) sizerGrid.Add(self.colourBar, pos=(1, 8), flag=wx.ALL, border=5) sizerGrid.Add(sizerCheck, pos=(2, 7), span=(1, 2), flag=wx.ALL, border=5) sizerGrid.Add(textRange, pos=(3, 7), flag=wx.TOP | wx.BOTTOM, border=5) sizerGrid.Add(textCentre, pos=(4, 7), flag=wx.ALL, border=5) sizerGrid.Add(self.spinCentre, pos=(4, 8), flag=wx.ALL, border=5) sizerGrid.Add(textBw, pos=(5, 7), flag=wx.ALL, border=5) sizerGrid.Add(self.spinBw, pos=(5, 8), flag=wx.ALL, border=5) sizerGrid.Add(buttonUpdate, pos=(6, 7), flag=wx.ALL | wx.ALIGN_CENTRE_VERTICAL, border=5) sizerGrid.Add(textOutput, pos=(7, 7), flag=wx.TOP | wx.BOTTOM, border=5) sizerGrid.Add(self.textRes, pos=(8, 7), flag=wx.ALL, border=5) sizerGrid.Add(buttonRes, pos=(8, 8), flag=wx.ALL, border=5) sizerGrid.Add(sizerButtons, pos=(9, 7), span=(1, 2), flag=wx.ALIGN_RIGHT | wx.ALL, border=5) self.SetSizerAndFit(sizerGrid) self.__draw_plot()
def set_type(self, display): for toolId in self.extraTools: self.DeleteTool(toolId) self.extraTools = [] if display != Display.STATUS: self.__add_check_tool('peak', 'Label peak', self.__on_check_peak, self.settings.annotate) self.__add_spacer() self.autoFId = wx.NewId() self.__add_check_tool('auto_f', 'Auto range frequency', self.__on_check_auto_f, self.settings.autoF, self.autoFId) self.autoLId = wx.NewId() self.__add_check_tool('auto_l', 'Auto range level', self.__on_check_auto_l, self.settings.autoL, self.autoLId) if display != Display.PLOT and display != Display.STATUS: self.autoTId = wx.NewId() self.__add_check_tool('auto_t', 'Auto range time', self.__on_check_auto_t, self.settings.autoT, self.autoTId) self.__add_spacer() if display == Display.PLOT: self.__add_check_tool('fade', 'Fade plots', self.__on_check_fade, self.settings.fadeScans) self.__add_spacer() self.avgId = wx.NewId() self.__add_check_tool('average', 'Show average', self.__on_check_avg, toolId=self.avgId) self.minId = wx.NewId() self.__add_check_tool('min', 'Show minimum', self.__on_check_min, toolId=self.minId) self.maxId = wx.NewId() self.__add_check_tool('max', 'Show maximum', self.__on_check_max, toolId=self.maxId) self.varId = wx.NewId() self.__add_check_tool('variance', 'Show variance', self.__on_check_var, toolId=self.varId) self.__set_func() self.__add_spacer() self.__add_check_tool('colourmap', 'Use colour maps', self.__on_colour_use, self.settings.colourMapUse) if display != Display.STATUS: colours = get_colours() colourId = wx.NewId() self.colourId = wx.Choice(self, id=colourId, choices=colours) self.colourId.SetSelection(colours.index(self.settings.colourMap)) self.AddControl(self.colourId) if display == Display.PLOT: self.colourId.Enable(self.settings.colourMapUse) self.Bind(wx.EVT_CHOICE, self.__on_colour, self.colourId) self.extraTools.append(colourId) if display == Display.SURFACE: self.__add_spacer() self.__add_check_tool('wireframe', 'Wireframe drawing', self.__on_check_wire, self.settings.wireframe) self.Realize()