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

Home » Public Forums » archive » Re: vertical line that moves with cursor in draw widget
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: vertical line that moves with cursor in draw widget [message #60724 is a reply to message #60723] Fri, 06 June 2008 19:51 Go to previous messageGo to previous message
ben.bighair is currently offline  ben.bighair
Messages: 221
Registered: April 2007
Senior Member
On Jun 6, 5:14 pm, cgoet...@igpp.ucla.edu wrote:
> Hello, I have a draw_widget with motion events set up. I draw a
> vertical line (using plots) which follows the cursor as it moves
> through the draw area. I can get the vertical line to follow the
> cursor easily enough - but I can't seem to figure out how to erase the
> previous lines. All the lines remain drawn. Any suggestions?
> Thanks! Cindy


Hi,

If you are using direct graphics, then your best bet is create a
"pixmap" copy of the window contained inthe draw widget. Then use the
DEVICE, copy = [blah, blah, blah...] to copy the contents of the
pixmap quickly to the the exposed draw window. This is pretty fast
and less expensive than trying to erase before plotting.

Here's an example. [By the way, you should consider buying on the of
the many fine intro to IDL books available. I like them all.]


Cheers,
Ben


PRO PLOT_EXAMPLE_DRAW_EVENT, ev

WIDGET_CONTROL, ev.id, GET_UVALUE = info

WSET, info.drawWin
DEVICE, copy = [0,0, info.dim[0], info.dim[1], 0,0, info.pixWin]

xy = CONVERT_COORD(ev.x, ev.y, /DEVICE, /TO_DATA)

PLOTS, [xy[0], xy[0]], !Y.CRANGE
PLOTS, !X.CRANGE, 30 + 5*[xy[0],xy[0]] - 11*([xy[0],xy[0]])^2
END


PRO PLOT_EXAMPLE

xsize = 400
ysize = 400

tlb = WIDGET_BASE()
drawID = WIDGET_DRAW(tlb, $
xsize = xsize, ysize = ysize, MOTION_EVENTS = 1, $
EVENT_PRO = "PLOT_EXAMPLE_DRAW_EVENT")
WINDOW,/FREE, xsize = xsize, ysize = ysize, /PIXMAP
pixWin = !D.window

WIDGET_CONTROL, tlb, /REALIZE
WIDGET_CONTROL, drawID, GET_VALUE = drawWin

WSET, drawWin
x = FINDGEN(100) - 50
y = 30 + 5*x - 11*(x^2)
PLOT, x,y
WSET, pixWin
DEVICE, COPY = [0,0,xsize, ysize, 0,0, drawWin]

info = {DRAWID: drawID, $
drawWin: drawWin, $
pixWin: pixWin, $
dim: [xsize, ysize]}
WIDGET_CONTROL, drawID, SET_UVALUE = info

XMANAGER, "PLOT_EXAMPLE", tlb
END
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: Re: Labelling the axes on a log plot
Next Topic: Re: widget, draw and file pickup

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

Current Time: Sun Nov 30 15:07:14 PST 2025

Total time taken to generate the page: 8.14509 seconds