op_anim_mgp_icon_draw()
Abstract
Adds a primitive that draws an icon to the specified macro.
Syntax
op_anim_mgp_icon_draw (anmid, props, ic_name, x, y)
| Argument | Type | Description |
|---|---|---|
anmid |
Anmid |
macro ID [This value is a numeric identifier which references an open animation macro, created via the KP op_anim_macro_create().] |
props |
int |
graphical property flags [This value is the bitwise OR combination of the Animation Graphical Properties flags OPC_ANIM_COLOR_*, OPC_ANIM_PIXOP_*, OPC_ANIM_BGCOLOR_*, OPC_ANIM_STYLE_*, OPC_ANIM_ALIGNH_*, OPC_ANIM_ALIGNV_*, OPC_ANIM_FONT_*, and OPC_ANIM_RETAIN. For more information, see “Animation“ on page 3.] |
ic_name |
char* |
icon name |
x |
int |
x coordinate of icon upper-left corner |
y |
int |
y coordinate of icon upper-left corner [The x and y coordinate values are measured in pixels from the origin of the viewer window (upper-left corner).] |
Return Type
void
no return value
Example
/** Construct a macro which draws an icon with a box surrounding it; **/
mid = op_anim_macro_create ("icon box");
/* Draw the icon at (X,Y); icon name is stored in N. */
op_anim_mgp_icon_draw (mid, OPC_ANIM_PIXOP_XOR, OPC_ANIM_REG_N_STR,
OPC_ANIM_REG_X_INT, OPC_ANIM_REG_Y_INT);
/* Draw the rectangle at (A=X-2,B=Y-2), with area = (W,H). */
op_anim_mgp_reg_set (mid, OPC_ANIM_REG_C_INT, 2);
op_anim_mgp_arop (mid, OPC_ANIM_REG_X_INT, OPC_ANIM_AROP_SUBTRACT,
OPC_ANIM_REG_C_INT, OPC_ANIM_REG_A_INT);
op_anim_mgp_arop (mid, OPC_ANIM_REG_Y_INT, OPC_ANIM_AROP_SUBTRACT,
OPC_ANIM_REG_C_INT, OPC_ANIM_REG_B_INT);
op_anim_mgp_rect_draw (mid, OPC_ANIM_COLOR_RED,
OPC_ANIM_REG_A_INT, OPC_ANIM_REG_B_INT,
OPC_ANIM_REG_W_INT, OPC_ANIM_REG_H_INT);
Details
The props, ic_name, x, and y arguments of this KP will accept macro register ID symbolic constants, as listed under “Animation Macro Register Identifier Symbolic Constants—Integer Values“ on page 8. If register IDs are supplied for these arguments, the actual values are taken from the specified registers at the time of macro invocation.
Icon drawings are affected by the pixop graphical property. If the pixop graphical property is set to a value other than the default (OPC_ANIM_PIXOP_SRC), portions of the icon which are drawn over non-black viewer pixels may be displayed in colors which are different from those specified in the Color Palette Editor (See “Icon Database Editor“ on page 615 for more information (note that the pixop value OPC_ANIM_PIXOP_XOR should be used if the specified macro will be invoked with the retain property for later erasure).
You can create icons and add them to an icon database by using the Icon Database Editor. For more information, see “Icon Database Editor“ on page 615. Icons as large as 100 pixels on a side can be designed. However, the larger the icon, the longer it takes to draw (large icons which are updated frequently can cause choppy animations on low-performance workstations).
Purpose
Provides a mechanism to draw an icon in the context of a macro. The icon can serve as a component in a completely customized display, or it can be added to a model diagram as an indicator of some dynamic event or status. Note that changing the icon of an object within a model diagram is performed via op_anim_ime_nobj_update(). Icon drawings are useful for depicting static model objects such as nodes or modules in alternative diagrams, or for depicting the condition and status of specific model objects or the simulation as a whole.
Errors
- Program Abort: segmentation violation (due to a badly formed string for the
ic_nameargument) - Recoverable Error: Animation macro ID (
<anmid>) is [out-of-range] [unrecognized]. (former case due toanmidargument value that is invalid, latter case to destroyed macro) - Diagnostic Error: Invalid property component (
<prop_comp>) for graphical primitive. (due to an inapplicable or invalid literal value for thepropsargument) - Diagnostic Error: Kernel procedure argument (
<arg>) has out-of-range value (<val>). (due to a literal value for the argumentsxorythat exceeds the range of a short)
Reference
- Use the KP op_anim_ime_nobj_update() to change the icon of an object displayed in a model diagram
- Use the KP op_anim_igp_icon_draw() to draw an icon in immediate mode
- Use the KP op_anim_macro_create() to create an empty macro
- Use the KP op_anim_macro_close() to indicate the completion of a macro definition
- Use the KP op_anim_igp_macro_draw() to invoke a macro within a viewer