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
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        #self.model._persistency_dict = copy.deepcopy(model._persistency_dict)
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
35        ##page name
36        self.page_name = ""
37        # Contains link between  model ,all its parameters, and panel organization
38        self.parameters =[]
39        # Contains list of parameters that cannot be fitted and reference to
40        #panel objects
41        self.fixed_param =[]
42        # Contains list of parameters with dispersity and reference to
43        #panel objects
44        self.fittable_param =[]
45        ## orientation parameters
46        self.orientation_params=[]
47        ## orientation parmaters for gaussian dispersity
48        self.orientation_params_disp=[]
49        ## smearer info
50        self.smearer=None
51        #list of dispersion paramaters
52        self.disp_list =[]
53        if self.model !=None:
54            self.disp_list = self.model.getDispParamList()
55        self._disp_obj_dict={}
56        self.disp_cb_dict={}
57        self.values=[]
58        self.weights=[]
59                   
60        #contains link between a model and selected parameters to fit
61        self.param_toFit =[]
62        ##dictionary of model type and model class
63        self.model_list_box = None
64        ## save the state of the context menu
65        self.saved_states={}
66        ## save  current value of combobox
67        self.formfactorcombobox = ""
68        self.structurecombobox  = ""
69        ## the indice of the current selection
70        self.disp_box = 0
71        ## Qrange
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
78        self.disable_smearer = True
79        ## disperity selection
80        self.enable_disp= False
81        self.disable_disp= True
82        ## plot 2D data
83        self.enable2D= False
84        ## state of selected all check button
85        self.cb1 = False
86        ## store value of chisqr
87        self.tcChi= None
88       
89   
90    def save_data(self, data):
91        """
92            Save data
93        """
94        self.data = copy.deepcopy(data)
95
96       
97    def clone(self):
98        model=None
99        if self.model !=None:
100            model = self.model.clone()
101       
102        obj          = PageState( self.parent,model= model )
103        obj.data = copy.deepcopy(self.data)
104        obj.model_list_box = copy.deepcopy(self.model_list_box)
105     
106        obj.manager = self.manager
107        obj.event_owner = self.event_owner
108        obj.disp_list = copy.deepcopy(self.disp_list)
109       
110        obj.enable2D = copy.deepcopy(self.enable2D)
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)
114        obj.orientation_params =  copy.deepcopy(self.orientation_params)
115        obj.orientation_params_disp =  copy.deepcopy(self.orientation_params_disp)
116       
117        obj.enable_disp = copy.deepcopy(self.enable_disp)
118        obj.disable_disp = copy.deepcopy(self.disable_disp)
119        obj.tcChi = self.tcChi
120 
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
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)
129        obj.enable_smearer = copy.deepcopy(self.enable_smearer)
130        obj.disable_smearer = copy.deepcopy(self.disable_smearer)
131       
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)
137        obj.smearer = copy.deepcopy(self.smearer)
138       
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
143        return obj
144
145
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       
169       
Note: See TracBrowser for help on using the repository browser.