Changeset 092a3d9 in sasview
- Timestamp:
- Jan 20, 2017 8:26:35 AM (8 years ago)
- Branches:
- 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
- Children:
- 03c372d
- Parents:
- 0f3c22d
- Location:
- src/sas
- Files:
-
- 3 added
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/GUITests.py
r87cc73a r092a3d9 23 23 from UnitTesting import PlotPropertiesTest 24 24 from UnitTesting import PlotUtilitiesTest 25 from UnitTesting import ColorMapTest 25 26 26 27 def suite(): … … 48 49 unittest.makeSuite(PlotPropertiesTest.PlotPropertiesTest, 'test'), 49 50 unittest.makeSuite(PlotUtilitiesTest.PlotUtilitiesTest, 'test'), 51 unittest.makeSuite(ColorMapTest.ColorMapTest, 'test'), 50 52 ) 51 53 return unittest.TestSuite(suites) -
src/sas/qtgui/Plotter.py
r0f3c22d r092a3d9 28 28 self.plot_dict = {} 29 29 30 # Simple window for data display31 self.txt_widget = QtGui.QTextEdit(None)32 30 # Window for text add 33 31 self.addText = AddText(self) … … 336 334 self.canvas.draw_idle() 337 335 338 def onDataInfo(self, plot_data):339 """340 Displays data info text window for the selected plot341 """342 text_to_show = GuiUtils.retrieveData1d(plot_data)343 # Hardcoded sizes to enable full width rendering with default font344 self.txt_widget.resize(420,600)345 346 self.txt_widget.setReadOnly(True)347 self.txt_widget.setWindowFlags(QtCore.Qt.Window)348 self.txt_widget.setWindowIcon(QtGui.QIcon(":/res/ball.ico"))349 self.txt_widget.setWindowTitle("Data Info: %s" % plot_data.filename)350 self.txt_widget.insertPlainText(text_to_show)351 352 self.txt_widget.show()353 # Move the slider all the way up, if present354 vertical_scroll_bar = self.txt_widget.verticalScrollBar()355 vertical_scroll_bar.triggerAction(QtGui.QScrollBar.SliderToMinimum)356 357 def onSavePoints(self, plot_data):358 """359 Saves plot data to a file360 """361 GuiUtils.saveData1D(plot_data)362 363 336 def onLinearFit(self, id): 364 337 """ -
src/sas/qtgui/Plotter2D.py
rb46f285 r092a3d9 2 2 import numpy 3 3 import pylab 4 import functools 4 5 5 6 from PyQt4 import QtGui 7 from PyQt4 import QtCore 6 8 7 9 DEFAULT_CMAP = pylab.cm.jet … … 10 12 import sas.qtgui.PlotUtilities as PlotUtilities 11 13 from sas.qtgui.PlotterBase import PlotterBase 14 from sas.qtgui.ColorMap import ColorMap 12 15 from sas.sasgui.guiframe.dataFitting import Data2D 13 16 … … 22 25 self.dimension = dimension 23 26 super(Plotter2DWidget, self).__init__(parent, manager=manager, quickplot=quickplot) 27 28 self.cmap = DEFAULT_CMAP.name 29 # Default scale 30 self.scale = 'log_{10}' 24 31 25 32 @property … … 55 62 56 63 # Toggle the scale 57 zmin_2D_temp = self.zmin 58 zmax_2D_temp = self.zmax 59 # self.scale predefined in the baseclass 60 if self.scale == 'log_{10}': 61 self.scale = 'linear' 62 if not self.zmin is None: 63 zmin_2D_temp = numpy.power(10, self.zmin) 64 if not self.zmax is None: 65 zmax_2D_temp = numpy.power(10, self.zmax) 66 else: 67 self.scale = 'log_{10}' 68 if not self.zmin is None: 69 # min log value: no log(negative) 70 if self.zmin <= 0: 71 zmin_2D_temp = MIN_Z 72 else: 73 zmin_2D_temp = numpy.log10(self.zmin) 74 if not self.zmax is None: 75 zmax_2D_temp = numpy.log10(self.zmax) 64 zmin_2D_temp, zmax_2D_temp = self.calculateDepth() 76 65 77 66 # Prepare and show the plot … … 85 74 zmax=zmax_2D_temp) 86 75 76 def calculateDepth(self): 77 """ 78 Re-calculate the plot depth parameters depending on the scale 79 """ 80 # Toggle the scale 81 zmin_temp = self.zmin 82 zmax_temp = self.zmax 83 # self.scale predefined in the baseclass 84 if self.scale == 'log_{10}': 85 if self.zmin is not None: 86 zmin_temp = numpy.power(10, self.zmin) 87 if self.zmax is not None: 88 zmax_temp = numpy.power(10, self.zmax) 89 else: 90 if self.zmin is not None: 91 # min log value: no log(negative) 92 zmin_temp = MIN_Z if self.zmin <= 0 else numpy.log10(self.zmin) 93 if self.zmax is not None: 94 zmax_temp = numpy.log10(self.zmax) 95 96 return (zmin_temp, zmax_temp) 97 98 87 99 def createContextMenu(self): 88 100 """ … … 90 102 """ 91 103 self.defaultContextMenu() 104 105 self.contextMenu.addSeparator() 106 self.actionDataInfo = self.contextMenu.addAction("&DataInfo") 107 self.actionDataInfo.triggered.connect( 108 functools.partial(self.onDataInfo, self.data)) 109 110 self.actionSavePointsAsFile = self.contextMenu.addAction("&Save Points as a File") 111 self.actionSavePointsAsFile.triggered.connect( 112 functools.partial(self.onSavePoints, self.data)) 113 self.contextMenu.addSeparator() 114 115 self.actionCircularAverage = self.contextMenu.addAction("&Perform Circular Average") 116 self.actionCircularAverage.triggered.connect(self.onCircularAverage) 117 118 self.actionSectorView = self.contextMenu.addAction("&Sector [Q View]") 119 self.actionSectorView.triggered.connect(self.onSectorView) 120 self.actionAnnulusView = self.contextMenu.addAction("&Annulus [Phi View]") 121 self.actionAnnulusView.triggered.connect(self.onAnnulusView) 122 self.actionBoxSum = self.contextMenu.addAction("&Box Sum") 123 self.actionBoxSum.triggered.connect(self.onBoxSum) 124 self.actionBoxAveragingX = self.contextMenu.addAction("&Box Averaging in Qx") 125 self.actionBoxAveragingX.triggered.connect(self.onBoxAveragingX) 126 self.actionBoxAveragingY = self.contextMenu.addAction("&Box Averaging in Qy") 127 self.actionBoxAveragingY.triggered.connect(self.onBoxAveragingY) 128 self.contextMenu.addSeparator() 129 self.actionEditGraphLabel = self.contextMenu.addAction("&Edit Graph Label") 130 self.actionEditGraphLabel.triggered.connect(self.onEditgraphLabel) 131 self.contextMenu.addSeparator() 132 self.actionColorMap = self.contextMenu.addAction("&2D Color Map") 133 self.actionColorMap.triggered.connect(self.onColorMap) 134 self.contextMenu.addSeparator() 135 self.actionChangeScale = self.contextMenu.addAction("Toggle Linear/Log Scale") 136 self.actionChangeScale.triggered.connect(self.onToggleScale) 92 137 93 138 def createContextMenuQuick(self): … … 111 156 Toggle axis and replot image 112 157 """ 158 # self.scale predefined in the baseclass 159 if self.scale == 'log_{10}': 160 self.scale = 'linear' 161 else: 162 self.scale = 'log_{10}' 163 113 164 self.plot() 165 166 def onCircularAverage(self): 167 """ 168 """ 169 pass 170 171 def onSectorView(self): 172 """ 173 """ 174 pass 175 176 def onAnnulusView(self): 177 """ 178 """ 179 pass 180 181 def onBoxSum(self): 182 """ 183 """ 184 pass 185 186 def onBoxAveragingX(self): 187 """ 188 """ 189 pass 190 191 def onBoxAveragingY(self): 192 """ 193 """ 194 pass 195 196 def onEditgraphLabel(self): 197 """ 198 """ 199 pass 200 201 def onColorMap(self): 202 """ 203 Display the color map dialog and modify the plot's map accordingly 204 """ 205 color_map_dialog = ColorMap(self, cmap=self.cmap, 206 zmin=self.vmin, 207 zmax=self.vmax, 208 data=self.data) 209 210 if color_map_dialog.exec_() == QtGui.QDialog.Accepted: 211 self.cmap = color_map_dialog.cmap() 212 self.vmin, self.vmax = color_map_dialog.norm() 213 # Redraw the chart with new cmap 214 self.plot() 215 pass 114 216 115 217 def showPlot(self, data, qx_data, qy_data, xmin, xmax, ymin, ymax, … … 140 242 try: 141 243 if self.zmin <= 0 and len(output[output > 0]) > 0: 142 zmin_temp = self.zmin _2D244 zmin_temp = self.zmin 143 245 output[output > 0] = numpy.log10(output[output > 0]) 144 246 elif self.zmin <= 0: … … 185 287 cb.set_label('$' + self.scale + '$') 186 288 289 self.vmin = cb.vmin 290 self.vmax = cb.vmax 291 187 292 else: 188 293 # clear the previous 2D from memory -
src/sas/qtgui/PlotterBase.py
rb46f285 r092a3d9 3 3 4 4 from PyQt4 import QtGui 5 from PyQt4 import QtCore 5 6 6 7 # TODO: Replace the qt4agg calls below with qt5 equivalent. … … 16 17 from sas.sasgui.plottools.binder import BindArtist 17 18 19 import sas.qtgui.GuiUtils as GuiUtils 20 from sas.sasgui.guiframe.dataFitting import Data1D, Data2D 18 21 from sas.qtgui.ScaleProperties import ScaleProperties 19 22 from sas.qtgui.WindowTitle import WindowTitle … … 37 40 # ... and the toolbar with all the default MPL buttons 38 41 self.toolbar = NavigationToolbar(self.canvas, self) 42 43 # Simple window for data display 44 self.txt_widget = QtGui.QTextEdit(None) 39 45 40 46 # Set the layout and place the canvas widget in it. … … 474 480 if self._scale_yhi is not None and self._scale_ylo is not None: 475 481 ax.set_ylim(self._scale_ylo, self._scale_yhi) 482 483 def onDataInfo(self, plot_data): 484 """ 485 Displays data info text window for the selected plot 486 """ 487 if isinstance(plot_data, Data1D): 488 text_to_show = GuiUtils.retrieveData1d(plot_data) 489 else: 490 text_to_show = GuiUtils.retrieveData2d(plot_data) 491 # Hardcoded sizes to enable full width rendering with default font 492 self.txt_widget.resize(420,600) 493 494 self.txt_widget.setReadOnly(True) 495 self.txt_widget.setWindowFlags(QtCore.Qt.Window) 496 self.txt_widget.setWindowIcon(QtGui.QIcon(":/res/ball.ico")) 497 self.txt_widget.setWindowTitle("Data Info: %s" % plot_data.filename) 498 self.txt_widget.insertPlainText(text_to_show) 499 500 self.txt_widget.show() 501 # Move the slider all the way up, if present 502 vertical_scroll_bar = self.txt_widget.verticalScrollBar() 503 vertical_scroll_bar.triggerAction(QtGui.QScrollBar.SliderToMinimum) 504 505 def onSavePoints(self, plot_data): 506 """ 507 Saves plot data to a file 508 """ 509 if isinstance(plot_data, Data1D): 510 GuiUtils.saveData1D(plot_data) 511 else: 512 GuiUtils.saveData2D(plot_data) -
src/sas/qtgui/UnitTesting/Plotter2DTest.py
rb46f285 r092a3d9 13 13 from sas.sasgui.guiframe.dataFitting import Data1D 14 14 from sas.sasgui.guiframe.dataFitting import Data2D 15 from UnitTesting.TestUtils import WarningTestNotImplemented 15 16 16 17 # Tested module … … 60 61 61 62 self.assertTrue(FigureCanvas.draw_idle.called) 63 64 def testCalculateDepth(self): 65 ''' Test the depth calculator ''' 66 WarningTestNotImplemented() 67 68 def testOnColorMap(self): 69 ''' Respond to the color map event ''' 70 WarningTestNotImplemented() 62 71 63 72 def testOnToggleScale(self): -
src/sas/qtgui/run_tests.bat
r87cc73a r092a3d9 22 22 python -m UnitTesting.PlotPropertiesTest 23 23 python -m UnitTesting.PlotUtilitiesTest 24 python -m UnitTesting.ColorMapTest -
src/sas/qtgui/run_tests.sh
r87cc73a r092a3d9 21 21 python -m UnitTesting.PlotPropertiesTest 22 22 python -m UnitTesting.PlotUtilitiesTest 23 python -m UnitTesting.ColorMapTest -
src/sas/sasgui/plottools/config.py
r239214f r092a3d9 64 64 65 65 # this should happen after initial matplotlib configuration 66 from .toolbar import NavigationToolBar67 from matplotlib.backends import backend_wxagg68 backend_wxagg.NavigationToolbar2WxAgg = NavigationToolBar66 #from .toolbar import NavigationToolBar 67 #from matplotlib.backends import backend_wxagg 68 #backend_wxagg.NavigationToolbar2WxAgg = NavigationToolBar 69 69 70 70 # CRUFT: bumps 0.7.5.6 and older uses wrong toolbar 71 backend_wxagg.NavigationToolbar2Wx = NavigationToolBar71 #backend_wxagg.NavigationToolbar2Wx = NavigationToolBar -
src/sas/sasgui/plottools/toolbar.py
rd7bb526 r092a3d9 35 35 36 36 # CRUFT: mpl 1.1 uses save rather than save_figure 37 try: save_figure = NavigationToolbar2WxAgg.save38 except AttributeError: pass37 #try: save_figure = NavigationToolbar2WxAgg.save 38 #except AttributeError: pass 39 39 40 40 def _init_toolbar(self):
Note: See TracChangeset
for help on using the changeset viewer.