Changeset ae83ad3 in sasview
- Timestamp:
- Mar 10, 2011 11:53:13 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:
- 003fa4e
- Parents:
- d4bf55e9
- Location:
- guiframe
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
guiframe/data_manager.py
rc70eb7c rae83ad3 142 142 """ 143 143 if prev_data.id not in self.stored_data.keys(): 144 return {}144 return None, {} 145 145 data_state = self.stored_data[prev_data.id] 146 146 self.stored_data[new_data.id] = data_state.clone() -
guiframe/data_panel.py
rc70eb7c rae83ad3 499 499 del self.list_cb_data[state_id] 500 500 del self.list_cb_theory[data_id] 501 print "went here" 502 501 503 502 def on_remove(self, event): 504 503 """ -
guiframe/gui_manager.py
rc70eb7c rae83ad3 934 934 self._mgr.GetPane(self.panels["default"].window_name).Hide() 935 935 self._mgr.Update() 936 936 937 def hide_panel(self, uid): 938 """ 939 hide panel 940 """ 941 ID = str(uid) 942 config.printEVT("hide_panel: %s" % ID) 943 if ID in self.panels.keys(): 944 if self._mgr.GetPane(self.panels[ID].window_name).IsShown(): 945 self._mgr.GetPane(self.panels[ID].window_name).Hide() 946 # Hide default panel 947 self._mgr.GetPane(self.panels["default"].window_name).Hide() 948 self._mgr.Update() 949 print "gui_manager hide_panel" 950 937 951 def clear_panel(self): 938 952 """ … … 1389 1403 self.__gui_style |= GUIFRAME.FLOATING_PANEL 1390 1404 for p in self.panels.values(): 1391 plot_panel = self._plotting_plugin.plot_panels 1405 plot_panel = self._plotting_plugin.plot_panels.values() 1392 1406 for p in self.panels.values(): 1393 1407 if p in plot_panel: … … 1402 1416 plot_panel = [] 1403 1417 if self._plotting_plugin is not None: 1404 plot_panel = self._plotting_plugin.plot_panels 1418 plot_panel = self._plotting_plugin.plot_panels.values() 1405 1419 for p in self.panels.values(): 1406 1420 if p in plot_panel: -
guiframe/local_perspectives/plotting/plotting.py
rc70eb7c rae83ad3 29 29 30 30 ## Plot panels 31 self.plot_panels = [] 32 self.new_plot_panels = {} 31 self.plot_panels = {} 33 32 self._panel_on_focus = None 34 33 … … 76 75 pass 77 76 78 77 def remove_plot(self, group_id, id): 78 """ 79 remove plot of ID = id from a panel of group ID =group_id 80 """ 81 82 if group_id in self.plot_panels.keys(): 83 panel = self.plot_panels[group_id] 84 panel.remove_data_by_id(id=id) 85 return True 86 else: 87 msg = "Panel with GROUP_ID: %s cannot be located" % str(group_id) 88 raise ValueError, msg 89 90 def hide_panel(self, group_id): 91 """ 92 hide panel with group ID = group_id 93 """ 94 if group_id in self.plot_panels.keys(): 95 panel = self.plot_panels[group_id] 96 self.parent.hide_panel(panel.uid) 97 print "plotting hide_panel" 98 return True 99 return False 100 101 def create_panel_helper(self, new_panel, data, group_id): 102 """ 103 """ 104 ## Set group ID if available 105 ## Assign data properties to the new create panel 106 new_panel.set_manager(self) 107 new_panel.group_id = group_id 108 title = data.title 109 new_panel.window_caption = title 110 new_panel.window_name = title 111 event_id = self.parent.popup_panel(new_panel) 112 #remove the default item in the menu 113 if len(self.plot_panels) == 0: 114 self.menu.RemoveItem(self.menu.FindItemByPosition(0)) 115 self.menu.Append(event_id, new_panel.window_caption, 116 "Show %s plot panel" % new_panel.window_caption) 117 # Set UID to allow us to reference the panel later 118 new_panel.uid = event_id 119 # Ship the plottable to its panel 120 new_panel.plot_data(data) 121 self.plot_panels[new_panel.group_id] = new_panel 122 print "self.plot_panels.keys()", self.plot_panels.keys() 123 124 def create_1d_panel(self, data, group_id): 125 """ 126 """ 127 # Create a new plot panel if none was available 128 if issubclass(data.__class__, Data1D): 129 from Plotter1D import ModelPanel1D 130 ## get the data representation label of the data to plot 131 ## when even the user select "change scale" 132 xtransform = data.xtransform 133 ytransform = data.ytransform 134 ## create a plotpanel for 1D Data 135 new_panel = ModelPanel1D(self.parent, -1, xtransform=xtransform, 136 ytransform=ytransform, style=wx.RAISED_BORDER) 137 return new_panel 138 139 msg = "1D Panel of group ID %s could not be created" % str(group_id) 140 raise ValueError, msg 141 142 def create_2d_panel(self, data, group_id): 143 """ 144 """ 145 if issubclass(data.__class__, Data2D): 146 ##Create a new plotpanel for 2D data 147 from Plotter2D import ModelPanel2D 148 scale = data.scale 149 new_panel = ModelPanel2D(self.parent, id = -1, 150 data2d=data, scale = scale, 151 style=wx.RAISED_BORDER) 152 return new_panel 153 msg = "2D Panel of group ID %s could not be created" % str(group_id) 154 raise ValueError, msg 155 156 def update_panel(self, data, panel): 157 """ 158 update the graph of a given panel 159 """ 160 # Check whether we already have a graph with the same units 161 # as the plottable we just received. 162 _, x_unit = data.get_xaxis() 163 _, y_unit = data.get_yaxis() 164 if x_unit != panel.graph.prop["xunit"] \ 165 or y_unit != panel.graph.prop["yunit"]: 166 msg = "Cannot add %s" % str(data.name) 167 msg += " to panel %s\n" % str(panel.window_caption) 168 msg += "Please edit %s's units, labels" % str(data.name) 169 raise ValueError, msg 170 else: 171 panel.plot_data( data) 172 self.parent.show_panel(panel.uid) 173 79 174 def _on_plot_event(self, event): 80 175 """ … … 86 181 87 182 """ 88 if hasattr(event, 'remove'): 183 184 if hasattr(event, 'action'): 89 185 group_id = event.group_id 90 id = event.id 91 if group_id in self.new_plot_panels.keys(): 92 panel = self.new_plot_panels[group_id] 93 panel.remove_data_by_id(id=id) 94 else: 95 msg = "Panel with GROUP_ID: %s canot be located" % str(group_id) 96 raise ValueError, msg 97 return 98 # Check whether we already have a graph with the same units 99 # as the plottable we just received. 186 #remove data from panel 187 if event.action.lower() == 'remove': 188 id = event.id 189 return self.remove_plot(group_id, id) 190 if event.action.lower() == 'hide': 191 return self.hide_panel(group_id) 192 100 193 data = event.plot 101 102 194 group_id_list = data.group_id 103 195 group_id = None 104 196 if group_id_list: 105 197 group_id = group_id_list[len(group_id_list)-1] 106 if group_id in self.new_plot_panels.keys(): 107 panel = self.new_plot_panels[group_id] 108 _, x_unit = data.get_xaxis() 109 _, y_unit = data.get_yaxis() 110 111 if x_unit != panel.graph.prop["xunit"] \ 112 or y_unit != panel.graph.prop["yunit"]: 113 msg = "Cannot add %s" % str(data.name) 114 msg += " to panel %s\n" % str(panel.window_caption) 115 msg += "Please edit %s's units, labels" % str(data.name) 116 raise ValueError, msg 198 199 if group_id in self.plot_panels.keys(): 200 #update a panel graph 201 panel = self.plot_panels[group_id] 202 self.update_panel(data, panel) 203 else: 204 #create a new panel 205 if issubclass(data.__class__, Data1D): 206 new_panel = self.create_1d_panel(data, group_id) 117 207 else: 118 panel.plot_data( data) 119 self.parent.show_panel(panel.uid) 120 else: 121 # Create a new plot panel if none was available 122 if issubclass(data.__class__, Data1D): 123 from Plotter1D import ModelPanel1D 124 ## get the data representation label of the data to plot 125 ## when even the user select "change scale" 126 xtransform = data.xtransform 127 ytransform = data.ytransform 128 ## create a plotpanel for 1D Data 129 new_panel = ModelPanel1D(self.parent, -1, xtransform=xtransform, 130 ytransform=ytransform, style=wx.RAISED_BORDER) 131 new_panel.set_manager(self) 132 new_panel.group_id = group_id 133 elif issubclass(data.__class__, Data2D): 134 ##Create a new plotpanel for 2D data 135 from Plotter2D import ModelPanel2D 136 scale = data.scale 137 new_panel = ModelPanel2D(self.parent, id = -1, 138 data2d=event.plot, scale = scale, 139 style=wx.RAISED_BORDER) 140 new_panel.set_manager(self) 141 new_panel.group_id = group_id 142 else: 143 msg = "Plotting received unexpected" 144 msg += " data type : %s" % str(data.__class__) 145 raise ValueError, msg 146 ## Set group ID if available 147 ## Assign data properties to the new create panel 148 title = data.title 149 new_panel.window_caption = title 150 new_panel.window_name = title 151 event_id = self.parent.popup_panel(new_panel) 152 #remove the default item in the menu 153 if len(self.new_plot_panels) == 0: 154 self.menu.RemoveItem(self.menu.FindItemByPosition(0)) 155 self.menu.Append(event_id, new_panel.window_caption, 156 "Show %s plot panel" % new_panel.window_caption) 157 # Set UID to allow us to reference the panel later 158 new_panel.uid = event_id 159 # Ship the plottable to its panel 160 new_panel.plot_data(data) 161 self.plot_panels.append(new_panel) 162 self.new_plot_panels[new_panel.group_id] = new_panel 208 new_panel = self.create_2d_panel(data, group_id) 209 self.create_panel_helper(new_panel, data, group_id) 163 210 164 211 return -
guiframe/setup.py
rba924ed rae83ad3 10 10 import sys 11 11 12 if len(sys.argv) == 1: 13 sys.argv.append('install') 12 14 13 15 path = os.path.join(os.getcwd(), 'local_perspectives')
Note: See TracChangeset
for help on using the changeset viewer.