MLockMessage Class Reference

#include <MLockMessage.h>

Class Description

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:

  • true - accept the default behavior. When the node/plug is locked the default behavior is to obey the lock. When the node/plug is unlocked the default behavior is to do the action/edit.
  • false - deny the default behavior. When the node/plug is locked the default behavior is to deny/override the lock; thus allowing the edit/action to occur. When the node/plug is unlocked the default behavior is make the node/plug locked - without physically setting the lock bit.

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...
 
- Public Types inherited from MMessage
enum  Action { kDefaultAction, kDoNotDoAction, kDoAction }
 Callback result action codes. More...
 
typedef void(* MBasicFunction) (void *clientData)
 Pointer to a basic callback function. More...
 
typedef void(* MElapsedTimeFunction) (float elapsedTime, float lastTime, void *clientData)
 Pointer to an elapsed time callback function. More...
 
typedef void(* MCheckFunction) (bool *retCode, void *clientData)
 Pointer to callback function which returns a true/false result. More...
 
typedef void(* MCheckFileFunction) (bool *retCode, MFileObject &file, void *clientData)
 Pointer to a callback function which takes a file object and returns a result. More...
 
typedef void(* MCheckPlugFunction) (bool *retCode, MPlug &plug, void *clientData)
 Pointer to a callback function which takes a plug and returns a result. More...
 
typedef void(* MComponentFunction) (MUintArray componentIds[], unsigned int count, void *clientData)
 Pointer to a callback function which takes an array of component ids. More...
 
typedef void(* MNodeFunction) (MObject &node, void *clientData)
 Pointer to a callback function which takes a dependency node. More...
 
typedef void(* MStringFunction) (const MString &str, void *clientData)
 Pointer to callback function which takes a string. More...
 
typedef void(* MTwoStringFunction) (const MString &str1, const MString &str2, void *clientData)
 Pointer to a callback function which takes two strings. More...
 
typedef void(* MThreeStringFunction) (const MString &str1, const MString &str2, const MString &str3, void *clientData)
 Pointer to a callback function which takes three strings. More...
 
typedef void(* MStringIntBoolIntFunction) (const MString &str, unsigned int index, bool flag, unsigned int type, void *clientData)
 Pointer to callback function which takes a string, an index, a flag and a type. More...
 
typedef void(* MStringIndexFunction) (const MString &, unsigned int index, void *clientData)
 Pointer to callback function which takes a string and index. More...
 
typedef void(* MNodeStringBoolFunction) (MObject &node, const MString &, bool, void *clientData)
 Pointer to a callback function which takes a node, a string and a boolean. More...
 
typedef void(* MStateFunction) (bool state, void *clientData)
 Pointer to a callback function which takes a boolean state. More...
 
typedef void(* MTimeFunction) (MTime &time, void *clientData)
 Pointer to callback function which takes a time. More...
 
typedef void(* MPlugFunction) (MPlug &srcPlug, MPlug &destPlug, bool made, void *clientData)
 Pointer to plug connection callback function. More...
 
typedef void(* MNodePlugFunction) (MObject &node, MPlug &plug, void *clientData)
 Pointer to a callback function which takes a dependency node and a plug. More...
 
typedef void(* MNodeStringFunction) (MObject &node, const MString &str, void *clientData)
 Pointer to a callback function which takes a dependency node and a string. More...
 
typedef void(* MParentChildFunction) (MDagPath &child, MDagPath &parent, void *clientData)
 Pointer to to a callback function which takes two DAG nodes in a parent/child relationship. More...
 
typedef void(* MModifierFunction) (MDGModifier &modifier, void *clientData)
 Pointer to a callback function which takes a DG modifier. More...
 
typedef void(* MStringArrayFunction) (const MStringArray &strs, void *clientData)
 Pointer to a callback function which takes a string array. More...
 
typedef void(* MNodeModifierFunction) (MObject &node, MDGModifier &modifier, void *clientData)
 Pointer to a callback function which takes a dependency node and a DG modifier. More...
 
typedef void(* MObjArray) (MObjectArray &objects, void *clientData)
 Pointer to a callback function which takes an array of objects. More...
 
typedef void(* MNodeObjArray) (MObject &node, MObjectArray &objects, void *clientData)
 Pointer to a callback function which takes a dependency node and an array of objects. More...
 
typedef void(* MStringNode) (const MString &str, MObject &node, void *clientData)
 Pointer to a callback function which takes a string and a dependency node. More...
 
