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