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

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

only uppercase between <proidl>...</proidl> in perspective of links to /usr/local_macosx/idl/idl_6.2/idl_6.2/

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