Changeset 662d8d87 in sasview
- Timestamp:
- Nov 23, 2015 1:29:38 AM (9 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, release_4.0.1, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 3596467
- Parents:
- 80ba1a2
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/perspectives/fitting/simfitpage.py
rd7b4decd r662d8d87 13 13 from sas.guiframe.events import PanelOnFocusEvent 14 14 from sas.guiframe.utils import IdList 15 from sas.guiframe.documentation_window import DocumentationWindow 15 16 16 17 #Control panel width … … 30 31 def get_fittableParam(model): 31 32 """ 32 return list of fittable parameters name ofa model33 return list of fittable parameters from a model 33 34 34 35 :param model: the model used … … 56 57 ## Title to appear on top of the window 57 58 window_caption = "Simultaneous Fit Page" 59 ID_DOC = wx.NewId() 58 60 ID_SET_ALL = wx.NewId() 59 61 ID_FIT = wx.NewId() … … 79 81 ## store page_finder 80 82 self.page_finder = page_finder 81 ## list conta ning info to set constraint83 ## list containing info to set constraint 82 84 ## look like self.constraint_dict[page_id]= page 83 85 self.constraint_dict = {} 84 86 ## item list 85 # self.constraints_list=[combobox1, combobox2,=,textcrtl, button ]87 ## self.constraints_list=[combobox1, combobox2,=,textcrtl, button ] 86 88 self.constraints_list = [] 87 89 ## list of current model … … 96 98 self.define_page_structure() 97 99 self.draw_page() 98 self.set_layout()99 100 self._set_save_flag(False) 100 101 101 102 def define_page_structure(self): 102 103 """ 103 Create empty sizer for apanel104 Create empty sizers, their hierarchy and set the sizer for the panel 104 105 """ 105 106 self.vbox = wx.BoxSizer(wx.VERTICAL) … … 114 115 self.vbox.Add(self.sizer2) 115 116 self.vbox.Add(self.sizer3) 116 117 def set_scroll(self):118 """119 """120 self.Layout()121 122 def set_layout(self):123 """124 layout125 """126 self.vbox.Layout()127 self.vbox.Fit(self)128 117 self.SetSizer(self.vbox) 129 self.set_scroll()130 118 self.Centre() 119 120 def draw_page(self): 121 """ 122 Construct the Simultaneous/Constrained fit page. fills the first 123 region (sizer1) with the list of available fit page pairs of data 124 and models. Then fills sizer2 with the checkbox for adding 125 constraints, and finally fills sizer3 with the fit button and 126 instructions. 127 """ 128 129 # create blank list of constraints 130 self.model_list = [] 131 self.model_toFit = [] 132 self.constraints_list = [] 133 self.constraint_dict = {} 134 self.nb_constraint = 0 135 self.model_cbox_left = None 136 self.model_cbox_right = None 137 138 if len(self.model_list) > 0: 139 for item in self.model_list: 140 item[0].SetValue(False) 141 self.manager.schedule_for_fit(value=0, uid=item[2]) 142 143 #------------------------------------------------------- 144 ## setup sizer1 (which fitpages to include) 145 self.sizer1.Clear(True) 146 box_description = wx.StaticBox(self, wx.ID_ANY, "Fit Combinations") 147 boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) 148 sizer_title = wx.BoxSizer(wx.HORIZONTAL) 149 sizer_couples = wx.GridBagSizer(5, 5) 150 151 #This if statement should be obsolete and can be removed in version 4 152 #Leave it here for now as no time to thoroughly test. However if no 153 #fit page is found the menu item that calls this page is inactive 154 # Nov. 22 2015 --PDB 155 if len(self.page_finder) == 0: 156 msg = " No fit combinations are found! \n\n" 157 msg += " Please load data and set up " 158 msg += "at least one fit panels first..." 159 sizer_title.Add(wx.StaticText(self, wx.ID_ANY, msg)) 160 else: 161 ## store model 162 self._store_model() 163 164 self.cb1 = wx.CheckBox(self, wx.ID_ANY, 'Select all') 165 self.cb1.SetValue(False) 166 wx.EVT_CHECKBOX(self, self.cb1.GetId(), self.check_all_model_name) 167 168 sizer_title.Add((10, 10), 0, 169 wx.TOP | wx.BOTTOM | wx.EXPAND | wx.ADJUST_MINSIZE, border=5) 170 sizer_title.Add(self.cb1, 0, 171 wx.TOP | wx.BOTTOM | wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, border=5) 172 173 ## draw list of model and data names 174 self._fill_sizer_model_list(sizer_couples) 175 176 boxsizer1.Add(sizer_title, flag=wx.TOP | wx.BOTTOM, border=5) 177 boxsizer1.Add(sizer_couples, 1, flag=wx.TOP | wx.BOTTOM, border=5) 178 self.sizer1.Add(boxsizer1, 1, wx.EXPAND | wx.ALL, 10) 179 # self.sizer1.Layout() 180 181 #-------------------------------------------------------- 182 ## set up the other 2 sizers: the constraints list and the 183 ## buttons (fit, help etc) sizer at the bottom of the page. 184 ## Note: the if statement should be removed along with the above 185 ## if statement as soon as it can be properly tested. 186 ## Nov. 22 2015 --PDB 187 if len(self.page_finder) > 0: 188 ## draw the sizer containing constraint info 189 if not self.batch_on: 190 self._fill_sizer_constraint() 191 ## draw fit button sizer 192 self._fill_sizer_fit() 193 194 195 def _fill_sizer_model_list(self, sizer): 196 """ 197 Receive a dictionary containing information to display model name 198 """ 199 ix = 0 200 iy = 0 201 list = [] 202 sizer.Clear(True) 203 204 new_name = wx.StaticText(self, wx.ID_ANY, ' Model Title ', 205 style=wx.ALIGN_CENTER) 206 new_name.SetBackgroundColour('orange') 207 new_name.SetForegroundColour(wx.WHITE) 208 sizer.Add(new_name, (iy, ix), (1, 1), 209 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 210 ix += 2 211 model_type = wx.StaticText(self, wx.ID_ANY, ' Model ') 212 model_type.SetBackgroundColour('grey') 213 model_type.SetForegroundColour(wx.WHITE) 214 sizer.Add(model_type, (iy, ix), (1, 1), 215 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 216 ix += 1 217 data_used = wx.StaticText(self, wx.ID_ANY, ' Data ') 218 data_used.SetBackgroundColour('grey') 219 data_used.SetForegroundColour(wx.WHITE) 220 sizer.Add(data_used, (iy, ix), (1, 1), 221 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 222 ix += 1 223 tab_used = wx.StaticText(self, wx.ID_ANY, ' FitPage ') 224 tab_used.SetBackgroundColour('grey') 225 tab_used.SetForegroundColour(wx.WHITE) 226 sizer.Add(tab_used, (iy, ix), (1, 1), 227 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 228 for id, value in self.page_finder.iteritems(): 229 if id not in self.parent.opened_pages: 230 continue 231 232 if self.batch_on != self.parent.get_page_by_id(id).batch_on: 233 continue 234 235 data_list = [] 236 model_list = [] 237 # get data name and model objetta 238 for fitproblem in value.get_fit_problem(): 239 240 data = fitproblem.get_fit_data() 241 if not data.is_data: 242 continue 243 name = '-' 244 if data is not None and data.is_data: 245 name = str(data.name) 246 data_list.append(name) 247 248 model = fitproblem.get_model() 249 if model is None: 250 continue 251 model_list.append(model) 252 253 if len(model_list) == 0: 254 continue 255 # Draw sizer 256 ix = 0 257 iy += 1 258 model = model_list[0] 259 name = '_' 260 if model is not None: 261 name = str(model.name) 262 cb = wx.CheckBox(self, wx.ID_ANY, name) 263 cb.SetValue(False) 264 cb.Enable(model is not None and data.is_data) 265 sizer.Add(cb, (iy, ix), (1, 1), 266 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 267 wx.EVT_CHECKBOX(self, cb.GetId(), self.check_model_name) 268 ix += 2 269 model_type = wx.StaticText(self, wx.ID_ANY, 270 model.__class__.__name__) 271 sizer.Add(model_type, (iy, ix), (1, 1), 272 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 273 if self.batch_on: 274 data_used = wx.ComboBox(self, wx.ID_ANY, style=wx.CB_READONLY) 275 data_used.AppendItems(data_list) 276 data_used.SetSelection(0) 277 else: 278 data_used = wx.StaticText(self, wx.ID_ANY, data_list[0]) 279 280 ix += 1 281 sizer.Add(data_used, (iy, ix), (1, 1), 282 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 283 ix += 1 284 caption = value.get_fit_tab_caption() 285 tab_caption_used = wx.StaticText(self, wx.ID_ANY, str(caption)) 286 sizer.Add(tab_caption_used, (iy, ix), (1, 1), 287 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 288 289 self.model_list.append([cb, value, id, model]) 290 291 iy += 1 292 sizer.Add((20, 20), (iy, ix), (1, 1), 293 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 294 295 def _fill_sizer_constraint(self): 296 """ 297 Fill sizer containing constraint info 298 """ 299 msg = "Select at least 1 model to add constraint " 300 wx.PostEvent(self.parent.parent, StatusEvent(status=msg)) 301 302 self.sizer2.Clear(True) 303 if self.batch_on: 304 if self.sizer2.IsShown(): 305 self.sizer2.Show(False) 306 return 307 box_description = wx.StaticBox(self, wx.ID_ANY, "Fit Constraints") 308 boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) 309 sizer_title = wx.BoxSizer(wx.HORIZONTAL) 310 self.sizer_all_constraints = wx.BoxSizer(wx.HORIZONTAL) 311 self.sizer_constraints = wx.BoxSizer(wx.VERTICAL) 312 sizer_button = wx.BoxSizer(wx.HORIZONTAL) 313 314 self.hide_constraint = wx.RadioButton(self, wx.ID_ANY, 'No', (10, 10), 315 style=wx.RB_GROUP) 316 self.show_constraint = wx.RadioButton(self, wx.ID_ANY, 'Yes', (10, 30)) 317 self.Bind(wx.EVT_RADIOBUTTON, self._display_constraint, 318 id=self.hide_constraint.GetId()) 319 self.Bind(wx.EVT_RADIOBUTTON, self._display_constraint, 320 id=self.show_constraint.GetId()) 321 if self.batch_on: 322 self.hide_constraint.Enable(False) 323 self.show_constraint.Enable(False) 324 self.hide_constraint.SetValue(True) 325 self.show_constraint.SetValue(False) 326 327 sizer_title.Add(wx.StaticText(self, wx.ID_ANY, " Model")) 328 sizer_title.Add((10, 10)) 329 sizer_title.Add(wx.StaticText(self, wx.ID_ANY, " Parameter")) 330 sizer_title.Add((10, 10)) 331 sizer_title.Add(wx.StaticText(self, wx.ID_ANY, " Add Constraint?")) 332 sizer_title.Add((10, 10)) 333 sizer_title.Add(self.show_constraint) 334 sizer_title.Add(self.hide_constraint) 335 sizer_title.Add((10, 10)) 336 337 self.btAdd = wx.Button(self, self.ID_ADD, 'Add') 338 self.btAdd.Bind(wx.EVT_BUTTON, self._onAdd_constraint, 339 id=self.btAdd.GetId()) 340 self.btAdd.SetToolTipString("Add another constraint?") 341 self.btAdd.Hide() 342 343 text_hint = wx.StaticText(self, wx.ID_ANY, 344 "Example: [M0][paramter] = M1.parameter") 345 sizer_button.Add(text_hint, 0, 346 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 10) 347 sizer_button.Add(self.btAdd, 0, 348 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 10) 349 350 boxsizer1.Add(sizer_title, flag=wx.TOP | wx.BOTTOM, border=10) 351 boxsizer1.Add(self.sizer_all_constraints, flag=wx.TOP | wx.BOTTOM, 352 border=10) 353 boxsizer1.Add(self.sizer_constraints, flag=wx.TOP | wx.BOTTOM, 354 border=10) 355 boxsizer1.Add(sizer_button, flag=wx.TOP | wx.BOTTOM, border=10) 356 357 self.sizer2.Add(boxsizer1, 0, wx.EXPAND | wx.ALL, 10) 358 359 360 def _fill_sizer_fit(self): 361 """ 362 Draw fit button 363 """ 364 self.sizer3.Clear(True) 365 box_description = wx.StaticBox(self, wx.ID_ANY, "Fit ") 366 boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) 367 sizer_button = wx.BoxSizer(wx.HORIZONTAL) 368 369 #Fit button 370 self.btFit = wx.Button(self, self.ID_FIT, 'Fit', size=wx.DefaultSize) 371 self.btFit.Bind(wx.EVT_BUTTON, self.onFit, id=self.btFit.GetId()) 372 self.btFit.SetToolTipString("Perform fit.") 373 374 #General Help button 375 self.btHelp = wx.Button(self, wx.ID_HELP, 'HELP') 376 self.btHelp.SetToolTipString("Simultaneous/Constrained Fitting help.") 377 self.btHelp.Bind(wx.EVT_BUTTON, self._onHelp) 378 379 #hint text on button line 380 if self.batch_on: 381 text = " Fit in Parallel all Data sets\n" 382 text += "and model selected." 383 else: 384 text = " At least one set of model and data\n" 385 text += " must be selected for fitting." 386 text_hint = wx.StaticText(self, wx.ID_ANY, text) 387 388 sizer_button.Add(text_hint) 389 sizer_button.Add(self.btFit, 0, wx.LEFT | wx.ADJUST_MINSIZE, 10) 390 sizer_button.Add(self.btHelp, 0, wx.LEFT | wx.ADJUST_MINSIZE, 10) 391 392 boxsizer1.Add(sizer_button, flag=wx.TOP | wx.BOTTOM, border=10) 393 self.sizer3.Add(boxsizer1, 0, wx.EXPAND | wx.ALL, 10) 131 394 132 395 def onRemove(self, event): … … 149 412 item.sizer.Clear(True) 150 413 self.sizer_constraints.Remove(item.sizer) 151 ##self.SetScrollbars(20,20,25,65)152 414 self.constraints_list.remove(item) 153 415 self.nb_constraint -= 1 154 416 self.sizer2.Layout() 155 self. Layout()417 self.FitInside() 156 418 break 157 419 … … 186 448 wx.PostEvent(self.parent.parent, StatusEvent(status=msg)) 187 449 450 def _onHelp(self, event): 451 """ 452 Bring up the simultaneous Fitting Documentation whenever the HELP 453 button is clicked. 454 455 Calls DocumentationWindow with the path of the location within the 456 documentation tree (after /doc/ ....". Note that when using old 457 versions of Wx (before 2.9) and thus not the release version of 458 installers, the help comes up at the top level of the file as 459 webbrowser does not pass anything past the # to the browser when it is 460 running "file:///...." 461 462 :param evt: Triggers on clicking the help button 463 """ 464 _TreeLocation = "user/perspectives/fitting/fitting_help.html" 465 _PageAnchor = "#simultaneous-fit-mode" 466 _doc_viewer = DocumentationWindow(self, self.ID_DOC, _TreeLocation, 467 _PageAnchor, 468 "Simultaneous/Constrained Fitting Help") 469 188 470 def set_manager(self, manager): 189 471 """ … … 223 505 224 506 self._update_easy_setup_cb() 225 self. Layout()226 self.Refresh() 507 self.FitInside() 508 227 509 228 510 def check_model_name(self, event): … … 256 538 if len(self.model_list) == len(self.model_toFit): 257 539 self.cb1.SetValue(True) 258 self. Layout()540 self.FitInside() 259 541 return 260 542 else: 261 543 self.cb1.SetValue(False) 262 self. Layout()544 self.FitInside() 263 545 264 546 def _update_easy_setup_cb(self): … … 277 559 self.model_cbox_left.SetSelection(0) 278 560 self.sizer2.Layout() 279 self.sizer3.Layout()280 281 def draw_page(self):282 """283 Draw a sizer containing couples of data and model284 """285 self.model_list = []286 self.model_toFit = []287 self.constraints_list = []288 self.constraint_dict = {}289 self.nb_constraint = 0290 self.model_cbox_left = None291 self.model_cbox_right = None292 293 if len(self.model_list) > 0:294 for item in self.model_list:295 item[0].SetValue(False)296 self.manager.schedule_for_fit(value=0, uid=item[2])297 298 self.sizer1.Clear(True)299 box_description = wx.StaticBox(self, wx.ID_ANY, "Fit Combinations")300 boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL)301 sizer_title = wx.BoxSizer(wx.HORIZONTAL)302 sizer_couples = wx.GridBagSizer(5, 5)303 #------------------------------------------------------304 if len(self.page_finder) == 0:305 msg = " No fit combinations are found! \n\n"306 msg += " Please load data and set up "307 msg += "at least two fit panels first..."308 sizer_title.Add(wx.StaticText(self, wx.ID_ANY, msg))309 else:310 ## store model311 self._store_model()312 313 self.cb1 = wx.CheckBox(self, wx.ID_ANY, 'Select all')314 self.cb1.SetValue(False)315 316 wx.EVT_CHECKBOX(self, self.cb1.GetId(), self.check_all_model_name)317 318 sizer_title.Add((10, 10), 0,319 wx.TOP | wx.BOTTOM | wx.EXPAND | wx.ADJUST_MINSIZE, border=5)320 sizer_title.Add(self.cb1, 0,321 wx.TOP | wx.BOTTOM | wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, border=5)322 323 ## draw list of model and data name324 self._fill_sizer_model_list(sizer_couples)325 ## draw the sizer containing constraint info326 if not self.batch_on:327 self._fill_sizer_constraint()328 ## draw fit button329 self._fill_sizer_fit()330 #--------------------------------------------------------331 boxsizer1.Add(sizer_title, flag=wx.TOP | wx.BOTTOM, border=5)332 boxsizer1.Add(sizer_couples, 1, flag=wx.TOP | wx.BOTTOM, border=5)333 334 self.sizer1.Add(boxsizer1, 1, wx.EXPAND | wx.ALL, 10)335 self.sizer1.Layout()336 #self.SetScrollbars(20,20,25,65)337 self.AdjustScrollbars()338 self.Layout()339 561 340 562 def _store_model(self): … … 362 584 self._show_all_constraint() 363 585 self._show_constraint() 364 self. Layout()586 self.FitInside() 365 587 return 366 588 else: 367 589 self._hide_constraint() 368 self.Layout()369 590 return 370 591 … … 415 636 item=sizer_constraint, 416 637 flag=wx.TOP | wx.BOTTOM | wx.EXPAND, border=5) 417 418 self.sizer_all_constraints.Layout() 419 self.sizer2.Layout() 420 #self.SetScrollbars(20,20,25,65) 638 self.FitInside() 421 639 422 640 def _on_select_modelcb(self, event): … … 475 693 self._show_constraint() 476 694 477 self.sizer_constraints.Layout() 478 self.sizer2.Layout() 479 self.SetScrollbars(20, 20, 25, 65) 480 self.Layout() 695 self.FitInside() 481 696 if not has_param: 482 697 msg = " There is no adjustable parameter (checked to fit)" … … 564 779 self.sizer_constraints.Layout() 565 780 self.sizer2.Layout() 781 self.Layout 566 782 567 783 def _hide_constraint(self): … … 589 805 self.sizer_constraints.Layout() 590 806 self.sizer2.Layout() 807 self.Layout 808 self.FitInside() 591 809 592 810 def _on_select_model(self, event): … … 620 838 btRemove.Show(True) 621 839 self.btAdd.Show(True) 622 self.sizer2.Layout() 840 # self.Layout() 841 self.FitInside() 623 842 624 843 def _on_select_param(self, event): … … 666 885 ## some model or parameters can be constrained 667 886 self._show_constraint() 668 self.sizer3.Layout() 669 self.Layout() 670 self.Refresh() 671 672 def _fill_sizer_fit(self): 673 """ 674 Draw fit button 675 """ 676 self.sizer3.Clear(True) 677 box_description = wx.StaticBox(self, wx.ID_ANY, "Fit ") 678 boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) 679 sizer_button = wx.BoxSizer(wx.HORIZONTAL) 680 681 self.btFit = wx.Button(self, self.ID_FIT, 'Fit', size=wx.DefaultSize) 682 self.btFit.Bind(wx.EVT_BUTTON, self.onFit, id=self.btFit.GetId()) 683 self.btFit.SetToolTipString("Perform fit.") 684 if self.batch_on: 685 text = " Fit in Parallel all Data set and model selected.\n" 686 else: 687 text = " This page requires at least one FitPage with a data\n" 688 text = " and a model for fitting." 689 text_hint = wx.StaticText(self, wx.ID_ANY, text) 690 691 sizer_button.Add(text_hint, wx.RIGHT | wx.EXPAND, 10) 692 sizer_button.Add(self.btFit, 0, wx.LEFT | wx.ADJUST_MINSIZE, 10) 693 694 boxsizer1.Add(sizer_button, flag=wx.TOP | wx.BOTTOM, border=10) 695 self.sizer3.Add(boxsizer1, 0, wx.EXPAND | wx.ALL, 10) 696 self.sizer3.Layout() 697 698 def _fill_sizer_constraint(self): 699 """ 700 Fill sizer containing constraint info 701 """ 702 msg = "Select at least 2 model to add constraint " 703 wx.PostEvent(self.parent.parent, StatusEvent(status=msg)) 704 705 self.sizer2.Clear(True) 706 if self.batch_on: 707 if self.sizer2.IsShown(): 708 self.sizer2.Show(False) 709 return 710 box_description = wx.StaticBox(self, wx.ID_ANY, "Fit Constraints") 711 boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) 712 sizer_title = wx.BoxSizer(wx.HORIZONTAL) 713 self.sizer_all_constraints = wx.BoxSizer(wx.HORIZONTAL) 714 self.sizer_constraints = wx.BoxSizer(wx.VERTICAL) 715 sizer_button = wx.BoxSizer(wx.HORIZONTAL) 716 717 self.hide_constraint = wx.RadioButton(self, wx.ID_ANY, 'No', (10, 10), 718 style=wx.RB_GROUP) 719 self.show_constraint = wx.RadioButton(self, wx.ID_ANY, 'Yes', (10, 30)) 720 self.Bind(wx.EVT_RADIOBUTTON, self._display_constraint, 721 id=self.hide_constraint.GetId()) 722 self.Bind(wx.EVT_RADIOBUTTON, self._display_constraint, 723 id=self.show_constraint.GetId()) 724 if self.batch_on: 725 self.hide_constraint.Enable(False) 726 self.show_constraint.Enable(False) 727 self.hide_constraint.SetValue(True) 728 self.show_constraint.SetValue(False) 729 730 sizer_title.Add(wx.StaticText(self, wx.ID_ANY, " Model")) 731 sizer_title.Add((10, 10)) 732 sizer_title.Add(wx.StaticText(self, wx.ID_ANY, " Parameter")) 733 sizer_title.Add((10, 10)) 734 sizer_title.Add(wx.StaticText(self, wx.ID_ANY, " Add Constraint?")) 735 sizer_title.Add((10, 10)) 736 sizer_title.Add(self.show_constraint) 737 sizer_title.Add(self.hide_constraint) 738 sizer_title.Add((10, 10)) 739 740 self.btAdd = wx.Button(self, self.ID_ADD, 'Add') 741 self.btAdd.Bind(wx.EVT_BUTTON, self._onAdd_constraint, 742 id=self.btAdd.GetId()) 743 self.btAdd.SetToolTipString("Add another constraint?") 744 self.btAdd.Hide() 745 746 text_hint = wx.StaticText(self, wx.ID_ANY, 747 "Example: [M0][paramter] = M1.parameter") 748 sizer_button.Add(text_hint, 0, 749 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 10) 750 sizer_button.Add(self.btAdd, 0, 751 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 10) 752 753 boxsizer1.Add(sizer_title, flag=wx.TOP | wx.BOTTOM, border=10) 754 boxsizer1.Add(self.sizer_all_constraints, flag=wx.TOP | wx.BOTTOM, 755 border=10) 756 boxsizer1.Add(self.sizer_constraints, flag=wx.TOP | wx.BOTTOM, 757 border=10) 758 boxsizer1.Add(sizer_button, flag=wx.TOP | wx.BOTTOM, border=10) 759 760 self.sizer2.Add(boxsizer1, 0, wx.EXPAND | wx.ALL, 10) 761 self.sizer2.Layout() 762 763 #self.SetScrollbars(20,20,25,65) 887 self.FitInside() 764 888 765 889 def _set_constraint(self): 766 890 """ 767 get values from the constrain st textcrtl ,parses them into model name891 get values from the constraint textcrtl ,parses them into model name 768 892 parameter name and parameters values. 769 893 store them in a list self.params .when when params is not empty … … 817 941 return True 818 942 819 def _fill_sizer_model_list(self, sizer):820 """821 Receive a dictionary containing information to display model name822 """823 ix = 0824 iy = 0825 list = []826 sizer.Clear(True)827 828 new_name = wx.StaticText(self, wx.ID_ANY, ' Model Title ',829 style=wx.ALIGN_CENTER)830 new_name.SetBackgroundColour('orange')831 new_name.SetForegroundColour(wx.WHITE)832 sizer.Add(new_name, (iy, ix), (1, 1),833 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)834 ix += 2835 model_type = wx.StaticText(self, wx.ID_ANY, ' Model ')836 model_type.SetBackgroundColour('grey')837 model_type.SetForegroundColour(wx.WHITE)838 sizer.Add(model_type, (iy, ix), (1, 1),839 wx.EXPAND | wx.ADJUST_MINSIZE, 0)840 ix += 1841 data_used = wx.StaticText(self, wx.ID_ANY, ' Data ')842 data_used.SetBackgroundColour('grey')843 data_used.SetForegroundColour(wx.WHITE)844 sizer.Add(data_used, (iy, ix), (1, 1),845 wx.EXPAND | wx.ADJUST_MINSIZE, 0)846 ix += 1847 tab_used = wx.StaticText(self, wx.ID_ANY, ' FitPage ')848 tab_used.SetBackgroundColour('grey')849 tab_used.SetForegroundColour(wx.WHITE)850 sizer.Add(tab_used, (iy, ix), (1, 1),851 wx.EXPAND | wx.ADJUST_MINSIZE, 0)852 for id, value in self.page_finder.iteritems():853 if id not in self.parent.opened_pages:854 continue855 856 if self.batch_on != self.parent.get_page_by_id(id).batch_on:857 continue858 859 data_list = []860 model_list = []861 # get data name and model objetta862 for fitproblem in value.get_fit_problem():863 864 data = fitproblem.get_fit_data()865 if not data.is_data:866 continue867 name = '-'868 if data is not None and data.is_data:869 name = str(data.name)870 data_list.append(name)871 872 model = fitproblem.get_model()873 if model is None:874 continue875 model_list.append(model)876 877 if len(model_list) == 0:878 continue879 # Draw sizer880 ix = 0881 iy += 1882 model = model_list[0]883 name = '_'884 if model is not None:885 name = str(model.name)886 cb = wx.CheckBox(self, wx.ID_ANY, name)887 cb.SetValue(False)888 cb.Enable(model is not None and data.is_data)889 sizer.Add(cb, (iy, ix), (1, 1),890 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)891 wx.EVT_CHECKBOX(self, cb.GetId(), self.check_model_name)892 ix += 2893 model_type = wx.StaticText(self, wx.ID_ANY,894 model.__class__.__name__)895 sizer.Add(model_type, (iy, ix), (1, 1),896 wx.EXPAND | wx.ADJUST_MINSIZE, 0)897 if self.batch_on:898 data_used = wx.ComboBox(self, wx.ID_ANY, style=wx.CB_READONLY)899 data_used.AppendItems(data_list)900 data_used.SetSelection(0)901 else:902 data_used = wx.StaticText(self, wx.ID_ANY, data_list[0])903 904 ix += 1905 sizer.Add(data_used, (iy, ix), (1, 1),906 wx.EXPAND | wx.ADJUST_MINSIZE, 0)907 ix += 1908 caption = value.get_fit_tab_caption()909 tab_caption_used = wx.StaticText(self, wx.ID_ANY, str(caption))910 sizer.Add(tab_caption_used, (iy, ix), (1, 1),911 wx.EXPAND | wx.ADJUST_MINSIZE, 0)912 913 self.model_list.append([cb, value, id, model])914 915 iy += 1916 sizer.Add((20, 20), (iy, ix), (1, 1),917 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)918 sizer.Layout()919 920 943 def on_set_focus(self, event=None): 921 944 """
Note: See TracChangeset
for help on using the changeset viewer.