FitIOJaM.mesa
Last Edited by Maureen Stone July 2, 1984 2:16:35 pm PDT
Last Edited by Michael Plass December 7, 1982 10:25 am
Last Edited by: Stone, November 21, 1983 11:33 am
DIRECTORY
FitState,
FitIO,
FitJaM,
FitBasic USING [Handle],
Cubic,
Complex,
IO,
BasicTime, --used implicitly by IO.time
FS,
JaMImager USING [Painter],
JaM,
Imager,
Real,
Rope USING [ROPE, Length],
Seq,
Vector;
FitIOJaM:
CEDAR
PROGRAM
IMPORTS JaMImager, JaM, IO, FS, Rope, FitIO, FitJaM
EXPORTS =
BEGIN OPEN FitState;
all: BOOLEAN ← FALSE;
fill: BOOLEAN ← FALSE;
State: TYPE = JaM.State;
DrawSamples:
PROC[state: State]= {
Paint:
PROC[dc: Imager.Context] = {
FitJaM.defaultFitIO.imager ← dc;
FitIO.SetContext[FitJaM.defaultFitIO];
FitIO.DrawSamples[handle: FitJaM.defaultFitState, all: all, fill: fill];
};
JaMImager.Painter[Paint,state];
};
MarkSamples:
PROC[state: State]= {
Paint:
PROC[dc: Imager.Context] = {
FitJaM.defaultFitIO.imager ← dc;
FitIO.SetContext[FitJaM.defaultFitIO];
FitIO.MarkSamples[FitJaM.defaultFitState, all];
};
JaMImager.Painter[Paint,state];
MarkNodes:
PROC[state: State] = {
Paint:
PROC[dc: Imager.Context] = {
FitJaM.defaultFitIO.imager ← dc;
FitIO.SetContext[FitJaM.defaultFitIO];
FitIO.MarkNodes[FitJaM.defaultFitState, all];
};
JaMImager.Painter[Paint,state];
};
MarkLinks:
PROC[state: State] = {
Paint:
PROC[dc: Imager.Context] = {
FitJaM.defaultFitIO.imager ← dc;
FitIO.SetContext[FitJaM.defaultFitIO];
FitIO.MarkJoints[FitJaM.defaultFitState, all];
};
JaMImager.Painter[Paint,state];
};
DrawLinks:
PROC[state: JaM.State] = {
Paint:
PROC[dc: Imager.Context] = {
FitJaM.defaultFitIO.imager ← dc;
FitIO.SetContext[FitJaM.defaultFitIO];
FitIO.DrawContour[FitJaM.defaultFitState, all, fill];
};
JaMImager.Painter[Paint,state];
};
SetMarkSize:
PROC[state: JaM.State] = {
FitJaM.defaultFitIO.feedback.sampleSize ← JaM.PopReal[state];
};
SetScale:
PROC[state: JaM.State] = {
FitIO.SetContext[FitJaM.defaultFitIO];
FitIO.MagnifyData[JaM.PopReal[state]];
};
SetOffset:
PROC[state: JaM.State] = {
y: REAL ← JaM.PopReal[state];
x: REAL ← JaM.PopReal[state];
FitIO.SetContext[FitJaM.defaultFitIO];
FitIO.PositionData[[x,y]];
};
SetFill: PROC[state: State] = {fill ← JaM.PopBool[state]};
OpenLogFile:
PROC[state: State] = {
rope: Rope.ROPE ← JaM.PopRope[state];
stream: IO.STREAM;
IF rope.Length[] > 0 THEN stream ← FS.StreamOpen[rope, append];
FitIO.SetContext[FitJaM.defaultFitIO];
FitIO.StartLog[stream];
};
CloseLogFile:
PROC[state: State] = {
FitIO.SetContext[FitJaM.defaultFitIO];
FitIO.StopLog[close: TRUE];
};
SetTypescript:
PROC[state: State] = {
IF JaM.PopBool[state]
THEN {
FitIO.SetContext[FitJaM.defaultFitIO];
FitIO.StartLog[! FitIO.NoLog =>
JaM.ExecuteRope[state, "(no log file) .print" ! JaM.Stop => CONTINUE]];
};
};
Note:
PROC[state: State] = {
c: Rope.ROPE ← JaM.PopRope[state];
IF FitJaM.defaultFitIO.logActions THEN PrintRope[c];
};
Notes:
PROC[state: State] = {
c: Rope.ROPE ← JaM.PopRope[state];
IF FitJaM.defaultFitIO.logActions THEN {PrintRope[c]; PrintRope[" "]};
};
Noter:
PROC[state: State] = {
c: Rope.ROPE ← JaM.PopRope[state];
IF FitJaM.defaultFitIO.logActions THEN {PrintLine[c]; FitJaM.defaultFitIO.log.Flush[]};
};
Time:
PROC[state: State] = {
IF FitJaM.defaultFitIO.logActions THEN {IO.Put[FitJaM.defaultFitIO.log,IO.time[]]; FitJaM.defaultFitIO.log.Flush[]};
};
PrintRope: PROC[s: Rope.ROPE] = {OPEN IO; Put[FitJaM.defaultFitIO.log,rope[s]]};
PrintLine: PROC[s: Rope.ROPE] = {OPEN IO; Put[FitJaM.defaultFitIO.log,rope[s],char[CR]]};
Init: FitJaM.InitProc = {
JaM.Register[state,".drawsa", DrawSamples];
JaM.Register[state,".marksa", MarkSamples];
JaM.Register[state,".drawli", DrawLinks];
JaM.Register[state,".markli", MarkLinks];
JaM.Register[state,".marknodes", MarkNodes];
JaM.Register[state,".setfill", SetFill];
JaM.Register[state,".setlog", SetTypescript];
JaM.Register[state,".setscale", SetScale];
JaM.Register[state,".setoffset", SetOffset];
JaM.Register[state,".setmarksize", SetMarkSize];
JaM.Register[state,".note", Note];
JaM.Register[state,".notes", Notes];
JaM.Register[state,".noter", Noter];
JaM.Register[state,".time", Time];
JaM.Register[state,".openlogfile", OpenLogFile]; -- filename => . Switches the log file.
JaM.Register[state,".closelogfile", CloseLogFile]; -- => . Closes the log file.
};
FitJaM.RegisterInit[$FitIOJaM, Init];
END.