source: sasview/sansview/perspectives/fitting/pagestate.py @ 24b8d5c

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 24b8d5c was c477b31, checked in by Gervaise Alina <gervyh@…>, 16 years ago

saving option for dispersity

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