Ejemplo n.º 1
0
    def testColormapEditableMode(self):
        """Test that the colormapDialog is correctly updated when changing the
        colormap editable status"""
        colormap = Colormap(normalization='linear', vmin=1.0, vmax=10.0)
        self.colormapDiag.show()
        self.colormapDiag.setColormap(colormap)
        for editable in (True, False):
            with self.subTest(editable=editable):
                colormap.setEditable(editable)
                self.assertTrue(
                    self.colormapDiag._comboBoxColormap.isEnabled() is editable)
                self.assertTrue(
                    self.colormapDiag._minValue.isEnabled() is editable)
                self.assertTrue(
                    self.colormapDiag._maxValue.isEnabled() is editable)
                self.assertTrue(
                    self.colormapDiag._normButtonLinear.isEnabled() is editable)
                self.assertTrue(
                    self.colormapDiag._normButtonLog.isEnabled() is editable)

        # Make sure the reset button is also set to enable when edition mode is
        # False
        self.colormapDiag.setModal(False)
        colormap.setEditable(True)
        self.colormapDiag._normButtonLog.click()
        resetButton = self.colormapDiag._buttonsNonModal.button(qt.QDialogButtonBox.Reset)
        self.assertTrue(resetButton.isEnabled())
        colormap.setEditable(False)
        self.assertFalse(resetButton.isEnabled())
Ejemplo n.º 2
0
    def testColormapEditableMode(self):
        """Test that the colormapDialog is correctly updated when changing the
        colormap editable status"""
        colormap = Colormap(normalization='linear', vmin=1.0, vmax=10.0)
        self.colormapDiag.show()
        self.qapp.processEvents()
        self.colormapDiag.setColormap(colormap)
        for editable in (True, False):
            with self.subTest(editable=editable):
                colormap.setEditable(editable)
                self.assertTrue(
                    self.colormapDiag._comboBoxColormap.isEnabled() is editable
                )
                self.assertTrue(
                    self.colormapDiag._minValue.isEnabled() is editable)
                self.assertTrue(
                    self.colormapDiag._maxValue.isEnabled() is editable)
                self.assertTrue(
                    self.colormapDiag._normButtonLinear.isEnabled() is editable
                )
                self.assertTrue(
                    self.colormapDiag._normButtonLog.isEnabled() is editable)

        # Make sure the reset button is also set to enable when edition mode is
        # False
        self.colormapDiag.setModal(False)
        colormap.setEditable(True)
        self.colormapDiag._normButtonLog.click()
        resetButton = self.colormapDiag._buttonsNonModal.button(
            qt.QDialogButtonBox.Reset)
        self.assertTrue(resetButton.isEnabled())
        colormap.setEditable(False)
        self.assertFalse(resetButton.isEnabled())
Ejemplo n.º 3
0
 def testEditableMode(self):
     """Make sure the colormap will raise NotEditableError when try to
     change a colormap not editable"""
     colormap = Colormap()
     colormap.setEditable(False)
     with self.assertRaises(NotEditableError):
         colormap.setVRange(0., 1.)
     with self.assertRaises(NotEditableError):
         colormap.setVMin(1.)
     with self.assertRaises(NotEditableError):
         colormap.setVMax(1.)
     with self.assertRaises(NotEditableError):
         colormap.setNormalization(Colormap.LOGARITHM)
     with self.assertRaises(NotEditableError):
         colormap.setName('magma')
     with self.assertRaises(NotEditableError):
         colormap.setColormapLUT([[0., 0., 0.], [1., 1., 1.]])
     with self.assertRaises(NotEditableError):
         colormap._setFromDict(colormap._toDict())
     state = colormap.saveState()
     with self.assertRaises(NotEditableError):
         colormap.restoreState(state)
Ejemplo n.º 4
0
 def testEditableMode(self):
     """Make sure the colormap will raise NotEditableError when try to
     change a colormap not editable"""
     colormap = Colormap()
     colormap.setEditable(False)
     with self.assertRaises(NotEditableError):
         colormap.setVRange(0., 1.)
     with self.assertRaises(NotEditableError):
         colormap.setVMin(1.)
     with self.assertRaises(NotEditableError):
         colormap.setVMax(1.)
     with self.assertRaises(NotEditableError):
         colormap.setNormalization(Colormap.LOGARITHM)
     with self.assertRaises(NotEditableError):
         colormap.setName('magma')
     with self.assertRaises(NotEditableError):
         colormap.setColormapLUT(numpy.array([0, 1]))
     with self.assertRaises(NotEditableError):
         colormap._setFromDict(colormap._toDict())
     state = colormap.saveState()
     with self.assertRaises(NotEditableError):
         colormap.restoreState(state)