;+
; NAME:
;	SMEI_SEQUENCE::SET_COLOUR_MAP
;
;
; PURPOSE:
;	Load and store colour map to use when plotting SMEI images
;
;
; CATEGORY:
;	SMEI_SEQUENCE
;
;
; KEYWORD PARAMETERS:
;	/menu		If set, then load a table using xloadct.
;	group	long	A widget group leader for xloadct
;	table	int	If set, then load the numbered colour table
;	map	byte	A 256x3 byte array that contains an explicit
;			colour map to use
;	redraw	int	A named variable to return the redraw
;			requirement. 
;
; CALLING SEQUENCE:
;	seqref -> set_colour_map
;
;
; MODIFICATION HISTORY:
;	Original: 9/12/02; SJT
;	Merge with set_colour_table and allow explicit tables:
;	19/12/02; SJT
;	Made call to XLOADCT modal so that it stores the colour table
;	correctly: 17/9/03; SJT
;	Return redraw state if needed: 23/11/09; SJT
;-

pro smei_sequence::set_colour_map, menu = menu, group = group, table = $
                                   table, map = map, redraw = redraw

if keyword_set(map) then begin
    sz = size(map)
    if sz[0] eq 2 and sz[1] eq 3 and sz[2] eq 256 then map = $
      transpose(map) $
    else if sz[0] ne 2 or sz[1] ne 256 or sz[2] ne 3 then begin
        smei_msg, /alert, ['Invalid shape for explicit colour map', $
                           'it must be a 256x3 array']
        return
    endif
    self.colour_table = map
endif else begin
    if keyword_set(menu) then xloadct, group = group, block = block, $
      /modal $
    else if n_elements(table) ne 0 then loadct, table, /silent $
    else smei_msg, /warn, ['Null call to set_colour_map', $
                           'comitting current colour table']

    colour_table = bytarr(256, 3)
    tvlct, colour_table, /get

    self.colour_table = colour_table
endelse

if !d.name ne 'PS' then begin
    junk = colormap_applicable(redraw)
    if redraw then self -> mk_pixmap, /clear
endif

end
