;+
; NAME:
;	SMEI_COLOUR
;
;
; PURPOSE:
;	Set the colour table for a SMEI sequence
;
;
; CATEGORY:
;	CLI
;
;
; CALLING SEQUENCE:
;	smei_colour, table
;
;
; INPUTS:
;	seqref	objref		Object reference to the sequence.
;	table	int/byte	Either a scalar giving the colour
;				table index, or a 256x3 array with a
;				colour map.
;
;
; OPTIONAL INPUTS:
;
;
;
; KEYWORD PARAMETERS:
;	/menu	If set, then use XLOADCT to select/adjust the colour
;		table.
;
;
; MODIFICATION HISTORY:
;	Original: 19/12/02; SJT
;-

pro smei_colour, seqref, table, menu = menu, help = help

if keyword_set(help) then begin
    self_help
    return
end

if not obj_valid(seqref) then begin
    smei_msg, /alert,  'SMEI_COLOUR requires an object reference'
    return
endif

if not obj_isa(seqref, 'SMEI_SEQUENCE') then begin
    smei_msg, /alert, $
              'The object you are trying to modify is not a ' + $
              'SMEI_SEQUENCE'
    return
endif

if keyword_set(menu) then seqref -> set_colour_map, /menu $
else if n_elements(table) eq 1 then seqref -> set_colour_map, table = $
  table $
else begin
    sz = size(table)
    if sz[0] eq 2 and sz[1] eq 3 and sz[2] eq 256 then table = $
      transpose(table) $
    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
    seqref -> get_colour_map, map = table
endelse

end
    
