Deepsearch Software Docs: Display and Colors

X-display Overview

Assuming you haven't subverted the standard deepsearch startup routines, then it should be possible to use the same software, if properly written, on 24-bit and 8-bit displays. Both displays do, in fact, have a "color table." This color table is used for everything in an 8-bit mode, but only for some things in a 24-bit mode, which leads to vast quantities of confusion. Hopefully, by using the standard things we've set up, you should be able to avoid most of that confusion.

By default, the deepsearch software loads a greyscale color table. If you are on an 8-bit display, 20 entries in that color table are set aside for "highlighting" colors; you may be familiar with these, given the green, blue, red, and pink boxes seen in the various stages of the searchscan software. If you are on a 24-bit display, all colors are available at all times, so there's no need to set anything aside in the color table. Routines like "frame" (which plot an image) use the color table, and will by default be displayed as a greyscale image.

Accessing Colors

There are several instances when you want to access colors. For example:

Unfortunately, you can't just give a number (absolute or even relative to a system variable) and expect it to be the same color on both a 24-bit and 8-bit display. For this reason, you should never, ever reference the !top_color variable, even if you think you know what it does! Right now, some deepsearch code does this, and that code will not work properly on a 24-bit display. It will take us time to clean this up, but meanwhile please don't continue to propogate the mess.

Again, if you haven't subverted the deepsearch startup, you can get access to these colors by using the deepsearch routine colordex. You may pass that function the name (or letter) of a color, and it will return to you the number you should use in the examples above.

An example:

IDL> col=colordex('green')
IDL> plot,x,y,color=col

Another example:

IDL> plot,x,y,color=colordex('green')

Yet another example:

IDL> boxdata,30,pho.x,pho.y,colordex('sky blue')

For more information on colordex, use the command

IDL> dlib,'colordex'

Which colors are available

There are nineteen colors available by name in the deepsearch IDL software. You may specify them by the name, or by a single letter. The routine colordex doesn't care about upper versus lower case.

ColorLetter
pinKK
MagentaM
RedR
peacHH
OrangeO
TanT
browNN
YellowY
Forest greenF
GreenG
Lime greenL
turQuoiseQ
AquamarineA
Sky blueS
BlueB
VioletV
PurpleP
WhiteW
BlaCk (BlaCk)C

(Note that some of the colors above may be rendered wrong thanks to limitations of web browsers. Don't worry about it.)

Limiting Colors on 8-bit Displays

By default, when an IDL session starts on an 8-bit display, it grabs all the available colors and does not share properly with other applications. In order to run IDL harmoniously with other applications, or even with other IDL sessions without flashing, you can add a line to your ~/.Xdefaults (or ~/.Xresources or ~/.rc/Xdefaults or ~/.rc/Xresources, depending on whether you're on a PC or a Sun and how your .xinitrc file is set up) such as the following:

idl.colors : 64 That tells IDL to use only 64 colors. 20 of these will be the "highlighting" colors set aside above, leaving you 44 for your greyscale. 64 colors should be few enough that you can run 3 simultaneous IDL sessions on an 8-bit display without flashing. You may adjust this number upwards or dowards to your taste.

Once IDL grabs whatever number of colors, it saves the setting in a system variable !d and !d.n_colors is set to that number of colors. Whenever the display device is changed between Postscript and X-window, !d is updated accordingly :

X window : !d.name='X' & !d.n_colors=(whatever IDL grabbed initially) Postscript: !d.name='PS' & !d.n_colors=256

Doing Color in Postscript Files

Normally, when you create a Postscript file (either by doing "set_plot,'ps'" manually, or using @plotbegin and @plotend), you get greyscale postscript. Images and everything should be fine. However, you won't get the same colors that you get on an X display (even with @plotbegin and @plotend).

If you do want to use color Postscript (meaning bigger but prettier Postscript files), and have the same colors available under Postscript as are available under X, then issue the following commands:

set_plot,'ps'
deepcolor
set_plot,'x'
(This will only work as written if you are using the default deepsearch setup.) You only need do this once per IDL session. However, for safety, you will probably want to include these lines in any code using @plotbegin and @plotend. These lines should appear near the beginning, and must appear before the first occurance of @plotbegin.

Internal System Variables

You should never look at, use, or trust any of these variables. There are two reasons for this. One, they already have different meaning on 8-bit and 24-bit displays, so if you are using them, your code probably won't work on both kinds of displays. Two, in the future we may decide to change how these variables are used internally, meaning that any code which counts on how they are used will break. Use the routines deepcolor and colordex as documented; well-behaved deepsearch programmers who change the meaning of these internal system variables will make sure that those routines still function as they are documented.

!top_color
The fraction of the color table from 0 to !top_color is initialized to a greyscale. The values of !top_color could in principle be different for each person who runs IDL, and for you each time you run IDL. In an 8-bit display, the colors in the color table above !top_color are the various "highlighting" colors mentioned above. For this reason, you will sometimes find old cold which referneces color values using expressions like "!top_color+1". You should not do this any more, because that specification won't work on 24-bit displays. Use colordex instead.

!top_colorx
Storage for what !top_color should be for an X display. This variable exists so that the device may switch between Postscript and X without trouble. The Postscript and X devices may each have different !top_color values.

!top_colorps
Analogous to !top_color, only for Postscript rather than X.