Changeset 9c2eeb1 in sasview for src/sas/sasgui
- Timestamp:
- Jul 1, 2016 4:18:29 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:
- c1b06a9
- Parents:
- 646b896
- Location:
- src/sas/sasgui/perspectives/corfunc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/corfunc/corfunc.py
r646b896 r9c2eeb1 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)) -
src/sas/sasgui/perspectives/corfunc/corfunc_panel.py
r646b896 r9c2eeb1 3 3 from wx.lib.scrolledpanel import ScrolledPanel 4 4 from sas.sasgui.guiframe.panel_base import PanelBase 5 from sas.sasgui.perspectives.invariant.invariant_widgets import OutputTextCtrl 5 6 6 7 BACKGROUND = 0.0 7 8 if sys.platform.count("win32") > 0: 8 _STATICBOX_WIDTH = 4509 PANEL_WIDTH = 5009 _STATICBOX_WIDTH = 350 10 PANEL_WIDTH = 400 10 11 PANEL_HEIGHT = 700 11 12 FONT_VARIANT = 0 12 13 else: 13 _STATICBOX_WIDTH = 49014 PANEL_WIDTH = 53014 _STATICBOX_WIDTH = 390 15 PANEL_WIDTH = 430 15 16 PANEL_HEIGHT = 700 16 17 FONT_VARIANT = 1 … … 32 33 self._background = BACKGROUND 33 34 self.state = None 34 35 self._main_sizer = None36 37 35 self.set_state() 38 36 self._do_layout() … … 41 39 return False 42 40 41 def _set_data(self, data=None): 42 """ 43 Update the GUI to reflect new data that has been loaded in 44 45 :param data: The data that has been loaded 46 """ 47 self.data_name_box.SetValue(str(data.name)) 48 if self._manager is not None: 49 self._manager.show_data(data=data, reset=True) 50 51 43 52 def _do_layout(self): 44 53 """ 45 54 Draw the window content 46 55 """ 47 self._main_sizer = wx.BoxSizer(wx.HORIZONTAL) 48 txt = wx.StaticText(self, id=wx.NewId(), label="TODO: Add GUI", 49 style=wx.ALIGN_CENTRE_HORIZONTAL) 50 self._main_sizer.Add(txt, 1, wx.EXPAND) 51 self.SetSizer(self._main_sizer) 52 self.SetAutoLayout(True) 56 vbox = wx.GridBagSizer(0,0) 57 58 # I(q) data box 59 databox = wx.StaticBox(self, -1, "I(q) data source") 60 61 pars_sizer = wx.GridBagSizer(5, 5) 62 63 box_sizer1 = wx.StaticBoxSizer(databox, wx.VERTICAL) 64 box_sizer1.SetMinSize((350, 50)) 65 66 file_name_label = wx.StaticText(self, -1, "Name:") 67 pars_sizer.Add(file_name_label, (0, 0), (1, 1), 68 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 69 70 self.data_name_box = OutputTextCtrl(self, -1, size=(350,20)) 71 pars_sizer.Add(self.data_name_box, (0, 1), (1, 1), 72 wx.EXPAND | wx.LEFT | wx.RIGHT | wx.ADJUST_MINSIZE, 15) 73 74 box_sizer1.Add(pars_sizer, 0, wx.EXPAND) 75 vbox.Add(box_sizer1, (0, 0), (1, 1), 76 wx.LEFT | wx.RIGHT | wx.EXPAND | wx.ADJUST_MINSIZE | wx.TOP, 5) 77 78 self.SetSizer(vbox)
Note: See TracChangeset
for help on using the changeset viewer.