Changeset b10cf92 in sasview for src/sas/qtgui/Utilities/GuiUtils.py


Ignore:
Timestamp:
May 17, 2018 1:49:28 PM (6 years ago)
Author:
wojciech
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:
3aa3351, a0ed202
Parents:
6459916 (diff), 57be490 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'ESS_GUI' of https://github.com/SasView/sasview into ESS_GUI

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/sas/qtgui/Utilities/GuiUtils.py

    rd4dac80 r57be490  
     1# -*- coding: utf-8 -*- 
    12""" 
    23Global defaults and various utility functions usable by the general GUI 
     
    248249    sendDataToGridSignal = QtCore.pyqtSignal(list) 
    249250 
     251    # Action Save Analysis triggered 
     252    saveAnalysisSignal = QtCore.pyqtSignal() 
    250253 
    251254def updateModelItemWithPlot(item, update_data, name=""): 
     
    378381                 if str(i.text()) == filename]) 
    379382    return item[0] if len(item)>0 else None 
     383 
     384def 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 
    380406 
    381407def plotsFromFilename(filename, model_item): 
     
    841867    return output.lstrip().rstrip() 
    842868 
     869def 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 
     884def 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 
     898def 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 
    843920def convertUnitToHTML(unit): 
    844921    """ 
Note: See TracChangeset for help on using the changeset viewer.