Changeset 8a687cfd in sasview for sansguiframe
- Timestamp:
- Jul 5, 2012 4:26:59 AM (12 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:
- 7c755888
- Parents:
- 8f59e95
- Location:
- sansguiframe/src/sans/guiframe/local_perspectives/plotting
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
sansguiframe/src/sans/guiframe/local_perspectives/plotting/Plotter1D.py
r8f59e95 r8a687cfd 687 687 688 688 def on_graphApp_close(self,e): 689 # returns toggleGrid? toggleLegend? xlab, ylab, xunit, yunit, xfont, yfont, xcolor, ycolor, legendloc 690 691 #to do - make this passback mechanism much nicer 692 data = self.graphApp.getAppInfo() 693 self.onGridOnOff(data[0]) 694 self.onLegend(data[1]) 695 self.ChangeLegendLoc(data[10]) 696 697 self.xaxis_label = data[2] 698 self.yaxis_label = data[3] 699 self.xaxis_unit = data[4] 700 self.yaxis_unit = data[5] 701 702 self.xaxis(data[2],data[4],data[6],data[8]) 703 self.yaxis(data[3],data[5],data[7],data[9]) 704 705 xfont = data[6] 706 yfont = data[7] 707 708 # and a little sanity checking along the way 689 # gets values from graph appearance dialog and sends them off 690 # to modify the plot 691 692 self.onGridOnOff(self.graphApp.get_togglegrid()) 693 self.onLegend(self.graphApp.get_togglelegend()) 694 self.ChangeLegendLoc(self.graphApp.get_legend_loc()) 695 696 self.xaxis_label = self.graphApp.get_xlab() 697 self.yaxis_label = self.graphApp.get_ylab() 698 self.xaxis_unit = self.graphApp.get_xunit() 699 self.yaxis_unit = self.graphApp.get_yunit() 700 701 self.xaxis(self.xaxis_label,self.xaxis_unit, 702 self.graphApp.get_xfont(),self.graphApp.get_xcolor()) 703 self.yaxis(self.yaxis_label,self.yaxis_unit, 704 self.graphApp.get_yfont(),self.graphApp.get_ycolor()) 709 705 710 706 self.graphApp.Destroy() -
sansguiframe/src/sans/guiframe/local_perspectives/plotting/Plotter2D.py
r940aca7 r8a687cfd 33 33 from sans.guiframe.dataFitting import Data1D 34 34 from matplotlib.font_manager import FontProperties 35 from graphAppearance import graphAppearance 35 36 (InternalEvent, EVT_INTERNAL) = wx.lib.newevent.NewEvent() 36 37 … … 39 40 DEFAULT_BEAM = 0.005 40 41 BIN_WIDTH = 1.0 42 43 44 def find_key(dic, val): 45 """return the key of dictionary dic given the value""" 46 return [k for k, v in dic.iteritems() if v == val][0] 41 47 42 48 … … 375 381 slicerpop.AppendSeparator() 376 382 377 id = wx.NewId() 378 slicerpop.Append(id, '&Edit Y Axis Label') 379 wx.EVT_MENU(self, id, self._on_yaxis_label) 380 id = wx.NewId() 381 slicerpop.Append(id, '&Edit X Axis Label') 382 wx.EVT_MENU(self, id, self._on_xaxis_label) 383 id = wx.NewId() 384 slicerpop.Append(id, '&Toggle Grid On/Off', 'Toggle Grid On/Off') 385 wx.EVT_MENU(self, id, self.onGridOnOff) 383 # id = wx.NewId() 384 # slicerpop.Append(id, '&Edit Y Axis Label') 385 # wx.EVT_MENU(self, id, self._on_yaxis_label) 386 # id = wx.NewId() 387 # slicerpop.Append(id, '&Edit X Axis Label') 388 # wx.EVT_MENU(self, id, self._on_xaxis_label) 389 # id = wx.NewId() 390 # slicerpop.Append(id, '&Toggle Grid On/Off', 'Toggle Grid On/Off') 391 # wx.EVT_MENU(self, id, self.onGridOnOff) 392 # slicerpop.AppendSeparator() 393 394 # ILL mod here 395 396 id = wx.NewId() 397 slicerpop.Append(id, '&Modify graph appearance','Modify graph appearance') 398 wx.EVT_MENU(self, id, self.modifyGraphAppearance) 386 399 slicerpop.AppendSeparator() 400 401 387 402 388 403 id = wx.NewId() … … 776 791 self.parent.show_data2d(data, default_name) 777 792 793 794 def modifyGraphAppearance(self,e): 795 self.graphApp = graphAppearance(self,'Modify graph appearance', 796 legend=False) 797 798 799 800 self.graphApp.setDefaults(self.grid_on,self.legend_on, 801 self.xaxis_label,self.yaxis_label, 802 self.xaxis_unit,self.yaxis_unit, 803 self.xaxis_font,self.yaxis_font, 804 find_key(self.get_loc_label(),self.legendLoc), 805 self.xcolor,self.ycolor) 806 self.graphApp.Bind(wx.EVT_CLOSE, self.on_graphApp_close) 807 808 809 def on_graphApp_close(self,e): 810 # gets values from graph appearance dialog and sends them off 811 # to modify the plot 812 813 self.onGridOnOff(self.graphApp.get_togglegrid()) 814 815 816 self.xaxis_label = self.graphApp.get_xlab() 817 self.yaxis_label = self.graphApp.get_ylab() 818 self.xaxis_unit = self.graphApp.get_xunit() 819 self.yaxis_unit = self.graphApp.get_yunit() 820 821 self.xaxis(self.xaxis_label,self.xaxis_unit, 822 self.graphApp.get_xfont(),self.graphApp.get_xcolor()) 823 self.yaxis(self.yaxis_label,self.yaxis_unit, 824 self.graphApp.get_yfont(),self.graphApp.get_ycolor()) 825 826 self.graphApp.Destroy() -
sansguiframe/src/sans/guiframe/local_perspectives/plotting/graphAppearance.py
r8f59e95 r8a687cfd 26 26 class graphAppearance(wx.Frame): 27 27 28 def __init__(self,parent,title ):28 def __init__(self,parent,title,legend=True): 29 29 super(graphAppearance,self).__init__(parent, title=title,size=(520,435)) 30 31 self.legend = legend 30 32 31 33 self.InitUI() … … 51 53 52 54 53 legendLocText = wx.StaticText(panel, label='Legend location: ') 54 self.legendLocCombo = wx.ComboBox(panel,style = wx.CB_READONLY, size=(180,-1)) 55 self.fillLegendLocs() 56 57 self.toggleLegend = wx.CheckBox(panel, label='Toggle legend on/off') 55 56 if self.legend: 57 legendLocText = wx.StaticText(panel, label='Legend location: ') 58 self.legendLocCombo = wx.ComboBox(panel,style = wx.CB_READONLY, size=(180,-1)) 59 self.fillLegendLocs() 60 else: 61 self.legendLocCombo = None 62 63 64 if self.legend: 65 self.toggleLegend = wx.CheckBox(panel, label='Toggle legend on/off') 66 else: 67 self.toggleLegend = None 68 58 69 self.toggleGrid = wx.CheckBox(panel, label='Toggle grid on/off') 59 70 … … 119 130 yhbox2.Add(yfontButton,flag=wx.ALL | wx.ALIGN_RIGHT, border=5) 120 131 121 122 hbox1.Add(legendLocText, flag = wx.ALL | wx.EXPAND | wx.ALIGN_LEFT, border=5) 123 hbox1.Add(self.legendLocCombo, flag = wx.ALL | wx.EXPAND | wx.ALIGN_LEFT, border=5) 124 hbox1.Add((5,-1)) 125 hbox1.Add(self.toggleLegend, flag = wx.ALL | wx.EXPAND | wx.ALIGN_LEFT, border=5) 132 if self.legend: 133 hbox1.Add(legendLocText, flag = wx.ALL | wx.EXPAND | wx.ALIGN_LEFT, border=5) 134 hbox1.Add(self.legendLocCombo, flag = wx.ALL | wx.EXPAND | wx.ALIGN_LEFT, border=5) 135 136 if self.legend: 137 hbox1.Add((5,-1)) 138 hbox1.Add(self.toggleLegend, flag = wx.ALL | wx.EXPAND | wx.ALIGN_LEFT, border=5) 126 139 127 140 hbox2.Add(self.okButton, flag = wx.ALL | wx.ALIGN_RIGHT, border=5) … … 223 236 xcolor,ycolor): 224 237 self.toggleGrid.SetValue(grid) 225 self.toggleLegend.SetValue(legend) 238 if self.legend: 239 self.toggleLegend.SetValue(legend) 226 240 self.xaxisText.SetValue(xlab) 227 241 self.yaxisText.SetValue(ylab) … … 242 256 243 257 244 245 self.legendLocCombo.SetStringSelection(legend_loc) 246 247 248 def getAppInfo(self): 249 grid_on = self.toggleGrid.GetValue() 250 legend_on = self.toggleLegend.GetValue() 251 xlab = self.xaxisText.GetValue() 252 ylab = self.yaxisText.GetValue() 253 xunit = self.xaxisUnitText.GetValue() 254 yunit = self.yaxisUnitText.GetValue() 255 legend_loc = self.get_loc_label()[self.legendLocCombo.GetStringSelection()] 256 xcolor = self.xfontColor.GetValue() 257 ycolor = self.yfontColor.GetValue() 258 259 260 return [grid_on,legend_on,xlab,ylab,xunit,yunit, 261 self.xfont,self.yfont, 262 xcolor,ycolor,legend_loc] 263 264 258 if self.legend: 259 self.legendLocCombo.SetStringSelection(legend_loc) 260 261 262 # get whether grid is toggled on/off 263 def get_togglegrid(self): 264 return self.toggleGrid.GetValue() 265 266 # get whether legend is toggled on/off 267 def get_togglelegend(self): 268 return self.toggleLegend.GetValue() 269 270 # get x label 271 def get_xlab(self): 272 return self.xaxisText.GetValue() 273 274 # get y label 275 def get_ylab(self): 276 return self.yaxisText.GetValue() 277 278 # get x unit 279 def get_xunit(self): 280 return self.xaxisUnitText.GetValue() 281 282 # get y unit 283 def get_yunit(self): 284 return self.yaxisUnitText.GetValue() 285 286 # get legend location 287 def get_legend_loc(self): 288 return self.get_loc_label()[self.legendLocCombo.GetStringSelection()] 289 290 # get x axis label color 291 def get_xcolor(self): 292 return self.xfontColor.GetValue() 293 294 # get y axis label color 295 def get_ycolor(self): 296 return self.yfontColor.GetValue() 297 298 # get x axis font (type is FontProperties) 299 def get_xfont(self): 300 return self.xfont 301 302 # get y axis font 303 def get_yfont(self): 304 return self.yfont 305 265 306 266 307 if __name__ == '__main__':
Note: See TracChangeset
for help on using the changeset viewer.