Silverfrost Forums

Welcome to our forums

How can I open child Simpleplot windows?

24 Sep 2009 1:51 #5022

I am trying to plot my data using the Simplot facilities and also want to open a second or third window from the main Simpleplot one in such a way that one can say OK and close the window showing a plot, or say 'calculate the linear regression of the data' and show the new plot in a second window without closing the previous one, i.e. something like:

First window: ans=winio@('%ca[My plot]%bg[grey]&') ans=winio@('%pl[scale=log_log,n_graphs=1,style=0,colour=red,x_array,y_axis=S_kt,x_axis=k]&',600,400,f,kt,S_kt) ans=winio@('%ff%nl%cn%bt[Linear regresion]%ta%bt[OK]')

Second window: ans=winio@('%ca[Linear Regression]%bg[grey]&') ans=winio@('%pl[scale=linear,n_graphs=2,style=1,style=1,colour=blue,colour=red,x_array,y_axis=W,x_axis=L]&',600,400,n,x2,y,y2) ans=winio@('%nl slope= %5rf%ta&',m) ans=winio@('%nl Alfa (=(m-1)/2)= %5rf%ta&',m2) ans=winio@('%ff%nl%cn%bt[OK]')

I tried to use %lw in the first window and %ch in the second one, but as soon as I click on any of the buttons of the first window, it is automatically closed and the second window does not appears. What am I doing wrong?

Agustin

24 Sep 2009 3:51 #5024

One way is to use a MDI frame %fr and %aw for the child windows.

An example appears in the help file under Win32 platform->ClearWin+->Window attributes->Attach window

24 Sep 2009 5:50 #5025

Sorry Paul, maybe I was not clear about what I wanted. I tried the options of %lw, %ch and even %aw, but what I get is that the first window showing the full plot does not remain on top and, as %lw leaves the window open, the button of 'Linear regression' makes no effect. I have a program with a graphics window created with %gr, on top of this appears a window created with %pl, where I plot my full set of data. In this window I can select either performing a linear regresion of the data (Linear Regression buton) or just quit (OK button). If I click on the first button, I should get 'ans =1' in order to tell the program to open a window asking for the range of data to be used for the linear regresion, computes the regresion and eventually a third window created with %pl to show the plot of the partial data set and the regresion line. The problem is that the first %pl window is always closed once I click on any button. What I would like to do is to allow that window to be open (i.e. until I click 'OK') so I can see both windows on the screen (the intermediate used for entering data ranges must disappears). The problem is that the %pl option does not allow to plot two arrays with different number of points, so I cannot plot both sets of data, the full one and the limited one used for the linear regresion, so that I thougth to open two simpleplot windows instead of one. Hope I am not being too confusing! Agustin

25 Sep 2009 8:03 #5029

Did you use %fr with your %aw?

25 Sep 2009 1:04 #5035

Yes, I used both codes, but maybe I am misunderstanding the application of these codes. The part of the code of my subroutine where they are use is the follows:

!First window: ans=winio@('%ca[My plot]%bg[grey]&') ans=winio@('%pl[scale=log_log,n_graphs=1,style=0,colour=red,x_array,y_axis=S_kt,x_axis=k]&',600,400,f,kt,S_kt) ans=winio@('%ff%nl%cn%bt[Linear regresion]%ta%bt[OK]& ') ans=winio@('%lw',ctrl)

! query for the limits of regresion line !this window should be closed once the required data is entered

if(ans==1) then low=MINVAL(kt) upper=MAXVAL(kt) ans=winio@('%bg[gray]&') ans=winio@('Limits for the Regresion&') ans=winio@('%nl Lower:%ta%6rf&',low) ans=winio@('%nl Uper:%ta%6rf&',upper) ans=winio@('%tc&',RGB@(0,0,255)) ans = winio@('%2nl%ta%cn%`bt[OK]')

! least square calculation here ....

!now we open the second window, so I can compare the full range plot !and this one:

ans=winio@('%pv%aw&',ctrl) ans=winio@('%ca[Linear Regression]%bg[grey]&') ans=winio@('%pl[scale=linear,n_graphs=2,style=1,style=1,colour=blue,colour=red,x_array,y_axis=W,x_axis=L]&',600,400,n,x2,y,y2) ans=winio@('%nl slope= %5rf%ta&',m) ans=winio@('%nl Alfa (=(m-1)/2)= %5rf%ta&',m2) ans=winio@('%ff%nl%cn%bt[OK]')

