source: trunk/SRC/ToBeReviewed/COULEURS/lct.pro @ 114

Last change on this file since 114 was 114, checked in by smasson, 18 years ago

new compilation options (compile_opt idl2, strictarrsubs) in each routine

  • Property svn:eol-style set to native
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 4.2 KB
Line 
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;        LIGHTNESS: a scalar used to change the Lightness of the color
18;            palette to be abble to adjust according to the printer we use,
19;            the media (paper or slide)...
20;               lightness < 1 to get lighter colors
21;                         > 1 to get darker colors
22;
23; rq: si le mot cle file n''est pas specifie, on cherche un fichier
24; contenant les palette du nom de palette.tbl.
25; Ce fichier peut etre dans n''importe quel repertoire du !path
26;
27; MODIFICATION HISTORY: Sebastien Masson (smasson@lodyc.jussieu.fr)
28;                       30/3/1999 ajout de _extra, de la recherche
29;                       du nom complet et pour que ca marche aussi en
30;                       mode PS et Z
31;                       6/7/1999: compatibilite mac et windows
32;-
33;------------------------------------------------------------
34;------------------------------------------------------------
35;------------------------------------------------------------
36PRO lct, numero, GET_NAME = get_name, LIGHTNESS = Lightness, _EXTRA = ex
37;
38  compile_opt idl2, strictarrsubs
39;
40@common
41; le mot cle file est passe par l''intermediere de EXTRA?
42; definition du mon du fichier qui contient les palettes de couleur
43   if n_elements(ex) NE 0 then BEGIN
44      if (where(tag_names(ex) EQ 'FILE'))[0] NE -1 then nompal=ex.FILE ELSE nompal='palette.tbl'
45   ENDIF ELSE nompal = 'palette.tbl'
46; quelle est l''adresse complete de nompal?
47   thisOS = strupcase(strmid(!version.os_family, 0, 3))
48   CASE thisOS of
49   'MAC':BEGIN & sep = ':' & pathsep = ',' & end
50   'WIN':BEGIN & sep = '\' & pathsep = ';' & end
51   ELSE: BEGIN & sep = '/' & pathsep = ':' & end
52   ENDCASE
53   cd, current = current
54   if strpos(nompal,sep) lt 0 then BEGIN
55      if rstrpos(current,sep) NE strlen(current)-1 then current = current+sep
56      multipath = str_sep(!path,pathsep)
57      for i = 0, n_elements(multipath)-1 do $
58       if rstrpos(multipath[i],sep) NE strlen(multipath[i])-1 then $
59       multipath[i] = multipath[i] +sep
60      nompal = [current, multipath]+ nompal
61   ENDIF
62; on test tous les noms possibles pour trouver ou est le fichier
63   nfile=n_elements(nompal)
64   n = 0
65   repeat begin
66      res = findfile(nompal[n])
67      n = n+1
68   endrep until res[0] NE '' OR n EQ n_elements(nompal)
69   if res[0] NE '' then BEGIN
70      nompal = nompal[n-1]
71      if n_elements(ex) NE 0 then $
72       if (where(tag_names(ex) EQ 'FILE'))[0] NE -1 then ex.FILE = nompal
73; si on est en mode POSTSCRIPT, il faut repasser en mode X pour
74; changer la palette de couleur
75      oldname = !d.name
76      if !d.name EQ 'PS' OR !d.name EQ 'Z' then BEGIN
77         thisOS = !VERSION.OS_FAMILY
78         thisOS = STRMID(thisOS, 0, 3)
79         thisOS = STRUPCASE(thisOS)
80         CASE thisOS of
81            'MAC': SET_PLOT, thisOS
82            'WIN': SET_PLOT, thisOS
83            ELSE: SET_PLOT, 'X'
84         ENDCASE
85         !p.BACKGROUND=(!d.n_colors-1) < 255
86         !p.color=0
87         if !d.n_colors gt 256 then !p.background='ffffff'x
88      ENDIF
89;
90      if arg_present(get_name) then begin
91         if n_elements(numero) EQ 0 then loadct, file=nompal, GET_NAME = get_name, _EXTRA = ex $
92         ELSE loadct,numero, file=nompal, /silent, GET_NAME = get_name,_EXTRA = ex
93      ENDIF ELSE BEGIN
94         if n_elements(numero) EQ 0 then loadct, file=nompal, _EXTRA = ex $
95         ELSE loadct,numero, file=nompal, /silent, _EXTRA = ex
96      ENDELSE
97;
98      if oldname EQ 'PS' AND keyword_set(lightness) then palit, lightness
99;
100      set_plot, oldname
101      IF oldname EQ 'X' OR oldname EQ 'MAC' OR oldname EQ 'WIN' then BEGIN
102         !p.BACKGROUND=(!d.n_colors-1) < 255
103         !p.color=0
104         if !d.n_colors gt 256 then !p.background='ffffff'x
105      ENDIF
106
107   ENDIF ELSE ras = report('le fichier de palettes demande n''existe pas...')
108
109   return
110end
Note: See TracBrowser for help on using the repository browser.