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