--BandsClientImpl.mesa
--Last Edited by Pier, October 26, 1982 12:54 pm
-- Last Edited by Eric Bier on October 12, 1982 6:15 pm

DIRECTORY

BandsClient,
CGBrick,
CGDevice,
CGBandDevice,
CopyBands,
GraphicsBasic,
Graphics,
GraphicsOps,
IO,
MessageWindow,
Rope,
System,
Time;

BandsClientImpl: PROGRAM
IMPORTS CGBrick, Graphics, CGBandDevice, CopyBands, GraphicsOps, IO, MessageWindow, Time
EXPORTS GraphicsBasic, BandsClient = {

DeviceObject: PUBLIC TYPE = CGDevice.Rep; -- exported to GraphicsBasic
Device: TYPE = CGDevice.Ref;
DeviceType: TYPE = CGBandDevice.BandDevice;
Separation: TYPE = CGBandDevice.Separation;

SetUpBrick: PUBLIC PROC [freq: REAL, angle: REAL, filter: PROC[x,y:REAL]
RETURNS [fvalue: REAL]] = {
CGBrick.currentBrick^ ← CGBrick.BuildBrick[freq, angle, filter];
};

OpenBands: PUBLIC PROC[bandD: DeviceType]
RETURNS [dc: Graphics.Context, device: Device] = {

box: Graphics.Box;
device ← CGBandDevice.New[bandD];
dc ← Graphics.NewContext[device];
box ← Graphics.GetBounds[dc];
Graphics.ClipBox[dc, box];
}; --OpenBands


CloseBands: PUBLIC PROC[device: Device, bandD: DeviceType] = {

CGBandDevice.Close[device];
ConcatBands[bandD];
};

CloseBandsNoConcat: PUBLIC PROC[device: Device, bandD: DeviceType] = {
 CGBandDevice.Close[device];
 };

ConcatBands: PUBLIC PROC[bandD: DeviceType] = {

SELECT bandD FROM
hornet => CopyBands.Copy[16];
platemaker => CopyBands.Copy[72];
ENDCASE => NULL;
};

Tentfilter: PROC [x,y: REAL] RETURNS [val: REAL] = {
RETURN [1.0-ABS[x]];
};

SetUpSeparation: PUBLIC PROC [s: Separation, filter: PROC[x,y:REAL] RETURNS [fvalue: REAL]] = {
angle: REAL;
CGBandDevice.SetSeparation[s];
angle ← SELECT s FROM
red =>75,
green => 105,
blue => 90,
none => 20,
ENDCASE => ERROR;
SetUpBrick[freq: 10, angle: angle, filter: filter];
};

AISBands: PUBLIC PROC [x, y: REAL, aisName: Rope.ROPE, bandD: DeviceType, s: Separation] = {
 dc: Graphics.Context;
 device: Device;
 ais: Graphics.ImageRef;
 timeStream: IO.STREAM;
 timeRope: Rope.ROPE;
 startTime, endTime: System.GreenwichMeanTime;
 totalTime: LONG CARDINAL;
 startTime ← Time.Current[];
  ais ← GraphicsOps.NewAisImage[aisName];
  SetUpSeparation[s, Tentfilter];
  [dc, device] ← OpenBands[bandD];
  Graphics.SetCP[dc, x, y];
  Graphics.DrawImage[dc, ais];
  CloseBands[device, bandD];
 endTime ← Time.Current[];
 totalTime ← endTime - startTime;
 timeStream ← IO.CreateOutputStreamToRope[];
 timeStream.PutF["AISBands took (%r) for %g",[cardinal[totalTime]], [rope[aisName]]];
 timeRope ← timeStream.GetOutputStreamRope[];
 MessageWindow.Append[timeRope, TRUE];
 }; -- end of AISBands

AISBandsNoConcat: PUBLIC PROC [x, y: REAL, aisName: Rope.ROPE, bandD: DeviceType, s: Separation] = {
 dc: Graphics.Context;
 device: Device;
 ais: Graphics.ImageRef;
 timeStream: IO.STREAM;
 timeRope: Rope.ROPE;
 startTime, endTime: System.GreenwichMeanTime;
 totalTime: LONG CARDINAL;
 startTime ← Time.Current[];
  ais ← GraphicsOps.NewAisImage[aisName];
  SetUpSeparation[s, Tentfilter];
  [dc, device] ← OpenBands[bandD];
  Graphics.SetCP[dc, x, y];
  Graphics.DrawImage[dc, ais];
  CloseBandsNoConcat[device, bandD];
 endTime ← Time.Current[];
 totalTime ← endTime - startTime;
 timeStream ← IO.CreateOutputStreamToRope[];
 timeStream.PutF["AISBands took (%r) for %g",[cardinal[totalTime]], [rope[aisName]]];
 timeRope ← timeStream.GetOutputStreamRope[];
 MessageWindow.Append[timeRope, TRUE];
 }; -- end of AISBandsNoCopy



}.

Log
Bier on October 11, 1982 11:00 am --
AISBands records the amount of time needed to make BANDS from the ais file and prints this out to the MessageWindow.

Bier on October 12, 1982 6:15 pm --
Added CloseBandsNoConcat and AISBandsNoConcat