[2] | 1 | ;------------------------------------------------------------ |
---|
| 2 | ;+ |
---|
| 3 | ; |
---|
[133] | 4 | ; @file_comments |
---|
[137] | 5 | ; Fastest than type loadct, file = 'palette.tbl' |
---|
[2] | 6 | ; |
---|
[137] | 7 | ; @categories graphics, color |
---|
[2] | 8 | ; |
---|
[137] | 9 | ; @param numpal {in}{optional} |
---|
| 10 | ; number of the color palette we want to select in the file palette.tbl |
---|
[2] | 11 | ; |
---|
[137] | 12 | ; @keyword LIGHTNESS |
---|
| 13 | ; a scalar used to change the Lightness of the color |
---|
| 14 | ; palette to be abble to adjust according to the printer we use, |
---|
| 15 | ; the media (paper or slide)... |
---|
[19] | 16 | ; lightness < 1 to get lighter colors |
---|
| 17 | ; > 1 to get darker colors |
---|
| 18 | ; |
---|
[137] | 19 | ; @keyword FILE {default='palette.tbl'} |
---|
| 20 | ; The file containing the color palette. It can be in any directory of the !path |
---|
[2] | 21 | ; |
---|
[137] | 22 | ; @keyword GET_NAME |
---|
| 23 | ; Set this keyword to a named variable in which the names of the color tables |
---|
| 24 | ; are reurned as a string array. No changes are made to the color table. |
---|
[133] | 25 | ; |
---|
[137] | 26 | ; @keyword _EXTRA |
---|
| 27 | ; Used to pass loadct keywords |
---|
[133] | 28 | ; |
---|
[137] | 29 | ; @history |
---|
| 30 | ; Sebastien Masson (smasson\@lodyc.jussieu.fr) |
---|
| 31 | ; 30/3/1999: add extra |
---|
| 32 | ; 6/7/1999: mac/windows compatibility |
---|
[133] | 33 | ; |
---|
| 34 | ; @version $Id$ |
---|
| 35 | ; |
---|
[2] | 36 | ;- |
---|
| 37 | ;------------------------------------------------------------ |
---|
[133] | 38 | PRO lct, numpal, FILE = file, GET_NAME = get_name, LIGHTNESS = Lightness, _EXTRA = ex |
---|
[114] | 39 | ; |
---|
| 40 | compile_opt idl2, strictarrsubs |
---|
| 41 | ; |
---|
[133] | 42 | ; definition of the name of the file containing colors palettes. |
---|
[137] | 43 | if keyword_set(file) then nametbl = file ELSE nametbl = 'palette.tbl' |
---|
[136] | 44 | ; What is the full address of nametbl? |
---|
[137] | 45 | thisOS = strupcase(strmid(!version.os_family, 0, 3)) |
---|
| 46 | CASE thisOS of |
---|
| 47 | 'MAC':BEGIN & sep = ':' & pathsep = ',' & end |
---|
| 48 | 'WIN':BEGIN & sep = '\' & pathsep = ';' & end |
---|
| 49 | ELSE: BEGIN & sep = '/' & pathsep = ':' & end |
---|
| 50 | ENDCASE |
---|
| 51 | cd, current = current |
---|
| 52 | if strpos(nametbl, sep) lt 0 then BEGIN |
---|
| 53 | if rstrpos(current, sep) NE strlen(current)-1 then current = current+sep |
---|
| 54 | multipath = str_sep(!path, pathsep) |
---|
| 55 | for i = 0, n_elements(multipath)-1 do $ |
---|
| 56 | if rstrpos(multipath[i], sep) NE strlen(multipath[i])-1 then $ |
---|
| 57 | multipath[i] = multipath[i] +sep |
---|
| 58 | nametbl = [current, multipath]+ nametbl |
---|
| 59 | ENDIF |
---|
[133] | 60 | ; we test all possible name in order to find where file is. |
---|
[137] | 61 | nfile = n_elements(nametbl) |
---|
| 62 | n = 0 |
---|
| 63 | repeat begin |
---|
| 64 | res = findfile(nametbl[n]) |
---|
| 65 | n = n+1 |
---|
| 66 | endrep until res[0] NE '' OR n EQ n_elements(nametbl) |
---|
| 67 | if res[0] NE '' then BEGIN |
---|
| 68 | nametbl = nametbl[n-1] |
---|
| 69 | if n_elements(ex) NE 0 then $ |
---|
| 70 | if (where(tag_names(ex) EQ 'FILE'))[0] NE -1 then ex.FILE = nametbl |
---|
[133] | 71 | ; if we are in POSTSCRIPT mode, we have to pass in X mode in order to change the color palette |
---|
[137] | 72 | oldname = !d.name |
---|
| 73 | if !d.name EQ 'PS' OR !d.name EQ 'Z' then BEGIN |
---|
| 74 | thisOS = !VERSION.OS_FAMILY |
---|
| 75 | thisOS = STRMID(thisOS, 0, 3) |
---|
| 76 | thisOS = STRUPCASE(thisOS) |
---|
| 77 | CASE thisOS of |
---|
| 78 | 'MAC': SET_PLOT, thisOS |
---|
| 79 | 'WIN': SET_PLOT, thisOS |
---|
| 80 | ELSE: SET_PLOT, 'X' |
---|
| 81 | ENDCASE |
---|
| 82 | !p.BACKGROUND = (!d.n_colors-1) < 255 |
---|
| 83 | !p.color = 0 |
---|
| 84 | if !d.n_colors gt 256 then !p.background = 'ffffff'x |
---|
| 85 | ENDIF |
---|
[2] | 86 | ; |
---|
[137] | 87 | if arg_present(get_name) then begin |
---|
| 88 | if n_elements(numpal) EQ 0 then $ |
---|
| 89 | loadct, file = nametbl, GET_NAME = get_name, _EXTRA = ex $ |
---|
| 90 | ELSE loadct, numpal, file = nametbl, /silent, GET_NAME = get_name, _EXTRA = ex |
---|
| 91 | ENDIF ELSE BEGIN |
---|
| 92 | if n_elements(numpal) EQ 0 then loadct, file = nametbl, _EXTRA = ex $ |
---|
| 93 | ELSE loadct, numpal, file = nametbl, /silent, _EXTRA = ex |
---|
| 94 | ENDELSE |
---|
[2] | 95 | ; |
---|
[137] | 96 | if oldname EQ 'PS' AND keyword_set(lightness) then palit, lightness |
---|
[19] | 97 | ; |
---|
[137] | 98 | set_plot, oldname |
---|
| 99 | IF oldname EQ 'X' OR oldname EQ 'MAC' OR oldname EQ 'WIN' then BEGIN |
---|
| 100 | !p.BACKGROUND = (!d.n_colors-1) < 255 |
---|
| 101 | !p.color = 0 |
---|
| 102 | if !d.n_colors gt 256 then !p.background = 'ffffff'x |
---|
| 103 | ENDIF |
---|
[2] | 104 | |
---|
[137] | 105 | ENDIF ELSE ras = report('The file containing the color palettes doesn''t exist...') |
---|
[2] | 106 | |
---|
[137] | 107 | return |
---|
[2] | 108 | end |
---|