Changeset 9b18735 in sasview
- Timestamp:
- Aug 11, 2010 5:35:03 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:
- b63dc6e
- Parents:
- 3eb2811
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
guiframe/data_loader.py
ref16f59 r9b18735 12 12 13 13 from sans.guicomm.events import NewPlotEvent, StatusEvent 14 SVS_FILE_EXT = ['.svs','.inv','.prv','.fitv'] 14 15 15 16 def enable_add_data(existing_panel, new_plot): … … 228 229 # plot data 229 230 wx.PostEvent(parent, NewPlotEvent(plot=new_plot, title=title)) 230 # set state and plot computation if exists 231 wx.PostEvent(parent,InvStateUpdateEvent()) 232 wx.PostEvent(parent,FitStateUpdateEvent()) 231 if format in SVS_FILE_EXT: 232 # set state and plot computation if exists 233 wx.PostEvent(parent,InvStateUpdateEvent()) 234 wx.PostEvent(parent,FitStateUpdateEvent()) 233 235 ## the output of the loader is a list , some xml files contain more than one data 234 236 else: … … 262 264 new_plot.copy_from_datainfo(item) 263 265 item.clone_without_data(clone=new_plot) 264 266 # find original data file name without timestemp 265 267 name = parse_name(name=str(item.run[0]), expression="_") 266 268 max_char = name.find("[") 269 if max_char < 0: 270 max_char = len(name) 271 original_name =name[0:max_char] 267 272 #TODO: this is a very annoying feature. We should make this 268 273 # an option. Excel doesn't do this. Why should we? … … 272 277 new_plot.name = name 273 278 new_plot.interactive = True 274 new_plot.group_id = name279 new_plot.group_id = original_name 275 280 new_plot.id = name 276 281 new_plot.is_data = True … … 293 298 # plot data 294 299 wx.PostEvent(parent, NewPlotEvent(plot=new_plot, title=str(title))) 295 296 # set state and plot computation if exists 297 wx.PostEvent(parent,InvStateUpdateEvent()) 298 wx.PostEvent(parent,FitStateUpdateEvent()) 300 301 if format in SVS_FILE_EXT: 302 # set state and plot computation if exists 303 wx.PostEvent(parent,InvStateUpdateEvent()) 304 wx.PostEvent(parent,FitStateUpdateEvent()) 299 305 except: 300 306 raise -
guiframe/gui_manager.py
r028a0e8 r9b18735 715 715 716 716 from data_loader import plot_data 717 from sans.perspectives import invariant 717 718 if path and os.path.isfile(path): 718 719 basename = os.path.basename(path) 719 720 if basename.endswith('.svs'): 721 #remove panels for new states 722 for item in self.panels: 723 try: 724 self.panels[item].clear_panel() 725 except: pass 720 726 plot_data(self, path,'.inv') 721 727 plot_data(self, path,'.prv') -
invariantview/perspectives/invariant/invariant.py
r4da35bc r9b18735 265 265 """ 266 266 Call-back method for the state reader. 267 This method is called when a .inv file is loaded.267 This method is called when a .inv/.svs file is loaded. 268 268 269 269 :param state: State object … … 271 271 self.temp_state = None 272 272 try: 273 273 274 if datainfo is None: 274 275 raise RuntimeError, "invariant.set_state: datainfo parameter cannot be None in standalone mode" 276 275 277 datainfo.meta_data['invstate'].file = datainfo.meta_data['invstate'].file 276 278 datainfo.name = datainfo.meta_data['invstate'].file … … 283 285 # set state 284 286 self.invariant_panel.is_state_data = True 285 # Load the invariant states287 286 288 # Make sure the user sees the invariant panel after loading 287 289 self.parent.set_perspective(self.perspective) 290 # Load the invariant states 288 291 self.temp_state = temp_state 289 292 #self.invariant_panel.set_state(state=temp_state,data=self.__data) 290 293 291 294 except: 292 295 logging.error("invariant.set_state: %s" % sys.exc_value) 293 296 294 def on_set_state_helper(self,event=None): 295 """ 297 def on_set_state_helper(self, event=None): 298 """ 299 Set the state when called by EVT_STATE_UPDATE event from guiframe 300 after a .inv/.svs file is loaded 296 301 """ 297 302 self.invariant_panel.set_state(state=self.temp_state,data=self.__data) 298 303 self.temp_state = None 304 305 299 306 300 307 def plot_theory(self, data=None, name=None): -
invariantview/perspectives/invariant/invariant_panel.py
r085bf4c r9b18735 123 123 if self._data is not None: 124 124 self.err_check_on_data() 125 self.get_state_by_num(0) 125 126 data_name = self._data.name 126 127 data_qmin = min (self._data.x) … … 132 133 self.compute_invariant(event=None) 133 134 self.state.file = self._data.name 135 #Reset the list of states 136 self.state.data = copy.deepcopy(data) 137 self._reset_state_list() 134 138 return True 135 139 def set_message(self): … … 159 163 def set_state(self,state=None,data=None): 160 164 """ 161 set state when loading it from a .inv file165 set state when loading it from a .inv/.svs file 162 166 """ 163 167 if state == None or data == None: … … 197 201 self.is_state_data = False 198 202 199 203 def clear_panel(self, format='.svs'): 204 """ 205 Clear panel to defaults, used by set_state of manager 206 """ 207 if format == '.svs': 208 self._data = None 209 # default data testctrl 210 self.hint_msg_txt.SetLabel('') 211 data_name = '' 212 data_qmin = '' 213 data_qmax = '' 214 self.data_name_tcl.SetValue(str(data_name)) 215 self.data_min_tcl.SetLabel(str(data_qmin)) 216 self.data_max_tcl.SetLabel(str(data_qmax)) 217 #reset output textctrl 218 self._reset_output() 219 #reset panel 220 self.reset_panel() 221 #reset state w/o data 222 self.set_state() 223 # default flags for state 224 self.new_state = False 225 self.is_state_data = False 226 self.is_power_out = False 200 227 201 228 def get_background(self): … … 744 771 self.button_bookmark.Disable() 745 772 self.button_report.Disable() 773 self.button_save.Disable() 746 774 self.button_calculate.SetFocus() 747 775 #self.SetupScrolling() -
sansview/perspectives/fitting/fitpanel.py
r8897d66 r9b18735 187 187 self.Bind(basepage.EVT_NEXT_STATE, self._onRedo) 188 188 189 #add default page 190 from hint_fitpage import HintFitPage 191 self.hint_page = HintFitPage(self) 192 self.AddPage(page=self.hint_page, caption="Hint") 193 194 195 196 #Add the first fit page 197 self.add_empty_page() 189 #add default pages 190 self.add_default_pages() 198 191 199 192 # increment number for model name … … 203 196 self.Center() 204 197 198 def add_default_pages(self): 199 """ 200 Add default pages such as a hint page and an empty fit page 201 """ 202 #add default page 203 from hint_fitpage import HintFitPage 204 self.hint_page = HintFitPage(self) 205 self.AddPage(page=self.hint_page, caption="Hint") 206 207 #Add the first fit page 208 self.add_empty_page() 209 210 205 211 def close_all(self): 206 212 """ … … 241 247 panel.reset_page(state=state) 242 248 249 def clear_panel(self, format='.svs'): 250 """ 251 Clear and close all panels, used by guimanager 252 """ 253 if format == '.svs': 254 #close all panels only when svs file opened 255 self.close_all() 256 self.manager.mypanels = [] 257 243 258 def on_close_page(self, event=None): 244 259 """ … … 438 453 panel = self.add_page(page_info=page_info) 439 454 return panel 440 455 441 456 def _onGetstate(self, event): 442 457 """ -
sansview/perspectives/fitting/fitting.py
r3eb2811 r9b18735 261 261 loader.associate_file_reader(".fitv", self.state_reader) 262 262 loader.associate_file_reader(".svs", self.state_reader) 263 self.format = None 263 264 264 #Send the fitting panel to guiframe 265 265 self.mypanels.append(self.fit_panel) … … 295 295 pass 296 296 297 def set_state(self, state, datainfo=None , format=None):297 def set_state(self, state, datainfo=None): 298 298 """ 299 299 Call-back method for the fit page state reader. … … 302 302 : param state: PageState object 303 303 : param datainfo: data 304 : param format: file extension in lower case with dot in front305 304 """ 306 305 # store fitting state in temp_state … … 308 307 # index to start with for a new set_state 309 308 self.state_index = 0 310 #file format (extension of the file) opened311 self.format = format312 309 313 310 def on_set_state_helper(self,event=None): … … 315 312 Set_state_helper. This actually sets state after plotting data from state file. 316 313 317 : event: FitStateUpdateEvent called by plot_data from guiframe, data_loader314 : event: FitStateUpdateEvent called by dataloader.plot_data from guiframe 318 315 """ 319 316 if self.temp_state == None or len(self.temp_state) == 0: 317 if self.state_index==0 and len(self.mypanels) <= 0: 318 self.fit_panel.add_default_pages() 320 319 return 321 320 322 321 try: 323 #close all panels only when svs file opened324 if self.format == '.svs':325 self.fit_panel.close_all()326 322 # Load fitting state 327 323 state = self.temp_state[self.state_index] … … 333 329 #just set data because set_state won't work 334 330 page_info = self.fit_panel.get_page_info(data=state.data) 335 self.fit_panel.add_page(page_info) 331 panel = self.fit_panel.add_page(page_info) 332 self.store_page(page=panel, data=state.data) 336 333 337 # get ready for the next set 334 # get ready for the next set_state 338 335 self.state_index += 1 339 336 340 337 #reset state variables to default when all set_state is finished. 341 338 if len(self.temp_state) == self.state_index: 339 342 340 self.temp_state = [] 343 341 # Make sure the user sees the fitting panel after loading … … 345 343 except: 346 344 self.temp_state = [] 347 self.format = None348 345 raise 349 346 -
sansview/perspectives/fitting/pagestate.py
r8897d66 r9b18735 1158 1158 state.data.group_id = name 1159 1159 #store state in fitting 1160 self.call_back(state=state, datainfo=output[ind] , format=extension.lower())1160 self.call_back(state=state, datainfo=output[ind]) 1161 1161 1162 1162 return output
Note: See TracChangeset
for help on using the changeset viewer.