Changes in / [d06c34c:225aca8] in sasview
- Files:
-
- 3 added
- 29 edited
Legend:
- Unmodified
- Added
- Removed
-
build_tools/jenkins_osx_build.sh
r460f5f2 re9e3e38 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' % pkg_resources.get_distribution('sasview').egg_name()"` sasview.app 48 #cd $WORKSPACE/sasview/dist 49 #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)"` -
sasview.latestversion
r0ea31ca r9533593 1 3.1. 01 3.1.1 -
sasview/README.txt
r8bea1519 r9533593 4 4 1- Features 5 5 =========== 6 7 - New in Version 3.1.1 8 -------------------- 9 - Fixes bug #457 that prevented SasView from starting if the user was not 10 connected to the internet, or was behind a proxy server. 6 11 7 12 - New in Version 3.1.0 … … 302 307 different browser and set that as your default browser. Issues have 303 308 been noted with Internet Explorer 11. 309 - Check for Updates may fail (with the status bar message ' Cannot 310 connect to the application server') if your internet connection uses 311 a proxy server. Tested resolutions for this are described on the 312 website FAQ. 304 313 - The copy and paste functions (^C, ^V) in the batch mode results grid 305 314 require two clicks: one to select the cell and a second to select the -
sasview/__init__.py
rbc84fa7 r9533593 1 __version__ = "3.1. 0"1 __version__ = "3.1.1" 2 2 __build__ = "1" -
sasview/local_config.py
r5846bb5 r957af0d 13 13 __build__ = sas.sasview.__build__ 14 14 __download_page__ = 'https://github.com/SasView/sasview/releases' 15 __update_URL__ = ['raw.githubusercontent.com', 16 '/SasView/sasview/master/sasview.latestversion'] 17 15 __update_URL__ = 'http://www.sasview.org/latestversion.json' 18 16 19 17 # Debug message flag … … 131 129 DEFAULT_PERSPECTIVE = 'None' 132 130 131 # Time out for updating sasview 132 UPDATE_TIMEOUT = 2 133 133 134 def printEVT(message): 134 135 if __EVT_DEBUG__: -
sasview/setup_mac.py
r018582f r49cd712 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 sasviewver 120 121 VERSION = sasviewver.__version__ 122 APPNAME = "SasView "+VERSION 123 DMGNAME = "SasView-"+VERSION 124 118 125 APP = ['sasview.py'] 119 126 DATA_FILES += ['images','test','media'] … … 133 140 } 134 141 setup( 135 name= "sasview",142 name=APPNAME, 136 143 app=APP, 137 144 data_files=DATA_FILES, … … 140 147 setup_requires=['py2app'], 141 148 ) 149 150 #Build dmg 151 DMG="dist/%s.dmg"%DMGNAME 152 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
r5846bb5 r9989a6a 10 10 __build__ = '1' 11 11 __download_page__ = 'https://github.com/SasView/sasview/releases' 12 __update_URL__ = ['raw.githubusercontent.com', 13 '/SasView/sasview/master/sasview.latestversion'] 12 __update_URL__ = 'http://www.sasview.org/latestversion.json' 14 13 15 14 -
src/sas/guiframe/data_processor.py
re54dbc3e r44d20af 1 1 """ 2 Implement grid used to store data 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 3 15 """ 4 16 import wx … … 26 38 """ 27 39 Object describing a cell in the grid. 28 29 40 """ 30 41 def __init__(self): 42 """ 43 Initialize attributes of class (label, value, col, row, object) 44 """ 31 45 self.label = "" 32 46 self.value = None … … 39 53 """ 40 54 Return a dictionary of column label and index or row selected 55 41 56 :param sentence: String to parse 42 57 :param list: list of columns label 58 :returns: col_dict 43 59 """ 60 44 61 p2 = re.compile(r'\d+') 45 62 p = re.compile(r'[\+\-\*\%\/]') … … 81 98 82 99 class SPanel(ScrolledPanel): 100 """ 101 ensure proper scrolling of GridPanel 102 103 Adds a SetupScrolling call to the normal ScrolledPanel init. 104 GridPanel then subclasses this class 105 106 """ 83 107 def __init__(self, parent, *args, **kwds): 108 """ 109 initialize ScrolledPanel then force a call to SetupScrolling 110 111 """ 84 112 ScrolledPanel.__init__(self, parent, *args, **kwds) 85 113 self.SetupScrolling() … … 87 115 88 116 class GridCellEditor(sheet.CCellEditor): 89 """ Custom cell editor """ 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 """ 90 127 def __init__(self, grid): 128 """ 129 Override of CCellEditor init. Runs the grid.GridCellEditor init code 130 """ 91 131 super(GridCellEditor, self).__init__(grid) 92 132 133 def PaintBackground(self, dc, rect, attr): 134 """ 135 Overrides wx.sheet.CCellEditor.PaintBackground which incorrectly calls 136 the base class method. 137 138 In wx3.0 all paint objects must explicitly 139 have a wxPaintDC (Device Context) object. Thus the paint event which 140 generates a call to this method provides such a DC object and the 141 base class in grid expects to receive that object. sheet was apparently 142 not updated to reflect this and hence fails. This could thus 143 become obsolete in a future bug fix of wxPython. 144 145 Apart from adding a dc variable in the list of arguments in the def 146 and in the call to the base class the rest of this method is copied 147 as is from sheet.CCellEditor.PaintBackground 148 149 **From original GridCellEditor docs:** 150 151 Draws the part of the cell not occupied by the edit control. The 152 base class version just fills it with background colour from the 153 attribute. 154 155 NOTE: There is no need to override this if you don't need 156 to do something out of the ordinary. 157 158 :param dc: the wxDC object for the paint 159 """ 160 # Call base class method. 161 DC = dc 162 super(sheet.CCellEditor,self).PaintBackground(DC, rect, attr) 163 93 164 def EndEdit(self, row, col, grid, previous): 94 """ 95 Commit editing the current cell. Returns True if the value has changed. 96 @param previous: previous value in the cell 165 """ 166 Commit editing the current cell. Returns True if the value has changed. 167 168 :param previous: previous value in the cell 97 169 """ 98 170 changed = False # Assume value not changed … … 108 180 class GridPage(sheet.CSheet): 109 181 """ 182 Class that receives the results of a batch fit. 183 184 GridPage displays the received results in a wx.grid using sheet. This is 185 then used by GridPanel and GridFrame to present the full GUI. 110 186 """ 111 187 def __init__(self, parent, panel=None): 112 188 """ 189 Initialize 190 191 Initialize all the attributes of GridPage, and the events. include 192 the init stuff from sheet.CSheet as well. 113 193 """ 114 194 #sheet.CSheet.__init__(self, parent) 115 195 116 196 # The following is the __init__ from CSheet. ########################## 117 197 # We re-write it here because the class is broken in wx 3.0, … … 139 219 140 220 # Sink events 221 self.Bind(wx.grid.EVT_GRID_RANGE_SELECT, self.OnRangeSelect) 222 self.Bind(wx.grid.EVT_GRID_ROW_SIZE, self.OnRowSize) 223 self.Bind(wx.grid.EVT_GRID_COL_SIZE, self.OnColSize) 224 self.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.OnGridSelectCell) 225 # NOTE: the following bind to standard sheet methods that are 226 # overriden in this subclassn - actually we have currently 227 # disabled the on_context_menu that would override the OnRightClick 228 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnCellChange) 141 229 self.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, self.OnLeftClick) 142 230 self.Bind(wx.grid.EVT_GRID_CELL_RIGHT_CLICK, self.OnRightClick) 143 231 #self.Bind(wx.grid.EVT_GRID_CELL_LEFT_DCLICK, self.OnLeftDoubleClick) 144 self.Bind(wx.grid.EVT_GRID_RANGE_SELECT, self.OnRangeSelect)145 self.Bind(wx.grid.EVT_GRID_ROW_SIZE, self.OnRowSize)146 self.Bind(wx.grid.EVT_GRID_COL_SIZE, self.OnColSize)147 self.Bind(wx.grid.EVT_GRID_CELL_CHANGE, self.OnCellChange)148 self.Bind(wx.grid.EVT_GRID_SELECT_CELL, self.OnGridSelectCell)149 232 # This ends the __init__ section for CSheet. ########################## 233 234 235 236 # The following events must be bound even if CSheet is working 237 # properly and does not need the above re-implementation of the 238 # CSheet init method. Basically these override any intrinsic binding 239 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) 150 241 151 242 self.AdjustScrollbars() … … 187 278 if self.GetNumberCols() > 0: 188 279 self.default_col_width = self.GetColSize(0) 280 # We have moved these to the top of the init section with the 281 # rest of the grid event bindings from the sheet init when 282 # appropriate 189 283 #self.Bind(wx.grid.EVT_GRID_LABEL_LEFT_CLICK, self.on_left_click) 190 284 #self.Bind(wx.grid.EVT_GRID_LABEL_RIGHT_CLICK, self.on_right_click) … … 194 288 195 289 def OnLeftClick(self, event): 290 """ 291 Overrides sheet.CSheet.OnLefClick. 292 293 Processes when a cell is selected by left clicking on that cell. First 294 process the base Sheet method then the current class specific method 295 """ 196 296 sheet.CSheet.OnLeftClick(self, event) 197 297 self.on_selected_cell(event) 198 199 def on_edit_cell(self, event): 200 """ 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. 201 307 """ 202 308 row, _ = event.GetRow(), event.GetCol() … … 209 315 def on_selected_cell(self, event): 210 316 """ 211 Handler catching cell selection 212 """ 317 Handler catching cell selection. 318 319 Called after calling base 'on left click' method. 320 """ 321 213 322 flag = event.CmdDown() or event.ControlDown() 214 323 flag_shift = event.ShiftDown() … … 280 389 def on_left_click(self, event): 281 390 """ 282 Catch the left click on label mouse event 283 """ 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 284 399 flag = event.CmdDown() or event.ControlDown() 285 400 … … 324 439 def on_right_click(self, event): 325 440 """ 326 Catch the right click mouse 327 """ 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 328 453 col = event.GetCol() 329 454 row = event.GetRow() … … 360 485 def insert_col_menu(self, menu, label, window): 361 486 """ 362 """ 487 method called to populate the 'insert column before current column' 488 submenu. 489 """ 490 363 491 if self.data is None: 364 492 return … … 380 508 def insert_after_col_menu(self, menu, label, window): 381 509 """ 382 """ 510 Method called to populate the 'insert column after current column' 511 submenu 512 """ 513 383 514 if self.data is None: 384 515 return … … 401 532 def on_remove_column(self, event=None): 402 533 """ 403 """ 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 404 538 if self.selected_cols is not None or len(self.selected_cols) > 0: 405 539 col = self.selected_cols[0] … … 408 542 def remove_column(self, col, numCols=1): 409 543 """ 410 Remove column to the current grid 411 """ 544 Remove the col column from the current grid 545 """ 546 412 547 # add data to the grid 413 548 row = 0 … … 429 564 def on_insert_column(self, event): 430 565 """ 431 """ 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 432 575 if self.selected_cols is not None or len(self.selected_cols) > 0: 433 576 col = self.selected_cols[0] … … 442 585 def on_insert_after_column(self, event): 443 586 """ 444 Insert the given column after the highlighted column 445 """ 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 446 596 if self.selected_cols is not None or len(self.selected_cols) > 0: 447 597 col = self.selected_cols[0] + 1 … … 455 605 def insert_column(self, col, col_name): 456 606 """ 457 """ 607 Insert column at position col with data[col_name] into the current 608 grid. 609 """ 610 458 611 row = 0 459 612 self.InsertCols(pos=col, numCols=1, updateLabels=True) … … 477 630 def on_set_x_axis(self, event): 478 631 """ 479 """ 632 Just calls the panel version of the method 633 """ 634 480 635 self.panel.set_xaxis(x=self.axis_value, label=self.axis_label) 481 636 482 637 def on_set_y_axis(self, event): 483 638 """ 484 """ 639 Just calls the panel version of the method 640 """ 641 485 642 self.panel.set_yaxis(y=self.axis_value, label=self.axis_label) 486 643 … … 488 645 """ 489 646 Add data to the grid 647 490 648 :param data_inputs: data to use from the context menu of the grid 491 :param data_ouputs: default columns deplayed 492 """ 649 :param data_ouputs: default columns displayed 650 """ 651 493 652 self.file_name = file_name 494 653 self.details = details … … 527 686 Set the values in grids 528 687 """ 688 529 689 # add data to the grid 530 690 row = 0 … … 562 722 Return value contained in the grid 563 723 """ 724 564 725 grid_view = {} 565 726 for col in xrange(self.GetNumberCols()): … … 584 745 def onContextMenu(self, event): 585 746 """ 586 Default context menu 587 """ 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 588 756 wx_id = wx.NewId() 589 757 c_menu = wx.Menu() … … 620 788 def on_copy(self, event): 621 789 """ 622 On copy event from the contextmenu 623 """ 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 624 798 self.Copy() 625 799 626 800 def on_paste(self, event): 627 801 """ 628 On paste event from the contextmenu 629 """ 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 630 810 if self.data == None: 631 811 self.data = {} … … 636 816 def on_clear(self, event): 637 817 """ 638 Clear the cells selected 639 """ 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 640 826 self.Clear() 641 827 … … 646 832 ## Title to appear on top of the window 647 833 """ 834 648 835 window_caption = "Notebook " 649 836 … … 682 869 def enable_close_button(self): 683 870 """ 684 display the close button on tab for more than 1 tabs else remove the 685 close button 686 """ 871 display the close button on the tab if more than 1 tab exits. 872 Otherwise remove the close button 873 """ 874 687 875 if self.GetPageCount() <= 1: 688 876 style = self.GetWindowStyleFlag() … … 700 888 def on_edit_axis(self): 701 889 """ 702 Return the select cell of a given selected column. Check that all cells 703 are from the same column 704 """ 890 Return the select cell range from a given selected column. Checks that 891 all cells are from the same column 892 """ 893 705 894 pos = self.GetSelection() 706 895 grid = self.GetPage(pos) … … 732 921 Add highlight rows 733 922 """ 923 734 924 pos = self.GetSelection() 735 925 grid = self.GetPage(pos) … … 759 949 def get_column_labels(self): 760 950 """ 761 return dictionary of columns labels of the current page 762 """ 951 return dictionary of columns labels on the current page 952 """ 953 763 954 pos = self.GetSelection() 764 955 grid = self.GetPage(pos) … … 773 964 """ 774 965 Receive a list of cells and create a string presenting the selected 775 cells. 966 cells that can be used as data for one axis of a plot. 967 776 968 :param cell_list: list of tuple 777 778 969 """ 779 970 pos = self.GetSelection() … … 853 1044 close the page 854 1045 """ 1046 855 1047 if self.GetPageCount() == 1: 856 1048 event.Veto() … … 858 1050 859 1051 def set_data(self, data_inputs, data_outputs, details="", file_name=None): 1052 """ 1053 """ 860 1054 if data_outputs is None or data_outputs == {}: 861 1055 return … … 880 1074 def get_odered_results(self, inputs, outputs=None): 881 1075 """ 882 Get ordered the results 883 """ 1076 Order a list of 'inputs.' Used to sort rows and columns to present 1077 in batch results grid. 1078 """ 1079 884 1080 # Let's re-order the data from the keys in 'Data' name. 885 1081 if outputs == None: … … 914 1110 Append a new column to the grid 915 1111 """ 1112 1113 # I Believe this is no longer used now that we have removed the 1114 # edit menu from the menubar - PDB July 12, 2015 916 1115 pos = self.GetSelection() 917 1116 grid = self.GetPage(pos) … … 922 1121 Remove the selected column from the grid 923 1122 """ 1123 # I Believe this is no longer used now that we have removed the 1124 # edit menu from the menubar - PDB July 12, 2015 924 1125 pos = self.GetSelection() 925 1126 grid = self.GetPage(pos) … … 927 1128 928 1129 class GridPanel(SPanel): 1130 """ 1131 A ScrolledPanel class that contains the grid sheet as well as a number of 1132 widgets to create interesting plots and buttons for help etc. 1133 """ 1134 929 1135 def __init__(self, parent, data_inputs=None, 930 1136 data_outputs=None, *args, **kwds): 1137 """ 1138 Initialize the GridPanel 1139 """ 1140 931 1141 SPanel.__init__(self, parent, *args, **kwds) 932 1142 … … 990 1200 def get_plot_axis(self, col, list): 991 1201 """ 992 993 1202 """ 994 1203 axis = [] … … 1015 1224 def on_view(self, event): 1016 1225 """ 1017 Get object represented buy the given cell and plot them. 1018 """ 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 1019 1230 pos = self.notebook.GetSelection() 1020 1231 grid = self.notebook.GetPage(pos) … … 1096 1307 Evaluate the contains of textcrtl and plot result 1097 1308 """ 1309 1098 1310 pos = self.notebook.GetSelection() 1099 1311 grid = self.notebook.GetPage(pos) … … 1203 1415 running "file:///...." 1204 1416 1205 :param evt: Triggers on clicking the help button 1206 """ 1417 :param evt: Triggers on clicking the help button 1418 """ 1419 1207 1420 #import documentation window here to avoid circular imports 1208 1421 #if put at top of file with rest of imports. … … 1218 1431 Get sentence from dict 1219 1432 """ 1433 1220 1434 for tok, (col_name, list) in dict.iteritems(): 1221 1435 col = column_names[col_name] … … 1230 1444 def layout_grid(self): 1231 1445 """ 1232 Draw the area related to the grid 1233 """ 1446 Draw the area related to the grid by adding it as the first element 1447 in the panel's grid_sizer 1448 """ 1449 1234 1450 self.notebook = Notebook(parent=self) 1235 1451 self.notebook.set_data(self._data_inputs, self._data_outputs) … … 1238 1454 def layout_plotting_area(self): 1239 1455 """ 1240 Draw area containing options to plot 1241 """ 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 1242 1460 view_description = wx.StaticBox(self, -1, 'Plot Fits/Residuals') 1243 1461 note = "To plot the fits (or residuals), click the 'View Fits' button" … … 1281 1499 (self.plot_button, 0, 1282 1500 wx.LEFT | wx.TOP | wx.BOTTOM, 12), 1283 (self.help_button,0, 1501 (self.help_button,0, 1284 1502 wx.LEFT | wx.TOP | wx.BOTTOM, 12)]) 1285 1503 … … 1316 1534 Get the selected column on the visible grid and set values for axis 1317 1535 """ 1536 1318 1537 try: 1319 1538 cell_list = self.notebook.on_edit_axis() … … 1335 1554 Receive a list of cells and create a string presenting the selected 1336 1555 cells. 1556 1337 1557 :param cell_list: list of tuple 1338 1339 """ 1558 """ 1559 1340 1560 if self.notebook is not None: 1341 1561 return self.notebook.create_axis_label(cell_list) … … 1345 1565 get controls to modify 1346 1566 """ 1567 1347 1568 if label != None: 1348 1569 tcrtl_label.SetValue(str(label)) … … 1353 1574 """ 1354 1575 """ 1576 # I Believe this is no longer used now that we have removed the 1577 # edit menu from the menubar - PDB July 12, 2015 1355 1578 if self.notebook is not None: 1356 1579 self.notebook.add_column() … … 1359 1582 """ 1360 1583 """ 1584 # I Believe this is no longer used now that we have removed the 1585 # edit menu from the menubar - PDB July 12, 2015 1361 1586 if self.notebook is not None: 1362 1587 self.notebook.on_remove_column() … … 1364 1589 1365 1590 class GridFrame(wx.Frame): 1591 """ 1592 The main wx.Frame for the batch results grid 1593 """ 1594 1366 1595 def __init__(self, parent=None, data_inputs=None, data_outputs=None, id=-1, 1367 title="Grid Window", size=(800, 500)): 1596 title="Batch Fitting Results Panel", size=(800, 500)): 1597 """ 1598 Initialize the Frame 1599 """ 1600 1368 1601 wx.Frame.__init__(self, parent=parent, id=id, title=title, size=size) 1369 1602 self.parent = parent … … 1389 1622 wx.EVT_MENU(self, self.save_menu.GetId(), self.on_save_page) 1390 1623 1391 # To add the edit menu, call add_edit_menu() here. 1392 self.edit = None 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 1393 1636 self.Bind(wx.EVT_MENU_OPEN, self.on_menu_open) 1394 1395 1637 self.Bind(wx.EVT_CLOSE, self.on_close) 1396 1638 1397 1639 def add_edit_menu(self, menubar): 1640 """ 1641 populates the edit menu on the menubar. Not activated as of SasView 1642 3.1.0 1643 """ 1398 1644 self.edit = wx.Menu() 1399 1645 … … 1429 1675 def on_copy(self, event): 1430 1676 """ 1431 On Copy 1432 """ 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 1433 1681 if event != None: 1434 1682 event.Skip() … … 1439 1687 def on_paste(self, event): 1440 1688 """ 1441 On Paste 1442 """ 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 1443 1693 if event != None: 1444 1694 event.Skip() … … 1449 1699 def on_clear(self, event): 1450 1700 """ 1451 On Clear 1452 """ 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 1453 1705 pos = self.panel.notebook.GetSelection() 1454 1706 grid = self.panel.notebook.GetPage(pos) … … 1466 1718 def on_remove_column(self, event): 1467 1719 """ 1468 On remove column 1469 """ 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 1470 1724 pos = self.panel.notebook.GetSelection() 1471 1725 grid = self.panel.notebook.GetPage(pos) … … 1535 1789 def on_save_page(self, event): 1536 1790 """ 1537 """ 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 1538 1797 if self.parent is not None: 1539 1798 pos = self.panel.notebook.GetSelection() … … 1566 1825 def on_open(self, event): 1567 1826 """ 1568 Open file containg batch result 1569 """ 1827 Open file containing batch result 1828 """ 1829 1570 1830 if self.parent is not None: 1571 1831 self.parent.on_read_batch_tofile(self) … … 1575 1835 open excel and display batch result in Excel 1576 1836 """ 1837 1577 1838 if self.parent is not None: 1578 1839 pos = self.panel.notebook.GetSelection() … … 1625 1886 details="", *args, **kwds): 1626 1887 """ 1888 Initialize dialog 1889 1627 1890 :param parent: Window instantiating this dialog 1628 :param result: result to display in a grid or export to an external 1891 :param result: result to display in a grid or export to an external\ 1629 1892 application. 1630 1893 """ 1894 1631 1895 #kwds['style'] = wx.CAPTION|wx.SYSTEM_MENU 1632 1896 wx.Frame.__init__(self, parent, *args, **kwds) … … 1651 1915 Draw the content of the current dialog window 1652 1916 """ 1917 1653 1918 vbox = wx.BoxSizer(wx.VERTICAL) 1654 1919 box_description = wx.StaticBox(self.panel, -1, str("Batch Outputs")) … … 1704 1969 Get the user selection and display output to the selected application 1705 1970 """ 1971 1706 1972 if self.flag == 1: 1707 1973 self.parent.open_with_localapp(data_inputs=self.data_inputs, … … 1715 1981 close the Window 1716 1982 """ 1983 1717 1984 self.Close() 1718 1985 … … 1721 1988 Receive event and display data into third party application 1722 1989 or save data to file. 1723 1724 1990 """ 1725 1991 if self.save_to_file.GetValue(): -
src/sas/guiframe/documentation_window.py
r7a508b6 rfb3f9af 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
r78f75d02 r957af0d 27 27 import urllib 28 28 import urllib2 29 29 import json 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 Connection 48 49 from matplotlib import _pylab_helpers 50 49 51 50 52 def get_app_dir(): … … 52 54 The application directory is the one where the default custom_config.py 53 55 file resides. 56 57 :returns: app_path - the path to the applicatin directory 54 58 """ 55 59 # First, try the directory of the executable we are running … … 68 72 69 73 # Finally, try the directory of the sasview module 70 # TODO: gui_manager will have to know about sasview until we74 # TODO: gui_manager will have to know about sasview until we 71 75 # clean all these module variables and put them into a config class 72 76 # that can be passed by sasview.py. … … 830 834 def PushStatusText(self, *args, **kwds): 831 835 """ 832 FIXME: No message is passed. What is this supposed to do?836 .. todo:: No message is passed. What is this supposed to do? 833 837 """ 834 838 field = self.sb.get_msg_position() 835 839 wx.Frame.PushStatusText(self, field=field, 836 string="FIXME :PushStatusText called without text")840 string="FIXME - PushStatusText called without text") 837 841 838 842 def add_perspective(self, plugin): … … 890 894 :param dir: directory in which to look for plug-ins 891 895 892 :return : list of plug-ins896 :returns: list of plug-ins 893 897 894 898 """ … … 937 941 file.close() 938 942 except: 939 # Should raise and catch at a higher level and 943 # Should raise and catch at a higher level and 940 944 # display error on status bar 941 945 logging.error(sys.exc_value) … … 984 988 985 989 # Set up welcome panel 986 # TODO: this needs serious simplification990 # TODO: this needs serious simplification 987 991 if self.welcome_panel_class is not None: 988 992 welcome_panel = MDIFrame(self, None, 'None', (100, 200)) … … 1074 1078 def onfreeze(self, theory_id): 1075 1079 """ 1080 Saves theory/model and passes to data loader. 1081 1082 ..warning:: This seems to be the exact same code as the next 1083 function called simply freeze. This probably needs fixing 1076 1084 """ 1077 1085 data_state_list = self._data_manager.freeze(theory_id) … … 1085 1093 def freeze(self, data_id, theory_id): 1086 1094 """ 1095 Saves theory/model and passes to data loader. 1096 1097 ..warning:: This seems to be the exact same code as the next 1098 function called simply freeze. This probably needs fixing 1087 1099 """ 1088 1100 data_state_list = self._data_manager.freeze_theory(data_id=data_id, … … 1149 1161 :param p: panel object to add to the AUI manager 1150 1162 1151 :return : ID of the event associated with the new panel [int]1163 :returns: ID of the event associated with the new panel [int] 1152 1164 1153 1165 """ … … 1170 1182 # Append nummber 1171 1183 captions = self._get_plotpanel_captions() 1172 # FIXME: Fix this aweful loop1184 # FIXME: Fix this awful loop 1173 1185 while (1): 1174 1186 caption = windowcaption + '%s' % str(self.graph_num) … … 2031 2043 a call-back method when the current version number has been obtained. 2032 2044 """ 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): 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): 2053 2075 """ 2054 2076 Call-back method for the process of checking for updates. … … 2063 2085 """ 2064 2086 try: 2087 version = version_info["version"] 2065 2088 if version == "0.0.0": 2066 2089 msg = "Could not connect to the application server." … … 2071 2094 if not standalone: 2072 2095 import webbrowser 2073 webbrowser.open(config.__download_page__) 2096 if "download_url" in version_info: 2097 webbrowser.open(version_info["download_url"]) 2098 else: 2099 webbrowser.open(config.__download_page__) 2074 2100 else: 2075 2101 msg += "See the help menu to download it." … … 2435 2461 """ 2436 2462 Save file as txt 2437 :TODO: Refactor and remove this method. See TODO in _onSave. 2463 2464 .. todo:: Refactor and remove this method. See 'TODO' in _onSave. 2438 2465 """ 2439 2466 if not path == None: … … 2863 2890 # Append nummber 2864 2891 inc = 1 2865 # FIXME: fix this terrible loop2892 # FIXME: fix this terrible loop 2866 2893 while (1): 2867 2894 caption = new_caption + '_%s' % str(inc) … … 2886 2913 2887 2914 :param name: window_name in AuiPaneInfo 2888 :return : AuiPaneInfo of the name2915 :returns: AuiPaneInfo of the name 2889 2916 """ 2890 2917 for panel in self.plot_panels.values(): … … 3058 3085 pass 3059 3086 3060 # Draw all panels 3087 # Draw all panels 3061 3088 if count == 1: 3062 3089 f_draw(self.schedule_full_draw_list[0]) 3063 3090 else: 3064 3091 map(f_draw, self.schedule_full_draw_list) 3065 # Reset the attr 3092 # Reset the attr 3066 3093 if len(self.schedule_full_draw_list) == 0: 3067 3094 self.set_schedule(False) … … 3104 3131 Get window size 3105 3132 3106 :return size: tuple 3133 :returns: size 3134 :rtype: tuple 3107 3135 """ 3108 3136 width, height = self.GetSizeTuple() … … 3125 3153 pass 3126 3154 3127 # restart idle 3155 # restart idle 3128 3156 self._redraw_idle(*args, **kwargs) 3129 3157 … … 3133 3161 Restart Idle 3134 3162 """ 3135 # restart idle 3163 # restart idle 3136 3164 self.idletimer.Restart(100 * TIME_FACTOR, *args, **kwargs) 3137 3165 … … 3290 3318 """ 3291 3319 is_maximized = False 3292 # Get size of screen without 3320 # Get size of screen without 3293 3321 for screenCount in range(wx.Display().GetCount()): 3294 3322 screen = wx.Display(screenCount) … … 3307 3335 customHeight = displayHeight * 0.9 3308 3336 else: 3309 # If the custom screen is bigger than the 3337 # If the custom screen is bigger than the 3310 3338 # window screen than make maximum size 3311 3339 if customWidth > displayWidth: … … 3405 3433 def show_data_panel(self, action): 3406 3434 """ 3435 Turns on the data panel 3436 3437 The the data panel is optional. Most of its functions can be 3438 performed from the menu bar and from the plots. 3407 3439 """ 3408 3440 self.parent.show_data_panel(action) -
src/sas/guiframe/local_perspectives/plotting/Plotter1D.py
rb99a4552 r098f3d2 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)569 566 570 567 wx_id = wx.NewId() -
src/sas/guiframe/local_perspectives/plotting/Plotter2D.py
rc039589 r098f3d2 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()306 302 slicerpop.Append(wx_id, '&Copy to Clipboard', 'Copy to the clipboard') 307 303 wx.EVT_MENU(self, wx_id, self.OnCopyFigureMenu) -
src/sas/guiframe/local_perspectives/plotting/SimplePlot.py
rb40ad40 r098f3d2 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)64 60 65 61 wx_id = wx.NewId() … … 234 230 wx.EVT_MENU(self, id, self.on_print_image) 235 231 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 242 232 menu.AppendSeparator() 243 233 id = wx.NewId() -
src/sas/guiframe/report_dialog.py
re8bb5b6 r098f3d2 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)74 68 75 69 button_print = wx.Button(self, wx.NewId(), "Print") -
src/sas/models/CoreMultiShellModel.py
rac7be54 re0c16ce 53 53 ## parameters with orientation: can be removed since there is no orientational params 54 54 self._set_orientation_params() 55 56 55 57 56 def _clone(self, obj): 58 57 """ … … 67 66 68 67 return obj 69 70 68 71 69 def _set_dispersion(self): 72 70 """ 73 71 model dispersions 74 72 Polydispersion should not be applied to s_model 75 """ 76 ##set dispersion from model 73 """ 74 ##set dispersion from model 77 75 for name , value in self.model.dispersion.iteritems(): 78 76 nshell = 0 … … 82 80 if name.split('_')[-1] == 'shell%s' % str(nshell): 83 81 self.dispersion[name] = value 84 else: 82 else: 85 83 continue 86 84 else: 87 85 self.dispersion[name] = value 88 86 89 87 def _set_orientation_params(self): 90 88 """ 91 89 model orientation and magnetic parameters, same params for this model 92 """ 90 """ 93 91 ##set dispersion from model 94 92 for param in self.model.orientation_params: … … 104 102 self.orientation_params.append(param) 105 103 self.magnetic_params.append(param) 106 continue 104 continue 107 105 108 106 def _set_params(self): 109 107 """ 110 108 Concatenate the parameters of the model to create 111 this model parameters 109 this model parameters 112 110 """ 113 111 # rearrange the parameters for the given # of shells … … 128 126 else: 129 127 self.params[name]= value 130 128 131 129 # set constrained values for the original model params 132 self._set_xtra_model_param() 133 130 self._set_xtra_model_param() 131 134 132 def _set_details(self): 135 133 """ 136 134 Concatenate details of the original model to create 137 this model details 135 this model details 138 136 """ 139 137 for name ,detail in self.model.details.iteritems(): 140 138 if name in self.params.iterkeys(): 141 139 self.details[name]= detail 142 143 140 141 144 142 def _set_xtra_model_param(self): 145 143 """ … … 163 161 self.model.setParam(key, 0.0) 164 162 except: pass 165 163 166 164 167 165 def getProfile(self): 168 166 """ 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 values173 : Note: This works only for func_shell num = 2.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. 174 172 """ 175 173 r = [] … … 181 179 r.append(self.params['rad_core0']) 182 180 beta.append(self.params['sld_core0']) 183 181 184 182 # for shells 185 183 for n in range(1, self.n_shells+1): 186 184 # Left side of each shells 187 r0 = r[len(r)-1] 185 r0 = r[len(r)-1] 188 186 r.append(r0) 189 187 exec "beta.append(self.params['sld_shell%s'% str(n)])" … … 193 191 r.append(r0) 194 192 exec "beta.append(self.params['sld_shell%s'% str(n)])" 195 193 196 194 # for solvent 197 195 r0 = r[len(r)-1] … … 201 199 r.append(r_solv) 202 200 beta.append(self.params['sld_solv']) 203 201 204 202 return r, beta 205 203 206 204 def setParam(self, name, value): 207 """ 205 """ 208 206 Set the value of a model parameter 209 210 : 211 : 207 208 :param name: name of the parameter 209 :param value: value of the parameter 212 210 """ 213 211 # set param to new model 214 212 self._setParamHelper( name, value) 215 ## setParam to model 213 ## setParam to model 216 214 if name == 'sld_solv': 217 215 # the sld_*** model.params not in params must set to value of sld_solv … … 243 241 self.params[item] = value 244 242 return 245 246 243 #raise ValueError, "Model does not contain parameter %s" % name 247 248 244 245 249 246 def _set_fixed_params(self): 250 247 """ … … 252 249 """ 253 250 for item in self.model.fixed: 254 if item.split('.')[0] in self.params.keys(): 251 if item.split('.')[0] in self.params.keys(): 255 252 self.fixed.append(item) 256 253 257 254 self.fixed.sort() 258 255 259 256 def run(self, x = 0.0): 260 """ 257 """ 261 258 Evaluate the model 262 263 : 264 : 259 260 :param x: input q-value (float or [float, float] as [r, theta]) 261 :return: (DAB value) 265 262 """ 266 263 # set effective radius and scaling factor before run … … 269 266 270 267 def runXY(self, x = 0.0): 271 """ 268 """ 272 269 Evaluate the model 273 274 : 275 : 270 271 :param x: input q-value (float or [float, float] as [qx, qy]) 272 :return: DAB value 276 273 """ 277 274 # set effective radius and scaling factor before run 278 275 279 276 return self.model.runXY(x) 280 277 281 278 ## Now (May27,10) directly uses the model eval function 282 279 ## instead of the for-loop in Base Component. 283 280 def evalDistribution(self, x = []): 284 """ 281 """ 285 282 Evaluate the model in cartesian coordinates 286 287 : 288 : 283 284 :param x: input q[], or [qx[], qy[]] 285 :return: scattering function P(q[]) 289 286 """ 290 287 # set effective radius and scaling factor before run 291 288 return self.model.evalDistribution(x) 292 289 293 290 def calculate_ER(self): 294 """ 291 """ 295 292 Calculate the effective radius for P(q)*S(q) 296 293 297 294 :return: the value of the effective radius 298 299 """ 295 """ 300 296 return self.model.calculate_ER() 301 297 302 298 def calculate_VR(self): 303 """ 299 """ 304 300 Calculate the volf ratio for P(q)*S(q) 305 301 306 302 :return: the value of the volf ratio 307 308 """ 303 """ 309 304 return self.model.calculate_VR() 310 305 311 306 def set_dispersion(self, parameter, dispersion): 312 307 """ 313 308 Set the dispersion object for a model parameter 314 315 : 316 : dispersion: dispersion object of type DispersionModel309 310 :param parameter: name of the parameter [string] 311 :param dispersion: dispersion object of type DispersionModel 317 312 """ 318 313 value = None … … 323 318 return value 324 319 except: 325 raise 320 raise -
src/sas/models/MultiplicationModel.py
rac7be54 rfb3f9af 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 , 'scale_factor'.12 then P*S is multiplied by a new parameter, 'scale_factor'. 13 13 The polydispersion is applicable only to P(Q), not to S(Q). 14 Note: P(Q) refers to 'form factor' model while S(Q) does to 'structure factor'. 14 15 .. note:: P(Q) refers to 'form factor' model while S(Q) does to 'structure factor'. 15 16 """ 16 17 def __init__(self, p_model, s_model ): … … 81 82 def _clone(self, obj): 82 83 """ 83 Internal utility function to copy the internal84 data members to afresh copy.84 Internal utility function to copy the internal data members to a 85 fresh copy. 85 86 """ 86 87 obj.params = copy.deepcopy(self.params) … … 96 97 def _set_dispersion(self): 97 98 """ 98 combined the two models dispersions99 Polydispersion should not beapplied to s_model99 combine the two models' dispersions. Polydispersity should not be 100 applied to s_model 100 101 """ 101 102 ##set dispersion only from p_model … … 107 108 Get SLD profile of p_model if exists 108 109 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). 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). 112 114 """ 113 115 try: … … 121 123 def _set_params(self): 122 124 """ 123 124 thismodel parameters125 Concatenate the parameters of the two models to create 126 these model parameters 125 127 """ 126 128 … … 141 143 def _set_details(self): 142 144 """ 143 144 this modeldetails145 Concatenate details of the two models to create 146 this model's details 145 147 """ 146 148 for name, detail in self.p_model.details.iteritems(): … … 154 156 def _set_scale_factor(self): 155 157 """ 156 Set scale=volfraction toP model158 Set scale=volfraction for P model 157 159 """ 158 160 value = self.params['volfraction'] … … 168 170 def _set_effect_radius(self): 169 171 """ 170 172 Set effective radius to S(Q) model 171 173 """ 172 174 if not 'effect_radius' in self.s_model.params.keys(): … … 206 208 def _setParamHelper(self, name, value): 207 209 """ 208 210 Helper function to setparam 209 211 """ 210 212 # Look for dispersion parameters … … 229 231 def _set_fixed_params(self): 230 232 """ 231 fill the self.fixed list with the p_model fixed list233 Fill the self.fixed list with the p_model fixed list 232 234 """ 233 235 for item in self.p_model.fixed: … … 240 242 """ 241 243 Evaluate the model 244 242 245 :param x: input q-value (float or [float, float] as [r, theta]) 243 246 :return: (scattering function value) … … 250 253 251 254 def runXY(self, x = 0.0): 252 """ Evaluate the model 253 @param x: input q-value (float or [float, float] as [qx, qy]) 254 @return: scattering function value 255 """ 256 Evaluate the model 257 258 :param x: input q-value (float or [float, float] as [qx, qy]) 259 :return: scattering function value 255 260 """ 256 261 # set effective radius and scaling factor before run … … 266 271 """ 267 272 Evaluate the model in cartesian coordinates 273 268 274 :param x: input q[], or [qx[], qy[]] 269 275 :return: scattering function P(q[]) … … 279 285 """ 280 286 Set the dispersion object for a model parameter 287 281 288 :param parameter: name of the parameter [string] 282 289 :dispersion: dispersion object of type DispersionModel … … 293 300 def fill_description(self, p_model, s_model): 294 301 """ 295 302 Fill the description for P(Q)*S(Q) 296 303 """ 297 304 description = "" -
src/sas/models/c_extension/c_models/GelFit.cpp
r79492222 r1d115ef 34 34 radius = Parameter(104.0,true); 35 35 radius.set_min(2.0); 36 scale= Parameter(2.0,true);36 FractalExp = 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] = scale();45 dp[2] = FractalExp(); 46 46 47 47 if (dp[2] <= 0) -
src/sas/models/c_extension/python_wrapper/WrapperGenerator.py
r13e46abe r1f5f206 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('\\','/') 567 569 lenkey = len(key) 568 570 newline = line … … 570 572 while newline.count(key) > 0: 571 573 index = newline.index(key) 572 newline = newline[:index] + value + newline[index + lenkey:]574 newline = newline[:index] + _new_value + newline[index + lenkey:] 573 575 574 576 return newline -
src/sas/models/c_extension/python_wrapper/modelTemplate.txt
rc93122e r1f5f206 17 17 18 18 .. WARNING:: 19 20 19 THIS FILE WAS GENERATED BY WRAPPERGENERATOR.PY 21 20 DO NOT MODIFY THIS FILE, MODIFY … … 30 29 def create_[PYTHONCLASS](): 31 30 """ 32 31 Create a model instance 33 32 """ 34 33 obj = [PYTHONCLASS]() … … 100 99 """ 101 100 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 110 111 :param x: input q, or [qx, qy] 111 112 :return: scattering function P(q) … … 116 117 """ 117 118 Evaluate the model in cartesian coordinates 119 118 120 :param x: input q[], or [qx[], qy[]] 119 121 :return: scattering function P(q[]) … … 124 126 """ 125 127 Calculate the effective radius for P(q)*S(q) 128 126 129 :return: the value of the effective radius 127 130 """ … … 131 134 """ 132 135 Calculate the volf ratio for P(q)*S(q) 136 133 137 :return: the value of the volf ratio 134 138 """ … … 138 142 """ 139 143 Set the dispersion object for a model parameter 144 140 145 :param parameter: name of the parameter [string] 141 146 :param dispersion: dispersion object of type DispersionModel -
src/sas/models/include/GelFit.h
r79492222 r1d115ef 33 33 Parameter radius; 34 34 35 // [DEFAULT]= scale= 236 Parameter scale;35 // [DEFAULT]=FractalExp= 2 36 Parameter FractalExp; 37 37 38 38 // [DEFAULT]=background= 0.01 -
src/sas/models/include/dabmodel.h
r79492222 rf008ee2 17 17 // [PYTHONCLASS] = DABModel 18 18 // [DISP_PARAMS] = length, scale, background 19 // [DESCRIPTION] = <text>Provide F(x) = scale/( 1 + (x*L)^2 )^(2) + background 20 // DAB (Debye Anderson Brumberger) function as a BaseComponent model 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 21 22 // </text> 22 23 // [FIXED] = -
src/sas/models/sas_extension/__init__.py
r79492222 rfb3f9af 1 """ 2 This is an empty package - should probably delete 3 """ -
src/sas/perspectives/fitting/fitpage.py
rd06c34c r098f3d2 2218 2218 """ 2219 2219 # compute weight for the current data 2220 from sas.perspectives.fitting.utils import get_weight2221 2220 flag_weight = self.get_weight_flag() 2222 2221 if is_2D == None: 2223 2222 is_2D = self._is_2D() 2224 weight = get_weight(data=self.data,2225 is2d=is_2D,2226 flag=flag_weight)2227 2223 self._manager.set_fit_weight(uid=self.uid, 2228 2224 flag=flag_weight, … … 2242 2238 self._update_paramv_on_fit() 2243 2239 2244 # msg default2245 msg = None2246 2240 if event != None: 2247 2241 tcrtl = event.GetEventObject() … … 2257 2251 # if any value is changed 2258 2252 if is_new_pinhole: 2259 msg =self._set_pinhole_smear()2253 self._set_pinhole_smear() 2260 2254 # hide all silt sizer 2261 2255 self._hide_all_smear_info() -
src/sas/perspectives/fitting/fitting.py
rf21d496 r098f3d2 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, then 673 # there is no point setting the weights. 674 if fid is None: 675 return 672 676 if uid in self.page_finder.keys(): 673 677 self.page_finder[uid].set_weight(flag=flag, is2d=is2d) -
src/sas/perspectives/fitting/resultpanel.py
r2f4b430 r9df6a03 9 9 import wx.lib.newevent 10 10 from wx.aui import AuiNotebook as Notebook 11 12 from bumps.gui.convergence_view import ConvergenceView 13 from bumps.gui.uncertainty_view import UncertaintyView, CorrelationView, TraceView 14 from bumps.dream.stats import var_stats, format_vars 11 15 12 16 from sas.guiframe.panel_base import PanelBase … … 55 59 result = event.result[0][0] 56 60 if hasattr(result, 'convergence'): 57 from bumps.gui.convergence_view import ConvergenceView58 61 best, pop = result.convergence[:, 0], result.convergence[:, 1:] 59 self.get_panel(ConvergenceView).update(best, pop) 62 self._get_view(ConvergenceView).update(best, pop) 63 else: 64 self._del_view(ConvergenceView) 60 65 if hasattr(result, 'uncertainty_state'): 61 from bumps.gui.uncertainty_view import UncertaintyView, CorrelationView, TraceView62 from bumps.dream.stats import var_stats, format_vars63 66 stats = var_stats(result.uncertainty_state.draw()) 64 67 msg = format_vars(stats) 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)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) 68 71 # TODO: stats should be stored in result rather than computed in bumps UncertaintyView 69 72 wx.PostEvent(self.frame.parent, 70 73 StatusEvent(status=msg, info="info")) 71 print 74 else: 75 for view in (CorrelationView, UncertaintyView, TraceView): 76 self._del_view(view) 72 77 73 78 def get_frame(self): 74 79 return self.frame 75 80 76 def add_panel(self, panel): 77 self.AddPage(panel, panel.title) 78 79 def get_panel(self, panel_class): 81 def _get_view(self, view_class): 80 82 for idx in range(self.PageCount): 81 if self.GetPageText(idx) == panel_class.title:83 if self.GetPageText(idx) == view_class.title: 82 84 return self.GetPage(idx) 83 85 else: 84 panel = panel_class(self)85 self. add_panel(panel)86 panel = view_class(self) 87 self.AddPage(panel, panel.title) 86 88 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
r7e0f9b5 rd3d67f0 3 3 """ 4 4 import logging 5 import traceback 5 6 import wx 6 7 # Try a normal import first … … 21 22 22 23 from plottables import Graph 23 from plottables import Text24 24 from TextDialog import TextDialog 25 25 from LabelDialog import LabelDialog … … 32 32 import numpy 33 33 34 from sas.guiframe.events import StatusEvent 34 from ..guiframe.events import StatusEvent 35 from .toolbar import NavigationToolBar, PlotPrintout, bind 35 36 36 37 def show_tree(obj, d=0): … … 88 89 lo, hi = math.pow(10., lo), math.pow(10., hi) 89 90 return (lo, hi) 90 91 92 def CopyImage(canvas):93 """94 0: matplotlib plot95 1: wx.lib.plot96 2: other97 """98 bmp = wx.BitmapDataObject()99 bmp.SetBitmap(canvas.bitmap)100 101 wx.TheClipboard.Open()102 wx.TheClipboard.SetData(bmp)103 wx.TheClipboard.Close()104 91 105 92 … … 333 320 """ 334 321 self.enable_toolbar = True 335 from toolbar import NavigationToolBar336 322 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) 337 325 self.toolbar.Realize() 338 326 ## The 'SetToolBar()' is not working on MAC: JHC … … 634 622 when clicking on linear Fit on context menu , display Fitting Dialog 635 623 """ 636 list = {}624 plot_dict = {} 637 625 menu = event.GetEventObject() 638 id = event.GetId()639 self.set_selected_from_menu(menu, id)626 event_id = event.GetId() 627 self.set_selected_from_menu(menu, event_id) 640 628 plotlist = self.graph.returnPlottable() 641 629 if self.graph.selected_plottable is not None: 642 630 for item in plotlist: 643 631 if item.id == self.graph.selected_plottable: 644 list[item] = plotlist[item]632 plot_dict[item] = plotlist[item] 645 633 else: 646 list = plotlist634 plot_dict = plotlist 647 635 from fitDialog import LinearFit 648 636 649 if len( list.keys()) > 0:650 first_item = list.keys()[0]637 if len(plot_dict.keys()) > 0: 638 first_item = plot_dict.keys()[0] 651 639 dlg = LinearFit(parent=None, plottable=first_item, 652 640 push_data=self.onFitDisplay, … … 862 850 Implement save image 863 851 """ 864 self.toolbar.save (evt)852 self.toolbar.save_figure(evt) 865 853 866 854 def onContextMenu(self, event): … … 870 858 """ 871 859 # Slicer plot popup menu 872 id = wx.NewId()860 wx_id = wx.NewId() 873 861 slicerpop = wx.Menu() 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() 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() 898 878 slicerpop.AppendSeparator() 899 slicerpop.Append( id, '&Properties')900 wx.EVT_MENU(self, id, self._onProperties)901 902 id = wx.NewId()879 slicerpop.Append(wx_id, '&Properties') 880 wx.EVT_MENU(self, wx_id, self._onProperties) 881 882 wx_id = wx.NewId() 903 883 slicerpop.AppendSeparator() 904 slicerpop.Append( id, '&Linear Fit')905 wx.EVT_MENU(self, id, self.onFitting)906 907 id = wx.NewId()884 slicerpop.Append(wx_id, '&Linear Fit') 885 wx.EVT_MENU(self, wx_id, self.onFitting) 886 887 wx_id = wx.NewId() 908 888 slicerpop.AppendSeparator() 909 slicerpop.Append( id, '&Toggle Legend On/Off', 'Toggle Legend On/Off')910 wx.EVT_MENU(self, id, self.onLegend)889 slicerpop.Append(wx_id, '&Toggle Legend On/Off', 'Toggle Legend On/Off') 890 wx.EVT_MENU(self, wx_id, self.onLegend) 911 891 912 892 loc_menu = wx.Menu() 913 893 for label in self._loc_labels: 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)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) 926 906 927 907 try: … … 1922 1902 self.xmax = xmax 1923 1903 #In case need to change the range of data plotted 1924 list = [] 1925 list = self.graph.returnPlottable() 1926 for item in list: 1927 #item.onFitRange(xminView,xmaxView) 1904 for item in self.graph.returnPlottable(): 1928 1905 item.onFitRange(None, None) 1929 1906 # Create new data plottable with result … … 1969 1946 Reset the graph by plotting the full range of data 1970 1947 """ 1971 list = [] 1972 list = self.graph.returnPlottable() 1973 for item in list: 1948 for item in self.graph.returnPlottable(): 1974 1949 item.onReset() 1975 1950 self.graph.render(self) … … 1978 1953 self.toolbar.update() 1979 1954 1955 def onPrint(self, event=None): 1956 self.toolbar.print_figure(event) 1957 1980 1958 def onPrinterSetup(self, event=None): 1981 1959 """ … … 1986 1964 def onPrinterPreview(self, event=None): 1987 1965 """ 1966 Matplotlib camvas can no longer print itself. Thus need to do 1967 everything ourselves: need to create a printpreview frame to to 1968 see the preview but needs a parent frame object. Also needs a 1969 printout object (just as any printing task). 1988 1970 """ 1989 1971 try: 1990 self.canvas.Printer_Preview(event=event) 1991 self.Update() 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) 1992 1987 except: 1988 traceback.print_exc() 1993 1989 pass 1994 1990 1995 def onPrint(self, event=None): 1996 """ 1991 def OnCopyFigureMenu(self, evt): 1992 """ 1993 Copy the current figure to clipboard 1997 1994 """ 1998 1995 try: 1999 self.canvas.Printer_Print(event=event) 2000 self.Update() 2001 except: 2002 pass 2003 2004 def OnCopyFigureMenu(self, evt): 2005 """ 2006 Copy the current figure to clipboard 2007 """ 2008 try: 2009 CopyImage(self.canvas) 1996 self.toolbar.copy_figure() 2010 1997 except: 2011 1998 print "Error in copy Image" -
src/sas/plottools/TextDialog.py
r3477478 r649806d 8 8 FONT_VARIANT = 1 9 9 PNL_WIDTH = 500 10 FAMILY = ['serif', 'sa s-serif', 'fantasy', 'monospace']10 FAMILY = ['serif', 'sans-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, 280))22 wx.Dialog.__init__(self, parent, id, title, size=(PNL_WIDTH, 300)) 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 = 6038 font_description = wx.StaticBox(self, -1, 'Font' , size=(PNL_WIDTH - 20, 70))37 _BOX_WIDTH = 70 38 font_description = wx.StaticBox(self, -1, 'Font') 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', size=(_BOX_WIDTH, 25)) 114 self.close_button = wx.Button(self, wx.ID_CANCEL, 'Cancel', size=(_BOX_WIDTH, 25)) 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)) 115 117 116 118 # Intro … … 121 123 sizer.Add(wx.StaticText(self, -1, explanation), (iy, ix), 122 124 (1, 1), wx.LEFT | wx.EXPAND | wx.ADJUST_MINSIZE, 15) 123 family_box.Add(wx.StaticText(self, -1, 'Family :'), -1, 0) 124 family_box.Add(self.font_family, -1, 0) 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) 125 128 family_box.Add((_BOX_WIDTH / 2, -1)) 126 family_box.Add(wx.StaticText(self, -1, 'Size :'), -1, 0) 127 family_box.Add(self.font_size, -1, 0) 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) 128 132 if unit_box != None: 129 133 family_box.Add((_BOX_WIDTH / 2, -1)) 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) 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) 134 139 style_box.Add((_BOX_WIDTH / 2, -1)) 135 style_box.Add(wx.StaticText(self, -1, 'Weight :'), -1, 0) 136 style_box.Add(self.font_weight, -1, 0) 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) 137 143 style_box.Add((_BOX_WIDTH / 2, -1)) 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) 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) 142 150 iy += 1 143 151 ix = 0 … … 152 160 vbox.Add(text_box, 0, wx.EXPAND, 15) 153 161 if unit_box != None: 154 unit_box.Add(unit_text, -1, 0)155 unit_box.Add(self.unit_ctrl, -1, 0)162 unit_box.Add(unit_text, 0, 0) 163 unit_box.Add(self.unit_ctrl, 0, 0) 156 164 vbox.Add((5, 5)) 157 165 vbox.Add(unit_box, 0, wx.LEFT, 15) -
src/sas/plottools/config.py
r79492222 rd3d67f0 58 58 matplotlib.rcParams[param] = 0.05 59 59 matplotlib.rcParams['legend.numpoints'] = 1 60 61 # this should happen after initial matplotlib configuration 62 from .toolbar import NavigationToolBar 63 from matplotlib.backends import backend_wxagg 64 backend_wxagg.NavigationToolbar2WxAgg = NavigationToolBar 65 66 # CRUFT: bumps 0.7.5.6 and older uses wrong toolbar 67 backend_wxagg.NavigationToolbar2Wx = NavigationToolBar -
src/sas/plottools/toolbar.py
r3477478 rd3d67f0 31 31 def _init_toolbar(self): 32 32 self._parent = self.canvas.GetParent() 33 _NTB2_HOME = wx.NewId()33 self._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 _NTB2_SAVE = wx.NewId()39 _NTB2_PRINT = wx.NewId()40 _NTB2_RESET = wx.NewId()38 self._NTB2_SAVE = wx.NewId() 39 self._NTB2_PRINT = wx.NewId() 40 self._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( _NTB2_HOME, context, context_tip, context_tip)55 self.AddSimpleTool(self._NTB2_HOME, context, context_tip, context_tip) 56 56 57 57 self.InsertSeparator(1) … … 69 69 70 70 self.AddSeparator() 71 self.AddSimpleTool( _NTB2_SAVE, _load_bitmap('filesave.png'),71 self.AddSimpleTool(self._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( _NTB2_PRINT, print_bmp, 'Print', 'Print plot')75 self.AddSimpleTool(self._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( _NTB2_RESET, reset_bmp, 'Reset', 'Reset graph range')78 self.AddSimpleTool(self._NTB2_RESET, reset_bmp, 'Reset', 'Reset graph range') 79 79 80 bind(self, wx.EVT_TOOL, self. on_menu, id=_NTB2_HOME)80 bind(self, wx.EVT_TOOL, self.context_menu, id=self._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= _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)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) 88 88 89 89 self.Realize() 90 90 91 91 def on_menu(self, event): 92 """93 Plot menu94 """95 92 try: 96 93 self._parent.onToolContextMenu(event=event) … … 98 95 logging.error("Plot toolbar could not show menu") 99 96 100 def on_reset(self, event):97 def context_menu(self, event): 101 98 """ 102 Reset plot 99 Default context menu for a plot panel 100 103 101 """ 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): 104 121 try: 105 self._parent.onResetGraph(event=event) 122 _printer = wx.Printer() 123 _printer.Print(self.canvas, PlotPrintout(self.canvas), True) 106 124 except: 107 logging.error("Plot toolbar could not reset plot") 125 import traceback 126 logging.error(traceback.format_exc()) 108 127 109 def on_print(self, event): 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): 110 139 """ 111 Print140 Initialize wx.Printout and get passed figure object 112 141 """ 113 try: 114 self.canvas.Printer_Preview(event=event) 115 except: 116 logging.error("Plot toolbar could not print") 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
Note: See TracChangeset
for help on using the changeset viewer.