Changeset 133 for trunk/SRC/Colors
- Timestamp:
- 07/07/06 11:57:27 (18 years ago)
- Location:
- trunk/SRC/Colors
- Files:
-
- 1 added
- 7 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/SRC/Colors/color24.pro
r132 r133 1 1 ;+ 2 ; NAME:3 ; COLOR244 2 ; 5 ; PURPOSE:6 ; 7 ; 3 ; @file_comments 4 ; The purpose of this function is to convert a RGB color triple 5 ; into the equivalent 24-big long integer. 8 6 ; 9 ; CATEGORY: 10 ; Graphics, Color Specification. 7 ; @categories Graphics, Color Specification. 11 8 ; 12 ; CALLING SEQUENCE: 13 ; color = COLOR24(rgb_triple) 14 ; 15 ; INPUTS: 16 ; RGB_TRIPLE: A three-element column or row array representing 9 ; @param RGB_TRIPLE {in}{required} A three-element column or row array representing 17 10 ; a color triple. The values of the elements must be between 18 11 ; 0 and 255. 19 12 ; 20 ; KEYWORD PARAMETERS: 21 ; None. 13 ; @returns a 24-bit long integer that is equivalent the input color. 14 ; The color is 15 ; described in terms of a hexidecimal number (e.g., FF206A) 16 ; where the left two digits represent the blue color, the 17 ; middle two digits represent the green color, and the right 18 ; two digits represent the red color. 22 19 ; 23 ; COMMON BLOCKS: 24 ; None. 25 ; 26 ; SIDE EFFECTS: 27 ; None. 28 ; 29 ; RESTRICTIONS: 30 ; None. 31 ; 32 ; EXAMPLE: 33 ; To convert the color triple for the color YELLOW, 20 ; @examples To convert the color triple for the color YELLOW, 34 21 ; (255, 255, 0), to the hexadecimal value '00FFFF'x 35 22 ; or the decimal number 65535, type: … … 40 27 ; COLORS or GETCOLOR 41 28 ; 42 ; MODIFICATION HISTORY:29 ; @history 43 30 ; Written by: David Fanning, 3 February 96. 31 ; 32 ; @version $Id$ 33 ; 44 34 ;- 45 46 47 35 FUNCTION COLOR24, number 48 36 ; 49 37 compile_opt idl2, strictarrsubs 50 ; 51 52 ; This FUNCTION accepts a [red, green, blue] triple that 53 ; describes a particular color and returns a 24-bit long 54 ; integer that is equivalent to that color. The color is 55 ; described in terms of a hexidecimal number (e.g., FF206A) 56 ; where the left two digits represent the blue color, the 57 ; middle two digits represent the green color, and the right 58 ; two digits represent the red color. 59 ; 60 ; The triple can be either a row or column vector of 3 elements. 61 38 ; 62 39 ON_ERROR, 1 63 40 -
trunk/SRC/Colors/colorbar.pro
r132 r133 1 1 ;+ 2 ; NAME: 3 ; COLORBAR 4 ; 5 ; PURPOSE: 6 ; The purpose of this routine is to add a color bar to the current 7 ; graphics window. 8 ; 9 ; CATEGORY: 10 ; Graphics, Widgets. 11 ; 12 ; CALLING SEQUENCE: 13 ; COLORBAR 14 ; 15 ; INPUTS: 16 ; None. 17 ; 18 ; KEYWORD PARAMETERS: 19 ; 20 ; BOTTOM: The lowest color index of the colors to be loaded in 2 ; 3 ; @file_comments 4 ; The purpose of this routine is to add a color bar to the current 5 ; graphics window. 6 ; 7 ; @categories Graphics, Widgets. 8 ; 9 ; @keyword BOTTOM The lowest color index of the colors to be loaded in 21 10 ; the bar. 22 11 ; 23 ; CB_CHARSIZE:The character size of the color bar annotations. Default is 1.0.24 ; 25 ; CB_CHARTICK:The character thick of the color bar annotations. Default is 1.0.26 ; 27 ; CB_COLOR:The color index of the bar outline and characters. Default12 ; @keyword CB_CHARSIZE The character size of the color bar annotations. Default is 1.0. 13 ; 14 ; @keyword CB_CHARTICK The character thick of the color bar annotations. Default is 1.0. 15 ; 16 ; @keyword CB_COLOR The color index of the bar outline and characters. Default 28 17 ; is ncolors - 1 + bottom. 29 18 ; 30 ; CB_LOG:to get logarithmic scale for the colorbar31 ; 32 ; CB_TITLE:This is title for the color bar. The default is to have19 ; @keyword CB_LOG to get logarithmic scale for the colorbar 20 ; 21 ; @keyword CB_TITLE This is title for the color bar. The default is to have 33 22 ; no title. 34 23 ; 35 ; DISCRET: Vecteur contenant les incices des couleurs a tracer en barre36 ; de couleur. On obtient ainsi une barre de couleur discrete ne comportant que37 ; les couleurs specifiees ds l'ordre ou elles apparaissent ds le vecteur.38 ; 39 ; DIVISIONS:The number of divisions to divide the bar into. There will24 ; @keyword DISCRETE Vector which contain color's indexes to trace in a color bar. Therefore 25 ; we obtain a discreet color bar which only contains specified colors in 26 ; order where they appear in the vector 27 ; 28 ; @keyword DIVISIONS The number of divisions to divide the bar into. There will 40 29 ; be (divisions + 1) annotations. The default is 2. 41 30 ; 42 ; FORMAT: The format of the bar annotations. Default is '(F6.2)'. 43 ; 44 ; CB_LABEL: C''est un vecteur qui specifie la valeur des sticks 45 ; presents dans la barre de couleur. Il permet qd on utilise 46 ; DISCRET d''avoir des couleurs qui ne s''incrementent pas de 47 ; facon regulieres. 48 ; 49 ; MAX: The maximum data value for the bar annotation. Default is 31 ; @keyword FORMAT The format of the bar annotations. Default is '(F6.2)'. 32 ; 33 ; @keyword CB_LABEL It is a vector who specifie sticks's value attend in the color bar. 34 ; It allowes, when we use DISCREET, to have colors which don't increase 35 ; by increments in a regular way. 36 ; 37 ; @keyword MAX The maximum data value for the bar annotation. Default is 50 38 ; NCOLORS-1. 51 39 ; 52 ; MIN:The minimum data value for the bar annotation. Default is 0.53 ; 54 ; NCOLORS:This is the number of colors in the color bar.55 ; 56 ; NOTITLE: oblige a ne pas mettre de titre meme si cb_title est declare57 ; 58 ; POSITION:A four-element array of normalized coordinates in the same40 ; @keyword MIN The minimum data value for the bar annotation. Default is 0. 41 ; 42 ; @keyword NCOLOR This is the number of colors in the color bar. 43 ; 44 ; @keyword NOTITLE Force to don't writte title even if CB_TITLE is declarerd. 45 ; 46 ; @keyword POSITION A four-element array of normalized coordinates in the same 59 47 ; form as the POSITION keyword on a plot. Default is 60 48 ; [0.88, 0.15, 0.95, 0.95] for a vertical bar and 61 49 ; [0.15, 0.88, 0.95, 0.95] for a horizontal bar. 62 50 ; 63 ; PSCOLOR:This keyword is only applied if the output is being sent to51 ; @keyword PSCOLOR This keyword is only applied if the output is being sent to 64 52 ; a PostScript file. It indicates that the PostScript device 65 53 ; is configured for color output. If this keyword is set, then … … 74 62 ; are outputting to a color PostScript printer. 75 63 ; 76 ; RIGHT:This puts the labels on the right-hand side of a vertical64 ; @keyword RIGHT This puts the labels on the right-hand side of a vertical 77 65 ; color bar. It applies only to vertical color bars. 78 66 ; 79 ; TOP:This puts the labels on top of the bar rather than under it.67 ; @keyword TOP This puts the labels on top of the bar rather than under it. 80 68 ; The keyword only applies if a horizontal color bar is rendered. 81 69 ; 82 ; VERTICAL:Setting this keyword give a vertical color bar. The default70 ; @keyword VERTICAL Setting this keyword give a vertical color bar. The default 83 71 ; is a horizontal color bar. 84 72 ; 85 ; COMMON BLOCKS: 86 ; None. 87 ; 88 ; SIDE EFFECTS: 89 ; Color bar is drawn in the current graphics window. 90 ; 91 ; RESTRICTIONS: 92 ; The number of colors available on the display device (not the 73 ; @restrictions Color bar is drawn in the current graphics window. 74 ; 75 ; @restrictions The number of colors available on the display device (not the 93 76 ; PostScript device) is used unless the NCOLORS keyword is used. 94 77 ; 95 ; EXAMPLE: 96 ; To display a horizontal color bar above a contour plot, type: 97 ; 98 ; LOADCT, 5, NCOLORS=100 99 ; CONTOUR, DIST(31,41), POSITION=[0.15, 0.15, 0.95, 0.75], $ 100 ; C_COLORS=INDGEN(25)*4, NLEVELS=25 101 ; COLORBAR, NCOLORS=100 102 ; 103 ; MODIFICATION HISTORY: 104 ; Written by: David Fanning, 10 JUNE 96. 78 ; @examples To display a horizontal color bar above a contour plot, type: 79 ; 80 ; IDL> LOADCT, 5, NCOLORS=100 81 ; IDL> CONTOUR, DIST(31,41), POSITION=[0.15, 0.15, 0.95, 0.75], $ 82 ; IDL> C_COLORS=INDGEN(25)*4, NLEVELS=25 83 ; IDL> COLORBAR, NCOLORS=100 84 ; 85 ; @history Written by: David Fanning, 10 JUNE 96. 105 86 ; 10/27/96: Added the ability to send output to PostScript. DWF 106 87 ; 11/4/96: Substantially rewritten to go to screen or PostScript … … 113 94 ; 3/3/98: ajout du keyword discret par 114 95 ; sebastien (smasson@lodyc.jussieu.fr) 96 ; 97 ; @version $Id$ 98 ; 115 99 ;- 116 100 117 101 PRO COLORBAR, BOTTOM=bottom, CB_CHARSIZE=cb_charsize, CB_CHARTHICK=cb_charthick $ 118 102 , CB_COLOR=cb_color, $ 119 DIVISIONS=divisions, DISCRET =discret,CB_LABEL = cb_label, $103 DIVISIONS=divisions, DISCRETE=discrete,CB_LABEL = cb_label, $ 120 104 FORMAT=format, POSITION=position, MAX=max, MIN=min, NCOLORS=ncolors, $ 121 105 PSCOLOR=pscolor, CB_TITLE=cb_title, VERTICAL=vertical, TOP=top, RIGHT=right, CB_LOG = CB_log, _extra = ex … … 189 173 190 174 IF KEYWORD_SET(vertical) THEN BEGIN 191 IF KEYWORD_SET(discret ) THEN begin192 facteur=256/n_elements(discret )193 discret =reform(replicate(1,facteur) # discret,facteur*n_elements(discret), /overwrite)194 bar = REPLICATE(1B,10) # discret 175 IF KEYWORD_SET(discrete) THEN begin 176 facteur=256/n_elements(discrete) 177 discrete=reform(replicate(1,facteur) # discrete,facteur*n_elements(discrete), /overwrite) 178 bar = REPLICATE(1B,10) # discrete 195 179 endif else bar = REPLICATE(1B,10) # BINDGEN(256) 196 180 IF N_ELEMENTS(position) EQ 0 THEN position = [0.88, 0.15, 0.95, 0.95] 197 181 ENDIF ELSE BEGIN 198 IF KEYWORD_SET(discret ) THEN begin199 facteur=256/n_elements(discret )200 discret =reform(replicate(1,facteur) # discret,facteur*n_elements(discret), /overwrite)201 bar = discret # REPLICATE(1B,10)182 IF KEYWORD_SET(discrete) THEN begin 183 facteur=256/n_elements(discrete) 184 discrete=reform(replicate(1,facteur) # discrete,facteur*n_elements(discrete), /overwrite) 185 bar = discrete # REPLICATE(1B,10) 202 186 endif else bar = BINDGEN(256) # REPLICATE(1B, 10) 203 187 IF N_ELEMENTS(position) EQ 0 THEN position = [0.15, 0.88, 0.95, 0.95] … … 205 189 206 190 ; Scale the color bar. 207 IF NOT KEYWORD_SET(discret ) THEN $191 IF NOT KEYWORD_SET(discrete) THEN $ 208 192 bar = BYTSCL(bar, TOP=ncolors-1) + bottom 209 193 -
trunk/SRC/Colors/getcolor.pro
r132 r133 1 1 ;+ 2 ; NAME: 3 ; GETCOLOR 4 ; 5 ; PURPOSE: 6 ; The original purpose of this function was to enable the 7 ; user to specify one of the 16 colors supported by the 8 ; McIDAS color map by name. Over time, however, the function 9 ; has become a general purpose function for handling and 10 ; supporting drawing colors in a device-independent way. 11 ; In particular, I have been looking for ways to write color 12 ; handling code that will work transparently on both 8-bit and 13 ; 24-bit machines. On 24-bit machines, the code should work the 14 ; same where color decomposition is turned on or off. 2 ; 3 ; @file_comments 4 ; The original purpose of this function was to enable the 5 ; user to specify one of the 16 colors supported by the 6 ; McIDAS color map by name. Over time, however, the function 7 ; has become a general purpose function for handling and 8 ; supporting drawing colors in a device-independent way. 9 ; In particular, I have been looking for ways to write color 10 ; handling code that will work transparently on both 8-bit and 11 ; 24-bit machines. On 24-bit machines, the code should work the 12 ; same where color decomposition is turned on or off. 15 13 ; 16 14 ; (The 16 supported colors in GETCOLOR come from the McIDAS color 17 15 ; table offered on the IDL newsgroup by Liam Gumley.) 18 16 ; 19 ; CATEGORY: 20 ; Graphics, Color Specification. 21 ; 22 ; CALLING SEQUENCE: 23 ; result = GETCOLOR(color) 24 ; 25 ; OPTIONAL INPUT PARAMETERS: 26 ; COLOR: A string with the "name" of the color. Valid names are: 17 ; @categories Graphics, Color Specification. 18 ; 19 ; @param thisColor {in}{optional} A string with the "name" of the color. Valid names are: 27 20 ; black 28 21 ; magenta … … 53 46 ; IDL 5.2 or higher. 54 47 ; 55 ; INDEX:The color table index where the specified color should be loaded.48 ; @param index {in}{optional} The color table index where the specified color should be loaded. 56 49 ; If this parameter is passed, then the return value of the function is the 57 50 ; index number and not the color triple. (If color decomposition is turned … … 69 62 ; TVLCT, colors, 100 70 63 ; 71 ; 72 ; INPUT KEYWORD PARAMETERS: 73 ; 74 ; NAMES: If this keyword is set, the return value of the function is 64 ; @keyword NAMES If this keyword is set, the return value of the function is 75 65 ; a 16-element string array containing the names of the colors. 76 66 ; These names would be appropriate, for example, in building … … 80 70 ; listID = Widget_List(baseID, Value=GetColor(/Names), YSize=16) 81 71 ; 82 ; LOAD:If this keyword is set, all 16 colors are automatically loaded72 ; @keyword LOAD If this keyword is set, all 16 colors are automatically loaded 83 73 ; starting at the color index specified by the START keyword. 84 74 ; Note that setting this keyword means that the return value of the … … 92 82 ; byte array or a long integer value. 93 83 ; 94 ; START:The starting color index number if the LOAD keyword is set. This keyword84 ; @keyword START The starting color index number if the LOAD keyword is set. This keyword 95 85 ; value is ignored unless the LOAD keyword is also set. The keyword is also 96 86 ; ignored if the TRUE keyword is set or if color decomposition in on in … … 98 88 ; !D.TABLE_SIZE - 17. 99 89 ; 100 ; TRUE:If this keyword is set, the specified color triple is returned90 ; @keyword TRUE If this keyword is set, the specified color triple is returned 101 91 ; as a 24-bit integer equivalent. The lowest 8 bits correspond to 102 92 ; the red value; the middle 8 bits to the green value; and the … … 105 95 ; were set. 106 96 ; 107 ; COMMON BLOCKS: 108 ; None. 109 ; 110 ; SIDE EFFECTS: 111 ; None. 112 ; 113 ; RESTRICTIONS: 114 ; The TRUE keyword causes the START keyword to be ignored. 97 ; @restrictions The TRUE keyword causes the START keyword to be ignored. 115 98 ; The NAMES keyword causes the COLOR, INDEX, START, and TRUE parameters to be ignored. 116 99 ; The COLOR parameter is ignored if the LOAD keyword is used. … … 119 102 ; returned if color decomposition is ON. 120 103 ; 121 ; EXAMPLE:122 ; 123 ; 124 ; yellow = GETCOLOR('yellow', 100)125 ; PLOT, data, COLOR=yellow104 ; 105 ; @examples To load a yellow color in color index 100 and plot in yellow, type: 106 ; 107 ; IDL> yellow = GETCOLOR('yellow', 100) 108 ; IDL> PLOT, data, COLOR=yellow 126 109 ; 127 110 ; or, 128 111 ; 129 ; PLOT, data, COLOR=GETCOLOR('yellow', 100)112 ; IDL> PLOT, data, COLOR=GETCOLOR('yellow', 100) 130 113 ; 131 114 ; To do the same thing on a 24-bit color system with decomposed color on, type: 132 115 ; 133 ; PLOT, data, COLOR=GETCOLOR('yellow', /TRUE)116 ; IDL> PLOT, data, COLOR=GETCOLOR('yellow', /TRUE) 134 117 ; 135 118 ; or in IDL 5.2 and higher, 136 119 ; 137 ; DEVICE, Decomposed=1138 ; PLOT, data, COLOR=GETCOLOR('yellow')120 ; IDL> DEVICE, Decomposed=1 121 ; IDL> PLOT, data, COLOR=GETCOLOR('yellow') 139 122 ; 140 123 ; To load all 16 colors into the current color table, starting at 141 124 ; color index 200, type: 142 125 ; 143 ; TVLCT, GETCOLOR(), 200126 ; IDL> TVLCT, GETCOLOR(), 200 144 127 ; 145 128 ; To add the color names to a list widget: 146 129 ; 147 ; listID = Widget_List(baseID, Value=GetColor(/Names), YSize=16)130 ; IDL> listID = Widget_List(baseID, Value=GetColor(/Names), YSize=16) 148 131 ; 149 132 ; To load all 16 colors and have the color indices returned in a structure: 150 133 ; 151 ; DEVICE, Decomposed=0152 ; colors = GetColor(/Load, Start=1)153 ; HELP, colors, /Structure134 ; IDL> DEVICE, Decomposed=0 135 ; IDL> colors = GetColor(/Load, Start=1) 136 ; IDL> HELP, colors, /Structure 154 137 ; PLOT, data, COLOR=colors.yellow 155 138 ; 156 139 ; To get the direct color values as 24-bit integers in color structure fields: 157 140 ; 158 ; DEVICE, Decomposed=1159 ; colors = GetColor(/Load)160 ; PLOT, data, COLOR=colors.yellow141 ; IDL> DEVICE, Decomposed=1 142 ; IDL> colors = GetColor(/Load) 143 ; IDL> PLOT, data, COLOR=colors.yellow 161 144 ; 162 145 ; Note that the START keyword value is ignored if on a 24-bit device, … … 164 147 ; writing code like this: 165 148 ; 166 ; colors = GetColor(/Load) 167 ; PLOT, data, Color=colors.yellow 168 ; 169 ; MODIFICATION HISTORY: 170 ; Written by: David Fanning, 10 February 96. 149 ; IDL> colors = GetColor(/Load) 150 ; IDL> PLOT, data, Color=colors.yellow; IDL> DEVICE, Decomposed=0 151 ; IDL> colors = GetColor(/Load, Start=1) 152 ; IDL> HELP, colors, /Structure 153 ; PLOT, data, COLOR=colors.yellow 154 ; 155 ; To get the direct color values as 24-bit integers in color structure fields: 156 ; 157 ; IDL> DEVICE, Decomposed=1 158 ; IDL> colors = GetColor(/Load) 159 ; IDL> PLOT, data, COLOR=colors.yellow 160 ; 161 ; Note that the START keyword value is ignored if on a 24-bit device, 162 ; so it is possible to write completely device-independent code by 163 ; writing code like this: 164 ; 165 ; IDL> colors = GetColor(/Load) 166 ; IDL> PLOT, data, Color=colors.yellow 167 ; 168 ; @history Written by: David Fanning, 10 February 96. 171 169 ; Fixed a bug in which N_ELEMENTS was spelled wrong. 7 Dec 96. DWF 172 170 ; Added the McIDAS colors to the program. 24 Feb 99. DWF … … 176 174 ; Added automatic recognition of DECOMPOSED=1 state. 7 June 99. DWF 177 175 ; Added LOAD AND START keywords. 7 June 99. DWF. 176 ; 177 ; @version $Id$ 178 178 ;- 179 180 181 182 FUNCTION COLOR24, number183 ;184 compile_opt idl2, strictarrsubs185 ;186 187 ; This FUNCTION accepts a [red, green, blue] triple that188 ; describes a particular color and returns a 24-bit long189 ; integer that is equivalent to that color. The color is190 ; described in terms of a hexidecimal number (e.g., FF206A)191 ; where the left two digits represent the blue color, the192 ; middle two digits represent the green color, and the right193 ; two digits represent the red color.194 ;195 ; The triple can be either a row or column vector of 3 elements.196 197 ON_ERROR, 1198 199 IF N_ELEMENTS(number) NE 3 THEN $200 MESSAGE, 'Augument must be a three-element vector.'201 202 IF MAX(number) GT 255 OR MIN(number) LT 0 THEN $203 MESSAGE, 'Argument values must be in range of 0-255'204 205 base16 = [[1L, 16L], [256L, 4096L], [65536L, 1048576L]]206 207 num24bit = 0L208 209 FOR j=0,2 DO num24bit = num24bit + ((number[j] MOD 16) * base16[0,j]) + $210 (Fix(number[j]/16) * base16[1,j])211 212 RETURN, num24bit213 END ; ************************ of COLOR24 ******************************214 215 216 179 217 180 FUNCTION GETCOLOR, thisColor, index, TRUE=truecolor, $ -
trunk/SRC/Colors/lct.pro
r132 r133 3 3 ;------------------------------------------------------------ 4 4 ;+ 5 ; NAME:lct6 5 ; 7 ; PURPOSE:plus court que de taper loadct,file='palette.tbl' 6 ; @file_comments 7 ; Fastest than type loadct,file='palette.tbl' 8 8 ; 9 ; CATEGORY:flemme9 ; @categories graphics, color specification 10 10 ; 11 ; CALLING SEQUENCE:lct[,numerp_couleur]11 ; @param numpal {in}{optional} number of the color palette we want to select in the file palette.tbl 12 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 13 ; @keyword LIGHTNESS a scalar used to change the Lightness of the color 18 14 ; palette to be abble to adjust according to the printer we use, 19 15 ; the media (paper or slide)... … … 21 17 ; > 1 to get darker colors 22 18 ; 23 ; rq: si le mot cle file n''est pas specifie, on cherche un fichier24 ; contenant les palette du nom depalette.tbl.25 ; Ce fichier peut etre dans n''importe quel repertoire du!path19 ; @keyword FILE {default=palette.tbl} is not specified, we are looking a file containing 20 ; palettes named palette.tbl. 21 ; This file can be in any directory of the !path 26 22 ; 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 23 ; @keyword GET_NAME 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. 25 ; 26 ; @keyword _EXTRA Used to pass your keywords 27 ; 28 ; @history Sebastien Masson (smasson@lodyc.jussieu.fr) 29 ; 30/3/1999: add extra 30 ; 6/7/1999: mac/windows comptibility 31 ; 32 ; @version $Id$ 33 ; 32 34 ;- 33 35 ;------------------------------------------------------------ 34 36 ;------------------------------------------------------------ 35 37 ;------------------------------------------------------------ 36 PRO lct, num ero, GET_NAME = get_name, LIGHTNESS = Lightness, _EXTRA = ex38 PRO lct, numpal, FILE = file, GET_NAME = get_name, LIGHTNESS = Lightness, _EXTRA = ex 37 39 ; 38 40 compile_opt idl2, strictarrsubs 39 41 ; 40 42 @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? 43 ; definition of the name of the file containing colors palettes. 44 if keyword_set(file) then nametbl = file ELSE nametbl = 'palette.tbl' 45 ; What is the full adress of nametbl? 47 46 thisOS = strupcase(strmid(!version.os_family, 0, 3)) 48 47 CASE thisOS of … … 52 51 ENDCASE 53 52 cd, current = current 54 if strpos(n ompal,sep) lt 0 then BEGIN53 if strpos(nametbl,sep) lt 0 then BEGIN 55 54 if rstrpos(current,sep) NE strlen(current)-1 then current = current+sep 56 55 multipath = str_sep(!path,pathsep) … … 58 57 if rstrpos(multipath[i],sep) NE strlen(multipath[i])-1 then $ 59 58 multipath[i] = multipath[i] +sep 60 n ompal = [current, multipath]+ nompal59 nametbl = [current, multipath]+ nametbl 61 60 ENDIF 62 ; on test tous les noms possibles pour trouver ou est le fichier63 nfile=n_elements(n ompal)61 ; we test all possible name in order to find where file is. 62 nfile=n_elements(nametbl) 64 63 n = 0 65 64 repeat begin 66 res = findfile(n ompal[n])65 res = findfile(nametbl[n]) 67 66 n = n+1 68 endrep until res[0] NE '' OR n EQ n_elements(n ompal)67 endrep until res[0] NE '' OR n EQ n_elements(nametbl) 69 68 if res[0] NE '' then BEGIN 70 n ompal = nompal[n-1]69 nametbl = nametbl[n-1] 71 70 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 71 if (where(tag_names(ex) EQ 'FILE'))[0] NE -1 then ex.FILE = nametbl 72 ; if we are in POSTSCRIPT mode, we have to pass in X mode in order to change the color palette 75 73 oldname = !d.name 76 74 if !d.name EQ 'PS' OR !d.name EQ 'Z' then BEGIN … … 89 87 ; 90 88 if arg_present(get_name) then begin 91 if n_elements(num ero) EQ 0 then loadct, file=nompal, GET_NAME = get_name, _EXTRA = ex $92 ELSE loadct,num ero, file=nompal, /silent, GET_NAME = get_name,_EXTRA = ex89 if n_elements(numpal) EQ 0 then loadct, file=nametbl, GET_NAME = get_name, _EXTRA = ex $ 90 ELSE loadct,numpal, file=nametbl, /silent, GET_NAME = get_name,_EXTRA = ex 93 91 ENDIF ELSE BEGIN 94 if n_elements(num ero) EQ 0 then loadct, file=nompal, _EXTRA = ex $95 ELSE loadct,num ero, file=nompal, /silent, _EXTRA = ex92 if n_elements(numpal) EQ 0 then loadct, file=nametbl, _EXTRA = ex $ 93 ELSE loadct,numpal, file=nametbl, /silent, _EXTRA = ex 96 94 ENDELSE 97 95 ; -
trunk/SRC/Colors/newpalette.pro
r132 r133 3 3 ;------------------------------------------------------------ 4 4 ;+ 5 ; NAME:newpalette6 5 ; 7 ; PURPOSE:permet de stocker la palette qui est a l''ecran dans un 8 ; fichier du meme type que celui fournit par defaut dans IDL: 6 ; @file_comments 7 ; Allows to stock the palette which is on the screen 8 ; in a same type file than the one gave by default in IDL 9 9 ; 'colors1.tbl'. 10 10 ; 11 ; CATEGORY:pour garder ses jolies palettes perso.11 ; @categories graphic, color specification 12 12 ; 13 ; CALLING SEQUENCE:newpalette,nom_de_palette13 ; @param namepal {in}{required} It is a string containing the name of the new palettte we want to write. 14 14 ; 15 ; INPUTS:nom_de_palette: c'est un string qui contient le nom de la16 ; nouvelle palette que l''on veut ecrire.15 ; @keyword OVER It is a whole number which designate the number of the palette 16 ; we want to replace the palette on the screen 17 17 ; 18 ; KEYWORD PARAMETERS: 18 ; @keyword FILE {default=palette.tbl} is not specified, we are looking a file containing 19 ; palettes named palette.tbl. 20 ; This file can be in any directory of the !path 21 ; On the other hand it must be writable 19 22 ; 20 ; OVER: c''est un entier qui designe le numero de la palette que l''on 21 ; veut remplacer par la palette a l''ecran. 22 ; 23 ; + ceux de modifyct 23 ; @keyword _extra Used to pass your keywords 24 24 ; 25 ; rq: si le mot cle file n''est pas specifie, on cherche un fichier 26 ; contenant les palettes du nom de palette.tbl. 27 ; Ce fichier peut etre dans n''importe quel repertoire du !path 28 ; Par contre il doit etre en droit d''ecriture 25 ; @history Guillaume Roulet (gr@lodyc.jussieu.fr) 26 ; 30/3/1999 s.masson, add _extra, research of the full name, OVER 27 ; 5/5/1999 s.masson 29 28 ; 30 ; MODIFICATION HISTORY: Guillaume Roulet (gr@lodyc.jussieu.fr) 31 ; 30/3/1999 s.masson, ajout de _extra, de le 32 ; recherche du nom complet, de OVER et du blabla 33 ; 5/5/1999 s.masson, va copie eventuelle du 34 ; fichier contenant les palettes 29 ; @version $Id$ 30 ; 31 ; @todo seb cleaning + traduction 35 32 ;- 36 33 ;------------------------------------------------------------ 37 34 ;------------------------------------------------------------ 38 35 ;------------------------------------------------------------ 39 pro newpalette,nom, OVER = over, _extra = ex 40 ; le mot cle file est passe par l''intermediere de EXTRA? 41 ; definition du mon du fichier qui contient les palettes de couleur 36 pro newpalette,namepal, FILE = file, OVER = over, _extra = ex 42 37 ; 43 38 compile_opt idl2, strictarrsubs 44 39 ; 45 if n_elements(ex) NE 0 then BEGIN 46 if (where(tag_names(ex) EQ 'FILE'))[0] NE -1 then nompal=ex.FILE ELSE nompal='palette.tbl' 47 ENDIF ELSE nompal = 'palette.tbl' 48 nomcourt = nompal 49 ; quelle est l''adresse complete de nompal? 50 nompal = find(nompal) 51 if nompal[0] NE 'NOT FOUND' then begin 52 nompal = nompal[0] 53 ; nompal nous appartient??? 40 ; definition of the name of the file containing colors palettes. 41 if keyword_set(file) then nametbl = file ELSE nametbl = 'palette.tbl' 42 nomcourt = nametbl 43 ; What is the full adress of nametbl? 44 nametbl = find(nametbl) 45 if nametbl[0] NE 'NOT FOUND' then begin 46 nametbl = nametbl[0] 47 ; does nametbl is our? 54 48 spawn, 'whoami', login 55 appartient = strpos(n ompal, login[0])49 appartient = strpos(nametbl, login[0]) 56 50 if appartient EQ -1 then begin 57 ouinon = report('Le fichier '+n ompal+' ne vous appartient pas, Voulez-vous copier le fichier '+nomcourt+' dans le repertoire courant: '+current+' ?', /default_no, /question)51 ouinon = report('Le fichier '+nametbl+' ne vous appartient pas, Voulez-vous copier le fichier '+nomcourt+' dans le repertoire courant: '+current+' ?', /default_no, /question) 58 52 if ouinon then return ELSE BEGIN 59 spawn, 'cp '+n ompal+' '+nomcourt ; on copie60 n ompal = nomcourt61 spawn, 'chmod u+w '+n ompal ; on se donne les droits d''ecriture53 spawn, 'cp '+nametbl+' '+nomcourt ; copy 54 nametbl = nomcourt 55 spawn, 'chmod u+w '+nametbl ; give writing rights 62 56 ENDELSE 63 57 endif 64 ENDIF ELSE BEGIN ; aucun fichier nompal a ete trouve65 n ompal = nomcourt ; on recupe le nompal d''origine66 ouinon = report('le fichier de palettes demande '+n ompal+' n''existe pas ds les repertoires !path. Voulez-vous cree un fichier '+nompal+' dans le repertoire courant', /default_no, /question)58 ENDIF ELSE BEGIN ; no file nametbl found 59 nametbl = nomcourt ; we reclaim the nametbl source 60 ouinon = report('le fichier de palettes demande '+nametbl+' n''existe pas ds les repertoires !path. Voulez-vous cree un fichier '+nametbl+' dans le repertoire courant', /default_no, /question) 67 61 if NOT ouinon then return 68 62 nomfichsource = filepath('colors1.tbl', subdir=['resource', 'colors']) 69 spawn,'cp '+nomfichsource+' '+n ompal ; on copie70 spawn, 'chmod u+w '+n ompal ; on se donne les droits d''ecriture63 spawn,'cp '+nomfichsource+' '+nametbl ; copy 64 spawn, 'chmod u+w '+nametbl ; give writing rights 71 65 ENDELSE 72 66 73 67 if n_elements(ex) NE 0 then $ 74 if (where(tag_names(ex) EQ 'FILE'))[0] NE -1 then ex.FILE = n ompal68 if (where(tag_names(ex) EQ 'FILE'))[0] NE -1 then ex.FILE = nametbl 75 69 ; 76 70 tvlct,r,g,b,/get … … 79 73 b=congrid(b,256) 80 74 IF n_elements(over) EQ 0 then over = 255 81 modifyct,over,n om,r,g,b,file=nompal, _extra = ex75 modifyct,over,namepal,r,g,b,file=nametbl, _extra = ex 82 76 ; 83 77 return -
trunk/SRC/Colors/xlct.pro
r132 r133 1 ; $Id$2 ;3 ; Copyright (c) 1991-1998, Research Systems, Inc. All rights reserved.4 ; Unauthorized reproduction prohibited.5 1 6 2 PRO XLCT_PSAVE ;Save/Restore our plotting state. … … 375 371 376 372 ;+ 377 ; NAME: 378 ; XLCT 379 ; PURPOSE: 380 ; comme xloadct mais plus cour a ecrire et appelle par defaut la 381 ; palette palette.tbl qui peut etre situee dans n''importe quel 382 ; repertoire de !path. 383 ; 384 ; CATEGORY: 385 ; Widgets 386 ; CALLING SEQUENCE: 387 ; XLCT 388 ; INPUTS: 389 ; None. 390 ; KEYWORDS: 391 ; FILE: If this keyword is set, the file by the given name is used 373 ; @file_comments 374 ; Like xloadct but fastest to write and call by default the palette 375 ; palette.tbl which can be in any directory 376 ; 377 ; @categories Widgets 378 ; 379 ; @keyword FILE If this keyword is set, the file by the given name is used 392 380 ; instead of the file colors1.tbl in the IDL directory. This 393 381 ; allows multiple IDL users to have their own color table file. 394 ; GROUP =The widget ID of the widget that calls Xlct. When382 ; @keyword GROUP The widget ID of the widget that calls Xlct. When 395 383 ; this ID is specified, a death of the caller results in a 396 384 ; death of Xlct 397 ; 385 ; @keyword NCOLORS = number of colors to use. Use color indices from BOTTOM 398 386 ; to the smaller of !D.TABLE_SIZE-1 and NCOLORS-1. 399 387 ; Default = !D.TABLE_SIZE = all available colors. 400 ; 388 ; @keyword BOTTOM = first color index to use. Use color indices from BOTTOM to 401 389 ; BOTTOM+NCOLORS-1. Default = 0. 402 ; 390 ; @keyword SILENT - Normally, no informational message is printed when 403 391 ; a color map is loaded. If this keyword is present and 404 392 ; zero, this message is printed. 405 ; 393 ; @keyword USE_CURRENT: If set, use the current color tables, regardless of 406 394 ; the contents of the COMMON block COLORS. 407 ; 395 ; @keyword MODAL: If set, then XLCT runs in "modal" mode, meaning that 408 396 ; all other widgets are blocked until the user quits XLCT. 409 397 ; A group leader must be specified (via the GROUP keyword) 410 398 ; for the MODAL keyword to have any effect. The default 411 399 ; is to not run in modal mode. 412 ; 400 ; @keyword BLOCK: Set this keyword to have XMANAGER block when this 413 401 ; application is registered. By default the Xmanager 414 402 ; keyword NO_BLOCK is set to 1 to provide access to the … … 418 406 ; application. For more information see the NO_BLOCK keyword 419 407 ; to XMANAGER. 420 ; 408 ; @keyword UPDATECALLBACK: Set this keyword to a string containing the name of 421 409 ; a user-supplied procedure that will be called when the color 422 410 ; table is updated by XLCT. The procedure may optionally … … 424 412 ; set to the value specified by the optional UPDATECBDATA 425 413 ; keyword. 426 ; 414 ; @keyword UPDATECBDATA: Set this keyword to a value of any type. It will be 427 415 ; passed via the DATA keyword to the user-supplied procedure 428 416 ; specified via the UPDATECALLBACK keyword, if any. If the … … 431 419 ; will be undefined. 432 420 ; 433 ; OUTPUTS: 434 ; None. 435 ; COMMON BLOCKS: 436 ; None. 437 ; SIDE EFFECTS: 438 ; One of the predefined color maps may be loaded. 439 ; RESTRICTIONS: 440 ; This routine uses the LOADCT user library procedure to 421 ; @restrictions One of the predefined color maps may be loaded. 422 ; 423 ; @restrictions This routine uses the LOADCT user library procedure to 441 424 ; do the actual work. 442 ; MODIFICATION HISTORY: 443 ; 5/5/1999 copie de xloadct par Sebastien Masson (smlod@ipsl.jussieu.fr) 425 ; 426 ; @history 5/5/1999 copie de xloadct par Sebastien Masson (smlod@ipsl.jussieu.fr) 427 ; 428 ; @version $Id$ 429 ; 444 430 ;- 445 431 … … 471 457 IF KEYWORD_SET(SILENT_f) THEN silent = SILENT_F ELSE silent = 1 472 458 ;----------------------------------------------------------------------------- 473 ; changements effectues parS.Masson459 ; Changes made by S.Masson 474 460 ;----------------------------------------------------------------------------- 475 461 IF N_ELEMENTS(file) GT 0 THEN filename = file ELSE BEGIN -
trunk/SRC/Colors/xpal.pro
r132 r133 1 ; $Id$2 ;3 ; Copyright (c) 1992-1998, Research Systems, Inc. All rights reserved.4 ; Unauthorized reproduction prohibited.5 1 ;+ 6 ; NAME: 7 ; XPAL 8 ; 9 ; PURPOSE: 10 ; comme xpalette mais plus court a ecrire et possede en plus 11 ; une touche save qui (grace a la routine newpalette) permet de 12 ; sauver la routine que l''on vient de faire. Rq qd on appuie 13 ; sur la touche predefined appelle xlct plutot que xloadct 14 ; 15 ; CATEGORY: 16 ; Color tables, widgets. 17 ; 18 ; CALLING SEQUENCE: 19 ; XPAL 20 ; 21 ; INPUTS: 22 ; No explicit inputs. The current color table is used as a starting 23 ; point. 24 ; 25 ; KEYWORD PARAMETERS: 26 ; BLOCK: Set this keyword to have XMANAGER block when this 2 ; 3 ; @file_comments 4 ; like xpalette but shorter to write and ,moreover, 5 ; possess a hotkey save which (thanks to the newpalette routine) 6 ; allows to save the routine that we have just done. Comment: when we 7 ; press the predefined hotkey, it calls xlct instead of xloadct 8 ; No explicit inputs. The current color table is used as a starting point. 9 ; 10 ; @categories Color tables, widgets. 11 ; 12 ; @keyword BLOCK Set this keyword to have XMANAGER block when this 27 13 ; application is registered. By default the Xmanager 28 14 ; keyword NO_BLOCK is set to 1 to provide access to the … … 32 18 ; application. For more information see the NO_BLOCK keyword 33 19 ; to XMANAGER. 34 ; UPDATECALLBACK:Set this keyword to a string containing the name of20 ; @keyword UPDATECALLBACK Set this keyword to a string containing the name of 35 21 ; a user-supplied procedure that will be called when the color 36 22 ; table is updated by XLOADCT. The procedure may optionally … … 38 24 ; set to the value specified by the optional UPDATECBDATA 39 25 ; keyword. 40 ; UPDATECBDATA:Set this keyword to a value of any type. It will be26 ; @keyword UPDATECBDATA Set this keyword to a value of any type. It will be 41 27 ; passed via the DATA keyword to the user-supplied procedure 42 28 ; specified via the UPDATECALLBACK keyword, if any. If the … … 45 31 ; will be undefined. 46 32 ; 47 ; OUTPUTS: 48 ; None. 49 ; 50 ; COMMON BLOCKS: 51 ; COLORS: Contains the current RGB color tables. 52 ; XP_COM: Private to this module. 53 ; 54 ; SIDE EFFECTS: 55 ; XPAL uses two colors from the current color table as 33 ; @uses COLORS: Contains the current RGB color tables. 34 ; @uses XP_COM: Private to this module. 35 ; 36 ; @restrictions XPAL uses two colors from the current color table as 56 37 ; drawing foreground and background colors. These are used 57 38 ; for the RGB plots on the left, and the current index marker on … … 72 53 ; to the display. 73 54 ; 74 ; PROCEDURE: 75 ; The XPAL widget has the following controls: 55 ; @examples The XPAL widget has the following controls: 76 56 ; 77 57 ; Left: Three plots showing the current Red, Green, and Blue vectors. … … 95 75 ; pressed: 96 76 ; 97 ; Done:Exits XPAL.98 ; 99 ; Predefined:Starts XLOADCT to allow selection of one of the77 ; Done: Exits XPAL. 78 ; 79 ; Predefined: Starts XLOADCT to allow selection of one of the 100 80 ; predefined color tables. 101 81 ; 102 ; Help:Supplies help information similar to this header.82 ; Help: Supplies help information similar to this header. 103 83 ; 104 84 ; Redraw: Completely redraws the display using the current … … 117 97 ; index and the mark index are interpolated linearly 118 98 ; to lie between the colors of two endpoints. 119 ; save: permet de sauver la palette qui est 120 ; actuellement a l''ecran. Qd on appuie sur ce 121 ; bouton, un widget apparait qui demande: 122 ; 1) le nom a donner a la palette que l''on veut sauver 123 ; 2) le numero de la palette que l''on veut 124 ; eventuellement ecrase par la nouvelle 125 ; palette.Si aucun numero n''est specifie la 126 ; nouvelle palette estajoutee aux anciennes. 127 ; 3) le nom du fichier qui contient les 128 ; palettes. Rq: suivre eventuellement les 129 ; indications fournis au prompteur. 99 ; save: Allows to save the palette which is currently 100 ; on the screen. When we press this hotkey, there is a 101 ; widget who appear and ask: 102 ; 1) the name of the palette we want to save. 103 ; 2) The number of the palette we may want to erase 104 ; by the new palette. If there is not any number 105 ; specified, the new palette is add to elders. 106 ; 3) The name of the file containing palettes. 107 ; Comment: May follow instructions gave by the prompter. 130 108 ; 131 109 ; … … 147 125 ; horizontally. 148 126 ; 149 ; MODIFICATION HISTORY: 150 ; addaptation de xpalette pour ajouter un bouton save par 127 ; @history addaptation de xpalette pour ajouter un bouton save par 151 128 ; Gima Nicolas (nglod@ipsl.jussieu.fr) et par Masson 152 129 ; Sebastien (smlod@ipsl.jussieu.fr) 130 ; 131 ; $Id$ 132 ; 153 133 ;- 154 134 ; 135 ;+ 136 ; @file_comments XP_NEW_COLORS: Choose the best foreground and background colors for the current 137 ; color maps and set !P appropriately. Returns 1 if the colors changed, 138 ; 0 otherwise. 139 ; 140 ; @returns 1 or 0 141 ;- 155 142 function XP_NEW_COLORS 156 ; Choose the best foreground and background colors for the current157 ; color maps and set !P appropriately. Returns 1 if the colors changed,158 ; 0 otherwise.159 143 ; 160 144 compile_opt idl2, strictarrsubs … … 202 186 endif 203 187 end 204 188 ;+ 189 ; @file_comments XP_XLCTCALLBACK: For visuals with static colormaps, update the graphics 190 ; after a change by XLOADCT. 191 ;- 205 192 pro XP_XLCTCALLBACK 206 ; For visuals with static colormaps, update the graphics207 ; after a change by XLOADCT.208 193 ; 209 194 compile_opt idl2, strictarrsubs … … 230 215 end 231 216 232 233 234 pro XP_REPLOT, color_index, type 235 ; Re-draw the RGB plots. Type has the following possible values. 236 ;; - 'D': Draw the data part of all three plots 217 ;+ 218 ; @file_comments XP_REPLOT: Re-draw the RGB plots. Type has the following possible values. 219 ; - 'D': Draw the data part of all three plots 237 220 ; - 'F': draw all three plots 238 221 ; - 'R': Draw the data part of the Red plot 239 222 ; - 'G': Draw the data part of the Green plot 240 223 ; - 'B': Draw the data part of the Blue plot 224 ;- 225 pro XP_REPLOT, color_index, type 241 226 ; 242 227 compile_opt idl2, strictarrsubs … … 312 297 313 298 314 315 pro XP_CHANGE_COLOR, type, value 316 ; Change current color. Type has the following possible values. 299 ;+ 300 ; @file_comments XP_CHANGE_COLOR: Change current color. Type has the following possible values. 317 301 ; - 'R': Change the R part of the current color 318 302 ; - 'G': ... 319 303 ; - 'B': ... 304 ;- 305 pro XP_CHANGE_COLOR, type, value 320 306 ; 321 307 compile_opt idl2, strictarrsubs … … 553 539 554 540 555 541 ;+ 542 ; 543 ; @keyword group 544 ; 545 ; @keyword BLOCK Set this keyword to have XMANAGER block when this 546 ; application is registered. By default the Xmanager 547 ; keyword NO_BLOCK is set to 1 to provide access to the 548 ; command line if active command line processing is available. 549 ; Note that setting BLOCK for this application will cause 550 ; all widget applications to block, not only this 551 ; application. For more information see the NO_BLOCK keyword 552 ; to XMANAGER. 553 ; @keyword UPDATECALLBACK Set this keyword to a string containing the name of 554 ; a user-supplied procedure that will be called when the color 555 ; table is updated by XLOADCT. The procedure may optionally 556 ; accept a keyword called DATA, which will be automatically 557 ; set to the value specified by the optional UPDATECBDATA 558 ; keyword. 559 ; @keyword UPDATECBDATA Set this keyword to a value of any type. It will be 560 ; passed via the DATA keyword to the user-supplied procedure 561 ; specified via the UPDATECALLBACK keyword, if any. If the 562 ; UPDATECBDATA keyword is not set the value accepted by the 563 ; DATA keyword to the procedure specified by UPDATECALLBACK 564 ; will be undefined. 565 ; 566 ;- 556 567 557 568 … … 597 608 !p.color = nc -1 ;Foreground color 598 609 !p.font = 0 ;Hdw font 599 save_win = !d.window ;Previous window610 save_win = !d.window ;Previous window 600 611 601 612 IF N_ELEMENTS(r_orig) LE 0 THEN BEGIN ;If no common, use current colors
Note: See TracChangeset
for help on using the changeset viewer.