Silverfrost Forums

Welcome to our forums

Native %pl

26 Oct 2016 3:24 #18243

A native %pl is now available for beta testing in both 32 bit and 64 bit applications.

Please use the following DLL download carefully but only if you have version 8.05 of the FTN95 and only after backing up your existing Silverfrost DLLs.

The download includes a txt file that provides instructions together with a sample program.

https://www.dropbox.com/s/11preu54yrhi11n/newDlls11.zip?dl=0

26 Oct 2016 8:20 #18244

Great!....now it works as I expected: no plot if no data. Thanks Paul for the update!......and some additional comments: I have been playing with the new version and found that 'pen_style' can be varied from 0 to 4, 0 is solid, 1 is dashed an 4 seems to me to be dotted (is this correct?), but it is not easy to distiguish them, at least on my screen (1920x1080). I have changed 'width' from 1 to 8, trying to distiguish the different lines and got the same 'visual' line thickness in all my plots (at least on my screen). I have no printer at the moment so I cannot check if the printed output shows better the differences between lines.

26 Oct 2016 11:32 #18245

Some new findings......%pl seems to be very strict: if at the very beginning one sets, for instance, 'N-graphs=2', then it is not possible to plot either 1 or 3 curves (or data sets) during the run of a program. It is obviously possible to do that by adding a new %pl statement with the new option for graphs, but then the call to this new %pl opens a new, additional window. Is this so, or am I doing anything wrong?.

Agustin

27 Oct 2016 6:57 #18246

Agustin

Thank you for the feedback.

The pen styles are those provided by the Microsoft GDI/GDI+ and have constants PS_SOLID = 0 etc. You will be able to get details by searching Microsoft MSDN. ClearWin+ %pl provides an interface into GDI+. GDI+ can input a user-defined 'dashed array' to define the spacing. This is available in %gr but not in %pl at the moment.

There is a bug that caused the line width to get lost and this has now been fixed. In the meantime it will work (I think) if you specify the line width as the last %pl option.

The primary design of the native %pl is constrained by the aim of porting existing code as far as possible without modification. The coding within the library is simply an extension of what was already present. A new design was not really a possibility within the time available.

Having got this far there will naturally be many ways that %pl can be extended but in the short term I can only add these to the wish list.

Providing a variable number of graphs within the present design might prove to be a challenge that is difficult to resist - I will try not to be tempted. In the meantime you might try filling in by drawing dummy graphs with zero height at every point.

27 Oct 2016 1:37 #18247

Agustin

I have added a new style value [style=3] that can be applied to any of the graphs drawn on one pair of axes. This bypasses the corresponding graph. There is also a new function SET_GRAPH_STYLE@(ID,INDEX,STYLE) that enables you to set the style (and activate or clear a graph) after the window has been created.

If you are interested in trying this out I will upload a new set of DLLs.

27 Oct 2016 1:58 #18248

Thanks Paul for your work....if you upload the new set of DLLs I will implement and try the new features of %pl with my code.

Agustin

27 Oct 2016 4:05 #18249

Here is a link to a new set of DLLs. The usual cautions still apply.

https://www.dropbox.com/s/2bu71rr4wcztuex/newDlls12.zip?dl=0

27 Oct 2016 10:35 #18250

