File: SVEditUserImplA.mesa
Last edited by Bier on May 23, 1985 2:18:59 pm PDT
Copyright © 1984 by Xerox Corporation. All rights reserved.
Author: Eric Bier in October 1982
Contents: All of the procedures called by SVEditTool when menus and buttons are pressed
DIRECTORY
DisplayList3d,
FileNames,
Graphics,
IO,
Labels,
Menus,
Rope,
SVEditUser,
SVFiles,
SV2d,
SV3d,
SVError,
SVInterfaceTypes,
SVModelTypes,
SVRayTypes,
SVSceneTypes,
SVToolObject,
SVTransforms,
SVViewer,
SVViewerInput,
SVViewerUser,
TFI3d,
ViewerClasses,
ViewerIO,
ViewerOps,
ViewerTools;
SVEditUserImplA: CEDAR PROGRAM
IMPORTS DisplayList3d, FileNames, IO, Labels, Rope, SVError, SVFiles, SVViewer, SVViewerUser, TFI3d, ViewerIO, ViewerOps, ViewerTools
EXPORTS SVEditUser =
BEGIN
ArtworkToolData: TYPE = SVInterfaceTypes.ArtworkToolData;
Assembly: TYPE = REF AssemblyObj;
AssemblyObj: TYPE = SVSceneTypes.AssemblyObj;
AssemblyList: TYPE = SVSceneTypes.AssemblyList;
Camera: TYPE = SVModelTypes.Camera;
CoordSystem: TYPE = SVModelTypes.CoordSystem;
DCProc: TYPE = SVInterfaceTypes.DCProc;
EditToolData: TYPE = SVInterfaceTypes.EditToolData;
MasterObject: TYPE = SVSceneTypes.MasterObject;
Matrix4by4: TYPE = SV3d.Matrix4by4;
MouseButton: TYPE = Menus.MouseButton;
Point2d: TYPE = SV2d.Point2d;
Point3d: TYPE = SV3d.Point3d;
PointSetOp: TYPE = SVRayTypes.PointSetOp;
Primitive: TYPE = SVRayTypes.Primitive;
Scene: TYPE = SVSceneTypes.Scene;
ScratchpadData: TYPE = SVInterfaceTypes.ScratchpadData;
Selection: TYPE = SVInterfaceTypes.Selection;
ToolData: TYPE = SVSceneTypes.ToolData;
Viewer: TYPE = ViewerClasses.Viewer;
ViewerCell: TYPE = REF ViewerCellObj;
ViewerCellObj: TYPE = SVInterfaceTypes.ViewerCellObj;
ViewerProc: TYPE = SVEditUser.ViewerProc;
ViewerAssemblyProc: TYPE = SVEditUser.ViewerAssemblyProc;
ViewerToolData: TYPE = SVInterfaceTypes.ViewerToolData;
GLOBAL VARIABLES
PaintSceneAllViewers: PUBLIC PROC [proc: ViewerProc, editToolData: EditToolData, scene: Scene] = TRUSTED {
viewerToolData: ViewerToolData;
success: BOOL;
viewerCell: ViewerCell;
drawProc: PROC [dc: Graphics.Context] = TRUSTED {
proc[dc, viewerToolData];
};
[viewerCell, success] ← FindSceneInAllViewers[scene, editToolData.allViewers];
IF NOT success THEN ERROR;
Draw the first viewer if there is one.
IF viewerCell.viewersOnScene = NIL THEN RETURN;
viewerToolData ← NARROW[viewerCell.viewersOnScene.data];
SVViewerUser.Painter[drawProc, viewerToolData];
Draw the rest (remember they are linked in a ring)
IF viewerCell.viewersOnScene.link = NIL THEN RETURN;
FOR list: Viewer ← viewerCell.viewersOnScene.link, list.link
UNTIL list = viewerCell.viewersOnScene DO
viewerToolData ← NARROW[list.data];
SVViewerUser.Painter[drawProc, viewerToolData];
ENDLOOP;
};
PaintAssemblyAllViewers: PUBLIC PROC [proc: ViewerAssemblyProc, editToolData: EditToolData, scene: Scene, assembly: Assembly] = {
viewerToolData: ViewerToolData;
success: BOOL;
viewerCell: ViewerCell;
drawProc: PROC [dc: Graphics.Context] = TRUSTED {
proc[dc, viewerToolData, assembly];
};
[viewerCell, success] ← FindSceneInAllViewers[scene, editToolData.allViewers];
IF NOT success THEN ERROR;
Draw the first viewer if there is one.
IF viewerCell.viewersOnScene = NIL THEN RETURN;
viewerToolData ← NARROW[viewerCell.viewersOnScene.data];
SVViewerUser.Painter[drawProc, viewerToolData];
Draw the rest (remember they are linked in a ring)
IF viewerCell.viewersOnScene.link = NIL THEN RETURN;
FOR list: Viewer ← viewerCell.viewersOnScene.link, list.link
UNTIL list = viewerCell.viewersOnScene DO
viewerToolData ← NARROW[list.data];
SVViewerUser.Painter[drawProc, viewerToolData];
ENDLOOP;
};
DrawAnySelections: PUBLIC PROC [dc: Graphics.Context, viewerToolData: ViewerToolData] = TRUSTED {
If the target or movee selection is in viewerToolData.outer then draw the coordinate system of this selection. Tell the selection about the current positions of CAMERA and WORLD before drawing it (We will assume, for now, that the assembly it refers to is already updated).
IF targetSelection.viewerToolData = viewerToolData AND targetSelection.assembly # NIL
THEN {
SVTransforms.TellAboutParent[targetSelection.coordSys];
SVViewerUser.DrawOneTargetCS[dc, viewerToolData, targetSelection.coordSys];
};
IF moveeSelection.viewerToolData = viewerToolData AND moveeSelection.assembly # NIL
THEN {
SVTransforms.TellAboutParent[moveeSelection.coordSys];
SVViewerUser.DrawOneCS[dc, viewerToolData, moveeSelection.coordSys];
};
};
SetTargetSelection: PUBLIC PROC [cameraPoint: Point2d, assembly: Assembly, primitive: Primitive, worldMat: Matrix4by4, viewerToolData: ViewerToolData] RETURNS [selection: Selection] = TRUSTED {
targetSelection.cameraPoint ← cameraPoint;
targetSelection.primitive ← primitive;
targetSelection.assembly ← assembly;
IF assembly # NIL THEN {
targetSelection.coordSys.parent ← assembly.coordSys.parent;
targetSelection.coordSys.mat ← Matrix3d.WorldToLocal[targetSelection.coordSys.withRespectTo.wrtWorld, worldMat];
targetSelection.coordSys.wrtWorld ← worldMat; -- not necessary but as long as its already calculated...
};
targetSelection.viewerToolData ← viewerToolData;
selection ← targetSelection;
At this point, we may wish to update "Assembly:" in the edittool to be the selected assembly. We should also make sure that the selected scene is the scene we are now pointing at.
SVViewerUser.Selected[NIL, viewerToolData, red, FALSE, FALSE]; -- fake a button push
SetTargetName[assembly, NARROW[viewerToolData.editToolData]];
};
SetMoveeSelection: PUBLIC PROC [cameraPoint: Point2d, assembly: Assembly, primitive: Primitive, worldMat: Matrix4by4, viewerToolData: ViewerToolData] RETURNS [selection: Selection] = TRUSTED {
moveeSelection.cameraPoint ← cameraPoint;
moveeSelection.assembly ← assembly;
moveeSelection.primitive ← primitive;
IF assembly # NIL THEN {
moveeSelection.coordSys.withRespectTo ← assembly.coordSys.withRespectTo;
moveeSelection.coordSys.mat ←
Matrix3d.WorldToLocal[moveeSelection.coordSys.withRespectTo.wrtWorld, worldMat];
moveeSelection.coordSys.wrtWorld ← worldMat; -- not necessary but as long as its already calculated...
};
moveeSelection.viewerToolData ← viewerToolData;
selection ← moveeSelection;
At this point, we may wish to update "WRT:" in the edittool to be the selected assembly.
SetMoveeName[assembly, NARROW[viewerToolData.editToolData]];
};
SetFinalTarget: PUBLIC PROC [cameraPoint: Point2d, assembly: Assembly, primitive: Primitive, worldMat: Matrix4by4, viewerToolData: ViewerToolData] RETURNS [selection: Selection] = TRUSTED {
localMat: Matrix4by4;
withRespectTo: CoordSystem;
finalTarget ← NEW[SelectionObj];
finalTarget.cameraPoint ← cameraPoint;
finalTarget.assembly ← assembly;
finalTarget.primitive ← primitive;
IF assembly # NIL THEN {
withRespectTo ← assembly.coordSys.withRespectTo;
localMat ← Matrix3d.WorldToLocal[withRespectTo.wrtWorld, worldMat];
finalTarget.coordSys ← CoordSys.CreateCoordSys["finalTarget", localMat, withRespectTo];
};
finalTarget.viewerToolData ← viewerToolData;
selection ← finalTarget;
};
SetFinalMovee: PUBLIC PROC [cameraPoint: Point2d, assembly: Assembly, primitive: Primitive, worldMat: Matrix4by4, viewerToolData: ViewerToolData] RETURNS [selection: Selection] = TRUSTED {
localMat: Matrix4by4;
withRespectTo: CoordSystem;
finalMovee ← NEW[SelectionObj];
finalMovee.cameraPoint ← cameraPoint;
finalMovee.assembly ← assembly;
finalMovee.primitive ← primitive;
IF assembly # NIL THEN {
withRespectTo ← assembly.coordSys.withRespectTo;
localMat ← Matrix3d.WorldToLocal[withRespectTo.wrtWorld, worldMat];
finalMovee.coordSys ← CoordSys.CreateCoordSys["finalMovee", localMat, withRespectTo];
};
finalMovee.viewerToolData ← viewerToolData;
selection ← finalMovee;
};
NewOutput: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
newViewer: Viewer;
inHandle, outHandle: IO.STREAM;
[inHandle, outHandle, newViewer] ← MakeNewViewerAndHandle[];
SVError.SetErrorStream[outHandle];
editToolData.messages ← newViewer;
};
MakeNewViewerAndHandle: PRIVATE PROC [] RETURNS [in, out: IO.STREAM, newViewer: Viewer] = TRUSTED {
newViewer ← ViewerOps.CreateViewer[
flavor: $TypeScript,
info: [
name: "SolidViews Typescript",
menu: NIL,
data: NIL,
iconic: TRUE,
column: right,
scrollable: TRUE,
icon: unInit
],
paint: FALSE];
ViewerOps.SetOpenHeight[newViewer, 120];
ViewerOps.OpenIcon[icon: newViewer, closeOthers: FALSE, bottom: TRUE, paint: TRUE];
[in, out] ← ViewerIO.CreateViewerStreams["solidviews output", newViewer, NIL, TRUE];
};
NewViewer: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED {
clientData is editToolData
editToolData: EditToolData ← NARROW[clientData];
viewerCell: ViewerCell;
currentViewerToolData: ViewerToolData;
wdir: Rope.ROPE;
scene: Scene;
wdir ← editToolData.originalWorkingDirectory;
scene ← DisplayList3d.CreateScene[Rope.Concat[wdir, "NoName.pic"]];
[currentViewerToolData, ----] ← SVViewer.CreateViewerTool[editToolData, scene, FALSE, TRUE, editToolData.originalWorkingDirectory];
[viewerCell, editToolData.allViewers] ← AddSceneToAllViewers[scene, editToolData.allViewers];
AddViewerToViewerCell[currentViewerToolData.outer, viewerCell];
SVViewerUser.Selected[NIL, currentViewerToolData, red, FALSE, FALSE];
fake a button press on the Selected button
SVViewerUser.UpdateHeader[scene.name, currentViewerToolData];
};
FindSceneInAllViewers: PUBLIC PROC [scene: Scene, allViewers: LIST OF ViewerCell] RETURNS [viewerCell: ViewerCell, success: BOOL] = TRUSTED {
success ← FALSE;
FOR list: LIST OF ViewerCell ← allViewers, list.rest UNTIL list = NIL OR success DO
IF list.first.scene = scene THEN {
viewerCell ← list.first;
success ← TRUE;
RETURN;
};
ENDLOOP;
};
AddSceneToAllViewers: PUBLIC PROC [scene: Scene, allViewers: LIST OF ViewerCell] RETURNS [viewerCell: ViewerCell, newAllViewers: LIST OF ViewerCell] = TRUSTED {
viewerCell ← NEW[ViewerCellObj ← [scene, NIL]];
newAllViewers ← CONS[viewerCell, allViewers];
};
FindViewerInAllViewers: PUBLIC PROC [viewer: Viewer, allViewers: LIST OF ViewerCell] RETURNS [viewerCell: ViewerCell, before, listCell, after: Viewer, success: BOOL] = TRUSTED {
viewers are linked in a ring so we go around until we are back at the first viewer.
firstViewer: Viewer;
success ← FALSE;
FOR allList: LIST OF ViewerCell ← allViewers, allList.rest UNTIL allList = NIL OR success DO
before ← NIL;
firstViewer ← allList.first.viewersOnScene;
IF firstViewer = NIL THEN LOOP;
is it the first viewer?
IF firstViewer = viewer THEN {
listCell ← firstViewer;
after ← firstViewer.link;
viewerCell ← allList.first;
success ← TRUE;
RETURN};
before ← firstViewer;
IF firstViewer.link = NIL THEN LOOP;
FOR viewerList: Viewer ← firstViewer.link, viewerList.link
UNTIL viewerList = firstViewer OR success DO
IF viewerList = viewer THEN {
listCell ← viewerList;
after ← viewerList.link;
viewerCell ← allList.first;
success ← TRUE;
RETURN};
before ← viewerList;
ENDLOOP;
ENDLOOP;
};
FindViewerInViewerCell: PUBLIC PROC [viewer: Viewer, viewerCell: ViewerCell] RETURNS [before, listCell, after: Viewer, success: BOOL] = TRUSTED {
viewers are linked in a ring so we go around until we are back at the first viewer.
firstViewer: Viewer;
success ← FALSE;
firstViewer ← viewerCell.viewersOnScene;
IF firstViewer = NIL THEN {success ← FALSE; RETURN};
is it the first viewer?
IF firstViewer = viewer THEN {
before ← NIL;-- this tells delete proc that it needs a new firstViewer
listCell ← firstViewer;
after ← firstViewer.link;
success ← TRUE;
RETURN};
before ← firstViewer;
FOR viewerList: Viewer ← viewerCell.viewersOnScene.link, viewerList.link
UNTIL viewerList = firstViewer OR viewerList = NIL DO
IF viewerList = viewer THEN {
listCell ← viewerList;
after ← viewerList.link;
success ← TRUE;
RETURN};
before ← viewerList;
ENDLOOP;
success ← FALSE;
};
DeleteViewerFromAllViewers: PUBLIC PROC [viewerCell: ViewerCell, before, listCell, after: Viewer] = TRUSTED {
viewerToolData: ViewerToolData;
IF before = NIL OR viewerCell.viewersOnScene = listCell THEN {
ViewerCell is in the key spot. after becomes new key spot.
Search the ring for the last cell (which currently refers to viewer cell) and have it refer to after.
IF after = NIL THEN {viewerCell.viewersOnScene ← NIL; RETURN};
FOR v: Viewer ← after, v.link
UNTIL v.link = listCell DO
REPEAT FINISHED =>
IF v = after THEN {
after.link ← NIL;
viewerToolData ← NARROW[after.data];
SVViewerUser.UpdateHeader[NIL, viewerToolData]}
ELSE v.link ← after;
ENDLOOP;
viewerCell.viewersOnScene ← after;
}
ELSE {
IF before = after THEN {
after.link ← NIL;
viewerToolData ← NARROW[after.data];
SVViewerUser.UpdateHeader[NIL, viewerToolData]}
ELSE before.link ← after;
};
};
AddViewerToViewerCell: PUBLIC PROC [viewer: Viewer, viewerCell: ViewerCell] = TRUSTED {
IF viewerCell.viewersOnScene = NIL THEN {
viewer.link ← NIL;
viewerCell.viewersOnScene ← viewer;
RETURN};
viewer.link ← viewerCell.viewersOnScene;
IF viewerCell.viewersOnScene.link = NIL THEN
viewerCell.viewersOnScene.link ← viewer
ELSE FOR v: Viewer ← viewerCell.viewersOnScene.link, v.link
UNTIL v.link=viewerCell.viewersOnScene DO
REPEAT FINISHED => v.link ← viewer;
ENDLOOP;
viewerCell.viewersOnScene ← viewer;
};
LoadScene: PUBLIC PROC [viewerToolData: ViewerToolData, picName: Rope.ROPE, wdir: Rope.ROPE] RETURNS [scene: Scene, success: BOOL] = TRUSTED {
a viewer is loading a new scene. All newly loaded scenes are considered unique (since the file might have been editted by hand since last loading) Add a viewer cell.
editToolData: EditToolData ← NARROW[viewerToolData.editToolData];
oldViewerCell, newViewerCell: ViewerCell;
before, listCell, after: Viewer;
sceneName: Rope.ROPE;
[scene, success] ← SVFiles.OpenScene[picName, wdir];
IF NOT success THEN RETURN;
[newViewerCell, editToolData.allViewers] ←
AddSceneToAllViewers[scene, editToolData.allViewers];
[oldViewerCell, before, listCell, after, success] ← FindViewerInAllViewers[viewerToolData.outer, editToolData.allViewers];
IF success THEN {
DeleteViewerFromAllViewers[oldViewerCell, before, listCell, after];
AddViewerToViewerCell[viewerToolData.outer, newViewerCell];
editToolData.sceneSection.currentScene ← scene;
sceneName ← FileNames.GetShortName[scene.name];
Labels.Set[editToolData.sceneSection.sceneName, sceneName];
}
ELSE ERROR;
};
SaveScene: PUBLIC PROC [viewerToolData: ViewerToolData, picName: Rope.ROPE] RETURNS [success: BOOL] = TRUSTED {
a viewer is saving a scene. Save if possible. No other action required. This viewer should be on our list from when this scene was opened or stored.
scene: Scene ← viewerToolData.scene;
success ← SVFiles.SaveScene[scene, picName];
};
StoreScene: PUBLIC PROC [viewerToolData: ViewerToolData, scene: Scene, picName: Rope.ROPE] RETURNS [success: BOOL] = TRUSTED {
a viewer is storing a scene. If this viewer previously had a scene, we will have to remove it from that scene list and add it to a new one. Otherwise we just have to add it.
editToolData: EditToolData ← NARROW[viewerToolData.editToolData];
oldViewerCell, newViewerCell: ViewerCell;
before, listCell, after: Viewer;
sceneAlreadyExists, viewerThere: BOOLFALSE;
success ← SVFiles.StoreScene[scene, picName];
SVViewerUser.SceneOldVersion[viewerToolData];
IF NOT success THEN RETURN;
[oldViewerCell, before, listCell, after, viewerThere] ←
FindViewerInAllViewers[viewerToolData.outer, editToolData.allViewers];
IF viewerThere THEN {-- if viewer was there delete it.
IF oldViewerCell.scene = scene THEN RETURN; -- user is storing old file.
DeleteViewerFromAllViewers[oldViewerCell, before, listCell, after];
};
if this viewerCell doesn't exist, add it.
[newViewerCell, sceneAlreadyExists] ← FindSceneInAllViewers[scene, editToolData.allViewers];
IF NOT sceneAlreadyExists THEN [newViewerCell, editToolData.allViewers] ←
AddSceneToAllViewers[scene, editToolData.allViewers];
add scene to proper viewer cell.
AddViewerToViewerCell[viewerToolData.outer, newViewerCell];
};
NotifyOfEmpty: PUBLIC PROC [viewerToolData: ViewerToolData, from: Scene, to: Scene] = TRUSTED {
editToolData: EditToolData ← NARROW[viewerToolData.editToolData];
before, listCell, after: Viewer;
success: BOOL;
viewerCell, newViewerCell: ViewerCell;
[viewerCell, success] ← FindSceneInAllViewers[from, editToolData.allViewers];
IF NOT success THEN ERROR;
[before, listCell, after, success] ← FindViewerInViewerCell [viewerToolData.outer, viewerCell];
IF NOT success THEN ERROR;
DeleteViewerFromAllViewers[viewerCell, before, listCell, after];
[newViewerCell, editToolData.allViewers] ← AddSceneToAllViewers[to, editToolData.allViewers];
AddViewerToViewerCell[viewerToolData.outer, newViewerCell];
};
NotifyDestroy: PUBLIC PROC [viewer: Viewer] = TRUSTED {
This viewer is about to be destroyed. The window manager will take care of removing it from our linked list. However, make sure that this viewer is not the viewer refered to by the viewerCell corresponding to its scene. (We would lose all our viewers if this is the case). If so, move our pointer to someone else.
viewerCell: ViewerCell;
before, listCell, after: Viewer;
success: BOOL;
viewerToolData: ViewerToolData ← NARROW[viewer.data];
editToolData: EditToolData ← NARROW[viewerToolData.editToolData];
[viewerCell, before, listCell, after, success] ← FindViewerInAllViewers[viewer, editToolData.allViewers];
IF NOT success THEN ERROR;
IF viewerCell.viewersOnScene = viewer THEN viewerCell.viewersOnScene ← viewer.link;
};
SceneNewVersion: PUBLIC PROC [viewerToolData: ViewerToolData] = TRUSTED {
Loops through split viewers updating headers.
viewerCell: ViewerCell;
scene: Scene ← viewerToolData.scene;
firstViewer: Viewer;
success: BOOL;
editToolData: EditToolData ← NARROW[viewerToolData.editToolData];
[viewerCell, success] ← FindSceneInAllViewers [scene, editToolData.allViewers];
IF NOT success THEN ERROR;
firstViewer ← viewerCell.viewersOnScene;
SVViewerUser.NewVersion[firstViewer];
FOR viewerList: Viewer ← firstViewer.link, viewerList.link
UNTIL viewerList = NIL OR viewerList = firstViewer DO
SVViewerUser.NewVersion[viewerList];
ENDLOOP;
};
UpdateAllHeaders: PUBLIC PROC [viewerToolData: ViewerToolData, scene: Scene] = TRUSTED {
Loops through split viewers updating headers.
viewerCell: ViewerCell;
firstViewer: Viewer;
success: BOOL;
editToolData: EditToolData ← NARROW[viewerToolData.editToolData];
[viewerCell, success] ← FindSceneInAllViewers [scene, editToolData.allViewers];
IF NOT success THEN ERROR;
firstViewer ← viewerCell.viewersOnScene;
SVViewerUser.UpdateHeader[scene.name, NARROW[firstViewer.data]];
FOR viewerList: Viewer ← firstViewer.link, viewerList.link
UNTIL viewerList = NIL OR viewerList = firstViewer DO
SVViewerUser.UpdateHeader[scene.name, NARROW[viewerList.data]];
ENDLOOP;
};
SceneOldVersion: PUBLIC PROC [viewerToolData: ViewerToolData, scene: Scene] = TRUSTED {
Loops through split viewers updating headers.
viewerCell: ViewerCell;
firstViewer: Viewer;
success: BOOL;
editToolData: EditToolData ← NARROW[viewerToolData.editToolData];
[viewerCell, success] ← FindSceneInAllViewers [scene, editToolData.allViewers];
IF NOT success THEN ERROR;
firstViewer ← viewerCell.viewersOnScene;
SVViewerUser.OldVersion[firstViewer];
FOR viewerList: Viewer ← firstViewer.link, viewerList.link
UNTIL viewerList = NIL OR viewerList = firstViewer DO
SVViewerUser.OldVersion[viewerList];
ENDLOOP;
This viewer has just been loaded with a different scene. Any selections are now invalid.
IF targetSelection.viewerToolData = viewerToolData THEN targetSelection.assembly ← NIL;
IF moveeSelection.viewerToolData = viewerToolData THEN moveeSelection.assembly ← NIL;
};
NewSelectedViewer: PUBLIC PROC [viewerToolData: ViewerToolData] = TRUSTED {
editToolData: EditToolData ← NARROW[viewerToolData.editToolData];
sceneName: Rope.ROPE;
IF viewerToolData # editToolData.currentViewerToolData
THEN {
SVViewerUser.Deselected[editToolData.currentViewerToolData];
editToolData.currentViewerToolData ← viewerToolData;
editToolData.sceneSection.currentScene ← viewerToolData.scene;
viewerToolData.textSection.isSelected ← TRUE;
Labels.SetDisplayStyle[viewerToolData.textSection.selected, $WhiteOnBlack, TRUE];
sceneName ← FileNames.GetShortName[viewerToolData.scene.name];
Labels.Set[editToolData.sceneSection.sceneName, sceneName];
};
};
ReSelectViewer: PUBLIC PROC [viewerToolData: ViewerToolData] = {
editToolData: EditToolData ← NARROW[viewerToolData.editToolData];
sceneName: Rope.ROPE;
IF editToolData.currentViewerToolData # viewerToolData THEN {
SVViewerUser.Deselected[editToolData.currentViewerToolData];
editToolData.currentViewerToolData ← viewerToolData;
viewerToolData.textSection.isSelected ← TRUE;
Labels.SetDisplayStyle[viewerToolData.textSection.selected, $WhiteOnBlack, TRUE];
sceneName ← FileNames.GetShortName[viewerToolData.scene.name];
Labels.Set[editToolData.sceneSection.sceneName, sceneName];
};
editToolData.sceneSection.currentScene ← viewerToolData.scene;
This should not be necessary but just in case.
};
SetSourceName: PUBLIC PROC [source: Assembly, editToolData: EditToolData] = {
oldMoveeRope: Rope.ROPE ← ViewerTools.GetContents[editToolData.sceneSection.source];
IF source = NIL THEN ViewerTools.SetContents[editToolData.sceneSection.source, NIL]
ELSE {
IF NOT Rope.Equal[oldMoveeRope, source.name, TRUE] THEN
ViewerTools.SetContents[editToolData.sceneSection.source, source.name];
};
};
SetTargetName: PUBLIC PROC [target: Assembly, editToolData: EditToolData] = {
oldTargetRope: Rope.ROPE ← ViewerTools.GetContents[editToolData.sceneSection.target];
IF target = NIL THEN ViewerTools.SetContents[editToolData.sceneSection.target, NIL]
ELSE {
IF NOT Rope.Equal[oldTargetRope, target.name, TRUE] THEN
ViewerTools.SetContents[editToolData.sceneSection.target, target.name];
};
};
SetPlaneName: PUBLIC PROC [plane: Assembly, editToolData: EditToolData] = {
oldPlaneRope: Rope.ROPE ← ViewerTools.GetContents[editToolData.sceneSection.plane];
IF plane = NIL THEN ViewerTools.SetContents[editToolData.sceneSection.plane, NIL]
ELSE {
IF NOT Rope.Equal[oldPlaneRope, plane.name, TRUE] THEN
ViewerTools.SetContents[editToolData.sceneSection.plane, plane.name];
};
};
SetCurrentAssemblyName: PUBLIC PROC [current: Assembly, editToolData: EditToolData] = {
oldSkitterRope: Rope.ROPE ← ViewerTools.GetContents[editToolData.sceneSection.current];
IF current = NIL THEN ViewerTools.SetContents[editToolData.sceneSection.current, NIL]
ELSE {
IF NOT Rope.Equal[oldSkitterRope, current.name, TRUE] THEN
ViewerTools.SetContents[editToolData.sceneSection.current, current.name];
};
};
Split: PUBLIC PROC [viewerToolData: ViewerToolData, scene: Scene] = TRUSTED {
Create a new viewer and split all viewers onto this scene
viewerCell: ViewerCell;
oldViewer, newViewer: Viewer;
success: BOOL;
currentViewerToolData: ViewerToolData;
editToolData: EditToolData ← NARROW[viewerToolData.editToolData];
[currentViewerToolData,----] ← SVViewer.CreateViewerTool[editToolData, scene, FALSE, FALSE, editToolData.originalWorkingDirectory];
newViewer ← currentViewerToolData.outer;
oldViewer ← viewerToolData.outer;
[viewerCell, success] ← FindSceneInAllViewers[scene, editToolData.allViewers];
AddViewerToViewerCell[newViewer, viewerCell];
newViewer.newVersion ← oldViewer.newVersion;
newViewer.newFile ← oldViewer.newFile;
newViewer.file ← oldViewer.file;
SVViewerUser.UpdateHeader[scene.name, currentViewerToolData];
ViewerOps.ComputeColumn[column: newViewer.column, paint: TRUE]; -- now do the painting
};
DestroyAllSolidviewsWindows: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = {
Destroy all solid viewers, the artwork tool, the scratchpad, the messages viewer, and the editTool. The user is done with Solidviews.
editToolData: EditToolData ← NARROW[clientData];
allViewers: LIST OF ViewerCell ← editToolData.allViewers;
viewerCell: ViewerCell;
artworkTool: Viewer ← NARROW[editToolData.artworkTool.data, ArtworkToolData].outer;
scratchpad: Viewer ← NARROW[editToolData.scratchpad.data, ScratchpadData].scratchViewerData.outer;
messages: Viewer ← editToolData.messages;
editTool: Viewer ← editToolData.outer;
next: Viewer;
FOR sceneCellList: LIST OF ViewerCell ← allViewers, sceneCellList.rest UNTIL sceneCellList = NIL DO
viewerCell ← sceneCellList.first;
IF viewerCell.viewersOnScene = NIL THEN {}
ELSE{
IF viewerCell.viewersOnScene.link = NIL THEN {}
ELSE {
FOR list: Viewer ← viewerCell.viewersOnScene.link, next
UNTIL list = viewerCell.viewersOnScene DO
next ← list.link;
ViewerOps.DestroyViewer[list];
ENDLOOP;
};
ViewerOps.DestroyViewer[viewerCell.viewersOnScene];
};
ENDLOOP;
ViewerOps.DestroyViewer[artworkTool];
ViewerOps.DestroyViewer[scratchpad];
ViewerOps.DestroyViewer[messages];
ViewerOps.DestroyViewer[editTool];
};
TGetCoordSys: PUBLIC PROC [viewer: Viewer, scene: Scene] RETURNS [cs: CoordSystem, success: BOOL] = TRUSTED {
csRope: Rope.ROPE;
csList: CoordSys.CoordSysList;
csRope ← ViewerTools.GetContents[viewer];
success ← TRUE;
csList ← CoordSys.MakeListFromTree[scene.coordSysRoot];
cs ← CoordSys.FindCoordSysInList[csRope, csList
! CoordSys.CoordSysNotFound => {success ← FALSE; CONTINUE}];
IF NOT success THEN {
SVError.Append["Assembly ", TRUE];
SVError.Append[csRope];
SVError.Append[" not found", FALSE, TRUE];
SVError.Blink[];
};
}; -- end of GetCoordSys
TGetAssembly: PUBLIC PROC [viewer: Viewer, scene: Scene] RETURNS [as: Assembly, success: BOOL] = TRUSTED {
viewer is a TextViewer.
asRope: Rope.ROPE;
asRope ← ViewerTools.GetContents[viewer];
success ← TRUE;
[as, ----] ← DisplayList3d.FindAssemblyFromName[asRope, scene
!DisplayList3d.AssemblyNotFound => {
SVError.Append["Assembly ", TRUE];
SVError.Append[asRope];
SVError.Append[" not found", FALSE, TRUE];
SVError.Blink[];
success ← FALSE;
CONTINUE}]
}; -- end of GetAssembly
FindAssemblyFromName: PUBLIC PROC [name: Rope.ROPE, scene: Scene] RETURNS [assembly: Assembly, superAssembly: Assembly, found: BOOL] = TRUSTED {
found ← TRUE;
[assembly, superAssembly] ←
DisplayList3d.FindAssemblyFromName[name, scene
!DisplayList3d.AssemblyNotFound => {found ← FALSE; CONTINUE}];
IF NOT found THEN {
SVError.Append["Assembly ", TRUE];
SVError.Append[name];
SVError.Append[" not found", FALSE, TRUE];
SVError.Blink[];
};
};
GetParent: PUBLIC PROC [editToolData: EditToolData] RETURNS [super: Assembly, success: BOOL] = TRUSTED {
superName: Rope.ROPE ← ViewerTools.GetContents[editToolData.sceneSection.parent];
scene: Scene ← editToolData.sceneSection.currentScene;
success ← TRUE;
super ← NIL;
[super, ----] ← DisplayList3d.FindAssemblyFromName[superName, scene
!DisplayList3d.AssemblyNotFound => {success ← FALSE; CONTINUE}];
IF NOT success THEN {
SVError.Append["Assembly "];
SVError.Append[superName];
SVError.Append[" not found", FALSE, TRUE];
SVError.Blink[];};
}; -- end of GetParent
GetPoint3d: PUBLIC PROC [textViewer: Viewer] RETURNS [pt: Point3d] = TRUSTED {
wholeRope: Rope.ROPE ← ViewerTools.GetContents[textViewer];
wholeStream: IO.STREAMIO.RIS[wholeRope];
TFI3d.ReadBlank[wholeStream];
pt[1] ← TFI3d.ReadReal[wholeStream];
TFI3d.ReadBlankAndRope[wholeStream, ","];
TFI3d.ReadBlank[wholeStream];
pt[2] ← TFI3d.ReadReal[wholeStream];
TFI3d.ReadBlankAndRope[wholeStream, ","];
TFI3d.ReadBlank[wholeStream];
pt[3] ← TFI3d.ReadReal[wholeStream];
};
ScenePrompt: PUBLIC PROC[parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.sceneSection.sceneName];
};
CurrentAssemblyPrompt: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.sceneSection.current];
};
SourcePrompt: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.sceneSection.source];
};
TargetPrompt: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.sceneSection.target];
};
NewPrompt: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.sceneSection.new];
};
ParentPrompt: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.sceneSection.parent];
};
RGBPrompt: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.artworkSection.rgb];
};
SphereRadiusPrompt: PUBLIC PROC[parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.sphereSection.radius];
};
BlockXYZPrompt: PUBLIC PROC[parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.blockSection.xyz];
};
CylinderRadiusPrompt: PUBLIC PROC[parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.cylinderSection.radius];
};
CylinderHeightPrompt: PUBLIC PROC[parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.cylinderSection.height];
};
ConeRadiusPrompt: PUBLIC PROC[parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.coneSection.radius];
};
ConeHeightPrompt: PUBLIC PROC[parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.coneSection.height];
};
BigRadiusPrompt: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton,
shift, control: BOOL] = TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.torusSection.bigRadius];
};
SectionRadiusPrompt: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton,
shift, control: BOOL] = TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.torusSection.sectionRadius];
};
LinDepthPrompt: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.linSection.depth];
};
StuffPrompt: PUBLIC PROC[parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.utilitySection.stuffNum];
};
DegreesPrompt: PUBLIC PROC[parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.transformSection.degrees];
};
TranslateXYZPrompt: PUBLIC PROC[parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.transformSection.transXYZ];
};
ScaleXYZPrompt: PUBLIC PROC[parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.transformSection.scaleXYZ];
};
EvenScaleXYZPrompt: PUBLIC PROC[parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.transformSection.scalar];
};
CameraNamePrompt: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.cameraSection.name];
};
FocusPrompt: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.cameraSection.focusPoint];
};
ScanResolutionPrompt: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton,
shift, control: BOOL] = TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.cameraSection.resolution];
};
CameraOriginPrompt: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.cameraSection.origin];
};
SlantPrompt: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.cameraSection.slant];
};
FocalLengthPrompt: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.cameraSection.focalLength];
};
FramePrompt: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.cameraSection.frame];
};
ClippingPlanePrompt: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.cameraSection.clippingPlanes];
};
VisibleAssemblyPrompt: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.cameraSection.visibleAssemblies];
};
CameraOrderPrompt: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.cameraOrderSection.order];
};
ResolutionPrompt: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.artworkSection.resolution];
};
TubeHeightPrompt: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.artworkSection.tubeHeight];
};
TubeRadiusPrompt: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.artworkSection.tubeRadius];
};
BoxXYZPrompt: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.artworkSection.boxXYZ];
};
ArtworkNamePrompt: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton,
shift, control: BOOL] = TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.artworkSection.picName];
};
ArtworkDegreesPrompt: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton,
shift, control: BOOL] = TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.artworkTransformSection.degrees];
};
LightNamePrompt: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.lightSection.name];
};
LightPositionPrompt: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.lightSection.position];
};
LightColorPrompt: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.lightSection.color];
};
Init: PRIVATE PROC = TRUSTED {
};
Init[];
END.