|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
aebolzan
Joined: 06 Jul 2007 Posts: 229 Location: La Plata, Argentina
|
Posted: Thu Sep 24, 2009 2:51 pm Post subject: How can I open child Simpleplot windows? |
|
|
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 |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7931 Location: Salford, UK
|
Posted: Thu Sep 24, 2009 4:51 pm Post subject: |
|
|
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 |
|
Back to top |
|
|
aebolzan
Joined: 06 Jul 2007 Posts: 229 Location: La Plata, Argentina
|
Posted: Thu Sep 24, 2009 6:50 pm Post subject: |
|
|
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 |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7931 Location: Salford, UK
|
Posted: Fri Sep 25, 2009 9:03 am Post subject: |
|
|
Did you use %fr with your %aw? |
|
Back to top |
|
|
aebolzan
Joined: 06 Jul 2007 Posts: 229 Location: La Plata, Argentina
|
Posted: Fri Sep 25, 2009 2:04 pm Post subject: |
|
|
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 |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7931 Location: Salford, UK
|
Posted: Fri Sep 25, 2009 2:39 pm Post subject: |
|
|
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. |
|
Back to top |
|
|
aebolzan
Joined: 06 Jul 2007 Posts: 229 Location: La Plata, Argentina
|
Posted: Sat Sep 26, 2009 12:20 am Post subject: |
|
|
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 |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7931 Location: Salford, UK
|
Posted: Sat Sep 26, 2009 12:56 pm Post subject: |
|
|
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. |
|
Back to top |
|
|
aebolzan
Joined: 06 Jul 2007 Posts: 229 Location: La Plata, Argentina
|
Posted: Sat Sep 26, 2009 2:11 pm Post subject: |
|
|
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 |
|
Back to top |
|
|
PaulLaidler Site Admin
Joined: 21 Feb 2005 Posts: 7931 Location: Salford, UK
|
Posted: Sat Sep 26, 2009 2:37 pm Post subject: |
|
|
There is a standard callback called "CONTINUE" that can be used if no action is required. |
|
Back to top |
|
|
aebolzan
Joined: 06 Jul 2007 Posts: 229 Location: La Plata, Argentina
|
Posted: Tue Sep 29, 2009 4:33 pm Post subject: |
|
|
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
real*8 :: low=1.0,upper=100.0
real*8, 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 |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|