PyDMImageView

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

Bases: ImageView, PyDMWidget, PyDMColorMap, ReadingOrder, DimensionOrder

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.

class ReadingOrder

Bases: object

Class to build ReadingOrder ENUM property.

autoDownsample

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

Return type:

bool

channel
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.

colorMap

Return the color map used by the ImageView.

Return type:

PyDMColorMap

colorMapMax

Maximum value for the colormap.

Return type:

float

colorMapMin

Minimum value for the colormap.

Return type:

float

dimensionOrder

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

Return type:

DimensionOrder

imageChannel

The channel address in use for the image data .

Returns:

Channel address

Return type:

str

imageWidth

Return the width of the image.

Return type:

int

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.

maxRedrawRate

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

normalizeData

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

Return type:

bool

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

readingOrder

Return the reading order of the imageChannel array.

Return type:

ReadingOrder

redrawImage()[source]

Set the image data into the ImageItem, if needed.

If necessary, reshape the image to 2D first.

scaleXAxis

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.

scaleYAxis

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.

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

showAxes

Whether or not axes should be shown on the widget.

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

widthChannel

The channel address in use for the image width .

Returns:

Channel address

Return type:

str

Note

See ImageView Documentation for all inherited properties and methods.