Changeset 8dfdd20 in sasview
- Timestamp:
- Jun 2, 2009 3:05:30 PM (16 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.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- d483799
- Parents:
- e50f15b
- Location:
- guiframe/local_perspectives/plotting
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
guiframe/local_perspectives/plotting/Plotter2D.py
re50f15b r8dfdd20 82 82 ## panel that contains result from slicer motion (ex: Boxsum info) 83 83 self.panel_slicer=None 84 84 85 ## Graph 85 86 self.graph = Graph() … … 87 88 self.graph.yaxis("\\rm{Intensity} ","cm^{-1}") 88 89 self.graph.render(self) 89 90 ## store default value of zmin and zmax 91 self.default_zmin_ctl = self.zmin_2D 92 self.default_zmax_ctl = self.zmax_2D 90 93 91 94 def _onEVT_1DREPLOT(self, event): … … 165 168 self.graph.render(self) 166 169 self.subplot.figure.canvas.draw_idle() 170 ## store default value of zmin and zmax 171 self.default_zmin_ctl = self.zmin_2D 172 self.default_zmax_ctl = self.zmax_2D 167 173 168 174 … … 263 269 264 270 import detector_dialog 265 dialog = detector_dialog.DetectorDialog(self, -1,base=self.parent) 271 272 dialog = detector_dialog.DetectorDialog(self, -1,base=self.parent, 273 reset_zmin_ctl =self.default_zmin_ctl, 274 reset_zmax_ctl = self.default_zmax_ctl,cmap=self.cmap) 266 275 ## info of current detector and data2D 267 276 xnpts = len(self.data2D.x_bins) … … 281 290 self.zmin_2D = evt.zmin 282 291 self.zmax_2D = evt.zmax 292 self.cmap= evt.cmap 283 293 284 294 dialog.Destroy() … … 291 301 zmin= self.zmin_2D, 292 302 zmax= self.zmax_2D, 303 cmap= self.cmap, 293 304 color=0,symbol=0,label=self.data2D.name)#'data2D') 294 305 self.subplot.figure.canvas.draw_idle() -
guiframe/local_perspectives/plotting/detector_dialog.py
red7384d r8dfdd20 6 6 7 7 import wx 8 import sys 8 9 from sans.guiframe.utils import format_number 9 from sans.guicomm.events import StatusEvent ,NewPlotEvent,SlicerEvent 10 11 10 from sans.guicomm.events import StatusEvent ,NewPlotEvent 11 12 import matplotlib 13 from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as Canvas 14 from matplotlib import pyplot, mpl, pylab 15 16 DEFAULT_CMAP= pylab.cm.jet 12 17 class DetectorDialog(wx.Dialog): 13 18 """ … … 15 20 """ 16 21 17 def __init__(self,parent,id=1,base=None, *args, **kwds): 22 def __init__(self,parent,id=1,base=None,dpi = None,cmap=DEFAULT_CMAP, 23 reset_zmin_ctl = None,reset_zmax_ctl = None, *args, **kwds): 18 24 19 25 kwds["style"] = wx.DEFAULT_DIALOG_STYLE … … 21 27 22 28 self.parent=base 29 self.dpi = dpi 30 self.cmap= cmap 31 32 self.reset_zmin_ctl= reset_zmin_ctl 33 self.reset_zmax_ctl= reset_zmax_ctl 34 23 35 self.label_xnpts = wx.StaticText(self, -1, "Detector width in pixels") 24 36 self.label_ynpts = wx.StaticText(self, -1, "Detector Height in pixels") … … 34 46 35 47 self.zmin_ctl = wx.TextCtrl(self, -1, size=(60,20)) 48 self.zmin_ctl.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) 36 49 self.zmax_ctl = wx.TextCtrl(self, -1, size=(60,20)) 50 self.zmax_ctl.Bind(wx.EVT_SET_FOCUS, self.onSetFocus) 37 51 38 52 self.static_line_3 = wx.StaticLine(self, -1) 39 53 40 54 self.button_Cancel = wx.Button(self, wx.ID_CANCEL, "Cancel") 55 self.button_reset = wx.Button(self, wx.NewId(),"Reset") 56 self.Bind(wx.EVT_BUTTON, self.resetValues, self.button_reset) 41 57 self.button_OK = wx.Button(self, wx.ID_OK, "OK") 42 self.button_Cancel = wx.Button(self, wx.ID_CANCEL, "Cancel")43 58 self.Bind(wx.EVT_BUTTON, self.checkValues, self.button_OK) 44 59 … … 55 70 zmin = 0 56 71 zmax = 0 72 cmap= None 57 73 sym4 = False 74 75 76 77 def onSetFocus(self, event): 78 """ 79 Highlight the txtcrtl 80 """ 81 # Get a handle to the TextCtrl 82 widget = event.GetEventObject() 83 # Select the whole control, after this event resolves 84 wx.CallAfter(widget.SetSelection, -1,-1) 85 return 86 87 def resetValues(self, event): 88 """ 89 reset detector info 90 """ 91 try: 92 self.zmin_ctl.SetValue(str(float(self.reset_zmin_ctl))) 93 self.zmax_ctl.SetValue(str(float(self.reset_zmax_ctl))) 94 self.cmap = DEFAULT_CMAP 95 self.cmap_selector.SetValue(str(self.cmap.name)) 96 self._on_select_cmap(event=None) 97 except: 98 msg ="error occurs while resetting Detector: %s"%sys.exc_value 99 wx.PostEvent(self.parent,StatusEvent(status= msg )) 100 58 101 59 102 def checkValues(self, event): … … 108 151 @param sym: 109 152 """ 110 self.xnpts_ctl.SetLabel(str(format_number(xnpts))) 111 self.ynpts_ctl.SetLabel(str(format_number(ynpts))) 112 self.qmax_ctl.SetLabel(str(format_number(qmax))) 113 self.beam_ctl.SetLabel(str(format_number(beam))) 153 self.xnpts_ctl.SetLabel(str(float(xnpts))) 154 self.ynpts_ctl.SetLabel(str(float(ynpts))) 155 self.qmax_ctl.SetLabel(str(float(qmax))) 156 self.beam_ctl.SetLabel(str(float(beam))) 157 158 114 159 115 160 if zmin !=None: 116 self.zmin_ctl.SetValue(str(f ormat_number(zmin)))161 self.zmin_ctl.SetValue(str(float(zmin))) 117 162 if zmax !=None: 118 self.zmax_ctl.SetValue(str(f ormat_number(zmax)))163 self.zmax_ctl.SetValue(str(float(zmax))) 119 164 120 165 def getContent(self): … … 143 188 event.zmin = v_min 144 189 event.zmax = v_max 190 event.cmap= self.cmap 145 191 146 192 return event … … 161 207 sizer_button = wx.BoxSizer(wx.HORIZONTAL) 162 208 sizer_params = wx.GridBagSizer(5,5) 209 sizer_colormap = wx.BoxSizer(wx.VERTICAL) 210 sizer_selection= wx.BoxSizer(wx.HORIZONTAL) 211 163 212 164 213 iy = 0 … … 181 230 sizer_params.Add(self.zmax_ctl, (iy,1), (1,1), wx.EXPAND|wx.ADJUST_MINSIZE, 0) 182 231 iy += 1 183 232 233 234 235 self.fig = mpl.figure.Figure(dpi=self.dpi, figsize=(4,1)) 236 237 self.ax1 = self.fig.add_axes([0.05, 0.65, 0.9, 0.15]) 238 239 240 self.norm = mpl.colors.Normalize(vmin=0, vmax=100) 241 self.cb1 = mpl.colorbar.ColorbarBase(self.ax1, cmap=self.cmap, 242 norm= self.norm, 243 orientation='horizontal') 244 self.cb1.set_label('Detector Colors') 245 self.canvas = Canvas(self, -1, self.fig) 246 sizer_colormap.Add(self.canvas,0, wx.LEFT | wx.EXPAND,5) 247 248 self.cmap_selector = wx.ComboBox(self, -1) 249 self.cmap_selector.SetValue(str(self.cmap.name)) 250 maps = sorted(m for m in pylab.cm.datad if not m.endswith("_r")) 251 252 for i,m in enumerate(maps): 253 254 self.cmap_selector.Append(str(m), pylab.get_cmap(m)) 255 256 wx.EVT_COMBOBOX(self.cmap_selector,-1, self._on_select_cmap) 257 sizer_selection.Add(wx.StaticText(self,-1,"Select Cmap: "),0, wx.LEFT|wx.ADJUST_MINSIZE,5) 258 sizer_selection.Add(self.cmap_selector, 0, wx.EXPAND|wx.ALL, 10) 259 184 260 sizer_main.Add(sizer_params, 0, wx.EXPAND|wx.ALL, 10) 261 262 sizer_main.Add(sizer_selection, 0, wx.EXPAND|wx.ALL, 10) 263 sizer_main.Add(sizer_colormap, 1, wx.EXPAND|wx.ALL, 10) 185 264 sizer_main.Add(self.static_line_3, 0, wx.EXPAND, 0) 186 265 187 266 188 sizer_button.Add( (20, 20), 1, wx.EXPAND|wx.ADJUST_MINSIZE,0)267 sizer_button.Add(self.button_reset,0, wx.LEFT|wx.ADJUST_MINSIZE, 100) 189 268 sizer_button.Add(self.button_OK, 0, wx.LEFT|wx.ADJUST_MINSIZE, 10) 190 269 sizer_button.Add(self.button_Cancel, 0, wx.LEFT|wx.RIGHT|wx.ADJUST_MINSIZE, 10) … … 197 276 self.Centre() 198 277 # end wxGlade 278 279 def _on_select_cmap(self, event): 280 """ 281 display a new cmap 282 """ 283 cmap_name= self.cmap_selector.GetCurrentSelection() 284 current_cmap= self.cmap_selector.GetClientData( cmap_name ) 285 self.cmap= current_cmap 286 self.cb1 = mpl.colorbar.ColorbarBase(self.ax1, cmap=self.cmap, 287 norm= self.norm, 288 orientation='horizontal') 289 self.canvas.draw() 199 290 200 291 … … 207 298 dialog = DetectorDialog(None, -1, "") 208 299 self.SetTopWindow(dialog) 209 dialog.setContent(128, 0.05) 300 dialog.setContent(xnpts=128,ynpts=128, qmax=20, 301 beam=20,zmin=2,zmax=60, sym=False) 210 302 print dialog.ShowModal() 211 303 evt = dialog.getContent() 212 print evt.npts, evt.qmax 304 if hasattr(evt,"npts"): 305 print "number of point: ",evt.npts 306 if hasattr(evt,"qmax"): 307 print "qmax: ",evt.qmax 213 308 dialog.Destroy() 214 309 return 1
Note: See TracChangeset
for help on using the changeset viewer.