MUIDrawManager Class Reference

#include <MUIDrawManager.h>

Class Description

Main interface for drawing basic UI drawables in Viewport 2.0 and Hardware Renderer 2.0.

The MUIDrawManager class provides a straight forward way to draw basic UI drawables like lines, icons, texts and other basic 2D/3D primitives.

MUIDrawManager is not designed for accessing at arbitrary time or arbitrary places. Access to the interface is restricted to certain methods on various API interfaces. An instance of MUIDrawManager is constructed and passed to these methods together with any required data and context information.

All drawing operations, including setting state like color and font size, must occur between calls to beginDrawable() and endDrawable(). For example, to draw a pair of red lines you would do the following:

MColor red(1.0f, 0.0f, 0.0f);
painter.beginDrawable();
painter.setColor( red );
painter.line( MPoint(0, 0, 0), MPoint(1, 1, 1) );
painter.line( MPoint(0, 0, 0), MPoint(-1, -1, 5) );
painter.endDrawable();

The call to endDrawable() resets the draw state, so if you want to continue drawing in red later on you would have to repeat the call to setColor().

painter.beginDrawable();
painter.setColor( red );
painter.text( MPoint(0, 0, 4), "Hello, world!" );
painter.endDrawable();

Note that draw operations may not take place immediately but instead be queued up for later execution during the draw phase.

To reduce draw overhead due to the small batch problem, Viewport 2.0 may batch the same type of UI drawables created by the same instance of MUIDrawManager, where the type means a combination of primitive type, internal shader, space dimension (2D/3D) and selection support. Some types are ineligible to be batched, e.g. line/triangle strip, textured drawing.

+ Examples:

Public Types

enum  FontSize { kDefaultFontSize = 12, kSmallFontSize = 9 }
 Font size for drawing the text. More...
 
enum  TextAlignment { kLeft, kCenter, kRight }
 Text alignment. More...
 
enum  TextIncline { kInclineNormal = 0, kInclineItalic = 1, kInclineOblique = 2 }
 Text incline. More...
 
enum  TextWeight {
  kWeightLight = 25, kWeightNormal = 50, kWeightDemiBold = 63, kWeightBold = 75,
  kWeightBlack = 87
}
 Text weight. More...
 
enum  TextStretch {
  kStretchUltraCondensed = 50, kStretchExtraCondensed = 62, kStretchCondensed = 75, kStretchSemiCondensed = 87,
  kStretchUnstretched = 100, kStretchSemiExpanded = 112, kStretchExpanded = 125, kStretchExtraExpanded = 150,
  kStretchUltraExpanded = 200
}
 Text stretch. More...
 
enum  TextLine { kLineNone, kLineOverline, kLineUnderline, kLineStrikeoutLine }
 Text line. More...
 
enum  LineStyle {
  kSolid, kShortDotted, kShortDashed, kDashed,
  kDotted
}
 Line style. More...
 
enum  PaintStyle { kFlat, kStippled, kShaded }
 Paint style. More...
 
enum  Primitive {
  kPoints, kLines, kLineStrip, kClosedLine,
  kTriangles, kTriStrip
}
 Primitive. More...
 
enum  Selectability { kNonSelectable, kSelectable, kAutomatic }
 Selectability. More...
 

Public Member Functions

void beginDrawable (Selectability selectability=kAutomatic, unsigned int selectionName=0)
 Resets all draw state, such as color and line style, to defaults and indicates the start of a sequence of drawing operations. More...
 
void beginDrawable (unsigned int name, bool nameIsPickable)
 obsolete, please use the one with selectability and selection name parameters More...
 
void endDrawable ()
 Indicates the end of a sequence of drawing operations. More...
 
void beginDrawInXray ()
 The drawables to be drawn between calls to beginDrawInXray() and endDrawInXray() will display on the top of other geometries in the scene, as the depth test is disabled for these drawables. More...
 
void endDrawInXray ()
 Pair with "MUIDrawManager::beginDrawInXray()".
 
void setColor (const MColor &color)
 Set the draw color. More...
 
void setColorIndex (const short index)
 Set the color index for the later primitive and text drawing. More...
 
void setPointSize (float value)
 Set the point size for the point drawing. More...
 
void setLineWidth (float value)
 Set the line width for the primitive drawing (line, rect, box...) More...
 
void setLineStyle (LineStyle style)
 Set the line style for the primitive drawing (line, rect, box...) More...
 
