X Output


What is X?

Interactive Display

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.

Producing X Output from NCAR GKS

GKS Workstation Types for X output

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.

GKS ESCAPE functions controlling X Output

In what follows, details are given on the escape functions in NCAR GKS that apply specifically to X workstations. These escape functions control aspects of the X output that are device specific and lie outside the scope of the GKS Standard. The user interface to these escape functions is via the entries NGSETI, NGSETR, and NGSETC.

X Color Model

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:

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 allowed

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.)
	      .
	      .
	      .

Window size

When you use NCAR GKS to draw to an X11 window, in the default case an X11 window of default size will be created at the time a workstation of type 8 is opened. Before drawing in this window you will need to position it and click on the window.

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-292
in 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.

Obsolete

Escape -1401 is obsolete because it has been replaced by -1402.


Links: GKS Index, GKS Home