--File: IPMainViewerImpl.mesa
Last edited by: Preas on July 12, 1984 2:40:35 pm PDT
Last Edited by: CSChow, February 2, 1985 3:35:10 am PST
--Intro: This interface is self-documentary. Use this as reference
--Imports:
-- (I) IPMVBasicOps = basic operations
-- (II) IPMVEditOps = editing operations
-- (III) IPMVStackOps = stack related operations
DIRECTORY
IO,
TerminalIO,
Rope,
Convert,
QuickViewer,
Graphics,
MessageWindow,
Menus,
Commander,
FS,
FileNames,
Atom,
SymTab,
ExprRead,
OrderedRefArray,
IP,
IPParams,
IPConstants,
IPTopOps,
IPNetTab,
IPTop,
IPCTG,
IPCoTab,
IPToolBox,
IPMVEditOps,
IPMVStackOps,
IPMVBasicOps,
IPMainViewer;
IPMainViewerImpl: CEDAR PROGRAM
IMPORTS IO, TerminalIO, Atom, MessageWindow, Rope, FS, FileNames, Commander, Convert, ExprRead, QuickViewer, OrderedRefArray, IP, IPParams, IPTop, IPCTG, IPCoTab, IPToolBox, IPTopOps, IPNetTab, IPMVEditOps, IPMVStackOps, IPMVBasicOps
EXPORTS IPMainViewer = BEGIN OPEN TIO: TerminalIO, Top: IPTop;
MVTop: PUBLIC Top.Ref ← NIL;
TrialSolutions: PUBLIC OrderedRefArray.Ref ← NIL;
wDir: PUBLIC Rope.ROPE;
mvName: Rope.ROPE ← "Phoenix";
selectedNet: IPNetTab.Net ← NIL;
showAllNames, showCompNames, showChNames: BOOLFALSE;
showCompsOnly, showChsOnly: BOOLFALSE;
trackKept: LIST OF REFNIL;
prevTrack: LIST OF REFNIL;
--Minor Details
showPinNameCutOff: PUBLIC REAL ← 3.0; --ie. set from interpreter
coStipple: CARDINAL ← IPConstants.White;
RollBack: PUBLIC PROC[fromFile: Rope.ROPE] ={
SetTopTo[Top.ReconstructSelf[fromFile]];
Refresh[];
TrialSolutions ← NIL;
trackKept ← prevTrack ← NIL;
}; --RollBack
GetInput: PUBLIC PROC[defaultDir, inputFile: Rope.ROPE] ={
tab: SymTab.Ref ← ExprRead.ReadFile[IPToolBox.ConstructFileName[defaultDir, inputFile, "desc"]];
systemName: Rope.ROPE ← ExprRead.FetchRope[tab, "ObjectName", TRUE].val;
SetTopTo[Top.Create1[defaultDir, inputFile]];
IF systemName # NIL THEN QuickViewer.SetViewerName[mvName ← systemName];
Refresh[];
TrialSolutions ← NIL;
trackKept ← prevTrack ← NIL;
}; --GetInputFile
CleanUp: PROC = {IF MVTop # NIL THEN IPTop.DestroySelf[MVTop]; MVTop ← NIL}; --CleanUp--
Refresh: PROC = {QuickViewer.EraseViewer[]; QuickViewer.DrawInViewer[DrawProc]}; --Refresh--
SetTopTo: PROC[newTop: Top.Ref] = {CleanUp[]; MVTop ← newTop}; --SetTopTo--
QuitProc: PROC [] = {
TIO.WriteRope["Quiting..."];
CleanUp[];
TIO.WriteRope["..Done\n"];
}; --QuitProc--
errorMessage: Rope.ROPE;
ClickProc: PROC[mouseButton: ATOM, xCoord, yCoord: REAL] ={
MessageWindow.Append[Rope.Cat[Atom.GetPName[mouseButton], " ",
Convert.RopeFromReal[xCoord], " ",
Convert.RopeFromReal[yCoord]], TRUE];
}; --ClickProc--
MenuHit: PROC[command: ATOM, mouse: Menus.MouseButton, shift, control: BOOL] = {
ENABLE {
TIO.UserAbort => {
errorMessage ← Rope.Cat[Atom.GetPName[command], "...userAbort"];
IF ~IPParams.DebugSystem THEN GOTO err
};
FS.Error => {TIO.WriteRope[Rope.Cat[Atom.GetPName[error.code], "...."]];
errorMessage ← error.explanation;
IF ~IPParams.DebugSystem THEN GOTO err};
IO.Error => {TIO.WriteRope[Rope.Cat[Atom.GetPName[command], "...."]];
errorMessage ← "Not enough arguments. Please try again";
IF ~IPParams.DebugSystem THEN GOTO err};
IO.EndOfStream => {TIO.WriteRope[Rope.Cat[Atom.GetPName[command], "...."]];
errorMessage ← "Input Error. Please try again";
IF ~IPParams.DebugSystem THEN GOTO err};
ExprRead.Error => {TIO.WriteRope[Rope.Cat[Atom.GetPName[command], "...."]];
errorMessage ← msg;
IF ~IPParams.DebugSystem THEN GOTO err};
IPTopOps.InvalidArgs =>{TIO.WriteRope[Rope.Cat[Atom.GetPName[op], "..."]];
errorMessage ← "Arguments are not valid";
IF ~IPParams.DebugSystem THEN GOTO err};
IPTopOps.UndoStackEmpty => {TIO.WriteRope["...undo stack is emptied..."];
errorMessage ← "Can't undo any further";
IF ~IPParams.DebugSystem THEN GOTO err};
OrderedRefArray.OutOfRange => {
TIO.WriteRope[Rope.Cat[Atom.GetPName[command], "...."]];
errorMessage ← Rope.Cat[Convert.RopeFromInt[index], " is not in range"];
IF ~IPParams.DebugSystem THEN GOTO err;
};
IPToolBox.ParseError => {
TIO.WriteRope["Input Error..."];
errorMessage ← "Arguments are not valid";
IF ~IPParams.DebugSystem THEN GOTO err};
IP.Error => {
SELECT ec FROM
missingRegistration => {
TIO.WriteRope[Rope.Cat[explanation, "..."]];
errorMessage ← "Unknown name";
IF ~IPParams.DebugSystem THEN GOTO err;
};
doubleRegistration => {
TIO.WriteRope[Rope.Cat[explanation, "..."]];
errorMessage ← "Name Conflict";
IF ~IPParams.DebugSystem THEN GOTO err;
};
callingError => {
TIO.WriteRope[Rope.Cat[explanation, "..."]];
errorMessage ← "Check Input And Retry or See Implementor";
IF ~IPParams.DebugSystem THEN GOTO err;
};
programmingError, noResource, other => {
TIO.WriteRope[Rope.Cat["You just found a bug: ", explanation]];
errorMessage ← "See Implementor";
IF ~IPParams.DebugSystem THEN GOTO err;
};
ENDCASE => ERROR;};
};
refreshFlag: BOOLTRUE;
reGeom: BOOLFALSE;
SELECT command FROM
$RollBack => {file: Rope.ROPETIO.RequestRope["Enter Full Name of Log File to Rollback from: "];
TIO.WriteRope[Rope.Cat["Reconstructing From: ", file, "..."]];
RollBack[file];
TIO.WriteRope["..Done\n"];
RETURN};
$GetInput => {
inputFile: Rope.ROPETIO.RequestRope["Enter Name of Description File From Which To Get Data: "];
GetInput[wDir, inputFile];
TIO.WriteRope["..Done\n"];
RETURN
};
ENDCASE => NULL;
IF MVTop = NIL THEN {
errorMessage ← "System is Empty! Please do Rollback or GetExample to load a new system";
IF ~IPParams.DebugSystem THEN GOTO err}; --ENDIF--
SELECT command FROM
$Name => {
IF ~shift AND ~ control THEN {
SELECT mouse FROM
$red => {showChNames ← NOT showChNames;};
$yellow => {showAllNames ← NOT showAllNames;
IF showAllNames
THEN {showCompNames ← TRUE; showChNames ← TRUE;}
ELSE {showCompNames ← FALSE; showChNames ← FALSE;};};
$blue => {showCompNames ← NOT showCompNames};
ENDCASE => ERROR;
TIO.WriteRope[(IF showAllNames THEN "Show all names..." ELSE "Not showing all names...")];
showAllNames ← showCompNames AND showChNames;
}; --endIf
IF shift THEN showCompsOnly ← ~ showCompsOnly;
IF control THEN showChsOnly ← ~ showChsOnly;
};
$DefChs => {
TIO.WriteRope["DefiningChannels..."];
[] ← MVTop.ReDefineChs[yPrimary: NOT shift, maxChWidth: control ! Top.ComponentsOverlapped => {errorMessage ← "Overlapping Components";
IF ~IPParams.DebugSystem THEN GOTO err}];
prevTrack ← NIL; trackKept ← NIL};
$ClrChs => {
TIO.WriteRope["Destroying Channels..."];
IPTop.ClearChannels[MVTop];
prevTrack ← NIL; trackKept ← NIL};
$PaintNet => {
argStream: IO.STREAMIO.RIS[TIO.RequestRope["Name of net to be painted: "]];
selectedNet ← IPNetTab.FetchNet[MVTop.nets, IO.GetLineRope[argStream]];
QuickViewer.DrawInViewer[DrawNetProc];
refreshFlag ← FALSE};
$Geom, $CheckPoint, $List, $ChkSlf, $EstChs => {
[reGeom, refreshFlag] ← IPMVBasicOps.MenuHit[MVTop, wDir, command, mouse, shift, control]
};
$Undo, $Un1, $Redo, $Re1, $KepTrk, $ClrStks, $StkSz, $ToSoln => {
[prevTrack, reGeom, refreshFlag] ← IPMVStackOps.MenuHit[MVTop, prevTrack, trackKept, command, mouse, shift, control, TrialSolutions]
};
$BrkX, $FomX, $RemZ, $FomZ, $LtoT, $TtoL, $FlxKne, $ExtKne, $Mrr, $Rot, $Ornt, $ClrCnr, $Grw, $Grw1, $Shr, $BrkXs, $SetCo, $MovCo, $SwapCo, $FlipT, $SetCoShp, $SpawnCo => {
[reGeom, refreshFlag] ← IPMVEditOps.MenuHit[MVTop, command, mouse, shift, control];
prevTrack ← NIL;
};
ENDCASE => ERROR;
IF reGeom THEN MVTop.Geometrize[horPosSense: NOT control, verPosSense: NOT shift];
IF refreshFlag THEN Refresh[];
TIO.WriteRope["..Done\n"];
EXITS
err => {MessageWindow.Append[errorMessage, TRUE]; MessageWindow.Blink[]; TIO.WriteRope["Aborted\n"];};
}; --MenuHit--
DrawNetProc: PROC[context: Graphics.Context, scaleFactor: REAL] ={
IPNetTab.PaintNet[net: selectedNet, context: context, scaleFactor: scaleFactor, showNetName: FALSE]
}; --DrawNetProc
DrawProc: PROC [context: Graphics.Context, scaleFactor: REAL] ={
IF MVTop # NIL THEN {
IF showCompsOnly THEN {
IPCoTab.PaintSelf[coTab: MVTop.coTab, context: context, scaleFactor: scaleFactor, coStipple: coStipple, showCoNames: (showCompNames OR showAllNames), showPhyPinNames: (scaleFactor > showPinNameCutOff)];
RETURN};
IF showChsOnly THEN {
IPCTG.PaintSelf[ctg: MVTop.ctg, context: context, scaleFactor: scaleFactor, showChName: (showChNames OR showAllNames)];
RETURN};
MVTop.PaintSelf[context: context, scaleFactor: scaleFactor, showChNames: (showChNames OR showAllNames), showCompNames: (showCompNames OR showAllNames), showPinNames: (scaleFactor > showPinNameCutOff)];}
}; --DrawProc--
BuildViewer: Commander.CommandProc={
IF cmd # NIL THEN {
argStream: IO.STREAMIO.RIS[cmd.commandLine];
mvName ← IO.GetID[argStream! IO.EndOfStream => CONTINUE;]};
QuickViewer.BuildViewer[DrawProc, QuitProc, MenuHit, ClickProc, mvName, FALSE, LIST[$RollBack, $GetInput, $CheckPoint], LIST[$DefChs, $ClrChs, $Geom,$Name, $List, $PaintNet, $EstChs], LIST[$EditOps, $BrkX, $FomX, $RemZ, $FomZ, $LtoT, $TtoL, $FlxKne, $ExtKne, $Grw, $Grw1, $Shr, $Rot, $Mrr, $Ornt, $ClrCnr], LIST[$OpsExtra, $SetCo, $MovCo, $SwapCo, $FlipT, $SpawnCo, $SetCoShp], LIST[$StkOps, $Undo, $Redo, $KepTrk, $ClrStks, $Un1, $Re1, $StkSz, $ToSoln]];
}; --BuildViewer
Commander.Register[key: "IPMainViewer", proc: BuildViewer, doc: "Create an IPMainViewer"];
[] ← BuildViewer[NIL];
wDir ← FileNames.CurrentWorkingDirectory[];
END.