class TestColormapAction(TestCaseQt): def setUp(self): TestCaseQt.setUp(self) self.plot = PlotWindow() self.plot.setAttribute(qt.Qt.WA_DeleteOnClose) self.colormap1 = Colormap(name='blue', vmin=0.0, vmax=1.0, normalization='linear') self.colormap2 = Colormap(name='red', vmin=10.0, vmax=100.0, normalization='log') self.defaultColormap = self.plot.getDefaultColormap() self.plot.getColormapAction()._actionTriggered(checked=True) self.colormapDialog = self.plot.getColormapAction()._dialog self.colormapDialog.setAttribute(qt.Qt.WA_DeleteOnClose) def tearDown(self): self.colormapDialog.close() self.plot.close() del self.colormapDialog del self.plot TestCaseQt.tearDown(self) def testActiveColormap(self): self.assertTrue( self.colormapDialog.getColormap() is self.defaultColormap) self.plot.addImage(data=numpy.random.rand(10, 10), legend='img1', origin=(0, 0), colormap=self.colormap1) self.plot.setActiveImage('img1') self.assertTrue(self.colormapDialog.getColormap() is self.colormap1) self.plot.addImage(data=numpy.random.rand(10, 10), legend='img2', origin=(0, 0), colormap=self.colormap2) self.plot.addImage(data=numpy.random.rand(10, 10), legend='img3', origin=(0, 0)) self.plot.setActiveImage('img3') self.assertTrue( self.colormapDialog.getColormap() is self.defaultColormap) self.plot.getActiveImage().setColormap(self.colormap2) self.assertTrue(self.colormapDialog.getColormap() is self.colormap2) self.plot.remove('img2') self.plot.remove('img3') self.plot.remove('img1') self.assertTrue( self.colormapDialog.getColormap() is self.defaultColormap) def testShowHideColormapDialog(self): self.plot.getColormapAction()._actionTriggered(checked=False) self.assertFalse(self.plot.getColormapAction().isChecked()) self.plot.getColormapAction()._actionTriggered(checked=True) self.assertTrue(self.plot.getColormapAction().isChecked()) self.plot.addImage(data=numpy.random.rand(10, 10), legend='img1', origin=(0, 0), colormap=self.colormap1) self.colormap1.setName('red') self.plot.getColormapAction()._actionTriggered() self.colormap1.setName('blue') self.colormapDialog.close() self.assertFalse(self.plot.getColormapAction().isChecked())
class TestColormapAction(TestCaseQt): def setUp(self): TestCaseQt.setUp(self) self.plot = PlotWindow() self.plot.setAttribute(qt.Qt.WA_DeleteOnClose) self.colormap1 = Colormap(name='blue', vmin=0.0, vmax=1.0, normalization='linear') self.colormap2 = Colormap(name='red', vmin=10.0, vmax=100.0, normalization='log') self.defaultColormap = self.plot.getDefaultColormap() self.plot.getColormapAction()._actionTriggered(checked=True) self.colormapDialog = self.plot.getColormapAction()._dialog self.colormapDialog.setAttribute(qt.Qt.WA_DeleteOnClose) def tearDown(self): self.colormapDialog.close() self.plot.close() del self.colormapDialog del self.plot TestCaseQt.tearDown(self) def testActiveColormap(self): self.assertTrue(self.colormapDialog.getColormap() is self.defaultColormap) self.plot.addImage(data=numpy.random.rand(10, 10), legend='img1', origin=(0, 0), colormap=self.colormap1) self.plot.setActiveImage('img1') self.assertTrue(self.colormapDialog.getColormap() is self.colormap1) self.plot.addImage(data=numpy.random.rand(10, 10), legend='img2', origin=(0, 0), colormap=self.colormap2) self.plot.addImage(data=numpy.random.rand(10, 10), legend='img3', origin=(0, 0)) self.plot.setActiveImage('img3') self.assertTrue(self.colormapDialog.getColormap() is self.defaultColormap) self.plot.getActiveImage().setColormap(self.colormap2) self.assertTrue(self.colormapDialog.getColormap() is self.colormap2) self.plot.remove('img2') self.plot.remove('img3') self.plot.remove('img1') self.assertTrue(self.colormapDialog.getColormap() is self.defaultColormap) def testShowHideColormapDialog(self): self.plot.getColormapAction()._actionTriggered(checked=False) self.assertFalse(self.plot.getColormapAction().isChecked()) self.plot.getColormapAction()._actionTriggered(checked=True) self.assertTrue(self.plot.getColormapAction().isChecked()) self.plot.addImage(data=numpy.random.rand(10, 10), legend='img1', origin=(0, 0), colormap=self.colormap1) self.colormap1.setName('red') self.plot.getColormapAction()._actionTriggered() self.colormap1.setName('blue') self.colormapDialog.close() self.assertFalse(self.plot.getColormapAction().isChecked())
def plot(qapp): plot = PlotWindow() plot.setAttribute(qt.Qt.WA_DeleteOnClose) yield weakref.proxy(plot) plot.close() qapp.processEvents()