GraphCntrlReset.mesa
Sweetsun Chen, September 6, 1985 8:10:57 pm PDT
CEDAR PROGRAM
= {
CntrlReset: ActionProc = {
Reset values, if not set yet. Affects panel only.
OPEN handle;
SELECT atom FROM
$Divisions => ResetDivisionsFields[handle];
$Bounds => ResetBoundsFields[handle];
$Carets => ResetCaretsFields[handle];
$Targets => ResetTargetsFields[handle];
$Grids => ResetGridsFields[handle];
$Color => {
msg: ROPE;
index: INT;
[msg, index] ← GetIntField[controller.colorIndex];
IF msg # NIL THEN BlinkMsg[msg.Concat[" in parsing the index field."]]
ELSE IF index NOT IN ColorIndex THEN BlinkMsg[
Rope.Cat["Index must be in [0..", Convert.RopeFromInt[NumberOfColors], ")"]]
ELSE ResetColorFields[handle];
};
$Font => {
msg: ROPE;
index: INT;
[msg, index]← GetIntField[controller.fontIndex];
IF msg # NIL THEN BlinkMsg[msg.Concat[" in parsing the index field."]]
ELSE IF index NOT IN FontIndex THEN BlinkMsg[
Rope.Cat["Index must be in [0..", Convert.RopeFromInt[NumberOfFonts], ")"]]
ELSE ResetFontFields[handle];
};
$Text => {
msg: ROPE;
id: INT;
[msg, id] ← GetIntField[controller.textId];
IF msg # NIL THEN BlinkMsg[msg.Concat[" in parsing the id field."]]
ELSE {
text: Text ← TextFromId[handle.texts, id];
IF text = NIL THEN BlinkMsg[Rope.Concat["There is no text with id = ", Rope.RopeFromInt[id]]]
ELSE ResetTextFields[handle, text];
};
};
$Entity => {
msg: ROPE;
id: INT;
[msg, id] ← GetIntField[controller.entityId];
IF msg # NIL THEN BlinkMsg[msg.Concat[" in parsing the id field."]]
ELSE {
entity: Entity ← EntityFromId[controller.entityHash, id];
IF entity = NIL THEN BlinkMsg[Rope.Concat["There is no curve with id = ", Rope.RopeFromInt[id]]]
ELSE ResetCurveFields[handle, curve];
};
};
$CurveGroup => {
msg: ROPE;
id: INT;
[msg, id] ← GetIntField[controller.entityId];
IF msg # NIL THEN BlinkMsg[msg.Concat[" in parsing the id field."]]
ELSE {
eg: EntityGroup ← EntityGroupFromId[handle.entityGroupList, id];
IF eg = NIL THEN BlinkMsg[Rope.Concat["There is no curve group with id = ", Rope.RopeFromInt[id]]]
ResetCurveGroupFields[handle, cg];
};
};
$Crosssection => {
};
ENDCASE => RaiseError[$UnknownAtom, "in CntrlReset"];
}; -- CntrlReset
ResetDivisionsFields: PROC[handle: GraphHandle] = { OPEN handle;
SetSwitchColor[controller.autoDivision, graph.auto[divisions]];
SetIntField[controller.divX, graph.division[x]];
SetIntField[controller.divY, graph.division[y]];
}; -- SetDivisionFields
ResetBoundsFields: PROC[handle: GraphHandle] = { OPEN handle;
SetSwitchColor[controller.autoBounds, graph.auto[bounds]];
SetRealField[controller.xmin, graph.bounds.xmin];
SetRealField[controller.ymin, graph.bounds.ymin];
SetRealField[controller.xmax, graph.bounds.xmax];
SetRealField[controller.ymax, graph.bounds.ymax];
}; -- SetBoundsFields
ResetCaretsFields: PROC[handle: GraphHandle] = { OPEN handle;
SetSwitchColor[controller.xhari1On, graph.caret[primary].on];
SetRealField[controller.xhair1x, graph.caret[primary].place.x];
SetRealField[controller.xhair1y, graph.caret[primary].place.y];
SetSwitchColor[controller.xhari2On, graph.caret[secondary].on];
SetRealField[controller.xhair2x, graph.caret[secondary].place.x];
SetRealField[controller.xhair2y, graph.caret[secondary].place.y];
SetSwitchColor[controller.slopeOn, graph.showSlope];
ViewerTools.SetContents[controller.slope,
RopeOfSlope[graph.caret[primary].place, graph.caret[secondary].place]];
SetSwitchColor[controller.textCaretOn, graph.caret[text].on];
SetRealField[controller.textCaretX, graph.caret[text].place.x];
SetRealField[controller.textCaretY, graph.caret[text].place.y];
}; -- ResetCaretsFields
ResetTargetsFields: PROC[handle: GraphHandle] = { OPEN handle;
SetSwitchColor[controller.targetXOn, graph.target[x].on];
SetRealField[controller.targetX, graph.target[x].value];
SetRealField[controller.targetXW, graph.target[x].width];
SetSwitchColor[controller.targetYOn, graph.target[y].on];
SetRealField[controller.targetY, graph.target[y].value];
SetRealField[controller.targetYW, graph.target[y].width];
}; -- ResetTargetsFields
ResetGridsFields: PROC[handle: GraphHandle] = { OPEN handle;
SetSwitchColor[controller.gridXOn, graph.grid[x]];
SetSwitchColor[controller.gridYOn, graph.grid[y]];
}; -- ResetGridsFields
ResetColorFields: PROC[handle: GraphHandle, index: ColorIndex] = { OPEN handle;
SetRealField[controller.red, graph.color[index].R];
SetRealField[controller.green, graph.color[index].G];
SetRealField[controller.blue, graph.color[index].B];
}; -- ResetColorFields
ResetFontFields: PROC[handle: GraphHandle, index: FontIndex] = { OPEN handle;
ViewerTools.SetContent[controller.fontFamily, graph.font[index].family];
SetIntField[controller.vFontSize, graph.font[index].vFontSize];
SetRealField[controller.pFontScale, graph.font[index].pFontScale];
}; -- ResetFontFields
ResetTextFields: PROC[handle: GraphHandle, text: Text] = { OPEN handle;
text # NIL!
ViewerTools.SetContent[controller.textContent, text.name];
SetRealField[controller.textPlaceX, text.place.x];
ChoiceButtons.UpdateChoiceButtons[controller.viewer, controller.justifX,
RopeFromJustifX[text.justifX]];
SetRealField[controller.textPlaceY, text.place.y];
ChoiceButtons.UpdateChoiceButtons[controller.viewer, controller.justifX,
RopeFromJustifY[text.justifY]];
SetIntField[controller.textColor, text.colorIndex];
SetIntField[controller.textFont, text.fontIndex];
}; -- ResetTextFields
ResetCurveFields: PROC[handle: GraphHandle, entity: Entity] = { OPEN handle;
entity # NIL!
ViewerTools.SetContent[controller.entityName, entity.name];
SetIntField[controller.entityColor, entity.colorIndex];
SetRealField[controller.entityWidth, entity.width];
ChoiceButtons.UpdateChoiceButtons[controller.viewer, controller.markRef,
RopeFromMark[entity.mark]];
SetIntField[controller.entityGroupId, entity.groupId];
ViewerTools.SetContent[controller.entityValues, RopeFromVector[entity.newValues];
}; -- ResetCurveFields
ResetCurveGroupFields: PROC[handle: GraphHandle, eg: EntityGroup] = { OPEN handle;
ViewerTools.SetContent[controller.groupName, eg.name];
SetIntField[controller.xId, eg.x.id];
ViewerTools.SetContent[controller.yIds, RopeOfEntityListIds[eg.entityList, eg.x]];
}; -- ResetCurveGroupFields
}.