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