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

Last change on this file since 154 was 137, checked in by smasson, 18 years ago

review of Colors and Calendar routines

  • Property svn:eol-style set to native
  • Property svn:keywords set to Id
File size: 2.8 KB
Line 
1;------------------------------------------------------------
2;+
3;
4; @file_comments
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
7; 'colors1.tbl'.
8;
9; @categories color
10;
11; @param namepal {in}{required}
12; a string containing the name of the new palette we want to write.
13;
14; @keyword OVER
15; the number of the palette we want to replace
16;
17; @keyword FILE {default='palette.tbl'}
18; The file containing the color palettes. It can be in any directory of the !path.
19;
20; @keyword _EXTRA
21; Used to pass modifyct keywords
22;
23; @history Guillaume Roulet (gr@lodyc.jussieu.fr)
24; 30/3/1999 s.masson, add _extra, research of the full name, OVER
25;                       5/5/1999 s.masson
26;
27; @version $Id$
28;
29;-
30;------------------------------------------------------------
31pro newpalette, namepal, FILE = file, OVER = over, _EXTRA = ex
32;
33  compile_opt idl2, strictarrsubs
34;
35; definition of the name of the file containing colors palettes.
36  if keyword_set(file) then nametbl = file ELSE nametbl = 'palette.tbl'
37; What is the full adress of 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
67;
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
74;
75    return
76  end
Note: See TracBrowser for help on using the repository browser.