;+ ; NAME: ; qvu_draw ; PURPOSE: ; Redraws qvu window ; CATEGORY: ; sat/idl/widget/qvu ; CALLING SEQUENCE: PRO qvu_draw, state, event ; INPUTS: ; state array[1]; type: structure ; qvu state structure ; event array[1]; type: structure ; event structure ; OUTPUTS: ; (none) ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; EulerRotate, InterpolateHeliosphere, MagnifyArray, plot3darc, plot3dline, setup3d ; vu_mean, vu_get, unitvectors, gridgen, Carrington ; PROCEDURE: ; If a time sequences is loaded then the image is based on the 3D matrix ; at the time set by the time slider, either by interpolation (if the fixgrid ; button is NOT set) or by picking the nearest grid time (if the fixgrid button ; IS set). ; MODIFICATION HISTORY: ; SEP-2001, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ;- IF state.count EQ 0 THEN RETURN index = widget_info(state.wid_index, /droplist_select) widget_control, state.wid_pole_lng, get_value=lng & lng = lng[0]/!radeg widget_control, state.wid_pole_lat, get_value=lat & lat = lat[0]/!radeg widget_control, state.wid_pole_rad, get_value=rad & rad = rad[0] widget_control, state.wid_pole_tim, get_value=tim & tim = tim[0] tim = Carrington(tim, /get_time) widget_control, state.wid_fixgrid, get_uvalue=set widget_control, state.wid_pick, get_uvalue=hdr, /no_copy widget_control, state.wid_path, get_uvalue=ff , /no_copy ; Interpolate on time array index as a function of Carrington time ; to calculate the density matrix at the proper (interpolated) time. hdrf = vu_gettime(hdr[*,0], ff, ut=tim, ff_ut=f, fixgrid=set) widget_control, state.wid_path, set_uvalue=ff , /no_copy widget_control, state.wid_pick, set_uvalue=hdr, /no_copy f = f[*,*,*,index] start_distance = vu_get(hdrf, /start_distance) distance_step = vu_get(hdrf, /distance_step ) array_range = vu_get(hdrf, /array_range ) rmax = vu_get(hdrf, /stop_distance ) widget_control, state.wid_cuttingplane, get_uvalue=cuttingplane widget_control, state.wid_synopticmap , get_uvalue=synopticmap widget_control, state.wid_orthographic, get_uvalue=orthographic IF synopticmap OR orthographic THEN rad = abs(rad) > start_distance ;======== ; Set up drawing of geometry of displayed map in 3D heliosphere ; Set up unit vectors along pole ; Then find two perpendicular unit vectors origin = [0,0,0] runit = [[1,0,0],[0,1,0],[0,0,1]] pole = cos(lat)*(cos(lng)*runit[*,0]+sin(lng)*runit[*,1])+sin(lat)*runit[*,2] xyz = unitvectors(pole, /ascending) widget_control, state.wid_plane, get_value=wid wold = !d.window wset, wid setup3d, -1.15, 1.15, 0.0, 1.0, /oblique erase CASE 1 OF cuttingplane: BEGIN ; Plot plane through sphere h = rad/rmax ; Distance of plane to origin r = sqrt( (1-h*h) > 0 ) ; Radius of small circle of intersection of plane and sphere ; Plot small circle plot3darc, origin+h*xyz[*,2], r*xyz[*,0], r*xyz[*,1],0, 2*!pi, color=round(0.9*!d.n_colors) ; Plot x,y,z axes FOR i=0,2 DO plot3dline, -runit[*,i],runit[*,i] ; Plot great circles connecting x-y, y-z, and z-x axis pairs FOR i=0,2 DO plot3darc, origin, runit[*,i],runit[*,(i+1) mod 3],0, 2*!pi ; Plot x',y',z' axes perpendicular to selected plane FOR i=0,2 DO plot3dline, origin, xyz[*,i],linestyle=3 END synopticmap: BEGIN ; Plot sphere corresponding to synoptic map ; Plot x,y,z axes FOR i=0,2 DO plot3dline, -runit[*,i],runit[*,i] ; Plot great circles connecting x-y, y-z, and z-x axis pairs FOR i=0,2 DO plot3darc, origin, runit[*,i],runit[*,(i+1) mod 3],0, 2*!pi h = rad/rmax ; Radius of synoptic sphere ; Plot x',y',z' axes for synoptic sphere ; (the z'-axis is NOT necessarily the solar rotation axis!) FOR i=0,2 DO plot3dline, -h*xyz[*,i],h*xyz[*,i] ; Plot great circles connecting x'-y', y'-z' and z'-x' axis pairs FOR i=0,2 DO plot3darc, origin, h*xyz[*,i],h*xyz[*,(i+1) mod 3],0, 2*!pi END orthographic: BEGIN END ENDCASE wset, wold widget_control, state.wid_grid, get_value=ndim, get_uvalue=winsize CASE 1 OF cuttingplane: BEGIN ; Plot cross section of plane with data sphere ndim = long([ndim,ndim]) ; Dimensions of image (may be rebinned to higher resolution later) R = gridgen(ndim, range=[-1.0,1.0,-1.0,1.0]); Rectangular 2D-vectors in plane of cross section ; Rectangular 3D-vectors in coordinate frame of data array R = (rad*xyz[*,2])#replicate(1,ndim[0]*ndim[1])+rmax*xyz[*,0:1]#R R = cv_coord(from_rect=R, /to_sphere); Convert to spherical coordinates xsize = winsize ysize = winsize END synopticmap: BEGIN ; Plot sphere in form of synoptic map ndim = long([ndim,ndim/2]) ; Dimensions of image in pixels (height is half of width) ; Spherical 3D-vectors for synoptic sphere R = [gridgen(ndim, range=!pi*[0.0,2.0,-0.5,0.5]),transpose(replicate(rad,ndim[0]*ndim[1]))] ; Rotate to coordinate frame of data array R = EulerRotate([-!pi/2,-(!pi/2-lat),-lng],R) xsize = winsize ysize = winsize/2 END orthographic: BEGIN ndim = long([ndim,ndim]) ; Dimensions of image (may be rebinned to higher resolution later) R = gridgen(ndim, range=[-1.0,1.0,-1.0,1.0]); x,y coordinates over a square from -1 to +1 h = total(R*R,1) ; Distance to disk center squared out = where(h GT 1) ; Pixels outside disk IF out[0] NE -1 THEN R[*,out] = BadValue(R) ; Set pixels outside disk bad z = reform(R[0,*]) ; Z-values across disk (bad outside disk) in = where( finite(z) ) ; Pixels on disk IF in[0] NE -1 THEN z[in] = sqrt( (1-h[in]) > 0 ) R = [R,transpose(z)] ; x,y,z, coordinates IF in[0] NE -1 THEN BEGIN z = R[*,in] z = CvT3D(rot=[0.0,0.0,-!pi/2.0, 0.0, lat-!pi/2.0, -lng], vector=z) z = cv_coord(from_rect=z, /to_sphere, /double) z[0,*] = AngleRange(z[0,*]) ; Keep inside [0,2*!pi] z[2,*] = rad*z[2,*] > rad ; Needed at source surface R[*,in] = z ENDIF xsize = winsize ysize = winsize END ENDCASE R = reform(R,3,ndim[0],ndim[1]) ; Get interpolated data f = InterpolateHeliosphere(R, f, start_distance, distance_step, $ xcrange=array_range, /cv2carrington, /periodic) xmin = min(f, max=xmax, /nan) IF ndim[0] LT winsize THEN BEGIN ; Rebin if necessary widget_control, state.wid_rebin[0], get_uvalue=congrid_on widget_control, state.wid_rebin[1], get_uvalue=rebin_on widget_control, state.wid_rebin[2], get_uvalue=magnify_on CASE 1 OF congrid_on: f = congrid(f, xsize, ysize, /interp, /minus_one) rebin_on : f = rebin (f, xsize, ysize) magnify_on: f = magnifyarray(f, xsize/ndim[0]) ENDCASE ENDIF IF synopticmap THEN BEGIN ; Center synoptic map in window vertically yoff = winsize/4 set = f f = fltarr(winsize,winsize) f[*,yoff:yoff+ysize-1] = set ENDIF widget_control, state.wid_fixscale, get_uvalue=set IF set THEN BEGIN ; Fix data limits for display widget_control, state.wid_minvalue, get_value=ymin widget_control, state.wid_maxvalue, get_value=ymax IF finite(ymin) THEN xmin = ymin IF finite(ymax) THEN xmax = ymax ENDIF widget_control, state.wid_minvalue, set_value=xmin widget_control, state.wid_maxvalue, set_value=xmax widget_control, state.wid_draw, get_value=wid wset, wid erase bad = where( 1-finite(f) ) top = 55 b = top+bytscl(f, min=xmin, max=xmax, top=255-top, /nan) b[bad] = 0B tv, b wset, wold widget_control, state.wid_draw, set_uvalue=f, /no_copy RETURN & END