source: sasview/sansguiframe/src/sans/guiframe/data_state.py @ 6a7cf2c

ESS_GUIESS_GUI_DocsESS_GUI_batch_fittingESS_GUI_bumps_abstractionESS_GUI_iss1116ESS_GUI_iss879ESS_GUI_iss959ESS_GUI_openclESS_GUI_orderingESS_GUI_sync_sascalccostrafo411magnetic_scattrelease-4.1.1release-4.1.2release-4.2.2release_4.0.1ticket-1009ticket-1094-headlessticket-1242-2d-resolutionticket-1243ticket-1249ticket885unittest-saveload
Last change on this file since 6a7cf2c was 8c347a6, checked in by Gervaise Alina <gervyh@…>, 13 years ago

moving guiframe under sansguiframe

  • Property mode set to 100644
File size: 3.4 KB
RevLine 
[3feed3e]1################################################################################
2#This software was developed by the University of Tennessee as part of the
3#Distributed Data Analysis of Neutron Scattering Experiments (DANSE)
4#project funded by the US National Science Foundation.
5#
6#See the license text in license.txt
7#
8#copyright 2010, University of Tennessee
9################################################################################
10"""
11"""
[c70eb7c]12import copy
13
[3feed3e]14
15class DataState(object):
16    """
17     Store information about data
18    """
[ec611aad]19    def __init__(self, data=None, parent=None):
[3feed3e]20        """
21       
22        """
23        self.parent = parent
[584c4c4]24        self.data = data
25        self.name = ""
26        self.path = None
[5c4b674]27        self.theory_list = {}
[584c4c4]28        self.message = ""
[c70eb7c]29        self.id = None
30       
31    def __str__(self):
32        _str  = ""
33        _str += "State with ID : %s \n" % str(self.id)
34        if self.data is not None:
35            _str += "Data name : %s \n" % str(self.data.name)
36            _str += "Data ID : %s \n" % str(self.data.id)
37        else:
[a3c96f7a]38            _str += "Theory Data: %s \n" % str(self.theory_data)
39        if self.theory_data is not None:
40            _str += "Data name : %s \n" % str(self.theory_data.name)
41            _str += "Theory Data ID : %s \n" % str(self.theory_data.id)
42        else:
43            _str += "Theory Data: %s \n" % str(self.theory_data)
[c70eb7c]44           
[df22224]45        _str += "Theories available: %s \n" % len(self.theory_list)
[c70eb7c]46        if self.theory_list:
47            for id, item in self.theory_list.iteritems():
48                theory_data, theory_state = item
49                _str += "Theory name : %s \n" % str(theory_data.name)
50                _str += "Theory ID : %s \n" % str(id)
[df22224]51                _str += "Theory info: \n"
[c70eb7c]52                _str += str(theory_data)
[5080cda]53               
[c70eb7c]54        return _str
55       
56    def clone(self):
57        obj = DataState(copy.deepcopy(self.data))
58        obj.parent = self.parent
59        obj.name = self.name
60        obj.path = self.path
61        obj.message = self.message
62        obj.id = self.id
63        for id, item in self.theory_list.iteritems():
64            theory_data, theory_state = item
65            state = None
66            if theory_state is not None:
67                state = theory_state.clone()
68            obj.theory_list[id] = [copy.deepcopy(theory_data), 
69                                   state]
70        return obj
[3feed3e]71       
72    def set_name(self, name):
[584c4c4]73        self.name = name
[c70eb7c]74       
[3feed3e]75    def get_name(self):
[584c4c4]76        return self.name
[c70eb7c]77   
[3feed3e]78    def set_data(self, data):
[a3c96f7a]79        """
80        """
[ec611aad]81        self.data = data
82 
83   
84    def get_data(self):
[a3c96f7a]85        """
86        """
[584c4c4]87        return self.data
[3feed3e]88   
89    def set_path(self, path):
90        """
91        Set the path of the loaded data
92        """
[584c4c4]93        self.path = path
[3feed3e]94       
95    def get_path(self):
96        """
97        return the path of the loaded data
98        """
[584c4c4]99        return self.path
[3feed3e]100   
[c70eb7c]101    def set_theory(self, theory_data, theory_state=None):
[3feed3e]102        """
103        """
[c70eb7c]104        self.theory_list[theory_data.id] = [theory_data, theory_state]
[df22224]105        data, state = self.theory_list.values()[0]
[552b3d5]106       
[3feed3e]107    def get_theory(self):
[584c4c4]108        return self.theory_list
[3feed3e]109   
110    def get_message(self):
111        """
112        return message
113        """
[584c4c4]114        return self.message
[3feed3e]115   
116 
Note: See TracBrowser for help on using the repository browser.