-- File: SVViewerUser.mesa
-- Last edited by Bier on July 7, 1983 11:12 am
-- Author: Eric Bier in October, 1982 (?)
-- Contents: Code to respond to button presses made in an SVViewer

DIRECTORY
 BitMap3d,
 CastRays,
 Containers,
 CoordSys,
CSG,
 CSGGraphics,
 DisplayList3d,
 Graphics,
 Matrix3d,
 Menus,
 Rope,
 SV2d,
 SVViewerTool,
 ViewerClasses;

SVViewerUser: CEDAR DEFINITIONS =
BEGIN

Camera: TYPE = CSGGraphics.Camera;
CoordSystem: TYPE = CoordSys.CoordSystem;
CSGTree: TYPE = CSG.CSGTree;
MouseButton: TYPE = Menus.MouseButton;
Point2d: TYPE = SV2d.Point2d;
Point3d: TYPE = Matrix3d.Point3d;
Scene: TYPE = DisplayList3d.Scene;
Viewer: TYPE = ViewerClasses.Viewer;
ViewerToolData: TYPE = SVViewerTool.ViewerToolData;

ViewerPictureData: TYPE = REF ViewerPictureDataObj;
ViewerPictureDataObj: TYPE = RECORD [
 proc: PROC [dc: Graphics.Context],
 scene: Scene, -- the collection of 3d objects we are looking at
 tree: CSGTree, -- for efficiency we will occasional cache the (viewpoint dependent) ray tracing tree
 camera: Camera, -- our point of view
 sceneStyleIndex: NAT, -- corresponds to camera.style
 bandsDeviceIndex: NAT,
 focus: Point3d, -- a point to aim the camera at
 baseCS: CoordSystem, -- ****
 mode: InteractionMode,
 showCoordSys: BOOL,
 doubleBuffer: BOOL,
 altDC: BitMap3d.AlternateDisplayContext,
 viewerToolData: ViewerToolData -- a back pointer
 ];

InteractionMode: TYPE = {select, cast};

DCProc: TYPE = PROC [Graphics.Context];

-- INTERWINDOW COMMUNICATION

UpdateHeader: PROC [pictureFile: Rope.ROPE, viewerToolData: ViewerToolData];
NotifyOfSplit: PROC [viewer: Viewer];
UnSplit: PROC [viewerToolData: ViewerToolData];
DrawOneCSInViewer: PROC [viewerToolData: ViewerToolData, cs: CoordSystem];

-- INTERMODULE COMMUNICATION

ReadTwoReals: PROC [textViewer: Viewer] RETURNS [x, y: REAL];
DrawSceneEtc: PROC [dc: Graphics.Context, viewerToolData: ViewerToolData];
-- may also draw coordinate systems, drawing planes, etc depending on the current selected modes.
DrawAllCS: PROC [dc: Graphics.Context, viewerToolData: ViewerToolData];
DrawOneCS: PROC [dc: Graphics.Context, viewerToolData: ViewerToolData, cs: CoordSystem];

Painter: PROC [proc: DCProc, viewerToolData: ViewerToolData ← NIL];

-- Menu Procs

DrawSceneInternal: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL]; -- like DrawScene but erases the screen before drawing.
EraseAndDrawSceneEtc: PROC [dc: Graphics.Context, viewerToolData: ViewerToolData];
PlaceOrigin: PROC [viewer: Viewer];
ResizeBitMap: PROC [viewer: Viewer];

-- in SVViewerUserImplA


Reset:
PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];
ConfirmReset
: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];
Save
: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];
ConfirmSave: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];
Load: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];
ConfirmLoad: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];
Store: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];
ConfirmStore: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];
Split: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];

Erase: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];
Empty: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];
ConfirmEmpty: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];
RayCast: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];
ConfirmRayCast: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];
RayCastProgress: CastRays.NotifyOfProgressProc;
Stop: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];
ARay: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];

-- in SVViewerUserImplB.mesa

Press: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];
PressAIS: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];
PressBWAIS: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];

DrawBoundBoxes: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];
SceneNewVersion: PROC [viewerToolData: ViewerToolData]; -- called internally
NewVersion: PROC [viewer: Viewer]; -- called by SVEditUserImplA
SceneOldVersion: PROC [viewerToolData: ViewerToolData]; -- called internally
OldVersion: PUBLIC PROC [viewer: Viewer]; -- called by SVEditUserImplA
DrawScene: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];
DrawCoordSystems: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];
DrawPt: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];
DrawColor: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];
DrawBlackAndWhite: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];
CrossHairs: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];
DrawDither: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];
Dither: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];
Extend: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];
Move: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];
SetFocalLength: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];
MakeBands: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];


-- PROMPTS

AISPrompt: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];
StylePrompt: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];
XYZPrompt: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];
FocalLengthPrompt: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];
PictureFilePrompt: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];

-- ON/OFF SWITCHES

DoubleBuffer: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];
ShowCoordsMode: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];

-- OPTIONS LISTERS

BandsDevice: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];

-- UTILITIES

Selected: PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL];
Deselected: PROC [viewerToolData: ViewerToolData];

-- Input Notify Procs

SingleRay: PROC [viewerToolData: ViewerToolData, cameraPoint: Point2d];
PointAt: PROC [viewerToolData: ViewerToolData, cameraPoint: Point2d];

END.