DataMuseum.dk

Presents historical artifacts from the history of:

ICL Comet 32

This is an automatic "excavation" of a thematic subset of
artifacts from Datamuseum.dk's BitArchive.

See our Wiki for more about ICL Comet 32

Excavated with: AutoArchaeologist - Free & Open Source Software.


top - metrics - download

⟦e7afe2dd9⟧ TextFile

    Length: 7111 (0x1bc7)
    Types: TextFile
    Notes: UNIX file
    Names: »transform.c«

Derivation

└─⟦26887b7e0⟧ Bits:30009717 Comet 32 harddisk image
    └─⟦28c352965⟧ »/a« UNIX Filesystem
        └─⟦this⟧ »usr/src/gks/gks/transform.c« 

TextFile

#include "../h/gks.h"
#include "../h/gksi.h"

Nrect ndc = {0.0,0.0,1.0,1.0};


#define IsntRect(REC) \
	isntrect((Real *)REC)

isntrect(r)
Real *r;
{	return ( r[0] >= r[2] || r[1] >= r[3] );
}

#define IsntRange(R1, R2) \
	isntrange((Real *)R1, (Real *)R2)

isntrange(r,s)
Real *r, *s;
{	return( s[0] > r[0] || s[1] > r[1] || 
		r[2] > s[2] || r[3] > s[3]  );
}

/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* s_window    - SET WINDOW.
*
* Input       - nt = transformation number.  Range: (1..n).
*               wr = window limits XMIN<XMAX, YMIN<YMAX.  Range: WC.
*               gks.gk_curnt = current normalization transformation.
*
* Process     - The window limits entry of the specified normalization
*               transformation in the GKS state list is set to the value
*               specified by the parameter.
*
* Output      - gks.gk_ntran = list of normalization transformations.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
s_window(nt, wr)
Int	nt;
Wrect	*wr;
{	static	char s_win[] = "s_window";

	ch_er_st(8, s_win);
	if ((nt < 1) || (nt > NO_NTRAN))
	{	rep_er(50, s_win);
		return;
	}
	if (IsntRect(wr))
	{	rep_er(51, s_win);
		return;
	}

	gks.gk_ntran[nt]->nt_wind = *wr;
	if(gks.gk_ntran[nt] == gks.gk_curnt)
		setcurntr(gks.gk_ntran[nt]);
}


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* s_viewport  - SET VIEWPORT.
*
* Input       - nt = transformation number.  Range: (1..n).
*               nr = viewport limits XMIN<XMAX, YMIN<YMAX.  Range: NDC.
*               gks.gk_curnt = current normalization transformation.
*               ndc = limits of NDC space.
*
* Process     - The viewport limits entry of the specified normalization
*               transformation in the GKS state list is set to the value
*               specivied by the parameter.
*
* Output      - gks.gk_ntran = list of normalization transformations.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
s_viewport(nt, nr)
Int	nt;
Nrect	*nr;
{	static	char s_vwp[] = "s_viewport";

	ch_er_st(8, s_vwp);
	if ((nt < 1) || (nt > NO_NTRAN))
	{	rep_er(50, s_vwp);
		return;
	}
	if(IsntRect(nr)) {
		rep_er(51, s_vwp);
		return;
	}
	if(IsntRange(nr, &ndc)) {
		rep_er(52, s_vwp);
		return;
	}
	gks.gk_ntran[nt]->nt_view = *nr;
	if(gks.gk_ntran[nt] == gks.gk_curnt)
		setcurntr(gks.gk_ntran[nt]);
}


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* s_cntran    - SELECT NORMALIZATION TRANSFORMATION.
*
* Input       - nt = transformation number.
*               gks.gk_curnt = current normalization transformation.
*               gks.gk_ntran = list of normalization transformations.
*
* Process     - The 'current normalization transformation number' entry
*               in the GKS state list is set to the value specified by
*               the parameter.
*
* Output      - gks.gk_curnt = current normalization transformation.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
s_cntran(nt)
Int	nt;
{	static	char sl_nt[] = "s_cntran";

	ch_er_st(8, sl_nt);
	if ((nt < 0) || (nt >= NO_NTRAN))
	{	rep_er(50, sl_nt);
		return;
	}

	if(gks.gk_curnt == gks.gk_ntran[nt]) return;
	else {	gks.gk_curnt = gks.gk_ntran[nt];
		setcurntr(gks.gk_ntran[nt]);
	}
}


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* s_clip      - SET CLIPPING INDICATOR.
*
* Input       - flg = clipping indicator.  Range: (TRUE, FALSE).
*               gks.gk_actv = list of active workstations.
*
* Process     - The 'clipping indicator' entry in the GKS state list
*               is set to the value specified by the parameter.
*
* Output      - gks.gk_clip = clipping indicator.
*               ws = current workstation state table.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
s_clip(flg)
Bool	flg;
{	ch_er_st(8, "s_clip");
	gks.gk_clip = flg;

	FORALLWS
		if ((ws = gks.gk_actv[i]) != NULL)
			(*ws->ws_wsd->wd_func.cli)(flg);
	ENDALLWS
}


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* s_w_wind    - SET WORKSTATION WINDOW.
*
* Input       - wsi = workstation identifier.
*               nr = workstation window limits XMIN<XMAX, YMIN<YMAX.
*                  Range: NDC.
*               gks.gk_opws = set of open workstations.
*               ndc = limits of NDC space.
*
* Process     - The 'requested workstation window' entry in the
*               workstation state list of the specified workstation is
*               set to the value specified by the parameter.
*
* Output      - ws = current workstation state list.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
s_w_wind(wsi, nr)
Wsi	wsi;
Nrect	*nr;
{	static	char s_wwi[] = "s_w_wind";
	Wss	*wst;

	ch_er_st(7, s_wwi);
	wst = (Wss *)wsi;

	/* Check for workstation open.*/
	FORALLWS
		if (gks.gk_opws[i] == wst)
			goto ok;
	ENDALLWS
	rep_er(25, s_wwi);
	return;

ok:	if(IsntRect(nr)) {
		rep_er(51, s_wwi);
		return;
	}
	if(IsntRange(nr, &ndc)) {
		rep_er(53, s_wwi);
		return;
	}

	ws = wst;
	(*ws->ws_wsd->wd_func.win)(nr);
}


