[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 |
---|
[232] | 21 | ; Used to pass keywords to <proidl>modifyct</proidl> |
---|
[2] | 22 | ; |
---|
[231] | 23 | ; @history |
---|
| 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] | 33 | pro newpalette, namepal, FILE = file, OVER = over, _EXTRA = ex |
---|
[114] | 34 | ; |
---|
| 35 | compile_opt idl2, strictarrsubs |
---|
| 36 | ; |
---|
[133] | 37 | ; definition of the name of the file containing colors palettes. |
---|
[137] | 38 | if keyword_set(file) then nametbl = file ELSE nametbl = 'palette.tbl' |
---|
[133] | 39 | ; What is the full adress of nametbl? |
---|
[137] | 40 | homedir = isadirectory(homedir, title = 'select MyIDL directory') |
---|
| 41 | namesave = nametbl |
---|
| 42 | nametbl = find(nametbl) |
---|
| 43 | if nametbl[0] NE 'NOT FOUND' then begin |
---|
| 44 | nametbl = nametbl[0] |
---|
| 45 | nameshort = file_basename(nametbl) |
---|
| 46 | ; is nametbl belongs to the same effective user ID (UID) as the IDL process? |
---|
| 47 | IF !d.name EQ 'X' THEN BEGIN ; works only for unix tye machine |
---|
[226] | 48 | IF file_test(nametbl, /user) NE 1 THEN BEGIN |
---|
| 49 | noanswer = report('The file '+nametbl+' is not yours... Do you want to copy '+nameshort+' in your MyIDL directory: '+homedir+' ?', /default_no, /question) |
---|
| 50 | IF noanswer THEN return ELSE BEGIN |
---|
[137] | 51 | file_copy, nametbl, homedir ; copy the file |
---|
| 52 | nametbl = homedir + nametbl ; update its name |
---|
| 53 | ENDELSE |
---|
| 54 | ENDIF |
---|
| 55 | ENDIF |
---|
| 56 | ; no file nametbl found |
---|
[226] | 57 | ENDIF ELSE BEGIN |
---|
[137] | 58 | nametbl = file_basename(namesave) ; get back the original nametbl |
---|
[226] | 59 | 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] | 60 | if NOT noanswer then return |
---|
[226] | 61 | nameorg = filepath('colors1.tbl', subdir = ['resource', 'colors']) |
---|
[137] | 62 | file_copy, nameorg, homedir |
---|
[226] | 63 | ENDELSE |
---|
[137] | 64 | ; is nametbl writable? |
---|
| 65 | IF file_test(nametbl, /write) NE 1 THEN file_chmod, nametbl, /u_write |
---|
| 66 | ; make sure that we will really use nametbl name even if _EXTRA keyword is used |
---|
[226] | 67 | if n_elements(ex) NE 0 then $ |
---|
[137] | 68 | if (where(tag_names(ex) EQ 'FILE'))[0] NE -1 then ex.FILE = nametbl |
---|
[2] | 69 | ; |
---|
[137] | 70 | tvlct, r, g, b, /get |
---|
| 71 | r = congrid(r, 256) |
---|
| 72 | g = congrid(g, 256) |
---|
| 73 | b = congrid(b, 256) |
---|
| 74 | IF n_elements(over) EQ 0 then over = 255 |
---|
| 75 | modifyct, over, namepal, r, g, b, file = nametbl, _extra = ex |
---|
[2] | 76 | ; |
---|
[137] | 77 | return |
---|
| 78 | end |
---|