C++ API Reference
MPxSelectionContext Class Reference

Base class for interative selection tools. More...

#include <MPxSelectionContext.h>

+ Inheritance diagram for MPxSelectionContext:

Public Member Functions

 MPxSelectionContext ()
 Class contstructor. More...
 
 ~MPxSelectionContext () override
 Default destructor. More...
 
MStatus doPress (MEvent &event, MHWRender::MUIDrawManager &drawMgr, const MHWRender::MFrameContext &context) override
 This method is not available in Python. More...
 
MStatus doRelease (MEvent &event, MHWRender::MUIDrawManager &drawMgr, const MHWRender::MFrameContext &context) override
 This method is not available in Python. More...
 
MStatus doDrag (MEvent &event, MHWRender::MUIDrawManager &drawMgr, const MHWRender::MFrameContext &context) override
 This method is not available in Python. More...
 
MStatus doHold (MEvent &event, MHWRender::MUIDrawManager &drawMgr, const MHWRender::MFrameContext &context) override
 This method is not available in Python. More...
 
MStatus doPress (MEvent &event) override
 This method is called when any mouse button is pressed. More...
 
MStatus doRelease (MEvent &event) override
 This method is called when any mouse button is released. More...
 
MStatus doDrag (MEvent &event) override
 This method is called when a mouse drag event occurs. More...
 
MStatus doHold (MEvent &event) override
 This method is called when after a mouse button is pressed but before the mouse is dragged. More...
 
MStatus helpStateHasChanged (MEvent &) override
 This method is called whenever the help state may need to be updated. More...
 
MStatus addManipulator (const MObject &manipulator) override
 This method adds a manipulator to the context, and also adds the manipulator to the DAG. More...
 
MStatus deleteManipulators () override
 This method deletes all the manipulators that belong to the context. More...
 
MStatus setAllowPreSelectHilight ()
 This method enables the support of pre-selection highlight for this context. More...
 
MStatus setAllowSoftSelect ()
 This method enables the support of soft selection for this context. More...
 
MStatus setAllowSymmetry ()
 This method enables the support of symmetrical selection for this context. More...
 
MStatus setAllowDoubleClickAction ()
 This method enables the support of double click smart selection for this 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...
 
MStatus getImage (MString &image, ImageIndex index) const
 NO SCRIPT SUPPORT. More...
 
void abortAction () override
 This method is called when the abort key is pressed. More...
 
bool processNumericalInput (const MDoubleArray &values, const MIntArray &flags, bool isAbsolute) override
 This method processes the input from the numerical input field. More...
 
bool feedbackNumericalInput () const override
 This method is called to update the numerical feedback. More...
 
MSyntax::MArgType argTypeNumericalInput (unsigned int index) const override
 This method is used by the feedback line to determine what units to display. More...
 
- Public Member Functions inherited from MPxContext
 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 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 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 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...
 
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 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...
 
- Static Public Member Functions inherited from MPxContext
static const char * className ()
 Returns the name of this class. More...
 

Protected Member Functions

bool isSelecting ()
 USE _isSelecting() IN SCRIPT. More...
 
MPoint startPoint ()
 USE _startPoint() IN SCRIPT. More...
 
MPoint lastDragPoint ()
 USE _lastDragPoint() IN SCRIPT. More...
 
MPxToolCommandnewToolCommand () override
 CALL _newToolCommand() IN SCRIPT. More...
 
- Protected Member Functions inherited from MPxContext
MStatus setHelpString (const MString &str)
 USE _setHelpString() IN SCRIPT. More...
 
MStatus setTitleString (const MString &str)
 USE _setTitleString() IN SCRIPT. More...
 
MStatus setCursor (const MCursor &newCursor)
 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...
 

Additional Inherited Members

- Public Types inherited from MPxContext
enum  ImageIndex { kImage1, kImage2, kImage3 }
 Used to select between the three possible images associated with the context. More...
 
- Static Protected Member Functions inherited from MPxContext
static bool ignoreEntry (const MIntArray &flags, unsigned int entry)
 USE _ignoreEntry() IN SCRIPT. More...
 

Detailed Description

Constructor & Destructor Documentation

OPENMAYA_MAJOR_NAMESPACE_OPEN MPxSelectionContext ( )

