urclib.ui_qt.visualizer.geometryglscene
OpenGL logic and scene rendering management.
Module Contents
Classes
Object for handling the rendering of geometry data and appling translation and scale transformations. |
Functions
|
Attributes
- urclib.ui_qt.visualizer.geometryglscene.POLY_GRAD_IND
- urclib.ui_qt.visualizer.geometryglscene.DEFAULT_FONT
- urclib.ui_qt.visualizer.geometryglscene.DEFAULT_CHAR_POINT_SIZE = 8
- urclib.ui_qt.visualizer.geometryglscene.dummyFn()
- exception urclib.ui_qt.visualizer.geometryglscene.GaiaGLException
Bases:
ExceptionBase exception for any GeometryGLScene related exceptions.
- exception urclib.ui_qt.visualizer.geometryglscene.GaiaGLShaderException(msg, log)
Bases:
GaiaGLExceptionException for reporting glsl shader compilation issues.
- msg
The framing message provided at construction.
- Type:
str
- log
The shader compiler information associated with the error.
- Type:
str
- Parameters:
msg (str) – The base message associated with the error.
log (str or bytes) – The log information from the shader compiler, which should contain the actual reason for failure.
- class urclib.ui_qt.visualizer.geometryglscene.GeometryGLScene(widget=None, refreshkey='', getextKey='', **kwargs)
Bases:
objectObject for handling the rendering of geometry data and appling translation and scale transformations.
- refreshkey
Name of function to call from widget whenever the draw state changes.
- Type:
str
- extentkey
Name of function to call from widget whenever draw extents are needed.
- Type:
str
- widget
The parent object that will manage the OpenGL context for the hosting UI framework.
- Type:
object
- orthoMat
Projection Matrix, using orthographic projection; describes how to render overall space.
- Type:
glm.mat4
- Parameters:
widget (object,optional) – The parent object that will manage the OpenGL context for the hosting UI framework.
refreshkey (str,optional) – Name of function to call from widget whenever the draw state changes.
getextKey (str,optional) – Name of function to call from widget whenever draw extents are needed.
- Keyword Arguments:
allowPolyPicking (bool,optional) – If True, polygons are mouse-pickable; otherwise, clicking has no effect on polygons.
allowPtPicking (bool,optional) – If True, points are mouse-pickable; otherwise, clicking has no effect on polygons.
useThicklines (bool,optional) – If true, use thick lines for selection.
beginContextKey (str,optional) – Identifier of method to invoke on parent widget to enter an OpenGL drawing state.
endContextKey (str,optional) – Identifier of method to invoke on parent widget to exit an OpenGL drawing state.
drawRubberBand (bool,optional) – If True draw the rubberband box using the previous set coordinates.
polygonColor (glm.vec4,optional) – The default polygon color in 4-channel RGBA [0,1].
pointColor (glm.vec4,optional) – The default point color in 4-channel RGBA [0,1].
gridColor (glm.vec4,optional) – The color to apply to polygon outlines in 4-channel RGBA [0,1].
pointSelectColor (glm.vec4,optional) – The selected point color in 4-channel RGBA [0,1].
selectLineColor1 (glm.vec4,optional) – First color to apply to line selection overlay 4-channel RGBA [0,1].
selectLineColor2 (glm.vec4,optional) – Second color to apply to line selection overlay 4-channel RGBA [0,1].
selectPolyColor1 (glm.vec4,optional) – First color to apply to polygon fill selection overlay 4-channel RGBA [0,1].
selectPolyColor2 (glm.vec4,optional) – Second color to apply to polygon fill selection overlay 4-channel RGBA [0,1].
fillSelections (bool,optional) – If True apply selection overlay to the interior of selected polygons
outlineSelections (bool,optional) – If True, the selection overlay is applied to the perimeter of a selected polygon.
fillPolygons (bool,optional) – If True, fills the interior of polygons with the appropriate color.
fillWithGradient (bool,optional) – If True, fill with contents of reference gradient values, if present.
- property geometryExtent
The extents of the minimum bound box for all geometry as [left,right,bottom,top].
- Type:
list
- property geometrySize
the x and y lengths of the scene in world units, in that order.
- Type:
tuple
- property geometryOrigin
The coordinate of the bottom-left corner of the extents, in world units.
- Type:
tuple
- property fillPolygons
flag indicating whether or not the polygons are being filled with the assigned color.
- Type:
bool
- property defaultPointColor
normalized color channel values to be applied to all points in (R,G,B) ordering.
- Type:
numpy.array
- property defaultGridColor
normalized color channel values to be applied to all polygon outlines in (R,G,B) ordering.
- Type:
numpy.array
- property defaultPolygonColor
normalized color channel values to be applied to all polygon interiors in (R,G,B) ordering.
- Type:
numpy.array
- property selectColor
The color used to highlight selected geometry.
- Type:
glm.vec4
- property pointSelectColor
The color used to highlight selected point geometry.
- Type:
glm.vec4
- property allowPicking
true if any layers allow picking; false otherwise.
- Type:
bool
- property allowPolyPicking
True if polygon picking is enabled; False otherwise.
- Type:
bool
- property allowPtPicking
True if point picking is enabled; False otherwise.
- Type:
bool
- property allowLinePicking
True if line picking is enabled; False otherwise.
- Type:
bool
- property backgroundColor
normalized color channel values to be applied to the background in (R,G,B) ordering. This is a write-only attribute.
- Type:
numpy.array
- property polygonSelectionFill
True if selected polygons are filled with a specific color; False otherwise.
- Type:
bool
- property polygonSelectionOutline
True if selected polygons are outlined with a specific color; False otherwise.
- Type:
bool
- property selectFillColors
The primary and secondary colors used to fill selected polygons as glm.vec4 values.
- Type:
tuple
- property selectLineColors
The primary and secondary colors used to outline selected polygons as glm.vec4 values.
- Type:
tuple
- property layerCount
Total number of layers registered with the scene.
- Type:
int
- property initialized
If True, initializeGL() has been called; otherwise the scene’s OpenGL supported hasn’t been initialized.
- Type:
bool
- property rubberBandColors
Primary and secondary colors for rubberband drawing as glm.vec4 values.
- Type:
tuple
- TEXHEAD_DT
- static getNextId()
Unique Id generator. Default implementation starts at 0 and increments by one on each call.
- Returns:
The next unique id.
- Return type:
int
- initializeGL()
Initializes the OpenGL subsystem. This will need to be called before any rendering can take place.
- _beginContext()
- _endContext()
- _doRefresh()
Call the widget’s refresh function.
- grabContext()
Method used as context for easily grabbing and releasing the host system’s draw context.
- Yields:
None
- GetGLExtents()
Get the extents of the OpenGL canvas.
- Returns:
Implementation-appropriate representation of the parent widgets extents.
- Return type:
object
- static _drawThickLineGL(start, count)
- paintGL()
Method responsible for applying draw instructions to the OpenGL state machine.
- _drawPolyLayer(rec, pickMode=False)
- _drawPointLayer(rec, pickMode=False)
- _drawLineLayer(rec, pickMode=False)
- _drawRaster(rec, pickMode=False)
- _drawTextLayer(rec)
- _regenFramebuffer(width, height)
- markFullRefresh()
Mark the scene for a full refresh on the next draw cycle.
- resizeGL(width, height)
Resize operations for the OpenGL context.
- Parameters:
width (int) – The new width of the viewport.
height (int) – The new height of the viewport.
- SetExtents(left, right, bottom, top, margin=0.05)
Set the extents for the orthogonal view
- Parameters:
left (float) – The left extent.
right (float) – The right extent.
bottom (float) – The bottom extent.
top (float) – The top extent.
margin (float,optional) – The margin to pad each extent with as a fraction of width or height as appropriate.
- SetMaxExtents(left, right, bottom, top)
Assign extents only if greater than the currently assigned extent.
- Parameters:
left (float) – The left extent.
right (float) – The right extent.
bottom (float) – The bottom extent.
top (float) – The top extent.
- recalcMaxExtentsFromLayers()
Recalculates the scene extents by iterating through each layer and finding the minimum bounding box for all.
- _addVectorRecord(verts, ext, rec, extra=None)
- _addRasterRecord(pxlData, channels, rec, internal=None, gradObj=None)
- _registerLayer(rec)
- AddPointLayer(verts, ext, **kwargs)
Set the points to be rendered.
- Parameters:
verts (numpy.array) – 1D array of vertex components to be rendered as points.
ext (tuple) – Minimum extents to apply; extents are in the order of (left, right, bottom, top).
- Keyword Arguments:
single_color (glm.vec4) – Default color option. Color to apply to all entries.
group_colors (list) – List of ColorRange objects, denoting sequentiol records with the same color.
indexed_colors (list) – List of IndexedColor objects, tying colors to specific indices.
value_gradient (GradientRecord) – GradientRecord object used to translate values passed in with attrib_data into color values.
attrib_data (numpy.ndarray) – float values (one for each point) intended to be translated into a color using the value_gradient object.
- Returns:
Index of new layer.
- Return type:
int
- AddPolyLayer(verts, polygroups, ext, **kwargs)
Set the polygons to be rendered.
- Parameters:
verts (numpy.array) – 1D array of vertex components to be rendered as points composing the polygon rings.
polygroups (list) – A list of lists of start indices and lengths. These are used to describe how to draw the contents of verts as polygons.
ext (tuple) – Minimum extents to apply; extents are in the order of (left, right, bottom, top).
- Returns:
Index of new layer.
- Return type:
int
- AddLineLayer(verts, ext, linecount=None, linegroups=None, values=None, **kwargs)
Add a layer of lines to be rendered.
- Parameters:
verts (numpy.array) – 1D array of vertex components to be rendered as points composing the polygon rings.
ext (tuple) – Minimum extents to apply; extents are in the order of (left, right, bottom, top).
linecount (int,optional) – Total number of line segments to draw; can be None if linegroups is not `None.
linegroups (list,optional) – A series of tuples, each containing a start index and record count, describing one or more line strings to draw. Can be None if linecount is not None.
values (list,optional) – Optional float values to apply to each line vertex.
- Returns:
Id of newly created line layer.
- Return type:
int
- AddTextLayer(strEntries, **kwargs)
Add a layer displaying text strings.
- Parameters:
strEntries (list) – StringEntry objects providing details for each string to be drawn.
- Keyword Arguments:
color (glm.vec4) – Color to use to render font.
h_justify (str) – The horizontal justification to use. See TextLayerRecord for options.
v_justify (str) – The vertical justification to use. See TextLayerRecord for options.
font_path (str) – Path to the freetype compatible font file, such as *.ttf or *.otf.
font_pt (int) – The point size to use to render the font.
- Returns:
Id of newly created layer.
- Return type:
int
See also
TextLayerRecord in _support.py.
- _loadTextData(rec, strEntries=(), lblArgs=None, fontArgs=None)
- _loadPointLayer(rec, ext, verts, attribVals=None)
- _loadPolyLayer(rec, ext, verts)
- _loadLineLayer(rec, ext, verts, refVals=None)
- _loadReferenceLayer(rec)
- _loadRasterLayer(pxlData, channels, rec, internal=None, gradObj=None)
- AddRasterImageLayer(pxlData, channels, exts)
Add Raster data to be directly displayed as an image.
- Parameters:
pxlData (numpy.ndarray) – Data composing the raster.
channels (int) – OpenGL flag indicating number of channels (ie GL_RED, GL_RGBA, etc.)
exts (tuple) – Minimum extents to apply; extents are in the order of (left, right, bottom, top).
- Returns:
id of newly created raster layer.
- Return type:
int
- AddRasterIndexedLayer(pxlData, channels, exts, internal=None, gradObj=GradientRecord())
Add a raster that represents data that must use a transfer gradient to be displayed.
- Parameters:
pxlData (numpy.ndarray) – Data composing the raster.
channels (int) – OpenGL flag indicating number of channels (ie GL_RED, GL_RGBA, etc.)
exts (tuple) – Minimum extents to apply; extents are in the order of (left, right, bottom, top).
internal (int,optional) – OpenGL flag for internal representation of the texture; Defaults to the value of channel.
gradObj (GradientRecord,optional) – Color profile to use for transfer function.
Returns:
- AddReferenceLayer(srcLayerId, pureAlias=False)
- Placeholder for a record being maintained by another instance. This allows for
providing alternate display attributes without having to duplicate source data.
- Parameters:
srcLayerId (LayerRecord) – The id of the layer to reference
pureAlias (bool) – If true, no attribute data is expected to change; otherwise, some attributes (such as color) may be duplicated.
- Returns:
id of reference record.
- Return type:
int
- _typeSetForRec(rec)
Find the list of ids which contain the same layer type as rec
- Parameters:
rec (LayerRecord) – The record of the type to retrieve the indices for.
- Returns:
The list of indices of the specified LayerRecord type.
- Return type:
list
- Raises:
ValueError – if the type of rec is not recognized as a LayerRecord subclass.
- _LoadGLBuffer(verts, ext, rec, extra=None)
Load vertex data into GPU memory, adjusting extents as necessary.
- Parameters:
verts (numpy.array) – 1D array of float values representing ordered vertex components.
ext (tuple or None) – A list of values representing the minimum extent. Ignored if set to None.
rec (LayerRecord) – Reference to Vertex Array Object to populate.
buff (int) – Reference to Vertex Buffer Object to populate.
Returns:
- _LoadTexture(vals, trgTex, texMode, channels, texLoc, internal=None, interp=False)
Load texture data into OpenGL and into VRAM.
- Parameters:
vals (numpy.ndarray) – The texture data to load.
trgTex (int) – OpenGL texture attachment point: GL_TEXTURE0, GL_TEXTURE1, etc.
texMode (int) – OpenGL texture type; either GL_TEXTURE_1D, or GL_TEXTURE_2D.
channels (int) – OpenGL channel description flag: must be GL_RED, GL_RG, GL_RGB, GL_BGR, GL_RGBA, or GL_BGRA.
texLoc (int) – The identifier for the texture object.
internal (int) – OpenGL for internal data representation.
interp (bool) – If True, texture data is linearly interpolated when sampled; otherwise, Texture data will remain pixelated.
- Raises:
ValueError – if channels or texMode specify unsupported flags.
- UpdateIndexRasterGradient(id, gradObj, targetTex=1)
Update Gradient used in transfer for indexed raster layer.
- Parameters:
id (int) – Identifier of layer to modify.
gradObj (GradientRecord) – The gradient representing the new color transfer profile.
targetTex (int,optional) – The target texture. Should be the offset from GL_TEXTURE0.
- DeleteLayer(id)
Remove a layer from the scene.
- Parameters:
id (int) – Id of the layer to remove.
- ClearPointSelections()
Clear selected points across all layers.
- ClearPolySelections()
Clear polygon selections across all layers.
- ClearLineSelections()
Clear line selections across all layers.
- ClearLayerSelections()
Clear selections across all layers.
- ClearPolyLayers()
Remove all polygon layers.
- ClearPointLayers()
Remove all point layers.
- ClearLineLayers()
Remove all line layers.
- ClearRasterLayers()
Remove all raster layers.
- ClearAllLayers()
Remove all layers
- SetLayerFillPolys(id, doFill)
Configure a polygon layer’s fill policy.
- Parameters:
id (int) – Id of the polygon layer to update.
doFill (bool) – Whether or not to fill polygons.
- SetLayerAttrVals(id, aVals)
Set attribute values for layer. These values can be used along with a transfer color gradient to display polygon associated data.
- Parameters:
id (int) – Id of layer to update.
aVals (numpy.ndarray) – Values to apply to each geometric entity in the layer.
- AllLayersFillPolys(doFill)
Apply filling attribute to all polygon layers.
- Parameters:
doFill (bool) – Whether or not all polygon layers should fill their polygons.
- SetLayerDrawGrid(id, isVisible)
DEPRECATED; use SetPolyLayerDrawOutline() instead.
- SetPolyLayerDrawOutline(id, isVisible)
Set visibility of polygon outlines for a specific layer.
- Parameters:
id (int) – The id of the layer to modify.
isVisible (bool) – Whether or not outlines should be drawn.
- AllLayersDrawGrid(visible)
DEPRECATED; use AllPolyLayersDrawOutline() instead.
- AllPolyLayersDrawOutline(visible)
Set visibility of polygon outlines for all polygon layers.
- Parameters:
visible (bool) – Whether or not outlines should be drawn.
- SetLayerVisible(id, isVisible)
Toggle layer visibility.
- Parameters:
id (int) – Id of layer to modify.
isVisible (bool) – Draw layer if True; hide layer if False.
- GetLayerVisible(id)
Test to see if layer is presently being drawn.
- Parameters:
id (int) – Id of the layer to query.
- Returns:
True if the layer is visible; False otherwise.
- Return type:
bool
- AllPointLayersVisible(isVisible)
Toggle visibility of all point layers.
- Parameters:
isVisible (bool) – Draw all point layers if True; hide all point layers if False.
- AllPolyLayersVisible(isVisible)
Toggle visibility of all polygon layers.
- Parameters:
isVisible (bool) – Draw all polygon layers if True; hide all polygon layers if False.
- AllRasterLayersVisible(isVisible)
Toggle visibility of all raster layers.
- Parameters:
isVisible (bool) – Draw all raster layers if True; hide all raster layers if False.
- layerIter()
Retrieve iterator to loop through all layers.
- Returns:
Iterator through layers.
- Return type:
generator
- UpdateLayerVertices(id, verts)
Update vertices for an existing layer.
- Parameters:
id (int) – The layer to update.
verts (numpy.array) – The new vertex positions.
Notes
Count of vertices will not change; do not add more vertices than added in original layer. Works best if layer is marked as volatile.
- GetLayer(id)
Retrieve details of the requested layer.
- Parameters:
id (int) – The id of the layer to retrieve.
- Returns:
Record of the requested layer.
- Return type:
- Raises:
KeyError – id value is not present amongst layers in scene.
- ToggleLayerSelect(layer, ind)
Toggle the selection mode for an object in the provided layer.
- Parameters:
layer (int) – The id of the layer to target.
ind (int) – Index of geometric entity to toggle. What ind refers to is specific to the type of layer.
- SelectAllLayer(id, select)
Set selection for all entities in a layer.
- Parameters:
id (int) – Id of layer to target.
select (bool) – The selection mode to apply (selected or deselected).
- GetSelectedGeom(id)
Retrieve indices of selected geometry in a given layer.
- Parameters:
id (int) – Id of layer to query.
- Returns:
Collection of indices corresponding to selected geometry within the layer.
- Return type:
tuple
- ResetView()
Reset the view matrix back to the identity state.
- DistanceForTranslate(start, finish)
Translate the view scene to reflect the delta between start and finish.
A translation is an addition to the values in the rightmost column of a vector (minus the homogenous anchor):
1 0 0 x + Tx |0 1 0 y + Ty |0 0 1 z + Tz |0 0 0 1 |Where T is the translation vector
- Parameters:
start (list) – 3-value vector containing 3D coordinates representing the start position.
finish (list) – 3-value vector containing 3D coordinates representing the finish position.
- TranslateView(curr)
Translate the view scene to reflect the delta between start and finish.
A translation is an addition to the values in the rightmost column of a vector (minus the homogenous anchor):
1 0 0 x + Tx |0 1 0 y + Ty |0 0 1 z + Tz |0 0 0 1 |Where T is the translation vector
- Parameters:
curr (list) – 3-value vector containing 3D coordinates of new position.
- TranslateViewTo(curr)
Translate the view scene to reflect the delta between start and finish.
A translation is an addition to the values in the rightmost column of a vector (minus the homogenous anchor):
1 0 0 Tx |0 1 0 Ty |0 0 1 Tz |0 0 0 1 |Where T is the translation vector
- Parameters:
curr (list) – 3-value vector containing 3D coordinates of new position.
- SetPosition(pos)
Set the absolute position of a translation instead of applying it to the existing position.
Overwriting the position of a matrix looks like this:
1 0 0 Px |0 1 0 Py |0 0 1 Pz |0 0 0 1 |Where P is the new Position Vector.
- Parameters:
pos (list) – A 3-value position vector or a 4-value homogenous coordinate vector, representing the new position.
- SetPtSize(id, newSize)
Set the size to use when rendering points.
- Parameters:
id (int) – id of layer to modify.
newSize (float) – The size to use when rendering a point.
- SetPtGlyph(id, glyph)
- Parameters:
id –
glyph –
Returns:
- IncrementZoom(zoomIn, stepSize=None)
Zoom the view in or out.
“Zooming” is really applying a scale operation to the view matrix, which looks like this:
Sx 0 0 0 |0 Sy 0 0 |0 0 Sz 0 |0 0 0 1 |Where S is the scaling vector.
Note that the translation values are also modified to keep the scene properly centered when zooming.
- Parameters:
zoomIn (bool) – Zoom in if true; zoom out if false.
stepSize (float) – The distance to zoom per increment.
- zoomToExts(left, right, bottom, top, sceneSpace=False)
Zoom to a bounding box.
- Parameters:
left (float) – Left extent of zoom box.
right (float) – Right extent of zoom box.
bottom (float) – Bottom extent of zoom box.
top (float) – Top extent of zoom box.
sceneSpace (bool) – If True, interpret the extents in scene/worldspace; otherwise, interpret in clip space, ie all extents are in [-1,1]
- zoomToRubberBand()
Zoom to extents defined by a “rubberband” box.
- _RepositionZoom(adj)
Recenter after zoom
- Parameters:
adj (float) – Ratio to use for recenter.
- MultiplyZoom(zoom)
Multiply scale value by S. | Sx 0 0 0 | | 0 Sy 0 0 | | 0 0 Sz 0 | | 0 0 0 1 |
- Parameters:
zoom (float) – The factor to increase/decrease scale by (‘S’ in the above diagram)
- zoomToLayer(id)
Zoom to the extents of a requested layer.
- Parameters:
id (int) – Id of the layer to focus on.
- updateProjMat()
Refresh the internal projection matrix.
- _updateMVP()
Update the cached MVP matrix and its inverse for use in rendering calculations.
- _getRecordIdColor(recId, featInd=None)
Get a color to represent the id (and feature id). Both recId and featInd are stored in 16 bit, meaning 65,536 unique values are supported for each field.
- Parameters:
recId (int) – The id for the layer.
featInd (int,optional) – The subfeature id of the layer.
- Returns:
The color to be used as an identifier during picking operations
- Return type:
glm.vec4
- _assignPolyFillColor(pickMode, rec, featInd)
Assign appropriate polygon colors for the current rendering option.
- Parameters:
pickMode (bool) – If True the associated polygons are colored with their id colors; otherwise, they are colord by the feature color specified by featInd.
rec (LayerRecord) – The record to update colors for.
featInd (int) – The indexed feature to reference the color for.
- layerColors(id)
list: Fill domainColors for each polygon listed in order; see the fillColor property for format of individual domainColors.
- updateColor(id, color, index=None)
Assign new single or indexed color within a layer.
- Parameters:
id (int) – Id of layer to update.
color (glm.vec4) – The color to assign.
index (int,optional) – The index of the color to update; if None, color is treated as single color for entire layer.
- updateGridColor(id, color)
DEPRECATED; use updatePolyOutlineColor instead.
- updatePolyOutlineColor(id, color)
Update the color of polygon outlines for a given layer.
- Parameters:
id (int) – The layer to update.
color (glm.vec4) – The color to apply to outlines.
- updateFillGrid(id, doFill)
DEPRECATED; use updateFillPolys() instead.
- updateFillPolys(id, doFill)
Update polygon filling for a given layer.
- Parameters:
id (int) – Id of the layer to modify.
doFill (bool) – Whether or not fill the polygons for the given layer.
- updateLineThickness(id, thickness)
Update the thickness of lines for a given layher.
- Parameters:
id (int) – The layer to update.
thickness (float) – The thickness to apply, in pixels.
- updateGridThickness(id, thickness)
DEPRECATED, use updateLineThickness() instead
- updatePointSize(id, ptSize)
Update the size of drawn points in a given point layer.
- Parameters:
id (int) – Id of the point layer to update.
ptSize (float) – The new point size, in pixels.
- _updateRubberBandColor()
Synchronize the color in the rubberband shaders with those stored within the GeometryGLScene object.
- _repackageIndexedColors(rec, dColor=glm.vec4(0.0, 0.0, 0.0, 1.0))
Synchronize the colors stored within a LayerRecord’s VBO with a LayerRecord’s indexed color values.
- Parameters:
rec (LayerRecord) – Record of the layer to update.
dColor (glm.vec4,optional) – The default color to apply to any entities which are not explicitly indexed.
- replaceIndexColors(lyrid, iColors, dColor=glm.vec4(0.0, 0.0, 0.0, 1.0))
Replace all indexed colors in a given layer.
- Parameters:
lyrid (int) – Id of layer to update.
iColors (list) – List of IndexedColor objects, tying colors to specific indices.
dColor (glm.vec4,optional) – The color to apply to any indices not included in iColors
- Raises:
ValueError – Layer does not use indexed coloring.
- updateIndexColor(lyrid, index, color)
- Parameters:
lyrid (int) – Id of layer to update.
index (int) – Index of the colorgroup to update.
color (glm.vec4) – The new color to apply.
- Raises:
ValueError – Layer does not use indexed coloring.
- setRasterSmoothing(lyrid, smooth)
Toggle smoothing for rasters; only has effect for raster layers.
- Parameters:
lyrid (int) – Id of layer to update.
smooth (bool) – If True the raster will be smoothed using linear interpolation; otherwis, the layer will be drawn as coarse pixels.
- setIndexRasterValueBoundaries(lyrid, low=0.0, high=1.0)
Set the bounds used to interpet index raster values.
- Parameters:
lyrid (int) – Id of the layer to update.
low (float,optional) – The lower bound of the interpreted values in [0,1].
high (float,optional) – The upper bound of the interpreted values in [0,1].
- setIndexClampGradient(lyrid, doClamp)
Set clamping of gradient interpolation range set by setIndexRasterValueBoundaries().
- Parameters:
lyrid (int) – Id of the layer to update.
doClamp (bool) – If True, clamps the gradient interpolation; otherwise, interpolates full range of [0,1].
- clearUtilityBuffers()
Clean up intermediate VBOs and VAOs.
- cleanupOpenGL()
Cleanup/release all OpenGL resources.
- doMousePick(x, y)
Perform a pick at the given pixel coordinate.
- Parameters:
x (int) – The horizontal pixel coordinate.
y (int) – The vertical pixel coordinate.
- Returns:
- The selected layer and geometric ids, respectively. None if pick coordinate does not overlap with
layer data.
- Return type:
tuple
- _UpdateSelections(index)
Update selection for point layer.
- Parameters:
index (int) – The layer to update; has no effect on non-point layers.
- updateRubberBand(p1, p2)
Update the position of the rubberband box. A rubberband is a box usually defined by a user clicking and dragging across a region.
- Parameters:
p1 (tuple) – The coordinates of a corner, diagonally opposite of p2.
p2 (tuple) – The coordinates of a corner, diagonally opposite of p1.
- ClipPtToScene(pt)
Perform a reverse-point lookup on the scene
- Parameters:
pt (object) – A container with at least two indexed values in the range of [-1,1]
- Returns:
The four-component homogenous coordinate from the scene
- Return type:
numpy.ndarray
- ScenePtToClip(pt)
Converts a point from scene space to the equivalent point in clip space.
- Parameters:
pt (tuple) – The point to convert from scene space to clip space.
- Returns:
pt as represented in clip space.
- Return type:
glm.vec4
- SetReferenceTexture(layerId, vals, refExts, oobColor=np.array([1.0, 1.0, 0.0, 1.0], dtype=np.float32))
Set 2D texture with values referenced from GIS operation.
layerId (int): The id of the layer to modify. vals (numpy.array): 2D array of pixel values. refExts (list): Reference spatial extents in [left,right,bottom,top] order. oobColor (numpy.ndarray): out-of-bound color; the color to apply for out-of-bound texture coordinates.
Returns:
- SetGradientTexture(layerId, gradObj, forRefTex=True)
Create 1D texture containing gradient colors for use as simple transfer function.
- Parameters:
layerId (int) – The id of the layer to modify.
gradObj (GradientRecord) – The gradient to apply to the data.
forRefTex (bool) – Determines which texture slot the gradient is inserted into.
- SetPolyLayerFillMode(id, pfMode)
Set whether or not polygons are filled for a given layer. Has no effect on non-polygon layers.
- Parameters:
id (int) – Id of the layer to update.
pfMode (bool) – If true, designate the polygons for filling; otherwise, just draw their boundaries
- moveUpStack(id)
Move a layer up the draw stack by one position.
- Parameters:
id (int) – The layer to move up, if possible.
- moveDownStack(id)
Move a layer down the draw stack by one position.
- Parameters:
id (int) – The layer to move down, if possible.
- moveTopStack(id)
Move a layer to the top of the draw stack.
- Parameters:
id (int) – The layer to place at the top of the stack.
- moveBottomStack(id)
Move a layer to the bottom of the draw stack.
- Parameters:
id (int) – The layer to place at the bottom of the stack.
- getDrawStackPosition(id)
Get the draw indexed position of a layer in the draw stack. The higher the index, the lower down the stack the layer is, with 0 being the topmost index.
- Parameters:
id (int) – The layer to query for position with.
- Returns:
The designated layers index within the draw stack.
- Return type:
int
- setDrawStackPosition(id, pos)
Move a layer to a specific position within the draw stack.
- Parameters:
id (int) – The layer to be moved to a specific position.
pos (int) – The index of the new position within the draw stack.
- _getTextRenderer(fontPath, ptSize)
Retrieve the TxtRenderer object for the given font and pointSize.
- Parameters:
fontPath (str) – Path to the font file.
ptSize (int) – The point size used to render the text.
- Returns:
Either a new renderer, or an existing renderer if one already matches the arguments.
- Return type:
- updateScreenAspect(aspect)
Update the height:width ratio of the displayed port.
- Parameters:
aspect (float) – height / width, in pixels.
- _refreshTextTransMat()
Refresh the matrix used for billboarding text glyphs
- dumpVertsToStream(rec, strm)
Dump vertices of a given layer to an output stream as binary data.
- Parameters:
rec (LayerRecord) – The record of the layer whose vertices will be dumped.
strm (FILE) – Filelike object representing the output stream.
- Raises:
GaiaGLCacheException – If any issues arise with locating and writing the data.
- dumpBuffToStream(buffType, buff, nbytes, strm, offset=0)
Directly dump the contents of an OpenGL Buffer Object (VBO) to a binary stream.
- Parameters:
buffType (int) – The OpenGL designation for the type of VBO, ie GL_ARRAY_BUFFER, GL_ELEMENT_ARRAY_BUFFER, etc.
buff (int) – The identifier of the buffer to dump.
nbytes (int) – The length of the buffer, in bytes.
strm (FILE) – Filelike object targeted for writing.
offset (int,optional) – The offset into the buffer to begin reading from, in bytes.
- Raises:
GaiaGLCacheException – If method is called before initialization.
- dumpTexToStream(rec, strm)
Dump texture (raster) data out as a binary stream.
- Parameters:
rec (RasterLayerRecord) – Record object representing the raster layer to dump.
strm (FILE) – Filelike object to be written to.
- loadTexFromStream(strm, skip=False)
Load texture data from a stream object.
- Parameters:
strm (FILE) – The filelike object to read from.
skip (bool,optional) – If true, skips over the entry in strm without loading data; defaults to False.
- Returns:
- Integer flag representing the internal data type of the texture, and a numpy array containing the
raw pixel data, or (None,None) if skip is True.
- Return type:
tuple