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

Home » Public Forums » archive » [Q}:Rubberbanding in IDL
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: [Q}:Rubberbanding in IDL [message #3889 is a reply to message #3805] Fri, 31 March 1995 00:00 Go to previous message
mbastian is currently offline  mbastian
Messages: 3
Registered: March 1994
Junior Member
Here is my rubber banding program.

Hope this helps.

Matthew Bastian
National Research Council of Canada


pro RubberBand, LeftHandSide, RightHandSide, Bottom, Top
;
; this program will draw a rubber band box that follows the cursor
; the first corner starts when the left mouse button is pressed
; and the other corner ends when the mouse button is released
;
!err = 0
LeftButtonPressed = 1
LoopCount = 0L

;
; set the clip rectangle to it's maximum limits in order for "zoom" to work
;
!p.clip = [0,0,!d.x_size,!d.y_size,0,0]

;
; keep looping until the user presses the left mouse button
;
while !err ne LeftButtonPressed do begin
;
; every 100 times through this loop print the usage message
;
if LoopCount mod 100L eq 0 then begin
print, 'Press left mouse button to activate rubber band box'
LoopCount = 0
endif
LoopCount = LoopCount + 1

;
; get the current mouse location in pixels relative to lower lhs corner
; note that this function return immediatly without waiting for a mouse
; button to be pressed
;
cursor, x1, y1, /nowait, /data
endwhile
print, 'Release left mouse button to de-activate rubber band box'

;
; keep looping and drawing the rubber band box until the button is released
;
!linetype = 0
x2 = x1
y2 = y1
x = -1
y = -1
device, set_graphics=6, get_graphics=oldg
oplot,[x1, x1, x2, x2, x1], [y1, y2, y2, y1, y1]; /device
while (!err eq LeftButtonPressed) or ((x eq -1) and (y eq -1)) do begin
cursor, x, y, /nowait, /data
if (x ne x2) or (y ne y2) then begin
oplot,[x1, x1, x2, x2, x1], [y1, y2, y2, y1, y1]
x2 = x
y2 = y
oplot,[x1, x1, x2, x2, x1], [y1, y2, y2, y1, y1]
endif
endwhile
oplot,[x1, x1, x2, x2, x1], [y1, y2, y2, y1, y1]
device, set_graphics=oldg

;
; set up the return values
; converting from screen coordinates to world coordinates
;
if x1 lt x2 then begin
LeftHandSide = float (x1)
RightHandSide = float (x2)
endif else begin
RightHandSide = float (x1)
LeftHandSide = float (x2)
endelse

if y1 lt y2 then begin
Bottom = float (y1)
Top = float (y2)
endif else begin
Top = float (y1)
Bottom = float (y2)
endelse

return
end
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: IDL call_external to sprlib ?
Next Topic: Re: [Q] NR_DFPMIN: Roundoff problem in lnsrch..

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

Current Time: Fri Oct 10 14:33:47 PDT 2025

Total time taken to generate the page: 1.12137 seconds