Class contstructor.

This constructor will only be called from MPxContextCommand::makeObj. Users must override this method.

~MPxSelectionContext ( )
override

Default destructor.

Users can override this method to free any user instantiated data when the context is destroyed.

Member Function Documentation

MStatus doPress ( MEvent event,
MHWRender::MUIDrawManager drawMgr,
const MHWRender::MFrameContext context 
)
overridevirtual

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.

Parameters
[in]eventThe button press event information.
[in]drawMgrThe UI draw manager, it can be used to draw some simple geometry including text.
[in]contextFrame level context information
Returns
Status code
Status Codes:
  • MS::kSuccess

Reimplemented from MPxContext.

Examples:
manipOverride/manipOverride.cpp, moveNumericTool/moveNumericTool.cpp, moveTool/moveTool.cpp, and richSelectionTool/richSelectionTool.cpp.
MStatus doRelease ( MEvent event,
MHWRender::MUIDrawManager drawMgr,
const MHWRender::MFrameContext context 
)
overridevirtual

This method is not available in Python.

This method is called when any mouse button is released.

The base method does nothing except marquee selection 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.

Parameters
[in]eventThe button press event information.
[in]drawMgrThe UI draw manager, it can be used to draw some simple geometry including text.
[in]contextFrame level context information
Returns
Status code
Status Codes:
  • MS::kSuccess

Reimplemented from MPxContext.

Examples:
manipOverride/manipOverride.cpp, moveNumericTool/moveNumericTool.cpp, moveTool/moveTool.cpp, and richSelectionTool/richSelectionTool.cpp.
MStatus doDrag ( MEvent event,
MHWRender::MUIDrawManager drawMgr,
const MHWRender::MFrameContext context 
)
overridevirtual

This method is not available in Python.

This method is called when a mouse drag event occurs.

The base method does nothing except marquee selection 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.

Parameters
[in]eventThe button press event information.
[in]drawMgrThe UI draw manager, it can be used to draw some simple geometry including text.
[in]contextFrame level context information
Returns
Status code
Status Codes:
  • MS::kSuccess

Reimplemented from MPxContext.

Examples:
manipOverride/manipOverride.cpp, moveNumericTool/moveNumericTool.cpp, and moveTool/moveTool.cpp.
MStatus doHold ( MEvent event,
MHWRender::MUIDrawManager drawMgr,
const MHWRender::MFrameContext context 
)
overridevirtual

This method is not available in Python.

This method is called when after a mouse button is pressed but before the mouse is dragged.

The base method does nothing except marquee selection 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.

Parameters
[in]eventThe button press event information.
[in]drawMgrThe UI draw manager, it can be used to draw some simple geometry including text.
[in]contextFrame level context information
Returns
Status code
Status Codes:
  • MS::kSuccess

Reimplemented from MPxContext.

Examples:
moveTool/moveTool.cpp.
MStatus doPress ( MEvent event)
overridevirtual

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.

The event can be used to get more explicit information about the press such as the button number. See MEvent for more information.

Parameters
[in]eventThe button press event information.
Returns
Status code
Status Codes:
  • MS::kSuccess

Reimplemented from MPxContext.

MStatus doRelease ( MEvent event)
overridevirtual

This method is called when any mouse button is released.

The base method does nothing except marquee selection 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.

Parameters
[in]eventThe mouse button release information.
Returns
Status code
Status Codes:
  • MS::kSuccess

Reimplemented from MPxContext.

MStatus doDrag ( MEvent event)
overridevirtual

This method is called when a mouse drag event occurs.

The base method does nothing except marquee selection 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.

Parameters
[in]eventThe mouse drag event information.
Returns
Status code
Status Codes:
  • MS::kSuccess

Reimplemented from MPxContext.

MStatus doHold ( MEvent event)
overridevirtual

This method is called when after a mouse button is pressed but before the mouse is dragged.

The base method does nothing except marquee selection 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.

Parameters
[in]eventThe mouse button hold event information.
Returns
Status code
Status Codes:
  • MS::kSuccess

Reimplemented from MPxContext.

MStatus helpStateHasChanged ( MEvent event)
overridevirtual

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.

Parameters
[in]eventThe event information. Unused in the base class.
Returns
Status code
Status Codes:
MS::kSuccess

