- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Examples

- Class List
- Class Hierarchy
- Class Members

Public Types | Public Member Functions

# MUIDrawManager Class Reference
OpenMayaRender - API module for rendering

This reference page is linked to from the following overview topics: Autodesk Maya 2014, 3.9 UI draw manager, 4.5 Handling custom renderables for object overrides.

Search for all occurrences

## Detailed Description

Main interface for drawing simple geometry in Viewport 2.0 and Maya Hardware Renderer 2.0.

Simple geometry includes things like lines and text.

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 wanted to continue drawing in red later on you would have to repeat the call to setColor(). E.g:

            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.

Examples:

  footPrintManip.cpp, footPrintNode.cpp, lineManip.cpp, lineManip.h, marqueeTool.cpp, and swissArmyManip.cpp.

`#include <MUIDrawManager.h>`

List of all members.

## Public Types
enum | FontSize { kDefaultFontSize, kSmallFontSize }
| Font size for drawing the text. More...
enum | TextAlignment { kLeft, kCenter, kRight }
| Text alignment. More...
enum | LineStyle { kSolid, kShortDotted, kShortDashed, kDashed, kDotted }
| Line style. More...
enum | PaintStyle { kFlat, kStippled }
| Paint style. More...
enum | Primitive { kPoints, kLines, kLineStrip, kClosedLine, kTriangles, kTriStrip }
| Primitive. More...
## Public Member Functions
void | beginDrawable ()
| Resets all draw state, such as color and line style, to defaults and indicates the start of a sequence of drawing operations.
void | endDrawable ()
| Indicates the end of a sequence of drawing operations.
void | setColor (const MColor &color)
| Set the draw color.
void | setColorIndex (const short index)
| Set the color index for the later primitive and text drawing.
void | setPointSize (float value)
| Set the point size for the point drawing.
void | setLineWidth (float value)
| Set the line width for the primitive drawing (line, rect, box...)
void | setLineStyle (LineStyle style)
| Set the line style for the primitive drawing (line, rect, box...)
void | setLineStyle (unsigned int factor, unsigned short pattern)
| Set the dashed line pattern for the primitive drawing (line, rect, box...)
void | setPaintStyle (PaintStyle style)
| Set the paint style for filled primitive drawing.
void | line (const MPoint &startPoint, const MPoint &endPoint)
| Draw a straight line between two points.
void | line2d (const MPoint &startPoint, const MPoint &endPoint)
| Draw a straight line between two points.
void | point (const MPoint &point)
| Draw a point.
void | point2d (const MPoint &point)
| Draw a point.
void | rect (const MPoint &center, const MVector &up, const MVector &normal, double scaleX, double scaleY, bool filled=false)
| Draw a rectangle.
void | rect2d (const MPoint &center, const MVector &up, double scaleX, double scaleY, bool filled=false)
| Draw a 2D rectangle on the screen.
void | sphere (const MPoint &center, double radius, bool filled=false)
| Draw a sphere.
void | circle (const MPoint &center, const MVector &normal, double radius, bool filled=false)
| Draw a circle.
void | circle2d (const MPoint &center, double radius, bool filled=false)
| Draw a 2D circle on the screen.
void | arc (const MPoint &center, const MVector &start, const MVector &end, const MVector &normal, double radius, bool filled=false)
| Draw an arc.
void | arc2d (const MPoint &center, const MVector &start, const MVector &end, double radius, bool filled=false)
| Draw a 2D arc on the screen.
void | mesh (Primitive mode, const MPointArray &position, const MVectorArray *normal=NULL, const MColorArray *color=NULL, const MUintArray *index=NULL)
| Draw custom geometric shapes from an array of vertices.
void | mesh2d (Primitive mode, const MPointArray &position, const MColorArray *color=NULL, const MUintArray *index=NULL)
| Draw custom 2d geometric shapes from an array of vertices.
void | cone (const MPoint &base, const MVector &direction, double radius, double height, bool filled=false)
| Draw a cone.
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.
void | setFontSize (FontSize fontSize)
| Set the size of font to be used when drawing text.
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.
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.

