replica nfl jerseysreplica nfl jerseyssoccer jerseyreplica nfl jerseys forums.silverfrost.com :: View topic - Avoiding flicker with rapid %pl updates
forums.silverfrost.com Forum Index forums.silverfrost.com
Welcome to the Silverfrost forums
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Avoiding flicker with rapid %pl updates
Goto page Previous  1, 2, 3  Next
 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+
View previous topic :: View next topic  
Author Message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8177
Location: Salford, UK

PostPosted: Sat Jan 25, 2025 7:43 am    Post subject: Reply with quote

Ken

Upon reflection, I think that %pl[external] ought to pick up the local font and I will take a look at this.

In the mean time I would expect the font (and background colour) to be picked up by the original %gr.
Back to top
View user's profile Send private message AIM Address
Kenneth_Smith



Joined: 18 May 2012
Posts: 799
Location: Hamilton, Lanarkshire, Scotland.

PostPosted: Sat Jan 25, 2025 12:58 pm    Post subject: Reply with quote

Paul,

Thanks I will experiment with these suggestions. I am rather like a wee bairn with a new toy!

Here�s what I can up with last the other evening which animates a pen plotter or CRO displaying the step response of a second order system.

https://www.dropbox.com/scl/fi/9zy9m3tgpnao0c1a54o6c/Second_order_step_response.f95?rlkey=nhyyj436y2780v57s41ohh0xl&st=kumwh0z5&dl=0
Back to top
View user's profile Send private message
Kenneth_Smith



Joined: 18 May 2012
Posts: 799
Location: Hamilton, Lanarkshire, Scotland.

PostPosted: Sun Jan 26, 2025 3:07 pm    Post subject: Reply with quote

It took me a while to realise that the %pl[external,buffered] has only a fleeting existence, being destroyed after the image is copied to the %gr. So calls later to simpleplot_redraw@ do not update the %gr.

Here is a minimum example to show what is required to get this approach to work.
Code:
module sin_wave
use clrwin
implicit none
  integer, parameter :: max_size = 100, gw = 900, gh = 500
  real*8,  parameter :: freq = 50.d0, omega = 2.d0*freq*4.d0*atan(1.d0)
  real*8,  parameter :: t_end = 1.d0/freq, dt = t_end / (max_size - 1)
  real*8 :: y(max_size)
  integer :: i
  integer :: npts
   
contains

  integer function gui()
  integer :: iw
    y =  [(sin(omega*((i - 1) * dt)), i = 1, max_size)]
    iw = winio@('%^bt[Run]%nl&',run_cb)
    iw = winio@('%gr[white]&', gw, gh)
    iw = winio@('')
    gui = 1
  end function gui

  integer function plot()
  integer :: iw
    iw = winio@('%pl[native,n_graphs=1,axes_pen=2,width=3,external,buffered]',&
                 npts,0.d0,dt,y)
    plot = 2
  end function plot

  integer function run_cb()
  integer :: i, k
    do i = 1, max_size
      npts = i 
      k = plot()
      call sleep@(0.02)
    end do
    run_cb = 2
  end function run_cb
 
end module sin_wave

winapp
program test
use sin_wave,  only : gui
i = gui()
end program test
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8177
Location: Salford, UK

PostPosted: Mon Jan 27, 2025 8:47 am    Post subject: Reply with quote

I have fixed the font issue for %pl[external,buffered]. Here is a link to DLLs that includes this single fix.

https://www.dropbox.com/scl/fi/wty9jw7f6o54ynnmyaspk/newDLLs134.zip?rlkey=1cyumj3kxm9qa2kt36tp2zggs&dl=0

The fix allows the font name and font size to be set locally before %pl.
Back to top
View user's profile Send private message AIM Address
Kenneth_Smith



Joined: 18 May 2012
Posts: 799
Location: Hamilton, Lanarkshire, Scotland.

PostPosted: Mon Jan 27, 2025 10:30 am    Post subject: Reply with quote

Paul, Thanks for your efforts on this. My test code works as expected now.
Back to top
View user's profile Send private message
JohnCampbell



Joined: 16 Feb 2006
Posts: 2615
Location: Sydney

PostPosted: Tue Jan 28, 2025 9:41 am    Post subject: Reply with quote

Ken,

I am a bit behind, as I am not using Ver 9.06 as yet.

However I ran your 27-Jan example in Plato (without buffering), plus having FTN95 help window opened and the FTN95 Help window index was also flickering.

Also noticed "call sleep@(0.02)" was also working, contrary to sleep@(time), for time < .05.

Thanks for the examples.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8177
Location: Salford, UK

PostPosted: Tue Jan 28, 2025 11:36 am    Post subject: Reply with quote

John

There was a bug in ClearWin+ that in some contexts was causing other applications to flicker. This has been fixed.
Back to top
View user's profile Send private message AIM Address
Kenneth_Smith



Joined: 18 May 2012
Posts: 799
Location: Hamilton, Lanarkshire, Scotland.

PostPosted: Tue Jan 28, 2025 1:07 pm    Post subject: Reply with quote

Paul,

If you run this program a dozen times, you may get a surprise. Using winop@ calls and extremely rapid update I occasionally get the clearwin error "Too many colours for %pl plot".

I m guessing, but it looks like the character string created by winop@ in the previous iteration is not cleared.

Code:
module data_mod
use clrwin
implicit none
integer, parameter :: n = 100
real*8 :: x(n), random_y(n), mean_y(n)
end module data_mod

program p
implicit none
integer :: iw
integer, external :: run_cb
iw = winio@('%^bt[Run]%nl&',run_cb)
iw = winio@('%gr[white]', 900, 600)
end program p

