Changes in / [fa307dd:d620d03c] in sasview
- Location:
- src/sas
- Files:
-
- 1 added
- 25 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/guiframe/data_processor.py
r5251ec6 ra5e1b6ca 79 79 if label_pos != -1 and len(elt) >= separator_pos and\ 80 80 elt[separator_pos] == "[": 81 # the label contain , meaning the range selected is not 81 # the label contain , meaning the range selected is not 82 82 # continuous 83 83 if elt.count(',') > 0: … … 107 107 class SPanel(ScrolledPanel): 108 108 """ 109 ensure proper scrolling of GridPanel 110 111 Adds a SetupScrolling call to the normal ScrolledPanel init. 109 ensure proper scrolling of GridPanel 110 111 Adds a SetupScrolling call to the normal ScrolledPanel init. 112 112 GridPanel then subclasses this class 113 113 114 114 """ 115 115 def __init__(self, parent, *args, **kwds): … … 129 129 grid.GridCellEditor) in order to override two of its methods: 130 130 PaintBackrgound and EndEdit. 131 131 132 132 This is necessary as the sheet module is broken in wx 3.0.2 and 133 133 improperly subclasses grid.GridCellEditor … … 247 247 248 248 249 # The following events must be bound even if CSheet is working 249 # The following events must be bound even if CSheet is working 250 250 # properly and does not need the above re-implementation of the 251 251 # CSheet init method. Basically these override any intrinsic binding … … 313 313 def OnCellChange(self, event): 314 314 """ 315 Overrides sheet.CSheet.OnCellChange. 315 Overrides sheet.CSheet.OnCellChange. 316 316 317 317 Processes when a cell has been edited by a cell editor. Checks for the … … 558 558 """ 559 559 560 # add data to the grid 560 # add data to the grid 561 561 row = 0 562 562 col_name = self.GetCellValue(row, col) … … 583 583 Sets up to insert column into the current grid before the current 584 584 highlighted column location and sets up what to populate that column 585 with. Then calls insert_column method to actually do the insertion. 585 with. Then calls insert_column method to actually do the insertion. 586 586 """ 587 587 … … 604 604 Sets up to insert column into the current grid after the current 605 605 highlighted column location and sets up what to populate that column 606 with. Then calls insert_column method to actually do the insertion. 606 with. Then calls insert_column method to actually do the insertion. 607 607 """ 608 608 … … 758 758 def onContextMenu(self, event): 759 759 """ 760 Method to handle cell right click context menu. 760 Method to handle cell right click context menu. 761 761 762 762 THIS METHOD IS NOT CURRENTLY USED. It is designed to provide a … … 1124 1124 """ 1125 1125 1126 # I Believe this is no longer used now that we have removed the 1126 # I Believe this is no longer used now that we have removed the 1127 1127 # edit menu from the menubar - PDB July 12, 2015 1128 1128 pos = self.GetSelection() … … 1134 1134 Remove the selected column from the grid 1135 1135 """ 1136 # I Believe this is no longer used now that we have removed the 1136 # I Believe this is no longer used now that we have removed the 1137 1137 # edit menu from the menubar - PDB July 12, 2015 1138 1138 pos = self.GetSelection() … … 1637 1637 # We need to grab a WxMenu handle here, otherwise the next one to grab 1638 1638 # the handle will be treated as the Edit Menu handle when checking in 1639 # on_menu_open event handler and thus raise an exception when it hits an 1639 # on_menu_open event handler and thus raise an exception when it hits an 1640 1640 # unitialized object. Alternative is to comment out that whole section 1641 1641 # in on_menu_open, but that would make it more difficult to undo the … … 1690 1690 On Copy from the Edit menu item on the menubar 1691 1691 """ 1692 # I Believe this is no longer used now that we have removed the 1692 # I Believe this is no longer used now that we have removed the 1693 1693 # edit menu from the menubar - PDB July 12, 2015 1694 1694 if event is not None: … … 1702 1702 On Paste from the Edit menu item on the menubar 1703 1703 """ 1704 # I Believe this is no longer used now that we have removed the 1704 # I Believe this is no longer used now that we have removed the 1705 1705 # edit menu from the menubar - PDB July 12, 2015 1706 1706 if event is not None: … … 1714 1714 On Clear from the Edit menu item on the menubar 1715 1715 """ 1716 # I Believe this is no longer used now that we have removed the 1716 # I Believe this is no longer used now that we have removed the 1717 1717 # edit menu from the menubar - PDB July 12, 2015 1718 1718 pos = self.panel.notebook.GetSelection() … … 1733 1733 On remove column from the Edit menu Item on the menubar 1734 1734 """ 1735 # I Believe this is no longer used now that we have removed the 1735 # I Believe this is no longer used now that we have removed the 1736 1736 # edit menu from the menubar - PDB July 12, 2015 1737 1737 pos = self.panel.notebook.GetSelection() … … 1824 1824 location = os.path.dirname(grid.file_name) 1825 1825 dlg = wx.FileDialog(self, "Save Project file", 1826 location, grid.file_name, ext, wx. SAVE)1826 location, grid.file_name, ext, wx.FD_SAVE) 1827 1827 path = None 1828 1828 if dlg.ShowModal() == wx.ID_OK: … … 2009 2009 location = os.path.dirname(self.file_name) 2010 2010 dlg = wx.FileDialog(self, "Save Project file", 2011 location, self.file_name, ext, wx. SAVE)2011 location, self.file_name, ext, wx.FD_SAVE) 2012 2012 path = None 2013 2013 if dlg.ShowModal() == wx.ID_OK: -
src/sas/sasgui/guiframe/gui_manager.py
r9220e89c ra5e1b6ca 282 282 toolbar = self.GetToolBar() 283 283 if toolbar is not None: 284 _, tb_h = toolbar.GetSize Tuple()284 _, tb_h = toolbar.GetSize() 285 285 height -= tb_h 286 286 return width, height … … 948 948 if panel_class.CENTER_PANE: 949 949 self.panels[str(wx_id)] = panel_class 950 _, pos_y = frame.GetPosition Tuple()950 _, pos_y = frame.GetPosition() 951 951 frame.SetPosition((d_panel_width + 1, pos_y)) 952 952 frame.SetSize((w, h)) … … 1116 1116 if not IS_WIN: 1117 1117 p.frame.Center() 1118 x_pos, _ = p.frame.GetPosition Tuple()1118 x_pos, _ = p.frame.GetPosition() 1119 1119 p.frame.SetPosition((x_pos, 112)) 1120 1120 p.frame.Show(True) … … 1917 1917 self._default_save_location, "sasview_proj", 1918 1918 extension, 1919 wx. SAVE)1919 wx.FD_SAVE) 1920 1920 if dlg.ShowModal() == wx.ID_OK: 1921 1921 path = dlg.GetPath() … … 2414 2414 dlg = wx.FileDialog(self, "Choose a file", 2415 2415 self._default_save_location, 2416 default_name, wildcard, wx. SAVE)2416 default_name, wildcard, wx.FD_SAVE) 2417 2417 2418 2418 if dlg.ShowModal() == wx.ID_OK: … … 2551 2551 dlg = wx.FileDialog(self, "Choose a file", 2552 2552 self._default_save_location, 2553 default_name, wildcard, wx. SAVE)2553 default_name, wildcard, wx.FD_SAVE) 2554 2554 2555 2555 if dlg.ShowModal() == wx.ID_OK: … … 3011 3011 if self.GetToolBar() is not None and self.GetToolBar().IsShown(): 3012 3012 if not IS_LINUX: 3013 _, size_y = self.GetToolBar().GetSize Tuple()3013 _, size_y = self.GetToolBar().GetSize() 3014 3014 return size_y 3015 3015 … … 3130 3130 :rtype: tuple 3131 3131 """ 3132 width, height = self.GetSize Tuple()3132 width, height = self.GetSize() 3133 3133 if not IS_WIN: 3134 3134 # Subtract toolbar height to get real window side -
src/sas/sasgui/guiframe/gui_statusbar.py
r5251ec6 r34f23c8 112 112 Method to send an arbitrary number of messages to the console log 113 113 114 :param messages: A list of strings to be sent to the console log. 114 :param messages: A list of strings to be sent to the console log. 115 115 """ 116 116 if messages: … … 234 234 If the window is resized, redraw the window. 235 235 """ 236 self.reposition() 236 self.reposition() 237 237 self.size_changed = True 238 238 … … 360 360 if hasattr(event, "status"): 361 361 self.SetStatusText(text=str(event.status), event=event) 362 362 363 363 def set_gauge(self, event): 364 364 """ … … 423 423 self.SetFieldsCount(1) 424 424 self.timeout = timeout 425 width, height = parent.GetSize Tuple()425 width, height = parent.GetSize() 426 426 self.gauge = wx.Gauge(self, style=wx.GA_HORIZONTAL, 427 427 size=(width, height/10)) -
src/sas/sasgui/guiframe/local_perspectives/plotting/AnnulusSlicer.py
r5251ec6 r34f23c8 161 161 new_plot.detector = self.base.data2D.detector 162 162 # If the data file does not tell us what the axes are, just assume... 163 new_plot.xaxis( "\\rm{\phi}", 'degrees')164 new_plot.yaxis( "\\rm{Intensity} ", "cm^{-1}")165 if hasattr(data, "scale") and data.scale == 'linear' and \166 self.base.data2D.name.count("Residuals") > 0:163 new_plot.xaxis(r"\rm{\phi}", 'degrees') 164 new_plot.yaxis(r"\rm{Intensity} ", "cm^{-1}") 165 if (hasattr(data, "scale") and data.scale == 'linear' 166 and self.base.data2D.name.count("Residuals") > 0): 167 167 new_plot.ytransform = 'y' 168 new_plot.yaxis( "\\rm{Residuals} ", "/")168 new_plot.yaxis(r"\rm{Residuals} ", "/") 169 169 170 170 new_plot.group_id = "AnnulusPhi" + self.base.data2D.name -
src/sas/sasgui/guiframe/local_perspectives/plotting/Plotter1D.py
r5251ec6 r34f23c8 205 205 self.canvas.set_resizing(self.resizing) 206 206 self.parent.set_schedule(True) 207 pos_x, pos_y = self.GetPosition Tuple()207 pos_x, pos_y = self.GetPosition() 208 208 if pos_x != 0 and pos_y != 0: 209 self.size, _ = self.GetClientSize Tuple()209 self.size, _ = self.GetClientSize() 210 210 self.SetSizer(self.sizer) 211 211 wx.CallAfter(self.parent.disable_app_menu, self) … … 714 714 pos = self.ScreenToClient(pos_evt) 715 715 except: 716 pos_x, pos_y = self.toolbar.GetPosition Tuple()716 pos_x, pos_y = self.toolbar.GetPosition() 717 717 pos = (pos_x, pos_y + 5) 718 718 self.PopupMenu(self._slicerpop, pos) -
src/sas/sasgui/guiframe/local_perspectives/plotting/Plotter2D.py
r5251ec6 r34f23c8 179 179 # On Windows platform, default window size is incorrect, so set 180 180 # toolbar width to figure width. 181 _, th = self.toolbar.GetSize Tuple()182 fw, _ = self.canvas.GetSize Tuple()181 _, th = self.toolbar.GetSize() 182 fw, _ = self.canvas.GetSize() 183 183 self.toolbar.SetSize(wx.Size(fw, th)) 184 184 self.sizer.Add(self.toolbar, 0, wx.LEFT | wx.EXPAND) … … 400 400 pos = self.ScreenToClient(pos_evt) 401 401 except: 402 pos_x, pos_y = self.toolbar.GetPosition Tuple()402 pos_x, pos_y = self.toolbar.GetPosition() 403 403 pos = (pos_x, pos_y + 5) 404 404 self.PopupMenu(slicerpop, pos) -
src/sas/sasgui/guiframe/local_perspectives/plotting/SimplePlot.py
r7432acb r34f23c8 84 84 pos = self.ScreenToClient(pos_evt) 85 85 except: 86 pos_x, pos_y = self.toolbar.GetPosition Tuple()86 pos_x, pos_y = self.toolbar.GetPosition() 87 87 pos = (pos_x, pos_y + 5) 88 88 self.PopupMenu(slicerpop, pos) … … 135 135 # set the resizing flag 136 136 self.canvas.set_resizing(self.resizing) 137 pos_x, pos_y = self.GetPosition Tuple()137 pos_x, pos_y = self.GetPosition() 138 138 if pos_x != 0 and pos_y != 0: 139 self.size, _ = self.GetClientSize Tuple()139 self.size, _ = self.GetClientSize() 140 140 self.SetSizer(self.sizer) 141 141 -
src/sas/sasgui/guiframe/plugin_base.py
r5251ec6 r34f23c8 105 105 def delete_data(self, data_id): 106 106 """ 107 Delete all references of data which id are in data_list. 107 Delete all references of data which id are in data_list. 108 108 """ 109 109 … … 142 142 """ 143 143 Create and return the list of application menu 144 items for the plug-in. 144 items for the plug-in. 145 145 146 146 :param parent: parent window … … 238 238 if self.frame is not None: 239 239 if old_frame is not None: 240 pos_x, pos_y = old_frame.GetPosition Tuple()240 pos_x, pos_y = old_frame.GetPosition() 241 241 self.frame.SetPosition((pos_x, pos_y)) 242 242 if not self.frame.IsShown(): … … 254 254 need to be overwritten by the derivated class 255 255 """ 256 256 257 257 def post_init(self): 258 258 """ … … 261 261 pass 262 262 263 def set_state(self, state=None, datainfo=None): 263 def set_state(self, state=None, datainfo=None): 264 264 """ 265 265 update state -
src/sas/sasgui/guiframe/startup_configuration.py
r5251ec6 r34f23c8 127 127 for panel in self.parent.plot_panels.values(): 128 128 #p_panel = self.parent._mgr.GetPane(panel.window_name) 129 width, _ = panel.frame.GetSize Tuple()129 width, _ = panel.frame.GetSize() 130 130 if panel.frame.IsShown(): 131 131 if p_size is None or width > p_size: … … 137 137 try: 138 138 control_frame = self.parent.get_current_perspective().frame 139 control_w, control_h = control_frame.GetSize Tuple()139 control_w, control_h = control_frame.GetSize() 140 140 self.current_string['CONTROL_WIDTH'] = control_w 141 141 self.current_string['CONTROL_HEIGHT'] = control_h … … 144 144 self.current_string['CONTROL_HEIGHT'] = -1 145 145 146 data_pw, _ = self.parent.panels["data_panel"].frame.GetSize Tuple()146 data_pw, _ = self.parent.panels["data_panel"].frame.GetSize() 147 147 if data_pw is None: 148 148 data_pw = CURRENT_STRINGS['DATAPANEL_WIDTH'] -
src/sas/sasgui/perspectives/calculator/data_editor.py
r5251ec6 ra5e1b6ca 19 19 _QMAX_DEFAULT = 0.13 20 20 _NPTS_DEFAULT = 50 21 #Control panel width 21 #Control panel width 22 22 if sys.platform.count("darwin") == 0: 23 23 PANEL_WIDTH = 500 … … 196 196 summary = 'No data info available...' 197 197 self.data_summary.SetValue(summary) 198 #self.summary_sizer.Add(self.data_summary, 1, wx.EXPAND|wx.ALL, 10) 198 #self.summary_sizer.Add(self.data_summary, 1, wx.EXPAND|wx.ALL, 10) 199 199 200 200 def _layout_button(self): … … 579 579 wildcard = "CanSAS 1D files(*.xml)|*.xml" 580 580 dlg = wx.FileDialog(self, "Choose a file", 581 self._default_save_location, "", wildcard , wx.SAVE) 581 self._default_save_location, "", wildcard , 582 wx.FD_SAVE) 582 583 583 584 for data in self._data: -
src/sas/sasgui/perspectives/calculator/data_operator.py
r5251ec6 r34f23c8 866 866 except: 867 867 # toolbar event 868 pos_x, pos_y = self.toolbar.GetPosition Tuple()868 pos_x, pos_y = self.toolbar.GetPosition() 869 869 pos = (pos_x, pos_y + 5) 870 870 self.PopupMenu(slicerpop, pos) -
src/sas/sasgui/perspectives/calculator/gen_scatter_panel.py
r5251ec6 ra5e1b6ca 43 43 44 44 _BOX_WIDTH = 76 45 #Slit length panel size 45 #Slit length panel size 46 46 if sys.platform.count("win32") > 0: 47 47 PANEL_TOP = 0 … … 133 133 #kwds['style'] = wx.SUNKEN_BORDER 134 134 PanelBase.__init__(self) 135 #Font size 135 #Font size 136 136 self.SetWindowVariant(variant=FONT_VARIANT) 137 137 self.SetupScrolling() 138 #thread to read data 138 #thread to read data 139 139 self.reader = None 140 140 self.ext = None … … 218 218 iy = 0 219 219 param_title = wx.StaticText(self, -1, 'Parameter') 220 sizer.Add(param_title, (iy, ix), (1, 1), \221 220 sizer.Add(param_title, (iy, ix), (1, 1), 221 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 222 222 ix += 1 223 223 value_title = wx.StaticText(self, -1, 'Value') 224 sizer.Add(value_title, (iy, ix), (1, 1), \225 224 sizer.Add(value_title, (iy, ix), (1, 1), 225 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 226 226 ix += 1 227 227 unit_title = wx.StaticText(self, -1, 'Unit') 228 sizer.Add(unit_title, (iy, ix), (1, 1), \229 228 sizer.Add(unit_title, (iy, ix), (1, 1), 229 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 230 230 for param in sorted(params.keys()): 231 231 iy += 1 232 232 ix = 0 233 233 p_name = wx.StaticText(self, -1, param) 234 sizer.Add(p_name, (iy, ix), (1, 1), \235 234 sizer.Add(p_name, (iy, ix), (1, 1), 235 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 236 236 ## add parameter value 237 237 ix += 1 … … 239 239 ctl = InputTextCtrl(self, -1, size=(_BOX_WIDTH * 2, 20), 240 240 style=wx.TE_PROCESS_ENTER) 241 #ctl.SetToolTipString( \241 #ctl.SetToolTipString( 242 242 # "Hit 'Enter' after typing to update the plot.") 243 243 ctl.SetValue(format_number(value, True)) … … 246 246 ix += 1 247 247 unit = wx.StaticText(self, -1, details[param][0]) 248 sizer.Add(unit, (iy, ix), (1, 1), \249 248 sizer.Add(unit, (iy, ix), (1, 1), 249 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 250 250 self.parameters.append([p_name, ctl, unit]) 251 251 … … 340 340 iy = 0 341 341 name = wx.StaticText(self, -1, 'No. of Qx (Qy) bins: ') 342 sizer.Add(name, (iy, ix), (1, 1), \343 342 sizer.Add(name, (iy, ix), (1, 1), 343 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 344 344 ## add parameter value 345 345 ix += 1 346 346 self.npt_ctl = InputTextCtrl(self, -1, size=(_BOX_WIDTH * 1.5, 20), 347 style=wx.TE_PROCESS_ENTER)347 style=wx.TE_PROCESS_ENTER) 348 348 self.npt_ctl.Bind(wx.EVT_TEXT, self._onparamEnter) 349 349 self.npt_ctl.SetValue(format_number(self.npts_x, True)) … … 352 352 ix += 1 353 353 unit = wx.StaticText(self, -1, '') 354 sizer.Add(unit, (iy, ix), (1, 1), \355 354 sizer.Add(unit, (iy, ix), (1, 1), 355 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 356 356 iy += 1 357 357 ix = 0 358 358 name = wx.StaticText(self, -1, 'Qx (Qy) Max: ') 359 sizer.Add(name, (iy, ix), (1, 1), \360 359 sizer.Add(name, (iy, ix), (1, 1), 360 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 361 361 ## add parameter value 362 362 ix += 1 … … 369 369 ix += 1 370 370 unit = wx.StaticText(self, -1, '[1/A]') 371 sizer.Add(unit, (iy, ix), (1, 1), \372 371 sizer.Add(unit, (iy, ix), (1, 1), 372 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 373 373 self.qrange_sizer.Add(sizer, 0, wx.LEFT, 10) 374 374 … … 684 684 self.sld_data = self.parent.get_sld_from_omf() 685 685 output = self.sld_data 686 #frame_size = wx.Size(470, 470) 686 #frame_size = wx.Size(470, 470) 687 687 self.plot_frame = PlotFrame(self, -1, 'testView') 688 688 frame = self.plot_frame … … 703 703 panel.dimension = 3 704 704 graph_title = self._sld_plot_helper(ax, output, has_arrow) 705 # Use y, z axes (in mpl 3d) as z, y axes 705 # Use y, z axes (in mpl 3d) as z, y axes 706 706 # that consistent with our SAS detector coords. 707 ax.set_xlabel('x ($\A%s$)' % output.pos_unit) 708 ax.set_ylabel('z ($\A%s$)' % output.pos_unit) 709 ax.set_zlabel('y ($\A%s$)' % output.pos_unit) 707 # Format Angstrom units (A) as latex $\AA$ 708 units = output.pos_unit if output.pos_unit != "A" else r"$\AA$" 709 ax.set_xlabel('x (%s)' % units) 710 ax.set_ylabel('z (%s)' % units) 711 ax.set_zlabel('y (%s)' % units) 710 712 panel.subplot.figure.subplots_adjust(left=0.05, right=0.95, 711 713 bottom=0.05, top=0.96) … … 741 743 marker = 'o' 742 744 m_size = 3.5 743 sld_tot = (np.fabs(sld_mx) + np.fabs(sld_my) + \744 np.fabs(sld_mz) + np.fabs(output.sld_n))745 sld_tot = (np.fabs(sld_mx) + np.fabs(sld_my) 746 + np.fabs(sld_mz) + np.fabs(output.sld_n)) 745 747 is_nonzero = sld_tot > 0.0 746 748 is_zero = sld_tot == 0.0 … … 766 768 pos_y[chosen_color], marker, c=color, alpha=0.5, 767 769 markeredgecolor=color, markersize=m_size, label=key) 768 # III. Plot All others 770 # III. Plot All others 769 771 if np.any(other_color): 770 772 a_name = '' … … 1028 1030 self.data = Data2D() 1029 1031 qmax = self.qmax_x #/ np.sqrt(2) 1030 self.data.xaxis( '\\rm{Q_{x}}','\AA^{-1}')1031 self.data.yaxis( '\\rm{Q_{y}}','\AA^{-1}')1032 self.data.xaxis(r'\rm{Q_{x}}', r'\AA^{-1}') 1033 self.data.yaxis(r'\rm{Q_{y}}', r'\AA^{-1}') 1032 1034 self.data.is_data = False 1033 1035 self.data.id = str(self.uid) + " GenData" … … 1120 1122 new_plot.dx = data.dx 1121 1123 new_plot.dy = data.dy 1122 new_plot.xaxis( '\\rm{Q_{x}}','\AA^{-1}')1123 new_plot.yaxis( '\\rm{Intensity}', 'cm^{-1}')1124 new_plot.xaxis(r'\rm{Q_{x}}', r'\AA^{-1}') 1125 new_plot.yaxis(r'\rm{Intensity}', 'cm^{-1}') 1124 1126 new_plot.is_data = False 1125 1127 new_plot.id = str(self.uid) + " GenData1D" … … 1127 1129 new_plot.name = model.name + '1d' 1128 1130 new_plot.title = "Generic model1D " 1129 new_plot.id = str(page_id) + ': ' + self.file_name \1130 + ' #%s' % str(self.graph_num) + "_1D"1131 new_plot.group_id = str(page_id) + " Model1D" + \1132 ' #%s' % str(self.graph_num) + "_1D"1131 new_plot.id = (str(page_id) + ': ' + self.file_name 1132 + ' #%s' % str(self.graph_num) + "_1D") 1133 new_plot.group_id = (str(page_id) + " Model1D" 1134 + ' #%s' % str(self.graph_num) + "_1D") 1133 1135 new_plot.is_data = False 1134 1136 … … 1175 1177 new_plot.name = model.name + '2d' 1176 1178 new_plot.title = "Generic model 2D " 1177 new_plot.id = str(page_id) + ': ' + self.file_name \1178 + ' #%s' % str(self.graph_num) + "_2D"1179 new_plot.group_id = str(page_id) + " Model2D" \1180 + ' #%s' % str(self.graph_num) + "_2D"1179 new_plot.id = (str(page_id) + ': ' + self.file_name 1180 + ' #%s' % str(self.graph_num) + "_2D") 1181 new_plot.group_id = (str(page_id) + " Model2D" 1182 + ' #%s' % str(self.graph_num) + "_2D") 1181 1183 new_plot.detector = data.detector 1182 1184 new_plot.source = data.source … … 1243 1245 *args, **kwds) 1244 1246 PanelBase.__init__(self) 1245 #Font size 1247 #Font size 1246 1248 self.SetWindowVariant(variant=FONT_VARIANT) 1247 1249 self.SetupScrolling() … … 1446 1448 ix = 0 1447 1449 name = wx.StaticText(self, -1, key) 1448 sizer.Add(name, (iy, ix), (1, 1), \1449 1450 sizer.Add(name, (iy, ix), (1, 1), 1451 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 1450 1452 ## add parameter value 1451 1453 ix += 1 … … 1459 1461 s_unit = '[' + omfdata.sld_unit + ']' 1460 1462 unit = wx.StaticText(self, -1, s_unit) 1461 sizer.Add(unit, (iy, ix), (1, 1), \1462 1463 sizer.Add(unit, (iy, ix), (1, 1), 1464 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 1463 1465 self.slds.append([key, ctl, unit]) 1464 1466 self.sld_sizer.Add(sizer, 0, wx.LEFT, 10) … … 1481 1483 ix = 0 1482 1484 name = wx.StaticText(self, -1, key) 1483 sizer.Add(name, (iy, ix), (1, 1), \1484 1485 sizer.Add(name, (iy, ix), (1, 1), 1486 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 1485 1487 ## add parameter value 1486 1488 ix += 1 … … 1494 1496 ix += 1 1495 1497 unit = wx.StaticText(self, -1, '') 1496 sizer.Add(unit, (iy, ix), (1, 1), \1497 1498 sizer.Add(unit, (iy, ix), (1, 1), 1499 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 1498 1500 self.nodes.append([key, ctl, unit]) 1499 1501 self.node_sizer.Add(sizer, 0, wx.LEFT, 10) … … 1516 1518 ix = 0 1517 1519 name = wx.StaticText(self, -1, key) 1518 sizer.Add(name, (iy, ix), (1, 1), \1519 1520 sizer.Add(name, (iy, ix), (1, 1), 1521 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 1520 1522 ## add parameter value 1521 1523 ix += 1 … … 1530 1532 p_unit = '[' + omfdata.pos_unit + ']' 1531 1533 unit = wx.StaticText(self, -1, p_unit) 1532 sizer.Add(unit, (iy, ix), (1, 1), \1533 1534 sizer.Add(unit, (iy, ix), (1, 1), 1535 wx.EXPAND | wx.ADJUST_MINSIZE, 0) 1534 1536 self.stepsize.append([key, ctl, unit]) 1535 1537 self.step_sizer.Add(sizer, 0, wx.LEFT, 10) … … 1626 1628 for ctr_list in self.slds: 1627 1629 ctr_list[1].Enable(False) 1628 #break 1630 #break 1629 1631 return 1630 1632 … … 1637 1639 max_val = np.max(sld_list[key]) 1638 1640 mean_val = np.mean(sld_list[key]) 1639 enable = ( min_val == max_val) and \1640 sld_data.pix_type == 'pixel'1641 enable = ((min_val == max_val) 1642 and sld_data.pix_type == 'pixel') 1641 1643 ctr_list[1].SetValue(format_number(mean_val, True)) 1642 1644 ctr_list[1].Enable(enable) … … 1669 1671 location, "sld_file", 1670 1672 extension, 1671 wx. SAVE)1673 wx.FD_SAVE) 1672 1674 if dlg.ShowModal() == wx.ID_OK: 1673 1675 path = dlg.GetPath() -
src/sas/sasgui/perspectives/calculator/image_viewer.py
r5251ec6 r34f23c8 62 62 # Any other formats (tiff, jpeg, etc) are passed 63 63 # to PIL which seems to have a problem in version 64 # 1.1.7 that causes a close error which shows up in 64 # 1.1.7 that causes a close error which shows up in 65 65 # the log file. This does not seem to have any adverse 66 66 # effects. PDB --- September 17, 2017. … … 383 383 print(err_msg) 384 384 385 self. OnClose(event)385 self.EndModal(wx.ID_OK) 386 386 387 387 def convert_image(self, rgb, xmin, xmax, ymin, ymax, zscale): … … 417 417 output.ymin = ymin 418 418 output.ymax = ymax 419 output.xaxis( '\\rm{Q_{x}}','\AA^{-1}')420 output.yaxis( '\\rm{Q_{y}}','\AA^{-1}')419 output.xaxis(r'\rm{Q_{x}}', r'\AA^{-1}') 420 output.yaxis(r'\rm{Q_{y}}', r'\AA^{-1}') 421 421 # Store loading process information 422 422 output.meta_data['loader'] = self.title.split('.')[-1] + "Reader" … … 451 451 # clear event 452 452 event.Skip() 453 self.Destroy() 453 self.EndModal(wx.ID_CANCEL) 454 #self.Destroy() 454 455 455 456 if __name__ == "__main__": -
src/sas/sasgui/perspectives/corfunc/corfunc_panel.py
ref74a8b ra5e1b6ca 337 337 dlg = wx.FileDialog(self, "Choose a file", 338 338 default_save_location, \ 339 self.window_caption, "*.crf", wx. SAVE)339 self.window_caption, "*.crf", wx.FD_SAVE) 340 340 if dlg.ShowModal() == wx.ID_OK: 341 341 path = dlg.GetPath() -
src/sas/sasgui/perspectives/fitting/basepage.py
rcb64d86 ra5e1b6ca 676 676 self._manager.parent._default_save_location 677 677 dlg = wx.FileDialog(self, "Choose a file", self._default_save_location, 678 self.window_caption, "*.fitv", wx. SAVE)678 self.window_caption, "*.fitv", wx.FD_SAVE) 679 679 680 680 if dlg.ShowModal() == wx.ID_OK: -
src/sas/sasgui/perspectives/fitting/report_dialog.py
r44e8f48 ra5e1b6ca 49 49 dlg = wx.FileDialog(self, "Choose a file", 50 50 wildcard=self.wild_card, 51 style=wx. SAVE | wx.OVERWRITE_PROMPT | wx.CHANGE_DIR)51 style=wx.FD_SAVE | wx.OVERWRITE_PROMPT | wx.CHANGE_DIR) 52 52 dlg.SetFilterIndex(0) # Set .html files to be default 53 53 -
src/sas/sasgui/perspectives/invariant/invariant_panel.py
r5251ec6 ra5e1b6ca 1255 1255 dlg = wx.FileDialog(self, "Choose a file", 1256 1256 self._default_save_location, \ 1257 self.window_caption, "*.inv", wx. SAVE)1257 self.window_caption, "*.inv", wx.FD_SAVE) 1258 1258 if dlg.ShowModal() == wx.ID_OK: 1259 1259 path = dlg.GetPath() -
src/sas/sasgui/perspectives/invariant/report_dialog.py
r5251ec6 ra5e1b6ca 52 52 dlg = wx.FileDialog(self, "Choose a file", 53 53 wildcard=self.wild_card, 54 style=wx. SAVE | wx.OVERWRITE_PROMPT | wx.CHANGE_DIR)54 style=wx.FD_SAVE | wx.OVERWRITE_PROMPT | wx.CHANGE_DIR) 55 55 dlg.SetFilterIndex(0) # Set .html files to be default 56 56 -
src/sas/sasgui/perspectives/pr/explore_dialog.py
r5251ec6 r34f23c8 50 50 window_caption = "D Explorer" 51 51 52 def __init__(self, d_min, d_max, parent, id= -1, color=None, \52 def __init__(self, d_min, d_max, parent, id= -1, color=None, 53 53 dpi=None, style=wx.NO_FULL_REPAINT_ON_RESIZE, **kwargs): 54 54 """ … … 77 77 self.plot.symbol = GUIFRAME_ID.CURVE_SYMBOL_NUM 78 78 79 # Graph 79 # Graph 80 80 self.graph = Graph() 81 self.graph.xaxis( "\\rm{D_{max}}", 'A')82 self.graph.yaxis( "\\rm{%s}" % DEFAULT_OUTPUT, "")81 self.graph.xaxis(r"\rm{D_{max}}", 'A') 82 self.graph.yaxis(r"\rm{%s}" % DEFAULT_OUTPUT, "") 83 83 self.graph.add(self.plot) 84 84 self.graph.render(self) … … 133 133 # Dictionary of outputs 134 134 self.outputs = {} 135 self.outputs['Chi2/dof'] = [ "\chi^2/dof", "a.u.", self.chi2]135 self.outputs['Chi2/dof'] = [r"\chi^2/dof", "a.u.", self.chi2] 136 136 self.outputs['Oscillation parameter'] = ["Osc", "a.u.", self.osc] 137 137 self.outputs['Positive fraction'] = ["P^+", "a.u.", self.pos] 138 self.outputs['1-sigma positive fraction'] = [ "P^+_{1\ \sigma}",138 self.outputs['1-sigma positive fraction'] = [r"P^+_{1\ \sigma}", 139 139 "a.u.", self.pos_err] 140 140 self.outputs['Rg'] = ["R_g", "A", self.rg] -
src/sas/sasgui/perspectives/pr/inversion_panel.py
r5251ec6 ra5e1b6ca 282 282 dlg = wx.FileDialog(self, "Choose a file", 283 283 self._default_save_location, 284 self.window_caption, "*.prv", wx. SAVE)284 self.window_caption, "*.prv", wx.FD_SAVE) 285 285 if dlg.ShowModal() == wx.ID_OK: 286 286 path = dlg.GetPath() -
src/sas/sasgui/perspectives/simulation/SimCanvas.py
r959eb01 r34f23c8 2 2 This software was developed by the University of Tennessee as part of the 3 3 Distributed Data Analysis of Neutron Scattering Experiments (DANSE) 4 project funded by the US National Science Foundation. 4 project funded by the US National Science Foundation. 5 5 6 6 See the license text in license.txt … … 32 32 except ImportError: 33 33 haveOpenGL = False 34 34 35 35 # Color set 36 DEFAULT_COLOR = [1.0, 1.0, 0.0, .2] 36 DEFAULT_COLOR = [1.0, 1.0, 0.0, .2] 37 37 COLOR_RED = [1.0, 0.0, 0.0, .2] 38 38 COLOR_GREEN = [0.0, 1.0, 0.0, .2] … … 48 48 class SimPanel(wx.Panel): 49 49 """ 50 3D viewer to support real-space simulation. 50 3D viewer to support real-space simulation. 51 51 """ 52 52 window_name = "3dview" 53 53 window_caption = "3D viewer" 54 54 55 55 def __init__(self, parent, id = -1, plots = None, standalone=False, **kwargs): 56 56 wx.Panel.__init__(self, parent, id = id, **kwargs) 57 57 self.parent = parent 58 58 59 59 #Add a sizer 60 60 mainSizer = wx.BoxSizer(wx.VERTICAL) 61 61 sliderSizer = wx.BoxSizer(wx.HORIZONTAL) 62 63 self.canvas = CanvasBase(self) 62 63 self.canvas = CanvasBase(self) 64 64 self.canvas.SetMinSize((200,2100)) 65 65 … … 72 72 self.SetSizer(mainSizer) 73 73 self.Bind(wx.EVT_CONTEXT_MENU, self._on_context_menu) 74 75 74 75 76 76 def _on_context_menu(self, event): 77 77 """ … … 83 83 slicerpop.Append(id, '&Reset 3D View') 84 84 wx.EVT_MENU(self, id, self.canvas.resetView) 85 85 86 86 pos = event.GetPosition() 87 87 pos = self.ScreenToClient(pos) 88 self.PopupMenu(slicerpop, pos) 89 88 self.PopupMenu(slicerpop, pos) 89 90 90 class CanvasBase(glcanvas.GLCanvas): 91 91 """ … … 94 94 window_name = "Simulation" 95 95 window_caption = "Simulation" 96 96 97 97 def __init__(self, parent): 98 98 glcanvas.GLCanvas.__init__(self, parent, -1) … … 113 113 self.Bind(wx.EVT_MOTION, self.OnMouseMotion) 114 114 self.Bind(wx.EVT_MOUSEWHEEL, self._onMouseWheel) 115 115 116 116 self.initialized = False 117 117 self.shapes = [] 118 118 self.parent = parent 119 119 120 120 # Reference vectors 121 121 self.x_vec = [1,0,0] 122 122 self.y_vec = [0,1,0] 123 123 124 124 self.mouse_down = False 125 125 self.scale = 1.0 126 126 self.zoom = 1.0 127 127 self.translation = [0,0,0] 128 128 129 129 # Bind to Edit events 130 130 self.parent.Bind(ShapeParameters.EVT_EDIT_SHAPE, self._onEditShape) 131 131 132 132 def resetView(self, evt=None): 133 133 """ … … 140 140 glLoadIdentity() 141 141 self.Refresh() 142 142 143 143 def _onEditShape(self, evt): 144 144 evt.Skip() … … 158 158 event.Skip() 159 159 160 def OnPaint(self, event): 160 def OnPaint(self, event): 161 161 size = self.GetClientSize() 162 162 side = size.width 163 163 if size.height<size.width: 164 164 side = size.height 165 165 166 166 if self.GetContext(): 167 167 glViewport(0, 0, side, side) 168 168 self.SetMinSize((side,side)) 169 169 170 170 dc = wx.PaintDC(self) 171 171 self.SetCurrent() … … 174 174 self.init = True 175 175 self.OnDraw() 176 event.Skip() 177 176 event.Skip() 177 178 178 def _onMouseWheel(self, evt): 179 179 # Initialize mouse position so we don't have unwanted rotation 180 180 self.x, self.y = self.lastx, self.lasty = evt.GetPosition() 181 181 self.tr_x, self.tr_y = self.tr_lastx, self.tr_lasty = evt.GetPosition() 182 182 183 183 scale = 1.15 184 184 if evt.GetWheelRotation()<0: 185 185 scale = 1.0/scale 186 187 self.zoom *= scale 188 186 187 self.zoom *= scale 188 189 189 glScale(scale, scale, scale) 190 190 self.Refresh(False) 191 191 192 192 def OnMouseDown(self, evt): 193 193 self.SetFocus() … … 214 214 slicerpop.Append(id, '&Reset 3D View') 215 215 wx.EVT_MENU(self, id, self.resetView) 216 216 217 217 pos = event.GetPosition() 218 218 #pos = self.ScreenToClient(pos) 219 self.PopupMenu(slicerpop, pos) 219 self.PopupMenu(slicerpop, pos) 220 220 221 221 def OnMouseMotion(self, evt): … … 223 223 self.tr_lastx, self.tr_lasty = self.tr_x, self.tr_y 224 224 x, y = evt.GetPosition() 225 225 226 226 # Min distance to do anything 227 227 if math.fabs(self.lastx-x)>10 or math.fabs(self.lasty-y)>10: 228 228 229 229 self.lastx, self.lasty = self.x, self.y 230 231 230 231 232 232 if math.fabs(self.lastx-x)>math.fabs(self.lasty-y): 233 233 self.x = x 234 234 else: 235 235 self.y = y 236 236 237 237 #self.x, self.y = evt.GetPosition() 238 238 self.Refresh(False) 239 239 240 240 elif evt.Dragging() and evt.RightIsDown(): 241 241 self.lastx, self.lasty = self.x, self.y … … 243 243 self.tr_x, self.tr_y = evt.GetPosition() 244 244 self.Refresh(False) 245 246 def InitGL( self ): 245 246 def InitGL( self ): 247 247 glutInitDisplayMode (GLUT_DOUBLE | GLUT_RGBA) 248 248 #glShadeModel(GL_FLAT); 249 249 250 250 glMatrixMode(GL_PROJECTION) 251 251 252 252 glLight(GL_LIGHT0, GL_AMBIENT, [.2, .2, .2, 0]) 253 253 254 254 # Object color 255 255 #glLight(GL_LIGHT0, GL_DIFFUSE, COLOR_BLUE) 256 256 257 257 glLight(GL_LIGHT0, GL_POSITION, [1.0, 1.0, -1.0, 0.0]) 258 259 258 259 260 260 glLightModelfv(GL_LIGHT_MODEL_AMBIENT, [1, 1, 1, 0]) 261 261 glEnable(GL_LIGHTING) … … 263 263 glEnable(GL_BLEND) 264 264 glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); 265 265 266 266 glEnable ( GL_ALPHA_TEST ) ; 267 267 glAlphaFunc ( GL_GREATER, 0 ) ; 268 268 glPixelStorei(GL_PACK_ALIGNMENT, 1) 269 269 glPixelStorei(GL_UNPACK_ALIGNMENT, 1) 270 270 271 271 glEnable(GL_NORMALIZE) 272 272 glDepthFunc(GL_LESS) … … 276 276 #glClear (GL_COLOR_BUFFER_BIT); 277 277 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) 278 279 278 279 280 280 gluPerspective(0, 1.0, 0.1, 60.0); 281 281 … … 296 296 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT) 297 297 # use a fresh transformation matrix 298 298 299 299 # get the max object size to re-scale 300 300 max_size = 1.0 … … 305 305 if l>max_size: 306 306 max_size = l 307 307 308 308 max_size *= 1.05 309 309 scale = self.scale/max_size 310 310 glScale(scale, scale, scale) 311 311 self.scale = max_size 312 312 313 313 self.drawAxes() 314 314 315 315 if self.mouse_down: 316 316 if math.fabs((self.x - self.lastx))>math.fabs((self.y - self.lasty)): 317 angle = 10.0*(self.x - self.lastx) / math.fabs(self.x - self.lastx) 317 angle = 10.0*(self.x - self.lastx) / math.fabs(self.x - self.lastx) 318 318 glRotate(angle, self.y_vec[0], self.y_vec[1], self.y_vec[2]); 319 319 self._rot_y(angle) 320 320 elif math.fabs(self.y - self.lasty)>0: 321 angle = 10.0*(self.y - self.lasty) / math.fabs(self.y - self.lasty) 321 angle = 10.0*(self.y - self.lasty) / math.fabs(self.y - self.lasty) 322 322 glRotate(angle, self.x_vec[0], self.x_vec[1], self.x_vec[2]); 323 323 self._rot_x(angle) … … 325 325 self.lasty = self.y 326 326 self.lastx = self.x 327 328 w, h = self.GetVirtualSizeTuple()329 327 328 w, h = self.GetVirtualSize() 329 330 330 # Translate in the x-y plane 331 331 vx = self.x_vec[0] * 2.0*float(self.tr_x - self.tr_lastx)/w \ … … 335 335 vz = self.x_vec[2] * 2.0*float(self.tr_x - self.tr_lastx)/w \ 336 336 + self.y_vec[2] * 2.0*float(self.tr_lasty - self.tr_y)/h 337 338 glTranslate(self.scale*vx/self.zoom, self.scale*vy/self.zoom, self.scale*vz/self.zoom) 339 337 338 glTranslate(self.scale*vx/self.zoom, self.scale*vy/self.zoom, self.scale*vz/self.zoom) 339 340 340 # push into visible buffer 341 341 self.SwapBuffers() 342 342 343 343 def _matrix_mult(self, v, axis, angle): 344 344 c = math.cos(angle) 345 s = math.sin(angle) 345 s = math.sin(angle) 346 346 x = axis[0] 347 347 y = axis[1] … … 351 351 vz = v[0]*(x*z*(1-c)-y*s) + v[1]*(y*z*(1-c)+x*s) + v[2]*(z*z*(1-c)+c) 352 352 return [vx, vy, vz] 353 353 354 354 def _rot_y(self, theta): 355 355 """ 356 356 Rotate the view by theta around the y-axis 357 357 """ 358 angle = theta/180.0*math.pi 358 angle = theta/180.0*math.pi 359 359 axis = self.y_vec 360 360 self.x_vec = self._matrix_mult(self.x_vec, self.y_vec, -angle) 361 361 362 362 def _rot_x(self, theta): 363 363 """ … … 366 366 angle = theta/180.0*math.pi 367 367 self.y_vec = self._matrix_mult(self.y_vec, self.x_vec, -angle) 368 369 368 369 370 370 def addShape(self, shape, name=None): 371 371 """ … … 403 403 404 404 def drawAxes(self): 405 """ 405 """ 406 406 Draw 3D axes 407 407 """ 408 408 pos = self.scale * 0.7 409 409 410 410 # Z-axis is red 411 zaxis= Arrow(x=pos, y=-pos, z=0, r_cyl=self.scale*0.005, r_cone=self.scale*0.01, 411 zaxis= Arrow(x=pos, y=-pos, z=0, r_cyl=self.scale*0.005, r_cone=self.scale*0.01, 412 412 l_cyl=self.scale*0.1, l_cone=self.scale*0.05) 413 413 zaxis.color = COLOR_RED 414 414 zaxis.draw() 415 415 416 416 # Y-axis is yellow 417 yaxis= Arrow(x=pos, y=-pos, z=0, r_cyl=self.scale*0.005, r_cone=self.scale*0.01, 417 yaxis= Arrow(x=pos, y=-pos, z=0, r_cyl=self.scale*0.005, r_cone=self.scale*0.01, 418 418 l_cyl=self.scale*0.1, l_cone=self.scale*0.05) 419 419 yaxis.color = COLOR_YELLOW 420 420 yaxis.rotate(-90,0,0) 421 421 yaxis.draw() 422 422 423 423 # X-axis is green 424 xaxis= Arrow(x=pos, y=-pos, z=0, r_cyl=self.scale*0.005, r_cone=self.scale*0.01, 424 xaxis= Arrow(x=pos, y=-pos, z=0, r_cyl=self.scale*0.005, r_cone=self.scale*0.01, 425 425 l_cyl=self.scale*0.1, l_cone=self.scale*0.05) 426 426 xaxis.color = COLOR_GREEN 427 427 xaxis.rotate(0,-90,0) 428 428 xaxis.draw() 429 429 430 430 glLight(GL_LIGHT0, GL_DIFFUSE, DEFAULT_COLOR) 431 431 … … 445 445 self.theta_y = 0 446 446 self.theta_z = 0 447 447 448 448 # Params 449 449 self.params = {} … … 453 453 self.details['contrast'] = 'A-2' 454 454 self.details['order'] = ' ' 455 455 456 456 self.highlighted = False 457 457 self.color = DEFAULT_COLOR 458 458 459 459 def get_volume(self): 460 460 return 0 461 461 462 462 def get_length(self): 463 463 return 1.0 464 464 465 465 def highlight(self, value=False): 466 466 self.highlighted = value 467 467 468 468 def rotate(self, alpha, beta, gamma): 469 """ 469 """ 470 470 Set the rotation angles of the shape 471 471 @param alpha: angle around the x-axis [degrees] … … 476 476 self.theta_y = beta 477 477 self.theta_z = gamma 478 478 479 479 def _rotate(self): 480 480 """ 481 481 Perform the OpenGL rotation 482 482 483 483 Note that the rotation order is reversed. 484 484 We do Y, X, Z do be compatible with simulation... 485 485 """ 486 486 487 487 glRotated(self.theta_z, 0, 0, 1) 488 488 glRotated(self.theta_x, 1, 0, 0) 489 489 glRotated(self.theta_y, 0, 1, 0) 490 490 491 491 def _pre_draw(self): 492 492 if self.highlighted: … … 506 506 self.l_cyl = l_cyl 507 507 self.l_cone = l_cone 508 508 509 509 def draw(self): 510 510 self._pre_draw() 511 511 glPushMatrix() 512 512 glTranslate(self.x, self.y, self.z) 513 513 514 514 # Perform rotation 515 515 glRotate(self.theta_x, 1, 0, 0) … … 520 520 qobj = gluNewQuadric(); 521 521 gluCylinder(qobj, self.r_cyl, self.r_cyl, self.l_cyl, 15, 5); 522 522 523 523 glTranslate(0, 0, self.z+self.l_cyl) 524 524 525 525 # Draw cone of the arrow 526 526 glutSolidCone(self.r_cone, self.l_cone, 30, 5) 527 527 528 528 # Translate back to original position 529 529 glTranslate(-self.x, -self.y, -self.z) … … 538 538 self.radius = radius 539 539 self.height = height 540 540 541 541 def draw(self): 542 542 glPushMatrix() … … 556 556 self.params['radius'] = radius 557 557 self.details['radius'] = 'A' 558 558 559 559 def get_volume(self): 560 560 return 4.0/3.0*math.pi*self.params['radius']*self.params['radius']*self.params['radius'] 561 561 562 562 def get_length(self): 563 563 return 2.0*self.params['radius'] 564 564 565 565 def draw(self): 566 566 self._pre_draw() … … 584 584 """ 585 585 Cylinder shape, by default the cylinder is oriented along 586 the z-axis. 587 586 the z-axis. 587 588 588 The reference point of the cylinder is the center of the 589 589 bottom circle. … … 596 596 self.details['radius'] = 'A' 597 597 self.details['length'] = 'A' 598 598 599 599 def get_volume(self): 600 600 return math.pi*self.params['radius']*self.params['radius']*self.params['length'] 601 601 602 602 def get_length(self): 603 603 if self.params['length']>2.0*self.params['radius']: … … 605 605 else: 606 606 return 2.0*self.params['radius'] 607 607 608 608 def draw(self): 609 609 self._pre_draw() 610 610 glPushMatrix() 611 611 612 612 glTranslate(self.x, self.y, self.z) 613 self._rotate() 613 self._rotate() 614 614 qobj = gluNewQuadric(); 615 615 # gluCylinder(qobj, r_base, r_top, L, div around z, div along z) … … 619 619 glPopMatrix() 620 620 glLight(GL_LIGHT0, GL_DIFFUSE, DEFAULT_COLOR) 621 621 622 622 def accept(self, visitor): 623 623 return visitor.fromCylinder(self) 624 624 625 625 def accept_update(self, visitor): 626 626 return visitor.update_cylinder(self) 627 627 628 628 # Fill the shape list 629 629 SHAPE_LIST.append(dict(name='Sphere', id=wx.NewId(), cl=Sphere)) 630 630 SHAPE_LIST.append(dict(name='Cylinder', id=wx.NewId(), cl=Cylinder)) 631 631 632 632 def getShapes(): 633 633 """ … … 635 635 """ 636 636 return SHAPE_LIST 637 637 638 638 def getShapeClass(id): 639 639 """ … … 647 647 return shape[0]['cl'] 648 648 return None 649 649 650 650 def getShapeClassByName(name): 651 651 """ -
src/sas/sasgui/plottools/PlotPanel.py
r75313af r9305b46 339 339 # On Windows platform, default window size is incorrect, so set 340 340 # toolbar width to figure width. 341 tw, th = self.toolbar.GetSize Tuple()342 fw, fh = self.canvas.GetSize Tuple()341 tw, th = self.toolbar.GetSize() 342 fw, fh = self.canvas.GetSize() 343 343 # By adding toolbar in sizer, we are able to put it at the bottom 344 344 # of the frame - so appearance is closer to GTK version. … … 439 439 y = hi_y 440 440 # Move the legend from its previous location by that same amount 441 loc_in_canvas = self.legend_x - mouse_diff_x, \442 self.legend_y - mouse_diff_y441 loc_in_canvas = (self.legend_x - mouse_diff_x, 442 self.legend_y - mouse_diff_y) 443 443 # Transform into legend coordinate system 444 444 trans_axes = self.legend.parent.transAxes.inverted() … … 630 630 Return values and labels used by Fit Dialog 631 631 """ 632 return self.xLabel, self.yLabel, self.Avalue, self.Bvalue, \633 self.ErrAvalue, self.ErrBvalue, self.Chivalue 632 return (self.xLabel, self.yLabel, self.Avalue, self.Bvalue, 633 self.ErrAvalue, self.ErrBvalue, self.Chivalue) 634 634 635 635 def setTrans(self, xtrans, ytrans): … … 667 667 title='Linear Fit') 668 668 669 if ( self.xmin != 0.0)and (self.xmax != 0.0)\670 and(self.xminView != 0.0)and (self.xmaxView != 0.0):669 if ((self.xmin != 0.0) and (self.xmax != 0.0) 670 and (self.xminView != 0.0) and (self.xmaxView != 0.0)): 671 671 dlg.setFitRange(self.xminView, self.xmaxView, 672 672 self.xmin, self.xmax) … … 925 925 except: 926 926 # toolbar event 927 pos_x, pos_y = self.toolbar.GetPosition Tuple()927 pos_x, pos_y = self.toolbar.GetPosition() 928 928 pos = (pos_x, pos_y + 5) 929 929 … … 1059 1059 Allows you to add text to the plot 1060 1060 """ 1061 xaxis_label, xaxis_unit, xaxis_font, xaxis_color, \1062 is_ok, is_tick= self._on_axis_label(axis='x')1061 xaxis_label, xaxis_unit, xaxis_font, xaxis_color, is_ok, is_tick \ 1062 = self._on_axis_label(axis='x') 1063 1063 if not is_ok: 1064 1064 return … … 1073 1073 if self.data is not None: 1074 1074 # 2D 1075 self.xaxis(self.xaxis_label, self.xaxis_unit, \1076 1075 self.xaxis(self.xaxis_label, self.xaxis_unit, 1076 self.xaxis_font, self.xaxis_color, self.xaxis_tick) 1077 1077 self.subplot.figure.canvas.draw_idle() 1078 1078 else: … … 1106 1106 Allows you to add text to the plot 1107 1107 """ 1108 yaxis_label, yaxis_unit, yaxis_font, yaxis_color, \1109 is_ok, is_tick= self._on_axis_label(axis='y')1108 yaxis_label, yaxis_unit, yaxis_font, yaxis_color, is_ok, is_tick \ 1109 = self._on_axis_label(axis='y') 1110 1110 if not is_ok: 1111 1111 return … … 1120 1120 if self.data is not None: 1121 1121 # 2D 1122 self.yaxis(self.yaxis_label, self.yaxis_unit, \1122 self.yaxis(self.yaxis_label, self.yaxis_unit, 1123 1123 self.yaxis_font, self.yaxis_color, self.yaxis_tick) 1124 1124 self.subplot.figure.canvas.draw_idle() … … 1156 1156 is_tick = textdial.getTickLabel() 1157 1157 label_temp = textdial.getText() 1158 if label_temp.count("\%s" % "\\") > 0: 1158 if r"\\" in label_temp: 1159 label = label_temp.replace(r"\\", r"??") 1159 1160 if self.parent is not None: 1160 msg = "Add Label: Error.Can not use double '\\' "1161 msg = r"Add Label error: Can not use double '\\' " 1161 1162 msg += "characters..." 1162 1163 wx.PostEvent(self.parent, StatusEvent(status=msg)) … … 1234 1235 # TODO: rather than redrawing on the fly. 1235 1236 self.subplot.clear() 1236 self.subplot.hold(True)1237 1237 1238 1238 def render(self): … … 1533 1533 """ 1534 1534 # No qx or qy given in a vector format 1535 if self.qx_data is None or self.qy_data is None \1536 or self.qx_data.ndim != 1 or self.qy_data.ndim != 1 :1535 if (self.qx_data is None or self.qy_data is None 1536 or self.qx_data.ndim != 1 or self.qy_data.ndim != 1): 1537 1537 # do we need deepcopy here? 1538 1538 return copy.deepcopy(self.data) … … 1593 1593 """ 1594 1594 # No qx or qy given in a vector format 1595 if self.qx_data is None or self.qy_data is None \1596 or self.qx_data.ndim != 1 or self.qy_data.ndim != 1 :1595 if (self.qx_data is None or self.qy_data is None 1596 or self.qx_data.ndim != 1 or self.qy_data.ndim != 1): 1597 1597 # do we need deepcopy here? 1598 1598 return copy.deepcopy(self.data) … … 1644 1644 """ 1645 1645 # No image matrix given 1646 if image is None or np.ndim(image) != 2 \ 1647 or np.isfinite(image).all() \ 1648 or weights is None: 1646 if (image is None or np.ndim(image) != 2 1647 or np.isfinite(image).all() or weights is None): 1649 1648 return image 1650 1649 # Get bin size in y and x directions … … 1676 1675 # go 4 next nearest neighbors when no non-zero 1677 1676 # neighbor exists 1678 if n_y != 0 and n_x != 0 and \1679 np.isfinite(image[n_y - 1][n_x - 1]):1677 if (n_y != 0 and n_x != 0 1678 and np.isfinite(image[n_y - 1][n_x - 1])): 1680 1679 temp_image[n_y][n_x] += image[n_y - 1][n_x - 1] 1681 1680 weit[n_y][n_x] += 1 1682 if n_y != len_y - 1 and n_x != 0 and \1683 np.isfinite(image[n_y + 1][n_x - 1]):1681 if (n_y != len_y - 1 and n_x != 0 1682 and np.isfinite(image[n_y + 1][n_x - 1])): 1684 1683 temp_image[n_y][n_x] += image[n_y + 1][n_x - 1] 1685 1684 weit[n_y][n_x] += 1 1686 if n_y != len_y and n_x != len_x - 1 and \1687 np.isfinite(image[n_y - 1][n_x + 1]):1685 if (n_y != len_y and n_x != len_x - 1 1686 and np.isfinite(image[n_y - 1][n_x + 1])): 1688 1687 temp_image[n_y][n_x] += image[n_y - 1][n_x + 1] 1689 1688 weit[n_y][n_x] += 1 1690 if n_y != len_y - 1 and n_x != len_x - 1 and \1691 np.isfinite(image[n_y + 1][n_x + 1]):1689 if (n_y != len_y - 1 and n_x != len_x - 1 1690 and np.isfinite(image[n_y + 1][n_x + 1])): 1692 1691 temp_image[n_y][n_x] += image[n_y + 1][n_x + 1] 1693 1692 weit[n_y][n_x] += 1 … … 1784 1783 item.transformX(transform.toX2, transform.errToX2) 1785 1784 xunits = convert_unit(2, xunits) 1786 self.graph._xaxis_transformed("%s^ {2}" % xname, "%s" % xunits)1785 self.graph._xaxis_transformed("%s^2" % xname, "%s" % xunits) 1787 1786 if self.xLabel == "x^(4)": 1788 1787 item.transformX(transform.toX4, transform.errToX4) 1789 1788 xunits = convert_unit(4, xunits) 1790 self.graph._xaxis_transformed("%s^ {4}" % xname, "%s" % xunits)1789 self.graph._xaxis_transformed("%s^4" % xname, "%s" % xunits) 1791 1790 if self.xLabel == "ln(x)": 1792 1791 item.transformX(transform.toLogX, transform.errToLogX) 1793 self.graph._xaxis_transformed( "\ln{(%s)}" % xname, "%s" % xunits)1792 self.graph._xaxis_transformed(r"\ln(%s)" % xname, "%s" % xunits) 1794 1793 if self.xLabel == "log10(x)": 1795 1794 item.transformX(transform.toX_pos, transform.errToX_pos) … … 1799 1798 item.transformX(transform.toX4, transform.errToX4) 1800 1799 xunits = convert_unit(4, xunits) 1801 self.graph._xaxis_transformed("%s^ {4}" % xname, "%s" % xunits)1800 self.graph._xaxis_transformed("%s^4" % xname, "%s" % xunits) 1802 1801 _xscale = 'log' 1803 1802 if self.yLabel == "ln(y)": 1804 1803 item.transformY(transform.toLogX, transform.errToLogX) 1805 self.graph._yaxis_transformed( "\ln{(%s)}" % yname, "%s" % yunits)1804 self.graph._yaxis_transformed(r"\ln(%s)" % yname, "%s" % yunits) 1806 1805 if self.yLabel == "y": 1807 1806 item.transformY(transform.toX, transform.errToX) … … 1822 1821 item.transformY(transform.toYX2, transform.errToYX2) 1823 1822 xunits = convert_unit(2, self.xaxis_unit) 1824 self.graph._yaxis_transformed( "%s \ \ %s^{2}" % (yname, xname),1823 self.graph._yaxis_transformed(r"%s \ \ %s^2" % (yname, xname), 1825 1824 "%s%s" % (yunits, xunits)) 1826 1825 if self.yLabel == "y*x^(4)": 1827 1826 item.transformY(transform.toYX4, transform.errToYX4) 1828 1827 xunits = convert_unit(4, self.xaxis_unit) 1829 self.graph._yaxis_transformed( "%s \ \ %s^{4}" % (yname, xname),1828 self.graph._yaxis_transformed(r"%s \ \ %s^4" % (yname, xname), 1830 1829 "%s%s" % (yunits, xunits)) 1831 1830 if self.yLabel == "1/sqrt(y)": … … 1833 1832 transform.errOneOverSqrtX) 1834 1833 yunits = convert_unit(-0.5, yunits) 1835 self.graph._yaxis_transformed( "1/\sqrt{%s}" % yname,1834 self.graph._yaxis_transformed(r"1/\sqrt{%s}" % yname, 1836 1835 "%s" % yunits) 1837 1836 if self.yLabel == "ln(y*x)": 1838 1837 item.transformY(transform.toLogXY, transform.errToLogXY) 1839 self.graph._yaxis_transformed( "\ln{(%s \ \ %s)}" % (yname, xname),1838 self.graph._yaxis_transformed(r"\ln(%s \ \ %s)" % (yname, xname), 1840 1839 "%s%s" % (yunits, self.xaxis_unit)) 1841 1840 if self.yLabel == "ln(y*x^(2))": 1842 1841 item.transformY(transform.toLogYX2, transform.errToLogYX2) 1843 1842 xunits = convert_unit(2, self.xaxis_unit) 1844 self.graph._yaxis_transformed( "\ln (%s \ \ %s^{2})" % (yname, xname),1843 self.graph._yaxis_transformed(r"\ln(%s \ \ %s^2)" % (yname, xname), 1845 1844 "%s%s" % (yunits, xunits)) 1846 1845 if self.yLabel == "ln(y*x^(4))": 1847 1846 item.transformY(transform.toLogYX4, transform.errToLogYX4) 1848 1847 xunits = convert_unit(4, self.xaxis_unit) 1849 self.graph._yaxis_transformed( "\ln (%s \ \ %s^{4})" % (yname, xname),1848 self.graph._yaxis_transformed(r"\ln(%s \ \ %s^4)" % (yname, xname), 1850 1849 "%s%s" % (yunits, xunits)) 1851 1850 if self.yLabel == "log10(y*x^(4))": … … 1853 1852 xunits = convert_unit(4, self.xaxis_unit) 1854 1853 _yscale = 'log' 1855 self.graph._yaxis_transformed( "%s \ \ %s^{4}" % (yname, xname),1854 self.graph._yaxis_transformed(r"%s \ \ %s^4" % (yname, xname), 1856 1855 "%s%s" % (yunits, xunits)) 1857 1856 item.transformView() … … 1897 1896 # Saving value to redisplay in Fit Dialog when it is opened again 1898 1897 self.Avalue, self.Bvalue, self.ErrAvalue, \ 1899 1898 self.ErrBvalue, self.Chivalue = func 1900 1899 self.xminView = xminView 1901 1900 self.xmaxView = xmaxView -
src/sas/sasgui/plottools/canvas.py
r5251ec6 r34f23c8 53 53 ppw = 1 54 54 pph = 1 55 (pgw, _)= self.GetPageSizePixels() # page size in pixels56 (dcw, _)= dc.GetSize()57 (grw, _) = self.canvas.GetSizeTuple()55 pgw, _ = self.GetPageSizePixels() # page size in pixels 56 dcw, _ = dc.GetSize() 57 grw, _ = self.canvas.GetSize() 58 58 59 59 # save current figure dpi resolution and bg color, … … 152 152 Render after a delay if no other render requests have been made. 153 153 """ 154 self.panel.subplot.grid(self.panel.grid_on) 155 if self.panel.legend is not None and self.panel.legend_pos_loc: 156 self.panel.legend._loc = self.panel.legend_pos_loc 154 if self.panel is not None: 155 # TODO: grid/panel manip doesn't belong here 156 self.panel.subplot.grid(self.panel.grid_on) 157 if self.panel.legend is not None and self.panel.legend_pos_loc: 158 self.panel.legend._loc = self.panel.legend_pos_loc 157 159 self.idletimer.Restart(5, *args, **kwargs) # Delay by 5 ms 158 160 -
src/sas/sasgui/plottools/toolbar.py
rcb64d86 r34f23c8 158 158 """ 159 159 _dc = self.GetDC() 160 (_dcX, _dcY) = _dc.GetSizeTuple()161 (_bmpX,_bmpY)= self.canvas.GetSize()160 _dcX, _dcY = _dc.GetSize() 161 _bmpX, _bmpY = self.canvas.GetSize() 162 162 _scale = min(_dcX/_bmpX, _dcY/_bmpY) 163 163 _dc.SetUserScale(_scale, _scale) -
src/sas/sasview/sasview.py
r5251ec6 r0dde203 227 227 try: 228 228 logger.info("Wx version: %s", wx.__version__) 229 logger.info("Wx PlatformInfo: %s", wx.PlatformInfo) 229 230 except AttributeError: 230 231 logger.error("Wx version: error reading version") … … 233 234 if "phoenix" in wx.PlatformInfo: 234 235 #wx.NewId = wx.Window.NewControlId 235 pass 236 from . import wx4cruft 237 wx4cruft.patch_py_editor() 236 238 else: 237 239 from . import wxcruft
Note: See TracChangeset
for help on using the changeset viewer.