Changeset e02d8f6 in sasview for src/sas/sasgui/perspectives/corfunc
- 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:
- 9c90cf3
- Parents:
- 3901e7c
- git-author:
- Lewis O'Driscoll <lewis.o'driscoll@…> (07/06/16 11:20:28)
- git-committer:
- Lewis O'Driscoll <lewis.o'driscoll@…> (07/11/16 04:36:55)
- Location:
- src/sas/sasgui/perspectives/corfunc
- Files:
-
- 1 added
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/corfunc/corfunc.py
r2196f102 re02d8f6 13 13 from sas.sasgui.guiframe.dataFitting import Data1D 14 14 from sas.sasgui.perspectives.pr.pr_widgets import DataDialog 15 from sas.sasgui.perspectives.corfunc.corfunc_state import Reader 16 from sas.sascalc.dataloader.loader import Loader 17 import sas.sascalc.dataloader 15 18 16 19 … … 30 33 self._always_active = True 31 34 35 self.state_reader = Reader(self.set_state) 36 self._extensions = '.cor' 37 l = Loader() 38 l.associate_file_reader('.cor', self.state_reader) 39 32 40 def get_panels(self, parent): 33 41 """ … … 43 51 44 52 return [self.corfunc_panel] 53 54 def set_state(self, state=None, datainfo=None): 55 """ 56 Callback for CorfuncState reader. Called when a .cor file is loaded 57 """ 58 self.corfunc_panel.set_state(state=state, data=datainfo) 45 59 46 60 def set_data(self, data_list=None): … … 98 112 id=self.data_id)) 99 113 self.data_id = data.id 100 self.corfunc_panel. _set_data(data)114 self.corfunc_panel.set_data(data) 101 115 except: 102 116 msg = "Corfunc set_data: " + str(sys.exc_value) -
src/sas/sasgui/perspectives/corfunc/corfunc_panel.py
r3901e7c re02d8f6 9 9 from sas.sasgui.perspectives.invariant.invariant_widgets import InvTextCtrl 10 10 from sas.sasgui.perspectives.fitting.basepage import ModelTextCtrl 11 from sas.sasgui.perspectives.corfunc.corfunc_state import CorfuncState 11 12 12 13 if sys.platform.count("win32") > 0: … … 39 40 self._qmax1_input = None 40 41 self._qmax2_input = None 41 self. _qmin = 042 self. _qmax = (0, 0)42 self.qmin = 0 43 self.qmax = (0, 0) 43 44 # Dictionary for saving IDs of text boxes used to display output data 44 45 self._output_ids = None 45 46 self.state = None 47 self._do_layout() 46 48 self.set_state() 47 self._do_layout()48 49 self._qmin_input.Bind(wx.EVT_TEXT, self._on_enter_qrange) 49 50 self._qmax1_input.Bind(wx.EVT_TEXT, self._on_enter_qrange) … … 51 52 52 53 def set_state(self, state=None, data=None): 53 # TODO: Implement state restoration 54 return False 54 if state is None: 55 self.state = CorfuncState() 56 else: 57 self.state = state 58 if data is not None: 59 self.state.data = data 60 self.set_data(self.state.data, set_qrange=False) 61 if self.state.qmin is not None: 62 self.set_qmin(self.state.qmin) 63 if self.state.qmax is not None and self.state.qmax != (None, None): 64 self.set_qmax(tuple(self.state.qmax)) 65 66 def get_state(self): 67 """ 68 Return the state of the panel 69 """ 70 state = CorfuncState() 71 state.set_saved_state('qmin_tcl', self.qmin) 72 state.set_saved_state('qmax1_tcl', self.qmax[0]) 73 state.set_saved_state('qmax2_tcl', self.qmax[1]) 74 if self._data is not None: 75 state.file = self._data.title 76 state.data = self._data 77 self.state = state 78 79 return self.state 55 80 56 81 def onSetFocus(self, evt): … … 59 84 self._validate_qrange() 60 85 61 def _set_data(self, data=None):86 def set_data(self, data=None, set_qrange=True): 62 87 """ 63 88 Update the GUI to reflect new data that has been loaded in … … 65 90 :param data: The data that has been loaded 66 91 """ 67 self._data_name_box.SetValue(str(data.name)) 92 if data is None: 93 return 94 self._data_name_box.SetValue(str(data.title)) 68 95 self._data = data 69 96 if self._manager is not None: 70 97 self._manager.show_data(data=data, reset=True) 71 lower = data.x[-1]*0.05 72 upper1 = data.x[-1] - lower*5 73 upper2 = data.x[-1] 74 self.set_qmin(lower) 75 self.set_qmax((upper1, upper2)) 76 77 78 def _on_enter_qrange(self, event): 98 if set_qrange: 99 lower = data.x[-1]*0.05 100 upper1 = data.x[-1] - lower*5 101 upper2 = data.x[-1] 102 self.set_qmin(lower) 103 self.set_qmax((upper1, upper2)) 104 105 def get_data(self): 106 return self._data 107 108 def save_project(self, doc=None): 109 """ 110 Return an XML node containing the state of the panel 111 """ 112 data = self._data 113 state = self.get_state() 114 if data is not None: 115 new_doc, sasentry = self._manager.state_reader._to_xml_doc(data) 116 new_doc = state.toXML(doc=new_doc, entry_node=sasentry) 117 if new_doc is not None: 118 if doc is not None and hasattr(doc, "firstChild"): 119 child = new_doc.getElementsByTagName("SASentry") 120 for item in child: 121 doc.firstChild.appendChild(item) 122 else: 123 doc = new_doc 124 return doc 125 126 127 def _on_enter_qrange(self, event=None): 79 128 """ 80 129 Read values from input boxes and save to memory. 81 130 """ 82 event.Skip()131 if event is not None: event.Skip() 83 132 if not self._validate_qrange(): 84 133 return … … 91 140 from sas.sasgui.perspectives.corfunc.corfunc import GROUP_ID_IQ_DATA 92 141 group_id = GROUP_ID_IQ_DATA 93 wx.PostEvent(self._manager.parent, PlotQrangeEvent( 94 ctrl=[self._qmin_input, self._qmax1_input, self._qmax2_input], 95 active=event.GetEventObject(), id=data_id, group_id=group_id, 96 leftdown=False)) 142 if event is not None: 143 wx.PostEvent(self._manager.parent, PlotQrangeEvent( 144 ctrl=[self._qmin_input, self._qmax1_input, self._qmax2_input], 145 active=event.GetEventObject(), id=data_id, group_id=group_id, 146 leftdown=False)) 97 147 98 148 def set_qmin(self, qmin): … … 139 189 "qmin must be less than qmax" 140 190 qmin_valid = False 141 # import pdb; pdb.set_trace() 191 142 192 if not (qmin_valid and qmax_valid): 143 193 if not qmin_valid:
Note: See TracChangeset
for help on using the changeset viewer.