-- XBandGraphicsImpl.mesa
-- Last changed by Pier, September 19, 1982 9:03 pm
-- Last Edited by: Stone, March 21, 1983 5:30 pm

DIRECTORY
KSpace,
CGBandGraphics,
CGBandDevice USING [New, Close],
CGDevice USING [Rep],
GraphicsBasic USING [DeviceRef],
Graphics,
JaMOps USING [defaultFrame],
JaMFnsDefs USING [Register],
TJaMGraphicsContexts USING [AddContext, RemoveContext];

XBandGraphicsImpl: PROGRAM
IMPORTS Graphics, CGBandDevice, JaMFnsDefs, TJaMGraphicsContexts, JaMOps, KSpace
EXPORTS CGBandGraphics = {
OPEN G: Graphics, J: JaMFnsDefs;

hornetRef: GraphicsBasic.DeviceRef←NIL;
platemakerRef: GraphicsBasic.DeviceRef←NIL;
screenRef: GraphicsBasic.DeviceRef←NIL;

DeviceObject: PUBLIC TYPE = CGDevice.Rep; -- export to GraphicsBasic
hornetdc: G.Context←NIL;
platemakerdc: G.Context←NIL;
screendc: G.Context←NIL;
dc: G.Context←NIL;
hornetbox, platemakerbox, screenbox: G.Box;


GetDC: PUBLIC PROCEDURE RETURNS[G.Context] = { RETURN[dc] };

CloseBands: PROCEDURE = {
noop: BOOLEANTRUE;
IF hornetRef#NIL THEN {
 CGBandDevice.Close[hornetRef];
 hornetRef←NIL;
 [] ← TJaMGraphicsContexts.RemoveContext[JaMOps.defaultFrame, $Hornet]};
IF platemakerRef#NIL THEN {
 CGBandDevice.Close[platemakerRef];
 platemakerRef←NIL;
 [] ← TJaMGraphicsContexts.RemoveContext[JaMOps.defaultFrame, $Platemaker]};
IF screenRef#NIL THEN {
 CGBandDevice.Close[screenRef];
 screenRef←NIL;
 [] ← TJaMGraphicsContexts.RemoveContext[JaMOps.defaultFrame, $Screen]};
};


HornetDC: PROCEDURE = {
KSpace.GetS[]; --reserve a contiguous space for AIS images
hornetRef ← CGBandDevice.New[hornet];--bands to Hornet
hornetdc ← G.NewContext[hornetRef];
hornetbox ← G.GetBounds[hornetdc];
G.ClipBox[hornetdc,hornetbox];
dc ← hornetdc;
KSpace.KillS[]; --return the reserved space
TJaMGraphicsContexts.AddContext[frame: JaMOps.defaultFrame, init: GetDC, name: $Hornet, enabled: TRUE, initOnErase: TRUE];
};

PlateMakerDC: PROCEDURE = {
KSpace.GetS[]; --reserve a contiguous space for AIS images
platemakerRef ← CGBandDevice.New[platemaker];--bands to PlateMakerDC
platemakerdc ← G.NewContext[platemakerRef];
platemakerbox ← G.GetBounds[platemakerdc];
G.ClipBox[platemakerdc,platemakerbox];
dc ← platemakerdc;
KSpace.KillS[]; --return the reserved space
TJaMGraphicsContexts.AddContext[frame: JaMOps.defaultFrame, init: GetDC, name: $Platemaker, enabled: TRUE, initOnErase: TRUE];
};

ScreenDC: PROCEDURE = { --bands to files to (eventually) screen OR checkplot
screenRef ← CGBandDevice.New[screen];
screendc ← G.NewContext[screenRef];
screenbox ← G.GetBounds[screendc];
G.ClipBox[screendc,screenbox];
dc ← screendc;
TJaMGraphicsContexts.AddContext[frame: JaMOps.defaultFrame, init: GetDC, name: $Screen, enabled: TRUE, initOnErase: TRUE];
};


-- Initialization starts here

J.Register[".hornetdc"L,HornetDC];
J.Register[".platemakerdc"L,PlateMakerDC];
J.Register[".screendc"L,ScreenDC];
J.Register[".closebands"L,CloseBands];

}.

LOG

Removed checkplot facility for Cedar 3.2, July 13, 1982