comp.lang.idl-pvwave archive
Messages from Usenet group comp.lang.idl-pvwave, compiled by Paulo Penteado

Home » Public Forums » archive » Re: Crosshair data point extraction - Query
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Crosshair data point extraction - Query [message #1514] Thu, 02 December 1993 07:58
oet is currently offline  oet
Messages: 28
Registered: February 1993
Junior Member
In article AA19871@tigermoth.aero.gla.ac.uk.gla.ac.uk, gnaa38@aero.gla.ac.uk (Paul Porcelli) writes:
> Is there any facility in IDL or Wave to produce a plot and then identifty the
> coordinates of a point by clicking the mouse or moving a crosshair over the
> point.

The procedure below plots a moving crosshair, example:

IDL> window
IDL> bighair, COLOR=!d.n_colors-1

-Thomas


********************************* CUT HERE **********************************

PRO BIGHAIR, x, y, KEYBOARD=KEYBOARD, ACCELERATE=ACCELERATE, $
PERMANENT=PERMANENT, COLOR=COLOR
;
;+
; NAME:
; BIGHAIR
;
; PURPOSE:
;
; Gets cursor location in current window,
; using cursor lines across the entire window.
; /Keyboard accepts arrow keys input from keyboard, rather than mouse
; Accelerate = number of pixels to jump in "/keyboard" mode.
; The X and Y cursor locations (in pixels) are returned.
; Further modification could allow Normalized or
; Data coordinates to be returned.
;
;
;
; CATEGORY:
; Interactive Drawing
;
;
; CALLING SEQUENCE:
;
; IDL> BIGHAIR, x, y [,/Keyboard [,Accelerate=# pixels]]
;
; KEYWORDS:
; KEYBOARD Use keyboard instead of mouse
; ACCELERATE increase steps on usage with keyboard
; PERMANENT show current position permanently
; COLOR color to draw bighair
;
; SEE ALSO:
;
;
; MODIFICATION HISTORY:
; Written by: Mike Mayer, 8/29/92
; Jim Pendleton, Dept. Physics & Astronomy
; Northwestern U.
; Added to idlmeteo 11-june-1993 oet@sma.ch
; 28-june-1993, oet@sma.ch, inserted short
; wait (0.2) after first plot, to get
; more stability on first plot.
; 9-Aug-1993, oet@sma.ch, added keywords
; PERMANENT and COLOR
;-

if keyword_set(COLOR) then col=color else col=!d.n_colors-1

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, COLOR=col ; Draw first crosshairs.
PLOTS, [0, xmax], [oldy, oldy], /Device, COLOR=col ; Draw first crosshairs.
wait, 0.3
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, COLOR=col ; Erase last crosshairs.
PLOTS, [0, xmax], [oldy, oldy], /Device, COLOR=col ; 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
if keyword_set(PERMANENT) then begin
coords=convert_coord(x,y,/DEVICE, /TO_DATA)
tmp_string= 'x: '+strtrim(coords(0),2) + $
' y: ' + strtrim(coords(1),2)
print, tmp_string
endif


PLOTS, [x, x], [0, ymax], /Device, COLOR=col ; Draw new crosshairs.
PLOTS, [0, xmax], [y, y], /Device, COLOR=col ; 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, COLOR=col ; Erase last crosshairs.
PLOTS, [0, xmax], [oldy, oldy], /Device, COLOR=col ; Erase last crosshairs.
EndIf
Empty
DEVICE, Set_Graphics = oldmode
PRINT, 'X = ' + STRTRIM(x, 2), ' Y = ' + STRTRIM(y, 2)
END
Re: Crosshair data point extraction - Query [message #1521 is a reply to message #1514] Wed, 01 December 1993 12:53 Go to previous message
offenbrg is currently offline  offenbrg
Messages: 31
Registered: August 1993
Member
gnaa38@aero.gla.ac.uk (Paul Porcelli) writes:

> Is there any facility in IDL or Wave to produce a plot and then identifty the
> coordinates of a point by clicking the mouse or moving a crosshair over the
> point.
> Thanks in advance.

There is a procedure called CURSOR (It appears in IDL, and should appear in
Wave as well but I'm not sure). You can use it with /DATA, /DEVICE and
/NORMAL coordinates.

Example:
plot,indgen(40),psym=1 ;plots '+' as the symbol.
cursor,x,y,3,/DATA ;Move the cursor onto a '+' and click with
;any mouse button.
print,x,y ;Ta-daah.


Have fun.
Joel
--
Joel D Offenberg | "Aren't you in the position of a life-long
Hughes STX/ UIT Science Team | vegetarian giving us your recipe for steak
offenbrg@fondue.gsfc.nasa.gov | and kidney pie?" - Rumpole of the Bailey
I get paid to stare into space. |
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: Wavelet transforms
Next Topic: Ghostscript & Ghostview as IDL Manual Browser

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ] [ PDF ]

Current Time: Sat Oct 11 02:14:35 PDT 2025

Total time taken to generate the page: 0.79656 seconds