ccpn.ui.gui.lib.OpenGL package¶
Module Documentation here
Submodules¶
ccpn.ui.gui.lib.OpenGL.CcpnOpenGL module¶
By Functionality:
- Zoom and pan:
Left-drag: pans the spectrum.
shift-left-drag: draws a zooming box and zooms the viewing window. shift-middle-drag: draws a zooming box and zooms the viewing window. shift-right-drag: draws a zooming box and zooms the viewing window. Two successive shift-right-clicks: define zoombox control-right click: reset the zoom
- Peaks:
Left-click: select peak near cursor in a spectrum display, deselecting others Control(Cmd)-left-click: (de)select peak near cursor in a spectrum display, adding/removing to selection. Control(Cmd)-left-drag: selects peaks in an area specified by the dragged region. Middle-drag: Moves a selected peak. Control(Cmd)-Shift-Left-click: picks a peak at the cursor position, adding to selection Control(Cmd)-shift-left-drag: picks peaks in an area specified by the dragged region.
- Others:
Right-click: raises the context menu.
By Mouse button:
Left-click: select peak near cursor in a spectrum display, deselecting others Control(Cmd)-left-click: (de)select peak near cursor in a spectrum display, adding/removing to selection. Control(Cmd)-Shift-Left-click: picks a peak at the cursor position, adding to selection
Left-drag: pans the spectrum. shift-left-drag: draws a zooming box and zooms the viewing window. Control(Cmd)-left-drag: selects peaks in an area specified by the dragged region. Control(Cmd)-shift-left-drag: picks peaks in an area specified by the dragged region.
shift-middle-drag: draws a zooming box and zooms the viewing window.
Right-click: raises the context menu. control-right click: reset the zoom Two successive shift-right-clicks: define zoombox
shift-right-drag: draws a zooming box and zooms the viewing window.
- class ccpn.ui.gui.lib.OpenGL.CcpnOpenGL.CcpnGLWidget(strip=None, mainWindow=None, stripIDLabel=None, antiAlias=4)[source]¶
Bases:
PyQt5.QtWidgets.QOpenGLWidget
Widget to handle all visible spectra/peaks/integrals/multiplets
- AXISLOCKEDBUTTON = True¶
- AXISLOCKEDBUTTONALLSTRIPS = True¶
- AXIS_INSIDE = False¶
- AXIS_LINE = 7¶
- AXIS_MARGINBOTTOM = 25¶
- AXIS_MARGINRIGHT = 50¶
- AXIS_MOUSEYOFFSET = 32¶
- AXIS_OFFSET = 3¶
- INVERTXAXIS = True¶
- INVERTYAXIS = True¶
- SHOWSPECTRUMONPHASING = True¶
- SPECTRUMXZOOM = 10.0¶
- SPECTRUMYZOOM = 10.0¶
- XAXES = ['[ppm]', '[Hz]', '[pnts]']¶
- YAXES = ['[ppm]', '[Hz]', '[pnts]']¶
- YAXISUSEEFORMAT = False¶
- addExternalRegion(values=None, axisCode=None, orientation=None, brush=None, colour='blue', movable=True, visible=True, bounds=None, obj=None, **kwds)[source]¶
- addInfiniteLine(values=None, axisCode=None, orientation=None, brush=None, colour='blue', movable=True, visible=True, bounds=None, obj=None, lineStyle='dashed', lineWidth=1.0)[source]¶
- addRegion(values=None, axisCode=None, orientation=None, brush=None, colour='blue', movable=True, visible=True, bounds=None, obj=None)[source]¶
- property aspectRatioMode¶
- None, mutable -
- property aspectRatios¶
- None, mutable -
- property axesVisible¶
- None, mutable -
- property axisCodes¶
- None, mutable -
- property axisOrder¶
- None, mutable -
- emitAllAxesChanged(allStrips=False)[source]¶
Signal all strips in the spectrumDisplay to refresh Strips will be scaled to the Y-Axis if aspect ratio is set to Locked/Fixed :param allStrips: True/False, if true, apply scaling to all strips; False, ignore the current strip in spectrumDisplay
- emitXAxisChanged(allStrips=False, aspectRatios=None)[source]¶
Signal all strips in the spectrumDisplay to refresh Strips will be scaled to the X-Axis if aspect ratio is set to Locked/Fixed :param allStrips: True/False, if true, apply scaling to all strips; False, ignore the current strip in spectrumDisplay
- emitYAxisChanged(allStrips=False, aspectRatios=None)[source]¶
Signal all strips in the spectrumDisplay to refresh Strips will be scaled to the Y-Axis if aspect ratio is set to Locked/Fixed :param allStrips: True/False, if true, apply scaling to all strips; False, ignore the current strip in spectrumDisplay
- getAxisRegion(axisIndex)[source]¶
Return the region for visible axisIndex 0/1 (for X/Y) if axis is reversed, the region will be returned as (max, min)
- getMousePosition()[source]¶
Get the coordinates of the mouse in the window (in ppm) based on the current axes
- getObjectsUnderMouse()[source]¶
Return a list of objects under the mouse position as a dict dict is of the form: {object plural name: list, …}
e.g. {‘peaks’: []}
Current objects returned are: peaks, integrals, multiplets :return: dict of objects
- keyPressEvent(event: PyQt5.QtGui.QKeyEvent)[source]¶
Process key events or pass to current strip of required
- property orderedAxes¶
- None, mutable -
- profile(asText=False)¶
Get the stats of all related calls firing from inside a specific function/method. Add on top of a function/method to profile it. E.g.:
@profile(dirPath=’/myDesktopPath/’) def my function(*args): …
- Parameters
dirPath – str, dir where to dump the pstat file.
asText – bool. Make a pstat copy as a human readable text file.
- rescale(rescaleOverlayText=True, rescaleMarksRulers=True, rescaleIntegralLists=True, rescaleRegions=True, rescaleSpectra=True, rescaleStaticHTraces=True, rescaleStaticVTraces=True, rescaleSpectrumLabels=True, rescaleLegend=True)[source]¶
Change to axes of the view, axis visibility, scale and rebuild matrices when necessary to improve display speed
- restoreZoom(zoomState=None)[source]¶
Restore zoom to the last stored zoom zoomState = (axisL, axisR, axisB, axisT)
- setAxesVisible(rightAxisVisible=True, bottomAxisVisible=False)[source]¶
Set the visibility of the axes
- setBackgroundColour(col, silent=False)[source]¶
set all background colours in the shaders :param col - vec4, 4 element list e.g.: [0.05, 0.05, 0.05, 1.0], very dark gray
- property showSpectraOnPhasing¶
- None, mutable -
- storeZoom()[source]¶
Store the current axis values to the zoom stack Sets this to the top of the stack, removing everything after
- property updateHTrace¶
- None, mutable -
- property updateVTrace¶
- None, mutable -
- property xUnits¶
- None, mutable -
- property yUnits¶
- None, mutable -
- zoom(xRegion: Tuple[float, float], yRegion: Tuple[float, float])[source]¶
Zooms strip to the specified region
- property zoomState¶
- None, immutable -
ccpn.ui.gui.lib.OpenGL.CcpnOpenGLABC module¶
By Functionality:
- Zoom and pan:
Left-drag: pans the spectrum.
shift-left-drag: draws a zooming box and zooms the viewing window. shift-middle-drag: draws a zooming box and zooms the viewing window. shift-right-drag: draws a zooming box and zooms the viewing window. Two successive shift-right-clicks: define zoombox control-right click: reset the zoom
- Peaks:
Left-click: select peak near cursor in a spectrum display, deselecting others Control(Cmd)-left-click: (de)select peak near cursor in a spectrum display, adding/removing to selection. Control(Cmd)-left-drag: selects peaks in an area specified by the dragged region. Middle-drag: Moves a selected peak. Control(Cmd)-Shift-Left-click: picks a peak at the cursor position, adding to selection Control(Cmd)-shift-left-drag: picks peaks in an area specified by the dragged region.
- Others:
Right-click: raises the context menu.
By Mouse button:
Left-click: select peak near cursor in a spectrum display, deselecting others Control(Cmd)-left-click: (de)select peak near cursor in a spectrum display, adding/removing to selection. Control(Cmd)-Shift-Left-click: picks a peak at the cursor position, adding to selection
Left-drag: pans the spectrum. shift-left-drag: draws a zooming box and zooms the viewing window. Control(Cmd)-left-drag: selects peaks in an area specified by the dragged region. Control(Cmd)-shift-left-drag: picks peaks in an area specified by the dragged region.
shift-middle-drag: draws a zooming box and zooms the viewing window.
Right-click: raises the context menu. control-right click: reset the zoom Two successive shift-right-clicks: define zoombox
shift-right-drag: draws a zooming box and zooms the viewing window.
- class ccpn.ui.gui.lib.OpenGL.CcpnOpenGLABC.CcpnGLWidgetABC(parent=None, mainWindow=None, **kwds)[source]¶
Bases:
PyQt5.QtWidgets.QOpenGLWidget
Widget to handle all visible spectra/peaks/integrals/multiplets
- AXISLOCKEDBUTTON = True¶
- AXISLOCKEDBUTTONALLSTRIPS = True¶
- AXIS_INSIDE = False¶
- AXIS_LINE = 7¶
- AXIS_MARGINBOTTOM = 25¶
- AXIS_MARGINRIGHT = 50¶
- AXIS_MOUSEYOFFSET = 32¶
- AXIS_OFFSET = 3¶
- INVERTXAXIS = True¶
- INVERTYAXIS = True¶
- SHOWSPECTRUMONPHASING = True¶
- SPECTRUMXZOOM = 10.0¶
- SPECTRUMYZOOM = 10.0¶
- XAXES = ['[ppm]', '[Hz]', '[pnts]']¶
- YAXES = ['[ppm]', '[Hz]', '[pnts]']¶
- YAXISUSEEFORMAT = False¶
ccpn.ui.gui.lib.OpenGL.CcpnOpenGLArrays module¶
GL routines used to draw vertex buffer objects (VBOs)
- class ccpn.ui.gui.lib.OpenGL.CcpnOpenGLArrays.GLLabelArray(GLContext=None, spectrumView=None, objListView=None)[source]¶
Bases:
ccpn.ui.gui.lib.OpenGL.CcpnOpenGLArrays.GLVertexArray
Array class to handle labels.
- class ccpn.ui.gui.lib.OpenGL.CcpnOpenGLArrays.GLSymbolArray(GLContext=None, spectrumView=None, objListView=None)[source]¶
Bases:
ccpn.ui.gui.lib.OpenGL.CcpnOpenGLArrays.GLVertexArray
Array class to handle symbols.
- class ccpn.ui.gui.lib.OpenGL.CcpnOpenGLArrays.GLVertexArray(numLists=1, renderMode=0, refreshMode=0, blendMode=False, drawMode=GL_LINES, fillMode=None, dimension=3, GLContext=None, clearArrays=True)[source]¶
Bases:
object
- defineAliasedIndexVBO()[source]¶
Define the buffers on the graphics card. Indexed mode with vertices and colour. If undefined, create new VBOs otherwise overwrite existing.
- Includes:
vertices: (x, y) * vertices colors: (R, G, B, a) * vertices indices: array of indexes into vertex list _ attribs: array of float for defining aliasPosition
- defineIndexVBO()[source]¶
Define the buffers on the graphics card. Indexed mode with vertices and colour. If undefined, create new VBOs otherwise overwrite existing.
- Includes:
vertices: (x, y) * vertices colors: (R, G, B, a) * vertices indices: array of indexes into vertex list _ attribs: array of float for defining aliasPosition
- defineTextArrayVBO()[source]¶
Define the buffers on the graphics card. Indexed mode with vertices/colours/texture co-ordinates/attribs. If undefined, create new VBOs otherwise overwrite existing.
- Includes:
vertices: (x, y) * vertices colors: (R, G, B, a) * vertices indices: array of indexes into vertex list texcoords (u, v) * vertices attribs (a, b) * vertices
- defineVertexColorVBO()[source]¶
Define the buffers on the graphics card. Not indexed mode with vertices and colour. If undefined, create new VBOs otherwise overwrite existing.
- Includes:
vertices: (x, y) * vertices colors: (R, G, B, a) * vertices
- drawAliasedIndexArrayNoColor()[source]¶
Draw the vertex buffers in indexed array mode. Arrays are copied from main memory each time. Indexed mode using only vertices, no colour.
- drawAliasedIndexVBO()[source]¶
Draw the vertex buffers in indexed array mode. Arrays are drawn from buffers already bound to graphics card memory. Indexed mode with vertices and colour.
- drawIndexArray()[source]¶
Draw the vertex buffers in indexed array mode. Arrays are copied from main memory each time. Indexed with vertices and colour.
- drawIndexArrayNoColor()[source]¶
Draw the vertex buffers in indexed array mode. Arrays are copied from main memory each time. Indexed mode using only vertices, no colour.
- drawIndexVBO()[source]¶
Draw the vertex buffers in indexed array mode. Arrays are drawn from buffers already bound to graphics card memory. Indexed mode with vertices and colour.
- drawTextArray()[source]¶
Draw the texture buffers in indexed array mode. Arrays are copied from main memory each time. Facilitates drawing of fonts.
- drawTextArrayVBO(enableClientState=False, disableClientState=False)[source]¶
Draw the texture buffers in indexed array mode. Arrays are drawn from buffers already bound to graphics card memory. Indexed mode with vertices, colour, texture and attributes.
- drawVertexColor()[source]¶
Draw the vertex buffers in direct array mode. Arrays are copied from main memory each time. Only vertices and colour required.
- drawVertexColorVBO()[source]¶
Draw the vertex buffers in direct array mode. Arrays are drawn from buffers already bound to graphics card memory. Only vertices and colour required.
- drawVertexNoColor()[source]¶
Draw the vertex buffers in direct array mode. Arrays are copied from main memory each time. Only vertices are required.
- initialise(numLists=1, renderMode=0, refreshMode=0, blendMode=False, drawMode=GL_LINES, fillMode=None, dimension=3, GLContext=None, clearArrays=True)[source]¶
Initialise the vertexArray object.
- updateAliasedIndexVBO()[source]¶
Update the buffers on the graphics card. Indexed mode with vertices and colour.
- updateAliasedIndexVBOIndices()[source]¶
Update the buffers on the graphics card. Only the index array.
- updateIndexVBO()[source]¶
Update the buffers on the graphics card. Indexed mode with vertices and colour.
- updateTextArrayVBO()[source]¶
Update the buffers on the graphics card. Indexed mode with vertices, colour, texture and attributes.
- updateTextArrayVBOAttribs()[source]¶
Update the buffers on the graphics card. Only update the attributes used for moving text.
ccpn.ui.gui.lib.OpenGL.CcpnOpenGLDefs module¶
Module Documentation here
- class ccpn.ui.gui.lib.OpenGL.CcpnOpenGLDefs.AxisModes(value)[source]¶
Bases:
ccpn.util.LabelledEnum.LabelledEnum
An enumeration.
- AXIS_DEFAULT = 1¶
- AXIS_FULLHEIGHT = 2¶
- AXIS_OFF = 0¶
ccpn.ui.gui.lib.OpenGL.CcpnOpenGLExport module¶
Code for exporting OpenGL stripDisplay to pdf and svg files.
- class ccpn.ui.gui.lib.OpenGL.CcpnOpenGLExport.Clipped_Flowable(width=0.0, height=0.0, mainPlot=None, mainDim=None)[source]¶
Bases:
reportlab.platypus.flowables.Flowable
- class ccpn.ui.gui.lib.OpenGL.CcpnOpenGLExport.GLExporter(parent, strip, filename, params)[source]¶
Bases:
object
Class container for exporting OpenGL stripDisplay to a file or object
- lineVisible(_parent, lineList, x=0.0, y=0.0, width=0.0, height=0.0, checkIntegral=False)[source]¶
return the list of visible lines
- pointVisible(_parent, lineList, x=0.0, y=0.0, width=0.0, height=0.0)[source]¶
return true if the line has visible endpoints
ccpn.ui.gui.lib.OpenGL.CcpnOpenGLFonts module¶
Module Documentation here
- class ccpn.ui.gui.lib.OpenGL.CcpnOpenGLFonts.CcpnGLFont(fileName=None, base=0, fontTransparency=None, activeTexture=0, scale=None)[source]¶
Bases:
object
- class ccpn.ui.gui.lib.OpenGL.CcpnOpenGLFonts.GLGlyphTuple(GlyphXpos, GlyphYpos, GlyphWidth, GlyphHeight, GlyphXoffset, GlyphYoffset, GlyphOrigW, GlyphOrigH, GlyphKerns, GlyphTX0, GlyphTY0, GlyphTX1, GlyphTY1, GlyphPX0, GlyphPY0, GlyphPX1, GlyphPY1)¶
Bases:
tuple
- GlyphHeight¶
Alias for field number 3
- GlyphKerns¶
Alias for field number 8
- GlyphOrigH¶
Alias for field number 7
- GlyphOrigW¶
Alias for field number 6
- GlyphPX0¶
Alias for field number 13
- GlyphPX1¶
Alias for field number 15
- GlyphPY0¶
Alias for field number 14
- GlyphPY1¶
Alias for field number 16
- GlyphTX0¶
Alias for field number 9
- GlyphTX1¶
Alias for field number 11
- GlyphTY0¶
Alias for field number 10
- GlyphTY1¶
Alias for field number 12
- GlyphWidth¶
Alias for field number 2
- GlyphXoffset¶
Alias for field number 4
- GlyphXpos¶
Alias for field number 0
- GlyphYoffset¶
Alias for field number 5
- GlyphYpos¶
Alias for field number 1
- class ccpn.ui.gui.lib.OpenGL.CcpnOpenGLFonts.GLString(text=None, font=None, obj=None, colour=(1.0, 1.0, 1.0, 1.0), x=0.0, y=0.0, ox=0.0, oy=0.0, angle=0.0, width=None, height=None, GLContext=None, blendMode=True, clearArrays=False, serial=None, pixelScale=None, alias=0)[source]¶
Bases:
ccpn.ui.gui.lib.OpenGL.CcpnOpenGLArrays.GLVertexArray
- drawTextArray()[source]¶
Draw text array with textures MUST be called inside GL current context, i.e., after GL.makeCurrent or inside initializeGL, paintGL
ccpn.ui.gui.lib.OpenGL.CcpnOpenGLGlobal module¶
Module Documentation here
- class ccpn.ui.gui.lib.OpenGL.CcpnOpenGLGlobal.AliasedPixelShader[source]¶
Bases:
ccpn.ui.gui.lib.OpenGL.CcpnOpenGLGlobal.PixelShader
Pixel shader for aliased peak plotting
Uses the projection/viewport matrices to calculate the gl_Position, and passes through the gl_Color to set the pixel. gl_Color is modified for peaks at different aliased positions
- CCPNSHADER = True¶
- fragmentShader = '\n #version 120\n\n uniform vec4 background;\n uniform float aliasShade;\n uniform int aliasEnabled;\n varying vec4 _FC;\n varying float _aliased;\n \n void main()\n {\n // set the pixel colour\n if (abs(_aliased) < 0.5) {\n gl_FragColor = _FC;\n }\n else if (aliasEnabled != 0) {\n // set the colour if aliasEnabled (set opaque or set the alpha)\n gl_FragColor = (aliasShade * _FC) + (1 - aliasShade) * background;\n //gl_FragColor = vec4(_FC.xyz, _FC.w * aliasShade);\n }\n else {\n // skip the pixel\n discard;\n }\n }\n '¶
- name = 'aliasedPixelShader'¶
- setAliasEnabled(aliasEnabled)[source]¶
Set the alias enabled: bool True/False Used to determine visibility of aliased peaks, using aliasShade False = disable visibility of aliased peaks :param aliasEnabled: bool
- setAliasPosition(aliasX, aliasY)[source]¶
Set the alias position: Used to calculate whether the current peak is in the aliased region :param aliasX: X alias region :param aliasY: Y alias region
- setAliasShade(aliasShade)[source]¶
Set the alias shade: a single float in range [0.0, 1.0] Used to determine visibility of aliased peaks, 0.0 -> background colour :param aliasShade: single float32
- setBackground(colour)[source]¶
Set the background colour, for use with the solid text colour is tuple/list of 4 float/np.float32 elements in range 0.0-1.0 values outside range will be clipped :param colour: tuple/list
- vertexShader = '\n #version 120\n\n uniform mat4 pMatrix;\n uniform mat4 mvMatrix;\n attribute float alias;\n uniform float aliasPosition;\n varying float _aliased;\n varying vec4 _FC;\n \n void main()\n {\n // calculate the position, set shading value\n gl_Position = pMatrix * mvMatrix * vec4(gl_Vertex.xy, 0.0, 1.0);\n _FC = gl_Color;\n _aliased = (aliasPosition - alias);\n }\n '¶
- class ccpn.ui.gui.lib.OpenGL.CcpnOpenGLGlobal.AliasedTextShader[source]¶
Bases:
ccpn.ui.gui.lib.OpenGL.CcpnOpenGLGlobal.TextShader
Text shader for displaying text in aliased regions
Shader for plotting text, uses a billboard technique by using an _offset to determine pixel positions Colour of the pixel is set by glColorPointer array. Alpha value is grabbed from the texture to give anti-aliasing and modified by the ‘alpha’ attribute to affect overall transparency.
- CCPNSHADER = True¶
- fragmentShader = '\n #version 120\n\n uniform sampler2D texture;\n uniform vec4 background;\n uniform int blendEnabled;\n uniform float alpha;\n uniform float aliasShade;\n uniform int aliasEnabled;\n varying vec4 _FC;\n varying vec2 _texCoord;\n vec4 _texFilter;\n float _opacity;\n varying float _aliased;\n \n void main()\n {\n _texFilter = texture2D(texture, _texCoord);\n // colour for blending enabled\n _opacity = _texFilter.w * alpha;\n \n // set the pixel colour\n if (abs(_aliased) < 0.5)\n if (blendEnabled != 0)\n // multiply the character fade by the color fade to give the actual transparency\n gl_FragColor = vec4(_FC.xyz, _FC.w * _opacity);\n \n else \n // plot a background box around the character\n gl_FragColor = vec4((_FC.xyz * _opacity) + (1.0 - _opacity) * background.xyz, 1.0);\n\n else if (aliasEnabled != 0) {\n // modify the opacity\n _opacity *= aliasShade;\n \n if (blendEnabled != 0)\n // multiply the character fade by the color fade to give the actual transparency\n gl_FragColor = vec4(_FC.xyz, _FC.w * _opacity);\n \n else \n // plot a background box around the character\n gl_FragColor = vec4((_FC.xyz * _opacity) + (1.0 - _opacity) * background.xyz, 1.0);\n }\n else\n // skip the pixel\n discard;\n }\n '¶
- name = 'aliasedTextShader'¶
- setAliasEnabled(aliasEnabled)[source]¶
Set the alias enabled: bool True/False Used to determine visibility of aliased peaks, using aliasShade False = disable visibility of aliased peaks :param aliasEnabled: bool
- setAliasPosition(aliasX, aliasY)[source]¶
Set the alias position: Used to calculate whether the current peak is in the aliased region :param aliasX: X alias region :param aliasY: Y alias region
- setAliasShade(aliasShade)[source]¶
Set the alias shade: a single float in range [0.0, 1.0] Used to determine visibility of aliased peaks, 0.0 -> background colour :param aliasShade: single float32
- setMVMatrix(matrix)[source]¶
Set the contents of viewport mvMatrix :param matrix: consisting of 16 float32 elements
- vertexShader = '\n #version 120\n\n uniform mat4 pTexMatrix;\n uniform mat4 mvMatrix;\n uniform vec4 axisScale;\n uniform vec2 stackOffset;\n uniform float aliasPosition;\n varying float _aliased;\n varying vec4 _FC;\n varying vec2 _texCoord;\n attribute vec3 _offset;\n\n void main()\n {\n gl_Position = pTexMatrix * mvMatrix * ((gl_Vertex * axisScale) + vec4(_offset.xy + stackOffset, 0.0, 0.0));\n //gl_Position = pTexMatrix * mvMatrix * (gl_Vertex + vec4(_offset.xy + stackOffset, 0.0, 0.0));\n\n _texCoord = gl_MultiTexCoord0.st;\n _FC = gl_Color;\n _aliased = (aliasPosition - _offset.z);\n }\n '¶
- class ccpn.ui.gui.lib.OpenGL.CcpnOpenGLGlobal.GLGlobalData(*args, **kwargs)[source]¶
Bases:
PyQt5.QtWidgets.QWidget
Class to handle the common information between all the GL widgets
- class ccpn.ui.gui.lib.OpenGL.CcpnOpenGLGlobal.PixelShader[source]¶
Bases:
ccpn.ui.gui.lib.OpenGL.CcpnOpenGLShader.ShaderProgramABC
Pixel shader for contour plotting
A very simple shader, uses the projection/viewport matrices to calculate the gl_Position, and passes through the gl_Color to set the pixel.
- CCPNSHADER = True¶
- attributes = {'mvMatrix': (16, <class 'numpy.float32'>), 'pMatrix': (16, <class 'numpy.float32'>)}¶
- fragmentShader = '\n #version 120\n\n varying vec4 _FC;\n\n void main()\n {\n // set the pixel colour\n gl_FragColor = _FC;\n }\n '¶
- name = 'pixelShader'¶
- setMVMatrix(matrix)[source]¶
Set the contents of viewport mvMatrix :param matrix: consisting of 16 float32 elements
- setPMatrix(matrix)[source]¶
Set the contents of projection pMatrix :param matrix: consisting of 16 float32 elements
- vertexShader = '\n #version 120\n\n uniform mat4 pMatrix;\n uniform mat4 mvMatrix;\n varying vec4 _FC;\n\n void main()\n {\n // calculate the position\n gl_Position = pMatrix * mvMatrix * gl_Vertex;\n _FC = gl_Color;\n }\n '¶
- class ccpn.ui.gui.lib.OpenGL.CcpnOpenGLGlobal.TextShader[source]¶
Bases:
ccpn.ui.gui.lib.OpenGL.CcpnOpenGLShader.ShaderProgramABC
Main Text shader
Shader for plotting text, uses a billboard technique by using an _offset to determine pixel positions Colour of the pixel is set by glColorPointer array. Alpha value is grabbed from the texture to give anti-aliasing and modified by the ‘alpha’ attribute to affect overall transparency.
- CCPNSHADER = True¶
- attributes = {'alpha': (1, <class 'numpy.float32'>), 'axisScale': (4, <class 'numpy.float32'>), 'background': (4, <class 'numpy.float32'>), 'blendEnabled': (1, <class 'numpy.uint32'>), 'pTexMatrix': (16, <class 'numpy.float32'>), 'stackOffset': (2, <class 'numpy.float32'>), 'texture': (1, <class 'numpy.uint32'>)}¶
- fragmentShader = '\n #version 120\n\n uniform sampler2D texture;\n uniform vec4 background;\n uniform int blendEnabled;\n uniform float alpha;\n varying vec4 _FC;\n varying vec2 _texCoord;\n vec4 _texFilter;\n float _opacity;\n\n void main()\n {\n _texFilter = texture2D(texture, _texCoord);\n // colour for blending enabled\n _opacity = _texFilter.w * alpha;\n\n if (blendEnabled != 0)\n // multiply the character fade by the color fade to give the actual transparency\n gl_FragColor = vec4(_FC.xyz, _FC.w * _opacity);\n\n else \n // plot a background box around the character\n gl_FragColor = vec4((_FC.xyz * _opacity) + (1.0 - _opacity) * background.xyz, 1.0);\n }\n '¶
- name = 'textShader'¶
- setAlpha(alpha)[source]¶
Set the alpha value, a multiplier to the transparency 0 - completely transparent; 1 - solid alpha to clipped to value [0.0, 1.0] :param alpha: single float32
- setAxisScale(axisScale)[source]¶
Set the axisScale values :param axisScale: consisting of 4 float32 elements
- setBackground(colour)[source]¶
Set the background colour, for use with the solid text :param colour: consisting of 4 float32 elements
- setBlendEnabled(blendEnabled)[source]¶
Set the blend enabled flag, determines whether the characters are surrounded with a solid background block :param blendEnabled: single uint32
- setPTexMatrix(matrix)[source]¶
Set the contents of projection pTexMatrix :param matrix: consisting of 16 float32 elements
- setStackOffset(stackOffset)[source]¶
Set the stacking value for the 1d widget :param stackOffset: consisting of 2 float32 elements, the stacking offset in thje X, Y dimensions
- setTextureID(textureID)[source]¶
Set the texture ID, determines which texture the text bitmaps are taken from :param textureID: uint32
- vertexShader = '\n #version 120\n\n uniform mat4 pTexMatrix;\n uniform vec4 axisScale;\n uniform vec2 stackOffset;\n varying vec4 _FC;\n varying vec2 _texCoord;\n attribute vec3 _offset;\n \n void main()\n {\n gl_Position = pTexMatrix * ((gl_Vertex * axisScale) + vec4(_offset.xy + stackOffset, 0.0, 0.0));\n\n _texCoord = gl_MultiTexCoord0.st;\n _FC = gl_Color;\n }\n '¶
ccpn.ui.gui.lib.OpenGL.CcpnOpenGLIntegral module¶
Module Documentation here
- class ccpn.ui.gui.lib.OpenGL.CcpnOpenGLIntegral.GLintegral1dLabelling(parent=None, strip=None, name=None, enableResize=False)[source]¶
Bases:
ccpn.ui.gui.lib.OpenGL.CcpnOpenGLIntegral.GLintegralNdLabelling
Class to handle symbol and symbol labelling for 1d displays
- class ccpn.ui.gui.lib.OpenGL.CcpnOpenGLIntegral.GLintegralListMethods[source]¶
Bases:
object
Class of methods common to 1d and Nd integrals This is added to the Integral Classes below and doesn’t require an __init__
- class ccpn.ui.gui.lib.OpenGL.CcpnOpenGLIntegral.GLintegralNdLabelling(parent=None, strip=None, name=None, enableResize=False)[source]¶
Bases:
ccpn.ui.gui.lib.OpenGL.CcpnOpenGLLabelling.GL1dLabelling
,ccpn.ui.gui.lib.OpenGL.CcpnOpenGLIntegral.GLintegralListMethods
,ccpn.ui.gui.lib.OpenGL.CcpnOpenGLLabelling.GLLabelling
Class to handle symbol and symbol labelling for Nd displays
ccpn.ui.gui.lib.OpenGL.CcpnOpenGLLabelling module¶
Classes to handle drawing of symbols and symbol labelling to the openGL window Currently this is peaks and multiplets
- class ccpn.ui.gui.lib.OpenGL.CcpnOpenGLLabelling.GL1dLabelling[source]¶
Bases:
object
Class to handle symbol and symbol labelling for generic 1d displays
- class ccpn.ui.gui.lib.OpenGL.CcpnOpenGLLabelling.GLLabelling(parent=None, strip=None, name=None, enableResize=False)[source]¶
Bases:
object
Base class to handle symbol and symbol labelling
- LENSQ = 9¶
- LENSQ2 = 18¶
- LENSQ4 = 36¶
- POINTCOLOURS = 9¶
- objIsInVisiblePlanesClear()[source]¶
clear the object visibility cache for each peak in the spectrumViews
ccpn.ui.gui.lib.OpenGL.CcpnOpenGLMultiplet module¶
Module Documentation here
- class ccpn.ui.gui.lib.OpenGL.CcpnOpenGLMultiplet.GLmultiplet1dLabelling(parent=None, strip=None, name=None, enableResize=False)[source]¶
Bases:
ccpn.ui.gui.lib.OpenGL.CcpnOpenGLLabelling.GL1dLabelling
,ccpn.ui.gui.lib.OpenGL.CcpnOpenGLMultiplet.GLmultipletNdLabelling
Class to handle symbol and symbol labelling for 1d displays
- appendExtraVertices(drawList, pIndex, multiplet, p0, colour, fade)[source]¶
Add extra vertices to the vertex list
- class ccpn.ui.gui.lib.OpenGL.CcpnOpenGLMultiplet.GLmultipletListMethods[source]¶
Bases:
object
Class of methods common to 1d and Nd multiplets This is added to the Multiplet Classes below and doesn’t require an __init__
- LENSQ = 17¶
- LENSQ2 = 34¶
- LENSQ4 = 68¶
- POINTCOLOURS = 17¶
- appendExtraIndices(drawList, index, multiplet)[source]¶
Add extra indices to the index list Returns the number of unique indices NOT the length of the appended list
- appendExtraVertices(drawList, pIndex, multiplet, p0, colour, fade)[source]¶
Add extra vertices to the vertex list
- extraIndicesCount(multiplet)[source]¶
Calculate how many indices to add Returns the size of array needed to hold the indices, see insertExtraIndices
- insertExtraIndices(drawList, indexPtr, index, multiplet)[source]¶
insert extra indices into the index list Returns (len, ind)
len: length of the inserted array ind: number of unique indices
- class ccpn.ui.gui.lib.OpenGL.CcpnOpenGLMultiplet.GLmultipletNdLabelling(parent=None, strip=None, name=None, enableResize=False)[source]¶
Bases:
ccpn.ui.gui.lib.OpenGL.CcpnOpenGLMultiplet.GLmultipletListMethods
,ccpn.ui.gui.lib.OpenGL.CcpnOpenGLLabelling.GLLabelling
Class to handle symbol and symbol labelling for Nd displays
- objIsInVisiblePlanes(spectrumView, multiplet, viewOutOfPlaneMultiplets=True)[source]¶
Return whether in plane or flanking plane
- Parameters
spectrumView – current spectrumView containing multiplets
multiplet – multiplet to test
viewOutOfPlaneMultiplets – whether to show outofplane multiplets, defaults to true
- Returns
inPlane - true/false inFlankingPlane - true/false type of outofplane - currently 0/1/2 indicating whether normal, infront or behind fade for colouring
ccpn.ui.gui.lib.OpenGL.CcpnOpenGLNotifier module¶
A Small class to control the communication of information across strips. E.g. Mouse co-ordinates
Signals to other connected strips to rescale on axis changes Signal other strips to update
- class ccpn.ui.gui.lib.OpenGL.CcpnOpenGLNotifier.GLNotifier(*args, **kwargs)[source]¶
Bases:
PyQt5.QtWidgets.QWidget
Class to control the communication between different strips
- GLADD1DPHASING = 'add1DPhasing'¶
- GLALLCONTOURS = 'updateAllContours'¶
- GLALLINTEGRALS = 'glAllIntegrals'¶
- GLALLMULTIPLETS = 'glAllMultiplets'¶
- GLALLPEAKS = 'glAllPeaks'¶
- GLANY = 'glUpdateAny'¶
- GLASPECTRATIOS = 'aspectRatios'¶
- GLAXES = 'glUpdateAxes'¶
- GLAXISVALUES = 'axisValues'¶
- GLBOTTOMAXISVALUE = 'bottomAxis'¶
- GLCLEARPHASING = 'clearPhasing'¶
- GLCURSOR = 'glUpdateCursor'¶
- GLDATA = 'glData'¶
- GLGRID = 'glUpdateGrid'¶
- GLHIGHLIGHTINTEGRALS = 'glHighlightIntegrals'¶
- GLHIGHLIGHTMULTIPLETS = 'glHighlightMultiplets'¶
- GLHIGHLIGHTPEAKS = 'glHighlightPeaks'¶
- GLINTEGRALLISTLABELS = 'glUpdateIntegralListLabels'¶
- GLINTEGRALLISTS = 'glUpdateIntegralLists'¶
- GLKEY = 'key'¶
- GLLEFTAXISVALUE = 'leftAxis'¶
- GLMAINWINDOW = 'mainWindow'¶
- GLMARKS = 'glUpdateMarks'¶
- GLMODIFIER = 'modifier'¶
- GLMOUSECOORDS = 'mouseCoords'¶
- GLMOUSEMOVEDDICT = 'mouseMovedict'¶
- GLMULTIPLETLISTLABELS = 'glUpdateMultipletListLabels'¶
- GLMULTIPLETLISTS = 'glUpdateMultipletLists'¶
- GLPEAKLISTLABELS = 'glUpdatePeakListLabels'¶
- GLPEAKLISTS = 'glUpdatePeakLists'¶
- GLPEAKNOTIFY = 'glPeakNotify'¶
- GLPREFERENCES = 'glPreferences'¶
- GLRESCALE = 'glRescale'¶
- GLRIGHTAXISVALUE = 'rightAxis'¶
- GLSOURCE = 'source'¶
- GLSPECTRUMDISPLAY = 'spectrumDisplay'¶
- GLSTRIP = 'strip'¶
- GLSTRIPAXES = 'stripAxes'¶
- GLSTRIPCOLUMN = 'stripColumn'¶
- GLSTRIPROW = 'stripRow'¶
- GLSTRIPZOOMALL = 'stripZoomAll'¶
- GLTARGETS = 'glTargets'¶
- GLTOPAXISVALUE = 'topAxis'¶
- GLTRIGGERS = 'glTriggers'¶
- GLUPDATEPIVOT = 'updatePivot'¶
- GLVALUES = 'glValues'¶
- emitEventToSpectrumDisplay(source=None, strip=None, display=None, targets=[], triggers=[], values={})[source]¶
- glAllAxesChanged¶
- glAxisLockChanged¶
- glAxisUnitsChanged¶
- glEvent¶
- glKeyEvent¶
- glMouseMoved¶
- glSymbolsChanged¶
- glXAxisChanged¶
- glYAxisChanged¶
ccpn.ui.gui.lib.OpenGL.CcpnOpenGLPeak module¶
Module Documentation here
- class ccpn.ui.gui.lib.OpenGL.CcpnOpenGLPeak.GLpeak1dLabelling(parent=None, strip=None, name=None, enableResize=False)[source]¶
Bases:
ccpn.ui.gui.lib.OpenGL.CcpnOpenGLLabelling.GL1dLabelling
,ccpn.ui.gui.lib.OpenGL.CcpnOpenGLPeak.GLpeakNdLabelling
Class to handle symbol and symbol labelling for 1d peak displays
- class ccpn.ui.gui.lib.OpenGL.CcpnOpenGLPeak.GLpeakListMethods[source]¶
Bases:
object
Class of methods common to 1d and Nd peaks This is added to the Peak Classes below and doesn’t require an __init__
- class ccpn.ui.gui.lib.OpenGL.CcpnOpenGLPeak.GLpeakNdLabelling(parent=None, strip=None, name=None, enableResize=False)[source]¶
Bases:
ccpn.ui.gui.lib.OpenGL.CcpnOpenGLPeak.GLpeakListMethods
,ccpn.ui.gui.lib.OpenGL.CcpnOpenGLLabelling.GLLabelling
Class to handle symbol and symbol labelling for Nd displays
- objIsInVisiblePlanes(spectrumView, peak, viewOutOfPlanePeaks=True)[source]¶
Return whether in plane or flanking plane
- Parameters
spectrumView – current spectrumView containing peaks
peak – peak to test
viewOutOfPlanePeaks – whether to show outofplane peaks, defaults to true
- Returns
inPlane - true/false inFlankingPlane - true/false type of outofplane - currently 0/1/2 indicating whether normal, infront or behind fade for colouring
ccpn.ui.gui.lib.OpenGL.CcpnOpenGLSandbox module¶
Module Documentation here
ccpn.ui.gui.lib.OpenGL.CcpnOpenGLShader module¶
Module containing functions for defining GLSL shaders.
- class ccpn.ui.gui.lib.OpenGL.CcpnOpenGLShader.ShaderProgramABC[source]¶
Bases:
object
Class defining a GL shader program A shader is defined by the following objects vertexShader, a string object containg the code to be compiled for the vertex shader. e.g.
- vertexShader = ‘’’
#version 120
varying vec4 _FC;
void main() {
_FC = gl_Color;
fragmentShader is similarly defined
attributes is a list of the attributes that can be accessed from the shader e.g.
- attributes = {‘pMatrix’(16, np.float32),
}
pMatrix is a block of 16 np.float32 objects
Version Tags for OpenGL and GLSL Versions OpenGL GLSL #version tag 1.2 none none 2.0 1.10.59 110 2.1 1.20.8 120 <- should be the lowest needed 3.0 1.30.10 130 3.1 1.40.08 140 3.2 1.50.11 150 3.3 3.30.6 330 4.0 4.00.9 400 4.1 4.10.6 410 4.2 4.20.6 420 4.3 4.30.6 430
(On MacOS, anything above 2.1 causes problems)
- CCPNSHADER = False¶
- attributeLocation(name)[source]¶
Function to get location of an OpenGL attribute variable
- Parameters
name – String, name of the variable for which location is to be returned
- Returns
int; integer describing location
- attributes = {}¶
- fragmentShader = None¶
- property name¶
- None, immutable - Return the name of the shaderProgramABC instance
- setGLUniform1f(uniformLocation=None, value=None)[source]¶
Set a single float32 attribute in the shader
- setGLUniform1i(uniformLocation=None, value=None)[source]¶
Set a single uint32 attribute in the shader
- setGLUniform2fv(uniformLocation=None, count=1, value=None)[source]¶
Set a 2x1 uint32 vector in the shader
- setGLUniform4fv(uniformLocation=None, count=1, value=None)[source]¶
Set a 4x1 float32 vector in the shader
- setGLUniform4iv(uniformLocation=None, count=1, value=None)[source]¶
Set a 4x1 uint32 vector in the shader
- setGLUniformMatrix4fv(uniformLocation=None, count=1, transpose=GL_FALSE, value=None)[source]¶
Set a 4x4 float32 matrix in the shader
- setProjectionAxes(attMatrix, left, right, bottom, top, near, far)[source]¶
Set the contents of the projection matrix
- setViewportMatrix(viewMatrix, left, right, bottom, top, near, far)[source]¶
Set the contents of the viewport matrix
- uniformLocation(name)[source]¶
Function to get location of an OpenGL uniform variable
- Parameters
name – String, name of the variable for which location is to be returned
- Returns
int; integer describing location
- vertexShader = None¶
ccpn.ui.gui.lib.OpenGL.CcpnOpenGLSimpleLabels module¶
Module Documentation here
- class ccpn.ui.gui.lib.OpenGL.CcpnOpenGLSimpleLabels.GLSimpleLegend(parent=None, strip=None, name=None, resizeGL=False, blendMode=False, drawMode=GL_LINES, dimension=2)[source]¶
Bases:
ccpn.ui.gui.lib.OpenGL.CcpnOpenGLSimpleLabels.GLSimpleStrings
Class to handle drawing the legend to the screen
- addString(obj, position=(0, 0), axisCodes=None, colour='#FF0000', alpha=1.0, lock=0, serial=0)[source]¶
Add a new string to the list
- objectInstance(obj)[source]¶
return the object instance to insert into the string To be subclassed as required
- class ccpn.ui.gui.lib.OpenGL.CcpnOpenGLSimpleLabels.GLSimpleStrings(parent=None, strip=None, name=None, resizeGL=False, blendMode=False, drawMode=GL_LINES, dimension=2)[source]¶
Bases:
object
Class to handle grouped labels with an optional infinite line if required Labels can be locked to screen co-ordinates or top/bottom, left/right justified
- addString(obj, position=(0, 0), axisCodes=None, colour='#FF0000', alpha=1.0, lock=0, serial=0)[source]¶
Add a new string to the list
- objectInstance(obj)[source]¶
return the object instance to insert into the string To be subclassed as required
ccpn.ui.gui.lib.OpenGL.CcpnOpenGLViewports module¶
Module Documentation here
ccpn.ui.gui.lib.OpenGL.CcpnOpenGLWidgets module¶
Module Documentation here
- class ccpn.ui.gui.lib.OpenGL.CcpnOpenGLWidgets.GLExternalRegion(project=None, GLContext=None, spectrumView=None, integralListView=None)[source]¶
Bases:
ccpn.ui.gui.lib.OpenGL.CcpnOpenGLArrays.GLVertexArray
- defineIndexVBO()[source]¶
Define the buffers on the graphics card. Indexed mode with vertices and colour. If undefined, create new VBOs otherwise overwrite existing.
- Includes:
vertices: (x, y) * vertices colors: (R, G, B, a) * vertices indices: array of indexes into vertex list _ attribs: array of float for defining aliasPosition
- class ccpn.ui.gui.lib.OpenGL.CcpnOpenGLWidgets.GLInfiniteLine(parent, glList, values=(0, 0), axisCode=None, orientation='h', brush=None, colour='blue', movable=True, visible=True, bounds=None, obj=None, objectView=None, lineStyle='dashed', lineWidth=1.0, regionType='line')[source]¶
Bases:
ccpn.ui.gui.lib.OpenGL.CcpnOpenGLWidgets.GLRegion
- property values¶
- None, mutable -
- valuesChanged¶
- class ccpn.ui.gui.lib.OpenGL.CcpnOpenGLWidgets.GLIntegralRegion(project=None, GLContext=None, spectrumView=None, integralListView=None)[source]¶
Bases:
ccpn.ui.gui.lib.OpenGL.CcpnOpenGLWidgets.GLExternalRegion
- class ccpn.ui.gui.lib.OpenGL.CcpnOpenGLWidgets.GLRegion(parent, glList, values=(0, 0), axisCode=None, orientation='h', brush=None, colour='blue', movable=True, visible=True, bounds=None, obj=None, objectView=None, lineStyle='dashed', lineWidth=1.0, regionType='region')[source]¶
Bases:
PyQt5.QtWidgets.QWidget
- property axisCode¶
- None, mutable -
- property bounds¶
- None, mutable -
- property brush¶
- None, mutable -
- property colour¶
- None, mutable -
- property lineStyle¶
- None, mutable -
- property lineWidth¶
- None, mutable -
- property orientation¶
- None, mutable -
- property values¶
- None, mutable -
- valuesChanged¶
- property visible¶
- None, mutable -
ccpn.ui.gui.lib.OpenGL.setup module¶
Module Documentation here