X is the windowing system used by most UNIX computers. X11 is the latest version of this windowing system. X was designed and developed by MIT (Massachusetts Institute of Technology) in the mid to late 1980s.
X is made up of three distinct parts. First, there is a library of graphical input and output routines for programming X clients. An X client is an application that draws graphics to a screen in the X environment, and gets input from the devices attached to that screen. (The keyboard and mouse in most environments.) Second, there is an X server that runs on the host machine that implements the requests made by an X client using the X library calls. And finally, there is the X protocol, which is the communication protocol used by the library and the server to communicate. Applications using the X driver in NCAR GKS are therefore X client applications.
X output can be produced from the NCAR GKS package into a pre-existing X window, or NCAR GKS can create the X window for you. The normal mode of operation is to let NCAR GKS create the X window for you, but it is sometimes useful for a user to provide a window for NCAR GKS to draw into.
These two output options are implemented in NCAR GKS as two different workstation types. Workstation type 7 is used to direct graphics output to a pre-existing X window, while workstation type 8 is used to have NCAR GKS create the X window. For an overview of workstation types in NCAR GKS, see the Workstation Functions documentation module.
In the default X environment, all windows share a common color table. Many systems can only support a table of 256 entries. This means that, in general, it is not possible to display 256 distinct colors in a single window. If another application is using a bunch of colors, then it may be that the window you are using to display NCAR Graphics will have only a limited number of colors available to it. The escape number -1402 is used to tell NCAR GKS which X Color Model to use to deal with this problem. There are currently three Color Models used in NCAR GKS:
If the X Workstation is directed to use the Shared X Color Model, then that X window will use the default color table shared by all applications. If you request more colors, via calls to GSCR, than there are available to the given window, then a color matching algorithm is employed. The idea of the algorithm is that the color in the current color table that is closest to the requested color will be selected. Closest is defined in terms of the normal distance metric on the RGB cube. If the closest color is farther away than the percentage error allowed times the length of the diagonal of the RGB color cube, then error number -220 is issued together with a warning. The closest color is still assigned for the requested color. The Shared X Color Model is the default for workstations of type 7.
For example, if you want an X workstation to use the shared color table, you would make the following call:
CALL NGSETI('SC',IWKID)where IWKID is the GKS workstation identifier of the workstation. If you want the escape element to apply to the next workstation created, you can specify "-1" for the workstation identifier in the NGSETI call.
Sometimes you might need to guarantee that 256 distinct colors are available to a given X window. If an X Workstation is directed to use the Private X Color Model, then that X Workstation will install its own X Color table for the X window. This means that X window will have a different Color table than all the other windows on the screen. Therefore, you usually have to have the mouse pointer in the window for the correct color table to be installed. One disadvantage of this Model is that there is usually a color flashing effect on the screen, since a different color table will be installed for all the other windows on the screen.
For example, if you want an X workstation to use a private color table, you would make the following call:
CALL NGSETI('PC',IWKID)where IWKID is the GKS workstation identifier of the workstation. If you want the escape element to apply to the next workstation created, you can specify "-1" for the workstation identifier in the NGSETI call.
The Mixed X Color Model attempts to take the best of both of the previous models. It starts out behaving like the Shared X Color Model, in that it uses the default color table for the screen. It differs in that, once it can't allocate any more colors from the default color table, it allocates its own private color table and starts using it. This way, color flashing is only present if it absolutely needs to be so that the X Workstation can display the correct color. The Mixed X Color Model is the default for Workstations of type 8.
For example, if you want an X workstation to use the shared color table until it needs to install a private color table, you would make the following call:
CALL NGSETI('MC',IWKID)where IWKID is the GKS workstation identifier of the workstation. If you want the escape element to apply to the next workstation created, you can specify "-1" for the workstation identifier in the NGSETI call.
Note: It is not possible to switch to a Shared X Color model once a private color table has been installed. This will generate error -221.
Percent Color Error is only used if the workstation is using a Shared X Color Model. Escape -1400 is used to set the Percent Color Error allowed. It is used to determine the amount of color error that is allowed before an error message is reported. The way this error is calculated is described above with the Shared X Color Model. Values of 0 and 100 are used to indicate that no error messages are wanted. The error generated is -220.
For example, suppose you want to specify that the percentage error to allow in the color matching algorithm for output to an X window is 20%. The following code would accomplish this:
PROGRAM DEMO C C Open GKS, open and activate an X output workstation. C CALL GOPKS(6,IDUM) CALL GOPWK(3,2,8) CALL GACWK(3) C C Specify a color matching percentage error of 20% for output C to an X window workstation with identifier 3. C CALL NGSETI('WO',3) CALL NGSETI('PE',20) C C Define colors C CALL GSCR(3,0,0.,0.,0.) CALL GSCR(3,1,1.,1.,1.) CALL GSCR(3,2,1.,0.,0.) . . .
If you would like to change the size of the window, you will need to put a line of the form:
Xgks*geometry: 612x612-13-292in your .Xdefaults file. In this case a window of the specified size and position will pop up and drawing into the window will proceed without your having to position the window or click on it.
Escape -1401 is obsolete because it has been replaced by -1402.