C++ API Reference
MPanelCanvas Class Reference

Custom Panel user drawing capabilities for supported panels. More...

#include <MPanelCanvas.h>

Public Types

enum  DrawLayer
 Principal layer values.
 
enum  GraphEditorReservedLayer
 Graph Editor reserved layers.
 
typedef void(* MDrawUIFunction) (MHWRender::MUIDrawManager &drawMgr, void *userData)
 UI callback function definition.
 

Public Member Functions

 MPanelCanvas (const MString &panelControlName, MStatus *stat=NULL)
 Constructor. More...
 
 ~MPanelCanvas ()
 Destructor.
 
bool supportsUIDrawing ()
 Returns whether the attached panel control supports drawing primitives in screen space. More...
 
bool isValid ()
 Returns true if MPanelCanvas has a valid pointer to a Graph Editor object, false otherwise. More...
 
int createVertexBuffer (const MTimeArray &xvals, const MFloatArray &yvals, const MColorArray *colors=NULL, MStatus *stat=NULL)
 Create a vertex buffer with time values as the x-coordinate. More...
 
int createVertexBuffer (const MFloatArray &xvals, const MFloatArray &yvals, const MColorArray *colors=NULL, MStatus *stat=NULL)
 Create a vertex buffer with screen space values as the x and y coordinates. More...
 
int createPrimitive (MHWRender::MGeometry::Primitive primType, int vertexBufferId, int startIndex, int numVertices, const MDrawProperties &props, MStatus *stat=NULL)
 Create a primitive of the given type using the vertex buffer specified by the given id, the range of vertices used from the buffer, and a drawing style. More...
 
MStatus addPrimitive (int primId, int layer)
 Add the primitive referred to by the given id to the list of primitives to be drawn at the given layer. More...
 
MStatus removePrimitive (int primId, int layer)
 Remove the primitive referred to by the given id from the list of primitives to be drawn at the given layer. More...
 
MStatus destroyPrimitive (int primId)
 Destroy the primitive referred to by the given id. More...
 
MStatus destroyVertexBuffer (int vertId)
 Destroy the vertex buffer referred to by the given id. More...
 
MStatus refresh ()
 Force the associated Graph Editor to refresh. More...
 
MStatus setAutoRefresh (bool enable)
 Set whether the associated editor will be automatically refreshed. More...
 
bool isAutoRefresh ()
 Returns whether the associated editor will automatically refresh. More...
 
MStatus setLayerVisible (int layer, bool isVisible)
 Set whether the given layer will be drawn. More...
 
bool isLayerVisible (int layer, MStatus *stat=NULL)
 Return whether the given layer is visible. More...
 
int registerDrawUICallback (int layer, MDrawUIFunction func, void *clientData=NULL, MStatus *returnStatus=NULL)
 Register a callback to be called when the given panel is drawing the given layer. More...
 
void unregisterDrawUICallback (int callbackId, MStatus *returnStatus=NULL)
 Unregister the callback specified by the given id. More...
 

Detailed Description

Custom Panel user drawing capabilities for supported panels.

This class provides methods for a user to draw additional primitives to a supporting control. The user can construct this class from the name of a panel which supports such drawing.

Constructor & Destructor Documentation

MPanelCanvas ( const MString editorName,
MStatus ReturnStatus = NULL 
)

Constructor.

Attaches to the Graph Editor corresponding the supplied name.

Parameters
[in]editorNamethe 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

bool supportsUIDrawing ( )

Returns whether the attached panel control supports drawing primitives in screen space.

If such drawing is not supported, the registerDrawUICallback () method will return MStatus::kNotImplemented.

Note that for the Graph Editor, if the panel for drawing has not yet been created (e.g., when the default Graph Editor has not yet been opened), this method will return false.

Returns
True if this MPanelCanvas supports UI drawing callbacks
bool isValid ( )

Returns true if MPanelCanvas has a valid pointer to a Graph Editor object, false otherwise.

Returns
True if this MPanelCanvas has a valid pointer to a Graph Editor
int createVertexBuffer ( const MTimeArray tVals,
const MFloatArray yVals,
const MColorArray cVals = NULL,
MStatus stat = NULL 
)

Create a vertex buffer with time values as the x-coordinate.

An id referring to the created buffer is returned.

Parameters
[in]tValsArray of time values
[in]yValsArray of y values
[in]cValsArray of colors
[out]statStatus code
Returns
Id associated with the created buffer
int createVertexBuffer ( const MFloatArray xVals,
const MFloatArray yVals,
const MColorArray cVals = NULL,
MStatus stat = NULL 
)

