urclib.ui_qt.visualizer.qt_support

Package for utilizing GAIAVisualizer in Qt.

Subpackages

Submodules

Package Contents

Classes

GaiaQtGLWidget

Qt-compatible widget for visualization support.

ColorButton

Button which acts as a colorwell with default color picking action attached to click.

GradientButton

Variant of the ColorButton which allows for defining a two-color gradient.

GradientSwatch

Widget for displaying a noninterative gradient as a swatch (preview).

GradientDialog

Dialog for editing values that compose a color ramp/gradient.

Functions

vecToQColor(c)

Converts from glm.vec3 or glm.vec4 to QColor.

QColorToVec(c)

Converts from QColor to glm.vec4.

GradRecToStops(gr)

Convert a GradientRecord to stops that QLinearGradient can understand.

StopsToGradRec(stps)

Convert a list of stops into a GradientRecord object.

class urclib.ui_qt.visualizer.qt_support.GaiaQtGLWidget(parent=None, inScene=None)

Bases: urclib.ui_qt.visualizer.qt_support._compat.QOpenGLWidget

Qt-compatible widget for visualization support.

GLDrawErrHandler

Optional function that takes a title and message as arguments. This function is called when an OpenGL error is encountered.

Type:

function(str,str),optional

dragButton

Qt enumeration for which mouse button is used with drag operations. Default is Qt.LeftButton.

Type:

int

selectButton

Qt enumeration for which mouse button is used with selection operations. Default is Qt.RightButton.

Type:

int

rubberBandEnabled

Flag indicating whether or not to allow rubber-band drawing for operations. Defaults to True.

Type:

bool

initZoom

Either List of extents or id of layer to zoom to on load of scene data. Default is None.

Type:

list or number,optional

Parameters:
  • parent (QWidget,optional) – The parent widget. Defaults to None.

  • inScene (GeometryGLScene,optional) – The scene object to associate with the widget; defaults to None.

Qt Signals:
  • selectionpicked (int,int) – Emitted when a geometric object in the scene is selected by the user. Emits the layer id and geometry object’s index within that layer.

  • mouseMoved (float,float) – Emitted whenever the mouse is moved within the widget. Mouse tracking must be enabled for this to work properly. The (x,y) coordinate emitted is in scene/world space.

  • mouseInOut (bool) – Emitted when the mouse cursor enters or leaves the scene. Flag is emitted indicating whether the cursor is still in the scene.

  • pointclicked (float,float) – Point in world coordinates where a click took place.

class SimpleExtent(qSize)

Bases: object

Simple representation of rectangular extents. Generic representation of QRect object.

width

width of the extent.

Type:

float

height

height of the extent.

Type:

float

x

The x-component of the bottom-left origin.

Type:

float

y

The y-component of the bottom-left origin.

Type:

float

Parameters:

qSize (QRect) – Rect to convert into extents.

property list_extents

extents in [left,right,bottom,top] form.

Type:

list

property scene

Teh currently assigned scene object

Type:

GeometryGLScene

selectionpicked
mouseMoved
mouseInOut
pointclicked
cleanupGL()

Deallocate any referenced OpenGL resources.

getSimpleExtent()

Retrieve scene extent in pixel space.

Returns:

Generalized extent object for widget.

Return type:

GaiaGLWidget.GaiaQtGLWidget

paintGL()

This is an overload of a method of QOpenGLWidget. See official documentation for more information.

See also

