Changeset 57be490 in sasview for src/sas/qtgui/Utilities/GuiUtils.py
- Timestamp:
- May 17, 2018 4:50:09 AM (7 years ago)
- Branches:
- ESS_GUI, 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:
- 085e3c9d
- Parents:
- 976978b
- git-author:
- Piotr Rozyczko <rozyczko@…> (04/13/18 09:34:43)
- git-committer:
- Piotr Rozyczko <rozyczko@…> (05/17/18 04:50:09)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Utilities/GuiUtils.py
rd4dac80 r57be490 1 # -*- coding: utf-8 -*- 1 2 """ 2 3 Global defaults and various utility functions usable by the general GUI … … 248 249 sendDataToGridSignal = QtCore.pyqtSignal(list) 249 250 251 # Action Save Analysis triggered 252 saveAnalysisSignal = QtCore.pyqtSignal() 250 253 251 254 def updateModelItemWithPlot(item, update_data, name=""): … … 378 381 if str(i.text()) == filename]) 379 382 return item[0] if len(item)>0 else None 383 384 def plotsFromModel(model_name, model_item): 385 """ 386 Returns the list of plots for the item with model name in the model 387 """ 388 assert isinstance(model_item, QtGui.QStandardItem) 389 assert isinstance(model_name, str) 390 391 plot_data = [] 392 # Iterate over model looking for named items 393 for index in range(model_item.rowCount()): 394 item = model_item.child(index) 395 if isinstance(item.data(), (Data1D, Data2D)): 396 plot_data.append(item.data()) 397 if model_name in str(item.text()): 398 #plot_data.append(item.child(0).data()) 399 # Going 1 level deeper only 400 for index_2 in range(item.rowCount()): 401 item_2 = item.child(index_2) 402 if item_2 and isinstance(item_2.data(), (Data1D, Data2D)): 403 plot_data.append(item_2.data()) 404 405 return plot_data 380 406 381 407 def plotsFromFilename(filename, model_item): … … 841 867 return output.lstrip().rstrip() 842 868 869 def replaceHTMLwithUTF8(html): 870 """ 871 Replace some important HTML-encoded characters 872 with their UTF-8 equivalents 873 """ 874 # Angstrom 875 html_out = html.replace("Å", "à 876 ") 877 # infinity 878 html_out = html_out.replace("∞", "â") 879 # +/- 880 html_out = html_out.replace("±", "±") 881 882 return html_out 883 884 def replaceHTMLwithASCII(html): 885 """ 886 Replace some important HTML-encoded characters 887 with their ASCII equivalents 888 """ 889 # Angstrom 890 html_out = html.replace("Å", "Ang") 891 # infinity 892 html_out = html_out.replace("∞", "inf") 893 # +/- 894 html_out = html_out.replace("±", "+/-") 895 896 return html_out 897 898 def convertUnitToUTF8(unit): 899 """ 900 Convert ASCII unit display into UTF-8 symbol 901 """ 902 if unit == "1/A": 903 return "à 904 <sup>-1</sup>" 905 elif unit == "1/cm": 906 return "cm<sup>-1</sup>" 907 elif unit == "Ang": 908 return "à 909 " 910 elif unit == "1e-6/Ang^2": 911 return "10<sup>-6</sup>/à 912 <sup>2</sup>" 913 elif unit == "inf": 914 return "â" 915 elif unit == "-inf": 916 return "-â" 917 else: 918 return unit 919 843 920 def convertUnitToHTML(unit): 844 921 """
Note: See TracChangeset
for help on using the changeset viewer.