typedef void(* MCameraLayerFunction) (MObject &cameraSetNode, unsigned int multiIndex, bool added, void *clientData)
 Pointer to a callback function which takes a dependency node, an unsigned integer, and a boolean value. More...
 
typedef void(* MCameraLayerCameraFunction) (MObject &cameraSetNode, unsigned int multiIndex, MObject &oldCamera, MObject &newCamera, void *clientData)
 Pointer to a callback function which takes a dependency node, an unsigned integer, and two camera transform nodes. More...
 
typedef void(* MConnFailFunction) (MPlug &srcPlug, MPlug &destPlug, const MString &srcPlugName, const MString &dstPlugName, void *clientData)
 Pointer to connection-failed callback function. More...
 
typedef void(* MPlugsDGModFunction) (MPlugArray &plugs, MDGModifier &modifier, void *clientData)
 Pointer to a callback function which takes an array of MPlugs and an MDGModifier. More...
 
typedef void(* MNodeUuidFunction) (MObject &node, const MUuid &uuid, void *clientData)
 Pointer to a callback function which takes a dependency node and a UUID. More...
 
typedef Action(* MCheckNodeUuidFunction) (bool doAction, MObject &node, MUuid &uuid, void *clientData)
 Pointer to a callback function which takes a dependency node and a UUID, and returns a result. More...
 
typedef void(* MObjectFileFunction) (const MObject &object, const MFileObject &file, void *clientData)
 Pointer to a callback function which takes an object and a file object. More...
 
typedef void(* MCheckObjectFileFunction) (bool *retCode, const MObject &referenceNode, MFileObject &file, void *clientData)
 Pointer to a callback function which takes an object and a file object and returns a result. More...
 
typedef void(* MRenderTileFunction) (int originX, int originY, int tileMaxX, int tileMaxY, const void *tileData)
 Pointer to a callback function which receives origin, size and image data. 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...
 
- Static Public Member Functions inherited from MMessage
static MStatus removeCallback (MCallbackId id)
 Remove the specified callback from maya. More...
 
static MStatus removeCallbacks (MCallbackIdArray &ids)
 Remove all of the specified callbacks from maya. More...
 
static MCallbackId currentCallbackId (MStatus *ReturnStatus=NULL)
 Return the callback ID of the currently executing callback. More...
 
static MStatus nodeCallbacks (MObject &node, MCallbackIdArray &ids)
 Returns a list of callback IDs associated registered to a given node. More...
 
static void setRegisteringCallableScript ()
 Mark this MMessage object as one that will be passed callbacks defined in script.
 
static bool registeringCallableScript ()
 Return true if this MMessage object has its callbacks defined in script.
 
static const char * className ()
 Returns the name of this class. More...
 
static MStatus removeCallbacks (MIntArray &ids)
 This method is obsolete. This method is not available in Python. More...
 
static MStatus nodeCallbacks (MObject &node, MIntArray &ids)
 This method is obsolete. More...
 

Member Typedef Documentation

typedef void(* MLockEventFunction) (MObject &node, MObject &aux, void *clientData, MLockMessage::LockEvent eventType, bool &decision)

Pointer to a dependency node lock event callback function.

Parameters
[in,out]nodeNode for which the lock event occurred.
[in,out]auxAuxiliary data used by some events. E.g. the attribute about to be added.
[in]clientDataPointer to user-defined data supplied when the callback was registered.
[in]eventTypeType of node lock event which occurred.
[out]decisionDecision 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.

Parameters
[in,out]dagPathPath to the DAG node for which the lock event occurred.
[in,out]otherPathSecond DAG node used in some events. E.g. the new parent.
[in]clientDataPointer to user-defined data supplied when the callback was registered.
[in]eventTypeType of DAG node lock event which occurred.
[out]decisionDecision 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.

Parameters
[in,out]plugPlug for which the lock event occurred.
[in,out]otherPlugSecond plug used in some events. E.g. during connect and disconnect events.
[in]clientDataPointer to user-defined data supplied when the callback was registered.
[in]eventTypeType of plug lock event which occurred.
[out]decisionDecision of the callback whether to allow (true) or disallow (false) the default action associated with the lock event.

Member Enumeration Documentation

Plug related locking events.

Enumerator
kInvalidPlug 

An invalid plug event received.

kPlugLockAttr 

User is trying to lock the plug.

kPlugUnlockAttr 

User is trying to unlock the plug.

kPlugAttrValChange 

