Item Delegates

BaseItemDelegate

Module containing the BaseItemDelegate class.

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

Bases: PyQt5.QtWidgets.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.
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.

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.
dataChanged
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

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.
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.
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.
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.
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.
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.
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.
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.
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
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.
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.
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 read-only mode.
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.
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.
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.
class UI4.Widgets.SceneGraphView.ItemDelegates.BaseItemDelegate.DummyItemDelegate(bridge, treeWidget, parent=None)

Bases: UI4.Widgets.SceneGraphView.ItemDelegates.BaseItemDelegate.BaseItemDelegate

An item delegate for the “dummy” column added to the right-hand side of C{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: UI4.Widgets.SceneGraphView.ItemDelegates.ParameterItemDelegate.ParameterItemDelegate

Class representing an item delegate for editing color component values.

ColorSwatchWidth = 50
DefaultColumnWidth = 76
MaximumColumnWidth = 150
Padding = 2
PaddingRight = 26
__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 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.

doesParameterValueMatchModelValue(parameterPolicy, index)

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

Return type:

bool

Parameters:
  • parameterPolicy (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.

isFilmlookEnabled()
Return type:bool
Returns:True if color swatches painted by the item delegate are transformed according to the selected color space, otherwise False.
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.
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.

LightLinkItemDelegate

Module containing the LightLinkItemDelegate class.

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

Bases: UI4.Widgets.SceneGraphView.ItemDelegates.ParameterItemDelegate.ParameterItemDelegate

Class representing an item delegate for showing light linking.

DefaultColumnWidth = 100
MaximumColumnWidth = None
MinimumColumnWidth = 60
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.

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.

MuteAndSoloItemDelegates

Module containing the MuteItemDelegate and SoloItemDelegate classes.

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

Bases: UI4.Widgets.SceneGraphView.ItemDelegates.StateItemDelegate.StateItemDelegateMixin, UI4.Widgets.SceneGraphView.ItemDelegates.ParameterItemDelegate.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.
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.

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.

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)
class UI4.Widgets.SceneGraphView.ItemDelegates.MuteAndSoloItemDelegates.SoloItemDelegate(bridge, treeWidget, parent=None)

Bases: UI4.Widgets.SceneGraphView.ItemDelegates.StateItemDelegate.StateItemDelegateMixin, UI4.Widgets.SceneGraphView.ItemDelegates.ParameterItemDelegate.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.
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.

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.

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)

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: UI4.Widgets.SceneGraphView.ItemDelegates.BaseItemDelegate.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: UI4.Widgets.SceneGraphView.ItemDelegates.ParameterItemDelegate.ParameterItemDelegate

Class representing an item delegate for editing numeric values.

DefaultColumnWidth = 50
Precision = 2
__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.

doesParameterValueMatchModelValue(parameterPolicy, index)

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

Return type:

bool

Parameters:
  • parameterPolicy (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.

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.
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.
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.
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.

ParameterItemDelegate

Module containing the ParameterItemDelegate class.

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

Bases: UI4.Widgets.SceneGraphView.ItemDelegates.BaseItemDelegate.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.
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.

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.
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 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.

doesParameterValueMatchModelValue(parameterPolicy, index)

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

Return type:

bool

Parameters:
  • parameterPolicy (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.

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.
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 (BaseParameterPolicy or None) – The parameter policy which has been set, or None if no parameter policy has been set.
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.
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.
getNodeAndParameterPolicy(index, requestIfNotCached=False)
Return type:

tuple of NodegraphAPI.Node or None and 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 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 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.
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.

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(editor, model, index)
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.

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).
showFinalValue()
Return type:bool
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.
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.

ShaderItemDelegate

Module containing the ShaderItemDelegate class.

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

Bases: UI4.Widgets.SceneGraphView.ItemDelegates.ParameterItemDelegate.ParameterItemDelegate

Class representing an item delegate for selecting a shader.

AffectsOtherItemDelegates = True
class MaterialSelectionPopupFrame(valuePolicy, lookFileAsset, lookFileMaterialPath, parent=None)

Bases: PyQt5.QtWidgets.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.
getShaderFilterPopup()
popup(globalPos)
setLookFileMaterialAssignmentCallback(callback, locationPath)
setMasterMaterialsRequestCallback(callback, locationPath)

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

setTemplateMaterialsRequestCallback(callback, locationPath)
ShaderItemDelegate.OnParameterSetCallbackType = 'onSceneGraphViewShaderSelected'
class ShaderItemDelegate.ShaderFilterPopup(valuePolicy, parent=None)

Bases: UI4.Widgets.FilterPopups.ShaderFilterPopup

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

class ItemDelegate(bridge, treeWidget, parent=None)

Bases: UI4.Widgets.SceneGraphView.ItemDelegates.BaseItemDelegate.BaseItemDelegate

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

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.
kTemplateMaterialColor = <PyQt5.QtGui.QColor object>
ShaderItemDelegate.ShaderFilterPopup.__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.
ShaderItemDelegate.ShaderFilterPopup.setMasterMaterialsRequestCallback(callback, locationPath)

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

ShaderItemDelegate.ShaderFilterPopup.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.

ShaderItemDelegate.__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.
ShaderItemDelegate.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.

ShaderItemDelegate.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.

ShaderItemDelegate.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.
ShaderItemDelegate.kTemplateMaterialKey = 'template materials'
ShaderItemDelegate.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.
ShaderItemDelegate.setMasterMaterialCallbacks(masterMaterialsRequestCallback, masterMaterialAssignmentCallback)

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

ShaderItemDelegate.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.

StateItemDelegate

Module containing the StateItemDelegate class and the StateItemDelegateMixin .

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

Bases: UI4.Widgets.SceneGraphView.ItemDelegates.StateItemDelegate.StateItemDelegateMixin, UI4.Widgets.SceneGraphView.ItemDelegates.BaseItemDelegate.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 mixin. This can be used with any class that inherits from BaseItemDelegate. Subclasses should populate the active state list during their constructor (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.
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.
calculateItemState(option, index)
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.

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.

getItemStates()
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.
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.
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.

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.
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

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: UI4.Widgets.SceneGraphView.ItemDelegates.StateItemDelegate.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.

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.

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.
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.
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.
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.

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.
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.