source: trunk/SRC/Colors/newpalette.pro @ 226

Last change on this file since 226 was 226, checked in by pinsard, 17 years ago

corrections of some misspellings in some *.pro

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.8 KB
RevLine 
[2]1;------------------------------------------------------------
2;+
3;
[226]4; @file_comments
[137]5; Allows to save the palette which is on the screen
[163]6; in a same type file than the one given by default in IDL
[2]7; 'colors1.tbl'.
8;
[226]9; @categories
[157]10; Color
[2]11;
[163]12; @param namepal {in}{required}{type=string}
[137]13; a string containing the name of the new palette we want to write.
[2]14;
[226]15; @keyword OVER
[137]16; the number of the palette we want to replace
[2]17;
[137]18; @keyword FILE {default='palette.tbl'}
19; The file containing the color palettes. It can be in any directory of the !path.
[2]20;
[226]21; @keyword _EXTRA
[137]22; Used to pass modifyct keywords
[2]23;
[157]24; @history Guillaume Roulet (gr\@lodyc.jussieu.fr)
[136]25; 30/3/1999 s.masson, add _extra, research of the full name, OVER
[133]26;                       5/5/1999 s.masson
[2]27;
[133]28; @version $Id$
29;
[2]30;-
31;------------------------------------------------------------
[137]32pro newpalette, namepal, FILE = file, OVER = over, _EXTRA = ex
[114]33;
34  compile_opt idl2, strictarrsubs
35;
[133]36; definition of the name of the file containing colors palettes.
[137]37  if keyword_set(file) then nametbl = file ELSE nametbl = 'palette.tbl'
[133]38; What is the full adress of nametbl?
[137]39  homedir = isadirectory(homedir,  title = 'select MyIDL directory')
40  namesave = nametbl
41  nametbl = find(nametbl)
42  if nametbl[0] NE 'NOT FOUND' then begin
43    nametbl = nametbl[0]
44    nameshort = file_basename(nametbl)
45; is nametbl belongs to the same effective user ID (UID) as the IDL process?
46    IF !d.name EQ 'X' THEN BEGIN ; works only for unix tye machine
[226]47      IF file_test(nametbl, /user) NE 1 THEN BEGIN
48        noanswer = report('The file '+nametbl+' is not yours... Do you want to copy '+nameshort+' in your MyIDL directory: '+homedir+' ?', /default_no, /question)
49        IF noanswer THEN return ELSE BEGIN
[137]50          file_copy, nametbl, homedir  ; copy the file
51          nametbl = homedir + nametbl  ; update its name
52        ENDELSE
53      ENDIF
54    ENDIF
55; no file nametbl found
[226]56    ENDIF ELSE BEGIN
[137]57      nametbl = file_basename(namesave)        ; get back the original nametbl
[226]58      noanswer = report('The file '+nametbl+' was not found !path directories... Do you want to create such a file in  your MyIDL directory: '+homedir+' ?', /default_no, /question)
[137]59      if NOT noanswer then return
[226]60      nameorg = filepath('colors1.tbl', subdir = ['resource', 'colors'])
[137]61      file_copy, nameorg, homedir
[226]62    ENDELSE
[137]63; is nametbl writable?
64    IF file_test(nametbl, /write) NE 1 THEN file_chmod, nametbl, /u_write
65; make sure that we will really use nametbl name even if _EXTRA keyword is used
[226]66    if n_elements(ex) NE 0 then $
[137]67       if (where(tag_names(ex) EQ 'FILE'))[0] NE -1 then ex.FILE = nametbl
[2]68;
[137]69    tvlct, r, g, b, /get
70    r = congrid(r, 256)
71    g = congrid(g, 256)
72    b = congrid(b, 256)
73    IF n_elements(over) EQ 0 then over = 255
74    modifyct, over, namepal, r, g, b, file = nametbl, _extra = ex
[2]75;
[137]76    return
77  end
Note: See TracBrowser for help on using the repository browser.