source: sasview/sansview/perspectives/fitting/pagestate.py @ 848a2ef

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 848a2ef 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
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        #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
32        ##page name
33        self.page_name = ""
34        # Contains link between  model ,all its parameters, and panel organization
35        self.parameters =[]
36        # Contains list of parameters that cannot be fitted and reference to
37        #panel objects
38        self.fixed_param =[]
39        # Contains list of parameters with dispersity and reference to
40        #panel objects
41        self.fittable_param =[]
42        ## orientation parameters
43        self.orientation_params=[]
44        ## orientation parmaters for gaussian dispersity
45        self.orientation_params_disp=[]
46        ## smearer info
47        self.smearer=None
48        #list of dispersion paramaters
49        self.disp_list =[]
50        self._disp_obj_dict={}
51        self.disp_cb_dict={}
52        #contains link between a model and selected parameters to fit
53        self.param_toFit =[]
54        ##dictionary of model type and model class
55        self.model_list_box = None
56        ## save the state of the context menu
57        self.saved_states={}
58        ## save  current value of combobox
59        self.formfactorcombobox = ""
60        self.structurecombobox  = ""
61        ## the indice of the current selection
62        self.disp_box = 0
63        ## Qrange
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
70        self.disable_smearer = True
71        ## disperity selection
72        self.enable_disp= False
73        self.disable_disp= True
74        ## plot 2D data
75        self.enable2D= False
76        ## state of selected all check button
77        self.cb1 = False
78       
79   
80    def save_data(self, data):
81        """
82            Save data
83        """
84        self.data = copy.deepcopy(data)
85
86       
87    def clone(self):
88        model=None
89        if self.model !=None:
90            model = self.model.clone()
91       
92        obj          = PageState( self.parent,model= model )
93        obj.data = copy.deepcopy(self.data)
94        obj.model_list_box = copy.deepcopy(self.model_list_box)
95        obj.manager = self.manager
96        obj.event_owner = self.event_owner
97       
98        obj.enable2D = copy.deepcopy(self.enable2D)
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)
102        obj.orientation_params =  copy.deepcopy(self.orientation_params)
103        obj.orientation_params_disp =  copy.deepcopy(self.orientation_params_disp)
104       
105        obj.enable_disp = copy.deepcopy(self.enable_disp)
106        obj.disable_disp = copy.deepcopy(self.disable_disp)
107       
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)
112        obj.enable_smearer = copy.deepcopy(self.enable_smearer)
113        obj.disable_smearer = copy.deepcopy(self.disable_smearer)
114       
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)
120        obj.smearer = copy.deepcopy(self.smearer)
121       
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
126        return obj
127
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       
151       
Note: See TracBrowser for help on using the repository browser.