C++ API Reference
|
Base class used to associate user-defined data with edits. More...
#include <MPxEditData.h>
Public Member Functions | |
MPxEditData () | |
Class constructor. | |
virtual | ~MPxEditData () |
Class destructor. | |
bool | isEqual (const MPxEditData *other) const |
Compares two MPxEditData objects for equality. More... | |
bool | isLessThan (const MPxEditData *other) const |
Compares two MPxEditData objects to determine their relative order for sorting purposes. More... | |
Static Public Member Functions | |
static const char * | className () |
Returns the name of this class. More... | |
Protected Member Functions | |
virtual bool | performIsEqual (const MPxEditData *other) const =0 |
This member function must be implemented by derived classes. More... | |
virtual bool | performIsLessThan (const MPxEditData *other) const =0 |
This member function must be implemented by derived classes. More... | |
Base class used to associate user-defined data with edits.
MPxEditData is a pure virtual base class, used to derive custom data objects which can be associated with individual MEdit objects.
A small set of comparison methods need to be defined to support query operations and use of associative data structures. The base class defines no other data or behavior.
Derived classes are free to add data members and methods as required.
As a convenience, Maya implements performIsEqual and performIsLessThan as the == and < operators, respectively. Python implementations can then provide comparison methods __eq__ and __lt__, as expected.
It is expected that classes derived from MPxEditData will define one or more data members to store the object's value and this data will be used by the virtual methods performIsEqual and performIsLessThan for comparison.
In Python, derived class objects passed to the virtual comparison method implementations will only be visible as MPxEditData base class objects, not the actual derived class objects.
For this reason, Python classes derived from MPxEditData have two additional methods, _setValue and _getValue that provide a mechanism for the derived class to access its custom data value using the base class interface.
Since these interfaces are defined directly in Python, the data value can be any valid Python type.
To handle the common case of having a Python string as a tag value, similarly to _setValue and _getValue, Python classes derived from MPxEditData also have methods _setStringValue and _getStringValue.
The argument to _setStringValue is expected to be a plain Python string, not a Unicode string. The MPxEditData object takes a copy of the argument to _setStringValue, and returns a copy of its string from _getStringValue.
MPxEditData objects associated with an MEdit must be dynamically allocated. Ownership of the editData will be assumed by Maya and subsequent management of the data object, including its eventual deletion will be handled along with the edit it is associated with. For this reason, an editData object should only be associated with a single edit, the same object should not be shared or associated with other edits. If multiple edits have editData of the same value, each edit must have its own unique copy.
In Python, the OpenMayaMPx asMPxPtr method is used to transfer ownership of a dynamically allocated object to Maya. The Python example below demonstrates how this could be implemented.
bool isEqual | ( | const MPxEditData * | other | ) | const |
Compares two MPxEditData objects for equality.
The base class method makes use of the derived class performIsEqual to determine the equality of two objects. Note that the base method will simply return false if the two MPxEditData objects are of different types.
[in] | other | An editData object to compare with this object |
bool isLessThan | ( | const MPxEditData * | other | ) | const |
Compares two MPxEditData objects to determine their relative order for sorting purposes.
The base class method makes use of the derived class implementation of performIsLessThan to determine the ordering of two MPxEditData objects. Note that the base method will simply order the values by typeid if the two objects are not of the same type.
[in] | other | An editData object to compare with this object |
|
static |
Returns the name of this class.
|
protectedpure virtual |
This member function must be implemented by derived classes.
It should compare two MPxEditData objects for equality. This member function is meant to be called by the isEqual member function.
[in] | other | An editData object to compare with this object |
|
protectedpure virtual |
This member function must be implemented by derived classes.
It should compare two MPxEditData objects to determine their relative order for sorting purposes. This member function is meant to be called by the isLessThan member function.
[in] | other | An editData object to compare with this object |