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 

Problem with rotate_font@

 
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support
View previous topic :: View next topic  
Author Message
Kenneth_Smith



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

PostPosted: Thu May 21, 2020 10:32 am    Post subject: Problem with rotate_font@ Reply with quote

I think this example may point to a bug, or perhaps I am doing something silly?


Code:
module example_22_5_20
use clrwin
implicit none
integer, parameter :: dp=kind(1.d0), gw = 800, gh = 600
real(kind=dp) :: x_array(1:20)=0.d0 , y_array(1:20)=0.d0

contains

  integer function generate_data()
  integer i
    do i = 1, 20
      x_array(i)=random@() - 0.5d0  ; y_array(i)=random@() - 0.5d0
    end do
    generate_data = 2
  end function generate_data

  integer function plot()
  integer, save :: iw
    call winop@('%pl[independent,x_array,link=none,symbol=6,gridlines,frame,margin=(100,100,100,100)]')
    iw = winio@('%pl&',gw,gh,20,x_array,y_array)
    iw = winio@('%ob&')
    iw = winio@('%^tt[SP redraw]&',sp_redraw_cb)
    iw = winio@('%2nl%^tt[x_axis]&',x_axis_cb)
    iw = winio@('%2nl%ws&','1. Click on x axis button, and note position of text drawn on screen.')
    iw = winio@('%1nl%ws&','2. Click on SP redraw button.')
    iw = winio@('%1nl%ws&','3. Click on x axis button.  Text is now drawn in different position.')
    iw = winio@('%2nl%ws&','If the calls to rotate_font@ (associated with drawing y axis text)')
    iw = winio@('%1nl%ws&','are commented out this does not happen.')
    iw = winio@('%cb&')
    iw = winio@(' ')

    iw = winio@('%gr&',gw,gh)
    iw = winio@('%ob&')
    iw = winio@('%^tt[SP redraw]&',sp_redraw_cb)
    iw = winio@('%2nl%^tt[x_axis]&',x_axis_cb)
    iw = winio@('%2nl%ws&','1. Click on x axis button, and note position of text drawn on screen.')
    iw = winio@('%1nl%ws&','2. Click on SP redraw button.')
    iw = winio@('%1nl%ws&','3. Click on x axis button.  Text is now drawn in different position.')
    iw = winio@('%2nl%ws&','If the calls to rotate_font@ (associated with drawing y axis text)')
    iw = winio@('%1nl%ws&','are commented out this does not happen.')
    iw = winio@('%cb&')
    iw = winio@(' ')
   
    plot = 2
  end function plot

  integer function sp_redraw_cb()
    call simpleplot_redraw@()
    sp_redraw_cb = 2
  end function sp_redraw_cb

  integer function x_axis_cb()
  integer tw, th
    call get_text_size@('x label', tw, th)
    call draw_characters@('x label', 400 - tw, gh-50, rgb@(0,0,0))
    call rotate_font@(90.d0)
    ! Here draw y label
    !
    call rotate_font(0.d0)  !Reset default angle for drawing text to horizontal
    x_axis_cb = 2
  end function x_axis_cb

end module example_22_5_20

program main
use example_22_5_20
implicit none
integer i
  i = generate_data() ; i = plot() ; i=i
end program main
Back to top
View user's profile Send private message Visit poster's website
Kenneth_Smith



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

PostPosted: Thu May 21, 2020 10:49 am    Post subject: Reply with quote

Missing the @ in my second call to rotate_font in the code above - but the problem still exists when this is corrected.
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


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

PostPosted: Thu May 21, 2020 11:52 am    Post subject: Reply with quote

Maybe rotate_font@ does not work that way and you have to rotate back again.

Try a simple %gr with just draw_characters@ and rotate_font@.
Back to top
View user's profile Send private message AIM Address
Kenneth_Smith



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

PostPosted: Thu May 21, 2020 12:10 pm    Post subject: Reply with quote

Paul,

I discovered by accident that a call to rotate_font@(0.d0) immediately, before the call to draw_characters@ fixes the problem. Without this, the text is initially drawn in the incorrect place, the first time the callback runs.

Ken

Code:
  integer function x_axis_cb()
  integer tw, th
    call get_text_size@('x label', tw, th)
    call draw_line_between@(0, gh-100, gw, gh - 100, rgb@(255,0,0))
    call draw_line_between@(0, gh-50, gw, gh - 50, rgb@(255,0,0))
    call rotate_font@(0.d0)                                         !COMMENT OUT TO SEE ERROR IN Y POSITION
    call draw_characters@('x label', 400 - tw, gh-50, rgb@(0,0,0))
    call rotate_font@(90.d0)
    ! Here draw y label
    !
    call rotate_font@(0.d0)  !Reset default angle for drawing text to horizontal
    x_axis_cb = 2
  end function x_axis_cb
Back to top
View user's profile Send private message Visit poster's website
John-Silver



Joined: 30 Jul 2013
Posts: 1520
Location: Aerospace Valley

PostPosted: Thu May 28, 2020 10:30 pm    Post subject: Reply with quote

Ken, when you write:
Quote:
Without this, the text is initially drawn in the incorrect place, the first time the callback runs.

how much is it in error ?
_________________
''Computers (HAL and MARVIN excepted) are incredibly rigid. They question nothing. Especially input data.Human beings are incredibly trusting of computers and don't check input data. Together cocking up even the simplest calculation ... Smile "
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    forums.silverfrost.com Forum Index -> Support All times are GMT + 1 Hour
Page 1 of 1

 
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