Exemplo n.º 1
0
    def __init__(self, parent=None):
        super().__init__(parent=parent)

        self._background_imitem = pg.ImageItem(autoDownsample=True)
        self._pos_map_imitem = pg.ImageItem(autoDownsample=True)
        self._neg_map_imitem = pg.ImageItem(autoDownsample=True)

        self._viewbox = pgext.ViewBoxWithoutPadding(
            lockAspect=True,
            enableMouse=True,
            enableMenu=False,
            invertY=True,
        )

        self._viewbox.addItem(self._background_imitem)
        self._viewbox.addItem(self._pos_map_imitem)
        self._viewbox.addItem(self._neg_map_imitem)

        glayout = pg.GraphicsLayoutWidget(self)
        glayout.ci.layout.setContentsMargins(0, 0, 0, 0)
        glayout.addItem(self._viewbox)

        self._layout = QtWidgets.QVBoxLayout(self)
        self._layout.setContentsMargins(0, 0, 0, 0)
        self._layout.addWidget(glayout)

        self.setLayout(self._layout)
Exemplo n.º 2
0
    def __init__(self,
                 parent: QtCore.QObject = None,
                 colormap: ColormapType = HOT_COLORMAP):
        super().__init__(parent)

        self._colormap = colormap

        self._lower_threshold_spinbox = QtWidgets.QDoubleSpinBox(self)
        self._upper_threshold_spinbox = QtWidgets.QDoubleSpinBox(self)

        self._colorbar_imageitem = pg.ImageItem()

        self._colorbar_viewbox = pgext.ViewBoxWithoutPadding(
            lockAspect=False,
            enableMouse=False,
            enableMenu=False,
        )

        self._colorbar_viewbox.addItem(self._colorbar_imageitem)

        self._colorbar_layout = pg.GraphicsLayoutWidget(self)

        size_policy = self._colorbar_layout.sizePolicy()
        size_policy.setVerticalPolicy(QtWidgets.QSizePolicy.Fixed)
        size_policy.setHorizontalPolicy(QtWidgets.QSizePolicy.Ignored)
        self._colorbar_layout.setSizePolicy(size_policy)

        self._colorbar_layout.ci.layout.setContentsMargins(0, 0, 0, 0)
        self._colorbar_layout.addItem(self._colorbar_viewbox)

        layout = QtWidgets.QHBoxLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)

        layout.addWidget(self._lower_threshold_spinbox)
        layout.addWidget(self._colorbar_layout)
        layout.addWidget(self._upper_threshold_spinbox)
        layout.setStretch(1, 1)

        self.setLayout(layout)
        self.setMaximumWidth(400)

        self._lower_threshold_spinbox.setMinimum(self.MIN_THRESHOLD)
        self._lower_threshold_spinbox.setMaximum(self.MAX_THRESHOLD)
        self._lower_threshold_spinbox.setSingleStep(self.STEP)
        self._lower_threshold_spinbox.setValue(self.MIN_THRESHOLD)

        self._upper_threshold_spinbox.setMinimum(self.MIN_THRESHOLD)
        self._upper_threshold_spinbox.setMaximum(self.MAX_THRESHOLD)
        self._upper_threshold_spinbox.setSingleStep(self.STEP)
        self._upper_threshold_spinbox.setValue(self.MAX_THRESHOLD)

        self._map_no_value = 0.0
        self._auto_thresholds = True

        self._make_colorbar()

        self._lower_threshold_spinbox.valueChanged.connect(
            self._thresholds_changed)
        self._upper_threshold_spinbox.valueChanged.connect(
            self._thresholds_changed)