C++ API Reference
MGraphEditorInfo Class Reference

Graph Editor state information with manipulation capabilities. More...

#include <MGraphEditorInfo.h>

+ Inheritance diagram for MGraphEditorInfo:

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 getAnimCurveNodes (MObjectArray &animCurveNodeArray, AnimCurveQuery animCurveQuery) const
 Returns an array of animCurve nodes, based on the attached Graph Editor's state information, which captures: More...
 
bool isStackedViewportMode () const
 Returns whether or not the Graph Editor is in Stacked view mode. More...
 
bool isNormalizedViewportMode () const
 Returns whether or not the Graph Editor is in Normalized view mode. More...
 
- Public Member Functions inherited from MPanelCanvasInfo
 MPanelCanvasInfo (const MString &editorName, MStatus *stat=NULL)
 The constructor. More...
 
virtual ~MPanelCanvasInfo ()
 Destructor.
 
MStatus getViewportBounds (double &left, double &right, double &bottom, double &top) const
 Return the viewport bounds. More...
 
MStatus getViewportBounds (MDoubleArray &boundsArray) const
 Get the attached Graph Editor's viewport bounds, using the currently defined animation time units. More...
 
MStatus getViewportSize (int &width, int &height) const
 Return the viewport size. More...
 
MStatus setViewportBounds (double left, double right, double bottom, double top) const
 Set the viewport bounds. 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...
 
bool supportsUIDrawing ()
 Returns whether the attached panel control supports drawing primitives in screen space. More...
 
void reset ()
 Resets all stored state information to be empty, thereby detaching from the currently attached Graph Editor (if any)
 
MString name () const
 Return the name of the currently attached panel. More...
 

Static Public Member Functions

static const char * className ()
 Returns the name of this class. More...
 
- Static Public Member Functions inherited from MPanelCanvasInfo
static const char * className ()
 Returns the name of this class. More...
 

Detailed 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)

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 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
bool isStackedViewportMode ( ) const

Returns whether or not the Graph Editor is in Stacked view mode.

return true if the Graph Editor is in Stacked view mode; false otherwise

bool isNormalizedViewportMode ( ) const

Returns whether or not the Graph Editor is in Normalized view mode.

return true if the Graph Editor is in a Normalized view mode. NOTE: Stacked mode also uses Normalized mode. So this method returns true in Stacked mode, as well; false if not in Stacked -nor- Normalized modes.

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: