Changeset a684c64 in sasview for src/sas/sasgui/perspectives/corfunc


Ignore:
Timestamp:
Jul 11, 2016 4:36:55 AM (8 years ago)
Author:
lewis
Branches:
master, 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, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
Children:
3560196
Parents:
173ee3a
git-author:
Lewis O'Driscoll <lewis.o'driscoll@…> (07/08/16 11:31:43)
git-committer:
Lewis O'Driscoll <lewis.o'driscoll@…> (07/11/16 04:36:55)
Message:

Implement saving/loading calculated parameters on project save

Location:
src/sas/sasgui/perspectives/corfunc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/sas/sasgui/perspectives/corfunc/corfunc_panel.py

    r1150083 ra684c64  
    2020    'd0': "Average Core Thickness: ", 
    2121    'A': "PolyDispersity: ", 
    22     'Lc/max': "Filling Fraction: " 
     22    'fill': "Filling Fraction: " 
    2323} 
    2424 
     
    6262        self.qmax = (0, 0) 
    6363        self.background = 0 
     64        self.extracted_params = None 
    6465        # Dictionary for saving refs to text boxes used to display output data 
    6566        self._output_boxes = None 
     
    9798        if self.state.background is not None: 
    9899            self.set_background(self.state.background) 
     100        if self.state.outputs is not None and self.state.outputs != {}: 
     101            self.set_extracted_params(self.state.outputs) 
    99102 
    100103    def get_state(self): 
     
    107110        state.set_saved_state('qmax2_tcl', self.qmax[1]) 
    108111        state.set_saved_state('background_tcl', self.background) 
     112        state.outputs = self.extracted_params 
    109113        if self._data is not None: 
    110114            state.file = self._data.title 
     
    134138        self._calculator.set_data(data) 
    135139        # Reset the outputs 
    136         for key in OUTPUT_STRINGS.keys(): 
    137             self._output_boxes[key].SetValue("-") 
     140        self.set_extracted_params(None) 
    138141        if self._manager is not None: 
    139142            from sas.sasgui.perspectives.corfunc.corfunc import IQ_DATA_LABEL 
     
    220223                StatusEvent(status=msg, info="Error")) 
    221224            return 
    222         for key in OUTPUT_STRINGS.keys(): 
    223             value = params[key] 
    224             self._output_boxes[key].SetValue(value) 
     225        self.set_extracted_params(params) 
    225226 
    226227    def save_project(self, doc=None): 
     
    257258        self._background_input.SetValue(str(bg)) 
    258259        self._calculator.background = bg 
     260 
     261    def set_extracted_params(self, params): 
     262        self.extracted_params = params 
     263        if params is None: 
     264            for key in OUTPUT_STRINGS.keys(): 
     265                self._output_boxes[key].SetValue('-') 
     266        else: 
     267            for key in OUTPUT_STRINGS.keys(): 
     268                value = params[key] 
     269                self._output_boxes[key].SetValue(value) 
    259270 
    260271 
  • src/sas/sasgui/perspectives/corfunc/corfunc_state.py

    r6970e51 ra684c64  
    2424# List of output parameters, used by __str__ 
    2525output_list = [ 
    26     ["long_period", "Long Period"], 
    27     ["hard_block_thickness", "Average Hard Block Thickness"], 
    28     ["interface_thickness", "Average Interface Thickness"], 
    29     ["core_thickness", "Average Core Thickness"], 
    30     ["polydispersity", "PolyDispersity"], 
    31     ["filling", "Filling Fraction"] 
     26    ['max', "Long Period (A): "], 
     27    ['Lc', "Average Hard Block Thickness (A): "], 
     28    ['dtr', "Average Interface Thickness (A): "], 
     29    ['d0', "Average Core Thickness: "], 
     30    ['A', "PolyDispersity: "], 
     31    ['fill', "Filling Fraction: "] 
    3232] 
    3333 
     
    4444        self.qmax = [0, 0] 
    4545        self.background = None 
    46         self.outputs = None 
     46        self.outputs = {} 
    4747 
    4848        self.saved_state = DEFAULT_STATE 
     
    160160            state.appendChild(element) 
    161161 
     162        # Output parameters 
     163        output = new_doc.createElement("output") 
     164        top_element.appendChild(output) 
     165        for item in output_list: 
     166            element = new_doc.createElement(item[0]) 
     167            element.appendChild(new_doc.createTextNode(self.outputs[item[0]])) 
     168            output.appendChild(element) 
    162169 
    163170        # Save the file or return the original document with the state 
     
    206213                        self.set_saved_state(name=item, value=value) 
    207214 
     215            # Parse outputs 
     216            entry = get_content('ns:output', node) 
     217            if entry is not None: 
     218                for item in output_list: 
     219                    parameter = get_content("ns:{}".format(item[0]), entry) 
     220                    if parameter is not None: 
     221                        self.outputs[item[0]] = parameter.text.strip() 
     222 
    208223 
    209224 
     
    214229 
    215230    type_name = "Corfunc" 
     231 
     232    type = ["Invariant file (*.inv)|*.inv", 
     233            "SASView file (*.svs)|*.svs"] 
     234 
     235    ext = ['.cor', '.COR', '.svs', '.SVS'] 
    216236 
    217237    def __init__(self, callback): 
     
    234254            basename = os.path.basename(path) 
    235255            root, ext = os.path.splitext(basename) 
    236             if ext.lower() != '.xml' and ext.lower() != '.svs': 
     256            if not ext.lower() in self.ext: 
    237257                raise IOError, "{} is not a supported file type".format(ext) 
    238258            tree = etree.parse(path, parser=etree.ETCompatXMLParser()) 
Note: See TracChangeset for help on using the changeset viewer.