Reimplemented from MPxContext.

MStatus addManipulator ( const MObject manipulator)
overridevirtual

This method adds a manipulator to the context, and also adds the manipulator to the DAG.

Note that the manipulator should not yet be added to the DAG when this method is called.

Parameters
[in]manipulatorthe manipulator to be added to the context
Returns
  • MS::kSuccess operation successful
  • MS::kFailure operation failed

Reimplemented from MPxContext.

MStatus deleteManipulators ( )
overridevirtual

This method deletes all the manipulators that belong to the context.

Returns
  • MS::kSuccess operation successful
  • MS::kFailure operation failed

Reimplemented from MPxContext.

MStatus setAllowPreSelectHilight ( )

This method enables the support of pre-selection highlight for this context.

It needs to be called by the user-overriden MPxContext::toolOnSetup method.

Returns
  • MS::kSuccess operation successful
  • MS::kFailure operation failed
MStatus setAllowSoftSelect ( )

This method enables the support of soft selection for this context.

Returns
  • MS::kSuccess operation successful
  • MS::kFailure operation failed
MStatus setAllowSymmetry ( )

This method enables the support of symmetrical selection for this context.

Returns
  • MS::kSuccess operation successful
  • MS::kFailure operation failed
MStatus setAllowDoubleClickAction ( )

This method enables the support of double click smart selection for this context.

Returns
  • MS::kSuccess operation successful
  • MS::kFailure operation failed
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.

Parameters
[in]imagethe name of an XPM file to be used as the icon
[in]indexthe index of the image being set; three image representations are permitted: kImage1, kImage2, kImage3
Returns
  • MS::kSuccess operation successful
  • MS::kFailure operation failed
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.

Parameters
[in]indexthe index for the image being retrieved; three image representations are permitted: kImage1, kImage2, kImage3
[out]ReturnStatusStatus code (see below)
Returns
String name
Status Codes:
  • MS::kSuccess operation successful
  • MS::kFailure operation failed
MStatus getImage ( MString image,
ImageIndex  index 
) const

NO SCRIPT SUPPORT.

This method is not available in Python.

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 image function which returns a string.

Parameters
[in]imagethe returned name of an XPM Icon file
[in]indexthe index for the image being retrieved; three image representations are permitted: kImage1, kImage2, kImage3
Returns
  • MS::kSuccess operation successful
  • MS::kFailure operation failed
bool isSelecting ( )
protected

USE _isSelecting() IN SCRIPT.

Determines whether an object is selected.

Returns
true An object(s) is selected, false otherwise.
MPoint startPoint ( )
protected

USE _startPoint() IN SCRIPT.

Returns the position of button press.

Returns
The start point
MPoint lastDragPoint ( )
protected

USE _lastDragPoint() IN SCRIPT.

Returns the position of the last drag point.

Returns
The last drag point
MPxToolCommand * newToolCommand ( )
overrideprotectedvirtual

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 )
Returns
A new instance of the MPxToolCommand.

Reimplemented from MPxContext.

void abortAction ( )
overridevirtual

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 from MPxContext.

bool processNumericalInput ( const MDoubleArray values,
const MIntArray flags,
bool  isAbsolute 
)
overridevirtual

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.

Parameters
[in]valuesthe values from the numerical input field
[in]flagsused in conjunction with the ignoreEntry method, determines whether or not a given entry should be ignored
[in]isAbsolutewhether or not the input should be interpreted as absolute
Returns
false the default return value.

Reimplemented from MPxContext.

Examples:
moveNumericTool/moveNumericTool.cpp.
bool feedbackNumericalInput ( ) const
overridevirtual

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.

Returns
false the default return value

Reimplemented from MPxContext.

Examples:
moveNumericTool/moveNumericTool.cpp.
MSyntax::MArgType argTypeNumericalInput ( unsigned int  index) const
overridevirtual

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:

Parameters
[in]indexthe index of the numerical input whose argument type is requested
Returns
MSyntax::kNoArg the default return value

Reimplemented from MPxContext.

Examples:
moveNumericTool/moveNumericTool.cpp.
const char * className ( )
static

Returns the name of this class.

Returns
Name of this class.

The documentation for this class was generated from the following files: