- Timestamp:
- Nov 9, 2017 8:43:55 AM (7 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:
- d6b8a1d
- Parents:
- 7969b9c
- git-author:
- Piotr Rozyczko <rozyczko@…> (11/03/17 10:58:39)
- git-committer:
- Piotr Rozyczko <rozyczko@…> (11/09/17 08:43:55)
- Location:
- src/sas
- Files:
-
- 20 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Calculators/DataOperationUtilityPanel.py
r4992ff2 rfbfc488 140 140 data1 = self.data1 141 141 data2 = self.data2 142 exec("output = data1 %s data2" % operator) 143 except: 144 raise 142 output = eval("data1 %s data2" % operator) 143 except Exception as ex: 144 logging.error(ex) 145 return 145 146 146 147 self.output = output -
src/sas/qtgui/Calculators/DensityPanel.py
r4992ff2 rfbfc488 60 60 61 61 # set validators 62 self.ui.editMolecularFormula.setValidator(FormulaValidator(self.ui.editMolecularFormula))62 #self.ui.editMolecularFormula.setValidator(FormulaValidator(self.ui.editMolecularFormula)) 63 63 64 64 rx = QtCore.QRegExp("[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?") … … 94 94 self.mapper.addMapping(self.ui.editMassDensity , MODEL.MASS_DENSITY) 95 95 96 # FIXME DOESNT WORK WITH QT5 97 #self.mapper.toFirst() 96 self.mapper.toFirst() 98 97 99 98 def dataChanged(self, top, bottom): … … 140 139 141 140 def modelReset(self): 142 #self.model.beginResetModel()143 141 try: 144 142 self.setMode(None) … … 148 146 finally: 149 147 pass 150 #self.model.endResetModel()151 148 152 149 def displayHelp(self): -
src/sas/qtgui/Calculators/GenericScatteringCalculator.py
r4992ff2 rfbfc488 135 135 "SLD files (*.SLD *.sld);;PDB files (*.pdb *.PDB);; " 136 136 "OMF files (*.OMF *.omf);; " 137 "All files (*.*)") 137 "All files (*.*)")[0] 138 138 if self.datafile: 139 139 self.default_shape = str(self.cbShape.currentText()) -
src/sas/qtgui/Calculators/KiessigPanel.py
r4992ff2 rfbfc488 55 55 self.thickness.set_deltaq(dq=float(self.deltaq_in.text())) 56 56 kiessing_result = self.thickness.compute_thickness() 57 float_as_str = "{:.3f}".format(kiessing_result) 58 self.lengthscale_out.setText(float_as_str) 57 if kiessing_result: 58 float_as_str = "{:.3f}".format(kiessing_result) 59 self.lengthscale_out.setText(float_as_str) 60 else: 61 # error or division by zero 62 self.lengthscale_out.setText("") 63 59 64 except (ArithmeticError, ValueError): 60 65 self.lengthscale_out.setText("") -
src/sas/qtgui/Calculators/ResolutionCalculatorPanel.py
r4992ff2 rfbfc488 317 317 if self.cbCustomSpectrum.currentText() == 'Add New': 318 318 datafile = QtWidgets.QFileDialog.getOpenFileName( 319 self, "Choose a spectral distribution file", 320 "All files (*.*)", 321 QtWidgets.QFileDialog.DontUseNativeDialog) 319 self, "Choose a spectral distribution file","", 320 "All files (*.*)", None, 321 QtWidgets.QFileDialog.DontUseNativeDialog)[0] 322 322 323 323 if datafile is None or str(datafile) == '': … … 568 568 : return: image (numpy array) 569 569 """ 570 # This fails in py3 with 571 # [Failure instance: Traceback: <class 'TypeError'>: 'map' object is not subscriptable 572 # INVESTIGATE 573 image = map(func, qx, qy, 570 image = list(map(func, qx, qy, 574 571 qx_min, qx_max, 575 qy_min, qy_max)[0] 572 qy_min, qy_max))[0] 573 576 574 return image 577 575 … … 751 749 self.plotter.plot() 752 750 self.plotter.show() 751 self.plotter.update() 753 752 754 753 def drawLines(self): -
src/sas/qtgui/Calculators/SldPanel.py
r4992ff2 rfbfc488 128 128 129 129 # set validators 130 self.ui.editMolecularFormula.setValidator(GuiUtils.FormulaValidator(self.ui.editMolecularFormula)) 130 # TODO: GuiUtils.FormulaValidator() crashes with Qt5 - fix 131 #self.ui.editMolecularFormula.setValidator(GuiUtils.FormulaValidator(self.ui.editMolecularFormula)) 131 132 132 133 rx = QtCore.QRegExp("[+\-]?(?:0|[1-9]\d*)(?:\.\d*)?(?:[eE][+\-]?\d+)?") … … 148 149 149 150 self.model.dataChanged.connect(self.dataChanged) 150 #QtCore.QObject.connect(151 # self.model,152 # QtCore.SIGNAL("dataChanged(QModelIndex,QModelIndex)"),153 # self.dataChanged)154 151 155 152 self.modelReset() … … 166 163 self.mapper.addMapping(edit, key) 167 164 168 # FIXME DOESNT WORK WITH QT5 169 #self.mapper.toFirst() 165 self.mapper.toFirst() 170 166 171 167 def dataChanged(self, top, bottom): … … 216 212 finally: 217 213 pass 218 214 #self.model.endResetModel() 219 215 220 216 def displayHelp(self): -
src/sas/qtgui/Calculators/SlitSizeCalculator.py
r4992ff2 rfbfc488 4 4 import os 5 5 import sys 6 import logging 6 7 7 8 from PyQt5 import QtCore … … 64 65 return 65 66 loader = Loader() 66 data = loader.load(path_str)[0] 67 try: 68 data = loader.load(path_str)[0] 69 # Can return multiple exceptions - gather them all under one umbrella and complain 70 except Exception as ex: 71 logging.error(ex) 72 return 67 73 68 74 self.data_file.setText(os.path.basename(path_str)) … … 79 85 "SAXSess 1D data (*.txt *.TXT *.dat *.DAT)", 80 86 None, 81 QtWidgets.QFileDialog.DontUseNativeDialog) 82 83 if path is None: 84 return 85 87 QtWidgets.QFileDialog.DontUseNativeDialog)[0] 86 88 return path 87 89 … … 106 108 self.clearResults() 107 109 msg = "ERROR: Data hasn't been loaded correctly" 108 raise RuntimeError(msg) 110 logging.error(msg) 111 return 109 112 110 113 if data.__class__.__name__ == 'Data2D': 111 114 self.clearResults() 112 115 msg = "Slit Length cannot be computed for 2D Data" 113 raise RuntimeError(msg) 116 logging.error(msg) 117 return 114 118 115 119 #compute the slit size … … 119 123 if xdata == [] or xdata is None or ydata == [] or ydata is None: 120 124 msg = "The current data is empty please check x and y" 121 raise ValueError(msg) 125 logging.error(msg) 126 return 122 127 slit_length_calculator = SlitlengthCalculator() 123 128 slit_length_calculator.set_data(x=xdata, y=ydata) … … 126 131 self.clearResults() 127 132 msg = "Slit Size Calculator: %s" % (sys.exc_info()[1]) 128 raise RuntimeError(msg) 133 logging.error(msg) 134 return 129 135 130 136 slit_length_str = "{:.5f}".format(slit_length) -
src/sas/qtgui/MainWindow/DataExplorer.py
r7969b9c rfbfc488 218 218 'options' : QtWidgets.QFileDialog.DontUseNativeDialog 219 219 } 220 filename = str(QtWidgets.QFileDialog.getOpenFileName(**kwargs))220 filename = QtWidgets.QFileDialog.getOpenFileName(**kwargs)[0] 221 221 if filename: 222 222 load_thread = threads.deferToThread(self.readProject, filename) … … 582 582 # Show the plot 583 583 new_plot.show() 584 new_plot.canvas.draw() 584 585 585 586 # Update the active chart list … … 628 629 paths = QtWidgets.QFileDialog.getOpenFileNames(self, "Choose a file", "", 629 630 wlist, None, QtWidgets.QFileDialog.DontUseNativeDialog)[0] 630 # [0] is new in Qt5 as getOpenFileNames() returns now a tuple! 631 if paths is None: 631 if not paths: 632 632 return 633 633 -
src/sas/qtgui/MainWindow/GuiManager.py
r7969b9c rfbfc488 8 8 from PyQt5.QtWidgets import * 9 9 from PyQt5.QtGui import * 10 from PyQt5.QtCore import Qt 10 from PyQt5.QtCore import Qt, QLocale 11 11 from PyQt5.QtWebKitWidgets import QWebView 12 12 … … 198 198 199 199 # Resize to the workspace height 200 #workspace_height = self._workspace.workspace.sizeHint().height()201 #perspective_size = self._current_perspective.sizeHint()200 workspace_height = self._workspace.workspace.sizeHint().height() 201 perspective_size = self._current_perspective.sizeHint() 202 202 #if workspace_height < perspective_size.height(): 203 #perspective_width = perspective_size.width()204 #self._current_perspective.resize(perspective_width, workspace_height-10)203 perspective_width = perspective_size.width() 204 self._current_perspective.resize(perspective_width, workspace_height-10) 205 205 206 206 self._current_perspective.show() … … 592 592 self.ipDockWidget.setObjectName("IPythonDockWidget") 593 593 self.ipDockWidget.setWidget(terminal) 594 self._workspace. workspace.addSubWindow(self.ipDockWidget, Qt.RightDockWidgetArea)594 self._workspace.addDockWidget(Qt.RightDockWidgetArea, self.ipDockWidget) 595 595 596 596 def actionImage_Viewer(self): -
src/sas/qtgui/MainWindow/MainWindow.py
r4992ff2 rfbfc488 69 69 # Show the main SV window 70 70 mainwindow = MainSasViewWindow() 71 mainwindow.show Maximized()71 mainwindow.show() 72 72 73 73 # no more splash screen -
src/sas/qtgui/Perspectives/Fitting/FittingWidget.py
r4992ff2 rfbfc488 61 61 QtGui.QStandardItemModel.__init__(self,parent) 62 62 63 def headerData(self, section, orientation, role ):63 def headerData(self, section, orientation, role=QtCore.Qt.DisplayRole): 64 64 """ 65 65 Displays tooltip for each column's header … … 592 592 elif model_column in [self.lstPoly.itemDelegate().poly_min, self.lstPoly.itemDelegate().poly_max]: 593 593 try: 594 value = float(item.text())594 value = GuiUtils.toDouble(item.text()) 595 595 except ValueError: 596 596 # Can't be converted properly, bring back the old value and exit … … 607 607 else: 608 608 try: 609 value = float(item.text())609 value = GuiUtils.toDouble(item.text()) 610 610 except ValueError: 611 611 # Can't be converted properly, bring back the old value and exit … … 624 624 model_row = item.row() 625 625 name_index = self._magnet_model.index(model_row, 0) 626 parameter_name = str(self._magnet_model.data(name_index) .toPyObject())626 parameter_name = str(self._magnet_model.data(name_index)) 627 627 628 628 if model_column == 0: … … 640 640 # Extract changed value. 641 641 try: 642 value = float(item.text())642 value = GuiUtils.toDouble(item.text()) 643 643 except ValueError: 644 644 # Unparsable field 645 645 return 646 646 647 property_index = self._magnet_model.headerData( 0, 1, model_column).toInt()[0]-1 # Value, min, max, etc.647 property_index = self._magnet_model.headerData(1, model_column)-1 # Value, min, max, etc. 648 648 649 649 # Update the parameter value - note: this supports +/-inf as well … … 1304 1304 # Extract changed value. 1305 1305 try: 1306 value = float(item.text())1306 value = GuiUtils.toDouble(item.text()) 1307 1307 except ValueError: 1308 1308 # Unparsable field 1309 1309 return 1310 parameter_name = str(self._model_model.data(name_index)) #.toPyObject()) # sld, background etc. 1310 1311 parameter_name = str(self._model_model.data(name_index)) # sld, background etc. 1311 1312 1312 1313 # Update the parameter value - note: this supports +/-inf as well … … 1687 1688 datafile = QtWidgets.QFileDialog.getOpenFileName( 1688 1689 self, "Choose a weight file", "", "All files (*.*)", None, 1689 QtWidgets.QFileDialog.DontUseNativeDialog) 1690 1691 if datafile is None or str(datafile)=='':1690 QtWidgets.QFileDialog.DontUseNativeDialog)[0] 1691 1692 if not datafile: 1692 1693 logging.info("No weight data chosen.") 1693 1694 raise IOError -
src/sas/qtgui/Perspectives/Fitting/ViewDelegate.py
r7969b9c rfbfc488 4 4 5 5 import sas.qtgui.Utilities.GuiUtils as GuiUtils 6 7 class CommaLessValidator(QtGui.QDoubleValidator): 8 """ 9 Custom double validator which doesn't allow for commas to be used as decimal point 10 """ 11 pass 6 12 7 13 class ModelViewDelegate(QtWidgets.QStyledItemDelegate): … … 44 50 if index.column() in self.fancyColumns(): 45 51 # Units - present in nice HTML 46 #options = QtWidgets.QStyleOptionViewItemV4(option)47 52 options = QtWidgets.QStyleOptionViewItem(option) 48 53 self.initStyleOption(options,index) … … 236 241 def createEditor(self, widget, option, index): 237 242 # Remember the current choice 238 current_text = index.data() .toString()243 current_text = index.data() 239 244 if not index.isValid(): 240 245 return 0 -
src/sas/qtgui/Plotting/BoxSum.py
r4992ff2 rfbfc488 11 11 12 12 class BoxSum(QtWidgets.QDialog, Ui_BoxSumUI): 13 apply_signal = QtCore.pyqtSignal(tuple, str)14 13 def __init__(self, parent=None, model=None): 15 14 super(BoxSum, self).__init__() … … 24 23 25 24 self.model = model 26 self.mapper = Qt Gui.QDataWidgetMapper()25 self.mapper = QtWidgets.QDataWidgetMapper() 27 26 self.mapper.setModel(self.model) 28 27 … … 32 31 self.mapper.addMapping(self.txtCenterX, 2) 33 32 self.mapper.addMapping(self.txtCenterY, 3) 34 self.mapper.addMapping(self.lblAvg, 4, "text")35 self.mapper.addMapping(self.lblAvgErr, 5, "text")36 self.mapper.addMapping(self.lblSum, 6, "text")37 self.mapper.addMapping(self.lblSumErr, 7, "text")38 self.mapper.addMapping(self.lblNumPoints, 8, "text")33 self.mapper.addMapping(self.lblAvg, 4, b"text") 34 self.mapper.addMapping(self.lblAvgErr, 5, b"text") 35 self.mapper.addMapping(self.lblSum, 6, b"text") 36 self.mapper.addMapping(self.lblSumErr, 7, b"text") 37 self.mapper.addMapping(self.lblNumPoints, 8, b"text") 39 38 40 39 # Populate the widgets with data from the first column … … 43 42 self.setFixedSize(self.minimumSizeHint()) 44 43 44 # Handle the Apply button click 45 self.buttonBox.button(QtWidgets.QDialogButtonBox.Close).clicked.connect(self.onClose) 46 47 def onClose(self): 48 """ 49 close the window containing this panel 50 """ 51 self.close() 52 -
src/sas/qtgui/Plotting/Plotter.py
r7969b9c rfbfc488 163 163 164 164 # refresh canvas 165 self.canvas.draw ()165 self.canvas.draw_idle() 166 166 167 167 def createContextMenu(self): -
src/sas/qtgui/Plotting/Plotter2D.py
r7969b9c rfbfc488 123 123 """ 124 124 # Toggle the scale 125 zmin_temp = self.zmin 125 zmin_temp = self.zmin if self.zmin else MIN_Z 126 126 zmax_temp = self.zmax 127 127 # self.scale predefined in the baseclass -
src/sas/qtgui/Plotting/PlotterBase.py
r7969b9c rfbfc488 34 34 self.manager = manager 35 35 self.quickplot = quickplot 36 37 #plt.style.use('ggplot') 38 plt.style.use('seaborn-darkgrid') 36 39 37 40 # a figure instance to plot on -
src/sas/qtgui/Plotting/Slicers/BoxSum.py
r4992ff2 rfbfc488 6 6 from PyQt5 import QtGui 7 7 8 from sas.qtgui.Utilities.GuiUtils import formatNumber 8 from sas.qtgui.Utilities.GuiUtils import formatNumber, toDouble 9 9 10 10 from .BaseInteractor import BaseInteractor … … 137 137 """ 138 138 params = {} 139 params["Height"] = float(self.model().item(0, 0).text())140 params["Width"] = float(self.model().item(0, 1).text())141 params["center_x"] = float(self.model().item(0, 2).text())142 params["center_y"] = float(self.model().item(0, 3).text())139 params["Height"] = toDouble(self.model().item(0, 0).text()) 140 params["Width"] = toDouble(self.model().item(0, 1).text()) 141 params["center_x"] = toDouble(self.model().item(0, 2).text()) 142 params["center_y"] = toDouble(self.model().item(0, 3).text()) 143 143 self.update_model = False 144 144 self.setParams(params) -
src/sas/qtgui/Utilities/GuiUtils.py
r4992ff2 rfbfc488 249 249 plot_item = item.child(index) 250 250 if plot_item.isCheckable(): 251 plot_data = plot_item.child(0).data() #.toPyObject()251 plot_data = plot_item.child(0).data() 252 252 if plot_data.id is not None and plot_data.id == py_update_data.id: 253 253 # replace data section in item … … 270 270 Adds 'update_data' to that row. 271 271 """ 272 #assert isinstance(update_data, QtCore.QVariant)273 #py_update_data = update_data.toPyObject()274 272 py_update_data = update_data 275 273 … … 339 337 if str(item.text()) == filename: 340 338 # TODO: assure item type is correct (either data1/2D or Plotter) 341 plot_data.append(item.child(0).data()) #.toPyObject())339 plot_data.append(item.child(0).data()) 342 340 # Going 1 level deeper only 343 341 for index_2 in range(item.rowCount()): … … 345 343 if item_2 and item_2.isCheckable(): 346 344 # TODO: assure item type is correct (either data1/2D or Plotter) 347 plot_data.append(item_2.child(0).data()) #.toPyObject())345 plot_data.append(item_2.child(0).data()) 348 346 349 347 return plot_data … … 361 359 if item.isCheckable() and item.checkState() == QtCore.Qt.Checked: 362 360 # TODO: assure item type is correct (either data1/2D or Plotter) 363 plot_data.append((item, item.child(0).data())) #.toPyObject()))361 plot_data.append((item, item.child(0).data())) 364 362 # Going 1 level deeper only 365 363 for index_2 in range(item.rowCount()): … … 367 365 if item_2 and item_2.isCheckable() and item_2.checkState() == QtCore.Qt.Checked: 368 366 # TODO: assure item type is correct (either data1/2D or Plotter) 369 plot_data.append((item_2, item_2.child(0).data())) #.toPyObject()))367 plot_data.append((item_2, item_2.child(0).data())) 370 368 371 369 return plot_data … … 635 633 636 634 def validate(self, input, pos): 637 try: 638 Formula(str(input)) 639 self._setStyleSheet("") 640 return QtGui.QValidator.Acceptable, pos 641 642 except Exception as e: 643 self._setStyleSheet("background-color:pink;") 644 return QtGui.QValidator.Intermediate, pos 635 636 self._setStyleSheet("") 637 return QtGui.QValidator.Acceptable, pos 638 639 #try: 640 # Formula(str(input)) 641 # self._setStyleSheet("") 642 # return QtGui.QValidator.Acceptable, pos 643 644 #except Exception as e: 645 # self._setStyleSheet("background-color:pink;") 646 # return QtGui.QValidator.Intermediate, pos 645 647 646 648 def _setStyleSheet(self, value): … … 756 758 The assumption - data stored in SasView standard, in child 0 757 759 """ 758 return item.child(0).data() #.toPyObject()760 return item.child(0).data() 759 761 760 762 def formatNumber(value, high=False): … … 806 808 else: 807 809 return name 810 811 def toDouble(value_string): 812 """ 813 toFloat conversion which cares deeply about user's locale 814 """ 815 # Holy shit this escalated quickly in Qt5. 816 # No more float() cast on general locales. 817 value = QtCore.QLocale().toFloat(value_string) 818 if value[1]: 819 return value[0] 820 821 # Try generic locale 822 value = QtCore.QLocale(QtCore.QLocale('en_US')).toFloat(value_string) 823 if value[1]: 824 return value[0] 825 else: 826 raise ValueError -
src/sas/qtgui/Utilities/IPythonWidget.py
r4992ff2 rfbfc488 3 3 from PyQt5 import QtWidgets 4 4 5 ##from PyQt4import QtSvg5 from PyQt5 import QtSvg 6 6 7 7 def new_load_qt(api_options): … … 18 18 # Do some monkey patching to satisfy pyinstaller complaining 19 19 # about pyside/pyqt confusion 20 qt_loaders.load_qt = new_load_qt21 qtconsole_qt_loaders.load_qt = qtconsole_new_load_qt20 #qt_loaders.load_qt = new_load_qt 21 #qtconsole_qt_loaders.load_qt = qtconsole_new_load_qt 22 22 23 23 from qtconsole.rich_jupyter_widget import RichJupyterWidget -
src/sas/sascalc/calculator/resolution_calculator.py
r574adc7 rfbfc488 1007 1007 try: 1008 1008 detector_offset = self.sample2detector_distance[1] 1009 except :1010 logger.error( sys.exc_value)1009 except Exception as ex: 1010 logger.error(ex) 1011 1011 1012 1012 # detector size in [no of pix_x,no of pix_y] … … 1057 1057 # qx_value and qy_value values in array 1058 1058 qx_value = qx_value.repeat(detector_pix_nums_y) 1059 qx_value = qx_value.reshape( detector_pix_nums_x, detector_pix_nums_y)1059 qx_value = qx_value.reshape(int(detector_pix_nums_x), int(detector_pix_nums_y)) 1060 1060 qy_value = qy_value.repeat(detector_pix_nums_x) 1061 qy_value = qy_value.reshape( detector_pix_nums_y, detector_pix_nums_x)1061 qy_value = qy_value.reshape(int(detector_pix_nums_y), int(detector_pix_nums_x)) 1062 1062 qy_value = qy_value.transpose() 1063 1063
Note: See TracChangeset
for help on using the changeset viewer.