source: sasview/guiframe/data_state.py @ 783940c

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 783940c was 5080cda, checked in by Gervaise Alina <gervyh@…>, 14 years ago

remove wx call from data manager

  • Property mode set to 100644
File size: 3.1 KB
Line 
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"""
12import copy
13
14
15class DataState(object):
16    """
17     Store information about data
18    """
19    def __init__(self, data, parent=None):
20        """
21       
22        """
23        self.parent = parent
24        self.data = data
25        self.name = ""
26        self.path = None
27        self.theory_list = {}
28        self.message = ""
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:
38            _str += "Data: %s \n" % str(self.data)
39           
40        _str += "Theories available: %s \n" % len(self.theory_list)
41        if self.theory_list:
42            for id, item in self.theory_list.iteritems():
43                theory_data, theory_state = item
44                _str += "Theory name : %s \n" % str(theory_data.name)
45                _str += "Theory ID : %s \n" % str(id)
46                _str += "Theory info: \n"
47                _str += str(theory_data)
48               
49        return _str
50       
51    def clone(self):
52        obj = DataState(copy.deepcopy(self.data))
53        obj.parent = self.parent
54        obj.name = self.name
55        obj.path = self.path
56        obj.message = self.message
57        obj.id = self.id
58        for id, item in self.theory_list.iteritems():
59            theory_data, theory_state = item
60            state = None
61            if theory_state is not None:
62                state = theory_state.clone()
63            obj.theory_list[id] = [copy.deepcopy(theory_data), 
64                                   state]
65        return obj
66       
67    def set_name(self, name):
68        self.name = name
69       
70    def get_name(self):
71        return self.name
72   
73    def set_data(self, data):
74        self.data = data
75       
76    def get_data(self):
77        return self.data
78   
79    def set_path(self, path):
80        """
81        Set the path of the loaded data
82        """
83        self.path = path
84       
85    def get_path(self):
86        """
87        return the path of the loaded data
88        """
89        return self.path
90   
91    def set_theory(self, theory_data, theory_state=None):
92        """
93        """
94        self.theory_list[theory_data.id] = [theory_data, theory_state]
95        data, state = self.theory_list.values()[0]
96       
97    def get_theory(self):
98        return self.theory_list
99   
100    def get_message(self):
101        """
102        return message
103        """
104        return self.message
105   
106 
Note: See TracBrowser for help on using the repository browser.