[d89f09b] | 1 | |
---|
[2140e68] | 2 | import sys,re,string, wx |
---|
| 3 | import wx.lib.newevent |
---|
[4ce74917] | 4 | from sans.guiframe.events import StatusEvent |
---|
[4bd492f] | 5 | from sans.guiframe.panel_base import PanelBase |
---|
| 6 | from wx.lib.scrolledpanel import ScrolledPanel |
---|
[1976004] | 7 | from sans.guiframe.events import PanelOnFocusEvent |
---|
[c99a6c5] | 8 | #Control panel width |
---|
[6e9976b] | 9 | if sys.platform.count("darwin")==0: |
---|
[c99a6c5] | 10 | PANEL_WID = 420 |
---|
[f1aa385] | 11 | FONT_VARIANT = 0 |
---|
[c99a6c5] | 12 | else: |
---|
| 13 | PANEL_WID = 490 |
---|
[f1aa385] | 14 | FONT_VARIANT = 1 |
---|
[8bd4dc0] | 15 | |
---|
| 16 | def get_fittableParam( model): |
---|
[2140e68] | 17 | """ |
---|
[5062bbf] | 18 | return list of fittable parameters name of a model |
---|
| 19 | |
---|
| 20 | :param model: the model used |
---|
| 21 | |
---|
[2140e68] | 22 | """ |
---|
[8bd4dc0] | 23 | fittable_param=[] |
---|
| 24 | for item in model.getParamList(): |
---|
| 25 | if not item in model.getDispParamList(): |
---|
[fb59ed9] | 26 | if not item in model.non_fittable: |
---|
| 27 | fittable_param.append(item) |
---|
[8bd4dc0] | 28 | |
---|
| 29 | for item in model.fixed: |
---|
| 30 | fittable_param.append(item) |
---|
[2140e68] | 31 | |
---|
[8bd4dc0] | 32 | return fittable_param |
---|
[2140e68] | 33 | |
---|
[4bd492f] | 34 | class SimultaneousFitPage(ScrolledPanel, PanelBase): |
---|
[d89f09b] | 35 | """ |
---|
[5062bbf] | 36 | Simultaneous fitting panel |
---|
| 37 | All that needs to be defined are the |
---|
| 38 | two data members window_name and window_caption |
---|
[d89f09b] | 39 | """ |
---|
[925a30e] | 40 | ## Internal name for the AUI manager |
---|
[d89f09b] | 41 | window_name = "simultaneous Fit page" |
---|
| 42 | ## Title to appear on top of the window |
---|
| 43 | window_caption = "Simultaneous Fit Page" |
---|
| 44 | |
---|
| 45 | |
---|
[2140e68] | 46 | def __init__(self, parent,page_finder ={}, *args, **kwargs): |
---|
[4bd492f] | 47 | ScrolledPanel.__init__(self, parent,style= wx.FULL_REPAINT_ON_RESIZE ) |
---|
| 48 | PanelBase.__init__(self, parent) |
---|
[d89f09b] | 49 | """ |
---|
[5062bbf] | 50 | Simultaneous page display |
---|
[d89f09b] | 51 | """ |
---|
[00daba9] | 52 | self.SetupScrolling() |
---|
[f1aa385] | 53 | ##Font size |
---|
| 54 | self.SetWindowVariant(variant = FONT_VARIANT) |
---|
[922497f] | 55 | self.uid = wx.NewId() |
---|
[d89f09b] | 56 | self.parent = parent |
---|
[2140e68] | 57 | ## store page_finder |
---|
[b28717b] | 58 | self.page_finder = page_finder |
---|
[2140e68] | 59 | ## list contaning info to set constraint |
---|
[6bbeacd4] | 60 | ## look like self.constraint_dict[page_id]= page |
---|
[2140e68] | 61 | self.constraint_dict={} |
---|
[1b14795] | 62 | ## item list |
---|
| 63 | # self.constraints_list=[combobox1, combobox2,=,textcrtl, button ] |
---|
[2140e68] | 64 | self.constraints_list=[] |
---|
| 65 | ## list of current model |
---|
| 66 | self.model_list=[] |
---|
| 67 | ## selected mdoel to fit |
---|
| 68 | self.model_toFit=[] |
---|
[b28717b] | 69 | ## number of constraint |
---|
| 70 | self.nb_constraint= 0 |
---|
[dc613d6] | 71 | self.uid = wx.NewId() |
---|
[b28717b] | 72 | ## draw page |
---|
[2140e68] | 73 | self.define_page_structure() |
---|
[b28717b] | 74 | self.draw_page() |
---|
[2140e68] | 75 | self.set_layout() |
---|
| 76 | |
---|
| 77 | def define_page_structure(self): |
---|
| 78 | """ |
---|
[5062bbf] | 79 | Create empty sizer for a panel |
---|
[2140e68] | 80 | """ |
---|
[d89f09b] | 81 | self.vbox = wx.BoxSizer(wx.VERTICAL) |
---|
[2140e68] | 82 | self.sizer1 = wx.BoxSizer(wx.VERTICAL) |
---|
| 83 | self.sizer2 = wx.BoxSizer(wx.VERTICAL) |
---|
[8bd4dc0] | 84 | self.sizer3 = wx.BoxSizer(wx.VERTICAL) |
---|
[c99a6c5] | 85 | |
---|
| 86 | self.sizer1.SetMinSize((PANEL_WID,-1)) |
---|
| 87 | self.sizer2.SetMinSize((PANEL_WID,-1)) |
---|
| 88 | self.sizer3.SetMinSize((PANEL_WID,-1)) |
---|
[d89f09b] | 89 | self.vbox.Add(self.sizer1) |
---|
| 90 | self.vbox.Add(self.sizer2) |
---|
[8bd4dc0] | 91 | self.vbox.Add(self.sizer3) |
---|
[51d47b5] | 92 | |
---|
[2140e68] | 93 | def set_scroll(self): |
---|
[5062bbf] | 94 | """ |
---|
| 95 | """ |
---|
[e1a97f8] | 96 | #self.SetScrollbars(20,20,25,65) |
---|
[2140e68] | 97 | self.Layout() |
---|
| 98 | |
---|
| 99 | def set_layout(self): |
---|
| 100 | """ |
---|
[5062bbf] | 101 | layout |
---|
[2140e68] | 102 | """ |
---|
[d89f09b] | 103 | self.vbox.Layout() |
---|
| 104 | self.vbox.Fit(self) |
---|
| 105 | self.SetSizer(self.vbox) |
---|
[2140e68] | 106 | self.set_scroll() |
---|
[d89f09b] | 107 | self.Centre() |
---|
| 108 | |
---|
[8bd4dc0] | 109 | def onRemove(self, event): |
---|
| 110 | """ |
---|
[5062bbf] | 111 | Remove constraint fields |
---|
[8bd4dc0] | 112 | """ |
---|
[a911b48] | 113 | if len(self.constraints_list)==1: |
---|
| 114 | self.hide_constraint.SetValue(True) |
---|
| 115 | self._hide_constraint() |
---|
| 116 | return |
---|
| 117 | if len(self.constraints_list)==0: |
---|
[8bd4dc0] | 118 | return |
---|
| 119 | for item in self.constraints_list: |
---|
| 120 | length= len(item) |
---|
| 121 | if event.GetId()==item[length-2].GetId(): |
---|
| 122 | sizer= item[length-1] |
---|
[bb7d8a4] | 123 | sizer.Clear(True) |
---|
[8bd4dc0] | 124 | self.sizer_constraints.Remove(sizer) |
---|
[1b14795] | 125 | #self.SetScrollbars(20,20,25,65) |
---|
[8bd4dc0] | 126 | self.constraints_list.remove(item) |
---|
| 127 | self.nb_constraint -= 1 |
---|
[1b14795] | 128 | self.sizer2.Layout() |
---|
| 129 | self.Layout() |
---|
[8bd4dc0] | 130 | break |
---|
[1b14795] | 131 | self._onAdd_constraint(None) |
---|
| 132 | |
---|
[922497f] | 133 | def onFit(self, event): |
---|
[5062bbf] | 134 | """ |
---|
| 135 | signal for fitting |
---|
| 136 | |
---|
| 137 | """ |
---|
[2140e68] | 138 | ## making sure all parameters content a constraint |
---|
| 139 | ## validity of the constraint expression is own by fit engine |
---|
[1153d0e] | 140 | if self.parent._manager._fit_engine != "park" and\ |
---|
| 141 | self._manager.sim_page.uid == self.uid: |
---|
| 142 | msg = "The FitEnging will be set to 'Park' fit engine\n" |
---|
| 143 | msg += " for the simultaneous fit..." |
---|
| 144 | #wx.MessageBox(msg, 'Info') |
---|
| 145 | wx.PostEvent(self._manager.parent, StatusEvent(status=\ |
---|
| 146 | "Fitting: %s"%msg, info="info")) |
---|
[ac11e40] | 147 | if self.show_constraint.GetValue(): |
---|
[00daba9] | 148 | if not self._set_constraint(): |
---|
| 149 | return |
---|
[2140e68] | 150 | ## model was actually selected from this page to be fit |
---|
[3215d32] | 151 | if len(self.model_toFit) >= 1 : |
---|
[66ff250] | 152 | self.manager._reset_schedule_problem(value=0) |
---|
[6f023e8] | 153 | for item in self.model_list: |
---|
| 154 | if item[0].GetValue(): |
---|
[c647377] | 155 | self.manager.schedule_for_fit(value=1, uid=item[2]) |
---|
[1b14795] | 156 | try: |
---|
[31469d50] | 157 | if not self.manager.onFit(uid=self.uid): |
---|
| 158 | return |
---|
[1b14795] | 159 | except: |
---|
| 160 | msg= "Select at least one parameter to fit in the FitPages." |
---|
| 161 | wx.PostEvent(self.parent.parent, StatusEvent(status=msg)) |
---|
[1b07935d] | 162 | else: |
---|
[31469d50] | 163 | msg= "Select at least one model check box to fit " |
---|
[1b14795] | 164 | wx.PostEvent(self.parent.parent, StatusEvent(status=msg)) |
---|
[f343069] | 165 | |
---|
[d89f09b] | 166 | def set_manager(self, manager): |
---|
| 167 | """ |
---|
[5062bbf] | 168 | set panel manager |
---|
| 169 | |
---|
| 170 | :param manager: instance of plugin fitting |
---|
| 171 | |
---|
[d89f09b] | 172 | """ |
---|
| 173 | self.manager = manager |
---|
[b28717b] | 174 | |
---|
[2140e68] | 175 | def check_all_model_name(self,event): |
---|
[d89f09b] | 176 | """ |
---|
[5062bbf] | 177 | check all models names |
---|
[d89f09b] | 178 | """ |
---|
[6bbeacd4] | 179 | self.model_toFit = [] |
---|
| 180 | if self.cb1.GetValue()== True: |
---|
[d89f09b] | 181 | for item in self.model_list: |
---|
[6c08ba5] | 182 | if item[0].IsEnabled(): |
---|
| 183 | item[0].SetValue(True) |
---|
| 184 | self.model_toFit.append(item) |
---|
[2140e68] | 185 | |
---|
| 186 | ## constraint info |
---|
| 187 | self._store_model() |
---|
| 188 | ## display constraint fields |
---|
| 189 | if self.show_constraint.GetValue(): |
---|
[77a43fb] | 190 | self._show_all_constraint() |
---|
[2140e68] | 191 | self._show_constraint() |
---|
| 192 | return |
---|
[d89f09b] | 193 | else: |
---|
| 194 | for item in self.model_list: |
---|
| 195 | item[0].SetValue(False) |
---|
[948add7] | 196 | |
---|
[d89f09b] | 197 | self.model_toFit=[] |
---|
[2140e68] | 198 | ##constraint info |
---|
| 199 | self._hide_constraint() |
---|
[925a30e] | 200 | |
---|
[2140e68] | 201 | def check_model_name(self,event): |
---|
[d89f09b] | 202 | """ |
---|
[5062bbf] | 203 | Save information related to checkbox and their states |
---|
[d89f09b] | 204 | """ |
---|
| 205 | self.model_toFit=[] |
---|
| 206 | for item in self.model_list: |
---|
| 207 | if item[0].GetValue()==True: |
---|
| 208 | self.model_toFit.append(item) |
---|
| 209 | else: |
---|
| 210 | if item in self.model_toFit: |
---|
| 211 | self.model_toFit.remove(item) |
---|
| 212 | self.cb1.SetValue(False) |
---|
[b28717b] | 213 | |
---|
[2140e68] | 214 | ## display constraint fields |
---|
[284f6fe] | 215 | if len(self.model_toFit)==1: |
---|
[2140e68] | 216 | self._store_model() |
---|
[1b14795] | 217 | if self.show_constraint.GetValue() and\ |
---|
| 218 | len(self.constraints_list)==0: |
---|
[77a43fb] | 219 | self._show_all_constraint() |
---|
[2140e68] | 220 | self._show_constraint() |
---|
[284f6fe] | 221 | elif len(self.model_toFit)< 1: |
---|
[b28717b] | 222 | ##constraint info |
---|
| 223 | self._hide_constraint() |
---|
[2140e68] | 224 | |
---|
| 225 | ## set the value of the main check button |
---|
[d89f09b] | 226 | if len(self.model_list)==len(self.model_toFit): |
---|
| 227 | self.cb1.SetValue(True) |
---|
[b28717b] | 228 | return |
---|
[d89f09b] | 229 | else: |
---|
| 230 | self.cb1.SetValue(False) |
---|
[948add7] | 231 | |
---|
[b28717b] | 232 | def draw_page(self): |
---|
[2140e68] | 233 | """ |
---|
[5062bbf] | 234 | Draw a sizer containing couples of data and model |
---|
[b28717b] | 235 | """ |
---|
[2140e68] | 236 | self.model_list=[] |
---|
| 237 | self.model_toFit=[] |
---|
[8bd4dc0] | 238 | self.constraints_list=[] |
---|
[1d2782d] | 239 | self.constraint_dict={} |
---|
| 240 | self.nb_constraint= 0 |
---|
| 241 | |
---|
[2140e68] | 242 | if len(self.model_list)>0: |
---|
| 243 | for item in self.model_list: |
---|
| 244 | item[0].SetValue(False) |
---|
[c647377] | 245 | self.manager.schedule_for_fit(value=0, uid=item[2]) |
---|
[2140e68] | 246 | |
---|
[5062bbf] | 247 | self.sizer1.Clear(True) |
---|
[8bd4dc0] | 248 | box_description= wx.StaticBox(self, -1,"Fit Combinations") |
---|
[2140e68] | 249 | boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) |
---|
| 250 | sizer_title = wx.BoxSizer(wx.HORIZONTAL) |
---|
| 251 | sizer_couples = wx.GridBagSizer(5,5) |
---|
| 252 | #------------------------------------------------------ |
---|
| 253 | if len(self.page_finder)==0: |
---|
[2296316] | 254 | msg = " No fit combinations are found! \n\n" |
---|
[1b14795] | 255 | msg += " Please load data and set up " |
---|
| 256 | msg += "at least two fit panels first..." |
---|
[2296316] | 257 | sizer_title.Add(wx.StaticText(self, -1, msg)) |
---|
[2140e68] | 258 | else: |
---|
| 259 | ## store model |
---|
| 260 | self._store_model() |
---|
| 261 | |
---|
[8bd4dc0] | 262 | self.cb1 = wx.CheckBox(self, -1,'Select all') |
---|
[2140e68] | 263 | self.cb1.SetValue(False) |
---|
| 264 | wx.EVT_CHECKBOX(self, self.cb1.GetId(), self.check_all_model_name) |
---|
| 265 | |
---|
[8bd4dc0] | 266 | sizer_title.Add((10,10),0, |
---|
| 267 | wx.TOP|wx.BOTTOM|wx.EXPAND|wx.ADJUST_MINSIZE,border=5) |
---|
| 268 | sizer_title.Add(self.cb1,0, |
---|
| 269 | wx.TOP|wx.BOTTOM|wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE,border=5) |
---|
| 270 | |
---|
| 271 | ## draw list of model and data name |
---|
[2140e68] | 272 | self._fill_sizer_model_list(sizer_couples) |
---|
| 273 | ## draw the sizer containing constraint info |
---|
| 274 | self._fill_sizer_constraint() |
---|
[8bd4dc0] | 275 | ## draw fit button |
---|
| 276 | self._fill_sizer_fit() |
---|
[2140e68] | 277 | #-------------------------------------------------------- |
---|
[8bd4dc0] | 278 | boxsizer1.Add(sizer_title, flag= wx.TOP|wx.BOTTOM,border=5) |
---|
[0a9871c] | 279 | boxsizer1.Add(sizer_couples, 1, flag= wx.TOP|wx.BOTTOM,border=5) |
---|
[2140e68] | 280 | |
---|
[0a9871c] | 281 | self.sizer1.Add(boxsizer1, 1, wx.EXPAND | wx.ALL, 10) |
---|
[2140e68] | 282 | self.sizer1.Layout() |
---|
[e1a97f8] | 283 | #self.SetScrollbars(20,20,25,65) |
---|
[2140e68] | 284 | self.AdjustScrollbars() |
---|
[0a9871c] | 285 | self.Layout() |
---|
[2140e68] | 286 | |
---|
| 287 | def _store_model(self): |
---|
[d89f09b] | 288 | """ |
---|
[5062bbf] | 289 | Store selected model |
---|
[d89f09b] | 290 | """ |
---|
[284f6fe] | 291 | if len(self.model_toFit) < 1: |
---|
[2140e68] | 292 | return |
---|
[1d2782d] | 293 | for item in self.model_toFit: |
---|
| 294 | model = item[3] |
---|
[6bbeacd4] | 295 | page_id= item[2] |
---|
| 296 | self.constraint_dict[page_id] = model |
---|
[2140e68] | 297 | |
---|
| 298 | def _display_constraint(self, event): |
---|
| 299 | """ |
---|
[5062bbf] | 300 | Show fields to add constraint |
---|
[2140e68] | 301 | """ |
---|
[284f6fe] | 302 | if len(self.model_toFit)< 1: |
---|
[2140e68] | 303 | msg= "Select at least 2 models to add constraint " |
---|
[1b14795] | 304 | wx.PostEvent(self.parent.parent, StatusEvent(status= msg )) |
---|
[2140e68] | 305 | ## hide button |
---|
| 306 | self._hide_constraint() |
---|
| 307 | return |
---|
| 308 | if self.show_constraint.GetValue(): |
---|
[1b14795] | 309 | self._show_all_constraint() |
---|
[2140e68] | 310 | self._show_constraint() |
---|
[e1a97f8] | 311 | self.Layout() |
---|
[2140e68] | 312 | return |
---|
| 313 | else: |
---|
| 314 | self._hide_constraint() |
---|
[e1a97f8] | 315 | self.Layout() |
---|
[2140e68] | 316 | return |
---|
[1b14795] | 317 | |
---|
| 318 | def _show_all_constraint(self): |
---|
| 319 | """ |
---|
| 320 | Show constraint fields |
---|
| 321 | """ |
---|
| 322 | #for id, model in self.constraint_dict.iteritems(): |
---|
| 323 | box_description= wx.StaticBox(self, -1,"Easy Setup ") |
---|
| 324 | boxsizer = wx.StaticBoxSizer(box_description, wx.HORIZONTAL) |
---|
| 325 | sizer_constraint = wx.BoxSizer(wx.HORIZONTAL|wx.LEFT|wx.RIGHT|wx.EXPAND) |
---|
| 326 | self.model_cbox_left = wx.ComboBox(self, -1, style=wx.CB_READONLY) |
---|
| 327 | self.model_cbox_left.Clear() |
---|
| 328 | self.model_cbox_right = wx.ComboBox(self, -1, style=wx.CB_READONLY) |
---|
| 329 | self.model_cbox_right.Clear() |
---|
| 330 | wx.EVT_COMBOBOX(self.model_cbox_left, -1, self._on_select_modelcb) |
---|
| 331 | wx.EVT_COMBOBOX(self.model_cbox_right, -1, self._on_select_modelcb) |
---|
| 332 | egal_txt= wx.StaticText(self,-1," = ") |
---|
| 333 | self.set_button =wx.Button(self, wx.NewId(),'Set All') |
---|
| 334 | self.set_button.Bind(wx.EVT_BUTTON, self._on_set_all_equal, |
---|
| 335 | id=self.set_button.GetId()) |
---|
| 336 | set_tip = "Add constraints for all the adjustable parameters " |
---|
| 337 | set_tip += "(checked in FitPages) if exist." |
---|
| 338 | self.set_button.SetToolTipString(set_tip) |
---|
| 339 | self.set_button.Disable() |
---|
| 340 | |
---|
| 341 | for id, model in self.constraint_dict.iteritems(): |
---|
| 342 | ## check if all parameters have been selected for constraint |
---|
| 343 | ## then do not allow add constraint on parameters |
---|
| 344 | self.model_cbox_left.Append( str(model.name), model) |
---|
| 345 | self.model_cbox_left.Select(0) |
---|
| 346 | for id, model in self.constraint_dict.iteritems(): |
---|
| 347 | ## check if all parameters have been selected for constraint |
---|
| 348 | ## then do not allow add constraint on parameters |
---|
| 349 | self.model_cbox_right.Append( str(model.name), model) |
---|
| 350 | boxsizer.Add(self.model_cbox_left, |
---|
| 351 | flag= wx.RIGHT|wx.EXPAND, border=10) |
---|
| 352 | boxsizer.Add(wx.StaticText(self, -1,".parameters"), |
---|
| 353 | flag= wx.RIGHT|wx.EXPAND, border=5) |
---|
| 354 | boxsizer.Add(egal_txt, flag= wx.RIGHT|wx.EXPAND, border=5) |
---|
| 355 | boxsizer.Add(self.model_cbox_right, |
---|
| 356 | flag= wx.RIGHT|wx.EXPAND, border=10) |
---|
| 357 | boxsizer.Add(wx.StaticText(self, -1,".parameters"), |
---|
| 358 | flag= wx.RIGHT|wx.EXPAND,border=5) |
---|
| 359 | boxsizer.Add((20,-1)) |
---|
| 360 | boxsizer.Add(self.set_button, flag= wx.RIGHT|wx.EXPAND, border=5) |
---|
| 361 | sizer_constraint.Add(boxsizer, flag= wx.RIGHT|wx.EXPAND, border=5) |
---|
| 362 | self.sizer_all_constraints.Insert(before=0, |
---|
| 363 | item=sizer_constraint, |
---|
| 364 | flag= wx.TOP|wx.BOTTOM|wx.EXPAND, border=5) |
---|
| 365 | |
---|
| 366 | self.sizer_all_constraints.Layout() |
---|
| 367 | self.sizer2.Layout() |
---|
[e1a97f8] | 368 | #self.SetScrollbars(20,20,25,65) |
---|
[1b14795] | 369 | |
---|
| 370 | def _on_select_modelcb(self, event): |
---|
| 371 | """ |
---|
| 372 | On select model left or right combobox |
---|
| 373 | """ |
---|
| 374 | event.Skip() |
---|
| 375 | flag = True |
---|
| 376 | if self.model_cbox_left.GetValue().strip() == '': |
---|
| 377 | flag = False |
---|
| 378 | if self.model_cbox_right.GetValue().strip() == '': |
---|
| 379 | flag = False |
---|
| 380 | if self.model_cbox_left.GetValue() ==\ |
---|
| 381 | self.model_cbox_right.GetValue(): |
---|
| 382 | flag = False |
---|
| 383 | self.set_button.Enable(flag) |
---|
| 384 | |
---|
| 385 | def _on_set_all_equal(self, event): |
---|
| 386 | """ |
---|
| 387 | On set button |
---|
| 388 | """ |
---|
| 389 | event.Skip() |
---|
| 390 | length = len(self.constraints_list) |
---|
| 391 | if length < 1: |
---|
| 392 | return |
---|
| 393 | param_list = [] |
---|
| 394 | param_listB = [] |
---|
| 395 | selection = self.model_cbox_left.GetCurrentSelection() |
---|
| 396 | model_left = self.model_cbox_left.GetValue() |
---|
| 397 | model = self.model_cbox_left.GetClientData(selection) |
---|
| 398 | selectionB = self.model_cbox_right.GetCurrentSelection() |
---|
| 399 | model_right = self.model_cbox_right.GetValue() |
---|
| 400 | modelB = self.model_cbox_right.GetClientData(selectionB) |
---|
| 401 | for id, dic_model in self.constraint_dict.iteritems(): |
---|
| 402 | if model == dic_model: |
---|
| 403 | param_list = self.page_finder[id].get_param2fit() |
---|
| 404 | if modelB == dic_model: |
---|
| 405 | param_listB = self.page_finder[id].get_param2fit() |
---|
| 406 | if len(param_list) > 0 and len(param_listB) > 0: |
---|
| 407 | break |
---|
| 408 | #param_list= get_fittableParam(model) |
---|
| 409 | #param_listB= get_fittableParam(modelB) |
---|
| 410 | num_cbox = 0 |
---|
| 411 | has_param = False |
---|
| 412 | for param in param_list: |
---|
| 413 | num_cbox += 1 |
---|
| 414 | if param in param_listB: |
---|
| 415 | self.model_cbox.SetStringSelection(model_left) |
---|
| 416 | self._on_select_model(None) |
---|
| 417 | self.param_cbox.Clear() |
---|
| 418 | self.param_cbox.Append( str(param), model) |
---|
| 419 | self.param_cbox.SetStringSelection( str(param)) |
---|
| 420 | self.ctl2.SetValue(str(model_right + "." + str(param))) |
---|
| 421 | has_param = True |
---|
[00daba9] | 422 | if num_cbox == (len(param_list) + 1): |
---|
[1b14795] | 423 | break |
---|
| 424 | self._show_constraint() |
---|
| 425 | |
---|
| 426 | self.sizer_constraints.Layout() |
---|
| 427 | self.sizer2.Layout() |
---|
[e1a97f8] | 428 | self.SetScrollbars(20,20,25,65) |
---|
| 429 | self.Layout() |
---|
[1b14795] | 430 | if not has_param: |
---|
| 431 | msg= " There is no adjustable parameter (checked to fit)" |
---|
| 432 | msg += " either one of the models." |
---|
| 433 | wx.PostEvent(self.parent.parent, StatusEvent(info="warning", |
---|
| 434 | status= msg )) |
---|
| 435 | else: |
---|
| 436 | msg= " The constraints are added." |
---|
| 437 | wx.PostEvent(self.parent.parent, StatusEvent(info="info", |
---|
| 438 | status= msg )) |
---|
[2140e68] | 439 | def _show_constraint(self): |
---|
| 440 | """ |
---|
[5062bbf] | 441 | Show constraint fields |
---|
[2140e68] | 442 | """ |
---|
[77e23a2] | 443 | self.btAdd.Show(True) |
---|
[2140e68] | 444 | if len(self.constraints_list)!= 0: |
---|
| 445 | nb_fit_param = 0 |
---|
[1b14795] | 446 | for id, model in self.constraint_dict.iteritems(): |
---|
[00daba9] | 447 | nb_fit_param += len(self.page_finder[id].get_param2fit()) |
---|
[2140e68] | 448 | ##Don't add anymore |
---|
| 449 | if len(self.constraints_list) == nb_fit_param: |
---|
[ac11e40] | 450 | msg= "Cannot add another constraint .Maximum of number " |
---|
| 451 | msg += "Parameters name reached %s"%str(nb_fit_param) |
---|
[1b14795] | 452 | wx.PostEvent(self.parent.parent, StatusEvent(status= msg )) |
---|
[b28717b] | 453 | self.sizer_constraints.Layout() |
---|
[ac11e40] | 454 | self.sizer2.Layout() |
---|
[00daba9] | 455 | #self.SetScrollbars(20,20,25,65) |
---|
[ac11e40] | 456 | return |
---|
[284f6fe] | 457 | if len(self.model_toFit) < 1 : |
---|
| 458 | msg= "Select at least 1 model to add constraint " |
---|
[1b14795] | 459 | wx.PostEvent(self.parent.parent, StatusEvent(status= msg )) |
---|
[b28717b] | 460 | self.sizer_constraints.Layout() |
---|
[2140e68] | 461 | self.sizer2.Layout() |
---|
[00daba9] | 462 | #self.SetScrollbars(20,20,25,65) |
---|
[2140e68] | 463 | return |
---|
| 464 | |
---|
| 465 | sizer_constraint = wx.BoxSizer(wx.HORIZONTAL) |
---|
[8bd4dc0] | 466 | model_cbox = wx.ComboBox(self, -1,style=wx.CB_READONLY) |
---|
[2140e68] | 467 | model_cbox.Clear() |
---|
[1b14795] | 468 | param_cbox = wx.ComboBox(self, -1,style=wx.CB_READONLY, size=(100,-1),) |
---|
[b28717b] | 469 | param_cbox.Hide() |
---|
[8dfe0fd] | 470 | |
---|
| 471 | #This is for GetCLientData() _on_select_param: Was None return on MAC. |
---|
| 472 | self.param_cbox = param_cbox |
---|
| 473 | |
---|
[2140e68] | 474 | wx.EVT_COMBOBOX(param_cbox,-1, self._on_select_param) |
---|
[1b14795] | 475 | self.ctl2 = wx.TextCtrl(self, -1) |
---|
[77a43fb] | 476 | egal_txt= wx.StaticText(self,-1, " = ") |
---|
| 477 | self.btRemove = wx.Button(self,wx.NewId(),'Remove') |
---|
| 478 | self.btRemove.Bind(wx.EVT_BUTTON, self.onRemove, |
---|
| 479 | id=self.btRemove.GetId()) |
---|
| 480 | self.btRemove.SetToolTipString("Remove constraint.") |
---|
| 481 | self.btRemove.Hide() |
---|
| 482 | if hasattr(self,"btAdd"): |
---|
| 483 | self.btAdd.Hide() |
---|
[1b14795] | 484 | for id, model in self.constraint_dict.iteritems(): |
---|
[2140e68] | 485 | ## check if all parameters have been selected for constraint |
---|
| 486 | ## then do not allow add constraint on parameters |
---|
[ac11e40] | 487 | model_cbox.Append( str(model.name), model) |
---|
[2140e68] | 488 | |
---|
[8dfe0fd] | 489 | #This is for GetCLientData() passing to self._on_select_param: Was None return on MAC. |
---|
| 490 | self.model_cbox = model_cbox |
---|
[2140e68] | 491 | |
---|
| 492 | wx.EVT_COMBOBOX(model_cbox,-1, self._on_select_model) |
---|
[1b14795] | 493 | sizer_constraint.Add((5,-1)) |
---|
[b28717b] | 494 | sizer_constraint.Add(model_cbox, flag= wx.RIGHT|wx.EXPAND,border=10) |
---|
| 495 | sizer_constraint.Add(param_cbox, flag= wx.RIGHT|wx.EXPAND,border=5) |
---|
| 496 | sizer_constraint.Add(egal_txt, flag= wx.RIGHT|wx.EXPAND,border=5) |
---|
[1b14795] | 497 | sizer_constraint.Add(self.ctl2, flag= wx.RIGHT|wx.EXPAND,border=10) |
---|
[77a43fb] | 498 | sizer_constraint.Add(self.btRemove, flag= wx.RIGHT|wx.EXPAND,border=10) |
---|
[b28717b] | 499 | |
---|
| 500 | self.sizer_constraints.Insert(before=self.nb_constraint, |
---|
[77a43fb] | 501 | item=sizer_constraint, flag= wx.TOP|wx.BOTTOM|wx.EXPAND, |
---|
| 502 | border=5) |
---|
[8bd4dc0] | 503 | ##[combobox1, combobox2,=,textcrtl, remove button ] |
---|
[77a43fb] | 504 | self.constraints_list.append([model_cbox, param_cbox, egal_txt, |
---|
| 505 | self.ctl2,self.btRemove,sizer_constraint]) |
---|
[5062bbf] | 506 | |
---|
[b28717b] | 507 | self.nb_constraint += 1 |
---|
| 508 | self.sizer_constraints.Layout() |
---|
[2140e68] | 509 | self.sizer2.Layout() |
---|
[00daba9] | 510 | #self.SetScrollbars(20,20,25,65) |
---|
[2140e68] | 511 | |
---|
| 512 | def _hide_constraint(self): |
---|
| 513 | """ |
---|
[5062bbf] | 514 | hide buttons related constraint |
---|
[ac11e40] | 515 | """ |
---|
[6bbeacd4] | 516 | for id in self.page_finder.iterkeys(): |
---|
| 517 | self.page_finder[id].clear_model_param() |
---|
[b28717b] | 518 | |
---|
[1b14795] | 519 | self.nb_constraint = 0 |
---|
| 520 | self.constraint_dict = {} |
---|
[69bee6d] | 521 | if hasattr(self,"btAdd"): |
---|
| 522 | self.btAdd.Hide() |
---|
[ac11e40] | 523 | self._store_model() |
---|
[1b14795] | 524 | self.constraints_list = [] |
---|
| 525 | self.sizer_all_constraints.Clear(True) |
---|
| 526 | self.sizer_all_constraints.Layout() |
---|
[b28717b] | 527 | self.sizer_constraints.Clear(True) |
---|
| 528 | self.sizer_constraints.Layout() |
---|
[2140e68] | 529 | self.sizer2.Layout() |
---|
[e1a97f8] | 530 | #self.SetScrollbars(20,20,25,65) |
---|
| 531 | #self.AdjustScrollbars() |
---|
[5062bbf] | 532 | |
---|
[2140e68] | 533 | def _on_select_model(self, event): |
---|
| 534 | """ |
---|
[5062bbf] | 535 | fill combox box with list of parameters |
---|
[2140e68] | 536 | """ |
---|
[8dfe0fd] | 537 | ##This way PC/MAC both work, instead of using event.GetClientData(). |
---|
| 538 | n = self.model_cbox.GetCurrentSelection() |
---|
| 539 | model = self.model_cbox.GetClientData(n) |
---|
[1b14795] | 540 | for id, dic_model in self.constraint_dict.iteritems(): |
---|
| 541 | if model == dic_model: |
---|
| 542 | param_list = self.page_finder[id].get_param2fit() |
---|
| 543 | break |
---|
| 544 | #param_list= get_fittableParam(model) |
---|
[2140e68] | 545 | length = len(self.constraints_list) |
---|
| 546 | if length < 1: |
---|
| 547 | return |
---|
| 548 | param_cbox = self.constraints_list[length-1][1] |
---|
| 549 | param_cbox.Clear() |
---|
| 550 | ## insert only fittable paramaters |
---|
| 551 | for param in param_list: |
---|
[ac11e40] | 552 | param_cbox.Append( str(param), model) |
---|
| 553 | |
---|
[2140e68] | 554 | param_cbox.Show(True) |
---|
[77a43fb] | 555 | self.btRemove.Show(True) |
---|
| 556 | self.btAdd.Show(True) |
---|
[2140e68] | 557 | self.sizer2.Layout() |
---|
[e1a97f8] | 558 | #self.SetScrollbars(20,20,25,65) |
---|
[2140e68] | 559 | |
---|
| 560 | def _on_select_param(self, event): |
---|
| 561 | """ |
---|
[5062bbf] | 562 | Store the appropriate constraint in the page_finder |
---|
[2140e68] | 563 | """ |
---|
[8dfe0fd] | 564 | ##This way PC/MAC both work, instead of using event.GetClientData(). |
---|
| 565 | n = self.param_cbox.GetCurrentSelection() |
---|
| 566 | model = self.param_cbox.GetClientData(n) |
---|
[2140e68] | 567 | param = event.GetString() |
---|
[ac11e40] | 568 | |
---|
[2140e68] | 569 | length = len(self.constraints_list) |
---|
| 570 | if length < 1: |
---|
| 571 | return |
---|
| 572 | egal_txt = self.constraints_list[length-1][2] |
---|
| 573 | egal_txt.Show(True) |
---|
| 574 | |
---|
| 575 | ctl2 = self.constraints_list[length-1][3] |
---|
| 576 | ctl2.Show(True) |
---|
[6e9976b] | 577 | #self.sizer2.Layout() |
---|
[e1a97f8] | 578 | #self.SetScrollbars(20,20,25,65) |
---|
[2140e68] | 579 | |
---|
| 580 | def _onAdd_constraint(self, event): |
---|
| 581 | """ |
---|
[5062bbf] | 582 | Add another line for constraint |
---|
[2140e68] | 583 | """ |
---|
[8bd4dc0] | 584 | if not self.show_constraint.GetValue(): |
---|
| 585 | msg= " Select Yes to add Constraint " |
---|
[1b14795] | 586 | wx.PostEvent(self.parent.parent, StatusEvent(status= msg )) |
---|
[8bd4dc0] | 587 | return |
---|
[1b14795] | 588 | ## check that a constraint is added |
---|
| 589 | # before allow to add another constraint |
---|
[2140e68] | 590 | for item in self.constraints_list: |
---|
| 591 | model_cbox = item[0] |
---|
| 592 | if model_cbox.GetString(0)=="": |
---|
| 593 | msg= " Select a model Name! " |
---|
[1b14795] | 594 | wx.PostEvent(self.parent.parent, StatusEvent(status= msg )) |
---|
[2140e68] | 595 | return |
---|
| 596 | param_cbox = item[1] |
---|
| 597 | if param_cbox.GetString(0)=="": |
---|
| 598 | msg= " Select a parameter Name! " |
---|
[1b14795] | 599 | wx.PostEvent(self.parent.parent, StatusEvent(status= msg )) |
---|
[2140e68] | 600 | return |
---|
| 601 | ctl2 = item[3] |
---|
| 602 | if ctl2.GetValue().lstrip().rstrip()=="": |
---|
[b28717b] | 603 | model= param_cbox.GetClientData(param_cbox.GetCurrentSelection()) |
---|
[1b14795] | 604 | msg= " Enter a constraint for %s.%s! "%(model.name, |
---|
| 605 | param_cbox.GetString(0)) |
---|
| 606 | wx.PostEvent(self.parent.parent, StatusEvent(status= msg )) |
---|
[b28717b] | 607 | return |
---|
[2140e68] | 608 | ## some model or parameters can be constrained |
---|
| 609 | self._show_constraint() |
---|
| 610 | |
---|
[8bd4dc0] | 611 | def _fill_sizer_fit(self): |
---|
| 612 | """ |
---|
[5062bbf] | 613 | Draw fit button |
---|
[8bd4dc0] | 614 | """ |
---|
| 615 | self.sizer3.Clear(True) |
---|
| 616 | box_description= wx.StaticBox(self, -1,"Fit ") |
---|
| 617 | boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) |
---|
| 618 | sizer_button = wx.BoxSizer(wx.HORIZONTAL) |
---|
| 619 | |
---|
| 620 | self.btFit = wx.Button(self,wx.NewId(),'Fit') |
---|
| 621 | self.btFit.Bind(wx.EVT_BUTTON, self.onFit,id= self.btFit.GetId()) |
---|
| 622 | self.btFit.SetToolTipString("Perform fit.") |
---|
[2140e68] | 623 | |
---|
[284f6fe] | 624 | text= "Hint: Park fitting engine will be selected automatically. \n" |
---|
| 625 | #text+= "automatically for more than 2 combinations checked" |
---|
[8bd4dc0] | 626 | text_hint = wx.StaticText(self,-1,text) |
---|
| 627 | |
---|
| 628 | sizer_button.Add(text_hint, wx.RIGHT|wx.EXPAND, 10) |
---|
| 629 | sizer_button.Add(self.btFit, 0, wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) |
---|
| 630 | |
---|
| 631 | boxsizer1.Add(sizer_button, flag= wx.TOP|wx.BOTTOM,border=10) |
---|
| 632 | self.sizer3.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10) |
---|
| 633 | self.sizer3.Layout() |
---|
[e1a97f8] | 634 | #self.SetScrollbars(20,20,25,65) |
---|
[2140e68] | 635 | |
---|
| 636 | def _fill_sizer_constraint(self): |
---|
| 637 | """ |
---|
[5062bbf] | 638 | Fill sizer containing constraint info |
---|
[2140e68] | 639 | """ |
---|
[5062bbf] | 640 | msg = "Select at least 2 model to add constraint " |
---|
[1b14795] | 641 | wx.PostEvent(self.parent.parent, StatusEvent(status= msg )) |
---|
[2140e68] | 642 | |
---|
| 643 | self.sizer2.Clear(True) |
---|
| 644 | box_description= wx.StaticBox(self, -1,"Fit Constraints") |
---|
| 645 | boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) |
---|
| 646 | sizer_title = wx.BoxSizer(wx.HORIZONTAL) |
---|
[1b14795] | 647 | self.sizer_all_constraints = wx.BoxSizer(wx.HORIZONTAL) |
---|
[b28717b] | 648 | self.sizer_constraints = wx.BoxSizer(wx.VERTICAL) |
---|
[2140e68] | 649 | sizer_button = wx.BoxSizer(wx.HORIZONTAL) |
---|
| 650 | |
---|
[1b14795] | 651 | self.hide_constraint = wx.RadioButton(self, -1, 'No', (10, 10), |
---|
| 652 | style=wx.RB_GROUP) |
---|
[2140e68] | 653 | self.show_constraint = wx.RadioButton(self, -1, 'Yes', (10, 30)) |
---|
| 654 | self.Bind( wx.EVT_RADIOBUTTON, self._display_constraint, |
---|
| 655 | id= self.hide_constraint.GetId() ) |
---|
| 656 | self.Bind( wx.EVT_RADIOBUTTON, self._display_constraint, |
---|
| 657 | id= self.show_constraint.GetId() ) |
---|
[17c5868] | 658 | self.hide_constraint.SetValue(True) |
---|
[2140e68] | 659 | sizer_title.Add( wx.StaticText(self,-1," Model") ) |
---|
| 660 | sizer_title.Add(( 10,10) ) |
---|
| 661 | sizer_title.Add( wx.StaticText(self,-1," Parameter") ) |
---|
| 662 | sizer_title.Add(( 10,10) ) |
---|
| 663 | sizer_title.Add( wx.StaticText(self,-1," Add Constraint?") ) |
---|
| 664 | sizer_title.Add(( 10,10) ) |
---|
| 665 | sizer_title.Add( self.show_constraint ) |
---|
| 666 | sizer_title.Add( self.hide_constraint ) |
---|
| 667 | sizer_title.Add(( 10,10) ) |
---|
[1b14795] | 668 | |
---|
[2140e68] | 669 | self.btAdd =wx.Button(self,wx.NewId(),'Add') |
---|
[1b14795] | 670 | self.btAdd.Bind(wx.EVT_BUTTON, self._onAdd_constraint, |
---|
| 671 | id=self.btAdd.GetId()) |
---|
[2140e68] | 672 | self.btAdd.SetToolTipString("Add another constraint?") |
---|
[77e23a2] | 673 | self.btAdd.Hide() |
---|
[8bd4dc0] | 674 | |
---|
[1b14795] | 675 | text_hint = wx.StaticText(self, -1, |
---|
| 676 | "Example: [M0][paramter] = M1.parameter") |
---|
[2140e68] | 677 | sizer_button.Add(text_hint, 0 , wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) |
---|
| 678 | sizer_button.Add(self.btAdd, 0, wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 10) |
---|
| 679 | |
---|
[8bd4dc0] | 680 | boxsizer1.Add(sizer_title, flag= wx.TOP|wx.BOTTOM,border=10) |
---|
[1b14795] | 681 | boxsizer1.Add(self.sizer_all_constraints, flag= wx.TOP|wx.BOTTOM, |
---|
| 682 | border=10) |
---|
| 683 | boxsizer1.Add(self.sizer_constraints, flag= wx.TOP|wx.BOTTOM, |
---|
| 684 | border=10) |
---|
| 685 | boxsizer1.Add(sizer_button, flag= wx.TOP|wx.BOTTOM, border=10) |
---|
[2140e68] | 686 | |
---|
| 687 | self.sizer2.Add(boxsizer1,0, wx.EXPAND | wx.ALL, 10) |
---|
| 688 | self.sizer2.Layout() |
---|
[e1a97f8] | 689 | #self.SetScrollbars(20,20,25,65) |
---|
[5062bbf] | 690 | |
---|
[2140e68] | 691 | def _set_constraint(self): |
---|
[d89f09b] | 692 | """ |
---|
[5062bbf] | 693 | get values from the constrainst textcrtl ,parses them into model name |
---|
| 694 | parameter name and parameters values. |
---|
[1b14795] | 695 | store them in a list self.params .when when params is not empty |
---|
| 696 | set_model uses it to reset the appropriate model |
---|
| 697 | and its appropriates parameters |
---|
[d89f09b] | 698 | """ |
---|
[2140e68] | 699 | for item in self.constraints_list: |
---|
[ac11e40] | 700 | model = item[0].GetClientData(item[0].GetCurrentSelection()) |
---|
| 701 | param = item[1].GetString(item[1].GetCurrentSelection()) |
---|
[2140e68] | 702 | constraint = item[3].GetValue().lstrip().rstrip() |
---|
[bb7d8a4] | 703 | if param.lstrip().rstrip()=="": |
---|
| 704 | param= None |
---|
[1b14795] | 705 | msg= " Constraint will be ignored!. missing parameters" |
---|
| 706 | msg+= " in combobox to set constraint! " |
---|
| 707 | wx.PostEvent(self.parent.parent, StatusEvent(status= msg )) |
---|
[6bbeacd4] | 708 | for id, value in self.constraint_dict.iteritems(): |
---|
[1f57dfd] | 709 | if model == value: |
---|
| 710 | if constraint == "": |
---|
[1b14795] | 711 | msg= " Constraint will be ignored!. missing value" |
---|
| 712 | msg+= " in textcrtl to set constraint! " |
---|
| 713 | wx.PostEvent(self.parent.parent, |
---|
| 714 | StatusEvent(status= msg )) |
---|
[1f57dfd] | 715 | constraint = None |
---|
[00daba9] | 716 | if str(param) in self.page_finder[id].get_param2fit(): |
---|
| 717 | msg = " Checking constraint for parameter: %s ", param |
---|
| 718 | wx.PostEvent(self.parent.parent, |
---|
| 719 | StatusEvent(info="info", status= msg )) |
---|
| 720 | else: |
---|
| 721 | model_name = item[0].GetLabel() |
---|
| 722 | fitpage = self.page_finder[id].get_fit_tab_caption() |
---|
| 723 | msg = "All constrainted parameters must be set " |
---|
| 724 | msg += " adjustable: '%s.%s' "% (model_name, param) |
---|
| 725 | msg += "is NOT checked in '%s'. "% fitpage |
---|
| 726 | msg += " Please check it to fit or" |
---|
| 727 | msg += " remove the line of the constraint." |
---|
| 728 | wx.PostEvent(self.parent.parent, |
---|
| 729 | StatusEvent(info="error", status= msg )) |
---|
| 730 | return False |
---|
| 731 | |
---|
[c647377] | 732 | for fid in self.page_finder[id].iterkeys(): |
---|
| 733 | self.page_finder[id].set_model_param(param, |
---|
| 734 | constraint, fid=fid) |
---|
[1f57dfd] | 735 | break |
---|
[00daba9] | 736 | return True |
---|
[5062bbf] | 737 | |
---|
[2140e68] | 738 | def _fill_sizer_model_list(self,sizer): |
---|
[d89f09b] | 739 | """ |
---|
[5062bbf] | 740 | Receive a dictionary containing information to display model name |
---|
| 741 | |
---|
| 742 | :param page_finder: the dictionary containing models information |
---|
| 743 | |
---|
[d89f09b] | 744 | """ |
---|
[2140e68] | 745 | ix = 0 |
---|
| 746 | iy = 0 |
---|
| 747 | list=[] |
---|
| 748 | sizer.Clear(True) |
---|
| 749 | |
---|
[1b14795] | 750 | new_name = wx.StaticText(self, -1, 'New Model Name', |
---|
| 751 | style=wx.ALIGN_CENTER) |
---|
[2140e68] | 752 | new_name.SetBackgroundColour('orange') |
---|
| 753 | sizer.Add(new_name,(iy, ix),(1,1), |
---|
| 754 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
[5062bbf] | 755 | ix += 2 |
---|
[2140e68] | 756 | model_type = wx.StaticText(self, -1, ' Model Type') |
---|
| 757 | model_type.SetBackgroundColour('grey') |
---|
| 758 | sizer.Add(model_type,(iy, ix),(1,1), |
---|
| 759 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
[5062bbf] | 760 | ix += 1 |
---|
[2140e68] | 761 | data_used = wx.StaticText(self, -1, ' Used Data') |
---|
| 762 | data_used.SetBackgroundColour('grey') |
---|
| 763 | sizer.Add(data_used,(iy, ix),(1,1), |
---|
| 764 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
[6bbeacd4] | 765 | ix += 1 |
---|
| 766 | tab_used = wx.StaticText(self, -1, ' Fit Tab') |
---|
| 767 | tab_used.SetBackgroundColour('grey') |
---|
| 768 | sizer.Add(tab_used,(iy, ix),(1,1), |
---|
| 769 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 770 | for id, value in self.page_finder.iteritems(): |
---|
[2140e68] | 771 | try: |
---|
| 772 | ix = 0 |
---|
[c647377] | 773 | for fitproblem in value.get_fit_problem(): |
---|
[0a9871c] | 774 | if not self.parent.get_page_by_id(id).batch_on: |
---|
| 775 | iy += 1 |
---|
| 776 | data = fitproblem.get_fit_data() |
---|
| 777 | model = fitproblem.get_model() |
---|
| 778 | name = '_' |
---|
| 779 | if model is not None: |
---|
| 780 | name = str(model.name) |
---|
| 781 | cb = wx.CheckBox(self, -1, name) |
---|
| 782 | cb.SetValue(False) |
---|
| 783 | cb.Enable(model is not None and data.is_data) |
---|
| 784 | sizer.Add(cb, (iy, ix), (1, 1), |
---|
| 785 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
| 786 | wx.EVT_CHECKBOX(self, cb.GetId(), self.check_model_name) |
---|
| 787 | ix += 2 |
---|
| 788 | type = model.__class__.__name__ |
---|
| 789 | model_type = wx.StaticText(self, -1, str(type)) |
---|
| 790 | sizer.Add(model_type, (iy, ix), (1, 1), |
---|
| 791 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 792 | name = '-' |
---|
| 793 | if data is not None and data.is_data: |
---|
| 794 | name = str(data.name) |
---|
| 795 | data_used = wx.StaticText(self, -1, name) |
---|
| 796 | ix += 1 |
---|
| 797 | sizer.Add(data_used, (iy, ix), (1, 1), |
---|
| 798 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
| 799 | ix += 1 |
---|
| 800 | caption = value.get_fit_tab_caption() |
---|
| 801 | tab_caption_used= wx.StaticText(self, -1, str(caption)) |
---|
| 802 | sizer.Add(tab_caption_used, (iy, ix), (1, 1), |
---|
| 803 | wx.EXPAND|wx.ADJUST_MINSIZE, 0) |
---|
[6bbeacd4] | 804 | |
---|
[0a9871c] | 805 | self.model_list.append([cb,value,id,model]) |
---|
[2140e68] | 806 | |
---|
| 807 | except: |
---|
[6bbeacd4] | 808 | raise |
---|
| 809 | #pass |
---|
[5062bbf] | 810 | iy += 1 |
---|
[c647377] | 811 | sizer.Add((20, 20), (iy, ix), (1, 1), |
---|
| 812 | wx.LEFT|wx.EXPAND|wx.ADJUST_MINSIZE, 15) |
---|
[2140e68] | 813 | sizer.Layout() |
---|
[0a9871c] | 814 | |
---|
[c647377] | 815 | |
---|
[4133316] | 816 | def on_set_focus(self, event=None): |
---|
| 817 | """ |
---|
| 818 | The derivative class is on focus if implemented |
---|
| 819 | """ |
---|
| 820 | if self.parent is not None: |
---|
[1976004] | 821 | if self.parent.parent is not None: |
---|
| 822 | wx.PostEvent(self.parent.parent, PanelOnFocusEvent(panel=self)) |
---|
| 823 | self.page_finder = self.parent._manager.get_page_finder() |
---|
[4133316] | 824 | |
---|