Changeset f866fb5 in sasview
- Timestamp:
- Aug 16, 2012 11:46:12 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:
- d8e3f7c
- Parents:
- 9f51c2c
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
plottools/src/danse/common/plottools/PlotPanel.py
r5da3cc5 rf866fb5 1295 1295 1296 1296 self.xcolor = color 1297 if units.count("{") > 0 and units.count("$") < 2: 1298 units = '$' + units + '$' 1299 if label.count("{") > 0 and label.count("$") < 2: 1300 label = '$' + label + '$' 1297 1301 if units != "": 1298 1302 label = label + " (" + units + ")" 1299 if label.count("{") > 0 and label.count("$") < 2:1300 label = '$' + label + '$'1301 1303 if font: 1302 1304 self.subplot.set_xlabel(label, fontproperties=font, color=color) … … 1314 1316 """yaxis label and units.""" 1315 1317 self.ycolor = color 1316 1318 if units.count("{") > 0 and units.count("$") < 2: 1319 units = '$' + units + '$' 1320 if label.count("{") > 0 and label.count("$") < 2: 1321 label = '$' + label + '$' 1317 1322 if units != "": 1318 1323 label = label + " (" + units + ")" 1319 if label.count("{") > 0 and label.count("$") < 2:1320 label = '$' + label + '$'1321 1324 if font: 1322 1325 self.subplot.set_ylabel(label, fontproperties=font, color=color) -
sansguiframe/src/sans/guiframe/local_perspectives/plotting/Plotter1D.py
r9f51c2c rf866fb5 422 422 423 423 id = wx.NewId() 424 self._slicerpop.Append(id, '&Copy to Clipboard', 'Copy to the clipboard') 424 self._slicerpop.Append(id, '&Copy to Clipboard', 425 'Copy to the clipboard') 425 426 wx.EVT_MENU(self, id, self.OnCopyFigureMenu) 426 427 … … 495 496 496 497 id = wx.NewId() 497 plot_menu.Append(id, '&Modify plot properties', name)498 plot_menu.Append(id, '&Modify Plot Property', name) 498 499 wx.EVT_MENU(self, id, self.createAppDialog) 499 500 … … 503 504 #plot_menu.SetTitle(name) 504 505 self._slicerpop.AppendMenu(id, '&%s'% name, plot_menu) 505 506 506 # Option to hide 507 #TODO: implement functionality to hide a plottable (legend click) 507 508 if not self.graph.selected_plottable in self.plots: 508 509 self._slicerpop.AppendSeparator() … … 514 515 515 516 id = wx.NewId() 516 self._slicerpop.Append(id, '&Modify graph appearance','Modify graph appearance') 517 self._slicerpop.Append(id, '&Modify Graph Appearance', 518 'Modify graph appearance') 517 519 wx.EVT_MENU(self, id, self.modifyGraphAppearance) 518 520 self._slicerpop.AppendSeparator() … … 550 552 def onFreeze(self, event): 551 553 """ 554 on Freeze data 552 555 """ 553 556 menu = event.GetEventObject() … … 621 624 menu = event.GetEventObject() 622 625 id = event.GetId() 623 self.set_selected_from_menu(menu, id)624 self.appearance_selected_plot = self.plots[self.graph.selected_plottable]625 626 self.set_selected_from_menu(menu, id) 627 self.appearance_selected_plot = \ 628 self.plots[self.graph.selected_plottable] 626 629 # find current properties 627 630 curr_color = self.appearance_selected_plot.custom_color … … 637 640 icon = self.parent.GetIcon() 638 641 self.appD.SetIcon(icon) 639 self.appD.setDefaults(float(curr_size),int(curr_color),str(appearanceDialog.find_key(self.get_symbol_label(),int(curr_symbol))),curr_label) 642 self.appD.set_defaults(float(curr_size), int(curr_color), 643 str(appearanceDialog.find_key(self.get_symbol_label(), 644 int(curr_symbol))), curr_label) 640 645 self.appD.Bind(wx.EVT_CLOSE, self.on_AppDialog_close) 641 646 642 def on_AppDialog_close(self,e): 647 def on_AppDialog_close(self, event): 648 """ 649 on_Modify Plot Property_close 650 """ 643 651 if(self.appD.okay_clicked == True): 644 info = self.appD.getCurrentValues() # returns (size,color,symbol,datalabel) 645 self.appearance_selected_plot.custom_color = self._color_labels[info[1].encode('ascii','ignore')] 652 # returns (size,color,symbol,datalabel) 653 info = self.appD.get_current_values() 654 self.appearance_selected_plot.custom_color = \ 655 self._color_labels[info[1].encode('ascii', 'ignore')] 646 656 647 657 self.appearance_selected_plot.markersize = float(info[0]) 648 self.appearance_selected_plot.symbol = self.get_symbol_label()[info[2]] # self._symbol_labels[info[2].encode('ascii','ignore')] 658 self.appearance_selected_plot.symbol = \ 659 self.get_symbol_label()[info[2]] 649 660 self.appearance_selected_plot.label = str(info[3]) 650 661 … … 652 663 helpString = 'Show/Hide Graph: ' 653 664 for plot in self.plots.itervalues(): 654 helpString += (' ' + str(plot.label) + ';')665 helpString += (' ' + str(plot.label) + ';') 655 666 self.parent._window_menu.SetHelpString(pos, helpString) 656 667 self._is_changed_legend_label = True … … 660 671 661 672 662 def modifyGraphAppearance(self,e): 663 self.graphApp = graphAppearance(self,'Modify Graph Appearance') 673 def modifyGraphAppearance(self, event): 674 """ 675 On Modify Graph Appearance 676 """ 677 self.graphApp = graphAppearance(self, 'Modify Graph Appearance') 664 678 icon = self.parent.GetIcon() 665 679 self.graphApp.SetIcon(icon) 666 667 668 self.graphApp.setDefaults(self.grid_on,self.legend_on, 669 self.xaxis_label,self.yaxis_label, 670 self.xaxis_unit,self.yaxis_unit, 671 self.xaxis_font,self.yaxis_font, 672 find_key(self.get_loc_label(),self.legendLoc), 680 self.graphApp.setDefaults(self.grid_on, self.legend_on, 681 self.xaxis_label, self.yaxis_label, 682 self.xaxis_unit, self.yaxis_unit, 683 self.xaxis_font, self.yaxis_font, 684 find_key(self.get_loc_label(), 685 self.legendLoc), 673 686 self.xcolor,self.ycolor) 674 687 self.graphApp.Bind(wx.EVT_CLOSE, self.on_graphApp_close) -
sansguiframe/src/sans/guiframe/local_perspectives/plotting/appearanceDialog.py
r9f51c2c rf866fb5 1 1 #!/usr/bin/python 2 3 2 """ 4 5 3 Dialog for appearance of plot symbols, color, size etc. 6 7 8 4 /** 9 5 This software was developed by Institut Laue-Langevin as part of … … 13 9 14 10 **/ 15 16 17 11 """ 18 19 12 import wx 20 13 import operator 21 14 22 23 # main appearance dialog starts here:24 25 26 15 class appearanceDialog(wx.Frame): 27 28 def __init__(self,parent,title): 29 super(appearanceDialog,self).__init__(parent, title=title,size=(570,450), style=wx.DEFAULT_FRAME_STYLE|wx.FRAME_FLOAT_ON_PARENT) 16 """ 17 Appearance dialog 18 """ 19 def __init__(self, parent, title): 20 """ 21 Initialization of the Panel 22 """ 23 super(appearanceDialog, self).__init__(parent, title=title, 24 size=(570,450), 25 style=wx.DEFAULT_FRAME_STYLE|wx.FRAME_FLOAT_ON_PARENT) 30 26 31 27 self.okay_clicked = False 32 28 self.parent = parent 33 self.symbolLabels = self.parent.get_symbol_label() 34 self.colorLabels = self.parent.get_color_label() 35 36 37 self.InitUI() 29 self.symbo_labels = self.parent.get_symbol_label() 30 self.color_labels = self.parent.get_color_label() 31 self.init_ui() 38 32 self.Centre() 39 33 self.Show() 40 34 41 42 def InitUI(self):43 44 # create spacing needed35 def init_ui(self): 36 """ 37 Create spacing needed 38 """ 45 39 panel = wx.Panel(self) 46 40 … … 57 51 ihbox2 = wx.BoxSizer(wx.HORIZONTAL) 58 52 59 symbol StaticBox = wx.StaticBox(panel, -1, 'Symbol')60 symbol StaticBoxSizer = wx.StaticBoxSizer(symbolStaticBox, wx.VERTICAL)53 symbolstaticbox = wx.StaticBox(panel, -1, 'Symbol') 54 symbolstaticboxsizer = wx.StaticBoxSizer(symbolstaticbox, wx.VERTICAL) 61 55 62 56 # add widgets - reverse order! 63 64 57 # texts 65 symbol Text = wx.StaticText(panel, label='Shape')66 color Text = wx.StaticText(panel, label='Color')67 size Text = wx.StaticText(panel, label='Size ')68 label Text = wx.StaticText(panel, label='Legend label')58 symboltext = wx.StaticText(panel, label='Shape') 59 colortext = wx.StaticText(panel, label='Color') 60 sizetext = wx.StaticText(panel, label='Size ') 61 labeltext = wx.StaticText(panel, label='Legend Label') 69 62 70 63 # selection widgets 71 self.symbolListBox = wx.ListBox(panel,-1,size=(200,200)) 72 self.colorListBox = wx.ComboBox(panel,style=wx.CB_READONLY, size=(195,-1)) 73 self.sizeComboBox = wx.ComboBox(panel,style=wx.CB_READONLY, size=(90,-1)) 74 self.sizeComboBox.Bind(wx.EVT_COMBOBOX, self.combo_click) 75 self.sizeCustomButton = wx.Button(panel, label='Custom...') 76 self.sizeCustomButton.Bind(wx.EVT_BUTTON, self.customSize) 77 self.labelTextBox = wx.TextCtrl(panel,-1, "",size=(-1,-1)) 64 self.symbollistbox = wx.ListBox(panel, -1, size=(200, 200)) 65 self.colorlistbox = wx.ComboBox(panel, style=wx.CB_READONLY, 66 size=(185, -1)) 67 self.sizecombobox = wx.ComboBox(panel, style=wx.CB_READONLY, 68 size=(90, -1)) 69 self.sizecombobox.Bind(wx.EVT_COMBOBOX, self.combo_click) 70 self.sizecustombutton = wx.Button(panel, label='Custom...') 71 self.sizecustombutton.Bind(wx.EVT_BUTTON, self.custom_size) 72 self.labeltextbox = wx.TextCtrl(panel, -1, "", size=(440, -1)) 78 73 79 74 # buttons 80 OkButton = wx.Button(panel, label='OK')81 OkButton.Bind(wx.EVT_BUTTON,self.onOK)82 cancel Button = wx.Button(panel, label='Cancel')83 cancel Button.Bind(wx.EVT_BUTTON, self.CloseDlg)75 okbutton = wx.Button(panel, label='OK') 76 okbutton.Bind(wx.EVT_BUTTON, self.on_ok) 77 cancelbutton = wx.Button(panel, label='Cancel') 78 cancelbutton.Bind(wx.EVT_BUTTON, self.close_dlg) 84 79 85 80 # now Add all the widgets to relevant spacer - tricky 86 ivbox1.Add(symbolText, flag = wx.ALL | wx.ALIGN_LEFT ,border=10) 87 ivbox1.Add(self.symbolListBox, flag = wx.ALL | wx.ALIGN_LEFT ,border=10) 88 89 ihbox1.Add(sizeText, flag = wx.ALL| wx.ALIGN_LEFT , border=10) 90 ihbox1.Add(self.sizeComboBox, flag = wx.ALL|wx.RIGHT | wx.ALIGN_LEFT , border=10) 91 ihbox1.Add(self.sizeCustomButton, flag = wx.ALIGN_LEFT | wx.ALL, border=10) 92 93 ihbox2.Add(colorText,flag = wx.ALL | wx.ALIGN_LEFT, border=10) 94 ihbox2.Add(self.colorListBox, flag = wx.ALL | wx.ALIGN_LEFT, border=10) 95 96 97 98 ivbox2.Add(ihbox1, flag =wx.ALIGN_LEFT,border=10) 99 ivbox2.Add(ihbox2, flag =wx.ALIGN_LEFT,border=10) 100 101 102 hbox1.Add(ivbox1,flag =wx.ALIGN_LEFT ,border=10) 103 hbox1.Add(ivbox2,flag =wx.ALIGN_LEFT ,border=10) 104 105 106 hbox2.Add(OkButton, flag = wx.ALL | wx.ALIGN_RIGHT, border=10) 107 hbox2.Add(cancelButton, flag = wx.ALL | wx.ALIGN_RIGHT, border=10) 108 109 hbox3.Add(labelText, flag= wx.EXPAND | wx.RIGHT | wx.ALIGN_LEFT, border=10) 110 hbox3.Add(self.labelTextBox, wx.EXPAND | wx.RIGHT |wx.ALIGN_LEFT , border=10) 81 ivbox1.Add(symboltext, flag=wx.ALL|wx.ALIGN_LEFT, border=10) 82 ivbox1.Add(self.symbollistbox, flag=wx.ALL|wx.ALIGN_LEFT, border=10) 83 84 ihbox1.Add(sizetext, flag=wx.ALL|wx.ALIGN_LEFT, border=10) 85 ihbox1.Add(self.sizecombobox, 86 flag= wx.ALL|wx.RIGHT|wx.ALIGN_LEFT, border=10) 87 ihbox1.Add(self.sizecustombutton, 88 flag=wx.ALIGN_LEFT|wx.ALL, border=10) 89 90 ihbox2.Add(colortext, flag=wx.ALL|wx.ALIGN_LEFT, border=10) 91 ihbox2.Add(self.colorlistbox, flag=wx.ALL|wx.ALIGN_LEFT, border=10) 92 93 ivbox2.Add(ihbox1, flag=wx.ALIGN_LEFT, border=10) 94 ivbox2.Add(ihbox2, flag=wx.ALIGN_LEFT, border=10) 95 96 hbox1.Add(ivbox1, flag=wx.ALIGN_LEFT, border=10) 97 hbox1.Add(ivbox2, flag=wx.ALIGN_LEFT, border=10) 98 99 hbox2.Add(okbutton, flag=wx.ALL| wx.ALIGN_RIGHT, border=10) 100 hbox2.Add(cancelbutton, flag=wx.ALL|wx.ALIGN_RIGHT, border=10) 101 102 hbox3.Add(labeltext, flag=wx.EXPAND|wx.ALL|wx.ALIGN_LEFT, border=10) 103 hbox3.Add(self.labeltextbox, flag=wx.EXPAND|wx.ALL|wx.ALIGN_LEFT, border=10) 111 104 112 symbolStaticBoxSizer.Add(hbox1,flag = wx.ALL | wx.EXPAND,border=10) 113 vbox.Add(symbolStaticBoxSizer, flag = wx.ALL | wx.EXPAND,border=10) 114 115 vbox.Add(hbox3,flag = wx.ALL | wx.EXPAND | wx.ALIGN_RIGHT, border=10) 116 117 118 vbox.Add(hbox2,flag = wx.ALL | wx.ALIGN_RIGHT, border=10) 119 105 symbolstaticboxsizer.Add(hbox1, flag=wx.ALL|wx.EXPAND, border=10) 106 vbox.Add(symbolstaticboxsizer, flag=wx.ALL|wx.EXPAND, border=10) 107 vbox.Add(hbox3, flag=wx.EXPAND|wx.RIGHT, border=10) 108 vbox.Add(wx.StaticLine(panel), 0, wx.ALL|wx.EXPAND, 5) 109 vbox.Add(hbox2, flag=wx.RIGHT|wx.ALIGN_RIGHT, border=10) 120 110 121 111 panel.SetSizer(vbox) 122 112 123 self.populateSymbol() 124 self.populateColor() 125 self.populateSize() 126 127 self.SetDefaultItem(self.symbolListBox) 128 129 def customSize(self,e): 130 dlg = wx.TextEntryDialog(self, 131 'Enter custom size', 132 'Custom size', 113 self.populate_symbol() 114 self.populate_color() 115 self.populate_size() 116 117 self.SetDefaultItem(self.symbollistbox) 118 119 def custom_size(self, event): 120 """ 121 On custom size 122 """ 123 dlg = wx.TextEntryDialog(self, 124 'Enter custom size', 125 'Custom size', 133 126 str(self.final_size)) 134 127 if(dlg.ShowModal() == wx.ID_OK): 135 128 if(float(dlg.GetValue()) < 0): 136 dial = wx.MessageDialog(None,137 'Unfortunately imaginary icons are not yet supported. Please enter a positive value',138 139 wx.OK |wx.ICON_ERROR)129 msg = "Unfortunately imaginary icons are not yet supported." 130 msg += "Please enter a positive value" 131 dial = wx.MessageDialog(None, msg, 'Error', 132 wx.OK|wx.ICON_ERROR) 140 133 dial.ShowModal() 141 134 dlg.Destroy() 142 self.custom Size(e)135 self.custom_size(event) 143 136 else: 144 137 self.final_size = dlg.GetValue() … … 147 140 dlg.Destroy() 148 141 149 def setDefaults(self,size,color,symbol,label): 142 def set_defaults(self, size, color, symbol, label): 143 """ 144 Set Defaults 145 """ 150 146 self.final_size = size 151 147 # set up gui values 152 self.label TextBox.SetValue(label)148 self.labeltextbox.SetValue(label) 153 149 if(size % 1 == 0 and size > 1 and size < 11): 154 self.size ComboBox.SetSelection(int(size) - 1)150 self.sizecombobox.SetSelection(int(size) - 1) 155 151 else: 156 self.sizeComboBox.SetSelection(4) 157 self.symbolListBox.SetSelection(self.sorted_sym_dic[symbol]) 158 colorname = appearanceDialog.find_key(self.parent.get_color_label(),color) 159 self.colorListBox.SetStringSelection(colorname) 160 161 def populateSymbol(self): 162 self.sorted_symbolLabels = sorted(self.symbolLabels.iteritems(),key=operator.itemgetter(1)) 152 self.sizecombobox.SetSelection(4) 153 self.symbollistbox.SetSelection(self.sorted_sym_dic[symbol]) 154 colorname = appearanceDialog.find_key(self.parent.get_color_label(), 155 color) 156 self.colorlistbox.SetStringSelection(colorname) 157 158 def populate_symbol(self): 159 """ 160 Populate Symbols 161 """ 162 self.sorted_symbo_labels = sorted(self.symbo_labels.iteritems(), 163 key=operator.itemgetter(1)) 163 164 self.sorted_sym_dic = {} 164 165 i = 0 165 for label in self.sorted_symbo lLabels:166 self.symbol ListBox.Append(str(label[0]))166 for label in self.sorted_symbo_labels: 167 self.symbollistbox.Append(str(label[0])) 167 168 self.sorted_sym_dic[str(label[0])] = i 168 169 i += 1 169 170 170 def populateColor(self): 171 sortedcolorLabels = sorted(self.colorLabels.iteritems(),key=operator.itemgetter(1)) 172 173 for color in sortedcolorLabels: 174 self.colorListBox.Append(str(color[0])) 171 def populate_color(self): 172 """ 173 Populate Colors 174 """ 175 sortedcolor_labels = sorted(self.color_labels.iteritems(), 176 key=operator.itemgetter(1)) 177 for color in sortedcolor_labels: 178 self.colorlistbox.Append(str(color[0])) 175 179 176 def populateSize(self): 177 178 for i in range(1,11): 179 self.sizeComboBox.Append(str(i) + '.0') 180 181 def combo_click(self,e): 182 self.final_size = self.sizeComboBox.GetValue() 183 184 def CloseDlg(self,e): 180 def populate_size(self): 181 """ 182 Populate Size 183 """ 184 for i in range(1, 11): 185 self.sizecombobox.Append(str(i) + '.0') 186 187 def combo_click(self, event): 188 """ 189 Combox on click 190 """ 191 event.Skip() 192 self.final_size = self.sizecombobox.GetValue() 193 194 def close_dlg(self, event): 195 """ 196 On Close Dlg 197 """ 198 event.Skip() 185 199 self.Destroy() 186 200 187 188 def get_symbol_label(self):189 """190 Associates label to symbol191 """192 _labels = {}193 i = 0194 _labels['Circle'] = i195 i += 1196 _labels['Cross X '] = i197 i += 1198 _labels['Triangle Down'] = i199 i += 1200 _labels['Triangle Up'] = i201 i += 1202 _labels['Triangle Left'] = i203 i += 1204 _labels['Triangle Right'] = i205 i += 1206 _labels['Cross +'] = i207 i += 1208 _labels['Square'] = i209 i += 1210 _labels['Diamond'] = i211 i += 1212 _labels['Hexagon1'] = i213 i += 1214 _labels['Hexagon2'] = i215 i += 1216 _labels['Pentagon'] = i217 i += 1218 _labels['Line'] = i219 i += 1220 _labels['Dash'] = i221 i += 1222 _labels['Vline'] = i223 i += 1224 _labels['Step'] = i225 return _labels226 227 def get_color_label(self):228 """229 Associates label to a specific color230 """231 _labels = {}232 i = 0233 _labels['Blue'] = i234 i += 1235 _labels['Green'] = i236 i += 1237 _labels['Red'] = i238 i += 1239 _labels['Cyan'] = i240 i += 1241 _labels['Magenta'] = i242 i += 1243 _labels['Yellow'] = i244 i += 1245 _labels['Black'] = i246 return _labels247 248 201 @staticmethod 249 def find_key(dic,val): 202 def find_key(dic, val): 203 """ 204 Find key 205 """ 250 206 return [k for k, v in dic.iteritems() if v == val][0] 251 207 252 def getCurrentValues(self): # returns (size,color,symbol,dataname) 253 208 def get_current_values(self): 209 """ 210 Get Current Values 211 :returns : (size, color, symbol, dataname) 212 """ 254 213 size = float(self.final_size) 255 name = str(self.labelTextBox.GetValue()) 256 selTuple = self.symbolListBox.GetSelections() 257 symbol = appearanceDialog.find_key(self.sorted_sym_dic,int(selTuple[0])) 258 color = str(self.colorListBox.GetValue()) 259 260 return(size,color,symbol,name) 261 262 def onOK(self,e): 214 name = str(self.labeltextbox.GetValue()) 215 seltuple = self.symbollistbox.GetSelections() 216 symbol = appearanceDialog.find_key(self.sorted_sym_dic, 217 int(seltuple[0])) 218 color = str(self.colorlistbox.GetValue()) 219 return(size, color, symbol, name) 220 221 def on_ok(self, event): 222 """ 223 On OK button clicked 224 """ 225 event.Skip() 263 226 self.okay_clicked = True 264 265 227 self.Close()
Note: See TracChangeset
for help on using the changeset viewer.