void setLineStyle (unsigned int factor, unsigned short pattern)
 Set the dashed line pattern for the primitive drawing (line, rect, box...) More...
 
void setPaintStyle (PaintStyle style)
 Set the paint style for filled primitive drawing. More...
 
unsigned int depthPriority () const
 Get the current depth priority value for primitive drawing. More...
 
void setDepthPriority (unsigned int priority)
 Set the depth priority for primitive drawing. More...
 
void line (const MPoint &startPoint, const MPoint &endPoint)
 Draw a straight line between two points. More...
 
void line2d (const MPoint &startPoint, const MPoint &endPoint)
 Draw a straight line between two points. More...
 
MStatus lineList (const MPointArray &points, bool draw2D)
 Draw a series of line segments in 3D or 2D. More...
 
MStatus lineStrip (const MPointArray &points, bool draw2D)
 Draw a series of connected line segments in 3D or 2D. More...
 
void point (const MPoint &point)
 Draw a point. More...
 
void point2d (const MPoint &point)
 Draw a point. More...
 
MStatus points (const MPointArray &points, bool draw2D)
 Draw a series of points in 3D or 2D. More...
 
void rect (const MPoint &center, const MVector &up, const MVector &normal, double scaleX, double scaleY, bool filled=false)
 Draw a rectangle. More...
 
void rect2d (const MPoint &center, const MVector &up, double scaleX, double scaleY, bool filled=false)
 Draw a 2D rectangle on the screen. More...
 
void sphere (const MPoint &center, double radius, bool filled=false)
 Draw a sphere. More...
 
void circle (const MPoint &center, const MVector &normal, double radius, bool filled=false)
 Draw a circle. More...
 
void circle2d (const MPoint &center, double radius, bool filled=false)
 Draw a 2D circle on the screen. More...
 
void arc (const MPoint &center, const MVector &start, const MVector &end, const MVector &normal, double radius, bool filled=false)
 Draw an arc. More...
 
void arc2d (const MPoint &center, const MVector &start, const MVector &end, double radius, bool filled=false)
 Draw a 2D arc on the screen. More...
 
void mesh (Primitive mode, const MPointArray &position, const MVectorArray *normal=NULL, const MColorArray *color=NULL, const MUintArray *index=NULL, const MPointArray *texcoord=NULL)
 Draw custom geometric shapes from an array of vertices. More...
 
void mesh2d (Primitive mode, const MPointArray &position, const MColorArray *color=NULL, const MUintArray *index=NULL, const MPointArray *texcoord=NULL)
 Draw custom 2d geometric shapes from an array of vertices. More...
 
void cone (const MPoint &base, const MVector &direction, double radius, double height, bool filled=false)
 Draw a cone. More...
 
void box (const MPoint &center, const MVector &up, const MVector &right, double scaleX=1.0, double scaleY=1.0, double scaleZ=1.0, bool filled=false)
 Draw a box. More...
 
void setFontIncline (const int fontIncline)
 Set the incline of font to be used when drawing text. More...
 
void setFontWeight (const int fontWeight)
 Set the weight of font to be used when drawing text. More...
 
void setFontStretch (const int fontStretch)
 Set the stretch of font to be used when drawing text. More...
 
void setFontLine (const int fontLine)
 Set the line of font to be used when drawing text. More...
 
void setFontSize (const unsigned int fontSize)
 Set the size of font to be used when drawing text. More...
 
void setFontName (const MString &faceName)
 Set the face name of font to be used when drawing text. More...
 
void text (const MPoint &position, const MString &text, TextAlignment alignment=kLeft, const int *backgroundSize=NULL, const MColor *backgroundColor=NULL, bool dynamic=false)
 Draw a screen facing and horizontal aligned text in viewport 2.0. More...
 
void text2d (const MPoint &position, const MString &text, TextAlignment alignment=kLeft, const int *backgroundSize=NULL, const MColor *backgroundColor=NULL, bool dynamic=false)
 Draw a text on the screen. More...
 
void setTexture (MHWRender::MTexture *texture)
 Set the active texture to apply when drawing a mesh. More...
 
MStatus setTextureSampler (MHWRender::MSamplerState::TextureFilter filter, MHWRender::MSamplerState::TextureAddress address)
 Set the filter and address mode used when applying a texture to a mesh. More...
 
MStatus setTextureMask (MHWRender::MBlendState::ChannelMask mask)
 Set the channel mask to used when applying a texture to a mesh. More...
 