I guess I am doing something wrong with this because once I click on the Regresion button, the first window is closed and no other appears.

Agustin

25 Sep 2009 1:39 #5036

I cannot tell from your code if you are doing the right thing.

You need %fr in a main window, then %aw for each window using %pl and %aw for each window used to read in data.

25 Sep 2009 11:20 #5037

Let's make the things simpler and avoid the child windows: how can I leave the following window opened when I click on 'Linear Regresion' button but close it when I click on 'OK'. If this is at all possible (maybe it is not), can I open later another window and still have this one opened until I click 'OK'? I tried different clearwin options but no one gave me what I needed.

ans=winio@('%ca[My plot]%bg[grey]&') ans=winio@('%pl[scale=log_log,style=0,colour=red,x_array,y_axis=S_kt,x_axis=k]&',600,400,n,x,y) ans=winio@('%ff%nl%cn%bt[Linear regresion]%ta%bt[OK]')

I thought and asked about child windows as an option, but maybe they are not the right answer to my problem....thanks for your patience!,

Agustin

26 Sep 2009 11:56 #5039

If you supply a callback for a button click then the close behaviour depends on the value returned by the callback function. Details can be found in the help file near the beginning of the section on ClearWin+.

See Win32 platform->ClearWin+->Format Windows->Callback functions.

26 Sep 2009 1:11 #5041

Thanks Paul, I will introduce a call-back function then. In fact I was thinking that a call-back function was the only way to leave the window opened, but I was trying to see if there was another option. I designed a module containing all the call-backs of the program, so that, one more is not a problem, but I would have preferred to have the full code in the same subroutine for simplicity. Thanks again and have a nice weekend!

Agustin

26 Sep 2009 1:37 #5042

There is a standard callback called 'CONTINUE' that can be used if no action is required.

29 Sep 2009 3:33 #5075

I eventually succeded! I followed your advise about using a call-back function and this is the result (code just for testing purposes:

module datos real8 :: low=1.0,upper=100.0 real8, dimension(1000) :: x,y,r,q integer:: n end module datos program test use mswin use datos external show integer ans n=0 do i=1,100 x(i)=i y(i)=x(i)**2+25 n=n+1 end do low=1 upper=1 ans=winio@('%ca[First window]%bg[grey]&') ans=winio@('%fn[Courier New]%ts&',1.1D0) ans=winio@('%pl[scale=linear,n_graphs=1,style=0,colour=red,x_array,y_axis=S_kt,x_axis=k]&',600,400,n,x,y) ans=winio@('Change x values&') ans=winio@('%2nl Lower lmit:%ta%6rf&',low) ans=winio@('%2nl UpperLimit:%ta%6rf&',upper) ans=winio@('%tc&',RGB@(0,0,255)) ans=winio@('%ff%nl%cn%^bt[Next]%ta%bt[OK]',show) end program test integer function show() use mswin use datos integer ans n=0 do i=low,upper x(i)=i y(i)=x(i)**2+25 n=n+1 end do do i=low,upper r(i)=i q(i)=r(i)**3+25 end do ans=winio@('%ca[New window]%bg[grey]&') ans=winio@('%fn[Courier New]%ts&',1.1D0) ans=winio@('%pl[scale=log_log,n_graphs=2,style=0,colour=red,colour=blue,x_array,y_axis=Log(S_kt),x_axis=Log(k)]&',600,400,n,x,y,q) ans=winio@('%ff%nl%cn%bt[Back]%ta%bt[OK]') show=2 end function show

The only problem is when the log plot shows superscripts in the x-axis: they are quite difficult to read! Is there any possibility to increase the size of the font used by the axis? The %ts only works for buttons font but not for axis labels. I haven't checked what happens if one uses simpleplot routines instead of %pl yet.

PROBLEM WITH LABEL SIZE SOLVED! JUST PUT SOME SIMPLEPLOT SUBROUTINES BEFORE CLEARWIN WINDOWS OPEN AND READY! In my code I added

call textmg(2) call chset(52)

before ans=winio@('%ca[First window]%bg[grey]&')

and changed the font and magnified it by factor 2, so that the superscripts can be seen better. Seems Simpleplot subroutines can be used also with %pl windows before they are created.

Agustin

Please login to reply.