|
|
DataMuseum.dkPresents historical artifacts from the history of: ICL Comet 32 |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about ICL Comet 32 Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - metrics - download
Length: 15134 (0x3b1e)
Types: TextFile
Notes: UNIX file
Names: »control.c«
└─⟦26887b7e0⟧ Bits:30009717 Comet 32 harddisk image
└─⟦28c352965⟧ »/a« UNIX Filesystem
└─⟦this⟧ »usr/src/gks/gks/control.c«
#include "../h/gks.h"
#include "../h/gksi.h"
#include "../h/comet.h"
GksState gksst = GKCL;
Gks gks;
Wss *ws; /* Current workstation state table.*/
/* ???The preceeding three declarations apparently override previous
external ones in gks.h and vdi.h.*/
Ntran nttab[NO_NTRAN];
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* open_gks - OPEN GKS.
*
* Process - GKS is set into the operating state GKOP = "GKS open".
* The GKS state list is initialised.
*
* Output gks = GKS state list. All values in this list are
* initialized to their default values.
* gksst = GKS operating state.
*
* Comments - The GKS state list is allocated at compile time, so no
* allocation is necessary here. The workstation
* description tables are always available by doing a
* "#include", so no action is needed to make them
* available.
*
* The error file is always stderr, so no entry 'error
* file' is needed in the GKS error state list. The
* permitted buffer area which can be used by GKS for
* internal purposes is not relevant in this implementation,
* since no dynamic memory management is done.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
open_gks()
{ Int j;
static Wrect wr = {0.0,0.0,1.0,1.0};
static Nrect nr = {0.0,0.0,1.0,1.0};
ch_er_st(1, "open_gks");
gksst = GKOP;
FORALLWS
{ gks.gk_opws[i] = NULL; /* Set of open workstations.*/
gks.gk_actv[i] = NULL; /* Set of active workstations.*/
}
ENDALLWS
for (j = 0; j < NO_NTRAN; j++) /* List of transformations:*/
{ gks.gk_ntran[j] = &nttab[j];
gks.gk_ntran[j]->nt_wind = wr; /* list of windows,*/
gks.gk_ntran[j]->nt_view = nr; /* list of viewports.*/
}
gks.gk_curnt = gks.gk_ntran[0]; /* Current normalization tran.*/
gks.gk_clip = TRUE; /* Clipping indicator.*/
gks.gk_lr_lt = 1; /* Current linetype.*/
gks.gk_lr_ci = 1; /* Current polyline colour index.*/
gks.gk_mr_mt = 1; /* Current marker type.*/
gks.gk_mr_ci = 1; /* Current polymarker colour index.*/
gks.gk_tx_ci = 1; /* Current text colour index.*/
gks.gk_chht = 0.01; /* Current character height.*/
gks.gk_chup.w_x = 0.0; /* Current character up vector.*/
gks.gk_chup.w_y = 1.0;
gks.gk_tx_ha = LEFT; /* Current text alignment, horizontal.*/
gks.gk_tx_va = BASE; /* Current text alignment, vertical.*/
gks.gk_tx_pa = RRIGHT; /* Current text path.*/
gks.gk_fa_is = HOLLOW; /* Current fill area interior style.*/
gks.gk_fa_ci = 1; /* Current fill area colour index.*/
gks.chng_attr = FALSE; /* Update charht at next text call.*/
gks.curntr.xm = 1.0; /* Current normalization trans. x mult.*/
gks.curntr.xa = 0.0; /* Current normalization trans. x add.*/
gks.curntr.ym = 1.0; /* Current normalization trans. y mult.*/
gks.curntr.ya = 0.0; /* Current normalization trans. y add.*/
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* clos_gks - CLOSE GKS.
*
* Input -
*
* Process - GKS is set into the operating state GKCL = "GKS closed".
*
* Output - gksst = GKS operating state.
*
* Comments - The GKS state list is allocated at compile time, so it
* can't be made unavailable. The workstation description
* tables are always available by doing a "#include", so
* they can't be made unavailable. There are no GKS
* buffers to release or GKS files to close.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
clos_gks()
{ ch_er_st(2, "clos_gks");
gksst = GKCL;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* open_ws - OPEN WORKSTATION.
*
*
* Input - wstyp = workstation type. Range: 1.
* gks.gk_opws = set of open workstations.
* gksst = GKS operating state.
*
* Process - If GKS is in operating state GKOP, it will be set into
* the state WSOP = "at least one workstation open". GKS
* requests the operating system to establish the specified
* connection for a workstation characterized in the
* workstation description table by the 'workstation type'.
* The workstation state list is initialised. The
* workstation identifier is added to the set of open
* workstations in the GKS state list.
*
* OPEN WORKSTAION ensures that the display surface is
* clear, but does not clear the surface needlessly.
*
* Output - Returns a workstation identifier, which is really a
* pointer to the workstation state list.
* gksst = GKS operating state.
* gks.gk_opws = set of open workstations.
*
* Comments - The workstation state list is allocated at compile time,
* so no allocation is necessary here.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
Wsi
open_ws(wstyp)
Dtype wstyp;
{ Wss *wst;
Wsd *wsd;
static char o_ws[] = "open_ws";
ch_er_st(8, o_ws);
/* Check for supported workstation type.*/
if((wsd = getwsd(wstyp)) == NULL)
{ rep_er(23, o_ws);
return (NULL);
}
/* Find a place for this workstation in the list of open ones.*/
FORALLWS
if (gks.gk_opws[i] == NULL)
{ if (gksst == GKOP) gksst = WSOP;
/* Call device dependent open workstation.*/
wst = (Wss *)((*wsd->wd_func.ope)(wsd));
if (wst == NULL)
break;
gks.gk_opws[i] = wst;
return ((Wsi)wst);
}
ENDALLWS
rep_er(26, o_ws);
return (NULL);
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* clos_ws - CLOSE WORKSTAITON.
*
*
* Input - wsi = workstation identifier.
* gks.gk_opws = set of open workstations.
* gks.gk_actv = set of active workstations.
*
* Process - An implicit UPDATE WORKSTATION is performed for the
* specified workstation. The workstation identifier is
* deleted from the set of open workstations in the GKS
* state list.
*
* The connection to the workstation is released. GKS is
* set into operating state GKOP if no workstations remain
* open. The display surface need not be cleared when
* CLOSE WORKSTATION is invoked, but it may be cleared.
*
* Output - gks.gk_opws = set of open workstations.
* gksst = GKS operating state.
* ws = current workstation state list.
*
* Comments - The workstation state list is allocated at compile time,
* so it can't be cancelled.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
clos_ws(wsi)
Wsi wsi;
{ static char c_ws[] = "clos_ws";
Wss *wst;
ch_er_st(7, c_ws);
wst = (Wss *)wsi;
/* Check for valid workstation identifier.*/
if (wst == NULL)
{ rep_er(20, c_ws);
return;
}
/* Check for workstation active.*/
FORALLWS
if (gks.gk_actv[i] == wst)
{ rep_er(29, c_ws);
return;
}
ENDALLWS
/* Check for workstation open.*/
FORALLWS
if (gks.gk_opws[i] == wst)
{ gks.gk_opws[i] = NULL;
goto ok;
}
ENDALLWS
rep_er(25, c_ws);
return;
/* Call device dependent close workstation.*/
ok: ws = wst;
(*ws->ws_wsd->wd_func.clo)();
/* Check for any workstation open, and change state if this was the
last one closed.*/
FORALLWS
if (gks.gk_opws[i] != NULL)
return;
ENDALLWS
gksst = GKOP;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* activate - ACTIVATE WORKSTATION.
*
*
* Input - wsi = workstation identifier.
* gks.gk_opws = set of open workstations.
* gks.gk_actv = set of active workstations.
*
* Process - GKS is set into the operating state WSAC = "At least
* one workstation active". The workstation identifier
* is added to the set of active workstations in the GKS
* state list.
*
* Output - gksst = GKS operating state.
* gks.gk_actv = set of active workstations.
* ws = current workstation state list.
*
* Comments - Output primitives are sent to all active workstations.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
activate(wsi)
Wsi wsi;
{ static char ac_ws[] = "activate";
Wss *wst;
ch_er_st(6, ac_ws);
wst = (Wss *)wsi;
/* Check for valid workstation identifier.*/
if (wst == NULL)
{ rep_er(20, ac_ws);
return;
}
/* Check for workstation open.*/
FORALLWS
if (gks.gk_opws[i] == wst)
goto ok;
ENDALLWS
rep_er(25, ac_ws);
return;
/* Check for workstation active.*/
ok: FORALLWS
if (gks.gk_actv[i] == wst)
{ rep_er(29, ac_ws);
return;
}
ENDALLWS
/* Find a place for this workstation in the list of active ones.*/
FORALLWS
if (gks.gk_actv[i] == NULL)
{ gks.gk_actv[i] = wst;
break;
}
ENDALLWS
ws = wst;
gksst = WSAC;
#if DBG > 0
printf("activate called\n");
#endif
/* Initialize attributes at the workstation.*/
(*ws->ws_wsd->wd_func.ltp)(gks.gk_lr_lt);
(*ws->ws_wsd->wd_func.lco)(gks.gk_lr_ci);
(*ws->ws_wsd->wd_func.mtp)(gks.gk_mr_mt);
(*ws->ws_wsd->wd_func.mco)(gks.gk_mr_ci);
(*ws->ws_wsd->wd_func.tco)(gks.gk_tx_ci);
(*ws->ws_wsd->wd_func.cht)(gks.gk_chht);
(*ws->ws_wsd->wd_func.cal)(gks.gk_tx_ha, gks.gk_tx_va);
(*ws->ws_wsd->wd_func.tpa)(gks.gk_tx_pa);
(*ws->ws_wsd->wd_func.fis)(gks.gk_fa_is);
(*ws->ws_wsd->wd_func.fco)(gks.gk_fa_ci);
(*ws->ws_wsd->wd_func.cli)(gks.gk_clip);
(*ws->ws_wsd->wd_func.clp)(&(gks.gk_curnt->nt_view));
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* deactivate - DEACTIVATE WORKSTATION.
*
* Input - wsi = workstation identifier.
* gks.gk_actv = set of active workstations.
*
* Process - The workstation identifier is deleted from the set of
* active workstations in the GKS state list. GKS is set
* into the operating state WSOP = "At least one
* workstation open" if no workstation remains active.
*
* Output - gksst = GKS operating state.
* gks.gk_actv = set of active workstations.
*
* Comments - Primitives will no longer be sent to this workstation.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
deactivate(wsi)
Wsi wsi;
{ static char de_ws[] = "deactivate";
Wss *wst;
ch_er_st(3, de_ws);
wst = (Wss *)wsi;
/* Check for valid workstation identifier.*/
if (wst == NULL)
{ rep_er(20, de_ws);
return;
}
/* Find workstation in active list.*/
FORALLWS
if (gks.gk_actv[i] == wst)
{ gks.gk_actv[i] = NULL;
goto ok;
}
ENDALLWS
/* Workstation not active, report error.*/
rep_er(30, de_ws);
/* Check for any workstation active, and change state if this was the
last one deactivated.*/
ok: FORALLWS
if (gks.gk_actv[i] != NULL)
return;
ENDALLWS
gksst = WSOP;
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* clear - CLEAR WORKSTATION.
*
* Input - wsi = workstation identifier.
* cf = control flag. Range: (CONDITIONALLY, ALWAYS).
* gks.gk_opws = set of open workstations.
*
* Process - All of the following actions are executed in the given
* sequence:
* a) All deferred actions for the specified workstation
* are executed (without intermediate clearing of the
* display surface).
* b) The display surface is set to a clear state according
* to the control flag as follows:
* CONDITIONALLY:
* The display surface is cleared only if the 'display
* surface empty' entry in the workstation's state
* list is NOTEMPTY.
* ALWAYS:
* the display surface is cleared.
* c) The switch 'new frame action necessary at update' in
* the workstation state list is set to NO.
* d) The switch 'display surface empty' in the workstation
* state list is set to EMPTY.
*
* Output - ws = current workstation state list.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
clear(wsi, cf)
Wsi wsi;
Clearf cf; /* Control flag.*/
{ static char cl_ws[] = "clear";
Wss *wst;
ch_er_st(6, cl_ws);
wst = (Wss *)wsi;
/* Check for valid workstation identifier.*/
if (wst == NULL)
{ rep_er(20, cl_ws);
return;
}
/* Check for workstation open.*/
FORALLWS
if (gks.gk_opws[i] == wst)
goto ok;
ENDALLWS
rep_er(25, cl_ws);
return;
/* Call device dependent clear workstation.*/
ok: ws = wst;
(*ws->ws_wsd->wd_func.cle)(cf);
}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
*
* update - UPDATE WORKSTATION.
*
* Input - wsi = workstation identifier.
* rf = regeneration flag. Range: (PERFORM, SUPPRESS).
*
* Process - All deferred actions for the specified workstation are
* executed (without intermediate clearing of the display
* surface).
*
* If the regeneration flag is set to PERFORM and the "new
* frame action necessary at update" entry in the
* workstation's state list is YES, then the following
* actions are executed in the sequence given:
* a) The display surface is cleared only if the "display
* surface empty" entry in the workstation's state list
* is NOT EMPTY. The entry is set to EMPTY.
* b) If the "workstation transformation update state"
* entry in the workstation's state list is PENDING,
* the "current workstation window" and "current
* workstation viewport" entries in the workstation's
* state list are assigned toe values of the "requested
* workstation window" and "requested workstation
* viewport" entries; the "workstation transformation
* update state" entry is set to NOT PENDING.
* c) The switch "new frame action necessary at update" in
* the workstation state list is set to NO.
*
* Output - ws = current workstation state list.
*
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
update(wsi, rf)
Wsi wsi;
Regenf rf;
{ static char up_ws[] = "update";
Wss *wst;
ch_er_st(7, up_ws);
wst = (Wss *)wsi;
/* Check for valid workstation identifier.*/
if (wst == NULL)
{ rep_er(20, up_ws);
return;
}
/* Check for workstation open.*/
FORALLWS
if (gks.gk_opws[i] == wst)
goto ok;
ENDALLWS
rep_er(25, up_ws);
return;
/* Call device dependent update workstation.*/
ok: ws = wst;
(*ws->ws_wsd->wd_func.upd)(rf);
}
/* Convert Dtype to Wsd *.*/
Wsd *
getwsd(wstyp)
Dtype wstyp;
{ /* Check for supported workstation type.*/
switch((int)wstyp)
{
case C32:
return(&COMET);
default:
return(NULL);
}
}