MStatus icon (const MPoint &position, const MString &name, float scale)
 Draw an icon at a given 3d position. More...
 

Static Public Member Functions

static unsigned int getFontList (MStringArray &list)
 Get the names of all font faces that are available on current system. More...
 
static unsigned int getIconNames (MStringArray &names)
 Get list of icon names. More...
 

Member Enumeration Documentation

enum FontSize

Font size for drawing the text.

Enumerator
kDefaultFontSize 

Default font, pixel size 12 in height.

kSmallFontSize 

Small font, pixel size 9 in height.

Text alignment.

Enumerator
kLeft 

Text aligned to the left of the background box.

kCenter 

Text aligned at the middle of the background box.

kRight 

Text aligned to the right of the background box.

Text incline.

Most of the font families support well for incline normal and italic. Oblique incline is not supported for most of the font families.

Enumerator
kInclineNormal 

Normal glyphs used in unstyled text.

kInclineItalic 

Italic glyphs that are specifically designed for the purpose of representing italicized text.

kInclineOblique 

Glyphs with an italic appearance that are typically based on the unstyled glyphs.

enum TextWeight

Text weight.

Most of the font families support well for weight light and bold. Weight normal/demibold/black is not supported for most of the font families.

Enumerator
kWeightLight 

Text with light weight.

kWeightNormal 

Text with normal weight.

kWeightDemiBold 

Text with demi bold weight.

kWeightBold 

Text with bold weight.

kWeightBlack 

Text with black weight.

Text stretch.

Enumerator
kStretchUltraCondensed 

Text with ultra condensed stretch.

kStretchExtraCondensed 

Text with extra condensed stretch.

kStretchCondensed 

Text with condensed stretch.

kStretchSemiCondensed 

Text with semi condensed stretch.

kStretchUnstretched 

Text with unstretched stretch.

kStretchSemiExpanded 

Text with semi expanded stretch.

kStretchExpanded 

Text with expanded stretch.

kStretchExtraExpanded 

Text with extra expanded stretch.

kStretchUltraExpanded 

Text with ultra expanded stretch.

enum TextLine

Text line.

Enumerator
kLineNone 

Font with no line.

kLineOverline 

Font with overline.

kLineUnderline 

Font with underline.

kLineStrikeoutLine 

Font with strike out line.

enum LineStyle

Line style.

Enumerator
kSolid 

Solid line.

kShortDotted 

Short Dotted line.

kShortDashed 

Short dashed line.

kDashed 

Dashed line.

kDotted 

Dotted line.

enum PaintStyle

Paint style.

Enumerator
kFlat 

Solid.

kStippled 

Stippled.

kShaded 

Shaded with lighting.

enum Primitive

Primitive.

Enumerator
kPoints 

Point list.

kLines 

Line list.

kLineStrip 

Line strip.

kClosedLine 

Closed line.

kTriangles 

Triangle list.

kTriStrip 

Triangle strip.

Selectability.

Enumerator
kNonSelectable 

Geometries cannot be used for selection.

kSelectable 

Use geometries for selection.

kAutomatic 

Use geometries for selection when not in manipulator context.

Member Function Documentation

void beginDrawable ( Selectability  selectability = kAutomatic,
unsigned int  selectionName = 0 
)

Resets all draw state, such as color and line style, to defaults and indicates the start of a sequence of drawing operations.

All drawing operations must take place between calls to beginDrawable() and endDrawable().

Locators are by default selectable with the default kAutomatic parameter. Please specify kNonSelectable to mark it non-selectable. The second parameter is not relevant to locators.

Manipulators are by default non-selectable with the default kAutomatic parameter. Please specify kSelectable, and provide a selection name (an unsigned int) for it to be selectable. This name can be used with MPxManipulatorNode::glActiveName() and is device independent. The name is only used for selection and will be ignored in the regular draw pass.

// Locator
painter.beginDrawable();
painter.line( MPoint(0,0,0), MPoint(1,1,1) );
painter.line( MPoint(0,0,0), MPoint( -1, -1, 11) );
painter.endDrawable();
// Manipulator
MGLuint selectionName;
glFirstHandle( selectionName );
painter.beginDrawable( MHWRender::kSelectable, selectionName );
painter.line( MPoint(0,0,0), MPoint(1,1,1) );
painter.line( MPoint(0,0,0), MPoint( -1, -1, 11) );
painter.endDrawable();
Parameters
[in]selectabilityWhether this drawable is selectable. Note the default value kAutomatic has different meaning for locators and manipulators.
[in]selectionNameUnique name (an unsigned int) of the component. This parameter is only relevant for manipulators.
+ Examples:
void beginDrawable ( unsigned int  name,
bool  nameIsPickable 
)