Create a vertex buffer with screen space values as the x and y coordinates.

An id referring to the created buffer is returned.

Parameters
[in]xValsArray of screen space x values
[in]yValsArray of screen space y values
[in]cValsArray of colors
[out]statStatus code
Returns
Id associated with the created buffer
int createPrimitive ( MHWRender::MGeometry::Primitive  primType,
int  bufferId,
int  startIndex,
int  numVertices,
const MDrawProperties &  props,
MStatus stat = NULL 
)

Create a primitive of the given type using the vertex buffer specified by the given id, the range of vertices used from the buffer, and a drawing style.

An id referring to the created primitive is returned.

Parameters
[in]primTypePrimitive type
[in]bufferIdId of vertex buffer to use
[in]startIndexIndex of first vertex in buffer
[in]numVerticesNumber of vertices in the primitive, starting at startIndex
[in]propsDraw properties of the primitive, where applicable
[out]statStatus code
Returns
Id associated with the created primitive
MStatus addPrimitive ( int  primitiveId,
int  layerId 
)

Add the primitive referred to by the given id to the list of primitives to be drawn at the given layer.

Parameters
[in]primitiveIdId of the primitive being added
[in]layerIdId of the layer to which the primitive is being added
Returns
status code
Status Codes:
  • MS::kSuccess Method was successful
  • MS::kFailure Object or parameter error
MStatus removePrimitive ( int  primitiveId,
int  layerId 
)

Remove the primitive referred to by the given id from the list of primitives to be drawn at the given layer.

The primitive will not be destroyed.

Parameters
[in]primitiveIdId of the primitive being removed
[in]layerIdId of the layer from which the primitive is being removed
Returns
status code
Status Codes:
  • MS::kSuccess Method was successful
  • MS::kFailure Object or parameter error
MStatus destroyPrimitive ( int  primitiveId)

Destroy the primitive referred to by the given id.

A primitive can only be destroyed if it is not present in any of the layers.

Parameters
[in]primitiveIdId of the primitive being removed
Returns
status code
Status Codes:
  • MS::kSuccess Method was successful
  • MS::kFailure Object or parameter error
MStatus destroyVertexBuffer ( int  bufferId)

Destroy the vertex buffer referred to by the given id.

If the buffer is being used by a primitive, an error will be generated.

Parameters
[in]bufferIdId of vertex buffer to destroy.
Returns
status code
Status Codes:
  • MS::kSuccess Method was successful
  • MS::kFailure Object or parameter error
MStatus refresh ( )

Force the associated Graph Editor to refresh.

Returns
status code
Status Codes:
  • MS::kSuccess Method was successful
  • MS::kFailure Object or parameter error
MStatus setAutoRefresh ( bool  enable)

Set whether the associated editor will be automatically refreshed.

Initially, automatic refresh is enabled.

Parameters
[in]enableEnables auto refresh if True, disable otherwise
Returns
status code
Status Codes:
  • MS::kSuccess Method was successful
  • MS::kFailure Object or parameter error
bool isAutoRefresh ( )

Returns whether the associated editor will automatically refresh.

Returns
True if the associated editor will automatically refresh, false otherwise
MStatus setLayerVisible ( int  layerId,
bool  isVisible 
)

Set whether the given layer will be drawn.

All layers are initially set to be visible. Only user defined layers may have their visibility set.

Parameters
[in]layerIdId of the layer to be made visible or invisible
[in]isVisibleIf true, the layer is made visible, otherwise invisible
Returns
status code
Status Codes:
  • MS::kSuccess Method was successful
  • MS::kFailure Object or parameter error
bool isLayerVisible ( int  layerId,
MStatus stat = NULL 
)

Return whether the given layer is visible.

Parameters
[in]layerIdId of the layer to be made visible or invisible
[out]statStatus code
Returns
True if the specified layer is visible, false otherwise
int registerDrawUICallback ( int  layerId,
MDrawUIFunction  cb,
void *  clientData = NULL,
MStatus stat = NULL 
)

Register a callback to be called when the given panel is drawing the given layer.

An id to the callback is returned.

Parameters
[in]layerIdId of the layer to be made visible or invisible
[in]cbCallback function to be registerd
[in]cliendDataData to be passed to callback when it is invoked
[out]statStatus code
Returns
Id associated with the registered callback
void unregisterDrawUICallback ( int  callbackId,
MStatus stat = NULL 
)

Unregister the callback specified by the given id.

Parameters
[in]callbackIdId of the callback being removed
[out]statStatus code

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