This document describes one method of attaching icons to objects. See Icons for a general description of all methods.
Instead of animating graphical simulations by simply highlighting the
rectangular boxes with colors, you can replace the boxes with arbitrary drawings,
-or actual images-, of meaningful objects.
You can do this with the following built-in routines:
|
A set of network-related icon images is provided with every CSIM distribution under csim/model_libs/icons. You can set your boxes to be displayed in the GUI as an aribtrary icon, by naming an image file under the Properties / Attributes / Icon dialogue.
The following is a detailed description of the image-display routines:
The CSIM_READ_IMAGE routine returns a pointer to the image. Use as, for example:
struct rs_image *image_ptr; image_ptr = CSIM_READ_IMAGE( "imagefile.ppm" );Image file names must end in either the .ppm or .bim suffix.
Example:
CSIM_SET_IMAGE_ICON( "/platoon1/radio8", image_ptr );
The original or default image is restored by calling CSIM_SET_IMAGE_ICON with a null image value.
The xoffset, and yoffset parameters enable you to specify a screen location for the icon to appear relative to the named box. This allows you to place animations adjacent to a box, or to effectively move the box's symbol around the screen. Normally, you would use a (0.0, 0.0) offset, which places the image's top-left corner at the top-left corner of the box. Positive offsets will move the image down or to the right, respectively.
The image will not be persistent. That is, any zooming or panning will erase the image.
Example:
display_image_resizable( "/platoon1/radio8", image_ptr, 0.0, 0.0 );
See also Fixed Size Images for non-resizable image routines. These routines will not resize the images based on zoom level. I.E. One pixel of original image - equals - one pixel on display image.