op_anim_viewer_scroll()

Abstract

Scrolls a viewer’s window so that the specified diagram coordinate is aligned with the viewer origin.

Syntax

op_anim_viewer_scroll (anvid, x, y)
Argument Type Description
anvid Anvid viewer ID
[This value is a numeric identifier which references the viewer to be scrolled.]
x int x coordinate of viewer origin
y int y coordinate of viewer origin
[The x and y coordinate values are measured in pixels from the origin of the model diagram (upper-left corner).]

Return Type

void

no return value

Example

/** Message transmission delay line (TDL) chart. **/

/* Calculate the vertical coordinates of TDL. */
simtime = op_sim_time ();
y_src = (simtime / MAX_SIM_TIME) * MAX_Y_LEV;
y_dst = ((simtime + xmit_time) / MAX_SIM_TIME) * MAX_Y_LEV;

/* Draw TDL. */
op_anim_igp_line_draw (vid, lprops, X_SRC, y_src, X_DST, y_dst);

/* Label line at source with simulation time. */
sprintf (tstring, "%g", simtime);
op_anim_igp_text_draw (vid, tprops, X_SRC - TEXT_WIDTH, y_src, tstring);

/* If simulation time passes beyond chart extent, scroll the chart, */
/* leaving some overlap to maintain context. */
if (((int) (simtime / SCROLL_DURATION)) > scrollnum)
	op_anim_viewer_scroll (vid, 0, (++scrollnum * SCROLL_DURATION) - 
		(SCROLL_DURATION * 0.10));

Details

When a viewer is created, its scrollbars are initialized: the horizontal scrollbar is positioned at the far left of its range, and the vertical scrollbar is positioned at the top of its range. This positioning aligns the diagram’s origin (0,0) with the viewer’s origin (the upper-left corner of the window). Manually adjusting the scrollbars of a viewer changes the coordinate of the diagram that is aligned with the viewer origin. This KP has a similar effect: it repositions the diagram within a viewer so that the specified coordinate is aligned with the viewer origin.

Purpose

Provides a mechanism to change the view of animated diagrams which are larger than the associated viewer’s window. Viewer scrolling is useful for custom diagrams which grow over time based on new simulation-generated data. In such cases, the most recent additions to the diagram can be kept in view by dynamically scrolling the viewer to the active area (this technique is illustrated in the Example section).

Errors

  • Diagnostic Error: Animation viewer ID (<anvid>) is out-of-range. (due to an invalid value for the anvid argument)
  • Diagnostic Error: Kernel procedure argument (<arg_name>) has out-of-range value (<value>). (due to a value for the arguments x and y that exceeds the range of a short)

Reference

本站文档由 北京智网畅联科技有限公司 整理、翻译并提供 · 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