[2] | 1 | ;------------------------------------------------------------ |
---|
| 2 | ;+ |
---|
| 3 | ; |
---|
[133] | 4 | ; @file_comments |
---|
[137] | 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 |
---|
[2] | 7 | ; 'colors1.tbl'. |
---|
| 8 | ; |
---|
[157] | 9 | ; @categories |
---|
| 10 | ; Color |
---|
[2] | 11 | ; |
---|
[136] | 12 | ; @param namepal {in}{required} |
---|
[137] | 13 | ; a string containing the name of the new palette we want to write. |
---|
[2] | 14 | ; |
---|
[136] | 15 | ; @keyword OVER |
---|
[137] | 16 | ; the number of the palette we want to replace |
---|
[2] | 17 | ; |
---|
[137] | 18 | ; @keyword FILE {default='palette.tbl'} |
---|
| 19 | ; The file containing the color palettes. It can be in any directory of the !path. |
---|
[2] | 20 | ; |
---|
[137] | 21 | ; @keyword _EXTRA |
---|
| 22 | ; Used to pass modifyct keywords |
---|
[2] | 23 | ; |
---|
[157] | 24 | ; @history 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 | ; |
---|
[133] | 28 | ; @version $Id$ |
---|
| 29 | ; |
---|
[2] | 30 | ;- |
---|
| 31 | ;------------------------------------------------------------ |
---|
[137] | 32 | pro newpalette, namepal, FILE = file, OVER = over, _EXTRA = ex |
---|
[114] | 33 | ; |
---|
| 34 | compile_opt idl2, strictarrsubs |
---|
| 35 | ; |
---|
[133] | 36 | ; definition of the name of the file containing colors palettes. |
---|
[137] | 37 | if keyword_set(file) then nametbl = file ELSE nametbl = 'palette.tbl' |
---|
[133] | 38 | ; What is the full adress of nametbl? |
---|
[137] | 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 |
---|
[2] | 68 | ; |
---|
[137] | 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 |
---|
[2] | 75 | ; |
---|
[137] | 76 | return |
---|
| 77 | end |
---|