obsolete, please use the one with selectability and selection name parameters

This method is obsolete.

Deprecated:

For manipulator drawing: resets all draw state, such as color and line style, to defaults and indicates the start of a sequence of drawing operations for the specified manipulator handle name. All drawing operations must take place between calls to beginDrawable() and endDrawable(). This name can be used with MPxManipulatorNode::glActiveName() and is device independant. The name is only used for selection and will be ignored in the regular draw pass.

MGLuint glPickableItem;
glFirstHandle( glPickableItem );
painter.beginDrawable( glPickableItem, true );
painter.line( MPoint(0,0,0), MPoint(1,1,1) );
painter.line( MPoint(0,0,0), MPoint( -1, -1, 11) );
painter.endDrawable();
Parameters
[in]nameUnique name (an unsigned int) of the component.
[in]nameIsPickableIf true, the component will be pickable
void beginDrawInXray ( )

The drawables to be drawn between calls to beginDrawInXray() and endDrawInXray() will display on the top of other geometries in the scene, as the depth test is disabled for these drawables.

These methods can be used to draw objects such as locators.

Limitations: Only the drawables meeting the following conditions will be affected by beginDrawInXray() and endDrawInXray(). 1. Created by the method "MUIDrawManager::mesh()"; 2. The first input parameter (primitive type) for "MUIDrawManager::mesh()" is one of "kTriangles", "kLines" and "kPoints". Any other drawables to be drawn between calls to beginDrawInXray() and endDrawInXray() will display as normal.

painter.beginDrawInXray();
painter.mesh(MHWRender::MUIDrawManager::kTriangles, ...); // assume this is geometry A
painter.mesh(MHWRender::MUIDrawManager::kLines, ...); // assume this is geometry B
painter.mesh(MHWRender::MUIDrawManager::kPoints, ...); // assume this is geometry C
painter.endDrawInXray();
painter.text(...); // assume this is text D

If several meshes are drawn between these two APIs, their draw order is reversed to the mesh() function call order. For example, in the above sample code: C will be drawn on top of B; B on top of A. If text calls are made after these two APIs, the text will be drawn on top. In above sample code: text D will be drawn on top of C.

+ Examples:
void setColorIndex ( const short  index)

Set the color index for the later primitive and text drawing.

For default, it will use (0.7, 0.7, 0.7, 1) as default color.

Parameters
[in]indexColor index
+ Examples:
void setPointSize ( float  value)

Set the point size for the point drawing.

Parameters
[in]valuePoint size in pixels.
+ Examples:
void setLineWidth ( float  value)

Set the line width for the primitive drawing (line, rect, box...)

Parameters
[in]valueLine width in pixels.
+ Examples:
void setLineStyle ( LineStyle  style)

Set the line style for the primitive drawing (line, rect, box...)

Parameters
[in]styleLine style type.
+ Examples:
void setLineStyle ( unsigned int  factor,
unsigned short  pattern 
)

Set the dashed line pattern for the primitive drawing (line, rect, box...)

Parameters
[in]factora multiplier for each bit in the line stipple pattern.
[in]patterna pattern determines which fragments of a line will be drawn
void setPaintStyle ( PaintStyle  style)

Set the paint style for filled primitive drawing.

Parameters
[in]stylePaint style type.
+ Examples:
unsigned int depthPriority ( ) const

Get the current depth priority value for primitive drawing.

If the method failed to execute a value of 0 will be returned.

Returns
Depth priority
void setDepthPriority ( unsigned int  priority)

Set the depth priority for primitive drawing.

The MRenderItem class lists some sample internal priorities which may be used.

Parameters
[in]priorityDepth priority.
+ Examples:
void line2d ( const MPoint startPoint,
const MPoint endPoint 
)

Draw a straight line between two points.

Parameters
[in]startPointThe start point of the line, only x-y components(in pixels) are used.
[in]endPointThe end point of the line, only x-y components(in pixels) are used.
+ Examples:
MStatus lineList ( const MPointArray points,
bool  draw2D 
)

Draw a series of line segments in 3D or 2D.

