Changeset a8ec5b1 in sasview


Ignore:
Timestamp:
Dec 9, 2016 5:56:20 AM (7 years ago)
Author:
wojciech
Branches:
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
Children:
253e7170
Parents:
d1fb22ee
Message:

Added data file loading

Location:
src/sas/qtgui
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/GuiManager.py

    r363fbfa ra8ec5b1  
    2626from sas.qtgui.DensityPanel import DensityPanel 
    2727from sas.qtgui.KiessigPanel import KiessigPanel 
     28from sas.qtgui.SlitSizeCalculator import SlitSizeCalculator 
    2829 
    2930# Perspectives 
     
    139140        self.DVCalculator = DensityPanel(self) 
    140141        #self.KIESSIGCalculator = DensityPanel(self)#KiessigPanel(self) 
    141         self.KIESSIGCalculator =  KiessigPanel(self) 
     142        self.KIESSIGCalculator = KiessigPanel(self) 
     143        self.SlitSizeCalculator = SlitSizeCalculator(self._parent, self, manager=self._data_manager) 
    142144    def statusBarSetup(self): 
    143145        """ 
     
    539541        """ 
    540542        """ 
    541         print("actionSlit_Size_Calculator TRIGGERED") 
    542         pass 
     543        self.SlitSizeCalculator.show() 
    543544 
    544545    def actionSAS_Resolution_Estimator(self): 
  • src/sas/qtgui/SlitSizeCalculator.py

    rd1fb22ee ra8ec5b1  
    22from PyQt4 import QtCore 
    33from UI.SlitSizeCalculator import Ui_SlitSizeCalculator 
     4from twisted.internet import threads 
     5import logging 
    46 
    57# sas-global 
    68from sas.sascalc.calculator.slit_length_calculator import SlitlengthCalculator 
    7  
     9from DataExplorer import DataExplorerWindow 
    810 
    911class SlitSizeCalculator(QtGui.QDialog, Ui_SlitSizeCalculator): 
    10     def __init__(self, parent=None): 
     12    def __init__(self, parent=None, guimanager=None, manager=None): 
    1113        super(SlitSizeCalculator, self).__init__() 
    1214        self.setupUi(self) 
     
    1416        self.setWindowTitle("Slit Size Calculator") 
    1517        self._parent = parent 
     18        self._guimanager = guimanager 
     19        self._manager = manager 
    1620 
    1721        self.thickness = SlitlengthCalculator() 
     
    3438        try: 
    3539            location = self._parent.HELP_DIRECTORY_LOCATION + \ 
    36                 "/user/sasgui/perspectives/calculator/slit_lenght_calculator.html" 
     40                "/user/sasgui/perspectives/calculator/slit_calculator_help.html" 
    3741 
    3842            self._parent._helpView.load(QtCore.QUrl(location)) 
     
    5054            return 
    5155        self.loadFromURL(path_str) 
     56        #Path_str is a list - it needs to be changed, so that only one file can be uploaded 
     57        self.deltaq_in.setText(path_str[0]) 
    5258 
    5359    def loadFromURL(self, url): 
     
    5561        Threaded file load 
    5662        """ 
    57         load_thread = threads.deferToThread(self.readData, url) 
    58         load_thread.addCallback(self.loadComplete) 
     63        data_explorer = DataExplorerWindow(parent=self._parent, guimanager=self._guimanager) 
     64        load_thread = threads.deferToThread(data_explorer.readData, url) 
     65        load_thread.addCallback(data_explorer.loadComplete) 
     66        #On complete loading 
    5967 
    6068    def chooseFiles(self): 
     
    6674        # But only with Qt built-in dialog (non-platform native) 
    6775        paths = QtGui.QFileDialog.getOpenFileNames(self, "Choose a file", "", 
    68                 "Scattering data (*.DAT, *.dat)", None, QtGui.QFileDialog.DontUseNativeDialog) 
     76                "SAXSess Data 1D (*.txt *.TXT *.dat *.DAT)", None, 
     77                QtGui.QFileDialog.DontUseNativeDialog) 
    6978        if paths is None: 
    7079            return 
     
    8392        """ 
    8493        self.close() 
     94 
     95    def complete_loading(self, data=None): 
     96        """ 
     97            Complete the loading and compute the slit size 
     98        """ 
     99        #TODO: Provided we have an access to data then it should be fairly easy 
     100        index = self.treeView.selectedIndexes()[0] 
     101        model_item = self.model.itemFromIndex(self.data_proxy.mapToSource(index)) 
     102        data = GuiUtils.dataFromItem(model_item) 
     103 
     104        if data is None or isinstance(data, Data2D): 
     105            #I guess this doesn't apply 
     106            if self.parent.parent is None: 
     107                return 
     108            msg = "Slit Length cannot be computed for 2D Data" 
     109            logging.info(msg) 
     110            return 
     111        self.data_name_tcl.SetValue(str(data.filename)) 
     112        #compute the slit size 
     113        try: 
     114            x = data.x 
     115            y = data.y 
     116            if x == [] or  x is None or y == [] or y is None: 
     117                msg = "The current data is empty please check x and y" 
     118                raise ValueError, msg 
     119            slit_length_calculator = SlitlengthCalculator() 
     120            slit_length_calculator.set_data(x=x, y=y) 
     121            slit_length = slit_length_calculator.calculate_slit_length() 
     122        except: 
     123            if self.parent.parent is None: 
     124                return 
     125            msg = "Slit Size Calculator: %s" % (sys.exc_value) 
     126            logging.info(msg) 
     127            return 
     128        self.slit_size_tcl.SetValue(str(slit_length)) 
     129        #Display unit 
     130        self.slit_size_unit_tcl.SetValue('[Unknown]') 
     131        if self.parent.parent is None: 
     132            return 
     133        msg = "Load Complete" 
     134        logging.info(msg) 
     135 
Note: See TracChangeset for help on using the changeset viewer.