integer function run_cb()
use data_mod
implicit none
integer :: i, iw
real*8 :: acc
 
  call random_number(random_y)
  acc = 0.d0
  do i = 1, n, 1
   
    x(i) = dble(i)
    acc = acc + random_y(i)
    mean_y(i) = acc / x(i)
       
!$$$$$$       iw = winio@('%fn[Consolas]%ts&',1.5d0)
!$$$$$$       iw = winio@('%pl[native,n_graphs=2,frame,gridlines,width=3,'//&
!$$$$$$                       'link=none,colour=red,symbol=10,'//&
!$$$$$$                       'link=lines,colour=blue,symbol=0,'//&
!$$$$$$                       'external,buffered'//']', i, 1.d0, 1.d0, random_y, mean_y)
         
!  The code commented out above works without any issues.
!  The equivalent code below using winop@ calls will
!  ** on occasion ** fail reporting the clearwin error
!  "Too many colours for %pl plot"
!  This happens when i is small, typically < 6
      print*, i
      call winop@('%pl[native]')
      call winop_int@('%pl[n_graphs]', 2)
      call winop@('%pl[frame,gridlines]')
      call winop_int@('%pl[width]',3)
      call winop@('%pl[link=none,colour=red,symbol=10]')
      call winop@('%pl[link=lines,colour=blue,symbol=0]')
      call winop@('%pl[external,buffered]')
      iw = winio@('%fn[Consolas]%tc[blue]%ts&',1.5d0)
      iw = winio@('%pl', i, 0.d0, 1.d0, random_y, mean_y)
  end do
  run_cb = 2
end function run_cb
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8177
Location: Salford, UK

PostPosted: Wed Jan 29, 2025 8:48 am    Post subject: Reply with quote

Ken

When setting the number of graphs, it must be the first option when using winop@ etc..

Also it looks like the %pl options must be kept together by moving the font attributes to the beginning. But I don't know why this is necessary.

So...

iw = winio@('%fn[Consolas]%tc[blue]%ts&',1.5d0)
call winop_int@('%pl[n_graphs]', 2)
call winop@('%pl[native]')
call winop@('%pl[frame,gridlines]')
call winop_int@('%pl[width]',3)
call winop@('%pl[link=none,colour=red,symbol=10]')
call winop@('%pl[link=lines,colour=blue,symbol=0]')
call winop@('%pl[external,buffered]')
iw = winio@('%pl', i, 0.d0, 1.d0, random_y, mean_y)

then maybe a call to perform_graphics_update@() and temporary_yield@() might be good.
Back to top
View user's profile Send private message AIM Address
Kenneth_Smith



Joined: 18 May 2012
Posts: 799
Location: Hamilton, Lanarkshire, Scotland.

PostPosted: Wed Jan 29, 2025 11:46 am    Post subject: Reply with quote

Thanks Paul,

For some reason I had it in my head that the requirement for n_graphs to be in the first winop@ call only applied when n_graphs > 10. I�m pretty sure that�s stated in the documentation somewhere.

All working now.

Also fine in the case where there are multiple %gr regions and a call to select_graphics_object@ is required. I plan to do a few more tests.
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8177
Location: Salford, UK

PostPosted: Wed Jan 29, 2025 12:58 pm    Post subject: Reply with quote

Yes. The documentation needs fixing. The change may not get into the next full release.
Back to top
View user's profile Send private message AIM Address
DanRRight



Joined: 10 Mar 2008
Posts: 2910
Location: South Pole, Antarctica

PostPosted: Wed Jan 29, 2025 3:29 pm    Post subject: Reply with quote

Thanks, Paul, for polishing one more thing in CWP.

Noticed something unusual here: winop_int@ and when looked at ctwplus.enh file I found a lot of things I missed because did not have time to look into this file hidden deeply into the directory structure. All these new features have to be actively advertised otherwise the situation look like with Franz Schubert, who was writing all his music into the table shelf Sad
Back to top
View user's profile Send private message
Kenneth_Smith



Joined: 18 May 2012
Posts: 799
Location: Hamilton, Lanarkshire, Scotland.

PostPosted: Thu Jan 30, 2025 12:13 pm    Post subject: Reply with quote

Paul,

Pleased to report that my further tests did not identify any additional problems.

Here is one with multiple graphs.

https://www.dropbox.com/scl/fi/cuu91mgnsmrjeqr6wbblf/three_pl_buffered.f95?rlkey=dwslwk621wxvjeo68xz53xx7t&st=q4nx73xj&dl=0

Thanks again for this enhancement.

Ken
Back to top
View user's profile Send private message
Kenneth_Smith



Joined: 18 May 2012
Posts: 799
Location: Hamilton, Lanarkshire, Scotland.

PostPosted: Sun Feb 02, 2025 10:51 pm    Post subject: Reply with quote

Here is another example which appeals to the electrical engineer or �sparky� in me.

The program simulates an electrical arc between two arcing horns in 2D, using midpoint displacement and recursion to generate the chaotic, jagged path of each sequential arc.

https://www.dropbox.com/scl/fi/pzwe2l0zuy4jazshnkmsd/arcing.f95?rlkey=vbwq0vbjiea290k386vtexvak&st=zxqml4c3&dl=0
Back to top
View user's profile Send private message
PaulLaidler
Site Admin


Joined: 21 Feb 2005
Posts: 8177
Location: Salford, UK

PostPosted: Mon Feb 03, 2025 8:24 am    Post subject: Reply with quote

Ken

These applications are very impressive.
Back to top
View user's profile Send private message AIM Address
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> ClearWin+ All times are GMT + 1 Hour
Goto page Previous  1, 2, 3  Next
Page 2 of 3

 
Jump to:  
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