-- File: SVEditTool.mesa
-- Last edited by Bier on December 18, 1982 1:51 am
-- Author: Eric Bier on June 28, 1983 6:24 pm
-- Contents: Produces container, menus and buttons for a Solidviews edit tool.

DIRECTORY
 Containers,
 CoordSys,
 DisplayList3d,
 GraphicsColor,
 Matrix3d,
 Scratchpad2d,
 SVArtworkTool,
 SVEditToolMenus,
 SVEditUser,
 UserExec,
 ViewerClasses;

SVEditTool: PROGRAM
IMPORTS Containers, DisplayList3d, Scratchpad2d, SVArtworkTool, SVEditToolMenus, SVEditUser, UserExec
  SHARES ViewerClasses -- to change rowsUsed of PRIVATE RECORD MenuRec -- =
BEGIN

Assembly: TYPE = REF AssemblyObj;
AssemblyObj: TYPE = DisplayList3d.AssemblyObj;
Color: TYPE = GraphicsColor.Color;
CoordSystem: TYPE = CoordSys.CoordSystem;
CSGTree: TYPE = DisplayList3d.CSGTree;
ExecHandle: TYPE = REF ExecRecord;
ExecRecord: TYPE = UserExec.ExecRecord;
MasterObject: TYPE = REF MasterObjectRec;
MasterObjectRec: TYPE = DisplayList3d.MasterObjectRec;
Point2d: TYPE = Matrix3d.Point2d;
Scene: TYPE = DisplayList3d.Scene;
Viewer: TYPE = ViewerClasses.Viewer;

-- declare the standard distances between menu lines.

entryHeight: CARDINAL = 12; -- height of a line of items
entryVSpace: CARDINAL = 3; -- vertical leading between lines
entryHSpace: CARDINAL = 8; -- horizontal space between items on a line
column0: CARDINAL = 0; -- horizontal space between margin and column 0;
column1: CARDINAL = 100; -- horizontal space between margin and column 1;
column2: CARDINAL = 200; -- horizontal space between margin and column 2.
column3: CARDINAL = 300; -- horizontal space between margin and column 3;

EditToolData: TYPE = REF EditToolDataObj;
EditToolDataObj: TYPE = SVEditUser.EditToolDataObj;

SphereSectionData: TYPE = SVEditUser.SphereSectionData;
BlockSectionData: TYPE = SVEditUser.BlockSectionData;
CylinderSectionData: TYPE = SVEditUser.CylinderSectionData;
ConeSectionData: TYPE = SVEditUser.ConeSectionData;

Init: PROC = {
 UserExec.RegisterCommand[
  name: "SolidViews",
  proc: BuildEditTool,
  briefDoc: "Create a 3d graphics tool"
  ];
 [] ← BuildEditTool[NIL, UserExec.GetExecHandle[], NIL]; -- create an instance of our tool
 };

BuildEditTool: UserExec.CommandProc = TRUSTED {
-- here we create the container

 editToolData: EditToolData ← NEW[EditToolDataObj];
 editToolData.outer ← Containers.Create[[
  name: "SolidViews EditTool",
  iconic: TRUE,
  column: right,
  scrollable: TRUE
  ]];
  
 editToolData.sceneSection.defaultScene ← DisplayList3d.CreateScene["DefaultScene"];
 editToolData.sceneSection.currentScene ← editToolData.sceneSection.defaultScene;
 editToolData.allViewers ← NIL;
 SVEditToolMenus.BuildCurrentSceneSection[editToolData];
 SVEditToolMenus.AddARule[editToolData];
 SVEditToolMenus.BuildCompositeSection[editToolData];
 SVEditToolMenus.BuildSphereSection[editToolData];
 SVEditToolMenus.BuildBlockSection[editToolData];
 SVEditToolMenus.BuildCylinderSection[editToolData];
 SVEditToolMenus.BuildConeSection[editToolData];
 SVEditToolMenus.BuildTorusSection[editToolData];
 SVEditToolMenus.BuildLinearSweepSection[editToolData];
 SVEditToolMenus.BuildRevoluteSweepSection[editToolData];
 SVEditToolMenus.BuildCopySection[editToolData];
 SVEditToolMenus.BuildRenameSection[editToolData];
 SVEditToolMenus.BuildMoveSection[editToolData];
 SVEditToolMenus.AddARule[editToolData];
 SVEditToolMenus.BuildTransformSection[editToolData];
 SVEditToolMenus.AddARule[editToolData];
 SVEditToolMenus.BuildListingSection[editToolData];
 SVEditToolMenus.AddARule[editToolData];
 SVEditToolMenus.BuildCameraSection[editToolData];
 SVEditToolMenus.AddARule[editToolData];
 SVEditToolMenus.BuildArtworkSection[editToolData];
 SVEditToolMenus.BuildTubeArtworkSection[editToolData];
 SVEditToolMenus.BuildBoxArtworkSection[editToolData];
 SVEditToolMenus.BuildArtworkTransformSection[editToolData];
 SVEditToolMenus.AddARule[editToolData];
 SVEditToolMenus.BuildLightSourceSection[editToolData];
 SVEditToolMenus.AddARule[editToolData];
 [----,editToolData.scratchpad] ←
  Scratchpad2d.CreateScratchpad[editToolData.outer];
 editToolData.artworkTool ← SVArtworkTool.Create[paint: TRUE];
 ViewerOps.PaintViewer[editToolData.outer, all];
 ViewerOps.OpenIcon[editToolData.outer, TRUE, TRUE, TRUE];
 SVEditUser.NewViewer[NIL, editToolData, red, FALSE, FALSE];
 }; -- end of BuildEditTool

Init[];

END.