#include <MPxContext.h>
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 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 } |
Public Member Functions | |
MPxContext () | |
virtual | ~MPxContext () |
virtual void | toolOnSetup (MEvent &event) |
virtual void | toolOffCleanup () |
virtual MStatus | doPress (MEvent &event) |
virtual MStatus | doRelease (MEvent &event) |
virtual MStatus | doDrag (MEvent &event) |
virtual MStatus | doHold (MEvent &event) |
virtual MStatus | doEnterRegion (MEvent &event) |
virtual MStatus | helpStateHasChanged (MEvent &event) |
virtual void | deleteAction () |
virtual void | completeAction () |
virtual MStatus | addManipulator (const MObject &manipulator) |
virtual MStatus | deleteManipulators () |
MStatus | setImage (const MString &image, ImageIndex index) |
MString | image (ImageIndex index, MStatus *ReturnStatus=NULL) const |
virtual void | abortAction () |
virtual bool | processNumericalInput (const MDoubleArray &values, const MIntArray &flags, bool isAbsolute) |
virtual bool | feedbackNumericalInput () const |
virtual MSyntax::MArgType | argTypeNumericalInput (unsigned int index) const |
virtual MString | stringClassName () const |
virtual void | getClassName (MString &name) const |
NO SCRIPT SUPPORT. | |
MStatus | getImage (MString &image, ImageIndex index) const |
NO SCRIPT SUPPORT. | |
Protected Member Functions | |
MStatus | setHelpString (const MString &str) |
USE _setHelpString() IN SCRIPT. | |
MStatus | setTitleString (const MString &str) |
USE _setTitleString() IN SCRIPT. | |
MStatus | setCursor (const MCursor &cursor) |
USE _setCursor() IN SCRIPT. | |
MStatus | beginMarquee (MEvent &event) |
USE _beginMarquee() IN SCRIPT. | |
MStatus | dragMarquee (MEvent &event) |
USE _dragMarquee() IN SCRIPT. | |
MStatus | releaseMarquee (MEvent &event, short &top, short &left, short &bottom, short &right) |
USE _releaseMarquee() IN SCRIPT. | |
virtual MPxToolCommand * | newToolCommand () |
CALL _newToolCommand() IN SCRIPT. | |
Static Protected Member Functions | |
static bool | ignoreEntry (const MIntArray &flags, unsigned int entry) |
USE _ignoreEntry() IN SCRIPT. | |
Friends | |
class | MPxSelectionContext |
class | MToolsInfo |
MPxContext::MPxContext | ( | ) |
Class contstructor. This constructor will only be called from MPxContextCommand::makeObj. Users must override this method.
MPxContext::~MPxContext | ( | ) | [virtual] |
Default destructor. Users can override this method to free any user instantiated data when the context is destroyed.
void MPxContext::toolOnSetup | ( | MEvent & | event | ) | [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 >.
void MPxContext::toolOffCleanup | ( | ) | [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 >.
This method is called when any mouse button is pressed. The base method does nothing and should be overriden if the user needs to do anything on a button press.
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 overriden if the user needs to do anything on a button release.
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 overriden if the user needs to do anything during a mouse drag.
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 overriden if the user needs to do anything on a button hold.
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 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.
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.
void MPxContext::deleteAction | ( | ) | [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.
void MPxContext::completeAction | ( | ) | [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.
MStatus MPxContext::deleteManipulators | ( | ) | [virtual] |
This method deletes all the manipulators that belong to the context.
Reimplemented in MPxSelectionContext.
MStatus MPxContext::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 |
Reimplemented in MPxSelectionContext.
MString MPxContext::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) |
Reimplemented in MPxSelectionContext.
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. |
MStatus MPxContext::releaseMarquee | ( | MEvent & | event, | |
short & | top, | |||
short & | left, | |||
short & | bottom, | |||
short & | right | |||
) | [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 |
MPxToolCommand * MPxContext::newToolCommand | ( | ) | [protected, virtual] |
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 :
MFnPlugin::registerContextCommand( contextCommand, contextCommandCreator, toolCommand, toolCommandCreator )
Reimplemented in MPxSelectionContext.
void MPxContext::abortAction | ( | ) | [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.
bool MPxContext::processNumericalInput | ( | const MDoubleArray & | values, | |
const MIntArray & | flags, | |||
bool | isAbsolute | |||
) | [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.
bool MPxContext::feedbackNumericalInput | ( | ) | const [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.
MSyntax::MArgType MPxContext::argTypeNumericalInput | ( | unsigned int | index | ) | const [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.
MString MPxContext::stringClassName | ( | ) | const [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:
MString MPxExampleContext::stringClassName() const { return "exampleTool"; }
This name is used by Maya to call the appropriate tool property sheet MEL scripts, specifically:
void MPxContext::getClassName | ( | MString & | name | ) | const [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:
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 |
Reimplemented in MPxSelectionContext.
MStatus MPxContext::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 |
Reimplemented in MPxSelectionContext.
bool MPxContext::ignoreEntry | ( | const MIntArray & | flags, | |
unsigned int | entry | |||
) | [static, protected] |
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 |
Autodesk® Maya® 2009 © 1997-2008 Autodesk, Inc. All rights reserved. | Generated with 1.5.6 |