Changeset 210ff4f in sasview
- Timestamp:
- Aug 4, 2010 2:44:48 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:
- af47c8d
- Parents:
- bf66f67
- Location:
- invariantview/perspectives/invariant
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
invariantview/perspectives/invariant/invariant.py
rf24925ab r210ff4f 240 240 self.__data = data 241 241 # Set the data set to be user for invariant calculation 242 self.invariant_panel.set_ current_data(data=data)242 self.invariant_panel.set_data(data=data) 243 243 244 244 def save_file(self, filepath, state=None): -
invariantview/perspectives/invariant/invariant_panel.py
rf24925ab r210ff4f 115 115 return flag 116 116 117 def on_select_data(self, event=None): 118 """ 119 On select data by combobox or by set_data 120 """ 121 if event !=None: 122 self.state 123 n = self.data_cbbox.GetCurrentSelection() 124 self.data_cbbox.SetSelection(n) 125 data, path = self.data_cbbox.GetClientData(n) 126 if self._data !=None: 127 self._manager.compute_helper(data=data) 128 data = self._data 129 return 130 131 #update the computation 132 data = self._data 133 if data == None: return 134 n = data.name 135 try: 136 pos = self.data_cbbox.FindString(data.name) 137 self.data_cbbox.SetSelection(pos) 138 self._manager.compute_helper(data=data) 139 except: 140 n = self.data_cbbox.GetCount() 141 self.data_cbbox.SetSelection(n) 142 143 def set_data(self, list=[], state=None): 144 """ 145 Receive a list of data from gui_manager to compute invariant 146 """ 147 if not list: 148 return 149 150 #count_bf = self.data_cbbox.GetCount() 151 for data, path in list: 152 if data.__class__.__name__ != "Data2D" and \ 153 data.name not in self.data_cbbox.GetItems(): 154 position = self.data_cbbox.GetCount() 155 self.data_cbbox.Insert(item=data.name, pos=position, 156 clientData=(data, path)) 157 158 count = self.data_cbbox.GetCount() 159 if count > 0: 160 self.data_cbbox.Enable() 161 # reset data (cb) only on the first data 162 if count ==1: 163 try: 164 #check if the data is from inv file 165 self._data.meta_data['invstate'].file 166 except: 167 self._data = data 168 self.on_select_data(event=None) 169 170 #data = self._data 171 title = "Untitled" 172 if hasattr(data,"title"): 173 title = str(data.title.lstrip().rstrip()) 174 if title == "": 175 title = str(data.name) 176 else: 177 title = str(data.name) 178 179 if self.is_state_data: 180 self.data_cbbox.SetValue(title) 181 self.data_cbbox.Enable(True) 182 self.is_state_data = False 183 184 wx.PostEvent(self.parent, NewPlotEvent(plot=data, title=title)) 185 186 187 def set_current_data(self, data, path=None): 188 """ 189 Set the data, mainly used by the inv state file 190 191 : return: True/False; if False, it will not set_current_data 192 """ 193 # warn the users 194 if self._data != None and data != None: 195 if self._data.name != data.name: 196 if not self._show_message(): 197 return False 198 117 def set_data(self, data): 118 """ 119 Set the data 120 """ 199 121 self._data = data 200 # reset popUpMenu201 self._set_bookmark_menu()202 122 #edit the panel 203 if data is not None: 204 123 if self._data is not None: 205 124 self.err_check_on_data() 206 self.get_state_by_num(0)207 125 data_name = self._data.name 208 data_qmin = min (data.x) 209 data_qmax = max (data.x) 210 211 if data.name not in self.data_cbbox.GetItems(): 212 position = self.data_cbbox.GetCount() 213 self.data_cbbox.Insert(pos=position, clientData=(data, None), 214 item=data.name) 215 else: 216 position = self.data_cbbox.FindString(data.name) 217 self.data_cbbox.SetSelection(position) 218 126 data_qmin = min (self._data.x) 127 data_qmax = max (self._data.x) 128 self.data_name_tcl.SetValue(str(data_name)) 219 129 self.data_min_tcl.SetLabel(str(data_qmin)) 220 130 self.data_max_tcl.SetLabel(str(data_qmax)) 221 self.button_save.Enable(True)222 131 self.reset_panel() 223 132 self.compute_invariant(event=None) 224 #Reset the list of states 225 self.state.data = copy.deepcopy(data) 226 self._reset_state_list() 227 228 return True 229 133 return True 230 134 def set_message(self): 231 135 """ … … 260 164 else: 261 165 self.new_state = True 262 if not self.set_ current_data(data, path=None):166 if not self.set_data(data): 263 167 return 264 168 self.state = state … … 1233 1137 self.data_name_boxsizer.SetMinSize((PANEL_WIDTH,-1)) 1234 1138 self.hint_msg_sizer = wx.BoxSizer(wx.HORIZONTAL) 1235 self. loaded_data_name_sizer = wx.BoxSizer(wx.HORIZONTAL)1139 self.data_name_sizer = wx.BoxSizer(wx.HORIZONTAL) 1236 1140 1237 1141 self.data_range_sizer = wx.BoxSizer(wx.HORIZONTAL) … … 1279 1183 self.hint_msg_txt.SetToolTipString(msg) 1280 1184 self.hint_msg_sizer.Add(self.hint_msg_txt) 1281 1282 self.data_txt = wx.StaticText(self, -1,"Data: ") 1283 self.data_cbbox = wx.ComboBox(self, -1, size=(260,20), 1284 style=wx.CB_READONLY) 1285 self.data_cbbox.Disable() 1286 wx.EVT_COMBOBOX(self.data_cbbox ,-1, self.on_select_data) 1287 1288 self.loaded_data_name_sizer.AddMany([(self.data_txt, 0, 1289 wx.LEFT|wx.RIGHT, 10), 1290 (self.data_cbbox, 0, wx.EXPAND)]) 1185 #Data name [string] 1186 data_name_txt = wx.StaticText(self, -1, 'Data : ') 1187 1188 self.data_name_tcl = OutputTextCtrl(self, -1, size=(_BOX_WIDTH*5, 20), style=0) 1189 self.data_name_tcl.SetToolTipString("Data's name.") 1190 self.data_name_sizer.AddMany([(data_name_txt, 0, wx.LEFT|wx.RIGHT, 10), 1191 (self.data_name_tcl, 0, wx.EXPAND)]) 1291 1192 #Data range [string] 1292 1193 data_range_txt = wx.StaticText(self, -1, 'Total Q Range (1/A): ') … … 1303 1204 (self.data_max_tcl, 0, wx.RIGHT, 10)]) 1304 1205 self.data_name_boxsizer.AddMany([(self.hint_msg_sizer, 0 , wx.ALL, 5), 1305 (self. loaded_data_name_sizer, 0 , wx.ALL, 10),1206 (self.data_name_sizer, 0 , wx.ALL, 10), 1306 1207 (self.data_range_sizer, 0 , wx.ALL, 10)]) 1307 1208 … … 1859 1760 1860 1761 data.name = data.filename 1861 self.panel.set_ current_data(data)1762 self.panel.set_data(data) 1862 1763 self.Centre() 1863 1764 self.Show(True)
Note: See TracChangeset
for help on using the changeset viewer.