Opis nabora ukazov emulacije GKS na
PC racunalnikih
Tomaz Kolsek, LECAD 1997
1.
GOPKS( ) ... preklop na graficni nacin dela
GCLKS( ) ... preklop na tekstovni nacin
2.
GSWN(TRN,xu1,yu1,xu2,yu2)
Nastavitev uporabniskega koordinatnega sistema (polozaja
izhodisca in velikosti enot)
TRN ... integer, Transformation Number (v emulaciji slepi arg.)
xu1, yu1, xu2, yu2 ... real
3.
GSWKVP(WKID, ix1, iy1, ix2, iy2)
Nastavitev polozaja in velikosti graficnega okna
WKID ... integer, Work Station Identifier (v emulaciji slepi arg.)
ix1, iy1, ix2, iy2 ... integer
(za VGA grafiko so parametri za pokritje celotnega zaslona ix1min=
0, iy1min=0, ix2max=639, iy2max=479 )
Primer: Zahtevajmo, da se bo grafika izrisovala na pravokotnem delu zaslona, ki ima
- spodnji levi vogal oddaljen 100 pixlov
od levega roba zaslona in 120 pixlov od spodnjega roba zaslona
- ter zgornji desni vogal oddaljen 500 pixlov od levega roba zaslona in 400 pixlov oddaljen od spodnjega roba zaslona
- koordinate tako definiranega okna pa so (-100, -40) spodnji levi vogal in
(200,150) zgornji desni vogal
CALL GSWN( -100.0, -40.0, 200.0, 150.0)
CALL GSWKVP( 100, 120, 500, 400)
4.
GPL(n, xp, yp) ... izris crtovja (poligona)
n ... integer ... stevilo tock v crtovju (za izris ene crte sta potrebni
dve tocki)
xp ... real(n) ... polje z vsaj n elementi, ki predstavljajo x-koordinate tock
yp ... real(n) ... polje z vsaj n elementi, ki predstavljajo y-koordinate tock
Primer dela kode v FORTRAN-u za izris pravokotnika:
TX(1) = -200.0
TX(2) = +200.0
TX(3) = TX(2)
TX(4) = TX(1)
TX(5) = TX(1)
TY(1) = -300.0
TY(2) = TY(1)
TY(3) = +300.0
TY(4) = TY(3)
TY(5) = TY(1)
CALL GPL(5, TX, TY)
,hr>
5.
GDP(n, px, py, ID, ldr, datrec)
...Generalized Drawing Primitive
n ... integer, stevilo tock v px,py (v emul. slepi arg.)
px,py ... real(3), x- in y-koordinate tock
ID ... integer, Primitive Identifier (-1 = krog,-2 = lok za emulacijo)
ldr ... integer, lenght of data record (v emul. slepi arg.)
datrec ... caharcter*80, datarecord
Primer dela kode v FORTRAN-u za
izris kroga s srediscem v
(100.0,100.0) in tocko na kroznici
(130.0, 140.0) (radij= 50.0):
PX(1) = 100.
PX(2) = 130.
PY(1) = 100.
PY(2) = 140.
CALL GDP(2, PX, PZ, -1, 1, ' ')
Primer dela kode v FORTRAN-u za izris loka s srediscem v
(10.0,10.0), zacetkom v (30.0, 10.0) in koncem v (10.0, 30.0)
(radij = 20.0):
PX(1) = 10.
PX(2) = 30.
PX(3) = 10.
PY(1) = 10.
PY(2) = 10.
PY(3) = 30.
CALL GDP(2, PX, PZ, -2, 1, ' ')
6.
GSPLCI(n) ... nastavitev barve za crte
n ... integer, indeks barve
Barvna tabela za VGA (16 color) :
0 = crna, 1 = modra, 2 = zelena, 3 = sinja (cyan), 4 = rdeca,
5 = vijolicna, 6 = rjava/oranzna, 7 = svetlo siva, 8 = temno
siva, 9 = poudarjeno modra, 10 = poudarjeno zelena, 11 =
poudarjeno sinja, 12 = poudarjeno rdeca, 13 = poudarjeno
vijolicna, 14 = rumena, 15 = bela, 16 = crna
7.
GTX(x,y, text) ... izpis teksta
x,y ... real, polozaj teksta
text ... Character*80
8.
GSTXCI( n ) ... nastavitev barve za tekst
n ... integer, barvni indeks, glej barvno tabelo
9.
GSCHH( n ) ... nastavitev velikosti znakov za
tekst
n ... integer ( vrednosti od 5 ... 99 )
10.
GCLS( ) ... nestandardni ukaz, brise celotno
grafiko na zaslonu
Primer izvorne kode v FORTRAN-u, ki uporablja nabor ukazov iz
emulacije knjiznice GKS:
program IPROFIL
real p(100,2)
integer n
real h,b,tp,ts
call podaj_dimenzije_profila(h,b,tp,ts)
call doloci_robne_tocke(h,b,tp,ts,p,n)
c --- odpre GKS ( zacne z graficnim nacinom dela )
call gopks()
c--- nastavitev work station view port
call gswkvp(1,0,0,639,479)
r = 480./640.
c --- nastavitev uporabniskega koordinatnega sistema
call gswn(1,-h*0.75,-h*0.75*r,+h*0.75,h*0.75*r)
c--- izris lika ( I profila )
call izris(p)
c--- izpis oznak
call oznaci(p,n,h,b,ts,tp)
c--- zapre GKS (zakljuci z graficnim nacinom dela
call gclks()
end
******************************************
subroutine podaj_dimenzije_profila(h,b,tp,ts)
real h,b,tp,ts
* print *, 'Podaj h,b,tp,ts profila I : '
* read *, h,b,tp,ts
h=120.
b=60.
tp = 10.
ts = 7.
end
c ****************************************************
subroutine doloci_robne_tocke(h,b,tp,ts,p,n)
real h,b,tp,ts,p(100,2)
integer n
c --- stevilo tock I profila = 16
c --- koordinatni sistem izberem v sredini profila
n=16
p(1,1) = -b/2
p(1,2) = +h/2
p(2,1) = -p(1,1)
p(2,2) = p(1,2)
p(3,1) = p(2,1)-tp
p(3,2) = p(2,2)-tp
p(4,1) = ts
p(4,2) = p(3,2)
p(5,1) = ts/2
p(5,2) = p(4,2)-ts/2
p(6,1) = p(5,1)
p(6,2) = -p(5,2)
p(7,1) = p(4,1)
p(7,2) = -p(4,2)
p(8,1) = p(3,1)
p(8,2) = -p(3,2)
p(9,1) = p(2,1)
p(9,2) = -p(2,2)
p(10,1) = -p(9,1)
p(10,2) = p(9,2)
p(11,1) = -p(8,1)
p(11,2) = p(8,2)
p(12,1) = -p(7,1)
p(12,2) = p(7,2)
p(13,1) = -p(6,1)
p(13,2) = p(6,2)
p(14,1) = -p(5,1)
p(14,2) = p(5,2)
p(15,1) = -p(4,1)
p(15,2) = p(4,2)
p(16,1) = -p(3,1)
p(16,2) = p(3,2)
end
****************************************
subroutine izris(p)
real p(100,2)
real x(10), y(10)
call gsplci(11)
x(1) = p(1,1)
y(1) = p(1,2)
x(2) = p(2,1)
y(2) = p(2,2)
call gpl(2,x,y)
x(1) = p(3,1)
y(1) = p(2,2)
x(2) = p(3,1)
y(2) = p(3,2)
x(3) = p(2,1)
y(3) = p(2,2)
call gdp(3,x,y, -2,1,' ')
x(1) = p(3,1)
y(1) = p(3,2)
x(2) = p(4,1)
y(2) = p(4,2)
call gpl(2,x,y)
x(1) = p(4,1)
y(1) = p(5,2)
x(2) = p(4,1)
y(2) = p(4,2)
x(3) = p(5,1)
y(3) = p(5,2)
call gdp(3,x,y, -2,1,' ')
x(1) = p(5,1)
y(1) = p(5,2)
x(2) = p(6,1)
y(2) = p(6,2)
call gpl(2,x,y)
x(1) = p(7,1)
y(1) = p(6,2)
x(2) = p(6,1)
y(2) = p(6,2)
x(3) = p(7,1)
y(3) = p(7,2)
call gdp(3,x,y, -2,1,' ')
x(1) = p(7,1)
y(1) = p(7,2)
x(2) = p(8,1)
y(2) = p(8,2)
call gpl(2,x,y)
x(1) = p(8,1)
y(1) = p(9,2)
x(2) = p(9,1)
y(2) = p(9,2)
x(3) = p(8,1)
y(3) = p(8,2)
call gdp(3,x,y, -2,1,' ')
x(1) = p(9,1)
y(1) = p(9,2)
x(2) = p(10,1)
y(2) = p(10,2)
call gpl(2,x,y)
x(1) = p(11,1)
y(1) = p(10,2)
x(2) = p(11,1)
y(2) = p(11,2)
x(3) = p(10,1)
y(3) = p(10,2)
call gdp(3,x,y, -2,1,' ')
x(1) = p(11,1)
y(1) = p(11,2)
x(2) = p(12,1)
y(2) = p(12,2)
call gpl(2,x,y)
x(1) = p(12,1)
y(1) = p(13,2)
x(2) = p(12,1)
y(2) = p(12,2)
x(3) = p(13,1)
y(3) = p(13,2)
call gdp(3,x,y, -2,1,' ')
x(1) = p(13,1)
y(1) = p(13,2)
x(2) = p(14,1)
y(2) = p(14,2)
call gpl(2,x,y)
x(1) = p(15,1)
y(1) = p(14,2)
x(2) = p(14,1)
y(2) = p(14,2)
x(3) = p(15,1)
y(3) = p(15,2)
call gdp(3,x,y, -2,1,' ')
x(1) = p(15,1)
y(1) = p(15,2)
x(2) = p(16,1)
y(2) = p(16,2)
call gpl(2,x,y)
x(1) = p(16,1)
y(1) = p(1,2)
x(2) = p(1,1)
y(2) = p(1,2)
x(3) = p(16,1)
y(3) = p(16,2)
call gdp(3,x,y, -2,1,' ')
return
end
c ********************************************
subroutine oznaci(p,n,h,b,ts,tp)
real p(100,2)
integer n
character*80 text
real x(3),y(3)
call gstxci(14)
call gschh(10)
do i=1,n
write(text,'(i2)') i
call gtx(p(i,1),p(i,2),text)
enddo
call gstxci(12)
call gschh(50)
call gtx(-h/2,0.,'LECAD')
call gsplci(13)
x(1) = -h/2.+h*0.75*50.*0.6/320.*2.6
y(1) = 0.-0.5*h*0.75*50./320.
x(2) = -h/2.
y(2) = 0.
call gdp(2,x,y, -1,1,' ')
call gstxci(10)
call gschh(15)
write(text,'('' H ='',f6.1,'', B ='',f5.1)') h,b
call gtx(b/4,0.,text)
write(text,'('' tp = '',f4.1,'', ts = '',f4.1)') ts,tp
call gtx(b/4,-h/6,text)
return
end
c **********************************************