#include <MPxManipulatorNode.h>
Base class for manipulator creation.
MPxManipulatorNode is the base class used for creating user-defined manipulators. This class is derived from MPxNode since manipulators in Maya are dependency nodes.
An MPxManipulatorNode should implement the following method:
Additionally, several of the following virtuals will need to be defined:
Implement the following method to properly support undo:
The draw() method is very important since drawing and picking are done together. The colorAndName() method should be called before drawing a GL component that should be pickable. Several color methods which return color indexes that Maya use are provided to allow custom manipulators to have a similar look.
When drawing a GL pickable component, an active name must be set. Use the glFirstHandle() to get this value from the base class.
To draw the manipulator in Viewport 2.0, the plugin must also implement preDrawUI() and drawUI(). Note that selection relies on the default viewport draw pass so the draw() method must still be implemented even if the manipulator is not intended for use in the default viewport. preDrawUI() is called before drawUI() and should be used to prepare and cache data which will be needed to draw the manipulator in drawUI().
A manipulator can be connected to a depend node instead of updating a node attribute directly in one of the do*() methods. To connect to a depend node, you must:
This class can work standalone or with MPxManipContainer.
Public Member Functions | |
MPxManipulatorNode () | |
Class constructor. | |
virtual | ~MPxManipulatorNode () |
Class destructor. | |
virtual MStatus | connectToDependNode (const MObject &dependNode) |
This method connects the manipulator to the dependency node. More... | |
virtual void | preDrawUI (const M3dView &view) |
This method is not available in Python. More... | |
virtual void | drawUI (MHWRender::MUIDrawManager &drawManager, const MHWRender::MFrameContext &frameContext) const |
This method is not available in Python. More... | |
virtual void | draw (M3dView &view, const MDagPath &path, M3dView::DisplayStyle style, M3dView::DisplayStatus status) |
This method is overloaded to draw the manipulators. More... | |
virtual MStatus | doPress (M3dView &view) |
This method gets called when the manipulator receives a mouse down event. More... | |
virtual MStatus | doDrag (M3dView &view) |
This method gets called when the manipulator receives a mouse drag event. More... | |
virtual MStatus | doRelease (M3dView &view) |
This method gets called when the manipulator receives a mouse release event. More... | |
virtual MStatus | doMove (M3dView &view, bool &refresh) |
This method gets called when the manipulator receives a mouse move event, if the manipulator registered for mouse move events. More... | |
MStatus | finishAddingManips () |
This method should be called from the user-defined manipulator plug-in near the end of the connectToDependNode method so that the converter in the manipulator can be initialized. More... | |
MStatus | colorAndName (M3dView &view, MGLuint glName, bool glNameIsPickable, short colorIndex) const |
This method is used to set the color of the GL component that is being drawn next. More... | |
MStatus | shouldDrawHandleAsSelected (unsigned int name, bool &useSelectedColor) const |
This method is obsolete. More... | |
MStatus | setHandleColor (MHWRender::MUIDrawManager &drawManager, unsigned int handleName, short colorIndex) const |
This method is used to set the color of component that is being drawn next. More... | |
MStatus | glFirstHandle (MGLuint &firstHandle) |
This method is used to find the unsigned int value that should be used for the first GL handle. More... | |
MStatus | glActiveName (MGLuint &glName) |
This method returns the unsigned int value which specifies the current active handle. More... | |
MStatus | mouseRay (MPoint &linePoint, MVector &lineDirection) const |
This method returns the location of the mouse within a view. More... | |
MStatus | mouseRayWorld (MPoint &linePoint, MVector &lineDirection) const |
This method returns the location of the mouse within a view. More... | |
MStatus | mousePosition (short &x_pos, short &y_pos) |
This method returns the current mouse position within a view. More... | |
MStatus | mouseDown (short &x_pos, short &y_pos) |
This method returns the mouse down position within a view. More... | |
MStatus | mouseUp (short &x_pos, short &y_pos) |
This method returns the mouse up position within a view. More... | |
MStatus | registerForMouseMove () |
This method registers this manipulator to receive mouse move events. More... | |
MStatus | deregisterForMouseMove () |
This method deregisters this manipulator from receiving mouse move events. More... | |
MStatus | addDoubleValue (const MString &valueName, double defaultValue, int &valueIndex) |
Manipulators which call connectPlugToValue() must first create the value on the node. More... | |
MStatus | addPointValue (const MString &valueName, const MPoint &defaultValue, int &valueIndex) |
Manipulators which call connectPlugToValue() must first create the value on the node. More... | |
MStatus | addVectorValue (const MString &valueName, const MVector &defaultValue, int &valueIndex) |
Manipulators which call connectPlugToValue() must first create the value on the node. More... | |
MStatus | setDoubleValue (int valueIndex, double value) |
This method is used for setting a double value associated with the manipulator. More... | |
MStatus | setPointValue (int valueIndex, const MPoint &value) |
This method is used for setting an MPoint value associated with the manipulator. More... | |
MStatus | setVectorValue (int valueIndex, const MVector &value) |
This method is used for setting a MVector value associated with the manipulator. More... | |
MStatus | getDoubleValue (int valueIndex, bool previousValue, double &value) |
This method is used for getting a double value associated with the manipulator. More... | |
MStatus | getPointValue (int valueIndex, bool previousValue, MPoint &value) |
This method is used for getting a MPoint value associated with the manipulator. More... | |
MStatus | getVectorValue (int valueIndex, bool previousValue, MVector &value) |
This method is used for getting a MVector value associated with the manipulator. More... | |
MStatus | connectPlugToValue (const MPlug &plug, int valueIndex, int &plugIndex) |
This method is called in the connectToDependNode() virtual if it is implemented for the custom manipulator. More... | |
MStatus | addDependentPlug (const MPlug &plug) |
This method adds the plug to the list of those to be keyframed. More... | |
MStatus | dependentPlugsReset () |
This method resets the list of dependent plugs for this manipulator. More... | |
short | mainColor () const |
This method returns the main color index. | |
short | xColor () const |
This method returns the color index of the x axis. | |
short | yColor () const |
This method returns the color index of the y axis. | |
short | zColor () const |
This method returns the color index of the z axis. | |
short | prevColor () const |
This method returns the previously color used by the colorAndName() method. | |
short | lineColor () const |
This method returns the color index of a line. | |
short | dimmedColor () const |
This method returns the color index for a dimmed or unselectable component. | |
short | selectedColor () const |
This method returns the color index of a selected component. | |
short | labelColor () const |
This method returns the color index of a label. | |
short | labelBackgroundColor () const |
This method returns the color index of a label background. | |
Public Member Functions inherited from MPxNode | |
MPxNode () | |
Constructor. More... | |
virtual | ~MPxNode () |
Destructor. | |
virtual void | postConstructor () |
Post constructor. More... | |
virtual MStatus | compute (const MPlug &plug, MDataBlock &dataBlock) |
This method should be overridden in user defined nodes. More... | |
virtual bool | getInternalValueInContext (const MPlug &plug, MDataHandle &dataHandle, MDGContext &ctx) |
This method is overridden by nodes that store attribute data in some internal format. More... | |
virtual bool | setInternalValueInContext (const MPlug &plug, const MDataHandle &dataHandle, MDGContext &ctx) |
This method is overridden by nodes that store attribute data in some internal format. More... | |
virtual bool | getInternalValue (const MPlug &plug, MDataHandle &dataHandle) |
This method is obsolete. More... | |
virtual bool | setInternalValue (const MPlug &plug, const MDataHandle &dataHandle) |
This method is obsolete. More... | |
virtual int | internalArrayCount (const MPlug &plug, const MDGContext &ctx) const |
This method is overridden by nodes that have internal array attributes which are not stored in Maya's datablock. More... | |
virtual void | copyInternalData (MPxNode *) |
This method is overridden by nodes that store attribute data in some internal format. More... | |
virtual MStatus | legalConnection (const MPlug &plug, const MPlug &otherPlug, bool asSrc, bool &isLegal) const |
This method allows you to check for legal connections being made to attributes of this node. More... | |
virtual MStatus | legalDisconnection (const MPlug &plug, const MPlug &otherPlug, bool asSrc, bool &isLegal) const |
This method allows you to check for legal disconnections being made to attributes of this node. More... | |
virtual MStatus | setDependentsDirty (const MPlug &plug, MPlugArray &plugArray) |
This method can be overridden in user defined nodes to specify which plugs should be set dirty based upon an input plug {plugBeingDirtied} which Maya is marking dirty. More... | |
virtual MStatus | preEvaluation (const MDGContext &context, const MEvaluationNode &evaluationNode) |
Prepare a node's internal state for threaded evaluation. More... | |
virtual MStatus | postEvaluation (const MDGContext &context, const MEvaluationNode &evaluationNode, PostEvaluationType evalType) |
Clean up node's internal state after threaded evaluation. More... | |
virtual SchedulingType | schedulingType () const |
When overridden this method controls the degree of parallelism supported by the node during threaded evaluation. More... | |
virtual MStatus | connectionMade (const MPlug &plug, const MPlug &otherPlug, bool asSrc) |
This method gets called when connections are made to attributes of this node. More... | |
virtual MStatus | connectionBroken (const MPlug &plug, const MPlug &otherPlug, bool asSrc) |
This method gets called when connections are broken with attributes of this node. More... | |
virtual MStatus | dependsOn (const MPlug &plug, const MPlug &otherPlug, bool &depends) const |
This method may be overridden by the user defined node. More... | |
virtual bool | isPassiveOutput (const MPlug &plug) const |
This method may be overridden by the user defined node if it wants to provide output attributes which do not prevent value modifications to the destination attribute. More... | |
virtual MStatus | shouldSave (const MPlug &plug, bool &isSaving) |
This method may be overridden by the user defined node. More... | |
virtual MPlug | passThroughToOne (const MPlug &plug) const |
This method may be overridden by nodes that have a one-to-one relationship between an input attribute and a corresponding output attribute. More... | |
virtual bool | passThroughToMany (const MPlug &plug, MPlugArray &plugArray) const |
This method is overridden by nodes that want to control the traversal behavior of some Maya search algorithms which traverse the history/future of shape nodes looking for directly related nodes. More... | |
virtual Type | type () const |
Returns the type of node that this is. More... | |
virtual bool | isAbstractClass () const |
Override this class to return true if this node is an abstract node. More... | |
virtual MStringArray | getFilesToArchive (bool shortName=false, bool unresolvedName=false, bool markCouldBeImageSequence=false) const |
Use this method to return all external files used by this node. More... | |
virtual void | getExternalContent (MExternalContentInfoTable &table) const |
Returns the external content (files) that this node depends on. More... | |
bool | addExternalContentForFileAttr (MExternalContentInfoTable &table, const MObject &attr) const |
Adds content info to the specified table from a file path attribute. More... | |
bool | setExternalContentForFileAttr (const MObject &attr, const MExternalContentLocationTable &table) |
Sets content info in the specified attribute from the table. More... | |
virtual void | setExternalContent (const MExternalContentLocationTable &table) |
Changes the location of external content in batch. More... | |
virtual MTypeId | typeId () const |
Returns the TYPEID of this node. More... | |
virtual MString | typeName () const |
Returns the type name of this node. More... | |
virtual MString | name () const |
Returns the name of this particular instance of this class. More... | |
virtual MObject | thisMObject () const |
Returns the MObject associated with this user defined node. More... | |
virtual MStatus | setExistWithoutInConnections (bool flag) |
This method specifies whether or not the node can exist without input connections. More... | |
virtual bool | existWithoutInConnections (MStatus *ReturnStatus=NULL) const |
Determines whether or not this node can exist without input connections. More... | |
virtual MStatus | setExistWithoutOutConnections (bool flag) |
This method specifies whether or not the node can exist without output connections. More... | |
virtual bool | existWithoutOutConnections (MStatus *ReturnStatus=NULL) const |
Determines whether or not this node can exist without output connections. More... | |
Static Public Member Functions | |
static MPxManipulatorNode * | newManipulator (const MString &manipName, MObject &manipObject, MStatus *ReturnStatus=NULL) |
This static function is used to create a user-defined manipulator. More... | |
static const char * | className () |
Returns the name of this class. More... | |
Static Public Member Functions inherited from MPxNode | |
static MStatus | addAttribute (const MObject &attr) |
This method adds a new attribute to a user defined node type during the type's initialization. More... | |
static MStatus | inheritAttributesFrom (const MString &parentClassName) |
This method allows a class of plugin node to inherit all of the attributes of a second class of plugin node. More... | |
static MStatus | attributeAffects (const MObject &whenChanges, const MObject &isAffected) |
This method specifies that a particular input attribute affects a specific output attribute. More... | |
static const char * | className () |
Returns the name of this class. More... | |
Static Public Attributes | |
static MObject | connectedNodes |
Connected node, message attribute. | |
Static Public Attributes inherited from MPxNode | |
static MObject | message |
message attribute | |
static MObject | isHistoricallyInteresting |
is historically interesting attribute | |
static MObject | caching |
caching attribute | |
static MObject | state |
state attribute | |
static MObject | frozen |
frozen attribute | |
This method connects the manipulator to the dependency node.
This is a virtual method and needs to be overridden from the plug-in.
[in] | node | the node to which the manipulator should be connected |
|
virtual |
This method is not available in Python.
This method is used to setup some drawing data for drawing the manipulator in Viewport 2.0 .
The data updated and cached in this function will be used later during 'drawUI()'.
This method is only called when the manipulator needs to be drawn in Viewport 2.0.
This method need only be overridden if custom data is needed for drawing in drawUI(). If no such data is needed, this method may be left unimplemented.
This function is empty in this base class.
[in] | view | The view in which to draw |
|
virtual |
This method is not available in Python.
This is the primary method for drawing the manipulator in Viewport 2.0.
All drawing should occur using the MUIDrawManager and any data cached in preDrawUI(). Raw OpenGL calls are not supported and if used behaviour will be undefined. Selection must still be handled in the draw() method, this method is only for display.
This method is only called when the manipulator needs to be drawn in Viewport 2.0.
This function is empty in this base class.
[in] | drawManager | The MUIDrawManager used to draw some simple UI |
[in] | frameContext | Frame level context information |
|
virtual |
This method is overloaded to draw the manipulators.
Selection is also setup with this method using the colorAndName() method call.
[in] | view | the view in which to draw |
[in] | path | the current path |
[in] | style | the display appearance |
[in] | status | the display status |
This method gets called when the manipulator receives a mouse down event.
You should return kUnknownParameter to allow Maya to process the event also.
[in] | view | the view that is active |
This method gets called when the manipulator receives a mouse drag event.
You should return kUnknownParameter to allow Maya to process the event also.
[in] | view | the view that is active |
This method gets called when the manipulator receives a mouse release event.
You should return kUnknownParameter to allow Maya to process the event also.
[in] | view | the view that is active |
This method gets called when the manipulator receives a mouse move event, if the manipulator registered for mouse move events.
To register for mouse move events, invoke registerForMouseMove() in the postConstructor of your manipulator.
You should return kUnknownParameter to allow Maya to process the event also.
[in] | view | the view that is active |
[out] | refresh | if true, refresh the view on this event. Default is false. |
MStatus finishAddingManips | ( | ) |
This method should be called from the user-defined manipulator plug-in near the end of the connectToDependNode method so that the converter in the manipulator can be initialized.
The converter cannot be initialized until all the connections from the manip values to the plug values have been specified.
MStatus colorAndName | ( | M3dView & | view, |
MGLuint | glName, | ||
bool | glNameIsPickable, | ||
short | colorIndex | ||
) | const |
This method is used to set the color of the GL component that is being drawn next.
It is also used to set GL name of the component so that picking can be supported.
[in] | view | the view that is active |
[in] | glName | GL "name" (an unsigned int) of the component. Must be unique. |
[in] | glNameIsPickable | If true, the component will be pickable |
[in] | colorIndex | Color to use, as provided by one of the *Color() methods in this class. |
MStatus shouldDrawHandleAsSelected | ( | unsigned int | name, |
bool & | useSelectedColor | ||
) | const |
This method is obsolete.
This method can be used to find out if the handle should be drawn using the selected color instead of the regular one.
[in] | name | unique name (an unsigned int) of the component. |
[out] | useSelectedColor | will be true if the handle is active or highlighted. |
MStatus setHandleColor | ( | MHWRender::MUIDrawManager & | drawManager, |
unsigned int | handleName, | ||
short | colorIndex | ||
) | const |
This method is used to set the color of component that is being drawn next.
The color will be correctly selected based on the component's state(highlighted, selected, etc.)
[in] | drawManager | The MUIDrawManager used to draw some simple UI. |
[in] | handleName | The unique name (an unsigned int) of the component. |
[in] | colorIndex | The default color, if the component is neither highlighted nor selected, the colorIndex will be used. |
MStatus glFirstHandle | ( | MGLuint & | firstHandle | ) |
This method is used to find the unsigned int value that should be used for the first GL handle.
[out] | firstHandle | Returns the first handle. |
MStatus glActiveName | ( | MGLuint & | glName | ) |
This method returns the unsigned int value which specifies the current active handle.
[out] | glName | active handle |
This method returns the location of the mouse within a view.
The location is defined by a point and a direction through the point. Both point and direction are in local space.
[out] | linePoint | local space line point of mouse |
[out] | lineDirection | local direction of mouse in view |
This method returns the location of the mouse within a view.
The location is defined by a point and a direction through the point. Both point and direction are in world space.
[out] | linePoint | world space line point of mouse |
[out] | lineDirection | world direction of mouse in view |
MStatus mousePosition | ( | short & | x_pos, |
short & | y_pos | ||
) |
This method returns the current mouse position within a view.
The position is in port coordinates.
[out] | x_pos | returns the x port coordinate |
[out] | y_pos | returns the y port coordinate |
MStatus mouseDown | ( | short & | x_pos, |
short & | y_pos | ||
) |
This method returns the mouse down position within a view.
The position is in port coordinates.
[out] | x_pos | returns the mouse down x port coordinate |
[out] | y_pos | returns the mouse down y port coordinate |
MStatus mouseUp | ( | short & | x_pos, |
short & | y_pos | ||
) |
This method returns the mouse up position within a view.
The position is in port coordinates.
[out] | x_pos | returns the mouse up x port coordinate |
[out] | y_pos | returns the mouse up y port coordinate |
MStatus registerForMouseMove | ( | ) |
This method registers this manipulator to receive mouse move events.
When registered, the doMove() function will be invoked on mouse move events.
MStatus deregisterForMouseMove | ( | ) |
This method deregisters this manipulator from receiving mouse move events.
Manipulators which call connectPlugToValue() must first create the value on the node.
Use this method to create a value of double type.
[in] | valueName | Name of the value. |
[in] | defaultValue | Default value. |
[out] | valueIndex | Index assigned to this value by Maya. Used in connectPlugToValue(). |
Manipulators which call connectPlugToValue() must first create the value on the node.
Use this method to create a value of double MPoint.
[in] | valueName | Name of the value. |
[in] | defaultValue | Default value. |
[out] | valueIndex | Index assigned to this value by Maya. Used in connectPlugToValue(). |
MStatus addVectorValue | ( | const MString & | valueName, |
const MVector & | defaultValue, | ||
int & | valueIndex | ||
) |
Manipulators which call connectPlugToValue() must first create the value on the node.
Use this method to create a value of double MVector.
[in] | valueName | Name of the value. |
[in] | defaultValue | Default value. |
[out] | valueIndex | Index assigned to this value by Maya. Used in connectPlugToValue(). |
MStatus setDoubleValue | ( | int | valueIndex, |
double | value | ||
) |
This method is used for setting a double value associated with the manipulator.
[in] | valueIndex | the index of the value to be set |
[in] | value | the value to set it to |
This method is used for setting an MPoint value associated with the manipulator.
[in] | valueIndex | the index of the value to be set |
[in] | value | the value to set it to |
This method is used for setting a MVector value associated with the manipulator.
[in] | valueIndex | the index of the value to be set |
[in] | value | the value to set it to |
MStatus getDoubleValue | ( | int | valueIndex, |
bool | previousValue, | ||
double & | value | ||
) |
This method is used for getting a double value associated with the manipulator.
[in] | valueIndex | the index of the value to be set |
[in] | previousValue | if true, get the previous value. if false, get the current value |
[out] | value | return the double value |
This method is used for getting a MPoint value associated with the manipulator.
[in] | valueIndex | the index of the value to be set |
[in] | previousValue | if true, get the previous value. if false, get the current value |
[out] | value | return the double value |
This method is used for getting a MVector value associated with the manipulator.
[in] | valueIndex | the index of the value to be set |
[in] | previousValue | if true, get the previous value. if false, get the current value |
[out] | value | return the double value |
This method is called in the connectToDependNode() virtual if it is implemented for the custom manipulator.
It will connect a plug to an already added manipulator value of the same type.
[in] | plug | the plug to connect the value to |
[in] | valueIndex | the index of the value. index is set by add*Value() method |
[out] | plugIndex | a new index for the plug that is being connected |
|
static |
This static function is used to create a user-defined manipulator.
The manipObject argument is set to the new manipulator node. Note that the manipName argument must be the name of a manipulator derived from MPxManipulatorNode. Also note that this method creates the newManipulator, but doesn't add it to the DAG. The primary use of this method is in conjunction with MPxSelectionContext::addManipulator, to add user-defined manipulators to a context.
[in] | manipName | manipulator name |
[out] | manipObject | manipulator object |
[out] | ReturnStatus | Status code. |
This method adds the plug to the list of those to be keyframed.
The call to addDependentPlug() should happen prior to the manipulator identifying the plugs to be set. For example, if your manipulator sets plugs based on the selection list or modifier keys you could call addDependentPlug() from your doPress() method. Note that the dependentPlugsReset() method is provided to clear out the list and should be called prior to addDependentPlugs().
[in] | plug | the plug to keyframe when using this manipulator |
MStatus dependentPlugsReset | ( | ) |
This method resets the list of dependent plugs for this manipulator.
Call this method prior to adding plugs via addDependentPlug() such as from your doPress() method.
|
static |
Returns the name of this class.