Changes in / [225aca8:d06c34c] in sasview
- Files:
-
- 3 deleted
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
build_tools/jenkins_osx_build.sh
re9e3e38 r460f5f2 46 46 python setup_mac.py py2app 47 47 48 #cd $WORKSPACE/sasview/dist49 #tar -czf `python -c "import pkg_resources;print '%s.tar.gz SasView-%s.app' % (pkg_resources.get_distribution('sasview').egg_name(),pkg_resources.get_distribution('sasview').version)"` 48 cd $WORKSPACE/sasview/dist 49 tar -czf `python -c "import pkg_resources;print '%s.tar.gz' % pkg_resources.get_distribution('sasview').egg_name()"` sasview.app -
sasview.latestversion
r9533593 r0ea31ca 1 3.1. 11 3.1.0 -
sasview/README.txt
r9533593 r8bea1519 4 4 1- Features 5 5 =========== 6 7 - New in Version 3.1.18 --------------------9 - Fixes bug #457 that prevented SasView from starting if the user was not10 connected to the internet, or was behind a proxy server.11 6 12 7 - New in Version 3.1.0 … … 307 302 different browser and set that as your default browser. Issues have 308 303 been noted with Internet Explorer 11. 309 - Check for Updates may fail (with the status bar message ' Cannot310 connect to the application server') if your internet connection uses311 a proxy server. Tested resolutions for this are described on the312 website FAQ.313 304 - The copy and paste functions (^C, ^V) in the batch mode results grid 314 305 require two clicks: one to select the cell and a second to select the -
sasview/__init__.py
r9533593 rbc84fa7 1 __version__ = "3.1. 1"1 __version__ = "3.1.0" 2 2 __build__ = "1" -
sasview/local_config.py
r957af0d r5846bb5 13 13 __build__ = sas.sasview.__build__ 14 14 __download_page__ = 'https://github.com/SasView/sasview/releases' 15 __update_URL__ = 'http://www.sasview.org/latestversion.json' 15 __update_URL__ = ['raw.githubusercontent.com', 16 '/SasView/sasview/master/sasview.latestversion'] 17 16 18 17 19 # Debug message flag … … 129 131 DEFAULT_PERSPECTIVE = 'None' 130 132 131 # Time out for updating sasview132 UPDATE_TIMEOUT = 2133 134 133 def printEVT(message): 135 134 if __EVT_DEBUG__: -
sasview/setup_mac.py
r49cd712 r018582f 116 116 CFBundleTypeRole="Shell" )],) 117 117 118 #Get version - NB nasty hack. Need to find correct way to give path to installed sasview (AJJ)119 import __init__ as sasviewver120 121 VERSION = sasviewver.__version__122 APPNAME = "SasView "+VERSION123 DMGNAME = "SasView-"+VERSION124 125 118 APP = ['sasview.py'] 126 119 DATA_FILES += ['images','test','media'] … … 140 133 } 141 134 setup( 142 name= APPNAME,135 name="sasview", 143 136 app=APP, 144 137 data_files=DATA_FILES, … … 147 140 setup_requires=['py2app'], 148 141 ) 149 150 #Build dmg151 DMG="dist/%s.dmg"%DMGNAME152 if os.path.exists(DMG): os.unlink(DMG)153 os.system('cd dist && ../../build_tools/dmgpack.sh "%s" "%s.app"'%(DMGNAME,APPNAME))154 os.system('chmod a+r "%s"'%DMG)155 -
src/sas/guiframe/config.py
r9989a6a r5846bb5 10 10 __build__ = '1' 11 11 __download_page__ = 'https://github.com/SasView/sasview/releases' 12 __update_URL__ = 'http://www.sasview.org/latestversion.json' 12 __update_URL__ = ['raw.githubusercontent.com', 13 '/SasView/sasview/master/sasview.latestversion'] 13 14 14 15 -
src/sas/guiframe/data_processor.py
r44d20af re54dbc3e 1 1 """ 2 Implement grid used to store results of a batch fit. 3 4 This is in Guiframe rather than fitting which is probably where it should be. 5 Actually could be a generic framework implemented in fit gui module. At this 6 point however there this grid behaves independently of the fitting panel and 7 only knows about information sent to it but not about the fits or fit panel and 8 thus cannot feed back to the fitting panel. This could change in the future. 9 10 The organization of the classes goes as: 11 12 .. image:: ../../user/guiframe/BatchGridClassLayout.png 13 :align: center 14 2 Implement grid used to store data 15 3 """ 16 4 import wx … … 38 26 """ 39 27 Object describing a cell in the grid. 28 40 29 """ 41 30 def __init__(self): 42 """43 Initialize attributes of class (label, value, col, row, object)44 """45 31 self.label = "" 46 32 self.value = None … … 53 39 """ 54 40 Return a dictionary of column label and index or row selected 55 56 41 :param sentence: String to parse 57 42 :param list: list of columns label 58 :returns: col_dict59 43 """ 60 61 44 p2 = re.compile(r'\d+') 62 45 p = re.compile(r'[\+\-\*\%\/]') … … 98 81 99 82 class SPanel(ScrolledPanel): 100 """101 ensure proper scrolling of GridPanel102 103 Adds a SetupScrolling call to the normal ScrolledPanel init.104 GridPanel then subclasses this class105 106 """107 83 def __init__(self, parent, *args, **kwds): 108 """109 initialize ScrolledPanel then force a call to SetupScrolling110 111 """112 84 ScrolledPanel.__init__(self, parent, *args, **kwds) 113 85 self.SetupScrolling() … … 115 87 116 88 class GridCellEditor(sheet.CCellEditor): 117 """ 118 Custom cell editor 119 120 This subclasses the sheet.CCellEditor (itself a subclass of 121 grid.GridCellEditor) in order to override two of its methods: 122 PaintBackrgound and EndEdit. 123 124 This is necessary as the sheet module is broken in wx 3.0.2 and 125 improperly subclasses grid.GridCellEditor 126 """ 89 """ Custom cell editor """ 127 90 def __init__(self, grid): 128 """129 Override of CCellEditor init. Runs the grid.GridCellEditor init code130 """131 91 super(GridCellEditor, self).__init__(grid) 132 92 133 def PaintBackground(self, dc, rect, attr):134 """135 Overrides wx.sheet.CCellEditor.PaintBackground which incorrectly calls136 the base class method.137 138 In wx3.0 all paint objects must explicitly139 have a wxPaintDC (Device Context) object. Thus the paint event which140 generates a call to this method provides such a DC object and the141 base class in grid expects to receive that object. sheet was apparently142 not updated to reflect this and hence fails. This could thus143 become obsolete in a future bug fix of wxPython.144 145 Apart from adding a dc variable in the list of arguments in the def146 and in the call to the base class the rest of this method is copied147 as is from sheet.CCellEditor.PaintBackground148 149 **From original GridCellEditor docs:**150 151 Draws the part of the cell not occupied by the edit control. The152 base class version just fills it with background colour from the153 attribute.154 155 NOTE: There is no need to override this if you don't need156 to do something out of the ordinary.157 158 :param dc: the wxDC object for the paint159 """160 # Call base class method.161 DC = dc162 super(sheet.CCellEditor,self).PaintBackground(DC, rect, attr)163 164 93 def EndEdit(self, row, col, grid, previous): 165 """ 166 Commit editing the current cell. Returns True if the value has changed. 167 168 :param previous: previous value in the cell 94 """ 95 Commit editing the current cell. Returns True if the value has changed. 96 @param previous: previous value in the cell 169 97 """ 170 98 changed = False # Assume value not changed … … 180 108 class GridPage(sheet.CSheet): 181 109 """ 182 Class that receives the results of a batch fit.183 184 GridPage displays the received results in a wx.grid using sheet. This is185 then used by GridPanel and GridFrame to present the full GUI.186 110 """ 187 111 def __init__(self, parent, panel=None): 188 112 """ 189 Initialize190 191 Initialize all the attributes of GridPage, and the events. include192 the init stuff from sheet.CSheet as well.193 113 """ 194 114 #sheet.CSheet.__init__(self, parent) 195 115 196 116 # The following is the __init__ from CSheet. ########################## 197 117 # We re-write it here because the class is broken in wx 3.0, … … 219 139 220 140 # Sink events 141 self.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnLeftClick) 142 self.Bind(wx.grid.EVT_GRID_CELL_RIGHT_CLICK, self.OnRightClick) 143 #self.Bind(wx.grid.EVT_GRID_CELL_LEFT_DCLICK, self.OnLeftDoubleClick) 221 144 self.Bind(wx.grid.EVT_GRID_RANGE_SELECT, self.OnRangeSelect) 222 145 self.Bind(wx.grid.EVT_GRID_ROW_SIZE, self.OnRowSize) 223 146 self.Bind(wx.grid.EVT_GRID_COL_SIZE, self.OnColSize) 147 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnCellChange) 224 148 self.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.OnGridSelectCell) 225 # NOTE: the following bind to standard sheet methods that are226 # overriden in this subclassn - actually we have currently227 # disabled the on_context_menu that would override the OnRightClick228 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnCellChange)229 self.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnLeftClick)230 self.Bind(wx.grid.EVT_GRID_CELL_RIGHT_CLICK, self.OnRightClick)231 #self.Bind(wx.grid.EVT_GRID_CELL_LEFT_DCLICK, self.OnLeftDoubleClick)232 149 # This ends the __init__ section for CSheet. ########################## 233 234 235 236 # The following events must be bound even if CSheet is working237 # properly and does not need the above re-implementation of the238 # CSheet init method. Basically these override any intrinsic binding239 self.Bind(wx.grid.EVT_GRID_LABEL_RIGHT_CLICK, self.on_right_click)240 self.Bind(wx.grid.EVT_GRID_LABEL_LEFT_CLICK, self.on_left_click)241 150 242 151 self.AdjustScrollbars() … … 278 187 if self.GetNumberCols() > 0: 279 188 self.default_col_width = self.GetColSize(0) 280 # We have moved these to the top of the init section with the281 # rest of the grid event bindings from the sheet init when282 # appropriate283 189 #self.Bind(wx.grid.EVT_GRID_LABEL_LEFT_CLICK, self.on_left_click) 284 190 #self.Bind(wx.grid.EVT_GRID_LABEL_RIGHT_CLICK, self.on_right_click) … … 288 194 289 195 def OnLeftClick(self, event): 290 """291 Overrides sheet.CSheet.OnLefClick.292 293 Processes when a cell is selected by left clicking on that cell. First294 process the base Sheet method then the current class specific method295 """296 196 sheet.CSheet.OnLeftClick(self, event) 297 197 self.on_selected_cell(event) 298 299 300 def OnCellChange(self, event): 301 """ 302 Overrides sheet.CSheet.OnCellChange. 303 304 Processes when a cell has been edited by a cell editor. Checks for the 305 edited row being outside the max row to use attribute and if so updates 306 the last row. Then calls the base handler using skip. 198 199 def on_edit_cell(self, event): 200 """ 307 201 """ 308 202 row, _ = event.GetRow(), event.GetCol() … … 315 209 def on_selected_cell(self, event): 316 210 """ 317 Handler catching cell selection. 318 319 Called after calling base 'on left click' method. 320 """ 321 211 Handler catching cell selection 212 """ 322 213 flag = event.CmdDown() or event.ControlDown() 323 214 flag_shift = event.ShiftDown() … … 389 280 def on_left_click(self, event): 390 281 """ 391 Is triggered when the left mouse button is clicked while the mouse 392 is hovering over the column 'label.' 393 394 This processes the information on the selected column: the column name 395 (in row 0 of column) and the range of cells with a valid value to be 396 used by the GridPanel set_axis methods. 397 """ 398 282 Catch the left click on label mouse event 283 """ 399 284 flag = event.CmdDown() or event.ControlDown() 400 285 … … 439 324 def on_right_click(self, event): 440 325 """ 441 Is triggered when the right mouse button is clicked while the mouse 442 is hovering over the column 'label.' 443 444 This brings up a context menu that allows the deletion of the column, 445 or the insertion of a new column either to the right or left of the 446 current column. If inserting a new column can insert a blank column or 447 choose a number of hidden columns. By default all the error parameters 448 are in hidden columns so as to save space on the grid. Also any other 449 intrinsic variables stored with the data such as Temperature, pressure, 450 time etc can be used to populate this menu. 451 """ 452 326 Catch the right click mouse 327 """ 453 328 col = event.GetCol() 454 329 row = event.GetRow() … … 485 360 def insert_col_menu(self, menu, label, window): 486 361 """ 487 method called to populate the 'insert column before current column' 488 submenu. 489 """ 490 362 """ 491 363 if self.data is None: 492 364 return … … 508 380 def insert_after_col_menu(self, menu, label, window): 509 381 """ 510 Method called to populate the 'insert column after current column' 511 submenu 512 """ 513 382 """ 514 383 if self.data is None: 515 384 return … … 532 401 def on_remove_column(self, event=None): 533 402 """ 534 Called when user chooses remove from the column right click menu 535 Checks the columnn exists then calls the remove_column method 536 """ 537 403 """ 538 404 if self.selected_cols is not None or len(self.selected_cols) > 0: 539 405 col = self.selected_cols[0] … … 542 408 def remove_column(self, col, numCols=1): 543 409 """ 544 Remove the col column from the current grid 545 """ 546 410 Remove column to the current grid 411 """ 547 412 # add data to the grid 548 413 row = 0 … … 564 429 def on_insert_column(self, event): 565 430 """ 566 Called when user chooses insert 'column before' submenu 567 of the column context menu obtained when right clicking on a given 568 column header. 569 570 Sets up to insert column into the current grid before the current 571 highlighted column location and sets up what to populate that column 572 with. Then calls insert_column method to actually do the insertion. 573 """ 574 431 """ 575 432 if self.selected_cols is not None or len(self.selected_cols) > 0: 576 433 col = self.selected_cols[0] … … 585 442 def on_insert_after_column(self, event): 586 443 """ 587 Called when user chooses insert 'column after' submenu 588 of the column context menu obtained when right clicking on a given 589 column header. 590 591 Sets up to insert column into the current grid after the current 592 highlighted column location and sets up what to populate that column 593 with. Then calls insert_column method to actually do the insertion. 594 """ 595 444 Insert the given column after the highlighted column 445 """ 596 446 if self.selected_cols is not None or len(self.selected_cols) > 0: 597 447 col = self.selected_cols[0] + 1 … … 605 455 def insert_column(self, col, col_name): 606 456 """ 607 Insert column at position col with data[col_name] into the current 608 grid. 609 """ 610 457 """ 611 458 row = 0 612 459 self.InsertCols(pos=col, numCols=1, updateLabels=True) … … 630 477 def on_set_x_axis(self, event): 631 478 """ 632 Just calls the panel version of the method 633 """ 634 479 """ 635 480 self.panel.set_xaxis(x=self.axis_value, label=self.axis_label) 636 481 637 482 def on_set_y_axis(self, event): 638 483 """ 639 Just calls the panel version of the method 640 """ 641 484 """ 642 485 self.panel.set_yaxis(y=self.axis_value, label=self.axis_label) 643 486 … … 645 488 """ 646 489 Add data to the grid 647 648 490 :param data_inputs: data to use from the context menu of the grid 649 :param data_ouputs: default columns displayed 650 """ 651 491 :param data_ouputs: default columns deplayed 492 """ 652 493 self.file_name = file_name 653 494 self.details = details … … 686 527 Set the values in grids 687 528 """ 688 689 529 # add data to the grid 690 530 row = 0 … … 722 562 Return value contained in the grid 723 563 """ 724 725 564 grid_view = {} 726 565 for col in xrange(self.GetNumberCols()): … … 745 584 def onContextMenu(self, event): 746 585 """ 747 Method to handle cell right click context menu. 748 749 THIS METHOD IS NOT CURRENTLY USED. It is designed to provide a 750 cell pop up context by right clicking on a cell and gives the 751 option to cut, paste, and clear. This will probably be removed in 752 future versions and is being superceded by more traditional cut and 753 paste options. 754 """ 755 586 Default context menu 587 """ 756 588 wx_id = wx.NewId() 757 589 c_menu = wx.Menu() … … 788 620 def on_copy(self, event): 789 621 """ 790 Called when copy is chosen from cell right click context menu 791 792 THIS METHOD IS NOT CURRENTLY USED. it is part of right click cell 793 context menu which is being removed. This will probably be removed in 794 future versions and is being superceded by more traditional cut and 795 paste options 796 """ 797 622 On copy event from the contextmenu 623 """ 798 624 self.Copy() 799 625 800 626 def on_paste(self, event): 801 627 """ 802 Called when paste is chosen from cell right click context menu 803 804 THIS METHOD IS NOT CURRENTLY USED. it is part of right click cell 805 context menu which is being removed. This will probably be removed in 806 future versions and is being superceded by more traditional cut and 807 paste options 808 """ 809 628 On paste event from the contextmenu 629 """ 810 630 if self.data == None: 811 631 self.data = {} … … 816 636 def on_clear(self, event): 817 637 """ 818 Called when clear cell is chosen from cell right click context menu 819 820 THIS METHOD IS NOT CURRENTLY USED. it is part of right click cell 821 context menu which is being removed. This will probably be removed in 822 future versions and is being superceded by more traditional cut and 823 paste options 824 """ 825 638 Clear the cells selected 639 """ 826 640 self.Clear() 827 641 … … 832 646 ## Title to appear on top of the window 833 647 """ 834 835 648 window_caption = "Notebook " 836 649 … … 869 682 def enable_close_button(self): 870 683 """ 871 display the close button on the tab if more than 1 tab exits. 872 Otherwise remove the close button 873 """ 874 684 display the close button on tab for more than 1 tabs else remove the 685 close button 686 """ 875 687 if self.GetPageCount() <= 1: 876 688 style = self.GetWindowStyleFlag() … … 888 700 def on_edit_axis(self): 889 701 """ 890 Return the select cell range from a given selected column. Checks that 891 all cells are from the same column 892 """ 893 702 Return the select cell of a given selected column. Check that all cells 703 are from the same column 704 """ 894 705 pos = self.GetSelection() 895 706 grid = self.GetPage(pos) … … 921 732 Add highlight rows 922 733 """ 923 924 734 pos = self.GetSelection() 925 735 grid = self.GetPage(pos) … … 949 759 def get_column_labels(self): 950 760 """ 951 return dictionary of columns labels on the current page 952 """ 953 761 return dictionary of columns labels of the current page 762 """ 954 763 pos = self.GetSelection() 955 764 grid = self.GetPage(pos) … … 964 773 """ 965 774 Receive a list of cells and create a string presenting the selected 966 cells that can be used as data for one axis of a plot. 967 775 cells. 968 776 :param cell_list: list of tuple 777 969 778 """ 970 779 pos = self.GetSelection() … … 1044 853 close the page 1045 854 """ 1046 1047 855 if self.GetPageCount() == 1: 1048 856 event.Veto() … … 1050 858 1051 859 def set_data(self, data_inputs, data_outputs, details="", file_name=None): 1052 """1053 """1054 860 if data_outputs is None or data_outputs == {}: 1055 861 return … … 1074 880 def get_odered_results(self, inputs, outputs=None): 1075 881 """ 1076 Order a list of 'inputs.' Used to sort rows and columns to present 1077 in batch results grid. 1078 """ 1079 882 Get ordered the results 883 """ 1080 884 # Let's re-order the data from the keys in 'Data' name. 1081 885 if outputs == None: … … 1110 914 Append a new column to the grid 1111 915 """ 1112 1113 # I Believe this is no longer used now that we have removed the1114 # edit menu from the menubar - PDB July 12, 20151115 916 pos = self.GetSelection() 1116 917 grid = self.GetPage(pos) … … 1121 922 Remove the selected column from the grid 1122 923 """ 1123 # I Believe this is no longer used now that we have removed the1124 # edit menu from the menubar - PDB July 12, 20151125 924 pos = self.GetSelection() 1126 925 grid = self.GetPage(pos) … … 1128 927 1129 928 class GridPanel(SPanel): 1130 """1131 A ScrolledPanel class that contains the grid sheet as well as a number of1132 widgets to create interesting plots and buttons for help etc.1133 """1134 1135 929 def __init__(self, parent, data_inputs=None, 1136 930 data_outputs=None, *args, **kwds): 1137 """1138 Initialize the GridPanel1139 """1140 1141 931 SPanel.__init__(self, parent, *args, **kwds) 1142 932 … … 1200 990 def get_plot_axis(self, col, list): 1201 991 """ 992 1202 993 """ 1203 994 axis = [] … … 1224 1015 def on_view(self, event): 1225 1016 """ 1226 Get object represented by the given cells and plot them. Basically 1227 plot the colum in y vs the column in x. 1228 """ 1229 1017 Get object represented buy the given cell and plot them. 1018 """ 1230 1019 pos = self.notebook.GetSelection() 1231 1020 grid = self.notebook.GetPage(pos) … … 1307 1096 Evaluate the contains of textcrtl and plot result 1308 1097 """ 1309 1310 1098 pos = self.notebook.GetSelection() 1311 1099 grid = self.notebook.GetPage(pos) … … 1415 1203 running "file:///...." 1416 1204 1417 :param evt: Triggers on clicking the help button 1418 """ 1419 1205 :param evt: Triggers on clicking the help button 1206 """ 1420 1207 #import documentation window here to avoid circular imports 1421 1208 #if put at top of file with rest of imports. … … 1431 1218 Get sentence from dict 1432 1219 """ 1433 1434 1220 for tok, (col_name, list) in dict.iteritems(): 1435 1221 col = column_names[col_name] … … 1444 1230 def layout_grid(self): 1445 1231 """ 1446 Draw the area related to the grid by adding it as the first element 1447 in the panel's grid_sizer 1448 """ 1449 1232 Draw the area related to the grid 1233 """ 1450 1234 self.notebook = Notebook(parent=self) 1451 1235 self.notebook.set_data(self._data_inputs, self._data_outputs) … … 1454 1238 def layout_plotting_area(self): 1455 1239 """ 1456 Add the area containing all the plot options, buttons etc to a plotting 1457 area sizer to later be added to the top level grid_sizer 1458 """ 1459 1240 Draw area containing options to plot 1241 """ 1460 1242 view_description = wx.StaticBox(self, -1, 'Plot Fits/Residuals') 1461 1243 note = "To plot the fits (or residuals), click the 'View Fits' button" … … 1499 1281 (self.plot_button, 0, 1500 1282 wx.LEFT | wx.TOP | wx.BOTTOM, 12), 1501 (self.help_button,0, 1283 (self.help_button,0, 1502 1284 wx.LEFT | wx.TOP | wx.BOTTOM, 12)]) 1503 1285 … … 1534 1316 Get the selected column on the visible grid and set values for axis 1535 1317 """ 1536 1537 1318 try: 1538 1319 cell_list = self.notebook.on_edit_axis() … … 1554 1335 Receive a list of cells and create a string presenting the selected 1555 1336 cells. 1556 1557 1337 :param cell_list: list of tuple 1558 """ 1559 1338 1339 """ 1560 1340 if self.notebook is not None: 1561 1341 return self.notebook.create_axis_label(cell_list) … … 1565 1345 get controls to modify 1566 1346 """ 1567 1568 1347 if label != None: 1569 1348 tcrtl_label.SetValue(str(label)) … … 1574 1353 """ 1575 1354 """ 1576 # I Believe this is no longer used now that we have removed the1577 # edit menu from the menubar - PDB July 12, 20151578 1355 if self.notebook is not None: 1579 1356 self.notebook.add_column() … … 1582 1359 """ 1583 1360 """ 1584 # I Believe this is no longer used now that we have removed the1585 # edit menu from the menubar - PDB July 12, 20151586 1361 if self.notebook is not None: 1587 1362 self.notebook.on_remove_column() … … 1589 1364 1590 1365 class GridFrame(wx.Frame): 1591 """1592 The main wx.Frame for the batch results grid1593 """1594 1595 1366 def __init__(self, parent=None, data_inputs=None, data_outputs=None, id=-1, 1596 title="Batch Fitting Results Panel", size=(800, 500)): 1597 """ 1598 Initialize the Frame 1599 """ 1600 1367 title="Grid Window", size=(800, 500)): 1601 1368 wx.Frame.__init__(self, parent=parent, id=id, title=title, size=size) 1602 1369 self.parent = parent … … 1622 1389 wx.EVT_MENU(self, self.save_menu.GetId(), self.on_save_page) 1623 1390 1624 # We need to grab a WxMenu handle here, otherwise the next one to grab 1625 # the handle will be treated as the Edit Menu handle when checking in 1626 # on_menu_open event handler and thus raise an exception when it hits an 1627 # unitialized object. Alternative is to comment out that whole section 1628 # in on_menu_open, but that would make it more difficult to undo the 1629 # hidding of the menu. PDB July 12, 2015. 1630 # 1631 # To enable the Edit menubar comment out next line and uncomment the 1632 # following line. 1633 self.edit = wx.Menu() 1634 #self.add_edit_menu() 1635 1391 # To add the edit menu, call add_edit_menu() here. 1392 self.edit = None 1636 1393 self.Bind(wx.EVT_MENU_OPEN, self.on_menu_open) 1394 1637 1395 self.Bind(wx.EVT_CLOSE, self.on_close) 1638 1396 1639 1397 def add_edit_menu(self, menubar): 1640 """1641 populates the edit menu on the menubar. Not activated as of SasView1642 3.1.01643 """1644 1398 self.edit = wx.Menu() 1645 1399 … … 1675 1429 def on_copy(self, event): 1676 1430 """ 1677 On Copy from the Edit menu item on the menubar 1678 """ 1679 # I Believe this is no longer used now that we have removed the 1680 # edit menu from the menubar - PDB July 12, 2015 1431 On Copy 1432 """ 1681 1433 if event != None: 1682 1434 event.Skip() … … 1687 1439 def on_paste(self, event): 1688 1440 """ 1689 On Paste from the Edit menu item on the menubar 1690 """ 1691 # I Believe this is no longer used now that we have removed the 1692 # edit menu from the menubar - PDB July 12, 2015 1441 On Paste 1442 """ 1693 1443 if event != None: 1694 1444 event.Skip() … … 1699 1449 def on_clear(self, event): 1700 1450 """ 1701 On Clear from the Edit menu item on the menubar 1702 """ 1703 # I Believe this is no longer used now that we have removed the 1704 # edit menu from the menubar - PDB July 12, 2015 1451 On Clear 1452 """ 1705 1453 pos = self.panel.notebook.GetSelection() 1706 1454 grid = self.panel.notebook.GetPage(pos) … … 1718 1466 def on_remove_column(self, event): 1719 1467 """ 1720 On remove column from the Edit menu Item on the menubar 1721 """ 1722 # I Believe this is no longer used now that we have removed the 1723 # edit menu from the menubar - PDB July 12, 2015 1468 On remove column 1469 """ 1724 1470 pos = self.panel.notebook.GetSelection() 1725 1471 grid = self.panel.notebook.GetPage(pos) … … 1789 1535 def on_save_page(self, event): 1790 1536 """ 1791 Saves data in grid to a csv file. 1792 1793 At this time only the columns displayed get saved. Thus any error 1794 bars not inserted before saving will not be saved in the file 1795 """ 1796 1537 """ 1797 1538 if self.parent is not None: 1798 1539 pos = self.panel.notebook.GetSelection() … … 1825 1566 def on_open(self, event): 1826 1567 """ 1827 Open file containing batch result 1828 """ 1829 1568 Open file containg batch result 1569 """ 1830 1570 if self.parent is not None: 1831 1571 self.parent.on_read_batch_tofile(self) … … 1835 1575 open excel and display batch result in Excel 1836 1576 """ 1837 1838 1577 if self.parent is not None: 1839 1578 pos = self.panel.notebook.GetSelection() … … 1886 1625 details="", *args, **kwds): 1887 1626 """ 1888 Initialize dialog1889 1890 1627 :param parent: Window instantiating this dialog 1891 :param result: result to display in a grid or export to an external \1628 :param result: result to display in a grid or export to an external 1892 1629 application. 1893 1630 """ 1894 1895 1631 #kwds['style'] = wx.CAPTION|wx.SYSTEM_MENU 1896 1632 wx.Frame.__init__(self, parent, *args, **kwds) … … 1915 1651 Draw the content of the current dialog window 1916 1652 """ 1917 1918 1653 vbox = wx.BoxSizer(wx.VERTICAL) 1919 1654 box_description = wx.StaticBox(self.panel, -1, str("Batch Outputs")) … … 1969 1704 Get the user selection and display output to the selected application 1970 1705 """ 1971 1972 1706 if self.flag == 1: 1973 1707 self.parent.open_with_localapp(data_inputs=self.data_inputs, … … 1981 1715 close the Window 1982 1716 """ 1983 1984 1717 self.Close() 1985 1718 … … 1988 1721 Receive event and display data into third party application 1989 1722 or save data to file. 1723 1990 1724 """ 1991 1725 if self.save_to_file.GetValue(): -
src/sas/guiframe/documentation_window.py
rfb3f9af r7a508b6 43 43 (self, parent, dummy_id, path, url_instruction, title, size=(850, 540)) 44 44 45 :param path: path to html file beginning AFTER /doc/ and ending in the \46 file.html .47 :param url_instructions: anchor string or other query e.g. '#MyAnchor '48 :param title :text to place in the title bar of the help panel45 :param path: path to html file beginning AFTER /doc/ and ending in the 46 file.html 47 :param url_instructions: anchor string or other query e.g. '#MyAnchor 48 :param title - text to place in the title bar of the help panel 49 49 """ 50 50 def __init__(self, parent, dummy_id, path, url_instruction, title, size=(850, 540)): -
src/sas/guiframe/gui_manager.py
r957af0d r78f75d02 27 27 import urllib 28 28 import urllib2 29 import json 29 30 30 31 31 from sas.guiframe.events import EVT_CATEGORY … … 46 46 from sas.guiframe.CategoryManager import CategoryManager 47 47 from sas.dataloader.loader import Loader 48 from sas.guiframe.proxy import Connection49 48 from matplotlib import _pylab_helpers 50 51 49 52 50 def get_app_dir(): … … 54 52 The application directory is the one where the default custom_config.py 55 53 file resides. 56 57 :returns: app_path - the path to the applicatin directory58 54 """ 59 55 # First, try the directory of the executable we are running … … 72 68 73 69 # Finally, try the directory of the sasview module 74 # 70 #TODO: gui_manager will have to know about sasview until we 75 71 # clean all these module variables and put them into a config class 76 72 # that can be passed by sasview.py. … … 834 830 def PushStatusText(self, *args, **kwds): 835 831 """ 836 .. todo:: No message is passed. What is this supposed to do?832 FIXME: No message is passed. What is this supposed to do? 837 833 """ 838 834 field = self.sb.get_msg_position() 839 835 wx.Frame.PushStatusText(self, field=field, 840 string="FIXME -PushStatusText called without text")836 string="FIXME: PushStatusText called without text") 841 837 842 838 def add_perspective(self, plugin): … … 894 890 :param dir: directory in which to look for plug-ins 895 891 896 :return s: list of plug-ins892 :return: list of plug-ins 897 893 898 894 """ … … 941 937 file.close() 942 938 except: 943 # Should raise and catch at a higher level and 939 # Should raise and catch at a higher level and 944 940 # display error on status bar 945 941 logging.error(sys.exc_value) … … 988 984 989 985 # Set up welcome panel 990 # 986 #TODO: this needs serious simplification 991 987 if self.welcome_panel_class is not None: 992 988 welcome_panel = MDIFrame(self, None, 'None', (100, 200)) … … 1078 1074 def onfreeze(self, theory_id): 1079 1075 """ 1080 Saves theory/model and passes to data loader.1081 1082 ..warning:: This seems to be the exact same code as the next1083 function called simply freeze. This probably needs fixing1084 1076 """ 1085 1077 data_state_list = self._data_manager.freeze(theory_id) … … 1093 1085 def freeze(self, data_id, theory_id): 1094 1086 """ 1095 Saves theory/model and passes to data loader.1096 1097 ..warning:: This seems to be the exact same code as the next1098 function called simply freeze. This probably needs fixing1099 1087 """ 1100 1088 data_state_list = self._data_manager.freeze_theory(data_id=data_id, … … 1161 1149 :param p: panel object to add to the AUI manager 1162 1150 1163 :return s: ID of the event associated with the new panel [int]1151 :return: ID of the event associated with the new panel [int] 1164 1152 1165 1153 """ … … 1182 1170 # Append nummber 1183 1171 captions = self._get_plotpanel_captions() 1184 # FIXME: Fix this awful loop1172 #FIXME: Fix this aweful loop 1185 1173 while (1): 1186 1174 caption = windowcaption + '%s' % str(self.graph_num) … … 2043 2031 a call-back method when the current version number has been obtained. 2044 2032 """ 2045 version_info = {"version": "0.0.0"} 2046 c = Connection(config.__update_URL__, config.UPDATE_TIMEOUT) 2047 response = c.connect() 2048 if response is not None: 2049 try: 2050 # 2051 content = response.read().strip() 2052 logging.info("Connected to www.sasview.org. Latest version: %s" 2053 % (content)) 2054 version_info = json.loads(content) 2055 except: 2056 logging.info("Failed to connect to www.sasview.org") 2057 self._process_version(version_info, standalone=event == None) 2058 2059 2060 2061 # 2062 # try: 2063 # req = urllib2.Request(config.__update_URL__) 2064 # res = urllib2.urlopen(req) 2065 # content = res.read().strip() 2066 # logging.info("Connected to www.sasview.org. Latest version: %s" 2067 # % (content)) 2068 # version_info = json.loads(content) 2069 # except: 2070 # logging.info("Failed to connect to www.sasview.org") 2071 # version_info = {"version": "0.0.0"} 2072 # self._process_version(version_info, standalone=event == None) 2073 2074 def _process_version(self, version_info, standalone=True): 2033 try: 2034 req = urllib2.Request('https://github.com/SasView/sasview/releases/latest') 2035 res = urllib2.urlopen(req) 2036 get_url= res.geturl() 2037 content = get_url.partition('/v')[2] 2038 logging.info("connected to GitHub. sasview.latestversion = %s" 2039 % (content)) 2040 except: 2041 msg = traceback.format_exc() 2042 logging.info(msg) 2043 logging.info("failed to connect to GitHub") 2044 content = "0.0.0" 2045 2046 version = content.strip() 2047 logging.info("Latest SasView version number: %s" % (version)) 2048 if len(re.findall('\d+\.\d+\.\d+$', version)) < 0: 2049 content = "0.0.0" 2050 self._process_version(content, standalone=event == None) 2051 2052 def _process_version(self, version, standalone=True): 2075 2053 """ 2076 2054 Call-back method for the process of checking for updates. … … 2085 2063 """ 2086 2064 try: 2087 version = version_info["version"]2088 2065 if version == "0.0.0": 2089 2066 msg = "Could not connect to the application server." … … 2094 2071 if not standalone: 2095 2072 import webbrowser 2096 if "download_url" in version_info: 2097 webbrowser.open(version_info["download_url"]) 2098 else: 2099 webbrowser.open(config.__download_page__) 2073 webbrowser.open(config.__download_page__) 2100 2074 else: 2101 2075 msg += "See the help menu to download it." … … 2461 2435 """ 2462 2436 Save file as txt 2463 2464 .. todo:: Refactor and remove this method. See 'TODO' in _onSave. 2437 :TODO: Refactor and remove this method. See TODO in _onSave. 2465 2438 """ 2466 2439 if not path == None: … … 2890 2863 # Append nummber 2891 2864 inc = 1 2892 # 2865 #FIXME: fix this terrible loop 2893 2866 while (1): 2894 2867 caption = new_caption + '_%s' % str(inc) … … 2913 2886 2914 2887 :param name: window_name in AuiPaneInfo 2915 :return s: AuiPaneInfo of the name2888 :return: AuiPaneInfo of the name 2916 2889 """ 2917 2890 for panel in self.plot_panels.values(): … … 3085 3058 pass 3086 3059 3087 # Draw all panels 3060 # Draw all panels 3088 3061 if count == 1: 3089 3062 f_draw(self.schedule_full_draw_list[0]) 3090 3063 else: 3091 3064 map(f_draw, self.schedule_full_draw_list) 3092 # Reset the attr 3065 # Reset the attr 3093 3066 if len(self.schedule_full_draw_list) == 0: 3094 3067 self.set_schedule(False) … … 3131 3104 Get window size 3132 3105 3133 :returns: size 3134 :rtype: tuple 3106 :return size: tuple 3135 3107 """ 3136 3108 width, height = self.GetSizeTuple() … … 3153 3125 pass 3154 3126 3155 # restart idle 3127 # restart idle 3156 3128 self._redraw_idle(*args, **kwargs) 3157 3129 … … 3161 3133 Restart Idle 3162 3134 """ 3163 # restart idle 3135 # restart idle 3164 3136 self.idletimer.Restart(100 * TIME_FACTOR, *args, **kwargs) 3165 3137 … … 3318 3290 """ 3319 3291 is_maximized = False 3320 # Get size of screen without 3292 # Get size of screen without 3321 3293 for screenCount in range(wx.Display().GetCount()): 3322 3294 screen = wx.Display(screenCount) … … 3335 3307 customHeight = displayHeight * 0.9 3336 3308 else: 3337 # If the custom screen is bigger than the 3309 # If the custom screen is bigger than the 3338 3310 # window screen than make maximum size 3339 3311 if customWidth > displayWidth: … … 3433 3405 def show_data_panel(self, action): 3434 3406 """ 3435 Turns on the data panel3436 3437 The the data panel is optional. Most of its functions can be3438 performed from the menu bar and from the plots.3439 3407 """ 3440 3408 self.parent.show_data_panel(action) -
src/sas/guiframe/local_perspectives/plotting/Plotter1D.py
r098f3d2 rb99a4552 564 564 self._slicerpop.Append(wx_id, '&Print Image', 'Print image ') 565 565 wx.EVT_MENU(self, wx_id, self.onPrint) 566 wx_id = wx.NewId() 567 self._slicerpop.Append(wx_id, '&Print Preview', 'Print preview') 568 wx.EVT_MENU(self, wx_id, self.onPrinterPreview) 566 569 567 570 wx_id = wx.NewId() -
src/sas/guiframe/local_perspectives/plotting/Plotter2D.py
r098f3d2 rc039589 300 300 301 301 wx_id = wx.NewId() 302 slicerpop.Append(wx_id, '&Print Preview', 'Print preview') 303 wx.EVT_MENU(self, wx_id, self.onPrinterPreview) 304 305 wx_id = wx.NewId() 302 306 slicerpop.Append(wx_id, '&Copy to Clipboard', 'Copy to the clipboard') 303 307 wx.EVT_MENU(self, wx_id, self.OnCopyFigureMenu) -
src/sas/guiframe/local_perspectives/plotting/SimplePlot.py
r098f3d2 rb40ad40 58 58 slicerpop.Append(wx_id, '&Print Image', 'Print image') 59 59 wx.EVT_MENU(self, wx_id, self.onPrint) 60 61 wx_id = wx.NewId() 62 slicerpop.Append(wx_id, '&Print Preview', 'Print preview') 63 wx.EVT_MENU(self, wx_id, self.onPrinterPreview) 60 64 61 65 wx_id = wx.NewId() … … 230 234 wx.EVT_MENU(self, id, self.on_print_image) 231 235 236 id = wx.NewId() 237 item = wx.MenuItem(menu, id, "&Print Preview") 238 item.SetBitmap(preview_bmp) 239 menu.AppendItem(item) 240 wx.EVT_MENU(self, id, self.on_print_preview) 241 232 242 menu.AppendSeparator() 233 243 id = wx.NewId() -
src/sas/guiframe/report_dialog.py
r098f3d2 re8bb5b6 66 66 hbox.Add(button_close) 67 67 button_close.SetFocus() 68 69 button_preview = wx.Button(self, wx.NewId(), "Preview") 70 button_preview.SetToolTipString("Print preview this report.") 71 button_preview.Bind(wx.EVT_BUTTON, self.onPreview, 72 id=button_preview.GetId()) 73 hbox.Add(button_preview) 68 74 69 75 button_print = wx.Button(self, wx.NewId(), "Print") -
src/sas/models/CoreMultiShellModel.py
re0c16ce rac7be54 53 53 ## parameters with orientation: can be removed since there is no orientational params 54 54 self._set_orientation_params() 55 55 56 56 57 def _clone(self, obj): 57 58 """ … … 66 67 67 68 return obj 68 69 70 69 71 def _set_dispersion(self): 70 72 """ 71 73 model dispersions 72 74 Polydispersion should not be applied to s_model 73 """ 74 ##set dispersion from model 75 """ 76 ##set dispersion from model 75 77 for name , value in self.model.dispersion.iteritems(): 76 78 nshell = 0 … … 80 82 if name.split('_')[-1] == 'shell%s' % str(nshell): 81 83 self.dispersion[name] = value 82 else: 84 else: 83 85 continue 84 86 else: 85 87 self.dispersion[name] = value 86 88 87 89 def _set_orientation_params(self): 88 90 """ 89 91 model orientation and magnetic parameters, same params for this model 90 """ 92 """ 91 93 ##set dispersion from model 92 94 for param in self.model.orientation_params: … … 102 104 self.orientation_params.append(param) 103 105 self.magnetic_params.append(param) 104 continue 106 continue 105 107 106 108 def _set_params(self): 107 109 """ 108 110 Concatenate the parameters of the model to create 109 this model parameters 111 this model parameters 110 112 """ 111 113 # rearrange the parameters for the given # of shells … … 126 128 else: 127 129 self.params[name]= value 128 130 129 131 # set constrained values for the original model params 130 self._set_xtra_model_param() 131 132 self._set_xtra_model_param() 133 132 134 def _set_details(self): 133 135 """ 134 136 Concatenate details of the original model to create 135 this model details 137 this model details 136 138 """ 137 139 for name ,detail in self.model.details.iteritems(): 138 140 if name in self.params.iterkeys(): 139 141 self.details[name]= detail 140 141 142 143 142 144 def _set_xtra_model_param(self): 143 145 """ … … 161 163 self.model.setParam(key, 0.0) 162 164 except: pass 163 165 164 166 165 167 def getProfile(self): 166 168 """ 167 Get SLD profile 168 **Note:** This works only for func_shell num = 2.169 170 :return: (r, beta) where r is a list of radius of the transition points\171 and beta is a list of the corresponding SLD values.169 Get SLD profile 170 171 : return: (r, beta) where r is a list of radius of the transition points 172 beta is a list of the corresponding SLD values 173 : Note: This works only for func_shell num = 2. 172 174 """ 173 175 r = [] … … 179 181 r.append(self.params['rad_core0']) 180 182 beta.append(self.params['sld_core0']) 181 183 182 184 # for shells 183 185 for n in range(1, self.n_shells+1): 184 186 # Left side of each shells 185 r0 = r[len(r)-1] 187 r0 = r[len(r)-1] 186 188 r.append(r0) 187 189 exec "beta.append(self.params['sld_shell%s'% str(n)])" … … 191 193 r.append(r0) 192 194 exec "beta.append(self.params['sld_shell%s'% str(n)])" 193 195 194 196 # for solvent 195 197 r0 = r[len(r)-1] … … 199 201 r.append(r_solv) 200 202 beta.append(self.params['sld_solv']) 201 203 202 204 return r, beta 203 205 204 206 def setParam(self, name, value): 205 """ 207 """ 206 208 Set the value of a model parameter 207 208 : param name: name of the parameter209 : param value: value of the parameter209 210 : param name: name of the parameter 211 : param value: value of the parameter 210 212 """ 211 213 # set param to new model 212 214 self._setParamHelper( name, value) 213 ## setParam to model 215 ## setParam to model 214 216 if name == 'sld_solv': 215 217 # the sld_*** model.params not in params must set to value of sld_solv … … 241 243 self.params[item] = value 242 244 return 245 243 246 #raise ValueError, "Model does not contain parameter %s" % name 244 245 247 248 246 249 def _set_fixed_params(self): 247 250 """ … … 249 252 """ 250 253 for item in self.model.fixed: 251 if item.split('.')[0] in self.params.keys(): 254 if item.split('.')[0] in self.params.keys(): 252 255 self.fixed.append(item) 253 256 254 257 self.fixed.sort() 255 258 256 259 def run(self, x = 0.0): 257 """ 260 """ 258 261 Evaluate the model 259 260 : param x: input q-value (float or [float, float] as [r, theta])261 : return: (DAB value)262 263 : param x: input q-value (float or [float, float] as [r, theta]) 264 : return: (DAB value) 262 265 """ 263 266 # set effective radius and scaling factor before run … … 266 269 267 270 def runXY(self, x = 0.0): 268 """ 271 """ 269 272 Evaluate the model 270 271 : param x: input q-value (float or [float, float] as [qx, qy])272 : return: DAB value273 274 : param x: input q-value (float or [float, float] as [qx, qy]) 275 : return: DAB value 273 276 """ 274 277 # set effective radius and scaling factor before run 275 278 276 279 return self.model.runXY(x) 277 280 278 281 ## Now (May27,10) directly uses the model eval function 279 282 ## instead of the for-loop in Base Component. 280 283 def evalDistribution(self, x = []): 281 """ 284 """ 282 285 Evaluate the model in cartesian coordinates 283 284 : param x: input q[], or [qx[], qy[]]285 : return: scattering function P(q[])286 287 : param x: input q[], or [qx[], qy[]] 288 : return: scattering function P(q[]) 286 289 """ 287 290 # set effective radius and scaling factor before run 288 291 return self.model.evalDistribution(x) 289 292 290 293 def calculate_ER(self): 291 """ 294 """ 292 295 Calculate the effective radius for P(q)*S(q) 293 296 294 297 :return: the value of the effective radius 295 """ 298 299 """ 296 300 return self.model.calculate_ER() 297 301 298 302 def calculate_VR(self): 299 """ 303 """ 300 304 Calculate the volf ratio for P(q)*S(q) 301 305 302 306 :return: the value of the volf ratio 303 """ 307 308 """ 304 309 return self.model.calculate_VR() 305 310 306 311 def set_dispersion(self, parameter, dispersion): 307 312 """ 308 313 Set the dispersion object for a model parameter 309 310 : param parameter: name of the parameter [string]311 : paramdispersion: dispersion object of type DispersionModel314 315 : param parameter: name of the parameter [string] 316 :dispersion: dispersion object of type DispersionModel 312 317 """ 313 318 value = None … … 318 323 return value 319 324 except: 320 raise 325 raise -
src/sas/models/MultiplicationModel.py
rfb3f9af rac7be54 10 10 which will be calculated from P(Q) via calculate_ER(), 11 11 and 2) 'scale' in P model which is synchronized w/ volfraction in S 12 then P*S is multiplied by a new param eter, 'scale_factor'.12 then P*S is multiplied by a new param, 'scale_factor'. 13 13 The polydispersion is applicable only to P(Q), not to S(Q). 14 15 .. note:: P(Q) refers to 'form factor' model while S(Q) does to 'structure factor'. 14 Note: P(Q) refers to 'form factor' model while S(Q) does to 'structure factor'. 16 15 """ 17 16 def __init__(self, p_model, s_model ): … … 82 81 def _clone(self, obj): 83 82 """ 84 Internal utility function to copy the internal data members to a85 fresh copy.83 Internal utility function to copy the internal 84 data members to a fresh copy. 86 85 """ 87 86 obj.params = copy.deepcopy(self.params) … … 97 96 def _set_dispersion(self): 98 97 """ 99 combine the two models' dispersions. Polydispersity should not be100 applied to s_model98 combined the two models dispersions 99 Polydispersion should not be applied to s_model 101 100 """ 102 101 ##set dispersion only from p_model … … 108 107 Get SLD profile of p_model if exists 109 108 110 :return: (r, beta) where r is a list of radius of the transition points\ 111 beta is a list of the corresponding SLD values 112 113 .. note:: This works only for func_shell num = 2 (exp function). 109 : return: (r, beta) where r is a list of radius of the transition points 110 beta is a list of the corresponding SLD values 111 : Note: This works only for func_shell num = 2 (exp function). 114 112 """ 115 113 try: … … 123 121 def _set_params(self): 124 122 """ 125 Concatenate the parameters of the two models to create126 thesemodel parameters123 Concatenate the parameters of the two models to create 124 this model parameters 127 125 """ 128 126 … … 143 141 def _set_details(self): 144 142 """ 145 Concatenate details of the two models to create146 this model'sdetails143 Concatenate details of the two models to create 144 this model details 147 145 """ 148 146 for name, detail in self.p_model.details.iteritems(): … … 156 154 def _set_scale_factor(self): 157 155 """ 158 Set scale=volfraction forP model156 Set scale=volfraction to P model 159 157 """ 160 158 value = self.params['volfraction'] … … 170 168 def _set_effect_radius(self): 171 169 """ 172 Set effective radius to S(Q) model170 Set effective radius to S(Q) model 173 171 """ 174 172 if not 'effect_radius' in self.s_model.params.keys(): … … 208 206 def _setParamHelper(self, name, value): 209 207 """ 210 Helper function to setparam208 Helper function to setparam 211 209 """ 212 210 # Look for dispersion parameters … … 231 229 def _set_fixed_params(self): 232 230 """ 233 Fill the self.fixed list with the p_model fixed list231 fill the self.fixed list with the p_model fixed list 234 232 """ 235 233 for item in self.p_model.fixed: … … 242 240 """ 243 241 Evaluate the model 244 245 242 :param x: input q-value (float or [float, float] as [r, theta]) 246 243 :return: (scattering function value) … … 253 250 254 251 def runXY(self, x = 0.0): 255 """ 256 Evaluate the model 257 258 :param x: input q-value (float or [float, float] as [qx, qy]) 259 :return: scattering function value 252 """ Evaluate the model 253 @param x: input q-value (float or [float, float] as [qx, qy]) 254 @return: scattering function value 260 255 """ 261 256 # set effective radius and scaling factor before run … … 271 266 """ 272 267 Evaluate the model in cartesian coordinates 273 274 268 :param x: input q[], or [qx[], qy[]] 275 269 :return: scattering function P(q[]) … … 285 279 """ 286 280 Set the dispersion object for a model parameter 287 288 281 :param parameter: name of the parameter [string] 289 282 :dispersion: dispersion object of type DispersionModel … … 300 293 def fill_description(self, p_model, s_model): 301 294 """ 302 Fill the description for P(Q)*S(Q)295 Fill the description for P(Q)*S(Q) 303 296 """ 304 297 description = "" -
src/sas/models/c_extension/c_models/GelFit.cpp
r1d115ef r79492222 34 34 radius = Parameter(104.0,true); 35 35 radius.set_min(2.0); 36 FractalExp= Parameter(2.0,true);36 scale = Parameter(2.0,true); 37 37 background = Parameter(0.01); 38 38 } … … 43 43 dp[0] = zeta(); 44 44 dp[1] = radius(); 45 dp[2] = FractalExp();45 dp[2] = scale(); 46 46 47 47 if (dp[2] <= 0) -
src/sas/models/c_extension/python_wrapper/WrapperGenerator.py
r1f5f206 r13e46abe 560 560 def replaceToken(self, line, key, value): #pylint: disable-msg=R0201 561 561 """ Replace a token in the template file 562 :param line: line of text to inspect563 :param key: token to look for564 :param value: string value to replace the token with565 :return: new string value562 @param line: line of text to inspect 563 @param key: token to look for 564 @param value: string value to replace the token with 565 @return: new string value 566 566 """ 567 _str_value = str(value)568 _new_value = _str_value.replace('\\','/')569 567 lenkey = len(key) 570 568 newline = line … … 572 570 while newline.count(key) > 0: 573 571 index = newline.index(key) 574 newline = newline[:index] + _new_value + newline[index + lenkey:]572 newline = newline[:index] + value + newline[index + lenkey:] 575 573 576 574 return newline -
src/sas/models/c_extension/python_wrapper/modelTemplate.txt
r1f5f206 rc93122e 17 17 18 18 .. WARNING:: 19 19 20 THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY 20 21 DO NOT MODIFY THIS FILE, MODIFY … … 29 30 def create_[PYTHONCLASS](): 30 31 """ 31 Create a model instance32 Create a model instance 32 33 """ 33 34 obj = [PYTHONCLASS]() … … 99 100 """ 100 101 Evaluate the model 101 102 102 :param x: input q, or [q,phi] 103 103 :return: scattering function P(q) … … 108 108 """ 109 109 Evaluate the model in cartesian coordinates 110 111 110 :param x: input q, or [qx, qy] 112 111 :return: scattering function P(q) … … 117 116 """ 118 117 Evaluate the model in cartesian coordinates 119 120 118 :param x: input q[], or [qx[], qy[]] 121 119 :return: scattering function P(q[]) … … 126 124 """ 127 125 Calculate the effective radius for P(q)*S(q) 128 129 126 :return: the value of the effective radius 130 127 """ … … 134 131 """ 135 132 Calculate the volf ratio for P(q)*S(q) 136 137 133 :return: the value of the volf ratio 138 134 """ … … 142 138 """ 143 139 Set the dispersion object for a model parameter 144 145 140 :param parameter: name of the parameter [string] 146 141 :param dispersion: dispersion object of type DispersionModel -
src/sas/models/include/GelFit.h
r1d115ef r79492222 33 33 Parameter radius; 34 34 35 // [DEFAULT]= FractalExp= 236 Parameter FractalExp;35 // [DEFAULT]=scale= 2 36 Parameter scale; 37 37 38 38 // [DEFAULT]=background= 0.01 -
src/sas/models/include/dabmodel.h
rf008ee2 r79492222 17 17 // [PYTHONCLASS] = DABModel 18 18 // [DISP_PARAMS] = length, scale, background 19 // [DESCRIPTION] = <text>DAB (Debye Anderson Brumberger) Model 20 // F(x) = scale * L^3/( 1 + (q*L)^2 )^2 + background 21 // L: the correlation length 19 // [DESCRIPTION] = <text>Provide F(x) = scale/( 1 + (x*L)^2 )^(2) + background 20 // DAB (Debye Anderson Brumberger) function as a BaseComponent model 22 21 // </text> 23 22 // [FIXED] = -
src/sas/models/sas_extension/__init__.py
rfb3f9af r79492222 1 """2 This is an empty package - should probably delete3 """ -
src/sas/perspectives/fitting/fitpage.py
r098f3d2 rd06c34c 2218 2218 """ 2219 2219 # compute weight for the current data 2220 from sas.perspectives.fitting.utils import get_weight 2220 2221 flag_weight = self.get_weight_flag() 2221 2222 if is_2D == None: 2222 2223 is_2D = self._is_2D() 2224 weight = get_weight(data=self.data, 2225 is2d=is_2D, 2226 flag=flag_weight) 2223 2227 self._manager.set_fit_weight(uid=self.uid, 2224 2228 flag=flag_weight, … … 2238 2242 self._update_paramv_on_fit() 2239 2243 2244 # msg default 2245 msg = None 2240 2246 if event != None: 2241 2247 tcrtl = event.GetEventObject() … … 2251 2257 # if any value is changed 2252 2258 if is_new_pinhole: 2253 self._set_pinhole_smear()2259 msg = self._set_pinhole_smear() 2254 2260 # hide all silt sizer 2255 2261 self._hide_all_smear_info() -
src/sas/perspectives/fitting/fitting.py
r098f3d2 rf21d496 539 539 self.add_fit_page(data=[data]) 540 540 except: 541 msg = "Fitting set_data: " + str(sys.exc_value)541 msg = "Fitting Set_data: " + str(sys.exc_value) 542 542 wx.PostEvent(self.parent, StatusEvent(status=msg, info="error")) 543 543 … … 670 670 :param weight: current dy data 671 671 """ 672 # If we are not dealing with a specific fit problem, then673 # there is no point setting the weights.674 if fid is None:675 return676 672 if uid in self.page_finder.keys(): 677 673 self.page_finder[uid].set_weight(flag=flag, is2d=is2d) -
src/sas/perspectives/fitting/resultpanel.py
r9df6a03 r2f4b430 9 9 import wx.lib.newevent 10 10 from wx.aui import AuiNotebook as Notebook 11 12 from bumps.gui.convergence_view import ConvergenceView13 from bumps.gui.uncertainty_view import UncertaintyView, CorrelationView, TraceView14 from bumps.dream.stats import var_stats, format_vars15 11 16 12 from sas.guiframe.panel_base import PanelBase … … 59 55 result = event.result[0][0] 60 56 if hasattr(result, 'convergence'): 57 from bumps.gui.convergence_view import ConvergenceView 61 58 best, pop = result.convergence[:, 0], result.convergence[:, 1:] 62 self._get_view(ConvergenceView).update(best, pop) 63 else: 64 self._del_view(ConvergenceView) 59 self.get_panel(ConvergenceView).update(best, pop) 65 60 if hasattr(result, 'uncertainty_state'): 61 from bumps.gui.uncertainty_view import UncertaintyView, CorrelationView, TraceView 62 from bumps.dream.stats import var_stats, format_vars 66 63 stats = var_stats(result.uncertainty_state.draw()) 67 64 msg = format_vars(stats) 68 self. _get_view(CorrelationView).update(result.uncertainty_state)69 self. _get_view(UncertaintyView).update((result.uncertainty_state, stats))70 self. _get_view(TraceView).update(result.uncertainty_state)65 self.get_panel(CorrelationView).update(result.uncertainty_state) 66 self.get_panel(UncertaintyView).update((result.uncertainty_state, stats)) 67 self.get_panel(TraceView).update(result.uncertainty_state) 71 68 # TODO: stats should be stored in result rather than computed in bumps UncertaintyView 72 69 wx.PostEvent(self.frame.parent, 73 70 StatusEvent(status=msg, info="info")) 74 else: 75 for view in (CorrelationView, UncertaintyView, TraceView): 76 self._del_view(view) 71 print 77 72 78 73 def get_frame(self): 79 74 return self.frame 80 75 81 def _get_view(self, view_class): 76 def add_panel(self, panel): 77 self.AddPage(panel, panel.title) 78 79 def get_panel(self, panel_class): 82 80 for idx in range(self.PageCount): 83 if self.GetPageText(idx) == view_class.title:81 if self.GetPageText(idx) == panel_class.title: 84 82 return self.GetPage(idx) 85 83 else: 86 panel = view_class(self)87 self. AddPage(panel, panel.title)84 panel = panel_class(self) 85 self.add_panel(panel) 88 86 return panel 89 90 def _del_view(self, view_class):91 for idx in range(self.PageCount):92 if self.GetPageText(idx) == view_class.title:93 self.DeletePage(idx)94 -
src/sas/plottools/PlotPanel.py
rd3d67f0 r7e0f9b5 3 3 """ 4 4 import logging 5 import traceback6 5 import wx 7 6 # Try a normal import first … … 22 21 23 22 from plottables import Graph 23 from plottables import Text 24 24 from TextDialog import TextDialog 25 25 from LabelDialog import LabelDialog … … 32 32 import numpy 33 33 34 from ..guiframe.events import StatusEvent 35 from .toolbar import NavigationToolBar, PlotPrintout, bind 34 from sas.guiframe.events import StatusEvent 36 35 37 36 def show_tree(obj, d=0): … … 89 88 lo, hi = math.pow(10., lo), math.pow(10., hi) 90 89 return (lo, hi) 90 91 92 def CopyImage(canvas): 93 """ 94 0: matplotlib plot 95 1: wx.lib.plot 96 2: other 97 """ 98 bmp = wx.BitmapDataObject() 99 bmp.SetBitmap(canvas.bitmap) 100 101 wx.TheClipboard.Open() 102 wx.TheClipboard.SetData(bmp) 103 wx.TheClipboard.Close() 91 104 92 105 … … 320 333 """ 321 334 self.enable_toolbar = True 335 from toolbar import NavigationToolBar 322 336 self.toolbar = NavigationToolBar(parent=self, canvas=self.canvas) 323 bind(self.toolbar, wx.EVT_TOOL, self.onResetGraph, id=self.toolbar._NTB2_RESET)324 bind(self.toolbar, wx.EVT_TOOL, self.onContextMenu, id=self.toolbar._NTB2_HOME)325 337 self.toolbar.Realize() 326 338 ## The 'SetToolBar()' is not working on MAC: JHC … … 622 634 when clicking on linear Fit on context menu , display Fitting Dialog 623 635 """ 624 plot_dict = {}636 list = {} 625 637 menu = event.GetEventObject() 626 event_id = event.GetId()627 self.set_selected_from_menu(menu, event_id)638 id = event.GetId() 639 self.set_selected_from_menu(menu, id) 628 640 plotlist = self.graph.returnPlottable() 629 641 if self.graph.selected_plottable is not None: 630 642 for item in plotlist: 631 643 if item.id == self.graph.selected_plottable: 632 plot_dict[item] = plotlist[item]644 list[item] = plotlist[item] 633 645 else: 634 plot_dict = plotlist646 list = plotlist 635 647 from fitDialog import LinearFit 636 648 637 if len( plot_dict.keys()) > 0:638 first_item = plot_dict.keys()[0]649 if len(list.keys()) > 0: 650 first_item = list.keys()[0] 639 651 dlg = LinearFit(parent=None, plottable=first_item, 640 652 push_data=self.onFitDisplay, … … 850 862 Implement save image 851 863 """ 852 self.toolbar.save _figure(evt)864 self.toolbar.save(evt) 853 865 854 866 def onContextMenu(self, event): … … 858 870 """ 859 871 # Slicer plot popup menu 860 wx_id = wx.NewId()872 id = wx.NewId() 861 873 slicerpop = wx.Menu() 862 slicerpop.Append(wx_id, '&Save image', 'Save image as PNG') 863 wx.EVT_MENU(self, wx_id, self.onSaveImage) 864 865 wx_id = wx.NewId() 866 slicerpop.Append(wx_id, '&Printer setup', 'Set image size') 867 wx.EVT_MENU(self, wx_id, self.onPrinterSetup) 868 869 wx_id = wx.NewId() 870 slicerpop.Append(wx_id, '&Print image', 'Print image ') 871 wx.EVT_MENU(self, wx_id, self.onPrint) 872 873 wx_id = wx.NewId() 874 slicerpop.Append(wx_id, '&Copy', 'Copy to the clipboard') 875 wx.EVT_MENU(self, wx_id, self.OnCopyFigureMenu) 876 877 wx_id = wx.NewId() 874 slicerpop.Append(id, '&Save image', 'Save image as PNG') 875 wx.EVT_MENU(self, id, self.onSaveImage) 876 877 id = wx.NewId() 878 slicerpop.Append(id, '&Printer setup', 'Set image size') 879 wx.EVT_MENU(self, id, self.onPrinterSetup) 880 881 id = wx.NewId() 882 slicerpop.Append(id, '&Printer Preview', 'Set image size') 883 wx.EVT_MENU(self, id, self.onPrinterPreview) 884 885 id = wx.NewId() 886 slicerpop.Append(id, '&Print image', 'Print image ') 887 wx.EVT_MENU(self, id, self.onPrint) 888 889 id = wx.NewId() 890 slicerpop.Append(id, '&Copy', 'Copy to the clipboard') 891 wx.EVT_MENU(self, id, self.OnCopyFigureMenu) 892 893 #id = wx.NewId() 894 #slicerpop.Append(id, '&Load 1D data file') 895 #wx.EVT_MENU(self, id, self._onLoad1DData) 896 897 id = wx.NewId() 878 898 slicerpop.AppendSeparator() 879 slicerpop.Append( wx_id, '&Properties')880 wx.EVT_MENU(self, wx_id, self._onProperties)881 882 wx_id = wx.NewId()899 slicerpop.Append(id, '&Properties') 900 wx.EVT_MENU(self, id, self._onProperties) 901 902 id = wx.NewId() 883 903 slicerpop.AppendSeparator() 884 slicerpop.Append( wx_id, '&Linear Fit')885 wx.EVT_MENU(self, wx_id, self.onFitting)886 887 wx_id = wx.NewId()904 slicerpop.Append(id, '&Linear Fit') 905 wx.EVT_MENU(self, id, self.onFitting) 906 907 id = wx.NewId() 888 908 slicerpop.AppendSeparator() 889 slicerpop.Append( wx_id, '&Toggle Legend On/Off', 'Toggle Legend On/Off')890 wx.EVT_MENU(self, wx_id, self.onLegend)909 slicerpop.Append(id, '&Toggle Legend On/Off', 'Toggle Legend On/Off') 910 wx.EVT_MENU(self, id, self.onLegend) 891 911 892 912 loc_menu = wx.Menu() 893 913 for label in self._loc_labels: 894 wx_id = wx.NewId()895 loc_menu.Append( wx_id, str(label), str(label))896 wx.EVT_MENU(self, wx_id, self.onChangeLegendLoc)897 wx_id = wx.NewId()898 slicerpop.AppendMenu( wx_id, '&Modify Legend Location', loc_menu)899 900 wx_id = wx.NewId()901 slicerpop.Append( wx_id, '&Modify Y Axis Label')902 wx.EVT_MENU(self, wx_id, self._on_yaxis_label)903 wx_id = wx.NewId()904 slicerpop.Append( wx_id, '&Modify X Axis Label')905 wx.EVT_MENU(self, wx_id, self._on_xaxis_label)914 id = wx.NewId() 915 loc_menu.Append(id, str(label), str(label)) 916 wx.EVT_MENU(self, id, self.onChangeLegendLoc) 917 id = wx.NewId() 918 slicerpop.AppendMenu(id, '&Modify Legend Location', loc_menu) 919 920 id = wx.NewId() 921 slicerpop.Append(id, '&Modify Y Axis Label') 922 wx.EVT_MENU(self, id, self._on_yaxis_label) 923 id = wx.NewId() 924 slicerpop.Append(id, '&Modify X Axis Label') 925 wx.EVT_MENU(self, id, self._on_xaxis_label) 906 926 907 927 try: … … 1902 1922 self.xmax = xmax 1903 1923 #In case need to change the range of data plotted 1904 for item in self.graph.returnPlottable(): 1924 list = [] 1925 list = self.graph.returnPlottable() 1926 for item in list: 1927 #item.onFitRange(xminView,xmaxView) 1905 1928 item.onFitRange(None, None) 1906 1929 # Create new data plottable with result … … 1946 1969 Reset the graph by plotting the full range of data 1947 1970 """ 1948 for item in self.graph.returnPlottable(): 1971 list = [] 1972 list = self.graph.returnPlottable() 1973 for item in list: 1949 1974 item.onReset() 1950 1975 self.graph.render(self) … … 1953 1978 self.toolbar.update() 1954 1979 1955 def onPrint(self, event=None):1956 self.toolbar.print_figure(event)1957 1958 1980 def onPrinterSetup(self, event=None): 1959 1981 """ … … 1964 1986 def onPrinterPreview(self, event=None): 1965 1987 """ 1966 Matplotlib camvas can no longer print itself. Thus need to do1967 everything ourselves: need to create a printpreview frame to to1968 see the preview but needs a parent frame object. Also needs a1969 printout object (just as any printing task).1970 1988 """ 1971 1989 try: 1972 #check if parent is a frame. If not keep getting the higher 1973 #parent till we find a frame 1974 _plot = self 1975 while not isinstance(_plot, wx.Frame): 1976 _plot = _plot.GetParent() 1977 assert _plot is not None 1978 1979 #now create the printpeview object 1980 _preview = wx.PrintPreview(PlotPrintout(self.canvas), 1981 PlotPrintout(self.canvas)) 1982 #and tie it to a printpreview frame then show it 1983 _frame = wx.PreviewFrame(_preview, _plot, "Print Preview", wx.Point(100, 100), wx.Size(600, 650)) 1984 _frame.Centre(wx.BOTH) 1985 _frame.Initialize() 1986 _frame.Show(True) 1990 self.canvas.Printer_Preview(event=event) 1991 self.Update() 1987 1992 except: 1988 traceback.print_exc()1989 1993 pass 1990 1994 1995 def onPrint(self, event=None): 1996 """ 1997 """ 1998 try: 1999 self.canvas.Printer_Print(event=event) 2000 self.Update() 2001 except: 2002 pass 2003 1991 2004 def OnCopyFigureMenu(self, evt): 1992 2005 """ … … 1994 2007 """ 1995 2008 try: 1996 self.toolbar.copy_figure()2009 CopyImage(self.canvas) 1997 2010 except: 1998 2011 print "Error in copy Image" -
src/sas/plottools/TextDialog.py
r649806d r3477478 8 8 FONT_VARIANT = 1 9 9 PNL_WIDTH = 500 10 FAMILY = ['serif', 'sa ns-serif', 'fantasy', 'monospace']10 FAMILY = ['serif', 'sas-serif', 'fantasy', 'monospace'] 11 11 SIZE = [8, 9, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72] 12 12 STYLE = ['normal', 'italic'] … … 20 20 Dialog window pops- up when selecting 'Add Text' on the toolbar 21 21 """ 22 wx.Dialog.__init__(self, parent, id, title, size=(PNL_WIDTH, 300))22 wx.Dialog.__init__(self, parent, id, title, size=(PNL_WIDTH, 280)) 23 23 self.parent = parent 24 24 # Font … … 35 35 text_box = wx.BoxSizer(wx.HORIZONTAL) 36 36 sizer = wx.GridBagSizer(1, 3) 37 _BOX_WIDTH = 7038 font_description = wx.StaticBox(self, -1, 'Font' )37 _BOX_WIDTH = 60 38 font_description = wx.StaticBox(self, -1, 'Font', size=(PNL_WIDTH - 20, 70)) 39 39 font_box = wx.StaticBoxSizer(font_description, wx.VERTICAL) 40 40 family_box = wx.BoxSizer(wx.HORIZONTAL) … … 103 103 self.font_style.SetToolTipString("Font style of the text.") 104 104 # font color 105 self.font_color = wx.ComboBox(self, -1, style =wx.CB_READONLY)105 self.font_color = wx.ComboBox(self, -1, style=wx.CB_READONLY) 106 106 wx.EVT_COMBOBOX(self.font_color, -1, self.on_color) 107 107 self.font_color.SetMinSize((_BOX_WIDTH, -1)) … … 111 111 # Buttons on the bottom 112 112 self.static_line_1 = wx.StaticLine(self, -1) 113 self.ok_button = wx.Button(self, wx.ID_OK, 'OK', 114 size = (_BOX_WIDTH, 25)) 115 self.close_button = wx.Button(self, wx.ID_CANCEL, 'Cancel', 116 size = (_BOX_WIDTH, 25)) 113 self.ok_button = wx.Button(self, wx.ID_OK, 'OK', size=(_BOX_WIDTH, 25)) 114 self.close_button = wx.Button(self, wx.ID_CANCEL, 'Cancel', size=(_BOX_WIDTH, 25)) 117 115 118 116 # Intro … … 123 121 sizer.Add(wx.StaticText(self, -1, explanation), (iy, ix), 124 122 (1, 1), wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 125 family_box.Add(wx.StaticText(self, -1, 'Family :', size = (50, -1)), 126 0, wx.TOP, 5) 127 family_box.Add(self.font_family, 0, 0) 123 family_box.Add(wx.StaticText(self, -1, 'Family :'), -1, 0) 124 family_box.Add(self.font_family, -1, 0) 128 125 family_box.Add((_BOX_WIDTH / 2, -1)) 129 family_box.Add(wx.StaticText(self, -1, 'Size :', size = (50, -1)), 130 0, wx.TOP, 5) 131 family_box.Add(self.font_size, 0, 0) 126 family_box.Add(wx.StaticText(self, -1, 'Size :'), -1, 0) 127 family_box.Add(self.font_size, -1, 0) 132 128 if unit_box != None: 133 129 family_box.Add((_BOX_WIDTH / 2, -1)) 134 family_box.Add(tick_label_text, 0, 0) 135 family_box.Add(self.tick_label_check, 0, 0) 136 style_box.Add(wx.StaticText(self, -1, 'Style :', size = (50, -1)), 137 0, wx.TOP, 5) 138 style_box.Add(self.font_style, 0, 0) 130 family_box.Add(tick_label_text, -1, 0) 131 family_box.Add(self.tick_label_check, -1, 0) 132 style_box.Add(wx.StaticText(self, -1, 'Style :'), -1, 0) 133 style_box.Add(self.font_style, -1, 0) 139 134 style_box.Add((_BOX_WIDTH / 2, -1)) 140 style_box.Add(wx.StaticText(self, -1, 'Weight :', size = (50, -1)), 141 0, wx.TOP, 5) 142 style_box.Add(self.font_weight, 0, 0) 135 style_box.Add(wx.StaticText(self, -1, 'Weight :'), -1, 0) 136 style_box.Add(self.font_weight, -1, 0) 143 137 style_box.Add((_BOX_WIDTH / 2, -1)) 144 style_box.Add(wx.StaticText(self, -1, 'Color :', size = (45, -1)), 145 0, wx.TOP, 5) 146 style_box.Add(self.font_color, 0, 0) 147 font_box.Add(family_box, 0, 10) 148 font_box.Add((0,5)) 149 font_box.Add(style_box, 0, 10) 138 style_box.Add(wx.StaticText(self, -1, 'Color :'), -1, 0) 139 style_box.Add(self.font_color, -1, 0) 140 font_box.Add(family_box, -1, 10) 141 font_box.Add(style_box, -1, 10) 150 142 iy += 1 151 143 ix = 0 … … 160 152 vbox.Add(text_box, 0, wx.EXPAND, 15) 161 153 if unit_box != None: 162 unit_box.Add(unit_text, 0, 0)163 unit_box.Add(self.unit_ctrl, 0, 0)154 unit_box.Add(unit_text, -1, 0) 155 unit_box.Add(self.unit_ctrl, -1, 0) 164 156 vbox.Add((5, 5)) 165 157 vbox.Add(unit_box, 0, wx.LEFT, 15) -
src/sas/plottools/config.py
rd3d67f0 r79492222 58 58 matplotlib.rcParams[param] = 0.05 59 59 matplotlib.rcParams['legend.numpoints'] = 1 60 61 # this should happen after initial matplotlib configuration62 from .toolbar import NavigationToolBar63 from matplotlib.backends import backend_wxagg64 backend_wxagg.NavigationToolbar2WxAgg = NavigationToolBar65 66 # CRUFT: bumps 0.7.5.6 and older uses wrong toolbar67 backend_wxagg.NavigationToolbar2Wx = NavigationToolBar -
src/sas/plottools/toolbar.py
rd3d67f0 r3477478 31 31 def _init_toolbar(self): 32 32 self._parent = self.canvas.GetParent() 33 self._NTB2_HOME = wx.NewId()33 _NTB2_HOME = wx.NewId() 34 34 self._NTB2_BACK = wx.NewId() 35 35 self._NTB2_FORWARD = wx.NewId() 36 36 self._NTB2_PAN = wx.NewId() 37 37 self._NTB2_ZOOM = wx.NewId() 38 self._NTB2_SAVE = wx.NewId()39 self._NTB2_PRINT = wx.NewId()40 self._NTB2_RESET = wx.NewId()38 _NTB2_SAVE = wx.NewId() 39 _NTB2_PRINT = wx.NewId() 40 _NTB2_RESET = wx.NewId() 41 41 42 42 # for mpl 1.2+ compatibility … … 53 53 context_tip += ' right-click the data symbols.' 54 54 context = wx.ArtProvider.GetBitmap(wx.ART_LIST_VIEW, wx.ART_TOOLBAR) 55 self.AddSimpleTool( self._NTB2_HOME, context, context_tip, context_tip)55 self.AddSimpleTool(_NTB2_HOME, context, context_tip, context_tip) 56 56 57 57 self.InsertSeparator(1) … … 69 69 70 70 self.AddSeparator() 71 self.AddSimpleTool( self._NTB2_SAVE, _load_bitmap('filesave.png'),71 self.AddSimpleTool(_NTB2_SAVE, _load_bitmap('filesave.png'), 72 72 'Save', 'Save plot contents to file') 73 73 74 74 print_bmp = wx.ArtProvider.GetBitmap(wx.ART_PRINT, wx.ART_TOOLBAR) 75 self.AddSimpleTool( self._NTB2_PRINT, print_bmp, 'Print', 'Print plot')75 self.AddSimpleTool(_NTB2_PRINT, print_bmp, 'Print', 'Print plot') 76 76 77 77 reset_bmp = wx.ArtProvider.GetBitmap(wx.ART_GO_HOME, wx.ART_TOOLBAR) 78 self.AddSimpleTool( self._NTB2_RESET, reset_bmp, 'Reset', 'Reset graph range')78 self.AddSimpleTool(_NTB2_RESET, reset_bmp, 'Reset', 'Reset graph range') 79 79 80 bind(self, wx.EVT_TOOL, self. context_menu, id=self._NTB2_HOME)80 bind(self, wx.EVT_TOOL, self.on_menu, id=_NTB2_HOME) 81 81 bind(self, wx.EVT_TOOL, self.forward, id=self._NTB2_FORWARD) 82 82 bind(self, wx.EVT_TOOL, self.back, id=self._NTB2_BACK) 83 83 bind(self, wx.EVT_TOOL, self.zoom, id=self._NTB2_ZOOM) 84 84 bind(self, wx.EVT_TOOL, self.pan, id=self._NTB2_PAN) 85 bind(self, wx.EVT_TOOL, self.save_figure, id= self._NTB2_SAVE)86 bind(self, wx.EVT_TOOL, self. print_figure, id=self._NTB2_PRINT)87 bind(self, wx.EVT_TOOL, self. home, id=self._NTB2_RESET)85 bind(self, wx.EVT_TOOL, self.save_figure, id=_NTB2_SAVE) 86 bind(self, wx.EVT_TOOL, self.on_print, id=_NTB2_PRINT) 87 bind(self, wx.EVT_TOOL, self.on_reset, id=_NTB2_RESET) 88 88 89 89 self.Realize() 90 90 91 91 def on_menu(self, event): 92 """ 93 Plot menu 94 """ 92 95 try: 93 96 self._parent.onToolContextMenu(event=event) … … 95 98 logging.error("Plot toolbar could not show menu") 96 99 97 def context_menu(self, event):100 def on_reset(self, event): 98 101 """ 99 Default context menu for a plot panel 102 Reset plot 103 """ 104 try: 105 self._parent.onResetGraph(event=event) 106 except: 107 logging.error("Plot toolbar could not reset plot") 100 108 109 def on_print(self, event): 101 110 """ 102 # Slicer plot popup menu 103 wx_id = wx.NewId() 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) 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) 111 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) 115 116 # Show the popup menu relative to the location of the toolbar 117 self.PopupMenu(popup, (0,0)) 118 119 120 def print_figure(self, event): 111 Print 112 """ 121 113 try: 122 _printer = wx.Printer() 123 _printer.Print(self.canvas, PlotPrintout(self.canvas), True) 114 self.canvas.Printer_Preview(event=event) 124 115 except: 125 import traceback 126 logging.error(traceback.format_exc()) 127 128 def copy_figure(self, event): 129 copy_image_to_clipboard(self.canvas) 130 131 class PlotPrintout(wx.Printout): 132 """ 133 Create the wx.Printout object for matplotlib figure from the PlotPanel. 134 Provides the required OnPrintPage and HasPage overrides. Other methods 135 may be added/overriden in the future. 136 :TODO: this needs LOTS of TLC .. but fixes immediate problem 137 """ 138 def __init__(self, canvas): 139 """ 140 Initialize wx.Printout and get passed figure object 141 """ 142 wx.Printout.__init__(self) 143 self.canvas = canvas 144 145 def OnPrintPage(self, page): 146 """ 147 Most rudimentry OnPrintPage overide. instatiates a dc object, gets 148 its size, gets the size of the figure object, scales it to the dc 149 canvas size keeping the aspect ratio intact, then prints as bitmap 150 """ 151 _dc = self.GetDC() 152 (_dcX, _dcY) = _dc.GetSizeTuple() 153 (_bmpX,_bmpY) = self.canvas.GetSize() 154 _scale = min(_dcX/_bmpX, _dcY/_bmpY) 155 _dc.SetUserScale(_scale, _scale) 156 _dc.DrawBitmap(self.canvas.bitmap, 0, 0, False,) 157 return True 158 159 def GetPageInfo(self): 160 """ 161 just sets the page to 1 - no flexibility for now 162 """ 163 return (1, 1, 1, 1) 164 165 166 def copy_image_to_clipboard(canvas): 167 bmp = wx.BitmapDataObject() 168 bmp.SetBitmap(canvas.bitmap) 169 170 wx.TheClipboard.Open() 171 wx.TheClipboard.SetData(bmp) 172 wx.TheClipboard.Close() 173 174 116 logging.error("Plot toolbar could not print")
Note: See TracChangeset
for help on using the changeset viewer.