- Timestamp:
- Dec 21, 2016 5:46:29 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:
- aadf0af1
- Parents:
- d3ca363
- Location:
- src/sas/qtgui
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/sas/qtgui/GuiManager.py
rabc5e70 r257bd57 46 46 def __init__(self, mainWindow=None, reactor=None, parent=None): 47 47 """ 48 Initialize the manager as a child of MainWindow. 48 49 """ 49 50 self._workspace = mainWindow … … 185 186 186 187 def communicator(self): 187 """ 188 """ 188 """ Accessor for the communicator """ 189 189 return self.communicate 190 190 191 191 def reactor(self): 192 """ 193 """ 192 """ Accessor for the reactor """ 194 193 return self._reactor 195 194 196 195 def setReactor(self, reactor): 197 """ 198 """ 196 """ Reactor setter """ 199 197 self._reactor = reactor 200 198 201 199 def perspective(self): 202 """ 203 """ 200 """ Accessor for the perspective """ 204 201 return self._current_perspective 205 202 -
src/sas/qtgui/Plotter.py
rd3ca363 r257bd57 18 18 super(PlotterWidget, self).__init__(parent, manager=manager, quickplot=quickplot) 19 19 self.parent = parent 20 self.addText = AddText(self) 20 21 21 22 @property … … 84 85 ax.set_yscale(self.yscale) 85 86 87 # define the ranges 88 self.setRange = SetGraphRange(parent=self, 89 x_range=self.ax.get_xlim(), y_range=self.ax.get_ylim()) 90 86 91 # refresh canvas 87 92 self.canvas.draw() … … 155 160 Show a dialog allowing adding custom text to the chart 156 161 """ 157 self.addText = AddText(self)158 162 if self.addText.exec_() == QtGui.QDialog.Accepted: 159 163 # Retrieve the new text, its font and color … … 208 212 """ 209 213 # min and max of data 210 x_range = self.ax.get_xlim()211 y_range = self.ax.get_ylim()212 self.setRange = SetGraphRange(parent=self,213 x_range=x_range, y_range=y_range)214 214 if self.setRange.exec_() == QtGui.QDialog.Accepted: 215 215 x_range = self.setRange.xrange() -
src/sas/qtgui/UnitTesting/PlotterTest.py
rd3ca363 r257bd57 6 6 from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas 7 7 from mock import MagicMock 8 from mock import patch 8 9 9 10 ####### TEMP … … 23 24 def setUp(self): 24 25 '''create''' 26 25 27 self.plotter = Plotter.Plotter(None, quickplot=True) 26 28 self.data = Data1D(x=[1.0, 2.0, 3.0], … … 110 112 def testXYTransform(self): 111 113 """ Assure the unit/legend transformation is correct""" 112 self.plotter. data = self.data114 self.plotter.plot(self.data) 113 115 114 116 self.plotter.xyTransform(xLabel="x", yLabel="y") … … 156 158 def testAddText(self): 157 159 """ Checks the functionality of adding text to graph """ 158 pass 160 161 self.plotter.plot(self.data) 162 self.plotter.x_click = 100.0 163 self.plotter.y_click = 100.0 164 # modify the text edit control 165 test_text = "Smoke in cabin" 166 test_font = QtGui.QFont("Arial", 16, QtGui.QFont.Bold) 167 test_color = "#00FF00" 168 self.plotter.addText.textEdit.setText(test_text) 169 170 # Return the requested font parameters 171 self.plotter.addText.font = MagicMock(return_value = test_font) 172 self.plotter.addText.color = MagicMock(return_value = test_color) 173 # Return OK from the dialog 174 self.plotter.addText.exec_ = MagicMock(return_value = QtGui.QDialog.Accepted) 175 # Add text to graph 176 self.plotter.onAddText() 177 self.plotter.show() 178 # Check if the text was added properly 179 self.assertEqual(len(self.plotter.textList), 1) 180 self.assertEqual(self.plotter.textList[0].get_text(), test_text) 181 self.assertEqual(self.plotter.textList[0].get_color(), test_color) 182 self.assertEqual(self.plotter.textList[0].get_fontproperties().get_family()[0], 'Arial') 183 self.assertEqual(self.plotter.textList[0].get_fontproperties().get_size(), 16) 159 184 160 185 def testOnRemoveText(self): 161 186 """ Cheks if annotations can be removed from the graph """ 162 pass 187 188 # Add some text 189 self.plotter.plot(self.data) 190 test_text = "Safety instructions" 191 self.plotter.addText.textEdit.setText(test_text) 192 # Return OK from the dialog 193 self.plotter.addText.exec_ = MagicMock(return_value = QtGui.QDialog.Accepted) 194 # Add text to graph 195 self.plotter.onAddText() 196 self.plotter.show() 197 # Check if the text was added properly 198 self.assertEqual(len(self.plotter.textList), 1) 199 200 # Now, remove the text 201 self.plotter.onRemoveText() 202 203 # And assure no text is displayed 204 self.assertEqual(self.plotter.textList, []) 205 206 # Attempt removal on empty and check 207 self.plotter.onRemoveText() 208 self.assertEqual(self.plotter.textList, []) 163 209 164 210 def testOnSetGraphRange(self): 165 211 """ Cheks if the graph can be resized for range """ 166 pass 212 new_x = (1,2) 213 new_y = (10,11) 214 self.plotter.plot(self.data) 215 self.plotter.show() 216 self.plotter.setRange.exec_ = MagicMock(return_value = QtGui.QDialog.Accepted) 217 self.plotter.setRange.xrange = MagicMock(return_value = new_x) 218 self.plotter.setRange.yrange = MagicMock(return_value = new_y) 219 220 # Call the tested method 221 self.plotter.onSetGraphRange() 222 # See that ranges changed accordingly 223 self.assertEqual(self.plotter.ax.get_xlim(), new_x) 224 self.assertEqual(self.plotter.ax.get_ylim(), new_y) 167 225 168 226 def testOnResetGraphRange(self): 169 227 """ Cheks if the graph can be reset after resizing for range """ 170 pass 228 # New values 229 new_x = (1,2) 230 new_y = (10,11) 231 # define the plot 232 self.plotter.plot(self.data) 233 self.plotter.show() 234 235 # mock setRange methods 236 self.plotter.setRange.exec_ = MagicMock(return_value = QtGui.QDialog.Accepted) 237 self.plotter.setRange.xrange = MagicMock(return_value = new_x) 238 self.plotter.setRange.yrange = MagicMock(return_value = new_y) 239 240 # Change the axes range 241 self.plotter.onSetGraphRange() 242 243 # Now, reset the range back 244 self.plotter.onResetGraphRange() 245 246 # See that ranges are changed 247 self.assertNotEqual(self.plotter.ax.get_xlim(), new_x) 248 self.assertNotEqual(self.plotter.ax.get_ylim(), new_y) 171 249 172 250 if __name__ == "__main__":
Note: See TracChangeset
for help on using the changeset viewer.