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

Home » Public Forums » archive » Re: Multiple widget_draw's and bad convert_coord
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: Multiple widget_draw's and bad convert_coord [message #25911 is a reply to message #25910] Tue, 24 July 2001 13:16 Go to previous message
btt is currently offline  btt
Messages: 345
Registered: December 2000
Senior Member
> convert_coord always returns the
> coordinates from the last plot even if I'm clicking in the first plot,

Hi Todd,

Yes, in direct graphics the *LAST* coordinate conversion parameters
(scaling and offset values for the plot) are saved... earlier parameters
get bumped out and like my hero, Bill Bradely, are quickly forgotten.

I have amended your code below (I've never used common blocks before...
it worked here but you never know what my wealth of brute force and
ignorance will lead to.)

You could perform the device to data calculation directly... the online
help 'Direct Graphics 2d Coordinate Conversion' has a table with the
necessary conversions listed. Liam Gumley (www.Gumley.com) has some
frame tools that will save the important stuff for each window setup...
then you can simply advance/retreat through your 'frames'.

Ben

;;----- Begin test code ---------
pro bad_test_event, ev, base
;add the last 4 items to the common block
common windowstuff, win1, win2, widget1, widget2, XS1, XS2, YS1, YS2

if( tag_names( ev, /structure_name ) eq 'WIDGET_DRAW' ) then begin
case ev.id of
widget1: begin
wset, win1
;RESTORE the values of !X.S and !Y.S before the conversion
!X.S = XS1
!Y.S = YS1
result = convert_coord( ev.x, ev.y, /device, /to_data )
print, result
end
widget2: begin
wset, win2
;RESTORE the values of !X.S and !Y.S before the conversion
!X.S = XS2
!Y.S = YS2
result = convert_coord( ev.x, ev.y, /device, /to_data )
print, result
end
endcase
endif
end ;; bad_test_event

pro bad_test

;add 4 extra items to the common block
common windowstuff, win1, win2, widget1, widget2, XS1, XS2, YS1, YS2

base = widget_base( /column )
widget1 = widget_draw( base, xsize=300, ysize=300, /button_events )
widget2 = widget_draw( base, xsize=300, ysize=300, /button_events )

widget_control, base, /realize

widget_control, widget1, get_value = win1
widget_control, widget2, get_value = win2

wset, win1
plot, findgen(50), findgen(50)^2
;SAVE the coordiante transform parameters established by a call to PLOT
XS1 = !X.S
YS1 = !Y.S

wset, win2
;SAVE the coordiante transform parameters established by a call to PLOT
plot, findgen(50)+50, sin(findgen(50)/49.*!pi)
XS2 = !X.S
YS2 = !Y.S

wset, win1
xmanager, 'bad_test', base

end
;; --------- End test code ---------------

--
Ben Tupper
Bigelow Laboratory for Ocean Sciences
180 McKown Point Rd.
W. Boothbay Harbor, ME 04575
btupper@bigelow.org
[Message index]
 
Read Message
Read Message
Read Message
Previous Topic: Re: FFT in a 2D variable in only one direction
Next Topic: text widget

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

Current Time: Wed Oct 08 17:43:48 PDT 2025

Total time taken to generate the page: 0.00453 seconds