backends Package

MatplotlibBackend Module

OpenGLBackend Module

OpenGL/Qt backend

class PyMca5.PyMcaGraph.backends.OpenGLBackend.Bounds(xMin, xMax, yMin, yMax, y2Min, y2Max)[source]

Bases: object

Describes plot bounds with 2 y axis

xAxis
y2Axis
yAxis
class PyMca5.PyMcaGraph.backends.OpenGLBackend.FocusManager(eventHandlers=())[source]

Bases: PyMca5.PyMcaGraph.backends.GLSupport.Interaction.StateMachine

Manages focus across multiple event handlers

On press an event handler can acquire focus. By default it looses focus when all buttons are released.

class Focus(machine)[source]

Bases: PyMca5.PyMcaGraph.backends.GLSupport.Interaction.State

enter(eventHandler, btn)[source]
onMove(x, y)[source]
onPress(x, y, btn)[source]
onRelease(x, y, btn)[source]
onWheel(x, y, angleInDegrees)[source]
class FocusManager.Idle(machine)[source]

Bases: PyMca5.PyMcaGraph.backends.GLSupport.Interaction.State

onMove(x, y)[source]
onPress(x, y, btn)[source]
onRelease(x, y, btn)[source]
onWheel(x, y, angle)[source]
FocusManager.cancel()[source]
class PyMca5.PyMcaGraph.backends.OpenGLBackend.ItemsInteraction(backend)[source]

Bases: PyMca5.PyMcaGraph.backends.GLSupport.Interaction.ClickOrDrag

class Idle(*args, **kw)[source]

Bases: PyMca5.PyMcaGraph.backends.GLSupport.Interaction.Idle

onMove(x, y)[source]
onPress(x, y, btn)[source]
ItemsInteraction.beginDrag(x, y)[source]
ItemsInteraction.cancel()[source]
ItemsInteraction.click(x, y, btn)[source]
ItemsInteraction.drag(x, y)[source]
ItemsInteraction.endDrag(startPos, endPos)[source]
class PyMca5.PyMcaGraph.backends.OpenGLBackend.MiniOrderedDict[source]

Bases: object

Simple subset of OrderedDict for python 2.6 support

get(key, default=None)[source]
keys()[source]
pop(key, default=<object object>)[source]
values()[source]
class PyMca5.PyMcaGraph.backends.OpenGLBackend.OpenGLBackend(parent=None, **kw)[source]

Bases: PySide.QtOpenGL.QGLWidget, PyMca5.PyMcaGraph.backends.OpenGLBackend.OpenGLPlotCanvas

getWidgetHandle()[source]
mouseMoveEvent(event)[source]
mousePressEvent(event)[source]
mouseReleaseEvent(event)[source]
postRedisplay()[source]

Thread-safe call to QWidget.update.

setCursor(cursor=0)[source]
sizeHint()[source]
staticMetaObject = <PySide.QtCore.QMetaObject object>
wheelEvent(event)[source]
class PyMca5.PyMcaGraph.backends.OpenGLBackend.OpenGLPlotCanvas(parent=None, **kw)[source]

Bases: PyMca5.PyMcaGraph.PlotBackend.PlotBackend

Implements PlotBackend API using OpenGL.

WARNINGS: Unless stated otherwise, this API is NOT thread-safe and MUST be called from the main thread. When numpy arrays are passed as arguments to the API (through addCurve() and addImage()), they are copied only if required. So, the caller should not modify these arrays afterwards.

addCurve(x, y, legend=None, info=None, replace=False, replot=True, color=None, symbol=None, linestyle=None, xlabel=None, ylabel=None, yaxis=None, xerror=None, yerror=None, z=1, selectable=True, fill=None, **kw)[source]
addImage(data, legend=None, info=None, replace=True, replot=True, xScale=None, yScale=None, z=0, selectable=False, draggable=False, colormap=None, **kw)[source]
addItem(xList, yList, legend=None, info=None, replace=False, replot=True, shape='polygon', fill=True, color=None, **kw)[source]
clear()[source]
clearCurves()[source]
clearImages()[source]
clearItems()[source]
clearMarkers()[source]
dataBounds

