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 

Draw_rectangle@ with %gr smooth4 or smooth8 options

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



Joined: 18 May 2012
Posts: 189
Location: Glasgow, Scotland.

PostPosted: Mon Nov 26, 2018 1:11 am    Post subject: Draw_rectangle@ with %gr smooth4 or smooth8 options Reply with quote

Below is a link to a simple drawing program which behaves as expected, drawing lines, circles, rectangles etc.

http://www.tr5mx.co.uk/canvas2.f95

If the %gr options smooth4 or smooth8 are included, there is a problem when drawing a non-filled rectangle. The drawn element does not appear immediately, and will only appear after another element e.g. a line or circle is drawn.

Ken
Back to top
View user's profile Send private message Visit poster's website
PaulLaidler
Site Admin


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

PostPosted: Mon Nov 26, 2018 8:55 am    Post subject: Reply with quote

Ken

I think that the trick is probably to call set_graphics_selection@ as in the following sample which is similar to yours.

Code:
!FTN95$WINAPP
!------------------------------------------------------------------
    module gr7data
      character*32 cstat
    end module gr7data
!---------------------------------------------------------------
    program gr7
      use gr7data
      integer i,winio@,RGB@
      integer,external::gr_func
      cstat=' '
      i=winio@('%ww&')
      i=winio@('%ca[Box Selection]&')
      i=winio@('%mn[E&xit]&','EXIT')
      i=winio@('%bg&',RGB@(240,240,240))
      i=winio@('%ob&')
      i=winio@('%^gr[colour=#f0f0f0,box_selection,smooth8]&',300,300,gr_func)
      i=winio@('%cb&')
      i=winio@('%ff %nl&')
      i=winio@('%ob[status]%20st%cb',cstat)
    end
!-----------------------------------------------------------
    integer function gr_func()
      use clrwin
      use gr7data
      integer x1,y1,x2,y2,nstat,a,b
      integer,parameter::MK_SHIFT=4,MK_CONTROL=8,RED=255
      call get_mouse_info@(x1,y1,nstat)
      write(cstat(1:30),'(3I7)') x1,y1,nstat
      call window_update@(cstat)
      if(clearwin_string@('CALLBACK_REASON') == 'MOUSE_LEFT_CLICK')then
        call set_line_width@(2)
        call get_graphics_selected_area@(x1,y1,x2,y2)
        call set_graphics_selection@(0)
        if(iand(nstat,MK_SHIFT)==MK_SHIFT) then
          call draw_rectangle@(x1,y1,x2,y2,RED)
        else if(iand(nstat,MK_CONTROL)==MK_CONTROL) then
          a=0.5*(x2-x1)
          b=0.5*(y2-y1)
          call draw_ellipse@(x1+a,y1+b,a,b,RED)
        else
          call draw_line_between@(x1,y1,x2,y2,RED)
        endif
        call set_graphics_selection@(1)
      endif
      gr_func=2
    end

!-----------------------------------------------------------

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



Joined: 18 May 2012
Posts: 189
Location: Glasgow, Scotland.

PostPosted: Mon Nov 26, 2018 3:19 pm    Post subject: Reply with quote

Thanks Paul, I forgot about that example. Modified your example to demonstrate issue as below, and uncommenting the call to set_graphics_selection@ the problem goes away. Very Happy

Ken

Code:
     program gr7
       integer i,winio@,RGB@
       integer,external::gr_func
       i=winio@('%ww&')
       i=winio@('%ca[Box Selection]&')
       i=winio@('%mn[E&xit]&', 'EXIT')
       i=winio@('%bg&', RGB@(240,240,240)) 
       i=winio@('%^gr[colour=#f0f0f0,box_selection,smooth8]', 300, 300, gr_func) 
     end
 !-----------------------------------------------------------
     integer function gr_func()
       use clrwin 
       integer x1, y1, x2, y2, nstat, a, b
       integer, parameter :: RED=255 
       
       if (clearwin_string@('CALLBACK_REASON') == 'MOUSE_LEFT_CLICK') then
         call set_line_width@(2)
         call get_graphics_selected_area@(x1, y1, x2, y2)
         print *,x1,y1,x2,y2
         call draw_rectangle@(x1,y1,x2,y2,RED) 
!         call set_graphics_selection@(1)
       endif       
       gr_func=2
     end
Back to top
View user's profile Send private message Visit poster's website
John-Silver



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

PostPosted: Mon Dec 03, 2018 6:53 am    Post subject: Reply with quote

Paul, your example above, is it in the HELP manual somewhere ?
_________________
''Computers are incredibly rigid. They question nothing. Especialy input data.Human beings are incredibly trusting of computers and don't check input data. Together they are capable of 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 -> ClearWin+ 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