Changeset dc5ef15 in sasview for src/sas/qtgui/Utilities/GuiUtils.py
- Timestamp:
- May 18, 2017 5:36:57 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:
- 6066a3f
- Parents:
- 2a432e7
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/Utilities/GuiUtils.py
rad6b4e2 rdc5ef15 4 4 5 5 import os 6 import re 6 7 import sys 7 8 import imp … … 16 17 from PyQt4 import QtGui 17 18 18 # Translate event handlers19 #from sas.sasgui.guiframe.events import EVT_CATEGORY20 #from sas.sasgui.guiframe.events import EVT_STATUS21 #from sas.sasgui.guiframe.events import EVT_APPEND_BOOKMARK22 #from sas.sasgui.guiframe.events import EVT_PANEL_ON_FOCUS23 #from sas.sasgui.guiframe.events import EVT_NEW_LOAD_DATA24 #from sas.sasgui.guiframe.events import EVT_NEW_COLOR25 #from sas.sasgui.guiframe.events import StatusEvent26 #from sas.sasgui.guiframe.events import NewPlotEvent27 28 19 from periodictable import formula as Formula 29 20 30 from sas.sasgui.plottools import transform 31 from sas.sasgui.plottools.convert_units import convert_unit 32 from sas.sasgui.guiframe.dataFitting import Data1D 33 from sas.sasgui.guiframe.dataFitting import Data2D 21 from sas.qtgui.Plotting import DataTransform 22 from sas.qtgui.Plotting.ConvertUnits import convertUnit 23 24 from sas.qtgui.Plotting.PlotterData import Data1D 25 from sas.qtgui.Plotting.PlotterData import Data2D 26 34 27 from sas.sascalc.dataloader.loader import Loader 28 from sas.qtgui.Utilities import CustomDir 35 29 36 30 … … 109 103 if config is None: 110 104 config = _find_local_config('local_config', os.getcwd()) 111 if config is None:112 # Didn't find local config, load the default113 import sas.sasgui.guiframe.config as config114 #logging.info("using default local_config")115 else:116 pass117 #logging.info("found local_config in %s", os.getcwd())105 #if config is None: 106 # # Didn't find local config, load the default 107 # import sas.sasgui.guiframe.config as config 108 # #logging.info("using default local_config") 109 #else: 110 # pass 111 # #logging.info("found local_config in %s", os.getcwd()) 118 112 else: 119 113 pass 120 114 #logging.info("found local_config in %s", PATH_APP) 121 115 122 from sas.sasgui.guiframe.customdir import SetupCustom 123 c_conf_dir = SetupCustom().setup_dir(PATH_APP) 116 c_conf_dir = CustomDir.setup_conf_dir(PATH_APP) 124 117 125 118 custom_config = _find_local_config('custom_config', c_conf_dir) … … 183 176 DEFAULT_OPEN_FOLDER = PATH_APP 184 177 185 DEFAULT_STYLE = config.DEFAULT_STYLE178 #DEFAULT_STYLE = config.DEFAULT_STYLE 186 179 187 180 PLUGIN_STATE_EXTENSIONS = config.PLUGIN_STATE_EXTENSIONS … … 672 665 # X 673 666 if xLabel == "x": 674 data.transformX( transform.toX, transform.errToX)667 data.transformX(DataTransform.toX, DataTransform.errToX) 675 668 xLabel = "%s(%s)" % (xname, xunits) 676 669 if xLabel == "x^(2)": 677 data.transformX( transform.toX2, transform.errToX2)678 xunits = convert _unit(2, xunits)670 data.transformX(DataTransform.toX2, DataTransform.errToX2) 671 xunits = convertUnit(2, xunits) 679 672 xLabel = "%s^{2}(%s)" % (xname, xunits) 680 673 if xLabel == "x^(4)": 681 data.transformX( transform.toX4, transform.errToX4)682 xunits = convert _unit(4, xunits)674 data.transformX(DataTransform.toX4, DataTransform.errToX4) 675 xunits = convertUnit(4, xunits) 683 676 xLabel = "%s^{4}(%s)" % (xname, xunits) 684 677 if xLabel == "ln(x)": 685 data.transformX( transform.toLogX, transform.errToLogX)678 data.transformX(DataTransform.toLogX, DataTransform.errToLogX) 686 679 xLabel = "\ln{(%s)}(%s)" % (xname, xunits) 687 680 if xLabel == "log10(x)": 688 data.transformX( transform.toX_pos, transform.errToX_pos)681 data.transformX(DataTransform.toX_pos, DataTransform.errToX_pos) 689 682 xscale = 'log' 690 683 xLabel = "%s(%s)" % (xname, xunits) 691 684 if xLabel == "log10(x^(4))": 692 data.transformX( transform.toX4, transform.errToX4)693 xunits = convert _unit(4, xunits)685 data.transformX(DataTransform.toX4, DataTransform.errToX4) 686 xunits = convertUnit(4, xunits) 694 687 xLabel = "%s^{4}(%s)" % (xname, xunits) 695 688 xscale = 'log' … … 697 690 # Y 698 691 if yLabel == "ln(y)": 699 data.transformY( transform.toLogX, transform.errToLogX)692 data.transformY(DataTransform.toLogX, DataTransform.errToLogX) 700 693 yLabel = "\ln{(%s)}(%s)" % (yname, yunits) 701 694 if yLabel == "y": 702 data.transformY( transform.toX, transform.errToX)695 data.transformY(DataTransform.toX, DataTransform.errToX) 703 696 yLabel = "%s(%s)" % (yname, yunits) 704 697 if yLabel == "log10(y)": 705 data.transformY( transform.toX_pos, transform.errToX_pos)698 data.transformY(DataTransform.toX_pos, DataTransform.errToX_pos) 706 699 yscale = 'log' 707 700 yLabel = "%s(%s)" % (yname, yunits) 708 701 if yLabel == "y^(2)": 709 data.transformY( transform.toX2, transform.errToX2)710 yunits = convert _unit(2, yunits)702 data.transformY(DataTransform.toX2, DataTransform.errToX2) 703 yunits = convertUnit(2, yunits) 711 704 yLabel = "%s^{2}(%s)" % (yname, yunits) 712 705 if yLabel == "1/y": 713 data.transformY( transform.toOneOverX, transform.errOneOverX)714 yunits = convert _unit(-1, yunits)706 data.transformY(DataTransform.toOneOverX, DataTransform.errOneOverX) 707 yunits = convertUnit(-1, yunits) 715 708 yLabel = "1/%s(%s)" % (yname, yunits) 716 709 if yLabel == "y*x^(2)": 717 data.transformY( transform.toYX2, transform.errToYX2)718 xunits = convert _unit(2, xunits)710 data.transformY(DataTransform.toYX2, DataTransform.errToYX2) 711 xunits = convertUnit(2, xunits) 719 712 yLabel = "%s \ \ %s^{2}(%s%s)" % (yname, xname, yunits, xunits) 720 713 if yLabel == "y*x^(4)": 721 data.transformY( transform.toYX4, transform.errToYX4)722 xunits = convert _unit(4, xunits)714 data.transformY(DataTransform.toYX4, DataTransform.errToYX4) 715 xunits = convertUnit(4, xunits) 723 716 yLabel = "%s \ \ %s^{4}(%s%s)" % (yname, xname, yunits, xunits) 724 717 if yLabel == "1/sqrt(y)": 725 data.transformY(transform.toOneOverSqrtX, 726 transform.errOneOverSqrtX) 727 yunits = convert_unit(-0.5, yunits) 718 data.transformY(DataTransform.toOneOverSqrtX, DataTransform.errOneOverSqrtX) 719 yunits = convertUnit(-0.5, yunits) 728 720 yLabel = "1/\sqrt{%s}(%s)" % (yname, yunits) 729 721 if yLabel == "ln(y*x)": 730 data.transformY( transform.toLogXY, transform.errToLogXY)722 data.transformY(DataTransform.toLogXY, DataTransform.errToLogXY) 731 723 yLabel = "\ln{(%s \ \ %s)}(%s%s)" % (yname, xname, yunits, xunits) 732 724 if yLabel == "ln(y*x^(2))": 733 data.transformY( transform.toLogYX2, transform.errToLogYX2)734 xunits = convert _unit(2, xunits)725 data.transformY(DataTransform.toLogYX2, DataTransform.errToLogYX2) 726 xunits = convertUnit(2, xunits) 735 727 yLabel = "\ln (%s \ \ %s^{2})(%s%s)" % (yname, xname, yunits, xunits) 736 728 if yLabel == "ln(y*x^(4))": 737 data.transformY( transform.toLogYX4, transform.errToLogYX4)738 xunits = convert _unit(4, xunits)729 data.transformY(DataTransform.toLogYX4, DataTransform.errToLogYX4) 730 xunits = convertUnit(4, xunits) 739 731 yLabel = "\ln (%s \ \ %s^{4})(%s%s)" % (yname, xname, yunits, xunits) 740 732 if yLabel == "log10(y*x^(4))": 741 data.transformY( transform.toYX4, transform.errToYX4)742 xunits = convert _unit(4, xunits)733 data.transformY(DataTransform.toYX4, DataTransform.errToYX4) 734 xunits = convertUnit(4, xunits) 743 735 yscale = 'log' 744 736 yLabel = "%s \ \ %s^{4}(%s%s)" % (yname, xname, yunits, xunits) … … 792 784 else: 793 785 return unit 786 787 def parseName(name, expression): 788 """ 789 remove "_" in front of a name 790 """ 791 if re.match(expression, name) is not None: 792 word = re.split(expression, name, 1) 793 for item in word: 794 if item.lstrip().rstrip() != '': 795 return item 796 else: 797 return name
Note: See TracChangeset
for help on using the changeset viewer.