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

Home » Public Forums » archive » Re: Widgets and contour plots
Show: Today's Messages :: Show Polls :: Message Navigator
E-mail to friend 
Switch to threaded view of this topic Create a new topic Submit Reply
Re: Widgets and contour plots [message #42163] Tue, 11 January 2005 14:43
btt is currently offline  btt
Messages: 345
Registered: December 2000
Senior Member
clive_cook59@hotmail.com wrote:
> Ben Tupper wrote:
>
>> Clive Cook wrote:
>>
>>> Hi,
>>>
>>> I am trying to write a widget program were buy passing the cursor
>
> over a
>
>>> contour plot a varying 2d plot changes according to the value where
>
> the
>
>>> cursor lies. I have a contour window with two boxes below that
>
> display the
>
>>> corresponding x and y values from the cursor location. So, i want
>
> to take
>
>>> the x value to produce a corresponding plot of the contour values
>
> against
>
>>> the y value.
>>>
>>> How do i take the x value and use that to generate a new plot?
>>>
>>
>> Hi,
>>
>> I'm not sure I completely understand what your needs are. In
>
> general, you can
>
>> transform your mouse location into data space location using
>
> CONVERT_COORD.
>
>> From there you have to have some way of 'getting' the interpolated
>
> values of
>
>> your contour for that location. You can use the well known
>
> Fanningistic
>
>> approach to storing valuable program info in the the top level base's
>
> UVALUE
>
>> property.
>>
>> Is that close?
>>
>> Ben
>>
>> ***START***
>> MyDrawEvent, ev
>>
>> ;get your valuable info
>> Widget_Control, ev.top, GET_UVALUE = info, /NO_COPY
>> ;set the current device state to match the draw widget's
>> Widget_Control, ev.ID, GET_VALUE = winNum
>> Wset, winNum
>>
>> ;convert from cursor coords to data coords
>> xy = CONVERT_COORD(ev.x, ev.y, /DEVICE, /TO_DATA)
>>
>> ;pass your favorite routine to 'get' you contour data
>> theseContourValues = GetMyContourValues(info.ContourData, xy)
>>
>> ;set the current window to you other window for plotting
>> Widget_Control, info.myOtherDrawWidget, GET_VALUE = myOtherWinNum
>> Wset, myOtherWindowNumber
>> ;plot 'contour values against the y value.'
>> Plot, XY[1], theseContourValues
>>
>> ;put your valuable info back in a safe place
>> Widget_Control, ev.top, SET_UVALUE = info, /NO_COPY
>>
>> End ;myDrawEvent
>>
>>
>> ****FINI***
>
>
> Hi Ben,
>
> Thanks for the advice. My problem now is that i seem to have problems
> locating the value of my draw widget (the 2d line plot window)so that
> i can
> set that as the active window. When i configure my widget base i draw 1
> large widget and then thecontour window in the top left in a new widget
> base, followed by a second draw widget to the left in a new widget base
> (contains the 2d line plot), followed my a widget below containing test
> boxes that display the values of the data at the points of the cursor.
> I am
> getting confused as to how to obtain the values of my various draw
> widgets,
> any help would be useful.
>
> I have tried using Dave Fannings methods but i am a little confused
> with
> this.
>


Hi,

You just have to maintain access to the window numbers you want use.
You can keep this info in the UVALUE property of the top level widget.
Here's an example...

**START**
;-----
; event
;-----
PRO WheresMyWidgetEvent, ev


;get the stuff out of the bucket
WIDGET_CONTROL, ev.top, GET_UVALUE = myStuff, /NO_COPY

;first copy the 'original data' to the image display
;then draw a line across at the cursor location
Widget_Control, myStuff.draw0_ID, Get_Value = win0
WSET, win0
DEVICE, COPY = [0,0,myStuff.sz[0],myStuff.sz[1], 0,0, myStuff.pix0]
PLOTS, [0, myStuff.Sz[0]], [ev.Y, ev.Y], /DEVICE

;now copy the 'baseline' chart to the chart display
;then plot the image values across
;
;**** NOTE **** we only know where to draw this because
;we saved a reference to the widget in the bucket
Widget_Control, myStuff.draw1_ID, Get_Value = win1
WSET, win1
DEVICE, COPY = [0,0,myStuff.sz[0],myStuff.sz[1], 0,0, myStuff.pix1]
OPLOT, LINDGEN(myStuff.Sz[0]), myStuff.image[*,ev.y]


;put you important things back in the bucket
WIDGET_CONTROL, ev.top, SET_UVALUE = myStuff, /NO_COPY
END



;------
; main
;------
PRO WheresMyWidget


;make a base widget with 2 draw widgets, one forand image and one for
;a plot... only the widget withg the image will generate events
tlb = widget_base(column = 2)

sz = [200,200]
draw0_ID = widget_draw(tlb, $
MOTION_EVENTS = 1, $
XSIZE = sz[0], YSIZE = sz[1], $
EVENT_PRO = 'WheresMyWidgetEvent')
draw1_ID = widget_draw(tlb,$
XSIZE = sz[0], YSIZE = sz[1])


;pop the widget up
WIDGET_CONTROL, tlb, /Realize


;set the image widget up for drawing
;show the image
;and make the 'refresh' copy on the pixmap
Widget_Control, draw0_ID, Get_Value = win0
WSET, win0
image = DIST(sz)
TV, BYTSCL(Image)
;make a pixmap window for each widget -
;these are used to 'refresh' the widgets
;before we draw on them
WINDOW, xsize = sz[0], ysize = sz[1], /PIXMAP,/FREE
pix0 = !D.window
WSET, pix0
DEVICE, COPY = [0,0,sz[0],sz[1], 0,0, win0]


;set the chart widget up for drawing
;show the chart (without any data yet)
;and make the 'refresh' copy on the pixmap
Widget_Control, draw1_ID, Get_Value = win1
WSET, win1
PLOT, [0,Sz[0]], [0,MAX(image)], $
XTITLE = 'Image Column', $
YTITLE = 'Image Value', $
/NODATA
WINDOW, xsize = sz[0], ysize = sz[1], /PIXMAP, /FREE
pix1= !D.window
WSET, pix1
DEVICE, COPY = [0,0,sz[0],sz[1], 0,0, win1]


;gather your things to put in the TLB's bucket
;and store them
myStuff = $
{Draw0_ID: draw0_ID, $
Draw1_ID: draw1_ID, $
Pix0: pix0, $
Pix1: pix1, $
SZ: sz, $
Image: Image}


WIDGET_CONTROL, tlb, SET_UVALUE = myStuff, /NO_COPY


XMANAGER, 'wheresmywidget', tlb
END
**FINI***
Re: Widgets and contour plots [message #42164 is a reply to message #42163] Tue, 11 January 2005 11:21 Go to previous message
David Fanning is currently offline  David Fanning
Messages: 11724
Registered: August 2001
Senior Member
clive_cook59@hotmail.com writes:

> Thanks for the advice. My problem now is that i seem to have problems
> locating the value of my draw widget (the 2d line plot window)so that
> i can
> set that as the active window. When i configure my widget base i draw 1
> large widget and then thecontour window in the top left in a new widget
> base, followed by a second draw widget to the left in a new widget base
> (contains the 2d line plot), followed my a widget below containing test
> boxes that display the values of the data at the points of the cursor.
> I am
> getting confused as to how to obtain the values of my various draw
> widgets,
> any help would be useful.
>
> I have tried using Dave Fannings methods but i am a little confused
> with this.

The graphics window index number (the window number
you want to WSET to) is the *value* of the draw widget.
If you know the ID of the draw widget (perhaps you clicked
somewhere in the window, so the ID is in the event structure)
you can easily get the window index number:

Widget_Control, event.ID, Get_Value=wid
WSet, wid

If you want to do something in other windows, you
have to know either the draw widget ID of those other
windows, or the window index number of the other windows
in order to draw into them.

Cheers,

David

--
David W. Fanning, Ph.D.
Fanning Software Consulting, Inc.
Coyote's Guide to IDL Programming: http:/www.dfanning.com/
Phone: 970-221-0438, IDL Book Orders: 1-888-461-0155
Re: Widgets and contour plots [message #42165 is a reply to message #42164] Tue, 11 January 2005 09:09 Go to previous message
clive_cook59 is currently offline  clive_cook59
Messages: 6
Registered: January 2005
Junior Member
Ben Tupper wrote:
> Clive Cook wrote:
>> Hi,
>>
>> I am trying to write a widget program were buy passing the cursor
over a
>> contour plot a varying 2d plot changes according to the value where
the
>> cursor lies. I have a contour window with two boxes below that
display the
>> corresponding x and y values from the cursor location. So, i want
to take
>> the x value to produce a corresponding plot of the contour values
against
>> the y value.
>>
>> How do i take the x value and use that to generate a new plot?
>>
>
> Hi,
>
> I'm not sure I completely understand what your needs are. In
general, you can
> transform your mouse location into data space location using
CONVERT_COORD.
> From there you have to have some way of 'getting' the interpolated
values of
> your contour for that location. You can use the well known
Fanningistic
> approach to storing valuable program info in the the top level base's
UVALUE
> property.
>
> Is that close?
>
> Ben
>
> ***START***
> MyDrawEvent, ev
>
> ;get your valuable info
> Widget_Control, ev.top, GET_UVALUE = info, /NO_COPY
> ;set the current device state to match the draw widget's
> Widget_Control, ev.ID, GET_VALUE = winNum
> Wset, winNum
>
> ;convert from cursor coords to data coords
> xy = CONVERT_COORD(ev.x, ev.y, /DEVICE, /TO_DATA)
>
> ;pass your favorite routine to 'get' you contour data
> theseContourValues = GetMyContourValues(info.ContourData, xy)
>
> ;set the current window to you other window for plotting
> Widget_Control, info.myOtherDrawWidget, GET_VALUE = myOtherWinNum
> Wset, myOtherWindowNumber
> ;plot 'contour values against the y value.'
> Plot, XY[1], theseContourValues
>
> ;put your valuable info back in a safe place
> Widget_Control, ev.top, SET_UVALUE = info, /NO_COPY
>
> End ;myDrawEvent
>
>
> ****FINI***

Hi Ben,

Thanks for the advice. My problem now is that i seem to have problems
locating the value of my draw widget (the 2d line plot window)so that
i can
set that as the active window. When i configure my widget base i draw 1
large widget and then thecontour window in the top left in a new widget
base, followed by a second draw widget to the left in a new widget base
(contains the 2d line plot), followed my a widget below containing test
boxes that display the values of the data at the points of the cursor.
I am
getting confused as to how to obtain the values of my various draw
widgets,
any help would be useful.

I have tried using Dave Fannings methods but i am a little confused
with
this.

many thanks

Clive Cook
Re: Widgets and contour plots [message #42191 is a reply to message #42165] Wed, 05 January 2005 05:10 Go to previous message
btt is currently offline  btt
Messages: 345
Registered: December 2000
Senior Member
Clive Cook wrote:
> Hi,
>
> I am trying to write a widget program were buy passing the cursor over a
> contour plot a varying 2d plot changes according to the value where the
> cursor lies. I have a contour window with two boxes below that display the
> corresponding x and y values from the cursor location. So, i want to take
> the x value to produce a corresponding plot of the contour values against
> the y value.
>
> How do i take the x value and use that to generate a new plot?
>

Hi,

I'm not sure I completely understand what your needs are. In general, you can
transform your mouse location into data space location using CONVERT_COORD.
From there you have to have some way of 'getting' the interpolated values of
your contour for that location. You can use the well known Fanningistic
approach to storing valuable program info in the the top level base's UVALUE
property.

Is that close?

Ben

***START***
MyDrawEvent, ev

;get your valuable info
Widget_Control, ev.top, GET_UVALUE = info, /NO_COPY
;set the current device state to match the draw widget's
Widget_Control, ev.ID, GET_VALUE = winNum
Wset, winNum

;convert from cursor coords to data coords
xy = CONVERT_COORD(ev.x, ev.y, /DEVICE, /TO_DATA)

;pass your favorite routine to 'get' you contour data
theseContourValues = GetMyContourValues(info.ContourData, xy)

;set the current window to you other window for plotting
Widget_Control, info.myOtherDrawWidget, GET_VALUE = myOtherWinNum
Wset, myOtherWindowNumber
;plot 'contour values against the y value.'
Plot, XY[1], theseContourValues

;put your valuable info back in a safe place
Widget_Control, ev.top, SET_UVALUE = info, /NO_COPY

End ;myDrawEvent


****FINI***
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Re: A color question with PS
Next Topic: Using CALL_EXTERNAL to manage Windows

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

Current Time: Fri Oct 10 14:06:27 PDT 2025

Total time taken to generate the page: 0.96024 seconds