Plug lock query on plug value change.

kPlugRemoveAttr 

Plug lock query on a remove attribute event.

kPlugRenameAttr 

Plug lock query on a rename attribute event.

kPlugConnect 

Plug lock query on a connect to a locked attribute.

kPlugDisconnect 

Plug lock query on a disconnect from a locked source attribute.

kLastPlug 

Used for internal bounds checking.

DAG related locking events.

Enumerator
kInvalidDAG 

Invalid DAG event received.

kGroup 

Lock query on group action.

kUnGroup 

Lock query on ungroup action.

kReparent 

Lock query on reparent action.

kChildReorder 

Lock query on a child add action.

kCreateNodeInstance 

Lock query on an instance event.

kCreateChildInstance 

Lock query on node whose children will be instanced.

kCreateParentInstance 

Lock query on node whose parent will be instanced.

kLastDAG 

Used for internal bounds checking.

enum LockEvent

Miscellaneous lock event types.

Enumerator
kInvalid 

Invalid node lock event received.

kRename 

Lock query on a rename event.

kDelete 

Lock query on a delete event.

kLockNode 

Lock query on a lock event.

kUnlockNode 

Lock query on an unlock event.

kAddAttr 

Lock query on an add attribute event.

kRemoveAttr 

Lock query on an remove attribute event.

kRenameAttr 

Lock query on an rename attribute event.

kUnlockAttr 

Lock query on an unlock attribute event.

kLockAttr 

Lock query on a lock attribute event.

kLast 

Used for internal bounds checking.

Member Function Documentation

MCallbackId setNodeLockQueryCallback ( MObject node,
MLockMessage::MLockEventFunction  func,
void *  clientData = NULL,
MStatus ReturnStatus = NULL 
)
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:

  • node - The node that triggered the callback.
  • aux - Any auxiliary data that may be needed, e.g. the attribute about to be added.
  • clientData - User defined data passed to the callback function.
  • eventType - Description of the event.
  • decision - 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

  • node - The node that the user is attempting to rename.
  • aux - MObject::kNullObj
  • default actions - If node is locked then the default action is to not allow the rename. Otherwise, if node is unlocked then node can be renamed.

kDelete

  • node - The node that the user is attempting to delete.
  • aux - MObject::kNullObj
  • default actions - If node is locked then the default action is to not allow the delete. If node is unlocked then the node can be deleted.

kLockNode

  • node - The node that the user is attempting to lock.
  • aux - MObject::kNullObj
  • default actions - If node 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

  • node - The node that the user is attempting to unlock.
  • aux - MObject::kNullObj
  • default actions - If node 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

  • node - The node that is having an attribute added.
  • 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.
  • default actions - If node is locked then the default action is to not allow to the addition of aux. If node is unlocked then aux can be added to the node.

kRemoveAttr

  • node - The node that is having an attribute removed.
  • 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 aux == MObject::kNullObj.
  • default actions - If node is locked then the default action is to not allow the attribute removal. If node is unlocked then aux can be removed.

kRenameAttr

  • node - The node that is having an attribute renamed.
  • aux - The attribute.
  • default actions - If node is locked then the default action is to not allow the rename. If node is unlocked then aux can be renamed.

kUnlockAttr

  • node - The node that is having an attribute unlocked.
  • aux - The attribute to be unlocked.
  • default actions - If node is locked then the default action is to not allow the unlock. If node is unlocked then aux attribute can be unlocked.

kLockAttr

  • node - The node that is having an attribute locked.
  • aux - The attribute to be locked.
  • default actions - If node is locked then the default action is to not allow the locking of aux. If node is unlocked then aux can be locked.
