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

Home » Public Forums » archive » Re: David Fanning's rubberband box
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: David Fanning's rubberband box [message #11099 is a reply to message #11097] Fri, 13 March 1998 00:00 Go to previous messageGo to previous message
Martin Schultz is currently offline  Martin Schultz
Messages: 515
Registered: August 1997
Senior Member
Joseph Scott Stuart wrote:
>
> I've recently gotten David Fanning's book, and I like it quite a bit.
> Good job, David! I am having a problem though with the rubberband box
> code on page 117. I'm using IDL 5.0.2 on an SGI. When I am finished
> drawing the rubberband box and release the mouse button, the program
> does not exit the repeat loop. I have to push another button before it
> will register that I've released the first button. I added the
> following line just before the ENDREP:
>
> cursor, x, y, /NoWait
> ENDREP UNITL !Mouse.Button NE 1
>
> That mostly fixed the problem, but it still seems to only work
> sporadically. That is, sometimes I'll draw a box, release the button,
> and it ends the loop as it is supposed to, other times it does not,


Scott,

please find attached my version of David F.'s rubberband. It
draws a rubberband box as long as you press the mouse button and exits
if you release it (*and* if you move the mouse which is caused by the
CHANGE flag). It's not perfect but works for me. If you come up with a
better solution let me know.

Regards,
Martin.



------------------------------------------------------------ -------
Dr. Martin Schultz
Department for Earth&Planetary Sciences, Harvard University
186 Pierce Hall, 29 Oxford St., Cambridge, MA-02138, USA

phone: (617)-496-8318
fax : (617)-495-4551

e-mail: mgs@io.harvard.edu
IDL-homepage: http://www-as.harvard.edu/people/staff/mgs/idl/
------------------------------------------------------------ -------



pro trackcursor,x1,y1,x2,y2,first=first,pixwin=pixwin
; draws rubberband for data selection
; as of 23 DEC 1997: uses device,copy (idea D.Fanning)
; return pixwin to destroy window afterwards

common trackcommon,curwin,pixwinindex

; create pixmap and copy current image
if (keyword_set(first)) then begin
curwin = !d.window
window,/free,xsize=!d.x_size,ysize=!d.y_size,/pixmap
pixwin = !d.window
pixwinindex = pixwin
device,copy=[0,0,!d.x_size,!d.y_size,0,0,curwin]
wset,curwin
endif

; copy old image from pixwin
device,copy=[0,0,!d.x_size,!d.y_size,0,0,pixwinindex]

; overlay red rectangle with new mouse coordinates
plots,[x1,x2,x2,x1,x1],[y1,y1,y2,y2,y1],color=2,thick=1

return
end



pro use_cursor,x1=mx1,x2=mx2,y1=my1,y2=my2
; activates graphics cursor for rubberband selection

!err=0
cursor,mx1,my1,/down
trackcursor,mx1,my1,mx1,my1,/first,pixwin=pixwin

while (!err ne 0) do begin
cursor,mx2,my2,/change
trackcursor,mx1,my1,mx2,my2
endwhile

wdelete,pixwin

; print,'X1=',mx1,',Y1=',my1
; print,'X2=',mx2,',Y2=',my2

end
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: LINKIMAGE problem (beginner)
Next Topic: Re: Histogram function

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

Current Time: Tue Dec 02 08:19:55 PST 2025

Total time taken to generate the page: 0.00234 seconds