Changeset 343fdb6 in sasview
- Timestamp:
- Jul 26, 2010 5:38:56 PM (14 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:
- 72a6bf8
- Parents:
- aebc4cc
- Location:
- invariantview/perspectives/invariant
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
invariantview/perspectives/invariant/invariant.py
rcb463b4 r343fdb6 228 228 else: 229 229 data = plottable 230 # Store reference to data 231 self.__data = data 232 # Set the data set to be user for invariant calculation 233 self.invariant_panel.set_current_data(data=data) 230 self.compute_helper(data=data) 234 231 232 def compute_helper(self, data): 233 """ 234 """ 235 if data is None: 236 return 237 # Store reference to data 238 self.__data = data 239 # Set the data set to be user for invariant calculation 240 self.invariant_panel.set_current_data(data=data) 241 235 242 def save_file(self, filepath, state=None): 236 243 """ -
invariantview/perspectives/invariant/invariant_panel.py
ra94c4e1 r343fdb6 82 82 self.new_state = False 83 83 self.is_power_out = False 84 84 85 85 #container of invariant value 86 86 self.inv_container = None … … 96 96 ## Default file location for save 97 97 self._default_save_location = os.getcwd() 98 98 99 99 def err_check_on_data(self): 100 100 """ … … 114 114 return flag 115 115 116 def on_select_data(self, event=None): 117 """ 118 """ 119 n = self.data_cbbox.GetCurrentSelection() 120 data, path = self.data_cbbox.GetClientData(n) 121 self._manager.compute_helper(data=data) 122 title = os.path.basename(path) 123 if hasattr(data,"title"): 124 title = str(data.title.lstrip().rstrip()) 125 if title == "": 126 title = str(data.name) 127 else: 128 title = str(data.name) 129 wx.PostEvent(self.parent, NewPlotEvent(plot=data, title=title)) 130 116 131 def set_data(self, list=[], state=None): 117 132 """ 118 133 Receive a list of data from gui_manager to compute invariant 119 134 """ 120 if list==[]: 121 msg = "Please select data for Invariant perspective.\n" 122 dial = wx.MessageDialog(None, msg, 'Error Loading File', 123 wx.OK | wx.ICON_EXCLAMATION) 124 dial.ShowModal() 125 return 126 elif len(list) == 1: 127 data, filepath = list[0] 128 if data.__class__.__name__ == "Data2D": 129 msg = "Invariant cannot be computed for Data2D.\n" 130 msg += "Please load another file.\n" 131 dial = wx.MessageDialog(None, msg, 'Error Loading File', 132 wx.OK | wx.ICON_EXCLAMATION) 133 dial.ShowModal() 134 else: 135 self.set_current_data(data=data) 136 else: 137 msg = " Invariant cannot be computed for more than one data.\n" 138 msg += "Please load only file.\n" 139 dial = wx.MessageDialog(None, msg, 'Error Loading File', 140 wx.OK | wx.ICON_EXCLAMATION) 141 dial.ShowModal() 142 135 if not list: 136 return 137 for data, path in list: 138 if data.__class__.__name__ != "Data2D" and \ 139 data.name not in self.data_cbbox.GetItems(): 140 self.data_cbbox.Insert(item=data.name, pos=0, 141 clientData=(data, path)) 142 if self.data_cbbox.GetCount() >0: 143 self.data_cbbox.SetSelection(0) 144 self.data_cbbox.Enable() 145 self.on_select_data(event=None) 146 143 147 def set_current_data(self, data): 144 148 """ … … 206 210 self.state = IState() 207 211 else: 208 209 212 if not self.set_current_data(data): 210 213 return … … 213 216 214 217 num = self.state.saved_state['state_num'] 218 self.get_state_by_num(state_num=num) 215 219 216 220 if num > 0 : … … 219 223 self._redo_enable() 220 224 225 221 226 # get bookmarks 222 227 self.bookmark_num = len(self.state.bookmark_list) 223 224 228 total_bookmark_num = self.bookmark_num+1 225 229 for ind in range(1,total_bookmark_num): … … 230 234 id = wx.NewId() 231 235 self.popUpMenu.Append(id,name,str('')) 232 wx.EVT_MENU(self, id, self._back_to_bookmark)236 wx.EVT_MENU(self, id, self._back_to_bookmark) 233 237 234 238 self.get_state_by_num(state_num=str(num)) 235 239 236 240 self._get_input_list() 241 237 242 238 243 self.new_state = False … … 502 507 msg= "\n\nStarting a new invariant computation..." 503 508 wx.PostEvent(self.parent, StatusEvent(status=msg)) 504 505 509 506 510 if self._data is None or self.err_check_on_data(): … … 589 593 self.is_power_out = False 590 594 wx.PostEvent(self.parent, StatusEvent(status = msg )) 591 595 592 596 #enable the button_ok for more details 593 597 self.button_details.Enable() … … 596 600 self.button_report.Enable(True) 597 601 wx.PostEvent(self.parent, StatusEvent(status = '\nFinished invariant computation...')) 598 602 599 603 def undo(self,event=None): 600 604 """ … … 666 670 667 671 backup_state_list = copy.deepcopy(self.state.state_list) 668 672 669 673 # get the previous state 670 674 try: … … 674 678 except : 675 679 raise ValueError, "No such state exists in history" 676 680 677 681 # get the state at pre_compute_num 678 682 comp_state = copy.deepcopy(self.state.state_list[current_compute_num]) … … 687 691 except: 688 692 pass 689 693 690 694 self.compute_invariant(event=None) 691 695 # set the input params at the state at pre_state_num … … 711 715 self.state.saved_state = current_state 712 716 self.state.state_num = state_num 713 714 717 715 718 716 719 def get_bookmark_by_num(self, num=None): … … 752 755 pass 753 756 self.state.saved_state = copy.deepcopy(current_state) 754 757 755 758 self._enable_high_q_section(event=None) 756 759 self._enable_low_q_section(event=None) … … 872 875 self._redo_disable() 873 876 874 875 877 def _reset_state_list(self,data=None): 876 878 """ … … 1140 1142 else: 1141 1143 return False 1142 1143 1144 1144 1145 def _reset_output(self): … … 1178 1179 self.data_name_boxsizer.SetMinSize((PANEL_WIDTH,-1)) 1179 1180 self.hint_msg_sizer = wx.BoxSizer(wx.HORIZONTAL) 1181 self.loaded_data_name_sizer = wx.BoxSizer(wx.HORIZONTAL) 1180 1182 self.data_name_sizer = wx.BoxSizer(wx.HORIZONTAL) 1181 1183 self.data_range_sizer = wx.BoxSizer(wx.HORIZONTAL) … … 1223 1225 self.hint_msg_txt.SetToolTipString(msg) 1224 1226 self.hint_msg_sizer.Add(self.hint_msg_txt) 1227 1228 self.data_txt = wx.StaticText(self, -1,"Loaded Data: ") 1229 self.data_cbbox = wx.ComboBox(self, -1, size=(260,20)) 1230 self.data_cbbox.Disable() 1231 wx.EVT_COMBOBOX(self.data_cbbox ,-1, self.on_select_data) 1232 1233 1225 1234 #Data name [string] 1226 1235 data_name_txt = wx.StaticText(self, -1, 'Data : ') 1227 1236 1228 self.data_name_tcl = OutputTextCtrl(self, -1, size=(_BOX_WIDTH*5, 20), style=0, name='data_name_tcl') 1237 self.data_name_tcl = OutputTextCtrl(self, -1,size=(260,20), style=0, 1238 name='data_name_tcl') 1229 1239 self.data_name_tcl.SetToolTipString("Data's name.") 1240 self.loaded_data_name_sizer.AddMany([(self.data_txt, 0, 1241 wx.LEFT|wx.RIGHT, 10), 1242 (self.data_cbbox, 0, wx.EXPAND)]) 1230 1243 self.data_name_sizer.AddMany([(data_name_txt, 0, wx.LEFT|wx.RIGHT, 10), 1231 (self.data_name_tcl, 0, wx.EXPAND)]) 1244 (self.data_name_tcl, 0, wx.EXPAND|wx.LEFT,35)]) 1245 1232 1246 #Data range [string] 1233 1247 data_range_txt = wx.StaticText(self, -1, 'Total Q Range (1/A): ') … … 1238 1252 self.data_max_tcl = OutputTextCtrl(self, -1, size=(_BOX_WIDTH, 20), style=0, name='data_max_tcl') 1239 1253 self.data_max_tcl.SetToolTipString("The maximum value of q range.") 1254 1240 1255 self.data_range_sizer.AddMany([(data_range_txt, 0, wx.RIGHT, 10), 1241 1256 (data_min_txt, 0, wx.RIGHT, 10), … … 1244 1259 (self.data_max_tcl, 0, wx.RIGHT, 10)]) 1245 1260 self.data_name_boxsizer.AddMany([(self.hint_msg_sizer, 0 , wx.ALL, 5), 1246 (self.data_name_sizer, 0 , wx.RIGHT, 10), 1247 (self.data_range_sizer, 0 , wx.ALL, 10)]) 1261 (self.loaded_data_name_sizer, 0 , wx.ALL, 10), 1262 (self.data_name_sizer, 0 , wx.LEFT|wx.RIGHT, 10), 1263 (self.data_range_sizer, 0 , wx.ALL, 10)]) 1248 1264 1249 1265 def _layout_bkg_scale(self):
Note: See TracChangeset
for help on using the changeset viewer.