From: pendleton@ossenu.astro.nwu.edu (Jim Pendleton)
Newsgroups: comp.lang.idl-pvwave
Subject: Re: Giant crosshairs (with arrows)
Date: 29 Aug 92 22:41:36 GMT
Article-I.D.: ossenu.1992Aug29.174136.1
Organization: GRO/OSSE Northwestern U.

In article <Btpv88.4ss@csn.org>, james@teal.csn.org (Jim Phillips) writes:
> In article <laa-270892173708@berserk.c3.lanl.gov> laa@lanl.gov (Lee Ankeny) writes:
>>Hello Wave gurus,
>>
>>I'd like to implement a "giant crosshair", like the old tek terminals used
>>to have. It would extend from top edge to bottom edge, and left edge to
>>right edge of the window, intersecting at the current mouse pointer
>>location.
>>
> 
> Hi Lee.  You might give this a try.  Not guaranteed to be bullet proof :-)
> But it should get you going in the right direction.  Courtesy of 
> Mike 4 Mayer, PVI field Technical Sales Engineer.
> 
> James K. Phillips       Sprocket Scientist     pvi!james@boulder.colorado.edu
>  Precision Visuals, Inc.                        (303) 530-9000
>  6260 Lookout Rd         Boulder - A quaint little town nestled between
>  Boulder, CO 80301                   the ROCKIES and REALITY.

I've modified BIGHAIR to optionally accept arrow keys from the keyboard (your
escape sequences may vary...I'm using ESC[A, B, C, D).  Also the blips from the
continuous overplotting have been eliminated by selectively plotting only when
the cursor position changes.

> ----8<----------CUT HERE -----8<---------------CUT HERE-------------
PRO BIGHAIR, x, y, keyboard=keyboard, accelerate=accelerate
;
; Procedure to get cursor location in current window,
; using cursor lines across the entire window.
; The X and Y cursor locations (in pixels) are returned.
; Further modification could allow Normalized or
; Data coordinates to be returned.
; /Keyboard accepts arrow keys input from keyboard, rather than mouse
; Accelerate = number of pixels to jump in "/keyboard" mode.
;
; Mike Mayer, 8/28/92
; Modified:
;	Jim Pendleton, Dept. Physics & Astronomy
;	Northwestern U.
;	8/29/92
;
; Usage:
; WAVE> BIGHAIR, x, y [,/Keyboard [,Accelerate=# pixels]]
;
DEVICE, Get_Graphics = oldmode
DEVICE, Set_Graphics = 6 ; XOR write mode.
xmax = !D.X_Vsize
ymax = !D.Y_Vsize
!Err = 0 ; Reset.
oldx = 0
oldy = 0
If (not Keyword_Set(Accelerate)) then Begin
	Accelerate = 1.
EndIf
If (not Keyword_Set(KeyBoard)) then Begin
	PRINT, 'Press left mouse button to quit...'
	CURSOR, oldx, oldy, /Device, /Change
EndIf Else Begin
	PRINT, 'Press space bar to quit...'
	oldx = xmax/2
	oldy = ymax/2
	x = oldx
	y = oldy
EndElse
PLOTS, [oldx, oldx], [0, ymax], /Device  ; Draw first crosshairs.
PLOTS, [0, xmax], [oldy, oldy], /Device  ; Draw first crosshairs.
EMPTY
Up = String(27B) + '[A'
Down = String(27B) + '[B'
Right = String(27B) + '[C'
Left = String(27B) + '[D'
Clear = Get_Kbrd(0)
Null = ''
WHILE !Err NE 1 DO BEGIN
   If (Keyword_Set(Keyboard)) then Begin
	   A = String(Byte(Get_Kbrd(0)))
	   While ((A ne String(27B)) and (StrUpCase(A) ne ' ')) Do Begin
		   A = String(Byte(Get_Kbrd(0)))
	   EndWhile
	   B = String(Byte(Get_Kbrd(0)))
	   C = String(Byte(Get_Kbrd(0)))
	   Key = A + B + C
   EndIf Else Begin
	   CURSOR, x, y, /Device, /Change
   EndElse
   PLOTS, [oldx, oldx], [0, ymax], /Device  ; Erase last crosshairs.
   PLOTS, [0, xmax], [oldy, oldy], /Device ; Erase last crosshairs.
   If (Keyword_Set(Keyboard)) then Begin
	   !Err = 0
	   Case Key Of
		Up : y = oldy + Accelerate
		Down : y = oldy - Accelerate
		Left : x = oldx - Accelerate
		Right : x = oldx + Accelerate
		Null : x = x
		Else : !Err = 1
	   EndCase
   EndIf
   If ((x ne oldx) or (y ne oldy)) then Begin
	   PLOTS, [x, x], [0, ymax], /Device ; Draw new crosshairs.
	   PLOTS, [0, xmax], [y, y], /Device ; Draw new crosshairs.
	   oldx = x
	   oldy = y
	   EMPTY
   EndIf
ENDWHILE
If (not Keyword_Set(Keyboard)) then Begin
;
; Already erased in Keyboard mode.
;
	PLOTS, [oldx, oldx], [0, ymax], /Device  ; Erase last crosshairs.
	PLOTS, [0, xmax], [oldy, oldy], /Device ; Erase last crosshairs.
EndIf
Empty
DEVICE, Set_Graphics = oldmode
PRINT, 'X = ' + STRTRIM(x, 2), '   Y = ' + STRTRIM(y, 2)
END
> ----8<----------CUT HERE -----8<---------------CUT HERE-------------

Jim Pendleton, SysMgr, etc.
GRO/OSSE, Dept. Physics & Astronomy
Northwestern U.
pendleton@ossenu.astro.nwu.edu