- Timestamp:
- Jan 31, 2011 11:36:01 AM (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:
- 0663dfb1
- Parents:
- 3f6508f
- Location:
- guiframe
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
guiframe/data_manager.py
r584c4c4 r213892bc 47 47 self._selected_data[data.id] = data_state 48 48 self.stored_data[data.id] = data_state 49 print "datalist", self._selected_data 50 49 51 50 def set_auto_plot(self, flag=False): 52 51 """ … … 78 77 return self._selected_data 79 78 79 def append_theory(self, data_id, theory): 80 """ 81 """ 82 print "append theory", self.stored_data, data_id 83 if data_id in self.stored_data: 84 data_state = self.stored_data[data_id] 85 data_state.set_theory(theory) 86 87 def delete_data(self, data_id, theory_id, delete_all): 88 """ 89 """ 90 #for id in 80 91 def delete_by_id(self, id_list=None): 81 92 """ -
guiframe/data_panel.py
r584c4c4 r213892bc 192 192 193 193 self.bt_append_plot = wx.Button(self, wx.NewId(), "Append Plot To") 194 self.bt_ import.SetToolTipString("Plot the selected data in the active panel")195 #wx.EVT_BUTTON(self, self.bt_import.GetId(), self.on_append_plot)194 self.bt_append_plot.SetToolTipString("Plot the selected data in the active panel") 195 wx.EVT_BUTTON(self, self.bt_append_plot.GetId(), self.on_append_plot) 196 196 197 197 self.bt_plot = wx.Button(self, wx.NewId(), "New Plot") … … 205 205 self.tctrl_perspective = wx.StaticText(self, -1, 'No Active Application') 206 206 self.tctrl_perspective.SetToolTipString("Active Application") 207 self.tctrl_plotpanel = wx.StaticText(self, -1, ' Plot panel on focus')208 self.tctrl_plotpanel.SetToolTipString("Active Plot tingPanel")207 self.tctrl_plotpanel = wx.StaticText(self, -1, 'No Plot panel on focus') 208 self.tctrl_plotpanel.SetToolTipString("Active Plot Panel") 209 209 #self.sizer3.AddMany([(self.bt_import,0, wx.ALL,5), 210 210 # (self.bt_append_plot,0, wx.ALL,5), … … 296 296 297 297 """ 298 print "list", list299 298 if not list: 300 299 return … … 366 365 for item in self.list_cb_data: 367 366 if item.IsChecked(): 367 368 368 data_to_plot.append(self.tree_ctrl.GetItemPyData(item)) 369 369 theory_to_plot = [] 370 370 for item in self.list_cb_theory: 371 371 if item.IsChecked(): 372 theory_to_plot.append(self.tree_ctrl.GetItemPyData(item))372 theory_to_plot.append(self.tree_ctrl.GetItemPyData(item)) 373 373 return data_to_plot, theory_to_plot 374 374 … … 379 379 self.tree_ctrl.GetItemText(item) in data_to_remove: 380 380 self.tree_ctrl.Delete(item) 381 for i in self.list_cb_theory:381 for item in self.list_cb_theory: 382 382 if item.IsChecked()and \ 383 383 self.tree_ctrl.GetItemText(item) in theory_to_remove: 384 384 self.tree_ctrl.Delete(item) 385 self.manager.delete_data(data_name=data_to_remove, 386 theory_name=theory_to_remove) 385 delete_all = False 386 if data_to_remove: 387 delete_all = True 388 self.parent.delete_data(data_id=data_to_remove, 389 theory_id=theory_to_remove, 390 delete_all=delete_all) 387 391 388 392 def on_import(self, event=None): … … 391 395 """ 392 396 self.post_helper(plot=False) 393 397 398 def on_append_plot(self, event=None): 399 """ 400 append plot to plot panel on focus 401 """ 402 self.post_helper(plot=True, append=True) 403 394 404 def on_plot(self, event=None): 395 405 """ … … 410 420 self.tctrl_plotpanel.SetLabel(str(name)) 411 421 412 def post_helper(self, plot=False ):422 def post_helper(self, plot=False, append=False): 413 423 """ 414 424 """ … … 416 426 417 427 if self.parent is not None: 418 self.parent.get_data_from_panel(data_id=data_to_plot, plot=plot) 428 self.parent.get_data_from_panel(data_id=data_to_plot, plot=plot, 429 append=append) 419 430 420 431 -
guiframe/gui_manager.py
r584c4c4 r213892bc 53 53 54 54 55 55 56 class ViewerFrame(wx.Frame): 56 57 """ … … 91 92 self.app_manager = None 92 93 self._mgr = None 93 #data manager94 from data_manager import DataManager95 self._data_manager = DataManager()96 self._data_panel = DataPanel(parent=self)97 98 94 #add current perpsective 99 95 self._current_perspective = None … … 128 124 #panel on focus 129 125 self.panel_on_focus = None 126 #data manager 127 from data_manager import DataManager 128 self._data_manager = DataManager() 129 self._data_panel = DataPanel(parent=self) 130 if self.panel_on_focus is not None: 131 self._data_panel.set_panel_on_focus(self.panel_on_focus.window_name) 130 132 # Check for update 131 133 #self._check_update(None) … … 141 143 Store reference to the last panel on focus 142 144 """ 145 print "set_panel_on_focus", event.panel 143 146 self.panel_on_focus = event.panel 144 147 if self.panel_on_focus is not None and self._data_panel is not None: 148 self._data_panel.set_panel_on_focus(self.panel_on_focus.window_name) 149 145 150 def build_gui(self): 146 151 """ … … 434 439 BestSize(wx.Size(PLOPANEL_WIDTH, PLOPANEL_HEIGTH))) 435 440 self._popup_fixed_panel(p) 436 441 437 442 elif style2 in GUIFRAME.FLOATING_PANEL: 438 443 self._mgr.AddPane(p, wx.aui.AuiPaneInfo(). … … 673 678 if plug.can_load_data(): 674 679 plug.load_data(event) 680 self.show_data_panel(event=None) 681 print "_load_data" 675 682 676 683 def _load_folder(self, event): … … 682 689 if plug.can_load_data(): 683 690 plug.load_folder(event) 691 self.show_data_panel(event=None) 684 692 685 693 def _on_status_event(self, evt): … … 1008 1016 return path 1009 1017 1010 def show_data_panel(self, event ):1018 def show_data_panel(self, event=None): 1011 1019 """ 1012 1020 show the data panel 1013 1021 """ 1014 1022 pane = self._mgr.GetPane(self.panels["data_panel"].window_name) 1015 if not pane.IsShown():1016 1017 1023 #if not pane.IsShown(): 1024 pane.Show(True) 1025 self._mgr.Update() 1018 1026 1019 1027 def add_data(self, data_list): … … 1041 1049 self.set_data(data_list) 1042 1050 1043 def get_data_from_panel(self, data_id, plot=False ):1051 def get_data_from_panel(self, data_id, plot=False,append=False): 1044 1052 """ 1045 1053 receive a list of data key retreive the data from data manager and set … … 1051 1059 data_list.append(data_state.data) 1052 1060 if plot: 1053 self.plot_data(data_list )1061 self.plot_data(data_list, append=append) 1054 1062 else: 1055 1063 #sent data to active application … … 1071 1079 logging.info(msg) 1072 1080 1073 def plot_data(self, data_list ):1081 def plot_data(self, data_list, append=False): 1074 1082 """ 1075 1083 send a list of data to plot 1076 1084 """ 1085 if not data_list: 1086 message = "Please check data to plot or append" 1087 wx.PostEvent(self, StatusEvent(status=message, info='warning')) 1088 return 1077 1089 for new_plot in data_list: 1078 1090 if append: 1091 if self.panel_on_focus is None: 1092 message = "cannot append plot. No plot panel on focus!" 1093 message += "please click on any available plot to set focus" 1094 wx.PostEvent(self, StatusEvent(status=message, 1095 info='warning')) 1096 return 1097 else: 1098 if self.enable_add_data(new_plot): 1099 new_plot.group_id = self.panel_on_focus.group_id 1079 1100 wx.PostEvent(self, NewPlotEvent(plot=new_plot, 1080 1101 title=str(new_plot.title))) 1081 1102 1103 def add_theory(self, data_id, theory): 1104 """ 1105 """ 1106 self._data_manager.append_theory(data_id, theory) 1107 style = self.__gui_style & GUIFRAME.MANAGER_ON 1108 if style == GUIFRAME.MANAGER_ON: 1109 if self._data_panel is not None: 1110 data_state = self._data_manager.get_by_id([data_id]) 1111 self._data_panel.load_data_list(data_state) 1112 1113 def delete_data(self, data_id, theory_id=None, delete_all=True): 1114 """ 1115 Delete data state if data_id is provide 1116 delete theory created with data of id data_id if theory_id is provide 1117 if delete all true: delete the all state 1118 else delete theory 1119 """ 1120 self._data_manager.delete_data(data_id=data_id, 1121 theory_id=theory_id, 1122 delete_all=delete_all) 1123 1082 1124 def set_current_perspective(self, perspective): 1083 1125 """ … … 1091 1133 self._data_panel.set_active_perspective(name) 1092 1134 1093 def set_plotpanel_floating(self, event ):1135 def set_plotpanel_floating(self, event=None): 1094 1136 """ 1095 1137 make the plot panel floatable … … 1102 1144 self._popup_floating_panel(p) 1103 1145 1104 def set_plotpanel_fixed(self, event ):1146 def set_plotpanel_fixed(self, event=None): 1105 1147 """ 1106 1148 make the plot panel fixed … … 1140 1182 self._mgr.GetPane(p.window_name).Show(flag) 1141 1183 self._mgr.Update() 1184 1185 def enable_add_data(self, new_plot): 1186 """ 1187 Enable append data on a plot panel 1188 """ 1189 is_theory = len(self.panel_on_focus.plots) <= 1 and \ 1190 self.panel_on_focus.plots.values()[0].__class__.__name__ == "Theory1D" 1191 1192 is_data2d = hasattr(new_plot, 'data') 1193 is_data1d = self.panel_on_focus.__class__.__name__ == "ModelPanel1D"\ 1194 and self.panel_on_focus.group_id is not None 1195 has_meta_data = hasattr(new_plot, 'meta_data') 1196 1197 #disable_add_data if the data is being recovered from a saved state file. 1198 is_state_data = False 1199 if has_meta_data: 1200 if 'invstate' in new_plot.meta_data: is_state_data = True 1201 if 'prstate' in new_plot.meta_data: is_state_data = True 1202 if 'fitstate' in new_plot.meta_data: is_state_data = True 1203 1204 return is_data1d and not is_data2d and not is_theory and not is_state_data 1142 1205 1143 1206 class DefaultPanel(wx.Panel):
Note: See TracChangeset
for help on using the changeset viewer.