Item Delegates

BaseItemDelegate

Module containing the BaseItemDelegate class.

class UI4.Widgets.SceneGraphView.ItemDelegates.BaseItemDelegate.BaseItemDelegate(bridge, treeWidget, parent=None)

Bases: QStyledItemDelegate

Base class for item delegate classes for use with SceneGraphView widgets.

Classes derived from this base class can define one or all of the following class variables, to control the size of columns that use an item delegate of the respective type:

  • DefaultColumnWidth - the initial width to use for a column that uses the item delegate

  • MinimumColumnWidth - the minimum width that a column may be resized to

  • MaximumColumnWidth - the maximum width that a column may be resized to

  • FixedColumnWidth - a fixed width to use for a column

When setting an item delegate of a class derived from this base class for a column in a SceneGraphView widget through the column’s data type (see SceneGraphColumn.setDataType() and RegisterDataType()), the values defined in the MinimumColumnWidth, MaximumColumnWidth, and FixedColumnWidth variables on the respective class are used to initialize corresponding values on the SceneGraphColumn instance that represents the column. This means that item delegate classes can provide defaults for those values, but values per column can be set as well, by using the setter functions for the individual values that are available in the SceneGraphColumn class, such as SceneGraphColumn.setMinimumWidth().

Note that columns that have a fixed width or an equal minimum and maximum width set for them cannot be resized.

Classes derived from this base class can define one or all of the following class variables to control other behaviour:

  • AffectsOtherItemDelegates - a boolean flag that controls whether a modification of data in the column the delegate is set for triggers an update of other item delegates in the SceneGraphView widget.

The AffectsOtherItemDelegates class variable is useful when other item delegates may depend on an item delegate of a particular type. It is used for the ShaderItemDelegate in order to update item delegates for shader parameters that may be shown for a light, like color, intensity, and exposure, when the shader selection for the light is changed.

Variables:

_valueComparisonEnabled – A flag that controls whether to check if the value of a parameter that corresponds to a cell in the column for which the item delegate instance is used matches the value of the corresponding attribute in the scene that is produced at the currently viewed node. Item delegate classes can evaluate the flag in initStyleOption() functions to determine whether to alter the appearance and editing behaviour of cells for which the values differ.

MaximumColumnWidth = 500
__init__(bridge, treeWidget, parent=None)

Initializes an instance of the class.

Parameters:
  • bridge (Bridge) – The SceneGraphView widget bridge to use for accessing information related to the current SceneGraphView widget configuration.

  • treeWidget (QtWidgets.QTreeWidget) – The tree widget that uses the item delegate.

  • parent (QtWidgets.QWidget or None) – The parent widget to own the new instance. Passed verbatim to the QtWidgets.QItemDelegate initializer.

editorEvent(event, model, option, index)

Event handler that is called when editing of an item starts.

Events related to automatic creation of editing widgets (i.e. that will result in createEditor() being called) will return True if the item is not editable.

