Appendix E : Sample Programs


This appendix lists two programs - the first one using 3DVIEWNIX graphics interface functions, the second one without using the 3DVIEWNIX graphics interface functions.

E.1 Program using the 3DVIEWNIX Graphics Interface Functions

The program is in ~3dviewnix/PROCESS/SAMPLES/EXAMPLES/example1.c

This program shows how to write a program that creates a connection to the X server, displays the 3dviewnix windows and displays the menu. The program first checks if someone else is running 3dviewnix in the same directory. If so, it exits, else it deletes all the old communication files and checks if the argument passed while invoking 3dviewnix are correct. If the arguments passed are correct, the program opens the connection to the X server. After the connection is opened, the program sets the correct visual class, and maps the 3dviewnix windows onto the screen. After the windows are mapped, the events in each window is selected. Then the menu is displayed and the user interface waits for the user to select a command in the menu.

When the user selects the command, the program checks if there is a process associated with the command. If there is a process associated, it cancels all the events in other windows, clears the image window, removes the menus, saves the current colormap in COLOR.COM file and executes the process(say process2). After the process2 exits, this program resets the cursor to the default cursor, loads the colormap that was saved before executing process2, redisplays the menu and lets the user select a new command in the menu.

This program continues until the user hits the quit button, or when a fatal error is encountered.

There is a makefile in the same directory (~3dviewnix/PROCESS/SAMPLES/EXAMPLES) that explains how to compile this program and create the executable.

E.2 Program without using the 3DVIEWNIX Graphics Interface Functions

The program is in ~3dviewnix/PROCESS/SAMPLES/EXAMPLES/example2.c

This program shows how to program without using the graphics interface code. It does not use the 3dviewnix user interface at all. This program reads the ACRNEMA specification file and writes it into three separate files for easy reading by 3dviewnix data protocol. The input to this program is a file of the type ACRNEMA_Vxx.STD, which contains several columns of data. This is carefully read, since only certain columns are important for the sake of writing the information to the specification files which are of the type SCENE_Vxx.SPC, STRUCTURE_Vxx.SPC, DISPLAY_Vxx.SPC.

There is a makefile in the same directory (~3dviewnix/PROCESS/SAMPLES/EXAMPLES) that explains how to compile this program and create the executable.