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

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

working on save option

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