Changeset 137 for trunk/SRC/Colors


Ignore:
Timestamp:
07/12/06 11:33:44 (18 years ago)
Author:
smasson
Message:

review of Colors and Calendar routines

Location:
trunk/SRC/Colors
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/SRC/Colors/color24.pro

    r136 r137  
    55; into the equivalent 24-big long integer.  
    66; 
    7 ; @categories Graphics, Color Specification. 
     7; @categories Graphics, Color 
    88; 
    99; @param rgb_triple {in}{required}  
  • trunk/SRC/Colors/colorbar.pro

    r136 r137  
    77; @categories Graphics, Widgets. 
    88; 
    9 ; @keyword BOTTOM 
     9; @keyword BOTTOM {default=0B} 
    1010; The lowest color index of the colors to be loaded in the bar. 
    1111; 
     
    2222; to get logarithmic scale for the colorbar 
    2323; 
    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  
    2828; Vector which contain color's indexes to trace in a color bar. Therefore 
    29 ; we obtain a discreet color bar which only contains specified colors in 
    30 ; order where they appear in the vector 
     29; we obtain a discrete colorbar which contains only the specified colors  
     30; in the order they appear in the vector 
    3131; 
    3232; @keyword DIVISIONS {default=2} 
     
    3737; The format of the bar annotations. 
    3838; 
    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 increase 
    42 ; by increments 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. 
    4343; 
    4444; @keyword MAX {default=NCOLORS - 1} 
     
    4848; The minimum data value for the bar annotation. 
    4949; 
    50 ; @keyword NCOLORS 
     50; @keyword NCOLORS {default=!D.N_COLORS} 
    5151; This is the number of colors in the color bar. 
    5252; 
     
    5454; Force to don't write title even if CB_TITLE is declared. 
    5555; 
    56 ; @keyword POSITION 
     56; @keyword POSITION {default=see bellow} 
    5757; A four-element array of normalized coordinates in the same 
    5858; form as the POSITION keyword on a plot. Default is 
     
    8282; The keyword only applies if a horizontal color bar is rendered. 
    8383; 
    84 ; @keyword VERTICAL 
     84; @keyword VERTICAL {default=0 -> horizontal color bar} 
    8585; Setting this keyword give a vertical color bar. 
    86 ; The default is a horizontal color bar. 
    87 ; 
    88 ; @restrictions 
    89 ; Color bar is drawn in the current graphics window. 
    9086; 
    9187; @restrictions 
     
    10197; IDL> COLORBAR, NCOLORS=100 
    10298; 
    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 
    107104;           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) 
    114110; 
    115111; @version $Id$ 
    116112; 
    117113;- 
    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? 
     114PRO 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 
    128120; 
    129121  compile_opt idl2, strictarrsubs 
    130122; 
    131  
     123; Is the PostScript device selected? 
    132124   postScriptDevice = (!D.NAME EQ 'PS') 
    133125 
     
    136128   IF N_ELEMENTS(ncolors) EQ 0 THEN BEGIN 
    137129 
    138                                 ; Most display devices to not use the 256 colors available to 
    139                                 ; the PostScript device. This presents a problem when writing 
    140                                 ; general-purpose programs that can be output to the display or 
    141                                 ; to the PostScript device. This problem is especially bothersome 
    142                                 ; if you don't specify the number of colors you are using in the 
    143                                 ; program. One way to work around this problem is to make the 
    144                                 ; default number of colors the same for the display device and for 
    145                                 ; the PostScript device. Then, the colors you see in PostScript are 
    146                                 ; identical to the colors you see on your display. Here is one way to 
    147                                 ; do it. 
     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. 
    148140 
    149141      IF postScriptDevice THEN BEGIN 
    150142         oldDevice = !D.NAME 
    151143 
    152                                 ; What kind of computer are we using? SET_PLOT to appropriate 
    153                                 ; display device. 
     144; What kind of computer are we using? SET_PLOT to appropriate 
     145; display device. 
    154146 
    155147         thisOS = !VERSION.OS_FAMILY 
     
    165157         if !d.n_colors gt 256 then !p.background='ffffff'x 
    166158 
    167                                 ; Open a window (to make sure !D.N_COLORS is accurate). 
     159; Open a window (to make sure !D.N_COLORS is accurate). 
    168160 
    169161         WINDOW, /FREE, /PIXMAP, XSIZE=10, YSIZE=10 
    170162         WDELETE, !D.WINDOW 
    171163 
    172                                 ; Here is how many colors we should use. 
     164; Here is how many colors we should use. 
    173165 
    174166         ncolors = !D.N_COLORS 
     
    209201   ENDELSE 
    210202 
    211                                 ; Scale the color bar. 
     203; Scale the color bar. 
    212204   IF NOT KEYWORD_SET(discrete) THEN $ 
    213205    bar = BYTSCL(bar, TOP=ncolors-1) + bottom 
    214206 
    215                                 ; Get starting locations in DEVICE coordinates. 
     207; Get starting locations in DEVICE coordinates. 
    216208 
    217209   xstart = position[0] * !D.X_VSIZE 
    218210   ystart = position[1] * !D.Y_VSIZE 
    219211 
    220                                 ; Get the size of the bar in DEVICE coordinates. 
     212; Get the size of the bar in DEVICE coordinates. 
    221213 
    222214   xsize = (position[2] - position[0]) * !D.X_VSIZE 
    223215   ysize = (position[3] - position[1]) * !D.Y_VSIZE 
    224216 
    225                                 ; For PostScript output only, draw the annotation in !P.COLOR 
    226                                 ; unless "pscolor" is set. This makes better output on grayscale 
    227                                 ; printers. 
     217; For PostScript output only, draw the annotation in !P.COLOR 
     218; unless "pscolor" is set. This makes better output on grayscale 
     219; printers. 
    228220 
    229221   IF postScriptDevice AND (pscolor NE 1) THEN BEGIN 
     
    232224   ENDIF 
    233225 
    234                                 ; Display the color bar in the window. Sizing is 
    235                                 ; different for PostScript and regular display. 
     226; Display the color bar in the window. Sizing is 
     227; different for PostScript and regular display. 
    236228 
    237229   IF postScriptDevice THEN BEGIN 
     
    246238   ENDELSE 
    247239 
    248                                 ; Annotate the color bar. 
     240; Annotate the color bar. 
    249241 
    250242   if keyword_set(cb_label) then begin 
     
    312304 
    313305   ENDELSE 
    314                                 ; Restore color variable if changed for PostScript. 
     306; Restore color variable if changed for PostScript. 
    315307 
    316308   IF postScriptDevice AND (pscolor NE 1) THEN cb_color = oldcolor 
  • trunk/SRC/Colors/getcolor.pro

    r136 r137  
    1515; table offered on the IDL newsgroup by Liam Gumley.) 
    1616; 
    17 ; @categories Graphics, Color Specification. 
     17; @categories Graphics, Color 
    1818; 
    1919; @param thisColor {in}{optional}  
     
    3636;           white 
    3737; 
    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; 
    4841; 
    4942; @param index {in}{optional}  
    5043; 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: 
    6150; 
    6251;           Device, Decomposed=0 
    6352;           colors = GetColor() 
    6453;           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; 
    6569; 
    6670; @keyword NAMES  
     
    112116; To load a yellow color in color index 100 and plot in yellow, type: 
    113117; 
    114 ; IDL> yellow = GETCOLOR('yellow', 100) 
    115 ; IDL> PLOT, data, COLOR=yellow 
    116 ; 
    117 ;       or, 
    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) 
    120124; 
    121125; To do the same thing on a 24-bit color system with decomposed color on, type: 
    122126; 
    123 ; IDL> PLOT, data, COLOR=GETCOLOR('yellow', /TRUE) 
    124 ; 
    125 ;       or in IDL 5.2 and higher, 
    126 ; 
    127 ; IDL> DEVICE, Decomposed=1 
    128 ; 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') 
    129133; 
    130134; To load all 16 colors into the current color table, starting at 
    131135; color index 200, type: 
    132136; 
    133 ; IDL> TVLCT, GETCOLOR(), 200 
     137;      IDL> TVLCT, GETCOLOR(), 200 
    134138; 
    135139; To add the color names to a list widget: 
    136140; 
    137 ; IDL> listID = Widget_List(baseID, Value=GetColor(/Names), YSize=16) 
    138 ; 
    139 ; To load all 16 colors and have the color indexes returned in a structure: 
    140 ; 
    141 ; IDL> DEVICE, Decomposed=0 
    142 ; IDL> colors = GetColor(/Load, Start=1) 
    143 ; IDL> HELP, colors, /Structure 
    144 ; PLOT, data, COLOR=colors.yellow 
     141;      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 
    145149; 
    146150; To get the direct color values as 24-bit integers in color structure fields: 
    147151; 
    148 ; IDL> DEVICE, Decomposed=1 
    149 ; IDL> colors = GetColor(/Load) 
    150 ; IDL> PLOT, data, COLOR=colors.yellow 
     152;      IDL> DEVICE, Decomposed=1 
     153;      IDL> colors = GetColor(/Load) 
     154;      IDL> PLOT, data, COLOR=colors.yellow 
    151155; 
    152156; Note that the START keyword value is ignored if on a 24-bit device, 
     
    154158; writing code like this: 
    155159; 
    156 ; IDL> colors = GetColor(/Load) 
    157 ; IDL> PLOT, data, Color=colors.yellow;           IDL> DEVICE, Decomposed=0 
    158 ; IDL> colors = GetColor(/Load, Start=1) 
    159 ; IDL> HELP, colors, /Structure 
    160 ; IDL> PLOT, data, COLOR=colors.yellow 
     160;      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 
    161165; 
    162166; To get the direct color values as 24-bit integers in color structure fields: 
    163167; 
    164 ; IDL> DEVICE, Decomposed=1 
    165 ; IDL> colors = GetColor(/Load) 
    166 ; IDL> PLOT, data, COLOR=colors.yellow 
     168;      IDL> DEVICE, Decomposed=1 
     169;      IDL> colors = GetColor(/Load) 
     170;      IDL> PLOT, data, COLOR=colors.yellow 
    167171; 
    168172; Note that the START keyword value is ignored if on a 24-bit device, 
     
    170174; writing code like this: 
    171175; 
    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. 
    183188; 
    184189; @version $Id$ 
  • trunk/SRC/Colors/lct.pro

    r136 r137  
    1 ;------------------------------------------------------------ 
    2 ;------------------------------------------------------------ 
    31;------------------------------------------------------------ 
    42;+ 
    53; 
    64; @file_comments  
    7 ; Fastest than type loadct,file='palette.tbl' 
     5; Fastest than type loadct, file = 'palette.tbl' 
    86; 
    9 ; @categories graphics, color specification 
     7; @categories graphics, color 
    108; 
    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 
    1211; 
    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)...  
    1616;               lightness < 1 to get lighter colors 
    1717;                         > 1 to get darker colors 
    1818; 
    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 
    2221; 
    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. 
    2525; 
    26 ; @keyword _EXTRA Used to pass your keywords 
     26; @keyword _EXTRA 
     27; Used to pass loadct keywords 
    2728; 
    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 
    3133; 
    3234; @version $Id$ 
     
    3436;- 
    3537;------------------------------------------------------------ 
    36 ;------------------------------------------------------------ 
    37 ;------------------------------------------------------------ 
    3838PRO lct, numpal, FILE = file, GET_NAME = get_name, LIGHTNESS = Lightness, _EXTRA = ex 
    3939; 
    4040  compile_opt idl2, strictarrsubs 
    4141; 
    42 @common 
    4342; definition of the name of the file containing colors palettes. 
    44    if keyword_set(file) then nametbl = file ELSE nametbl = 'palette.tbl' 
     43  if keyword_set(file) then nametbl = file ELSE nametbl = 'palette.tbl' 
    4544; What is the full address of nametbl? 
    46    thisOS = strupcase(strmid(!version.os_family, 0, 3)) 
    47    CASE thisOS of 
    48    'MAC':BEGIN & sep = ':' & pathsep = ',' & end 
    49    'WIN':BEGIN & sep = '\' & pathsep = ';' & end 
    50    ELSE: BEGIN & sep = '/' & pathsep = ':' & end 
    51    ENDCASE 
    52    cd, current = current 
    53    if strpos(nametbl,sep) lt 0 then BEGIN 
    54       if rstrpos(current,sep) NE strlen(current)-1 then current = current+sep 
    55       multipath = str_sep(!path,pathsep) 
    56       for i = 0, n_elements(multipath)-1 do $ 
    57        if rstrpos(multipath[i],sep) NE strlen(multipath[i])-1 then $ 
    58        multipath[i] = multipath[i] +sep 
    59       nametbl = [current, multipath]+ nametbl 
    60    ENDIF 
     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 
    6160; we test all possible name in order to find where file is. 
    62    nfile=n_elements(nametbl) 
    63    n = 0 
    64    repeat begin 
    65       res = findfile(nametbl[n])  
    66       n = n+1 
    67    endrep until res[0] NE '' OR n EQ n_elements(nametbl)  
    68    if res[0] NE '' then BEGIN 
    69       nametbl = nametbl[n-1] 
    70       if n_elements(ex) NE 0 then $  
    71         if (where(tag_names(ex) EQ 'FILE'))[0] NE -1 then ex.FILE = nametbl 
     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 
    7271; if we are in POSTSCRIPT mode, we have to pass in X mode in order to change the color palette 
    73       oldname = !d.name 
    74       if !d.name EQ 'PS' OR !d.name EQ 'Z' then BEGIN  
    75          thisOS = !VERSION.OS_FAMILY 
    76          thisOS = STRMID(thisOS, 0, 3) 
    77          thisOS = STRUPCASE(thisOS) 
    78          CASE thisOS of 
    79             'MAC': SET_PLOT, thisOS 
    80             'WIN': SET_PLOT, thisOS 
    81             ELSE: SET_PLOT, 'X' 
    82          ENDCASE 
    83          !p.BACKGROUND=(!d.n_colors-1) < 255 
    84          !p.color=0 
    85          if !d.n_colors gt 256 then !p.background='ffffff'x 
    86       ENDIF 
     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 
    8786; 
    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  
    9595; 
    96       if oldname EQ 'PS' AND keyword_set(lightness) then palit, lightness  
     96    if oldname EQ 'PS' AND keyword_set(lightness) then palit, lightness  
    9797; 
    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 
     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 
    104104 
    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...') 
    106106 
    107    return 
     107  return 
    108108end 
  • trunk/SRC/Colors/newpalette.pro

    r136 r137  
    1 ;------------------------------------------------------------ 
    2 ;------------------------------------------------------------ 
    31;------------------------------------------------------------ 
    42;+ 
    53; 
    64; @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 
     5; Allows to save the palette which is on the screen 
     6; in a same type file than the one gven by default in IDL 
    97; 'colors1.tbl'. 
    108; 
    11 ; @categories graphic, color specification 
     9; @categories color 
    1210; 
    1311; @param namepal {in}{required}  
    14 ; It is a 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. 
    1513; 
    1614; @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 
    1916; 
    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. 
    2419; 
    25 ; @keyword _extra  
    26 ; Used to pass your keywords 
     20; @keyword _EXTRA  
     21; Used to pass modifyct keywords 
    2722; 
    2823; @history Guillaume Roulet (gr@lodyc.jussieu.fr) 
     
    3227; @version $Id$ 
    3328; 
    34 ; @todo seb cleaning + traduction 
    3529;- 
    3630;------------------------------------------------------------ 
    37 ;------------------------------------------------------------ 
    38 ;------------------------------------------------------------ 
    39 pro newpalette,namepal, FILE = file, OVER = over, _extra = ex 
     31pro newpalette, namepal, FILE = file, OVER = over, _EXTRA = ex 
    4032; 
    4133  compile_opt idl2, strictarrsubs 
    4234; 
    4335; 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' 
    4637; 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 
    7267; 
    73    tvlct,r,g,b,/get 
    74    r=congrid(r,256) 
    75    g=congrid(g,256) 
    76    b=congrid(b,256) 
    77    IF n_elements(over) EQ 0 then over = 255 
    78    modifyct,over,namepal,r,g,b,file=nametbl, _extra = ex 
     68    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 
    7974; 
    80    return 
    81 end 
     75    return 
     76  end 
  • trunk/SRC/Colors/xlct.pro

    r136 r137  
    1  
     1;+ 
     2; @hidden 
     3;- 
    24PRO XLCT_PSAVE                  ;Save/Restore our plotting state. 
    35;  Swaps our state with the current state each time its called. 
     
    2325end 
    2426 
     27;+ 
     28; @hidden 
     29;- 
    2530pro xlct_alert_caller 
    2631; 
     
    5257 
    5358; Redraw the ramp image. 
     59;+ 
     60; @hidden 
     61;- 
    5462PRO xlct_show 
    5563; 
     
    7280END 
    7381 
     82;+ 
     83; @hidden 
     84; @param i 
     85; ??? 
     86; @param c 
     87; ??? 
     88;- 
    7489PRO xlct_draw_cps, i, c 
    7590; 
     
    93108end 
    94109 
     110;+ 
     111; @hidden 
     112; @keyword UPDATE 
     113; ??? 
     114;- 
    95115PRO xlct_transfer, UPDATE=update 
    96116; 
     
    125145end 
    126146 
     147;+ 
     148; @hidden 
     149; @param event 
     150; ??? 
     151;- 
    127152PRO xlct_event, event 
    128153; 
     
    375400; palette.tbl which can be in any directory 
    376401; 
    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) 
    427461; 
    428462; @version $Id$ 
  • trunk/SRC/Colors/xpal.pro

    r136 r137  
    1 ;+ 
    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 ; @uses XP_COM: Private to this module. 
    13 ; 
    14 ; @restrictions 
    15 ; XPAL uses two colors from the current color table as 
    16 ; drawing foreground and background colors. These are used 
    17 ; for the RGB plots on the left, and the current index marker on 
    18 ; the right. This means that if the user set these two colors 
    19 ; to the same value, the XPAL display could become unreadable 
    20 ; (like writing on black paper with black ink). XPAL minimizes 
    21 ; this possibility by noting changes to the color map and always 
    22 ; using the brightest available color for the foreground color 
    23 ; and the darkest for the background. Thus, the only way 
    24 ; to make XPAL's display unreadable is to set the entire color 
    25 ; map to a single color, which is highly unlikely. The only side 
    26 ; effect of this policy is that you may notice XPAL redrawing 
    27 ; the entire display after you've modified the current color. 
    28 ; This simply means that the change has made XPAL pick new 
    29 ; drawing colors. 
    30 ; 
    31 ; The new color tables are saved in the COLORS common and loaded 
    32 ; to the display. 
    33 ; 
    34 ; @examples 
    35 ; 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 changing 
    42 ;                  one color at a time. This color is known as 
    43 ;                  the "current color" and is indicated in the 
    44 ;                  color spectrum display with a special marker. 
    45 ;               3) The current mark index. The mark is used to 
    46 ;                  remember a color index. It is established by 
    47 ;                  pressing the "Set Mark Button" while the current 
    48 ;                  color index is the desired mark index. 
    49 ;               4) The current color. The special marker used in 
    50 ;                  color spectrum display prevents the user from seeing 
    51 ;                  the color of the current index, but it is visible 
    52 ;                  here. 
    53 ; 
    54 ;               A panel of control buttons, which do the following when 
    55 ;               pressed: 
    56 ; 
    57 ;                 Done: Exits XPAL. 
    58 ; 
    59 ;           Predefined: Starts XLOADCT to allow selection of one of the 
    60 ;                       predefined color tables. 
    61 ; 
    62 ;                 Help: Supplies help information similar to this header. 
    63 ; 
    64 ;               Redraw: Completely redraws the display using the current 
    65 ;                       state of the color map. 
    66 ; 
    67 ;             Set Mark: Set the value of the mark index to the 
    68 ;                       current index. 
    69 ; 
    70 ;          Switch Mark: Exchange the mark and the current index. 
    71 ; 
    72 ;         Copy Current: Every color lying between the current 
    73 ;                       index and the mark index (inclusive) is given 
    74 ;                       the current color. 
    75 ; 
    76 ;          Interpolate: The colors lying between the current 
    77 ;                       index and the mark index are interpolated linearly 
    78 ;                       to lie between the colors of two endpoints. 
    79 ;                 save: Allows to save  the palette which is currently 
    80 ;                       on the screen. When we press this hotkey, there is a 
    81 ;                       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 erase 
    84 ;                        by the new palette. If there is not any number 
    85 ;                        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 the 
    91 ;       current color. 
    92 ; 
    93 ;       Right:  A display which shows the current color map as a series of 
    94 ;               squares. Color index 0 is at the upper left. The color index 
    95 ;               increases monotonically by rows going left to right and top 
    96 ;               to bottom.  The current color index is indicated by a special 
    97 ;               marker symbol. There are 4 ways to change the current color: 
    98 ;                       1) Press any mouse button while the mouse 
    99 ;                          pointer is over the color map display. 
    100 ;                       2) Use the "By Index" slider to move to 
    101 ;                          the desired color index. 
    102 ;                       3) Use the "Row" Slider to move the marker 
    103 ;                          vertically. 
    104 ;                       4) Use the "Column" Slider to move the marker 
    105 ;                          horizontally. 
    106 ; 
    107 ; @history adaptation de xpalette pour ajouter un bouton save par 
    108 ;          Grima Nicolas (nglod\@ipsl.jussieu.fr) et par Masson 
    109 ;          Sebastien (smlod\@ipsl.jussieu.fr) 
    110 ; 
    111 ; $Id$ 
    112 ; 
    113 ;- 
    114 ; 
    115 ;+ 
    116 ; @file_comments 
    1171; XP_NEW_COLORS: Choose the best foreground and background colors for 
    1182; the current color maps and set !P appropriately. 
     3;+ 
    1194; 
    1205; @returns 
    1216; 1 if the colors changed, 0 otherwise. 
     7; @hidden 
    1228;- 
    1239function XP_NEW_COLORS 
     
    17056  endif 
    17157end 
    172 ;+ 
    173 ; @file_comments 
    17458; XP_XLCTCALLBACK:  For visuals with static colormaps, update the graphics 
    17559; after a change by XLOADCT. 
     60;+ 
     61; @hidden 
    17662;- 
    17763pro XP_XLCTCALLBACK 
     
    20389end 
    20490 
    205 ;+ 
    206 ; @file_comments 
    20791; XP_REPLOT: Re-draw the RGB plots. Type has the following possible values. 
    20892;       - 'D': Draw the data part of all three plots 
     
    21195;       - 'G': Draw the data part of the Green plot 
    21296;       - 'B': Draw the data part of the Blue plot 
     97;+ 
     98; @param color_index 
     99; ??? 
     100; @param type 
     101; ??? 
     102; 
     103; @hidden 
    213104;- 
    214105pro XP_REPLOT, color_index, type 
     
    286177 
    287178 
    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. 
    290180;       - 'R': Change the R part of the current color 
    291181;       - 'G': ... 
    292182;       - 'B': ... 
     183;+ 
     184; 
     185; @param type 
     186; ??? 
     187; @param value 
     188; ??? 
     189; 
     190; @hidden 
    293191;- 
    294192pro XP_CHANGE_COLOR, type, value 
     
    333231 
    334232end 
    335  
    336  
    337  
    338  
    339  
    340  
    341  
     233;+ 
     234; @param event 
     235; ??? 
     236; @hidden 
     237;- 
    342238pro XP_BUTTON_EVENT, event 
    343239; 
     
    455351end 
    456352 
    457  
     353;+ 
     354; @hidden 
     355; @param ev 
     356; ??? 
     357;- 
    458358PRO xp_button_event_event, ev 
    459359; 
     
    482382 
    483383 
     384;+ 
     385; @param event 
     386; ??? 
     387; @hidden 
     388;- 
    484389 
    485390pro XP_EVENT, event 
     
    524429   endcase 
    525430 
    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 
    533542; 
    534543; @keyword BLOCK 
     
    558567; will be undefined. 
    559568; 
    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;- 
     576pro XPAL, GROUP=group, BLOCK=block, UPDATECALLBACK=updt_cb_name, $ 
    562577        UPDATECBDATA=updt_cb_data 
    563578; 
Note: See TracChangeset for help on using the changeset viewer.