I have been testing this new version of %pl and found some issues. I have added to your example a second function z(n):

 WINAPP
      MODULE mydata
        USE clrwin
       C_EXTERNAL SET_GRAPH_STYLE@ '__set_graph_style'(VAL,VAL,VAL):INTEGER*4
        INTEGER,PARAMETER::n=1000
        INTEGER n_points
        real*8:: y(n)=0.0,z(n)=0.0
      CONTAINS
      INTEGER FUNCTION draw()
        INTEGER i,x
        DOUBLE PRECISION p1,p2,p3
        p1=1.5d0
        p2=150.0d0
        p3=15d0
        x=0
        DO i=1,n
          y(i)=p1*sin(x/p3)*exp(-x/p2)
          x=x+1
        ENDDO
        i = set_graph_style@(0,1,0)
        CALL simpleplot_redraw@()
        draw = 2
      END FUNCTION draw

       INTEGER FUNCTION draw2()
        INTEGER i,x
        DOUBLE PRECISION p2,p3,p4
        p2=150.0d0
        p3=20d0
        p4=2
        x=0
        DO i=1,n
          z(i)=p4*sin(x/p3)*exp(-x/p2)
          x=x+1
        ENDDO
        i = set_graph_style@(0,2,2)
        CALL simpleplot_redraw@()
        draw2 = 2
      END FUNCTION draw2

      INTEGER FUNCTION clear()
        CALL clear_screen@()
        i = set_graph_style@(0,1,3)
        i = set_graph_style@(0,2,3)
        CALL simpleplot_redraw@()
        clear = 2
      END FUNCTION clear
      END MODULE mydata
      
      PROGRAM main
      USE mydata
      C_EXTERNAL WINOP@ '__winop'(INSTRING)
       n_points = 1000
      i=winio@('%ww[no_border]%ca[Damped wave]%pv&')
      i=winio@('%mn[Edit[Draw,draw2, Clear]]&', draw, draw2,clear)
      i=winio@('%fn[Tahoma]&')
      i=winio@('%ts&', 1.1d0)
      i=winio@('%tc&',rgb@(0,0,80))
      i=winio@('%it&')
      i=winio@('%`bg&',rgb@(230,255,225))
      CALL winop@('%pl[native]')
      CALL winop@('%pl[style=3]')     ! curve joins points
      CALL winop@('%pl[style=3]')     ! curve joins points
      CALL winop@('%pl[pen_style=0]')
      CALL winop@('%pl[pen_style=4]')
      CALL winop@('%pl[title='Sample plot']')
      CALL winop@('%pl[x_axis=Time(Milliseconds)]')
      CALL winop@('%pl[y_axis=Amplitude@(-4.0)]')
      CALL winop@('%pl[smoothing=4]') ! anti-aliasing
      CALL winop@('%pl[smoothing=4]') ! anti-aliasing
      CALL winop@('%pl[width=1]')
      CALL winop@('%pl[width=4]')
      i=winio@('%pl[colour=red,colour=blue,N_GRAPHS=2]',500,400,n_points,0.0d0,1.0d0,y,z)
      END

The first problem I found is that 'style' should be set to 3, or the program crashes (in the NativePl.txt says that one can set 0,1,2, but seems that the old 'style' has been replaced by the SET_GRAPH_STYLE@, right? ). I do not understand quite well the actual meaning of 'style' (maybe because I am using the 'set_graph_style@(0,1,0)' the use of style=3 is mandatory?) . The second issue I found is that the second 'width' is used for both plots. I guess this is a bug. For the rest, it seems that all works fine. I have run several times the program changing options and worked. I still have to test the use of %`pl for plotting one or the other plot.

Agustin

28 Oct 2016 7:21 #18251

Agustin

I don't understand the problem about the style. Your program works OK for me except for a couple of details:

  1. I have to add a call to clear_screen@ before drawing otherwise the title goes wrong.

  2. I get an added box around the whole graph area after calling clear_screen.

I can probably fix both these issues.

In the design I have assumed that one line width and one smoothing value will apply to all graphs. So in your program the last value that is set will be applied to all graphs. If you need either of these to vary between graphs then I could change the design.

28 Oct 2016 10:48 #18253

Agustin

I have managed to get it to fail now so I will take a look at it.

28 Oct 2016 11:58 #18254

Quoted from PaulLaidler Agustin

  1. I have to add a call to clear_screen@ before drawing otherwise the title goes wrong..

yes, I forgot to mention this issue

In the design I have assumed that one line width and one smoothing value will apply to all graphs. So in your program the last value that is set will be applied to all graphs. If you need either of these to vary between graphs then I could change the design.

Sorry, I did not know about this design, it was not mentioned in the notes and I assumed that this option worked as others: one option for each plot. As you say, I am also not sure if one really needs different widths for each type of line in a plot, but I think that this should be clarified in the corresponding notes.

By the way, yesterday night I was testing the use of two %pl windows using a handle (`%pl). I have to test some issues, but when I tried to plot y(n) on one %pl and z(n) on the other, it resulted that the second screen showed a black background. But I am still testing this, maybe I did something wrong. Thanks for your work.

Agustin

28 Oct 2016 12:41 #18255

Paul,

