Base Node¶
Module containing the BaseNode
class.
-
class
PackageSuperToolAPI.BaseNode.
BaseNode
(version=None)¶ Bases:
NodegraphAPI.SuperTool.SuperTool
Base class for a PackageSuperToolAPI-based node type. Should be extended by the respective SuperTool’s
Node
class.This is responsible for setting up all the standard network of nodes in these types of SuperTool.
-
VERSION
= 1¶
-
__init__
(version=None)¶ Initializes an instance of the class.
Derived classes should call this method in their initializer, as well as creating any nodes required by the respective SuperTool which do not belong to an individual package.
Parameters: version ( int
) – The version of the node, to be used by the upgrade system.
-
adoptLocationForEditing
(locationPath, locationAttributes=None)¶ Adopts the scene graph location with the given path for editing within the SuperTool node.
Parameters: - locationPath (
str
) – The path of the scene graph location to adopt. - locationAttributes (
FnAttribute.GroupAttribute
) – The attribute data at the given scene graph location. If not provided, it will be determined. Providing the attribute data is simply for performance.
Raises: ValueError – If no scene graph attributes could be found for the given location path.
- locationPath (
-
adoptLocationsForEditing
(locationPaths, locationAttributes=None)¶ Adopts the scene graph locations with the given paths for editing within the SuperTool.
Parameters: - locationPaths (
list
ofstr
) – The paths of the scene graph locations to adopt. - locationAttributes (
list
ofFnAttribute.GroupAttribute
) – An optional list providing attribute data for each location inlocationPaths
. If provided, the length of this list must match the length oflocationPaths
.
Raises: ValueError – If the given lists of location paths and location attributes are of different lengths.
- locationPaths (
-
canAdoptLocationForEditing
(location)¶ Returns a flag indicating whether or not the scene graph location with the given path can be adopted for editing by the SuperTool.
Return type: bool
Parameters: location ( str
) – The path of the scene graph location to query whether it can be adopted by the SuperTOol.Returns: True
if the scene graph location with the given path can be adopted for editing by the SuperTool, otherwiseFalse
.
-
canAdoptLocationsForEditing
(locations)¶ Return type: bool
Parameters: locations ( list
ofstr
) – The scene graph locations to query whether they can all be adopted by the SuperTool.Returns: True
if all of the given scene graph locations can be adopted for editing by the SuperTool, otherwiseFalse
.
-
getAPIVersion
()¶ Return type: int
Returns: The version of the API used to construct the SuperTool.
-
classmethod
getDefaultRootLocation
()¶ Abstract function that allows the subclasses to specify the default location under which the package locations will be created.
Return type: str
Returns: The default path of the scene graph location to use as the root of the scene graph hierarchy created by this SuperTool. Raises: NotImplementedError – If not implemented by a subclass.
-
classmethod
getItemListAttributeName
()¶ Allows subclasses to specify the name of the string attribute under ‘globals.itemLists’ in /root/world where the name of the SuperTool instances will be added as values. The default implementation returns
None
, which means that no entry will be added under ‘globals.itemLists’.Return type: str
orNone
Returns: The name of the string attribute under ‘globals.itemLists’ at /root/world where the names of instances of the SuperTool will be added, or None
to indicate that the SuperTool should not add to the global item list.
-
getLocationAttributes
(locationPath)¶ Return type: FnAttribute.GroupAttribute
orNone
Parameters: locationPath ( str
) – The path of the location for which to return attributes.Returns: The attributes at the location with the given path, or None
if no such location could be found.
-
getPackageForPath
(locationPath, raiseOnMissing=True, locationAttributes=None, includeEditPackages=True, createDummyOnMissing=False)¶ Return type: Package
orNone
Parameters: - locationPath (
str
) – The location to return a correspondingPackage
instance for. - raiseOnMissing (
bool
) – IfTrue
and noPackage
is found for the givenlocationPath
, aKeyError
will be thrown. IfFalse
and noPackage
is found,None
will be returned and no exception will be raised. - locationAttributes (
FnAttribute
orNone
) – Optionally provide the attributes at the location specified bylocationPath
. If this is not given (default) they will be queried from the scene graph. - includeEditPackages (
bool
) – Flag that controls whether edit packages (those that subclassEditPackage
) should be considered. - createDummyOnMissing (
bool
) – WhenTrue
, if no explicit local package is found at the given location, if the type of the location in the incoming scene is recognised as a valid ‘group’-like type, a dummy stand-in package will be created that represents the location.
Returns: The
Package
that corresponds to the given location path, orNone
if no such package was found andraiseOnMissing
isFalse
.Raises: KeyError – If no package was found for the given path, and
raiseOnMissing
isTrue
andcreateDummyOnMissing
isFalse
.- locationPath (
-
getRegisteredDisplayPackageClasses
()¶ Return type: list
ofPackage
Returns: A list of package classes that have been registered for the SuperTool and are inteded for display in a UI.
-
getRegisteredPackageClasses
()¶ Return type: list
oftuple
of(str, type)
Returns: A list of (name, class) tuples for the registered package classes for the SuperTool. The name
element is the name of the package class. To access the display name (if the package class supports it), query theDISPLAY_NAME
attribute (if it exists) on the class.
-
getRootLocation
()¶ Return type: str
Returns: The path of the root location of the SuperTool under which the package locations are created.
-
getRootPackage
()¶ Return type: Package
Returns: The root package for the SuperTool.
-
getShowIncomingScene
()¶ Return type: bool
Returns: True
if the incoming scene should be shown in the SceneGraphView widget for the SuperTool, otherwiseFalse
.
-
classmethod
getSuperToolName
()¶ Abstract function to be implemented by the subclass. Returns the name of the SuperTool. This name will be used, for example, in the registration of the keyboard shortcut actions.
Return type: str
Returns: The name of the SuperTool. Raises: NotImplementedError – If not implemented by a subclass.
-
getSyncSelection
()¶ Return type: int
Returns: The sync selection state for the SuperTool, which will be one of SYNC_SELECTION_OFF
,SYNC_SELECTION_OUT
orSYNC_SELECTION_IN_OUT
. This determines whether and how selection is kept in sync between the SuperTool and the Scene Graph tab.See: setSyncSelection
-
getVersion
()¶ Return type: int
Returns: The version of the SuperTool.
-
isLocationAdopted
(locationPath)¶ Return type: bool
Parameters: locationPath ( str
) – The path of the scene graph location to query whether it is adopted by the SuperTool.Returns: True
if the scene graph location with the given path has been adopted by the SuperTool, otherwiseFalse
.
-
setRootLocation
(locationPath)¶ Sets the path of the root location of the SuperTool, under which the package locations will be created.
Parameters: locationPath ( str
) – The path of the root location for the SuperTool.
-
setShowIncomingScene
(state)¶ Sets if the incoming scene should be shown in the SceneGraphView widget for the SuperTool.
Parameters: state ( bool
) – A flag indicating whether the incoming scene should be shown in the SceneGraphView widget.
-
setSyncSelection
(syncSelection)¶ Sets the sync selection state for the SuperTool. This determines whether and how selection is kept in sync between the SuperTool and the Scene Graph tab.
Parameters: syncSelection ( int
) – The sync selection state for the SuperTool. Should be one of:SYNC_SELECTION_OFF
,SYNC_SELECTION_OUT
orSYNC_SELECTION_IN_OUT
.See: getSyncSelection
-
setVersion
(version)¶ Sets the version of the SuperTool to the given version.
Parameters: version ( int
) – The version of the SuperTool.
-
classmethod
superToolRegistered
()¶ A method which can be implemented in derived classes to perform any actions required after registration of the SuperTool.
The default implementation does nothing.
-
upgrade
(rootPackage)¶ Upgrades the internal node network of the SuperTool node with the given root package to the latest version of that SuperTool.
Is called from the initializer of the
RootPackage
base class when a class derived fromRootPackage
is instantiated and the base class initializer is called.Can be re-implemented in derived classes by comparing the result of
getVersion
with the value of aVERSION
class variable, in order to determine whether an upgrade is necessary, and which changes to make.The default implementation iterates over packages and calls
Package.upgradeToVersion
for each intermediate version between the SuperTool’s saved version and the latest version of the SuperTool’s definition.Parameters: rootPackage ( RootPackage
) – The root package of the SuperTool node to upgrade.
-
-
PackageSuperToolAPI.BaseNode.
RegisterTagAdoptedNodeType
()¶ Registers the “_GafferTagAdopted” node type.