Changeset d620d03c in sasview for src/sas/sasgui/perspectives
- Timestamp:
- Apr 1, 2019 9:35:50 PM (6 years ago)
- Parents:
- fa307dd (diff), 0dde203 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent. - git-author:
- Paul Kienzle <pkienzle@…> (04/01/19 21:35:50)
- git-committer:
- GitHub <noreply@…> (04/01/19 21:35:50)
- Location:
- src/sas/sasgui/perspectives
- Files:
-
- 4 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
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
r82d88d5 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/perspectives/fitting/media/fitting.rst
rc926a97 r332c10d 17 17 Smearing Functions <resolution> 18 18 19 Fitting Models with Structure Factors <fitting_sq> 20 21 Writing a Plugin Model <plugin> 22 19 23 Polarisation/Magnetic Scattering <magnetism/magnetism> 20 24 21 25 Oriented Particles <orientation/orientation> 22 26 … … 27 31 Fitting SESANS Data <sesans/sesans_fitting> 28 32 29 Writing a Plugin Model <plugin>30 31 33 Computations with a GPU <gpu_setup> 32 34 -
src/sas/sasgui/perspectives/fitting/media/fitting_help.rst
r9258c43c rfa307dd 42 42 * *Ellipsoid* - ellipsoidal shapes (oblate,prolate, core shell, etc) 43 43 * *Parellelepiped* - as the name implies 44 * *Sphere* - s heroidal shapes (sphere, core multishell, vesicle, etc)44 * *Sphere* - spheroidal shapes (sphere, core multishell, vesicle, etc) 45 45 * *Lamellae* - lamellar shapes (lamellar, core shell lamellar, stacked 46 46 lamellar, etc) … … 61 61 on the *Description* button to the right. 62 62 63 Product Models 64 ^^^^^^^^^^^^^^ 65 66 S(Q) models can be combined with many models in the other categories to 67 generate what SasView calls "product models". The combination can be done by 68 one of two methods, but how they behave is slightly different. 69 70 The first, most straightforward, method is simply to use the S(Q) drop-down in 71 the FitPage: 72 73 .. figure:: p_and_s_buttons.png 74 75 This example would then generate a product model with the following parameters: 76 77 .. figure:: p_and_s_buttons_parameters.png 78 79 The other method is to use the :ref:`Sum|Multi(p1,p2)` tool under Fitting > 80 Plugin Model Operations: 81 82 .. figure:: p_and_s_sum_model.png 83 84 This creates a product model with the following parameters: 85 86 .. figure:: p_and_s_sum_model_parameters.png 87 88 As can be seen, the second method has produced a product model with an extra 89 parameter: *radius_effective*. This is the radial distance determining the 90 range of the $S(Q)$ interaction and may, or may not, be the same as the 91 *radius*, in this example, depending on the concentration of the system. In 92 other systems, *radius_effective* may depend on the particle form (shape). 93 94 See :ref:`Product_Models` for more information. 95 63 96 Show 1D/2D 64 97 ^^^^^^^^^^ … … 119 152 120 153 For a complete list of all the library models available in SasView, see 121 the `Model Documentation <../../../ index.html>`_ .154 the `Model Documentation <../../../sasgui/perspectives/fitting/models/index.html>`_ . 122 155 123 156 It is also possible to add your own models. … … 217 250 a P(Q) model has been selected). 218 251 252 .. _Sum|Multi(p1,p2): 253 219 254 Sum|Multi(p1,p2) 220 255 ^^^^^^^^^^^^^^^^ … … 338 373 These optimisers form the *Bumps* package written by P Kienzle. For more information 339 374 on each optimiser, see the :ref:`Fitting_Documentation`. 375 376 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 377 378 Fitting Integer Parameters 379 -------------------------- 380 381 Most of the parameters in SasView models will naturally take floating point (decimal) 382 values, but there are some parameters which can only have integer values. Examples 383 include, but are not limited to, the number of shells in a multilayer vesicle, the 384 number of beads in a pearl necklace, the number of arms of a star polymer, and so on. 385 Wherever possible/recognised, the integer nature of a parameter is specified in the 386 respective model documentation and/or parameter table, so read the documentation 387 carefully! 388 389 Integer parameters must be fitted with care. 390 391 Start with your best possible guess for the value of the parameter. And using 392 *a priori* knowledge, fix as many of the other parameters as possible. 393 394 The SasView optimizers treat integer parameters internally as floating point 395 numbers, but the values presented to the user are truncated or rounded, as 396 appropriate. 397 398 In most instances integer parameters will probably be greater than zero. A good 399 policy in such cases is to use a constraint to enforce this. 400 401 Because an integer parameter should, by definition, only move in integer steps, 402 problems may be encountered if the optimizer step size is too small. Similarly, 403 be **very careful** about applying polydispersity to integer parameters. 404 405 The Levenberg-Marquardt and Quasi-Newton BFGS (and other derivative-based) 406 optimizers are probably best avoided for fitting models with integer parameters. 340 407 341 408 .. ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ
Note: See TracChangeset
for help on using the changeset viewer.