- Timestamp:
- Jul 26, 2010 5:24:49 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:
- 343fdb6
- Parents:
- 55f5a77
- Location:
- guiframe
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
guiframe/data_loader.py
r4e9583c raebc4cc 191 191 ## name of the data allow to differentiate data when plotted 192 192 name = parse_name(name=output.filename, expression="_") 193 if not name in parent.indice_load_data.keys():194 parent.indice_load_data[name] = 0195 else:193 #if not name in parent.indice_load_data.keys(): 194 # parent.indice_load_data[name] = 0 195 #else: 196 196 ## create a copy of the loaded data 197 parent.indice_load_data[name] += 1198 name = name +"[%i]"%parent.indice_load_data[name]197 # parent.indice_load_data[name] += 1 198 # name = name +"[%i]"%parent.indice_load_data[name] 199 199 200 200 new_plot.name = name … … 222 222 #add this plot the an existing panel 223 223 new_plot.group_id = existing_panel.group_id 224 wx.PostEvent(parent, NewPlotEvent(plot=new_plot, title=title)) 225 224 parent.set_loaded_data(data_list=[(new_plot, path)]) 226 225 ## the output of the loader is a list , some xml files contain more than one data 227 226 else: … … 279 278 #add this plot the an existing panel 280 279 new_plot.group_id = existing_panel.group_id 281 wx.PostEvent(parent, NewPlotEvent(plot=new_plot, title=str(title)))280 parent.set_loaded_data(data_list=[(new_plot, path)]) 282 281 i+=1 283 282 -
guiframe/data_manager.py
r4e9583c raebc4cc 23 23 def __init__(self, parent): 24 24 """ 25 Initialize the class. This class is binded with event sent by 26 sans.guiframe.data_loader, sans.perspective.theoryview.theory 27 to collected data created and loaded data. 25 Store opened path and data object created at the loading time 26 """ 27 self.loaded_data_list = [] 28 self.created_data_list = [] 29 self.list_of_data = [] 30 self.message = "" 28 31 29 30 attribute:: available_data is dictionary of data 31 attribute:: data_to_plot dictionary of data to plot automatically 32 attribute:: sorted_data is a list of tuples containing data's name, 33 data's type(Data1D, Data2, Theory1D, Theory2D), data of 34 modification etc. 35 :param parent: is the class that instantiates this object. 36 for sansview :parent is gui_manager 32 def get_message(self): 37 33 """ 38 self.available_data = {} 39 self.sorted_data = {} 40 self.selected_data_list = [] 41 #gui manager 42 self.parent = parent 43 44 def get_data(self, data_list={}): 34 return message 35 """ 36 return self.message 37 38 def set_loaded_data(self, data_list=[]): 39 """ 40 save data and path 41 """ 42 if not data_list: 43 return 44 else: 45 for data, path in data_list: 46 if data.name not in self.list_of_data: 47 self.loaded_data_list.append((data, path)) 48 self.list_of_data.append(data.name) 49 else: 50 self.message += " %s already loaded"%str(data.name) 51 52 def set_created_data(self, data_list=[]): 45 53 """ 46 54 return 47 55 """ 48 if not data_list:49 return self.available_data.values()50 56 for data, path in data_list: 51 if data.name not in self.available_data.keys(): 52 self.available_data[data.name] = (data, path) 53 return self.available_data.values() 57 for created_data, created_path in self.created_data_list: 58 if data.name == created_data.name: 59 self.message += " %s already created"%str(data.name) 60 else: 61 self.created_data_list.append((data, path)) 54 62 55 def on_get_data(self, data_list, plot=False):63 def get_data(self): 56 64 """ 57 This method is a handler to an event sent by data_loader or theory 58 perspective. It gets a list of data object through that event 59 and stores that list into available_data dictionary. Only new data are 60 stored. 65 Send list of available data 66 """ 67 return self.loaded_data_list + self.created_data_list 61 68 62 param event: contains a list of data. The size of the list is >= 163 """64 for data, path in data_list:65 if data.name not in self.available_data.keys():66 self.available_data[data.name] = (data, path)67 if plot:68 self.data_to_plot[data.name] = (data, path)69 70 return self.get_sorted_list()71 72 def sort_data(self):73 """74 Get the dictionary of data and created a list of turple of data's name,75 data's type(Data1D, Data2, Theory1D, Theory2D), data of76 modification etc.77 In other words extra data from available_data dictionary and create78 sorted_data_list.79 """80 self.sorted_data = {}81 index = 182 for data, path in self.available_data.values():83 self.sorted_data[index]= (data.name, data.__class__.__name__,84 "created on...", path)85 index += 186 return self.sorted_data.values()87 88 def get_sorted_list(self):89 """90 Return a list of turple of data sorted91 return: sorted_data_list .92 """93 return self.sort_data()94 95 def remove_data(self, data_name_list):96 """97 Remove data which names are in data_name_list from available_data and98 sorted_data_list. Post an event to all perspectives(including plotting99 perspective) to remove all reference of these data from themselves .100 101 param data_name_list: a list containing names of data to remove from102 the whole application.103 """104 for data_name in data_name_list:105 del self.available_data[data_name]106 del self.data_to_plot[data_name]107 return self.get_sorted_list()108 109 def post_data(self, data_name_list, perspective=None,plot=False):110 """111 Set data from available_data for with the name is in data_name_list112 and post these data to the current active perspective113 """114 self.selected_data_list = []115 for data_name in data_name_list:116 self.selected_data_list.append(self.available_data[data_name])117 self.parent.post_data(list_of_data=self.selected_data_list,118 perspective=perspective,plot=plot)119 120 def get_selected_data(self):121 """122 """123 return self.selected_data_list124 125 -
guiframe/gui_manager.py
r4e9583c raebc4cc 42 42 import config 43 43 44 import warnings 45 warnings.simplefilter("ignore") 46 47 import logging 48 from sans.guicomm.events import NewLoadedDataEvent 44 49 from sans.guicomm.events import EVT_STATUS 45 50 from sans.guicomm.events import EVT_NEW_PLOT,EVT_SLICER_PARS_UPDATE 46 51 from sans.guicomm.events import EVT_ADD_MANY_DATA 47 import warnings 48 warnings.simplefilter("ignore") 49 50 import logging 52 53 54 from data_manager import DataManager 51 55 52 56 def quit_guiframe(parent=None): … … 226 230 ## Application manager 227 231 self.app_manager = None 232 233 ## Data Manager 234 self.data_manager = DataManager(parent=self) 228 235 229 236 ## Find plug-ins … … 698 705 self._mgr.Update() 699 706 707 def set_loaded_data(self, data_list=[]): 708 """ 709 Save data and path in to data manager 710 """ 711 self.data_manager.set_loaded_data(data_list=data_list) 712 713 def get_data_manager(self): 714 """ 715 return data manager instance 716 """ 717 return self.data_manager 718 700 719 def _on_open(self, event): 701 720 """ … … 708 727 if path and os.path.isfile(path): 709 728 plot_data(self, path) 710 729 data_list = self.data_manager.get_data() 730 731 if self.defaultPanel is not None and \ 732 self._mgr.GetPane(self.panels["default"].window_name).IsShown(): 733 self.on_close_welcome_panel() 734 else: 735 for item in self.panels.keys(): 736 # Check whether this is a sticky panel 737 if hasattr(self.panels[item], "ALWAYS_ON"): 738 if self.panels[item].ALWAYS_ON: 739 continue 740 if self._mgr.GetPane(self.panels[item].window_name).IsShown(): 741 self.panels[item].set_data(list=data_list) 742 711 743 def _onClose(self, event): 712 744 """ … … 864 896 if not self._mgr.GetPane(self.panels[item].window_name).IsShown(): 865 897 self._mgr.GetPane(self.panels[item].window_name).Show() 898 list_of_data = self.data_manager.get_data() 899 self.panels[item].set_data(list=list_of_data) 866 900 else: 867 901 if self._mgr.GetPane(self.panels[item].window_name).IsShown(): 868 902 self._mgr.GetPane(self.panels[item].window_name).Hide() 869 903 870 904 self._mgr.Update() 871 905
Note: See TracChangeset
for help on using the changeset viewer.