Re: drawing lines interactively [message #30528] |
Sun, 05 May 2002 11:45 |
R.Bauer
Messages: 1424 Registered: November 1998
|
Senior Member |
|
|
Marten Blixt wrote:
>
> Hi all,
>
> I have a small problem which I've solved only partially.
>
> I would like to draw a line on an image using the mouse, by clicking on the
> two end points.
> Sofar I can do just that, by using
> TV,testimage,TRUE=1
> CURSOR, x0,y0,/DEVICE,/DOWN
> CURSOR,x1,y1,/DEVICE,/DOWN
> PLOT,[x0,x1],[y0,y1], /DATA,/NOERASE
>
> but then the line appears *after* the two endpoints have been choosen, and I
> would like a "temporary line", between the first point and the current position
> of the cursor, to be shown. This should help me in positioning the last point.
>
> There is probably a simple solution to this, I just haven't found it. Does any
> of you know how?
>
> Many thanks,
> M�rten Blixt
Dear M�rten
there are a lot of routines from Ray Sterner (JHUAPL) already available.
I am often using hori, veri, hor, ver, hline, vline and crossi.
http://fermi.jhuapl.edu/s1r/idl/s1rlib/local_idl.html
or the routine path:
ftp://fermi.jhuapl.edu/pub/idl/routines/
regards
Reimar
--
Reimar Bauer
Institut fuer Stratosphaerische Chemie (ICG-I)
Forschungszentrum Juelich
email: R.Bauer@fz-juelich.de
------------------------------------------------------------ -------
a IDL library at ForschungsZentrum Juelich
http://www.fz-juelich.de/icg/icg1/idl_icglib/idl_lib_intro.h tml
============================================================ =======
|
|
|
Re: drawing lines interactively [message #30536 is a reply to message #30528] |
Fri, 03 May 2002 14:51  |
David Fanning
Messages: 11724 Registered: August 2001
|
Senior Member |
|
|
Marten Blixt (maarten@blues.phys.uit.no) writes:
> I have a small problem which I've solved only partially.
>
> I would like to draw a line on an image using the mouse, by clicking on the
> two end points.
> Sofar I can do just that, by using
> TV,testimage,TRUE=1
> CURSOR, x0,y0,/DEVICE,/DOWN
> CURSOR,x1,y1,/DEVICE,/DOWN
> PLOT,[x0,x1],[y0,y1], /DATA,/NOERASE
>
> but then the line appears *after* the two endpoints have been choosen, and I
> would like a "temporary line", between the first point and the current position
> of the cursor, to be shown. This should help me in positioning the last point.
>
> There is probably a simple solution to this, I just haven't found it. Does any
> of you know how?
You can see a fairly simple solution to this in the program
Drawline. Use your left mouse button to draw a freehand line,
or your right mouse button to draw a straight line.
http://www.dfanning.com/tip_examples/drawline.pro
You can also read the following tip:
http://www.dfanning.com/widget_tips/line_on_image.html
Cheers,
David
--
David W. Fanning, Ph.D.
Fanning Software Consulting
Phone: 970-221-0438, E-mail: david@dfanning.com
Coyote's Guide to IDL Programming: http://www.dfanning.com/
Toll-Free IDL Book Orders: 1-888-461-0155
|
|
|
Re: drawing lines interactively [message #30538 is a reply to message #30536] |
Fri, 03 May 2002 09:05  |
James Kuyper
Messages: 425 Registered: March 2000
|
Senior Member |
|
|
What you have to do is to capture all mouse movements, not just clicks.
You do this by choosing the "/MOTION_EVENTS" option when creating your
draw widget. Alternatively, you can use the DRAW_MOTION_EVENTS option of
WIDGET_CONTROL to turn the reporting of motion events on and off.
Each time your event handler recieves a new WIDGET_DRAW event with
TYPE=2, it's a report of a new mouse position. You can then draw your line.
The tricky part is making the line temporary. That means you have to
keep track of where you drew it, and then "undraw" it when the next
mouse position event comes in. There's probably other ways to do it, but
I know of only one simple way, that involves putting graphics into XOR mode:
DEVICE, GET_GRAPHICS=oldg, SET_GRAPHICS=6
PLOT,[x0,x1],[y0,y1], /DATA,/NOERASE
DEVICE, SET_GRAPHICS=oldg
If you draw the same line in that mode twice in a row, the second
occurance will un-draw the first.
|
|
|
Re: drawing lines interactively [message #30540 is a reply to message #30538] |
Fri, 03 May 2002 09:33  |
nobody@nowhere.com (S
Messages: 55 Registered: July 2001
|
Member |
|
|
you could just use the ANNOTATE widget, which will let you draw text, lines,
etc. on the current graphics window interactively, and export to postscript
or bitmap.
On Fri, 3 May 2002 16:22:06 +0000 (UTC), Marten Blixt
<maarten@blues.phys.uit.no> wrote:
> Hi all,
>
> I have a small problem which I've solved only partially.
>
> I would like to draw a line on an image using the mouse, by clicking on the
> two end points.
> Sofar I can do just that, by using
> TV,testimage,TRUE=1
> CURSOR, x0,y0,/DEVICE,/DOWN
> CURSOR,x1,y1,/DEVICE,/DOWN
> PLOT,[x0,x1],[y0,y1], /DATA,/NOERASE
>
> but then the line appears *after* the two endpoints have been choosen, and I
> would like a "temporary line", between the first point and the current position
> of the cursor, to be shown. This should help me in positioning the last point.
>
> There is probably a simple solution to this, I just haven't found it. Does any
> of you know how?
>
> Many thanks,
> M�rten Blixt
--
Steve S.
steve@NOSPAMmailaps.org
remove NOSPAM before replying
|
|
|