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

Home » Public Forums » archive » Re: How to retrieve information from an event to use it in another event?
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: How to retrieve information from an event to use it in another event? [message #54489] Tue, 19 June 2007 09:54 Go to next message
Vince Hradil is currently offline  Vince Hradil
Messages: 574
Registered: December 1999
Senior Member
On Jun 19, 11:34 am, "aleks.fra...@gmail.com" <aleks.fra...@gmail.com>
wrote:
> On 19 jun, 11:55, Paul van Delst <Paul.vanDe...@noaa.gov> wrote:
>
>
>
>> aleks.fra...@gmail.com wrote:
>>> Hello!
>>> Maybe it's a likely simple question, but I can't figure it out. I have
>>> 2 buttons and I want them to communicate. My widget has 2 buttons and
>>> each button is a separate event. Button A chooses an image A to open.
>>> Button B chooses an image B to open. I need to keep the information
>>> from image A in order to compare with image B. Because they are 2
>>> separate events, when the first events ends ( opens image A ) all the
>>> information about image A is lost. What do I need to do to keep the
>>> information from an event and use it in another event?
>
>> What do you mean be "information from image A" ? The image itself (for comparison with
>> image B) or information about image A (e.g. size, min/max vals etc) ?
>
>> Asking the same question a bit more broadly: What, exactly, do you want your widget to do?
>
>> cheers,
>
>> paulv
>
>> --
>> Paul van Delst Ride lots.
>> CIMSS @ NOAA/NCEP/EMC Eddy Merckx
>
> Ok, I'll try it in another way.
>
> I have I have 2 buttons: Open1 and Open2
>
> ;Starts here
> CASE eventval OF
> 'Open1' :BEGIN
> cd,'c:\rsi\idl63\examples\data'
> envi_select, title="WAVECHANGE: Select 'Initial State' Image",$
> fid=fid1, dims=dims1, pos=pos1
>
> if (fid1 eq -1) then return
>
> envi_file_query, fid1, fname=fname1, bname=bname1,$
> data_type=data_type1,$
> ns=ns1, nl=nl1, nb=nb1,$
> sname=sname1, xstart=xstart1, ystart=ystart1
>
> WIDGET_CONTROL,(*pinfo).wOpen1,SENSITIVE=0
>
> WIDGET_CONTROL,(*pinfo).wOpen2,SENSITIVE=1
>
> END
>
> 'Open2' :BEGIN
>
> envi_select, title="WAVECHANGE: Select 'Final State' Image",$
> fid=fid2, dims=dims2, pos=pos2
>
> if (fid2 eq -1) then return
>
> envi_file_query, fid2, fname=fname2, bname=bname2,$
> data_type=data_type2,$
> ns=ns2, nl=nl2, nb=nb2,$
> sname=sname2, xstart=xstart2, ystart=ystart2
>
> name_pos = STRPOS(fname1, '\', /REVERSE_SEARCH)
> path=STRMID(fname1, 0,name_pos+1)
>
> ;;
> ;;_____HERE IS THE PROBLEM..
> ;;_____I need to compare fid1 with fid2, but the program kills all
> information from 'Open1' event
> ;;
> if (fid1 eq fid2) then begin
> message=[["You have selected the same image twice!"],[""],
> ["Please, select both images again"]]
> result=dialog_message (message,title="Error!", /error)
> return
> endif
>
> if (nb1 ne nb2) then begin
> message=[["The selected images must have the same number of
> bands!"],[""],["Please, select both images again"]]
> result=dialog_message (mensagem,title="Error!", /error)
> return
> endif
>
> END
>
> When I finish the first case, it seems that all the information about
> 'Open1' is killed. I need the variables from Open1 to use them im my
> 'Open2'. In other words, I need to retreave the variables: fid1, dim1,
> pos1, data_type1, ns1, nl1, nb1, sname1, xstart1, ystart1.
>
> I hope I was clear this time.
>
> Thank you.

make an info structure in your "main" program like:
info = {fid1:(-1), fid2:(-1), nb1:0L, nb2:0L .. etc }
make a pointer to that
infoptr = ptr_new(info)
in your event function put:
widget_control, event.top, get_uvalue=infoptr

Then you can look use (*infoptr).fid1, etc...
Re: How to retrieve information from an event to use it in another event? [message #54491 is a reply to message #54489] Tue, 19 June 2007 09:34 Go to previous messageGo to next message
aleks.franca@gmail.co is currently offline  aleks.franca@gmail.co
Messages: 33
Registered: March 2007
Member
On 19 jun, 11:55, Paul van Delst <Paul.vanDe...@noaa.gov> wrote:
> aleks.fra...@gmail.com wrote:
>> Hello!
>> Maybe it's a likely simple question, but I can't figure it out. I have
>> 2 buttons and I want them to communicate. My widget has 2 buttons and
>> each button is a separate event. Button A chooses an image A to open.
>> Button B chooses an image B to open. I need to keep the information
>> from image A in order to compare with image B. Because they are 2
>> separate events, when the first events ends ( opens image A ) all the
>> information about image A is lost. What do I need to do to keep the
>> information from an event and use it in another event?
>
> What do you mean be "information from image A" ? The image itself (for comparison with
> image B) or information about image A (e.g. size, min/max vals etc) ?
>
> Asking the same question a bit more broadly: What, exactly, do you want your widget to do?
>
> cheers,
>
> paulv
>
> --
> Paul van Delst Ride lots.
> CIMSS @ NOAA/NCEP/EMC Eddy Merckx

Ok, I'll try it in another way.

I have I have 2 buttons: Open1 and Open2

;Starts here
CASE eventval OF
'Open1' :BEGIN
cd,'c:\rsi\idl63\examples\data'
envi_select, title="WAVECHANGE: Select 'Initial State' Image",$
fid=fid1, dims=dims1, pos=pos1

if (fid1 eq -1) then return

envi_file_query, fid1, fname=fname1, bname=bname1,$
data_type=data_type1,$
ns=ns1, nl=nl1, nb=nb1,$
sname=sname1, xstart=xstart1, ystart=ystart1

WIDGET_CONTROL,(*pinfo).wOpen1,SENSITIVE=0

WIDGET_CONTROL,(*pinfo).wOpen2,SENSITIVE=1

END

'Open2' :BEGIN

envi_select, title="WAVECHANGE: Select 'Final State' Image",$
fid=fid2, dims=dims2, pos=pos2

if (fid2 eq -1) then return

envi_file_query, fid2, fname=fname2, bname=bname2,$
data_type=data_type2,$
ns=ns2, nl=nl2, nb=nb2,$
sname=sname2, xstart=xstart2, ystart=ystart2

name_pos = STRPOS(fname1, '\', /REVERSE_SEARCH)
path=STRMID(fname1, 0,name_pos+1)


;;
;;_____HERE IS THE PROBLEM..
;;_____I need to compare fid1 with fid2, but the program kills all
information from 'Open1' event
;;
if (fid1 eq fid2) then begin
message=[["You have selected the same image twice!"],[""],
["Please, select both images again"]]
result=dialog_message (message,title="Error!", /error)
return
endif

if (nb1 ne nb2) then begin
message=[["The selected images must have the same number of
bands!"],[""],["Please, select both images again"]]
result=dialog_message (mensagem,title="Error!", /error)
return
endif


END

When I finish the first case, it seems that all the information about
'Open1' is killed. I need the variables from Open1 to use them im my
'Open2'. In other words, I need to retreave the variables: fid1, dim1,
pos1, data_type1, ns1, nl1, nb1, sname1, xstart1, ystart1.

I hope I was clear this time.

Thank you.
Re: How to retrieve information from an event to use it in another event? [message #54499 is a reply to message #54491] Tue, 19 June 2007 07:55 Go to previous messageGo to next message
Paul Van Delst[1] is currently offline  Paul Van Delst[1]
Messages: 1157
Registered: April 2002
Senior Member
aleks.franca@gmail.com wrote:
> Hello!
> Maybe it's a likely simple question, but I can't figure it out. I have
> 2 buttons and I want them to communicate. My widget has 2 buttons and
> each button is a separate event. Button A chooses an image A to open.
> Button B chooses an image B to open. I need to keep the information
> from image A in order to compare with image B. Because they are 2
> separate events, when the first events ends ( opens image A ) all the
> information about image A is lost. What do I need to do to keep the
> information from an event and use it in another event?

What do you mean be "information from image A" ? The image itself (for comparison with
image B) or information about image A (e.g. size, min/max vals etc) ?

Asking the same question a bit more broadly: What, exactly, do you want your widget to do?

cheers,

paulv

--
Paul van Delst Ride lots.
CIMSS @ NOAA/NCEP/EMC Eddy Merckx
Re: How to retrieve information from an event to use it in another event? [message #54502 is a reply to message #54499] Tue, 19 June 2007 07:11 Go to previous messageGo to next message
Vince Hradil is currently offline  Vince Hradil
Messages: 574
Registered: December 1999
Senior Member
On Jun 19, 8:55 am, "aleks.fra...@gmail.com" <aleks.fra...@gmail.com>
wrote:
> On 19 jun, 10:45, hradilv <hrad...@yahoo.com> wrote:
>
>
>
>> On Jun 19, 8:37 am, "aleks.fra...@gmail.com" <aleks.fra...@gmail.com>
>> wrote:
>
>>> Hello!
>>> Maybe it's a likely simple question, but I can't figure it out. I have
>>> 2 buttons and I want them to communicate. My widget has 2 buttons and
>>> each button is a separate event. Button A chooses an image A to open.
>>> Button B chooses an image B to open. I need to keep the information
>>> from image A in order to compare with image B. Because they are 2
>>> separate events, when the first events ends ( opens image A ) all the
>>> information about image A is lost. What do I need to do to keep the
>>> information from an event and use it in another event?
>
>>> obs: I use a CASE statement
>
>>> Thank you
>
>> Save the event structure in a variable?
>
> Ok, I've tryed that, but I don't know if I'm doing it right. How do I
> save the event in a variable?

You could use a global variable. But how about this, is it possible
to query the current stat of the "other" widget to determine the
information that you need using WIDGET_INFO or WIDGET_CONTROL?
Re: How to retrieve information from an event to use it in another event? [message #54504 is a reply to message #54502] Tue, 19 June 2007 06:55 Go to previous messageGo to next message
aleks.franca@gmail.co is currently offline  aleks.franca@gmail.co
Messages: 33
Registered: March 2007
Member
On 19 jun, 10:45, hradilv <hrad...@yahoo.com> wrote:
> On Jun 19, 8:37 am, "aleks.fra...@gmail.com" <aleks.fra...@gmail.com>
> wrote:
>
>> Hello!
>> Maybe it's a likely simple question, but I can't figure it out. I have
>> 2 buttons and I want them to communicate. My widget has 2 buttons and
>> each button is a separate event. Button A chooses an image A to open.
>> Button B chooses an image B to open. I need to keep the information
>> from image A in order to compare with image B. Because they are 2
>> separate events, when the first events ends ( opens image A ) all the
>> information about image A is lost. What do I need to do to keep the
>> information from an event and use it in another event?
>
>> obs: I use a CASE statement
>
>> Thank you
>
> Save the event structure in a variable?

Ok, I've tryed that, but I don't know if I'm doing it right. How do I
save the event in a variable?
Re: How to retrieve information from an event to use it in another event? [message #54506 is a reply to message #54504] Tue, 19 June 2007 06:45 Go to previous messageGo to next message
Vince Hradil is currently offline  Vince Hradil
Messages: 574
Registered: December 1999
Senior Member
On Jun 19, 8:37 am, "aleks.fra...@gmail.com" <aleks.fra...@gmail.com>
wrote:
> Hello!
> Maybe it's a likely simple question, but I can't figure it out. I have
> 2 buttons and I want them to communicate. My widget has 2 buttons and
> each button is a separate event. Button A chooses an image A to open.
> Button B chooses an image B to open. I need to keep the information
> from image A in order to compare with image B. Because they are 2
> separate events, when the first events ends ( opens image A ) all the
> information about image A is lost. What do I need to do to keep the
> information from an event and use it in another event?
>
> obs: I use a CASE statement
>
> Thank you

Save the event structure in a variable?
Re: How to retrieve information from an event to use it in another event? [message #54635 is a reply to message #54489] Tue, 19 June 2007 20:49 Go to previous message
Michael Galloy is currently offline  Michael Galloy
Messages: 1114
Registered: April 2006
Senior Member
On Jun 19, 10:54 am, hradilv <hrad...@yahoo.com> wrote:
> make an info structure in your "main" program like:
> info = {fid1:(-1), fid2:(-1), nb1:0L, nb2:0L .. etc }
> make a pointer to that
> infoptr = ptr_new(info)

Don't forget to save the pointer in the tlb's UVALUE:

widget_control, tlb, set_uvalue=infoptr

> in your event function put:
> widget_control, event.top, get_uvalue=infoptr
>
> Then you can look use (*infoptr).fid1, etc...

Yes, this is the basic idea most people use when writing widget
programs. Save information in fields of a structure that is stored
(either directly or via a pointer) in the top-level base's UVALUE.
If you use a pointer, be sure to free the pointer when the program
finishes (use the CLEANUP keyword to XMANAGER).

Mike
--
www.michaelgalloy.com
  Switch to threaded view of this topic Create a new topic Submit Reply
Previous Topic: Encoding of IDL strings
Next Topic: Re: history of command prompt

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

Current Time: Fri Oct 10 00:31:56 PDT 2025

Total time taken to generate the page: 0.96202 seconds