#include <MNodeMessage.h>
Dependency node messages.
This class is used to register callbacks for dependency node messages of specific dependency nodes.
There are 5 add callback methods which will add callbacks for the following messages
The first parameter passed to each of the add callback methods is the dependency node that will trigger the callback.
Callbacks that are registered for attribute changed/addedOrRemoved messages will be passed an AttributeMessage value as a parameter. This value indicates the type of attribute message that has occurred. See the AttributeMessage enum for all available messages.
Each method returns an id which is used to remove the callback.
To remove a callback use MMessage::removeCallback. All callbacks that are registered by a plug-in must be removed by that plug-in when it is unloaded. Failure to do so will result in a fatal error.
Public Types | |
enum | AttributeMessage { kConnectionMade = 0x01, kConnectionBroken = 0x02, kAttributeEval = 0x04, kAttributeSet = 0x08, kAttributeLocked = 0x10, kAttributeUnlocked = 0x20, kAttributeAdded = 0x40, kAttributeRemoved = 0x80, kAttributeRenamed = 0x100, kAttributeKeyable = 0x200, kAttributeUnkeyable = 0x400, kIncomingDirection = 0x800, kAttributeArrayAdded = 0x1000, kAttributeArrayRemoved = 0x2000, kOtherPlugSet = 0x4000, kLast = 0x8000 } |
The type of attribute changed/addedOrRemoved messages that has occurred. More... | |
enum | KeyableChangeMsg { kKeyChangeInvalid = 0, kMakeKeyable, kMakeUnkeyable, kKeyChangeLast } |
Allows you to prevent attributes from becoming (un)keyable. More... | |
typedef void(* | MAttr2PlugFunction) (MNodeMessage::AttributeMessage msg, MPlug &plug, MPlug &otherPlug, void *clientData) |
Pointer to an AttributeMessage callback which takes two plugs. More... | |
typedef void(* | MAttrPlugFunction) (MNodeMessage::AttributeMessage msg, MPlug &plug, void *clientData) |
Pointer to an AttributeMessage callback which takes a single plug. More... | |
typedef void(* | MKeyableFunction) (MPlug &plug, void *clientData, MNodeMessage::KeyableChangeMsg msg, bool &decision) |
Pointer to a change in keyability callback function. More... | |
Callback result action codes. More... |
Static Public Member Functions | |
static MCallbackId | addAttributeChangedCallback (MObject &node, MNodeMessage::MAttr2PlugFunction func, void *clientData=NULL, MStatus *ReturnStatus=NULL) |
This method registers a callback for attribute changed messages. More... | |
static MCallbackId | addAttributeAddedOrRemovedCallback (MObject &node, MNodeMessage::MAttrPlugFunction func, void *clientData=NULL, MStatus *ReturnStatus=NULL) |
Registers callbacks for attribute add/removed messages. More... | |
static MCallbackId | addNodeDirtyCallback (MObject &node, MMessage::MNodeFunction func, void *clientData=NULL, MStatus *ReturnStatus=NULL) |
Registers a callback for node dirty messages. More... | |
static MCallbackId | addNodeDirtyPlugCallback (MObject &node, MMessage::MNodePlugFunction func, void *clientData=NULL, MStatus *ReturnStatus=NULL) |
Registers a callback for node dirty messages. More... | |
static MCallbackId | addNameChangedCallback (MObject &node, MMessage::MNodeStringFunction func, void *clientData=NULL, MStatus *ReturnStatus=NULL) |
Registers a callback for name changed messages. More... | |
static MCallbackId | addUuidChangedCallback (MObject &node, MMessage::MNodeUuidFunction func, void *clientData=NULL, MStatus *ReturnStatus=NULL) |
Registers a callback for UUID changed messages. More... | |
static MCallbackId | addNodeAboutToDeleteCallback (MObject &node, MMessage::MNodeModifierFunction func, void *clientData=NULL, MStatus *ReturnStatus=NULL) |
Registers a callback which will get called when a node is about to be deleted. More... | |
static MCallbackId | addNodePreRemovalCallback (MObject &node, MMessage::MNodeFunction func, void *clientData=NULL, MStatus *ReturnStatus=NULL) |
Registers a callback which will get called before a node is deleted. More... | |
static MCallbackId | addNodeDestroyedCallback (MObject &node, MMessage::MBasicFunction func, void *clientData=NULL, MStatus *ReturnStatus=NULL) |
NodeDestroyed callback. More... | |
static MCallbackId | addKeyableChangeOverride (MPlug &plug, MNodeMessage::MKeyableFunction func, void *clientData=NULL, MStatus *status=NULL) |
Attribute keyable state change override. More... | |
static const char * | className () |
Returns the name of this class. More... | |
typedef void(* MAttr2PlugFunction) (MNodeMessage::AttributeMessage msg, MPlug &plug, MPlug &otherPlug, void *clientData) |
Pointer to an AttributeMessage callback which takes two plugs.
[in] | msg | Type of message which caused the function to be called. |
[in,out] | plug | First plug. Meaning depends upon the specific message which invoked the callback. |
[in,out] | otherPlug | Second plug. Meaning depends upon the specific message which invoked the callback. |
[in] | clientData | Pointer to user-defined data supplied when the callback was registered. |
typedef void(* MAttrPlugFunction) (MNodeMessage::AttributeMessage msg, MPlug &plug, void *clientData) |
Pointer to an AttributeMessage callback which takes a single plug.
[in] | msg | Type of message which caused the function to be called. |
[in,out] | plug | Meaning depends upon the specific message which invoked the callback. |
[in] | clientData | Pointer to user-defined data supplied when the callback was registered. |
typedef void(* MKeyableFunction) (MPlug &plug, void *clientData, MNodeMessage::KeyableChangeMsg msg, bool &decision) |
Pointer to a change in keyability callback function.
[in,out] | plug | The plug whose keyability is changing. |
[in] | clientData | Pointer to user-defined data supplied when the callback was registered. |
[in] | msg | Specifies how the plug's keyability is changing. |
[out] | decision | Callback sets this true to accept the change, false to reject it. |
enum AttributeMessage |
The type of attribute changed/addedOrRemoved messages that has occurred.
enum KeyableChangeMsg |
|
static |
This method registers a callback for attribute changed messages.
See the AttributeChanged enum for a list of all possible messages that will trigger the callback.
Note: Attribute Changed messages will not be generated while Maya is either in playback or scrubbing modes. If you need to do something during playback or scrubbing you will have to register a callback for the timeChanged message which is the only message message that is sent during those modes.
The callback function will be passed the type of attribute message that has occurred, the plug(s) for the attributes, and any client data that the user wishes to pass in.
Example callback ( prints out a message when a connection is made or broken ) :
[in] | node | the node to register the callback for. If this is a NULL MObject then the callback applies to all nodes. |
[in] | func | the callback function, which takes the following parameters:
|
[in] | clientData | User defined data that will be passed to the callback function |
[out] | ReturnStatus | status code |
|
static |
Registers callbacks for attribute add/removed messages.
This is a more specific version of addAttributeChanged as only attribute added and attribute removed messages will trigger the callback.
[in] | node | the node to register the callback for |
[in] | func | the callback function, which takes the following parameters:
|
[in] | clientData | User defined data that will be passed to the callback function |
[out] | ReturnStatus | status code |
|
static |
Registers a callback for node dirty messages.
[in] | node | the node to register the callback for |
[in] | func | the callback function, which takes the following parameters:
|
[in] | clientData | User defined data that will be passed to the callback function |
[out] | ReturnStatus | status code |
|
static |
Registers a callback for node dirty messages.
This callback provides the plug on the node that was dirtied. Only provides dirty information on input plugs.
[in] | node | the node to register the callback for |
[in] | func | the callback function, which takes the following parameters:
|
[in] | clientData | User defined data that will be passed to the callback function |
[out] | ReturnStatus | status code |
|
static |
Registers a callback for name changed messages.
[in] | node | the node. If this is a NULL MObject then the callback applies to all node name changes. |
[in] | func | the callback function, which takes the following parameters:
|
[in] | clientData | User defined data that will be passed to the callback function |
[out] | ReturnStatus | status code |
|
static |
Registers a callback for UUID changed messages.
[in] | node | the node. If this is a NULL MObject then the callback applies to all node UUID changes. |
[in] | func | the callback function, which takes the following parameters:
|
[in] | clientData | User defined data that will be passed to the callback function |
[out] | ReturnStatus | status code |
|
static |
Registers a callback which will get called when a node is about to be deleted.
The callback will be passed the MDGModifer that will be used to delete the node. This modifier can be used to do any DG modifications, such as disconnections, before the node is deleted. These operations are also stored and performed when the deletion operation is undone or redone.
The callback registered with this method will only get called when the deletion operation is first performed. Undos and redos will be handled solely through the MDGModifier which was passed to the callback on the original deletion. If you also wish to receive notification of deletion events when they are redone, you should register an additional callback using addNodePreRemovalCallback().
When a node is deleted Maya automatically breaks all connections to that node. This process takes place after the callback has been called. This means that if you use the passed-in MDGModifier to break any connections to the node you must be sure to call the modifier's doIt() method before returning from the callback. Otherwise Maya will see that the connections still exist and try to delete them again, which can lead to errors.
The example below shows a callback function which takes the connection coming into the node's input attribute and reconnects it to all of the plugs connected to the node's output attribute:
Note that it uses the passed-in MDGModifier to perform all the disconnections and connections. This ensures that if the deletion is undone or redone then all of the connections will be restored correctly.
After it is done breaking connections, the callback calls the modifier's doIt() method to commit those disconnections. As noted above, this is necessary to ensure that Maya doesn't see the connections and try to break them again later on.
[in] | node | the node to register the callback for |
[in] | func | the callback function, which takes the following parameters:
|
[in] | clientData | User defined data that will be passed to the callback function |
[out] | ReturnStatus | status code |
|
static |
Registers a callback which will get called before a node is deleted.
This callback is called before connections on the node are removed. Unlike the aboutToDelete callback, this callback will be invoked whenever the node is deleted, even during a redo.
Pre-removal and aboutToDelete callbacks serve different purposes. If DG changes need to be made when a node is deleted, the aboutToDelete callback should be used to add undoable operations to an MDGModifier to perform these changes. When the desired actions cannot be accomplished using the MDGModifier passed to the aboutToDelete callback, this callback can be used to receive notification of the deletion event, even during redo.
Note that this callback method should not perform any DG operations.
[in] | node | the node to register the callback for |
[in] | func | the callback function, which takes the following parameters:
|
[in] | clientData | User defined data that will be passed to the callback function |
[out] | ReturnStatus | status code |
|
static |
NodeDestroyed callback.
Registers a callback which will get called when a node's destructor is called.
[in] | node | the node to register the callback for |
[in] | func | the callback function, which takes the following parameters:
|
[in] | clientData | User defined data that will be passed to the callback function |
[out] | ReturnStatus | status code |
|
static |
Attribute keyable state change override.
This method registers a callback that is invoked by any class that changes the keyable state of an attribute.
When the callback is invoked, the API programmer can make a decision on how to handle the given keyable change event. The programmer can either accept the the keyable state change by returning a decision == 'true' or reject it by returning decision == 'false'.
Note: you can only attach one callback keyable change override callback per attribute. It is an error to attach more than one callback to the same attribute.
[in] | plug | The plug to which to attach the callback. |
[in] | func | the callback function, which takes the following parameters:
|
[in] | clientData | User defined data passed back to the user. |
[in] | ReturnStatus | status code |
|
static |
Returns the name of this class.