Parameters
[in]pointsArray of point positions. Pairs of points are interpreted as line segments. If an odd number of points is specified then the last point will not be drawn, as it does not form a line segment.
[in]draw2DDraw in 2D or 3D.
Returns
Status Code
Status Codes:
+ Examples:
MStatus lineStrip ( const MPointArray points,
bool  draw2D 
)

Draw a series of connected line segments in 3D or 2D.

Parameters
[in]pointsArray of point positions. Each point in the array is connected to form a line strip.
[in]draw2DDraw in 2D or 3D.
Returns
Status Code
Status Codes:
+ Examples:
void point ( const MPoint point)

Draw a point.

Parameters
[in]pointPosition of the point.
void point2d ( const MPoint point)

Draw a point.

Parameters
[in]pointPosition of the point, only x-y components(in pixels) are used.
MStatus points ( const MPointArray points,
bool  draw2D 
)

Draw a series of points in 3D or 2D.

Parameters
[in]pointsArray of point positions.
[in]draw2DDraw in 2D or 3D.
Returns
Status Code
Status Codes:
+ Examples:
void rect ( const MPoint center,
const MVector up,
const MVector normal,
double  scaleX,
double  scaleY,
bool  filled = false 
)

Draw a rectangle.

The rectangle is within the plane determined by a normal vector, and a up vector is given to determine the X-Y direction.

Parameters
[in]centerCenter of the rectangle
[in]upUp vector of the rectangle
[in]normalNormal vector of the rectangle plane
[in]scaleXScale factor in X-direction
[in]scaleYScale factor in Y-direction
[in]filledIf true the rectangle will be filled otherwise it will just be drawn as an outline.
+ Examples:
void rect2d ( const MPoint center,
const MVector up,
double  scaleX,
double  scaleY,
bool  filled = false 
)

Draw a 2D rectangle on the screen.

The rectangle is always facing the camera, and a up vector is given to determine the X-Y direction.

Parameters
[in]centerCenter of the rectangle, only x-y components(in pixels) are used.
[in]upUp vector of the rectangle, only x-y components are used.
[in]scaleXScale factor in X-direction
[in]scaleYScale factor in Y-direction
[in]filledIf true the rectangle will be filled otherwise it will just be drawn as an outline.
+ Examples:
void sphere ( const MPoint center,
double  radius,
bool  filled = false 
)

Draw a sphere.

Parameters
[in]centerCenter of the sphere.
[in]radiusRadius of the sphere.
[in]filledIf true the sphere will be filled otherwise it will just be drawn as a wireframe.
+ Examples:
void circle ( const MPoint center,
const MVector normal,
double  radius,
bool  filled = false 
)

Draw a circle.

The circle is drawn within the plane determined by a normal vector.

Parameters
[in]centerCenter of the circle
[in]normalNormal vector of the circle plane
[in]radiusRadius of the circle
[in]filledIf true the circle will be filled otherwise it will just be drawn as an outline.
+ Examples:
void circle2d ( const MPoint center,
double  radius,
bool  filled = false 
)

Draw a 2D circle on the screen.

The circle is always facing the camera.

Parameters
[in]centerCenter of the circle, only x-y components(in pixels) are used.
[in]radiusRadius(in pixels) of the circle
[in]filledIf true the circle will be filled otherwise it will just be drawn as an outline.
+ Examples:
void arc ( const MPoint center,
const MVector start,
const MVector end,
const MVector normal,
double  radius,
bool  filled = false 
)

Draw an arc.

The arc is within the plane determined by a normal vector. The arc sweeps in CCW from the vector that is the projection of the given start vector onto the arc plane, and ends at the vector that is the projection of the given end vector onto the arc plane.

Parameters
[in]centerCenter of the arc
[in]startStart vector, its projection onto the arc plane is the start of the arc.
[in]endEnd vector, its projection onto the arc plane is the end of the arc.
[in]normalNormal vector of the arc plane.
[in]radiusRadius of the arc.
[in]filledIf true the arc will be filled otherwise it will just be drawn as an outline.
+ Examples:
void arc2d ( const MPoint center,
const MVector start,
const MVector end,
double  radius,
bool  filled = false 
)

Draw a 2D arc on the screen.

The arc is always facing the camera. The arc sweeps in CCW from the start vector and ends at the end vector.

