op_anim_mgp_line_draw()

摘要

向指定宏添加一个图元,绘制一条线段。

语法

op_anim_mgp_line_draw (anmid, props, x1, y1, x2, y2)
参数 类型 说明
anmid Anmid 宏 ID
[该值是引用某个已打开动画宏的数字标识符,由 KP op_anim_macro_create() 创建。]
props int 图形属性标志
[该值是动画图形属性标志 OPC_ANIM_COLOR_*、OPC_ANIM_PIXOP_*、OPC_ANIM_BGCOLOR_*、OPC_ANIM_STYLE_*、OPC_ANIM_ALIGNH_*、OPC_ANIM_ALIGNV_*、OPC_ANIM_FONT_* 和 OPC_ANIM_RETAIN 按位 OR 组合。更多信息见“Animation“ 第 3 页。]
x1 int 线段第一个端点的 x 坐标
y1 int 线段第一个端点的 y 坐标
x2 int 线段第二个端点的 x 坐标
y2 int 线段第二个端点的 y 坐标
[x1、x2、y1 和 y2 坐标值以像素为单位,从查看器窗口的原点(左上角)起测量。]

返回类型

void

无返回值

示例

/* Create a macro which draws a line between two nodes. */
mid = op_anim_macro_create ("node dynconn");

/* Determine the positions of the nodes A & B; the position of A is */
/* stored in (M,N) and the position of B is stored in (O,P). */
op_anim_mme_nobj_pos (mid, OPC_ANIM_OBJTYPE_NODE, OPC_ANIM_REG_A_STR,
	OPC_ANIM_REG_M_INT, OPC_ANIM_REG_N_INT, OPC_ANIM_VERTEX_ICON_CTR);
op_anim_mme_nobj_pos (mid, OPC_ANIM_OBJTYPE_NODE, OPC_ANIM_REG_B_STR,
	OPC_ANIM_REG_O_INT, OPC_ANIM_REG_P_INT, OPC_ANIM_VERTEX_ICON_CTR);

/* Draw the line between the nodes. */
op_anim_mgp_line_draw (mid, OPC_ANIM_COLOR_GREEN,
	OPC_ANIM_REG_M_INT, OPC_ANIM_REG_N_INT, OPC_ANIM_REG_O_INT, OPC_ANIM_REG_P_INT);

/* Execute the macro for source & destination nodes. */
op_anim_igp_macro_draw (vid, OPC_ANIM_RETAIN, mid,
	OPC_ANIM_REG_A_STR, src_nd_name,
	OPC_ANIM_REG_B_STR, dst_nd_name, OPC_EOL);

详情

此 KP 的 props、x1、y1、x2 和 y2 参数可以接受宏寄存器 ID 符号常量,如“Animation Macro Register Identifier Symbolic Constants—Integer Values“ 第 8 页下列出的常量。如果为这些参数传入寄存器 ID,则实际值在宏被调用时从指定寄存器中取得。

线段绘图受 color、pixop 和 style 图形属性的影响。线段的 color 图形属性可以赋值 64 个索引颜色值中的任意一个(格式为 OPC_ANIM_COLOR_RGB<rgb>)或 25 个命名颜色值之一(默认颜色为黑色)。如果 pixop 图形属性被设置为默认值(OPC_ANIM_PIXOP_SRC)以外的值,绘制在非黑色查看器像素之上的线段部分可能显示为所赋值以外的颜色(注意:如果指定宏将以 retain 属性被调用以便之后擦除,则应使用 pixop 值 OPC_ANIM_PIXOP_XOR)。线段的 style 图形属性可以取三个值之一:实线由符号常量 OPC_ANIM_STYLE_SOLID 指定(默认值),虚线由 OPC_ANIM_STYLE_DASHES 指定,点线由 OPC_ANIM_STYLE_DOTS 指定。

用途

提供了一种在宏的上下文中绘制线段的机制。线段可以作为完全自定义显示的组成部分,也可以作为某种动态事件或状态的指示器添加到模型图中。线段绘图适合描绘模型图组件之间的动态连接:例如远程中断、数据包投递、无线电传输和已建立的电路。此类应用可以通过 KP op_anim_mme_nobj_pos() 将模型对象的位置加载到宏寄存器中来实现。

错误

  • 可恢复错误:Animation macro ID (<anmid>) is [out-of-range] [unrecognized].(前者由于 anmid 参数的值无效,后者由于宏已被销毁)
  • 诊断错误:Invalid property component (<prop_comp>) for graphical primitive.(由于 props 参数的字面值不适用或无效)
  • 诊断错误:Kernel procedure argument (<arg>) has out-of-range value (<val>).(由于 x1、y1、x2 或 y2 参数的字面值超出 short 的范围)

参考

本站文档由 北京智网畅联科技有限公司 整理、翻译并提供 · Documentation compiled and provided by Beijing ZNetLink Technology Co., Ltd.

交流群 · QQ Group:OPNET/智网妙算网络仿真交流群(群号 486383494)

原文档 © 2017 Riverbed Technology · 本站为公益翻译,由 AI 辅助完成,请仔细甄别

Original documentation © 2017 Riverbed Technology. Community translation, AI-assisted. Contact: jiazequn@znetlink.com