pro spd_ui_draw_object::getSpecModel,plotData,zrange,palette,model=model
compile_opt idl2
model = obj_new('IDLgrModel')
pal = obj_new('IDLgrPalette')
getctpath,ctpath
pal->loadct,palette,file=ctpath
pal->getProperty,red_values=rv,green_values=gv,blue_values=bv
out = reform(intarr(4,(*plotData).pixx,(*plotdata).pixy),4,(*plotData).pixx,(*plotdata).pixy)
if (*plotData).zscale eq 1 || (*plotData).zscale eq 2 then begin
idx = where(finite((*plotData).data,/infinity,sign=-1),c)
if c gt 0 then begin
(*plotData).alpha[idx] = 255
(*plotData).data[idx] = zrange[0]
endif
endif
zval = bytscl((*plotData).data,/nan,min=zrange[0],max=zrange[1])
out[0,*,*] = rv[zval]
out[1,*,*] = gv[zval]
out[2,*,*] = bv[zval]
out[3,*,*] = (*plotdata).alpha
out = reform(out,4,(*plotData).pixx,(*plotData).pixy)
imageObj = obj_new('IDLgrImage',out,$
location=[(*plotData).xstart,(*plotData).ystart,(*plotData).zstack],$
dimensions=[(*plotData).xsize,(*plotData).ysize],$
depth_test_disable=2,$
blend_function=[3,4])
polygon = obj_new('IDLgrPolygon', $
[[(*plotData).xstart,(*plotData).ystart,(*plotData).zstack],$
[(*plotData).xstart+(*plotData).xsize,(*plotData).ystart,(*plotData).zstack],$
[(*plotData).xstart+(*plotData).xsize,(*plotData).ystart+(*plotData).ysize,(*plotData).zstack],$
[(*plotData).xstart,(*plotData).ystart+(*plotData).ysize,(*plotData).zstack]], $
texture_map=imageObj,$
texture_coord=[[0,0],[1,0],[1,1],[0,1]], $
color=self->convertColor([255,255,255]),$
shading=1,$
clip_planes=(*plotData).clip,$
/double )
model->add,polygon
end