Parameters
[in]centerCenter of the arc, only x-y components(in pixels) are used
[in]startStart vector, only x-y components are used.
[in]endEnd vector, only x-y components are used.
[in]radiusRadius(in pixels) of the arc.
[in]filledIf true the arc will be filled otherwise it will just be drawn as an outline.
+ Examples:
void mesh ( Primitive  mode,
const MPointArray position,
const MVectorArray normal = NULL,
const MColorArray color = NULL,
const MUintArray index = NULL,
const MPointArray texcoord = NULL 
)

Draw custom geometric shapes from an array of vertices.

If the optional normal or color arrays are provided they must contain a single value per element of the positions array (i.e. all three arrays must be the same length).

The optional index array specifies the order in which the vertex positions (and their corresponding normals and colors) should be drawn. Vertices can be reused by having their indices appear multiple times, so the index array may be longer (or shorter) than the other three arrays.

If the index array is not provided then the vertices will be drawn in the order in which they appear in the positions array.

Parameters
[in]modePrimitive mode, e.g., point list, line list, etc.
[in]positionList of the vertex positions.
[in]normalList of the vertex normals.
[in]colorList of the vertex colors.
[in]indexList of the vertex indices.
[in]texcoordList of the vertex texture coordinates.
+ Examples:
void mesh2d ( Primitive  mode,
const MPointArray position,
const MColorArray color = NULL,
const MUintArray index = NULL,
const MPointArray texcoord = NULL 
)

Draw custom 2d geometric shapes from an array of vertices.

If the optional color arrays are provided they must contain a single value per element of the positions array (i.e. both arrays must be the same length).

The optional index array specifies the order in which the vertex positions (and their corresponding colors) should be drawn. Vertices can be reused by having their indices appear multiple times, so the index array may be longer (or shorter) than the other two arrays.

If the index array is not provided then the vertices will be drawn in the order in which they appear in the positions array.

Parameters
[in]modePrimitive mode, e.g., point list, line list, etc.
[in]positionList of the vertex positions, only x-y components of the point are used.
[in]colorList of the vertex colors.
[in]indexList of the vertex indices.
[in]texcoordList of the vertex texture coordinates.
+ Examples:
void cone ( const MPoint base,
const MVector direction,
double  radius,
double  height,
bool  filled = false 
)

Draw a cone.

Parameters
[in]baseBase position for the cone
[in]directionThe cone's tip will point in this direction.
[in]radiusRadius of the cone
[in]heightHeight of the cone
[in]filledIf true the cone will be filled otherwise it will just be drawn as an outline.
+ Examples:
void box ( const MPoint center,
const MVector up,
const MVector right,
double  scaleX = 1.0,
double  scaleY = 1.0,
double  scaleZ = 1.0,
bool  filled = false 
)

Draw a box.

Parameters
[in]centerCenter position for the box
[in]upThe top of the box will be facing this direction.
[in]rightThe side of the box will be facing this direction.
[in]scaleXX size of the box
[in]scaleYY size of the box
[in]scaleZZ size of the box
[in]filledIf true the box will be filled otherwise it will just be drawn as an outline.
+ Examples:
unsigned int getFontList ( MStringArray list)
static

Get the names of all font faces that are available on current system.

The names can then be used for MUIDrawManager::setFontName().

Parameters
[out]listThe list to populate font names
Returns
Number of fonts that are available on current system
void setFontIncline ( const int  fontIncline)

Set the incline of font to be used when drawing text.

Parameters
[in]fontInclineThe font incline to use.
+ Examples:
void setFontWeight ( const int  fontWeight)

Set the weight of font to be used when drawing text.

Parameters
[in]fontWeightThe font weight to use.
+ Examples:
void setFontStretch ( const int  fontStretch)

Set the stretch of font to be used when drawing text.

Parameters
[in]fontStretchThe font stretch to use.
+ Examples:
void setFontLine ( const int  fontLine)

Set the line of font to be used when drawing text.

Parameters
[in]fontLineThe font line to use.
+ Examples:
void setFontName ( const MString faceName)

Set the face name of font to be used when drawing text.

Parameters
[in]faceNameThe font face name(case-insensitive) to use, All system font faces are supported. "helvetica" is the default for invalid input.
+ Examples:
void text ( const MPoint position,
const MString text,
TextAlignment  alignment = kLeft,
const int *  backgroundSize = NULL,
const MColor backgroundColor = NULL,
bool  dynamic = false 
)

Draw a screen facing and horizontal aligned text in viewport 2.0.

It has a fixed size in screen space.

