op_anim_macro_create()
Abstract
Creates an empty macro that can be defined using calls to op_anim_mgp… and op_anim_mme… KPs.
Syntax
op_anim_macro_create (mac_name)
| Argument | Type | Description |
|---|---|---|
mac_name |
char* |
macro name [This value is a string which is used as the name of the new macro.] |
Return Type
Anmid
macro ID
Example
/** Construct a macro which depicts a field within a packet. **/
mid = op_anim_macro_create ("pk field");
/* Draw a rectangle fixed at (X,Y) which has width(W) = no. bits(B) x 8 */
op_anim_mgp_reg_set (mid, OPC_ANIM_REG_C_INT, 8);
op_anim_mgp_arop (mid, OPC_ANIM_REG_B_INT, OPC_ANIM_AROP_MULTIPLY,
OPC_ANIM_REG_C_INT, OPC_ANIM_REG_W_INT);
op_anim_mgp_rect_draw (mid, OPC_ANIM_COLOR_RED, OPC_ANIM_REG_X_INT,
OPC_ANIM_REG_Y_INT, OPC_ANIM_REG_W_INT, 15);
/* Draw the field name at (L,Y) where L = X + (W / 2) */
op_anim_mgp_reg_set (mid, OPC_ANIM_REG_C_INT, 2);
op_anim_mgp_arop (mid, OPC_ANIM_REG_W_INT, OPC_ANIM_AROP_DIVIDE, OPC_ANIM_REG_C_INT,
OPC_ANIM_REG_H_INT);
op_anim_mgp_arop (mid, OPC_ANIM_REG_X_INT, OPC_ANIM_AROP_ADD, OPC_ANIM_REG_H_INT,
OPC_ANIM_REG_L_INT);
op_anim_mgp_text_draw (mid, OPC_ANIM_ALIGNH_CENTER | OPC_ANIM_ALIGNV_BOTTOM |
OPC_ANIM_FONT_OPEN_10 | OPC_ANIM_COLOR_RED,
OPC_ANIM_REG_L_INT, OPC_ANIM_REG_Y_INT, OPC_ANIM_REG_S_STR);
op_anim_macro_close (mid);
Details
If a macro has already been created with the same name as the mac_name argument of this KP, no new macro will be created, and the existing macro’s ID is returned. Thus this KP can be used by distributed processes to share a single macro definition by using its name as a “rendezvous”. Once a macro has been closed, further attempts to add primitives to it via op_anim_mgp… KP calls will be ignored.
Purpose
Provides a mechanism for creating a macro, a collection of animation requests which can be invoked as a single atomic operation. Macro invocation is useful for repetitively drawing figures composed of multiple graphical primitives. Displaying graphical primitives in the proximity of model elements within a viewer model diagram requires the definition of a macro, since the position of model elements can only be determined in the context of a macro, via the KP op_anim_mme_nobj_pos().
Errors
- Program Abort: segmentation violation (due to a badly formed string for the
mac_nameargument)
Reference
- Use the
op_anim_mgp…KPs to add animation requests to an existing macro - Use the KP op_anim_macro_close() to complete a macro definition, prohibiting the addition of further requests
- Use the KP op_anim_macro_destroy() to deallocate the memory associated with a macro which is no longer in use