#include <MLockMessage.h>
Node and plug locking messages.
Plug locking was implemented with Maya 1.0. Individual plugs can be locked so that their values cannot be changed. The locking state is held within the plug. The plug's locked state can be changed via the API with the method MPlug::setLocked(bool), or, in MEL, using the command "setAttr -l {on,off}".
The ability to lock nodes was added with Maya 4.5. Node locking prevents renaming, reparenting, deletion, and other node-related changes. It also restricts the ability to change the state of any plug locks. The intent is that the user relies upon plug locking first, to lock the desired plugs they don't want to change, and then uses node locking to lock the node itself. Node locking can be set via MEL command, "lockNode", or via MFnDependencyNode::setLocked(bool)
MLockMessage class allows the API user to register callbacks that control how Maya handles locks. The registered callbacks are invoked whenever a query to the lock state is involved. Therefore, the callback would be called even if the node was not locked.
When a callback is invoked, the API user will be given a decision variable where they can place their decision. This decision variable is a boolean, and the boolean can take on the following values:
Caveats
You must use caution when using these routines. The flow of execution is interrupted when these callbacks are invoked. Therefore, you should make your decision in a timely maanner or a serious performance penalty will result. Also, you should NEVER try to alter the DG state while executing within callback. This includes quering/assigning a plug's value. You may, however, examine state information like the lock state of the plug/node.
Inheritance diagram for MLockMessage:Public Types | |
| enum | LockPlugEvent { kInvalidPlug = 0, kPlugLockAttr, kPlugUnlockAttr, kPlugAttrValChange, kPlugRemoveAttr, kPlugRenameAttr, kPlugConnect, kPlugDisconnect, kLastPlug } |
| Plug related locking events. More... | |
| enum | LockDAGEvent { kInvalidDAG = 0, kGroup, kUnGroup, kReparent, kChildReorder, kCreateNodeInstance, kCreateChildInstance, kCreateParentInstance, kLastDAG } |
| DAG related locking events. More... | |
| enum | LockEvent { kInvalid = 0, kRename, kDelete, kLockNode, kUnlockNode, kAddAttr, kRemoveAttr, kRenameAttr, kUnlockAttr, kLockAttr, kLast } |
| Miscellaneous lock event types. More... | |
| typedef void(* | MLockEventFunction )(MObject &node, MObject &aux, void *clientData, MLockMessage::LockEvent eventType, bool &decision) |
| Pointer to a dependency node lock event callback function. More... | |
| typedef void(* | MLockDagEventFunction )(MDagPath &dagPath, MDagPath &otherPath, void *clientData, MLockMessage::LockDAGEvent eventType, bool &decision) |
| Pointer to a DAG lock event callback function. More... | |
| typedef void(* | MLockPlugEventFunction )(MPlug &plug, MPlug &otherPlug, void *clientData, MLockMessage::LockPlugEvent eventType, bool &decision) |
| Pointer to a plug lock event callback function. More... | |
Static Public Member Functions | |
| static MCallbackId | setNodeLockQueryCallback (MObject &node, MLockMessage::MLockEventFunction func, void *clientData=NULL, MStatus *status=NULL) |
| This methods registers a callback that is invoked in any locking condition on node properties, e.g. More... | |
| static MCallbackId | setNodeLockDAGQueryCallback (MDagPath &path, MLockMessage::MLockDagEventFunction func, void *clientData=NULL, MStatus *status=NULL) |
| This methods registers a callback that is invoked in any situation involving a locking condition on DAG level changes. More... | |
| static MCallbackId | setPlugLockQueryCallback (MPlug &plug, MLockMessage::MLockPlugEventFunction func, void *clientData=NULL, MStatus *status=NULL) |
| This method registers a callback that is invoked in any locking condition on a plug, e.g. More... | |
| static MCallbackId | setPlugLockQueryCallback (MObject &node, MLockMessage::MLockPlugEventFunction func, void *clientData=NULL, MStatus *status=NULL) |
| This method registers a callback that is invoked in any locking condition on any plug of a given node, e.g. More... | |
| static const char * | className () |
| Returns the name of this class. More... | |
| typedef void(* MLockEventFunction)(MObject &node, MObject &aux, void *clientData, MLockMessage::LockEvent eventType, bool &decision) |
Pointer to a dependency node lock event callback function.
| [in,out] | node | Node for which the lock event occurred. |
| [in,out] | aux | Auxiliary data used by some events. E.g. the attribute about to be added. |
| [in] | clientData | Pointer to user-defined data supplied when the callback was registered. |
| [in] | eventType | Type of node lock event which occurred. |
| [out] | decision | Decision of the callback whether to allow (true) or disallow (false) the default action associated with the lock event. |
| typedef void(* MLockDagEventFunction)(MDagPath &dagPath, MDagPath &otherPath, void *clientData, MLockMessage::LockDAGEvent eventType, bool &decision) |
Pointer to a DAG lock event callback function.
| [in,out] | dagPath | Path to the DAG node for which the lock event occurred. |
| [in,out] | otherPath | Second DAG node used in some events. E.g. the new parent. |
| [in] | clientData | Pointer to user-defined data supplied when the callback was registered. |
| [in] | eventType | Type of DAG node lock event which occurred. |
| [out] | decision | Decision of the callback whether to allow (true) or disallow (false) the default action associated with the lock event. |
| typedef void(* MLockPlugEventFunction)(MPlug &plug, MPlug &otherPlug, void *clientData, MLockMessage::LockPlugEvent eventType, bool &decision) |
Pointer to a plug lock event callback function.
| [in,out] | plug | Plug for which the lock event occurred. |
| [in,out] | otherPlug | Second plug used in some events. E.g. during connect and disconnect events. |
| [in] | clientData | Pointer to user-defined data supplied when the callback was registered. |
| [in] | eventType | Type of plug lock event which occurred. |
| [out] | decision | Decision of the callback whether to allow (true) or disallow (false) the default action associated with the lock event. |
| enum LockPlugEvent |
Plug related locking events.
| enum LockDAGEvent |
DAG related locking events.
| enum LockEvent |
Miscellaneous lock event types.
|
static |
This methods registers a callback that is invoked in any locking condition on node properties, e.g.
name, lock status, etc. When called, the API user can make a decision on how to handle the given locking situation. The programmer can either accept the default action, or they can deny the default action. The decision is returned through a decision variable which is passed to the callback function.
The callback function takes the following parameters:
\li <b>node</b> - The node that triggered the callback. \li <b>aux</b> - Any auxiliary data that may be needed, e.g. the attribute about to be added. \li <b>clientData</b> - User defined data passed to the callback function. \li <b>eventType</b> - Description of the event. \li <b>decision</b> - The decision that is made by the registered callback. A value of true accepts the default behavior. A value of false denies the default action.
The meanings of the node and aux parameters for each eventType, and default actions associated with those event types, are as follows:
kRename
\li node - The node that the user is attempting to rename. \li aux - MObject::kNullObj \li default actions - If <b>node</b> is locked then the default action is to not allow the rename. Otherwise, if <b>node</b> is unlocked then <b>node</b> can be renamed.
kDelete
\li node - The node that the user is attempting to delete. \li aux - MObject::kNullObj \li default actions - If <b>node</b> is locked then the default action is to not allow the delete. If <b>node</b> is unlocked then the <b>node</b> can be deleted.
kLockNode
\li node - The node that the user is attempting to lock. \li aux - MObject::kNullObj \li default actions - If <b>node</b> is unlocked then the default action is to ALLOW the node to be locked. The callback is not invoked when the user tries to unlock an already unlocked node.
kUnlockNode
\li node - The node that the user is attempting to unlock. \li aux - MObject::kNullObj \li default actions - If <b>node</b> is locked then the default action is to ALLOW the unlock. The callback is not invoked when the user tries to unlock an already unlocked node.
kAddAttr
\li node - The node that is having an attribute added. \li aux - MObject of the attribute to be added. Note: the attribute does not belong to the node yet. You can only access the attribute information using MFnAttribute. \li default actions - If <b>node</b> is locked then the default action is to not allow to the addition of <b>aux</b>. If <b>node</b> is unlocked then <b>aux</b> can be added to the node.
kRemoveAttr
\li node - The node that is having an attribute removed. \li aux - The attribute to be removed. In certain situations the user is allowed to do a global delete, e.g. "deleteAttr -at AttrName [nodes]". In these cases the plug is not created until checks have been performed; so <b>aux</b> == MObject::kNullObj. \li default actions - If <b>node</b> is locked then the default action is to not allow the attribute removal. If <b>node</b> is unlocked then <b>aux</b> can be removed.
kRenameAttr
\li node - The node that is having an attribute renamed. \li aux - The attribute. \li default actions - If <b>node</b> is locked then the default action is to not allow the rename. If <b>node</b> is unlocked then <b>aux</b> can be renamed.
kUnlockAttr
\li node - The node that is having an attribute unlocked. \li aux - The attribute to be unlocked. \li default actions - If <b>node</b> is locked then the default action is to not allow the unlock. If <b>node</b> is unlocked then <b>aux</b> attribute can be unlocked.
kLockAttr
\li node - The node that is having an attribute locked. \li aux - The attribute to be locked. \li default actions - If <b>node</b> is locked then the default action is to not allow the locking of <b>aux</b>. If <b>node</b> is unlocked then <b>aux</b> can be locked.
| [in] | node | - The node to register the callback for. |
| [in] | func | - Pointer to the callback function. |
| [in] | clientData | - Client data that should be passed back to the callback. |
| [out] | ReturnStatus | - status code |
|
static |
This methods registers a callback that is invoked in any situation involving a locking condition on DAG level changes.
When called, the API user can make a decision on how to handle the given locking situation. The programmer can either accept the default action, or they can deny the default action. The decision is returned through a decision variable which is passed to the callback function.
The callback function takes the following parameters:
The meanings of the dagPath and otherPath parameters for each eventType, and default actions associated with those event types, are as follows:
kGroup
\li dagPath - Path of the node to be grouped. \li otherPath - Path of the group node. \li default actions - If <b>dagPath</b> is locked then the default action is to not allow the grouping. If <b>dagPath</b> is unlocked then <b>dagPath</b> can be grouped with <b>otherPath</b>.
kUnGroup
\li dagPath - Path of the node attempted to ungroup. \li otherPath - Path of the group node. \li default actions - If <b>dagPath</b> is locked then the default action is to not allow the ungrouping. If <b>dagPath</b> is unlocked then <b>dagPath</b> can be ungrouped from <b>otherPath</b>.
kReparent
\li dagPath - Path of the node which is being reparented. \li otherPath - Path of the new parent, if any. When reparenting to the world, otherPath will be invalid. \li default actions - If <b>dagPath</b> is locked then the default action is to not allow the reparenting. If <b>dagPath</b> is unlocked then <b>dagPath</b> can be parented to <b>otherPath</b>.
kChildReorder
\li dagPath - Path of the child node to be reordered. \li otherPath - Path of the parent node. \li default actions - If <b>dagPath</b> is locked then the default action is to not allow the reordering. If <b>dagPath</b> is unlocked then <b>dagPath</b> can be reordered on <b>otherPath</b>.
kCreateNodeInstance
\li dagPath - Path of the node which is being instanced. \li otherPath - Invalid Path. \li default actions - If <b>dagPath</b> is locked then the default action is to not allow the instance to be created. If <b>dagPath</b> is unlocked then <b>dagPath</b> can be instanced.
kCreateChildInstance
\li dagPath - Path of the node whose child is being instanced. \li otherPath - Path of the child node. \li default actions - If <b>dagPath</b> is locked then the default action is to not allow the instance to be created. If <b>dagPath</b> is unlocked then <b>dagPath</b> can be instanced.
| [in] | dagPath | The path to attach the callback. |
| [in] | func | - Pointer to the callback function. |
| [in] | clientData | Client data that should be passed back to the callback. |
| [out] | ReturnStatus | status code |
|
static |
This method registers a callback that is invoked in any locking condition on a plug, e.g.
plug unlock, plug lock, connections, etc. When the callback is invoked, the API programmer can make a decision on how to handle the given locking situation. The programmer can either accept the default action, or they can deny the default action. The decision is made through the decision variable described above.
The callback function takes the following parameters:
\li <b>plug</b> - The plug that triggered the callback. \li <b>otherPlug</b> - The other plug involved in the callback. This is only valid during connect and disconnect events. \li <b>clientData</b> - User defined data passed to the callback function. \li <b>eventType</b> - Description of the event. \li <b>decision</b> - The decision that is made by the registered callback. A value of true accepts the default behavior. A value of false denies the default action.
The meanings of the plug and otherPlug parameters for each eventType, and default actions associated with those event types, are as follows:
kPlugLockAttr
\li plug - The plug that the user is attempting to lock. \li otherPlug - NULL plug. \li default actions - If <b>plug</b> is unlocked then the default action is to allow the plug to be locked.
kPlugUnlockAttr
\li plug - The plug that the user is attempting to unlock. \li otherPlug - NULL plug. \li default actions - If <b>plug</b> is locked then the default action is to allow the plug to be unlocked.
kPlugAttrValChange
\li plug - The plug that the user is attempting to change. \li otherPlug - NULL plug. \li default actions - If <b>plug</b> is locked then the default action is to not allow <b>plug</b> to change. If <b>plug</b> is unlocked then <b>plug</b> can change.
kPlugRemoveAttr
\li plug - The plug that the user is attempting to remove. \li otherPlug - NULL plug. \li default actions - If <b>plug</b> is locked then the default action is to not allow removal. Otherwise, if <b>plug</b> is unlocked then <b>plug</b> can be removed.
kPlugRenameAttr
\li plug - The plug that the user is attempting to rename. \li otherPlug - NULL plug. \li default actions - If <b>plug</b> is locked then the default action is to not allow the rename. Otherwise, if <b>plug</b> is unlocked then <b>plug</b> can be renamed.
kPlugConnect
\li plug - The plug that is to be connected (incoming connection). \li otherPlug - The source plug of the connection being made. \li default actions - If <b>plug</b> is locked then the connection is DENIED. If <b>plug</b> is unlocked then <b>otherPlug</b> can be connected to <b>plug</b>.
kPlugDisconnect
\li plug - The plug that it is having an incoming connection broken. \li otherPlug - The source plug of the connection being made. \li default actions - If <b>plug</b> is locked then the default action is to DENY the connection from being broken. If <b>plug</b> is unlocked then <b>otherPlug</b> can be disconnected from <b>plug</b>.
| [in] | plug | - The plug to attach the callback. |
| [in] | func | - Pointer to the callback function. |
| [in] | clientData | - Client data that should be passed back to the callback. |
| [out] | ReturnStatus | - status code |
|
static |
This method registers a callback that is invoked in any locking condition on any plug of a given node, e.g.
plug unlock, plug lock, connections, etc. When the callback is invoked, the API programmer can make a decision on how to handle the given locking situation. The programmer can either accept the default action, or they can deny the default action. The decision is returned through a decision variable which is passed to the callback function.
The callback function takes the following parameters:
\li <b>plug</b> - The plug that triggered the callback. \li <b>otherPlug</b> - The other plug involved in the callback. This is only valid during connect and disconnect events. \li <b>clientData</b> - User defined data passed to the callback function. \li <b>eventType</b> - Description of the event. \li <b>decision</b> - The decision that is made by the registered callback. A value of true accepts the default behavior. A value of false denies the default action.
If a lock event occurs on a plug which has callbacks registered both on the plug itself, using the previous method, and on the entire node, using this method, then only the plug-specific callback will be called. This allows you to have both plug-specific and node-wide callbacks on a node while ensuring that the most specific callback is the one called.
The meanings of the plug and otherPlug parameters for each eventType, and the default actions associated with those event types, are described in the plug-specific version of the method, above.
| [in] | node | - The node to attach the callback. |
| [in] | func | - Pointer to the callback function. |
| [in] | clientData | - Client data that should be passed back to the callback. |
| [out] | ReturnStatus | - status code |
\li <b>MS::kFailure</b> - Error registering callback. This can occur when a global watcher is already attached to the node. \li <b>MS::kInsufficientMemory</b> - Not enough memory to register the callback. \li <b>MS::kInvalidParameter</b> - The given node is not a valid node to register the callback on. \li <b>MS::kSuccess</b> - Callback successfully added.
|
static |
Returns the name of this class.