def __init__(self, parent=None, colormap=None): """ :param parent: Parent QWidget """ super(ArrayComplexImagePlot, self).__init__(parent) self.__signals = None self.__signals_names = None self.__x_axis = None self.__x_axis_name = None self.__y_axis = None self.__y_axis_name = None self._plot = ComplexImageView(self) if colormap is not None: for mode in (ComplexImageView.ComplexMode.ABSOLUTE, ComplexImageView.ComplexMode.SQUARE_AMPLITUDE, ComplexImageView.ComplexMode.REAL, ComplexImageView.ComplexMode.IMAGINARY): self._plot.setColormap(colormap, mode) self._plot.getPlot().getIntensityHistogramAction().setVisible(True) self._plot.setKeepDataAspectRatio(True) maskToolWidget = self._plot.getPlot().getMaskToolsDockWidget().widget() maskToolWidget.setItemMaskUpdated(True) # not closable self._selector = NumpyAxesSelector(self) self._selector.setNamedAxesSelectorVisibility(False) self._selector.selectionChanged.connect(self._updateImage) self._auxSigSlider = HorizontalSliderWithBrowser(parent=self) self._auxSigSlider.setMinimum(0) self._auxSigSlider.setValue(0) self._auxSigSlider.valueChanged[int].connect(self._sliderIdxChanged) self._auxSigSlider.setToolTip("Select auxiliary signals") layout = qt.QVBoxLayout() layout.addWidget(self._plot) layout.addWidget(self._selector) layout.addWidget(self._auxSigSlider) self.setLayout(layout)
def __init__(self, parent=None): """ :param parent: Parent QWidget """ super(ArrayImagePlot, self).__init__(parent) self.__signals = None self.__signals_names = None self.__x_axis = None self.__x_axis_name = None self.__y_axis = None self.__y_axis_name = None self._plot = Plot2D(self) self._plot.setDefaultColormap( Colormap(name="viridis", vmin=None, vmax=None, normalization=Colormap.LINEAR)) self._plot.getIntensityHistogramAction().setVisible(True) self.selectorDock = qt.QDockWidget("Data selector", self._plot) # not closable self.selectorDock.setFeatures(qt.QDockWidget.DockWidgetMovable | qt.QDockWidget.DockWidgetFloatable) self._selector = NumpyAxesSelector(self.selectorDock) self._selector.setNamedAxesSelectorVisibility(False) self._selector.selectionChanged.connect(self._updateImage) self._auxSigSlider = HorizontalSliderWithBrowser(parent=self) self._auxSigSlider.setMinimum(0) self._auxSigSlider.setValue(0) self._auxSigSlider.valueChanged[int].connect(self._sliderIdxChanged) self._auxSigSlider.setToolTip("Select auxiliary signals") layout = qt.QVBoxLayout() layout.addWidget(self._plot) layout.addWidget(self._auxSigSlider) self.selectorDock.setWidget(self._selector) self._plot.addTabbedDockWidget(self.selectorDock) self.setLayout(layout)
def __init__(self, parent=None): """Constructor :param parent: Parent of the widget """ super(_Axis, self).__init__(parent) self.__axisNumber = None self.__customAxisNames = set([]) self.__label = qt.QLabel(self) self.__axes = qt.QComboBox(self) self.__axes.currentIndexChanged[int].connect(self.__axisMappingChanged) self.__slider = HorizontalSliderWithBrowser(self) self.__slider.valueChanged[int].connect(self.__sliderValueChanged) layout = qt.QHBoxLayout(self) layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self.__label) layout.addWidget(self.__axes) layout.addWidget(self.__slider, 10000) layout.addStretch(1) self.setLayout(layout)
def __init__(self, parent=None): """ :param parent: Parent QWidget """ super(XYVScatterPlot, self).__init__(parent) self.__y_axis = None """1D array""" self.__y_axis_name = None self.__values = None """List of 1D arrays (for multiple scatters with identical x, y coordinates)""" self.__x_axis = None self.__x_axis_name = None self.__x_axis_errors = None self.__y_axis = None self.__y_axis_name = None self.__y_axis_errors = None self._plot = ScatterView(self) self._plot.setColormap( Colormap(name="viridis", vmin=None, vmax=None, normalization=Colormap.LINEAR)) self._slider = HorizontalSliderWithBrowser(parent=self) self._slider.setMinimum(0) self._slider.setValue(0) self._slider.valueChanged[int].connect(self._sliderIdxChanged) self._slider.setToolTip("Select auxiliary signals") layout = qt.QGridLayout() layout.setContentsMargins(0, 0, 0, 0) layout.addWidget(self._plot, 0, 0) layout.addWidget(self._slider, 1, 0) self.setLayout(layout)
def setArrayData(self, data, labels=None, copy=True, editable=False): """Set the data array. Update frame browsers and labels. :param data: Numpy array or similar object (e.g. nested sequence, h5py dataset...) :param labels: list of labels for each dimension of the array, or boolean ``True`` to use default labels ("dimension 0", "dimension 1", ...). `None` to disable labels (default). :param bool copy: If *True*, store a copy of *data* in the model. If *False*, store a reference to *data* if possible (only possible if *data* is a proper numpy array or an object that implements the same methods). :param bool editable: Flag to enable editing data. Default is *False* """ self._data_shape = _get_shape(data) n_widgets = len(self._browserWidgets) n_dimensions = len(self._data_shape) # Reset text of labels self._dimensionLabelsText = [] for i in range(n_dimensions): if labels in [True, 1]: label_text = "Dimension %d" % i elif labels is None or i >= len(labels): label_text = "" else: label_text = labels[i] self._dimensionLabelsText.append(label_text) # not enough widgets, create new ones (we need n_dim - 2) for i in range(n_widgets, n_dimensions - 2): browser = HorizontalSliderWithBrowser(self.browserContainer) self.browserLayout.addWidget(browser, i, 1) self._browserWidgets.append(browser) browser.valueChanged.connect(self._browserSlot) browser.setEnabled(False) browser.hide() label = qt.QLabel(self.browserContainer) self._browserLabels.append(label) self.browserLayout.addWidget(label, i, 0) label.hide() n_widgets = len(self._browserWidgets) for i in range(n_widgets): label = self._browserLabels[i] browser = self._browserWidgets[i] if (i + 2) < n_dimensions: label.setText(self._dimensionLabelsText[i]) browser.setRange(0, self._data_shape[i] - 1) browser.setEnabled(True) browser.show() if labels is not None: label.show() else: label.hide() else: browser.setEnabled(False) browser.hide() label.hide() # set model self.model.setArrayData(data, copy=copy, editable=editable) # some linux distributions need this call self.view.setModel(self.model) if editable: self.view.enableCut() self.view.enablePaste() # initialize & connect axesSelector self.axesSelector.setNDimensions(n_dimensions) self.axesSelector.sigDimensionsChanged.connect(self.setFrameAxes)