- Timestamp:
- Aug 24, 2016 11:15:28 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:
- d45d590
- Parents:
- 5a525e1
- git-author:
- Lewis O'Driscoll <lewis.o'driscoll@…> (08/24/16 10:59:41)
- git-committer:
- Lewis O'Driscoll <lewis.o'driscoll@…> (08/24/16 11:15:28)
- Location:
- src/sas/sasgui/perspectives/corfunc
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/perspectives/corfunc/corfunc.py
r5a525e1 r96d293da 33 33 self.state_reader = Reader(self.set_state) 34 34 self._extensions = '.cor' 35 l = Loader()36 l.associate_file_reader('.cor', self.state_reader)37 35 38 36 def get_panels(self, parent): … … 48 46 self._frame_set_helper() 49 47 self.perspective.append(self.corfunc_panel.window_name) 48 49 l = Loader() 50 l.associate_file_reader('.cor', self.state_reader) 50 51 51 52 return [self.corfunc_panel] … … 82 83 Callback for CorfuncState reader. Called when a .cor file is loaded 83 84 """ 84 self.corfunc_panel.set_state(state=state, data=datainfo) 85 if isinstance(datainfo, list): 86 data = datainfo[0] 87 else: 88 data = datainfo 89 self.corfunc_panel.set_state(state=state, data=data) 90 self.on_perspective(event=None) 91 data = self.parent.create_gui_data(data, None) 92 self.parent.add_data({ data.id: data }) 85 93 86 94 def set_data(self, data_list=None): -
src/sas/sasgui/perspectives/corfunc/corfunc_panel.py
r204f628 r96d293da 1 1 import wx 2 2 import sys 3 import os 3 4 import numpy as np 4 5 from wx.lib.scrolledpanel import ScrolledPanel 5 6 from sas.sasgui.guiframe.events import PlotQrangeEvent 6 7 from sas.sasgui.guiframe.events import StatusEvent 8 from sas.sasgui.guiframe.events import PanelOnFocusEvent 7 9 from sas.sasgui.guiframe.panel_base import PanelBase 8 10 from sas.sasgui.guiframe.utils import check_float … … 299 301 doc_viewer = DocumentationWindow(self, -1, tree_location, "", 300 302 "Correlation Function Help") 303 304 def get_save_flag(self): 305 if self._data is not None: 306 return True 307 return False 308 309 def on_set_focus(self, event=None): 310 if self._manager.parent is not None: 311 wx.PostEvent(self._manager.parent, PanelOnFocusEvent(panel=self)) 312 313 def on_save(self, event=None): 314 """ 315 Save corfunc state into a file 316 """ 317 # Ask the user the location of the file to write to. 318 path = None 319 default_save_location = os.getcwd() 320 if self._manager.parent != None: 321 default_save_location = self._manager.parent.get_save_location() 322 323 dlg = wx.FileDialog(self, "Choose a file", 324 default_save_location, \ 325 self.window_caption, "*.cor", wx.SAVE) 326 if dlg.ShowModal() == wx.ID_OK: 327 path = dlg.GetPath() 328 default_save_location = os.path.dirname(path) 329 if self._manager.parent != None: 330 self._manager.parent._default_save_location = default_save_location 331 else: 332 return None 333 334 dlg.Destroy() 335 # MAC always needs the extension for saving 336 extens = ".cor" 337 # Make sure the ext included in the file name 338 f_name = os.path.splitext(path)[0] + extens 339 self._manager.state_reader.write(f_name, self._data, self.get_state()) 301 340 302 341 def save_project(self, doc=None): -
src/sas/sasgui/perspectives/corfunc/corfunc_state.py
rcaeb382 r96d293da 10 10 from sas.sasgui.guiframe.gui_style import GUIFRAME_ID 11 11 from sas.sasgui.guiframe.dataFitting import Data1D 12 from sas.sascalc.dataloader.data_info import Data1D as LoaderData1D 12 13 from sas.sascalc.dataloader.loader import Loader 13 14 … … 250 251 type_name = "Corfunc" 251 252 252 type = [" Invariant file (*.inv)|*.inv",253 type = ["Corfunc file (*.cor)|*.cor", 253 254 "SASView file (*.svs)|*.svs"] 254 255 … … 312 313 if datainfo is None: 313 314 datainfo = Data1D(x=[], y=[]) 314 elif not issubclass(datainfo.__class__, Data1D):315 msg = ("The CanSAS writer expects a Data1D instance. {} was " ,315 elif not (isinstance(datainfo, Data1D) or isinstance(datainfo, LoaderData1D)): 316 msg = ("The CanSAS writer expects a Data1D instance. {} was " 316 317 "provided").format(datainfo.__class__.__name__) 317 318 raise RuntimeError, msg
Note: See TracChangeset
for help on using the changeset viewer.