source: sasview/theoryview/perspectives/theory/pagestate.py @ 023c8e2

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 023c8e2 was 74755ff, checked in by Gervaise Alina <gervyh@…>, 14 years ago

working on documentation theory view

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