Bounds of the currently loaded data Not including markers (TODO check consistency with MPLBackend)

Type:Bounds
dataToPixel(x=None, y=None, axis='left', check=True)[source]
Parameters:check (bool) – Toggle checking if data position is in displayed area. If False, this method never returns None.
Raises:ValueError if x or y < 0. with log axis.
getDefaultColormap()[source]
getDrawMode()[source]
getGraphTitle()[source]
getGraphXLabel()[source]
getGraphXLimits()[source]
getGraphYLabel()[source]
getGraphYLimits(axis='left')[source]
getSupportedColormaps()[source]
initializeGL()[source]
insertMarker(x, y, legend=None, text=None, color='k', selectable=False, draggable=False, **kw)[source]
insertXMarker(x, legend=None, text=None, color='k', selectable=False, draggable=False, **kw)[source]
insertYMarker(y, legend=None, text=None, color='k', selectable=False, draggable=False, **kw)[source]
invertYAxis(flag=True)[source]
isDrawModeEnabled()[source]
isKeepDataAspectRatio()[source]
isXAxisAutoScale()[source]
isXAxisLogarithmic()[source]
isYAxisAutoScale()[source]
isYAxisInverted()[source]
isYAxisLogarithmic()[source]
isZoomModeEnabled()[source]
keepDataAspectRatio(flag=True)[source]
makeCurrent()[source]

Override this method to allow to set the current OpenGL context.

matrixPlotDataTransformedProj

Orthographic projection matrix for rendering transformed data

Type:numpy.matrix
matrixY2PlotDataTransformedProj

Orthographic projection matrix for rendering transformed data for the 2nd Y axis

Type:numpy.matrix
onMouseMove(xPixel, yPixel)[source]
onMousePress(xPixel, yPixel, btn)[source]
onMouseRelease(xPixel, yPixel, btn)[source]
onMouseWheel(xPixel, yPixel, angleInDegrees)[source]
paintGL()[source]
pickImageOrCurve(x, y, test=None)[source]
pickMarker(x, y, test=None)[source]
pixelToData(x=None, y=None, axis='left', check=True)[source]
Parameters:check (bool) – Toggle checking if pixel is in plot area. If False, this method never returns None.
plotDataBounds

Bounds of the displayed area in data coordinates

Type:Bounds
plotDataTransformedBounds

Bounds of the displayed area in transformed data coordinates (i.e., log scale applied if any)

Type:Bounds
plotSizeInPixels()[source]
postRedisplay()[source]
removeCurve(legend, replot=True)[source]
removeImage(legend, replot=True)[source]
removeItem(legend, replot=True)[source]
removeMarker(legend, replot=True)[source]
replot()[source]
resetSelectionArea(name=None)[source]

Remove the name selection area set by setSelectionArea. If name is None (the default), it removes all selection areas.

Parameters:name – The name key provided to setSelectionArea or None
resetZoom()[source]
resizeGL(width, height)[source]
saveGraph(fileName, fileFormat='svg', dpi=None, **kw)[source]

Save the graph as an image to a file.

WARNING: This method is performing some OpenGL calls. It must be called from the main thread.

setActiveCurve(legend, replot=True)[source]
setCursor(cursor=0)[source]

Override this method in subclass to enable cursor shape changes

setDefaultColormap(colormap=None)[source]
setDrawModeEnabled(flag=True, shape='polygon', label=None, color=None, **kw)[source]
setGraphTitle(title='')[source]
setGraphXLabel(label='X')[source]
setGraphXLimits(xMin, xMax)[source]
setGraphYLabel(label='Y')[source]
setGraphYLimits(yMin, yMax, axis='left')[source]
setLimits(xMin, xMax, yMin, yMax, y2Min=None, y2Max=None)[source]
setSelectionArea(points, fill=None, color=None, name=None)[source]

