Re: Multiple widget_draw's and bad convert_coord [message #25905] |
Tue, 24 July 2001 14:14 |
Todd Clements
Messages: 23 Registered: January 2001
|
Junior Member |
|
|
Ben -
Thanks... saving and restoring those values worked perfectly. I knew I'd
find a good solution on this newsgroup!
Todd
Ben Tupper <btupper@bigelow.org> wrote:
>> convert_coord always returns the
>> coordinates from the last plot even if I'm clicking in the first plot,
> 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.)
|
|
|
Re: Multiple widget_draw's and bad convert_coord [message #25910 is a reply to message #25905] |
Tue, 24 July 2001 13:19  |
Paul van Delst
Messages: 364 Registered: March 1997
|
Senior Member |
|
|
Todd Clements wrote:
>
> Hi all...
>
> The attached sample code shows my problem. I have multiple widget_draws
> in a program that I'm writing, and I get button events from them so I
> can let the user select portions of a correlated spectrum to use as a
> gate for another spectrum. Anyway, I need to be able to get the
> coordinates that were selected in multiple plots (one at a time, of
> course), but when I try to do this, convert_coord always returns the
> coordinates from the last plot even if I'm clicking in the first plot,
> no matter how often I use wset to try and set the window.
where do you save the properties of the first plot?
--
Paul van Delst A little learning is a dangerous thing;
CIMSS @ NOAA/NCEP Drink deep, or taste not the Pierian spring;
Ph: (301)763-8000 x7274 There shallow draughts intoxicate the brain,
Fax:(301)763-8545 And drinking largely sobers us again.
Alexander Pope.
|
|
|
Re: Multiple widget_draw's and bad convert_coord [message #25911 is a reply to message #25910] |
Tue, 24 July 2001 13:16  |
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
|
|
|