def browseDir(self, event): """ Show the DirDialog and ask the user to change the directory where machine labels are stored """ self.adjustLabelCheck.Enable(False) if self.adjust_original_labels == True: dlg = wx.FileDialog( self, "Choose the labeled dataset file(CollectedData_*.h5 file)", "", "", "All CollectedData_*.h5 files(CollectedData_*.h5)|CollectedData_*.h5", wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) else: fname = str('machinelabels-iter' + str(self.iterationindex) + '.h5') dlg = wx.FileDialog( self, "Choose the machinelabels file for current iteration.", "", "", wildcard=fname, style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST) if dlg.ShowModal() == wx.ID_OK: self.data_file = dlg.GetPath() self.dir = str(Path(self.data_file).parents[0]) print(self.dir) self.fileName = str(Path(self.data_file).stem) self.Button1.Enable(False) self.Button2.Enable(True) self.Button4.Enable(True) self.Button5.Enable(True) self.close.Enable(True) else: dlg.Destroy() self.Close(True) dlg.Destroy() self.fig1, (self.ax1f1) = plt.subplots(figsize=self.img_size, facecolor="None") try: self.dataname = str(self.data_file) except: print("No machinelabels file found!") self.Destroy() self.iter = 0 if os.path.isfile(self.dataname): self.Dataframe = pd.read_hdf(self.dataname, 'df_with_missing') self.scorer = self.Dataframe.columns.get_level_values(0)[0] bodyParts = self.Dataframe.columns.get_level_values(1) _, idx = np.unique(bodyParts, return_index=True) self.bodyparts2plot = bodyParts[np.sort(idx)] self.num_joints = len(self.bodyparts2plot) self.index = list(self.Dataframe.iloc[:, 0].index) self.drs = [] self.updatedCoords = [] # Reading images imagename1 = os.path.join(self.project_path, self.index[self.iter]) im = PIL.Image.open(imagename1) # Plotting im_axis = self.ax1f1.imshow(im, self.colormap) if self.file == 0: self.checkBox = wx.CheckBox(self.top_split, label='Adjust marker size.', pos=(self.gui_width * .43, self.gui_height * .85)) self.checkBox.Bind(wx.EVT_CHECKBOX, self.onChecked) self.slider = wx.Slider( self.top_split, -1, self.markerSize, 0, 20, size=(200, -1), pos=(self.gui_width * .43, self.gui_height * .8), style=wx.SL_HORIZONTAL | wx.SL_AUTOTICKS | wx.SL_LABELS) self.slider.Bind(wx.EVT_SLIDER, self.OnSliderScroll) self.slider.Enable(False) self.canvas = FigureCanvas(self.top_split, -1, self.fig1) self.colorparams = list(range(0, (self.num_joints + 1))) MainFrame.plot(self, im, im_axis) self.toolbar = NavigationToolbar(self.canvas) if self.adjust_original_labels == False: instruction = wx.MessageBox( '1. Enter the likelihood threshold. \n\n2. Each prediction will be shown with a unique color. \n All the data points above the threshold will be marked as circle filled with a unique color. All the data points below the threshold will be marked with a hollow circle. \n\n3. Enable the checkbox to adjust the marker size. \n\n4. Hover your mouse over data points to see the labels and their likelihood. \n\n5. Left click and drag to move the data points. \n\n6. Right click on any data point to remove it. Be careful, you cannot undo this step. \n Click once on the zoom button to zoom-in the image.The cursor will become cross, click and drag over a point to zoom in. \n Click on the zoom button again to disable the zooming function and recover the cursor. \n Use pan button to pan across the image while zoomed in. Use home button to go back to the full;default view. \n\n7. When finished click \'Save\' to save all the changes. \n\n8. Click OK to continue', 'User instructions', wx.OK | wx.ICON_INFORMATION) if instruction == 4: """ If ok is selected then the image is updated with the thresholded value of the likelihood """ textBox = wx.TextEntryDialog( self, "Select the likelihood threshold", caption="Enter the threshold", value="0.1") textBox.ShowModal() self.threshold = float(textBox.GetValue()) textBox.Destroy() self.drs = [] self.updatedCoords = [] plt.close(self.fig1) self.canvas.Destroy() self.fig1, (self.ax1f1) = plt.subplots(figsize=(12, 7.8), facecolor="None") #imagename1 = os.path.join(self.dir,self.index[self.iter]) imagename1 = os.path.join(self.project_path, self.index[self.iter]) im = PIL.Image.open(imagename1) im_axis = self.ax1f1.imshow(im, self.colormap) self.ax1f1.set_title( str( str(self.iter) + "/" + str(len(self.index) - 1) + " " + str(Path(self.index[self.iter]).stem) + " " + " Threshold chosen is: " + str("{0:.2f}".format(self.threshold)))) self.canvas = FigureCanvas(self.top_split, -1, self.fig1) MainFrame.plot(self, im, im_axis) MainFrame.confirm(self) self.toolbar = NavigationToolbar(self.canvas) else: self.threshold = 0.1 self.ax1f1.set_title( str( str(self.iter) + "/" + str(len(self.index) - 1) + " " + str(Path(self.index[self.iter]).stem) + " " + " Threshold chosen is: " + str("{0:.2f}".format(self.threshold)))) else: self.ax1f1.set_title( str( str(self.iter) + "/" + str(len(self.index) - 1) + " " + str(Path(self.index[self.iter]).stem))) else: msg = wx.MessageBox('No Machinelabels file found! Want to retry?', 'Error!', wx.YES_NO | wx.ICON_WARNING) if msg == 2: self.Button1.Enable(True) self.Button2.Enable(False) self.Button4.Enable(False) else: self.Destroy()
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) 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 createframe(self): #星座图绘制区域 self.figure = Figure() self.canvas = FigureCanvas(self, -1, self.figure) self.toolbar = NavigationToolbar2Wx(self.canvas) self.toolbar.AddLabelTool( 5, '', wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN, wx.ART_TOOLBAR, (32, 32))) self.toolbar.Realize() self.button1 = wx.Button(self, -1, "PCFI星座图") self.button1.SetBackgroundColour('black') self.button1.SetForegroundColour('white') self.Bind(wx.EVT_BUTTON, self.draw_pcfich, self.button1) self.button2 = wx.Button(self, -1, "PDCCH星座图") self.button2.SetBackgroundColour('black') self.button2.SetForegroundColour('white') self.Bind(wx.EVT_BUTTON, self.draw_pdcch, self.button2) self.button3 = wx.Button(self, -1, "PDSCH星座图") self.button3.SetBackgroundColour('black') self.button3.SetForegroundColour('white') self.Bind(wx.EVT_BUTTON, self.draw_pdsch, self.button3) #RNTI RNTI_st = wx.StaticText(self.panel, -1, u"RNTI:") self.RNTI = wx.SpinCtrl(self.panel, -1, "", (-1, -1)) self.RNTI.SetRange(61, 65523) self.RNTI.SetValue(100) #sfn sfn_st = wx.StaticText(self.panel, -1, u"子帧总数:") self.sfn = wx.TextCtrl(self.panel, -1, "", style=wx.TE_READONLY) #小区ID id_cell = wx.StaticText(self.panel, -1, u'小区ID:') self.id_cell_t = wx.TextCtrl(self.panel, -1, "0", style=wx.TE_READONLY) #系统带宽 bandwidth = wx.StaticText(self.panel, -1, u'系统带宽:') self.bandwidth_t = wx.TextCtrl(self.panel, -1, "0", style=wx.TE_READONLY) #sfn_number sfn_start_st = wx.StaticText(self.panel, -1, u"起始帧号:") self.sfn_start = wx.TextCtrl(self.panel, -1, "0", size=(80, 30)) sfn_total_st = wx.StaticText(self.panel, -1, u"子帧总数:") self.sfn_total = wx.TextCtrl(self.panel, -1, "100") #刷新处理按钮 self.refresh = wx.Button(self.panel, label="刷新") self.Bind(wx.EVT_BUTTON, self.process, self.refresh) self.refresh.SetBackgroundColour('black') self.refresh.SetForegroundColour('white') #选择文件 self.button_file = wx.Button(self.panel, label="选择") self.Bind(wx.EVT_BUTTON, self.file_select, self.button_file) self.button_file.SetBackgroundColour('black') self.button_file.SetForegroundColour('white') #数据源 data_st = wx.StaticText(self.panel, -1, u"数据源:") self.data_t = wx.TextCtrl(self.panel, -1, "", style=wx.TE_READONLY) # self.cb_grid = wx.CheckBox(self.panel, -1, "显示网格", style=wx.ALIGN_RIGHT) ########开始布局############ sizer1 = wx.BoxSizer(wx.HORIZONTAL) sizer1.Add(self.button1, 1, wx.EXPAND) sizer1.Add(self.button2, 1, wx.EXPAND) sizer1.Add(self.button3, 1, wx.EXPAND) sizer2 = wx.FlexGridSizer(cols=4, hgap=5, vgap=5) sizer2.AddGrowableCol(1) sizer2.AddGrowableCol(3) sizer2.Add(RNTI_st, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL) sizer2.Add(self.RNTI, 0, wx.EXPAND) sizer2.Add(sfn_st, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL) sizer2.Add(self.sfn, 0, wx.EXPAND) sizer2.Add(id_cell, 0, wx.ALIGN_RIGHT) sizer2.Add(self.id_cell_t, 0, wx.EXPAND) sizer2.Add(bandwidth, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL) sizer2.Add(self.bandwidth_t, 0, wx.EXPAND) sizer3 = wx.FlexGridSizer(cols=4, hgap=5, vgap=5) sizer3.AddGrowableCol(1) sizer3.Add(data_st, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL) sizer3.Add(self.data_t, 0, wx.EXPAND) sizer3.Add(self.button_file, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL) sizer4 = wx.FlexGridSizer(cols=7, hgap=5, vgap=5) sizer4.AddGrowableCol(5) sizer4.Add(sfn_start_st, 0, wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL) sizer4.Add(self.sfn_start, 0, wx.EXPAND) sizer4.Add((20, 20)) sizer4.Add(sfn_total_st, 0, wx.ALIGN_CENTER_VERTICAL) sizer4.Add(self.sfn_total, 0, wx.EXPAND) sizer4.Add((20, 20), wx.EXPAND) sizer4.Add(self.refresh, 0, wx.ALIGN_RIGHT) sizer5 = wx.StaticBoxSizer(wx.StaticBox(self, wx.NewId(), u'星座图信息'), wx.VERTICAL) sizer5.Add(sizer2, 0, wx.EXPAND | wx.ALL, 10) sizer5.Add(sizer4, 0, wx.EXPAND | wx.ALL, 10) sizer5.Add(sizer3, 0, wx.EXPAND | wx.ALL, 10) self.panel.SetSizer(sizer5) sizer5.Fit(self) sizer5.SetSizeHints(self) self.sizer = wx.BoxSizer(wx.VERTICAL) self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW) self.sizer.Add(wx.StaticLine(self), 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5) self.sizer.Add(sizer1, 0, wx.EXPAND) self.sizer.Add(wx.StaticLine(self), 0, wx.EXPAND | wx.TOP | wx.BOTTOM, 5) self.sizer.Add(self.panel, 0, wx.EXPAND) self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.TOP | wx.GROW) self.SetSizer(self.sizer) self.Fit()
def __init__(self, parent, sysComps): ''' Creates the main panel with all the controls on it ''' wx.Panel.__init__(self, parent) self.parent = parent self.sysComps = sysComps self.dataWriteBulk = 10 # add controls self.cb_freeze = wx.CheckBox(self, -1, "Freeze") self.Bind(wx.EVT_CHECKBOX, self.on_cb_freeze, self.cb_freeze) self.slider_label = wx.StaticText(self, -1, "Zoom (min): ") self.slider_zoom = wx.Slider(self, -1, value=1, minValue=1, maxValue=60, style=wx.SL_AUTOTICKS | wx.SL_LABELS) self.slider_zoom.SetTickFreq(10, 1) self.Bind(wx.EVT_COMMAND_SCROLL_THUMBTRACK, self.on_slider_width, self.slider_zoom) # set figure self.dpi = 100 self.figure, self.axes = plt.subplots() self.canvas = FigureCanvas(self, -1, self.figure) self.toolbar = NavigationToolbar(self.canvas) self.axes.set_xlabel('time', fontsize=12) self.axes.set_ylabel('percent (%) - dashed line for negative values', fontsize=12) self.axes.set_ybound(0, 100) self.axes.xaxis_date() self.axes.get_xaxis().set_ticks([]) self.axes.set_axis_bgcolor('white') self.figure.canvas.mpl_connect('pick_event', self.OnPick) # Show on screen self.controllersHBox = wx.BoxSizer(wx.HORIZONTAL) self.controllersHBox.Add(self.cb_freeze, 0) self.controllersHBox.AddSpacer(30) self.controllersHBox.Add(self.slider_label, 0) self.controllersHBox.Add(self.slider_zoom, 1) self.controllersHBox.Add(self.toolbar, 0, wx.EXPAND | wx.ALIGN_LEFT) self.vbox = wx.BoxSizer(wx.VERTICAL) self.vbox.Add(self.canvas, 1, wx.EXPAND | wx.GROW | wx.ALL) self.vbox.Add(self.controllersHBox, 0, wx.EXPAND) # fit all to screen self.parent.GetSizer().Add(self, 1, wx.EXPAND | wx.GROW | wx.ALL) self.SetSizer(self.vbox) self.vbox.Fit(self) # order data sources self.lastTime = None self.time = [] self.realAnalogData = {} self.plottedAnalogData = {} self.digitalData = {} self.allRealData = {} self.plottedLines = {} variableNamesOnLegend = [] colors = ['b', 'g', 'r', 'c', 'm', 'b', 'y'] colorCycler = cycle(colors) lineWidths = [1] * len(colors) + [2] * len(colors) + [4] * len(colors) lineWidthCycler = cycle(lineWidths) for comp in self.sysComps: for var in comp.vars.values(): name = var.FullName() if isinstance(var, SysVarAnalog): variableNamesOnLegend += [name] self.realAnalogData[name] = AnalogData(var.range) color = next(colorCycler) lineWidth = next(lineWidthCycler) if var.showInSignalLog: nameOnLegend = name + ' [' + str( var.range[0]) + ',' + str(var.range[1]) + ']' graphVisible = True else: nameOnLegend = None graphVisible = False if not self.hasBipolarRange(name): self.plottedAnalogData[name] = AnalogData(var.range) self.plottedLines[name] = self.axes.plot( self.time, self.plottedAnalogData[name].data, '-', lw=lineWidth, color=color, label=nameOnLegend, visible=graphVisible)[0] else: # split this variable to two unipolar variables for the sake of plotting self.plottedAnalogData[name + '_POS'] = AnalogData( [0, var.range[1]]) self.plottedAnalogData[name + '_NEG'] = AnalogData( [var.range[0], 0]) self.plottedLines[name + '_POS'] = self.axes.plot( self.time, self.plottedAnalogData[name + '_POS'].data, '-', lw=lineWidth, color=color, label=nameOnLegend, visible=graphVisible)[0] self.plottedLines[name + '_NEG'] = self.axes.plot( self.time, self.plottedAnalogData[name + '_NEG'].data, '--', lw=lineWidth, color=color, visible=graphVisible)[0] # digital data isn't plotted if isinstance(var, SysVarDigital): self.digitalData[name] = Data() self.allRealData.update(self.realAnalogData) self.allRealData.update(self.digitalData) # finalize legend self.axes.set_ybound(0, 100) leg = self.axes.legend(loc='upper left', fancybox=True, shadow=True) leg.get_frame().set_alpha(0.4) self.lineLegendDict = {} for legline, lineName in zip(leg.get_lines(), variableNamesOnLegend): legline.set_picker(5) # 5 pts tolerance self.lineLegendDict[legline] = lineName self.lineLegendDictReverseDict = { v: k for k, v in self.lineLegendDict.items() }
def __init__(self): self.screen_size = wx.DisplaySize() #print("the screen size is {0}".format(self.screen_size)) self.screen_dpi = 100 self.frame_length = int(self.screen_size[0] * 0.88) self.frame_width = int(self.screen_size[1] * 0.88) self.fig_length = self.frame_length // self.screen_dpi self.fig_width = self.frame_width // self.screen_dpi self.frame_length = self.fig_length * self.screen_dpi self.frame_width = self.fig_width * self.screen_dpi wx.Frame.__init__(self, None, wx.ID_ANY, #wx.Frame.__init__(self, None, wx.ID_ANY, style=wx.FRAME_SHAPED, title='CP1/X86 TPCC Performance Comparison', #size=(self.frame_length, self.frame_width) size=(1900, 1000) #size=(1000, 500) #size=(1200, 500) ) # Matplotlib Figure, x/y-size should size_in_Frame/dpi #eg: 1800 = 15 * 120, 600 = 5 * 120 self.fig = Figure((19, 10), 100) #self.fig = Figure((10, 5), 100) #self.fig = Figure((self.fig_length, self.fig_width), self.screen_dpi) #self.fig.subplots_adjust(wspace=10) #print(self.frame_length, self.frame_width) #print(self.fig_length, self.fig_width) self.canvas = FigureCanvas(self, wx.ID_ANY, self.fig) self.ax = self.fig.add_subplot(211) self.ax.set_ylim([Y_MIN_VALUE, Y_MAX_VALUE]) self.ax.set_xlim([X_MIN_VALUE, X_MAX_VALUE]) self.ax.set_autoscale_on(False) #self.ax.set_xticks([]) self.ax.set_xticks(range(0, 61, 10)) #self.ax.set_xticks(range(X_MIN_VALUE, X_MAX_VALUE + 1, X_STEP_VALUE)) self.ax.set_yticks(range(Y_MIN_VALUE, Y_MAX_VALUE + 1, Y_STEP_VALUE)) self.ax.set_xlabel("Time(second)") self.ax.set_ylabel("Transactions Per Minute(tpmC)") self.ax.grid(True) self.power8_current_all_values = [None] * EMPTY_NUMBER self.x86_current_all_values = [None] * EMPTY_NUMBER self.power8_plot, = self.ax.plot(range(EMPTY_NUMBER), #self.power8_current_all_values, label='CP1 Value', self.power8_current_all_values, label='CP1 TPC-C', #color='red', linestyle = ':', linewidth = 2, marker = 'o' color='red', marker = '.' ) self.x86_plot, = self.ax.plot(range(EMPTY_NUMBER), #self.x86_current_all_values, label='X86 Value', self.x86_current_all_values, label='X86 TPC-C', color='green', marker = '.' ) self.ax.legend(loc='upper center', ncol=4, prop=font_manager.FontProperties(size=16) #prop=font_manager.FontProperties(size=10) ) # for 2nd subplot self.average = self.fig.add_subplot(212) self.average.set_ylim(0, 6) #self.average.set_xlim(Y_MIN_VALUE, Y_MAX_VALUE) self.average.set_xlim(Y_MIN_VALUE, 300000) #self.average.set_ylabel("yHello world") self.average.set_xlabel("Transactions Per Minute(tpmC)") self.power8_accumulate_value = 0 self.x86_accumulate_value = 0 self.power8_previous_value = 0 self.x86_previous_value = 0 self.power8_ave_index = [3] self.x86_ave_index = [1] self.power8_ave_value = [0] self.x86_ave_value = [0] self.power8_barh, = self.average.barh(bottom=self.power8_ave_index, width=self.power8_ave_value, height=1.0, color='red', label='CP1 TPC-C (Average)') self.x86_barh, = self.average.barh(bottom=self.x86_ave_index, width=self.x86_ave_value, height=1.0, color='green', label="X86 TPC-C (Average)") self.average.grid(True) self.average.legend(loc='upper center', ncol=4, prop=font_manager.FontProperties(size=16) #prop=font_manager.FontProperties(size=10) ) self.average.set_yticks([]) self.fig.subplots_adjust(left=0.08, right=0.95, bottom=0.05, top=0.95) ########################################################################################## # TODO: resize the subplot in figure self.ax.set_position([0.08, 0.40, 0.85, 0.55]) self.average.set_position([0.08, 0.05, 0.85, 0.28]) self.canvas.draw() # save the clean background self.background_1st = self.canvas.copy_from_bbox(self.ax.bbox) self.background_2nd = self.canvas.copy_from_bbox(self.average.bbox) self.global_timer_index = 0 self.local_timer_index = 0 self.power8_current_all_values = [] self.x86_current_all_values = [] wx.EVT_TIMER(self, TIMER_ID, self.on_timer)
def __init__(self, parent): self.panel = wx.Panel.__init__(self, parent) self.PhotoMaxSize = 299 font = wx.SystemSettings.GetFont(wx.SYS_SYSTEM_FONT) font.SetPointSize(10) # main vbox vbox = wx.BoxSizer(wx.VERTICAL) # horizontal box for images hbox0 = wx.BoxSizer(wx.HORIZONTAL) #vbox.Add(st1, flag=wx.EXPAND | wx.LEFT | wx.TOP, border=20) # imagen vbox1 = wx.BoxSizer(wx.VERTICAL) st1 = wx.StaticText(self, label='Resized Image') vbox1.Add(st1) figure = Figure(figsize=(3, 3)) self.axes = figure.add_subplot(111) self.axes.axis('off') figure.tight_layout(pad=0) self.canvas = FigureCanvas(self, -1, figure) vbox1.Add(self.canvas, flag=wx.TOP, border=10) hbox0.Add(vbox1, 0, wx.ALL, 5) # bad class vbox2 = wx.BoxSizer(wx.VERTICAL) st2 = wx.StaticText(self, label='Bad Quality Information') vbox2.Add(st2) bad_figure = Figure(figsize=(3, 3)) self.bad_axes = bad_figure.add_subplot(111) self.bad_axes.axis('off') bad_figure.tight_layout(pad=0) self.bad_canvas = FigureCanvas(self, -1, bad_figure) vbox2.Add(self.bad_canvas, flag=wx.TOP, border=10) hbox0.Add(vbox2, 0, wx.ALL, 5) # good class vbox3 = wx.BoxSizer(wx.VERTICAL) st3 = wx.StaticText(self, label='Good Quality Information') vbox3.Add(st3) good_figure = Figure(figsize=(3, 3)) self.good_axes = good_figure.add_subplot(111) self.good_axes.axis('off') good_figure.tight_layout(pad=0) self.good_canvas = FigureCanvas(self, -1, good_figure) vbox3.Add(self.good_canvas, flag=wx.TOP, border=10) hbox0.Add(vbox3, 0, wx.ALL, 5) vbox.Add(hbox0, flag=wx.EXPAND | wx.LEFT, border=20) vbox.Add((-1, 25)) # button hbox1 = wx.BoxSizer(wx.HORIZONTAL) input_button = wx.Button(self, label="Browse Image") input_button.Bind(wx.EVT_BUTTON, self.onBrowse) hbox1.Add(input_button, 0, wx.ALL | wx.CENTER, 5) # texto para la carpeta self.inputText = wx.StaticText(self, label='') self.inputText.SetFont(font) hbox1.Add(self.inputText, flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL, border=8) st4 = wx.StaticText(self, label='Select Image Information:') hbox1.Add(st4, flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL, border=450) self.dropdown = wx.ComboBox( self, value="SmoothGrad Saliency", choices=['SmoothGrad Saliency', 'GradCAM++'], style=wx.CB_READONLY) hbox1.Add(self.dropdown, flag=wx.LEFT, border=10) vbox.Add(hbox1, flag=wx.EXPAND | wx.LEFT, border=20) self.SetSizer(vbox)
def __init__( self, parent ): wx.Frame.__init__ ( self, parent, id = wx.ID_ANY, title = u"wxPython Main Form", pos = wx.DefaultPosition, size = wx.Size( 1050,577 ), style = wx.DEFAULT_FRAME_STYLE|wx.TAB_TRAVERSAL ) self.SetSizeHints( wx.DefaultSize, wx.DefaultSize ) bSizer1 = wx.BoxSizer( wx.VERTICAL ) bSizer2 = wx.BoxSizer( wx.HORIZONTAL ) self.m_staticText2 = wx.StaticText( self, wx.ID_ANY, u"Starting Date", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText2.Wrap( -1 ) bSizer2.Add( self.m_staticText2, 0, wx.ALL, 5 ) self.dateBegin = wx.adv.DatePickerCtrl( self, wx.ID_ANY, wx.DefaultDateTime, wx.DefaultPosition, wx.DefaultSize, wx.adv.DP_DEFAULT ) bSizer2.Add( self.dateBegin, 0, wx.ALL, 5 ) self.m_staticText3 = wx.StaticText( self, wx.ID_ANY, u"Ending Date", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText3.Wrap( -1 ) bSizer2.Add( self.m_staticText3, 0, wx.ALL, 5 ) self.dateEnd = wx.adv.DatePickerCtrl( self, wx.ID_ANY, wx.DefaultDateTime, wx.DefaultPosition, wx.DefaultSize, wx.adv.DP_DEFAULT ) bSizer2.Add( self.dateEnd, 0, wx.ALL, 5 ) self.m_staticText1 = wx.StaticText( self, wx.ID_ANY, u"USGS Station ID", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText1.Wrap( -1 ) bSizer2.Add( self.m_staticText1, 0, wx.ALL, 5 ) self.txtID = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) bSizer2.Add( self.txtID, 0, wx.ALL, 5 ) self.btnDownload = wx.Button( self, wx.ID_ANY, u"Download", wx.DefaultPosition, wx.DefaultSize, 0 ) bSizer2.Add( self.btnDownload, 0, wx.ALL, 5 ) bSizer1.Add( bSizer2, 0, 0, 5 ) bSizer3 = wx.BoxSizer( wx.HORIZONTAL ) m_radioBox1Choices = [ u"Daily", u"Monthly", u"Annual"] self.m_radioBox1 = wx.RadioBox( self, wx.ID_ANY, u"wxRadioBox", wx.DefaultPosition, wx.DefaultSize, m_radioBox1Choices, 1, wx.RA_SPECIFY_COLS ) self.m_radioBox1.SetSelection( 0 ) bSizer3.Add( self.m_radioBox1, 0, wx.ALL, 5 ) self.m_panel1 = wx.Panel( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL ) self.m_panel1.SetBackgroundColour( wx.SystemSettings.GetColour( wx.SYS_COLOUR_INFOBK ) ) self.m_panel1.figure = matplotlib.figure.Figure() self.canvas = FigureCanvas(self.m_panel1, -1, self.m_panel1.figure) self.axes = self.m_panel1.figure.add_subplot(111) bSizer3.Add( self.m_panel1, 1, wx.EXPAND |wx.ALL, 5 ) # bSizer31 = wx.BoxSizer( wx.HORIZONTAL ) # bSizer31.Add(self.canvas, 1, wx.EXPAND |wx.ALL, 5 ) # self.m_panel1.SetSizer(bSizer31) bSizer1.Add( bSizer3, 2, wx.EXPAND, 5 ) bSizer5 = wx.BoxSizer( wx.VERTICAL ) self.m_grid1 = wx.grid.Grid( self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, 0 ) # Grid self.m_grid1.CreateGrid( 5, 5 ) self.m_grid1.EnableEditing( True ) self.m_grid1.EnableGridLines( True ) self.m_grid1.EnableDragGridSize( False ) self.m_grid1.SetMargins( 0, 0 ) # Columns self.m_grid1.EnableDragColMove( False ) self.m_grid1.EnableDragColSize( True ) self.m_grid1.SetColLabelSize( 30 ) self.m_grid1.SetColLabelAlignment( wx.ALIGN_CENTER, wx.ALIGN_CENTER ) # Rows self.m_grid1.EnableDragRowSize( True ) self.m_grid1.SetRowLabelSize( 80 ) self.m_grid1.SetRowLabelAlignment( wx.ALIGN_CENTER, wx.ALIGN_CENTER ) # Label Appearance # Cell Defaults self.m_grid1.SetDefaultCellAlignment( wx.ALIGN_LEFT, wx.ALIGN_TOP ) bSizer5.Add( self.m_grid1, 0, wx.ALL, 5 ) bSizer1.Add( bSizer5, 1, wx.EXPAND, 5 ) self.SetSizer( bSizer1 ) self.Layout() # Connect Events self.btnDownload.Bind( wx.EVT_BUTTON, self.downloadData ) self.m_radioBox1.Bind( wx.EVT_RADIOBOX, self.changeFreq ) # check downloaded data == 0 self.downloaded = False
def __init__(self): wx.Frame.__init__(self, None, -1, 'Scrimmage Plotting Tool') self.figure = Figure() self.ax = self.figure.add_subplot(111) self.canvas = FigureCanvas(self, -1, self.figure) self.toolbar = NavigationToolbar2Wx(self.canvas) self.toolbar.Realize() self.vsizer = wx.BoxSizer(wx.VERTICAL) self.buttonSizer = wx.BoxSizer(wx.HORIZONTAL) self.buttonSizer.Add(wx.Button(self, 101, "Open Frames"), 0) self.Bind(wx.EVT_BUTTON, self.open_frames, id=101) self.buttonSizer.Add(wx.Button(self, 102, "Set Plot Title"), 0) self.Bind(wx.EVT_BUTTON, self.changePlotTitle, id=102) self.buttonSizer.Add(wx.Button(self, 103, "Set Y Label"), 0) self.Bind(wx.EVT_BUTTON, self.changeYLabel, id=103) self.buttonSizer.Add(wx.Button(self, 104, "Set Y Min"), 0) self.Bind(wx.EVT_BUTTON, self.setYMin, id=104) self.buttonSizer.Add(wx.Button(self, 105, "Set Y Max"), 0) self.Bind(wx.EVT_BUTTON, self.setYMax, id=105) self.buttonSizer.Add(wx.Button(self, 106, "Set Font Size"), 0) self.Bind(wx.EVT_BUTTON, self.setFontSize, id=106) self.vsizer.Add(self.buttonSizer, 0) self.sizer = wx.BoxSizer(wx.HORIZONTAL) self.canvasSizer = wx.BoxSizer(wx.VERTICAL) self.canvasSizer.Add(self.canvas, 1, wx.ALL | wx.EXPAND | wx.CENTER, 0) self.canvasSizer.Add(self.toolbar, 0, wx.ALL | wx.EXPAND | wx.RIGHT, 0) self.logs = dict() self.logTree = CT.CustomTreeCtrl(self, agwStyle=wx.TR_DEFAULT_STYLE) self.logTreeRoot = self.logTree.AddRoot("Scrimmage Logs") self.Bind(CT.EVT_TREE_ITEM_CHECKED, self.logTreeChecked) self.keySizer = wx.BoxSizer(wx.VERTICAL) self.keySizer.Add(wx.StaticText(self, -1, "Key:")) rightColumn = wx.BoxSizer(wx.VERTICAL) rightColumn.Add(self.keySizer, 4) self.sizer.Add(self.logTree, 2, wx.ALL | wx.EXPAND | wx.CENTER, 5) self.sizer.Add(self.canvasSizer, 8, wx.ALL | wx.EXPAND | wx.CENTER, 5) self.sizer.Add(rightColumn, 4, wx.ALL | wx.EXPAND | wx.TOP, 5) self.vsizer.Add(self.sizer, 20, wx.ALL | wx.EXPAND | wx.TOP, 5) self.SetSizer(self.vsizer) self.Fit() self.plottedItems = list() self.plottedButtons = dict() self.plottedColors = dict() self.closeButtonNum = 0 self.closeLookup = dict() self.timeShift = dict() self.timeShiftSliders = dict() self.plotTitle = None self.ymin = None self.ymax = None self.ylabel = None self.flyingStates = set() self.flyingStatesToPlot = set()
def __init__(self, data_source, device_info: DeviceInfo, seconds: int = 5, downsample_factor: int = 2, refresh: int = 500, y_scale=100): wx.Frame.__init__(self, None, -1, 'EEG Viewer', size=(800, 550)) self.data_source = data_source self.refresh_rate = refresh self.samples_per_second = device_info.fs self.records_per_refresh = int( (self.refresh_rate / 1000) * self.samples_per_second) self.channels = device_info.channels self.removed_channels = ['TRG', 'timestamp'] self.data_indices = self.init_data_indices() self.seconds = seconds self.downsample_factor = downsample_factor self.filter = downsample_filter(downsample_factor, device_info.fs) self.autoscale = True self.y_min = -y_scale self.y_max = y_scale self.buffer = self.init_buffer() # figure size is in inches. self.figure = Figure(figsize=(12, 9), dpi=80, tight_layout={'pad': 0.0}) # space between axis label and tick labels self.yaxis_label_space = 60 self.yaxis_label_fontsize = 14 # fixed width font so we can adjust spacing predictably self.yaxis_tick_font = 'DejaVu Sans Mono' self.yaxis_tick_fontsize = 10 self.axes = self.init_axes() self.canvas = FigureCanvas(self, -1, self.figure) self.CreateStatusBar() # Toolbar self.toolbar = wx.BoxSizer(wx.VERTICAL) self.start_stop_btn = wx.Button(self, -1, "Start") self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.update_view, self.timer) self.Bind(wx.EVT_BUTTON, self.toggle_stream, self.start_stop_btn) # Filtered checkbox self.sigpro_checkbox = wx.CheckBox(self, label="Filtered") self.sigpro_checkbox.SetValue(False) self.Bind(wx.EVT_CHECKBOX, self.toggle_filtering_handler, self.sigpro_checkbox) # Autoscale checkbox self.autoscale_checkbox = wx.CheckBox(self, label="Autoscale") self.autoscale_checkbox.SetValue(self.autoscale) self.Bind(wx.EVT_CHECKBOX, self.toggle_autoscale_handler, self.autoscale_checkbox) # Number of seconds text box self.seconds_choices = [2, 5, 10] if self.seconds not in self.seconds_choices: self.seconds_choices.append(self.seconds) self.seconds_choices.sort() opts = [str(x) + " seconds" for x in self.seconds_choices] self.seconds_input = wx.Choice(self, choices=opts) cur_sec_selection = self.seconds_choices.index(self.seconds) self.seconds_input.SetSelection(cur_sec_selection) self.Bind(wx.EVT_CHOICE, self.seconds_handler, self.seconds_input) controls = wx.BoxSizer(wx.HORIZONTAL) controls.Add(self.start_stop_btn, 1, wx.ALIGN_CENTER, 0) controls.Add(self.sigpro_checkbox, 1, wx.ALIGN_CENTER, 0) controls.Add(self.autoscale_checkbox, 1, wx.ALIGN_CENTER, 0) # TODO: pull right; currently doesn't do that controls.Add(self.seconds_input, 0, wx.ALIGN_RIGHT, 0) self.toolbar.Add(controls, 1, wx.ALIGN_CENTER, 0) self.init_channel_buttons() sizer = wx.BoxSizer(wx.VERTICAL) sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.EXPAND) sizer.Add(self.toolbar, 0, wx.ALIGN_BOTTOM | wx.ALIGN_CENTER) self.SetSizer(sizer) self.SetAutoLayout(1) self.Fit() self.init_data() self.started = False self.start()
def layout_widgets(self): v = wx.BoxSizer(wx.VERTICAL) self.SetSizer(v) # Figure and figure controls self.fig = Figure((5.0, 4.0), dpi=100) self.canvas = FigureCanvas(self, wx.ID_ANY, self.fig) self.axes = self.fig.add_subplot(111) toolbar = NavigationToolbar(self.canvas) self.plot_cursor_position_info = wx.StaticText(self, style=wx.ALIGN_RIGHT, size=(250, -1), label='') self.canvas.mpl_connect('motion_notify_event', self.mouse_position_on_plot) v.Add(self.canvas, proportion=1, flag=wx.EXPAND) h = wx.BoxSizer(wx.HORIZONTAL) h.Add(toolbar, proportion=1) h.AddSpacer(10) h.Add(self.plot_cursor_position_info, flag=wx.ALIGN_CENTER_VERTICAL) h.AddSpacer(5) v.Add(h, flag=wx.EXPAND) # Choose line probe to plot h = wx.BoxSizer(wx.HORIZONTAL) v.Add(h, flag=wx.ALL | wx.EXPAND, border=4) h.Add(wx.StaticText(self, label='Line probe:'), flag=wx.ALIGN_CENTER_VERTICAL) h.AddSpacer(5) self.line_probe_selector = wx.Choice(self) self.line_probe_selector.Bind(wx.EVT_CHOICE, self.on_select_line_probe) h.Add(self.line_probe_selector, proportion=1) h.AddSpacer(5) b = wx.Button(self, label='Load') b.Bind(wx.EVT_BUTTON, self.load_line_probes) h.Add(b) # Choose timestep h = wx.BoxSizer(wx.HORIZONTAL) v.Add(h, flag=wx.ALL | wx.EXPAND, border=4) h.Add(wx.StaticText(self, label='Time step:'), flag=wx.ALIGN_CENTER_VERTICAL) h.AddSpacer(5) self.time_selector = wx.Slider(self) def lam(evt): return setattr(self, 'need_update', True) self.time_selector.Bind(wx.EVT_SLIDER, lam) h.Add(self.time_selector, proportion=1) # Customize the plot text fgs = wx.FlexGridSizer(cols=2, vgap=3, hgap=10) fgs.AddGrowableCol(1, proportion=1) v.Add(fgs, flag=wx.ALL | wx.EXPAND, border=6) # Plot title fgs.Add(wx.StaticText(self, label='Plot title:'), flag=wx.ALIGN_CENTER_VERTICAL) self.title = wx.TextCtrl(self) self.title.Bind(wx.EVT_TEXT, self.update_plot_soon) fgs.Add(self.title, flag=wx.EXPAND) # Plot xlabel / log x axis fgs.Add(wx.StaticText(self, label='Label X:'), flag=wx.ALIGN_CENTER_VERTICAL) self.xlabel = wx.TextCtrl(self) self.xlabel.Bind(wx.EVT_TEXT, self.update_plot_soon) fgs.Add(self.xlabel, flag=wx.EXPAND) # Plot ylabel fgs.Add(wx.StaticText(self, label='Label Y:'), flag=wx.ALIGN_CENTER_VERTICAL) self.ylabel = wx.TextCtrl(self) self.ylabel.Bind(wx.EVT_TEXT, self.update_plot_soon) fgs.Add(self.ylabel, flag=wx.EXPAND) # Plot ylabel fgs.Add(wx.StaticText(self, label='Aspect ratio:'), flag=wx.ALIGN_CENTER_VERTICAL) self.aspect = wx.Choice(self) self.aspect.Set(['equal', 'auto']) self.aspect.Select(1) self.aspect.Bind(wx.EVT_CHOICE, self.update_plot_soon) fgs.Add(self.aspect, flag=wx.EXPAND) v.Fit(self)
def __init__(self, panel, notify, settings, status, remoteControl): self.panel = panel self.notify = notify self.plot = None self.settings = settings self.status = status self.remoteControl = remoteControl self.spectrum = None self.isLimited = None self.limit = None self.extent = None self.annotate = None self.isDrawing = False self.toolTip = wx.ToolTip('') self.mouseSelect = None self.mouseZoom = None self.measureTable = None self.background = None self.selectStart = None self.selectEnd = None self.menuClearSelect = [] self.measure = None self.show = None self.doDraw = False wx.Panel.__init__(self, panel) self.figure = matplotlib.figure.Figure(facecolor='white') self.figure.set_size_inches(0, 0) self.canvas = FigureCanvas(self, -1, self.figure) self.canvas.SetToolTip(self.toolTip) self.measureTable = PanelMeasure(self, settings) self.toolbar = NavigationToolbar(self.canvas, self, settings, self.__hide_overlay) self.toolbar.Realize() vbox = wx.BoxSizer(wx.VERTICAL) vbox.Add(self.canvas, 1, wx.EXPAND) vbox.Add(self.measureTable, 0, wx.EXPAND) vbox.Add(self.toolbar, 0, wx.EXPAND) self.SetSizer(vbox) vbox.Fit(self) self.create_plot() self.canvas.mpl_connect('button_press_event', self.__on_press) self.canvas.mpl_connect('figure_enter_event', self.__on_enter) self.canvas.mpl_connect('axes_leave_event', self.__on_leave) self.canvas.mpl_connect('motion_notify_event', self.__on_motion) self.canvas.mpl_connect('draw_event', self.__on_draw) self.Bind(wx.EVT_IDLE, self.__on_idle) self.Bind(wx.EVT_SIZE, self.__on_size) self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.__on_timer, self.timer)
def __init__(self, parent): wx.Frame.__init__(self, parent, id=wx.ID_ANY, title=u"Testu logs", pos=wx.DefaultPosition, size=wx.Size(700, 450), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL) self.SetSizeHints(wx.DefaultSize, wx.DefaultSize) bSizer1 = wx.BoxSizer(wx.HORIZONTAL) self.m_panel1 = wx.Panel(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL) bSizer1.Add(self.m_panel1, 1, wx.EXPAND, 5) self.m_panel2 = wx.Panel(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.BORDER_SUNKEN | wx.TAB_TRAVERSAL) self.m_panel2.SetMinSize(wx.Size(150, -1)) self.figure = Figure() self.axes = self.figure.add_subplot(111) self.canvas = FigureCanvas(self, -1, self.figure) self.sizer = wx.BoxSizer(wx.HORIZONTAL) self.sizer.Add(self.canvas, 1, wx.EXPAND) self.SetSizer(self.sizer) self.Fit global x x = range(1, 6) global y y = 1000 colors = [] global barcollection self.barcollection = self.axes.bar(x, y, color=colors) global my_cmap my_cmap = plt.cm.get_cmap( 'jet') #seit parveido krasu lai atbilstu colormap global k k = 0. global Blit Blit = True ##########TIMER self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.draw, self.timer) ################ self.figure.canvas.draw() self.axesbackground = self.figure.canvas.copy_from_bbox(self.axes.bbox) plt.show(block=False) bSizer2 = wx.BoxSizer(wx.VERTICAL) bSizer2.Add((0, 0), 1, wx.EXPAND, 5) self.m_button1 = wx.Button(self.m_panel2, wx.ID_ANY, u"Variants A", wx.DefaultPosition, wx.DefaultSize, 0) bSizer2.Add(self.m_button1, 0, wx.ALL, 5) self.m_button2 = wx.Button(self.m_panel2, wx.ID_ANY, u"Variants B", wx.DefaultPosition, wx.DefaultSize, 0) bSizer2.Add(self.m_button2, 0, wx.ALL, 5) self.toggleBtn = wx.Button(self.m_panel2, wx.ID_ANY, "Start") bSizer2.Add(self.toggleBtn, 0, wx.ALL, 5) bSizer2.Add((0, 0), 1, wx.EXPAND, 5) self.m_panel2.SetSizer(bSizer2) self.m_panel2.Layout() bSizer2.Fit(self.m_panel2) bSizer1.Add(self.m_panel2, 0, wx.EXPAND, 5) self.SetSizer(bSizer1) self.Layout() self.Centre(wx.BOTH) self.m_statusBar1 = self.CreateStatusBar( 1, wx.STB_SIZEGRIP | wx.BORDER_RAISED, wx.ID_ANY) # Connect Events self.Bind(wx.EVT_CLOSE, self.OnClose) self.Bind(wx.EVT_IDLE, self.OnIdle) self.m_button1.Bind(wx.EVT_BUTTON, self.OnVariantsA) self.m_button2.Bind(wx.EVT_BUTTON, self.OnVariantsB) self.toggleBtn.Bind(wx.EVT_BUTTON, self.onToggle) ######################## self.figure.canvas.mpl_connect('button_press_event', self.OnClick)
def looper(): global conv_param, m, ecut_value, kgrid_value, tsmear_value m = 0 for conv_param in range_param: if conv_selection == 1: ecut = float(conv_param) kgrid = float(kgrid_value) tsmear = float(tsmear_value) print 'Processing STEP ' + str(m + 1) + ' of ' + str( len(range_param)) + ': ecut = ' + str( ecut) + ' eV..........' elif conv_selection == 2: kgrid = float(conv_param) tsmear = float(tsmear_value) ecut = float(ecut_value) print 'Processing STEP ' + str(m + 1) + ' of ' + str( len(range_param)) + ': kgrid = ' + str( int(kgrid)) + 'X' + str(int(kgrid)) + 'X' + str( int(kgrid)) + '..........' incar_generator(ecut, tsmear) kpoints_generator(kgrid) poscar_generator(latt_param[0], latt_param[1], latt_param[2], lattice_vectors, no_species, position_atoms_PUC) commands.getoutput('cd working; mpirun -np ' + str(multiprocessing.cpu_count() - 2) + ' vasp') #run vasp commands.getoutput('cd working; mv OSZICAR ../GS_Plots/' + Material + '/conv_test/OSZICAR_' + str(conv_param)) #cut output file commands.getoutput('cd working; mv OUTCAR ../GS_Plots/' + Material + '/conv_test/OUTCAR_' + str(conv_param)) #cut output file commands.getoutput( 'cd working; find . ! -name "POTCAR" -type f -exec rm -f {} +' ) #start from scratch every time if m >= 1: param_lower_bound, delta_etot = plot_conv( conv_selection, Material, float(delta_E_value) ) #extract energy data from output file and write it to file for plotting gSizer333.Clear() self.figure = figure() self.axes = self.figure.add_subplot(111) if conv_selection == 1: self.axes.set_xlabel('ecut (eV)') elif conv_selection == 2: self.axes.set_xlabel('kgrid') self.axes.set_ylabel(r'$\Delta$' + 'E (eV)') self.axes.semilogy(param_lower_bound, delta_etot) self.axes.scatter(param_lower_bound, delta_etot) xlimits = list( linspace(self.axes.get_xlim()[0], self.axes.get_xlim()[1], 100)) self.axes.plot(xlimits, [float(delta_E_value)] * len(xlimits), 'k-', label='target') self.axes.legend() self.canvas = FigureCanvas(self, -1, self.figure) self.canvas.draw() self.canvas.Refresh() gSizer333.Add( self.canvas, 1, wx.ALL | wx.ALIGN_CENTER_HORIZONTAL | wx.ALIGN_CENTER_VERTICAL | wx.EXPAND, 5) w, h = self.GetClientSize() if m % 2 == 0: self.SetSize((w, h + 1)) else: self.SetSize((w, h - 1)) time.sleep(0.5) close(self.figure) m = m + 1 m_gauge1.SetValue(m / len(range_param) * 100) if m == len(range_param): print 'JOB FINISHED :)'
def nextImage(self, event): """ Reads the next image and enables the user to move the annotations """ MainFrame.confirm(self) self.canvas.Destroy() plt.close(self.fig1) self.Button3.Enable(True) self.checkBox.Enable(False) self.slider.Enable(False) self.iter = self.iter + 1 self.fig1, (self.ax1f1) = plt.subplots(figsize=self.img_size, facecolor="None") # Checks for the last image and disables the Next button if len(self.index) - self.iter == 1: self.Button2.Enable(False) if len(self.index) > self.iter: self.updatedCoords = [] #read the image #imagename1 = os.path.join(self.dir,self.index[self.iter]) imagename1 = os.path.join(self.project_path, self.index[self.iter]) im = PIL.Image.open(imagename1) #Plotting im_axis = self.ax1f1.imshow(im, self.colormap) self.ax1f1.imshow(im) if self.adjust_original_labels == True: self.ax1f1.set_title( str( str(self.iter) + "/" + str(len(self.index) - 1) + " " + str(Path(self.index[self.iter]).stem))) else: self.ax1f1.set_title( str( str(self.iter) + "/" + str(len(self.index) - 1) + " " + str(Path(self.index[self.iter]).stem) + " " + " Threshold chosen is: " + str("{0:.2f}".format(self.threshold)))) self.canvas = FigureCanvas(self.top_split, -1, self.fig1) if np.max(im) == 0: msg = wx.MessageBox('Invalid image. Click Yes to remove', 'Error!', wx.YES_NO | wx.ICON_WARNING) if msg == 2: self.Dataframe = self.Dataframe.drop(self.index[self.iter]) self.index = list(self.Dataframe.iloc[:, 0].index) self.iter = self.iter - 1 plt.close(self.fig1) #imagename1 = os.path.join(self.dir,self.index[self.iter]) # im=io.imread(imagename1) imagename1 = os.path.join(self.project_path, self.index[self.iter]) im = PIL.Image.open(imagename1) #Plotting im_axis = self.ax1f1.imshow(im, self.colormap) self.ax1f1.imshow(im) if self.adjust_original_labels == True: self.ax1f1.set_title( str( str(self.iter) + "/" + str(len(self.index) - 1) + " " + str(Path(self.index[self.iter]).stem))) else: self.ax1f1.set_title( str( str(self.iter) + "/" + str(len(self.index) - 1) + " " + self.index[self.iter] + " " + " Threshold chosen is: " + str("{0:.2f}".format(self.threshold)))) self.canvas = FigureCanvas(self.top_split, -1, self.fig1) print(self.iter) MainFrame.plot(self, im, im_axis) self.toolbar = NavigationToolbar(self.canvas) else: self.Button2.Enable(False)
def __init__(self, filename, index_column, label_column, window_size, window_stride, max_simplices, kernel_scale): wx.Frame.__init__(self, None, -1, 'Data Visualization', size=(550, 350)) self.filename = filename self.index_column = index_column self.label_column = label_column self.window_size = window_size self.window_stride = window_stride self.max_simplices = max_simplices self.kernel_scale = kernel_scale self.spans = [] with open(self.filename, 'r') as data_file: self.data_len = len(csv.reader(data_file, delimiter=',').next()) self.data_indices = [ i for i in range(0,self.data_len) \ if not ((i == self.index_column) or (i == self.label_column) or \ (((self.index_column == -1) or (self.label_column == -1)) and (i == self.data_len-1)))] print "Data indicies %s" % (self.data_indices, ) with open(self.filename, 'r') as data_file: data_reader = csv.reader(data_file, delimiter=',') last_label = -1 for (index, line) in itertools.izip(itertools.count(0), data_reader): if line[self.label_column] != last_label: self.spans.extend([DataSpan(line[self.label_column])]) self.spans[-1].addData([index] + [line[i] for i in self.data_indices]) last_label = line[self.label_column] print "Spans %s" % ([ "elements %s label %s" % (len(span.data), span.label) for span in self.spans ]) self.labels = set([span.label for span in self.spans]) self.index = 1 self.SetBackgroundColour(wx.NamedColour("WHITE")) self.figure = Figure() self.axes = self.figure.add_subplot(111) self.canvas = FigureCanvas(self, -1, self.figure) self.click_cid_down = self.canvas.mpl_connect('button_press_event', self.mouseDown) self.click_cid_up = self.canvas.mpl_connect('button_release_event', self.mouseUp) self.click_cid_move = self.canvas.mpl_connect('motion_notify_event', self.mouseMove) self.sizer = wx.BoxSizer(wx.VERTICAL) self.sizer.Add(NavigationToolbar2Wx(self.canvas), 1, wx.LEFT | wx.TOP | wx.GROW) self.sizer.Add(self.canvas, 8, wx.LEFT | wx.TOP | wx.GROW) self.SetSizer(self.sizer) self.title = self.figure.suptitle("Data for Column %s" % (self.index, )) self.caption = self.figure.text(0.25, 0.8, "%s Samples Read" % (\ reduce((lambda x,y: x+y),[len(span.data) for span in self.spans], 0))) self.Fit() self.background = self.axes.figure.canvas.copy_from_bbox( self.axes.bbox) self.Bind(wx.EVT_PAINT, self.OnPaint) self.Bind(wx.EVT_KEY_UP, self.KeyEvent) self.point_Refresh() self.state = (None, 0)
def __init__( self, parent=None, id=wx.ID_ANY, title='Image Navigation', size=wx.Size(500,500) ): wx.Frame.__init__( self, None, id=id, title=title, size=size ) if parent is not None: self.positioners = parent.positioners else: # include this for motor-less testing self.positioners = dict( motorX=None, motorY=None ) self.p1 = None self.p2 = None self.calibrated = [False, False] self.calibrate_p1 = False self.calibrate_p2 = False self.moveto = False self.cid = None self.plotpanel = wx.Panel( self, id=wx.ID_ANY ) box = wx.BoxSizer( wx.VERTICAL ) #self.fig = pylab.figure( facecolor='white' ) self.fig = Figure( facecolor='white' ) self.fig.clf() self.axes = self.fig.add_subplot(111) self.axes.set_axis_off() self.canvas = FigureCanvas( parent=self.plotpanel, id=wx.ID_ANY, figure=self.fig ) box.Add( self.canvas, proportion = 1, flag=wx.EXPAND, border=10 ) ######## toolbar sizer; includes marker making button and text entry field boxToolbar = wx.BoxSizer( wx.HORIZONTAL ) mpl_toolbar = MPLToolbar( self.fig.canvas ) boxToolbar.Add( mpl_toolbar, proportion = .2, flag=wx.BOTTOM, border=5 ) boxToolbar.AddStretchSpacer(1) self.txt_move_indicator = wx.StaticText( parent=self.plotpanel, id=wx.ID_ANY, label="Image not yet calibrated.", size=(150,15) ) boxToolbar.Add( self.txt_move_indicator, flag=wx.CENTER ) self.button_move = wx.Button( self.plotpanel, wx.ID_ANY, '' ) boxToolbar.Add( self.button_move, flag=wx.CENTER|wx.RIGHT, border=2 ) self.button_move.Bind( wx.EVT_BUTTON, self.on_button_clicked_move ) box.Add( boxToolbar, 0, wx.EXPAND ) # calibration information: # # point 1: box_p1 = wx.BoxSizer( wx.HORIZONTAL ) box_p1.Add( wx.StaticText( parent=self.plotpanel, id=wx.ID_ANY, label="Point 1: " ), flag=wx.CENTER|wx.ALL, border=5 ) self.button_calibrate_p1 = wx.Button( self.plotpanel, wx.ID_ANY, 'set' ) box_p1.Add( self.button_calibrate_p1, flag=wx.CENTER ) self.button_calibrate_p1.Bind( wx.EVT_BUTTON, self.on_button_clicked_calibrate_p1 ) self.info_calibration_p1 = wx.StaticText( parent=self.plotpanel, id=wx.ID_ANY, label='(uncalibrated)' ) box_p1.Add( self.info_calibration_p1, flag=wx.CENTER|wx.ALL, border=5 ) box.Add( box_p1, proportion=0, flag=wx.EXPAND ) # point 2: box_p2 = wx.BoxSizer( wx.HORIZONTAL ) box_p2.Add( wx.StaticText( parent=self.plotpanel, id=wx.ID_ANY, label="Point 2: " ), flag=wx.CENTER|wx.ALL, border=5 ) self.button_calibrate_p2 = wx.Button( self.plotpanel, wx.ID_ANY, 'set' ) box_p2.Add( self.button_calibrate_p2, flag=wx.CENTER ) self.button_calibrate_p2.Bind( wx.EVT_BUTTON, self.on_button_clicked_calibrate_p2 ) self.info_calibration_p2 = wx.StaticText( parent=self.plotpanel, id=wx.ID_ANY, label='(uncalibrated)' ) box_p2.Add( self.info_calibration_p2, flag=wx.CENTER|wx.ALL, border=5 ) box.Add( box_p2, proportion=0, flag=wx.EXPAND ) # image flipped?: self.choices = dict( flipped="this image is flipped with respect to the sample", notflipped="this image is NOT flipped with respect to the sample" ) self.flip_dropdown = wx.ComboBox( parent=self.plotpanel, id=wx.ID_ANY, choices=[ self.choices['flipped'], self.choices['notflipped'] ], style=wx.CB_DROPDOWN|wx.CB_READONLY ) self.flip_dropdown.SetValue( self.choices['notflipped'] ) self.flip_dropdown.Bind( wx.EVT_COMBOBOX, self.on_flip_dropdown_changed ) box.Add( self.flip_dropdown, proportion=0, flag=wx.ALL, border=4 ) self.plotpanel.SetSizer( box ) self.add_menu_bar() self.Show( True )
def __init__(self, parent): wx.Panel.__init__(self, parent) self.currentDirectory = os.getcwd() self.inputDirectory = "" self.outputDirectory = "" self.num_images = 0 font = wx.SystemSettings.GetFont(wx.SYS_SYSTEM_FONT) font.SetPointSize(10) # we create a main horizontal box to attach the intruction image in the right. hbox = wx.BoxSizer(wx.HORIZONTAL) vbox = wx.BoxSizer(wx.VERTICAL) ################## INPUT FOLDER ########################### # titulo st1 = wx.StaticText(self, label='Select Input Folder') vbox.Add(st1, flag=wx.EXPAND | wx.LEFT | wx.TOP, border=20) # button hbox1 = wx.BoxSizer(wx.HORIZONTAL) input_button = wx.Button(self, label="Choose Folder") input_button.Bind(wx.EVT_BUTTON, self.onDirIn) hbox1.Add(input_button, 0, wx.ALL | wx.CENTER, 5) # texto para la carpeta self.inputText = wx.StaticText(self, label='') self.inputText.SetFont(font) hbox1.Add(self.inputText, flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL, border=8) vbox.Add(hbox1, flag=wx.EXPAND | wx.LEFT, border=20) # texto para el generador self.genText = wx.StaticText(self, label='') vbox.Add(self.genText, flag=wx.EXPAND | wx.LEFT, border=25) ################## OUTPUT FOLDER ########################### # titulo st2 = wx.StaticText(self, label='Select Output Folder') vbox.Add(st2, flag=wx.EXPAND | wx.LEFT | wx.TOP, border=20) # button hbox2 = wx.BoxSizer(wx.HORIZONTAL) output_button = wx.Button(self, label="Choose Folder") output_button.Bind(wx.EVT_BUTTON, self.onDirOut) hbox2.Add(output_button, 0, wx.ALL | wx.CENTER, 5) # texto para la carpeta self.outputText = wx.StaticText(self, label='') self.outputText.SetFont(font) hbox2.Add(self.outputText, flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL, border=8) vbox.Add(hbox2, flag=wx.EXPAND | wx.LEFT, border=20) # texto para el generador self.outGenText = wx.StaticText(self, label='') vbox.Add(self.outGenText, flag=wx.EXPAND | wx.LEFT, border=25) vbox.Add((-1, 25)) ################## CHECKBOX AND PERCENTAGE ################## hbox3 = wx.BoxSizer(wx.HORIZONTAL) # Slider st3 = wx.StaticText(self, label='Percentage of images') hbox3.Add(st3, flag=wx.LEFT, border=0) sl3 = wx.Slider(self, value=10, minValue=0, maxValue=100) sl3.Bind(wx.EVT_SLIDER, self.onSlider) hbox3.Add(sl3, flag=wx.LEFT, border=10) self.sliderValue = sl3.GetValue() self.sliderText = wx.StaticText(self, label=str(self.sliderValue) + " %") hbox3.Add(self.sliderText, flag=wx.LEFT, border=10) vbox.Add(hbox3, flag=wx.LEFT, border=20) vbox.Add((-1, 25)) # Checkbox cb3 = wx.CheckBox(self, label='Copy images') self.checkboxValue = True cb3.SetValue(self.checkboxValue) cb3.Bind(wx.EVT_CHECKBOX, self.onCheckbox) vbox.Add(cb3, flag=wx.LEFT, border=20) vbox.Add((-1, 50)) ################## BUTTONS ################## hbox4 = wx.BoxSizer(wx.HORIZONTAL) #btn2 = wx.Button(self, label='Close') #btn2.Bind(wx.EVT_BUTTON, self.onClose) #hbox4.Add(btn2, flag=wx.EXPAND) btn1 = wx.Button(self, label='Process', size=(150, 60)) btn1.Bind(wx.EVT_BUTTON, self.onProcess) hbox4.Add(btn1, flag=wx.EXPAND | wx.LEFT, border=10) vbox.Add(hbox4, flag=wx.LEFT, border=100) hbox.Add(vbox, flag=wx.LEFT, border=5) hbox.Add((40, -1)) figure = Figure(figsize=(5.5, 4)) axes = figure.add_subplot(111) axes.axis('off') axes.imshow(imread('instructions.png')) figure.tight_layout(pad=0) canvas = FigureCanvas(self, -1, figure) #img = wx.Image('instructions.png', wx.BITMAP_TYPE_ANY) # scale the image, preserving the aspect ratio ''' W = img.GetWidth() H = img.GetHeight() main_size = 408 if W > H: NewW = main_size NewH = main_size * H / W else: NewH = main_size NewW = main_size * W / H img = img.Scale(NewW, NewH) ''' #imageIns = wx.StaticBitmap(self, wx.ID_ANY, # wx.Bitmap(img)) hbox.Add(canvas, 0, wx.ALL, 5) self.SetSizer(hbox)
def __init__(self, parent, selPanel,infoPanel=None, mainframe=None): # Superclass constructor super(PlotPanel,self).__init__(parent) # Font handling font = parent.GetFont() font.SetPointSize(font.GetPointSize()-1) self.SetFont(font) # Preparing a special font manager for chinese characters self.specialFont=None CH_F_PATHS = [ os.path.join(pyplot_rc['datapath'], 'fonts/ttf/SimHei.ttf'), os.path.join(os.path.dirname(__file__),'../SimHei.ttf')] for fpath in CH_F_PATHS: if os.path.exists(fpath): fontP = font_manager.FontProperties(fname=fpath) fontP.set_size(font.GetPointSize()) self.specialFont=fontP break # data self.selPanel = selPanel self.infoPanel=infoPanel self.parent = parent self.mainframe= mainframe self.plotData = [] if self.selPanel is not None: bg=self.selPanel.BackgroundColour self.SetBackgroundColour(bg) # sowhow, our parent has a wrong color # GUI self.fig = Figure(facecolor="white", figsize=(1, 1)) self.fig.set_tight_layout(True) # subplots_adjust(top=0.98,bottom=0.12,left=0.12,right=0.98) self.canvas = FigureCanvas(self, -1, self.fig) self.canvas.mpl_connect('motion_notify_event', self.onMouseMove) self.navTB = MyNavigationToolbar2Wx(self.canvas) # --- Tool Panel self.toolSizer= wx.BoxSizer(wx.VERTICAL) # --- PlotType Panel self.pltTypePanel= PlotTypePanel(self); # --- Plot type specific options self.spcPanel = SpectralCtrlPanel(self) self.pdfPanel = PDFCtrlPanel(self) self.cmpPanel = CompCtrlPanel(self) self.mmxPanel = MinMaxPanel(self) # --- Ctrl Panel self.ctrlPanel= wx.Panel(self) # Check Boxes self.cbScatter = wx.CheckBox(self.ctrlPanel, -1, 'Scatter',(10,10)) self.cbSub = wx.CheckBox(self.ctrlPanel, -1, 'Subplot',(10,10)) self.cbLogX = wx.CheckBox(self.ctrlPanel, -1, 'Log-x',(10,10)) self.cbLogY = wx.CheckBox(self.ctrlPanel, -1, 'Log-y',(10,10)) self.cbSync = wx.CheckBox(self.ctrlPanel, -1, 'Sync-x',(10,10)) self.cbXHair = wx.CheckBox(self.ctrlPanel, -1, 'CrossHair',(10,10)) #self.cbSub.SetValue(True) # DEFAULT TO SUB? self.cbSync.SetValue(True) self.cbXHair.SetValue(True) # Have cross hair by default self.Bind(wx.EVT_CHECKBOX, self.scatter_select, self.cbScatter) self.Bind(wx.EVT_CHECKBOX, self.redraw_event , self.cbSub ) self.Bind(wx.EVT_CHECKBOX, self.log_select , self.cbLogX ) self.Bind(wx.EVT_CHECKBOX, self.log_select , self.cbLogY ) self.Bind(wx.EVT_CHECKBOX, self.redraw_event , self.cbSync ) self.Bind(wx.EVT_CHECKBOX, self.crosshair_event, self.cbXHair ) # LAYOUT cb_sizer = wx.FlexGridSizer(rows=3, cols=2, hgap=2, vgap=0) cb_sizer.Add(self.cbScatter, 0, flag=wx.ALL, border=1) cb_sizer.Add(self.cbSub , 0, flag=wx.ALL, border=1) cb_sizer.Add(self.cbLogX , 0, flag=wx.ALL, border=1) cb_sizer.Add(self.cbLogY , 0, flag=wx.ALL, border=1) cb_sizer.Add(self.cbSync , 0, flag=wx.ALL, border=1) cb_sizer.Add(self.cbXHair , 0, flag=wx.ALL, border=1) self.ctrlPanel.SetSizer(cb_sizer) # --- Ctrl Panel crossHairPanel= wx.Panel(self) self.lbCrossHairX = wx.StaticText(crossHairPanel, -1, 'x= ... ') self.lbCrossHairY = wx.StaticText(crossHairPanel, -1, 'y= ... ') self.lbCrossHairX.SetFont(getMonoFont(self)) self.lbCrossHairY.SetFont(getMonoFont(self)) cbCH = wx.FlexGridSizer(rows=2, cols=1, hgap=2, vgap=0) cbCH.Add(self.lbCrossHairX , 0, flag=wx.ALL, border=1) cbCH.Add(self.lbCrossHairY , 0, flag=wx.ALL, border=1) crossHairPanel.SetSizer(cbCH) # --- layout of panels row_sizer = wx.BoxSizer(wx.HORIZONTAL) sl2 = wx.StaticLine(self, -1, size=wx.Size(1,-1), style=wx.LI_VERTICAL) sl3 = wx.StaticLine(self, -1, size=wx.Size(1,-1), style=wx.LI_VERTICAL) sl4 = wx.StaticLine(self, -1, size=wx.Size(1,-1), style=wx.LI_VERTICAL) row_sizer.Add(self.pltTypePanel , 0 , flag=wx.ALL|wx.CENTER , border=2) row_sizer.Add(sl2 , 0 , flag=wx.EXPAND|wx.CENTER , border=0) row_sizer.Add(self.navTB , 0 , flag=wx.LEFT|wx.RIGHT|wx.CENTER , border=2) row_sizer.Add(sl3 , 0 , flag=wx.EXPAND|wx.CENTER , border=0) row_sizer.Add(self.ctrlPanel , 1 , flag=wx.ALL|wx.EXPAND|wx.CENTER , border=2) row_sizer.Add(sl4 , 0 , flag=wx.EXPAND|wx.CENTER , border=0) row_sizer.Add(crossHairPanel,0, flag=wx.EXPAND|wx.CENTER|wx.LEFT , border=2) plotsizer = wx.BoxSizer(wx.VERTICAL) self.slCtrl = wx.StaticLine(self, -1, size=wx.Size(-1,1), style=wx.LI_HORIZONTAL) self.slCtrl.Hide() sl1 = wx.StaticLine(self, -1, size=wx.Size(-1,1), style=wx.LI_HORIZONTAL) plotsizer.Add(self.toolSizer,0,flag = wx.EXPAND|wx.CENTER|wx.TOP|wx.BOTTOM,border = 10) plotsizer.Add(self.canvas ,1,flag = wx.EXPAND,border = 5 ) plotsizer.Add(sl1 ,0,flag = wx.EXPAND,border = 0) plotsizer.Add(self.spcPanel ,0,flag = wx.EXPAND|wx.CENTER|wx.TOP|wx.BOTTOM,border = 10) plotsizer.Add(self.pdfPanel ,0,flag = wx.EXPAND|wx.CENTER|wx.TOP|wx.BOTTOM,border = 10) plotsizer.Add(self.cmpPanel ,0,flag = wx.EXPAND|wx.CENTER|wx.TOP|wx.BOTTOM,border = 10) plotsizer.Add(self.mmxPanel ,0,flag = wx.EXPAND|wx.CENTER|wx.TOP|wx.BOTTOM,border = 10) plotsizer.Add(self.slCtrl ,0,flag = wx.EXPAND,border = 0) plotsizer.Add(row_sizer ,0,flag = wx.NORTH ,border = 5) self.show_hide(self.spcPanel, self.pltTypePanel.cbFFT.GetValue()) self.show_hide(self.cmpPanel, self.pltTypePanel.cbCompare.GetValue()) self.show_hide(self.pdfPanel, self.pltTypePanel.cbPDF.GetValue()) self.show_hide(self.mmxPanel, self.pltTypePanel.cbMinMax.GetValue()) self.SetSizer(plotsizer) self.plotsizer=plotsizer;
def __init__(self, parent): wx.Frame.__init__(self, parent, id=wx.ID_ANY, title=u"Captura de señales para el gesto 1", pos=wx.DefaultPosition, size=wx.Size(1400, 1000), style=wx.DEFAULT_FRAME_STYLE | wx.TAB_TRAVERSAL) self.SetSizeHintsSz(wx.DefaultSize, wx.DefaultSize) bSizer4 = wx.BoxSizer(wx.VERTICAL) self.panel = wx.Panel(self) sizer = wx.BoxSizer(wx.VERTICAL) self.panel.SetSizer(sizer) self.m_staticText2 = wx.StaticText( self, wx.ID_ANY, u"Captura de señales para el primer gesto \n", wx.DefaultPosition, wx.Size(700, -1), 0) self.m_staticText2.Wrap(-1) self.m_staticText2.SetFont( wx.Font(34, 70, 90, 90, False, wx.EmptyString)) bSizer4.Add(self.m_staticText2, 0, wx.ALIGN_CENTER_HORIZONTAL, 10) bSizer49 = wx.BoxSizer(wx.VERTICAL) bSizer50 = wx.BoxSizer(wx.HORIZONTAL) bSizer50.SetMinSize(wx.Size(700, 50)) self.m_staticText30 = wx.StaticText( self, wx.ID_ANY, u"Para iniciar el experimento por favor observe \n ", wx.DefaultPosition, wx.Size(1000, -1), 0) self.m_staticText30.Wrap(-1) self.m_staticText30.SetFont( wx.Font(17, 70, 90, 90, False, wx.EmptyString)) bSizer50.Add(self.m_staticText30, 0, wx.ALL, 5) bSizer52 = wx.BoxSizer(wx.VERTICAL) bSizer52.SetMinSize(wx.Size(90, -1)) self.m_button32 = wx.Button(self, wx.ID_ANY, u"Inicio", wx.Point(-1, -1), wx.Size(150, -1), 0) self.m_button32.SetFont(wx.Font(25, 70, 90, 90, False, wx.EmptyString)) bSizer52.Add(self.m_button32, 0, wx.TOP, 10) bSizer50.Add(bSizer52, 1, 0, 5) self.m_animCtrl1 = AnimationCtrl(self, pos=(40, 40), size=(14, 14), name="AnimationCtrl") self.m_animCtrl1.LoadFile( r"C:\Users\crist\OneDrive\Escritorio\Universidad\LASER\Tesis\Open_BCI_and_MYO_UD\GUI_Adquisicion/manos.gif" ) self.m_animCtrl1.Play() self.m_animCtrl1.SetMinSize(wx.Size(200, -1)) bSizer50.Add(self.m_animCtrl1, 0, wx.ALIGN_CENTER, 5) bSizer49.Add(bSizer50, 1, 0, 5) bSizer51 = wx.BoxSizer(wx.VERTICAL) bSizer57 = wx.BoxSizer(wx.HORIZONTAL) # grafica EMG self.figureEMG = plt.figure(figsize=(1, 6), dpi=60) self.axes = [ self.figureEMG.add_subplot('81' + str(i)) for i in range(1, 9) ] self.n = 512 [(ax.set_ylim(ymin=-200, ymax=200)) for ax in self.axes] global graphs self.graphs = [ ax.plot(np.arange(self.n), np.zeros(self.n))[0] for ax in self.axes ] plt.ion() self.canvEMG = FigureCanvas(self, wx.ID_ANY, self.figureEMG) bSizer57.Add(self.canvEMG, 1, wx.TOP | wx.LEFT | wx.EXPAND) # grafica EEG self.figureEEG = plt.figure(figsize=(1, 6), dpi=60) self.axesEEG = [ self.figureEEG.add_subplot('81' + str(i)) for i in range(1, 9) ] [(ax.set_ylim([-150000, 150000])) for ax in self.axesEEG] self.m = 100 self.graphsEEG = [ ax.plot(np.arange(self.m), np.zeros(self.m))[0] for ax in self.axesEEG ] plt.ion() self.canvasEEG = FigureCanvas(self, -1, self.figureEEG) bSizer57.Add(self.canvasEEG, 1, wx.TOP | wx.LEFT | wx.EXPAND) bSizer51.Add(bSizer57, 1, wx.EXPAND, 5) bSizer49.Add(bSizer51, 1, wx.EXPAND, 5) bSizer53 = wx.BoxSizer(wx.HORIZONTAL) self.m_staticText31 = wx.StaticText(self, wx.ID_ANY, u"Señal EMG", wx.DefaultPosition, wx.Size(700, 30), 0) self.m_staticText31.Wrap(-1) self.m_staticText31.SetFont( wx.Font(18, 70, 90, 90, False, wx.EmptyString)) bSizer53.Add(self.m_staticText31, 0, wx.LEFT, 5) self.m_staticText32 = wx.StaticText(self, wx.ID_ANY, u"Señal EEG", wx.DefaultPosition, wx.Size(-1, 30), 0) self.m_staticText32.Wrap(-1) self.m_staticText32.SetFont( wx.Font(18, 70, 90, 90, False, wx.EmptyString)) bSizer53.Add(self.m_staticText32, 0, 0, 5) bSizer49.Add(bSizer53, 1, 0, 5) bSizer8 = wx.BoxSizer(wx.HORIZONTAL) self.m_staticText33 = wx.StaticText(self, wx.ID_ANY, u"Tiempo:", wx.DefaultPosition, wx.Size(550, -1), 0) self.m_staticText33.Wrap(-1) self.m_staticText33.SetFont( wx.Font(18, 70, 90, 90, False, wx.EmptyString)) bSizer8.Add(self.m_staticText33, 0, wx.ALL, 5) pos = wx.DefaultPosition size = wx.Size(1, 11) style = gizmos.LED_ALIGN_CENTER self.led = gizmos.LEDNumberCtrl(self, -1, pos, size, style) self.led.SetBackgroundColour("white") self.led.SetForegroundColour("black") bSizerTimmer = wx.BoxSizer(wx.VERTICAL) bSizerTimmer.Add(self.led, 1, wx.TOP | wx.LEFT | wx.EXPAND) bSizer49.Add(bSizerTimmer, 1, wx.EXPAND, 5) self.button_siguiente = wx.Button(self, wx.ID_ANY, u"Aceptar", wx.DefaultPosition, wx.Size(150, -1), 0) self.button_siguiente.SetFont( wx.Font(18, 70, 90, 90, False, wx.EmptyString)) bSizer8.Add(self.button_siguiente, 0, wx.ALL, 5) self.button_salir = wx.Button(self, wx.ID_ANY, u"Salir", wx.DefaultPosition, wx.Size(150, -1), 0) self.button_salir.SetFont( wx.Font(18, 70, 90, 90, False, wx.EmptyString)) bSizer8.Add(self.button_salir, 0, wx.ALL, 5) bSizer49.Add(bSizer8, 0, wx.TOP, 1) bSizer4.Add(bSizer49, 1, wx.EXPAND, 5) self.SetSizer(bSizer4) self.Layout() self.Centre(wx.BOTH) # Connect Events self.m_button32.Bind(wx.EVT_BUTTON, self.OnClickInicio) self.button_siguiente.Bind(wx.EVT_BUTTON, self.OnClickConcentimiento) self.button_salir.Bind(wx.EVT_BUTTON, self.OnClickSalir) # Arrancar conexion myo self.conexionMYO() def hiloMYOConexion(arg): hiloConexionMYO = threading.currentThread() while getattr(hiloConexionMYO, "do_run", True): print("working on %s" % arg) self.mainMYO() print("Stopping as you wish.") self.hiloConexionMYO = threading.Thread(target=hiloMYOConexion, args=("PLOT_EMG_MYO", )) self.hiloConexionMYO.setDaemon(True) self.hiloConexionMYO.start() # Arranca conexion UltraCortex self.datosEEG = [] self.start_board() def hiloPlotUltracortex(arg): hiloPlotUltracortex = threading.currentThread() while getattr(hiloPlotUltracortex, "do_run", True): print("working on %s" % arg) time.sleep(3) self.mainplotUltracortex() print("Stopping as you wish.") self.hiloPlotUltracortex = threading.Thread( target=hiloPlotUltracortex, args=("PLOT_EEG_ULTRACORTEX", )) self.hiloPlotUltracortex.setDaemon(True) self.hiloPlotUltracortex.start()
def __init__(self, *args, **kwds): # begin wxGlade: SFP.__init__ kwds["style"] = kwds.get("style", 0) | wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, *args, **kwds) self.SetSize((550, 800)) self._devices = wx.ComboBox(self, wx.ID_ANY, choices=[], style=wx.CB_DROPDOWN) # noqa: E501 self._modinst_session = nimodinst.Session('niscope') for dev in self._modinst_session.devices: dev_name = dev.device_name self._devices.Append('{0}'.format(dev_name)) self._min_sample_rate = wx.SpinCtrlDouble(self, wx.ID_ANY, "1000000.0", min=0.0, max=100000000.0) # noqa: E501 self._min_record_length = wx.SpinCtrl(self, wx.ID_ANY, "1000", min=0, max=100000000) # noqa: E501 self._channel_list = wx.TextCtrl(self, wx.ID_ANY, "0") self._vertical_range = wx.SpinCtrlDouble(self, wx.ID_ANY, "1.0", min=0.0, max=100.0) # noqa: E501 self._probe_attenuation = wx.SpinCtrlDouble(self, wx.ID_ANY, "1.0", min=0.0, max=100.0) # noqa: E501 self._vertical_offset = wx.SpinCtrlDouble(self, wx.ID_ANY, "0.0", min=0.0, max=100.0) # noqa: E501 self._vertical_coupling = wx.ComboBox(self, wx.ID_ANY, choices=["AC", "DC", "Ground"], style=wx.CB_DROPDOWN | wx.CB_READONLY) # noqa: E501 self._trigger_type = wx.Notebook(self, wx.ID_ANY) self._trigger_type_immediate = wx.Panel(self._trigger_type, wx.ID_ANY) self._trigger_type_edge = wx.Panel(self._trigger_type, wx.ID_ANY) self._trigger_source_edge = wx.TextCtrl(self._trigger_type_edge, wx.ID_ANY, "0") # noqa: E501 self._trigger_level_edge = wx.SpinCtrlDouble(self._trigger_type_edge, wx.ID_ANY, "0.0", min=0.0, max=30.0) # noqa: E501 self._trigger_slope_edge = wx.ComboBox(self._trigger_type_edge, wx.ID_ANY, choices=["Positive", "Negative"], style=wx.CB_DROPDOWN | wx.CB_READONLY) # noqa: E501 self._trigger_coupling_edge = wx.ComboBox(self._trigger_type_edge, wx.ID_ANY, choices=["AC", "DC", "HF_REJECT", "LF_REJECT", "AC_PLUS_HF_REJECT"], style=wx.CB_DROPDOWN | wx.CB_READONLY) # noqa: E501 self._trigger_type_digital = wx.Panel(self._trigger_type, wx.ID_ANY) self._trigger_source_digital = wx.TextCtrl(self._trigger_type_digital, wx.ID_ANY, "VAL_RTSI_0") # noqa: E501 self._trigger_slope_digital = wx.ComboBox(self._trigger_type_digital, wx.ID_ANY, choices=[], style=wx.CB_DROPDOWN) # noqa: E501 self._trigger_type_window = wx.Panel(self._trigger_type, wx.ID_ANY) self._trigger_source_window = wx.TextCtrl(self._trigger_type_window, wx.ID_ANY, "0") # noqa: E501 self._mode_window = wx.ComboBox(self._trigger_type_window, wx.ID_ANY, choices=[], style=wx.CB_DROPDOWN) # noqa: E501 self._low_level_window = wx.SpinCtrlDouble(self._trigger_type_window, wx.ID_ANY, "0.0", min=-30.0, max=30.0) # noqa: E501 self._high_level_window = wx.SpinCtrlDouble(self._trigger_type_window, wx.ID_ANY, "0.0", min=-30.0, max=30.0) # noqa: E501 self._trigger_coupling_window = wx.ComboBox(self._trigger_type_window, wx.ID_ANY, choices=["AC", "DC", "HF_REJECT", "LF_REJECT", "AC_PLUS_HF_REJECT"], style=wx.CB_DROPDOWN) # noqa: E501 self._trigger_type_hysteresis = wx.Panel(self._trigger_type, wx.ID_ANY) self._trigger_source_hysteresis = wx.TextCtrl(self._trigger_type_hysteresis, wx.ID_ANY, "0") # noqa: E501 self._trigger_level_hysteresis = wx.SpinCtrlDouble(self._trigger_type_hysteresis, wx.ID_ANY, "0.0", min=-30.0, max=30.0) # noqa: E501 self._hysteresis = wx.SpinCtrlDouble(self._trigger_type_hysteresis, wx.ID_ANY, "0.0", min=-30.0, max=30.0) # noqa: E501 self._trigger_slope_hysteresis = wx.ComboBox(self._trigger_type_hysteresis, wx.ID_ANY, choices=["Positive", "Negative"], style=wx.CB_DROPDOWN | wx.CB_READONLY) # noqa: E501 self._trigger_coupling_hysteresis = wx.ComboBox(self._trigger_type_hysteresis, wx.ID_ANY, choices=["AC", "DC", "HF_REJECT", "LF_REJECT", "AC_PLUS_HF_REJECT"], style=wx.CB_DROPDOWN | wx.CB_READONLY) # noqa: E501 figure = Figure() self._waveform_axes = figure.add_subplot(111) self._waveform_canvas = FigureCanvas(self, wx.ID_ANY, figure) self._status = wx.StaticText(self, wx.ID_ANY, "Good!") # Extra code that we need somewhere in the generated code self._timer = wx.Timer(self, wx.ID_ANY) self._running = False self.Bind(wx.EVT_TIMER, self.OnUpdate, self._timer) self._timer.Start(250) self._dev_name = '' self._session = None self.__set_properties() self.__do_layout() self.Bind(wx.EVT_COMBOBOX, self.OnConfigUpdate, self._devices) self.Bind(wx.EVT_TEXT, self.OnConfigUpdate, self._devices) self.Bind(wx.EVT_TEXT_ENTER, self.OnConfigUpdate, self._devices) self.Bind(wx.EVT_SPINCTRLDOUBLE, self.OnConfigUpdate, self._min_sample_rate) # noqa: E501 self.Bind(wx.EVT_SPINCTRLDOUBLE, self.OnConfigUpdate, self._min_record_length) # noqa: E501 self.Bind(wx.EVT_TEXT_ENTER, self.OnConfigUpdate, self._channel_list) # noqa: E501 self.Bind(wx.EVT_SPINCTRLDOUBLE, self.OnConfigUpdate, self._vertical_range) # noqa: E501 self.Bind(wx.EVT_SPINCTRLDOUBLE, self.OnConfigUpdate, self._probe_attenuation) # noqa: E501 self.Bind(wx.EVT_SPINCTRLDOUBLE, self.OnConfigUpdate, self._vertical_offset) # noqa: E501 self.Bind(wx.EVT_COMBOBOX, self.OnConfigUpdate, self._vertical_coupling) # noqa: E501 self.Bind(wx.EVT_TEXT, self.OnConfigUpdate, self._vertical_coupling) # noqa: E501 self.Bind(wx.EVT_TEXT_ENTER, self.OnConfigUpdate, self._vertical_coupling) # noqa: E501 self.Bind(wx.EVT_TEXT, self.OnConfigUpdate, self._trigger_source_edge) # noqa: E501 self.Bind(wx.EVT_TEXT_ENTER, self.OnConfigUpdate, self._trigger_source_edge) # noqa: E501 self.Bind(wx.EVT_SPINCTRLDOUBLE, self.OnConfigUpdate, self._trigger_level_edge) # noqa: E501 self.Bind(wx.EVT_COMBOBOX, self.OnConfigUpdate, self._trigger_slope_edge) # noqa: E501 self.Bind(wx.EVT_TEXT, self.OnConfigUpdate, self._trigger_slope_edge) # noqa: E501 self.Bind(wx.EVT_TEXT_ENTER, self.OnConfigUpdate, self._trigger_slope_edge) # noqa: E501 self.Bind(wx.EVT_COMBOBOX, self.OnConfigUpdate, self._trigger_coupling_edge) # noqa: E501 self.Bind(wx.EVT_TEXT, self.OnConfigUpdate, self._trigger_coupling_edge) # noqa: E501 self.Bind(wx.EVT_TEXT_ENTER, self.OnConfigUpdate, self._trigger_coupling_edge) # noqa: E501 self.Bind(wx.EVT_TEXT, self.OnConfigUpdate, self._trigger_source_digital) # noqa: E501 self.Bind(wx.EVT_TEXT_ENTER, self.OnConfigUpdate, self._trigger_source_digital) # noqa: E501 self.Bind(wx.EVT_COMBOBOX, self.OnConfigUpdate, self._trigger_slope_digital) # noqa: E501 self.Bind(wx.EVT_TEXT, self.OnConfigUpdate, self._trigger_slope_digital) # noqa: E501 self.Bind(wx.EVT_TEXT_ENTER, self.OnConfigUpdate, self._trigger_slope_digital) # noqa: E501 self.Bind(wx.EVT_TEXT, self.OnConfigUpdate, self._trigger_source_window) # noqa: E501 self.Bind(wx.EVT_TEXT_ENTER, self.OnConfigUpdate, self._trigger_source_window) # noqa: E501 self.Bind(wx.EVT_COMBOBOX, self.OnConfigUpdate, self._mode_window) self.Bind(wx.EVT_TEXT, self.OnConfigUpdate, self._mode_window) self.Bind(wx.EVT_TEXT_ENTER, self.OnConfigUpdate, self._mode_window) self.Bind(wx.EVT_SPINCTRLDOUBLE, self.OnConfigUpdate, self._low_level_window) # noqa: E501 self.Bind(wx.EVT_SPINCTRLDOUBLE, self.OnConfigUpdate, self._high_level_window) # noqa: E501 self.Bind(wx.EVT_COMBOBOX, self.OnConfigUpdate, self._trigger_coupling_window) # noqa: E501 self.Bind(wx.EVT_TEXT, self.OnConfigUpdate, self._trigger_coupling_window) # noqa: E501 self.Bind(wx.EVT_TEXT_ENTER, self.OnConfigUpdate, self._trigger_coupling_window) # noqa: E501 self.Bind(wx.EVT_TEXT, self.OnConfigUpdate, self._trigger_source_hysteresis) # noqa: E501 self.Bind(wx.EVT_TEXT_ENTER, self.OnConfigUpdate, self._trigger_source_hysteresis) # noqa: E501 self.Bind(wx.EVT_SPINCTRLDOUBLE, self.OnConfigUpdate, self._trigger_level_hysteresis) # noqa: E501 self.Bind(wx.EVT_SPINCTRLDOUBLE, self.OnConfigUpdate, self._hysteresis) # noqa: E501 self.Bind(wx.EVT_COMBOBOX, self.OnConfigUpdate, self._trigger_slope_hysteresis) # noqa: E501 self.Bind(wx.EVT_TEXT, self.OnConfigUpdate, self._trigger_slope_hysteresis) # noqa: E501 self.Bind(wx.EVT_TEXT_ENTER, self.OnConfigUpdate, self._trigger_slope_hysteresis) # noqa: E501 self.Bind(wx.EVT_COMBOBOX, self.OnConfigUpdate, self._trigger_coupling_hysteresis) # noqa: E501 self.Bind(wx.EVT_TEXT, self.OnConfigUpdate, self._trigger_coupling_hysteresis) # noqa: E501 self.Bind(wx.EVT_TEXT_ENTER, self.OnConfigUpdate, self._trigger_coupling_hysteresis) # noqa: E501 self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
def InitUI(self): self.SetupScrolling() self.fig = None self.ax2 = None self.tags = None self.depths = None self.tagmarkLineList = None self.depthTagList = None self.depthList = None self.iceTagList = None self.bottomIceList = None self.slushTagList = None self.bottomSlushList = None self.midsectionPanelSizerV = wx.BoxSizer(wx.VERTICAL) self.SetSizer(self.midsectionPanelSizerV) #table # self.panelSizerH = wx.BoxSizer(wx.HORIZONTAL) # tableSizerV = wx.BoxSizer(wx.VERTICAL) # self.table = ScrolledPanel(self, size=(self.width, 140)) # self.table.SetSizer(tableSizerV) # self.table.SetupScrolling(False, True) # self.panelSizerH.Add((40, -1), 0, wx.EXPAND) # self.panelSizerH.Add(self.table, 0, wx.EXPAND) # self.panelSizerH.Add((10, -1), 0, wx.EXPAND) # self.headerPanel = wx.Panel(self.table, style=wx.SIMPLE_BORDER) # self.headerPanel.SetBackgroundColour('Grey') # self.panel1 = wx.Panel(self.table, style=wx.SIMPLE_BORDER) # self.panel2 = wx.Panel(self.table, style=wx.SIMPLE_BORDER) # self.panel3 = wx.Panel(self.table, style=wx.SIMPLE_BORDER) # self.panel4 = wx.Panel(self.table, style=wx.SIMPLE_BORDER) # self.panel5 = wx.Panel(self.table, style=wx.SIMPLE_BORDER) # self.panel6 = wx.Panel(self.table, style=wx.SIMPLE_BORDER) # self.panel7 = wx.Panel(self.table, style=wx.SIMPLE_BORDER) # self.panel8 = wx.Panel(self.table, style=wx.SIMPLE_BORDER) # self.panel9 = wx.Panel(self.table, style=wx.SIMPLE_BORDER) # self.panel10 = wx.Panel(self.table, style=wx.SIMPLE_BORDER) # self.background_colour = self.panel1.GetBackgroundColour() # sizerH0 = wx.BoxSizer(wx.HORIZONTAL) # sizerH1 = wx.BoxSizer(wx.HORIZONTAL) # sizerH2 = wx.BoxSizer(wx.HORIZONTAL) # sizerH3 = wx.BoxSizer(wx.HORIZONTAL) # sizerH4 = wx.BoxSizer(wx.HORIZONTAL) # sizerH5 = wx.BoxSizer(wx.HORIZONTAL) # sizerH6 = wx.BoxSizer(wx.HORIZONTAL) # sizerH7 = wx.BoxSizer(wx.HORIZONTAL) # sizerH8 = wx.BoxSizer(wx.HORIZONTAL) # sizerH9 = wx.BoxSizer(wx.HORIZONTAL) # sizerH10 = wx.BoxSizer(wx.HORIZONTAL) # self.headerPanel.SetSizer(sizerH0) # self.panel1.SetSizer(sizerH1) # self.panel2.SetSizer(sizerH2) # self.panel3.SetSizer(sizerH3) # self.panel4.SetSizer(sizerH4) # self.panel5.SetSizer(sizerH5) # self.panel6.SetSizer(sizerH6) # self.panel7.SetSizer(sizerH7) # self.panel8.SetSizer(sizerH8) # self.panel9.SetSizer(sizerH9) # self.panel10.SetSizer(sizerH10) # self.testTxt0_1 = wx.StaticText(self.headerPanel, 1, label=self.headerLbl) # self.testTxt0_2 = wx.StaticText(self.headerPanel, 1, label=self.headerLbl) # self.testTxt0_3 = wx.StaticText(self.headerPanel, 1, label=self.headerLbl) # self.testTxt0_4 = wx.StaticText(self.headerPanel, 1, label=self.headerLbl) # self.font1 = wx.Font(22, wx.DECORATIVE, wx.ITALIC, wx.BOLD) # self.font2 = wx.Font(48, wx.ROMAN, wx.NORMAL, wx.BOLD) # self.testTxt1_1 = wx.StaticText(self.panel1, 1, label=self.testLbl1) # self.testTxt1_2 = wx.StaticText(self.panel1, 1, label=self.testLbl1) # self.testTxt1_3 = wx.StaticText(self.panel1, 1, label=self.testLbl1) # self.testTxt1_4 = wx.StaticText(self.panel1, 1, label=self.testLbl1) # self.testTxt2_1 = wx.StaticText(self.panel2, 1, label=self.testLbl2) # self.testTxt2_2 = wx.StaticText(self.panel2, 1, label=self.testLbl2) # self.testTxt2_3 = wx.StaticText(self.panel2, 1, label=self.testLbl2) # self.testTxt2_4 = wx.StaticText(self.panel2, 1, label=self.testLbl2) # self.testTxt3_1 = wx.StaticText(self.panel3, 1, label=self.testLbl3) # self.testTxt3_2 = wx.StaticText(self.panel3, 1, label=self.testLbl3) # self.testTxt3_3 = wx.StaticText(self.panel3, 1, label=self.testLbl3) # self.testTxt3_4 = wx.StaticText(self.panel3, 1, label=self.testLbl3) # self.testTxt4_1 = wx.StaticText(self.panel4, 1, label=self.testLbl4) # self.testTxt4_2 = wx.StaticText(self.panel4, 1, label=self.testLbl4) # self.testTxt4_3 = wx.StaticText(self.panel4, 1, label=self.testLbl4) # self.testTxt4_4 = wx.StaticText(self.panel4, 1, label=self.testLbl4) # self.testTxt5_1 = wx.StaticText(self.panel5, 1, label=self.testLbl4) # self.testTxt5_2 = wx.StaticText(self.panel5, 1, label=self.testLbl4) # self.testTxt5_3 = wx.StaticText(self.panel5, 1, label=self.testLbl4) # self.testTxt5_4 = wx.StaticText(self.panel5, 1, label=self.testLbl4) # self.testTxt6_1 = wx.StaticText(self.panel6, 1, label=self.testLbl4) # self.testTxt6_2 = wx.StaticText(self.panel6, 1, label=self.testLbl4) # self.testTxt6_3 = wx.StaticText(self.panel6, 1, label=self.testLbl4) # self.testTxt6_4 = wx.StaticText(self.panel6, 1, label=self.testLbl4) # self.testTxt7_1 = wx.StaticText(self.panel7, 1, label=self.testLbl4) # self.testTxt7_2 = wx.StaticText(self.panel7, 1, label=self.testLbl4) # self.testTxt7_3 = wx.StaticText(self.panel7, 1, label=self.testLbl4) # self.testTxt7_4 = wx.StaticText(self.panel7, 1, label=self.testLbl4) # self.testTxt8_1 = wx.StaticText(self.panel8, 1, label=self.testLbl4) # self.testTxt8_2 = wx.StaticText(self.panel8, 1, label=self.testLbl4) # self.testTxt8_3 = wx.StaticText(self.panel8, 1, label=self.testLbl4) # self.testTxt8_4 = wx.StaticText(self.panel8, 1, label=self.testLbl4) # self.testTxt9_1 = wx.StaticText(self.panel9, 1, label=self.testLbl4) # self.testTxt9_2 = wx.StaticText(self.panel9, 1, label=self.testLbl4) # self.testTxt9_3 = wx.StaticText(self.panel9, 1, label=self.testLbl4) # self.testTxt9_4 = wx.StaticText(self.panel9, 1, label=self.testLbl4) # self.testTxt10_1 = wx.StaticText(self.panel10, 1, label=self.testLbl4) # self.testTxt10_2 = wx.StaticText(self.panel10, 1, label=self.testLbl4) # self.testTxt10_3 = wx.StaticText(self.panel10, 1, label=self.testLbl4) # self.testTxt10_4 = wx.StaticText(self.panel10, 1, label=self.testLbl4) # for index, row in enumerate(self.table.GetChildren()): # row_sizer = row.GetSizer() # for idx, widget in enumerate(row.GetChildren()): # if index == 0: # widget.SetFont(self.font1) # else: # widget.Bind(wx.EVT_ENTER_WINDOW, self.onMouseOver) # widget.Bind(wx.EVT_LEAVE_WINDOW, self.onMouseLeave) # widget.SetToolTip(wx.ToolTip(self.tipLbl)) # row_sizer.Add(widget, 1, wx.EXPAND) # tableSizerV.Add(row, 0, wx.EXPAND) #plot self.panel2SizerH = wx.BoxSizer(wx.HORIZONTAL) self.canvasPanel = wx.Panel(self, style=wx.SIMPLE_BORDER, size=self.canvasSize) self.canvaSizerV = wx.BoxSizer(wx.VERTICAL) self.canvasPanel.SetSizer(self.canvaSizerV) midsecHeader = self.GetParent().header if midsecHeader != None: self.fig, \ self.ax2, \ self.tags, \ self.depths, \ self.tagmarkLineList, \ self.depthTagList, \ self.depthList, \ self.iceTagList, \ self.bottomIceList, \ self.slushTagList, \ self.bottomSlushList = midsecHeader.GeneratePlot() self.annot = self.ax2.annotate("", xy=(0, 0), xytext=(40, -45),textcoords="offset points", \ bbox=dict(boxstyle="round", fc="w"), arrowprops=dict(arrowstyle="Fancy")) self.annot.set_visible(False) self.canvas = FigureCanvas(self.canvasPanel, -1, self.fig) self.fig.canvas.mpl_connect('button_press_event', self.onMouseClickAx2) self.fig.canvas.mpl_connect('motion_notify_event', self.onMouseOverAx2) self.canvaSizerV.Add(self.canvas, 0, wx.EXPAND) # self.panel2SizerH.Add((20, -1), 0, wx.EXPAND) self.panel2SizerH.Add(self.canvasPanel, 1, wx.EXPAND | wx.LEFT, 20) # self.midsectionPanelSizerV.Add((-1, 20), 0, wx.EXPAND) # self.midsectionPanelSizerV.Add(self.panelSizerH, 0, wx.EXPAND) # self.midsectionPanelSizerV.Add((-1, 20), 0, wx.EXPAND) self.midsectionPanelSizerV.Add(self.panel2SizerH, 0, wx.EXPAND) plt.close()
def add_canvas(self): self.figure = figure = Figure() self.axes = self.make_axes() self.canvas = FigureCanvas(self, wx.ID_ANY, figure) self.sizer.Add(self.canvas, 1, wx.LEFT|wx.TOP|wx.EXPAND)
def __init__(self, parent): wx.Panel.__init__(self, parent) self.parent = parent self.mainframe = wx.GetTopLevelParent(self) #split the notebook page in two and create panels panelsizer = wx.BoxSizer(wx.HORIZONTAL) # sizer splitter = wx.SplitterWindow(self, -1) self.left_panel = scrolled.ScrolledPanel(splitter, -1, style=wx.BORDER_SUNKEN) self.left_panel.SetVirtualSizeWH(200, 200) self.left_panel.SetScrollRate(10,10) self.right_panel = wx.Panel(splitter, -1, style=wx.BORDER_SUNKEN) splitter.SetMinimumPaneSize(115) # cannot shrink panel to less than this #initialize the figure and canvas self.histFigure = Figure(figsize=(4,4),facecolor='white') self.histCanvas = FigureCanvas(self.right_panel, -1, self.histFigure) self.toolbar = VMToolbar(self.histCanvas) #initialize the plot area self.axes = self.histFigure.add_axes([0.1, 0.1, 0.8, 0.8], clip_on='True', adjustable='box',autoscale_on='True',label='hist') self.axes.set_axis_off() #create the variables for color and etc, or else the dialog crashes if one doesn't choose the colors self.fcolor = '#A52A2A' self.lcolor = '#000000' self.fontSize = 'x-small' #define the controls txt = wx.StaticText(self.left_panel, -1, _('Histogram data')) txtp = wx.StaticText(self.left_panel, -1, _('(planes)')) self.rb1 = wx.RadioButton(self.left_panel, -1, _('Dip Dir.'), style=wx.RB_GROUP) self.rb3 = wx.RadioButton(self.left_panel, -1, _('Strike')) self.rb2 = wx.RadioButton(self.left_panel, -1, _('Dip')) txtl = wx.StaticText(self.left_panel, -1, _('(lines)')) self.rb4 = wx.RadioButton(self.left_panel, -1, _('Trend')) self.rb5 = wx.RadioButton(self.left_panel, -1, _('Plunge')) self.rb1.SetValue(True) grid1 = wx.GridSizer(8, 1) grid1.Add(txt,0, wx.LEFT, 5) grid1.Add(txtp,0, wx.LEFT|wx.TOP, 5) grid1.Add(self.rb1,0, wx.LEFT, 5) grid1.Add(self.rb3,0, wx.LEFT, 5) grid1.Add(self.rb2,0, wx.LEFT, 5) grid1.Add(txtl,0, wx.LEFT|wx.TOP, 5) grid1.Add(self.rb4,0, wx.LEFT, 5) grid1.Add(self.rb5,0, wx.LEFT, 5) txt1 = wx.StaticText(self.left_panel, -1, _('Interval (deg)')) self.spin = FS.FloatSpin(self.left_panel, -1, size=(60, -1), value=10, min_val=1, max_val=90, increment=1, digits=0) txt2 = wx.StaticText(self.left_panel, -1, _('Fill Colour')) self.fcbtn = csel.ColourSelect(self.left_panel, pos=(0, 0), size=(60, 20)) self.fcbtn.SetColour(self.fcolor) txt3 = wx.StaticText(self.left_panel, -1, _('Outline Colour')) self.lcbtn = csel.ColourSelect(self.left_panel, pos=(0, 0), size=(60, 20)) self.lcbtn.SetColour(self.lcolor) self.cb_norm = wx.CheckBox(self.left_panel, -1, _('Normed')) self.cb_norm.SetValue(False) grid2 = wx.FlexGridSizer(8, 1, 2, 2) grid2.Add(txt1,0, wx.LEFT|wx.TOP, 5) grid2.Add(self.spin,0, wx.LEFT, 5) # bins grid2.Add(txt2,0, wx.LEFT|wx.TOP, 5) grid2.Add(self.fcbtn,0, wx.LEFT, 5) # fill colour grid2.Add(txt3,0, wx.LEFT|wx.TOP, 5) grid2.Add(self.lcbtn,0, wx.LEFT, 5) # line colour grid2.Add((2,2),0, wx.TOP, 20) grid2.Add(self.cb_norm,0, wx.LEFT|wx.TOP, 5) # Normed # create draw/clear buttons self.drawButton = wx.Button(self.right_panel, -1, _('Plot'), size=(60, 30)) self.clearButton = wx.Button(self.right_panel, -1, _('Clear'), size=(60, 30)) hbox2 = wx.BoxSizer(wx.HORIZONTAL) hbox2.Add(self.drawButton, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL,3) hbox2.Add(self.clearButton, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL,3) hbox2.Add(self.toolbar, 1, wx.EXPAND|wx.ALL, 1) #bind buttons to events self.Bind(wx.EVT_BUTTON, self.onDrawHist, self.drawButton) self.Bind(wx.EVT_BUTTON, self.onClearHist, self.clearButton) self.fcbtn.Bind(csel.EVT_COLOURSELECT, self.chooseFColor) self.lcbtn.Bind(csel.EVT_COLOURSELECT, self.chooseLColor) #layout of widgets, left panel vbox = wx.BoxSizer(wx.VERTICAL) vbox.Add(grid1, 0, wx.ALL, 5) vbox.Add(grid2, 0, wx.ALL, 5) self.left_panel.SetSizer(vbox) #layout of canvas, right panel vbox2 = wx.BoxSizer(wx.VERTICAL) vbox2.Add(self.histCanvas, 1, wx.EXPAND)#|wx.SHAPED vbox2.Add(hbox2, 0, wx.EXPAND|wx.ALL, 1) self.right_panel.SetSizer(vbox2) splitter.SplitVertically(self.left_panel,self.right_panel,135) panelsizer.Add(splitter,1, wx.EXPAND|wx.ALL, 2) # the panels are inside this sizer with 2px border self.SetSizer(panelsizer) # panelsizer.Fit(self) # self.mainframe.sb.SetStatusText('Plots rose diagrams for selected file (linear data)') #retrieve data from pubsub pub.subscribe(self.__onReceivePlanarData, 'object.Plan_added_DDD') # from MainForm pub.subscribe(self.__onReceivePlanarData, 'object.Plan_added_RH') # from MainForm pub.subscribe(self.__onReceiveFaultData, 'object.Fault_added') # from MainForm pub.subscribe(self.__onReceiveLinearData, 'object.Lin_added') # from MainForm pub.subscribe(self.__onReceiveFontSize, 'object.FontSize') # from MainForm pub.subscribe(self.__onReceiveSelection, 'object.selected') # from TreePanel pub.subscribe(self.__onReceiveNameSel, 'object.selected_vals') # from TreePanel
def __init__(self, parent, size, permission=False): wx.Panel.__init__(self, parent, size=size) self.SetBackgroundColour(wxc.NamedColour("BLACK")) self.permission = permission self.figure = Figure(dpi=65) #figsize=(16,9)) self.figure.set_size_inches(1, 1, forward=True) #self.axes.xaxis.set_ticks_position('bottom') #self.axes.yaxis.set_ticks_position('left') self.axes = self.figure.add_subplot( 111, frameon=False) #plt.subplot(111, projection="lambert") d = (0, 0, 0.999, 0.999) self.axes.get_xaxis().set_visible(False) self.axes.get_yaxis().set_visible(False) self.w, self.h = self.figure.get_size_inches() * self.figure.dpi CanvasPanel2.w = size[0] self.axes.set_position( d ) # x-top-left-corner, y-top-left-corner, x-width, y-width (in pixels) self.canvas = FigureCanvas(self, -1, self.figure) if permission: self.axes.triplot(Triangulation.points[:, 0], Triangulation.points[:, 1], Triangulation.triang) self.axes.plot(Triangulation.points[:, 0], Triangulation.points[:, 1], 'r.') #Triangulation.points = [] #Triangulation.triang = [] self.figure.canvas.mpl_connect('motion_notify_event', self.StatusBarUpdate) self.canvas.draw() self.axes.axis( 'scaled' ) # si cet instruction n'est pas activé , il n'y aura pas d'affichage self.sizer = wx.BoxSizer(wx.VERTICAL) self.toolbar = CustomNavToolbar(self.canvas) self.toolbar.DeleteToolByPos(6) #self.toolbar.AddLabelTool(12,'',wx.Bitmap('save_as2.png'))#wx.ArtProvider.GetBitmap(wx.ART_FILE_OPEN, wx.ART_TOOLBAR, (16,16))) #self.toolbar.Realize() #self.toolbar.wx_ids['Selection'] = 500 #self.sizer.Add(self.toolbar, 0,wx.LEFT | wx.TOP | wx.GROW) #self.toolbar.update() #print self.toolbar.wx_ids['Selection'] #self.toolbar.ToggleTool(self.toolbar.wx_ids['Pan'], False) self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW) self.SetSizer(self.sizer) self.Fit()
def initForm(self, parent): wx.Frame.__init__(self, parent, id=wx.ID_ANY, title=u"Обработка данных детектора", pos=wx.DefaultPosition, size=wx.Size(500, 300), style=wx.DEFAULT_FRAME_STYLE | wx.MAXIMIZE | wx.TAB_TRAVERSAL) self.SetSizeHintsSz(wx.DefaultSize, wx.DefaultSize) gSizer1 = wx.GridSizer(0, 2, 0, 1) bSizer2 = wx.BoxSizer(wx.VERTICAL) self.m_panel1 = wx.Panel(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL) self.m_panel1.SetBackgroundColour( wx.SystemSettings.GetColour(wx.SYS_COLOUR_MENU)) gSizer4 = wx.GridSizer(2, 3, 0, 0) self.m_checkBox1 = wx.CheckBox(self.m_panel1, wx.ID_ANY, u"Темп счета нейтронов (без учета БЭ)", wx.DefaultPosition, wx.DefaultSize, 0) self.m_checkBox1.SetValue(True) gSizer4.Add(self.m_checkBox1, 0, wx.ALL, 1) self.m_checkBox2 = wx.CheckBox(self.m_panel1, wx.ID_ANY, u"Давление", wx.DefaultPosition, wx.DefaultSize, 0) self.m_checkBox2.SetValue(True) gSizer4.Add(self.m_checkBox2, 0, wx.ALL, 1) self.m_checkBox3 = wx.CheckBox(self.m_panel1, wx.ID_ANY, u"Темп счета нейтронов(с учетом БЭ)", wx.DefaultPosition, wx.DefaultSize, 0) self.m_checkBox3.SetValue(True) gSizer4.Add(self.m_checkBox3, 0, wx.ALL, 1) self.m_staticText4 = wx.StaticText(self.m_panel1, wx.ID_ANY, u"min:\nmax:\navg:", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText4.Wrap(-1) gSizer4.Add(self.m_staticText4, 0, wx.ALL, 3) self.m_staticText5 = wx.StaticText(self.m_panel1, wx.ID_ANY, u"min:\nmax:\navg:", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText5.Wrap(-1) gSizer4.Add(self.m_staticText5, 0, wx.ALL, 3) self.m_staticText6 = wx.StaticText(self.m_panel1, wx.ID_ANY, u"min:\nmax:\navg:", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText6.Wrap(-1) gSizer4.Add(self.m_staticText6, 0, wx.ALL, 3) self.m_panel1.SetSizer(gSizer4) self.m_panel1.Layout() gSizer4.Fit(self.m_panel1) self.m_panel1.Layout() bSizer2.Add(self.m_panel1, 0.88, wx.EXPAND, 5) gSizer1.Add(bSizer2, 1, wx.EXPAND, 5) bSizer3 = wx.BoxSizer(wx.VERTICAL) bSizer31 = wx.BoxSizer(wx.VERTICAL) self.m_panel2 = wx.Panel(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TAB_TRAVERSAL) self.m_panel2.SetBackgroundColour( wx.SystemSettings.GetColour(wx.SYS_COLOUR_MENU)) self.m_staticText7 = wx.StaticText(self.m_panel2, wx.ID_ANY, u"P0 = ", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText7.Wrap(-1) bSizer31.Add(self.m_staticText7, 0, wx.ALL, 5) self.m_staticText8 = wx.StaticText(self.m_panel2, wx.ID_ANY, u"I0 = ", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText8.Wrap(-1) bSizer31.Add(self.m_staticText8, 0, wx.ALL, 5) self.m_staticText9 = wx.StaticText(self.m_panel2, wx.ID_ANY, u"B = ", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText9.Wrap(-1) bSizer31.Add(self.m_staticText9, 0, wx.ALL, 5) self.m_staticText10 = wx.StaticText(self.m_panel2, wx.ID_ANY, u"β = ", wx.DefaultPosition, wx.DefaultSize, 0) self.m_staticText10.Wrap(-1) bSizer31.Add(self.m_staticText10, 0, wx.ALL, 5) self.m_panel2.SetSizer(bSizer31) self.m_panel2.Layout() bSizer31.Fit(self.m_panel2) bSizer3.Add(self.m_panel2, 0.9, wx.EXPAND, 5) gSizer1.Add(bSizer3, 1, wx.EXPAND, 5) self.SetSizer(gSizer1) self.Layout() self.m_menubar1 = wx.MenuBar(0) self.m_fileMenu = wx.Menu() self.m_mbopenFile = wx.MenuItem(self.m_fileMenu, wx.ID_ANY, u"Открыть", wx.EmptyString, wx.ITEM_NORMAL) self.m_fileMenu.AppendItem(self.m_mbopenFile) self.m_fileMenu.AppendSeparator() self.m_mbexit = wx.MenuItem(self.m_fileMenu, wx.ID_ANY, u"Выход", wx.EmptyString, wx.ITEM_NORMAL) self.m_fileMenu.AppendItem(self.m_mbexit) self.m_menubar1.Append(self.m_fileMenu, u"Файл") #self.m_menu3 = wx.Menu() #self.m_mbGraph1 = wx.MenuItem( self.m_menu3, wx.ID_ANY, u"Данные 1", wx.EmptyString, wx.ITEM_CHECK ) #self.m_menu3.AppendItem( self.m_mbGraph1 ) #self.m_mbGraph1.Check( True ) #self.m_mbGraph2 = wx.MenuItem( self.m_menu3, wx.ID_ANY, u"Данные 2", wx.EmptyString, wx.ITEM_CHECK ) #self.m_menu3.AppendItem( self.m_mbGraph2 ) #self.m_mbGraph2.Check( True ) #self.m_menubar1.Append( self.m_menu3, u"Скрыть" ) self.SetMenuBar(self.m_menubar1) #заготовки для графикa 1 self.figure1 = Figure() self.canvas1 = FigureCanvas(self, wx.ID_ANY, self.figure1) bSizer2.Add(self.canvas1, 3, wx.LEFT | wx.TOP | wx.EXPAND) self.toolbar1 = NavigationToolbar2Wx(self.canvas1) self.toolbar1.Realize() bSizer2.Add(self.toolbar1, 0, wx.LEFT | wx.EXPAND) #self.Fit() ##### #2 self.figure2 = Figure() self.canvas2 = FigureCanvas(self, wx.ID_ANY, self.figure2) bSizer3.Add(self.canvas2, 3, wx.LEFT | wx.TOP | wx.EXPAND) self.toolbar2 = NavigationToolbar2Wx(self.canvas2) self.toolbar2.Realize() bSizer3.Add(self.toolbar2, 0, wx.LEFT | wx.EXPAND) #self.Fit() ## self.SetAutoLayout(True) self.Centre(wx.BOTH) self.SetIcon(wx.Icon('icon.ico', wx.BITMAP_TYPE_ICO)) self.Refresh()
def __init__(self, parent, sf, shapes2, size, use_grid, permission=False, sites_bouger=[]): wx.Panel.__init__(self, parent, size=size) self.SetBackgroundColour(wxc.NamedColour("BLACK")) self.permission = permission self.figure = Figure(dpi=65) #figsize=(16,9)) self.figure.set_size_inches(1, 1, forward=True) #self.axes.xaxis.set_ticks_position('bottom') #self.axes.yaxis.set_ticks_position('left') self.axes = self.figure.add_subplot( 111, frameon=False) #plt.subplot(111, projection="lambert") user_grid = False if use_grid: d = (0, 0.01, 0.99, 0.99) self.axes.grid(use_grid) else: #self.axes = self.figure.add_subplot(111, frameon=False) d = (0, 0, 0.999, 0.999) self.axes.get_xaxis().set_visible(False) self.axes.get_yaxis().set_visible(False) self.w, self.h = self.figure.get_size_inches() * self.figure.dpi CanvasPanel3.w = size[0] self.axes.set_position( d ) # x-top-left-corner, y-top-left-corner, x-width, y-width (in pixels) self.canvas = FigureCanvas(self, -1, self.figure) if permission: self.axes.clear() self.canvas.Update() recs = sf.records() shapes = sf.shapes Nshp = len(shapes) """ for nshp in xrange(Nshp): ptchs = [] pts = array(shapes[nshp].points) if shapes[nshp].shapeType == 5: prt = shapes[nshp].parts par = list(prt) + [pts.shape[0]] for pij in xrange(len(prt)): ptchs.append(Polygon(pts[par[pij]:par[pij+1]])) self.axes.add_collection(PatchCollection(ptchs,facecolor='none',edgecolor='b', linewidths=2)) """ """ data = [(50, 50), (70, 70)] pp = [] for x, y in data : c = Circle((x,y), 0.5) pp.append(c) p = PatchCollection(pp, cmap=mpl.cm.jet, alpha=0.4) self.axes.add_collection(PatchCollection(p,facecolor='none',edgecolor='r', linewidths=2)) """ #self.axes.scatter(50, 50, s=10, c='g', marker='^', label='Two Fires') #print "Len shapes :", len(shapes) """ for obj in range(0, len(shapes)): for pt in range(0, len(shapes[obj].points)): if shapes[obj].points[pt] != shapes2[obj].points[pt]: print "------------------------------------" print "Not equal !" print "Original :",shapes[obj].points[pt], obj, pt print "Modifie :",shapes2[obj].points[pt], obj, pt """ #t = [ [147.83058185027457, -42.27884684129017] ,[146.66141197230283, -41.096120875508596] ] self.axes.triplot(Triangulation.points[:, 0], Triangulation.points[:, 1], Triangulation.triang) self.axes.plot(Triangulation.points[:, 0], Triangulation.points[:, 1], 'r.') shapes = shapes2 Nshp = len(shapes) import random color = random.choice(["g", "r", "y"]) for nshp in xrange(Nshp): ptchs = [] pts = array(shapes[nshp].points) if shapes[nshp].shapeType == 5: prt = shapes[nshp].parts par = list(prt) + [pts.shape[0]] for pij in xrange(len(prt)): ptchs.append(Polygon(pts[par[pij]:par[pij + 1]])) self.axes.add_collection( PatchCollection(ptchs, facecolor='none', edgecolor="black", linewidths=1.5)) """ pp = [ [146.661411968, -41.09612087949996] , [146.66141197230283, -41.096120875508596] #(142.89579288266205, -43.922664989702909), #(142.89579288266205, -43.922664989702909) ] """ #ptchs.append(Circle(pp[0], 0.001)) #self.axes.add_collection(PatchCollection(ptchs,facecolor='r',edgecolor="r", linewidths= 5)) #ptchs.append(Circle(pp[1], 0.001)) #self.axes.add_collection(PatchCollection(ptchs,facecolor='g',edgecolor="g", linewidths= 0.1, alpha=0.9)) original = { 'family': 'Courier New', 'color': 'green', 'weight': 'bold', 'size': 12, } modified = { 'family': 'Courier New', 'color': 'red', 'weight': 'bold', 'size': 12, } usb = self.GetTopLevelParent( ).rightpanel.get_original_per_sites_bouger() for pp in sites_bouger: self.axes.plot(pp[0][0][0], pp[0][0][1], 'r+') # modifie self.axes.plot(pp[1][0][0], pp[1][0][1], 'g+') # original #self.axes.text(pp[0][0][0], pp[0][0][1], "Modifie" , fontdict = modified, ha='left') #self.axes.text(pp[1][0][0], pp[1][0][1], "Original" , fontdict = original, ha='left') for tt in usb: if tt == complex(pp[0][0][0], pp[0][0][1]): v = usb[tt] self.axes.text(pp[0][0][0], pp[0][0][1], u"Modifié ( " + str(v[2]) + " )", fontdict=modified, ha='left') self.axes.text(pp[1][0][0], pp[1][0][1], "Original ( " + str(v[3]) + " )", fontdict=original, ha='left') self.figure.canvas.mpl_connect('motion_notify_event', self.StatusBarUpdate) self.canvas.draw() CanvasPanel.draw_map = True self.axes.axis( 'scaled' ) # si cet instruction n'est pas activé , il n'y aura pas d'affichage self.sizer = wx.BoxSizer(wx.VERTICAL) self.toolbar = CustomNavToolbar(self.canvas) self.toolbar.DeleteToolByPos(6) self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW) self.SetSizer(self.sizer) self.Fit()
def __init__(self, parent, id, title, dm): wx.Frame.__init__(self, parent, -1, title) if platform != "darwin": icon = wx.Icon("LogoIcon.ico", wx.BITMAP_TYPE_ICO) self.SetIcon(icon) self.dm = dm self.manualEditorPresent = False self.Bind(wx.EVT_CLOSE, self.OnEnd) self.WindowParent = parent self.panel = wx.Panel(self) # Create the mpl Figure and FigCanvas objects. # 5x4 inches, 100 dots-per-inch # if ColoredBGPlots: self.fig = matplotlib.figure.Figure( (5.0, 4.0), facecolor=EpisodesEditionBGColor) else: self.fig = matplotlib.figure.Figure((5.0, 4.0)) self.canvas = FigureCanvas(self.panel, -1, self.fig) self.canvas.mpl_connect('button_press_event', self.OnClick) self.axes = self.fig.add_subplot(111) self.fig.subplots_adjust(left=0.07, bottom=0.07, right=0.98, top=0.94, wspace=0.20, hspace=0.15) self.xvector, self.yvector = self.dm.GetHRDataPlot() self.ymin = min(self.yvector) self.ymax = max(self.yvector) self.xmin = self.xvector[0] self.xmax = self.xvector[-1] self.hboxEditEpisodes = wx.BoxSizer(wx.HORIZONTAL) self.hboxEditEpisodes.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW) # ----------------- Begin of sizer for buttons in edit episodes self.vboxEditEpRightColumn = wx.BoxSizer(wx.VERTICAL) self.EpTypes, self.EpVisibleTypes = self.dm.GetVisibleEpisodes() self.InsertTagsSelector() # Begin of AddEpisode staticbox sbAdd = wx.StaticBox(self.panel, label="Add") sbAddSizer = wx.StaticBoxSizer(sbAdd, wx.VERTICAL) if len(self.EpTypes) > 0: InitValue = self.EpTypes[0] else: InitValue = 'NEW_TAG' self.cbCombo = wx.ComboBox(self.panel, choices=self.EpTypes, value=InitValue, style=wx.CB_DROPDOWN) sbAddSizer.Add(self.cbCombo, flag=wx.ALL | wx.EXPAND, border=borderSmall) self.cbCombo.Disable() self.addButton = wx.Button(self.panel, -1, "Add episode", size=buttonSizeEditEpisodes) self.Bind(wx.EVT_BUTTON, self.OnAdd, self.addButton) sbAddSizer.Add(self.addButton, 0, border=borderSmall, flag=wx.ALL | wx.ALIGN_RIGHT) self.addButton.Disable() self.clearButton = wx.Button(self.panel, -1, "Clear", size=buttonSizeEditEpisodes) self.Bind(wx.EVT_BUTTON, self.OnClear, self.clearButton) sbAddSizer.Add(self.clearButton, 0, border=borderSmall, flag=wx.RIGHT | wx.ALIGN_RIGHT) self.clearButton.Disable() self.vboxEditEpRightColumn.Add(sbAddSizer, flag=wx.ALL, border=borderSmall) # End of AddEpisode staticbox self.vboxEditEpRightColumn.AddStretchSpacer(prop=1) self.renButton = wx.Button(self.panel, -1, "Rename", size=buttonSizeEditEpisodes) self.Bind(wx.EVT_BUTTON, self.OnRen, self.renButton) self.vboxEditEpRightColumn.Add(self.renButton, 0, border=borderSmall, flag=wx.ALL | wx.ALIGN_RIGHT) if not self.dm.HasEpisodes(): self.renButton.Disable() self.manualButton = wx.Button(self.panel, -1, "Manual...", size=buttonSizeEditEpisodes) self.Bind(wx.EVT_BUTTON, self.OnManual, id=self.manualButton.GetId()) self.manualButton.SetToolTip( wx.ToolTip("Click to edit episodes manually")) self.vboxEditEpRightColumn.Add(self.manualButton, 0, border=borderSmall, flag=wx.ALL | wx.ALIGN_RIGHT) self.endButton = wx.Button(self.panel, -1, "End", size=buttonSizeEditEpisodes) self.Bind(wx.EVT_BUTTON, self.OnEnd, id=self.endButton.GetId()) self.endButton.SetToolTip( wx.ToolTip("Click to finish editing episodes")) self.vboxEditEpRightColumn.Add(self.endButton, 0, border=borderSmall, flag=wx.ALL | wx.ALIGN_RIGHT) self.hboxEditEpisodes.Add(self.vboxEditEpRightColumn, 0, flag=wx.EXPAND, border=borderBig) # ----------------- End of sizer for buttons in edit episodes self.panel.SetSizer(self.hboxEditEpisodes) #self.hboxEditEpisodes.Fit(self) self.DrawFigure() self.sb = self.CreateStatusBar() self.sb.SetStatusText('') defSize, minSize = Utils.RecalculateWindowSizes( mainWindowSize, mainWindowMinSize) self.SetSize(defSize) self.SetMinSize(minSize) self.Show(True) self.Layout()
def __init__(self, parent, sf, size, use_grid): wx.Panel.__init__(self, parent, size=size) self.SetBackgroundColour(wxc.NamedColour("BLACK")) self.selection_coords = [] self.draw_selection = False self.figure = Figure(figsize=(10, 12), dpi=65) #figsize=(16,9)) self.figure.set_size_inches(1, 1, forward=True) #self.axes.xaxis.set_ticks_position('bottom') #self.axes.yaxis.set_ticks_position('left') self.axes = self.figure.add_subplot(111, frameon=False) #self.axes.clear() #self.Refresh() user_grid = False d = (0, 0, 0.999, 0.999) self.axes.get_xaxis().set_visible(False) self.axes.get_yaxis().set_visible(False) self.w, self.h = self.figure.get_size_inches() * self.figure.dpi CanvasPanel.w = size[0] self.axes.set_position( d ) # x-top-left-corner, y-top-left-corner, x-width, y-width (in pixels) self.canvas = FigureCanvas(self, -1, self.figure) recs = sf.records() shapes = sf.shapes Nshp = len(shapes) for nshp in xrange(Nshp): ptchs = [] pts = array(shapes[nshp].points) if shapes[nshp].shapeType == 5: prt = shapes[nshp].parts par = list(prt) + [pts.shape[0]] for pij in xrange(len(prt)): ptchs.append(Polygon(pts[par[pij]:par[pij + 1]])) else: #print "type shape >> ",shapes[nshp].shapeType pass self.axes.add_collection( PatchCollection(ptchs, facecolor='none', edgecolor='black', linewidths=1.5)) #self.axes.plot(146.661411968, -41.09612087949996, 'g+') #self.axes.plot(146.66141197230283, -41.096120875508596, 'r+') """ circle = Circle((100, 100), 3) ptchs.append(circle) p = PatchCollection(ptchs) self.axes.add_collection(p) """ self.figure.canvas.mpl_connect('key_press_event', toggle_selector) self.figure.canvas.mpl_connect('motion_notify_event', self.StatusBarUpdate) #self.canvas.Refresh() CanvasPanel.draw_map = True self.axes.axis( 'scaled' ) # si cet instruction n'est pas activé , il n'y aura pas d'affichage self.canvas.draw() #print self.figure.canvas.manager toggle_selector.RS = RectangleSelector( self.axes, self.line_select_callback, drawtype='box', useblit=False, button=[1], # don't use middle button , button=[1, 3] minspanx=5, minspany=5, spancoords='pixels', interactive=True) toggle_selector.RS.set_active(False) self.sizer = wx.BoxSizer(wx.VERTICAL) self.toolbar = CustomNavToolbar(self.canvas) self.toolbar.DeleteToolByPos(6) self.sizer.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW) self.SetSizer(self.sizer) self.Fit()
def __init__(self, parent, spectrum, settings): self.spectrum = spectrum self.settings = settings self.sweeps = None self.isExporting = False wx.Dialog.__init__(self, parent=parent, title='Export Plot Sequence') self.queue = Queue.Queue() self.timer = wx.Timer(self) self.Bind(wx.EVT_TIMER, self.__on_timer, self.timer) self.timer.Start(self.POLL) self.figure = matplotlib.figure.Figure(facecolor='white') self.canvas = FigureCanvas(self, -1, self.figure) self.plot = Plotter(self.queue, self.figure, settings) textPlot = wx.StaticText(self, label='Plot') self.checkAxes = wx.CheckBox(self, label='Axes') self.checkAxes.SetValue(True) self.Bind(wx.EVT_CHECKBOX, self.__on_axes, self.checkAxes) self.checkGrid = wx.CheckBox(self, label='Grid') self.checkGrid.SetValue(True) self.Bind(wx.EVT_CHECKBOX, self.__on_grid, self.checkGrid) self.checkBar = wx.CheckBox(self, label='Bar') self.checkBar.SetValue(True) self.Bind(wx.EVT_CHECKBOX, self.__on_bar, self.checkBar) sizerCheck = wx.BoxSizer(wx.HORIZONTAL) sizerCheck.Add(self.checkAxes, flag=wx.ALL, border=5) sizerCheck.Add(self.checkGrid, flag=wx.ALL, border=5) sizerCheck.Add(self.checkBar, flag=wx.ALL, border=5) textRange = wx.StaticText(self, label='Range') self.sweepTimeStamps = sorted([timeStamp for timeStamp in spectrum.keys()]) sweepChoices = [format_time(timeStamp, True) for timeStamp in self.sweepTimeStamps] textStart = wx.StaticText(self, label="Start") self.choiceStart = wx.Choice(self, choices=sweepChoices) self.choiceStart.SetSelection(0) self.Bind(wx.EVT_CHOICE, self.__on_choice, self.choiceStart) textEnd = wx.StaticText(self, label="End") self.choiceEnd = wx.Choice(self, choices=sweepChoices) self.choiceEnd.SetSelection(len(self.sweepTimeStamps) - 1) self.Bind(wx.EVT_CHOICE, self.__on_choice, self.choiceEnd) textSweeps = wx.StaticText(self, label='Sweeps') self.textSweeps = wx.StaticText(self, label="") textOutput = wx.StaticText(self, label='Output') self.textSize = wx.StaticText(self) buttonSize = wx.Button(self, label='Change...') buttonSize.SetToolTipString('Change exported image size') self.Bind(wx.EVT_BUTTON, self.__on_imagesize, buttonSize) self.__show_image_size() buttonBrowse = wx.Button(self, label='Browse...') self.Bind(wx.EVT_BUTTON, self.__on_browse, buttonBrowse) self.editDir = wx.TextCtrl(self) self.editDir.SetValue(settings.dirExport) 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) sizerGrid = wx.GridBagSizer(5, 5) sizerGrid.Add(self.canvas, pos=(0, 0), span=(10, 6), flag=wx.EXPAND | wx.ALL, border=5) sizerGrid.Add(textPlot, pos=(0, 7), flag=wx.TOP | wx.BOTTOM, border=5) sizerGrid.Add(sizerCheck, pos=(1, 7), span=(1, 2), flag=wx.ALL, border=5) sizerGrid.Add(textRange, pos=(2, 7), flag=wx.TOP | wx.BOTTOM, border=5) sizerGrid.Add(textStart, pos=(3, 7), flag=wx.ALIGN_CENTRE_VERTICAL | wx.ALL, border=5) sizerGrid.Add(self.choiceStart, pos=(3, 8), flag=wx.ALL, border=5) sizerGrid.Add(textEnd, pos=(4, 7), flag=wx.ALIGN_CENTRE_VERTICAL | wx.ALL, border=5) sizerGrid.Add(self.choiceEnd, pos=(4, 8), flag=wx.ALL, border=5) sizerGrid.Add(textSweeps, pos=(5, 7), flag=wx.ALIGN_CENTRE_VERTICAL | wx.ALL, border=5) sizerGrid.Add(self.textSweeps, pos=(5, 8), flag=wx.ALIGN_CENTRE_VERTICAL | wx.ALL, border=5) sizerGrid.Add(textOutput, pos=(6, 7), flag=wx.TOP | wx.BOTTOM, border=5) sizerGrid.Add(self.textSize, pos=(7, 7), flag=wx.ALIGN_CENTRE_VERTICAL | wx.ALL, border=5) sizerGrid.Add(buttonSize, pos=(7, 8), flag=wx.ALL, border=5) sizerGrid.Add(self.editDir, pos=(8, 7), span=(1, 2), flag=wx.ALL | wx.EXPAND, border=5) sizerGrid.Add(buttonBrowse, pos=(9, 7), flag=wx.ALL, border=5) sizerGrid.Add(sizerButtons, pos=(10, 7), span=(1, 2), flag=wx.ALIGN_RIGHT | wx.ALL, border=5) self.SetSizerAndFit(sizerGrid) self.__draw_plot()
def __init__(self, parent): wx.Panel.__init__(self, parent=parent) splitter = wx.SplitterWindow(self) # XXX: we may need to place the canvas in its own Panel self.figure = Figure() self.canvas = FigureCanvas(splitter, wx.ID_ANY, self.figure) self.vehiclePointer = None self.imageTopic = None rightPanel = wx.Panel(splitter) cPanel = wx.BoxSizer(wx.VERTICAL) rightPanel.SetSizer(cPanel) self.orbResultChooser = FilePrompt(rightPanel, 'ORB-SLAM Result Bag', self.onClickOrbChoose) cPanel.Add(self.orbResultChooser, flag=wx.EXPAND) self.groundTruthChooser = FilePrompt(rightPanel, 'GroundTruth', self.onClickGtChoose) cPanel.Add(self.groundTruthChooser, flag=wx.EXPAND) timePosBox = wx.BoxSizer(wx.HORIZONTAL) timePosBox.Add(wx.StaticText(rightPanel, label='Time Position'), flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, proportion=0) self.timeDisplay = wx.TextCtrl(rightPanel, style=wx.TE_READONLY) timePosBox.Add(self.timeDisplay, flag=wx.EXPAND | wx.ALIGN_CENTER, proportion=1) cPanel.Add(timePosBox, flag=wx.EXPAND) orbStatusBox = wx.BoxSizer(wx.HORIZONTAL) orbStatusBox.Add(wx.StaticText(rightPanel, label="ORB Status"), flag=wx.ALIGN_LEFT | wx.ALIGN_CENTER_VERTICAL, proportion=0) self.orbStatus = wx.StaticText(rightPanel, label="Init") orbStatusBox.Add(self.orbStatus, flag=wx.ALIGN_CENTER | wx.EXPAND, proportion=1) cPanel.Add(orbStatusBox, flag=wx.EXPAND) bagGroup = wx.StaticBoxSizer( wx.StaticBox(rightPanel, label='Image Source Bag'), wx.VERTICAL) askBag = FilePrompt(rightPanel, "Image Bag File", self.onBagChange) bagGroup.Add(askBag, flag=wx.EXPAND) self.imageTopicChooser = wx.ComboBox(rightPanel) bagGroup.Add(self.imageTopicChooser, flag=wx.EXPAND) self.imageTopicChooser.Bind(wx.EVT_COMBOBOX, self.onImageTopicChange) self.bagImageView = BagImagePreview(rightPanel) bagGroup.Add(self.bagImageView, flag=wx.EXPAND) cPanel.Add(bagGroup, flag=wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL) splitter.SplitVertically(self.canvas, rightPanel) splitter.SetMinimumPaneSize(30) mainLayout = wx.BoxSizer(wx.VERTICAL) self.SetSizer(mainLayout) mainLayout.Add(splitter, proportion=1, flag=wx.EXPAND | wx.ALIGN_TOP) self.timeChooser = wx.Slider(self) self.timeChooser.Bind(wx.EVT_SCROLL, self.onChangeTimePosition) mainLayout.Add(self.timeChooser, flag=wx.EXPAND | wx.ALIGN_BOTTOM) self.Fit()