source: sasview/theoryview/perspectives/theory/pagestate.py @ 2eaf74d

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 2eaf74d was 0277d084, checked in by Gervaise Alina <gervyh@…>, 15 years ago

add theory view

  • Property mode set to 100644
File size: 8.3 KB
Line 
1
2
3import copy
4
5class PageState(object):
6    """
7        Contains info to reconstruct a page
8    """
9    def __init__(self, parent,model=None, data=None):
10       
11        """
12            Initialization of the Panel
13        """
14        #TODO: remove this once the inheritence is cleaned up
15        ## Data member to store the dispersion object created
16        self._disp_obj_dict = {}
17        ## reset True change the state of exsiting button
18        self.reset = False
19        #Data used for fitting
20        self.data = data
21        #engine type
22        self.engine_type = None
23        # flag to allow data2D plot
24        self.enable2D = False
25        # model on which the fit would be performed
26        self.model = model
27        #if not hasattr(self.model, "_persistency_dict"):
28        #    self.model._persistency_dict = {}
29        #self.model._persistency_dict = copy.deepcopy(model._persistency_dict)
30        #fit page manager
31        self.manager = None
32        #Store the parent of this panel parent
33        # For this application fitpanel is the parent
34        self.parent  = parent
35        # Event_owner is the owner of model event
36        self.event_owner = None
37        ##page name
38        self.page_name = ""
39        # Contains link between  model ,all its parameters, and panel organization
40        self.parameters =[]
41        # Contains list of parameters that cannot be fitted and reference to
42        #panel objects
43        self.fixed_param =[]
44        # Contains list of parameters with dispersity and reference to
45        #panel objects
46        self.fittable_param =[]
47        ## orientation parameters
48        self.orientation_params=[]
49        ## orientation parmaters for gaussian dispersity
50        self.orientation_params_disp=[]
51        ## smearer info
52        self.smearer=None
53        #list of dispersion paramaters
54        self.disp_list =[]
55        if self.model !=None:
56            self.disp_list = self.model.getDispParamList()
57        self._disp_obj_dict={}
58        self.disp_cb_dict={}
59        self.values=[]
60        self.weights=[]
61                   
62        #contains link between a model and selected parameters to fit
63        self.param_toFit =[]
64        ##dictionary of model type and model class
65        self.model_list_box = None
66        ## save the state of the context menu
67        self.saved_states={}
68        ## save selection of combobox
69        self.formfactorcombobox = None
70        self.structurecombobox  = None
71        ## radio box to select type of model
72        self.shape_rbutton = False
73        self.shape_indep_rbutton = False
74        self.struct_rbutton = False
75        self.plugin_rbutton = False
76        ## the indice of the current selection
77        self.disp_box = 0
78        ## Qrange
79        ## Q range
80        self.qmin= 0.001
81        self.qmax= 0.1
82        self.npts = None
83        self.name=""
84        ## enable smearering state
85        self.enable_smearer = False
86        self.disable_smearer = True
87        ## disperity selection
88        self.enable_disp= False
89        self.disable_disp= True
90        ## plot 2D data
91        self.enable2D= False
92        ## state of selected all check button
93        self.cb1 = False
94        ## store value of chisqr
95        self.tcChi= None
96   
97    def clone(self):
98        model=None
99        if self.model !=None:
100            model = self.model.clone()
101       
102        obj          = PageState( self.parent,model= model )
103        obj.data = copy.deepcopy(self.data)
104        obj.model_list_box = copy.deepcopy(self.model_list_box)
105        obj.engine_type = copy.deepcopy(self.engine_type)
106       
107        obj.formfactorcombobox= self.formfactorcombobox
108        obj.structurecombobox  =self.structurecombobox 
109       
110        obj.shape_rbutton = self.shape_rbutton
111        obj.shape_indep_rbutton = self.shape_indep_rbutton
112        obj.struct_rbutton = self.struct_rbutton
113        obj.plugin_rbutton = self.plugin_rbutton
114       
115        obj.manager = self.manager
116        obj.event_owner = self.event_owner
117        obj.disp_list = copy.deepcopy(self.disp_list)
118       
119        obj.enable2D = copy.deepcopy(self.enable2D)
120        obj.parameters = copy.deepcopy(self.parameters)
121        obj.fixed_param = copy.deepcopy(self.fixed_param)
122        obj.fittable_param = copy.deepcopy(self.fittable_param)
123        obj.orientation_params =  copy.deepcopy(self.orientation_params)
124        obj.orientation_params_disp =  copy.deepcopy(self.orientation_params_disp)
125        obj.enable_disp = copy.deepcopy(self.enable_disp)
126        obj.disable_disp = copy.deepcopy(self.disable_disp)
127        obj.tcChi = self.tcChi
128 
129        if len(self._disp_obj_dict)>0:
130            for k , v in self._disp_obj_dict.iteritems():
131                obj._disp_obj_dict[k]= v
132        if len(self.disp_cb_dict)>0:
133            for k , v in self.disp_cb_dict.iteritems():
134                obj.disp_cb_dict[k]= v
135               
136        obj.values = copy.deepcopy(self.values)
137        obj.weights = copy.deepcopy(self.weights)
138        obj.enable_smearer = copy.deepcopy(self.enable_smearer)
139        obj.disable_smearer = copy.deepcopy(self.disable_smearer)
140       
141        obj.disp_box = copy.deepcopy(self.disp_box)
142        obj.qmin = copy.deepcopy(self.qmin)
143        obj.qmax = copy.deepcopy(self.qmax)
144        obj.npts = copy.deepcopy(self.npts )
145        obj.cb1 = copy.deepcopy(self.cb1)
146        obj.smearer = copy.deepcopy(self.smearer)
147       
148        for name, state in self.saved_states.iteritems():
149            copy_name = copy.deepcopy(name)
150            copy_state = state.clone()
151            obj.saved_states[copy_name]= copy_state
152        return obj
153
154     
155    def old__repr__(self):
156        """ output string for printing"""
157        rep = "\n\nState name: %s\n"%self.name
158        rep +="data : %s\n"% str(self.data)
159        rep += "Plotting Range: min: %s, max: %s, steps: %s\n"%(str(self.qmin),
160                                                str(self.qmax),str(self.npts))
161        rep +="model  : %s\n\n"% str(self.model)
162        rep +="number parameters(self.parameters): %s\n"%len(self.parameters)
163        for item in self.parameters:
164            rep += "parameter name: %s \n"%str(item[1])
165            rep += "value: %s\n"%str(item[2])
166            rep += "selected: %s\n"%str(item[0])
167            rep += "error displayed : %s \n"%str(item[4][0])
168            rep += "error value:%s \n"%str(item[4][1])
169            rep += "minimum displayed : %s \n"%str(item[5][0])
170            rep += "minimum value : %s \n"%str(item[5][1])
171            rep += "maximum displayed : %s \n"%str(item[6][0])
172            rep += "maximum value : %s \n"%str(item[6][1])
173            rep += "parameter unit: %s\n\n"%str(item[7])
174        rep +="number orientation parameters"
175        rep +="(self.orientation_params): %s\n"%len(self.orientation_params)
176        for item in self.orientation_params:
177            rep += "parameter name: %s \n"%str(item[1])
178            rep += "value: %s\n"%str(item[2])
179            rep += "selected: %s\n"%str(item[0])
180            rep += "error displayed : %s \n"%str(item[4][0])
181            rep += "error value:%s \n"%str(item[4][1])
182            rep += "minimum displayed : %s \n"%str(item[5][0])
183            rep += "minimum value : %s \n"%str(item[5][1])
184            rep += "maximum displayed : %s \n"%str(item[6][0])
185            rep += "maximum value : %s \n"%str(item[6][1])
186            rep += "parameter unit: %s\n\n"%str(item[7])
187        rep +="number dispersity parameters"
188        rep +="(self.orientation_params_disp): %s\n"%len(self.orientation_params_disp)
189        for item in self.orientation_params_disp:
190            rep += "parameter name: %s \n"%str(item[1])
191            rep += "value: %s\n"%str(item[2])
192            rep += "selected: %s\n"%str(item[0])
193            rep += "error displayed : %s \n"%str(item[4][0])
194            rep += "error value:%s \n"%str(item[4][1])
195            rep += "minimum displayed : %s \n"%str(item[5][0])
196            rep += "minimum value : %s \n"%str(item[5][1])
197            rep += "maximum displayed : %s \n"%str(item[6][0])
198            rep += "maximum value : %s \n"%str(item[6][1])
199            rep += "parameter unit: %s\n\n"%str(item[7])
200       
201        return rep
202
203       
204       
205       
Note: See TracBrowser for help on using the repository browser.