Changeset 0399c78 in sasview for invariantview/perspectives/invariant/invariant_panel.py
- Timestamp:
- Jul 30, 2010 6:54:53 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:
- f24925ab
- Parents:
- 178bfea
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
invariantview/perspectives/invariant/invariant_panel.py
r178bfea r0399c78 117 117 def on_select_data(self, event=None): 118 118 """ 119 """ 120 121 n = self.data_cbbox.GetCurrentSelection() 119 On select data by combobox or contextmenu or by set_data 120 """ 121 if event !=None: 122 n = self.data_cbbox.GetCurrentSelection() 123 data, path = self.data_cbbox.GetClientData(n) 124 #warning message for losing all the calculation and states 125 if self._data !=None: 126 if self._data.name != data.name: 127 if self._show_message(): 128 self._manager.compute_helper(data=data) 129 data = self._data 130 return 131 132 #update the computation 133 data = self._data 134 if data == None: return 135 n = data.name 122 136 try: 123 data, path = self.data_cbbox.GetClientData(n) 124 125 if not self._data == data: 126 self._manager.compute_helper(data=data) 127 else: 128 msg = "The data named %s is already loaded..."% data.name 129 wx.PostEvent(self.parent, StatusEvent(status=msg)) 137 pos = self.data_cbbox.FindString(data.name) 138 self.data_cbbox.SetSelection(pos) 139 self._manager.compute_helper(data=data) 130 140 except: 131 self.data_cbbox.SetSelection(0) 141 n = self.data_cbbox.GetCount() 142 self.data_cbbox.SetSelection(n) 132 143 133 144 def set_data(self, list=[], state=None): … … 137 148 if not list: 138 149 return 150 139 151 count_bf = self.data_cbbox.GetCount() 140 152 for data, path in list: … … 144 156 self.data_cbbox.Insert(item=data.name, pos=position, 145 157 clientData=(data, path)) 158 146 159 count = self.data_cbbox.GetCount() 147 160 if count >0: 148 # set data only on the first or state data 161 # set data only on the first or state data 149 162 if count ==1 or self.is_state_data: 150 # when count increased especially if self.is_state_data.151 if count > count_bf:152 self.data_cbbox.SetSelection(count-1)153 154 163 self.data_cbbox.Enable() 164 self._data = data 155 165 self.on_select_data(event=None) 156 166 self.is_state_data = False 157 158 title = "Untitled" 159 if hasattr(data,"title"): 160 title = str(data.title.lstrip().rstrip()) 161 if title == "": 162 title = str(data.name) 163 else: 167 168 title = "Untitled" 169 if hasattr(data,"title"): 170 title = str(data.title.lstrip().rstrip()) 171 if title == "": 164 172 title = str(data.name) 165 166 wx.PostEvent(self.parent, NewPlotEvent(plot=data, title=title)) 173 else: 174 title = str(data.name) 175 176 wx.PostEvent(self.parent, NewPlotEvent(plot=data, title=title)) 177 167 178 168 179 def set_current_data(self, data, path=None): 169 180 """ 170 Set the data 181 Set the data, mainly used by the inv state file 171 182 172 183 : return: True/False; if False, it will not set_current_data … … 174 185 # warn the users 175 186 if self._data != None and data != None: 176 if not self._show_message(): 177 return False 187 if self._data.name != data.name: 188 if not self._show_message(): 189 return False 178 190 179 191 self._data = data … … 181 193 self._set_bookmark_menu() 182 194 #edit the panel 183 if self._data is not None:195 if data is not None: 184 196 185 197 self.err_check_on_data() 186 198 self.get_state_by_num(0) 187 199 data_name = self._data.name 188 data_qmin = min ( self._data.x)189 data_qmax = max ( self._data.x)200 data_qmin = min (data.x) 201 data_qmax = max (data.x) 190 202 191 203 if data.name not in self.data_cbbox.GetItems(): 192 self.data_cbbox.Insert(pos=0, clientData=(data, None), 204 position = self.data_cbbox.GetCount() 205 self.data_cbbox.Insert(pos=position, clientData=(data, None), 193 206 item=data.name) 194 207 else: 195 208 pos = self.data_cbbox.FindString(data.name) 196 209 self.data_cbbox.SetSelection(pos) 210 197 211 self.data_min_tcl.SetLabel(str(data_qmin)) 198 212 self.data_max_tcl.SetLabel(str(data_qmax)) … … 268 282 self.state.data = self._data 269 283 self.new_state = False 284 270 285 271 286 … … 1159 1174 Show warning message when resetting data 1160 1175 """ 1161 1162 mssg += 'Loading a new data set will reset all the work done in this panel. \n\r' 1163 mssg += 'Please make sure to save it first... \n\r' 1164 answer = wx.MessageBox(mssg, msg, wx.CANCEL|wx.OK|wx.ICON_EXCLAMATION) 1165 1166 if answer == wx.OK: 1167 return True 1168 else: 1169 return False 1170 1176 count_bf = self.data_cbbox.GetCount() 1177 if count_bf > 1: 1178 mssg += 'Loading a new data set will reset all the work done in this panel. \n\r' 1179 mssg += 'Please make sure to save it first... \n\r' 1180 answer = wx.MessageBox(mssg, msg, wx.CANCEL|wx.OK|wx.ICON_EXCLAMATION) 1181 1182 if answer == wx.OK: 1183 return True 1184 else: 1185 return False 1186 else: True 1171 1187 1172 1188 def _reset_output(self): … … 1803 1819 self.SetSizer(self.main_sizer) 1804 1820 self.SetAutoLayout(True) 1805 1821 1822 1806 1823 class InvariantDialog(wx.Dialog): 1807 1824 """
Note: See TracChangeset
for help on using the changeset viewer.