Specifically, the following events are intercepted:

  • QtCore.QEvent.MouseButtonDblClick

  • QtCore.QEvent.KeyPress and QtCore.QEvent.KeyRelease where the keys are (QtCore.Qt.Key_F2, QtCore.Qt.Key_Enter, or QtCore.Qt.Key_Return

Most other events are passed to the base class QtWidgets.QStyledItemDelegate.editorEvent() for handling.

Return type:

bool

Parameters:
  • event (QtCore.QEvent) – The event that triggered the editing.

  • model (QtCore.QAbstractItemModel) – The model that contains the item to edit.

  • option (QtWidgets.QStyleOptionViewItem) – The style option used for rendering the item to edit.

  • index (QtCore.QModelIndex) – The model index of the item to edit.

Returns:

True if given editor event was handled, otherwise False.

See:

isEditable(), setEditable()

updateEditorGeometry(editor, option, index)

Updates the geometry of the given editor according to the given style option and model index.

Parameters:
  • editor (QtWidgets.QWidget) – The editor whose geometry to update.

  • option (QtWidgets.QStyleOptionViewItem) – Style option used to control how the editor widget appears.

  • index (QtCore.QModelIndex) – The model index of the item that the editor widget has been created for.

isValueComparisonEnabled()
Return type:

bool

Returns:

True if the value of a parameter that corresponds to a cell in the column for which the item delegate instance is used is to be compared to the value of the corresponding attribute in the scene that is produced at the currently viewed node, or False if not.

See:

setValueComparisonEnabled()

setValueComparisonEnabled(valueComparisonEnabled)

Sets the flag that controls whether the item delegate instance is to check if the value of a parameter that corresponds to a cell in the column for which the instance is used matches the value of the corresponding attribute in the scene that is produced at the currently viewed node. Item delegate classes can evaluate the flag in initStyleOption() functions to determine whether to alter the appearance and editing behaviour of cells for which the values differ.

Parameters:

valueComparisonEnabled (bool) – The flag value.

initStyleOption(option, index)

Initializes the given style option with the values of the item with the given model index.

Parameters:
  • option (QtWidgets.QStyleOptionViewItem) – The style option to fill with values of the item with the given model index.

  • index (QtCore.QModelIndex) – The model index of the item whose values to use for initializing the given style option.

classmethod isPropertyValid(propertyName)

Determines if the given property name is a valid, known property on the item delegate.

Return type:

bool

Parameters:

propertyName (str) – The name of the property to validate.

Returns:

True if the property is valid, False otherwise.

getProperty(propertyName)
Return type:

object or None

Parameters:

propertyName (str) – The name of the property to retrieve the value for.

Returns:

The property value associated with the given name, or None if the given name is not found.

setProperty(propertyName, propertyValue)
Parameters:
  • propertyName (str) – The name of the column property to set.

  • propertyValue (object or None) – The value to set for the column property.

canChangeSelection(index, event)

Callback for customizing selection behaviour in the tree widget that uses this item delegate. Is called from the tree widget’s selectionCommand() function when the selection state could potentially change in response to the given user input event, such as a mouse or keyboard event. Can be overridden to control when selection should change and when it should stay as it is.

Return type:

bool

Parameters:
  • index (QtCore.QModelIndex) – The model index of the item for which to determine whether selection state can change.

  • event (QtCore.QEvent) – A user input event, such as a mouse or keyboard event.

Returns:

True if the selection state can change, otherwise False.

getAttributeName()
Return type:

str or None

Returns:

The name of a scene graph attribute whose value to show in a column that uses the item delegate, or None if no attribute name has been set for this item delegate.

setAttributeName(attributeName, updateColumns=True)

Sets the name of a scene graph attribute whose values to show in a column that uses the item delegate.

Parameters:
  • attributeName (str or None) – The name of a scene graph attribute whose value to show in a column that uses the item delegate, or None to reset that attribute name.

  • updateColumns (bool) – A flag indicating whether columns which use this item delegate should have their attribute names updated.

getAttributeNames()
Return type:

list

Returns:

A list of names of scene graph attributes whose values to show in a column that uses the item delegate.

Note:

The item delegate will show the value of the first available attribute found on a particular scene graph location in a column cell.

setAttributeNames(*attributeNames, **kwargs)

Sets the names of scene graph attributes whose values to show in a column that uses the item delegate.

Specifying updateColumns=False as a keyword argument will prevent columns which use this item delegate from having their attribute names updated.

Parameters:

attributeNames (tuple of str) – A sequence of names of scene graph attributes whose values to show in a column that uses the item delegate.

Note:

The item delegate will show the value of the first available attribute found on a particular scene graph location in a column cell.

isEditable()
Return type:

bool

Returns:

True if items in the row or column for which the item delegate is used can potentially be edited (for example if corresponding parameters have been set for them), otherwise False.

setEditable(editable)

Sets the editable state of the item delegate to the given state.

Parameters:

editable (bool) – True if items in the row or column for which the item delegate is used can potentially be edited (for example if corresponding parameters have been set for them), or False to use the item delegate in I{read-only mode}.

getLocationPathsForEditing(editedItem)
Return type:

list of str

Parameters:

editedItem (LocationTreeWidgetItem or None) – The item in the tree widget from which the editing operation has been initiated.

Returns:

A list of paths of scene graph locations that are to be the target of an editing operation in the tree widget that this item delegate is used for, which may be the selected items, or an item for which a state item cell has been clicked.

getAttributesForLocationPath(locationPath)
Return type:

FnAttribute.GroupAttribute or None

Parameters:

locationPath (str) – The full path of the location whose attributes to return.

Returns:

The attributes of the given scene graph location, or None if no attributes are available for the given location.

customizeColumnTitleContextMenu(menu)

Base abstract method that can be implemented by sub-classes to customize the context menu of a list view column header.

Parameters:

menu (QtWidgets.QMenu) – The context menu to customize.

class UI4.Widgets.SceneGraphView.ItemDelegates.BaseItemDelegate.DummyItemDelegate(bridge, treeWidget, parent=None)

Bases: BaseItemDelegate

An item delegate for the “dummy” column added to the right-hand side of SceneGraphView widgets to ensure that the selection highlighting extends across the full width of the widget.

FixedColumnWidth = 0.1
initStyleOption(option, index)

Initializes the given style option with the values of the item with the given model index.

Parameters:
  • option (QtWidgets.QStyleOptionViewItem) – The style option to fill with values of the item with the given model index.

  • index (QtCore.QModelIndex) – The model index of the item whose values to use for initializing the given style option.

ColorItemDelegate

Module containing the ColorItemDelegate class.

class UI4.Widgets.SceneGraphView.ItemDelegates.ColorItemDelegate.ColorItemDelegate(bridge, treeWidget, parent=None)

Bases: ParameterItemDelegate

Class representing an item delegate for editing color component values.

ColorSwatchWidth = 50
Padding = 2
PaddingRight = 26
DefaultColumnWidth = 76
MaximumColumnWidth = 150
__init__(bridge, treeWidget, parent=None)

Initializes an instance of the class.

Parameters:
  • bridge (Bridge) – The SceneGraphView widget bridge to use for accessing information related to the current SceneGraphView widget configuration.

  • treeWidget (QtWidgets.QTreeWidget) – The tree widget that uses the item delegate.

  • parent (QtWidgets.QWidget or None) – The parent widget to own the new instance. Passed verbatim to the base class initializer.

isFilmlookEnabled()
Return type:

bool

Returns:

True if color swatches painted by the item delegate are transformed according to the selected color space, otherwise False.

setFilmlookEnabled(filmlookEnabled)

Sets a flag that controls whether color swatches painted by the item delegate are to be transformed according to the selected color space, and repaints the column that this item delegate is used for in the tree widget.

Parameters:

filmlookEnabled (bool) – Flag that controls whether color swatches painted by the item delegate are transformed according to the selected color space.

doesParameterValueMatchModelValue(parameterPolicy, index)

Determines whether the given parameter policy value matches the value current stored in the data model.

Return type:

bool

Parameters:
  • parameterPolicy (L{BaseParameterPolicy<UI4.FormMaster. BaseParameterPolicy.BaseParameterPolicy>}) – The ParameterPolicy object representing the parameter that is responsible for editing the given model index. This is guaranteed to not be None.

  • index (QtCore.QModelIndex) – The model index for the given cell to compare against the parameter policy.

Returns:

True if the parameter policy value and the value in the model at the given index match, False otherwise.

createEditor(parent, option, index)
Return type:

QtWidgets.QWidget or None

Parameters:
  • parent (QtWidgets.QWidget) – The parent widget to use for the editor widget.

  • option (QtWidgets.QStyleOptionViewItem) – Style option used to control how the editor widget appears.

  • index (QtCore.QModelIndex) – The model index of the item to create an editor widget for.

Returns:

The widget to use for editing the item specified by the given index, or None if editing the item with the given model index is not possible.

paint(painter, option, index)

Renders the delegate using the given painter and style option for the item specified by the given index.

Parameters:
  • painter (QtGui.QPainter) – The painter to use for drawing the item delegate.

  • option (QtWidgets.QStyleOptionViewItem) – An object describing the parameters used to draw an item in a view widget.

  • index (QtCore.QModelIndex) – The model index of the item to draw.

LightLinkItemDelegate

Module containing the LightLinkItemDelegate class.

class UI4.Widgets.SceneGraphView.ItemDelegates.LightLinkItemDelegate.LightLinkItemDelegate(bridge, treeWidget, parent=None)

Bases: ParameterItemDelegate

Class representing an item delegate for showing light linking.

DefaultColumnWidth = 100
MinimumColumnWidth = 60
MaximumColumnWidth = None
paint(painter, option, index)

Renders the delegate using the given painter and style option for the item specified by the given index.

Parameters:
  • painter (QtGui.QPainter) – The painter to use for drawing the item delegate.

  • option (QtWidgets.QStyleOptionViewItem) – An object describing the parameters used to draw an item in a view widget.

  • index (QtCore.QModelIndex) – The model index of the item to draw.

getContentWidth(option, index)
Return type:

int

Parameters:
  • option (QtWidgets.QStyleOptionViewItem) – A style option describing the parameters necessary for drawing a tree widget item.

  • index (QtCore.QModelIndex) – The model index of the item whose contents to measure.

Returns:

The width needed by the delegate to display the content of the item that corresponds to the given model index.

MuteAndSoloItemDelegates

Module containing the MuteItemDelegate and SoloItemDelegate classes.

class UI4.Widgets.SceneGraphView.ItemDelegates.MuteAndSoloItemDelegates.MuteItemDelegate(bridge, treeWidget, parent=None)

Bases: StateItemDelegateMixin, ParameterItemDelegate

Implementation of StateItemDelegate specific to ‘mute’ functionality.

FixedColumnWidth = 0
__init__(bridge, treeWidget, parent=None)

Initializes an instance of the class.

Parameters:
  • bridge (Bridge) – The SceneGraphView widget bridge to use for accessing information related to the current SceneGraphView widget configuration.

  • treeWidget (QtWidgets.QTreeWidget) – The tree widget that uses the item delegate.

  • parent (QtWidgets.QWidget or None) – The parent widget to own the new instance. Passed verbatim to the QtWidgets.QItemDelegate initializer.

initStyleOption(option, index)

Initializes the given style option with the values of the item with the given model index.

Parameters:
  • option (QtWidgets.QStyleOptionViewItem) – The style option to fill with values of the item with the given model index.

  • index (QtCore.QModelIndex) – The model index of the item whose values to use for initializing the given style option.

modifyItemState(item, index, event)

Modifies the state of the given item.

Return type:

bool

Parameters:
  • item (QtWidgets.QTreeWidgetItem) – The item whose state to modify.

  • index (QtCore.QModelIndex) – The model index that corresponds to the item whose state to modify.

  • event (QtGui.QMouseEvent) – The mouse event which caused the change in item state.

Returns:

True if the state was modified, False otherwise.

calculateItemState(option, index)

Calculates the item state based on mute being set and/or overridden.

Return type:

str

Parameters:
  • option (QStyleOptionViewItem) – The style option.

  • index (QtCore.QModelIndex) – The model index that corresponds to the item whose state to calculate.

Returns:

Item state based on mute being set and/or overridden.

setGafferNode(gafferNode)

Sets the Gaffer node that state changes should be targeted to.

Parameters:

gafferNode (Node) – The Gaffer Node to target state changes to.

toolTipEvent(index)

Event callback that’s raised when a user hovers their mouse cursor over a cell in a column that is managed by this item delegate.

Parameters:

index (QtCore.QModelIndex) – The model index for the cell that is being hovered over.

class UI4.Widgets.SceneGraphView.ItemDelegates.MuteAndSoloItemDelegates.SoloItemDelegate(bridge, treeWidget, parent=None)

Bases: StateItemDelegateMixin, ParameterItemDelegate

Implementation of StateItemDelegate specific to ‘solo’ functionality

FixedColumnWidth = 32
__init__(bridge, treeWidget, parent=None)

Initializes an instance of the class.

Parameters:
  • bridge (Bridge) – The SceneGraphView widget bridge to use for accessing information related to the current SceneGraphView widget configuration.

  • treeWidget (QtWidgets.QTreeWidget) – The tree widget that uses the item delegate.

  • parent (QtWidgets.QWidget or None) – The parent widget to own the new instance. Passed verbatim to the QtWidgets.QItemDelegate initializer.

initStyleOption(option, index)

Initializes the given style option with the values of the item with the given model index.

Parameters:
  • option (QtWidgets.QStyleOptionViewItem) – The style option to fill with values of the item with the given model index.

  • index (QtCore.QModelIndex) – The model index of the item whose values to use for initializing the given style option.

modifyItemState(item, index, event)

Modifies the state of the given item.

Return type:

bool

Parameters:
  • item (QtWidgets.QTreeWidgetItem) – The item whose state to modify.

  • index (QtCore.QModelIndex) – The model index that corresponds to the item whose state to modify.

  • event (QtGui.QMouseEvent) – The mouse event which caused the change in item state.

Returns:

True if the state was modified, False otherwise.

calculateItemState(option, index)

Calculates the item state based on solo being set and/or overridden.

Return type:

str

Parameters:
  • option (QStyleOptionViewItem) – The style option.

  • index (QtCore.QModelIndex) – The model index that corresponds to the item whose state to calculate.

Returns:

Item state based on solo being set and/or overridden.

setGafferNode(gafferNode)

Sets the Gaffer node that state changes should be targeted to.

Parameters:

gafferNode (Node) – The Gaffer Node to target state changes to.

toolTipEvent(index)

Event callback that’s raised when a user hovers their mouse cursor over a cell in a column that is managed by this item delegate.

Parameters:

index (QtCore.QModelIndex) – The model index for the cell that is being hovered over.

NameItemDelegate

Module containing NameItemDelegate class, implementing an item delegate for use as the base of the Name column’s ItemDelegate for Package-based SuperTools and tabs showing scene graph locations.

class UI4.Widgets.SceneGraphView.ItemDelegates.NameItemDelegate.NameItemDelegate(bridge, treeWidget, parent=None)

Bases: BaseItemDelegate

DefaultColumnWidth = 250
MaximumColumnWidth = None
PolishOpAttributeName = '__sceneGraphTab'
TopLevelLocation = '/root'
initStyleOption(option, index)

Initializes the given style option with the values of the item with the given model index.

Parameters:
  • option (QtWidgets.QStyleOptionViewItem) – The style option to fill with values of the item with the given model index.

  • index (QtCore.QModelIndex) – The model index of the item whose values to use for initializing the given style option.

shouldShowPinning()

Can be overridden in sub-classes to define whether pinning state is relevant to the context in which the widget is being used.

The default implementation returns False.

Return type:

bool

Returns:

True if the pinning icon decoration should be shown, otherwise False.

NumberItemDelegate

Module containing the NumberItemDelegate class.

class UI4.Widgets.SceneGraphView.ItemDelegates.NumberItemDelegate.NumberItemDelegate(bridge, treeWidget, parent=None)

Bases: ParameterItemDelegate

Class representing an item delegate for editing numeric values.

Precision = 2
DefaultColumnWidth = 50
__init__(bridge, treeWidget, parent=None)

Initializes an instance of the class.

Parameters:
  • bridge (Bridge) – The SceneGraphView widget bridge to use for accessing information related to the current SceneGraphView widget configuration.

  • treeWidget (QtWidgets.QTreeWidget) – The tree widget that uses the item delegate.

  • parent (QtWidgets.QWidget or None) – The parent widget to own the new instance. Passed verbatim to the base class initializer.

createEditor(parent, option, index)
Return type:

QtWidgets.QWidget or None

Parameters:
  • parent (QtWidgets.QWidget) – The parent widget to use for the editor widget.

  • option (QtWidgets.QStyleOptionViewItem) – Style option used to control how the editor widget appears.

  • index (QtCore.QModelIndex) – The model index of the cell in the tree widget for which to create an editor widget.

Returns:

The widget to use for editing the item specified by the given index, or None if editing the item with the given model index is not possible.

setEditorData(editor, index)

Sets the contents of the given editor to the data for the item at the given index. Note that the index contains information about the model being used.

Parameters:
  • editor (QtWidgets.QWidget) – The widget used to edit the item specified by the given index.

  • index (QtCore.QModelIndex) – The model index of the item to which the given editor widget belongs.

initStyleOption(option, index)

Initializes the given style option with the values of the item with the given model index.

Parameters:
  • option (QtWidgets.QStyleOptionViewItem) – The style option to fill with values of the item with the given model index.

  • index (QtCore.QModelIndex) – The model index of the item whose values to use for initializing the given style option.

doesParameterValueMatchModelValue(parameterPolicy, index)

Determines whether the given parameter policy value matches the value current stored in the data model.

Return type:

bool

Parameters:
  • parameterPolicy (L{BaseParameterPolicy<UI4.FormMaster. BaseParameterPolicy.BaseParameterPolicy>}) – The ParameterPolicy object representing the parameter that is responsible for editing the given model index. This is guaranteed to not be None.

  • index (QtCore.QModelIndex) – The model index for the given cell to compare against the parameter policy.

Returns:

True if the parameter policy value and the value in the model at the given index match, False otherwise.

getEditorClass()

Derived classes can implement this function to return a particular type of widget to create in createEditor(). This allows a derived class to specify the widget type to be used for editing without having to override createEditor().

The only argument passed when initializing the editor widget is the parent widget of the item delegate. If the getEditorClass() function is not overridden, or if it returns None, createEditor() calls the base class implementation to create a default editor widget depending on the type of display data shown in the cell.

Return type:

QtWidgets.QWidget or None

Returns:

The type of editor widget to create in the createEditor() function, or None in order for createEditor() to create a default type of widget based on the type of data stored in the model at a given model index.

editorClosed(editor, endEditHint)

Is called by a slot that is connected to the closeEditor() signal when the given editor widget of an item has been closed, meaning that editing has been finished, and the value is to be submitted or discarded. Allows derived classes to customize behavior depending on the data type of the respective item delegate.

Parameters:
  • editor (QtWidgets.QWidget) – The editor widget that was closed.

  • endEditHint (QtWidgets.QAbstractItemDelegate.EndEditHint) – Hint that provides a way for the delegate to influence how the model and view behave after editing is completed.

ParameterItemDelegate

Module containing the ParameterItemDelegate class.

class UI4.Widgets.SceneGraphView.ItemDelegates.ParameterItemDelegate.ParameterItemDelegate(bridge, treeWidget, parent=None)

Bases: BaseItemDelegate

Base class for item delegate classes that are aware of node graph parameters.

Variables:

_OnParameterSetCallbackID – The ID of an application callback which is registered for derived classes if they define a OnParameterSetCallbackType class variable giving the name of a callback type. This callback should be triggered by derived classes on parameter set, by calling executeOnParameterSetCallback(), passing the node or parameter policy which was set.

__init__(bridge, treeWidget, parent=None)

Initializes an instance of the class.

Parameters:
  • bridge (Bridge) – The SceneGraphView widget bridge to use for accessing information related to the current SceneGraphView widget configuration.

  • treeWidget (QtWidgets.QTreeWidget) – The tree widget that uses the item delegate.

  • parent (QtWidgets.QWidget or None) – The parent widget to own the new instance. Passed verbatim to the base class initializer.

clone(parent=None)

Creates a new instance of this item delegate, optionally assigning its parent.

Return type:

ParameterItemDelegate

Parameters:

parent (QtWidgets.QWidget) – An optional QWidget to parent the new item delegate to. If this is None, the parent of the original item delegate will be used as the new item delegate’s parent.

Returns:

The new ParameterItemDelegate instance.

showFinalValue()
Return type:

bool

setShowFinalValue(state)

Sets a flag that causes the item delegate to display the final attribute value rather than the parameter value.

Parameters:

state (bool) – True to show the final value, False to show the parameter value (default).

canChangeSelection(index, event)

Callback for customizing selection behaviour in the tree widget that uses this item delegate. Is called from the tree widget’s selectionCommand() function when the selection state could potentially change in response to the given user input event, such as a mouse or keyboard event. Can be overridden to control when selection should change and when it should stay as it is.

Return type:

bool

Parameters:
  • index (QtCore.QModelIndex) – The model index of the item for which to determine whether selection state can change.

  • event (QtCore.QEvent) – A user input event, such as a mouse or keyboard event.

Returns:

True if the selection state can change, otherwise False.

setNodeAndParameter(locationPath, node, parameter)

Sets the node and parameter on that node that is responsible for editing an attribute of the scene graph location with the given path to the given node and parameter, or resets that node and parameter for the scene graph location with the given path.

Parameters:
  • locationPath (str) – The path of the scene graph location to set the parameter for.

  • node (NodegraphAPI.Node or None) – The node to set for the scene graph location with the given path.

  • parameter (NodegraphAPI.Parameter or None) – The parameter to set for the scene graph location with the given path.

Raises:

ValueError – If the given parameter is not part of a node.

getNodeAndParameterPolicy(index, requestIfNotCached=False)
Return type:

tuple of NodegraphAPI.Node or None and L{BaseParameterPolicy<UI4.FormMaster.BaseParameterPolicy. BaseParameterPolicy>} or None

Parameters:
  • index (QtCore.QModelIndex) – The model index of the item for which to return a node and parameter policy.

  • requestIfNotCached (bool) – Flag to control whether to request a node for the scene graph location represented by the given model index. Can be set to True in createEditor() functions of derived classes in order to request a node when creating an editor for a parameter that does not exist on that node yet, such as a shader parameter on a Material node.

Returns:

A tuple of node and parameter policy that represents the parameter that is responsible for editing an attribute of the scene graph location represented by the given model index. May contain None values if no node or no parameter policy is available for the given model index.

getNodesAndParameterPoliciesForEditing(editedCellIndex, requestIfNotCached=False)
Return type:

list of tuple of NodegraphAPI.Node and L{BaseParameterPolicy<UI4.FormMaster.BaseParameterPolicy. BaseParameterPolicy>}

Parameters:
  • editedCellIndex (QtCore.QModelIndex) – The model index of the cell in the tree widget from which the editing operation has been initiated.

  • requestIfNotCached (bool) – Flag to control whether to request nodes for scene graph locations. Is passed to getNodeAndParameterPolicy() as-is.

Returns:

A list of tuples containing the nodes and parameter policies for locations that are to be the target of an editing operation.

getParameterPoliciesForEditing(editedCellIndex)
Return type:

list of L{BaseParameterPolicy<UI4.FormMaster. BaseParameterPolicy.BaseParameterPolicy>}

Parameters:

editedCellIndex (QtCore.QModelIndex) – The model index of the cell in the tree widget from which the editing operation has been initiated.

Returns:

A list of parameter policies for locations that are to be the target of an editing operation.

getModelIndexesForEditing(editedCellIndex)
Return type:

list of QtCore.QModelIndex

Parameters:

editedCellIndex (QtCore.QModelIndex) – The model index of the cell in the tree widget from which the editing operation has been initiated.

Returns:

A list of model indexes for locations that are to be the target of an editing operation.

getEditorClass()

Derived classes can implement this function to return a particular type of widget to create in createEditor(). This allows a derived class to specify the widget type to be used for editing without having to override createEditor().

The only argument passed when initializing the editor widget is the parent widget of the item delegate. If the getEditorClass() function is not overridden, or if it returns None, createEditor() calls the base class implementation to create a default editor widget depending on the type of display data shown in the cell.

Return type:

QtWidgets.QWidget or None

Returns:

The type of editor widget to create in the createEditor() function, or None in order for createEditor() to create a default type of widget based on the type of data stored in the model at a given model index.

editorClosed(editor, endEditHint)

Is called by a slot that is connected to the closeEditor() signal when the given editor widget of an item has been closed, meaning that editing has been finished, and the value is to be submitted or discarded. Allows derived classes to customize behavior depending on the data type of the respective item delegate.

The default implementation closes any pop-up widget, if one is currently displayed.

Parameters:
  • editor (QtWidgets.QWidget) – The editor widget that was closed.

  • endEditHint (QtWidgets.QAbstractItemDelegate.EndEditHint) – Hint that provides a way for the delegate to influence how the model and view behave after editing is completed.

getStateColor(option, index)
Return type:

QtGui.QColor or None

Parameters:
  • option (QtWidgets.QStyleOptionViewItem) – An object describing the parameters used to draw an item in a view widget.

  • index (QtCore.QModelIndex) – The model index of the item for which to return a state color.

Returns:

A color indicating the state of the value of the item with the given model index, or None if no such color is available.

createContextMenu(index, selectedItems)

Creates and returns a menu with commands related to the cell with the given model index, taking into account the given selected items.

Return type:

QtWidgets.QMenu or None

Parameters:
  • index (QtCore.QModelIndex) – The model index of the cell for which to create a context menu.

  • selectedItems (list of QtWidgets.QTreeWidgetItem) – A list of items that are currently selected in the tree widget that uses this item delegate.

Returns:

A menu with commands related to the cell with the given model index, taking into account the given selected items, or None if no such menu is provided by this item delegate.

executeOnParameterSetCallback(node=None, parameterPolicy=None)

Executes the ‘on parameter set’ callback, if one has been registered.

Parameters:
  • node (NodegraphAPI.Node or None) – The node which has been set, or None if no node has been set.

  • parameterPolicy (L{BaseParameterPolicy<UI4.FormMaster. BaseParameterPolicy.BaseParameterPolicy>} or None) – The parameter policy which has been set, or None if no parameter policy has been set.

doesParameterValueMatchModelValue(parameterPolicy, index)

Determines whether the given parameter policy value matches the value current stored in the data model.

Return type:

bool

Parameters:
  • parameterPolicy (L{BaseParameterPolicy<UI4.FormMaster. BaseParameterPolicy.BaseParameterPolicy>}) – The ParameterPolicy object representing the parameter that is responsible for editing the given model index. This is guaranteed to not be None.

  • index (QtCore.QModelIndex) – The model index for the given cell to compare against the parameter policy.

Returns:

True if the parameter policy value and the value in the model at the given index match, False otherwise.

toolTipEvent(index)

Event callback that’s raised when a user hovers their mouse cursor over a cell in a column that is managed by this item delegate.

Parameters:

index (QtCore.QModelIndex) – The model index for the cell that is being hovered over.

createEditor(parent, option, index)
Return type:

QtWidgets.QWidget or None

Parameters:
  • parent (QtWidgets.QWidget) – The parent widget to use for the editor widget.

  • option (QtWidgets.QStyleOptionViewItem) – Style option used to control how the editor widget appears.

  • index (QtCore.QModelIndex) – The model index of the item to create an editor widget for.

Returns:

The widget to use for editing the item specified by the given index, or None if editing the item with the given model index is not possible.

updateEditorGeometry(editor, option, index)

Updates the editor for the item specified by index according to the style option given.

Parameters:
  • editor (QtWidgets.QWidget) – The editor whose geometry to update.

  • option (QtWidgets.QStyleOptionViewItem) – The style option to take into account for updating the given editor’s geometry.

  • index (QtCore.QModelIndex) – The model index of the item to take into account for updating the given editor’s geometry.

initStyleOption(option, index)

Initializes the given style option with the values of the item with the given model index.

Parameters:
  • option (QtWidgets.QStyleOptionViewItem) – The style option to fill with values of the item with the given model index.

  • index (QtCore.QModelIndex) – The model index of the item whose values to use for initializing the given style option.

setModelData(self, QWidget, QAbstractItemModel, QModelIndex)

ShaderItemDelegate

Module containing the ShaderItemDelegate class.

class UI4.Widgets.SceneGraphView.ItemDelegates.ShaderItemDelegate.ShaderItemDelegate(bridge, treeWidget, parent=None)

Bases: ParameterItemDelegate

Class representing an item delegate for selecting a shader.

AffectsOtherItemDelegates = True
OnParameterSetCallbackType = 'onSceneGraphViewShaderSelected'
kTemplateMaterialKey = 'template materials'
class MaterialSelectionPopupFrame(valuePolicy, lookFileAsset, lookFileMaterialPath, parent=None)

Bases: QFrame

Class implementing a tabbed material selection popup widget. Provides a familiar classic Gaffer UI allowing users to select shaders, Template Materials, and materials from Look Files.

__init__(valuePolicy, lookFileAsset, lookFileMaterialPath, parent=None)

Initializes an instance of MaterialSelectionPopupFrame.

Parameters:
  • valuePolicy (ValuePolicy) – The value policy to work with, representing a shader parameter and providing information about the types of shaders to show in the popup.

  • lookFileAsset (str) – The asset ID of the Look File that is currently referenced by this location, or an empty string if no Look File is referenced.

  • lookFileMaterialPath (str) – The scene graph location path in lookFileAsset that is assigned to this location, or an empty string if no material is selected from the Look File.

  • parent (QtWidgets.QWidget or None) – The parent widget to use for the popup widget, or None to use the popup widget as a stand-alone widget.

setTemplateMaterialsRequestCallback(callback, locationPath)
setLookFileMaterialAssignmentCallback(callback, locationPath)
getShaderFilterPopup()
popup(globalPos)
setMasterMaterialsRequestCallback(callback, locationPath)
Deprecated:

This function is deprecated. Please use setTemplateMaterialsRequestCallback() instead.

class ShaderFilterPopup(valuePolicy, parent=None)

Bases: ShaderFilterPopup

Class implementing a shader filter popup widget used by the ShaderItemDelegate when editing the value of a cell in a column that uses the item delegate.

class ItemDelegate(bridge, treeWidget, parent=None)

Bases: BaseItemDelegate

Class implementing an item delegate used by the ShaderFilterPopup for painting tree widget items that represent Template Materials in a different style.

kTemplateMaterialColor = <PyQt5.QtGui.QColor object>
initStyleOption(option, index)

Initializes the given style option with the values of the item with the given model index.

Parameters:
  • option (QtWidgets.QStyleOptionViewItem) – The style option to fill with values of the item with the given model index.

  • index (QtCore.QModelIndex) – The model index of the item whose values to use for initializing the given style option.

__init__(valuePolicy, parent=None)

Initializes an instance of the class.

Parameters:
  • valuePolicy (ValuePolicy) – The value policy to work with, representing a shader parameter and providing information about the types of shaders to show in the popup.

  • parent (QtWidgets.QWidget or None) – The parent widget to use for the popup widget, or None to use the popup widget as a stand-alone widget.

setTemplateMaterialsRequestCallback(callback, locationPath)

Sets the callback to use for obtaining a list of paths of scene graph locations that represent Template Materials to the given callback.

Parameters:
  • callback (callable) – The callback to use for obtaining a list of paths of Template Material scene graph locations.

  • locationPath (str) – The path of a scene graph location to pass to the given callback when it is called.

Raises:

ValueError – If the given callback object is not callable.

setMasterMaterialsRequestCallback(callback, locationPath)
Deprecated:

This function is deprecated. Please use setTemplateMaterialsRequestCallback() instead.

__init__(bridge, treeWidget, parent=None)

Initializes an instance of the class.

Parameters:
  • bridge (Bridge) – The SceneGraphView widget bridge to use for accessing information related to the current SceneGraphView widget configuration.

  • treeWidget (QtWidgets.QTreeWidget) – The tree widget that uses the item delegate.

  • parent (QtWidgets.QWidget or None) – The parent widget to own the new instance. Passed verbatim to the base class initializer.

setTemplateMaterialCallbacks(templateMaterialsRequestCallback, templateMaterialAssignmentCallback)

Sets the callbacks to use for obtaining a list of paths of scene graph locations that represent Template Materials and for assigning a Template Material to a light to the given callbacks.

Parameters:
  • templateMaterialsRequestCallback (callable) – The callback to use for obtaining a list of paths of Template Material scene graph locations.

  • templateMaterialAssignmentCallback (callable) – The callback to use for assigning a Template Material to a light.

Raises:

ValueError – If one of the given callback objects is not callable.

setLookFileMaterialCallback(lookFileMaterialAssignmentCallback)

Sets the callback used for assigning a Look File Material to a given package.

Parameters:

lookFileMaterialAssignmentCallback (callable or None) – The callback to be used for assigning a Look File Material to a package.

Raises:

ValueError – If the given callback object is not callable.

createContextMenu(index, selectedItems)

Creates and returns a menu with commands related to the cell with the given model index, taking into account the given selected items.

Return type:

QtWidgets.QMenu or None

Parameters:
  • index (QtCore.QModelIndex) – The model index of the cell for which to create a context menu.

  • selectedItems (list of QtWidgets.QTreeWidgetItem) – A list of items that are currently selected in the tree widget that uses this item delegate.

Returns:

A menu with commands related to the cell with the given model index, taking into account the given selected items, or None if no such menu is provided by this item delegate.

createEditor(parent, option, index)
Return type:

QtWidgets.QWidget or None

Parameters:
  • parent (QtWidgets.QWidget) – The parent widget to use for the editor widget.

  • option (QtWidgets.QStyleOptionViewItem) – Style option used to control how the editor widget appears.

  • index (QtCore.QModelIndex) – The model index of the cell in the tree widget for which to create an editor widget.

Returns:

The widget to use for editing the item specified by the given index, or None if editing the item with the given model index is not possible.

initStyleOption(option, index)

Initializes the given style option with the values of the item with the given model index.

Parameters:
  • option (QtWidgets.QStyleOptionViewItem) – The style option to fill with values of the item with the given model index.

  • index (QtCore.QModelIndex) – The model index of the item whose values to use for initializing the given style option.

setMasterMaterialCallbacks(masterMaterialsRequestCallback, masterMaterialAssignmentCallback)
Deprecated:

This function is deprecated. Please use setTemplateMaterialCallbacks() instead.

StateItemDelegate

Module containing the StateItemDelegate class and the StateItemDelegateMixin .

class UI4.Widgets.SceneGraphView.ItemDelegates.StateItemDelegate.StateItemDelegate(bridge, treeWidget, parent=None)

Bases: StateItemDelegateMixin, BaseItemDelegate

Generic multi-state item delegate.

Inherits from BaseItemDelegate directly and provides the functionality of the StateItemDelegateMixin.

__init__(bridge, treeWidget, parent=None)

Initializes an instance of the class.

Parameters:
  • bridge (Bridge) – The SceneGraphView widget bridge to use for accessing information related to the current SceneGraphView widget configuration.

  • treeWidget (QtWidgets.QTreeWidget) – The tree widget that uses the item delegate.

  • parent (QtWidgets.QWidget or None) – The parent widget to own the new instance. Passed verbatim to the QtWidgets.QItemDelegate initializer.

initStyleOption(option, index)

Initializes the given style option with the values of the item with the given model index.

Parameters:
  • option (QtWidgets.QStyleOptionViewItem) – The style option to fill with values of the item with the given model index.

  • index (QtCore.QModelIndex) – The model index of the item whose values to use for initializing the given style option.

class UI4.Widgets.SceneGraphView.ItemDelegates.StateItemDelegate.StateItemDelegateMixin(bridge, treeWidget, parent=None)

Bases: object

Generic multi-state item delegate mix-in. This can be used with any class that inherits from BaseItemDelegate.

Derived classes should populate the active state list during their initializer (using addState()), and should also provide implementations of getItemState() and modifyItemState(), in order for the UI to update to the correct state, and allow the user to modify the state, respectively.

DefaultColumnWidth = 32
__init__(bridge, treeWidget, parent=None)

Initializes an instance of the class.

Parameters:
  • bridge (Bridge) – The SceneGraphView widget bridge to use for accessing information related to the current SceneGraphView widget configuration.

  • treeWidget (QtWidgets.QTreeWidget) – The tree widget that uses the item delegate.

  • parent (QtWidgets.QWidget or None) – The parent widget to own the new instance. Passed verbatim to the QtWidgets.QItemDelegate initializer.

editorEvent(event, itemModel, option, index)

Processes editor events.

Return type:

bool

Parameters:
  • event (QtCore.QEvent) – The editor event to process.

  • itemModel (QtCore.QAbstractItemModel) – The item model.

  • option (QtWidgets.QStyleOptionViewItem) – The style option.

  • index (QtCore.QModelIndex) – The model index.

Returns:

True if given editor event was handled, otherwise False.

initStyleOption(option, index)

Initializes the given style option with the values of the item with the given model index.

Parameters:
  • option (QtWidgets.QStyleOptionViewItem) – The style option to fill with values of the item with the given model index.

  • index (QtCore.QModelIndex) – The model index of the item whose values to use for initializing the given style option.

canChangeSelection(index, event)

Callback for customizing selection behaviour in the tree widget that uses this item delegate. Is called from the tree widget’s selectionCommand() function when the selection state could potentially change in response to the given user input event, such as a mouse or keyboard event. Can be overridden to control when selection should change and when it should stay as it is.

Return type:

bool

Parameters:
  • index (QtCore.QModelIndex) – The model index of the item for which to determine whether selection state can change.

  • event (QtCore.QEvent) – A user input event, such as a mouse or keyboard event.

Returns:

True if the selection state can change, otherwise False.

addState(name, icon=None, text=None)

Adds a state to the list of uniquely-named available states.

Parameters:
  • name (str) – The unique name of the state to add.

  • icon (QtGui.QIcon or None) – The icon to use to represent the state.

  • text (str or None) – The text to use to represent the state.

removeState(name)

Removes the given state from the list of available states. If the given state isn’t found in the list of available, a ValueError is raised.

Parameters:

name (str) – The name of the state to remove.

isValidState(name)
Return type:

bool

Parameters:

name (str) – The name of the state whose validity will be returned.

Returns:

True if the given state name has been registered in our list of states, otherwise False.

setItemState(state, locationPath)

Set the item state for a particular location path

Parameters:
  • state (str) – The state to apply to the location

  • locationPath (str) – The location to apply the state to

modifyItemState(item, index, event)

Modifies the state of the given item, corresponding to the given model index, according to the given mouse event. Subclasses should return True if they have successfully modified the state, and False if they haven’t.

Return type:

bool

Parameters:
  • item (QtWidgets.QTreeWidgetItem) – The item that was clicked.

  • index (QtCore.QModelIndex) – The model index.

  • event (QtGui.QMouseEvent) – The mouse event which caused the change in item state.

Returns:

True if the state was modified, False otherwise.

calculateItemState(option, index)
getItemStates()

WorkingSetItemDelegate

Module containing the WorkingSetItemDelegate class, implementing an item delegate used to represent the state of a Working Set within a SceneGraphView widget.

class UI4.Widgets.SceneGraphView.ItemDelegates.WorkingSetItemDelegate.WorkingSetItemDelegate(bridge, treeWidget, parent=None, workingSetName=None)

Bases: StateItemDelegate

Implementation of StateItemDelegate specific to Working Set functionality.

FixedColumnWidth = 32
WorkingSetName = 'workingSetName'
WorkingSetStateAttributeName = 'workingSets_state'
__init__(bridge, treeWidget, parent=None, workingSetName=None)

Initializes an instance of the class.

Parameters:
  • bridge (Bridge) – The SceneGraphView widget bridge to use for accessing information related to the current SceneGraphView widget configuration.

  • treeWidget (QtWidgets.QTreeWidget) – The tree widget that uses the item delegate.

  • parent (QtWidgets.QWidget or None) – The parent widget to own the new instance. Passed verbatim to the QtWidgets.QItemDelegate initializer.

  • workingSetName (str or None) – The name of the Working Set which this item delegate will operate on. (optional)

calculateItemState(option, index)

Calculates the item state.

Return type:

PyUtilModule.WorkingSet.WorkingSet.State or None

Parameters:
  • option (QStyleOptionViewItem) – The style option.

  • index (QtCore.QModelIndex) – The model index that corresponds to the item whose state to calculate.

Returns:

The state of the specified item.

modifyItemState(item, index, event)

Modifies the state of the given item, corresponding to the given model index, according to the given mouse event.

Return type:

bool

Parameters:
  • item (QtWidgets.QTreeWidgetItem) – The item that was clicked.

  • index (QtCore.QModelIndex) – The model index.

  • event (QtGui.QMouseEvent) – The mouse event which caused the change in item state.

Returns:

True if the state was modified, False otherwise.

customizeColumnTitleContextMenu(menu)

Allows the item delegate to customize the context menu of a list view column header.

Parameters:

menu (QtWidgets.QMenu) – The context menu to customize.

setWorkingSetName(workingSetName)

Sets the name of the Working Set to use. This registers callbacks to update terminal Ops when the contents of the Working Set change, and sets the attribute name on the item delegate to display the output of the WorkingSet.Polish Op.

Parameters:

workingSetName (str) – The registered name of the WorkingSet to use.

classmethod isPropertyValid(propertyName)

Determines whether the given property name is valid.

Return type:

bool

Parameters:

propertyName (str) – The name of the property to validate.

Returns:

True if the property is valid and known by the item delegate, otherwise False.

setProperty(propertyName, propertyValue)
Parameters:
  • propertyName (str) – The name of the column property to set.

  • propertyValue (object or None) – The value to set for the column property.

getTerminalOps()
Return type:

list of tuple of (str, FnAttribute.GroupAttribute, str) or (str, FnAttribute.GroupAttribute) or (str)

Returns:

A list of Ops, defined by Op type name, with optional Op args and terminal Op keys.

createContextMenu(index, selectedItems)

Creates and returns a menu with commands related to the cell with the given model index, taking into account the given selected items.

Return type:

QtWidgets.QMenu or None

Parameters:
  • index (QtCore.QModelIndex) – The model index of the cell for which to create a context menu.

  • selectedItems (list of QtWidgets.QTreeWidgetItem) – A list of items that are currently selected in the tree widget that uses this item delegate.

Returns:

A menu with commands related to the cell with the given model index, taking into account the given selected items, or None if no such menu is provided by this item delegate.