Parameters
[in]positionPosition of the text to be drawn, it is 3d object space.
[in]textContent of the text string.
[in]alignmentAlignment of the text. "kLeft", background box's left bottom will be located at "position". In width direction, text area will be aligned to the left side of background. In height direction, text are will be aligned in the middle of background.

"kCenter", background box' center bottom will be located at "position". text area's center and background box's center will be the same point.

"kRight", background box's right bottom will be located at "position". In width direction, text area will be aligned to the right side of background. In height direction, text are will be aligned in the middle of background.

Parameters
[in]backgroundSizeThe background box size of the text. Default is NULL, in this case there will be no background, just shows the text. If it is specified with smaller size than text, the text will be clipped. It is a int array with size 2, like "int backgroundSize[] = { width, height } " Size unit is the screen pixel.
[in]backgroundColorThe color of the background, it can be transparent. If NULL is passed, background will be fully transparent.
[in]dynamicThis is mostly used for performance. If the text draw is not changed frequently, we can leave it as default value false. If the text draw is changing very often like it is showing some dynamic numbers, in this case making dynamic true will give better performance.
+ Examples:
void text2d ( const MPoint position,
const MString text,
TextAlignment  alignment = kLeft,
const int *  backgroundSize = NULL,
const MColor backgroundColor = NULL,
bool  dynamic = false 
)

Draw a text on the screen.

Parameters
[in]positionPosition of the text to be drawn, it is in screen space, only x-y components are used.
[in]textContent of the text string.
[in]alignmentAlignment of the text. "kLeft", background box's left bottom will be located at "position". In width direction, text area will be aligned to the left side of background. In height direction, text are will be aligned in the middle of background.

"kCenter", background box' center bottom will be located at "position". text area's center and background box's center will be the same point.

"kRight", background box's right bottom will be located at "position". In width direction, text area will be aligned to the right side of background. In height direction, text are will be aligned in the middle of background.

Parameters
[in]backgroundSizeThe background box size(in pixels) of the text. Default is NULL, in this case there will be no background, just shows the text. If it is specified with smaller size than text, the text will be clipped. It is a int array with size 2, like "int backgroundSize[] = { width, height } " Size unit is the screen pixel.
[in]backgroundColorThe color of the background, it can be transparent. If NULL is passed, background will be fully transparent.
[in]dynamicThis is mostly used for performance. If the text draw is not changed frequently, we can leave it as default value false. If the text draw is changing very often like it is showing some dynamic numbers, in this case making dynamic true will give better performance.
+ Examples:
void setTexture ( MHWRender::MTexture texture)

Set the active texture to apply when drawing a mesh.

This will remain in effect until the next call to setTexture();

Parameters
[in]textureThe texture which will affect the later drawing
+ Examples:

Set the filter and address mode used when applying a texture to a mesh.

This will remain in effect until the next call to setTextureSampler();

Parameters
[in]filterThe filter which will affect the later drawing. Currently, only kMinMagMipPoint and kMinMagMipLinear are supported.
[in]addressThe canonical range which will affect the later drawing. Currently, only kTexWrap and kTexClamp are supported.
Returns
kInvalidParameter when filter and address combination is not supported.
+ Examples:
MStatus setTextureMask ( MHWRender::MBlendState::ChannelMask  mask)

Set the channel mask to used when applying a texture to a mesh.

This will remain in effect until the next call to setTextureMask();

Parameters
[in]maskThe channel mask which will affect the later drawing. Currently, only kRGBAChannels, kRGBChannels and kAlphaChannel are supported.
Returns
kInvalidParameter when mask is not supported.
+ Examples:
MStatus icon ( const MPoint position,
const MString name,
float  scale 
)

Draw an icon at a given 3d position.

Parameters
[in]position3d location of the icon.
[in]nameThe name of an icon. The list of available icon names can be found using the MUIDrawManager::getIconNames() method.
[in]scaleUniform scaling factor for the icon
Returns
Status Code
Status Codes:
  • MS::kSuccess Method was successful
  • MS::KFailure The icon item could not be drawn.
+ Examples:
unsigned int getIconNames ( MStringArray names)
static

Get list of icon names.

The names can be used for drawing icons using the MUIDrawManager::icon() method.

Parameters
[out]namesList of icon names
Returns
Number of available icons

The documentation for this class was generated from the following files:
  • MUIDrawManager.h
  • MUIDrawManager.cpp