How to use the silx.gui.qt.Signal function in silx

To help you get started, we’ve selected a few silx examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github silx-kit / pyFAI / pyFAI / gui / tasks / MaskTask.py View on Github external
from .AbstractCalibrationTask import AbstractCalibrationTask
from ..CalibrationContext import CalibrationContext
from ..helper.SynchronizeRawView import SynchronizeRawView
from ..helper.MarkerManager import MarkerManager
from ..helper.SynchronizeMaskToolColor import SynchronizeMaskToolColor
from ..helper.SynchronizePlotBackground import SynchronizePlotBackground


_logger = logging.getLogger(__name__)


class _MaskToolsWidget(silx.gui.plot.MaskToolsWidget.MaskToolsWidget):
    """Inherite the silx mask to be able to save and restore internally
    imported/exported masks to the application model."""

    sigUserMaskChanged = qt.Signal()
    """Emitted when the user changes the mask.

    sigMaskChanged on silx 0.9 to not provide that. This signal is used with a
    filter.
    """

    def __init__(self, parent=None, plot=None):
        silx.gui.plot.MaskToolsWidget.MaskToolsWidget.__init__(self, parent=parent, plot=plot)
        self.__syncColor = SynchronizeMaskToolColor(self)
        self.sigMaskChanged.connect(self.__emitUserMaskChanged)

    def __emitUserMaskChanged(self):
        self.sigUserMaskChanged.emit()

    def __extractDirectory(self, filename):
        if filename is not None and filename != "":
github silx-kit / silx / silx / gui / fit / Parameters.py View on Github external
try:
        return float(sstring)
    except ValueError:
        return 0


class QComboTableItem(qt.QComboBox):
    """:class:`qt.QComboBox` augmented with a ``sigCellChanged`` signal
    to emit a tuple of ``(row, column)`` coordinates when the value is
    changed.

    This signal can be used to locate the modified combo box in a table.

    :param row: Row number of the table cell containing this widget
    :param col: Column number of the table cell containing this widget"""
    sigCellChanged = qt.Signal(int, int)
    """Signal emitted when this ``QComboBox`` is activated.
    A ``(row, column)`` tuple is passed."""

    def __init__(self, parent=None, row=None, col=None):
        self._row = row
        self._col = col
        qt.QComboBox.__init__(self, parent)
        self.activated[int].connect(self._cellChanged)

    def _cellChanged(self, idx):  # noqa
        self.sigCellChanged.emit(self._row, self._col)


class QCheckBoxItem(qt.QCheckBox):
    """:class:`qt.QCheckBox` augmented with a ``sigCellChanged`` signal
    to emit a tuple of ``(row, column)`` coordinates when the check box has
github silx-kit / silx / silx / gui / plot / tools / profile / core.py View on Github external
'yLabel',
        'colormap',
    ])


class ProfileRoiMixIn:
    """Base mix-in for ROI which can be used to select a profile.

    This mix-in have to be applied to a :class:`~silx.gui.plot.items.roi.RegionOfInterest`
    in order to be usable by a :class:`~silx.gui.plot.tools.profile.manager.ProfileManager`.
    """

    ITEM_KIND = None
    """Define the plot item which can be used with this profile ROI"""

    sigProfilePropertyChanged = qt.Signal()
    """Emitted when a property of the profile have changed"""

    def __init__(self, parent=None):
        self.__profileWindow = None
        self.__profileManager = None
        self.setName("Profile")
        self.setEditable(True)
        self.setSelectable(True)

    def invalidateProfile(self):
        """Must be called by the implementation when the profile have to be
        recomputed."""
        profileManager = self.getProfileManager()
        if profileManager is not None:
            profileManager.requestUpdateProfile(self)
github silx-kit / silx / silx / gui / plot / StatsWidget.py View on Github external
It provides the added item.
    """

    sigItemRemoved = qt.Signal(object)
    """Signal emitted when an item is (about to be) removed.

    It provides the removed item.
    """

    sigCurrentChanged = qt.Signal(object)
    """Signal emitted when the current item has changed.

    It provides the current item.
    """

    sigVisibleDataChanged = qt.Signal()
    """Signal emitted when the visible data area has changed"""

    def __init__(self, plot=None):
        super(_Wrapper, self).__init__(parent=None)
        self._plotRef = None if plot is None else weakref.ref(plot)

    def getPlot(self):
        """Returns the plot attached to this widget"""
        return None if self._plotRef is None else self._plotRef()

    def getItems(self):
        """Returns the list of items in the plot

        :rtype: List[object]
        """
        return ()
github silx-kit / silx / silx / gui / plot / items / roi.py View on Github external
logger = logging.getLogger(__name__)


class _RegionOfInterestBase(qt.QObject):
    """Base class of 1D and 2D region of interest

    :param QObject parent: See QObject
    :param str name: The name of the ROI
    """

    sigAboutToBeRemoved = qt.Signal()
    """Signal emitted just before this ROI is removed from its manager."""

    sigItemChanged = qt.Signal(object)
    """Signal emitted when item has changed.

    It provides a flag describing which property of the item has changed.
    See :class:`ItemChangedType` for flags description.
    """

    def __init__(self, parent=None):
        qt.QObject.__init__(self, parent=parent)
        self.__name = ''

    def getName(self):
        """Returns the name of the ROI

        :return: name of the region of interest
        :rtype: str
        """
