[2] | 1 | ;------------------------------------------------------------ |
---|
| 2 | ;------------------------------------------------------------ |
---|
| 3 | ;------------------------------------------------------------ |
---|
| 4 | ;+ |
---|
| 5 | ; NAME:lct |
---|
| 6 | ; |
---|
| 7 | ; PURPOSE:plus court que de taper loadct,file='palette.tbl' |
---|
| 8 | ; |
---|
| 9 | ; CATEGORY:flemme |
---|
| 10 | ; |
---|
| 11 | ; CALLING SEQUENCE:lct[,numerp_couleur] |
---|
| 12 | ; |
---|
| 13 | ; INPUTS:optionnel: numero de la couleur que l''on veut ds palette.tbl |
---|
| 14 | ; |
---|
| 15 | ; KEYWORD PARAMETERS: ceux de loadct |
---|
| 16 | ; |
---|
| 17 | ; rq: si le mot cle file n''est pas specifie, on cherche un fichier |
---|
| 18 | ; contenant les palette du nom de palette.tbl. |
---|
| 19 | ; Ce fichier peut etre dans n''importe quel repertoire du !path |
---|
| 20 | ; |
---|
| 21 | ; MODIFICATION HISTORY: Sebastien Masson (smasson@lodyc.jussieu.fr) |
---|
| 22 | ; 30/3/1999 ajout de _extra, de la recherche |
---|
| 23 | ; du nom complet et pour que ca marche aussi en |
---|
| 24 | ; mode PS et Z |
---|
| 25 | ; 6/7/1999: compatibilite mac et windows |
---|
| 26 | ;- |
---|
| 27 | ;------------------------------------------------------------ |
---|
| 28 | ;------------------------------------------------------------ |
---|
| 29 | ;------------------------------------------------------------ |
---|
| 30 | PRO lct, numero, GET_NAME = get_name, _EXTRA = ex |
---|
| 31 | @common |
---|
| 32 | ; le mot cle file est passe par l''intermediere de EXTRA? |
---|
| 33 | ; definition du mon du fichier qui contient les palettes de couleur |
---|
| 34 | if n_elements(ex) NE 0 then BEGIN |
---|
| 35 | if (where(tag_names(ex) EQ 'FILE'))[0] NE -1 then nompal=ex.FILE ELSE nompal='palette.tbl' |
---|
| 36 | ENDIF ELSE nompal = 'palette.tbl' |
---|
| 37 | ; quelle est l''adresse complete de nompal? |
---|
| 38 | thisOS = strupcase(strmid(!version.os_family, 0, 3)) |
---|
| 39 | CASE thisOS of |
---|
| 40 | 'MAC':BEGIN & sep = ':' & pathsep = ',' & end |
---|
| 41 | 'WIN':BEGIN & sep = '\' & pathsep = ';' & end |
---|
| 42 | ELSE: BEGIN & sep = '/' & pathsep = ':' & end |
---|
| 43 | ENDCASE |
---|
| 44 | cd, current = current |
---|
| 45 | if strpos(nompal,sep) lt 0 then BEGIN |
---|
| 46 | if rstrpos(current,sep) NE strlen(current)-1 then current = current+sep |
---|
| 47 | multipath = str_sep(!path,pathsep) |
---|
| 48 | for i = 0, n_elements(multipath)-1 do $ |
---|
| 49 | if rstrpos(multipath[i],sep) NE strlen(multipath[i])-1 then $ |
---|
| 50 | multipath[i] = multipath[i] +sep |
---|
| 51 | nompal = [current, multipath]+ nompal |
---|
| 52 | ENDIF |
---|
| 53 | ; on test tous les noms possibles pour trouver ou est le fichier |
---|
| 54 | nfile=n_elements(nompal) |
---|
| 55 | n = 0 |
---|
| 56 | repeat begin |
---|
| 57 | res = findfile(nompal[n]) |
---|
| 58 | n = n+1 |
---|
| 59 | endrep until res[0] NE '' OR n EQ n_elements(nompal) |
---|
| 60 | if res[0] NE '' then BEGIN |
---|
| 61 | nompal = nompal[n-1] |
---|
| 62 | if n_elements(ex) NE 0 then $ |
---|
| 63 | if (where(tag_names(ex) EQ 'FILE'))[0] NE -1 then ex.FILE = nompal |
---|
| 64 | ; si on est en mode POSTSCRIPT, il faut repasser en mode X pour |
---|
| 65 | ; changer la palette de couleur |
---|
| 66 | oldname = !d.name |
---|
| 67 | if !d.name EQ 'PS' OR !d.name EQ 'Z' then BEGIN |
---|
| 68 | thisOS = !VERSION.OS_FAMILY |
---|
| 69 | thisOS = STRMID(thisOS, 0, 3) |
---|
| 70 | thisOS = STRUPCASE(thisOS) |
---|
| 71 | CASE thisOS of |
---|
| 72 | 'MAC': SET_PLOT, thisOS |
---|
| 73 | 'WIN': SET_PLOT, thisOS |
---|
| 74 | ELSE: SET_PLOT, 'X' |
---|
| 75 | ENDCASE |
---|
| 76 | !p.BACKGROUND=(!d.n_colors-1) < 255 |
---|
| 77 | !p.color=0 |
---|
| 78 | if !d.n_colors gt 256 then !p.background='ffffff'x |
---|
| 79 | ENDIF |
---|
| 80 | ; |
---|
| 81 | if arg_present(get_name) then begin |
---|
| 82 | if n_elements(numero) EQ 0 then loadct, file=nompal, GET_NAME = get_name, _EXTRA = ex $ |
---|
| 83 | ELSE loadct,numero, file=nompal, /silent, GET_NAME = get_name,_EXTRA = ex |
---|
| 84 | ENDIF ELSE BEGIN |
---|
| 85 | if n_elements(numero) EQ 0 then loadct, file=nompal, _EXTRA = ex $ |
---|
| 86 | ELSE loadct,numero, file=nompal, /silent, _EXTRA = ex |
---|
| 87 | ENDELSE |
---|
| 88 | ; |
---|
| 89 | if oldname EQ 'PS' then BEGIN |
---|
| 90 | tvlct, rouge, vert, bleu, /get |
---|
| 91 | palit, coefpalit |
---|
| 92 | endif |
---|
| 93 | set_plot, oldname |
---|
| 94 | IF oldname EQ 'X' OR oldname EQ 'MAC' OR oldname EQ 'WIN' then BEGIN |
---|
| 95 | !p.BACKGROUND=(!d.n_colors-1) < 255 |
---|
| 96 | !p.color=0 |
---|
| 97 | if !d.n_colors gt 256 then !p.background='ffffff'x |
---|
| 98 | ENDIF |
---|
| 99 | |
---|
| 100 | ENDIF ELSE ras = report('le fichier de palettes demande n''existe pas...') |
---|
| 101 | |
---|
| 102 | return |
---|
| 103 | end |
---|