pro xgetdistance,x0=x0,y0=y0,x1=x1,y1=y1,ds=ds ;+ ; XGETDISTANCE ; ; xgetdistance ; ;- common active,active device, get_graphics = old, set_graphics = 6 ;Set xor col = (!d.n_colors/2) !err=0 while (!err ne 1) do begin cursor,x0,y0,/change wait,0.3 endwhile x1=x0+1 y1=y0+1 plots,[x0,x1],[y0,y1],/data,col=col tvcrs,x1,y1,/data change_start=1 ; Get out when the right button is pushed repeat begin cursor,x,y,/change case !err of 0: begin ; No buttons - move the current end wait,0.1 plots,[x0,x1],[y0,y1],/data,col=col if(change_start) then begin x1=x & y1=y endif else begin x0=x & y0=y endelse plots,[x0,x1],[y0,y1],/data,col=col endcase 1: begin ; Left Button - Toggle change_start if (change_start) then begin change_start=0 tvcrs,x0,y0,/data endif else begin change_start=1 tvcrs,x1,y1,/data endelse wait,0.3 endcase 2: 4: ; Right button endcase endrep until (!err eq 4) device,set_graphics=old ds=sqrt((x1-x0)^2 + (y1-y0)^2) print,'(X,Y)_0 = ',x0,y0,' (X,Y)_1 = ',x1,y1,' DS = ',ds end