[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Moving a Line
- Subject: Re: Moving a Line
- From: Steve Hartmann <slh(at)vuse.vanderbilt.edu>
- Date: Mon, 19 Jun 2000 10:38:27 -0500
- Newsgroups: comp.lang.idl-pvwave
- Organization: Vanderbilt University usenet news server
- References: <Pine.GSO.4.21.0006151810530.29407-100000@world.evansville.net>
- Xref: news.doit.wisc.edu comp.lang.idl-pvwave:19981
Mark,
Your program stays in the REPEAT loop until a button other than the left
button is pressed. So when you are finished and you press the right mouse
button, 'xx1' is updated to the current x-position of the mouse.
If you replace the REPEAT...ENDREP loop with this:
Repeat Begin
Cursor, xtemp, ytemp, /Wait, /Device
If !Mouse.Button EQ 1 Then Begin
xx1= xtemp
Device, Copy=[0,0,sx,sy,0,0,1]
PlotS, [xx,xx1], [yy,yy], /Device
EndIf
EndRep Until !Mouse.Button NE 1
then it appears to work as desired. It still doesn't work correctly if the
second x-coordinate is smaller than the first (but maybe you aren't concerned
about this possibility). If you replace you last line with the following, then
the magnitude of the line will be re-drawn in the lower left corner, even if
the line goes from right to left.
Device, Copy=[xx < xx1, yy, xx > xx1,yy,5,5,lastwin]
I'm not sure if you want to 'move' or 'copy' the line. Right now it will do
either, depending on where the first line is drawn. You can add the following
line at the end of the program to erase the first line:
Device, Copy=[0,0, sx, sy, 0, 6, 1]
I hope this helps,
Steve Hartmann
Mark Guagenti wrote:
> I need some help figuring out how to copy a line drawn on the current
> graphics window to another position in the same window. What should happen
> is the user draws a straight line with the mouse on the current window and
> then that line he drew gets moved to the lover left hand corner of the
> window. What my program does right now is when the user clicks with his
> left mouse button it gets the first point then waits for the user to click
> the left mouse button again to get the second point. The program then uses
> plots to make a straight horizontal line using the 2 x positions
> found. The program SHOULD then copy that line to start at position
> [5,5]. But instead the program draws a line starting at [5,5] which goes
> to the x position of the current mouse position instead of the last
> clicked mouse position. I attached the code I am using to try
> this. Thanks for any help.
>
> -- Mark
>
> Grace and peace to you from God our Father and the Lord Jesus Christ.
> 1 Cor. 1:3
>
> PRO CursorHelp
> result = Dialog_Message('Click with your LEFT
> mouse button to choose the first point. Then click your LEFT mouse button
> again to choose the second point. Click the RIGHT mouse button to show
> the measurement.', /INFORMATION)
> Window, 2, XSize=300, YSize=300
> sx = 300
> sy=300
> LastWin = !D.Window
> Window, 1, /Pixmap, XSize =300, YSize=300
> WSet, LastWin
> Cursor, xx, yy, /Device, /Down
>
> y = yy - 0
> x = xx - 0
> if !order ne 0 then y = sy - 1 - y ;Invert?
> if (x lt 0) or (x ge sx) or (y lt 0) or (y ge
> sy) then begin
> result = dialog_message('Point outside
> image', /INFORMATION)
> return
> endif
> REPEAT BEGIN
> Cursor, xx1, yy1, /Wait, /Device
> Device, Copy=[0,0,sx,sy,0,0,1]
> PlotS, [xx,xx1], [yy,yy], /Device
> ENDREP UNTIL !Mouse.Button NE 1
> Device, Copy=[xx,yy,xx1,yy,5,5,lastwin]
> END