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

Home » Public Forums » archive » Re: cursor command
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Return to the default flat view Create a new topic Submit Reply
Re: cursor command [message #83773 is a reply to message #83772] Wed, 03 April 2013 06:52 Go to previous messageGo to previous message
Russell Ryan is currently offline  Russell Ryan
Messages: 122
Registered: May 2012
Senior Member
On Tuesday, April 2, 2013 1:04:49 PM UTC-4, gpet...@ucsc.edu wrote:
> Can you use the cursor command on a 2d contour map?


Ok. So now I think I know what's wrong. You want to draw a contour plot, then select a line, then have it plot the profile along that line. Got it. Well, I suppose a line is given by either two points: (x1,y1) and (x2,y2) or by a slope-intercept pair (m,b). Of course it's easy to convert between the two, but since you'e asked about cursor, I suppose we should use the two xy pairs.

Here's the pseudocode.
1. plot the contour.
2. click once to get one point.
3. click a second time to get the other point.
4. draw the profile
5. Goto 2 or quit.

Here's some IDL code
;step 0 read the image
img=dist(200)
sz=size(img,/dim) ;the size of the image

;step 1. draw the contour
window,1,retain=2,xsize=400,ysize=400
contour,img

npoints=100 ;number of the line plot

;start a while loop so we can "goto" step 2


;save the current state of the mouse button. this is generally
;a good habit anytime you modify or test the system variables
mousebutton=!mouse.button & !mouse.button=0
print,'right click to quit'
while !mouse.button ne 4 do begin
;double chcek that the window is set to the main one.
wset,1

print,'please click on one point.'
cursor,x1,y1,3,/data
if x1 lt 0 || y1 lt 0 || x1 gt sz(0) || y1 gt sz(1) then begin
print,'first point is off the image.'
goto,skip
endif

print,'please click on a second point.'
cursor,x2,y2,3,/data
if x2 lt 0 || y2 lt 0 || x2 gt sz(0) || y2 gt sz(1) then begin
print,'second point is off the image.'
goto,skip
endif



;okay at this point, we have the two x,y pairs
;over plot the line
oplot,[x1,x2],[y1,y2],line=1

;now extract the contour (via Fanning's webpage)
xloc=x1+(x2-x1)*findgen(npoints)/(npoints-1)
yloc=y1+(y2-y1)*findgen(npoints)/(npoints-1)
line=interpolate(img,xloc,yloc)

;now create a second window for the plot
window,3,retain=2,xsize=400,ysize=400
plot,line

;set the window back to the first (in case you want to do it again)
wset,1

skip:
endwhile

;if here, menas you quit. so lets uset the mousestate
!mouse.button=mousebutton
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: map_do_segments: map file: plow not found
Next Topic: How to parse the output of restore, filename, /ver

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

Current Time: Fri Oct 10 10:32:29 PDT 2025

Total time taken to generate the page: 0.24036 seconds