Changeset 6d727ae in sasview
- Timestamp:
- Mar 29, 2011 4:25:54 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:
- 3b72b36
- Parents:
- 59fbcff
- Location:
- guiframe
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
guiframe/data_panel.py
r91bdf87 r6d727ae 22 22 PANEL_WIDTH = 200 23 23 #PANEL_HEIGHT = 560 24 PANEL_HEIGHT = 8 0024 PANEL_HEIGHT = 840 25 25 STYLE_FLAG = wx.SUNKEN_BORDER|CT.TR_HAS_BUTTONS| CT.TR_HIDE_ROOT|\ 26 26 wx.WANTS_CHARS|CT.TR_HAS_VARIABLE_ROW_HEIGHT -
guiframe/gui_manager.py
r29ef718 r6d727ae 149 149 self.panel_on_focus = None 150 150 self.loader = Loader() 151 151 #data manager 152 152 from data_manager import DataManager 153 153 self._data_manager = DataManager() … … 155 155 if self.panel_on_focus is not None: 156 156 self._data_panel.set_panel_on_focus(self.panel_on_focus.window_caption) 157 # list of plot panels in schedule to full redraw 158 self.schedule = False 159 #self.callback = True 160 self._idle_count = 0 161 self.schedule_full_draw_list = [] 162 self.idletimer = wx.CallLater(1, self._onDrawIdle) 163 157 164 # Check for update 158 165 #self._check_update(None) … … 551 558 # Use a large best size to make sure the AUI 552 559 # manager takes all the available space 553 BestSize(wx.Size(PLOPANEL_WIDTH, PLOPANEL_HEIGTH))) 560 BestSize(wx.Size(PLOPANEL_WIDTH, PLOPANEL_HEIGTH)). 561 MinSize(wx.Size(PLOPANEL_WIDTH*0.9, PLOPANEL_HEIGTH))) 554 562 self._popup_fixed_panel(p) 555 563 … … 921 929 922 930 """ 923 self.show_panel(evt.GetId()) 931 self.show_panel(evt.GetId(), 'on') 932 wx.CallLater(5, self.set_schedule(True)) 924 933 925 934 def on_close_welcome_panel(self): … … 953 962 self._mgr.Update() 954 963 955 def show_panel(self, uid ):964 def show_panel(self, uid, show=None): 956 965 """ 957 966 Shows the panel with the given id … … 963 972 config.printEVT("show_panel: %s" % ID) 964 973 if ID in self.panels.keys(): 965 if not self._mgr.GetPane(self.panels[ID].window_name).IsShown(): 966 self._mgr.GetPane(self.panels[ID].window_name).Show() 974 if not self._mgr.GetPane(self.panels[ID].window_name).IsShown(): 975 if show == 'on': 976 self._mgr.GetPane(self.panels[ID].window_name).Show() 977 elif self.panels[ID].window_name.split(" ")[0] == "Residuals": 978 self._mgr.GetPane(self.panels[ID].window_name).Hide() 979 else: 980 self._mgr.GetPane(self.panels[ID].window_name).Show() 967 981 # Hide default panel 968 982 self._mgr.GetPane(self.panels["default"].window_name).Hide() 969 self._mgr.Update() 970 983 self._mgr.Update() 984 self._redraw_idle() 985 971 986 def hide_panel(self, uid): 972 987 """ … … 1794 1809 if self.panel_on_focus is not None: 1795 1810 self._toolbar.enable_reset(self.panel_on_focus) 1811 1812 def set_schedule_full_draw(self, panel=None, func='del'): 1813 """ 1814 Add/subtract the schedule full draw list with the panel given 1815 1816 :param panel: plot panel 1817 :param func: append or del [string] 1818 """ 1819 1820 # append this panel in the schedule list if not in yet 1821 if func == 'append': 1822 if not panel in self.schedule_full_draw_list: 1823 self.schedule_full_draw_list.append(panel) 1824 # remove this panel from schedule list 1825 elif func == 'del': 1826 if len(self.schedule_full_draw_list) > 0: 1827 if panel in self.schedule_full_draw_list: 1828 self.schedule_full_draw_list.remove(panel) 1829 1830 # reset the schdule 1831 if len(self.schedule_full_draw_list) == 0: 1832 self.schedule = False 1833 else: 1834 self.schedule = True 1835 1836 def full_draw(self): 1837 """ 1838 Draw the panels with axes in the schedule to full dwar list 1839 """ 1840 count = len(self.schedule_full_draw_list) 1841 #if not self.schedule: 1842 if count < 1: 1843 self.set_schedule(False) 1844 return 1845 else: 1846 ind = 0 1847 # if any of the panel is shown do full_draw 1848 for panel in self.schedule_full_draw_list: 1849 ind += 1 1850 if self._mgr.GetPane(panel.window_name).IsShown(): 1851 break 1852 # otherwise, return 1853 if ind == count: 1854 return 1855 1856 #Simple redraw only for a panel shown 1857 def f_draw(panel): 1858 """ 1859 Draw A panel in the full dwar list 1860 """ 1861 # Check if the panel is shown 1862 if self._mgr.GetPane(panel.window_name).IsShown(): 1863 try: 1864 # This checking of GetCapture is to stop redrawing 1865 # while any panel is capture. 1866 if self.GetCapture() == None: 1867 # draw if possible 1868 panel.set_resizing(False) 1869 panel.draw_plot() 1870 except: 1871 pass 1872 #print self.callback,self.schedule,self.schedule_full_draw_list 1873 1874 # Draw all panels 1875 map(f_draw, self.schedule_full_draw_list) 1876 1877 # Reset the attr 1878 if len(self.schedule_full_draw_list) == 0: 1879 self.set_schedule(False) 1880 else: 1881 self.set_schedule(True) 1882 # update mgr 1883 self._mgr.Update() 1884 1885 def set_schedule(self, schedule=False): 1886 """ 1887 Set schedule 1888 """ 1889 self.schedule = schedule 1890 1891 def get_schedule(self): 1892 """ 1893 Get schedule 1894 """ 1895 return self.schedule 1896 1897 1898 def _onDrawIdle(self, *args, **kwargs): 1899 """ 1900 ReDraw with axes 1901 """ 1902 # check if it is time to redraw 1903 if self.GetCapture() == None: 1904 # Draw plot, changes resizing too 1905 self.full_draw() 1906 1907 # restart idle 1908 self._redraw_idle(*args, **kwargs) 1909 1910 1911 def _redraw_idle(self, *args, **kwargs): 1912 """ 1913 Restart Idle 1914 """ 1915 # restart idle 1916 self.idletimer.Restart(55, *args, **kwargs) 1917 1796 1918 1797 1919 class DefaultPanel(wx.Panel, PanelBase): -
guiframe/gui_toolbar.py
recc85443 r6d727ae 36 36 """ 37 37 """ 38 tbar_size = (2 2, 22)38 tbar_size = (20, 15) 39 39 button_type = wx.ITEM_NORMAL 40 40 -
guiframe/local_perspectives/plotting/Plotter1D.py
ra3c96f7a r6d727ae 81 81 self.graph.yaxis("\\rm{Intensity} ", "cm^{-1}") 82 82 self.graph.render(self) 83 84 # In resizing event 85 self.resizing = False 86 self.canvas.set_resizing(self.resizing) 87 self.Bind(wx.EVT_SIZE, self._OnReSize) 83 88 84 89 def get_symbol_label(self): … … 88 93 _labels = {} 89 94 i = 0 90 _labels[' Points'] = i91 i += 1 92 _labels[' X '] = i95 _labels['Circle'] = i 96 i += 1 97 _labels['Cross X '] = i 93 98 i += 1 94 99 _labels['Triangle Down'] = i … … 100 105 _labels['Triangle Right'] = i 101 106 i += 1 102 _labels[' Plus'] = i107 _labels['Cross +'] = i 103 108 i += 1 104 109 _labels['Square'] = i 105 110 i += 1 106 _labels['Thin Diamond'] = i107 i += 1108 111 _labels['Diamond'] = i 109 112 i += 1 113 _labels['Diamond'] = i 114 i += 1 110 115 _labels['Hexagon1'] = i 111 116 i += 1 … … 114 119 _labels['Pentagon'] = i 115 120 i += 1 116 _labels[' Curve'] = i121 _labels['Line'] = i 117 122 return _labels 118 123 … … 129 134 self.graph.reset() 130 135 self.plots = {} 131 136 137 def _OnReSize(self, event): 138 """ 139 On response of the resize of a panel, set axes_visiable False 140 """ 141 # ready for another event 142 event.Skip() 143 # set the resizing flag 144 self.resizing = True 145 self.canvas.set_resizing(self.resizing) 146 self.parent.set_schedule(True) 147 148 149 def set_resizing(self, resizing=False): 150 """ 151 Set the resizing (True/False) 152 """ 153 self.resizing = resizing 154 #self.canvas.set_resizing(resizing) 155 156 def schedule_full_draw(self, func='append'): 157 """ 158 Put self in schedule to full redraw list 159 """ 160 # append/del this panel in the schedule list 161 self.parent.set_schedule_full_draw(self, func) 162 163 132 164 def remove_data_by_id(self, id): 133 165 """' … … 174 206 ## Set the view scale for all plots 175 207 self._onEVT_FUNC_PROPERTY() 176 ## render the graph 177 self.graph.render(self) 178 self.subplot.figure.canvas.draw_idle() 208 ## render the graph<=No need this done in canvas 209 #self.graph.render(self) 210 #self.subplot.figure.canvas.draw_idle() 211 212 def draw_plot(self): 213 """ 214 Draw plot 215 """ 216 self.draw() 217 179 218 180 219 … … 233 272 # Various plot options 234 273 id = wx.NewId() 235 self._slicerpop.Append(id, '&Save image', 'Save image as PNG')274 self._slicerpop.Append(id, '&Save Image', 'Save image as PNG') 236 275 wx.EVT_MENU(self, id, self.onSaveImage) 237 276 id = wx.NewId() 238 self._slicerpop.Append(id, '&Print image', 'Print image ')277 self._slicerpop.Append(id, '&Print Image', 'Print image ') 239 278 wx.EVT_MENU(self, id, self.onPrint) 240 279 id = wx.NewId() 241 self._slicerpop.Append(id, '&Print Preview', ' image preview for print')280 self._slicerpop.Append(id, '&Print Preview', 'Print preview') 242 281 wx.EVT_MENU(self, id, self.onPrinterPreview) 243 282 244 283 id = wx.NewId() 284 self._slicerpop.Append(id, '&Copy to Clipboard', 'Copy to the clipboard') 285 wx.EVT_MENU(self, id, self.OnCopyFigureMenu) 286 287 self._slicerpop.AppendSeparator() 288 245 289 #add menu of other plugins 246 290 item_list = self.parent.get_context_menu(self) 291 247 292 if (not item_list == None) and (not len(item_list) == 0): 248 293 for item in item_list: … … 257 302 pass 258 303 self._slicerpop.AppendSeparator() 259 id = wx.NewId() 260 261 self._slicerpop.Append(id, '&Print image', 'Print image') 304 #id = wx.NewId() 305 #self._slicerpop.Append(id, '&Print image', 'Print image') 262 306 if self.graph.selected_plottable in self.plots: 263 307 plot = self.plots[self.graph.selected_plottable] 308 309 id = wx.NewId() 310 self._slicerpop.Append(id, '&Linear Fit') 311 wx.EVT_MENU(self, id, self.onFitting) 312 self._slicerpop.AppendSeparator() 313 id = wx.NewId() 314 name = plot.name 315 self._slicerpop.Append(id, "&Save Points as a File") 316 wx.EVT_MENU(self, id, self._onSave) 317 id = wx.NewId() 318 self._slicerpop.Append(id, "Remove %s Curve" % name) 319 wx.EVT_MENU(self, id, self._onRemove) 264 320 if not plot.is_data: 265 321 id = wx.NewId() … … 274 330 self._slicerpop.AppendMenu(id,'&Modify Symbol', symbol_menu) 275 331 self._slicerpop.AppendSeparator() 276 #else: 277 id = wx.NewId() 278 self._slicerpop.Append(id, '&Linear Fit') 279 wx.EVT_MENU(self, id, self.onFitting) 280 id = wx.NewId() 281 name = plot.name 282 self._slicerpop.Append(id, "&Save points") 283 wx.EVT_MENU(self, id, self._onSave) 284 id = wx.NewId() 285 self._slicerpop.Append(id, "Remove %s curve" % name) 286 wx.EVT_MENU(self, id, self._onRemove) 332 287 333 id = wx.NewId() 288 334 self.hide_menu = self._slicerpop.Append(id, "Hide Error") … … 328 374 self._onEVT_FUNC_PROPERTY() 329 375 ## render the graph 330 self.graph.render(self)331 self.subplot.figure.canvas.draw_idle()376 #self.graph.render(self) 377 #self.subplot.figure.canvas.draw_idle() 332 378 333 379 def _onsaveTXT(self, path): … … 353 399 has_errors = False 354 400 if has_errors: 355 out.write("<X> <Y> <dY>\n") 401 if data.dx != None: 402 out.write("<X> <Y> <dY> <dX>\n") 403 else: 404 out.write("<X> <Y> <dY>\n") 356 405 else: 357 406 out.write("<X> <Y>\n") … … 359 408 for i in range(len(data.x)): 360 409 if has_errors: 361 out.write("%g %g %g\n" % (data.x[i], 362 data.y[i], 363 data.dy[i])) 410 if data.dx != None: 411 out.write("%g %g %g %g\n" % (data.x[i], 412 data.y[i], 413 data.dy[i], 414 data.dx[i])) 415 else: 416 out.write("%g %g %g\n" % (data.x[i], 417 data.y[i], 418 data.dy[i])) 364 419 else: 365 420 out.write("%g %g\n" % (data.x[i], -
guiframe/local_perspectives/plotting/Plotter2D.py
r003fa4e r6d727ae 194 194 self.graph.title(self.data2D.name) 195 195 self.graph.render(self) 196 self.subplot.figure.canvas.draw_idle() 196 self.draw_plot() 197 #self.subplot.figure.canvas.draw_idle() 197 198 ## store default value of zmin and zmax 198 199 self.default_zmin_ctl = self.zmin_2D … … 211 212 212 213 id = wx.NewId() 213 slicerpop.Append(id, '&Save image')214 slicerpop.Append(id, '&Save Image') 214 215 wx.EVT_MENU(self, id, self.onSaveImage) 215 216 216 217 id = wx.NewId() 217 slicerpop.Append(id,'&Print image', 'Print image')218 slicerpop.Append(id,'&Print Image', 'Print image') 218 219 wx.EVT_MENU(self, id, self.onPrint) 219 220 220 221 id = wx.NewId() 221 slicerpop.Append(id,'&Print Preview', ' image preview for print')222 slicerpop.Append(id,'&Print Preview', 'Print preview') 222 223 wx.EVT_MENU(self, id, self.onPrinterPreview) 223 224 … … 238 239 239 240 item_list = self.parent.get_context_menu(self) 240 if (not item_list == None) and (not len(item_list) == 0): 241 if (not item_list == None) and (not len(item_list) == 0) and\ 242 self.data2D.name.split(" ")[0] != 'Residuals': 243 # The line above; Not for trunk 241 244 for item in item_list: 242 245 try: … … 253 256 id = wx.NewId() 254 257 slicerpop.Append(id, '&Perform circular average') 255 wx.EVT_MENU(self, id, self.onCircular) 258 wx.EVT_MENU(self, id, self.onCircular) \ 259 # For Masked Data 260 if not plot.mask.all(): 261 id = wx.NewId() 262 slicerpop.Append(id, '&Masked circular average') 263 wx.EVT_MENU(self, id, self.onMaskedCircular) 256 264 id = wx.NewId() 257 265 slicerpop.Append(id, '&Sector [Q view]') … … 356 364 profiles and resetting the widgets. 357 365 """ 358 self.draw ()366 self.draw_plot() 359 367 360 368 def _getEmptySlicerEvent(self): … … 401 409 event.params = self.slicer.get_params() 402 410 wx.PostEvent(self, event) 403 404 def onCircular(self, event): 411 412 def onMaskedCircular(self, event): 413 """ 414 perform circular averaging on Data2D with mask if it exists 415 416 :param event: wx.menu event 417 418 """ 419 self.onCircular(event, True) 420 421 def onCircular(self, event, ismask=False): 405 422 """ 406 423 perform circular averaging on Data2D … … 424 441 Circle = CircularAverage(r_min=0, r_max=self.radius, 425 442 bin_width=bin_width) 426 circ = Circle(self.data2D )443 circ = Circle(self.data2D, ismask=ismask) 427 444 from sans.guiframe.dataFitting import Data1D 428 445 if hasattr(circ, "dxl"): … … 443 460 new_plot.interactive = True 444 461 new_plot.detector = self.data2D.detector 462 445 463 ## If the data file does not tell us what the axes are, just assume... 446 464 new_plot.xaxis("\\rm{Q}", "A^{-1}") 447 new_plot.yaxis("\\rm{Intensity} ", "cm^{-1}") 465 if hasattr(self.data2D, "scale"): 466 if self.data2D.scale == 'linear': 467 new_plot.ytransform = 'y' 468 new_plot.yaxis("\\rm{Residuals} ", "normalized") 469 else: 470 new_plot.yaxis("\\rm{Intensity} ", "cm^{-1}") 471 448 472 new_plot.group_id = "Circ avg " + self.data2D.name 449 473 new_plot.id = "Circ avg " + self.data2D.name -
guiframe/local_perspectives/plotting/plotting.py
r957723f r6d727ae 35 35 self._panel_on_focus = None 36 36 self.menu_default_id = None 37 # Plot menu 38 self.menu = None 39 37 40 38 41 def set_panel_on_focus(self, panel): … … 59 62 self.menu = wx.Menu() 60 63 self.menu.Append(DEFAULT_MENU_ITEM_ID, DEFAULT_MENU_ITEM_LABEL, 61 "No plotavailable")64 "No graph available") 62 65 self.menu.FindItemByPosition(0).Enable(False) 63 return [(self.menu, " Plot")]66 return [(self.menu, "Graph")] 64 67 65 68 def get_panels(self, parent): … … 135 138 self.menu.Delete(DEFAULT_MENU_ITEM_ID) 136 139 137 self.menu.Append (event_id, new_panel.window_caption,140 self.menu.AppendCheckItem(event_id, new_panel.window_caption, 138 141 "Show %s plot panel" % new_panel.window_caption) 142 self.menu.Check(event_id, True) 143 wx.EVT_MENU(self.parent, event_id, self._on_check_menu) 144 wx.EVT_SHOW(new_panel, self._on_close_panel) 139 145 # Set UID to allow us to reference the panel later 140 146 new_panel.uid = event_id … … 266 272 267 273 return 268 274 275 def _on_check_menu(self, event): 276 """ 277 Check mark on menu 278 """ 279 event.Skip() 280 event_id = event.GetId() 281 282 #self.menu.Enable(event_id, False) 283 self.parent._on_view(event) 284 if not self.menu.IsChecked(event_id): 285 self.menu.Check(event_id, True) 286 287 288 def _on_close_panel(self, event): 289 """ 290 Update check mark on panel's show and hide event 291 """ 292 event.Skip() 293 panel = event.GetEventObject() 294 id = panel.uid 295 if event.GetShow() and self.parent._mgr.GetPane(panel).IsShown(): 296 if not self.menu.IsChecked(id): 297 self.menu.Check(id, True) 298 #self.menu.Enable(id, False) 299 else: 300 try: 301 if self.menu.IsChecked(id): 302 self.menu.Check(id, False) 303 #self.menu.Enable(id, True) 304 except: 305 pass
Note: See TracChangeset
for help on using the changeset viewer.