Changeset 137 for trunk/SRC/Colors
- Timestamp:
- 07/12/06 11:33:44 (18 years ago)
- Location:
- trunk/SRC/Colors
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/SRC/Colors/color24.pro
r136 r137 5 5 ; into the equivalent 24-big long integer. 6 6 ; 7 ; @categories Graphics, Color Specification.7 ; @categories Graphics, Color 8 8 ; 9 9 ; @param rgb_triple {in}{required} -
trunk/SRC/Colors/colorbar.pro
r136 r137 7 7 ; @categories Graphics, Widgets. 8 8 ; 9 ; @keyword BOTTOM 9 ; @keyword BOTTOM {default=0B} 10 10 ; The lowest color index of the colors to be loaded in the bar. 11 11 ; … … 22 22 ; to get logarithmic scale for the colorbar 23 23 ; 24 ; @keyword CB_TITLE 25 ; This is title for the color bar. The default is to have no title.26 ; 27 ; @keyword DISCRETE 24 ; @keyword CB_TITLE {default=''} 25 ; This is title for the color bar. 26 ; 27 ; @keyword DISCRETE 28 28 ; Vector which contain color's indexes to trace in a color bar. Therefore 29 ; we obtain a discre et color bar which only contains specified colors in30 ; order wherethey appear in the vector29 ; we obtain a discrete colorbar which contains only the specified colors 30 ; in the order they appear in the vector 31 31 ; 32 32 ; @keyword DIVISIONS {default=2} … … 37 37 ; The format of the bar annotations. 38 38 ; 39 ; @keyword CB_LABEL 40 ; It is a vector who specifies sticks's value attend in the color bar.41 ; It allowes, when we use DISCREET, to have colors which don't increase42 ; byincrements in a regular way.39 ; @keyword CB_LABEL 40 ; A vector to specify sticks values of the color bar. It allowes, 41 ; when we use DISCRETE, to have colors that don't increase by 42 ; increments in a regular way. 43 43 ; 44 44 ; @keyword MAX {default=NCOLORS - 1} … … 48 48 ; The minimum data value for the bar annotation. 49 49 ; 50 ; @keyword NCOLORS 50 ; @keyword NCOLORS {default=!D.N_COLORS} 51 51 ; This is the number of colors in the color bar. 52 52 ; … … 54 54 ; Force to don't write title even if CB_TITLE is declared. 55 55 ; 56 ; @keyword POSITION 56 ; @keyword POSITION {default=see bellow} 57 57 ; A four-element array of normalized coordinates in the same 58 58 ; form as the POSITION keyword on a plot. Default is … … 82 82 ; The keyword only applies if a horizontal color bar is rendered. 83 83 ; 84 ; @keyword VERTICAL 84 ; @keyword VERTICAL {default=0 -> horizontal color bar} 85 85 ; Setting this keyword give a vertical color bar. 86 ; The default is a horizontal color bar.87 ;88 ; @restrictions89 ; Color bar is drawn in the current graphics window.90 86 ; 91 87 ; @restrictions … … 101 97 ; IDL> COLORBAR, NCOLORS=100 102 98 ; 103 ; @history Written by: David Fanning, 10 JUNE 96. 104 ; 10/27/96: Added the ability to send output to Postscript. DWF 105 ; 11/4/96: Substantially rewritten to go to screen or Postscript 106 ; file without having to know much about the Postscript device 99 ; @history 100 ; Written by: David Fanning, 10 JUNE 96. 101 ; 10/27/96: Added the ability to send output to PostScript. DWF 102 ; 11/04/96: Substantially rewritten to go to screen or PostScript 103 ; file without having to know much about the PostScript device 107 104 ; or even what the current graphics device is. DWF 108 ; 1/27/97: Added the RIGHT and TOP keywords. Also modified the 109 ; way the TITLE keyword works. DWF 110 ; 7/15/97: Fixed a problem some machines have with plots that have 111 ; no valid data range in them. DWF 112 ; 3/3/98: ajout du keyword discret par 113 ; sebastien (smasson\@lodyc.jussieu.fr) 105 ; 01/27/97: Added the RIGHT and TOP keywords. Also modified the 106 ; way the TITLE keyword works. DWF 107 ; 07/15/97: Fixed a problem some machines have with plots that have 108 ; no valid data range in them. DWF 109 ; 03/03/98: Add DISCRETE keyword, sebastien masson (smasson\@lodyc.jussieu.fr) 114 110 ; 115 111 ; @version $Id$ 116 112 ; 117 113 ;- 118 PRO COLORBAR, BOTTOM=bottom, CB_CHARSIZE=cb_charsize, $ 119 CB_CHARTHICK=cb_charthick $ 120 , CB_COLOR=cb_color, $ 121 DIVISIONS=divisions, DISCRETE=discrete,CB_LABEL = cb_label, $ 122 FORMAT=format, POSITION=position, MAX=max, MIN=min, $ 123 NCOLORS=ncolors, $ 124 PSCOLOR=pscolor, CB_TITLE=cb_title, NOTITLE=notitle, $ 125 VERTICAL=vertical, $ 126 TOP=top, RIGHT=right, CB_LOG = CB_log, _extra = ex 127 ; Is the Postscript device selected? 114 PRO COLORBAR, BOTTOM=bottom, CB_CHARSIZE=cb_charsize, CB_CHARTHICK=cb_charthick $ 115 , CB_COLOR=cb_color, DIVISIONS=divisions, DISCRETE=discrete $ 116 , CB_LABEL = cb_label, FORMAT=format, POSITION=position $ 117 , MAX = max, MIN = min, NCOLORS = ncolors, PSCOLOR=pscolor $ 118 , CB_TITLE = cb_title, VERTICAL = vertical, TOP = top, RIGHT = right $ 119 , CB_LOG = CB_log, NOTITLE = notitle, _extra = ex 128 120 ; 129 121 compile_opt idl2, strictarrsubs 130 122 ; 131 123 ; Is the PostScript device selected? 132 124 postScriptDevice = (!D.NAME EQ 'PS') 133 125 … … 136 128 IF N_ELEMENTS(ncolors) EQ 0 THEN BEGIN 137 129 138 139 140 141 142 143 144 145 146 147 130 ; Most display devices to not use the 256 colors available to 131 ; the PostScript device. This presents a problem when writing 132 ; general-purpose programs that can be output to the display or 133 ; to the PostScript device. This problem is especially bothersome 134 ; if you don't specify the number of colors you are using in the 135 ; program. One way to work around this problem is to make the 136 ; default number of colors the same for the display device and for 137 ; the PostScript device. Then, the colors you see in PostScript are 138 ; identical to the colors you see on your display. Here is one way to 139 ; do it. 148 140 149 141 IF postScriptDevice THEN BEGIN 150 142 oldDevice = !D.NAME 151 143 152 153 144 ; What kind of computer are we using? SET_PLOT to appropriate 145 ; display device. 154 146 155 147 thisOS = !VERSION.OS_FAMILY … … 165 157 if !d.n_colors gt 256 then !p.background='ffffff'x 166 158 167 159 ; Open a window (to make sure !D.N_COLORS is accurate). 168 160 169 161 WINDOW, /FREE, /PIXMAP, XSIZE=10, YSIZE=10 170 162 WDELETE, !D.WINDOW 171 163 172 164 ; Here is how many colors we should use. 173 165 174 166 ncolors = !D.N_COLORS … … 209 201 ENDELSE 210 202 211 203 ; Scale the color bar. 212 204 IF NOT KEYWORD_SET(discrete) THEN $ 213 205 bar = BYTSCL(bar, TOP=ncolors-1) + bottom 214 206 215 207 ; Get starting locations in DEVICE coordinates. 216 208 217 209 xstart = position[0] * !D.X_VSIZE 218 210 ystart = position[1] * !D.Y_VSIZE 219 211 220 212 ; Get the size of the bar in DEVICE coordinates. 221 213 222 214 xsize = (position[2] - position[0]) * !D.X_VSIZE 223 215 ysize = (position[3] - position[1]) * !D.Y_VSIZE 224 216 225 226 227 217 ; For PostScript output only, draw the annotation in !P.COLOR 218 ; unless "pscolor" is set. This makes better output on grayscale 219 ; printers. 228 220 229 221 IF postScriptDevice AND (pscolor NE 1) THEN BEGIN … … 232 224 ENDIF 233 225 234 235 226 ; Display the color bar in the window. Sizing is 227 ; different for PostScript and regular display. 236 228 237 229 IF postScriptDevice THEN BEGIN … … 246 238 ENDELSE 247 239 248 240 ; Annotate the color bar. 249 241 250 242 if keyword_set(cb_label) then begin … … 312 304 313 305 ENDELSE 314 306 ; Restore color variable if changed for PostScript. 315 307 316 308 IF postScriptDevice AND (pscolor NE 1) THEN cb_color = oldcolor -
trunk/SRC/Colors/getcolor.pro
r136 r137 15 15 ; table offered on the IDL newsgroup by Liam Gumley.) 16 16 ; 17 ; @categories Graphics, Color Specification.17 ; @categories Graphics, Color 18 18 ; 19 19 ; @param thisColor {in}{optional} … … 36 36 ; white 37 37 ; 38 ; The color YELLOW is returned if the color name can't be resolved. 39 ; Case is unimportant. 40 ; 41 ; If the function is called with just this single input parameter, 42 ; the return value is either a 1-by-3 array containing the RGB values of 43 ; that particular color, or a 24-bit integer that can be "decomposed" into 44 ; that particular color, depending upon the state of the TRUE keyword and 45 ; upon whether color decomposition is turned on or off. The state of color 46 ; decomposition can ONLY be determined if the program is being run in 47 ; IDL 5.2 or higher. 38 ; The color YELLOW is returned if the color name can't be resolved. 39 ; Case is unimportant. 40 ; 48 41 ; 49 42 ; @param index {in}{optional} 50 43 ; The color table index where the specified color should be loaded. 51 ; If this parameter is passed, then the return value of the function is the 52 ; index number and not the color triple. (If color decomposition is turned 53 ; on AND the user specifies an index parameter, the color is loaded in the 54 ; color table at the proper index, but a 24-bit value is returned to the 55 ; user in IDL 5.2 and higher.) 56 ; 57 ; If no positional parameter is present, then the return value is either a 16-by-3 58 ; byte array containing the RGB values of all 16 colors or it is a 16-element 59 ; long integer array containing color values that can be decomposed into colors. 60 ; The 16-by-3 array is appropriate for loading color tables with the TVLCT command: 44 ; 45 ; @returns 46 ; If no positional parameter is present, then the return value is either a 16-by-3 47 ; byte array containing the RGB values of all 16 colors or it is a 16-element 48 ; long integer array containing color values that can be decomposed into colors. 49 ; The 16-by-3 array is appropriate for loading color tables with the TVLCT command: 61 50 ; 62 51 ; Device, Decomposed=0 63 52 ; colors = GetColor() 64 53 ; TVLCT, colors, 100 54 ; 55 ; If function is called with just this single input parameter, 56 ; the return value is either a 1-by-3 array containing the RGB values of 57 ; that particular color, or a 24-bit integer that can be "decomposed" into 58 ; that particular color, depending upon the state of the TRUE keyword and 59 ; upon whether color decomposition is turned on or off. The state of color 60 ; decomposition can ONLY be determined if the program is being run in 61 ; IDL 5.2 or higher. 62 ; 63 ; If index parameter is passed, then the return value of the function is the 64 ; index number and not the color triple. (If color decomposition is turned 65 ; on AND the user specifies an index parameter, the color is loaded in the 66 ; color table at the proper index, but a 24-bit value is returned to the 67 ; user in IDL 5.2 and higher.) 68 ; 65 69 ; 66 70 ; @keyword NAMES … … 112 116 ; To load a yellow color in color index 100 and plot in yellow, type: 113 117 ; 114 ; IDL> yellow = GETCOLOR('yellow', 100)115 ; IDL> PLOT, data, COLOR=yellow116 ; 117 ; 118 ; 119 ; IDL> PLOT, data, COLOR=GETCOLOR('yellow', 100)118 ; IDL> yellow = GETCOLOR('yellow', 100) 119 ; IDL> PLOT, data, COLOR=yellow 120 ; 121 ; or, 122 ; 123 ; IDL> PLOT, data, COLOR=GETCOLOR('yellow', 100) 120 124 ; 121 125 ; To do the same thing on a 24-bit color system with decomposed color on, type: 122 126 ; 123 ; IDL> PLOT, data, COLOR=GETCOLOR('yellow', /TRUE)124 ; 125 ; 126 ; 127 ; IDL> DEVICE, Decomposed=1128 ; IDL> PLOT, data, COLOR=GETCOLOR('yellow')127 ; IDL> PLOT, data, COLOR=GETCOLOR('yellow', /TRUE) 128 ; 129 ; or in IDL 5.2 and higher, 130 ; 131 ; IDL> DEVICE, Decomposed=1 132 ; IDL> PLOT, data, COLOR=GETCOLOR('yellow') 129 133 ; 130 134 ; To load all 16 colors into the current color table, starting at 131 135 ; color index 200, type: 132 136 ; 133 ; IDL> TVLCT, GETCOLOR(), 200137 ; IDL> TVLCT, GETCOLOR(), 200 134 138 ; 135 139 ; To add the color names to a list widget: 136 140 ; 137 ; IDL> listID = Widget_List(baseID, Value=GetColor(/Names), YSize=16)138 ; 139 ; To load all 16 colors and have the color ind exes returned in a structure:140 ; 141 ; IDL> DEVICE, Decomposed=0142 ; IDL> colors = GetColor(/Load, Start=1)143 ; IDL> HELP, colors, /Structure144 ; PLOT, data, COLOR=colors.yellow141 ; IDL> listID = Widget_List(baseID, Value=GetColor(/Names), YSize=16) 142 ; 143 ; To load all 16 colors and have the color indices returned in a structure: 144 ; 145 ; IDL> DEVICE, Decomposed=0 146 ; IDL> colors = GetColor(/Load, Start=1) 147 ; IDL> HELP, colors, /Structure 148 ; PLOT, data, COLOR=colors.yellow 145 149 ; 146 150 ; To get the direct color values as 24-bit integers in color structure fields: 147 151 ; 148 ; IDL> DEVICE, Decomposed=1149 ; IDL> colors = GetColor(/Load)150 ; IDL> PLOT, data, COLOR=colors.yellow152 ; IDL> DEVICE, Decomposed=1 153 ; IDL> colors = GetColor(/Load) 154 ; IDL> PLOT, data, COLOR=colors.yellow 151 155 ; 152 156 ; Note that the START keyword value is ignored if on a 24-bit device, … … 154 158 ; writing code like this: 155 159 ; 156 ; IDL> colors = GetColor(/Load)157 ; IDL> PLOT, data, Color=colors.yellow; IDL> DEVICE, Decomposed=0158 ; IDL> colors = GetColor(/Load, Start=1)159 ; IDL> HELP, colors, /Structure160 ; IDL>PLOT, data, COLOR=colors.yellow160 ; IDL> colors = GetColor(/Load) 161 ; IDL> PLOT, data, Color=colors.yellow; IDL> DEVICE, Decomposed=0 162 ; IDL> colors = GetColor(/Load, Start=1) 163 ; IDL> HELP, colors, /Structure 164 ; PLOT, data, COLOR=colors.yellow 161 165 ; 162 166 ; To get the direct color values as 24-bit integers in color structure fields: 163 167 ; 164 ; IDL> DEVICE, Decomposed=1165 ; IDL> colors = GetColor(/Load)166 ; IDL> PLOT, data, COLOR=colors.yellow168 ; IDL> DEVICE, Decomposed=1 169 ; IDL> colors = GetColor(/Load) 170 ; IDL> PLOT, data, COLOR=colors.yellow 167 171 ; 168 172 ; Note that the START keyword value is ignored if on a 24-bit device, … … 170 174 ; writing code like this: 171 175 ; 172 ; IDL> colors = GetColor(/Load) 173 ; IDL> PLOT, data, Color=colors.yellow 174 ; 175 ; @history Written by: David Fanning, 10 February 96. 176 ; Fixed a bug in which N_ELEMENTS was spelled wrong. 7 Dec 96. DWF 177 ; Added the McIDAS colors to the program. 24 Feb 99. DWF 178 ; Added the INDEX parameter to the program 8 Mar 99. DWF 179 ; Added the NAMES keyword at insistence of Martin Schultz. 10 Mar 99. DWF 180 ; Reordered the colors so black is first and white is last. 7 June 99. DWF 181 ; Added automatic recognition of DECOMPOSED=1 state. 7 June 99. DWF 182 ; Added LOAD AND START keywords. 7 June 99. DWF. 176 ; IDL> colors = GetColor(/Load) 177 ; IDL> PLOT, data, Color=colors.yellow 178 ; 179 ; @history 180 ; Written by: David Fanning, 10 February 96. 181 ; Fixed a bug in which N_ELEMENTS was spelled wrong. 7 Dec 96. DWF 182 ; Added the McIDAS colors to the program. 24 Feb 99. DWF 183 ; Added the INDEX parameter to the program 8 Mar 99. DWF 184 ; Added the NAMES keyword at insistence of Martin Schultz. 10 Mar 99. DWF 185 ; Reorderd the colors so black is first and white is last. 7 June 99. DWF 186 ; Added automatic recognition of DECOMPOSED=1 state. 7 June 99. DWF 187 ; Added LOAD AND START keywords. 7 June 99. DWF. 183 188 ; 184 189 ; @version $Id$ -
trunk/SRC/Colors/lct.pro
r136 r137 1 ;------------------------------------------------------------2 ;------------------------------------------------------------3 1 ;------------------------------------------------------------ 4 2 ;+ 5 3 ; 6 4 ; @file_comments 7 ; Fastest than type loadct, file='palette.tbl'5 ; Fastest than type loadct, file = 'palette.tbl' 8 6 ; 9 ; @categories graphics, color specification7 ; @categories graphics, color 10 8 ; 11 ; @param numpal {in}{optional} number of the color palette we want to select in the file palette.tbl 9 ; @param numpal {in}{optional} 10 ; number of the color palette we want to select in the file palette.tbl 12 11 ; 13 ; @keyword LIGHTNESS a scalar used to change the Lightness of the color 14 ; palette to be able to adjust according to the printer we use, 15 ; the media (paper or slide)... 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)... 16 16 ; lightness < 1 to get lighter colors 17 17 ; > 1 to get darker colors 18 18 ; 19 ; @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 19 ; @keyword FILE {default='palette.tbl'} 20 ; The file containing the color palette. It can be in any directory of the !path 22 21 ; 23 ; @keyword GET_NAME Set this keyword to a named variable in which the names of the color tables 24 ; are returned as a string array. No changes are made to the color table. 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. 25 25 ; 26 ; @keyword _EXTRA Used to pass your keywords 26 ; @keyword _EXTRA 27 ; Used to pass loadct keywords 27 28 ; 28 ; @history Sebastien Masson (smasson@lodyc.jussieu.fr) 29 ; 30/3/1999: add extra 30 ; 6/7/1999: mac/windows compatibility 29 ; @history 30 ; Sebastien Masson (smasson\@lodyc.jussieu.fr) 31 ; 30/3/1999: add extra 32 ; 6/7/1999: mac/windows compatibility 31 33 ; 32 34 ; @version $Id$ … … 34 36 ;- 35 37 ;------------------------------------------------------------ 36 ;------------------------------------------------------------37 ;------------------------------------------------------------38 38 PRO lct, numpal, FILE = file, GET_NAME = get_name, LIGHTNESS = Lightness, _EXTRA = ex 39 39 ; 40 40 compile_opt idl2, strictarrsubs 41 41 ; 42 @common43 42 ; definition of the name of the file containing colors palettes. 44 43 if keyword_set(file) then nametbl = file ELSE nametbl = 'palette.tbl' 45 44 ; What is the full address of nametbl? 46 47 48 49 50 51 52 53 if strpos(nametbl,sep) lt 0 then BEGIN54 if rstrpos(current,sep) NE strlen(current)-1 then current = current+sep55 multipath = str_sep(!path,pathsep)56 57 if rstrpos(multipath[i], sep) NE strlen(multipath[i])-1 then $58 multipath[i] = multipath[i] +sep59 60 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 61 60 ; we test all possible name in order to find where file is. 62 nfile=n_elements(nametbl)63 64 65 66 67 68 69 70 71 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 72 71 ; if we are in POSTSCRIPT mode, we have to pass in X mode in order to change the color palette 73 74 75 76 77 78 79 80 81 82 83 !p.BACKGROUND=(!d.n_colors-1) < 25584 !p.color=085 if !d.n_colors gt 256 then !p.background='ffffff'x86 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 87 86 ; 88 if arg_present(get_name) then begin 89 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 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 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 95 95 ; 96 96 if oldname EQ 'PS' AND keyword_set(lightness) then palit, lightness 97 97 ; 98 99 100 !p.BACKGROUND=(!d.n_colors-1) < 255101 !p.color=0102 if !d.n_colors gt 256 then !p.background='ffffff'x103 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 104 104 105 ENDIF ELSE ras = report('le fichier de palettes demande n''existe pas...')105 ENDIF ELSE ras = report('The file containing the color palettes doesn''t exist...') 106 106 107 107 return 108 108 end -
trunk/SRC/Colors/newpalette.pro
r136 r137 1 ;------------------------------------------------------------2 ;------------------------------------------------------------3 1 ;------------------------------------------------------------ 4 2 ;+ 5 3 ; 6 4 ; @file_comments 7 ; Allows to s tockthe palette which is on the screen8 ; in a same type file than the one g aveby default in IDL5 ; Allows to save the palette which is on the screen 6 ; in a same type file than the one gven by default in IDL 9 7 ; 'colors1.tbl'. 10 8 ; 11 ; @categories graphic, color specification9 ; @categories color 12 10 ; 13 11 ; @param namepal {in}{required} 14 ; It isa string containing the name of the new palette we want to write.12 ; a string containing the name of the new palette we want to write. 15 13 ; 16 14 ; @keyword OVER 17 ; It is a whole number which designate the number of the palette 18 ; we want to replace the palette on the screen 15 ; the number of the palette we want to replace 19 16 ; 20 ; @keyword FILE {default=palette.tbl} 21 ; if not specified, we are looking a file containing palettes named palette.tbl. 22 ; This file can be in any directory of the !path 23 ; On the other hand it must be writable 17 ; @keyword FILE {default='palette.tbl'} 18 ; The file containing the color palettes. It can be in any directory of the !path. 24 19 ; 25 ; @keyword _ extra26 ; Used to pass yourkeywords20 ; @keyword _EXTRA 21 ; Used to pass modifyct keywords 27 22 ; 28 23 ; @history Guillaume Roulet (gr@lodyc.jussieu.fr) … … 32 27 ; @version $Id$ 33 28 ; 34 ; @todo seb cleaning + traduction35 29 ;- 36 30 ;------------------------------------------------------------ 37 ;------------------------------------------------------------ 38 ;------------------------------------------------------------ 39 pro newpalette,namepal, FILE = file, OVER = over, _extra = ex 31 pro newpalette, namepal, FILE = file, OVER = over, _EXTRA = ex 40 32 ; 41 33 compile_opt idl2, strictarrsubs 42 34 ; 43 35 ; definition of the name of the file containing colors palettes. 44 if keyword_set(file) then nametbl = file ELSE nametbl = 'palette.tbl' 45 nomcourt = nametbl 36 if keyword_set(file) then nametbl = file ELSE nametbl = 'palette.tbl' 46 37 ; What is the full adress of nametbl? 47 nametbl = find(nametbl) 48 if nametbl[0] NE 'NOT FOUND' then begin 49 nametbl = nametbl[0] 50 ; does nametbl is our? 51 spawn, 'whoami', login 52 appartient = strpos(nametbl, login[0]) 53 if appartient EQ -1 then begin 54 ouinon = report('Le fichier '+nametbl+' ne vous appartient pas, Voulez-vous copier le fichier '+nomcourt+' dans le repertoire courant: '+current+' ?', /default_no, /question) 55 if ouinon then return ELSE BEGIN 56 spawn, 'cp '+nametbl+' '+nomcourt ; copy 57 nametbl = nomcourt 58 spawn, 'chmod u+w '+nametbl ; give writing rights 59 ENDELSE 60 endif 61 ENDIF ELSE BEGIN ; no file nametbl found 62 nametbl = nomcourt ; we reclaim the nametbl source 63 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) 64 if NOT ouinon then return 65 nomfichsource = filepath('colors1.tbl', subdir=['resource', 'colors']) 66 spawn,'cp '+nomfichsource+' '+nametbl ; copy 67 spawn, 'chmod u+w '+nametbl ; give writing rights 68 ENDELSE 69 70 if n_elements(ex) NE 0 then $ 71 if (where(tag_names(ex) EQ 'FILE'))[0] NE -1 then ex.FILE = nametbl 38 homedir = isadirectory(homedir, title = 'select MyIDL directory') 39 namesave = nametbl 40 nametbl = find(nametbl) 41 if nametbl[0] NE 'NOT FOUND' then begin 42 nametbl = nametbl[0] 43 nameshort = file_basename(nametbl) 44 ; is nametbl belongs to the same effective user ID (UID) as the IDL process? 45 IF !d.name EQ 'X' THEN BEGIN ; works only for unix tye machine 46 IF file_test(nametbl, /user) NE 1 THEN BEGIN 47 noanswer = report('The file '+nametbl+' is not yours... Do you want to copy '+nameshort+' in your MyIDL diectory: '+homedir+' ?', /default_no, /question) 48 IF noanswer THEN return ELSE BEGIN 49 file_copy, nametbl, homedir ; copy the file 50 nametbl = homedir + nametbl ; update its name 51 ENDELSE 52 ENDIF 53 ENDIF 54 ; no file nametbl found 55 ENDIF ELSE BEGIN 56 nametbl = file_basename(namesave) ; get back the original nametbl 57 noanswer = report('The file '+nametbl+' was not found !path directories... Do you want to create such a file in your MyIDL diectory: '+homedir+' ?', /default_no, /question) 58 if NOT noanswer then return 59 nameorg = filepath('colors1.tbl', subdir = ['resource', 'colors']) 60 file_copy, nameorg, homedir 61 ENDELSE 62 ; is nametbl writable? 63 IF file_test(nametbl, /write) NE 1 THEN file_chmod, nametbl, /u_write 64 ; make sure that we will really use nametbl name even if _EXTRA keyword is used 65 if n_elements(ex) NE 0 then $ 66 if (where(tag_names(ex) EQ 'FILE'))[0] NE -1 then ex.FILE = nametbl 72 67 ; 73 tvlct,r,g,b,/get74 r=congrid(r,256)75 g=congrid(g,256)76 b=congrid(b,256)77 IF n_elements(over) EQ 0 then over = 25578 modifyct,over,namepal,r,g,b,file=nametbl, _extra = ex68 tvlct, r, g, b, /get 69 r = congrid(r, 256) 70 g = congrid(g, 256) 71 b = congrid(b, 256) 72 IF n_elements(over) EQ 0 then over = 255 73 modifyct, over, namepal, r, g, b, file = nametbl, _extra = ex 79 74 ; 80 return81 end75 return 76 end -
trunk/SRC/Colors/xlct.pro
r136 r137 1 1 ;+ 2 ; @hidden 3 ;- 2 4 PRO XLCT_PSAVE ;Save/Restore our plotting state. 3 5 ; Swaps our state with the current state each time its called. … … 23 25 end 24 26 27 ;+ 28 ; @hidden 29 ;- 25 30 pro xlct_alert_caller 26 31 ; … … 52 57 53 58 ; Redraw the ramp image. 59 ;+ 60 ; @hidden 61 ;- 54 62 PRO xlct_show 55 63 ; … … 72 80 END 73 81 82 ;+ 83 ; @hidden 84 ; @param i 85 ; ??? 86 ; @param c 87 ; ??? 88 ;- 74 89 PRO xlct_draw_cps, i, c 75 90 ; … … 93 108 end 94 109 110 ;+ 111 ; @hidden 112 ; @keyword UPDATE 113 ; ??? 114 ;- 95 115 PRO xlct_transfer, UPDATE=update 96 116 ; … … 125 145 end 126 146 147 ;+ 148 ; @hidden 149 ; @param event 150 ; ??? 151 ;- 127 152 PRO xlct_event, event 128 153 ; … … 375 400 ; palette.tbl which can be in any directory 376 401 ; 377 ; @categories Widgets 378 ; 379 ; @keyword FILE If this keyword is set, the file by the given name is used 380 ; instead of the file colors1.tbl in the IDL directory. This 381 ; allows multiple IDL users to have their own color table file. 382 ; @keyword GROUP The widget ID of the widget that calls Xlct. When 383 ; this ID is specified, a death of the caller results in a 384 ; death of Xlct 385 ; @keyword NCOLORS = number of colors to use. Use color indexes from BOTTOM 386 ; to the smaller of !D.TABLE_SIZE-1 and NCOLORS-1. 387 ; Default = !D.TABLE_SIZE = all available colors. 388 ; @keyword BOTTOM = first color index to use. Use color indexes from BOTTOM to 389 ; BOTTOM+NCOLORS-1. Default = 0. 390 ; @keyword SILENT - Normally, no informational message is printed when 391 ; a color map is loaded. If this keyword is present and 392 ; zero, this message is printed. 393 ; @keyword USE_CURRENT: If set, use the current color tables, regardless of 394 ; the contents of the COMMON block COLORS. 395 ; @keyword MODAL: If set, then XLCT runs in "modal" mode, meaning that 396 ; all other widgets are blocked until the user quits XLCT. 397 ; A group leader must be specified (via the GROUP keyword) 398 ; for the MODAL keyword to have any effect. The default 399 ; is to not run in modal mode. 400 ; @keyword BLOCK: Set this keyword to have XMANAGER block when this 401 ; application is registered. By default the Xmanager 402 ; keyword NO_BLOCK is set to 1 to provide access to the 403 ; command line if active command line processing is available. 404 ; Note that setting BLOCK for this application will cause 405 ; all widget applications to block, not only this 406 ; application. For more information see the NO_BLOCK keyword 407 ; to XMANAGER. 408 ; @keyword UPDATECALLBACK: Set this keyword to a string containing the name of 409 ; a user-supplied procedure that will be called when the color 410 ; table is updated by XLCT. The procedure may optionally 411 ; accept a keyword called DATA, which will be automatically 412 ; set to the value specified by the optional UPDATECBDATA 413 ; keyword. 414 ; @keyword UPDATECBDATA: Set this keyword to a value of any type. It will be 415 ; passed via the DATA keyword to the user-supplied procedure 416 ; specified via the UPDATECALLBACK keyword, if any. If the 417 ; UPDATECBDATA keyword is not set the value accepted by the 418 ; DATA keyword to the procedure specified by UPDATECALLBACK 419 ; will be undefined. 420 ; 421 ; @restrictions One of the predefined color maps may be loaded. 422 ; 423 ; @restrictions This routine uses the LOADCT user library procedure to 424 ; do the actual work. 425 ; 426 ; @history 5/5/1999 copie de xloadct par Sebastien Masson (smlod@ipsl.jussieu.fr) 402 ; @categories Widgets, Color 403 ; 404 ; @keyword FILE {default='palette.tbl'} 405 ; If this keyword is set, the file by the given name is used 406 ; instead of the file colors1.tbl in the IDL directory. This 407 ; allows multiple IDL users to have their own color table file. 408 ; 409 ; @keyword GROUP 410 ; The widget ID of the widget that calls Xlct. When this ID is 411 ; specified, a death of the caller results in a death of Xlct 412 413 ; @keyword NCOLORS {default=!D.TABLE_SIZE = all available colors} 414 ; number of colors to use. Use color indexes from BOTTOM to the 415 ; smaller of !D.TABLE_SIZE-1 and NCOLORS-1. 416 ; 417 ; @keyword BOTTOM {default=0.} 418 ; first color index to use. Use color indexes from BOTTOM to 419 ; BOTTOM+NCOLORS-1. 420 ; 421 ; @keyword SILENT 422 ; Normally, no informational message is printed when a color map 423 ; is loaded. If this keyword is present and zero, this message is printed. 424 ; 425 ; @keyword USE_CURRENT 426 ; If set, use the current color tables, regardless of 427 ; the contents of the COMMON block COLORS. 428 ; 429 ; @keyword MODAL {default=not run in modal mode} 430 ; If set, then XLCT runs in "modal" mode, meaning that 431 ; all other widgets are blocked until the user quits XLCT. 432 ; A group leader must be specified (via the GROUP keyword) 433 ; for the MODAL keyword to have any effect. 434 ; 435 ; @keyword BLOCK 436 ; Set this keyword to have XMANAGER block when this 437 ; application is registered. By default the Xmanager 438 ; keyword NO_BLOCK is set to 1 to provide access to the 439 ; command line if active command line processing is available. 440 ; Note that setting BLOCK for this application will cause 441 ; all widget applications to block, not only this 442 ; application. For more information see the NO_BLOCK keyword 443 ; to XMANAGER. 444 ; 445 ; @keyword UPDATECALLBACK 446 ; Set this keyword to a string containing the name of 447 ; a user-supplied procedure that will be called when the color 448 ; table is updated by XLCT. The procedure may optionally 449 ; accept a keyword called DATA, which will be automatically 450 ; set to the value specified by the optional UPDATECBDATA keyword. 451 ; 452 ; @keyword UPDATECBDATA 453 ; Set this keyword to a value of any type. It will be 454 ; passed via the DATA keyword to the user-supplied procedure 455 ; specified via the UPDATECALLBACK keyword, if any. If the 456 ; UPDATECBDATA keyword is not set the value accepted by the 457 ; DATA keyword to the procedure specified by UPDATECALLBACK 458 ; will be undefined. 459 ; 460 ; @history 5/5/1999 copie de xloadct par Sebastien Masson (smasson\@lodyc.jussieu.fr) 427 461 ; 428 462 ; @version $Id$ -
trunk/SRC/Colors/xpal.pro
r136 r137 1 ;+2 ;3 ; @file_comments4 ; 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 we7 ; press the predefined hotkey, it calls xlct instead of xloadct8 ; No explicit inputs. The current color table is used as a starting point.9 ;10 ; @categories Color tables, widgets.11 ;12 ; @uses XP_COM: Private to this module.13 ;14 ; @restrictions15 ; XPAL uses two colors from the current color table as16 ; drawing foreground and background colors. These are used17 ; for the RGB plots on the left, and the current index marker on18 ; the right. This means that if the user set these two colors19 ; to the same value, the XPAL display could become unreadable20 ; (like writing on black paper with black ink). XPAL minimizes21 ; this possibility by noting changes to the color map and always22 ; using the brightest available color for the foreground color23 ; and the darkest for the background. Thus, the only way24 ; to make XPAL's display unreadable is to set the entire color25 ; map to a single color, which is highly unlikely. The only side26 ; effect of this policy is that you may notice XPAL redrawing27 ; the entire display after you've modified the current color.28 ; This simply means that the change has made XPAL pick new29 ; drawing colors.30 ;31 ; The new color tables are saved in the COLORS common and loaded32 ; to the display.33 ;34 ; @examples35 ; The XPAL widget has the following controls:36 ;37 ; Left: Three plots showing the current Red, Green, and Blue vectors.38 ;39 ; Center: A status region containing:40 ; 1) The total number of colors.41 ; 2) The current color. XPAL allows changing42 ; one color at a time. This color is known as43 ; the "current color" and is indicated in the44 ; color spectrum display with a special marker.45 ; 3) The current mark index. The mark is used to46 ; remember a color index. It is established by47 ; pressing the "Set Mark Button" while the current48 ; color index is the desired mark index.49 ; 4) The current color. The special marker used in50 ; color spectrum display prevents the user from seeing51 ; the color of the current index, but it is visible52 ; here.53 ;54 ; A panel of control buttons, which do the following when55 ; pressed:56 ;57 ; Done: Exits XPAL.58 ;59 ; Predefined: Starts XLOADCT to allow selection of one of the60 ; predefined color tables.61 ;62 ; Help: Supplies help information similar to this header.63 ;64 ; Redraw: Completely redraws the display using the current65 ; state of the color map.66 ;67 ; Set Mark: Set the value of the mark index to the68 ; current index.69 ;70 ; Switch Mark: Exchange the mark and the current index.71 ;72 ; Copy Current: Every color lying between the current73 ; index and the mark index (inclusive) is given74 ; the current color.75 ;76 ; Interpolate: The colors lying between the current77 ; index and the mark index are interpolated linearly78 ; to lie between the colors of two endpoints.79 ; save: Allows to save the palette which is currently80 ; on the screen. When we press this hotkey, there is a81 ; widget who appear and ask:82 ; 1) the name of the palette we want to save.83 ; 2) The number of the palette we may want to erase84 ; by the new palette. If there is not any number85 ; specified, the new palette is add to elders.86 ; 3) The name of the file containing palettes.87 ; Comment: May follow instructions gave by the prompter.88 ;89 ;90 ; Three sliders (R, G, and B) that allow the user to modify the91 ; current color.92 ;93 ; Right: A display which shows the current color map as a series of94 ; squares. Color index 0 is at the upper left. The color index95 ; increases monotonically by rows going left to right and top96 ; to bottom. The current color index is indicated by a special97 ; marker symbol. There are 4 ways to change the current color:98 ; 1) Press any mouse button while the mouse99 ; pointer is over the color map display.100 ; 2) Use the "By Index" slider to move to101 ; the desired color index.102 ; 3) Use the "Row" Slider to move the marker103 ; vertically.104 ; 4) Use the "Column" Slider to move the marker105 ; horizontally.106 ;107 ; @history adaptation de xpalette pour ajouter un bouton save par108 ; Grima Nicolas (nglod\@ipsl.jussieu.fr) et par Masson109 ; Sebastien (smlod\@ipsl.jussieu.fr)110 ;111 ; $Id$112 ;113 ;-114 ;115 ;+116 ; @file_comments117 1 ; XP_NEW_COLORS: Choose the best foreground and background colors for 118 2 ; the current color maps and set !P appropriately. 3 ;+ 119 4 ; 120 5 ; @returns 121 6 ; 1 if the colors changed, 0 otherwise. 7 ; @hidden 122 8 ;- 123 9 function XP_NEW_COLORS … … 170 56 endif 171 57 end 172 ;+173 ; @file_comments174 58 ; XP_XLCTCALLBACK: For visuals with static colormaps, update the graphics 175 59 ; after a change by XLOADCT. 60 ;+ 61 ; @hidden 176 62 ;- 177 63 pro XP_XLCTCALLBACK … … 203 89 end 204 90 205 ;+206 ; @file_comments207 91 ; XP_REPLOT: Re-draw the RGB plots. Type has the following possible values. 208 92 ; - 'D': Draw the data part of all three plots … … 211 95 ; - 'G': Draw the data part of the Green plot 212 96 ; - 'B': Draw the data part of the Blue plot 97 ;+ 98 ; @param color_index 99 ; ??? 100 ; @param type 101 ; ??? 102 ; 103 ; @hidden 213 104 ;- 214 105 pro XP_REPLOT, color_index, type … … 286 177 287 178 288 ;+ 289 ; @file_comments XP_CHANGE_COLOR: Change current color. Type has the following possible values. 179 ; XP_CHANGE_COLOR: Change current color. Type has the following possible values. 290 180 ; - 'R': Change the R part of the current color 291 181 ; - 'G': ... 292 182 ; - 'B': ... 183 ;+ 184 ; 185 ; @param type 186 ; ??? 187 ; @param value 188 ; ??? 189 ; 190 ; @hidden 293 191 ;- 294 192 pro XP_CHANGE_COLOR, type, value … … 333 231 334 232 end 335 336 337 338 339 340 341 233 ;+ 234 ; @param event 235 ; ??? 236 ; @hidden 237 ;- 342 238 pro XP_BUTTON_EVENT, event 343 239 ; … … 455 351 end 456 352 457 353 ;+ 354 ; @hidden 355 ; @param ev 356 ; ??? 357 ;- 458 358 PRO xp_button_event_event, ev 459 359 ; … … 482 382 483 383 384 ;+ 385 ; @param event 386 ; ??? 387 ; @hidden 388 ;- 484 389 485 390 pro XP_EVENT, event … … 524 429 endcase 525 430 526 end 527 528 529 530 ;+ 531 ; 532 ; @keyword group 431 END 432 433 ;+ 434 ; 435 ; @file_comments 436 ; like xpalette but shorter to write and, moreover, 437 ; possess a hotkey save which (thanks to the newpalette routine) 438 ; allows to save the routine that we have just done. Comment: when we 439 ; press the predefined hotkey, it calls xlct instead of xloadct 440 ; No explicit inputs. The current color table is used as a starting point. 441 ; 442 ; @categories Color, widgets. 443 ; 444 ; @uses XP_COM: Private to this module. 445 ; 446 ; @restrictions 447 ; XPAL uses two colors from the current color table as 448 ; drawing foreground and background colors. These are used 449 ; for the RGB plots on the left, and the current index marker on 450 ; the right. This means that if the user set these two colors 451 ; to the same value, the XPAL display could become unreadable 452 ; (like writing on black paper with black ink). XPAL minimizes 453 ; this possibility by noting changes to the color map and always 454 ; using the brightest available color for the foreground color 455 ; and the darkest for the background. Thus, the only way 456 ; to make XPAL's display unreadable is to set the entire color 457 ; map to a single color, which is highly unlikely. The only side 458 ; effect of this policy is that you may notice XPAL redrawing 459 ; the entire display after you've modified the current color. 460 ; This simply means that the change has made XPAL pick new 461 ; drawing colors. 462 ; 463 ; The new color tables are saved in the COLORS common and loaded 464 ; to the display. 465 ; 466 ; @examples 467 ; The XPAL widget has the following controls: 468 ; 469 ; Left: Three plots showing the current Red, Green, and Blue vectors. 470 ; 471 ; Center: A status region containing: 472 ; 1) The total number of colors. 473 ; 2) The current color. XPAL allows changing 474 ; one color at a time. This color is known as 475 ; the "current color" and is indicated in the 476 ; color spectrum display with a special marker. 477 ; 3) The current mark index. The mark is used to 478 ; remember a color index. It is established by 479 ; pressing the "Set Mark Button" while the current 480 ; color index is the desired mark index. 481 ; 4) The current color. The special marker used in 482 ; color spectrum display prevents the user from seeing 483 ; the color of the current index, but it is visible 484 ; here. 485 ; 486 ; A panel of control buttons, which do the following when 487 ; pressed: 488 ; 489 ; Done: Exits XPAL. 490 ; 491 ; Predefined: Starts XLOADCT to allow selection of one of the 492 ; predefined color tables. 493 ; 494 ; Help: Supplies help information similar to this header. 495 ; 496 ; Redraw: Completely redraws the display using the current 497 ; state of the color map. 498 ; 499 ; Set Mark: Set the value of the mark index to the 500 ; current index. 501 ; 502 ; Switch Mark: Exchange the mark and the current index. 503 ; 504 ; Copy Current: Every color lying between the current 505 ; index and the mark index (inclusive) is given 506 ; the current color. 507 ; 508 ; Interpolate: The colors lying between the current 509 ; index and the mark index are interpolated linearly 510 ; to lie between the colors of two endpoints. 511 ; save: Allows to save the palette which is currently 512 ; on the screen. When we press this hotkey, there is a 513 ; widget who appear and ask: 514 ; 1) the name of the palette we want to save. 515 ; 2) The number of the palette we may want to erase 516 ; by the new palette. If there is not any number 517 ; specified, the new palette is add to elders. 518 ; 3) The name of the file containing palettes. 519 ; Comment: May follow instructions gave by the prompter. 520 ; 521 ; 522 ; Three sliders (R, G, and B) that allow the user to modify the 523 ; current color. 524 ; 525 ; Right: A display which shows the current color map as a series of 526 ; squares. Color index 0 is at the upper left. The color index 527 ; increases monotonically by rows going left to right and top 528 ; to bottom. The current color index is indicated by a special 529 ; marker symbol. There are 4 ways to change the current color: 530 ; 1) Press any mouse button while the mouse 531 ; pointer is over the color map display. 532 ; 2) Use the "By Index" slider to move to 533 ; the desired color index. 534 ; 3) Use the "Row" Slider to move the marker 535 ; vertically. 536 ; 4) Use the "Column" Slider to move the marker 537 ; horizontally. 538 ; 539 ; @keyword GROUP 540 ; The widget ID of the widget that calls xpal. When this ID is 541 ; specified, a death of the caller results in a death of xpal 533 542 ; 534 543 ; @keyword BLOCK … … 558 567 ; will be undefined. 559 568 ; 560 ;- 561 pro XPAL, group=group, BLOCK=block, UPDATECALLBACK=updt_cb_name, $ 569 ; @history adaptation de xpalette pour ajouter un bouton save par 570 ; Grima Nicolas (nglod\@ipsl.jussieu.fr) et par Masson 571 ; Sebastien (smlod\@ipsl.jussieu.fr) 572 ; 573 ; $Id$ 574 ; 575 ;- 576 pro XPAL, GROUP=group, BLOCK=block, UPDATECALLBACK=updt_cb_name, $ 562 577 UPDATECBDATA=updt_cb_data 563 578 ;
Note: See TracChangeset
for help on using the changeset viewer.