## Member Enumeration Documentation

enum FontSize

Search for all occurrences

Font size for drawing the text.

Enumerator:

  kDefaultFontSize | Search for all occurrences
  kSmallFontSize | Search for all occurrences

enum TextAlignment

Search for all occurrences

Text alignment.

Enumerator:

  kLeft | Search for all occurrences
  kCenter | Search for all occurrences
  kRight | Search for all occurrences

enum LineStyle

Search for all occurrences

Line style.

Enumerator:

  kSolid | Search for all occurrences
  kShortDotted | Search for all occurrences
  kShortDashed | Search for all occurrences
  kDashed | Search for all occurrences
  kDotted | Search for all occurrences

enum PaintStyle

Search for all occurrences

Paint style.

Enumerator:

  kFlat | Search for all occurrences
  kStippled | Search for all occurrences

enum Primitive

Search for all occurrences

Primitive.

Enumerator:

  kPoints | Search for all occurrences
  kLines | Search for all occurrences
  kLineStrip | Search for all occurrences
  kClosedLine | Search for all occurrences
  kTriangles | Search for all occurrences
  kTriStrip | Search for all occurrences

## Member Function Documentation

void beginDrawable | ( |  | ) |

Search for all occurrences

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().

                painter.beginDrawable();
                painter.line( MPoint(0,0,0), MPoint(1,1,1) );
                painter.line( MPoint(0,0,0), MPoint( -1, -1, 11) );
                painter.endDrawable();

Examples:
  footPrintManip.cpp, footPrintNode.cpp, lineManip.cpp, marqueeTool.cpp, and swissArmyManip.cpp.

void endDrawable | ( |  | ) |

Search for all occurrences

Indicates the end of a sequence of drawing operations.

All internal drawing state, such as color and line style, are reset to defaults.

Examples:
  footPrintManip.cpp, footPrintNode.cpp, lineManip.cpp, marqueeTool.cpp, and swissArmyManip.cpp.

void setColor | ( | const MColor & | color | ) |

Search for all occurrences

Set the draw color.

This will remain in effect until the next call to setColor(), setColorIndex() or endDrawable().

For text this color will be used as the foreground color. Background color can be specified directly in the call to text().

Default: (0.7, 0.7, 0.7, 1)

Parameters:

  [in] | color | The color which will affect the later drawing

Examples:
  footPrintManip.cpp, footPrintNode.cpp, marqueeTool.cpp, and swissArmyManip.cpp.

void setColorIndex | ( | const short | index | ) |

Search for all occurrences

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] | index | Color index

Examples:
  lineManip.cpp.

void setPointSize | ( | float | value | ) |

Search for all occurrences

Set the point size for the point drawing.

Parameters:

  [in] | value | Point size in pixels.

void setLineWidth | ( | float | value | ) |

Search for all occurrences

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

Parameters:

  [in] | value | Line width in pixels.

void setLineStyle | ( | LineStyle | style | ) |

Search for all occurrences

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

Parameters:

  [in] | style | Line style type.

void setLineStyle | ( | unsigned int | factor,
|  | unsigned short | pattern
| ) |  |

Search for all occurrences

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

Parameters:

  [in] | factor | a multiplier for each bit in the line stipple pattern.
  [in] | pattern | a pattern determines which fragments of a line will be drawn

void setPaintStyle | ( | PaintStyle | style | ) |

Search for all occurrences

Set the paint style for filled primitive drawing.

Parameters:

  [in] | style | Paint style type.

void line | ( | const MPoint & | startPoint,
|  | const MPoint & | endPoint
| ) |  |

Search for all occurrences

Draw a straight line between two points.

Parameters:

  [in] | startPoint | The start point of the line.
  [in] | endPoint | The end point of the line.

Examples:
  lineManip.cpp, and marqueeTool.cpp.

void line2d | ( | const MPoint & | startPoint,
|  | const MPoint & | endPoint
| ) |  |

