urclib.ui_qt.visualizer.qt_support.GradientDlg
Classes and utilities relevant to displaying and manipulating a dialog for editing a gradient color ramp.
Module Contents
Classes
Delegate for handling custom cell displays in anchor table. |
|
Model for use with the anchor editor table. |
|
Dialog for editing values that compose a color ramp/gradient. |
- class urclib.ui_qt.visualizer.qt_support.GradientDlg.AnchorTableDelegate(maxAnchors, parent=None)
Bases:
urclib.ui_qt.visualizer.qt_support._compat.QStyledItemDelegateDelegate for handling custom cell displays in anchor table.
- Parameters:
maxAnchors (int) – The maximum number of anchors to allow (minimum is always 2).
parent (PyQt5.QtWidgets.QWidget or None, optional) – The parent widget, if any.
- createEditor(parent, option, index)
- destroyEditor(editor, index)
This is an overloaded method of PyQt5.QtWidgets.QStyledItemDelegate. See official Qt Documentation.
- Parameters:
editor (PyQt5.QtWidgets.QWidget) – The widget created by invoking createEditor().
index (PyQt5.QtCore.QModelIndex) – Index of the table cell which requested the deletion of the editor.
See also
[Official Qt Documentation](https://doc.qt.io/qt-5/qabstractitemdelegate.html#destroyEditor)
- setEditorData(editor, index)
This is an overloaded method of PyQt5.QtWidgets.QStyledItemDelegate. See official Qt Documentation.
- Parameters:
editor (PyQt5.QtWidgets.QWidget) – The widget created by invoking createEditor().
index (PyQt5.QtCore.QModelIndex) – Index of the table cell which requested the deletion of the editor.
See also
[Official Qt Documentation](https://doc.qt.io/qt-5/qstyleditemdelegate.html#setEditorData)
- setModelData(editor, model, index)
This is an overloaded method of PyQt5.QtWidgets.QStyledItemDelegate. See official Qt Documentation.
- Parameters:
editor (PyQt5.QtWidgets.QWidget) – The widget created by invoking createEditor().
model (PyQt5.QtCore.QAbstractItemModel) – The model to assign the committed data to.
index (PyQt5.QtCore.QModelIndex) – Index of the table cell which requested the deletion of the editor.
See also
[Official Qt Documentation](https://doc.qt.io/qt-5/qstyleditemdelegate.html#setModelData)
- paint(painter, option, index)
This is an overloaded method of PyQt5.QtWidgets.QStyledItemDelegate. See official Qt Documentation.
- Parameters:
painter (PyQt5.QtGui.QPainter) – Painting object.
option (PyQt5.QtWidgets.QStyleOptionViewItem) – Style options for the painting process.
index (PyQt5.QtCore.QModelIndex) – Index of the table cell which requested the deletion of the editor.
See also
[Official Qt Documentation](https://doc.qt.io/qt-5/qabstractitemdelegate.html#paint)
- _handleAction(action)
Handle an action selected for a row in the table.
- Parameters:
action (str) – The text of the selected action
- _valChanged(val)
Emits a signal when a value has changed.
- _comboChanged(val)
Clears the focus of the widget which invoked this slot.
- class urclib.ui_qt.visualizer.qt_support.GradientDlg.AnchorTableModel(minVal, maxVal, anchors, parent=None)
Bases:
urclib.ui_qt.visualizer.qt_support._compat.QAbstractTableModelModel for use with the anchor editor table.
- alphaValue
The alpha (opacity) to apply to a gradient.
- Type:
float
- Parameters:
minVal (float) – The lower bound of the values to be represented by the gradient.
maxVal (float) – The upper bound of the values to be represented by the gradient.
anchors (list) – Lists of the form (weight, color) to represent anchor points for the gradient.
parent (PyQt5.QtWidget.QWidget or None, optional) – Parent widget, if any.
- property gradient
The gradient defined by the entries within this model.
- Type:
PyQt5.QtGui.QLinearGradient
- property gradientWithAlpha
The gradient defined by the entries within this model, with an alpha value included
- Type:
PyQt5.QtGui.QLinearGradient
- property anchors
lists of weights and colors representing the anchors which define the gradient.
- Type:
list
- gradientChanged
- COLS
- flags(index)
This is an overload of a PyQt5.QtCore.QAbstractTableModel. See the official documentation for details.
- Parameters:
index (PyQt5.QtCore.QModelIndex) – The index of the cell being queried.
- Returns:
The relevant bitflags as an integer.
- Return type:
int
See also
[Official Qt Documentation](https://doc.qt.io/qt-5/qabstracttablemodel.html#flags)
- headerData(section, orientation, role=Qt.DisplayRole)
This is an overload of a PyQt5.QtCore.QAbstractTableModel. See the official documentation for details.
- Parameters:
section (int) – The target section, either row or column depending on the specified orientation.
orientation (int) – Flag indicating direction; either Qt.Horizontal or Qt.Vertical
role (int,optional) – Constant indicating the role for which information is being requested.
- Returns:
The requested variant value.
- Return type:
PyQt5.QtCore.QVariant
See also
[Official Qt Documentation](https://doc.qt.io/qt-5/qabstractitemmodel.html#headerData)
- setData(index, value, role=Qt.DisplayRole)
This is an overload of a PyQt5.QtCore.QAbstractTableModel. See the official documentation for details.
- Parameters:
index (PyQt5.QtCore.QModelIndex) – The index of the cell being modified.
value (PyQt5.QtCore.QVariant) – The value being assigned.
role (int,optional) – Constant indicating the role for which information is being requested.
- Returns:
True if the value assignment was successful; False otherwise.
- Return type:
bool
See also
[Official Qt Documentation](https://doc.qt.io/qt-5/qabstractitemmodel.html#setData)
- data(index, role=Qt.DisplayRole)
This is an overload of a PyQt5.QtCore.QAbstractTableModel. See the official documentation for details.
- Parameters:
index (PyQt5.QtCore.QModelIndex) – The index of the cell being queried.
role (int,optional) – Constant indicating the role for which information is being requested.
- Returns:
The requested value wrapped in a QVariant object.
- Return type:
PyQt5.QtCore.QVariant
See also
[Official Qt Documentation](https://doc.qt.io/qt-5/qabstractitemmodel.html#data)
- columnCount(parent=QModelIndex())
This is an overload of a PyQt5.QtCore.QAbstractTableModel. See the official documentation for details.
- Parameters:
parent (PyQt5.QtCore.QModelIndex) – Unused
- Returns:
The total number of columns.
- Return type:
int
See also
[Official Qt Documentation](https://doc.qt.io/qt-5/qabstractitemmodel.html#columnCount)
- rowCount(parent=QModelIndex())
This is an overload of a PyQt5.QtCore.QAbstractTableModel. See the official documentation for details.
- Parameters:
parent (PyQt5.QtCore.QModelIndex) – Unused
- Returns:
The total number of rows present in the table.
- Return type:
int
See also
[Official Qt Documentation](https://doc.qt.io/qt-5/qabstractitemmodel.html#rowCount)
- _emitGradient()
Convenience method for emitting the model’s stored gradient as a signal.
- getValueRange(r)
Find the range of values covered by a given anchor.
- Parameters:
r (int) – Index of the anchor to query.
- Returns:
The lower and upper bounds of the range coverd by the anchor at index r.
- Return type:
tuple
- markRow(row=-1)
Designate the row to be marked by a triangle.
- Parameters:
row (int) – index of the row to select. A value outside of the range of [0,rowCount()) will deselect all rows.
- adjustAnchorCount(count)
Adjust the total number of anchors to display in the table.
- Parameters:
count (int) – The new count of anchors to display.
- insertRow(row, parent=QModelIndex())
This is an overload of a PyQt5.QtCore.QAbstractTableModel. See the official documentation for details.
- Parameters:
row (int) – The index before which to insert a new row.
parent (PyQt5.QtCore.QModelIndex) – Unused
See also
[Official Qt Documentation](https://doc.qt.io/qt-5/qabstractitemmodel.html#insertRow)
- removeRow(row, parent=QModelIndex())
This is an overload of a PyQt5.QtCore.QAbstractTableModel. See the official documentation for details.
- Parameters:
row (int) – The index of the row to remove.
parent (PyQt5.QtCore.QModelIndex) – Unused
See also
[Official Qt Documentation](https://doc.qt.io/qt-5/qabstractitemmodel.html#removeRow)
- swapColors(r1, r2)
Swap colors between two anchors.
- Parameters:
r1 (int) – Row of the first anchor in the color swap.
r2 (int) – Row of the second anchor in the color swap.
- _mixColors(c1, c2, wt=0.5)
Linearly mix two colors.
- Parameters:
c1 (PyQt5.QtGui.QColor) – The first color to include in mix.
c2 (PyQt5.QtGui.QColor) – The second color to include in mix.
wt (float,optional) – A value in the range of [0,1] indicating the relative contribution of each color. A value of 0 is just c1; a value of 1 is all c2. The default is 0.5 (equal contribution).
- Returns:
The new color that resulted from the mixing operation.
- Return type:
PyQt5.QtGui.QColor
- _mixWeights(w1, w2, wt=0.5)
Linearly mix two anchor weights.
- Parameters:
w1 (float) – The first weight to mix.
w2 (float) – The second weight to mix.
wt (float,optional) – A value in the range of [0,1] indicating the relative contribution of each weight. A value of 0 is just w1; a value of 1 is all w2. The default is 0.5 (equal contribution).
- Returns:
The new weight resulting from the mixing operation.
- Return type:
float
- _mixAnchors(a1, a2, wt=0.5)
Linearly mix two anchor entries.
- Parameters:
w1 (tuple) – The first weight and color to mix.
w2 (tuple) – The second weight and color to mix.
wt (float,optional) – A value in the range of [0,1] indicating the relative contribution of each anchor. A value of 0 is just a1; a value of 1 is all a2. The default is 0.5 (equal contribution).
- Returns:
The new weight and color resulting from the mixing operation between anchor entries.
- Return type:
list
- redistributeWeights()
Evenly redistribute weights across all entries.
- class urclib.ui_qt.visualizer.qt_support.GradientDlg.GradientDialog(minVal, maxVal, anchors, modifyAlpha=False, alphaVal=1.0, parent=None)
Bases:
urclib.ui_qt.visualizer.qt_support._compat.QDialogDialog 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.