program T_dislin3
	! test zakladnich procedur

use std_type
use dislinDP

implicit none

intrinsic :: sin,cos

real(kind=DP),dimension(100) :: x, y
real(kind=DP) :: p
integer :: i,j,N
character(len=256) :: legenda

x = (/(0.1_DP*i,i=1,100)/)	! vytvoreni pole x= 0.1, 0.2, ..., 10.0

call metafl('xwin')			! level 0 ; vystup do okna na obrazovce	
call scrmod('reverse')		! 0 ; cerne na bilem pozadi

call x11mod('nostore')		! 0 ; vystup primo na obrazovku, 

call window(50,50,800,600)	! 0,1,2,3; poloha a velikost okna v pixelech

call disini()				! 0 -> 1; inicializace

call ax2grf()			! 1,2,3; potlaci kresbu prave a horni osy, jen ramecek

call hname(40)
call name('Osa X','X')		! 1,2,3
call name('Osa Y','Y')		! musi byt PRED volanim graf

call hname(40)				! 1,2,3; vyska pisma, default=36
CALL winfnt('Tahoma')		! 1,2,3

call ticks(5,'Y')			! 1,2,3; pocet malych dilku na ose Y (def=2)
call ticlen(30,15)			! 1,2,3; delka velkych a malych dilku (def=24,16)

call axspos(300,1800)		! 1; poloha leveho spodniho rohu souradnic
call graf(0.0_DP,10.0_DP,0.0_DP,1.0_DP,-1.1_DP,1.1_DP,-1.0_DP,0.5_DP)	! 1->2 

call chacod('iso2')		! 1,2,3; nastavi ISO-latin-2

call winfnt('Cambria')
call htitle(50)			! 1,2,3; neni-li uvedeno, pouzije se height()
call titlin('Test základních procedur',3)	! 1,2,3; 3.radek/4
call title()			! 2,3


call hsymbl(24)	!1,2,3; velikost symbolu v plot units (zde 2.4 mm)
y = sin(x)
call color('orange')	! 1,2,3
do i=1,size(x)
	call rlsymb(3,x(i),y(i))	! 2,3		
	call cekejMS(10)	
end do

call setrgb(0.4_DP,0.8_DP,0.3_DP)	! 1,2,3; rgb slozky z [0.0,1.0] 
call curve(x,cos(x),size(x))	! 2,3;

call color('magenta')
y = 0.3*sin(x)+0.7*cos(x)

do i=1,size(x)-1
	call rline(x(i),y(i),x(i+1),y(i+1))
	call CekejMS(5)
end do

! ----- legenda ------
call legini(legenda,3,21)
call height(30)
call linesp(2.5_DP)
call winfnt('Arial Narrow')
call leglin(legenda,'sin(x)',1)
call leglin(legenda,'cos(x)',2)
call leglin(legenda,'0.3*sin(x)+0.7*cos(x)',3)

call legtit('')
call frmclr(256)		! bila, legenda bez ramecku 
call legpos(nxposn(10.1_DP),nyposn(1.1_DP))
call color('orange')
call legpat(-1,5,3,-1,-1,1)
call setrgb(0.4_DP,0.8_DP,0.3_DP)
call legpat(0,5,-1,-1,-1,2)
call color('magenta')
call legpat(0,5,-1,-1,-1,3)
call color('white')		! text popisu, white = black pri scrmod('reverse')
call legend(legenda,3)


call disfin()

! ----------------------------------------------------
contains

subroutine CekejMS(msec)
    ! ceka "msec" milisekund
    integer,intent(in) :: msec
    integer,dimension(8) :: hdnt
    integer :: ms1,ms2

    call date_and_time(values=hdnt)
    ms1 = 3600000*hdnt(5)+60000*hdnt(6)+1000*hdnt(7)+hdnt(8)
    do 
        call date_and_time(values=hdnt)
		ms2 = 3600000*hdnt(5)+60000*hdnt(6)+1000*hdnt(7)+hdnt(8) 
        if (abs(ms2-ms1)>=msec) exit
    end do
end subroutine CekejMS
	

end program T_dislin3

!! Nastavene knihovny 
!! 
!!3:	-ldismgSP  NEBO   -ldismgDP (je-li use dislinDP) ;jsou v g:\g95\ModLib
!!4:	-luser32 -lgdi32 (jsou v adresari lib instalace g95)
!! Pozor !
!! Je-li pri linkovani nastavena -ldismgSP a vse ostatni je v DP,
!! nehlasi chybu, ale spusteny program maluje(?) nesmysly
!!