Changeset 6267876 in sasview for src/sas/sasgui/guiframe/local_perspectives/plotting
- Timestamp:
- Apr 10, 2017 12:42:23 PM (8 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 3e5648b
- Parents:
- 37d461c (diff), d26f025 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - git-author:
- Jeff Krzywon <krzywon@…> (04/10/17 12:42:23)
- git-committer:
- krzywon <krzywon@…> (04/10/17 12:42:23)
- Location:
- src/sas/sasgui/guiframe/local_perspectives/plotting
- Files:
-
- 1 added
- 1 deleted
- 15 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/guiframe/local_perspectives/plotting/AnnulusSlicer.py
rd85c194 r7432acb 122 122 data = self.base.data2D 123 123 # If we have no data, just return 124 if data ==None:124 if data is None: 125 125 return 126 126 … … 132 132 # if the user does not specify the numbers of points to plot 133 133 # the default number will be nbins= 36 134 if nbins ==None:134 if nbins is None: 135 135 self.nbins = 36 136 136 else: … … 498 498 # Update locations 499 499 self.outer_circle.update() 500 # if self.is_inside !=None:500 # if self.is_inside is not None: 501 501 out = self._post_data() 502 502 return out … … 521 521 522 522 # If we have no data, just return 523 if data ==None:523 if data is None: 524 524 return 525 525 mask = data.mask -
src/sas/sasgui/guiframe/local_perspectives/plotting/Arc.py
rd85c194 r7432acb 71 71 x = [] 72 72 y = [] 73 if theta1 !=None:73 if theta1 is not None: 74 74 self.theta1 = theta1 75 if theta2 !=None:75 if theta2 is not None: 76 76 self.theta2 = theta2 77 77 while self.theta2 < self.theta1: … … 81 81 npts = int((self.theta2 - self.theta1) / (math.pi / 120)) 82 82 83 if r ==None:83 if r is None: 84 84 self.radius = math.sqrt(math.pow(self._mouse_x, 2) + \ 85 85 math.pow(self._mouse_y, 2)) -
src/sas/sasgui/guiframe/local_perspectives/plotting/Edge.py
rd85c194 r7432acb 63 63 Draw the new roughness on the graph. 64 64 """ 65 if r1 !=None:65 if r1 is not None: 66 66 self.r1 = r1 67 if r2 !=None:67 if r2 is not None: 68 68 self.r2 = r2 69 if theta !=None:69 if theta is not None: 70 70 self.theta = theta 71 71 x1 = self.r1 * math.cos(self.theta) -
src/sas/sasgui/guiframe/local_perspectives/plotting/Plotter1D.py
r9c0f3c17 r7432acb 183 183 # So manually recode the size (=x_size) and compare here. 184 184 # Massy code to work around:< 185 if self.parent._mgr !=None:185 if self.parent._mgr is not None: 186 186 max_panel = self.parent._mgr.GetPane(self) 187 187 if max_panel.IsMaximized(): 188 188 self.parent._mgr.RestorePane(max_panel) 189 189 max_panel.Maximize() 190 if self.x_size !=None:190 if self.x_size is not None: 191 191 if self.x_size == self.GetSize(): 192 192 self.resizing = False … … 212 212 On Qmin Qmax vertical line event 213 213 """ 214 if event ==None:214 if event is None: 215 215 return 216 216 event.Skip() 217 217 active_ctrl = event.active 218 if active_ctrl ==None:218 if active_ctrl is None: 219 219 return 220 220 if hasattr(event, 'is_corfunc'): … … 231 231 colors.append('purple') 232 232 values.append(min(x_data.max(), float(ctrl[2].GetValue()))) 233 if self.ly ==None:233 if self.ly is None: 234 234 self.ly = [] 235 235 for c, v in zip(colors, values): … … 241 241 xval = float(active_ctrl.GetValue()) 242 242 position = self.get_data_xy_vals(xval) 243 if position !=None and not self.is_corfunc:243 if position is not None and not self.is_corfunc: 244 244 wx.PostEvent(self.parent, StatusEvent(status=position)) 245 245 except: … … 336 336 if hasattr(event, "action"): 337 337 dclick = event.action == 'dclick' 338 if ax ==None or dclick:338 if ax is None or dclick: 339 339 # remove the vline 340 340 self._check_zoom_plot() … … 342 342 self.q_ctrl = None 343 343 return 344 if self.ly != None and event.xdata !=None:344 if self.ly is not None and event.xdata is not None: 345 345 # Selecting a new line if cursor lines are displayed already 346 346 dqmin = math.fabs(event.xdata - self.ly[0].get_xdata()) … … 361 361 Move the cursor line to write Q range 362 362 """ 363 if self.q_ctrl ==None:363 if self.q_ctrl is None: 364 364 return 365 365 # release a q range vline 366 if self.ly !=None and not self.leftdown:366 if self.ly is not None and not self.leftdown: 367 367 for ly in self.ly: 368 368 ly.set_alpha(0.7) … … 370 370 return 371 371 ax = event.inaxes 372 if ax ==None or not hasattr(event, 'action'):372 if ax is None or not hasattr(event, 'action'): 373 373 return 374 end_drag = event.action != 'drag' and event.xdata !=None374 end_drag = event.action != 'drag' and event.xdata is not None 375 375 nop = len(self.plots) 376 376 pos_x, _ = float(event.xdata), float(event.ydata) … … 514 514 ax = event.inaxes 515 515 PlotPanel.onLeftDown(self, event) 516 if ax !=None:516 if ax is not None: 517 517 try: 518 518 pos_x = float(event.xdata) # / size_x … … 618 618 # add menu of other plugins 619 619 item_list = self.parent.get_current_context_menu(self) 620 if ( not item_list == None) and (not len(item_list) == 0):620 if (item_list is not None) and (len(item_list)): 621 621 for item, wx_id in zip(item_list, [ids.next() for i in range(len(item_list))]): 622 623 622 try: 624 623 plot_menu.Append(wx_id, item[0], name) … … 684 683 685 684 686 if self.position !=None:685 if self.position is not None: 687 686 wx_id = ids.next() 688 687 self._slicerpop.Append(wx_id, '&Add Text') … … 761 760 default_name = default_name.split('.')[0] 762 761 default_name += "_out" 763 if self.parent !=None:762 if self.parent is not None: 764 763 self.parent.save_data1d(data, default_name) 765 764 … … 779 778 default_name = default_name.split('.')[0] 780 779 # default_name += "_out" 781 if self.parent !=None:780 if self.parent is not None: 782 781 self.parent.show_data1d(data, default_name) 783 782 … … 811 810 curr_label = self.appearance_selected_plot.label 812 811 813 if curr_color ==None:812 if curr_color is None: 814 813 curr_color = self._color_labels['Blue'] 815 814 curr_symbol = 13 -
src/sas/sasgui/guiframe/local_perspectives/plotting/Plotter2D.py
r2df1bd1 r7432acb 144 144 """ 145 145 # Not implemented 146 if event ==None:146 if event is None: 147 147 return 148 148 event.Skip() … … 156 156 PlotPanel.onLeftDown(self, event) 157 157 ax = event.inaxes 158 if ax !=None:158 if ax is not None: 159 159 # data coordinate position 160 160 pos_x = "%8.3g" % event.xdata … … 227 227 if self._is_changed_legend_label: 228 228 data.label = self.title_label 229 if data.label ==None:229 if data.label is None: 230 230 data.label = data.name 231 231 if not self.title_font: … … 264 264 # control axis labels from the panel itself 265 265 yname, yunits = data.get_yaxis() 266 if self.yaxis_label !=None:266 if self.yaxis_label is not None: 267 267 yname = self.yaxis_label 268 268 yunits = self.yaxis_unit … … 271 271 self.yaxis_unit = yunits 272 272 xname, xunits = data.get_xaxis() 273 if self.xaxis_label !=None:273 if self.xaxis_label is not None: 274 274 xname = self.xaxis_label 275 275 xunits = self.xaxis_unit … … 320 320 if len(self.data2D.detector) <= 1: 321 321 item_list = self.parent.get_current_context_menu(self) 322 if ( not item_list == None) and (not len(item_list) == 0) and\323 self.data2D.name.split(" ")[0] != 'Residuals' :322 if ((item_list is not None) and len(item_list) and 323 self.data2D.name.split(" ")[0] != 'Residuals'): 324 324 for item, wx_id in zip(item_list, [ids.next() for i in range(len(item_list))]): 325 325 try: … … 355 355 slicerpop.Append(wx_id, '&Box Averaging in Qy') 356 356 wx.EVT_MENU(self, wx_id, self.onBoxavgY) 357 if self.slicer !=None:357 if self.slicer is not None: 358 358 wx_id = ids.next() 359 359 slicerpop.Append(wx_id, '&Clear Slicer') … … 361 361 if self.slicer.__class__.__name__ != "BoxSum": 362 362 wx_id = ids.next() 363 name = '&Edit Slicer Parameters and Batch Slicing' 364 slicerpop.Append(wx_id, name) 363 slicerpop.Append(wx_id, '&Edit Slicer Parameters') 365 364 wx.EVT_MENU(self, wx_id, self._onEditSlicer) 366 365 slicerpop.AppendSeparator() … … 436 435 msg = "Add Text: Error. Check your property values..." 437 436 logger.error(msg) 438 if self.parent !=None:437 if self.parent is not None: 439 438 wx.PostEvent(self.parent, StatusEvent(status=msg)) 440 439 dial.Destroy() … … 533 532 534 533 """ 535 # Clear current slicer536 if not self.slicer ==None:534 ## Clear current slicer 535 if self.slicer is not None: 537 536 self.slicer.clear() 538 # Create a new slicer537 ## Create a new slicer 539 538 self.slicer_z += 1 540 539 self.slicer = slicer(self, self.subplot, zorder=self.slicer_z) 541 540 self.subplot.set_ylim(self.data2D.ymin, self.data2D.ymax) 542 541 self.subplot.set_xlim(self.data2D.xmin, self.data2D.xmax) 543 # Draw slicer542 ## Draw slicer 544 543 self.update() 545 544 self.slicer.update() … … 573 572 npt = math.floor(npt) 574 573 from sas.sascalc.dataloader.manipulations import CircularAverage 575 # compute the maximum radius of data2D574 ## compute the maximum radius of data2D 576 575 self.qmax = max(math.fabs(self.data2D.xmax), 577 576 math.fabs(self.data2D.xmin)) … … 579 578 math.fabs(self.data2D.ymin)) 580 579 self.radius = math.sqrt(math.pow(self.qmax, 2) + math.pow(self.ymax, 2)) 581 # 580 ##Compute beam width 582 581 bin_width = (self.qmax + self.qmax) / npt 583 # Create data1D circular average of data2D582 ## Create data1D circular average of data2D 584 583 Circle = CircularAverage(r_min=0, r_max=self.radius, 585 584 bin_width=bin_width) … … 600 599 new_plot.name = "Circ avg " + self.data2D.name 601 600 new_plot.source = self.data2D.source 602 # 601 #new_plot.info = self.data2D.info 603 602 new_plot.interactive = True 604 603 new_plot.detector = self.data2D.detector 605 604 606 # If the data file does not tell us what the axes are, just assume...605 ## If the data file does not tell us what the axes are, just assume... 607 606 new_plot.xaxis("\\rm{Q}", "A^{-1}") 608 607 if hasattr(self.data2D, "scale") and \ … … 616 615 new_plot.id = "Circ avg " + self.data2D.name 617 616 new_plot.is_data = True 618 self.parent.update_theory(data_id=self.data2D.id, theory=new_plot) 617 self.parent.update_theory(data_id=self.data2D.id, \ 618 theory=new_plot) 619 619 wx.PostEvent(self.parent, 620 620 NewPlotEvent(plot=new_plot, title=new_plot.name)) … … 630 630 """ 631 631 if self.slicer is not None: 632 from parameters_panel_slicerimport SlicerParameterPanel632 from SlicerParameters import SlicerParameterPanel 633 633 dialog = SlicerParameterPanel(self, -1, "Slicer Parameters") 634 634 dialog.set_slicer(self.slicer.__class__.__name__, … … 668 668 params = self.slicer.get_params() 669 669 ## Create a new panel to display results of summation of Data2D 670 from parameters_panel_boxsumimport SlicerPanel670 from slicerpanel import SlicerPanel 671 671 win = MDIFrame(self.parent, None, 'None', (100, 200)) 672 672 new_panel = SlicerPanel(parent=win, id=-1, … … 758 758 if default_name.count('.') > 0: 759 759 default_name = default_name.split('.')[0] 760 #default_name += "_out" 760 761 if self.parent is not None: 761 762 self.parent.show_data2d(data, default_name) 762 763 763 764 def modifyGraphAppearance(self, e): 764 self.graphApp = graphAppearance(self, 'Modify graph appearance', 765 legend=False) 765 self.graphApp = graphAppearance(self, 'Modify graph appearance', legend=False) 766 766 self.graphApp.setDefaults(self.grid_on, self.legend_on, 767 767 self.xaxis_label, self.yaxis_label, -
src/sas/sasgui/guiframe/local_perspectives/plotting/SectorSlicer.py
rd85c194 r7432acb 144 144 data = self.base.data2D 145 145 # If we have no data, just return 146 if data ==None:146 if data is None: 147 147 return 148 148 ## Averaging … … 151 151 phimin = -self.left_line.phi + self.main_line.theta 152 152 phimax = self.left_line.phi + self.main_line.theta 153 if nbins ==None:153 if nbins is None: 154 154 nbins = 20 155 155 sect = SectorQ(r_min=0.0, r_max=radius, … … 362 362 self.left_moving = left 363 363 theta3 = 0 364 if phi !=None:364 if phi is not None: 365 365 self.phi = phi 366 if delta ==None:366 if delta is None: 367 367 delta = 0 368 368 if right: … … 374 374 self.theta = mline.theta + self.phi 375 375 376 if mline !=None:376 if mline is not None: 377 377 if delta != 0: 378 378 self.theta2 = mline + delta … … 538 538 """ 539 539 540 if theta !=None:540 if theta is not None: 541 541 self.theta = theta 542 542 x1 = self.radius * math.cos(self.theta) -
src/sas/sasgui/guiframe/local_perspectives/plotting/SimplePlot.py
r25b9707a r7432acb 87 87 pos = (pos_x, pos_y + 5) 88 88 self.PopupMenu(slicerpop, pos) 89 if self.scale !=None:89 if self.scale is not None: 90 90 self.parent.scale2d = self.scale 91 91 … … 106 106 self.leftdown = True 107 107 ax = event.inaxes 108 if ax !=None:108 if ax is not None: 109 109 self.xInit, self.yInit = event.xdata, event.ydata 110 110 try: … … 123 123 """ 124 124 self.resizing = False 125 if self.x_size !=None:125 if self.x_size is not None: 126 126 if self.x_size == self.GetSize(): 127 127 self.canvas.set_resizing(self.resizing) … … 161 161 self.plots[plot.name] = plot 162 162 # Axis scales 163 if plot.xtransform !=None:163 if plot.xtransform is not None: 164 164 self.xLabel = plot.xtransform 165 if plot.ytransform !=None:165 if plot.ytransform is not None: 166 166 self.yLabel = plot.ytransform 167 167 # Init graph -
src/sas/sasgui/guiframe/local_perspectives/plotting/boxMask.py
rd85c194 r7432acb 123 123 x2=self.vertical_lines.x2, 124 124 width=self.vertical_lines.half_width) 125 # if self.is_inside !=None:125 # if self.is_inside is not None: 126 126 out = self._post_data() 127 127 return out -
src/sas/sasgui/guiframe/local_perspectives/plotting/boxSlicer.py
r9a5097c r7432acb 139 139 140 140 """ 141 if self.direction ==None:141 if self.direction is None: 142 142 self.direction = direction 143 143 … … 147 147 y_max = math.fabs(self.horizontal_lines.y) 148 148 149 if nbins !=None:149 if nbins is not None: 150 150 self.nbins = nbins 151 if self.averager ==None:152 if new_slab ==None:151 if self.averager is None: 152 if new_slab is None: 153 153 msg = "post data:cannot average , averager is empty" 154 154 raise ValueError, msg … … 357 357 """ 358 358 # # Reset x, y- coordinates if send as parameters 359 if x !=None:359 if x is not None: 360 360 self.x = np.sign(self.x) * math.fabs(x) 361 if y !=None:361 if y is not None: 362 362 self.y = np.sign(self.y) * math.fabs(y) 363 363 # # Draw lines and markers … … 464 464 """ 465 465 # # reset x, y -coordinates if given as parameters 466 if x !=None:466 if x is not None: 467 467 self.x = np.sign(self.x) * math.fabs(x) 468 if y !=None:468 if y is not None: 469 469 self.y = np.sign(self.y) * math.fabs(y) 470 470 # # draw lines and markers -
src/sas/sasgui/guiframe/local_perspectives/plotting/boxSum.py
rd85c194 r7432acb 353 353 Draw the new roughness on the graph. 354 354 """ 355 if center_x !=None:355 if center_x is not None: 356 356 self.x = center_x 357 if center_y !=None:357 if center_y is not None: 358 358 self.y = center_y 359 359 self.center_marker.set(xdata=[self.x], ydata=[self.y]) … … 490 490 """ 491 491 # # save the new height, witdh of the rectangle if given as a param 492 if width !=None:492 if width is not None: 493 493 self.half_width = width 494 if height !=None:494 if height is not None: 495 495 self.half_height = height 496 496 # # If new center coordinates are given draw the rectangle 497 497 # #given these value 498 if center !=None:498 if center is not None: 499 499 self.center_x = center.x 500 500 self.center_y = center.y … … 511 511 return 512 512 # # if x1, y1, y2, y3 are given draw the rectangle with this value 513 if x1 !=None:513 if x1 is not None: 514 514 self.x1 = x1 515 if x2 !=None:515 if x2 is not None: 516 516 self.x2 = x2 517 if y1 !=None:517 if y1 is not None: 518 518 self.y1 = y1 519 if y2 !=None:519 if y2 is not None: 520 520 self.y2 = y2 521 521 # # Draw 2 vertical lines and a marker … … 657 657 """ 658 658 # # save the new height, witdh of the rectangle if given as a param 659 if width !=None:659 if width is not None: 660 660 self.half_width = width 661 if height !=None:661 if height is not None: 662 662 self.half_height = height 663 663 # # If new center coordinates are given draw the rectangle 664 664 # #given these value 665 if center !=None:665 if center is not None: 666 666 self.center_x = center.x 667 667 self.center_y = center.y … … 679 679 return 680 680 # # if x1, y1, y2, y3 are given draw the rectangle with this value 681 if x1 !=None:681 if x1 is not None: 682 682 self.x1 = x1 683 if x2 !=None:683 if x2 is not None: 684 684 self.x2 = x2 685 if y1 !=None:685 if y1 is not None: 686 686 self.y1 = y1 687 if y2 !=None:687 if y2 is not None: 688 688 self.y2 = y2 689 689 # # Draw 2 vertical lines and a marker -
src/sas/sasgui/guiframe/local_perspectives/plotting/detector_dialog.py
r8416a02 r7432acb 90 90 zmin = self.reset_zmin_ctl 91 91 zmax = self.reset_zmax_ctl 92 if zmin ==None:92 if zmin is None: 93 93 zmin = "" 94 if zmax ==None:94 if zmax is None: 95 95 zmax = "" 96 96 self.zmin_ctl.SetValue(str(zmin)) … … 155 155 self.qmax_ctl.SetLabel(str(format_number(qmax))) 156 156 self.beam_ctl.SetLabel(str(format_number(beam))) 157 if zmin !=None:157 if zmin is not None: 158 158 self.zmin_ctl.SetValue(str(format_number(zmin))) 159 if zmax !=None:159 if zmax is not None: 160 160 self.zmax_ctl.SetValue(str(format_number(zmax))) 161 161 -
src/sas/sasgui/guiframe/local_perspectives/plotting/masking.py
r9a5097c r45dffa69 100 100 wx.Dialog.__init__(self, parent, id=id, *args, **kwds) 101 101 102 if data !=None:102 if data is not None: 103 103 # Font size 104 104 kwds = [] … … 235 235 event.Skip() 236 236 # from boxMask import BoxMask 237 if event !=None:237 if event is not None: 238 238 self._on_clear_slicer(event) 239 239 self.slicer_z += 1 … … 249 249 Add new mask to old mask 250 250 """ 251 if not self.slicer ==None:251 if self.slicer is not None: 252 252 data = Data2D() 253 253 data = self.data … … 269 269 Erase new mask from old mask 270 270 """ 271 if not self.slicer ==None:271 if self.slicer is not None: 272 272 self.slicer_mask = self.slicer.update() 273 273 mask = self.data.mask … … 307 307 Clear the slicer on the plot 308 308 """ 309 if not self.slicer ==None:309 if self.slicer is not None: 310 310 self.slicer.clear() 311 311 self.subplot.figure.canvas.draw() … … 336 336 """ 337 337 # the case of liitle numbers of True points 338 if len(mask[mask]) < 10 and self.data !=None:338 if len(mask[mask]) < 10 and self.data is not None: 339 339 self.ShowMessage() 340 340 mask = copy.deepcopy(self.mask) … … 355 355 temp_data.data[mask == False] = temp_mask[mask == False] 356 356 self.plotpanel.clear() 357 if self.slicer !=None:357 if self.slicer is not None: 358 358 self.slicer.clear() 359 359 self.slicer = None … … 460 460 wx.Dialog.__init__(self, parent, id=id, *args, **kwds) 461 461 462 if data !=None:462 if data is not None: 463 463 # Font size 464 464 kwds = [] … … 710 710 Status msg 711 711 """ 712 if self.parent.parent.parent !=None:712 if self.parent.parent.parent is not None: 713 713 wx.PostEvent(self.parent.parent.parent, 714 714 StatusEvent(status=msg, type=type)) -
src/sas/sasgui/guiframe/local_perspectives/plotting/plotting.py
rca224b1 r235f514 88 88 On Qmin Qmax vertical line event 89 89 """ 90 if event ==None:90 if event is None: 91 91 return 92 92 if event.id in self.plot_panels.keys(): … … 99 99 100 100 def _on_plot_lim(self, event=None): 101 if event ==None:101 if event is None: 102 102 return 103 103 if event.id in self.plot_panels.keys(): -
src/sas/sasgui/guiframe/local_perspectives/plotting/profile_dialog.py
rd85c194 r7432acb 44 44 wx.Dialog.__init__(self, parent, id=id, *args, **kwds) 45 45 46 if data !=None:46 if data is not None: 47 47 #Font size 48 48 kwds = [] … … 284 284 default_name = default_name.split('.')[0] 285 285 default_name += "_out" 286 if self.parent !=None:286 if self.parent is not None: 287 287 # What an ancestor! 288 288 fit_panel = self.parent.parent.parent -
src/sas/sasgui/guiframe/local_perspectives/plotting/sector_mask.py
rd85c194 r7432acb 96 96 self.left_line.update(phi=self.right_line.phi, delta=None, 97 97 mline=self.main_line, side=True, left=False) 98 #if self.is_inside !=None:98 #if self.is_inside is not None: 99 99 out = self._post_data() 100 100 return out … … 117 117 data = self.base.data 118 118 # If we have no data, just return 119 if data ==None:119 if data is None: 120 120 return 121 121 ## Averaging -
src/sas/sasgui/guiframe/local_perspectives/plotting/parameters_panel_boxsum.py
r7432acb r37d461c 1 1 import wx 2 2 import wx.lib.newevent 3 #from copy import deepcopy 3 from parameters_panel_slicer import SlicerParameterPanel 4 4 from sas.sasgui.guiframe.utils import format_number 5 from sas.sasgui.guiframe. events import SlicerParameterEvent6 from sas.sasgui.guiframe.events import EVT_SLICER_PARS7 from sas.sasgui.guiframe.events import EVT_SLICER 5 from sas.sasgui.guiframe.panel_base import PanelBase 6 from sas.sasgui.guiframe.events import (SlicerParameterEvent, EVT_SLICER_PARS, 7 EVT_SLICER) 8 8 9 from sas.sasgui.guiframe.panel_base import PanelBase10 9 11 10 class SlicerPanel(wx.Panel, PanelBase): … … 13 12 Panel class to show the slicer parameters 14 13 """ 15 #TODO: show units 16 #TODO: order parameters properly 17 ## Internal name for the AUI manager 14 # Internal name for the AUI manager 18 15 window_name = "Slicer panel" 19 # #Title to appear on top of the window16 # Title to appear on top of the window 20 17 window_caption = "Slicer Panel" 21 18 CENTER_PANE = False … … 25 22 wx.Panel.__init__(self, parent, id, *args, **kwargs) 26 23 PanelBase.__init__(self) 27 # #Initialization of the class24 # Initialization of the class 28 25 self.base = base 29 26 if params is None: … … 44 41 else: 45 42 self.set_slicer(type, params) 46 ## Bindings 47 self.parent.Bind(EVT_SLICER, self.onEVT_SLICER) 48 self.parent.Bind(EVT_SLICER_PARS, self.onParamChange) 49 50 def onEVT_SLICER(self, event): 51 """ 52 Process EVT_SLICER events 53 When the slicer changes, update the panel 54 55 :param event: EVT_SLICER event 56 57 """ 58 event.Skip() 59 if event.obj_class is None: 60 self.set_slicer(None, None) 61 else: 62 self.set_slicer(event.type, event.params) 43 # Bindings 44 self.parent.Bind(EVT_SLICER, SlicerParameterPanel.on_evt_slicer) 45 self.parent.Bind(EVT_SLICER_PARS, SlicerParameterPanel.on_param_change) 63 46 64 47 def set_slicer(self, type, params): … … 84 67 keys.sort() 85 68 for item in keys: 86 if not item.lower() in ["num_points", "avg", "avg_error", "sum", "sum_error"]: 69 if not item.lower() in ["num_points", "avg", "avg_error", "sum", 70 "sum_error"]: 87 71 n += 1 88 72 text = wx.StaticText(self, -1, item, style=wx.ALIGN_LEFT) 89 73 self.bck.Add(text, (n - 1, 0), 90 flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL, border=15) 74 flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 75 border=15) 91 76 ctl = wx.TextCtrl(self, -1, size=(80, 20), 92 77 style=wx.TE_PROCESS_ENTER) … … 95 80 ctl.SetToolTipString(hint_msg) 96 81 ctl.SetValue(str(format_number(params[item]))) 97 self.Bind(wx.EVT_TEXT_ENTER, self.on TextEnter)98 ctl.Bind(wx.EVT_SET_FOCUS, self.on SetFocus)99 ctl.Bind(wx.EVT_KILL_FOCUS, self.on TextEnter)82 self.Bind(wx.EVT_TEXT_ENTER, self.on_text_enter) 83 ctl.Bind(wx.EVT_SET_FOCUS, self.on_set_focus) 84 ctl.Bind(wx.EVT_KILL_FOCUS, self.on_text_enter) 100 85 self.parameters.append([item, ctl]) 101 self.bck.Add(ctl, (n - 1, 1), flag=wx.TOP | wx.BOTTOM, border=0) 86 self.bck.Add(ctl, (n - 1, 1), flag=wx.TOP | wx.BOTTOM, 87 border=0) 102 88 for item in keys: 103 if item.lower() in ["num_points", "avg", "avg_error", "sum", "sum_error"]: 89 if item.lower() in ["num_points", "avg", "avg_error", "sum", 90 "sum_error"]: 104 91 n += 1 105 text = wx.StaticText(self, -1, item + ": ", style=wx.ALIGN_LEFT) 106 self.bck.Add(text, (n - 1, 0), flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 92 text = wx.StaticText(self, -1, item + ": ", 93 style=wx.ALIGN_LEFT) 94 self.bck.Add(text, (n - 1, 0), 95 flag=wx.LEFT | wx.ALIGN_CENTER_VERTICAL, 107 96 border=15) 108 97 ctl = wx.StaticText(self, -1, … … 110 99 style=wx.ALIGN_LEFT) 111 100 ctl.SetToolTipString("Result %s" % item) 112 self.bck.Add(ctl, (n - 1, 1), flag=wx.TOP | wx.BOTTOM, border=0) 101 self.bck.Add(ctl, (n - 1, 1), flag=wx.TOP | wx.BOTTOM, 102 border=0) 113 103 self.bck.Layout() 114 104 self.Layout() 115 p sizer = self.parent.GetSizer()116 if p sizer is not None:117 p sizer.Layout()105 p_sizer = self.parent.GetSizer() 106 if p_sizer is not None: 107 p_sizer.Layout() 118 108 119 def on SetFocus(self, evt):109 def on_set_focus(self, evt): 120 110 """ 121 111 Highlight the txtcrtl … … 126 116 # Select the whole control, after this event resolves 127 117 wx.CallAfter(widget.SetSelection, -1, -1) 128 return129 118 130 def onParamChange(self, evt): 131 """ 132 Receive and event and reset the text field contained in self.parameters 133 134 """ 135 evt.Skip() 136 for item in self.parameters: 137 if item[0] in evt.params: 138 item[1].SetValue(format_number(evt.params[item[0]])) 139 item[1].Refresh() 140 141 def onTextEnter(self, evt): 119 def on_text_enter(self, evt): 142 120 """ 143 121 Parameters have changed … … 149 127 try: 150 128 params[item[0]] = float(item[1].GetValue()) 151 item[1].SetBackgroundColour(wx.SystemSettings_GetColour(wx.SYS_COLOUR_WINDOW)) 129 item[1].SetBackgroundColour(wx.SystemSettings_GetColour( 130 wx.SYS_COLOUR_WINDOW)) 152 131 item[1].Refresh() 153 132 except: … … 155 134 item[1].SetBackgroundColour("pink") 156 135 item[1].Refresh() 157 158 if has_error == False: 136 if not has_error: 159 137 # Post parameter event 160 # #base is guiframe is this case138 # base is guiframe is this case 161 139 event = SlicerParameterEvent(type=self.type, params=params) 162 140 wx.PostEvent(self.base, event) … … 166 144 On Close Event 167 145 """ 168 ID= self.uid169 self.parent.delete_panel( ID)146 uid = self.uid 147 self.parent.delete_panel(uid) 170 148 self.frame.Destroy()
Note: See TracChangeset
for help on using the changeset viewer.