class MPxSelectionContext

Jump to documentation

: public MPxContext Base class for interative selection tools (OpenMayaUI) (OpenMayaMPx.py)

Inheritance:

MPxSelectionContext < MPxContext

public members:

MPxSelectionContext ()
virtual ~MPxSelectionContext ()
virtual MStatus doPress ( MEvent & event )
virtual MStatus doRelease ( MEvent & event )
virtual MStatus doDrag ( MEvent & event )
virtual MStatus doHold ( MEvent & event )
virtual MStatus helpStateHasChanged ( MEvent & )
virtual MStatus addManipulator ( const MObject & manipulator )
virtual MStatus deleteManipulators ()
MStatus setImage ( const MString & image , ImageIndex index )
MString image ( ImageIndex index, MStatus * ReturnStatus = NULL ) const
MStatus getImage ( MString & image , ImageIndex index ) const
NO SCRIPT SUPPORT
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 void getClassName ( MString & name ) const

protected members:

bool isSelecting ()
USE _isSelecting() IN SCRIPT
MPoint startPoint ()
USE _startPoint() IN SCRIPT
MPoint lastDragPoint ()
USE _lastDragPoint() IN SCRIPT
virtual MPxToolCommand * newToolCommand ()
CALL _newToolCommand() IN SCRIPT

Inherited from MPxContext:

public members:

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
MStatus getImage ( MString & image , ImageIndex index ) const

protected members:

MStatus setHelpString ( const MString & str )
MStatus setTitleString ( const MString & str )
MStatus setCursor ( const MCursor & cursor )
MStatus beginMarquee ( MEvent & event )
MStatus dragMarquee ( MEvent & event )
MStatus releaseMarquee ( MEvent & event, short& top, short& left, short& bottom, short& right )
virtual MPxToolCommand * newToolCommand ()
static bool ignoreEntry ( const MIntArray &flags, unsigned int entry )

Documentation

Description

This class is used in creating user defined tools that use the internal selection mechanism in maya.

Functions

MPxSelectionContext:: MPxSelectionContext ()

Description

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

MPxSelectionContext:: ~MPxSelectionContext ()

Description

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

MStatus MPxSelectionContext:: helpStateHasChanged ( MEvent & )

Description 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.

Arguments

  • event The event information.

Return Value

  • Status code

Status Codes

  • MS::kSuccess

MStatus MPxSelectionContext:: doPress ( MEvent & event)

Description

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.

Arguments

  • event The button press event information.

Return Value

  • Status code

Status Codes

  • MS::kSuccess

MStatus MPxSelectionContext:: doDrag ( MEvent & event)

Description

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.

Arguments

  • event The mouse drag event information.

Return Value

  • Status code

Status Codes

  • MS::kSuccess

MStatus MPxSelectionContext:: doRelease ( MEvent & event)

Description

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.

Arguments

  • event The mouse button release information.

Return Value

  • Status code

Status Codes

  • MS::kSuccess

MStatus MPxSelectionContext:: doHold ( MEvent & event)

Description

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.

Arguments

  • event The mouse button hold event information.

Return Value

  • Status code

Status Codes

  • MS::kSuccess

MStatus MPxSelectionContext:: addManipulator (const MObject &manipulator)

Description

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.

Arguments

  • manipulator the manipulator to be added to the context

Return Value

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

MStatus MPxSelectionContext:: deleteManipulators ()

Description

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

Return Value

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

MStatus MPxSelectionContext:: setImage (const MString & image , ImageIndex index)

Description

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.

Arguments

  • image the name of an XPM file to be used as the icon
  • index the index of the image being set; three image representations are permitted: kImage1, kImage2, kImage3

Return Value

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

MStatus MPxSelectionContext:: getImage ( MString & image , ImageIndex index) const

Description

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.

Arguments

  • image the returned name of an XPM Icon file
  • index the index for the image being retrieved; three image representations are permitted: kImage1, kImage2, kImage3

Return Value

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

MString MPxSelectionContext:: image (ImageIndex index, MStatus * ReturnStatus) const

Description

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.

Arguments

  • index the index for the image being retrieved; three image representations are permitted: kImage1, kImage2, kImage3
  • ReturnStatus Status code (see below)

Return Value

  • string name

Status Codes

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

MPoint MPxSelectionContext:: startPoint ()

Description

Returns the position of button press.

Return Value

  • The start point

MPoint MPxSelectionContext:: lastDragPoint ()

Description

Returns the position of the last drag point.

Return Value

  • The last drag point

bool MPxSelectionContext:: isSelecting ()

Description

Determines whether an object is selected.

Return Value

  • true An object(s) is selected
  • false No object(s) is selected

MPxToolCommand * MPxSelectionContext:: newToolCommand ()

Description

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 )
	

Return Value

  • A new instance of the MPxToolCommand.

void MPxSelectionContext:: abortAction ()

Description

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.

Return Value

  • none

bool MPxSelectionContext:: processNumericalInput ( const MDoubleArray &values, const MIntArray &flags, bool isAbsolute )

Description

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.

Arguments

  • values the values from the numerical input field
  • flags used in conjunction with the ignoreEntry method, determines whether or not a given entry should be ignored
  • isAbsolute whether or not the input should be interpreted as absolute

Return Value

  • false the default return value

bool MPxSelectionContext:: feedbackNumericalInput () const

Description

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.

Return Value

  • false the default return value

MSyntax::MArgType MPxSelectionContext:: argTypeNumericalInput (unsigned int index) const

Description

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:

  • MSyntax::kNoArg for no argument
  • MSyntax::kDistance for linear units
  • MSyntax::kAngle for angular units

Arguments

  • index the index of the numerical input whose argument type is requested

Return Value

  • MSyntax::kNoArg the default return value

void MPxSelectionContext:: getClassName ( MString &name) const

Description

This method is called to determine the name that uniquely identifies the context. This method should be overridden such that the name is set to the appropriate string. For example:

	void MPxExampleContext::getClassName(MString &name) const
	{ name.set("exampleTool"); }
	

This name is used by Maya to call the appropriate tool property sheet MEL scripts, specifically:

  • <name>Properties.mel
  • <name>Values.mel

If this method is not overriden, by default it will set the string to "defaultTool".

Arguments

  • name string that uniquely identifies the context

Return Value

  • none

This class has no child classes.


Autodesk® Maya® 8.0 © 1997-2006 Autodesk, Inc. All rights reserved. doc++ Copyright