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 delegateMinimumColumnWidth
- the minimum width that a column may be resized toMaximumColumnWidth
- the maximum width that a column may be resized toFixedColumnWidth
- 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 (seeSceneGraphColumn.setDataType()
andRegisterDataType()
), the values defined in theMinimumColumnWidth
,MaximumColumnWidth
, andFixedColumnWidth
variables on the respective class are used to initialize corresponding values on theSceneGraphColumn
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 theSceneGraphColumn
class, such asSceneGraphColumn.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 theSceneGraphView
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 theShaderItemDelegate
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
orNone
) – The parent widget to own the new instance. Passed verbatim to theQtWidgets.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, otherwiseFalse
.
- 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.
- 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
andQtCore.QEvent.KeyRelease
where the keys are(QtCore.Qt.Key_F2
,QtCore.Qt.Key_Enter
, orQtCore.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, otherwiseFalse
.- See
- getAttributeName()¶
- Return type
str
orNone
- 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
orNone
- 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
ofstr
- Parameters
editedItem (
LocationTreeWidgetItem
orNone
) – 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
orNone
- 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), otherwiseFalse
.
- 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, orFalse
if not.- See
- 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
orNone
) – The name of a scene graph attribute whose value to show in a column that uses the item delegate, orNone
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
ofstr
) – 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), orFalse
to use the item delegate in I{read-only mode}.
- setProperty(propertyName, propertyValue)¶
- Parameters
propertyName (
str
) – The name of the column property to set.propertyValue (
object
orNone
) – 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
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 currentSceneGraphView
widget configuration.treeWidget (
QtWidgets.QTreeWidget
) – The tree widget that uses the item delegate.parent (
QtWidgets.QWidget
orNone
) – The parent widget to own the new instance. Passed verbatim to the base class initializer.
- createEditor(parent, option, index)¶
- Return type
QtWidgets.QWidget
orNone
- 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 (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.
- isFilmlookEnabled()¶
- Return type
bool
- Returns
True
if color swatches painted by the item delegate are transformed according to the selected color space, otherwiseFalse
.
- 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
orNone
) – The parent widget to own the new instance. Passed verbatim to theQtWidgets.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 GafferNode
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:
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
orNone
) – The parent widget to own the new instance. Passed verbatim to theQtWidgets.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 GafferNode
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:
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, otherwiseFalse
.
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 currentSceneGraphView
widget configuration.treeWidget (
QtWidgets.QTreeWidget
) – The tree widget that uses the item delegate.parent (
QtWidgets.QWidget
orNone
) – The parent widget to own the new instance. Passed verbatim to the base class initializer.
- createEditor(parent, option, index)¶
- Return type
QtWidgets.QWidget
orNone
- 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 (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.
- 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 overridecreateEditor()
.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 returnsNone
,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
orNone
- Returns
The type of editor widget to create in the
createEditor()
function, orNone
in order forcreateEditor()
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 callingexecuteOnParameterSetCallback()
, 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 currentSceneGraphView
widget configuration.treeWidget (
QtWidgets.QTreeWidget
) – The tree widget that uses the item delegate.parent (
QtWidgets.QWidget
orNone
) – 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, otherwiseFalse
.
- clone(parent=None)¶
Creates a new instance of this item delegate, optionally assigning its parent.
- Return type
- Parameters
parent (
QtWidgets.QWidget
) – An optionalQWidget
to parent the new item delegate to. If this isNone
, 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
orNone
- Parameters
index (
QtCore.QModelIndex
) – The model index of the cell for which to create a context menu.selectedItems (
list
ofQtWidgets.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
orNone
- 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 (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.
- 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
orNone
) – The node which has been set, orNone
if no node has been set.parameterPolicy (L{BaseParameterPolicy<UI4.FormMaster. BaseParameterPolicy.BaseParameterPolicy>} or
None
) – The parameter policy which has been set, orNone
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 overridecreateEditor()
.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 returnsNone
,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
orNone
- Returns
The type of editor widget to create in the
createEditor()
function, orNone
in order forcreateEditor()
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
ofQtCore.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
ofNodegraphAPI.Node
orNone
and L{BaseParameterPolicy<UI4.FormMaster.BaseParameterPolicy. BaseParameterPolicy>} orNone
- 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 toTrue
increateEditor()
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
oftuple
ofNodegraphAPI.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 togetNodeAndParameterPolicy()
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.
- getStateColor(option, index)¶
- Return type
QtGui.QColor
orNone
- 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(self, QWidget, QAbstractItemModel, QModelIndex)¶
- 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
orNone
) – The node to set for the scene graph location with the given path.parameter (
NodegraphAPI.Parameter
orNone
) – 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 byindex
according to the styleoption
given.- Parameters
editor (
QtWidgets.QWidget
) – The editor whose geometry to update.option (
QtWidgets.QStyleOptionViewItem
) – The style option to take into account for updating the giveneditor
’s geometry.index (
QtCore.QModelIndex
) – The model index of the item to take into account for updating the giveneditor
’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 inlookFileAsset
that is assigned to this location, or an empty string if no material is selected from the Look File.parent (
QtWidgets.QWidget
orNone
) – The parent widget to use for the popup widget, orNone
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)¶
- OnParameterSetCallbackType = 'onSceneGraphViewShaderSelected'¶
- class ShaderFilterPopup(valuePolicy, parent=None)¶
Bases:
UI4.Widgets.FilterPopups.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:
UI4.Widgets.SceneGraphView.ItemDelegates.BaseItemDelegate.BaseItemDelegate
Class implementing an item delegate used by the
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>¶
- __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
orNone
) – The parent widget to use for the popup widget, orNone
to use the popup widget as a stand-alone widget.
- setMasterMaterialsRequestCallback(callback, locationPath)¶
- Deprecated
This function is deprecated. Please use setTemplateMaterialsRequestCallback() instead.
- 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.
- __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 currentSceneGraphView
widget configuration.treeWidget (
QtWidgets.QTreeWidget
) – The tree widget that uses the item delegate.parent (
QtWidgets.QWidget
orNone
) – The parent widget to own the new instance. Passed verbatim to the base class initializer.
- 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
orNone
- Parameters
index (
QtCore.QModelIndex
) – The model index of the cell for which to create a context menu.selectedItems (
list
ofQtWidgets.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
orNone
- 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.
- kTemplateMaterialKey = 'template materials'¶
- setLookFileMaterialCallback(lookFileMaterialAssignmentCallback)¶
Sets the callback used for assigning a Look File Material to a given package.
- Parameters
lookFileMaterialAssignmentCallback (
callable
orNone
) – The callback to be used for assigning a Look File Material to a package.- Raises
ValueError – If the given callback object is not callable.
- setMasterMaterialCallbacks(masterMaterialsRequestCallback, masterMaterialAssignmentCallback)¶
- Deprecated
This function is deprecated. Please use setTemplateMaterialCallbacks() instead.
- 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 theStateItemDelegateMixin
.- __init__(bridge, treeWidget, parent=None)¶
Initializes an instance of the class.
- Parameters
bridge (
Bridge
) – TheSceneGraphView
widget bridge to use for accessing information related to the currentSceneGraphView
widget configuration.treeWidget (
QtWidgets.QTreeWidget
) – The tree widget that uses the item delegate.parent (
QtWidgets.QWidget
orNone
) – The parent widget to own the new instance. Passed verbatim to theQtWidgets.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 ofgetItemState()
andmodifyItemState()
, 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
) – TheSceneGraphView
widget bridge to use for accessing information related to the currentSceneGraphView
widget configuration.treeWidget (
QtWidgets.QTreeWidget
) – The tree widget that uses the item delegate.parent (
QtWidgets.QWidget
orNone
) – The parent widget to own the new instance. Passed verbatim to theQtWidgets.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
orNone
) – The icon to use to represent the state.text (
str
orNone
) – 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, otherwiseFalse
.
- 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, otherwiseFalse
.
- 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, otherwiseFalse
.
- 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, andFalse
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 locationlocationPath (
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
orNone
) – The parent widget to own the new instance. Passed verbatim to theQtWidgets.QItemDelegate
initializer.workingSetName (
str
orNone
) – The name of the Working Set which this item delegate will operate on. (optional)
- calculateItemState(option, index)¶
Calculates the item state.
- Return type
- 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
orNone
- Parameters
index (
QtCore.QModelIndex
) – The model index of the cell for which to create a context menu.selectedItems (
list
ofQtWidgets.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
oftuple
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, otherwiseFalse
.
- 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
orNone
) – 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 theWorkingSet
to use.