Set a polygon selection area overlaid on the plot. Multiple simultaneous areas are supported through the name parameter.

Parameters:
  • points (An iterable of (x, y) coordinates) – The 2D coordinates of the points of the polygon
  • fill (str) – The fill mode: ‘hatch’, ‘solid’ or None (default)
  • color (list or tuple of 4 float in the range [0, 1]) – RGBA color to use (default: black)
  • name – The key associated with this selection area
setXAxisAutoScale(flag=True)[source]
setXAxisLogarithmic(flag=True)[source]
setYAxisAutoScale(flag=True)[source]
setYAxisLogarithmic(flag=True)[source]
setZoomModeEnabled(flag=True, color=None)[source]
showGrid(flag=True)[source]
updateAxis()[source]
class PyMca5.PyMcaGraph.backends.OpenGLBackend.Range[source]

Bases: PyMca5.PyMcaGraph.backends.OpenGLBackend.Range

Describes a 1D range

center
range_
class PyMca5.PyMcaGraph.backends.OpenGLBackend.Select[source]

Bases: object

color
parameters = {}
class PyMca5.PyMcaGraph.backends.OpenGLBackend.Select1Point(backend, parameters)[source]

Bases: PyMca5.PyMcaGraph.backends.GLSupport.Interaction.StateMachine, PyMca5.PyMcaGraph.backends.OpenGLBackend.Select

class Idle(machine)[source]

Bases: PyMca5.PyMcaGraph.backends.GLSupport.Interaction.State

onPress(x, y, btn)[source]
class Select1Point.Select(machine)[source]

Bases: PyMca5.PyMcaGraph.backends.GLSupport.Interaction.State

enter(x, y)[source]
onMove(x, y)[source]
onRelease(x, y, btn)[source]
Select1Point.cancel()[source]
Select1Point.cancelSelect()[source]
Select1Point.endSelect(x, y)[source]
Select1Point.select(x, y)[source]
class PyMca5.PyMcaGraph.backends.OpenGLBackend.Select2Points(backend, parameters)[source]

Bases: PyMca5.PyMcaGraph.backends.GLSupport.Interaction.StateMachine, PyMca5.PyMcaGraph.backends.OpenGLBackend.Select

class Idle(machine)[source]

Bases: PyMca5.PyMcaGraph.backends.GLSupport.Interaction.State

onPress(x, y, btn)[source]
class Select2Points.Select(machine)[source]

Bases: PyMca5.PyMcaGraph.backends.GLSupport.Interaction.State

enter(x, y)[source]
onMove(x, y)[source]
onRelease(x, y, btn)[source]
class Select2Points.Start(machine)[source]

Bases: PyMca5.PyMcaGraph.backends.GLSupport.Interaction.State

enter(x, y)[source]
onMove(x, y)[source]
onRelease(x, y, btn)[source]
Select2Points.beginSelect(x, y)[source]
Select2Points.cancel()[source]
Select2Points.cancelSelect()[source]
Select2Points.endSelect(x, y)[source]
Select2Points.select(x, y)[source]
class PyMca5.PyMcaGraph.backends.OpenGLBackend.SelectHLine(backend, parameters)[source]

Bases: PyMca5.PyMcaGraph.backends.OpenGLBackend.Select1Point

cancelSelect()[source]
endSelect(x, y)[source]
select(x, y)[source]
class PyMca5.PyMcaGraph.backends.OpenGLBackend.SelectLine(backend, parameters)[source]

Bases: PyMca5.PyMcaGraph.backends.OpenGLBackend.Select2Points

beginSelect(x, y)[source]
cancelSelect()[source]
endSelect(x, y)[source]
select(x, y)[source]
class PyMca5.PyMcaGraph.backends.OpenGLBackend.SelectPolygon(backend, parameters)[source]

Bases: PyMca5.PyMcaGraph.backends.GLSupport.Interaction.StateMachine, PyMca5.PyMcaGraph.backends.OpenGLBackend.Select