Parameters
[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
Returns
A unique id for the callback.
Status Codes:
MCallbackId setNodeLockDAGQueryCallback ( MDagPath dagPath,
MLockMessage::MLockDagEventFunction  func,
void *  clientData = NULL,
MStatus ReturnStatus = NULL 
)
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:

  • dagPath - The DAG path that the event occurred on.
  • otherPath - The other path involved, e.g. the new parent.
  • clientData - User defined data passed to the callback function.
  • eventType - Description of the event.
  • decision - The decision that is made by the registered callback. A value of true accepts the default behavior. A value of false rejects the default action.

The meanings of the dagPath and otherPath parameters for each eventType, and default actions associated with those event types, are as follows:

kGroup

  • dagPath - Path of the node to be grouped.
  • otherPath - Path of the group node.
  • default actions - If dagPath is locked then the default action is to not allow the grouping. If dagPath is unlocked then dagPath can be grouped with otherPath.

kUnGroup

  • dagPath - Path of the node attempted to ungroup.
  • otherPath - Path of the group node.
  • default actions - If dagPath is locked then the default action is to not allow the ungrouping. If dagPath is unlocked then dagPath can be ungrouped from otherPath.

kReparent

  • dagPath - Path of the node which is being reparented.
  • otherPath - Path of the new parent, if any. When reparenting to the world, otherPath will be invalid.
  • default actions - If dagPath is locked then the default action is to not allow the reparenting. If dagPath is unlocked then dagPath can be parented to otherPath.

kChildReorder

  • dagPath - Path of the child node to be reordered.
  • otherPath - Path of the parent node.
  • default actions - If dagPath is locked then the default action is to not allow the reordering. If dagPath is unlocked then dagPath can be reordered on otherPath.

kCreateNodeInstance

  • dagPath - Path of the node which is being instanced.
  • otherPath - Invalid Path.
  • default actions - If dagPath is locked then the default action is to not allow the instance to be created. If dagPath is unlocked then dagPath can be instanced.

kCreateChildInstance

  • dagPath - Path of the node whose child is being instanced.
  • otherPath - Path of the child node.
  • default actions - If dagPath is locked then the default action is to not allow the instance to be created. If dagPath is unlocked then dagPath can be instanced.
Parameters
[in]dagPathThe path to attach the callback.
[in]func- Pointer to the callback function.
[in]clientDataClient data that should be passed back to the callback.
[out]ReturnStatusstatus code
Returns
A unique id for the callback.
Status Codes:
MCallbackId setPlugLockQueryCallback ( MPlug plug,
MLockMessage::MLockPlugEventFunction  func,
void *  clientData = NULL,
MStatus ReturnStatus = NULL 
)
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:

  • plug - The plug that triggered the callback.
  • otherPlug - The other plug involved in the callback. This is only valid during connect and disconnect events.
  • clientData - User defined data passed to the callback function.
  • eventType - Description of the event.
  • decision - 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

  • plug - The plug that the user is attempting to lock.
  • otherPlug - NULL plug.
  • default actions - If plug is unlocked then the default action is to allow the plug to be locked.

kPlugUnlockAttr

  • plug - The plug that the user is attempting to unlock.
  • otherPlug - NULL plug.
  • default actions - If plug is locked then the default action is to allow the plug to be unlocked.

kPlugAttrValChange

  • plug - The plug that the user is attempting to change.
  • otherPlug - NULL plug.
  • default actions - If plug is locked then the default action is to not allow plug to change. If plug is unlocked then plug can change.

kPlugRemoveAttr

  • plug - The plug that the user is attempting to remove.
  • otherPlug - NULL plug.
  • default actions - If plug is locked then the default action is to not allow removal. Otherwise, if plug is unlocked then plug can be removed.

kPlugRenameAttr

  • plug - The plug that the user is attempting to rename.
  • otherPlug - NULL plug.
  • default actions - If plug is locked then the default action is to not allow the rename. Otherwise, if plug is unlocked then plug can be renamed.

kPlugConnect

  • plug - The plug that is to be connected (incoming connection).
  • otherPlug - The source plug of the connection being made.
  • default actions - If plug is locked then the connection is DENIED. If plug is unlocked then otherPlug can be connected to plug.

kPlugDisconnect

  • plug - The plug that it is having an incoming connection broken.
  • otherPlug - The source plug of the connection being made.
  • default actions - If plug is locked then the default action is to DENY the connection from being broken. If plug is unlocked then otherPlug can be disconnected from plug.
Parameters
[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
Returns
A unique id for the callback.
Status Codes:
MCallbackId setPlugLockQueryCallback ( MObject node,
MLockMessage::MLockPlugEventFunction  func,
void *  clientData = NULL,
MStatus ReturnStatus = NULL 
)
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:

  • plug - The plug that triggered the callback.
  • otherPlug - The other plug involved in the callback. This is only valid during connect and disconnect events.
  • clientData - User defined data passed to the callback function.
  • eventType - Description of the event.
  • decision - 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.

Parameters
[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
Returns
A unique id for the callback.
Status Codes:
const char * className ( )
static

Returns the name of this class.

Returns
The name of this class.

The documentation for this class was generated from the following files:
  • MLockMessage.h
  • MLockMessage.cpp