source: sasview/sansview/perspectives/fitting/pagestate.py @ b324aa9

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 b324aa9 was b421b1a, checked in by Jae Cho <jhjcho@…>, 15 years ago

fixed bookmark bugs

  • Property mode set to 100644
File size: 8.3 KB
RevLine 
[c77d859]1
2
[6f023e8]3import copy
[c77d859]4
[cfc0913]5class PageState(object):
[c77d859]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 = {}
[cfc0913]17        ## reset True change the state of exsiting button
18        self.reset = False
[c77d859]19        #Data used for fitting
20        self.data = data
[c99a6c5]21        #engine type
22        self.engine_type = None
[c77d859]23        # flag to allow data2D plot
[cfc0913]24        self.enable2D = False
[c77d859]25        # model on which the fit would be performed
26        self.model = model
[0aeabc6]27        #if not hasattr(self.model, "_persistency_dict"):
28        #    self.model._persistency_dict = {}
29        #self.model._persistency_dict = copy.deepcopy(model._persistency_dict)
[c77d859]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
[c9a4377]37        ##page name
[cfc0913]38        self.page_name = ""
[c77d859]39        # Contains link between  model ,all its parameters, and panel organization
[cfc0913]40        self.parameters =[]
[c77d859]41        # Contains list of parameters that cannot be fitted and reference to
42        #panel objects
[cfc0913]43        self.fixed_param =[]
[c77d859]44        # Contains list of parameters with dispersity and reference to
45        #panel objects
[cfc0913]46        self.fittable_param =[]
[60132ef]47        ## orientation parameters
48        self.orientation_params=[]
[fc6ea43]49        ## orientation parmaters for gaussian dispersity
50        self.orientation_params_disp=[]
[3370922]51        ## smearer info
52        self.smearer=None
[c77d859]53        #list of dispersion paramaters
[cfc0913]54        self.disp_list =[]
[71f0373]55        if self.model !=None:
56            self.disp_list = self.model.getDispParamList()
[c477b31]57        self._disp_obj_dict={}
58        self.disp_cb_dict={}
[dad49a0]59        self.values=[]
60        self.weights=[]
61                   
[c77d859]62        #contains link between a model and selected parameters to fit
[cfc0913]63        self.param_toFit =[]
[a074145]64        ##dictionary of model type and model class
[cfc0913]65        self.model_list_box = None
[a074145]66        ## save the state of the context menu
67        self.saved_states={}
[240b9966]68        ## save selection of combobox
[3b9e023]69        self.formfactorcombobox = None
70        self.structurecombobox  = None
[240b9966]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
[b787e68c]76        ## the indice of the current selection
77        self.disp_box = 0
[c77d859]78        ## Qrange
[cfc0913]79        ## Q range
80        self.qmin= 0.001
81        self.qmax= 0.1
82        self.npts = None
[240b9966]83        self.name=""
[cfc0913]84        ## enable smearering state
85        self.enable_smearer = False
[fc6ea43]86        self.disable_smearer = True
[cfc0913]87        ## disperity selection
88        self.enable_disp= False
[fc6ea43]89        self.disable_disp= True
[c477b31]90        ## plot 2D data
91        self.enable2D= False
[cfc0913]92        ## state of selected all check button
93        self.cb1 = False
[0aeabc6]94        ## store value of chisqr
95        self.tcChi= None
[240b9966]96   
[6f023e8]97    def clone(self):
98        model=None
99        if self.model !=None:
100            model = self.model.clone()
101       
[cfc0913]102        obj          = PageState( self.parent,model= model )
[6f023e8]103        obj.data = copy.deepcopy(self.data)
[dcf29d7]104        obj.model_list_box = copy.deepcopy(self.model_list_box)
[c99a6c5]105        obj.engine_type = copy.deepcopy(self.engine_type)
[240b9966]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       
[dcf29d7]115        obj.manager = self.manager
116        obj.event_owner = self.event_owner
[71f0373]117        obj.disp_list = copy.deepcopy(self.disp_list)
[fc6ea43]118       
[c477b31]119        obj.enable2D = copy.deepcopy(self.enable2D)
[cfc0913]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)
[60132ef]123        obj.orientation_params =  copy.deepcopy(self.orientation_params)
[fc6ea43]124        obj.orientation_params_disp =  copy.deepcopy(self.orientation_params_disp)
[b787e68c]125        obj.enable_disp = copy.deepcopy(self.enable_disp)
[fc6ea43]126        obj.disable_disp = copy.deepcopy(self.disable_disp)
[0aeabc6]127        obj.tcChi = self.tcChi
128 
[c477b31]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
[dad49a0]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
[b421b1a]135               
[dad49a0]136        obj.values = copy.deepcopy(self.values)
137        obj.weights = copy.deepcopy(self.weights)
[b787e68c]138        obj.enable_smearer = copy.deepcopy(self.enable_smearer)
[fc6ea43]139        obj.disable_smearer = copy.deepcopy(self.disable_smearer)
[b421b1a]140       
[b787e68c]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)
[3370922]146        obj.smearer = copy.deepcopy(self.smearer)
147       
[a074145]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
[6f023e8]152        return obj
[c77d859]153
[240b9966]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
[71f0373]202
[cfc0913]203       
204       
[c77d859]205       
Note: See TracBrowser for help on using the repository browser.