Search for all occurrences

Draw a straight line between two points.

Parameters:

  [in] | startPoint | The start point of the line, only x-y components(in pixels) are used.
  [in] | endPoint | The end point of the line, only x-y components(in pixels) are used.

void point | ( | const MPoint & | point | ) |

Search for all occurrences

Draw a point.

Parameters:

  [in] | point | Position of the point.

void point2d | ( | const MPoint & | point | ) |

Search for all occurrences

Draw a point.

Parameters:

  [in] | point | Position of the point, only x-y components(in pixels) are used.

void rect | ( | const MPoint & | center,
|  | const MVector & | up,
|  | const MVector & | normal,
|  | double | scaleX,
|  | double | scaleY,
|  | bool | filled = `false`
| ) |  |

Search for all occurrences

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] | center | Center of the rectangle
  [in] | up | Up vector of the rectangle
  [in] | normal | Normal vector of the rectangle plane
  [in] | scaleX | Scale factor in X-direction
  [in] | scaleY | Scale factor in Y-direction
  [in] | filled | If true the rectangle will be filled otherwise it will just be drawn as an outline.

void rect2d | ( | const MPoint & | center,
|  | const MVector & | up,
|  | double | scaleX,
|  | double | scaleY,
|  | bool | filled = `false`
| ) |  |

Search for all occurrences

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] | center | Center of the rectangle, only x-y components(in pixels) are used.
  [in] | up | Up vector of the rectangle, only x-y components are used.
  [in] | scaleX | Scale factor in X-direction
  [in] | scaleY | Scale factor in Y-direction
  [in] | filled | If true the rectangle will be filled otherwise it will just be drawn as an outline.

void sphere | ( | const MPoint & | center,
|  | double | radius,
|  | bool | filled = `false`
| ) |  |

Search for all occurrences

Draw a sphere.

Parameters:

  [in] | center | Center of the sphere.
  [in] | radius | Radius of the sphere.
  [in] | filled | If true the sphere will be filled otherwise it will just be drawn as a wireframe.

void circle | ( | const MPoint & | center,
|  | const MVector & | normal,
|  | double | radius,
|  | bool | filled = `false`
| ) |  |

Search for all occurrences

Draw a circle.

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

Parameters:

  [in] | center | Center of the circle
  [in] | normal | Normal vector of the circle plane
  [in] | radius | Radius of the circle
  [in] | filled | If true the circle will be filled otherwise it will just be drawn as an outline.

void circle2d | ( | const MPoint & | center,
|  | double | radius,
|  | bool | filled = `false`
| ) |  |

Search for all occurrences

Draw a 2D circle on the screen.

The circle is always facing the camera.

Parameters:

  [in] | center | Center of the circle, only x-y components(in pixels) are used.
  [in] | radius | Radius(in pixels) of the circle
  [in] | filled | If true the circle will be filled otherwise it will just be drawn as an outline.

void arc | ( | const MPoint & | center,
|  | const MVector & | start,
|  | const MVector & | end,
|  | const MVector & | normal,
|  | double | radius,
|  | bool | filled = `false`
| ) |  |

Search for all occurrences

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] | center | Center of the arc
  [in] | start | Start vector, its projection onto the arc plane is the start of the arc.
  [in] | end | End vector, its projection onto the arc plane is the end of the arc.
  [in] | normal | Normal vector of the arc plane.
  [in] | radius | Radius of the arc.
  [in] | filled | If true the arc will be filled otherwise it will just be drawn as an outline.

void arc2d | ( | const MPoint & | center,
|  | const MVector & | start,
|  | const MVector & | end,
|  | double | radius,
|  | bool | filled = `false`
| ) |  |

Search for all occurrences

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] | center | Center of the arc, only x-y components(in pixels) are used
  [in] | start | Start vector, only x-y components are used.
  [in] | end | End vector, only x-y components are used.
  [in] | radius | Radius(in pixels) of the arc.
  [in] | filled | If true the arc will be filled otherwise it will just be drawn as an outline.

