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 given by default in IDL |
---|
7 | ; 'colors1.tbl'. |
---|
8 | ; |
---|
9 | ; @categories |
---|
10 | ; Color |
---|
11 | ; |
---|
12 | ; @param namepal {in}{required}{type=string} |
---|
13 | ; a string containing the name of the new palette we want to write. |
---|
14 | ; |
---|
15 | ; @keyword OVER |
---|
16 | ; the number of the palette we want to replace |
---|
17 | ; |
---|
18 | ; @keyword FILE {default='palette.tbl'} |
---|
19 | ; The file containing the color palettes. It can be in any directory of the !path. |
---|
20 | ; |
---|
21 | ; @keyword _EXTRA |
---|
22 | ; Used to pass modifyct keywords |
---|
23 | ; |
---|
24 | ; @history Guillaume Roulet (gr\@lodyc.jussieu.fr) |
---|
25 | ; 30/3/1999 s.masson, add _extra, research of the full name, OVER |
---|
26 | ; 5/5/1999 s.masson |
---|
27 | ; |
---|
28 | ; @version $Id$ |
---|
29 | ; |
---|
30 | ;- |
---|
31 | ;------------------------------------------------------------ |
---|
32 | pro newpalette, namepal, FILE = file, OVER = over, _EXTRA = ex |
---|
33 | ; |
---|
34 | compile_opt idl2, strictarrsubs |
---|
35 | ; |
---|
36 | ; definition of the name of the file containing colors palettes. |
---|
37 | if keyword_set(file) then nametbl = file ELSE nametbl = 'palette.tbl' |
---|
38 | ; What is the full adress of nametbl? |
---|
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 |
---|
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 diectory: '+homedir+' ?', /default_no, /question) |
---|
49 | IF noanswer THEN return ELSE BEGIN |
---|
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 |
---|
56 | ENDIF ELSE BEGIN |
---|
57 | nametbl = file_basename(namesave) ; get back the original nametbl |
---|
58 | 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) |
---|
59 | if NOT noanswer then return |
---|
60 | nameorg = filepath('colors1.tbl', subdir = ['resource', 'colors']) |
---|
61 | file_copy, nameorg, homedir |
---|
62 | ENDELSE |
---|
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 |
---|
66 | if n_elements(ex) NE 0 then $ |
---|
67 | if (where(tag_names(ex) EQ 'FILE'))[0] NE -1 then ex.FILE = nametbl |
---|
68 | ; |
---|
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 |
---|
75 | ; |
---|
76 | return |
---|
77 | end |
---|