class Idle(machine)[source]

Bases: PyMca5.PyMcaGraph.backends.GLSupport.Interaction.State

onPress(x, y, btn)[source]
class SelectPolygon.Select(machine)[source]

Bases: PyMca5.PyMcaGraph.backends.GLSupport.Interaction.State

enter(x, y)[source]
onMove(x, y)[source]
onPress(x, y, btn)[source]
onRelease(x, y, btn)[source]
updateSelectionArea()[source]
SelectPolygon.cancel()[source]
class PyMca5.PyMcaGraph.backends.OpenGLBackend.SelectRectangle(backend, parameters)[source]

Bases: PyMca5.PyMcaGraph.backends.OpenGLBackend.Select2Points

beginSelect(x, y)[source]
cancelSelect()[source]
endSelect(x, y)[source]
select(x, y)[source]
class PyMca5.PyMcaGraph.backends.OpenGLBackend.SelectVLine(backend, parameters)[source]

Bases: PyMca5.PyMcaGraph.backends.OpenGLBackend.Select1Point

cancelSelect()[source]
endSelect(x, y)[source]
select(x, y)[source]
class PyMca5.PyMcaGraph.backends.OpenGLBackend.Zoom(backend, color)[source]

Bases: PyMca5.PyMcaGraph.backends.GLSupport.Interaction.ClickOrDrag

class ZoomIdle(machine)[source]

Bases: PyMca5.PyMcaGraph.backends.GLSupport.Interaction.Idle

onWheel(x, y, angle)[source]
Zoom.beginDrag(x, y)[source]
Zoom.cancel()[source]
Zoom.click(x, y, btn)[source]
Zoom.drag(x1, y1)[source]
Zoom.endDrag(startPos, endPos)[source]
class PyMca5.PyMcaGraph.backends.OpenGLBackend.ZoomAndSelect(backend, color)[source]

Bases: PyMca5.PyMcaGraph.backends.OpenGLBackend.FocusManager

PyMca5.PyMcaGraph.backends.OpenGLBackend.convertRGBDataToPNG(data)[source]

Convert a RGB bitmap to PNG.

It only supports RGB bitmap with one byte per channel stored as a 3D array. See Definitive Guide and Specification for details.

Parameters:data (numpy.ndarray of unsigned bytes) – A 3D array (h, w, rgb) storing an RGB image
Returns:The PNG encoded data
Return type:bytes
PyMca5.PyMcaGraph.backends.OpenGLBackend.prepareCurveSignal(button, label, type_, xData, yData, x, y, xPixel, yPixel)[source]
PyMca5.PyMcaGraph.backends.OpenGLBackend.prepareDrawingSignal(event, type_, points, parameters=None)[source]
PyMca5.PyMcaGraph.backends.OpenGLBackend.prepareHoverSignal(label, type_, posData, posPixel, draggable, selectable)[source]
PyMca5.PyMcaGraph.backends.OpenGLBackend.prepareImageSignal(button, label, type_, col, row, x, y, xPixel, yPixel)[source]
PyMca5.PyMcaGraph.backends.OpenGLBackend.prepareMarkerSignal(eventType, button, label, type_, draggable, selectable, posDataMarker, posPixelCursor=None, posDataCursor=None)[source]
PyMca5.PyMcaGraph.backends.OpenGLBackend.prepareMouseSignal(eventType, button, xData, yData, xPixel, yPixel)[source]
PyMca5.PyMcaGraph.backends.OpenGLBackend.saveImageToFile(data, fileNameOrObj, fileFormat)[source]

Save a RGB image to a file.

Parameters:
  • data (numpy.ndarray with of unsigned bytes.) – A 3D array (h, w, 3) storing an RGB image.
  • fileNameOrObj (A str or a 'file-like' object with a 'write' method.) – Filename or object to use to write the image.
  • fileType (str) – The type of the file in: ‘png’, ‘ppm’, ‘svg’, ‘tiff’.

PyQtGraphBackend Module