PyDMImageView

class pydm.widgets.image.PyDMImageView(parent=None, image_channel=None, width_channel=None)[source]

Bases: ImageView, PyDMWidget

A PyQtGraph ImageView with support for Channels and more from PyDM.

If there is no channelWidth it is possible to define the width of the image with the width property.

The normalizeData property defines if the colors of the images are relative to the colorMapMin and colorMapMax property or to the minimum and maximum values of the image.

Use the newImageSignal to hook up to a signal that is emitted when a new image is rendered in the widget.

Parameters:
  • parent (QWidget) – The parent widget for the Label

  • image_channel (str, optional) – The channel to be used by the widget for the image data.

  • width_channel (str, optional) – The channel to be used by the widget to receive the image width information

class DimensionOrder

Bases: object

Class to build DimensionOrder ENUM property.

This relates to how the pva image data is being sent. Included in this data are the dimensions of the image (width and height) as part of the array ‘dimension_t[] dimension’. (https://github.com/epics-base/normativeTypesCPP/wiki/Normative+Types+Specification#ntndarray) But if the array should be ordered [height, width] or [width, height] does not seem to be specified. This option lets the user set which ordering PyDM should interpret this ‘dimension’ array as having.

HeightFirst = [height, width] WidthFirst = [width, height] (PyDM assumes HeightFirst as default)

If you are wondering what ordering a certain pva address is using, you can ‘pvget’ the address to see the ordering of values in its ‘dimension’ array.

Q_ENUM(a0: Union[type, enum.Enum])
class ReadingOrder

Bases: object

Class to build ReadingOrder ENUM property.

channels()[source]

Return the channels being used for this Widget.

Returns:

channels – List of PyDMChannel objects

Return type:

list

channels_for_tools()[source]

Return channels for tools.

eventFilter(self, a0: Optional[QObject], a1: Optional[QEvent]) bool[source]
image_connection_state_changed(conn)[source]

Callback invoked when the Image Channel connection state is changed.

Parameters:

conn (bool) – The new connection state.

image_value_changed(new_image)[source]

Callback invoked when the Image Channel value is changed.

We try to do as little as possible in this method, because it gets called every time the image channel updates, which might be extremely often. Basically just store the data, and set a flag requesting that the image be redrawn.

Parameters:

new_image (np.ndarray) – The new image data. This can be a flat 1D array, or a 2D array.

image_width_changed(new_width)[source]

Callback invoked when the Image Width Channel value is changed.

Parameters:

new_width (int) – The new image width

keyPressEvent(ev)[source]

Handle keypress events.

process_image(image)[source]

Boilerplate method to be used by applications in order to add calculations and also modify the image before it is displayed at the widget.

Warning

This code runs in a separated QThread so it MUST not try to write to QWidgets.

Parameters:

image (np.ndarray) – The Image Data as a 2D numpy array

Returns:

The Image Data as a 2D numpy array after processing.

Return type:

np.ndarray

readAutoDownsample() bool[source]

Return if we should or not apply the autoDownsample option to PyQtGraph.

Return type:

bool

readChannel() None[source]

The channel address in use for this widget.

Returns:

channel – Channel address

Return type:

str

readColorMap() PyDMColorMap[source]

Return the color map used by the ImageView.

Return type:

PyDMColorMap

readColorMapMax() float[source]

Maximum value for the colormap.

Return type:

float

readColorMapMin() float[source]

Minimum value for the colormap.

Return type:

float

readDimensionOrder() DimensionOrder[source]

Return the dimension order of the imageChannel array. (for more info see DimensionOrder class definition)

Return type:

DimensionOrder

readImageChannel() str[source]

The channel address in use for the image data .

Returns:

Channel address

Return type:

str

readImageWidth() int[source]

Return the width of the image.

Return type:

int

readMaxRedrawRate() int[source]

The maximum rate (in Hz) at which the plot will be redrawn.

The plot will not be redrawn if there is not new data to draw.

Return type:

int

readNormalizeData() bool[source]

Return True if the colors are relative to data maximum and minimum.

Return type:

bool

readReadingOrder() ReadingOrder[source]

Return the reading order of the imageChannel array.

Return type:

ReadingOrder

readScaleXAxis() float[source]

Sets the scale for the X Axis.

For example, if your image has 100 pixels per millimeter, you can set xAxisScale to 1/100 = 0.01 to make the X Axis report in millimeter units.

readScaleYAxis() float[source]

Sets the scale for the Y Axis.

For example, if your image has 100 pixels per millimeter, you can set yAxisScale to 1/100 = 0.01 to make the Y Axis report in millimeter units.

readShowAxes() bool[source]

Whether or not axes should be shown on the widget.

readWidthChannel() str[source]

The channel address in use for the image width .

Returns:

Channel address

Return type:

str

redrawImage()[source]

Set the image data into the ImageItem, if needed.

If necessary, reshape the image to 2D first.

setAutoDownsample(new_value) None[source]

Whether we should or not apply the autoDownsample option to PyQtGraph.

Parameters:

new_value (bool) –

setChannel(ch) None[source]

The channel address to use for this widget.

Parameters:

value (str) – Channel address

setColorMap(cmap=None)[source]

Update the image colormap.

Parameters:

cmap (ColorMap) –

setColorMapLimits(mn, mx)[source]

Set the limit values for the colormap.

Parameters:
  • mn (int) – The lower limit

  • mx (int) – The upper limit

setColorMapMax(new_max) None[source]

Set the maximum value for the colormap.

Parameters:

new_max (float) –

setColorMapMin(new_min) None[source]

Set the minimum value for the colormap.

Parameters:

new_min (float) –

setDimensionOrder(new_order) None[source]

Set dimension order of the imageChannel array.

Parameters:

new_order (DimensionOrder) –

setImageChannel(value) None[source]

The channel address in use for the image data .

Parameters:

value (str) – Channel address

setImageWidth(new_width) None[source]

Set the width of the image.

Can be overridden by widthChannel.

Parameters:

new_width (int) –

setMaxRedrawRate(redraw_rate) None[source]

The maximum rate (in Hz) at which the plot will be redrawn.

The plot will not be redrawn if there is not new data to draw.

Parameters:

redraw_rate (int) –

setNormalizeData(new_norm) None[source]

Define if the colors are relative to minimum and maximum of the data.

Parameters:

new_norm (bool) –

setReadingOrder(new_order) None[source]

Set reading order of the imageChannel array.

Parameters:

new_order (ReadingOrder) –

setWidthChannel(value) None[source]

The channel address in use for the image width .

Parameters:

value (str) – Channel address

toggleRedraw() bool[source]

Start or stop the thread responsible for drawing the image. Can be called by the user to pause redrawing the image, and resume later if needed.

Returns:

True if the image is being redrawn on a timer, false otherwise

Return type:

bool

widget_ctx_menu()[source]

Fetch the Widget specific context menu.

It will be populated with additional tools by assemble_tools_menu.

Returns:

If the return of this method is None a new QMenu will be created by assemble_tools_menu.

Return type:

QMenu or None

Note

See ImageView Documentation for all inherited properties and methods.