Base Editor¶
Module containing the BaseEditor class.
-
class
PackageSuperToolAPI.BaseEditor.BaseEditor(parent, node)¶ Class implementing a widget for editing parameters of a PackageSuperToolAPI-based node.
Variables: AddPackageRegistry – Maps action IDs for “Add Package” actions to the package class for the package which should be added when the action is triggered. -
AddPackageRegistry= {}¶
-
PackageMenuActionsRegistry= {}¶
-
SEPARATOR= '----'¶
-
TAB_AREA_UPDATE_INTERVAL= 100¶
-
canSelectionBeExported()¶ Return type: boolReturns: Trueif the current selection can be exported, otherwiseFalse.
-
getAddPackageMenuActions()¶ Allows derived classes to add custom items to the Add menu in the context menu of the
SceneGraphViewwidget, specifying types of packages that can be added to the SuperTool. These menu items trigger actions configured ingetKeyboardShortcuts. Is called when the menu is shown.Return type: listoftupleof (str,str,bool)Returns: A list of tuples (one per action). Each tuple should contain: - The name of the action, as specified by the indices of the
dictreturned bygetKeyboardShortcuts. - A string containing the text to use for the menu item.
- A flag indicating whether the menu item is to be made available.
Note: The base class implementation returns an empty list. - The name of the action, as specified by the indices of the
-
getAttribute(locationPath, attributeName)¶ Return type: FnAttributeorNoneParameters: - locationPath (
str) – The location path for which we wish to fetch the attribute of the given name. - attributeName (
str) – The name of an attribute to fetch for the given location.
Returns: The requested attribute at the given location, or
Noneif no such attribute was found.- locationPath (
-
getChildrenUnder(parentPath)¶ Deprecated: This function will be removed. Please use getSceneGraphView().getSceneGraphChildren() instead.
-
classmethod
getDefaultSceneGraphViewTerminalOpUpdates(graphState)¶ Return type: tupleoftupleof (str,FnAttribute.GroupAttribute,str)Parameters: graphState ( NodegraphAPI.GraphState) – The graph state to be queried for the “system” Op arguments, for the Ops that need it.Returns: A tuple containing a description of a default chain of Ops whose arguments are to be updated, each in the form of a tuple of Op type name as a string, Op arguments as a FnAttribute.GroupAttributeand a key indicating which Op to update.Note: The base class implementation returns an empty list.
-
classmethod
getDefaultSceneGraphViewTerminalOps(graphState)¶ Return type: tupleoftupleof (str,FnAttribute.GroupAttribute) or (str,FnAttribute.GroupAttribute,str)Parameters: graphState ( NodegraphAPI.GraphState) – The graph state to be queried for the “system” Op arguments, for the Ops that make use of them.Returns: A tuple containing a description of a chain of default Ops, each in the form of a tuple of Op type name as a string and Op arguments as a FnAttribute.GroupAttribute. Any Ops which may need to be updated later with new arguments can be supplied with a string key to identify them.Note: The base class implementation returns an empty list.
-
classmethod
getKeyboardShortcuts()¶ To be implemented by subclasses. Returns a dictionary of keyboard shortcuts for actions in the SuperTool UI. The format of this dictionary is the same that is passed to
RegisterActions()inUI4.App.KeyboardShortcutManager. The keyboard shortcuts returned from this function will be added to the default shortcuts and registered. Is called at startup.The keyboard shortcut information returned in the dictionary should be tuples containing:
- A unique and immutable action hash, used by the keyboard shortcut manager to store the keyboard shortcut configuration.
- A string describing a key combination (e.g. ‘Shift-P’).
- A callback to be called when the used presses the specified key combination of the shortcut.
Return type: dictofstrtotupleof (str,str,callable)Returns: A dictionary of action names to keyboard shortcut information. Note: The base class implementation returns an empty dictionary.
-
classmethod
getLayoutOrientation()¶ Return type: intReturns: The layout orientation of the SuperTool editor’s layout: either LAYOUT_VERTICAL(the default) orLAYOUT_HORIZONTAL.Note: In vertical layout (the default), the tab area is positioned below the SceneGraphViewwidget. In horizontal layout, the tab area is positioned to the right of theSceneGraphViewwidget.
-
getMainNode()¶ Return type: BaseNode.BaseNodeReturns: The main node of this SuperTool.
-
getMainPanelWidget()¶ Return type: QtGui.QWidgetReturns: The main panel widget that contains the parameter tabs and the SceneGraphView widget for this SuperTool.
-
getMenuActions()¶ Allows derived classes to add custom items to the context menu of the
SceneGraphViewwidget of this SuperTool. These menu items trigger actions configured ingetKeyboardShortcuts. Is called when the menu is shown.Return type: listoftupleof (str,str,bool)Returns: A list of tuples (one per action). Each tuple should contain: - The name of the action, as specified by the indices of the
dictreturned bygetKeyboardShortcuts. - A string containing the text to use for the menu item.
- A flag indicating whether the menu item is to be made available.
Note: The base class implementation returns an empty list. - The name of the action, as specified by the indices of the
-
getPackageForPath(locationPath, includeEditPackages=True, createDummyOnMissing=False)¶ Return type: PackageorNoneParameters: - locationPath (
str) – A location path that might belong to a package. - includeEditPackages (
bool) – Flag that controls whether edit packages (those that subclassEditPackage) should be considered. - createDummyOnMissing (
bool) – Flag that controls whether a dummy/stub package should be created if the given locationPath doesn’t have a local package associated with it.
Returns: The package for the given location path, or
Noneif no such package could be found.- locationPath (
-
getSceneGraphView()¶ Return type: UI4.Widgets.SceneGraphViewReturns: The SceneGraphView widget for this SuperTool.
-
classmethod
getSceneGraphViewTerminalOpUpdates(graphState, rootLocations)¶ Allows derived classes to provide updates for terminal Ops that are used for the
SceneGraphViewwidget of this SuperTool.Return type: listoftupleof (str,FnAttribute.GroupAttribute,str)Parameters: - graphState (
NodegraphAPI.GraphState) – The graph state to be queried for the “system” Op arguments, for Ops that make use of them. - rootLocations (
tupleofstr) – The paths of scene graph locations that are used as roots in the SuperTool’sSceneGraphViewwidget.
Returns: A list with a description of a chain of Ops whose arguments are to be updated, each in the form of a tuple of Op type name as a string, Op arguments as a
FnAttribute.GroupAttributeand a key identifying the Op to update.Note: The base class implementation returns an empty list.
See: - graphState (
-
classmethod
getSceneGraphViewTerminalOps(graphState, rootLocations)¶ Undocumented.
-
getSelectedItems()¶ Return type: listofstrReturns: A list of locations selected in the SceneGraphView widget for this SuperTool.
-
getSelectedPackages(includeEditPackages=True, createDummyOnMissing=True)¶ Returns the currently selected packages in the SceneGraphView.
Return type: listoftupleParameters: - includeEditPackages (
bool) – Flag that controls whether edit packages (those that subclassEditPackage) should be considered. - createDummyOnMissing (
bool) – Flag that controls whether a dummy/stub package should be created if the given locationPath doesn’t have a local package associated with it.
Returns: The selected packages in the SceneGraphView widget, as a list of tuples of the form
(scene graph location path, package). IfpackageisNone, a package could not be found for the corresponding selected location. This can occur if a selected location is not managed by this SuperTool.- includeEditPackages (
-
classmethod
getSuperToolName()¶ Return type: strReturns: The name of the SuperTool. Is used in the registration of keyboard shortcut actions for the SuperTool’s UI, and for the separator above custom menu actions that are defined in getMenuActions.Raises: NotImplementedError – If not implemented in the subclass.
-
classmethod
getTabNames()¶ Return type: listofstrReturns: The names of the tabs in the SuperTool’s Parameters tab interface. Note: The base class implementation returns an empty list.
-
getTopLevelPackage(package)¶ Return type: PackageParameters: package ( Package) – The package for which the top-level package should be returned.Returns: The top-level package under which the given package exists.
-
hideEvent(event)¶ Overrides the standard
QWidgetevent handler for “hide” events.
-
onSelectionChanged()¶ Callback invoked when the selection of packages in the
SceneGraphViewwidget of the SuperTool has changed.A list of packages that are currently selected can be obtained by calling
self.getSelectedPackages().Following a call of this function, the tab area below the
SceneGraphViewwidget is updated for the first of the selected packages.Note: The base class implementation does nothing.
-
populateContextMenu(menu)¶ Populates the given context menu.
The default implementation adds the standard context menu items: package management items like Delete Package or Duplicate Package, the **Add** menu and the items defined by
getAddPackageMenuActionsandgetMenuActions. To include these standard items, the implementation of this function on the SuperTool’sEditorclass should call its implementation inBaseEditor.Parameters: menu ( QtGui.QMenu) – An instance of the (still empty) context menu to be populated with new items.
-
classmethod
registerAddPackageKeyboardShortcut(packageClass)¶ Registers a keyboard shortcut to add a package of the given class. This is called from the initializer
BaseEditor, to ensure that shortcuts are registered for any user package types which have been declared since startup.Parameters: packageClass ( type) – The class of the package for which to add an “add package” keyboard shortcut.
-
classmethod
registerKeyboardShortcuts()¶ Registers the core set of keyboard shortcuts for the Super Tool. This function is invoked once per Super Tool.
-
classmethod
registerPackageKeyboardShortcuts(packageClass)¶ Registers keyboard shortcuts declared by the given class. This is called from the initializer
BaseEditor, to ensure that shortcuts are registered for any user package types which have been declared since startup.Parameters: packageClass ( type) – The class of the package for which to add keyboard shortcuts.
-
setColumnToUpdateOnStateChange(columnName)¶ Adds the column of the given name in the SceneGraphView widget to a list of columns which will be updated when a state change takes place.
-
setupSceneGraphViewColumns()¶ Configures the
SceneGraphViewwidget that is part of the widgets that are shown for a SuperTool of this type that is edited in a **Parameters** tab.A column can be added using
self.getSceneGraphView().addColumn( '<column name>'). Columns have a data type which controls the appearance and possible editing of values in its cells. Columns are associated with attributes to display using thesetAttributeName()function on column objects returned fromaddColumn().The values in cells of a column can be made editable for the user by calling
setEditable(True)on a column object. Edits are fed back to parameters on nodes within the SuperTool. SeePackage.getOverrideNodeAndParameterto learn how package types specify which node parameters drive the editing of attributes that correspond to a column in aSceneGraphViewwidget.Raises: NotImplementedError – If the function has not been implemented by a subclass.
-
showEvent(event)¶ Overrides the standard
QWidgetevent handler for “show” events.
-
-
class
PackageSuperToolAPI.BaseEditor.GafferThreeInteractionDelegate¶ -
addToNodeSpecificShelfEnvironment(targetNode, editor, envDict)¶ Adds a variable named
selectedItemsto the node-specific shelf script environment for GafferThree nodes. This makes this value available for use in GafferThree shelf scripts.
-