Changeset a47d0c8 in sasview for src/sas/sasgui
- Timestamp:
- Aug 12, 2016 6:40:40 AM (8 years ago)
- Branches:
- master, ESS_GUI, ESS_GUI_Docs, ESS_GUI_batch_fitting, ESS_GUI_bumps_abstraction, ESS_GUI_iss1116, ESS_GUI_iss879, ESS_GUI_iss959, ESS_GUI_opencl, ESS_GUI_ordering, ESS_GUI_sync_sascalc, costrafo411, magnetic_scatt, release-4.1.1, release-4.1.2, release-4.2.2, ticket-1009, ticket-1094-headless, ticket-1242-2d-resolution, ticket-1243, ticket-1249, ticket885, unittest-saveload
- Children:
- 1925a8e
- Parents:
- 2c627ad (diff), 2cff9db (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. - Location:
- src/sas/sasgui
- Files:
-
- 11 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/sasgui/guiframe/local_perspectives/plotting/Plotter1D.py
r5a54aa4 ra47d0c8 580 580 self._slicerpop.set_graph(self.graph) 581 581 ids = iter(self._menu_ids) 582 if not self.graph.selected_plottable in self.plots: 583 584 585 586 587 588 589 590 591 592 593 594 595 596 582 583 # Various plot options 584 wx_id = ids.next() 585 self._slicerpop.Append(wx_id, '&Save Image', 'Save image as PNG') 586 wx.EVT_MENU(self, wx_id, self.onSaveImage) 587 wx_id = ids.next() 588 self._slicerpop.Append(wx_id, '&Print Image', 'Print image ') 589 wx.EVT_MENU(self, wx_id, self.onPrint) 590 591 wx_id = ids.next() 592 self._slicerpop.Append(wx_id, '&Copy to Clipboard', 593 'Copy to the clipboard') 594 wx.EVT_MENU(self, wx_id, self.OnCopyFigureMenu) 595 596 self._slicerpop.AppendSeparator() 597 597 598 598 for plot in self.plots.values(): … … 617 617 item_list = self.parent.get_current_context_menu(self) 618 618 if (not item_list == None) and (not len(item_list) == 0): 619 # Note: reusing menu ids in submenu. This code works because 620 # IdItems is set up as a lazy iterator returning each id in 621 # sequence, creating new ids as needed so it never runs out. 622 # zip() is set up to stop when any iterator is empty, so it 623 # only asks for the number of ids in item_list. 624 for item, wx_id in zip(item_list, self._menu_ids): 619 for item, wx_id in zip(item_list, [ids.next() for i in range(len(item_list))]): 625 620 626 621 try: … … 671 666 # Option to hide 672 667 # TODO: implement functionality to hide a plottable (legend click) 673 if not self.graph.selected_plottable in self.plots: 668 669 self._slicerpop.AppendSeparator() 670 loc_menu = wx.Menu() 671 for label in self._loc_labels: 672 wx_id = ids.next() 673 loc_menu.Append(wx_id, str(label), str(label)) 674 wx.EVT_MENU(self, wx_id, self.onChangeLegendLoc) 675 676 wx_id = ids.next() 677 self._slicerpop.Append(wx_id, '&Modify Graph Appearance', 678 'Modify graph appearance') 679 wx.EVT_MENU(self, wx_id, self.modifyGraphAppearance) 680 self._slicerpop.AppendSeparator() 681 682 683 if self.position != None: 684 wx_id = ids.next() 685 self._slicerpop.Append(wx_id, '&Add Text') 686 wx.EVT_MENU(self, wx_id, self._on_addtext) 687 wx_id = ids.next() 688 self._slicerpop.Append(wx_id, '&Remove Text') 689 wx.EVT_MENU(self, wx_id, self._on_removetext) 674 690 self._slicerpop.AppendSeparator() 675 loc_menu = wx.Menu() 676 for label in self._loc_labels: 677 wx_id = ids.next() 678 loc_menu.Append(wx_id, str(label), str(label)) 679 wx.EVT_MENU(self, wx_id, self.onChangeLegendLoc) 680 681 wx_id = ids.next() 682 self._slicerpop.Append(wx_id, '&Modify Graph Appearance', 683 'Modify graph appearance') 684 wx.EVT_MENU(self, wx_id, self.modifyGraphAppearance) 685 self._slicerpop.AppendSeparator() 686 687 688 if self.position != None: 689 wx_id = ids.next() 690 self._slicerpop.Append(wx_id, '&Add Text') 691 wx.EVT_MENU(self, wx_id, self._on_addtext) 692 wx_id = ids.next() 693 self._slicerpop.Append(wx_id, '&Remove Text') 694 wx.EVT_MENU(self, wx_id, self._on_removetext) 695 self._slicerpop.AppendSeparator() 696 wx_id = ids.next() 697 self._slicerpop.Append(wx_id, '&Change Scale') 698 wx.EVT_MENU(self, wx_id, self._onProperties) 691 wx_id = ids.next() 692 self._slicerpop.Append(wx_id, '&Change Scale') 693 wx.EVT_MENU(self, wx_id, self._onProperties) 694 self._slicerpop.AppendSeparator() 695 wx_id = ids.next() 696 self._slicerpop.Append(wx_id, '&Reset Graph Range') 697 wx.EVT_MENU(self, wx_id, self.onResetGraph) 698 699 if self.parent.ClassName.count('wxDialog') == 0: 699 700 self._slicerpop.AppendSeparator() 700 701 wx_id = ids.next() 701 self._slicerpop.Append(wx_id, '&Reset Graph Range') 702 wx.EVT_MENU(self, wx_id, self.onResetGraph) 703 704 if self.parent.ClassName.count('wxDialog') == 0: 705 self._slicerpop.AppendSeparator() 706 wx_id = ids.next() 707 self._slicerpop.Append(wx_id, '&Window Title') 708 wx.EVT_MENU(self, wx_id, self.onChangeCaption) 702 self._slicerpop.Append(wx_id, '&Window Title') 703 wx.EVT_MENU(self, wx_id, self.onChangeCaption) 709 704 try: 710 705 pos_evt = event.GetPosition() -
src/sas/sasgui/guiframe/local_perspectives/plotting/Plotter2D.py
rd85c194 r1a696bf 293 293 294 294 wx_id = ids.next() 295 slicerpop.Append(wx_id, '&Save Image' )295 slicerpop.Append(wx_id, '&Save Image', 'Save image as png') 296 296 wx.EVT_MENU(self, wx_id, self.onSaveImage) 297 297 … … 320 320 if (not item_list == None) and (not len(item_list) == 0) and\ 321 321 self.data2D.name.split(" ")[0] != 'Residuals': 322 # The line above; Not for trunk 323 # Note: reusing menu ids for the sub-menus. See Plotter1D. 324 for item, wx_id in zip(item_list, self._menu_ids): 322 for item, wx_id in zip(item_list, [ids.next() for i in range(len(item_list))]): 325 323 try: 326 324 slicerpop.Append(wx_id, item[0], item[1]) -
src/sas/sasgui/guiframe/local_perspectives/plotting/SimplePlot.py
rd85c194 r25b9707a 188 188 """ 189 189 def __init__(self, parent, id, title, scale='log_{10}', 190 size=wx.Size(550, 470) ):190 size=wx.Size(550, 470), show_menu_icons=True): 191 191 """ 192 192 comment … … 202 202 self._default_save_location = None 203 203 self.scale = scale 204 self._show_menu_icons = show_menu_icons 204 205 self.plotpanel = SimplePlotPanel(self, -1) 205 206 self._build_menubar() … … 213 214 quit_bmp = wx.ArtProvider.GetBitmap(wx.ART_QUIT, wx.ART_TOOLBAR, tsize) 214 215 print_bmp = wx.ArtProvider.GetBitmap(wx.ART_PRINT, wx.ART_TOOLBAR, tsize) 215 preview_bmp = wx.ArtProvider.GetBitmap(wx.ART_REPORT_VIEW, wx.ART_TOOLBAR, tsize)216 216 copy_bmp = wx.ArtProvider.GetBitmap(wx.ART_COPY, wx.ART_TOOLBAR, tsize) 217 217 menu_bar = wx.MenuBar() … … 219 219 menu = wx.Menu() 220 220 id = wx.NewId() 221 item = wx.MenuItem(menu, id, "&Save Image") 222 item.SetBitmap(save_bmp) 223 menu.AppendItem(item) 221 save_item = wx.MenuItem(menu, id, "&Save Image") 222 menu.AppendItem(save_item) 224 223 wx.EVT_MENU(self, id, self.on_save_file) 225 224 226 225 id = wx.NewId() 227 item = wx.MenuItem(menu, id, "&Print Image") 228 item.SetBitmap(print_bmp) 229 menu.AppendItem(item) 226 print_item = wx.MenuItem(menu, id, "&Print Image") 227 menu.AppendItem(print_item) 230 228 wx.EVT_MENU(self, id, self.on_print_image) 231 229 232 230 menu.AppendSeparator() 233 231 id = wx.NewId() 234 item = wx.MenuItem(menu, id, "&Quit") 235 item.SetBitmap(quit_bmp) 236 menu.AppendItem(item) 232 quit_item = wx.MenuItem(menu, id, "&Quit") 233 menu.AppendItem(quit_item) 237 234 238 235 menu_bar.Append(menu, "&File") … … 241 238 menu_edit = wx.Menu() 242 239 id = wx.NewId() 243 item = wx.MenuItem(menu_edit, id, "&Copy") 244 item.SetBitmap(copy_bmp) 245 menu_edit.AppendItem(item) 240 copy_item = wx.MenuItem(menu_edit, id, "&Copy") 241 menu_edit.AppendItem(copy_item) 246 242 wx.EVT_MENU(self, id, self.on_copy_image) 243 244 if self._show_menu_icons: 245 save_item.SetBitmap(save_bmp) 246 print_item.SetBitmap(print_bmp) 247 quit_item.SetBitmap(quit_bmp) 248 copy_item.SetBitmap(copy_bmp) 247 249 248 250 menu_bar.Append(menu_edit, "&Edit") … … 324 326 except: 325 327 self.Destroy() 326 -
src/sas/sasgui/perspectives/calculator/data_operator.py
re871a2d r0e760e9 15 15 from sas.sasgui.guiframe.documentation_window import DocumentationWindow 16 16 17 #Control panel width 17 #Control panel width 18 18 if sys.platform.count("win32") > 0: 19 19 PANEL_TOP = 0 … … 156 156 157 157 wx.EVT_TEXT_ENTER(self.data_namectr, -1, self.on_name) 158 wx.EVT_TEXT _ENTER(self.numberctr, -1, self.on_number)158 wx.EVT_TEXT(self.numberctr, -1, self.on_number) 159 159 wx.EVT_COMBOBOX(self.data1_cbox, -1, self.on_select_data1) 160 160 wx.EVT_COMBOBOX(self.operator_cbox, -1, self.on_select_operator) … … 235 235 self.name_sizer.Layout() 236 236 237 def on_number(self, event=None ):237 def on_number(self, event=None, control=None): 238 238 """ 239 239 On selecting Number for Data2 240 240 """ 241 241 self.send_warnings('') 242 item = event.GetEventObject() 242 item = control 243 if item is None and event is not None: 244 item = event.GetEventObject() 245 elif item is None: 246 raise ValueError("Event or control must be supplied") 243 247 text = item.GetValue().strip() 244 248 if self.numberctr.IsShown(): … … 251 255 except: 252 256 self._set_textctrl_color(self.numberctr, 'pink') 253 msg = "DataOperation: Number requires a float number." 254 self.send_warnings(msg, 'error') 255 return 257 if event is None: 258 msg = "DataOperation: Number requires a float number." 259 self.send_warnings(msg, 'error') 260 return False 256 261 else: 257 262 self._set_textctrl_color(self.numberctr, self.color) … … 263 268 self.draw_output(self.output) 264 269 self.Refresh() 270 return True 265 271 266 272 def on_select_data1(self, event=None): … … 607 613 wx.MessageBox(msg, 'Error') 608 614 return 615 if self.numberctr.IsEnabled() and self.numberctr.IsShown(): 616 valid_num = self.on_number(control=self.numberctr) 617 if not valid_num: 618 return 609 619 # send data to data manager 610 620 self.output.name = name … … 731 741 #add plot 732 742 self.graph.add(plot) 733 #draw 743 #draw 734 744 self.graph.render(self) 735 745 … … 985 995 window = DataOperatorWindow(parent=None, data=[], title="Data Editor") 986 996 app.MainLoop() 987 -
src/sas/sasgui/perspectives/calculator/image_viewer.py
rd0248bd r25b9707a 73 73 parent.put_icon(plot_frame) 74 74 except: 75 print "parent", parent76 75 err_msg += "Failed to load '%s'.\n" % basename 77 76 if err_msg: … … 109 108 """ 110 109 # Initialize the Frame object 111 PlotFrame.__init__(self, parent, id, title, scale, size) 110 PlotFrame.__init__(self, parent, id, title, scale, size, 111 show_menu_icons=False) 112 112 self.parent = parent 113 113 self.data = image … … 437 437 ImageView(None).load() 438 438 app.MainLoop() 439 -
src/sas/sasgui/plottools/PlotPanel.py
rdd5bf63 r1ed6be7 713 713 if dial.ShowModal() == wx.ID_OK: 714 714 self.xLabel, self.yLabel, self.viewModel = dial.getValues() 715 if self.viewModel == "Linear y vs x":716 self.xLabel = "x"717 self.yLabel = "y"718 self.viewModel = "--"719 dial.setValues(self.xLabel, self.yLabel, self.viewModel)720 if self.viewModel == "Guinier lny vs x^(2)":721 self.xLabel = "x^(2)"722 self.yLabel = "ln(y)"723 self.viewModel = "--"724 dial.setValues(self.xLabel, self.yLabel, self.viewModel)725 if self.viewModel == "XS Guinier ln(y*x) vs x^(2)":726 self.xLabel = "x^(2)"727 self.yLabel = "ln(y*x)"728 self.viewModel = "--"729 dial.setValues(self.xLabel, self.yLabel, self.viewModel)730 if self.viewModel == "Porod y*x^(4) vs x^(4)":731 self.xLabel = "x^(4)"732 self.yLabel = "y*x^(4)"733 self.viewModel = "--"734 dial.setValues(self.xLabel, self.yLabel, self.viewModel)735 715 self._onEVT_FUNC_PROPERTY() 736 716 dial.Destroy() … … 1211 1191 1212 1192 # Properties defined by plot 1213 1193 1214 1194 # Ricardo: 1215 # A empty label "$$" will prevent the panel from displaying! 1216 1195 # A empty label "$$" will prevent the panel from displaying! 1217 1196 if prop["xlabel"]: 1218 1197 self.subplot.set_xlabel(r"$%s$"%prop["xlabel"]) … … 1220 1199 self.subplot.set_ylabel(r"$%s$"%prop["ylabel"]) 1221 1200 self.subplot.set_title(prop["title"]) 1222 1201 1223 1202 1224 1203 def clear(self): … … 1564 1543 bins=[self.y_bins, self.x_bins], 1565 1544 weights=self.data) 1566 # Now, normalize the image by weights only for weights>1: 1545 # Now, normalize the image by weights only for weights>1: 1567 1546 # If weight == 1, there is only one data point in the bin so 1568 1547 # that no normalization is required. … … 1760 1739 for item in list: 1761 1740 item.setLabel(self.xLabel, self.yLabel) 1762 1763 1741 # control axis labels from the panel itself 1764 1742 yname, yunits = item.get_yaxis() … … 1790 1768 if self.xLabel == "ln(x)": 1791 1769 item.transformX(transform.toLogX, transform.errToLogX) 1792 self.graph._xaxis_transformed("\ln \\ %s" % xname, "%s" % xunits)1770 self.graph._xaxis_transformed("\ln{(%s)}" % xname, "%s" % xunits) 1793 1771 if self.xLabel == "log10(x)": 1794 1772 item.transformX(transform.toX_pos, transform.errToX_pos) … … 1802 1780 if self.yLabel == "ln(y)": 1803 1781 item.transformY(transform.toLogX, transform.errToLogX) 1804 self.graph._yaxis_transformed("\ln \\ %s" % yname, "%s" % yunits)1782 self.graph._yaxis_transformed("\ln{(%s)}" % yname, "%s" % yunits) 1805 1783 if self.yLabel == "y": 1806 1784 item.transformY(transform.toX, transform.errToX) … … 1818 1796 yunits = convert_unit(-1, yunits) 1819 1797 self.graph._yaxis_transformed("1/%s" % yname, "%s" % yunits) 1798 if self.yLabel == "y*x^(2)": 1799 item.transformY(transform.toYX2, transform.errToYX2) 1800 xunits = convert_unit(2, self.xaxis_unit) 1801 self.graph._yaxis_transformed("%s \ \ %s^{2}" % (yname, xname), 1802 "%s%s" % (yunits, xunits)) 1820 1803 if self.yLabel == "y*x^(4)": 1821 1804 item.transformY(transform.toYX4, transform.errToYX4) … … 1831 1814 if self.yLabel == "ln(y*x)": 1832 1815 item.transformY(transform.toLogXY, transform.errToLogXY) 1833 self.graph._yaxis_transformed("\ln (%s \ \ %s)" % (yname, xname),1816 self.graph._yaxis_transformed("\ln{(%s \ \ %s)}" % (yname, xname), 1834 1817 "%s%s" % (yunits, self.xaxis_unit)) 1835 1818 if self.yLabel == "ln(y*x^(2))": … … 1847 1830 xunits = convert_unit(4, self.xaxis_unit) 1848 1831 _yscale = 'log' 1849 self.graph._yaxis_transformed("%s \ \ %s^{4}" % (yname, xname),1850 "%s%s" % (yunits, xunits))1851 if self.viewModel == "Guinier lny vs x^(2)":1852 item.transformX(transform.toX2, transform.errToX2)1853 xunits = convert_unit(2, xunits)1854 self.graph._xaxis_transformed("%s^{2}" % xname, "%s" % xunits)1855 item.transformY(transform.toLogX, transform.errToLogX)1856 self.graph._yaxis_transformed("\ln\ \ %s" % yname, "%s" % yunits)1857 if self.viewModel == "Porod y*x^(4) vs x^(4)":1858 item.transformX(transform.toX4, transform.errToX4)1859 xunits = convert_unit(4, self.xaxis_unit)1860 self.graph._xaxis_transformed("%s^{4}" % xname, "%s" % xunits)1861 item.transformY(transform.toYX4, transform.errToYX4)1862 1832 self.graph._yaxis_transformed("%s \ \ %s^{4}" % (yname, xname), 1863 1833 "%s%s" % (yunits, xunits)) -
src/sas/sasgui/plottools/PropertyDialog.py
r3409a90 r5129686 23 23 iy += 1 24 24 ix = 1 25 self.xvalue = wx.ComboBox(self, -1 )25 self.xvalue = wx.ComboBox(self, -1, style=wx.CB_READONLY) 26 26 x_size += self.xvalue.GetSize()[0] 27 sizer.Add(self.xvalue, (iy, ix), (1, 1), wx. EXPAND | wx.ADJUST_MINSIZE, 0)27 sizer.Add(self.xvalue, (iy, ix), (1, 1), wx.ADJUST_MINSIZE, 0) 28 28 29 29 ix += 2 30 self.yvalue = wx.ComboBox(self, -1 )30 self.yvalue = wx.ComboBox(self, -1, style=wx.CB_READONLY) 31 31 x_size += self.yvalue.GetSize()[0] 32 sizer.Add(self.yvalue, (iy, ix), (1, 1), wx. EXPAND | wx.ADJUST_MINSIZE, 0)32 sizer.Add(self.yvalue, (iy, ix), (1, 1), wx.ADJUST_MINSIZE, 0) 33 33 34 34 ix += 2 35 self.view = wx.ComboBox(self, -1) 35 self.view = wx.ComboBox(self, -1, style=wx.CB_READONLY) 36 self.view.Bind(wx.EVT_COMBOBOX, self.viewChanged) 36 37 x_size += self.view.GetSize()[0] 37 38 self.view.SetMinSize((160, 30)) … … 64 65 self.yvalue.Insert("ln(y)", 2) 65 66 self.yvalue.Insert("y^(2)", 3) 66 self.yvalue.Insert("y*x^(4)", 4) 67 self.yvalue.Insert("1/sqrt(y)", 5) 68 self.yvalue.Insert("log10(y)", 6) 69 self.yvalue.Insert("ln(y*x)", 7) 70 self.yvalue.Insert("ln(y*x^(2))", 8) 71 self.yvalue.Insert("ln(y*x^(4))", 9) 72 self.yvalue.Insert("log10(y*x^(4))", 10) 67 self.yvalue.Insert("y*x^(2)", 4) 68 self.yvalue.Insert("y*x^(4)", 5) 69 self.yvalue.Insert("1/sqrt(y)", 6) 70 self.yvalue.Insert("log10(y)", 7) 71 self.yvalue.Insert("ln(y*x)", 8) 72 self.yvalue.Insert("ln(y*x^(2))", 9) 73 self.yvalue.Insert("ln(y*x^(4))", 10) 74 self.yvalue.Insert("log10(y*x^(4))", 11) 73 75 # type of view or model used 74 76 self.view.SetValue("--") … … 78 80 self.view.Insert("XS Guinier ln(y*x) vs x^(2)", 3) 79 81 self.view.Insert("Porod y*x^(4) vs x^(4)", 4) 80 # This did not work in 3.1.2 and does not work now. 81 # prefer to fix (should not be too hard) but for the moment 82 # am removing as an option the user sees so they don't get 83 # disappointed. PDB 7/10/2016 84 # self.view.Insert("Kratky y*x^(2) vs x", 5) 82 self.view.Insert("Kratky y*x^(2) vs x", 5) 85 83 self.SetSizer(vbox) 86 84 self.Fit() 87 85 self.Centre() 86 87 def viewChanged(self, event): 88 event.Skip() 89 view = self.view.GetValue() 90 if view == "Linear y vs x": 91 self.xvalue.SetValue("x") 92 self.yvalue.SetValue("y") 93 elif view == "Guinier lny vs x^(2)": 94 self.xvalue.SetValue("x^(2)") 95 self.yvalue.SetValue("ln(y)") 96 elif view == "XS Guinier ln(y*x) vs x^(2)": 97 self.xvalue.SetValue("x^(2)") 98 self.yvalue.SetValue("ln(y*x)") 99 elif view == "Porod y*x^(4) vs x^(4)": 100 self.xvalue.SetValue("x^(4)") 101 self.yvalue.SetValue("y*x^(4)") 102 elif view == "Kratky y*x^(2) vs x": 103 self.xvalue.SetValue("x") 104 self.yvalue.SetValue("y*x^(2)") 88 105 89 106 def setValues(self, x, y, view): -
src/sas/sasgui/plottools/transform.py
rd7bb526 r8abd96d 291 291 292 292 293 def errToYX2( x, y, dx=None, dy=None):293 def errToYX2(y, x, dy=None, dx=None): 294 294 """ 295 295 """ … … 325 325 326 326 327 def errToLogYX2( x, y, dx=None, dy=None):327 def errToLogYX2(y, x, dy=None, dx=None): 328 328 """ 329 329 calculate error of Log(yx**2) … … 375 375 376 376 377 def errToLogYX4( x, y=None, dx=None, dy=None):377 def errToLogYX4(y, x, dy=None, dx=None): 378 378 """ 379 379 error for ln(y*x^(4)) … … 396 396 397 397 398 def errToYX4( x, y=None, dx=None, dy=None):398 def errToYX4(y, x, dy=None, dx=None): 399 399 """ 400 400 error for (y*x^(4))
Note: See TracChangeset
for help on using the changeset viewer.