#include <MPxContext.h>
Base class for user defined contexts.
This is the base class for user defined contexts.
Contexts provide a way to create interactive tools in Maya. A context class defines what happens when interactive events, such as mouse events, occur within an interactive panel in Maya.
Since there are default actions for all tools in Maya, such as the right mouse button event which brings up an options menu, only as subset of the events that occur in a view can be overridden. The events that can be overridden are:
A context is activated by pressing the toolButton for that context. Once the context is activated, it will handle the events that occur within 3d panel.
A context is deactivated when some other tool button is pressed.
There can be more than one instance of a context in Maya, for example, dragging a tool icon into the shelf creates another instance of that context. Since there can be multiple instances of the same context there is a command class, MPxContextCommand, which is responsible for the creation of contexts. See MPxContextCommand for more information.
Public Types | |
enum | ImageIndex { kImage1 = 0, kImage2, kImage3 } |
Used to select between the three possible images associated with the context. More... | |
Public Member Functions | |
MPxContext () | |
Class contstructor. More... | |
virtual | ~MPxContext () |
Default destructor. More... | |
virtual void | toolOnSetup (MEvent &event) |
This method is called when the context is activated, i.e when the toolButton for the context is pressed. More... | |
virtual void | toolOffCleanup () |
This method is called when the context is deactivated, i.e when another context is activated. More... | |
virtual MStatus | doPress (MEvent &event, MHWRender::MUIDrawManager &drawMgr, const MHWRender::MFrameContext &context) |
This method is not available in Python. More... | |
virtual MStatus | doRelease (MEvent &event, MHWRender::MUIDrawManager &drawMgr, const MHWRender::MFrameContext &context) |
This method is not available in Python. More... | |
virtual MStatus | doDrag (MEvent &event, MHWRender::MUIDrawManager &drawMgr, const MHWRender::MFrameContext &context) |
This method is not available in Python. More... | |
virtual MStatus | doHold (MEvent &event, MHWRender::MUIDrawManager &drawMgr, const MHWRender::MFrameContext &context) |
This method is not available in Python. More... | |
virtual MStatus | drawFeedback (MHWRender::MUIDrawManager &drawMgr, const MHWRender::MFrameContext &context) |
This method is not available in Python. More... | |
virtual MStatus | doPtrMoved (MEvent &event, MHWRender::MUIDrawManager &drawMgr, const MHWRender::MFrameContext &context) |
This method is called when a mouse move event occurs. More... | |
virtual MStatus | doPress (MEvent &event) |
This method is called when any mouse button is pressed. More... | |
virtual MStatus | doRelease (MEvent &event) |
This method is called when any mouse button is released. More... | |
virtual MStatus | doDrag (MEvent &event) |
This method is called when a mouse drag event occurs. More... | |
virtual MStatus | doHold (MEvent &event) |
This method is called when a mouse button is pressed but before the mouse is dragged. More... | |
virtual MStatus | doPtrMoved (MEvent &event) |
This method is called when a mouse move event occurs. More... | |
virtual MStatus | doEnterRegion (MEvent &event) |
This method is called when the mouse pointer enters a screen panel region. More... | |
virtual MStatus | helpStateHasChanged (MEvent &event) |
This method is called whenever the help state may need to be updated. More... | |
virtual void | deleteAction () |
This method is called when the delete or backspace key is pressed. More... | |
virtual void | completeAction () |
This method is called when the complete key is pressed. More... | |
virtual MStatus | addManipulator (const MObject &manipulator) |
This method adds a manipulator to the context. More... | |
virtual MStatus | deleteManipulators () |
This method deletes all the manipulators that belong to the context. More... | |
MStatus | setImage (const MString &image, ImageIndex index) |
This method is used to set an XPM icon image that is to be used to represent this tool context in various places including the tool bar and can be queried from mel using the contextInfo command. More... | |
MString | image (ImageIndex index, MStatus *ReturnStatus=NULL) const |
This method is used to retrieve an XPM icon image that has previously been set for this tool context. More... | |
virtual void | abortAction () |
This method is called when the abort key is pressed. More... | |
virtual bool | processNumericalInput (const MDoubleArray &values, const MIntArray &flags, bool isAbsolute) |
This method processes the input from the numerical input field. More... | |
virtual bool | feedbackNumericalInput () const |
This method is called to update the numerical feedback. More... | |
virtual MSyntax::MArgType | argTypeNumericalInput (unsigned int index) const |
This method is used by the feedback line to determine what units to display. More... | |
virtual MString | stringClassName () const |
This method is called to determine the name that uniquely identifies the context. More... | |
virtual void | getClassName (MString &name) const |
NO SCRIPT SUPPORT. More... | |
MStatus | getImage (MString &image, ImageIndex index) const |
NO SCRIPT SUPPORT. More... | |
Static Public Member Functions | |
static const char * | className () |
Returns the name of this class. More... | |
Protected Member Functions | |
MStatus | setHelpString (const MString &str) |
USE _setHelpString() IN SCRIPT. More... | |
MStatus | setTitleString (const MString &str) |
USE _setTitleString() IN SCRIPT. More... | |
MStatus | setCursor (const MCursor &cursor) |
USE _setCursor() IN SCRIPT. More... | |
MStatus | beginMarquee (MEvent &event) |
USE _beginMarquee() IN SCRIPT. More... | |
MStatus | dragMarquee (MEvent &event) |
USE _dragMarquee() IN SCRIPT. More... | |
MStatus | releaseMarquee (MEvent &event, short &top, short &left, short &bottom, short &right) |
USE _releaseMarquee() IN SCRIPT. More... | |
virtual MPxToolCommand * | newToolCommand () |
CALL _newToolCommand() IN SCRIPT. More... | |
Static Protected Member Functions | |
static bool | ignoreEntry (const MIntArray &flags, unsigned int entry) |
USE _ignoreEntry() IN SCRIPT. More... | |
Friends | |
class | MPxSelectionContext |
class | MPxTexContext |
class | MToolsInfo |
enum ImageIndex |
MPxContext | ( | ) |
Class contstructor.
This constructor will only be called from MPxContextCommand::makeObj. Users must override this method.
|
virtual |
Default destructor.
Users can override this method to free any user instantiated data when the context is destroyed.
|
virtual |
This method is called when the context is activated, i.e when the toolButton for the context is pressed.
Users can override this method and use it to set up any user defined data that needs to be initialized on each activation.
[in] | event | The button press event information. |
Reimplemented in MTemplateSelectionContext< ContextNameString, ContextClass, NodeType, ManipulatorClass, ManipulatorNodeName >.
|
virtual |
This method is called when the context is deactivated, i.e when another context is activated.
Users can override this method and use it to reset any user defined data to a specific state.
Reimplemented in MTemplateSelectionContext< ContextNameString, ContextClass, NodeType, ManipulatorClass, ManipulatorNodeName >.
|
virtual |
This method is not available in Python.
This method is called when any mouse button is pressed.
The base method does nothing and should be overridden if the user needs to do anything on a button press.
This method is called only when in Viewport 2.0. MUIDrawManager must be used for any viewport drawing done in this method. Direct calls to OpenGL or DirectX are unsupported and may result in instability or unpredictable behavior.
MUIDrawManager allows for drawing primitives in the 3D modeling space. Those primitives will then be projected onto a 2D overlay plane before being displayed.
The event can be used to get more explicit information about the press such as the button number. See MEvent for more information.
[in] | event | The button press event information. |
[in] | drawMgr | The UI draw manager, it can be used to draw some simple geometry including text. |
[in] | context | Frame level context information |
Reimplemented in MPxTexContext.
|
virtual |
This method is not available in Python.
This method is called when any mouse button is released.
The base method does nothing and should be overridden if the user needs to do anything on a button release.
This method is called only when in Viewport 2.0. MUIDrawManager must be used for any viewport drawing done in this method. Direct calls to OpenGL or DirectX are unsupported and may result in instability or unpredictable behavior.
MUIDrawManager allows for drawing primitives in the 3D modeling space. Those primitives will then be projected onto a 2D overlay plane before being displayed.
The event can be used to get more explicit information about the release such as the button number. See MEvent for more information.
[in] | event | The button press event information. |
[in] | drawMgr | The UI draw manager, it can be used to draw some simple geometry including text. |
[in] | context | Frame level context information |
Reimplemented in MPxTexContext.
|
virtual |
This method is not available in Python.
This method is called when a mouse drag event occurs.
The base method does nothing and should be overridden if the user needs to do anything during a mouse drag.
This method is called only when in Viewport 2.0. MUIDrawManager must be used for any viewport drawing done in this method. Direct calls to OpenGL or DirectX are unsupported and may result in instability or unpredictable behavior.
MUIDrawManager allows for drawing primitives in the 3D modeling space. Those primitives will then be projected onto a 2D overlay plane before being displayed.
The event can be used to get more explicit information about the drag such as the cursor location. See MEvent for more information.
[in] | event | The button press event information. |
[in] | drawMgr | The UI draw manager, it can be used to draw some simple geometry including text. |
[in] | context | Frame level context information |
Reimplemented in MPxTexContext.
|
virtual |
This method is not available in Python.
This method is called when a mouse button is pressed but before the mouse is dragged.
The base method does nothing and should be overridden if the user needs to do anything on a button hold.
This method is called only when in Viewport 2.0. MUIDrawManager must be used for any viewport drawing done in this method. Direct calls to OpenGL or DirectX are unsupported and may result in instability or unpredictable behavior.
MUIDrawManager allows for drawing primitives in the 3D modeling space. Those primitives will then be projected onto a 2D overlay plane before being displayed.
The event can be used to get more explicit information about the hold such as the button number. See MEvent for more information.
[in] | event | The button press event information. |
[in] | drawMgr | The UI draw manager, it can be used to draw some simple geometry including text. |
[in] | context | Frame level context information |
|
virtual |
This method is not available in Python.
This method is called to draw primitives when your context is activated.
This method is called only when using Viewport 2.0. MUIDrawManager must be used for any viewport drawing done in this method. Direct calls to OpenGL or DirectX are unsupported and may result in instability or unpredictable behavior.
MUIDrawManager allows for drawing primitives in the 3D modeling space. Those primitives will then be projected onto a 2D overlay plane before being displayed.
[in] | drawMgr | The UI draw manager. It can be used to draw some simple geometry including text. |
[in] | context | Frame level context information |
|
virtual |
This method is called when a mouse move event occurs.
The base method does nothing and should be overridden if the user needs to do anything during a mouse drag.
This method is called only when in Viewport 2.0. MUIDrawManager must be used for any viewport drawing done in this method. Direct calls to OpenGL or DirectX are unsupported and may result in instability or unpredictable behavior.
MUIDrawManager allows for drawing primitives in the 3D modeling space. Those primitives will then be projected onto a 2D overlay plane before being displayed.
The event can be used to get more explicit information about the drag such as the cursor location. See MEvent for more information.
[in] | event | The button press event information. |
[in] | drawMgr | The UI draw manager, it can be used to draw some simple geometry including text. |
[in] | context | Frame level context information |
Reimplemented in MPxTexContext.
This method is called when any mouse button is pressed.
The base method does nothing and should be overridden if the user needs to do anything on a button press.
This method is called only when it is in either default viewport renderer or hardware viewport renderer, not viewport 2.0.
The event can be used to get more explicit information about the press such as the button number. See MEvent for more information.
[in] | event | The button press event information. |
Reimplemented in MPxSelectionContext.
This method is called when any mouse button is released.
The base method does nothing and should be overridden if the user needs to do anything on a button release.
This method is called only when it is in either default viewport renderer or hardware viewport renderer, not viewport 2.0.
The event can be used to get more explicit information about the release such as the button number. See MEvent for more information.
[in] | event | The mouse button release information. |
Reimplemented in MPxSelectionContext.
This method is called when a mouse drag event occurs.
The base method does nothing and should be overridden if the user needs to do anything during a mouse drag.
This method is called only when it is in either default viewport renderer or hardware viewport renderer, not viewport 2.0.
The event can be used to get more explicit information about the drag such as the cursor location. See MEvent for more information.
[in] | event | The mouse drag event information. |
Reimplemented in MPxSelectionContext.
This method is called when a mouse button is pressed but before the mouse is dragged.
The base method does nothing and should be overridden if the user needs to do anything on a button hold.
This method is called only when it is in either default viewport renderer or hardware viewport renderer, not viewport 2.0.
The event can be used to get more explicit information about the hold such as the button number. See MEvent for more information.
[in] | event | The mouse button hold event information. |
Reimplemented in MPxSelectionContext.
This method is called when a mouse move event occurs.
The base method does nothing and should be overridden if the user needs to do anything during a mouse drag.
This method is called only when it is in either default viewport renderer or hardware viewport renderer, not viewport 2.0.
The event can be used to get more explicit information about the drag such as the cursor location. See MEvent for more information.
[in] | event | The mouse drag event information. |
This method is called when the mouse pointer enters a screen panel region.
The base method sets the help string and the cursor which may have been set via setHelpString and setCursor respectively.
This same method is called for default viewport renderer regions, hardware viewport renderer regions, and viewport 2.0 regions. There is not a separate method for VP 2.0 regions as there is with MPxContext::doPress(), MPxContext::doHold(), and MPxContext::doRelease().
The event can be used to get more explicit information about the event. See MEvent for more information.
[in] | event | The enter region event information. |
This method is called whenever the help state may need to be updated.
The base method does nothing and should be overriden if the user needs to change the help information based on events.
The event can be used to get more explicit information about the event. See MEvent for more information.
[in] | event | The event information. |
Reimplemented in MPxSelectionContext.
|
virtual |
This method is called when the delete or backspace key is pressed.
The default behaviour for this method is to delete the items on the current selection list. Users can override this method if they wish to do anything else when this event occurs.
|
virtual |
This method is called when the complete key is pressed.
The default complete key in Maya is the enter key. Users can override this method if a tool has several steps. For example, a tool may have several steps where the user must select objects and then press the completion key before proceeding.
This method adds a manipulator to the context.
[in] | manipulator | the manipulator to be added to the context |
Reimplemented in MPxSelectionContext.
|
virtual |
This method deletes all the manipulators that belong to the context.
Reimplemented in MPxSelectionContext.
MStatus setImage | ( | const MString & | image, |
ImageIndex | index | ||
) |
This method is used to set an XPM icon image that is to be used to represent this tool context in various places including the tool bar and can be queried from mel using the contextInfo command.
[in] | image | the name of an XPM file to be used as the icon |
[in] | index | the index of the image being set; three image representations are permitted: kImage1, kImage2, kImage3 |
MString image | ( | ImageIndex | index, |
MStatus * | ReturnStatus = NULL |
||
) | const |
This method is used to retrieve an XPM icon image that has previously been set for this tool context.
This icon image will be used to represent this tool context in various places including the tool bar and can be queried from mel using the contextInfo command.
[in] | index | the index for the image being retrieved; three image representations are permitted: kImage1, kImage2, kImage3 |
[out] | ReturnStatus | Status code (see below) |
USE _setHelpString() IN SCRIPT.
Set the help string to the given MString.
This string will appear in the help line in Maya.
[in] | str | The new help string. |
USE _setTitleString() IN SCRIPT.
Set the title of the context to the MString that is passed in.
This string will appear in the help line when this context is activated.
[in] | str | The new title string. |
USE _setCursor() IN SCRIPT.
Set the cursor used by the context to the MCursor that is passed in.
[in] | newCursor | The new cursor. |
USE _beginMarquee() IN SCRIPT.
Start drawing a dragged out marquee box.
A marquee box is a rectangular area of the screen specified by two points representing opposite corners of the rectangle. Marquee's are commonly used in the selection of multiple items from a region of the screen. The marquee rectangle acts as a guideline for the region of the screen that will be effected.
[in] | event | Current event information. |
USE _dragMarquee() IN SCRIPT.
Draws a rectangle representing the dragged out area initiated with the beginMarquee method.
[in] | event | Current event information. |
|
protected |
USE _releaseMarquee() IN SCRIPT.
End the marquee drawing cycle and return the coordinates corresponding to the dragged out area.
The rectangular guideline representing the dragged area is cleared.
[in] | event | Current event information. |
[out] | top | highest value |
[out] | left | left-most value |
[out] | bottom | lowest value |
[out] | right | right-most value |
|
protectedvirtual |
CALL _newToolCommand() IN SCRIPT.
Create a new instance of the tool command associated with this context.
The tool command (derived from MPxToolCommand) is the command that was registered along with the context command in :
Reimplemented in MPxSelectionContext, and MPxTexContext.
|
virtual |
This method is called when the abort key is pressed.
The default abort key in Maya is the escape key. Users can override this method if they wish to perform certain operations when the abort key is pressed.
Reimplemented in MPxSelectionContext.
|
virtual |
This method processes the input from the numerical input field.
Users can override this method if they wish to process numerical input. For a given entry in the numeric input field, if the user types a dot ".", this indicates that the entry should not be modified. The overridden version of this method should take this into account using the ignoreEntry method with the flags that are passed in. The overridden version of this method should also process the numeric input as an absolute input or relative input depending on whether the isAbsolute flag is true or not. The return value should indicate whether or not the numerical input has been processed.
[in] | values | the values from the numerical input field |
[in] | flags | used in conjunction with the ignoreEntry method, determines whether or not a given entry should be ignored |
[in] | isAbsolute | whether or not the input should be interpreted as absolute |
Reimplemented in MPxSelectionContext.
|
virtual |
This method is called to update the numerical feedback.
The format and values for the feedback line can be set through the methods in MFeedbackLine, specifically setFormat and setValue. The return value should indicate whether or not the numerical feedback has been provided.
Reimplemented in MPxSelectionContext.
|
virtual |
This method is used by the feedback line to determine what units to display.
Users should override this method to return the appropriate argument type for the given index of the numeric input field. Specifically, this method should be overridden to return one of the following:
[in] | index | the index of the numerical input whose argument type is requested |
Reimplemented in MPxSelectionContext.
|
virtual |
This method is called to determine the name that uniquely identifies the context.
Either this method, or the getClassName method, should be overridden such that the name is set to the appropriate string. For example:
This name is used by Maya to call the appropriate tool property sheet MEL scripts, specifically:
If this method is not overriden, by default it will set the string to "defaultTool".
|
virtual |
NO SCRIPT SUPPORT.
This method is called to determine the name that uniquely identifies the context.
Either this method, or the stringClassName method which returns a string, should be overridden such that the name is set to the appropriate string. For example:
This name is used by Maya to call the appropriate tool property sheet MEL scripts, specifically:
If this method is not overriden, by default it will set the string to "defaultTool".
Python Notes
This method is not supported in Python. For contexts implemented in Python please see stringClassName() which returns a string.
[out] | name | string that uniquely identifies the context |
MStatus getImage | ( | MString & | image, |
ImageIndex | index | ||
) | const |
NO SCRIPT SUPPORT.
This method is used to retrieve an XPM icon image that has previously been set for this tool context.
This icon image will be used to represent this tool context in various places including the tool bar and can be queried from mel using the contextInfo command.
Python Notes
This method is not supported in Python. See the version which returns a string.
[out] | image | the returned name of an XPM Icon file |
[in] | index | the index for the image being retrieved; three image representations are permitted: kImage1, kImage2, kImage3 |
|
static |
Returns the name of this class.
|
staticprotected |
USE _ignoreEntry() IN SCRIPT.
This is a helper method which can be called from processNumericalInput to examine a flags array and return true if the requested (0-based) entry is to be ignored.
[in] | flags | used in conjunction with the processNumericalInput method, determines whether or not a given entry should be ignored. |
[in] | entry | the entry specified by a (0-based) index |