PRO qImage_cw_CrossSection, state, event ;+ ; NAME: ; qImage_cw_CrossSection ; PURPOSE: ; Displays the horizontal and vertical cross-sections in a separate qLine widget. ; CATEGORY: ; Compound widget qImage_cw ; CALLING SEQUENCE: ; INPUTS: ; state array[1]; type: structure ; qImage_cw state structure ; event array[1]; type: structure ; event from state.wid_xcross or state.wid_ycross widgets ; OUTPUTS: ; (to qLine) ; INCLUDE: @compile_opt.pro ; On error, return to caller ; CALLS: ; qImage_cw_Box, qImage_cw_BoxImage, qLine ; PROCEDURE: ; The cross section is calculate the same way as for the curves ; plotted along the main draw widget in qImage_cw. ; MODIFICATION HISTORY: ; FEB-2000, Paul Hick (UCSD/CASS; pphick@ucsd.edu) ;- image_size = qImage_cw_Property(state, /image_size) n = max(image_size) xx = indgen(n) zz = replicate(!values.f_nan, 2, n) qImage_cw_Box, state, box, /get n = -1 p = [ [0,box[1]], [image_size[0]-1,box[3]] ] IF qImage_cw_BoxImage(state, p, sub_img=x, sub_box=sub_box) THEN BEGIN p = sub_box n = p[3]-p[1]+1 x = reform(x, n_elements(x)/n, n, /overwrite) zz[0,p[0]:p[2]] = total(x,2)/n ENDIF q = [ [box[0],0], [box[2], image_size[1]-1] ] IF qImage_cw_BoxImage(state, q, sub_img=y, sub_box=sub_box) THEN BEGIN q = sub_box n = q[2]-q[0]+1 y = reform(y, n, n_elements(y)/n, /overwrite) zz[1,q[1]:q[3]] = total(y,1)/n ENDIF ; The pixel numbering on the Y-axis takes state.img_offset into account. ; However the pixel numbering on the X-axis doesn't. IF n NE -1 THEN BEGIN p = [ [q[0],p[1]], [q[2],p[3]] ] n = p[2:3]-p[0:1]+1 q = state.img_offset#[1,1]+p ytitle = strarr(2) CASE n[0] OF 1L : ytitle[1] = 'pixel X['+strcompress(q[0],/rem)+']' ELSE: ytitle[1] = 'pixels X['+strcompress(q[0],/rem)+'-'+strcompress(q[2],/rem)+']' ENDCASE CASE n[1] OF 1L : ytitle[0] = 'pixel Y['+strcompress(q[1],/rem)+']' ELSE: ytitle[0] = 'pixels Y['+strcompress(q[1],/rem)+'-'+strcompress(q[3],/rem)+']' ENDCASE str = strarr(20) ; The square represents the image on the screen. Note that this may be less than the whole ; image if only a partial image is being displayed (e.g. by pView). IF n[0] LT image_size[0] THEN BEGIN str[ 0] = 'dim = ['+strcompress(image_size[0])+','+strcompress(image_size[1])+']' str[ 1] = 'box = [ ['+strcompress(p[0])+','+strcompress(p[1])+'] ,'+ $ '['+strcompress(p[2])+','+strcompress(p[3])+'] ]' str[ 2] = 'ur = (convert_coord(!x.crange[1],!y.crange[1],/data,/to_normal))[0:1]' str[ 3] = 'aspect = float(!d.y_size)/!d.x_size' str[ 4] = 'd = 0.1' str[ 5] = 'll = ur-d*[dim[0],dim[1]/aspect]/dim[0]' str[ 6] = 'plots, /normal, [ll[0],ur[0],ur[0],ll[0],ll[0]],[ll[1],ll[1],ur[1],ur[1],ll[1]]' str[ 7] = 'b = ll+d*[box[0],box[1]/aspect]/dim[0]' str[ 8] = 'e = ll+d*[box[2],box[3]/aspect]/dim[0]' str[ 9] = 'polyfill, /normal, [b[0],e[0],e[0],b[0],b[0]],[ll[1],ll[1],ur[1],ur[1],ll[1]], color=175B' ENDIF IF n[1] LT image_size[1] THEN BEGIN str[10] = 'dim = ['+strcompress(image_size[0])+','+strcompress(image_size[1])+']' str[11] = 'box = [ ['+strcompress(p[0])+','+strcompress(p[1])+'] ,'+ $ '['+strcompress(p[2])+','+strcompress(p[3])+'] ]' str[12] = 'ur = (convert_coord(!x.crange[1],!y.crange[1],/data,/to_normal))[0:1]' str[13] = 'aspect = float(!d.y_size)/!d.x_size' str[14] = 'd = 0.1' str[15] = 'll = ur-d*[dim[0],dim[1]/aspect]/dim[0]' str[16] = 'plots, /normal, [ll[0],ur[0],ur[0],ll[0],ll[0]],[ll[1],ll[1],ur[1],ur[1],ll[1]]' str[17] = 'b = ll+d*[box[0],box[1]/aspect]/dim[0]' str[18] = 'e = ll+d*[box[2],box[3]/aspect]/dim[0]' str[19] = 'polyfill, /normal, [ll[0],ur[0],ur[0],ll[0],ll[0]],[b[1],b[1],e[1],e[1],b[1]], color=175B' ENDIF qLine, xx, zz, group=state.wid_draw, $ title = 'Cross Section', $ ytitle = ['Pixel Number (without offset)',ytitle], $ newyaxis = [0,1,1], $ linestyle= [0,0,2], $ xmargin = [10,10], $ plotstr = str ENDIF RETURN & END