<> <> <> <> <> <> <> <> DIRECTORY AtomButtons, EmbeddedButtons, Feedback, FeedbackOps, FeedbackTypes, GGActive, GGBasicTypes, GGCircleCache, GGContainer, GGControlPanelTypes, GGCoreOps, GGEvent, GGInterfaceTypes, GGMenu, GGModelTypes, GGScene, GGSceneType, GGSegmentTypes, GGShapes, GGState, GGUserInput, GGUserProfile, GGWindow, Imager, ImagerFont, List, Menus, PFS, PFSNames, PutGet, Rope, Rules, TextNode, TiogaActive, TiogaOps, UserProfile, ViewerClasses, ViewerTools; GGMenuImpl: CEDAR PROGRAM IMPORTS AtomButtons, EmbeddedButtons, Feedback, FeedbackOps, GGActive, GGCircleCache, GGContainer, GGCoreOps, GGEvent, GGScene, GGShapes, GGState, GGUserInput, GGUserProfile, GGWindow, Imager, ImagerFont, List, PFS, PFSNames, PutGet, Rope, Rules, TiogaActive, TiogaOps, UserProfile, ViewerTools EXPORTS GGInterfaceTypes, GGModelTypes, GGMenu = BEGIN ControlsObj: PUBLIC TYPE = GGControlPanelTypes.ControlsObj; MsgRouter: TYPE = FeedbackTypes.MsgRouter; GGData: TYPE = GGInterfaceTypes.GGData; GravityExtentData: TYPE = REF GravityExtentDataObj; GravityExtentDataObj: TYPE = GGInterfaceTypes.GravityExtentDataObj; Point: TYPE = GGBasicTypes.Point; SceneObj: PUBLIC TYPE = GGSceneType.SceneObj; -- export of opaque type SceneRef: TYPE = REF SceneObj; Viewer: TYPE = ViewerClasses.Viewer; ROPE: TYPE = Rope.ROPE; popUpFont: Imager.Font; -- initialized in Init below; entryHeight: CARDINAL = 15; -- height of a line of items docEntryHeight: CARDINAL = 19; -- height of a line of items entryHSpace: CARDINAL = 2; -- horizontal space between items on a line entryVSpace: CARDINAL = 2; -- vertical leading between lines fullColumn: CARDINAL = 600; -- the width of the standard large left column. smallNumberSize: CARDINAL = 60; PUChoiceList: PROC [r0, r1, r2, r3, r4, r5, r6, r7, r8, r9, r10, r11, r12, r13, r14, r15, r16, r17, r18, r19: AtomButtons.PopUpChoice _ [] ] RETURNS [list: AtomButtons.PopUpChoices] = GGCoreOps.PUChoiceList; RList: PROC [ref1, ref2, ref3: REF ANY _ NIL] RETURNS [LIST OF REF ANY] = GGCoreOps.List; AddARule: PROC [ggData: GGData] = { rule: Rules.Rule _ Rules.Create[[ parent: ggData.controls.panel, wy: ggData.height, ww: ggData.controls.panel.cw, wh: 2 ]]; GGContainer.ChildXBound[ggData.controls.panel, rule]; ggData.height _ ggData.height + rule.wh + entryVSpace; }; <<>> BuildControlPanel: PUBLIC PROC [ggData: GGData, fancyPanel: BOOL _ FALSE] = { BuildActiveDocument[ggData, fancyPanel]; InitializeGravityLine[ggData]; BuildSlopeLine[ggData]; BuildAngleLine[ggData]; BuildRadiusLine[ggData]; BuildDistanceLine[ggData]; BuildMeasureLine[ggData]; BuildFeedbackLine[ggData]; AddARule[ggData]; }; BuildFeedbackLine: PROC [ggData: GGData] = { nextX: NAT _ AtomButtons.BuildButtonLine[ggData.controls.panel, 0, ggData.height, ggData, GGUserInput.EventNotify, LIST[ [label["Feedback . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . Line", FeedbackLineInGGData, fullColumn]] ]]; ggData.height _ ggData.height + entryHeight; }; FeedbackLineInGGData: AtomButtons.UpdateProc = { <> <> <<(BT) Complaint: Gargoyle informs the user of a user-initiated problem>> <<(BT) Error: internal error. One of Gargoyle's invariants has been broken>> <<(L) Confirm: Gargoyle asks the user to confirm a guarded operation>> <<(L) DuringMouse: feedback generated each time the mouse is moved.>> <<(L) Feedback: an acknowledgement that Gargoyle has done what you asked>> <<(LT) Show: info that was explicitly requested (e.g. what color is this?)>> <<(LT) Statistics: Gargoyle prints user requested statistics>> <<(LT) Warning: Problems during a batch operation, like MergeInterpress>> <<(T) Typescript: Output that only seems appropriate for the typescript, period.>> <<(L) = send to label. (B) = send to label and blink. (T) = send to typescript>> ggData: GGData _ NARROW[clientData]; router: MsgRouter _ Feedback.CreateRouter[]; FeedbackOps.SetMultiLabel[router, button, TRUE, LIST[$Error, $Complaint]]; -- blink FeedbackOps.SetMultiLabel[router, button, FALSE, LIST[$DuringMouse, $Feedback, $Warning, $Confirm, $Show, $Statistics]]; FeedbackOps.SetMultiTypescript[router, $Gargoyle, LIST[$Error, $Warning, $Show, $Typescript, $Complaint, $Statistics]]; ggData.router _ router; ggData.controls.feedbackLine _ button; }; IsGargoyle: PROC [path: PFS.PATH] RETURNS [BOOL] = { shortname: ROPE _ PFSNames.ComponentRope[PFSNames.ShortName[PFSNames.StripVersionNumber[path]]]; RETURN[Rope.Match["*.gargoyle", shortname, FALSE] OR Rope.Match["*.gg", shortname, FALSE]]; }; panelNames: ARRAY [0..2] OF ROPE = ["[PCedar]GargoyleControlPanel.tioga", "[CedarCommon]GargoyleControlPanel.tioga", "[PCedar]GargoyleControlPanel.tioga"]; fancyPanelNames: ARRAY [0..2] OF ROPE = ["[PCedar]GargoyleControlPanel.gargoyle", "[CedarCommon]GargoyleControlPanel.gargoyle", "[PCedar]GargoyleControlPanel.gargoyle"]; FindControlPanel: PROC [] RETURNS [filename: ROPE _ NIL, isGargoyle: BOOL _ FALSE] = { <> <<(1) The file specified in Gargoyle.ControlPanelFile: in the user profile.>> <<(2) The file "[PCedar]GargoyleControlPanel.tioga" (useful during development)>> <<(3) The file "[CedarCommon]GargoyleControlPanel.tioga">> <<(4) The file "[PCedar]GargoyleControlPanel.tioga">> <> value: LIST OF ROPE; fullName: PFS.PATH _ NIL; path: PFS.PATH; value _ UserProfile.ListOfTokens["Gargoyle.ControlPanelFile", NIL]; IF value # NIL THEN { FOR list: LIST OF ROPE _ value, list.rest UNTIL list = NIL DO path _ PFS.PathFromRope[list.first]; fullName _ PFS.FileInfo[name: path ! PFS.Error=>CONTINUE].fullFName; IF fullName # NIL THEN RETURN[PFS.RopeFromPath[fullName], IsGargoyle[fullName]]; ENDLOOP; }; <> FOR i: NAT IN [0..2] DO path _ PFS.PathFromRope[panelNames[i]]; fullName _ PFS.FileInfo[name: path ! PFS.Error=>CONTINUE].fullFName; IF fullName # NIL THEN RETURN[PFS.RopeFromPath[fullName], IsGargoyle[fullName]]; ENDLOOP; }; FindFancyControlPanel: PROC [] RETURNS [filename: ROPE _ NIL] = { <> <<(1) The file specified in Gargoyle.ControlPanelFile: in the user profile.>> <<(2) The file "[PCedar]GargoyleControlPanel.gargoyle" (useful during development)>> <<(3) The file "[CedarCommon]GargoyleControlPanel.gargoyle">> <<(4) The file "[PCedar]GargoyleControlPanel.gargoyle">> <> value: LIST OF ROPE; fullName: PFS.PATH _ NIL; path: PFS.PATH; value _ UserProfile.ListOfTokens["Gargoyle.ControlPanelFile", NIL]; IF value # NIL THEN { FOR list: LIST OF ROPE _ value, list.rest UNTIL list = NIL DO path _ PFS.PathFromRope[list.first]; fullName _ PFS.FileInfo[name: path ! PFS.Error=>CONTINUE].fullFName; IF fullName # NIL THEN { IF IsGargoyle[fullName] THEN RETURN[PFS.RopeFromPath[fullName]] }; ENDLOOP; }; <> FOR i: NAT IN [0..2] DO path _ PFS.PathFromRope[fancyPanelNames[i]]; fullName _ PFS.FileInfo[name: path ! PFS.Error=>CONTINUE].fullFName; IF fullName # NIL THEN RETURN[PFS.RopeFromPath[fullName]]; ENDLOOP; }; BuildActiveDocument: PROC [ggData: GGData, fancyPanel: BOOL] = { nextX: NAT _ 0; v: Viewer; lines: NAT _ 6; height: NAT _ lines*docEntryHeight; doc: TextNode.Ref _ NIL; filename: ROPE; true: ROPE = "TRUE"; isGargoyle: BOOL _ FALSE; IF fancyPanel THEN filename _ FindFancyControlPanel[]; IF filename # NIL THEN { isGargoyle _ TRUE; } ELSE [filename, isGargoyle] _ FindControlPanel[]; IF filename = NIL THEN Feedback.AppendByName[$System, oneLiner, $Error, "No file found for Gargoyle control panel in [PCedar], [CedarCommon], [PCedar] nor in Gargoyle.ControlPanelFile user profile entry."] ELSE { Feedback.PutFByName[$System, oneLiner, $Feedback, "Loading %g as Gargoyle's control panel", [rope[filename]]]; IF NOT isGargoyle THEN doc _ PutGet.FromFile[filename]; }; IF isGargoyle THEN { thisData: GGData; scene: GGModelTypes.Scene _ GGScene.CreateScene[]; height _ 140; [v, thisData] _ GGWindow.CreateChildViewer[scene: scene, wx: 0, wy: ggData.height, wh: height, parent: ggData.controls.panel, workingDirectory: "[PCedar]", paint: TRUE ]; ggData.controls.controlPanel _ GGActive.LookupDoc[thisData]; GGUserInput.EventNotify[thisData, LIST[$MergeAll, filename]]; GGUserInput.EventNotify[thisData, LIST[$DeselectAll]]; GGUserInput.EventNotify[thisData, LIST[$SetActive, true]]; GGUserInput.EventNotify[thisData, LIST[$SetScaleUnit, NEW[REAL _ 1.0], $Quiet]]; GGUserInput.EventNotify[thisData, LIST[$CleanVersion]]; GGState.SetReadOnly[thisData, TRUE]; } ELSE { v _ ViewerTools.MakeNewTextViewer[[ wx: 0, wy: ggData.height, wh: height, parent: ggData.controls.panel, data: doc, scrollable: TRUE, border: TRUE]]; ggData.controls.controlPanel _ TiogaActive.LookupDoc[v]; TiogaOps.Interpret[v, LIST[$ActivityOn]]; }; GGContainer.ChildXBound[ggData.controls.panel, v]; ggData.controls.controlPanelViewer _ v; EmbeddedButtons.LinkDocToApplication[doc: ggData.controls.controlPanel, target: $Gargoyle, targetViewer: ggData.controls.actionArea, applicationData: ggData, notifyProc: ControlPanelNotify]; EmbeddedButtons.LinkDocToApplication[doc: ggData.controls.controlPanel, target: $UnQueuedGargoyle, targetViewer: ggData.controls.actionArea, applicationData: ggData, notifyProc: UnQueuedControlPanelNotify]; ggData.height _ ggData.height + height; }; ControlPanelNotify: EmbeddedButtons.NotifyProc = { <> newEvent: LIST OF REF _ List.Append[events]; -- make a copy of the eventList, because EmbeddedButtons resuses the original ggData: GGData _ NARROW[applicationData]; [] _ GGActive.ControlPanelButtonHandler[ggData, newEvent, buttonInfo]; }; UnQueuedControlPanelNotify: EmbeddedButtons.NotifyProc = { <> newEvent: LIST OF REF ANY _ List.Append[events]; -- make a copy of the eventList, because EmbeddedButtons resuses the original GGUserInput.UnQueuedEventNotify[applicationData, newEvent]; }; <<<> <> <> <> <> <> <> <> <> <> <> <<>> <> <> <> <> <<[button["GravExtent:", LIST[LIST[$ShowGravExtent]]]]>> <<]];>> <<>> <> <> <> <> <> <> <> <> <<[LIST[$GravityExtentChange, $ValueDown]],>> <<[LIST[$GravityExtentChange, $InitialValue]],>> <<[LIST[$GravityExtentChange, $ValueUp]]],>> <> <> <> <> <<];>> <<>> <> <> <> <<[twoState["Gravity", LIST[$ToggleGravity], TRUE, GravityInGGData]],>> <<[twoState["Midpts", LIST[$ToggleMidpoints], FALSE, MidpointsInGGData]],>> <<[twoState["Auto", LIST[$ToggleHeuristics], GGUserProfile.GetDefaultHeuristics[], HeuristicsInGGData]],>> <<[twoState["Alignments", LIST[$ToggleShowAlignments], TRUE, AlignmentsInGGData]]>> <<],>> <> <<>> <<>> <> <<};>> <<>>>> <<>> InitializeGravityLine: PROC [ggData: GGData] = { ggData.hitTest.gravityType _ pointsPreferred; GGState.SetGravityExtent[ggData, GGUserProfile.GetDefaultGravityExtent[]/72.0]; GGState.SetHeuristics[ggData, GGUserProfile.GetDefaultHeuristics[]]; }; BuildSlopeLine: PROC [ggData: GGData] = { buttonHandle: AtomButtons.SortedButtonHandle; nextX: NAT _ AtomButtons.BuildButtonLine[ggData.controls.panel, 0, ggData.height, ggData, GGUserInput.EventNotify,LIST[ [button["Slope:", LIST[LIST[$SlopePrompt]] ]], [button["Get!", LIST[LIST[$GetSlope]] ]], [button["Add!", LIST[LIST[$AddSlope]] ]], [button["Delete!", LIST[LIST[$DeleteSlope]] ]] ]]; buttonHandle _ AtomButtons.CreateSortedButtonViewer[ggData.controls.panel, nextX, ggData.height]; ggData.controls.slopeHandle _ buttonHandle; GGEvent.StandardSlopes[ggData, LIST[$InitStandardSlopes]]; ggData.height _ ggData.height + entryHeight; }; BuildAngleLine: PROC [ggData: GGData] = { buttonHandle: AtomButtons.SortedButtonHandle; nextX: NAT _ AtomButtons.BuildButtonLine[ggData.controls.panel, 0, ggData.height, ggData, GGUserInput.EventNotify,LIST[ [button["Angle:", LIST[LIST[$AnglePrompt]] ]], [button["Get!", LIST[LIST[$GetAngle]] ]], [button["Add!", LIST[LIST[$AddAngle]] ]], [button["Delete!", LIST[LIST[$DeleteAngle]] ]] ]]; buttonHandle _ AtomButtons.CreateSortedButtonViewer[ggData.controls.panel, nextX, ggData.height]; ggData.controls.angleHandle _ buttonHandle; GGEvent.StandardAngles[ggData, LIST[$InitStandardAngles]]; ggData.height _ ggData.height + entryHeight; }; BuildRadiusLine: PROC [ggData: GGData] = { buttonHandle: AtomButtons.SortedButtonHandle; nextX: NAT _ AtomButtons.BuildButtonLine[ggData.controls.panel, 0, ggData.height, ggData, GGUserInput.EventNotify, LIST[ [button["Radius:", LIST[LIST[$RadiusPrompt]] ]], [button["Get!", LIST[LIST[$GetRadius]] ]], [button["Add!", LIST[LIST[$AddRadius]] ]], [button["Delete!", LIST[LIST[$DeleteRadius]] ]] ]]; buttonHandle _ AtomButtons.CreateSortedButtonViewer[ggData.controls.panel, nextX, ggData.height]; ggData.controls.radiusHandle _ buttonHandle; GGEvent.StandardRadii[ggData, LIST[$InitStandardRadii]]; ggData.controls.radiusCircleCache _ GGCircleCache.Create[]; ggData.height _ ggData.height + entryHeight; }; BuildDistanceLine: PROC [ggData: GGData] = { buttonHandle: AtomButtons.SortedButtonHandle; nextX: NAT _ AtomButtons.BuildButtonLine[ggData.controls.panel, 0, ggData.height, ggData, GGUserInput.EventNotify, LIST[ [button["LineDist:", LIST[LIST[$DistancePrompt]] ]], [button["Get!", LIST[LIST[$GetDistance]] ]], [button["Add!", LIST[LIST[$AddDistance]] ]], [button["Delete!", LIST[LIST[$DeleteDistance]] ]] ]]; buttonHandle _ AtomButtons.CreateSortedButtonViewer[ggData.controls.panel, nextX, ggData.height]; ggData.controls.distanceHandle _ buttonHandle; GGEvent.StandardDistances[ggData, LIST[$InitStandardDistances]]; ggData.height _ ggData.height + entryHeight; }; BuildMeasureLine: PROC [ggData: GGData] = { nextX: NAT _ AtomButtons.BuildButtonLine[ggData.controls.panel, 0, ggData.height, ggData, GGUserInput.EventNotify, LIST[ <<[label["Measure- "]],>> [button["_", LIST[LIST[$MeasureSlopeFromSelection]], -1, TRUE ]], [button["Slope:", LIST[LIST[$MeasureSlopeHit]], -1, TRUE ]], [text["0.0", SlopeViewInGGData, smallNumberSize]], [button["_", LIST[LIST[$MeasureAngleFromSelection]], -1, TRUE ]], [button["Angle:", LIST[LIST[$MeasureAngleHit]], -1, TRUE ]], [text["0.0", AngleViewInGGData, smallNumberSize]], [button["_", LIST[LIST[$MeasureRadiusFromSelection]], -1, TRUE ]], [button["Radius:", LIST[LIST[$MeasureRadiusHit]], -1, TRUE ]], [text["0.0", DistanceViewInGGData, smallNumberSize]], [button["_", LIST[LIST[$MeasureLineDistFromSelection]], -1, TRUE ]], [button["LineDist:", LIST[LIST[$MeasureLineDistHit]], -1, TRUE ]], [text["0.0", LineDistViewInGGData, smallNumberSize]] ]]; ggData.height _ ggData.height + entryHeight; }; <