void mesh | ( | Primitive | mode,
|  | const MPointArray & | position,
|  | const MVectorArray * | normal = `NULL`,
|  | const MColorArray * | color = `NULL`,
|  | const MUintArray * | index = `NULL`
| ) |  |

Search for all occurrences

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] | mode | Primitive mode, e.g., point list, line list, etc.
  [in] | position | List of the vertex positions.
  [in] | normal | List of the vertex normals.
  [in] | color | List of the vertex colors.
  [in] | index | List of the vertex indices.

void mesh2d | ( | Primitive | mode,
|  | const MPointArray & | position,
|  | const MColorArray * | color = `NULL`,
|  | const MUintArray * | index = `NULL`
| ) |  |

Search for all occurrences

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] | mode | Primitive mode, e.g., point list, line list, etc.
  [in] | position | List of the vertex positions, only x-y components of the point are used.
  [in] | color | List of the vertex colors.
  [in] | index | List of the vertex indices.

void cone | ( | const MPoint & | base,
|  | const MVector & | direction,
|  | double | radius,
|  | double | height,
|  | bool | filled = `false`
| ) |  |

Search for all occurrences

Draw a cone.

Parameters:

  [in] | base | Base position for the cone
  [in] | direction | The cone's tip will point in this direction.
  [in] | radius | Radius of the cone
  [in] | height | Height of the cone
  [in] | filled | If true the cone will be filled otherwise it will just be drawn as an outline.

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

Search for all occurrences

Draw a box.

Parameters:

  [in] | center | Center position for the box
  [in] | up | The top of the box will be facing this direction.
  [in] | right | The side of the box will be facing this direction.
  [in] | scaleX | X size of the box
  [in] | scaleY | Y size of the box
  [in] | scaleZ | Z size of the box
  [in] | filled | If true the box will be filled otherwise it will just be drawn as an outline.

void setFontSize | ( | FontSize | fontSize | ) |

Search for all occurrences

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

Default: kDefaultFontSize

Parameters:

  [in] | fontSize | The font size to use.

Examples:
  footPrintNode.cpp.

void text | ( | const MPoint & | position,
|  | const MString & | text,
|  | TextAlignment | alignment = `kLeft`,
|  | const int * | backgroundSize = `NULL`,
|  | const MColor * | backgroundColor = `NULL`,
|  | bool | dynamic = `false`
| ) |  |

Search for all occurrences

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

It has a fixed size in screen space.

Parameters:

  [in] | position | Position of the text to be drawn, it is 3d object space.
  [in] | text | Content of the text string.
  [in] | alignment | Alignment 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] | backgroundSize | The 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] | backgroundColor | The color of the background, it can be transparent. If NULL is passed, background will be fully transparent.
  [in] | dynamic | This 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:
  footPrintManip.cpp, footPrintNode.cpp, lineManip.cpp, and swissArmyManip.cpp.

void text2d | ( | const MPoint & | position,
|  | const MString & | text,
|  | TextAlignment | alignment = `kLeft`,
|  | const int * | backgroundSize = `NULL`,
|  | const MColor * | backgroundColor = `NULL`,
|  | bool | dynamic = `false`
| ) |  |

Search for all occurrences

Draw a text on the screen.

Parameters:

  [in] | position | Position of the text to be drawn, it is in screen space, only x-y components are used.
  [in] | text | Content of the text string.
  [in] | alignment | Alignment 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] | backgroundSize | The 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] | backgroundColor | The color of the background, it can be transparent. If NULL is passed, background will be fully transparent.
  [in] | dynamic | This 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.

MUIDrawManager MUIDrawManager MUIDrawManager MUIDrawManager MUIDrawManager MUIDrawManager MUIDrawManager MUIDrawManager MUIDrawManager MUIDrawManager
MUIDrawManager MUIDrawManager MUIDrawManager MUIDrawManager MUIDrawManager MUIDrawManager MUIDrawManager MUIDrawManager MUIDrawManager MUIDrawManager