[Official Qt Documentation](https://doc.qt.io/qt-5/qopenglwidget.html#paintGL)

initializeGL()

This is an overload of a method of QOpenGLWidget. See official documentation for more information.

See also

[Official Qt Documentation](https://doc.qt.io/qt-5/qopenglwidget.html#initializeGL)

resizeGL(w, h)

This is an overload of a method of QOpenGLWidget. See official documentation for more information.

Parameters:
  • w (int) – The new width of the viewport, in pixels.

  • h (int) – The new height of the viewport, in pixels.

See also

[Official Qt Documentation](https://doc.qt.io/qt-5/qopenglwidget.html#resizeGL)

makeCurrent()

This is an overload of a method of QOpenGLWidget. See official documentation for more information.

See also

[Official Qt Documentation](https://doc.qt.io/qt-5/qopenglwidget.html#makeCurrent)

doneCurrent()

This is an overload of a method of QOpenGLWidget. See official documentation for more information.

See also

[Official Qt Documentation](https://doc.qt.io/qt-5/qopenglwidget.html#doneCurrent)

_raiseUninitException(fnlbl)

Convenience method for raising an error when method is called which relies on scene property, when scene is None

Parameters:

fnlbl (str) – The name of the function/method being invoked.

pointToScene(curPos, toClipspace=False)

Converts a point (generally considered the cursor position) from pixel space to projected space.

Parameters:
  • curPos (glm.vec2) – The point in widget pixel space.

  • toClipspace (bool,optional) – If true, converts coordinate into clip space instead of world space. Defaults to False.

Returns:

The coordinates in scene projected space.

Return type:

glm.vec4

forceRefresh()

Explicitly mark the scene for redrawing and post an update notification.

mouseMoveEvent(event)

This is an overload of a method of QOpenGLWidget. See official documentation for more information.

Parameters:

event (PyQt5.QtGui.QMouseEvent) – The triggering event.

See also

[Official Qt Documentation](https://doc.qt.io/qt-5/qwidget.html#mouseMoveEvent)

mouseReleaseEvent(event)

This is an overload of a method of QOpenGLWidget. See official documentation for more information.

Parameters:

event (PyQt5.QtGui.QMouseEvent) – The triggering event.

See also

[Official Qt Documentation](https://doc.qt.io/qt-5/qwidget.html#mouseReleaseEvent)

enterEvent(event)

This is an overload of a method of QOpenGLWidget. See official documentation for more information.

Parameters:

event (PyQt5.QtGui.QEvent) – The triggering event.

See also

[Official Qt Documentation](https://doc.qt.io/qt-5/qwidget.html#enterEvent)

leaveEvent(event)

This is an overload of a method of QOpenGLWidget. See official documentation for more information.

Parameters:

event (PyQt5.QtGui.QEvent) – The triggering event.

See also

[Official Qt Documentation](https://doc.qt.io/qt-5/qwidget.html#leaveEvent)

wheelEvent(event)

This is an overload of a method of QOpenGLWidget. See official documentation for more information.

Parameters:

event (PyQt5.QtGui.QWheelEvent) – The triggering event.

See also

[Official Qt Documentation](https://doc.qt.io/qt-5/qwidget.html#wheelEvent)

showEvent(event)

This is an overload of a method of QOpenGLWidget. See official documentation for more information.

Parameters:

event (PyQt5.QtGui.QShowEvent) – The triggering event.

See also

[Official Qt Documentation](https://doc.qt.io/qt-5/qwidget.html#showEvent)

_doInitLayerZoom()

Perform scene zoom on load.

class urclib.ui_qt.visualizer.qt_support.ColorButton(*args, **kwargs)

Bases: urclib.ui_qt.visualizer.qt_support._compat.QPushButton

Button which acts as a colorwell with default color picking action attached to click.

Parameters:
  • *args – Forwarded to QPushButton.

  • **kwargs – Forwarded to QPushButton.

property basecolor

The selected base color of the button.

Type:

drawUtils.SimpaColor

baseColorChanged
paintEvent(pevent)

Qt event handler for paint events.

Parameters:

pevent (PyQt5.QtGui.QPaintEvent) – The triggering event object.

Returns:

_setfill(painter)

Set the fill style for the paint object.

Parameters:

painter (PyQt5.QtWidgets.QStylePainter) – The painter object drawing the button.

_clicked()

Default click action behavior.

Results in launching color picker and assigning the selected color to the ‘basecolor’ property.

_run_colorpicker(incolor, title)

Launch the color picker dialog.

Parameters:
  • incolor (PyQt5.QtGui.QColor) – The initializing color for the dialog.

  • title (str) – The title to apply to the dialog.

Returns:

The color selected by the user.

Return type:

PyQt5.QtGui.QColor

class urclib.ui_qt.visualizer.qt_support.GradientButton(*args, **kwargs)

Bases: ColorButton

Variant of the ColorButton which allows for defining a two-color gradient.

highColorChanged

Signal indicating that the selected high boundary color has changed.

Type:

PyQt5.QtCore.pyqtSignal

Parameters:
  • *args – Forwarded to ColorButton.

  • **kwargs – Forwarded to ColorButton.

property stops

The stop values for the gradient definition.

Type:

PyQt5.QtGui.QGradientStops

gradientChanged
gradientWithAlphaChanged
setDirection(direction)

Set the direction of the gradient.

The default orientation for a new gradient button is equivalent to the __horizontal__ argument for _dir_, as described below.

Parameters:

direction (str) – Indicates the direction of the gradient. Currently supports two values: * __vertical__: Gradient runs from top to bottom, high to low. * __horizontal__: Gradient runs from right to left, low to high.

override_clickaction(newaction=None)

Replace the default click action with one provided from elsewhere

Parameters:

newaction (function, optional) – The action to fire when the button is clicked; resets to the default action if the value is _None_. Defaults to _None_.

Returns:

_setfill(painter)

Set the fill style for the paint object. Overloaded ColorButton method.

Parameters:

painter (PyQt5.QtWidgets.QStylePainter) – The painter object drawing the button.

_clicked()

Default click action behavior.

Results in launching color picker and assigning the selected color to the ‘basecolor’ property.

class urclib.ui_qt.visualizer.qt_support.GradientSwatch(parent=None)

Bases: urclib.ui_qt.visualizer.qt_support._compat.QWidget

Widget for displaying a noninterative gradient as a swatch (preview).

Parameters:

parent (PyQt5.QtWidgets.QWidget,optional) – The parent widget object, if any.

property gradient

The gradient object used in the swatch

Type:

PyQt5.QtGui.QLinearGradient

paintEvent(pevent)

Qt event handler for paint events.

Parameters:

pevent (PyQt5.QtGui.QPaintEvent) – The triggering event object.

Returns:

setGradient(g)

Sets the gradient used by the swatch; accessor used for Qt single-slot system.

Parameters:

g (PyQt5.QtGui.QLinearGradient) – The gradient object used in swatch.

class urclib.ui_qt.visualizer.qt_support.GradientDialog(minVal, maxVal, anchors, modifyAlpha=False, alphaVal=1.0, parent=None)

Bases: urclib.ui_qt.visualizer.qt_support._compat.QDialog

Dialog for editing values that compose a color ramp/gradient.

alphaVal

Value in range [0,1] which represents the opacity of the gradient.

Type:

float

Parameters:
  • minVal (float) – The lower bound value of the range represented by the color gradient.

  • maxVal (float) – The upper bound value of the range represented by the color gradient.

  • anchors (list) – List of lists, each with weight and color. Represents the anchors defining the gradient.

  • modifyAlpha (bool,optional) – If True, enables options to modify the gradient’s alpha value. Defaults to False.

  • alphaVal (float,optional) – The alpha value to apply. Defaults to 1 (full opacity).

  • parent (PyQt5.QtWidgets.QWidget or None, optional) – Parent widget, or None if the dialog has no designated parent.

property alphaValue

The designated alpha value to apply to all colors in the gradient.

Type:

float

MIN_ANCHORS = 2
MAX_ANCHORS = 20
gradient()

PyQt5.QtWidgets.QLinearGradient: The gradient edited by the dialog.

gradientWithAlpha()

PyQt5.QtWidgets.QLinearGradient: The gradient edited by the dialog, with alpha.

_selectChanged(selected, deselected)

Update table when selected row changes.

Parameters:
  • selected (PyQt5.QtCore.QItemSelection) – The newly selected row(s).

  • deselected (PyQt5.QtCore.QItemSelection) – unused.

_anchorsChanged(index, first, last)

Called when anchors are either added or removed to the table.

Parameters:
  • index (PyQt5.QtCore.QModelIndex) – Unused.

  • first (int) – Unused.

  • last (int) – Unused.

_updateAlpha(val)

Refresh the alpha value being used.

Parameters:

val (int) – Value in the range of [0,100], representing percent of opacity.

urclib.ui_qt.visualizer.qt_support.vecToQColor(c)

Converts from glm.vec3 or glm.vec4 to QColor.

Parameters:

c (glm.vec3 or glm.vec4) – The color vector to convert.

Returns:

The Qt representation of the color.

Return type:

PyQt5.QtGui.QColor

urclib.ui_qt.visualizer.qt_support.QColorToVec(c)

Converts from QColor to glm.vec4.

Parameters:

c (PyQt5.QtGui.QColor) – The QColor object to convert.

Returns:

The color in a representation that OpenGL can understand.

Return type:

glm.vec4

urclib.ui_qt.visualizer.qt_support.GradRecToStops(gr)

Convert a GradientRecord to stops that QLinearGradient can understand.

Parameters:

gr (GradientRecord) – The gradient record to convert.

Returns:

tuple entries of the form (weight,PyQt5.QtGui.QColor) which can be fed to a

PyQt5.QWidgets.QLinearGradient object.

Return type:

list

urclib.ui_qt.visualizer.qt_support.StopsToGradRec(stps)

Convert a list of stops into a GradientRecord object.

Parameters:

stps (list) – tuple entries of the form (weight,PyQt5.QtGui.QColor), typically retrieved from a PyQt5.QWidgets.QLinearGradient object.

Returns:

The gradient stop representation.

Return type:

GradientRecord