Пример #1
0
class AtContrastWidget(QtWidgets.QWidget):

    def __init__(self, parent, view, featuredlg=None, *args, **kw):
        super(AtContrastWidget, self).__init__(parent)
        self.view = view
        self.featuredlg = featuredlg
        self.parent = parent

        vbox = QtWidgets.QVBoxLayout(self)
        vbox.setContentsMargins(2, 2, 2, 2)

        self.enhancer = AtEnhancerWidget(self)
        vbox.addWidget(self.enhancer)
        self.enhancer.sliderReleased.connect(self.enhanceContrast)

    def setChannelNames(self, channels, colors):
        self.enhancer.clear()
        for channel, color in zip(channels, colors):
            self.enhancer.addChannel(cn.display(channel), color,
                                     no_auto_button=True)

    def updateView(self, index=None):
        channels = self.enhancer.channelFlags()
        for item in self.view.items:
                item.setActiveChannels(channels)
                item.toggleOutline(self.view.vflags & ViewFlags.Outline)
        self.enhanceContrast(index)

    def enhanceContrast(self, index=None):
        if index is None:
            index = self.enhancer.currentChannelIndex()

        try:
            QApplication.setOverrideCursor(QCursor(Qt.WaitCursor))
            lut = self.enhancer.lut_from_channel(index, 256)
            for item in self.view.items:
                item.enhancePixmap(index, lut)
        finally:
            QApplication.restoreOverrideCursor()