- Timestamp:
- Dec 13, 2016 7:02:55 AM (8 years ago)
- 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:
- 6b9d41d
- Parents:
- a8ec5b1
- Location:
- src/sas/qtgui
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/DataExplorer.py
rcad617b r253e7170 490 490 data_error = False 491 491 error_message = "" 492 493 492 number_of_files = len(path) 494 493 self.communicator.progressBarUpdateSignal.emit(0.0) -
src/sas/qtgui/SlitSizeCalculator.py
ra8ec5b1 r253e7170 2 2 from PyQt4 import QtCore 3 3 from UI.SlitSizeCalculator import Ui_SlitSizeCalculator 4 from twisted.internet import threads 5 import logging 4 from sas.sascalc.dataloader.loader import Loader 5 from sas.sasgui.guiframe.dataFitting import Data1D 6 from sas.sasgui.guiframe.dataFitting import Data2D 7 from sas.sascalc.calculator.slit_length_calculator import SlitlengthCalculator 6 8 7 # sas-global 8 from sas.sascalc.calculator.slit_length_calculator import SlitlengthCalculator 9 from DataExplorer import DataExplorerWindow 9 import sys 10 10 11 11 class SlitSizeCalculator(QtGui.QDialog, Ui_SlitSizeCalculator): … … 50 50 Execute the computation of thickness 51 51 """ 52 path_str = self.chooseFile s()52 path_str = self.chooseFile() 53 53 if not path_str: 54 54 return 55 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]) 55 loader = Loader() 56 data = loader.load(path_str) 58 57 59 def loadFromURL(self, url): 60 """ 61 Threaded file load 62 """ 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 58 self.deltaq_in.setText(path_str) 59 #We are loading data for one model only therefor index 0 60 self.complete_loading(data) 61 #Complete loading here 67 62 68 def chooseFile s(self):63 def chooseFile(self): 69 64 """ 70 65 Shows the Open file dialog and returns the chosen path(s) … … 73 68 # Location is automatically saved - no need to keep track of the last dir 74 69 # But only with Qt built-in dialog (non-platform native) 75 path s = QtGui.QFileDialog.getOpenFileNames(self, "Choose a file", "",76 "SA XSess Data 1D (*.txt *.TXT *.dat *.DAT)", None,70 path = QtGui.QFileDialog.getOpenFileName(self, "Choose a file", "", 71 "SAS data 1D (*.txt *.TXT *.dat *.DAT)", None, 77 72 QtGui.QFileDialog.DontUseNativeDialog) 78 if path sis None:73 if path is None: 79 74 return 80 75 81 if isinstance(path s, QtCore.QStringList):82 path s = [str(f) for f in paths]76 if isinstance(path, QtCore.QString): 77 path = str(path) 83 78 84 if not isinstance(paths, list): 85 paths = [paths] 86 87 return paths 79 return path 88 80 89 81 def onClose(self): … … 97 89 Complete the loading and compute the slit size 98 90 """ 99 #TODO: Provided we have an access to data then it should be fairly easy100 index = self.treeView.selectedIndexes()[0]101 model_item = self.model.itemFromIndex(self.data_proxy.mapToSource(index))102 data = GuiUtils.dataFromItem(model_item)103 91 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 92 if data is None: 93 msg = "ERROR: Data hasn't been loaded correctly" 94 raise RuntimeError, msg 95 96 if isinstance(data, Data2D): 108 97 msg = "Slit Length cannot be computed for 2D Data" 109 logging.info(msg) 110 return 111 self.data_name_tcl.SetValue(str(data.filename)) 98 raise Exception, msg 99 112 100 #compute the slit size 113 101 try: 114 x = data.x115 y = data.y116 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, msg119 slit_length_calculator = SlitlengthCalculator()120 slit_length_calculator.set_data(x=x, y=y)121 slit_length = slit_length_calculator.calculate_slit_length()102 x = data.x 103 y = data.y 104 if x == [] or x is None or y == [] or y is None: 105 msg = "The current data is empty please check x and y" 106 raise ValueError, msg 107 slit_length_calculator = SlitlengthCalculator() 108 slit_length_calculator.set_data(x=x, y=y) 109 slit_length = slit_length_calculator.calculate_slit_length() 122 110 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)) 111 msg = "Slit Size Calculator: %s" % (sys.exc_value) 112 raise RuntimeError, msg 113 114 print("Slit lenght", slit_length) 115 self.lengthscale_out.setText(str(slit_length)) 129 116 #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) 117 self.lineEdit.setText("[UNKNOWN]") 135 118
Note: See TracChangeset
for help on using the changeset viewer.