Changeset 7858575 in sasview for src/sas/sasgui/perspectives/corfunc/corfunc.py
- Timestamp:
- Jul 11, 2016 4:36:55 AM (8 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, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 9f7dde3
- Parents:
- c23f303
- git-author:
- Lewis O'Driscoll <lewis.o'driscoll@…> (07/01/16 06:18:29)
- git-committer:
- Lewis O'Driscoll <lewis.o'driscoll@…> (07/11/16 04:36:55)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/corfunc/corfunc.py
rc23f303 r7858575 3 3 """ 4 4 import wx 5 import sys 5 6 import logging 6 7 from sas.sasgui.guiframe.plugin_base import PluginBase 7 8 from sas.sasgui.guiframe.gui_manager import MDIFrame 9 from sas.sasgui.guiframe.events import StatusEvent 10 from sas.sasgui.guiframe.events import NewPlotEvent 11 from sas.sasgui.guiframe.gui_style import GUIFRAME_ID 8 12 from sas.sasgui.perspectives.corfunc.corfunc_panel import CorfuncPanel 13 from sas.sasgui.guiframe.dataFitting import Data1D 14 from sas.sasgui.perspectives.pr.pr_widgets import DataDialog 15 16 17 GROUP_ID_IQ_DATA = r"$I_{obs}(q)$" 18 IQ_DATA_LABEL = r"$I_{obs}(q)$" 19 9 20 10 21 class Plugin(PluginBase): … … 25 36 self.parent = parent 26 37 self.frame = MDIFrame(self.parent, None, 'None', (100,200)) 27 # self.test_panel = PanelBase(parent=self.frame) 28 # self.test_panel.set_manager(self) 29 # self.frame.set_panel(self.test_panel) 30 # self.perspective.append("testwindow") 38 self.data_id = IQ_DATA_LABEL 31 39 self.corfunc_panel = CorfuncPanel(parent=self.frame) 32 40 self.frame.set_panel(self.corfunc_panel) … … 35 43 36 44 return [self.corfunc_panel] 45 46 def set_data(self, data_list=None): 47 """ 48 Load the data that's been selected 49 50 :param data_list: The data to load in 51 """ 52 if data_list is None: 53 data_list = [] 54 if len(data_list) >= 1: 55 if len(data_list) == 1: 56 data = data_list[0] 57 else: 58 data_1d_list = [] 59 data_2d_list = [] 60 err_msg = "" 61 62 for data in data_list: 63 if data is not None: 64 if issubclass(data.__class__, Data1D): 65 data_1d_list.append(data) 66 else: 67 err_msg += "{} type {} \n".format(str(data.name), 68 str(data.__class__)) 69 data_2d_list.append(data) 70 if len(data_2d_list) > 0: 71 msg = "Corfunc doesn't support the following data types:\n" 72 msg += err_msg 73 if len(data_1d_list) == 0: 74 msg += "No data recieved" 75 wx.PostEvent(self.parent, StatusEvent(status=msg, 76 info='error')) 77 return 78 elif len(data_list) > 1: 79 msg = "Corfunc does not allow multiple data\n" 80 msg += "Please select one.\n" 81 dlg = DataDialog(data_list=data_1d_list, text=msg) 82 if dlg.ShowModal() == wx.ID_OK: 83 data = dlg.get_data() 84 else: 85 data = None 86 dlg.Destroy() 87 88 if data is None: 89 msg += "Corfunc recieved no data\n" 90 wx.PostEvent(self.parent, StatusEvent(status=msg, 91 info='error')) 92 return 93 if issubclass(data.__class__, Data1D): 94 try: 95 wx.PostEvent(self.parent, NewPlotEvent(action='remove', 96 group_id=GROUP_ID_IQ_DATA, 97 id=self.data_id)) 98 self.data_id = data.id 99 self.corfunc_panel._set_data(data) 100 except: 101 msg = "Corfunc set_data: " + str(sys.exc_value) 102 wx.PostEvent(self.parent, StatusEvent(status=msg, 103 info='error')) 104 105 def show_data(self, path=None, data=None, reset=False): 106 """ 107 Show data read from a file 108 109 :param path: The path to the file 110 :param data: The data to plot (Data1D) 111 :param reset: If True, all other plottables will be cleared 112 """ 113 if data.dy is not None: 114 new_plot = Data1D(data.x, data.y, dy=data.dy) 115 else: 116 new_plot = Data1D(data.x, data.y) 117 new_plot.symbol = GUIFRAME_ID.CURVE_SYMBOL_NUM 118 new_plot.name = IQ_DATA_LABEL 119 new_plot.xaxis("\\rm{Q}", 'A^{-1}') 120 new_plot.yaxis("\\rm{Intensity} ", "cm^{-1}") 121 new_plot.interactive = True 122 new_plot.group_id = GROUP_ID_IQ_DATA 123 new_plot.id = self.data_id 124 new_plot.title = "I(q)" 125 wx.PostEvent(self.parent, 126 NewPlotEvent(plot=new_plot, title="I(q)", reset=reset))
Note: See TracChangeset
for help on using the changeset viewer.