MGraphEditorInfo Class Reference

#include <MGraphEditorInfo.h>

Class Description

Graph Editor state information with manipulation capabilities.

This class provides methods to obtain UI related information from a specific Graph Editor. Support is included for obtaining/setting viewport bounds and obtaining animation curve nodes.

Note: the following are built-in GraphEditor-specific event callback names:

  • graphEditorChanged
    • Triggered whenever there is a Graph Editor refresh/resize event
  • graphEditorParamCurveSelected
    • Triggered whenever an animation curve is selected or de-selected
  • graphEditorOutlinerHighlightChanged
    • Triggered whenever there is a change to the Outliner list selection
  • graphEditorOutlinerListChanged
    • Triggered whenever there is a change to the Outliner list contents

Python 1.0 Example: (getting the names of the curves selected in the default Graph Editor)

import maya.OpenMaya as om
import maya.OpenMayaAnim as oma
import maya.OpenMayaUI as omu
def printParamCurves(*queryCriteria):
info = omu.MGraphEditorInfo()
dependNodeArray=om.MObjectArray()
info.getAnimCurveNodes(dependNodeArray, queryCriteria[0])
for i in range(0, dependNodeArray.length()):
mObj=dependNodeArray[i]
if (mObj is None or not mObj.hasFn(om.MFn.kAnimCurve)):
continue
animCurveNode = oma.MFnAnimCurve(mObj)
animCurveNodeName = om.MFnDependencyNode(mObj).name()
print animCurveNodeName
eventId0 = om.MEventMessage.addEventCallback('graphEditorParamCurveSelected',
printParamCurves,
eventId1 = om.MEventMessage.addEventCallback(
'graphEditorOutlinerHighlightChanged',
printParamCurves,
eventId2 = om.MEventMessage.addEventCallback('graphEditorOutlinerListChanged',
printParamCurves,
# Note: execute these lines later when the above callbacks aren't required
#
om.MMessage.removeCallback(eventId0)
om.MMessage.removeCallback(eventId1)
om.MMessage.removeCallback(eventId2)

Python 1.0 Example: (getting the default Graph Editor's viewport bounds when it encounters a refresh event)

import maya.OpenMaya as om
import maya.OpenMayaUI as omu
def printViewportBounds(*obj):
info = omu.MGraphEditorInfo()
leftSu=om.MScriptUtil(0.0)
leftPtr=leftSu.asDoublePtr()
rightSu=om.MScriptUtil(0.0)
rightPtr=rightSu.asDoublePtr()
bottomSu=om.MScriptUtil(0.0)
bottomPtr=bottomSu.asDoublePtr()
topSu=om.MScriptUtil(0.0)
topPtr=topSu.asDoublePtr()
info.getViewportBounds(leftPtr, rightPtr, bottomPtr, topPtr)
print '%d %d %d %d' % (om.MScriptUtil(leftPtr).asDouble(),
om.MScriptUtil(rightPtr).asDouble(), om.MScriptUtil(bottomPtr).asDouble(),
om.MScriptUtil(topPtr).asDouble())
eventId = om.MEventMessage.addEventCallback('graphEditorChanged',
printViewportBounds)
# Note: execute this line later when the above callback isn't required
#
om.MMessage.removeCallback(eventId)

Python 1.0 Example: (setting the default Graph Editor's viewport bounds)

import maya.OpenMayaUI as omu
info = omu.MGraphEditorInfo()
info.setViewportBounds(-100,100,-100,100)

Public Types

enum  AnimCurveQuery { kAnimCurveOutlinerOnly = 0, kAnimCurveHighlighted, kAnimCurveSelected, kAnimCurveAllKnown }
 Defines the query criteria for animation curves specifically with respect to the attached Graph Editor's own viewport. More...
 

Public Member Functions

 MGraphEditorInfo (MStatus *ReturnStatus=NULL)
 Constructor. More...
 
 MGraphEditorInfo (const MString &graphEditorName, MStatus *ReturnStatus=NULL)
 Constructor. More...
 
virtual ~MGraphEditorInfo ()
 Destructor.
 
MStatus getViewportBounds (double &left, double &right, double &bottom, double &top) const
 Get the attached Graph Editor's viewport bounds, using the currently defined animation time units. More...
 
MStatus getViewportBounds (MDoubleArray &boundsArray) const
 Get the attached Graph Editor's viewport bounds, using the currently defined animation time units. More...
 
MStatus setViewportBounds (double left, double right, double bottom, double top) const
 Set the attached Graph Editor's viewport bounds to those that are supplied using the currently defined animation time units as seen in the viewport. More...
 
MStatus setViewportBounds (const MDoubleArray &boundsArray) const
 Set the attached Graph Editor's viewport bounds to those that are supplied using the currently defined animation time units as seen in the viewport. More...
 
MStatus getAnimCurveNodes (MObjectArray &animCurveNodeArray, AnimCurveQuery animCurveQuery) const
 Returns an array of animCurve nodes, based on the attached Graph Editor's state information, which captures: More...
 
void reset ()
 Resets all stored state information to be empty, thereby detaching from the currently attached Graph Editor (if any)
 
MString name () const
 Returns the name of the currently attached Graph Editor (if any) More...
 

Static Public Member Functions

static const char * className ()
 Returns the name of this class. More...
 

Member Enumeration Documentation

Defines the query criteria for animation curves specifically with respect to the attached Graph Editor's own viewport.

Enumerator
kAnimCurveOutlinerOnly 

Curve(s) present in Outliner (but not visible in the viewport).

Note: this is not currently supported

kAnimCurveHighlighted 

Curve(s) highlighted in Outliner (and visible in the viewport)

kAnimCurveSelected 

Curve(s) selected (via keys/tangent handles) in the viewport.

kAnimCurveAllKnown 

Curve(s) known to exist (independent of any Outliner filtering)

Constructor & Destructor Documentation

OPENMAYA_MAJOR_NAMESPACE_OPEN MGraphEditorInfo ( MStatus ReturnStatus = NULL)

Constructor.

Attaches to the default Graph Editor object - graphEditor1GraphEd

Parameters
[out]ReturnStatusthe return status
Status Codes:
  • MS::kSuccess The default Graph Editor object is valid
  • MS::kFailure The default Graph Editor object does not exist
  • MS::kNotImplemented The default Graph Editor is currently in an unsupported state (stacked curves or normalized display modes)
MGraphEditorInfo ( const MString graphEditorName,
MStatus ReturnStatus = NULL 
)

Constructor.

Attaches to the Graph Editor corresponding the supplied name.

Parameters
[in]graphEditorNamethe name of the Graph Editor (i.e. graphEditor1GraphEd)
[out]ReturnStatusthe return status
Status Codes:
  • MS::kSuccess The supplied Graph Editor object name is valid
  • MS::kFailure The supplied Graph Editor object name is invalid
  • MS::kNotImplemented The supplied Graph Editor is currently in an unsupported state (stacked curves or normalized display modes)

Member Function Documentation

MStatus getViewportBounds ( double &  left,
double &  right,
double &  bottom,
double &  top 
) const

Get the attached Graph Editor's viewport bounds, using the currently defined animation time units.

Note: a viewport that is displaying stacked curves or re-normalized curves is not currently supported.

Parameters
[out]leftleft co-ordinate
[out]rightright co-ordinate
[out]bottombottom co-ordinate
[out]toptop co-ordinate
Returns
the return status
Status Codes:
  • MS::kSuccess The viewport bounds were obtained
  • MS::kFailure The viewport bounds could not be obtained
  • MS::kNotImplemented The supplied Graph Editor is currently in an unsupported state (stacked curves or normalized display modes)
MStatus getViewportBounds ( MDoubleArray boundsArray) const

Get the attached Graph Editor's viewport bounds, using the currently defined animation time units.

Note: a viewport that is displaying stacked curves or re-normalized curves is not currently supported.

Parameters
[out]boundsArrayan array of four doubles representing in order: (left, right, bottom, top) bounds co-ordinates
Returns
the return status
Status Codes:
  • MS::kSuccess The viewport bounds were obtained
  • MS::kFailure The viewport bounds could not be obtained
  • MS::kNotImplemented The supplied Graph Editor is currently in an unsupported state (stacked curves or normalized display modes)
MStatus setViewportBounds ( double  left,
double  right,
double  bottom,
double  top 
) const

Set the attached Graph Editor's viewport bounds to those that are supplied using the currently defined animation time units as seen in the viewport.

Note: a viewport that is displaying stacked curves or re-normalized curves is not currently supported.

Parameters
[in]leftleft co-ordinate
[in]rightright co-ordinate
[in]bottombottom co-ordinate
[in]toptop co-ordinate
Returns
the return status
Status Codes:
  • MS::kSuccess The viewport bounds were changed
  • MS::kFailure The viewport bounds could not be changed
  • MS::kNotImplemented The supplied Graph Editor is currently in an unsupported state (stacked curves or normalized display modes)
MStatus setViewportBounds ( const MDoubleArray boundsArray) const

Set the attached Graph Editor's viewport bounds to those that are supplied using the currently defined animation time units as seen in the viewport.

Note: a viewport that is displaying stacked curves or re-normalized curves is not currently supported.

Parameters
[in]boundsArrayan array of exactly four doubles representing in order: (left, right, bottom, top) bounds co-ordinates
Returns
the return status
Status Codes:
  • MS::kSuccess The viewport bounds were changed
  • MS::kFailure The viewport bounds could not be changed
  • MS::kNotImplemented The supplied Graph Editor is currently in an unsupported state (stacked curves or normalized display modes)
MStatus getAnimCurveNodes ( MObjectArray animCurveNodeArray,
AnimCurveQuery  animCurveQuery 
) const

Returns an array of animCurve nodes, based on the attached Graph Editor's state information, which captures:

1) animCurve nodes present in the Outliner, but not visible in the viewport 2) animCurve nodes highlighted in the Outliner and visible in the viewport 3) animCurve nodes selected (via keys/tangent handles) in the viewport 4) animCurve nodes known to exist (independent of any Outliner filtering)

Parameters
[out]animCurveNodeArrayan array to store the found anim curves
[in]animCurveQuerythe anim curves to enumerate (by display state)
Returns
the return status
Status Codes:
  • MS::kSuccess animation curves were obtained
  • MS::kFailure animation curves could not be obtained
MString name ( ) const

Returns the name of the currently attached Graph Editor (if any)

Returns
The name of the currently attached Graph Editor or an empty string if no Graph Editor is attached
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:
  • MGraphEditorInfo.h
  • MGraphEditorInfo.cpp