source: sasview/sansview/perspectives/fitting/pagestate.py @ 588f84f

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 588f84f was 0aeabc6, checked in by Gervaise Alina <gervyh@…>, 16 years ago

refactor draw model .working on save option

  • Property mode set to 100644
File size: 5.6 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
21        # flag to allow data2D plot
[cfc0913]22        self.enable2D = False
[c77d859]23        # model on which the fit would be performed
24        self.model = model
[0aeabc6]25        #if not hasattr(self.model, "_persistency_dict"):
26        #    self.model._persistency_dict = {}
27        #self.model._persistency_dict = copy.deepcopy(model._persistency_dict)
[c77d859]28        #fit page manager
29        self.manager = None
30        #Store the parent of this panel parent
31        # For this application fitpanel is the parent
32        self.parent  = parent
33        # Event_owner is the owner of model event
34        self.event_owner = None
[c9a4377]35        ##page name
[cfc0913]36        self.page_name = ""
[c77d859]37        # Contains link between  model ,all its parameters, and panel organization
[cfc0913]38        self.parameters =[]
[c77d859]39        # Contains list of parameters that cannot be fitted and reference to
40        #panel objects
[cfc0913]41        self.fixed_param =[]
[c77d859]42        # Contains list of parameters with dispersity and reference to
43        #panel objects
[cfc0913]44        self.fittable_param =[]
[60132ef]45        ## orientation parameters
46        self.orientation_params=[]
[fc6ea43]47        ## orientation parmaters for gaussian dispersity
48        self.orientation_params_disp=[]
[3370922]49        ## smearer info
50        self.smearer=None
[c77d859]51        #list of dispersion paramaters
[cfc0913]52        self.disp_list =[]
[71f0373]53        if self.model !=None:
54            self.disp_list = self.model.getDispParamList()
[c477b31]55        self._disp_obj_dict={}
56        self.disp_cb_dict={}
[dad49a0]57        self.values=[]
58        self.weights=[]
59                   
[c77d859]60        #contains link between a model and selected parameters to fit
[cfc0913]61        self.param_toFit =[]
[a074145]62        ##dictionary of model type and model class
[cfc0913]63        self.model_list_box = None
[a074145]64        ## save the state of the context menu
65        self.saved_states={}
[c77d859]66        ## save  current value of combobox
67        self.formfactorcombobox = ""
68        self.structurecombobox  = ""
[b787e68c]69        ## the indice of the current selection
70        self.disp_box = 0
[c77d859]71        ## Qrange
[cfc0913]72        ## Q range
73        self.qmin= 0.001
74        self.qmax= 0.1
75        self.npts = None
76        ## enable smearering state
77        self.enable_smearer = False
[fc6ea43]78        self.disable_smearer = True
[cfc0913]79        ## disperity selection
80        self.enable_disp= False
[fc6ea43]81        self.disable_disp= True
[c477b31]82        ## plot 2D data
83        self.enable2D= False
[cfc0913]84        ## state of selected all check button
85        self.cb1 = False
[0aeabc6]86        ## store value of chisqr
87        self.tcChi= None
[c9a4377]88       
[cfc0913]89   
90    def save_data(self, data):
[c77d859]91        """
[cfc0913]92            Save data
[c77d859]93        """
[cfc0913]94        self.data = copy.deepcopy(data)
[b787e68c]95
[cfc0913]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)
[71f0373]105     
[dcf29d7]106        obj.manager = self.manager
107        obj.event_owner = self.event_owner
[71f0373]108        obj.disp_list = copy.deepcopy(self.disp_list)
[fc6ea43]109       
[c477b31]110        obj.enable2D = copy.deepcopy(self.enable2D)
[cfc0913]111        obj.parameters = copy.deepcopy(self.parameters)
112        obj.fixed_param = copy.deepcopy(self.fixed_param)
113        obj.fittable_param = copy.deepcopy(self.fittable_param)
[60132ef]114        obj.orientation_params =  copy.deepcopy(self.orientation_params)
[fc6ea43]115        obj.orientation_params_disp =  copy.deepcopy(self.orientation_params_disp)
116       
[b787e68c]117        obj.enable_disp = copy.deepcopy(self.enable_disp)
[fc6ea43]118        obj.disable_disp = copy.deepcopy(self.disable_disp)
[0aeabc6]119        obj.tcChi = self.tcChi
120 
[c477b31]121        if len(self._disp_obj_dict)>0:
122            for k , v in self._disp_obj_dict.iteritems():
123                obj._disp_obj_dict[k]= v
[dad49a0]124        if len(self.disp_cb_dict)>0:
125            for k , v in self.disp_cb_dict.iteritems():
126                obj.disp_cb_dict[k]= v
127        obj.values = copy.deepcopy(self.values)
128        obj.weights = copy.deepcopy(self.weights)
[b787e68c]129        obj.enable_smearer = copy.deepcopy(self.enable_smearer)
[fc6ea43]130        obj.disable_smearer = copy.deepcopy(self.disable_smearer)
131       
[b787e68c]132        obj.disp_box = copy.deepcopy(self.disp_box)
133        obj.qmin = copy.deepcopy(self.qmin)
134        obj.qmax = copy.deepcopy(self.qmax)
135        obj.npts = copy.deepcopy(self.npts )
136        obj.cb1 = copy.deepcopy(self.cb1)
[3370922]137        obj.smearer = copy.deepcopy(self.smearer)
138       
[a074145]139        for name, state in self.saved_states.iteritems():
140            copy_name = copy.deepcopy(name)
141            copy_state = state.clone()
142            obj.saved_states[copy_name]= copy_state
[6f023e8]143        return obj
[c77d859]144
[71f0373]145
[cfc0913]146class PageMemento(object):
147    """
148        Store the state of a fitpage or model page of fitpanel
149    """
150    def __init__(self, state):
151        """ Initialization"""
152        self.state = state
153       
154    def setState(self,state):
155        """
156            set current state
157            @param state: new state
158        """
159        self.state = state
160       
161    def getState(self):
162        """
163            @return state
164        """
165        return self.state
166       
167       
168       
[c77d859]169       
Note: See TracBrowser for help on using the repository browser.