Changes in / [e8e3e38:ed5beb3] in sasview
- Files:
-
- 1 added
- 6 deleted
- 22 edited
Legend:
- Unmodified
- Added
- Removed
-
.gitignore
ra93d6b1 rbc873053 15 15 .mplconfig 16 16 17 /setup.cfg 18 17 19 /dist 18 20 /build … … 21 23 **/test/logs 22 24 *.pyc 25 *.so 23 26 default_categories.json 24 27 … … 34 37 /docs/sphinx-docs/source/user/perspectives 35 38 39 # test outputs 40 /test/pr_inversion/test/test_output.txt 41 /test/sasdataloader/test/plugins.zip 42 /test/sasdataloader/test/test_log.txt -
sasview/README.txt
r9533593 r40c69b3 255 255 256 256 2.2- Installing from source 257 - Get the code from GitHub at https://github.com/SasView/sasview.git 258 for this release version use: https://github.com/SasView/sasview/releases 259 - run 'python setup.py install' under the 'sasview-x.x.x' folder 257 - Get the source code 258 - to follow the current development version from source control use 259 git clone https://github.com/SasView/sasview.git 260 git clone https://github.com/bumps/bumps.git 261 - to install a specific version 262 263 - Build, install and run a specific release 264 - make sure the requirements below are already installed 265 - retrieve the source from https://github.com/SasView/sasview/releases 266 - open a command line window in the 'sasview-x.x.x' directory 267 - run 'python setup.py install' 260 268 - run 'python sasview.py' under the 'sasview' folder. 261 269 270 - Build, install and run the current development version 271 - clone the source from git; also clone bumps, which is developed in parallel 272 git clone https://github.com/SasView/sasview.git 273 git clone https://github.com/bumps/bumps.git 274 - open a command line window in the 'sasview' directory 275 - run 'python setup.py build' 276 - run 'python run.py'; this runs from the source directories, so you 277 don't have to rebuild every time you make a change, unless you are 278 changing the C++ model files 279 262 280 - The following modules are required (version numbers are what are used 263 281 in the windows release build): -
sasview/sasview.py
r199bb42b r85130cb 69 69 70 70 import wx 71 71 72 try: 72 73 logging.info("Wx version: %s" % wx.__version__) 73 74 except: 74 75 logging.error("Wx version: error reading version") 76 77 import wxcruft 78 wxcruft.call_later_fix() 79 #wxcruft.trace_new_id() 75 80 76 81 # The below will make sure that sasview application uses the matplotlib font -
src/sas/guiframe/gui_toolbar.py
r79492222 r6f16e25 36 36 Implement toolbar for guiframe 37 37 """ 38 ID_BOOKMARK = wx.NewId() 38 39 def __init__(self, parent, *args, **kwds): 39 40 Tbar.__init__(self, parent, *args, **kwds) … … 133 134 Add default items in bookmark menu 134 135 """ 135 id = wx.NewId() 136 self._bookmark_menu.Append(id, 'Bookmark This Page State') 136 self._bookmark_menu.Append(self.ID_BOOKMARK, 'Bookmark This Page State') 137 137 self._bookmark_menu.AppendSeparator() 138 wx.EVT_MENU(self, id, self.on_bookmark)138 wx.EVT_MENU(self, self.ID_BOOKMARK, self.on_bookmark) 139 139 140 140 def on_bind_button(self): -
src/sas/guiframe/local_perspectives/plotting/Plotter1D.py
r098f3d2 r6f16e25 19 19 from sas.guiframe.events import StatusEvent 20 20 from sas.guiframe.events import PanelOnFocusEvent 21 from sas.guiframe.utils import PanelMenu 21 from sas.guiframe.utils import PanelMenu, IdList 22 22 from sas.guiframe.panel_base import PanelBase 23 23 from sas.guiframe.gui_style import GUIFRAME_ICON … … 35 35 """return the key of dictionary dic given the value""" 36 36 return [k for k, v in dic.iteritems() if v == val][0] 37 38 39 37 40 38 class ModelPanel1D(PlotPanel, PanelBase): … … 52 50 ## Group ID 53 51 group_id = None 52 _menu_ids = IdList() 54 53 55 54 def __init__(self, parent, id=-1, color=None, … … 68 67 69 68 self._available_data = [] 70 self._menu_add_ids = []71 69 self._symbol_labels = self.get_symbol_label() 72 70 self._color_labels = self.get_color_label() … … 556 554 self._slicerpop.set_plots(self.plots) 557 555 self._slicerpop.set_graph(self.graph) 556 ids = iter(self._menu_ids) 558 557 if not self.graph.selected_plottable in self.plots: 559 558 # Various plot options 560 wx_id = wx.NewId()559 wx_id = ids.next() 561 560 self._slicerpop.Append(wx_id, '&Save Image', 'Save image as PNG') 562 561 wx.EVT_MENU(self, wx_id, self.onSaveImage) 563 wx_id = wx.NewId()562 wx_id = ids.next() 564 563 self._slicerpop.Append(wx_id, '&Print Image', 'Print image ') 565 564 wx.EVT_MENU(self, wx_id, self.onPrint) 566 565 567 wx_id = wx.NewId()566 wx_id = ids.next() 568 567 self._slicerpop.Append(wx_id, '&Copy to Clipboard', 569 568 'Copy to the clipboard') … … 582 581 continue 583 582 584 wx_id = wx.NewId()583 wx_id = ids.next() 585 584 plot_menu.Append(wx_id, "&DataInfo", name) 586 585 wx.EVT_MENU(self, wx_id, self. _onDataShow) 587 wx_id = wx.NewId()586 wx_id = ids.next() 588 587 plot_menu.Append(wx_id, "&Save Points as a File", name) 589 588 wx.EVT_MENU(self, wx_id, self._onSave) … … 592 591 # add menu of other plugins 593 592 item_list = self.parent.get_current_context_menu(self) 594 595 593 if (not item_list == None) and (not len(item_list) == 0): 596 for item in item_list: 594 # Note: reusing menu ids in submenu. This code works because 595 # IdItems is set up as a lazy iterator returning each id in 596 # sequence, creating new ids as needed so it never runs out. 597 # zip() is set up to stop when any iterator is empty, so it 598 # only asks for the number of ids in item_list. 599 for item, wx_id in zip(item_list, self._menu_ids): 597 600 598 601 try: 599 wx_id = wx.NewId()600 602 plot_menu.Append(wx_id, item[0], name) 601 603 wx.EVT_MENU(self, wx_id, item[2]) … … 607 609 608 610 if self.parent.ClassName.count('wxDialog') == 0: 609 wx_id = wx.NewId()611 wx_id = ids.next() 610 612 plot_menu.Append(wx_id, '&Linear Fit', name) 611 613 wx.EVT_MENU(self, wx_id, self.onFitting) 612 614 plot_menu.AppendSeparator() 613 615 614 wx_id = wx.NewId()616 wx_id = ids.next() 615 617 plot_menu.Append(wx_id, "Remove", name) 616 618 wx.EVT_MENU(self, wx_id, self._onRemove) 617 619 if not plot.is_data: 618 wx_id = wx.NewId()620 wx_id = ids.next() 619 621 plot_menu.Append(wx_id, '&Freeze', name) 620 622 wx.EVT_MENU(self, wx_id, self.onFreeze) … … 622 624 623 625 if plot.is_data: 624 wx_id = wx.NewId()626 wx_id = ids.next() 625 627 self.hide_menu = plot_menu.Append(wx_id, "Hide Error Bar", name) 626 628 … … 636 638 plot_menu.AppendSeparator() 637 639 638 wx_id = wx.NewId()640 wx_id = ids.next() 639 641 plot_menu.Append(wx_id, '&Modify Plot Property', name) 640 642 wx.EVT_MENU(self, wx_id, self.createAppDialog) 641 wx_id = wx.NewId()643 wx_id = ids.next() 642 644 # plot_menu.SetTitle(name) 643 645 self._slicerpop.AppendMenu(wx_id, '&%s' % name, plot_menu) … … 648 650 loc_menu = wx.Menu() 649 651 for label in self._loc_labels: 650 wx_id = wx.NewId()652 wx_id = ids.next() 651 653 loc_menu.Append(wx_id, str(label), str(label)) 652 654 wx.EVT_MENU(self, wx_id, self.onChangeLegendLoc) 653 655 654 wx_id = wx.NewId()656 wx_id = ids.next() 655 657 self._slicerpop.Append(wx_id, '&Modify Graph Appearance', 656 658 'Modify graph appearance') … … 660 662 661 663 if self.position != None: 662 wx_id = wx.NewId()664 wx_id = ids.next() 663 665 self._slicerpop.Append(wx_id, '&Add Text') 664 666 wx.EVT_MENU(self, wx_id, self._on_addtext) 665 wx_id = wx.NewId()667 wx_id = ids.next() 666 668 self._slicerpop.Append(wx_id, '&Remove Text') 667 669 wx.EVT_MENU(self, wx_id, self._on_removetext) 668 670 self._slicerpop.AppendSeparator() 669 wx_id = wx.NewId()671 wx_id = ids.next() 670 672 self._slicerpop.Append(wx_id, '&Change Scale') 671 673 wx.EVT_MENU(self, wx_id, self._onProperties) 672 674 self._slicerpop.AppendSeparator() 673 wx_id = wx.NewId()675 wx_id = ids.next() 674 676 self._slicerpop.Append(wx_id, '&Reset Graph Range') 675 677 wx.EVT_MENU(self, wx_id, self.onResetGraph) … … 677 679 if self.parent.ClassName.count('wxDialog') == 0: 678 680 self._slicerpop.AppendSeparator() 679 wx_id = wx.NewId()681 wx_id = ids.next() 680 682 self._slicerpop.Append(wx_id, '&Window Title') 681 683 wx.EVT_MENU(self, wx_id, self.onChangeCaption) -
src/sas/guiframe/local_perspectives/plotting/Plotter2D.py
r098f3d2 r6f16e25 287 287 288 288 """ 289 ids = iter(self._menu_ids) 289 290 slicerpop = PanelMenu() 290 291 slicerpop.set_plots(self.plots) 291 292 slicerpop.set_graph(self.graph) 292 293 293 wx_id = wx.NewId()294 wx_id = ids.next() 294 295 slicerpop.Append(wx_id, '&Save Image') 295 296 wx.EVT_MENU(self, wx_id, self.onSaveImage) 296 297 297 wx_id = wx.NewId()298 wx_id = ids.next() 298 299 slicerpop.Append(wx_id, '&Print Image', 'Print image') 299 300 wx.EVT_MENU(self, wx_id, self.onPrint) 300 301 301 wx_id = wx.NewId()302 wx_id = ids.next() 302 303 slicerpop.Append(wx_id, '&Copy to Clipboard', 'Copy to the clipboard') 303 304 wx.EVT_MENU(self, wx_id, self.OnCopyFigureMenu) … … 305 306 # saving data 306 307 plot = self.data2D 307 wx_id = wx.NewId()308 wx_id = ids.next() 308 309 slicerpop.Append(wx_id, "&Data Info") 309 310 wx.EVT_MENU(self, wx_id, self._onDataShow) 310 311 311 wx_id = wx.NewId()312 wx_id = ids.next() 312 313 slicerpop.Append(wx_id, "&Save as a File (DAT)") 313 314 self.action_ids[str(wx_id)] = plot … … 320 321 self.data2D.name.split(" ")[0] != 'Residuals': 321 322 # The line above; Not for trunk 322 for item in item_list: 323 # Note: reusing menu ids for the sub-menus. See Plotter1D. 324 for item, wx_id in zip(item_list, self._menu_ids): 323 325 try: 324 wx_id = wx.NewId()325 326 slicerpop.Append(wx_id, item[0], item[1]) 326 327 wx.EVT_MENU(self, wx_id, item[2]) … … 331 332 slicerpop.AppendSeparator() 332 333 333 wx_id = wx.NewId()334 wx_id = ids.next() 334 335 slicerpop.Append(wx_id, '&Perform Circular Average') 335 336 wx.EVT_MENU(self, wx_id, self.onCircular) \ 336 337 # For Masked Data 337 338 if not plot.mask.all(): 338 wx_id = wx.NewId()339 wx_id = ids.next() 339 340 slicerpop.Append(wx_id, '&Masked Circular Average') 340 341 wx.EVT_MENU(self, wx_id, self.onMaskedCircular) 341 wx_id = wx.NewId()342 wx_id = ids.next() 342 343 slicerpop.Append(wx_id, '&Sector [Q View]') 343 344 wx.EVT_MENU(self, wx_id, self.onSectorQ) 344 wx_id = wx.NewId()345 wx_id = ids.next() 345 346 slicerpop.Append(wx_id, '&Annulus [Phi View ]') 346 347 wx.EVT_MENU(self, wx_id, self.onSectorPhi) 347 wx_id = wx.NewId()348 wx_id = ids.next() 348 349 slicerpop.Append(wx_id, '&Box Sum') 349 350 wx.EVT_MENU(self, wx_id, self.onBoxSum) 350 wx_id = wx.NewId()351 wx_id = ids.next() 351 352 slicerpop.Append(wx_id, '&Box Averaging in Qx') 352 353 wx.EVT_MENU(self, wx_id, self.onBoxavgX) 353 wx_id = wx.NewId()354 wx_id = ids.next() 354 355 slicerpop.Append(wx_id, '&Box Averaging in Qy') 355 356 wx.EVT_MENU(self, wx_id, self.onBoxavgY) 356 357 if self.slicer != None: 357 wx_id = wx.NewId()358 wx_id = ids.next() 358 359 slicerpop.Append(wx_id, '&Clear Slicer') 359 360 wx.EVT_MENU(self, wx_id, self.onClearSlicer) 360 361 if self.slicer.__class__.__name__ != "BoxSum": 361 wx_id = wx.NewId()362 wx_id = ids.next() 362 363 slicerpop.Append(wx_id, '&Edit Slicer Parameters') 363 364 wx.EVT_MENU(self, wx_id, self._onEditSlicer) 364 365 slicerpop.AppendSeparator() 365 366 366 wx_id = wx.NewId()367 wx_id = ids.next() 367 368 slicerpop.Append(wx_id, '&Edit Graph Label', 'Edit Graph Label') 368 369 wx.EVT_MENU(self, wx_id, self.onEditLabels) … … 371 372 # ILL mod here 372 373 373 wx_id = wx.NewId()374 wx_id = ids.next() 374 375 slicerpop.Append(wx_id, '&Modify graph appearance', 'Modify graph appearance') 375 376 wx.EVT_MENU(self, wx_id, self.modifyGraphAppearance) 376 377 slicerpop.AppendSeparator() 377 378 378 wx_id = wx.NewId()379 wx_id = ids.next() 379 380 slicerpop.Append(wx_id, '&2D Color Map') 380 381 wx.EVT_MENU(self, wx_id, self._onEditDetector) 381 382 slicerpop.AppendSeparator() 382 383 383 wx_id = wx.NewId()384 wx_id = ids.next() 384 385 slicerpop.Append(wx_id, '&Toggle Linear/Log Scale') 385 386 wx.EVT_MENU(self, wx_id, self._onToggleScale) 386 387 387 388 slicerpop.AppendSeparator() 388 wx_id = wx.NewId()389 wx_id = ids.next() 389 390 slicerpop.Append(wx_id, '&Window Title') 390 391 wx.EVT_MENU(self, wx_id, self.onChangeCaption) -
src/sas/guiframe/utils.py
r79492222 r6f16e25 123 123 return begin_flag, end_flag 124 124 125 class IdList: 126 """ 127 Create a list of wx ids that can be reused. 128 129 Ids for items need to be unique within their context. In a dynamic 130 application where the number of ids needed different each time the 131 form is created, depending for example, on the number of items that 132 need to be shown in the context menu, you cannot preallocate the 133 ids that you are going to use for the form. Instead, you can use 134 an IdList, which will reuse ids from context to context, adding new 135 ones if the new context requires more than a previous context. 136 137 IdList is set up as an iterator, which returns new ids forever 138 or until it runs out. This makes it pretty useful for defining 139 menus:: 140 141 class Form(wx.Dialog): 142 _form_id_pool = IdList() 143 def __init__(self): 144 ... 145 menu = wx.Menu() 146 for item, wx_id in zip(menu_items, self._form_id_pool): 147 name, description, callback = item 148 menu.Append(wx_id, name, description) 149 wx.EVT_MENU(self, wx_id, callback) 150 ... 151 152 It is a little unusual to use an iterator outside of a loop, but it is 153 supported. For example, when defining a form, your class definition 154 might look something like:: 155 156 class Form(wx.Dialog): 157 _form_id_pool = IdList() 158 def __init__(self, pairs, ...): 159 ids = iter(_form_id_pool) 160 ... 161 wx.StaticText(self, ids.next(), "Some key-value pairs") 162 for name, value in pairs: 163 label = wx.StaticText(self, ids.next(), name) 164 input = wx.TextCtrl(self, ids.next(), value=str(value)) 165 ... 166 ... 167 168 If the dialog is really dynamic, and not defined all in one place, then 169 save the id list iterator as *self._ids = iter(_form_id_pool)* in the 170 constructor. 171 172 The wx documentation is not clear on whether ids need to be unique. 173 Clearly different dialogs can use the same ids, as this is done for the 174 standard button ids such as wx.ID_HELP. Presumably each widget on the 175 form needs its own id, but whether these ids can match the ids of menu 176 items is not indicated, or whether different submenus need their own 177 ids. Using different id lists for menu items and widgets is safest, 178 but probably not necessary. And what about notebook tabs. Do the 179 ids need to be unique across all tabs? 180 """ 181 def __init__(self): 182 self._ids = [] 183 def __iter__(self): 184 return _IdListIterator(self) 185 def __getitem__(self, index): 186 while index >= len(self._ids): 187 self._ids.append(wx.NewId()) 188 return self._ids[index] 189 190 class _IdListIterator: 191 def __init__(self, id_list): 192 self.id_list = id_list 193 self.index = -1 194 def next(self): 195 self.index += 1 196 return self.id_list[self.index] 197 -
src/sas/models/PeakGaussModel.py
rac7be54 rd430ee8 3 3 PeakGaussModel function as a BaseComponent model 4 4 """ 5 from __future__ import division 5 6 6 7 from sas.models.BaseComponent import BaseComponent -
src/sas/models/resolution.py
rbe0c318 r80ba1a2 11 11 MINIMUM_RESOLUTION = 1e-8 12 12 13 class Resolution1D(object): 13 14 # When extrapolating to -q, what is the minimum positive q relative to q_min 15 # that we wish to calculate? 16 MIN_Q_SCALE_FOR_NEGATIVE_Q_EXTRAPOLATION = 0.01 17 18 class Resolution(object): 14 19 """ 15 20 Abstract base class defining a 1D resolution function. … … 32 37 33 38 34 class Perfect1D(Resolution 1D):39 class Perfect1D(Resolution): 35 40 """ 36 41 Resolution function to use when there is no actual resolution smearing … … 45 50 46 51 47 class Pinhole1D(Resolution 1D):52 class Pinhole1D(Resolution): 48 53 r""" 49 54 Pinhole aperture with q-dependent gaussian resolution. … … 77 82 78 83 79 class Slit1D(Resolution 1D):84 class Slit1D(Resolution): 80 85 """ 81 86 Slit aperture with a complicated resolution function. … … 92 97 The *weight_matrix* is computed by :func:`slit1d_resolution` 93 98 """ 94 def __init__(self, q, width, height, q_calc=None): 95 # TODO: maybe issue warnings rather than raising errors 96 if not np.isscalar(width): 97 if np.any(np.diff(width) > 0.0): 98 raise ValueError("Slit resolution requires fixed width slits") 99 width = width[0] 100 if not np.isscalar(height): 101 if np.any(np.diff(height) > 0.0): 102 raise ValueError("Slit resolution requires fixed height slits") 103 height = height[0] 104 99 def __init__(self, q, width, height=0., q_calc=None): 105 100 # Remember what width/height was used even though we won't need them 106 101 # after the weight matrix is constructed 107 102 self.width, self.height = width, height 103 104 # Allow independent resolution on each point even though it is not 105 # needed in practice. 106 if np.isscalar(width): 107 width = np.ones(len(q))*width 108 else: 109 width = np.asarray(width) 110 if np.isscalar(height): 111 height = np.ones(len(q))*height 112 else: 113 height = np.asarray(height) 108 114 109 115 self.q = q.flatten() … … 147 153 148 154 149 def slit_resolution(q_calc, q, width, height ):155 def slit_resolution(q_calc, q, width, height, n_height=30): 150 156 r""" 151 157 Build a weight matrix to compute *I_s(q)* from *I(q_calc)*, given 152 $q_v$ = *width* and $q_h$ = *height*. 153 154 *width* and *height* are scalars since current instruments use the 155 same slit settings for all measurement points. 158 $q_\perp$ = *width* and $q_\parallel$ = *height*. *n_height* is 159 is the number of steps to use in the integration over $q_\parallel$ 160 when both $q_\perp$ and $q_\parallel$ are non-zero. 161 162 Each $q$ can have an independent width and height value even though 163 current instruments use the same slit setting for all measured points. 156 164 157 165 If slit height is large relative to width, use: … … 159 167 .. math:: 160 168 161 I_s(q_ o) = \frac{1}{\Delta q_v}162 \int_0^{\Delta q_ v} I(\sqrt{q_o^2 + u^2} du169 I_s(q_i) = \frac{1}{\Delta q_\perp} 170 \int_0^{\Delta q_\perp} I(\sqrt{q_i^2 + q_\perp^2} dq_\perp 163 171 164 172 If slit width is large relative to height, use: … … 166 174 .. math:: 167 175 168 I_s(q_o) = \frac{1}{2 \Delta q_v} 169 \int_{-\Delta q_v}^{\Delta q_v} I(u) du 170 """ 171 if width == 0.0 and height == 0.0: 172 #print "condition zero" 173 return 1 174 176 I_s(q_i) = \frac{1}{2 \Delta q_\parallel} 177 \int_{-\Delta q_\parallel}^{\Delta q_\parallel} 178 I(|q_i + q_\parallel|) dq_\parallel 179 180 For a mixture of slit width and height use: 181 182 .. math:: 183 184 I_s(q_i) = \frac{1}{2 \Delta q_\parallel \Delta q_\perp} 185 \int_{-\Delta q_\parallel)^{\Delta q_parallel} 186 \int_0^[\Delta q_\perp} 187 I(\sqrt{(q_i + q_\parallel)^2 + q_\perp^2}) 188 dq_\perp dq_\parallel 189 190 191 Algorithm 192 --------- 193 194 We are using the mid-point integration rule to assign weights to each 195 element of a weight matrix $W$ so that 196 197 .. math:: 198 199 I_s(q) = W I(q_\text{calc}) 200 201 If *q_calc* is at the mid-point, we can infer the bin edges from the 202 pairwise averages of *q_calc*, adding the missing edges before 203 *q_calc[0]* and after *q_calc[-1]*. 204 205 For $q_\parallel = 0$, the smeared value can be computed numerically 206 using the $u$ substitution 207 208 .. math:: 209 210 u_j = \sqrt{q_j^2 - q^2} 211 212 This gives 213 214 .. math:: 215 216 I_s(q) \approx \sum_j I(u_j) \Delta u_j 217 218 where $I(u_j)$ is the value at the mid-point, and $\Delta u_j$ is the 219 difference between consecutive edges which have been first converted 220 to $u$. Only $u_j \in [0, \Delta q_\perp]$ are used, which corresponds 221 to $q_j \in [q, \sqrt{q^2 + \Delta q_\perp}]$, so 222 223 .. math:: 224 225 W_{ij} = \frac{1}{\Delta q_\perp} \Delta u_j 226 = \frac{1}{\Delta q_\perp} 227 \sqrt{q_{j+1}^2 - q_i^2} - \sqrt{q_j^2 - q_i^2} 228 \text{if} q_j \in [q_i, \sqrt{q_i^2 + q_\perp^2}] 229 230 where $I_s(q_i)$ is the theory function being computed and $q_j$ are the 231 mid-points between the calculated values in *q_calc*. We tweak the 232 edges of the initial and final intervals so that they lie on integration 233 limits. 234 235 (To be precise, the transformed midpoint $u(q_j)$ is not necessarily the 236 midpoint of the edges $u((q_{j-1}+q_j)/2)$ and $u((q_j + q_{j+1})/2)$, 237 but it is at least in the interval, so the approximation is going to be 238 a little better than the left or right Riemann sum, and should be 239 good enough for our purposes.) 240 241 For $q_\perp = 0$, the $u$ substitution is simpler: 242 243 .. math:: 244 245 u_j = |q_j - q| 246 247 so 248 249 .. math:: 250 251 W_ij = \frac{1}{2 \Delta q_\parallel} \Delta u_j 252 = \frac{1}{2 \Delta q_\parallel} (q_{j+1} - q_j) 253 \text{if} q_j \in [q-\Delta q_\parallel, q+\Delta q_\parallel] 254 255 However, we need to support cases were $u_j < 0$, which means using 256 $2 (q_{j+1} - q_j)$ when $q_j \in [0, q_\parallel-q_i]$. This is not 257 an issue for $q_i > q_\parallel$. 258 259 For bot $q_\perp > 0$ and $q_\parallel > 0$ we perform a 2 dimensional 260 integration with 261 262 .. math:: 263 264 u_jk = \sqrt{q_j^2 - (q + (k\Delta q_\parallel/L))^2} 265 \text{for} k = -L \ldots L 266 267 for $L$ = *n_height*. This gives 268 269 .. math:: 270 271 W_{ij} = \frac{1}{2 \Delta q_\perp q_\parallel} 272 \sum_{k=-L}^L \Delta u_jk (\frac{\Delta q_\parallel}{2 L + 1} 273 274 275 """ 276 #np.set_printoptions(precision=6, linewidth=10000) 277 278 # The current algorithm is a midpoint rectangle rule. 175 279 q_edges = bin_edges(q_calc) # Note: requires q > 0 176 280 q_edges[q_edges<0.0] = 0.0 # clip edges below zero 177 178 #np.set_printoptions(linewidth=10000) 179 if width <= 100.0 * height or height == 0: 180 # The current algorithm is a midpoint rectangle rule. In the test case, 181 # neither trapezoid nor Simpson's rule improved the accuracy. 182 #print "condition h", q_edges.shape, q.shape, q_calc.shape 183 weights = np.zeros((len(q), len(q_calc)), 'd') 184 for i, qi in enumerate(q): 185 weights[i, :] = np.diff(q_to_u(q_edges, qi)) 186 weights /= width 187 weights = weights.T 188 else: 189 #print "condition w" 190 # Make q_calc into a row vector, and q into a column vector 191 q, q_calc = q[None,:], q_calc[:,None] 192 in_x = (q_calc >= q-width) * (q_calc <= q+width) 193 weights = np.diff(q_edges)[:,None] * in_x 194 281 weights = np.zeros((len(q), len(q_calc)), 'd') 282 283 #print q_calc 284 for i, (qi, w, h) in enumerate(zip(q, width, height)): 285 if w == 0. and h == 0.: 286 # Perfect resolution, so return the theory value directly. 287 # Note: assumes that q is a subset of q_calc. If qi need not be 288 # in q_calc, then we can do a weighted interpolation by looking 289 # up qi in q_calc, then weighting the result by the relative 290 # distance to the neighbouring points. 291 weights[i, :] = (q_calc == qi) 292 elif h == 0: 293 weights[i, :] = _q_perp_weights(q_edges, qi, w) 294 elif w == 0: 295 in_x = 1.0 * ((q_calc >= qi-h) & (q_calc <= qi+h)) 296 abs_x = 1.0*(q_calc < abs(qi - h)) if qi < h else 0. 297 #print qi - h, qi + h 298 #print in_x + abs_x 299 weights[i,:] = (in_x + abs_x) * np.diff(q_edges) / (2*h) 300 else: 301 L = n_height 302 for k in range(-L, L+1): 303 weights[i,:] += _q_perp_weights(q_edges, qi+k*h/L, w) 304 weights[i,:] /= 2*L + 1 305 306 return weights.T 307 308 309 def _q_perp_weights(q_edges, qi, w): 310 # Convert bin edges from q to u 311 u_limit = np.sqrt(qi**2 + w**2) 312 u_edges = q_edges**2 - qi**2 313 u_edges[q_edges < abs(qi)] = 0. 314 u_edges[q_edges > u_limit] = u_limit**2 - qi**2 315 weights = np.diff(np.sqrt(u_edges))/w 316 #print "i, qi",i,qi,qi+width 317 #print q_calc 318 #print weights 195 319 return weights 196 320 … … 212 336 function. 213 337 """ 214 height # keep lint happy215 q_min, q_max = np.min(q), np.max(np.sqrt(q**2 + width**2)) 338 q_min, q_max = np.min(q-height), np.max(np.sqrt((q+height)**2 + width**2)) 339 216 340 return geometric_extrapolation(q, q_min, q_max) 217 341 … … 233 357 ]) 234 358 return edges 235 236 237 def q_to_u(q, q0):238 """239 Convert *q* values to *u* values for the integral computed at *q0*.240 """241 # array([value])**2 - value**2 is not always zero242 qpsq = q**2 - q0**2243 qpsq[qpsq<0] = 0244 return sqrt(qpsq)245 359 246 360 … … 275 389 q = np.sort(q) 276 390 if q_min < q[0]: 277 if q_min <= 0: q_min = q [0]/10391 if q_min <= 0: q_min = q_min*MIN_Q_SCALE_FOR_NEGATIVE_Q_EXTRAPOLATION 278 392 n_low = np.ceil((q[0]-q_min) / (q[1]-q[0])) if q[1]>q[0] else 15 279 393 q_low = np.linspace(q_min, q[0], n_low+1)[:-1] … … 297 411 *points_per_decade* sets the ratio between consecutive steps such 298 412 that there will be $n$ points used for every factor of 10 increase 299 in $q$.413 in *q*. 300 414 301 415 If *points_per_decade* is not given, it will be estimated as follows. … … 316 430 Substituting: 317 431 318 .. math::319 320 432 n_\text{extend} = (n-1) (\log q_\text{max} - \log q_n) 321 / (\log q_n - \log q_1)433 / (\log q_n - log q_1) 322 434 """ 323 435 q = np.sort(q) … … 327 439 log_delta_q = log(10.) / points_per_decade 328 440 if q_min < q[0]: 329 if q_min < 0: q_min = q[0] /10441 if q_min < 0: q_min = q[0]*MIN_Q_SCALE_FOR_NEGATIVE_Q_EXTRAPOLATION 330 442 n_low = log_delta_q * (log(q[0])-log(q_min)) 331 443 q_low = np.logspace(log10(q_min), log10(q[0]), np.ceil(n_low)+1)[:-1] … … 359 471 360 472 361 def romberg_slit_1d(q, delta_qv, form, pars):473 def romberg_slit_1d(q, width, height, form, pars): 362 474 """ 363 475 Romberg integration for slit resolution. … … 366 478 that make it slow to evaluate but give it good accuracy. 367 479 """ 368 from scipy.integrate import romberg 480 from scipy.integrate import romberg, dblquad 369 481 370 482 if any(k not in form.info['defaults'] for k in pars.keys()): … … 374 486 (", ".join(sorted(extra)), ", ".join(sorted(keys)))) 375 487 376 _fn = lambda u, q0: eval_form(sqrt(q0**2 + u**2), form, pars) 377 r = [romberg(_fn, 0, delta_qv[0], args=(qi,), 378 divmax=100, vec_func=True, tol=0, rtol=1e-8) 379 for qi in q] 488 if np.isscalar(width): 489 width = [width]*len(q) 490 if np.isscalar(height): 491 height = [height]*len(q) 492 _int_w = lambda w, qi: eval_form(sqrt(qi**2 + w**2), form, pars) 493 _int_h = lambda h, qi: eval_form(abs(qi+h), form, pars) 494 # If both width and height are defined, then it is too slow to use dblquad. 495 # Instead use trapz on a fixed grid, interpolated into the I(Q) for 496 # the extended Q range. 497 #_int_wh = lambda w, h, qi: eval_form(sqrt((qi+h)**2 + w**2), form, pars) 498 q_calc = slit_extend_q(q, np.asarray(width), np.asarray(height)) 499 Iq = eval_form(q_calc, form, pars) 500 result = np.empty(len(q)) 501 for i, (qi, w, h) in enumerate(zip(q, width, height)): 502 if h == 0.: 503 r = romberg(_int_w, 0, w, args=(qi,), 504 divmax=100, vec_func=True, tol=0, rtol=1e-8) 505 result[i] = r/w 506 elif w == 0.: 507 r = romberg(_int_h, -h, h, args=(qi,), 508 divmax=100, vec_func=True, tol=0, rtol=1e-8) 509 result[i] = r/(2*h) 510 else: 511 w_grid = np.linspace(0, w, 21)[None,:] 512 h_grid = np.linspace(-h, h, 23)[:,None] 513 u = sqrt((qi+h_grid)**2 + w_grid**2) 514 Iu = np.interp(u, q_calc, Iq) 515 #print np.trapz(Iu, w_grid, axis=1) 516 Is = np.trapz(np.trapz(Iu, w_grid, axis=1), h_grid[:,0]) 517 result[i] = Is / (2*h*w) 518 """ 519 r, err = dblquad(_int_wh, -h, h, lambda h: 0., lambda h: w, 520 args=(qi,)) 521 result[i] = r/(w*2*h) 522 """ 523 380 524 # r should be [float, ...], but it is [array([float]), array([float]),...] 381 return np.asarray(r).flatten()/delta_qv[0]525 return result 382 526 383 527 … … 520 664 521 665 def compare(self, q, output, answer, tolerance): 522 err = (output - answer)/answer523 idx = abs(err) >= tolerance524 problem = zip(q[idx], output[idx], answer[idx], err[idx])525 print "\n".join(str(v) for v in problem)666 #err = (output - answer)/answer 667 #idx = abs(err) >= tolerance 668 #problem = zip(q[idx], output[idx], answer[idx], err[idx]) 669 #print "\n".join(str(v) for v in problem) 526 670 np.testing.assert_allclose(output, answer, rtol=tolerance) 527 671 … … 609 753 data = np.loadtxt(data_string.split('\n')).T 610 754 q, delta_qv, _, answer = data 611 answer = romberg_slit_1d(q, delta_qv, self.model, pars)755 answer = romberg_slit_1d(q, delta_qv, 0., self.model, pars) 612 756 q_calc = slit_extend_q(interpolate(q, 2*np.pi/radius/20), 613 delta_qv[0], delta_qv[0])757 delta_qv[0], 0.) 614 758 resolution = Slit1D(q, width=delta_qv, height=0, q_calc=q_calc) 615 759 output = self.Iq_sphere(pars, resolution) … … 629 773 form = load_model('ellipsoid', dtype='double') 630 774 q = np.logspace(log10(4e-5),log10(2.5e-2), 68) 631 delta_qv = [0.117]632 resolution = Slit1D(q, width= delta_qv, height=0)633 answer = romberg_slit_1d(q, delta_qv, form, pars)775 width, height = 0.117, 0. 776 resolution = Slit1D(q, width=width, height=height) 777 answer = romberg_slit_1d(q, width, height, form, pars) 634 778 output = resolution.apply(eval_form(resolution.q_calc, form, pars)) 635 779 # TODO: 10% is too much error; use better algorithm 780 #print np.max(abs(answer-output)/answer) 636 781 self.compare(q, output, answer, 0.1) 637 782 … … 860 1005 861 1006 def _eval_demo_1d(resolution, title): 1007 import sys 862 1008 from sasmodels import core 863 from sasmodels.models import cylinder 864 ## or alternatively: 865 # cylinder = core.load_model_definition('cylinder') 866 model = core.load_model(cylinder) 1009 name = sys.argv[1] if len(sys.argv) > 1 else 'cylinder' 1010 1011 if name == 'cylinder': 1012 pars = {'length':210, 'radius':500} 1013 elif name == 'teubner_strey': 1014 pars = {'a2':0.003, 'c1':-1e4, 'c2':1e10, 'background':0.312643} 1015 elif name == 'sphere' or name == 'spherepy': 1016 pars = TEST_PARS_SLIT_SPHERE 1017 elif name == 'ellipsoid': 1018 pars = { 1019 'scale':0.05, 1020 'rpolar':500, 'requatorial':15000, 1021 'sld':6, 'solvent_sld': 1, 1022 } 1023 else: 1024 pars = {} 1025 defn = core.load_model_definition(name) 1026 model = core.load_model(defn) 867 1027 868 1028 kernel = core.make_kernel(model, [resolution.q_calc]) 869 theory = core.call_kernel(kernel, {'length':210, 'radius':500})1029 theory = core.call_kernel(kernel, pars) 870 1030 Iq = resolution.apply(theory) 1031 1032 if isinstance(resolution, Slit1D): 1033 width, height = resolution.width, resolution.height 1034 Iq_romb = romberg_slit_1d(resolution.q, width, height, model, pars) 1035 else: 1036 dq = resolution.q_width 1037 Iq_romb = romberg_pinhole_1d(resolution.q, dq, model, pars) 871 1038 872 1039 import matplotlib.pyplot as plt 873 1040 plt.loglog(resolution.q_calc, theory, label='unsmeared') 874 1041 plt.loglog(resolution.q, Iq, label='smeared', hold=True) 1042 plt.loglog(resolution.q, Iq_romb, label='romberg smeared', hold=True) 875 1043 plt.legend() 876 1044 plt.title(title) … … 879 1047 880 1048 def demo_pinhole_1d(): 881 q = np.logspace(- 3, -1, 400)1049 q = np.logspace(-4, np.log10(0.2), 400) 882 1050 q_width = 0.1*q 883 1051 resolution = Pinhole1D(q, q_width) … … 885 1053 886 1054 def demo_slit_1d(): 887 q = np.logspace(-3, -1, 400) 888 qx_width = 0.005 889 qy_width = 0.0 890 resolution = Slit1D(q, qx_width, qy_width) 891 _eval_demo_1d(resolution, title="0.005 Qx Slit Resolution") 1055 q = np.logspace(-4, np.log10(0.2), 100) 1056 w = h = 0. 1057 #w = 0.000000277790 1058 w = 0.0277790 1059 #h = 0.00277790 1060 #h = 0.0277790 1061 resolution = Slit1D(q, w, h) 1062 _eval_demo_1d(resolution, title="(%g,%g) Slit Resolution"%(w,h)) 892 1063 893 1064 def demo(): … … 895 1066 plt.subplot(121) 896 1067 demo_pinhole_1d() 1068 #plt.yscale('linear') 897 1069 plt.subplot(122) 898 1070 demo_slit_1d() 1071 #plt.yscale('linear') 899 1072 plt.show() 900 1073 901 1074 902 1075 if __name__ == "__main__": 903 #demo()904 main()1076 demo() 1077 #main() -
src/sas/perspectives/fitting/basepage.py
r2c8dc19 r6f16e25 15 15 from wx.lib.scrolledpanel import ScrolledPanel 16 16 from sas.guiframe.panel_base import PanelBase 17 from sas.guiframe.utils import format_number, check_float 17 from sas.guiframe.utils import format_number, check_float, IdList 18 18 from sas.guiframe.events import PanelOnFocusEvent 19 19 from sas.guiframe.events import StatusEvent … … 57 57 ## Title to appear on top of the window 58 58 window_caption = "Fit Page " 59 # These two buttons have specific IDs since they seem to be created more 60 # frequently than they need to. In particular, set_dispers_sizer() is 61 # called by _on_select_model 62 ID_BOOKMARK = wx.NewId() 63 ID_DISPERSER_HELP = wx.NewId() 64 _id_pool = IdList() 59 65 60 66 def __init__(self, parent, color='blue', **kwargs): … … 66 72 #Set window's font size 67 73 self.SetWindowVariant(variant=FONT_VARIANT) 68 69 74 self.SetBackgroundColour(color) 75 76 self._ids = iter(self._id_pool) 70 77 ## parent of the page 71 78 self.parent = parent … … 199 206 self.popUpMenu = wx.Menu() 200 207 201 id = wx.NewId()202 self._keep = wx.MenuItem(self.popUpMenu, id, "Add bookmark",208 wx_id = self._ids.next() 209 self._keep = wx.MenuItem(self.popUpMenu, wx_id, "Add bookmark", 203 210 " Keep the panel status to recall it later") 204 211 self.popUpMenu.AppendItem(self._keep) … … 206 213 self._set_bookmark_flag(False) 207 214 self._set_save_flag(False) 208 wx.EVT_MENU(self, id, self.on_bookmark)215 wx.EVT_MENU(self, wx_id, self.on_bookmark) 209 216 self.popUpMenu.AppendSeparator() 210 217 … … 594 601 fill sizer containing dispersity info 595 602 """ 603 #print "==== entering set_dispers_sizer ===" 596 604 self.sizer4.Clear(True) 597 605 name = "Polydispersity and Orientational Distribution" 598 box_description = wx.StaticBox(self, -1, name)606 box_description = wx.StaticBox(self, wx.ID_ANY, name) 599 607 box_description.SetForegroundColour(wx.BLUE) 600 608 boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) 601 609 #---------------------------------------------------- 602 self.disable_disp = wx.RadioButton(self, -1, 'Off', (10, 10),610 self.disable_disp = wx.RadioButton(self, wx.ID_ANY, 'Off', (10, 10), 603 611 style=wx.RB_GROUP) 604 self.enable_disp = wx.RadioButton(self, -1, 'On', (10, 30))612 self.enable_disp = wx.RadioButton(self, wx.ID_ANY, 'On', (10, 30)) 605 613 # best size for MAC and PC 606 614 if ON_MAC: … … 608 616 else: 609 617 size_q = (20, 15) 610 self.disp_help_bt = wx.Button(self, wx.NewId(), '?',618 self.disp_help_bt = wx.Button(self, self.ID_DISPERSER_HELP, '?', 611 619 style=wx.BU_EXACTFIT, 612 620 size=size_q) … … 624 632 sizer_dispersion.Add((20, 20)) 625 633 name = "" # Polydispersity and \nOrientational Distribution " 626 sizer_dispersion.Add(wx.StaticText(self, -1, name))634 sizer_dispersion.Add(wx.StaticText(self, wx.ID_ANY, name)) 627 635 sizer_dispersion.Add(self.enable_disp) 628 636 sizer_dispersion.Add((20, 20)) … … 795 803 wx.PostEvent(self._manager.parent, StatusEvent(status=msg)) 796 804 797 id = wx.NewId() 798 self.popUpMenu.Append(id, name, str(msg)) 799 wx.EVT_MENU(self, id, self.onResetModel) 805 self.popUpMenu.Append(self.ID_BOOKMARK, name, str(msg)) 806 wx.EVT_MENU(self, self.ID_BOOKMARK, self.onResetModel) 800 807 wx.PostEvent(self._manager.parent, 801 808 AppendBookmarkEvent(title=name, … … 1438 1445 reset the context menu 1439 1446 """ 1447 ids = iter(self._id_pool) # Reusing ids for context menu 1440 1448 for name, _ in self.state.saved_states.iteritems(): 1441 1449 self.number_saved_state += 1 1442 1450 ## Add item in the context menu 1443 id = wx.NewId()1451 wx_id = ids.next() 1444 1452 msg = 'Save model and state %g' % self.number_saved_state 1445 self.popUpMenu.Append( id, name, msg)1446 wx.EVT_MENU(self, id, self.onResetModel)1453 self.popUpMenu.Append(wx_id, name, msg) 1454 wx.EVT_MENU(self, wx_id, self.onResetModel) 1447 1455 1448 1456 def _reset_plotting_range(self, state): … … 1831 1839 sld_data.name = 'SLD' 1832 1840 sld_data.axes = self.sld_axes 1833 self.panel = SLDPanel(self, data=sld_data, axes=self.sld_axes, id= -1) 1841 self.panel = SLDPanel(self, data=sld_data, axes=self.sld_axes, 1842 id=wx.ID_ANY) 1834 1843 self.panel.ShowModal() 1835 1844 … … 2421 2430 self.sizer4_4.Clear(True) 2422 2431 text = "No polydispersity available for this model" 2423 model_disp = wx.StaticText(self, -1, text)2432 model_disp = wx.StaticText(self, wx.ID_ANY, text) 2424 2433 self.sizer4_4.Add(model_disp, (iy, ix), (1, 1), 2425 2434 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 10) … … 2851 2860 name = self.formfactorbox.GetValue() 2852 2861 _PageAnchor = '#' + name.lower() 2853 _doc_viewer = DocumentationWindow(self, -1, _TreeLocation,2862 _doc_viewer = DocumentationWindow(self, wx.ID_ANY, _TreeLocation, 2854 2863 _PageAnchor, name + " Help") 2855 2864 else: 2856 _doc_viewer = DocumentationWindow(self, -1, _TreeLocation, "",2857 2865 _doc_viewer = DocumentationWindow(self, wx.ID_ANY, _TreeLocation, 2866 "", "General Model Help") 2858 2867 2859 2868 … … 2906 2915 2907 2916 _TreeLocation = "_images/M_angles_pic.bmp" 2908 _doc_viewer = DocumentationWindow(self, -1, _TreeLocation, "",2917 _doc_viewer = DocumentationWindow(self, wx.ID_ANY, _TreeLocation, "", 2909 2918 "Magnetic Angle Defintions") 2910 2919 … … 2926 2935 2927 2936 _TreeLocation = "user/perspectives/fitting/mag_help.html" 2928 _doc_viewer = DocumentationWindow(self, -1, _TreeLocation, "",2937 _doc_viewer = DocumentationWindow(self, wx.ID_ANY, _TreeLocation, "", 2929 2938 "Polarized Beam/Magnetc Help") 2930 2939 … … 2973 2982 _TreeLocation = "user/perspectives/fitting/pd_help.html" 2974 2983 _PageAnchor = "" 2975 _doc_viewer = DocumentationWindow(self, -1, _TreeLocation,2984 _doc_viewer = DocumentationWindow(self, wx.ID_ANY, _TreeLocation, 2976 2985 _PageAnchor, "Polydispersity Help") 2977 2986 … … 3517 3526 fill sizer containing model info 3518 3527 """ 3528 # This should only be called once per fit tab 3529 #print "==== Entering _fill_model_sizer" 3519 3530 ##Add model function Details button in fitpanel. 3520 3531 ##The following 3 lines are for Mac. Let JHC know before modifying... … … 3522 3533 self.formfactorbox = None 3523 3534 self.multifactorbox = None 3524 self.mbox_description = wx.StaticBox(self, -1, str(title))3535 self.mbox_description = wx.StaticBox(self, wx.ID_ANY, str(title)) 3525 3536 boxsizer1 = wx.StaticBoxSizer(self.mbox_description, wx.VERTICAL) 3526 3537 sizer_cat = wx.BoxSizer(wx.HORIZONTAL) 3527 3538 self.mbox_description.SetForegroundColour(wx.RED) 3528 id = wx.NewId() 3529 self.model_func = wx.Button(self, id, 'Help', size=(80, 23)) 3530 self.model_func.Bind(wx.EVT_BUTTON, self.on_function_help_clicked, id=id) 3539 wx_id = self._ids.next() 3540 self.model_func = wx.Button(self, wx_id, 'Help', size=(80, 23)) 3541 self.model_func.Bind(wx.EVT_BUTTON, self.on_function_help_clicked, 3542 id=wx_id) 3531 3543 self.model_func.SetToolTipString("Full Model Function Help") 3532 id = wx.NewId() 3533 self.model_help = wx.Button(self, id, 'Description', size=(80, 23)) 3534 self.model_help.Bind(wx.EVT_BUTTON, self.on_model_help_clicked, id=id) 3544 wx_id = self._ids.next() 3545 self.model_help = wx.Button(self, wx_id, 'Description', size=(80, 23)) 3546 self.model_help.Bind(wx.EVT_BUTTON, self.on_model_help_clicked, 3547 id=wx_id) 3535 3548 self.model_help.SetToolTipString("Short Model Function Description") 3536 id = wx.NewId()3537 self.model_view = wx.Button(self, id, "Show 2D", size=(80, 23))3538 self.model_view.Bind(wx.EVT_BUTTON, self._onModel2D, id= id)3549 wx_id = self._ids.next() 3550 self.model_view = wx.Button(self, wx_id, "Show 2D", size=(80, 23)) 3551 self.model_view.Bind(wx.EVT_BUTTON, self._onModel2D, id=wx_id) 3539 3552 hint = "toggle view of model from 1D to 2D or 2D to 1D" 3540 3553 self.model_view.SetToolTipString(hint) 3541 3554 3542 cat_set_box = wx.StaticBox(self, -1, 'Category')3555 cat_set_box = wx.StaticBox(self, wx.ID_ANY, 'Category') 3543 3556 sizer_cat_box = wx.StaticBoxSizer(cat_set_box, wx.HORIZONTAL) 3544 3557 sizer_cat_box.SetMinSize((200, 50)) 3545 self.categorybox = wx.ComboBox(self, -1, style=wx.CB_READONLY) 3558 self.categorybox = wx.ComboBox(self, wx.ID_ANY, 3559 style=wx.CB_READONLY) 3546 3560 self.categorybox.SetToolTip(wx.ToolTip("Select a Category/Type")) 3547 3561 self._populate_listbox() 3548 wx.EVT_COMBOBOX(self.categorybox, -1, self._show_combox)3549 #self.shape_rbutton = wx.RadioButton(self, -1, 'Shapes',3562 wx.EVT_COMBOBOX(self.categorybox, wx.ID_ANY, self._show_combox) 3563 #self.shape_rbutton = wx.RadioButton(self, wx.ID_ANY, 'Shapes', 3550 3564 # style=wx.RB_GROUP) 3551 #self.shape_indep_rbutton = wx.RadioButton(self, -1,3565 #self.shape_indep_rbutton = wx.RadioButton(self, wx.ID_ANY, 3552 3566 # "Shape-Independent") 3553 #self.struct_rbutton = wx.RadioButton(self, -1, "Structure Factor ") 3554 #self.plugin_rbutton = wx.RadioButton(self, -1, "Uncategorized") 3567 #self.struct_rbutton = wx.RadioButton(self, wx.ID_ANY, 3568 # "Structure Factor ") 3569 #self.plugin_rbutton = wx.RadioButton(self, wx.ID_ANY, 3570 # "Uncategorized") 3555 3571 3556 3572 #self.Bind(wx.EVT_RADIOBUTTON, self._show_combox, … … 3564 3580 #MAC needs SetValue 3565 3581 3566 show_cat_button = wx.Button(self, -1, "Modify")3582 show_cat_button = wx.Button(self, wx.ID_ANY, "Modify") 3567 3583 cat_tip = "Modify model categories \n" 3568 3584 cat_tip += "(also accessible from the menu bar)." … … 3590 3606 mutifactor_selection = wx.BoxSizer(wx.HORIZONTAL) 3591 3607 3592 self.text1 = wx.StaticText(self, -1, "")3593 self.text2 = wx.StaticText(self, -1, "P(Q)*S(Q)")3594 self.mutifactor_text = wx.StaticText(self, -1, "No. of Shells: ")3595 self.mutifactor_text1 = wx.StaticText(self, -1, "")3596 self.show_sld_button = wx.Button(self, -1, "Show SLD Profile")3608 self.text1 = wx.StaticText(self, wx.ID_ANY, "") 3609 self.text2 = wx.StaticText(self, wx.ID_ANY, "P(Q)*S(Q)") 3610 self.mutifactor_text = wx.StaticText(self, wx.ID_ANY, "No. of Shells: ") 3611 self.mutifactor_text1 = wx.StaticText(self, wx.ID_ANY, "") 3612 self.show_sld_button = wx.Button(self, wx.ID_ANY, "Show SLD Profile") 3597 3613 self.show_sld_button.Bind(wx.EVT_BUTTON, self._on_show_sld) 3598 3614 3599 self.formfactorbox = wx.ComboBox(self, -1, style=wx.CB_READONLY)3615 self.formfactorbox = wx.ComboBox(self, wx.ID_ANY, style=wx.CB_READONLY) 3600 3616 self.formfactorbox.SetToolTip(wx.ToolTip("Select a Model")) 3601 3617 if self.model != None: 3602 3618 self.formfactorbox.SetValue(self.model.name) 3603 self.structurebox = wx.ComboBox(self, -1, style=wx.CB_READONLY)3604 self.multifactorbox = wx.ComboBox(self, -1, style=wx.CB_READONLY)3619 self.structurebox = wx.ComboBox(self, wx.ID_ANY, style=wx.CB_READONLY) 3620 self.multifactorbox = wx.ComboBox(self, wx.ID_ANY, style=wx.CB_READONLY) 3605 3621 self.initialize_combox() 3606 wx.EVT_COMBOBOX(self.formfactorbox, -1, self._on_select_model)3607 3608 wx.EVT_COMBOBOX(self.structurebox, -1, self._on_select_model)3609 wx.EVT_COMBOBOX(self.multifactorbox, -1, self._on_select_model)3622 wx.EVT_COMBOBOX(self.formfactorbox, wx.ID_ANY, self._on_select_model) 3623 3624 wx.EVT_COMBOBOX(self.structurebox, wx.ID_ANY, self._on_select_model) 3625 wx.EVT_COMBOBOX(self.multifactorbox, wx.ID_ANY, self._on_select_model) 3610 3626 ## check model type to show sizer 3611 3627 if self.model != None: -
src/sas/perspectives/fitting/batchfitpage.py
r373d4ee r6f16e25 38 38 fill sizer 0 with data info 39 39 """ 40 self.data_box_description = wx.StaticBox(self, -1, 'I(q) Data Source')40 self.data_box_description = wx.StaticBox(self, wx.ID_ANY, 'I(q) Data Source') 41 41 if check_data_validity(self.data): 42 42 dname_color = wx.BLUE … … 47 47 #---------------------------------------------------------- 48 48 sizer_data = wx.BoxSizer(wx.VERTICAL) 49 text1 = wx.StaticText(self, -1, ' - Choose a file to set initial fit parameters -')49 text1 = wx.StaticText(self, wx.ID_ANY, ' - Choose a file to set initial fit parameters -') 50 50 text1.SetForegroundColour(wx.RED) 51 51 sizer_data.Add(text1) 52 text2 = wx.StaticText(self, -1, ' - This panel is not designed to view individual fits. - ')52 text2 = wx.StaticText(self, wx.ID_ANY, ' - This panel is not designed to view individual fits. - ') 53 53 text2.SetForegroundColour(wx.RED) 54 54 sizer_data.Add(text2) 55 55 56 56 combo = wx.BoxSizer(wx.HORIZONTAL) 57 self.dataSource = wx.ComboBox(self, -1, style=wx.CB_READONLY)58 wx.EVT_COMBOBOX(self.dataSource, -1, self.on_select_data)57 self.dataSource = wx.ComboBox(self, wx.ID_ANY, style=wx.CB_READONLY) 58 wx.EVT_COMBOBOX(self.dataSource, wx.ID_ANY, self.on_select_data) 59 59 self.dataSource.SetMinSize((_DATA_BOX_WIDTH, -1)) 60 60 61 combo.Add(wx.StaticText(self, -1, 'Name : '))61 combo.Add(wx.StaticText(self, wx.ID_ANY, 'Name : ')) 62 62 combo.Add((0, 5)) 63 63 combo.Add(self.dataSource) … … 86 86 # 87 87 # #Sizers 88 # box_description_range = wx.StaticBox(self, -1, str(title))88 # box_description_range = wx.StaticBox(self, wx.ID_ANY, str(title)) 89 89 # boxsizer_range = wx.StaticBoxSizer(box_description_range, wx.VERTICAL) 90 90 # self.sizer_set_smearer = wx.BoxSizer(wx.VERTICAL) … … 96 96 # sizer_fit = wx.GridSizer(2, 4, 2, 6) 97 97 # #Fit button 98 # self.btFit = wx.Button(self, wx.NewId(), 'Fit', size=(88, 25))98 # self.btFit = wx.Button(self, self._ids.next(), 'Fit', size=(88, 25)) 99 99 # self.default_bt_colour = self.btFit.GetDefaultAttributes() 100 100 # self.btFit.Bind(wx.EVT_BUTTON, self._onFit, id= self.btFit.GetId()) … … 102 102 # 103 103 # # Update and Draw button 104 # self.draw_button = wx.Button(self, wx.NewId(), 'Compute', size=(88, 24))104 # self.draw_button = wx.Button(self, self._ids.next(), 'Compute', size=(88, 24)) 105 105 # self.draw_button.Bind(wx.EVT_BUTTON, \ 106 106 # self._onDraw,id=self.draw_button.GetId()) … … 122 122 # self.sizer5.Clear(True) 123 123 # 124 # self.qmin = ModelTextCtrl(self, -1, size=(_BOX_WIDTH, 20),124 # self.qmin = ModelTextCtrl(self, wx.ID_ANY, size=(_BOX_WIDTH, 20), 125 125 # style=wx.TE_PROCESS_ENTER, 126 126 # text_enter_callback = self._onQrangeEnter) … … 128 128 # self.qmin.SetToolTipString("Minimun value of Q in linear scale.") 129 129 # 130 # self.qmax = ModelTextCtrl(self, -1, size=(_BOX_WIDTH, 20),130 # self.qmax = ModelTextCtrl(self, wx.ID_ANY, size=(_BOX_WIDTH, 20), 131 131 # style=wx.TE_PROCESS_ENTER, 132 132 # text_enter_callback=self._onQrangeEnter) … … 134 134 # self.qmax.SetToolTipString("Maximum value of Q in linear scale.") 135 135 # 136 # id = wx.NewId()136 # id = self._ids.next() 137 137 # self.reset_qrange =wx.Button(self, id, 'Reset', size=(77, 20)) 138 138 # … … 144 144 # sizer = wx.GridSizer(2, 4, 2, 6) 145 145 # 146 # self.btEditMask = wx.Button(self, wx.NewId(),'Editor', size=(88, 23))146 # self.btEditMask = wx.Button(self, self._ids.next(),'Editor', size=(88, 23)) 147 147 # self.btEditMask.Bind(wx.EVT_BUTTON, 148 148 # self._onMask,id=self.btEditMask.GetId()) 149 149 # self.btEditMask.SetToolTipString("Edit Mask.") 150 # self.EditMask_title = wx.StaticText(self, -1, ' Masking(2D)')151 # 152 # sizer.Add(wx.StaticText(self, -1, 'Q range'))153 # sizer.Add(wx.StaticText(self, -1, ' Min[1/A]'))154 # sizer.Add(wx.StaticText(self, -1, ' Max[1/A]'))150 # self.EditMask_title = wx.StaticText(self, wx.ID_ANY, ' Masking(2D)') 151 # 152 # sizer.Add(wx.StaticText(self, wx.ID_ANY, 'Q range')) 153 # sizer.Add(wx.StaticText(self, wx.ID_ANY, ' Min[1/A]')) 154 # sizer.Add(wx.StaticText(self, wx.ID_ANY, ' Max[1/A]')) 155 155 # sizer.Add(self.EditMask_title) 156 156 # -
src/sas/perspectives/fitting/fitpage.py
r098f3d2 r6f16e25 93 93 fill sizer 0 with data info 94 94 """ 95 self.data_box_description = wx.StaticBox(self, -1, 'I(q) Data Source') 95 self.data_box_description = wx.StaticBox(self, wx.ID_ANY, 96 'I(q) Data Source') 96 97 if check_data_validity(self.data): 97 98 dname_color = wx.BLUE … … 102 103 #---------------------------------------------------------- 103 104 sizer_data = wx.BoxSizer(wx.HORIZONTAL) 104 self.dataSource = wx.ComboBox(self, -1, style=wx.CB_READONLY)105 wx.EVT_COMBOBOX(self.dataSource, -1, self.on_select_data)105 self.dataSource = wx.ComboBox(self, wx.ID_ANY, style=wx.CB_READONLY) 106 wx.EVT_COMBOBOX(self.dataSource, wx.ID_ANY, self.on_select_data) 106 107 self.dataSource.SetMinSize((_DATA_BOX_WIDTH, -1)) 107 sizer_data.Add(wx.StaticText(self, -1, 'Name : '))108 sizer_data.Add(wx.StaticText(self, wx.ID_ANY, 'Name : ')) 108 109 sizer_data.Add(self.dataSource) 109 110 sizer_data.Add((0, 5)) … … 221 222 222 223 #Sizers 223 box_description_range = wx.StaticBox(self, -1, str(title))224 box_description_range = wx.StaticBox(self, wx.ID_ANY, str(title)) 224 225 box_description_range.SetForegroundColour(wx.BLUE) 225 226 boxsizer_range = wx.StaticBoxSizer(box_description_range, wx.VERTICAL) … … 229 230 self.sizer_set_masking = wx.BoxSizer(wx.HORIZONTAL) 230 231 sizer_chi2 = wx.BoxSizer(wx.VERTICAL) 231 smear_set_box = wx.StaticBox(self, -1, 'Set Instrumental Smearing') 232 smear_set_box = wx.StaticBox(self, wx.ID_ANY, 233 'Set Instrumental Smearing') 232 234 sizer_smearer_box = wx.StaticBoxSizer(smear_set_box, wx.HORIZONTAL) 233 235 sizer_smearer_box.SetMinSize((_DATA_BOX_WIDTH, 60)) 234 236 235 weighting_set_box = wx.StaticBox(self, -1, \237 weighting_set_box = wx.StaticBox(self, wx.ID_ANY, 236 238 'Set Weighting by Selecting dI Source') 237 239 weighting_box = wx.StaticBoxSizer(weighting_set_box, wx.HORIZONTAL) … … 239 241 weighting_box.SetMinSize((_DATA_BOX_WIDTH, 40)) 240 242 #Filling the sizer containing weighting info. 241 self.dI_noweight = wx.RadioButton(self, -1, 'No Weighting',242 style=wx.RB_GROUP)243 self.dI_didata = wx.RadioButton(self, -1, 'Use dI Data')244 self.dI_sqrdata = wx.RadioButton(self, -1, 'Use |sqrt(I Data)|')245 self.dI_idata = wx.RadioButton(self, -1, 'Use |I Data|')243 self.dI_noweight = wx.RadioButton(self, wx.ID_ANY, 244 'No Weighting', style=wx.RB_GROUP) 245 self.dI_didata = wx.RadioButton(self, wx.ID_ANY, 'Use dI Data') 246 self.dI_sqrdata = wx.RadioButton(self, wx.ID_ANY, 'Use |sqrt(I Data)|') 247 self.dI_idata = wx.RadioButton(self, wx.ID_ANY, 'Use |I Data|') 246 248 self.Bind(wx.EVT_RADIOBUTTON, self.onWeighting, 247 249 id=self.dI_noweight.GetId()) … … 269 271 270 272 # combobox for smear2d accuracy selection 271 self.smear_accuracy = wx.ComboBox(self, -1, size=(50, -1),272 s tyle=wx.CB_READONLY)273 self.smear_accuracy = wx.ComboBox(self, wx.ID_ANY, 274 size=(50, -1), style=wx.CB_READONLY) 273 275 self._set_accuracy_list() 274 276 self.smear_accuracy.SetValue(self.smear2d_accuracy) 275 277 self.smear_accuracy.SetSelection(0) 276 self.smear_accuracy.SetToolTipString( \278 self.smear_accuracy.SetToolTipString( 277 279 "'Higher' uses more Gaussian points for smearing computation.") 278 280 279 wx.EVT_COMBOBOX(self.smear_accuracy, -1, self._on_select_accuracy) 281 wx.EVT_COMBOBOX(self.smear_accuracy, wx.ID_ANY, 282 self._on_select_accuracy) 280 283 281 284 #Fit button 282 self.btFit = wx.Button(self, wx.NewId(), 'Fit')285 self.btFit = wx.Button(self, self._ids.next(), 'Fit') 283 286 self.default_bt_colour = self.btFit.GetDefaultAttributes() 284 287 self.btFit.Bind(wx.EVT_BUTTON, self._onFit, id=self.btFit.GetId()) … … 286 289 287 290 #General Help button 288 self.btFitHelp = wx.Button(self, -1, 'Help')291 self.btFitHelp = wx.Button(self, wx.ID_ANY, 'Help') 289 292 self.btFitHelp.SetToolTipString("General fitting help.") 290 293 self.btFitHelp.Bind(wx.EVT_BUTTON, self._onFitHelp) … … 299 302 else: 300 303 size_q = (30, 20) #on MAC 301 self.btSmearHelp = wx.Button(self, -1, '?', style=wx.BU_EXACTFIT,\302 s ize=size_q)304 self.btSmearHelp = wx.Button(self, wx.ID_ANY, '?', 305 style=wx.BU_EXACTFIT, size=size_q) 303 306 self.btSmearHelp.SetToolTipString("Resolution smearing help.") 304 307 self.btSmearHelp.Bind(wx.EVT_BUTTON, self._onSmearHelp) 305 308 306 309 #textcntrl for custom resolution 307 self.smear_pinhole_max = ModelTextCtrl(self, -1,310 self.smear_pinhole_max = ModelTextCtrl(self, wx.ID_ANY, 308 311 size=(_BOX_WIDTH - 25, 20), 309 312 style=wx.TE_PROCESS_ENTER, 310 313 text_enter_callback=self.onPinholeSmear) 311 self.smear_pinhole_min = ModelTextCtrl(self, -1,314 self.smear_pinhole_min = ModelTextCtrl(self, wx.ID_ANY, 312 315 size=(_BOX_WIDTH - 25, 20), 313 316 style=wx.TE_PROCESS_ENTER, 314 317 text_enter_callback=self.onPinholeSmear) 315 self.smear_slit_height = ModelTextCtrl(self, -1,318 self.smear_slit_height = ModelTextCtrl(self, wx.ID_ANY, 316 319 size=(_BOX_WIDTH - 25, 20), 317 320 style=wx.TE_PROCESS_ENTER, 318 321 text_enter_callback=self.onSlitSmear) 319 self.smear_slit_width = ModelTextCtrl(self, -1,322 self.smear_slit_width = ModelTextCtrl(self, wx.ID_ANY, 320 323 size=(_BOX_WIDTH - 25, 20), 321 324 style=wx.TE_PROCESS_ENTER, … … 323 326 324 327 ## smear 325 self.smear_data_left = BGTextCtrl(self, -1,328 self.smear_data_left = BGTextCtrl(self, wx.ID_ANY, 326 329 size=(_BOX_WIDTH - 25, 20), style=0) 327 330 self.smear_data_left.SetValue(str(self.dq_l)) 328 self.smear_data_right = BGTextCtrl(self, -1,331 self.smear_data_right = BGTextCtrl(self, wx.ID_ANY, 329 332 size=(_BOX_WIDTH - 25, 20), style=0) 330 333 self.smear_data_right.SetValue(str(self.dq_r)) … … 337 340 338 341 #Filling the sizer containing instruments smearing info. 339 self.disable_smearer = wx.RadioButton(self, -1,342 self.disable_smearer = wx.RadioButton(self, wx.ID_ANY, 340 343 'None', style=wx.RB_GROUP) 341 self.enable_smearer = wx.RadioButton(self, -1, 342 'Use dQ Data') 344 self.enable_smearer = wx.RadioButton(self, wx.ID_ANY, 'Use dQ Data') 343 345 #self.enable_smearer.SetToolTipString( 344 346 #"Click to use the loaded dQ data for smearing.") 345 self.pinhole_smearer = wx.RadioButton(self, -1,347 self.pinhole_smearer = wx.RadioButton(self, wx.ID_ANY, 346 348 'Custom Pinhole Smear') 347 349 #self.pinhole_smearer.SetToolTipString 348 350 #("Click to input custom resolution for pinhole smearing.") 349 self.slit_smearer = wx.RadioButton(self, -1, 'Custom Slit Smear')351 self.slit_smearer = wx.RadioButton(self, wx.ID_ANY, 'Custom Slit Smear') 350 352 #self.slit_smearer.SetToolTipString 351 353 #("Click to input custom resolution for slit smearing.") … … 368 370 369 371 # StaticText for chi2, N(for fitting), Npts + Log/linear spacing 370 self.tcChi = BGTextCtrl(self, -1, "-", size=(75, 20), style=0)372 self.tcChi = BGTextCtrl(self, wx.ID_ANY, "-", size=(75, 20), style=0) 371 373 self.tcChi.SetToolTipString("Chi2/Npts(Fit)") 372 self.Npts_fit = BGTextCtrl(self, -1, "-", size=(75, 20), style=0)373 self.Npts_fit.SetToolTipString( \374 self.Npts_fit = BGTextCtrl(self, wx.ID_ANY, "-", size=(75, 20), style=0) 375 self.Npts_fit.SetToolTipString( 374 376 " Npts : number of points selected for fitting") 375 self.Npts_total = ModelTextCtrl(self, -1, 376 size=(_BOX_WIDTH, 20), 377 self.Npts_total = ModelTextCtrl(self, wx.ID_ANY, size=(_BOX_WIDTH, 20), 377 378 style=wx.TE_PROCESS_ENTER, 378 379 text_enter_callback=self._onQrangeEnter) … … 382 383 383 384 # Update and Draw button 384 self.draw_button = wx.Button(self, wx.NewId(), 'Compute')385 self.draw_button.Bind(wx.EVT_BUTTON, \385 self.draw_button = wx.Button(self, self._ids.next(), 'Compute') 386 self.draw_button.Bind(wx.EVT_BUTTON, 386 387 self._onDraw, id=self.draw_button.GetId()) 387 388 self.draw_button.SetToolTipString("Compute and Draw.") 388 389 389 390 self.points_sizer = wx.BoxSizer(wx.HORIZONTAL) 390 self.pointsbox = wx.CheckBox(self, -1, 'Log?', (10, 10))391 self.pointsbox = wx.CheckBox(self, wx.ID_ANY, 'Log?', (10, 10)) 391 392 self.pointsbox.SetValue(False) 392 393 self.pointsbox.SetToolTipString("Check mark to use log spaced points") 393 394 wx.EVT_CHECKBOX(self, self.pointsbox.GetId(), self.select_log) 394 395 395 self.points_sizer.Add(wx.StaticText(self, -1, 'Npts '))396 self.points_sizer.Add(wx.StaticText(self, wx.ID_ANY, 'Npts ')) 396 397 self.points_sizer.Add(self.pointsbox) 397 398 398 box_description_1 = wx.StaticText(self, -1, ' Chi2/Npts')399 box_description_2 = wx.StaticText(self, -1, 'Npts(Fit)')399 box_description_1 = wx.StaticText(self, wx.ID_ANY, ' Chi2/Npts') 400 box_description_2 = wx.StaticText(self, wx.ID_ANY, 'Npts(Fit)') 400 401 401 402 # StaticText for smear 402 self.smear_description_none = wx.StaticText(self, -1,403 self.smear_description_none = wx.StaticText(self, wx.ID_ANY, 403 404 smear_message_none, style=wx.ALIGN_LEFT) 404 self.smear_description_dqdata = wx.StaticText(self, 405 - 1,smear_message_dqdata, style=wx.ALIGN_LEFT)406 self.smear_description_type = wx.StaticText(self, 407 - 1,"Type:", style=wx.ALIGN_LEFT)408 self.smear_description_accuracy_type = wx.StaticText(self, -1,409 410 self.smear_description_smear_type = BGTextCtrl(self, -1,405 self.smear_description_dqdata = wx.StaticText(self, wx.ID_ANY, 406 smear_message_dqdata, style=wx.ALIGN_LEFT) 407 self.smear_description_type = wx.StaticText(self, wx.ID_ANY, 408 "Type:", style=wx.ALIGN_LEFT) 409 self.smear_description_accuracy_type = wx.StaticText(self, wx.ID_ANY, 410 "Accuracy:", style=wx.ALIGN_LEFT) 411 self.smear_description_smear_type = BGTextCtrl(self, wx.ID_ANY, 411 412 size=(57, 20), style=0) 412 413 self.smear_description_smear_type.SetValue(str(self.dq_l)) 413 414 self.SetBackgroundColour(self.GetParent().GetBackgroundColour()) 414 self.smear_description_2d = wx.StaticText(self, -1,415 self.smear_description_2d = wx.StaticText(self, wx.ID_ANY, 415 416 smear_message_2d, style=wx.ALIGN_LEFT) 416 self.smear_message_new_s = wx.StaticText(self, -1,417 self.smear_message_new_s = wx.StaticText(self, wx.ID_ANY, 417 418 smear_message_new_ssmear, style=wx.ALIGN_LEFT) 418 self.smear_message_new_p = wx.StaticText(self, -1,419 self.smear_message_new_p = wx.StaticText(self, wx.ID_ANY, 419 420 smear_message_new_psmear, style=wx.ALIGN_LEFT) 420 self.smear_description_2d_x = wx.StaticText(self, -1,421 self.smear_description_2d_x = wx.StaticText(self, wx.ID_ANY, 421 422 smear_message_2d_x_title, style=wx.ALIGN_LEFT) 422 self.smear_description_2d_x.SetToolTipString( \423 self.smear_description_2d_x.SetToolTipString( 423 424 " dQp(parallel) in q_r direction.") 424 self.smear_description_2d_y = wx.StaticText(self, -1,425 self.smear_description_2d_y = wx.StaticText(self, wx.ID_ANY, 425 426 smear_message_2d_y_title, style=wx.ALIGN_LEFT) 426 427 self.smear_description_2d_y.SetToolTipString(\ 427 428 " dQs(perpendicular) in q_phi direction.") 428 self.smear_description_pin_min = wx.StaticText(self, -1,429 self.smear_description_pin_min = wx.StaticText(self, wx.ID_ANY, 429 430 smear_message_pinhole_min_title, style=wx.ALIGN_LEFT) 430 self.smear_description_pin_max = wx.StaticText(self, -1,431 self.smear_description_pin_max = wx.StaticText(self, wx.ID_ANY, 431 432 smear_message_pinhole_max_title, style=wx.ALIGN_LEFT) 432 self.smear_description_slit_height = wx.StaticText(self, -1,433 self.smear_description_slit_height = wx.StaticText(self, wx.ID_ANY, 433 434 smear_message_slit_height_title, style=wx.ALIGN_LEFT) 434 self.smear_description_slit_width = wx.StaticText(self, -1,435 self.smear_description_slit_width = wx.StaticText(self, wx.ID_ANY, 435 436 smear_message_slit_width_title, style=wx.ALIGN_LEFT) 436 437 … … 519 520 self.sizer5.Clear(True) 520 521 521 self.qmin = ModelTextCtrl(self, -1, size=(_BOX_WIDTH, 20),522 self.qmin = ModelTextCtrl(self, wx.ID_ANY, size=(_BOX_WIDTH, 20), 522 523 style=wx.TE_PROCESS_ENTER, 523 524 set_focus_callback=self.qrang_set_focus, … … 530 531 self.qmin.SetToolTipString(qmin_tip) 531 532 532 self.qmax = ModelTextCtrl(self, -1, size=(_BOX_WIDTH, 20),533 self.qmax = ModelTextCtrl(self, wx.ID_ANY, size=(_BOX_WIDTH, 20), 533 534 style=wx.TE_PROCESS_ENTER, 534 535 set_focus_callback=self.qrang_set_focus, … … 545 546 self.qmin.Bind(wx.EVT_TEXT, self.on_qrange_text) 546 547 self.qmax.Bind(wx.EVT_TEXT, self.on_qrange_text) 547 wx_id = wx.NewId()548 wx_id = self._ids.next() 548 549 self.reset_qrange = wx.Button(self, wx_id, 'Reset') 549 550 … … 553 554 sizer = wx.GridSizer(5, 5, 2, 6) 554 555 555 self.btEditMask = wx.Button(self, wx.NewId(), 'Editor')556 self.btEditMask = wx.Button(self, self._ids.next(), 'Editor') 556 557 self.btEditMask.Bind(wx.EVT_BUTTON, self._onMask, 557 558 id=self.btEditMask.GetId()) 558 559 self.btEditMask.SetToolTipString("Edit Mask.") 559 self.EditMask_title = wx.StaticText(self, -1, ' Masking(2D)')560 561 sizer.Add(wx.StaticText(self, -1, ' Q range'))562 sizer.Add(wx.StaticText(self, -1, ' Min[1/A]'))563 sizer.Add(wx.StaticText(self, -1, ' Max[1/A]'))560 self.EditMask_title = wx.StaticText(self, wx.ID_ANY, ' Masking(2D)') 561 562 sizer.Add(wx.StaticText(self, wx.ID_ANY, ' Q range')) 563 sizer.Add(wx.StaticText(self, wx.ID_ANY, ' Min[1/A]')) 564 sizer.Add(wx.StaticText(self, wx.ID_ANY, ' Max[1/A]')) 564 565 sizer.Add(self.EditMask_title) 565 566 sizer.Add((-1,5)) … … 618 619 619 620 ## fill a sizer with the combobox to select dispersion type 620 model_disp = wx.StaticText(self, -1, 'Function')621 model_disp = wx.StaticText(self, wx.ID_ANY, 'Function') 621 622 CHECK_STATE = self.cb1.GetValue() 622 623 import sas.models.dispersion_models … … 625 626 ix = 0 626 627 iy = 0 627 disp = wx.StaticText(self, -1, ' ')628 disp = wx.StaticText(self, wx.ID_ANY, ' ') 628 629 self.sizer4_4.Add(disp, (iy, ix), (1, 1), 629 630 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 630 631 ix += 1 631 values = wx.StaticText(self, -1, 'PD[ratio]')632 values = wx.StaticText(self, wx.ID_ANY, 'PD[ratio]') 632 633 polytext = "Polydispersity (= STD/mean); " 633 634 polytext += "the standard deviation over the mean value." … … 641 642 else: 642 643 err_text = '' 643 self.text_disp_1 = wx.StaticText(self, -1, err_text)644 self.text_disp_1 = wx.StaticText(self, wx.ID_ANY, err_text) 644 645 self.sizer4_4.Add(self.text_disp_1, (iy, ix), (1, 1), \ 645 646 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 646 647 647 648 ix += 1 648 self.text_disp_min = wx.StaticText(self, -1, 'Min')649 self.text_disp_min = wx.StaticText(self, wx.ID_ANY, 'Min') 649 650 self.sizer4_4.Add(self.text_disp_min, (iy, ix), (1, 1), \ 650 651 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 651 652 652 653 ix += 1 653 self.text_disp_max = wx.StaticText(self, -1, 'Max')654 self.text_disp_max = wx.StaticText(self, wx.ID_ANY, 'Max') 654 655 self.sizer4_4.Add(self.text_disp_max, (iy, ix), (1, 1), 655 656 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 656 657 657 658 ix += 1 658 npts = wx.StaticText(self, -1, 'Npts')659 npts = wx.StaticText(self, wx.ID_ANY, 'Npts') 659 660 npts.SetToolTipString("Number of sampling points for the numerical\n\ 660 661 integration over the distribution function.") … … 662 663 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 663 664 ix += 1 664 nsigmas = wx.StaticText(self, -1, 'Nsigs')665 nsigmas = wx.StaticText(self, wx.ID_ANY, 'Nsigs') 665 666 nsigmas.SetToolTipString("Number of sigmas between which the range\n\ 666 667 of the distribution function will be used for weighting. \n\ … … 695 696 if p == "width": 696 697 ix = 0 697 cb = wx.CheckBox(self, -1, name0, (10, 10))698 cb = wx.CheckBox(self, wx.ID_ANY, name0, (10, 10)) 698 699 cb.SetValue(CHECK_STATE) 699 700 cb.SetToolTipString("Check mark to fit") … … 703 704 ix = 1 704 705 value = self.model.getParam(name1) 705 ctl1 = ModelTextCtrl(self, -1,706 ctl1 = ModelTextCtrl(self, wx.ID_ANY, 706 707 size=(_BOX_WIDTH / 1.3, 20), 707 708 style=wx.TE_PROCESS_ENTER) … … 715 716 ## text to show error sign 716 717 ix = 2 717 text2 = wx.StaticText(self, -1, '+/-')718 text2 = wx.StaticText(self, wx.ID_ANY, '+/-') 718 719 self.sizer4_4.Add(text2, (iy, ix), (1, 1), 719 720 wx.EXPAND | wx.ADJUST_MINSIZE, 0) … … 722 723 723 724 ix = 3 724 ctl2 = wx.TextCtrl(self, -1,725 ctl2 = wx.TextCtrl(self, wx.ID_ANY, 725 726 size=(_BOX_WIDTH / 1.3, 20), 726 727 style=0) … … 732 733 733 734 ix = 4 734 ctl3 = ModelTextCtrl(self, -1,735 ctl3 = ModelTextCtrl(self, wx.ID_ANY, 735 736 size=(_BOX_WIDTH / 2, 20), 736 737 style=wx.TE_PROCESS_ENTER, … … 741 742 742 743 ix = 5 743 ctl4 = ModelTextCtrl(self, -1,744 ctl4 = ModelTextCtrl(self, wx.ID_ANY, 744 745 size=(_BOX_WIDTH / 2, 20), 745 746 style=wx.TE_PROCESS_ENTER, … … 755 756 ix = 6 756 757 value = self.model.getParam(name2) 757 Tctl = ModelTextCtrl(self, -1,758 Tctl = ModelTextCtrl(self, wx.ID_ANY, 758 759 size=(_BOX_WIDTH / 2.2, 20), 759 760 style=wx.TE_PROCESS_ENTER) … … 767 768 ix = 7 768 769 value = self.model.getParam(name3) 769 Tct2 = ModelTextCtrl(self, -1,770 Tct2 = ModelTextCtrl(self, wx.ID_ANY, 770 771 size=(_BOX_WIDTH / 2.2, 20), 771 772 style=wx.TE_PROCESS_ENTER) … … 779 780 780 781 ix = 8 781 disp_box = wx.ComboBox(self, -1, size=(65, -1),782 disp_box = wx.ComboBox(self, wx.ID_ANY, size=(65, -1), 782 783 style=wx.CB_READONLY, name='%s' % name1) 783 784 for key, value in self.polydisp.iteritems(): … … 785 786 disp_box.Append(name_disp, value) 786 787 disp_box.SetStringSelection("gaussian") 787 wx.EVT_COMBOBOX(disp_box, -1, self._on_disp_func)788 wx.EVT_COMBOBOX(disp_box, wx.ID_ANY, self._on_disp_func) 788 789 self.sizer4_4.Add(disp_box, (iy, ix), (1, 1), wx.EXPAND) 789 790 self.fittable_param.append([cb, name1, ctl1, text2, … … 815 816 if p == "width": 816 817 ix = 0 817 cb = wx.CheckBox(self, -1, name0, (10, 10))818 cb = wx.CheckBox(self, wx.ID_ANY, name0, (10, 10)) 818 819 cb.SetValue(CHECK_STATE) 819 820 cb.SetToolTipString("Check mark to fit") … … 828 829 ix = 1 829 830 value = self.model.getParam(name1) 830 ctl1 = ModelTextCtrl(self, -1,831 ctl1 = ModelTextCtrl(self, wx.ID_ANY, 831 832 size=(_BOX_WIDTH / 1.3, 20), 832 833 style=wx.TE_PROCESS_ENTER) … … 854 855 ## text to show error sign 855 856 ix = 2 856 text2 = wx.StaticText(self, -1, '+/-')857 text2 = wx.StaticText(self, wx.ID_ANY, '+/-') 857 858 self.sizer4_4.Add(text2, (iy, ix), (1, 1), 858 859 wx.EXPAND | wx.ADJUST_MINSIZE, 0) … … 861 862 862 863 ix = 3 863 ctl2 = wx.TextCtrl(self, -1,864 ctl2 = wx.TextCtrl(self, wx.ID_ANY, 864 865 size=(_BOX_WIDTH / 1.3, 20), 865 866 style=0) … … 876 877 877 878 ix = 4 878 ctl3 = ModelTextCtrl(self, -1,879 ctl3 = ModelTextCtrl(self, wx.ID_ANY, 879 880 size=(_BOX_WIDTH / 2, 20), 880 881 style=wx.TE_PROCESS_ENTER, … … 887 888 888 889 ix = 5 889 ctl4 = ModelTextCtrl(self, -1,890 ctl4 = ModelTextCtrl(self, wx.ID_ANY, 890 891 size=(_BOX_WIDTH / 2, 20), 891 892 style=wx.TE_PROCESS_ENTER, … … 903 904 ix = 6 904 905 value = self.model.getParam(name2) 905 Tctl = ModelTextCtrl(self, -1,906 Tctl = ModelTextCtrl(self, wx.ID_ANY, 906 907 size=(_BOX_WIDTH / 2.2, 20), 907 908 style=wx.TE_PROCESS_ENTER) … … 923 924 ix = 7 924 925 value = self.model.getParam(name3) 925 Tct2 = ModelTextCtrl(self, -1,926 Tct2 = ModelTextCtrl(self, wx.ID_ANY, 926 927 size=(_BOX_WIDTH / 2.2, 20), 927 928 style=wx.TE_PROCESS_ENTER) … … 943 944 944 945 ix = 8 945 disp_box = wx.ComboBox(self, -1, size=(65, -1),946 disp_box = wx.ComboBox(self, wx.ID_ANY, size=(65, -1), 946 947 style=wx.CB_READONLY, name='%s' % name1) 947 948 for key, value in self.polydisp.iteritems(): … … 949 950 disp_box.Append(name_disp, value) 950 951 disp_box.SetStringSelection("gaussian") 951 wx.EVT_COMBOBOX(disp_box, -1, self._on_disp_func)952 wx.EVT_COMBOBOX(disp_box, wx.ID_ANY, self._on_disp_func) 952 953 self.sizer4_4.Add(disp_box, (iy, ix), (1, 1), wx.EXPAND) 953 954 self.fittable_param.append([cb, name1, ctl1, text2, … … 1079 1080 1080 1081 _TreeLocation = "user/perspectives/fitting/fitting_help.html" 1081 _doc_viewer = DocumentationWindow(self, -1, _TreeLocation, "",1082 _doc_viewer = DocumentationWindow(self, wx.ID_ANY, _TreeLocation, "", 1082 1083 "General Fitting Help") 1083 1084 … … 1098 1099 1099 1100 _TreeLocation = "user/perspectives/fitting/sm_help.html" 1100 _doc_viewer = DocumentationWindow(self, -1, _TreeLocation, "",1101 _doc_viewer = DocumentationWindow(self, wx.ID_ANY, _TreeLocation, "", 1101 1102 "Instrumental Resolution Smearing \ 1102 1103 Help") … … 1182 1183 self._keep.Enable(False) 1183 1184 self._set_save_flag(False) 1185 # TODO: why do we have to variables for one flag?? 1184 1186 self.enable_disp.SetValue(False) 1185 1187 self.disable_disp.SetValue(True) 1188 # TODO: should not have an untrapped exception when displaying disperser 1189 # TODO: do we need to create the disperser panel on every model change? 1190 # Note: if we fix this, then remove ID_DISPERSER_HELP from basepage 1186 1191 try: 1187 1192 self.set_dispers_sizer() … … 2831 2836 return 2832 2837 2833 box_description = wx.StaticBox(self, -1, str("Model Parameters"))2838 box_description = wx.StaticBox(self, wx.ID_ANY, str("Model Parameters")) 2834 2839 boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) 2835 2840 sizer = wx.GridBagSizer(5, 5) … … 2898 2903 ix = 0 2899 2904 select_text = "Select All" 2900 self.cb1 = wx.CheckBox(self, -1, str(select_text), (10, 10))2905 self.cb1 = wx.CheckBox(self, wx.ID_ANY, str(select_text), (10, 10)) 2901 2906 wx.EVT_CHECKBOX(self, self.cb1.GetId(), self.select_all_param) 2902 2907 self.cb1.SetToolTipString("To check/uncheck all the boxes below.") … … 2906 2911 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 5) 2907 2912 ix += 1 2908 self.text2_2 = wx.StaticText(self, -1, 'Value')2913 self.text2_2 = wx.StaticText(self, wx.ID_ANY, 'Value') 2909 2914 sizer.Add(self.text2_2, (iy, ix), (1, 1), \ 2910 2915 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 2911 2916 ix += 2 2912 self.text2_3 = wx.StaticText(self, -1, 'Error')2917 self.text2_3 = wx.StaticText(self, wx.ID_ANY, 'Error') 2913 2918 sizer.Add(self.text2_3, (iy, ix), (1, 1), \ 2914 2919 wx.EXPAND | wx.ADJUST_MINSIZE, 0) … … 2916 2921 self.text2_3.Hide() 2917 2922 ix += 1 2918 self.text2_min = wx.StaticText(self, -1, 'Min')2923 self.text2_min = wx.StaticText(self, wx.ID_ANY, 'Min') 2919 2924 sizer.Add(self.text2_min, (iy, ix), (1, 1), \ 2920 2925 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 2921 2926 #self.text2_min.Hide() 2922 2927 ix += 1 2923 self.text2_max = wx.StaticText(self, -1, 'Max')2928 self.text2_max = wx.StaticText(self, wx.ID_ANY, 'Max') 2924 2929 sizer.Add(self.text2_max, (iy, ix), (1, 1), \ 2925 2930 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 2926 2931 #self.text2_max.Hide() 2927 2932 ix += 1 2928 self.text2_4 = wx.StaticText(self, -1, '[Units]')2933 self.text2_4 = wx.StaticText(self, wx.ID_ANY, '[Units]') 2929 2934 sizer.Add(self.text2_4, (iy, ix), (1, 1), \ 2930 2935 wx.EXPAND | wx.ADJUST_MINSIZE, 0) … … 2947 2952 self.temp_multi_functional)\ 2948 2953 and (item in self.model.non_fittable): 2949 non_fittable_name = wx.StaticText(self, -1, item)2954 non_fittable_name = wx.StaticText(self, wx.ID_ANY, item) 2950 2955 sizer.Add(non_fittable_name, (iy, ix), (1, 1), \ 2951 2956 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 21) … … 2955 2960 if len(self.model.fun_list) > 0: 2956 2961 #num = item.split('_')[1][5:7] 2957 fun_box = wx.ComboBox(self, -1, size=(100, -1),2962 fun_box = wx.ComboBox(self, wx.ID_ANY, size=(100, -1), 2958 2963 style=wx.CB_READONLY, name='%s' % item) 2959 2964 self._set_fun_box_list(fun_box) … … 2961 2966 #self.fun_box.SetToolTipString("A function 2962 2967 # describing the interface") 2963 wx.EVT_COMBOBOX(fun_box, -1, self._on_fun_box)2968 wx.EVT_COMBOBOX(fun_box, wx.ID_ANY, self._on_fun_box) 2964 2969 else: 2965 fun_box = ModelTextCtrl(self, -1,2970 fun_box = ModelTextCtrl(self, wx.ID_ANY, 2966 2971 size=(_BOX_WIDTH, 20), 2967 2972 style=wx.TE_PROCESS_ENTER, name='%s' % item) … … 2975 2980 else: 2976 2981 ## add parameters name with checkbox for selecting to fit 2977 cb = wx.CheckBox(self, -1, item)2982 cb = wx.CheckBox(self, wx.ID_ANY, item) 2978 2983 cb.SetValue(CHECK_STATE) 2979 2984 cb.SetToolTipString(" Check mark to fit.") … … 2987 2992 ix += 1 2988 2993 value = self.model.getParam(item) 2989 ctl1 = ModelTextCtrl(self, -1, size=(_BOX_WIDTH, 20),2994 ctl1 = ModelTextCtrl(self, wx.ID_ANY, size=(_BOX_WIDTH, 20), 2990 2995 style=wx.TE_PROCESS_ENTER) 2991 2996 ctl1.SetToolTipString(\ … … 2995 3000 ## text to show error sign 2996 3001 ix += 1 2997 text2 = wx.StaticText(self, -1, '+/-')3002 text2 = wx.StaticText(self, wx.ID_ANY, '+/-') 2998 3003 sizer.Add(text2, (iy, ix), (1, 1), \ 2999 3004 wx.EXPAND | wx.ADJUST_MINSIZE, 0) … … 3001 3006 text2.Hide() 3002 3007 ix += 1 3003 ctl2 = wx.TextCtrl(self, -1,3008 ctl2 = wx.TextCtrl(self, wx.ID_ANY, 3004 3009 size=(_BOX_WIDTH / 1.2, 20), style=0) 3005 3010 sizer.Add(ctl2, (iy, ix), (1, 1), … … 3009 3014 3010 3015 ix += 1 3011 ctl3 = ModelTextCtrl(self, -1,3016 ctl3 = ModelTextCtrl(self, wx.ID_ANY, 3012 3017 size=(_BOX_WIDTH / 1.9, 20), 3013 3018 style=wx.TE_PROCESS_ENTER, … … 3021 3026 3022 3027 ix += 1 3023 ctl4 = ModelTextCtrl(self, -1,3028 ctl4 = ModelTextCtrl(self, wx.ID_ANY, 3024 3029 size=(_BOX_WIDTH / 1.9, 20), 3025 3030 style=wx.TE_PROCESS_ENTER, … … 3034 3039 # Units 3035 3040 if item in self.model.details: 3036 units = wx.StaticText(self, -1,3041 units = wx.StaticText(self, wx.ID_ANY, 3037 3042 self.model.details[item][0], style=wx.ALIGN_LEFT) 3038 3043 else: 3039 units = wx.StaticText(self, -1, "",3044 units = wx.StaticText(self, wx.ID_ANY, "", 3040 3045 style=wx.ALIGN_LEFT) 3041 3046 sizer.Add(units, (iy, ix), (1, 1), … … 3060 3065 for item in keys: 3061 3066 if item in self.model.orientation_params: 3062 orient_angle = wx.StaticText(self, -1, '[For 2D only]:')3063 mag_on_button = wx.Button(self, -1, "Magnetic ON")3067 orient_angle = wx.StaticText(self, wx.ID_ANY, '[For 2D only]:') 3068 mag_on_button = wx.Button(self, wx.ID_ANY, "Magnetic ON") 3064 3069 mag_on_button.SetToolTipString("Turn Pol Beam/Mag scatt on/off") 3065 3070 mag_on_button.Bind(wx.EVT_BUTTON, self._on_mag_on) 3066 mag_angle_help_button = wx.Button(self, -1, "Magnetic angles?")3071 mag_angle_help_button = wx.Button(self, wx.ID_ANY, "Magnetic angles?") 3067 3072 mag_angle_help_button.SetToolTipString("see angle definitions") 3068 mag_help_button = wx.Button(self, -1, "Mag HELP")3073 mag_help_button = wx.Button(self, wx.ID_ANY, "Mag HELP") 3069 3074 mag_help_button.SetToolTipString("Help on pol beam/mag fitting") 3070 3075 mag_help_button.Bind(wx.EVT_BUTTON, self._on_mag_help) … … 3124 3129 ix = 0 3125 3130 ## add parameters name with checkbox for selecting to fit 3126 cb = wx.CheckBox(self, -1, item)3131 cb = wx.CheckBox(self, wx.ID_ANY, item) 3127 3132 cb.SetValue(CHECK_STATE) 3128 3133 cb.SetToolTipString("Check mark to fit") -
src/sas/perspectives/fitting/fitpanel.py
rac7be54 r6f16e25 36 36 """ 37 37 """ 38 nb.__init__(self, parent, -1,38 nb.__init__(self, parent, wx.ID_ANY, 39 39 style=wx.aui.AUI_NB_WINDOWLIST_BUTTON | 40 40 wx.aui.AUI_NB_DEFAULT_STYLE | … … 324 324 if caption == "Const & Simul Fit": 325 325 self.sim_page = SimultaneousFitPage(self, page_finder=page_finder, 326 id= -1, batch_on=False)326 id= wx.ID_ANY, batch_on=False) 327 327 self.sim_page.window_caption = caption 328 328 self.sim_page.window_name = caption -
src/sas/perspectives/fitting/fitting.py
r7945367 r6f16e25 277 277 model_list = model_manager.get_model_name_list() 278 278 plug_dir = models.find_plugins_dir() 279 textdial = TextDialog(None, self, -1, 'Easy Sum/Multi(p1, p2) Editor',279 textdial = TextDialog(None, self, wx.ID_ANY, 'Easy Sum/Multi(p1, p2) Editor', 280 280 model_list, plug_dir) 281 281 self.put_icon(textdial) … … 760 760 _TreeLocation = "user/perspectives/fitting/optimizer.html" 761 761 _anchor = "#fit-"+algorithm_id 762 DocumentationWindow(self.parent, -1, _TreeLocation, _anchor, "Optimizer Help")762 DocumentationWindow(self.parent, wx.ID_ANY, _TreeLocation, _anchor, "Optimizer Help") 763 763 764 764 -
src/sas/perspectives/fitting/fitting_widgets.py
r2f4b430 r6f16e25 41 41 """ 42 42 vbox = wx.BoxSizer(wx.VERTICAL) 43 box_description = wx.StaticBox(self, -1, str("Hint"))43 box_description = wx.StaticBox(self, wx.ID_ANY, str("Hint")) 44 44 hint_sizer = wx.StaticBoxSizer(box_description, wx.VERTICAL) 45 45 selection_sizer = wx.GridBagSizer(5, 5) 46 46 button_sizer = wx.BoxSizer(wx.HORIZONTAL) 47 self.data_1d_selected = wx.RadioButton(self, -1, 'Data1D',47 self.data_1d_selected = wx.RadioButton(self, wx.ID_ANY, 'Data1D', 48 48 style=wx.RB_GROUP) 49 self.data_2d_selected = wx.RadioButton(self, -1, 'Data2D')49 self.data_2d_selected = wx.RadioButton(self, wx.ID_ANY, 'Data2D') 50 50 self.data_1d_selected.SetValue(True) 51 51 self.data_2d_selected.SetValue(False) … … 55 55 hint = "Selected Data set contains both 1D and 2D Data.\n" 56 56 hint += "Please select on type of analysis before proceeding.\n" 57 hint_sizer.Add(wx.StaticText(self, -1, hint))57 hint_sizer.Add(wx.StaticText(self, wx.ID_ANY, hint)) 58 58 #draw area containing radio buttons 59 59 ix = 0 … … 72 72 vbox.Add(hint_sizer, 0, wx.EXPAND | wx.ALL, 10) 73 73 vbox.Add(selection_sizer, 0, wx.TOP | wx.BOTTOM, 10) 74 vbox.Add(wx.StaticLine(self, -1), 0, wx.EXPAND, 0)74 vbox.Add(wx.StaticLine(self, wx.ID_ANY), 0, wx.EXPAND, 0) 75 75 vbox.Add(button_sizer, 0, wx.TOP | wx.BOTTOM, 10) 76 76 self.SetSizer(vbox) … … 103 103 return 104 104 select_data_text = " %s Data selected.\n" % str(self._nb_selected_data) 105 self._data_text_ctrl = wx.StaticText(self, -1, str(select_data_text))105 self._data_text_ctrl = wx.StaticText(self, wx.ID_ANY, str(select_data_text)) 106 106 107 107 self._data_text_ctrl.SetForegroundColour('blue') … … 126 126 text += "for adequate plot display size. \n" 127 127 text += "unchecked data won't be send to fitting . \n" 128 text_ctrl = wx.StaticText(self, -1, str(text))128 text_ctrl = wx.StaticText(self, wx.ID_ANY, str(text)) 129 129 self._sizer_txt.Add(text_ctrl) 130 130 iy = 0 … … 133 133 for i in range(len(data_list)): 134 134 data_count += 1 135 cb = wx.CheckBox(self._panel, -1, str(data_list[i].name), (10, 10))135 cb = wx.CheckBox(self._panel, wx.ID_ANY, str(data_list[i].name), (10, 10)) 136 136 wx.EVT_CHECKBOX(self, cb.GetId(), self._count_selected_data) 137 137 if data_count <= MAX_NBR_DATA: … … 153 153 self._sizer_button.Add(button_OK, 0, 154 154 wx.LEFT | wx.RIGHT | wx.ADJUST_MINSIZE, 10) 155 static_line = wx.StaticLine(self, -1)155 static_line = wx.StaticLine(self, wx.ID_ANY) 156 156 self._sizer_txt.Add(self._panel, 0, wx.EXPAND | wx.ALL, 10) 157 157 self._sizer_main.Add(self._sizer_txt, 0, wx.EXPAND | wx.ALL, 10) -
src/sas/perspectives/fitting/hint_fitpage.py
r2f4b430 r6f16e25 27 27 """ 28 28 name = "Hint" 29 box_description = wx.StaticBox(self, -1, name)29 box_description = wx.StaticBox(self, wx.ID_ANY, name) 30 30 boxsizer = wx.StaticBoxSizer(box_description, wx.VERTICAL) 31 31 msg = " How to link data to the control panel: \n \n" … … 33 33 msg += " Then Highlight and right click on the data plot. \n" 34 34 msg += " Finally, select 'Select data for fitting' in the pop-up menu. \n" 35 self.hint_txt = wx.StaticText(self, -1, msg, style=wx.ALIGN_LEFT)35 self.hint_txt = wx.StaticText(self, wx.ID_ANY, msg, style=wx.ALIGN_LEFT) 36 36 boxsizer.Add(self.hint_txt, wx.ALL | wx.EXPAND, 20) 37 37 self.vbox = wx.BoxSizer(wx.VERTICAL) -
src/sas/perspectives/fitting/pagestate.py
r0e33a8d r6f16e25 605 605 images = self.set_plot_state(figs, canvases) 606 606 report_list = [report_str, text_str, images] 607 dialog = ReportDialog(report_list, None, -1, "")607 dialog = ReportDialog(report_list, None, wx.ID_ANY, "") 608 608 dialog.Show() 609 609 -
src/sas/perspectives/fitting/resultpanel.py
r9df6a03 r6f16e25 41 41 | wx.CLIP_CHILDREN) 42 42 & ~wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB) 43 Notebook.__init__(self, parent, -1, style=style)43 Notebook.__init__(self, parent, wx.ID_ANY, style=style) 44 44 PanelBase.__init__(self, parent) 45 45 self.frame = parent -
src/sas/perspectives/fitting/simfitpage.py
racf8e4a5 r662d8d87 2 2 Simultaneous fit page 3 3 """ 4 import sys, re, string, wx 4 import sys 5 from collections import namedtuple 6 7 import wx 5 8 import wx.lib.newevent 9 from wx.lib.scrolledpanel import ScrolledPanel 10 6 11 from sas.guiframe.events import StatusEvent 7 12 from sas.guiframe.panel_base import PanelBase 8 from wx.lib.scrolledpanel import ScrolledPanel9 13 from sas.guiframe.events import PanelOnFocusEvent 14 from sas.guiframe.utils import IdList 15 from sas.guiframe.documentation_window import DocumentationWindow 16 10 17 #Control panel width 11 18 if sys.platform.count("darwin") == 0: … … 17 24 18 25 26 # Each constraint requires five widgets and sizer. Package them in 27 # a named tuple for easy access. 28 ConstraintLine = namedtuple('ConstraintLine', 29 'model_cbox param_cbox egal_txt constraint btRemove sizer') 30 19 31 def get_fittableParam(model): 20 32 """ 21 return list of fittable parameters name ofa model33 return list of fittable parameters from a model 22 34 23 35 :param model: the model used … … 34 46 35 47 return fittable_param 36 37 48 38 49 class SimultaneousFitPage(ScrolledPanel, PanelBase): … … 46 57 ## Title to appear on top of the window 47 58 window_caption = "Simultaneous Fit Page" 48 49 def __init__(self, parent, page_finder={}, id= -1, batch_on=False, 50 *args, **kwargs): 59 ID_DOC = wx.NewId() 60 ID_SET_ALL = wx.NewId() 61 ID_FIT = wx.NewId() 62 ID_ADD = wx.NewId() 63 _id_pool = IdList() 64 65 def __init__(self, parent, page_finder={}, id=wx.ID_ANY, batch_on=False, 66 *args, **kwargs): 51 67 ScrolledPanel.__init__(self, parent, id=id, 52 68 style=wx.FULL_REPAINT_ON_RESIZE, … … 56 72 Simultaneous page display 57 73 """ 74 self._ids = iter(self._id_pool) 58 75 self.SetupScrolling() 59 76 ##Font size … … 64 81 ## store page_finder 65 82 self.page_finder = page_finder 66 ## list conta ning info to set constraint83 ## list containing info to set constraint 67 84 ## look like self.constraint_dict[page_id]= page 68 85 self.constraint_dict = {} 69 86 ## item list 70 # self.constraints_list=[combobox1, combobox2,=,textcrtl, button ]87 ## self.constraints_list=[combobox1, combobox2,=,textcrtl, button ] 71 88 self.constraints_list = [] 72 89 ## list of current model … … 78 95 self.model_cbox_left = None 79 96 self.model_cbox_right = None 80 self.uid = wx.NewId()81 97 ## draw page 82 98 self.define_page_structure() 83 99 self.draw_page() 84 self.set_layout()85 100 self._set_save_flag(False) 86 101 87 102 def define_page_structure(self): 88 103 """ 89 Create empty sizer for apanel104 Create empty sizers, their hierarchy and set the sizer for the panel 90 105 """ 91 106 self.vbox = wx.BoxSizer(wx.VERTICAL) … … 100 115 self.vbox.Add(self.sizer2) 101 116 self.vbox.Add(self.sizer3) 102 103 def set_scroll(self):104 """105 """106 self.Layout()107 108 def set_layout(self):109 """110 layout111 """112 self.vbox.Layout()113 self.vbox.Fit(self)114 117 self.SetSizer(self.vbox) 115 self.set_scroll()116 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) 117 394 118 395 def onRemove(self, event): … … 126 403 if len(self.constraints_list) == 0: 127 404 return 405 wx.CallAfter(self._remove_after, event.GetId()) 406 #self._onAdd_constraint(None) 407 408 def _remove_after(self, id): 128 409 for item in self.constraints_list: 129 length = len(item) 130 if event.GetId() == item[length - 2].GetId(): 131 sizer = item[length - 1] 132 sizer.Clear(True) 133 self.sizer_constraints.Remove(sizer) 134 #self.SetScrollbars(20,20,25,65) 410 if id == item.btRemove.GetId(): 411 self.sizer_constraints.Hide(item.sizer) 412 item.sizer.Clear(True) 413 self.sizer_constraints.Remove(item.sizer) 135 414 self.constraints_list.remove(item) 136 415 self.nb_constraint -= 1 137 416 self.sizer2.Layout() 138 self. Layout()417 self.FitInside() 139 418 break 140 141 #self._onAdd_constraint(None)142 419 143 420 def onFit(self, event): … … 171 448 wx.PostEvent(self.parent.parent, StatusEvent(status=msg)) 172 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 173 470 def set_manager(self, manager): 174 471 """ … … 195 492 if not self.batch_on: 196 493 ## display constraint fields 197 if self.show_constraint.GetValue() and\198 len(self.constraints_list) == 0 :494 if (self.show_constraint.GetValue() and 495 len(self.constraints_list) == 0): 199 496 self._show_all_constraint() 200 497 self._show_constraint() … … 203 500 item[0].SetValue(False) 204 501 205 self.model_toFit = []206 502 if not self.batch_on: 207 503 ##constraint info … … 209 505 210 506 self._update_easy_setup_cb() 211 self. Layout()212 self.Refresh() 507 self.FitInside() 508 213 509 214 510 def check_model_name(self, event): … … 242 538 if len(self.model_list) == len(self.model_toFit): 243 539 self.cb1.SetValue(True) 244 self. Layout()540 self.FitInside() 245 541 return 246 542 else: 247 543 self.cb1.SetValue(False) 248 self. Layout()544 self.FitInside() 249 545 250 546 def _update_easy_setup_cb(self): … … 252 548 Update easy setup combobox on selecting a model 253 549 """ 254 if self.model_cbox_left != None and self.model_cbox_right != None: 255 try: 256 # when there is something 257 self.model_cbox_left.Clear() 258 self.model_cbox_right.Clear() 259 self.model_cbox.Clear() 260 except: 261 # when there is nothing 262 pass 263 #for id, model in self.constraint_dict.iteritems(): 264 for item in self.model_toFit: 265 model = item[3] 266 ## check if all parameters have been selected for constraint 267 ## then do not allow add constraint on parameters 268 if str(model.name) not in self.model_cbox_left.GetItems(): 269 self.model_cbox_left.Append(str(model.name), model) 270 if str(model.name) not in self.model_cbox_right.GetItems(): 271 self.model_cbox_right.Append(str(model.name), model) 272 if str(model.name) not in self.model_cbox.GetItems(): 273 self.model_cbox.Append(str(model.name), model) 550 if self.model_cbox_left == None or self.model_cbox_right == None: 551 return 552 553 models = [(item[3].name, item[3]) for item in self.model_toFit] 554 setComboBoxItems(self.model_cbox_left, models) 555 setComboBoxItems(self.model_cbox_right, models) 556 for item in self.constraints_list: 557 setComboBoxItems(item[0], models) 558 if self.model_cbox_left.GetSelection() == wx.NOT_FOUND: 274 559 self.model_cbox_left.SetSelection(0) 275 self.sizer2.Layout() 276 self.sizer3.Layout() 277 278 def draw_page(self): 279 """ 280 Draw a sizer containing couples of data and model 281 """ 282 self.model_list = [] 283 self.model_toFit = [] 284 self.constraints_list = [] 285 self.constraint_dict = {} 286 self.nb_constraint = 0 287 self.model_cbox_left = None 288 self.model_cbox_right = None 289 290 if len(self.model_list) > 0: 291 for item in self.model_list: 292 item[0].SetValue(False) 293 self.manager.schedule_for_fit(value=0, uid=item[2]) 294 295 self.sizer1.Clear(True) 296 box_description = wx.StaticBox(self, -1, "Fit Combinations") 297 boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) 298 sizer_title = wx.BoxSizer(wx.HORIZONTAL) 299 sizer_couples = wx.GridBagSizer(5, 5) 300 #------------------------------------------------------ 301 if len(self.page_finder) == 0: 302 msg = " No fit combinations are found! \n\n" 303 msg += " Please load data and set up " 304 msg += "at least two fit panels first..." 305 sizer_title.Add(wx.StaticText(self, -1, msg)) 306 else: 307 ## store model 308 self._store_model() 309 310 self.cb1 = wx.CheckBox(self, -1, 'Select all') 311 self.cb1.SetValue(False) 312 313 wx.EVT_CHECKBOX(self, self.cb1.GetId(), self.check_all_model_name) 314 315 sizer_title.Add((10, 10), 0, 316 wx.TOP | wx.BOTTOM | wx.EXPAND | wx.ADJUST_MINSIZE, border=5) 317 sizer_title.Add(self.cb1, 0, 318 wx.TOP | wx.BOTTOM | wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, border=5) 319 320 ## draw list of model and data name 321 self._fill_sizer_model_list(sizer_couples) 322 ## draw the sizer containing constraint info 323 if not self.batch_on: 324 self._fill_sizer_constraint() 325 ## draw fit button 326 self._fill_sizer_fit() 327 #-------------------------------------------------------- 328 boxsizer1.Add(sizer_title, flag=wx.TOP | wx.BOTTOM, border=5) 329 boxsizer1.Add(sizer_couples, 1, flag=wx.TOP | wx.BOTTOM, border=5) 330 331 self.sizer1.Add(boxsizer1, 1, wx.EXPAND | wx.ALL, 10) 332 self.sizer1.Layout() 333 #self.SetScrollbars(20,20,25,65) 334 self.AdjustScrollbars() 335 self.Layout() 560 self.sizer2.Layout() 336 561 337 562 def _store_model(self): … … 359 584 self._show_all_constraint() 360 585 self._show_constraint() 361 self. Layout()586 self.FitInside() 362 587 return 363 588 else: 364 589 self._hide_constraint() 365 self.Layout()366 590 return 367 591 … … 370 594 Show constraint fields 371 595 """ 372 box_description = wx.StaticBox(self, -1, "Easy Setup ")596 box_description = wx.StaticBox(self, wx.ID_ANY, "Easy Setup ") 373 597 boxsizer = wx.StaticBoxSizer(box_description, wx.HORIZONTAL) 374 598 sizer_constraint = wx.BoxSizer(wx.HORIZONTAL) 375 self.model_cbox_left = wx.ComboBox(self, -1, style=wx.CB_READONLY)599 self.model_cbox_left = wx.ComboBox(self, wx.ID_ANY, style=wx.CB_READONLY) 376 600 self.model_cbox_left.Clear() 377 self.model_cbox_right = wx.ComboBox(self, -1, style=wx.CB_READONLY)601 self.model_cbox_right = wx.ComboBox(self, wx.ID_ANY, style=wx.CB_READONLY) 378 602 self.model_cbox_right.Clear() 379 wx.EVT_COMBOBOX(self.model_cbox_left, -1, self._on_select_modelcb)380 wx.EVT_COMBOBOX(self.model_cbox_right, -1, self._on_select_modelcb)381 egal_txt = wx.StaticText(self, -1, " = ")382 self.set_button = wx.Button(self, wx.NewId(), 'Set All')603 wx.EVT_COMBOBOX(self.model_cbox_left, wx.ID_ANY, self._on_select_modelcb) 604 wx.EVT_COMBOBOX(self.model_cbox_right, wx.ID_ANY, self._on_select_modelcb) 605 egal_txt = wx.StaticText(self, wx.ID_ANY, " = ") 606 self.set_button = wx.Button(self, self.ID_SET_ALL, 'Set All') 383 607 self.set_button.Bind(wx.EVT_BUTTON, self._on_set_all_equal, 384 608 id=self.set_button.GetId()) … … 399 623 boxsizer.Add(self.model_cbox_left, 400 624 flag=wx.RIGHT | wx.EXPAND, border=10) 401 boxsizer.Add(wx.StaticText(self, -1, ".parameters"),402 flag=wx.RIGHT | wx.EXPAND, border=5)625 #boxsizer.Add(wx.StaticText(self, wx.ID_ANY, ".parameters"), 626 # flag=wx.RIGHT | wx.EXPAND, border=5) 403 627 boxsizer.Add(egal_txt, flag=wx.RIGHT | wx.EXPAND, border=5) 404 628 boxsizer.Add(self.model_cbox_right, 405 629 flag=wx.RIGHT | wx.EXPAND, border=10) 406 boxsizer.Add(wx.StaticText(self, -1, ".parameters"),407 flag=wx.RIGHT | wx.EXPAND, border=5)630 #boxsizer.Add(wx.StaticText(self, wx.ID_ANY, ".parameters"), 631 # flag=wx.RIGHT | wx.EXPAND, border=5) 408 632 boxsizer.Add((20, -1)) 409 633 boxsizer.Add(self.set_button, flag=wx.RIGHT | wx.EXPAND, border=5) … … 412 636 item=sizer_constraint, 413 637 flag=wx.TOP | wx.BOTTOM | wx.EXPAND, border=5) 414 415 self.sizer_all_constraints.Layout() 416 self.sizer2.Layout() 417 #self.SetScrollbars(20,20,25,65) 638 self.FitInside() 418 639 419 640 def _on_select_modelcb(self, event): … … 427 648 if self.model_cbox_right.GetValue().strip() == '': 428 649 flag = False 429 if self.model_cbox_left.GetValue() == \430 self.model_cbox_right.GetValue() :650 if (self.model_cbox_left.GetValue() == 651 self.model_cbox_right.GetValue()): 431 652 flag = False 432 653 self.set_button.Enable(flag) … … 460 681 num_cbox += 1 461 682 if param in param_listB: 462 self.model_cbox.SetStringSelection(model_left) 683 item = self.constraints_list[-1] 684 item.model_cbox.SetStringSelection(model_left) 463 685 self._on_select_model(None) 464 self.param_cbox.Clear()465 self.param_cbox.Append(str(param), model)466 self.param_cbox.SetStringSelection(str(param))467 self.ctl2.SetValue(str(model_right + "." + str(param)))686 item.param_cbox.Clear() 687 item.param_cbox.Append(str(param), model) 688 item.param_cbox.SetStringSelection(str(param)) 689 item.constraint.SetValue(str(model_right + "." + str(param))) 468 690 has_param = True 469 691 if num_cbox == (len(param_list) + 1): … … 471 693 self._show_constraint() 472 694 473 self.sizer_constraints.Layout() 474 self.sizer2.Layout() 475 self.SetScrollbars(20, 20, 25, 65) 476 self.Layout() 695 self.FitInside() 477 696 if not has_param: 478 697 msg = " There is no adjustable parameter (checked to fit)" … … 496 715 ##Don't add anymore 497 716 if len(self.constraints_list) == nb_fit_param: 498 msg = "Cannot add another constraint .Maximum of number "717 msg = "Cannot add another constraint. Maximum of number " 499 718 msg += "Parameters name reached %s" % str(nb_fit_param) 500 719 wx.PostEvent(self.parent.parent, StatusEvent(status=msg)) … … 510 729 511 730 sizer_constraint = wx.BoxSizer(wx.HORIZONTAL) 512 model_cbox = wx.ComboBox(self, -1, style=wx.CB_READONLY) 731 732 # Model list 733 model_cbox = wx.ComboBox(self, wx.ID_ANY, style=wx.CB_READONLY) 513 734 model_cbox.Clear() 514 param_cbox = wx.ComboBox(self, -1, style=wx.CB_READONLY, size=(100, -1),)515 param_cbox.Hide()516 517 #This is for GetCLientData() _on_select_param: Was None return on MAC.518 self.param_cbox = param_cbox519 520 wx.EVT_COMBOBOX(param_cbox, -1, self._on_select_param)521 self.ctl2 = wx.TextCtrl(self, -1)522 egal_txt = wx.StaticText(self, -1, " = ")523 self.btRemove = wx.Button(self, wx.NewId(), 'Remove')524 self.btRemove.Bind(wx.EVT_BUTTON, self.onRemove,525 id=self.btRemove.GetId())526 self.btRemove.SetToolTipString("Remove constraint.")527 self.btRemove.Hide()528 if hasattr(self, "btAdd"):529 self.btAdd.Hide()530 735 for id, model in self.constraint_dict.iteritems(): 531 736 ## check if all parameters have been selected for constraint 532 737 ## then do not allow add constraint on parameters 533 738 model_cbox.Append(str(model.name), model) 534 535 #This is for GetCLientData() passing to self._on_select_param: Was None return on MAC. 536 self.model_cbox = model_cbox 537 538 wx.EVT_COMBOBOX(model_cbox, -1, self._on_select_model) 739 wx.EVT_COMBOBOX(model_cbox, wx.ID_ANY, self._on_select_model) 740 741 # Parameters in model 742 param_cbox = wx.ComboBox(self, wx.ID_ANY, style=wx.CB_READONLY, 743 size=(100, -1)) 744 param_cbox.Hide() 745 wx.EVT_COMBOBOX(param_cbox, wx.ID_ANY, self._on_select_param) 746 747 egal_txt = wx.StaticText(self, wx.ID_ANY, " = ") 748 749 # Parameter constraint 750 constraint = wx.TextCtrl(self, wx.ID_ANY) 751 752 # Remove button 753 #btRemove = wx.Button(self, self.ID_REMOVE, 'Remove') 754 btRemove = wx.Button(self, self._ids.next(), 'Remove') 755 btRemove.Bind(wx.EVT_BUTTON, self.onRemove, 756 id=btRemove.GetId()) 757 btRemove.SetToolTipString("Remove constraint.") 758 btRemove.Hide() 759 760 # Hid the add button, if it exists 761 if hasattr(self, "btAdd"): 762 self.btAdd.Hide() 763 539 764 sizer_constraint.Add((5, -1)) 540 765 sizer_constraint.Add(model_cbox, flag=wx.RIGHT | wx.EXPAND, border=10) 541 766 sizer_constraint.Add(param_cbox, flag=wx.RIGHT | wx.EXPAND, border=5) 542 767 sizer_constraint.Add(egal_txt, flag=wx.RIGHT | wx.EXPAND, border=5) 543 sizer_constraint.Add( self.ctl2, flag=wx.RIGHT | wx.EXPAND, border=10)544 sizer_constraint.Add( self.btRemove, flag=wx.RIGHT | wx.EXPAND, border=10)768 sizer_constraint.Add(constraint, flag=wx.RIGHT | wx.EXPAND, border=10) 769 sizer_constraint.Add(btRemove, flag=wx.RIGHT | wx.EXPAND, border=10) 545 770 546 771 self.sizer_constraints.Insert(before=self.nb_constraint, 547 item=sizer_constraint, flag=wx.TOP | wx.BOTTOM | wx.EXPAND, 548 border=5) 549 self.constraints_list.append([model_cbox, param_cbox, egal_txt, 550 self.ctl2, self.btRemove, sizer_constraint]) 772 item=sizer_constraint, flag=wx.TOP | wx.BOTTOM | wx.EXPAND, 773 border=5) 774 c = ConstraintLine(model_cbox, param_cbox, egal_txt, 775 constraint, btRemove, sizer_constraint) 776 self.constraints_list.append(c) 551 777 552 778 self.nb_constraint += 1 553 779 self.sizer_constraints.Layout() 554 780 self.sizer2.Layout() 781 self.Layout 555 782 556 783 def _hide_constraint(self): … … 558 785 hide buttons related constraint 559 786 """ 560 for id in 787 for id in self.page_finder.iterkeys(): 561 788 self.page_finder[id].clear_model_param() 562 789 … … 566 793 self.btAdd.Hide() 567 794 self._store_model() 568 if self.model_cbox_left != None: 569 try: 570 self.model_cbox_left.Clear() 571 except: 572 pass 795 if self.model_cbox_left is not None: 796 self.model_cbox_left.Clear() 573 797 self.model_cbox_left = None 574 if self.model_cbox_right != None: 575 try: 576 self.model_cbox_right.Clear() 577 except: 578 pass 798 if self.model_cbox_right is not None: 799 self.model_cbox_right.Clear() 579 800 self.model_cbox_right = None 580 801 self.constraints_list = [] … … 584 805 self.sizer_constraints.Layout() 585 806 self.sizer2.Layout() 807 self.Layout 808 self.FitInside() 586 809 587 810 def _on_select_model(self, event): … … 589 812 fill combox box with list of parameters 590 813 """ 814 if not self.constraints_list: 815 return 816 817 ##This way PC/MAC both work, instead of using event.GetClientData(). 818 model_cbox = self.constraints_list[-1].model_cbox 819 n = model_cbox.GetCurrentSelection() 820 if n == wx.NOT_FOUND: 821 return 822 823 model = model_cbox.GetClientData(n) 591 824 param_list = [] 592 ##This way PC/MAC both work, instead of using event.GetClientData().593 n = self.model_cbox.GetCurrentSelection()594 model = self.model_cbox.GetClientData(n)595 825 for id, dic_model in self.constraint_dict.iteritems(): 596 826 if model == dic_model: 597 827 param_list = self.page_finder[id].get_param2fit() 598 #break 599 length = len(self.constraints_list) 600 if length < 1: 601 return 602 param_cbox = self.constraints_list[length - 1][1] 828 break 829 830 param_cbox = self.constraints_list[-1].param_cbox 603 831 param_cbox.Clear() 604 832 ## insert only fittable paramaters 605 833 for param in param_list: 606 834 param_cbox.Append(str(param), model) 607 608 835 param_cbox.Show(True) 609 self.btRemove.Show(True) 836 837 btRemove = self.constraints_list[-1].btRemove 838 btRemove.Show(True) 610 839 self.btAdd.Show(True) 611 self.sizer2.Layout() 840 # self.Layout() 841 self.FitInside() 612 842 613 843 def _on_select_param(self, event): … … 620 850 #param = event.GetString() 621 851 622 length = len(self.constraints_list) 623 if length < 1: 624 return 625 egal_txt = self.constraints_list[length - 1][2] 626 egal_txt.Show(True) 627 628 ctl2 = self.constraints_list[length - 1][3] 629 ctl2.Show(True) 852 if self.constraints_list: 853 self.constraints_list[-1].egal_txt.Show(True) 854 self.constraints_list[-1].constraint.Show(True) 630 855 631 856 def _onAdd_constraint(self, event): … … 640 865 # before allow to add another constraint 641 866 for item in self.constraints_list: 642 model_cbox = item[0] 643 if model_cbox.GetString(0) == "": 867 if item.model_cbox.GetString(0) == "": 644 868 msg = " Select a model Name! " 645 869 wx.PostEvent(self.parent.parent, StatusEvent(status=msg)) 646 870 return 647 param_cbox = item[1] 648 if param_cbox.GetString(0) == "": 871 if item.param_cbox.GetString(0) == "": 649 872 msg = " Select a parameter Name! " 650 873 wx.PostEvent(self.parent.parent, StatusEvent(status=msg)) 651 874 return 652 ctl2 = item[3] 653 if ctl2.GetValue().lstrip().rstrip() == "": 654 model = param_cbox.GetClientData(\ 655 param_cbox.GetCurrentSelection()) 875 if item.constraint.GetValue().lstrip().rstrip() == "": 876 model = item.param_cbox.GetClientData( 877 item.param_cbox.GetCurrentSelection()) 656 878 if model != None: 657 879 msg = " Enter a constraint for %s.%s! " % (model.name, 658 880 item.param_cbox.GetString(0)) 659 881 else: 660 882 msg = " Enter a constraint" 661 883 wx.PostEvent(self.parent.parent, StatusEvent(status=msg)) 662 884 return 663 885 ## some model or parameters can be constrained 664 886 self._show_constraint() 665 self.sizer3.Layout() 666 self.Layout() 667 self.Refresh() 668 669 def _fill_sizer_fit(self): 670 """ 671 Draw fit button 672 """ 673 self.sizer3.Clear(True) 674 box_description = wx.StaticBox(self, -1, "Fit ") 675 boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) 676 sizer_button = wx.BoxSizer(wx.HORIZONTAL) 677 678 self.btFit = wx.Button(self, wx.NewId(), 'Fit', size=wx.DefaultSize) 679 self.btFit.Bind(wx.EVT_BUTTON, self.onFit, id=self.btFit.GetId()) 680 self.btFit.SetToolTipString("Perform fit.") 681 if self.batch_on: 682 text = " Fit in Parallel all Data set and model selected.\n" 683 else: 684 text = " This page requires at least one FitPage with a data\n" 685 text = " and a model for fitting." 686 text_hint = wx.StaticText(self, -1, text) 687 688 sizer_button.Add(text_hint, wx.RIGHT | wx.EXPAND, 10) 689 sizer_button.Add(self.btFit, 0, wx.LEFT | wx.ADJUST_MINSIZE, 10) 690 691 boxsizer1.Add(sizer_button, flag=wx.TOP | wx.BOTTOM, border=10) 692 self.sizer3.Add(boxsizer1, 0, wx.EXPAND | wx.ALL, 10) 693 self.sizer3.Layout() 694 695 def _fill_sizer_constraint(self): 696 """ 697 Fill sizer containing constraint info 698 """ 699 msg = "Select at least 2 model to add constraint " 700 wx.PostEvent(self.parent.parent, StatusEvent(status=msg)) 701 702 self.sizer2.Clear(True) 703 if self.batch_on: 704 if self.sizer2.IsShown(): 705 self.sizer2.Show(False) 706 return 707 box_description = wx.StaticBox(self, -1, "Fit Constraints") 708 boxsizer1 = wx.StaticBoxSizer(box_description, wx.VERTICAL) 709 sizer_title = wx.BoxSizer(wx.HORIZONTAL) 710 self.sizer_all_constraints = wx.BoxSizer(wx.HORIZONTAL) 711 self.sizer_constraints = wx.BoxSizer(wx.VERTICAL) 712 sizer_button = wx.BoxSizer(wx.HORIZONTAL) 713 714 self.hide_constraint = wx.RadioButton(self, -1, 'No', (10, 10), 715 style=wx.RB_GROUP) 716 self.show_constraint = wx.RadioButton(self, -1, 'Yes', (10, 30)) 717 self.Bind(wx.EVT_RADIOBUTTON, self._display_constraint, 718 id=self.hide_constraint.GetId()) 719 self.Bind(wx.EVT_RADIOBUTTON, self._display_constraint, 720 id=self.show_constraint.GetId()) 721 if self.batch_on: 722 self.hide_constraint.Enable(False) 723 self.show_constraint.Enable(False) 724 self.hide_constraint.SetValue(True) 725 self.show_constraint.SetValue(False) 726 727 sizer_title.Add(wx.StaticText(self, -1, " Model")) 728 sizer_title.Add((10, 10)) 729 sizer_title.Add(wx.StaticText(self, -1, " Parameter")) 730 sizer_title.Add((10, 10)) 731 sizer_title.Add(wx.StaticText(self, -1, " Add Constraint?")) 732 sizer_title.Add((10, 10)) 733 sizer_title.Add(self.show_constraint) 734 sizer_title.Add(self.hide_constraint) 735 sizer_title.Add((10, 10)) 736 737 self.btAdd = wx.Button(self, wx.NewId(), 'Add') 738 self.btAdd.Bind(wx.EVT_BUTTON, self._onAdd_constraint, 739 id=self.btAdd.GetId()) 740 self.btAdd.SetToolTipString("Add another constraint?") 741 self.btAdd.Hide() 742 743 text_hint = wx.StaticText(self, -1, 744 "Example: [M0][paramter] = M1.parameter") 745 sizer_button.Add(text_hint, 0 , wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 10) 746 sizer_button.Add(self.btAdd, 0, wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 10) 747 748 boxsizer1.Add(sizer_title, flag=wx.TOP | wx.BOTTOM, border=10) 749 boxsizer1.Add(self.sizer_all_constraints, flag=wx.TOP | wx.BOTTOM, 750 border=10) 751 boxsizer1.Add(self.sizer_constraints, flag=wx.TOP | wx.BOTTOM, 752 border=10) 753 boxsizer1.Add(sizer_button, flag=wx.TOP | wx.BOTTOM, border=10) 754 755 self.sizer2.Add(boxsizer1, 0, wx.EXPAND | wx.ALL, 10) 756 self.sizer2.Layout() 757 758 #self.SetScrollbars(20,20,25,65) 887 self.FitInside() 759 888 760 889 def _set_constraint(self): 761 890 """ 762 get values from the constrain st textcrtl ,parses them into model name891 get values from the constraint textcrtl ,parses them into model name 763 892 parameter name and parameters values. 764 893 store them in a list self.params .when when params is not empty … … 767 896 """ 768 897 for item in self.constraints_list: 769 select0 = item [0].GetSelection()898 select0 = item.model_cbox.GetSelection() 770 899 if select0 == wx.NOT_FOUND: 771 900 continue 772 model = item [0].GetClientData(select0)773 select1 = item [1].GetSelection()901 model = item.model_cbox.GetClientData(select0) 902 select1 = item.param_cbox.GetSelection() 774 903 if select1 == wx.NOT_FOUND: 775 904 continue 776 param = item [1].GetString(select1)777 constraint = item [3].GetValue().lstrip().rstrip()905 param = item.param_cbox.GetString(select1) 906 constraint = item.constraint.GetValue().lstrip().rstrip() 778 907 if param.lstrip().rstrip() == "": 779 908 param = None … … 808 937 # wrap in param/constraint in str() to remove unicode 809 938 self.page_finder[id].set_model_param(str(param), 810 939 str(constraint), fid=fid) 811 940 break 812 941 return True 813 814 def _fill_sizer_model_list(self, sizer):815 """816 Receive a dictionary containing information to display model name817 """818 ix = 0819 iy = 0820 list = []821 sizer.Clear(True)822 823 new_name = wx.StaticText(self, -1, ' Model Title ',824 style=wx.ALIGN_CENTER)825 new_name.SetBackgroundColour('orange')826 new_name.SetForegroundColour(wx.WHITE)827 sizer.Add(new_name, (iy, ix), (1, 1),828 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)829 ix += 2830 model_type = wx.StaticText(self, -1, ' Model ')831 model_type.SetBackgroundColour('grey')832 model_type.SetForegroundColour(wx.WHITE)833 sizer.Add(model_type, (iy, ix), (1, 1),834 wx.EXPAND | wx.ADJUST_MINSIZE, 0)835 ix += 1836 data_used = wx.StaticText(self, -1, ' Data ')837 data_used.SetBackgroundColour('grey')838 data_used.SetForegroundColour(wx.WHITE)839 sizer.Add(data_used, (iy, ix), (1, 1),840 wx.EXPAND | wx.ADJUST_MINSIZE, 0)841 ix += 1842 tab_used = wx.StaticText(self, -1, ' FitPage ')843 tab_used.SetBackgroundColour('grey')844 tab_used.SetForegroundColour(wx.WHITE)845 sizer.Add(tab_used, (iy, ix), (1, 1),846 wx.EXPAND | wx.ADJUST_MINSIZE, 0)847 for id, value in self.page_finder.iteritems():848 if id not in self.parent.opened_pages:849 continue850 851 if self.batch_on != self.parent.get_page_by_id(id).batch_on:852 continue853 854 data_list = []855 model_list = []856 # get data name and model objetta857 for fitproblem in value.get_fit_problem():858 859 data = fitproblem.get_fit_data()860 if not data.is_data:861 continue862 name = '-'863 if data is not None and data.is_data:864 name = str(data.name)865 data_list.append(name)866 867 model = fitproblem.get_model()868 if model is None:869 continue870 model_list.append(model)871 872 if len(model_list) == 0:873 continue874 # Draw sizer875 ix = 0876 iy += 1877 model = model_list[0]878 name = '_'879 if model is not None:880 name = str(model.name)881 cb = wx.CheckBox(self, -1, name)882 cb.SetValue(False)883 cb.Enable(model is not None and data.is_data)884 sizer.Add(cb, (iy, ix), (1, 1),885 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)886 wx.EVT_CHECKBOX(self, cb.GetId(), self.check_model_name)887 ix += 2888 type = model.__class__.__name__889 model_type = wx.StaticText(self, -1, str(type))890 sizer.Add(model_type, (iy, ix), (1, 1),891 wx.EXPAND | wx.ADJUST_MINSIZE, 0)892 if self.batch_on:893 data_used = wx.ComboBox(self, -1, style=wx.CB_READONLY)894 data_used.AppendItems(data_list)895 data_used.SetSelection(0)896 else:897 data_used = wx.StaticText(self, -1, data_list[0])898 899 ix += 1900 sizer.Add(data_used, (iy, ix), (1, 1),901 wx.EXPAND | wx.ADJUST_MINSIZE, 0)902 ix += 1903 caption = value.get_fit_tab_caption()904 tab_caption_used = wx.StaticText(self, -1, str(caption))905 sizer.Add(tab_caption_used, (iy, ix), (1, 1),906 wx.EXPAND | wx.ADJUST_MINSIZE, 0)907 908 self.model_list.append([cb, value, id, model])909 910 iy += 1911 sizer.Add((20, 20), (iy, ix), (1, 1),912 wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15)913 sizer.Layout()914 942 915 943 def on_set_focus(self, event=None): … … 921 949 wx.PostEvent(self.parent.parent, PanelOnFocusEvent(panel=self)) 922 950 self.page_finder = self.parent._manager.get_page_finder() 951 952 953 def setComboBoxItems(cbox, items): 954 assert isinstance(cbox, wx.ComboBox) 955 selected = cbox.GetStringSelection() 956 cbox.Clear() 957 for k, (name, value) in enumerate(items): 958 cbox.Append(name, value) 959 cbox.SetStringSelection(selected) -
src/sas/plottools/toolbar.py
rd3d67f0 r2d88fc4 19 19 20 20 class NavigationToolBar(NavigationToolbar2WxAgg): 21 _NTB2_HOME = wx.NewId() 22 _NTB2_BACK = wx.NewId() 23 _NTB2_FORWARD = wx.NewId() 24 _NTB2_PAN = wx.NewId() 25 _NTB2_ZOOM = wx.NewId() 26 _NTB2_SAVE = wx.NewId() 27 _NTB2_PRINT = wx.NewId() 28 _NTB2_RESET = wx.NewId() 29 _NTB2_COPY = wx.NewId() 21 30 """ 22 31 Overwrite matplotlib toolbar … … 31 40 def _init_toolbar(self): 32 41 self._parent = self.canvas.GetParent() 33 self._NTB2_HOME = wx.NewId()34 self._NTB2_BACK = wx.NewId()35 self._NTB2_FORWARD = wx.NewId()36 self._NTB2_PAN = wx.NewId()37 self._NTB2_ZOOM = wx.NewId()38 self._NTB2_SAVE = wx.NewId()39 self._NTB2_PRINT = wx.NewId()40 self._NTB2_RESET = wx.NewId()41 42 42 43 # for mpl 1.2+ compatibility … … 101 102 """ 102 103 # Slicer plot popup menu 103 wx_id = wx.NewId()104 104 popup = wx.Menu() 105 popup.Append( wx_id, '&Save image', 'Save image as PNG')106 wx.EVT_MENU(self, wx_id, self.save_figure)105 popup.Append(self._NTB2_SAVE, '&Save image', 'Save image as PNG') 106 wx.EVT_MENU(self, self._NTB2_SAVE, self.save_figure) 107 107 108 wx_id = wx.NewId() 109 popup.Append(wx_id, '&Print image', 'Print image ') 110 wx.EVT_MENU(self, wx_id, self.print_figure) 108 popup.Append(self._NTB2_PRINT, '&Print image', 'Print image ') 109 wx.EVT_MENU(self, self._NTB2_PRINT, self.print_figure) 111 110 112 wx_id = wx.NewId() 113 popup.Append(wx_id, '&Copy to Clipboard', 'Copy image to the clipboard') 114 wx.EVT_MENU(self, wx_id, self.copy_figure) 111 popup.Append(self._NTB2_COPY, '&Copy to Clipboard', 'Copy image to the clipboard') 112 wx.EVT_MENU(self, self._NTB2_COPY, self.copy_figure) 115 113 116 114 # Show the popup menu relative to the location of the toolbar -
test/sasfit/test/utest_fit_line.py
racf8e4a5 rbc873053 11 11 from sas.models.LineModel import LineModel 12 12 from sas.models.Constant import Constant 13 14 from bumps import fitters 15 try: 16 from bumps.options import FIT_CONFIG 17 def set_fitter(alg, opts): 18 FIT_CONFIG.selected_id = alg 19 FIT_CONFIG.values[alg].update(opts, monitors=[]) 20 except: 21 # CRUFT: Bumps changed its handling of fit options around 0.7.5.6 22 def set_fitter(alg, opts): 23 #print "fitting",alg,opts 24 #print "options",fitters.FIT_OPTIONS[alg].__dict__ 25 fitters.FIT_DEFAULT = alg 26 fitters.FIT_OPTIONS[alg].options.update(opts, monitors=[]) 27 13 28 14 29 class testFitModule(unittest.TestCase): … … 67 82 68 83 def fit_bumps(self, alg, **opts): 69 #Importing the Fit module 70 from bumps import fitters 71 fitters.FIT_DEFAULT = alg 72 fitters.FIT_OPTIONS[alg].options.update(opts) 73 fitters.FIT_OPTIONS[alg].options.update(monitors=[]) 74 #print "fitting",alg,opts 75 #kprint "options",fitters.FIT_OPTIONS[alg].__dict__ 84 set_fitter(alg, opts) 76 85 self.fit_single(isdream=(alg=='dream')) 77 86 -
test/sasfit/test/utest_fit_smeared.py
racf8e4a5 rbc873053 13 13 from sas.models.CylinderModel import CylinderModel 14 14 from sas.models.SphereModel import SphereModel 15 16 17 from bumps import fitters 18 try: 19 from bumps.options import FIT_CONFIG 20 def set_fitter(alg, opts): 21 FIT_CONFIG.selected_id= alg 22 FIT_CONFIG.values[alg].update(opts, monitors=[]) 23 except: 24 # CRUFT: Bumps changed its handling of fit options around 0.7.5.6 25 def set_fitter(alg, opts): 26 #print "fitting",alg,opts 27 #print "options",fitters.FIT_OPTIONS[alg].__dict__ 28 fitters.FIT_DEFAULT = alg 29 fitters.FIT_OPTIONS[alg].options.update(opts, monitors=[]) 30 15 31 16 32 class testFitModule(unittest.TestCase): … … 57 73 Cylinder fit with dispersion 58 74 """ 59 alg = 'lm' 60 from bumps import fitters 61 fitters.FIT_DEFAULT = alg 62 #fitters.FIT_OPTIONS[alg].options.update(opts) 63 fitters.FIT_OPTIONS[alg].options.update(monitors=[]) 75 set_fitter('lm', {}) 64 76 self._dispersion(fitter = Fit()) 65 77
Note: See TracChangeset
for help on using the changeset viewer.