/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* s_w_vprt    - SET WORKSTATION VIEWPORT.
*
* Input       - wsi = workstation identifier.
*               dr = workstation viewport limits XMIN<XMAX, YMIN<YMAX.
*                  Range: DC.
*               gks.gk_opws = set of open workstations.
*
* Process     - The 'requested workstation viewport' entry in the
*               workstation state list of the specified workstation is
*               set to the value specified by the parameter.
*
* Output      - ws = current workstation state list.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
s_w_vprt(wsi, dr)
Wsi	wsi;
Drect	*dr;
{	static	char s_wvp[] = "s_w_vprt";
	Wss	*wst;

	ch_er_st(7, s_wvp);
	wst = (Wss *)wsi;

	/* Check for workstation open.*/
	FORALLWS
		if (gks.gk_opws[i] == wst)
			goto ok;
	ENDALLWS
	rep_er(25, s_wvp);
	return;

ok:	if(IsntRect(dr)) {
		rep_er(51, s_wvp);
		return;
	}

	if (IsntRange(dr, &wst->ws_wsd->wd_dlim)) {
		rep_er(54, s_wvp);
		return;
	}

	ws = wst;
	(*ws->ws_wsd->wd_func.vie)(dr);
}


/* Normalization Transformation */
setcurntr(nt)
Ntran *nt;
{
	gks.curntr.xm = (nt->nt_view.n_ur.n_x - nt->nt_view.n_ll.n_x) /
			 (nt->nt_wind.w_ur.w_x - nt->nt_wind.w_ll.w_x);
	gks.curntr.ym = (nt->nt_view.n_ur.n_y - nt->nt_view.n_ll.n_y) /
			 (nt->nt_wind.w_ur.w_y - nt->nt_wind.w_ll.w_y);
	gks.curntr.xa = nt->nt_view.n_ll.n_x -
			 gks.curntr.xm * nt->nt_wind.w_ll.w_x;
	gks.curntr.ya = nt->nt_view.n_ll.n_y -
			 gks.curntr.ym * nt->nt_wind.w_ll.w_y;

	/* Set flag that says charht has to be recomputed.*/
	if (nt == gks.gk_curnt)
		gks.chng_attr = TRUE;

	/* Set clipping boundary in device.*/
	FORALLWS
		if ((ws = gks.gk_actv[i]) != NULL)
			(*ws->ws_wsd->wd_func.clp)(&(nt->nt_view));
	ENDALLWS
}

ntransf(p,q)
Wc *p;
Nc *q;
{
	q->n_x = p->w_x * gks.curntr.xm + gks.curntr.xa;
	q->n_y = p->w_y * gks.curntr.ym + gks.curntr.ya;
}

ntrany(p, q)
Real	*p, *q;
{	*q = *p * gks.curntr.ym;
}