;+ ; ;thm_ui_draw_object method: convertColor ; ; ;this routine converts between True color and indexed color ;depending upon which color mode is set by the window ;if keyword: backwards is set, the routine will return a 1x3 array, ;Which may be useful in some applications. ; ;$LastChangedBy: pcruce $ ;$LastChangedDate: 2010-08-25 18:05:01 -0700 (Wed, 25 Aug 2010) $ ;$LastChangedRevision: 7774 $ ;$URL: svn+ssh://thmsvn@ambrosia.ssl.berkeley.edu/repos/thmsoc/tags/tdas_8_00/idl/themis/thm_ui_new/display/draw_object/thm_ui_draw_object__convertcolor.pro $ ;- function thm_ui_draw_object::convertColor,color,backwards=backwards compile_opt idl2 self.destination->getProperty,palette=pal,color_model=col if col eq 1 && n_elements(color) eq 1 then return,color if col eq 0 && n_elements(color) eq 3 then begin if (keyword_set(backwards) && size(color,/n_dim) eq 2) || $ (~keyword_set(backwards) && size(color,/n_dim) eq 1) then begin return,color endif if (keyword_set(backwards) && size(color,/n_dim) eq 1) || $ (~keyword_set(backwards) && size(color,/n_dim) eq 2) then begin return,transpose(color) endif endif ;If we don't have a valid palette object, ;Use the command line color table. if ~obj_valid(pal) then begin tvlct,r,g,b,/get pal = obj_new('IDLgrPalette',r,g,b) self.destination->setProperty,palette=pal endif if n_elements(color) eq 1 then begin if keyword_set(backwards) then begin return,transpose(pal->getRGB(color)) endif else begin return,pal->getRGB(color) endelse endif if n_elements(color) eq 3 then begin return,pal->nearestcolor(color[0],color[1],color[2]) endif self.statusBar->update,'Error: Invalid color argument passed to thm_ui_draw_object' ;t=error_message('Invalid color argument',/traceback) return,-1 end