Model Icons
Instead of drawing diagrams with plain rectangular boxes, you can replace boxes with arbitrary icons or images of meaningful objects. There are three distinct places in the process of modeling and simulation where you may set the icons. Each successive stage overrides any settings of earlier stages.
Stages where icons can be set:
- Model Definition - This is when you define a model's behavior in the text-editor. Use DEFAULT_ICON( ) in the model's header area. This becomes truly the default icon for the given model type. This icon will appear automatically and immediately anywhere the model is instantiated, unless overridden by a subsequent properties setting. See Setting Default Icons.
- Model Instantiation - This is when you are drawing block-diagrams in the GUI, and you set the properties of a particular model instance. You can use this to give particular instances of a model distinct icons. Set this under a box's properties dialog. See Setting a Specific Object's Icon.
- Simulation Run-time - As you run a simulation, models may change their images as the simulation runs. These are controlled by the CSIM_SET_IMAGE_ICON within a model's behavior code. See Changing Icons During Simulation.
The following document is divided into three sections corresponding to the three ways that icons can be set. Please see the appropriate section.
Regardless of the actual size of the source image, the size of the box, or which method you use, CSIM ensures that the image appears the same size as the box you place it on. For example, you can assign the same image to several boxes of differing sizes. The image will be stretched, shrunk, or squeezed accordingly for each box.
Most popular image formats are accepted, including JPEG, GIF, PNG, BMP, TIFF, PPM, etc.. Most platforms have the necessary run-time libraries to display these formats. However, without image-support libraries, only PPM format can be accepted. In such cases, either install the missing libraries, such as from Netpbm, or convert your images to PPM through an image tool, such as Gimp, XV, PhotoShop, or ImageMagick.
A set of useful icon images is provided within CSIM's distribution package under the $CSIM_MODEL_LIBS/icons directory. These images are complimentary. You can use or add your own images. The following table lists the existing images with their file names.
Complimentary images and their file names -
Network Symbols:
| host host.ppm | host server host_server.ppm | ids ids.ppm | ine ine.ppm |
|---|---|---|---|
| firewall firewall.ppm | bridge bridge.ppm | radio terminal radio_terminal.ppm | radio channel radio_channel.ppm |
| router router.ppm | satelite satelite.ppm | satelite ground satelite_ground.ppm | switch switch.ppm |
| NetworkController NetworkController.ppm.scz | Server Server.ppm.scz | csco router csco_router.ppm.scz |
Logic Symbols:
| andgate andgate.ppm | nandgate nandgate.ppm | notgate notgate.ppm | orgate orgate.gif |
|---|---|---|---|
| norgate norgate.ppm | xorgate xorgate.gif | xnorgate xnorgate.ppm | clockgen clockgen.ppm |
Standard Queuing/Server Symbols:
| std box0 std_box0.ppm | std db0 std_db0.ppm | std delay0 std_delay0.ppm | std diam0 std_diam0.ppm |
|---|---|---|---|
| std diamond0 std_diamond0.ppm | std in0 std_in0.ppm | std out0 std_out0.ppm | std qserver0 std_qserver0.ppm |
| std queue0 std_queue0.ppm | std sink0 std_sink0.ppm | std src0 std_src0.ppm |
(See: Elements of Queuing Systems)
In some cases icons have been made to look best on the default black screen background. However, for other background colors, such as on white paper print-outs, a second set of the same icons has been provided with reverse colors. Such is the case with the standard queuing icons below.
| std box std_box.ppm | std db std_db.ppm | std delay std_delay.ppm | std diam std_diam.ppm |
|---|---|---|---|
| std diamond std_diamond.ppm | std in std_in.ppm | std out std_out.ppm | std qserver std_qserver.ppm |
| std queue std_queue.ppm | std sink std_sink.ppm | std src std_src.ppm |
Another set of icons accompanies the new Analog Circuit library. Under $CSIM_MODEL_LIBS/analog_circuits/images are the following schematic symbols:
| resistor resistor.ppm | capacitor capacitor.ppm | inductor inductor.ppm | switch switch.ppm |
|---|---|---|---|
| battery battery.ppm | diode diode.ppm | zenior zenior.ppm | scr SCR.ppm |
| LED LED.ppm | photodiode photodiode.ppm | xfromer transformer.ppm | Jfet JFET.ppm |
| MosFet MOSFET.ppm | bjtransistor npn_transistor.ppm | Transistor npn pnp_transistor.ppm |
1. Setting Default Icons for a Class
You can set the default icon for a type of model where you define the model, with the DEFAULT_ICON( ) construct. This is when you define a model's behavior in the text-editor.
Example:
DEFINE_DEVICE_TYPE: i486x
PORT_LIST( clk, addr, data_io, rw );
DEFAULT_ICON( $CSIM_MODEL_LIBS/icons/host.ppm );
. . .
Simply name the image file to be rendered whenever a device of this type is snapped down (added to a diagram). This becomes the default icon for the given model type. The icon will appear automatically and immediately anywhere the model is instantiated, unless overridden by a subsequent properties setting.
2. Setting a Specific Object's Icon
This is when you are drawing block-diagrams in the GUI. Open the properties of a particular object (model instance). Click Attributes. You will see a button marked Icon. Clicking the Icon button under the object's property/attributes dialog will open a file browser to enter an image file's name.
You can use this option to give particular instances of a model distinct icons. Remember this is under a box's properties dialog.
3. Changing Icons During Simulation
You can change icon-images during simulation run-time with the following built-in routines in your models:
- CSIM_SET_IMAGE_ICON - Replaces a named box on your diagram with an image. You use it similar to the highlight_box() function.
- CSIM_CLEAR_IMAGE_ICON - Clears any replaced icon to the original icon or regular box.
One useful way of using this feature is to illustrate a component going through various state changes, by displaying the component with a different image for each state it is in. For efficiency, you can graphically show your components in various states by preloading images depicting each state into different image variables at start-up. Then change the component's image according to its state.
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 arbitrary icon, by naming an image file under the Properties / Attributes / Icon dialog.
The following is a detailed description of the image-display routines:
- CSIM_SET_IMAGE_ICON( char *object_name, char *image_filename ) -
This routine accepts an object-name in your diagram, and the name of a file containing an image.
It displays the image at that object location; on-top of the
object's box. Regardless of the actual size of the original image,
the image is automatically resized to fit the size of the box.
The image is persistent, in that any redrawing of the display, such as due to
zooming, panning, or navigating, will preserve the image.
Many popular image formats are accepted, such as
JPG, GIF, PNG, and PPM. However, if your system lacks image-support libraries, then
only PPM format will be guaranteed to work.
In such cases, either install the missing libraries,
such as from Netpbm, or
convert your images to PPM through an image tool, such as
ImageMagick Convert,
or The Gimp,
..., etc.. PPM images can always be converted to more compact files through the scz_compress utility found in the tools/platform/general_utilities directory of every CSIM distribution. Compressed (.ppm.scz) images can be de-compressed on-the-fly and displayed directly by CSIM.
Use as, for example:
```
CSIM_SET_IMAGE_ICON( MY_NAME, "imagefile.ppm" );
```
You could change the icon of other boxes in your modeled diagram.
Example:
``` CSIM_SET_IMAGE_ICON( "/platoon1/radio8", "radio.jpg" );
```
- CSIM_CLEAR_IMAGE_ICON( char *object_name ) -
The original or default image is restored by calling CSIM_CLEAR_IMAGE_ICON( char *object_name )
For example:
CSIM_CLEAR_IMAGE_ICON( MY_NAME );
Or
CSIM_CLEAR_IMAGE_ICON( "/platoon1/radio8" );