github silx-kit / silx / silx / gui / plot / tools / roi.py View on Github external
It supports the multiple ROIs: points, rectangles, polygons,
    lines, horizontal and vertical lines.

    See ``plotInteractiveImageROI.py`` sample code (:ref:`sample-code`).

    :param silx.gui.plot.PlotWidget parent:
        The plot widget in which to control the ROIs.
    """

    sigRoiAdded = qt.Signal(roi_items.RegionOfInterest)
    """Signal emitted when a new ROI has been added.

    It provides the newly add :class:`RegionOfInterest` object.
    """

    sigRoiAboutToBeRemoved = qt.Signal(roi_items.RegionOfInterest)
    """Signal emitted just before a ROI is removed.

    It provides the :class:`RegionOfInterest` object that is about to be removed.
    """

    sigRoiChanged = qt.Signal()
    """Signal emitted whenever the ROIs have changed."""

    sigCurrentRoiChanged = qt.Signal(object)
    """Signal emitted whenever a ROI is selected."""

    sigInteractiveModeStarted = qt.Signal(object)
    """Signal emitted when switching to ROI drawing interactive mode.

    It provides the class of the ROI which will be created by the interactive
    mode.
github silx-kit / silx / silx / gui / plot / ComplexImageView.py View on Github external
from ...utils.deprecation import deprecated
from .. import qt, icons
from .PlotWindow import Plot2D
from . import items
from .items import ImageComplexData
from silx.gui.widgets.FloatEdit import FloatEdit

_logger = logging.getLogger(__name__)


# Widgets

class _AmplitudeRangeDialog(qt.QDialog):
    """QDialog asking for the amplitude range to display."""

    sigRangeChanged = qt.Signal(tuple)
    """Signal emitted when the range has changed.

    It provides the new range as a 2-tuple: (max, delta)
    """

    def __init__(self,
                 parent=None,
                 amplitudeRange=None,
                 displayedRange=(None, 2)):
        super(_AmplitudeRangeDialog, self).__init__(parent)
        self.setWindowTitle('Set Displayed Amplitude Range')

        if amplitudeRange is not None:
            amplitudeRange = min(amplitudeRange), max(amplitudeRange)
        self._amplitudeRange = amplitudeRange
        self._defaultDisplayedRange = displayedRange
github silx-kit / silx / silx / gui / plot3d / ScalarFieldView.py View on Github external
class Isosurface(qt.QObject):
    """Class representing an iso-surface

    :param parent: The View widget this iso-surface belongs to
    """

    sigLevelChanged = qt.Signal(float)
    """Signal emitted when the iso-surface level has changed.

    This signal provides the new level value (might be nan).
    """

    sigColorChanged = qt.Signal()
    """Signal emitted when the iso-surface color has changed"""

    sigVisibilityChanged = qt.Signal(bool)
    """Signal emitted when the iso-surface visibility has changed.

    This signal provides the new visibility status.
    """

    def __init__(self, parent):
        super(Isosurface, self).__init__(parent=parent)
        self._level = float('nan')
        self._autoLevelFunction = None
        self._color = rgba('#FFD700FF')
        self._data = None
        self._group = scene.Group()

    def _setData(self, data, copy=True):
        """Set the data set from which to build the iso-surface.
github silx-kit / silx / silx / gui / plot3d / ScalarFieldView.py View on Github external
else:
            dataBBox = self._group.transforms.transformBounds(
                self._selectedRange[::-1].T).T
            return SelectedRegion(self._selectedRange, dataBBox,
                                  translation=self.getTranslation(),
                                  scale=self.getScale())

    # Handle iso-surfaces

    sigIsosurfaceAdded = qt.Signal(object)
    """Signal emitted when a new iso-surface is added to the view.

    The newly added iso-surface is provided by this signal
    """

    sigIsosurfaceRemoved = qt.Signal(object)
    """Signal emitted when an iso-surface is removed from the view

    The removed iso-surface is provided by this signal.
    """

    def addIsosurface(self, level, color):
        """Add an iso-surface to the view.

        :param level:
            The value at which to build the iso-surface or a callable
            (e.g., a function) taking a 3D numpy.ndarray as input and
            returning a float.
            Example: numpy.mean(data) + numpy.std(data)
        :type level: float or callable
        :param color: RGBA color of the isosurface
        :type color: str or array-like of 4 float in [0., 1.]
github silx-kit / silx / silx / gui / plot / _BaseMaskToolsWidget.py View on Github external
A mask is an array of the same shape as some underlying data. The mask
    array stores integer values in the range 0-255, to allow for 254 levels
    of mask (value 0 is reserved for unmasked data).

    The mask is updated using spatial selection methods: data located inside
    a selected area is masked with a specified mask level.

    """

    sigChanged = qt.Signal()
    """Signal emitted when the mask has changed"""

    sigUndoable = qt.Signal(bool)
    """Signal emitted when undo becomes possible/impossible"""

    sigRedoable = qt.Signal(bool)
    """Signal emitted when redo becomes possible/impossible"""

    def __init__(self, dataItem=None):
        self.historyDepth = 10
        """Maximum number of operation stored in history list for undo"""
        # Init lists for undo/redo
        self._history = []
        self._redo = []

        # Store the mask
        self._mask = numpy.array((), dtype=numpy.uint8)

        # Store the plot item to be masked
        self._dataItem = None
        if dataItem is not None:
            self.setDataItem(dataItem)