I am testing the use of %`pl option and found that in the best case, the same data is plotted on both secreens. I have set:

i=winio@('%pl[colour=red,N_GRAPHS=1]&',500,400,n_points,0.0d0,1.0d0,y,1) and i=winio@('%pl[colour=blue,N_GRAPHS=1]&',500,400,n_points,0.0d0,1.0d0,z,2)

and

i = set_graph_style@(1,1,0)

in function draw()

and i = set_graph_style@(2,2,0)

in function draw2()

Am I right?....what I get are two windows and only the first plot is drawn in either window 1 or window 2. I guess I am doing something wrong, but what?

Agustin

29 Oct 2016 9:10 (Edited: 18 Sep 2017 12:14) #18260

Agustin

I have fixed a couple of bugs and simplified the design.

Here is a link to a new set of DLLs. The download includes new mod files, instructions and sample programs.

https://www.dropbox.com/s/hgobb0wix83d8ce/newDlls13.zip?dl=0

18 Sept 2017 This link has expired.

29 Oct 2016 4:16 #18264

I am testing the new dll and find that things run better now. I see that you eliminated the set_graph_style@ routine. Although this routine was a good idea, in the end introduced some confusion with the old directives for %pl. Now all is simpler and straightforward. There is however a bug: when you plot two %pl, everything is OK.....only if you maintain the size of the window: when you maximise the window, the second plot appears on top at the left and with the original size. Only the first plot is increased in size (I haven't tried what happens with four plots 😃 ).

And now some comments:

  1. the code you wrote in the notes does not include the statement 'C_EXTERNAL WINOP@ '__winop'(INSTRING)', however you need it or the complier does not understand the winop@ statements.

  2. the number of labels (and labels, and number of ticks) cannot be set by the user, they are set by clearwin and changes with the size of the window. Should it be so?. Is there any (simple) chance to modify this behaviour?

Thanks again for your work. Have a nice weekend!

Agustin

29 Oct 2016 4:42 #18265

Agustin

With two %pl controls the %pv does not work. We need to take the %pv out of that sample program. It is not a fault in the code but a limitation of %pv that it only works for one resizable control.

  1. I have added winop@ to the .ins and mod files that are included in the download. If you use these then it should be OK.

  2. Yes, the number of ticks cannot be set by the user. Also the user does not have much control over the way that the numbers at the tick marks are presented. I think that this was also true in the original %pl.

29 Oct 2016 6:39 #18266

Quoted from PaulLaidler

With two %pl controls the %pv does not work. We need to take the %pv out of that sample program. It is not a fault in the code but a limitation of %pv that it only works for one resizable control.

OK, no problem, we can set the size of the window from the start and continue with the program

  1. I have added winop@ to the .ins and mod files that are included in the download. If you use these then it should be OK.

I am using the ins and mod files you provided and I still need to include this statement or I get:

'Compiling and linking file: PL-new.f95 WARNING the following symbols are missing: WINOP# C:\Documentos\Trabajos\Azpeitia\Fortran\Testing\lgotemp@.obj (C:\DOCUMENTOS\TRABAJOS\AZPEITIA\FORTRAN\TESTING\PL-NEW.F95) Creating executable: C:\Documentos\Trabajos\Azpeitia\Fortran\Testing\PL-new.EXE Compilation and linking completed.

  1. Yes, the number of ticks cannot be set by the user. Also the user does not have much control over the way that the numbers at the tick marks are presented. I think that this was also true in the original %pl.

Do you think that this issue could be changed in the future?

Agustin

29 Oct 2016 7:54 #18267

Agustin

Maybe a feature could be added that allows the user to specify the x increment between tick marks and also the y increment. It is difficult to know how far to take this. The x tick marks have to be spaced so that the corresponding numbers do not overlap. The y ticks marks are not a problem but for y numbers the y-axis has to be a suitable distance from the margin. Add to this the need for an optimal format for the numbers and it all becomes quite tricky.

29 Oct 2016 9:06 #18268

thanks for the answer.....maybe sometimes I am missing the point that %pl is just a fast and simple way to plot 2D data without the need of a graphics subroutines package like the old Simpleplot. For what it was designed, I have to say that it works now great with your new implementations. The only thing that it would need is the availability of more symbols for scatter plots. But that's all for such a tool. Thanks again for your nice work.

Agustin

31 Oct 2016 12:16 #18295

Agustin

Here is my final version for now assuming that there are no outstanding bugs. I have added alternatives to the box shape and also options [dx=fval] and [dy=fval]. These allow the user to set a preferred gap between the tick marks. ClearWin+ will use these preferences where possible.

https://www.dropbox.com/s/tw2yzllrpu61yo2/newDlls14.zip?dl=0

8 Nov 2016 4:29 #18337

Is it possible that %pl cannot be used to plot allocatable arrays?. I was struggling to move my program from using Simpleplot to the new %pl, but could not plot anything. In the end I come to the idea that the only possibility was that my data was in allocatable arrays that can change size along the run of the program. Is it so?

Agustin

Please login to reply.