DrawAnySelections:
PUBLIC
PROC [dc: Graphics.Context, viewerToolData: ViewerToolData] =
TRUSTED {
If the primary or secondary 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 primarySelection.viewerToolData = viewerToolData
THEN {
CoordSys.TellAboutParent[primarySelection.coordSys];
SVViewerUser.DrawOneCS[dc, viewerToolData, primarySelection.coordSys];
};
IF secondarySelection.viewerToolData = viewerToolData
THEN {
CoordSys.TellAboutParent[secondarySelection.coordSys];
SVViewerUser.DrawOneCS[dc, viewerToolData, secondarySelection.coordSys];
};
};
SetPrimarySelection:
PUBLIC
PROC [cameraPoint: Point2d, assembly: Assembly, primitive: Primitive, worldMat: Matrix4by4, viewerToolData: ViewerToolData]
RETURNS [selection: Selection] =
TRUSTED {
primarySelection.cameraPoint ← cameraPoint;
primarySelection.primitive ← primitive;
primarySelection.assembly ← assembly;
IF assembly #
NIL
THEN {
primarySelection.coordSys.withRespectTo ← assembly.coordSys.withRespectTo;
primarySelection.coordSys.mat ← Matrix3d.WorldToLocal[primarySelection.coordSys.withRespectTo.wrtWorld, worldMat];
primarySelection.coordSys.wrtWorld ← worldMat; -- not necessary but as long as its already calculated...
};
primarySelection.viewerToolData ← viewerToolData;
selection ← primarySelection;
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
SetAssembly[assembly, NARROW[viewerToolData.editToolData]];
};
SetSecondarySelection:
PUBLIC
PROC [cameraPoint: Point2d, assembly: Assembly, primitive: Primitive, worldMat: Matrix4by4, viewerToolData: ViewerToolData]
RETURNS [selection: Selection] =
TRUSTED {
secondarySelection.cameraPoint ← cameraPoint;
secondarySelection.assembly ← assembly;
secondarySelection.primitive ← primitive;
IF assembly #
NIL
THEN {
secondarySelection.coordSys.withRespectTo ← assembly.coordSys.withRespectTo;
secondarySelection.coordSys.mat ←
Matrix3d.WorldToLocal[secondarySelection.coordSys.withRespectTo.wrtWorld, worldMat];
secondarySelection.coordSys.wrtWorld ← worldMat; -- not necessary but as long as its already calculated...
};
secondarySelection.viewerToolData ← viewerToolData;
selection ← secondarySelection;
};
SetFinalPrimary:
PUBLIC
PROC [cameraPoint: Point2d, assembly: Assembly, primitive: Primitive, worldMat: Matrix4by4, viewerToolData: ViewerToolData]
RETURNS [selection: Selection] =
TRUSTED {
localMat: Matrix4by4;
withRespectTo: CoordSystem;
finalPrimary ← NEW[SelectionObj];
finalPrimary.cameraPoint ← cameraPoint;
finalPrimary.assembly ← assembly;
finalPrimary.primitive ← primitive;
IF assembly #
NIL
THEN {
withRespectTo ← assembly.coordSys.withRespectTo;
localMat ← Matrix3d.WorldToLocal[withRespectTo.wrtWorld, worldMat];
finalPrimary.coordSys ← CoordSys.CreateCoordSys["finalPrimary", localMat, withRespectTo];
};
finalPrimary.viewerToolData ← viewerToolData;
selection ← finalPrimary;
};
SetFinalSecondary:
PUBLIC
PROC [cameraPoint: Point2d, assembly: Assembly, primitive: Primitive, worldMat: Matrix4by4, viewerToolData: ViewerToolData]
RETURNS [selection: Selection] =
TRUSTED {
localMat: Matrix4by4;
withRespectTo: CoordSystem;
finalSecondary ← NEW[SelectionObj];
finalSecondary.cameraPoint ← cameraPoint;
finalSecondary.assembly ← assembly;
finalSecondary.primitive ← primitive;
IF assembly #
NIL
THEN {
withRespectTo ← assembly.coordSys.withRespectTo;
localMat ← Matrix3d.WorldToLocal[withRespectTo.wrtWorld, worldMat];
finalSecondary.coordSys ← CoordSys.CreateCoordSys["finalSecondary", localMat, withRespectTo];
};
finalSecondary.viewerToolData ← viewerToolData;
selection ← finalSecondary;
};
GetPrimarySelection:
PUBLIC
PROC
RETURNS [selection: Selection] =
TRUSTED {
selection ← primarySelection;
};
GetSecondarySelection:
PUBLIC
PROC
RETURNS [selection: Selection] =
TRUSTED {
selection ← secondarySelection;
};
GetFinalPrimary:
PUBLIC
PROC
RETURNS [selection: Selection] =
TRUSTED {
selection ← finalPrimary;
};
GetFinalSecondary:
PUBLIC
PROC
RETURNS [selection: Selection] =
TRUSTED {
selection ← finalSecondary;
};
ExtendSecondary:
PUBLIC
PROC =
TRUSTED {
find parent of secondarySelection.assembly if any. Set secondarySelection.assembly to this value. Indicate the selection by changing the name in the "Assembly" slot of the edittool.
viewerPictureData: ViewerPictureData;
editToolData: EditToolData;
scene: Scene;
assembly, parent: Assembly;
IF secondarySelection.assembly = NIL THEN RETURN;
viewerPictureData ← NARROW[secondarySelection.viewerToolData.viewerPicture.data];
editToolData ← NARROW[secondarySelection.viewerToolData.editToolData];
scene ← viewerPictureData.scene;
[assembly, parent] ← DisplayList3d.FindAssemblyFromName[secondarySelection.assembly.name, scene];
IF parent#NIL THEN secondarySelection.assembly ← parent;
ViewerTools.SetContents[
editToolData.sceneSection.assemblyName,
secondarySelection.assembly.name, TRUE];
NotifyOfExtendedSelection[secondarySelection.viewerToolData, finalSecondary, secondarySelection]; -- **** Dangerous to assume that finalSecondary is correct
[] ← SetFinalSecondary[secondarySelection.cameraPoint, secondarySelection.assembly, secondarySelection.primitive, secondarySelection.coordSys.wrtWorld, secondarySelection.viewerToolData];
};
NotifyOfExtendedSelection:
PUBLIC
PROC [viewerToolData: ViewerToolData, oldSelection: Selection, newSelection: Selection] =
TRUSTED {
SVViewerInput.ComplementBoundBox[oldSelection.primitive.boundBox, viewerToolData];
SVViewerInput.ComplementBoundBox[newSelection.primitive.boundBox, viewerToolData];
};
Painter: 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;
};
GetOutHandle:
PUBLIC
PROC
RETURNS [outHandle:
IO.
STREAM] =
TRUSTED {
IF globalOutHandle = NIL
THEN [globalInHandle, globalOutHandle] ← MakeNewViewerAndHandle[];
outHandle ← globalOutHandle;
};
NewOutput:
PUBLIC
PROC [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
[globalInHandle, globalOutHandle] ← MakeNewViewerAndHandle[];
};
MakeNewViewerAndHandle:
PRIVATE
PROC []
RETURNS [in, out:
IO.
STREAM] =
TRUSTED {
newViewer: Viewer ← ViewerOps.CreateViewer[
flavor: $TypeScript,
info: [
name: "SolidViews Output",
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;
scene: Scene ← DisplayList3d.CreateScene["NoName.pic"];
[currentViewerToolData, ----] ← SVViewer.CreateViewerTool[editToolData, scene, FALSE, TRUE];
[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, viewerList.link
UNTIL viewerList = firstViewer
OR success
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]
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;
[scene, success] ← SVFiles.OpenScene[picName];
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;
Labels.Set[editToolData.sceneSection.sceneName, scene.name];
}
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.
viewerPictureData: ViewerPictureData ← NARROW[viewerToolData.viewerPicture.data];
scene: Scene ← viewerPictureData.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: BOOL ← FALSE;
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 is 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, 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.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;
};
NewSelectedViewer:
PUBLIC
PROC [viewerToolData: ViewerToolData] =
TRUSTED {
editToolData: EditToolData ← NARROW[viewerToolData.editToolData];
viewerPictureData: ViewerPictureData ← NARROW[viewerToolData.viewerPicture.data];
IF viewerToolData # editToolData.currentViewerToolData
THEN {
SVViewerUser.Deselected[editToolData.currentViewerToolData];
editToolData.currentViewerToolData ← viewerToolData;
editToolData.sceneSection.currentScene ← viewerPictureData.scene;
editToolData.currentViewerToolData.textSection.isSelected ← TRUE;
Labels.SetDisplayStyle[editToolData.currentViewerToolData.textSection.selected, $WhiteOnBlack, TRUE];
Labels.Set[editToolData.sceneSection.sceneName, viewerPictureData.scene.name];
};
};
ReSelectViewer:
PUBLIC
PROC [viewerToolData: ViewerToolData] = {
editToolData: EditToolData ← NARROW[viewerToolData.editToolData];
viewerPictureData: ViewerPictureData ← NARROW[viewerToolData.viewerPicture.data];
IF editToolData.currentViewerToolData # viewerToolData
THEN {
SVViewerUser.Deselected[editToolData.currentViewerToolData];
editToolData.currentViewerToolData ← viewerToolData;
editToolData.currentViewerToolData.textSection.isSelected ← TRUE;
Labels.SetDisplayStyle[editToolData.currentViewerToolData.textSection.selected, $WhiteOnBlack, TRUE];
};
editToolData.sceneSection.currentScene ← viewerPictureData.scene;
Labels.Set[editToolData.sceneSection.sceneName, viewerPictureData.scene.name];
};
SetAssembly:
PUBLIC PROC [assembly: Assembly, editToolData: EditToolData] = {
assemblyRope: Rope.ROPE ← ViewerTools.GetContents[editToolData.sceneSection.assemblyName];
IF
NOT Rope.Equal[assemblyRope, assembly.name,
TRUE]
THEN
ViewerTools.SetContents[editToolData.sceneSection.assemblyName, assembly.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];
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
};
DrawSceneInternal:
PUBLIC
PROC [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
scene: Scene ← editToolData.sceneSection.currentScene;
Painter[SVViewerUser.EraseAndDrawSceneEtc, editToolData, scene];
};
GetCoordSys:
PUBLIC
PROC [viewer: Viewer, scene: Scene]
RETURNS [cs: CoordSystem, success:
BOOL] =
TRUSTED {
csRope: Rope.ROPE;
csRope ← ViewerTools.GetContents[viewer];
success ← TRUE;
cs ← CoordSys.FindCoordSysFromName[csRope, scene.coordSystems
! CoordSys.CoordSysNotFound => {success ← FALSE; CONTINUE}];
IF
NOT success
THEN {
MessageWindow.Append["Assembly ", TRUE];
MessageWindow.Append[csRope];
MessageWindow.Append[" not found"];
MessageWindow.Blink[];
};
};-- end of GetCoordSys
GetAssembly:
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 => {MessageWindow.Append["Assembly ", TRUE];
MessageWindow.Append[asRope];
MessageWindow.Append[" not found"];
MessageWindow.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 {
MessageWindow.Append["Assembly ", TRUE];
MessageWindow.Append[name];
MessageWindow.Append[" not found"];
MessageWindow.Blink[];
};
GetSuper:
PUBLIC
PROC [editToolData: EditToolData]
RETURNS [super: Assembly, success:
BOOL] =
TRUSTED {
superName: Rope.ROPE ← ViewerTools.GetContents[editToolData.sceneSection.wrt];
scene: Scene ← editToolData.sceneSection.currentScene;
success ← TRUE;
super ← NIL;
[super, ----] ← DisplayList3d.FindAssemblyFromName[superName, scene
!DisplayList3d.AssemblyNotFound => {success ← FALSE; CONTINUE}];
IF
NOT success
THEN {
MessageWindow.Append["Assembly "];
MessageWindow.Append[superName];
MessageWindow.Append[" not found"];
MessageWindow.Blink[];};
}; -- end of GetSuper
GetPoint3d:
PUBLIC
PROC [textViewer: Viewer]
RETURNS [pt: Point3d] =
TRUSTED {
wholeRope: Rope.ROPE ← ViewerTools.GetContents[textViewer];
wholeStream: IO.STREAM ← IO.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]; -- force the selection
};
AssemblyNamePrompt:
PUBLIC
PROC [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.sceneSection.assemblyName]; -- force the selection
};
WithRespectToPrompt:
PUBLIC
PROC [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.sceneSection.wrt]; -- force the selection
};
RGBPrompt:
PUBLIC
PROC [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.artworkSection.rgb]; -- force the selection
};
SphereRadiusPrompt:
PUBLIC
PROC[parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.sphereSection.radius]; -- force the selection
};
BlockXYZPrompt:
PUBLIC
PROC[parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.blockSection.xyz]; -- force the selection
};
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];
};
PrefixPrompt: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton,
shift, control:
BOOL] =
TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.copySection.prefix];
};
CopyFromPrompt:
PUBLIC
PROC [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.copySection.assemblyName];
};
NewNamePrompt: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton,
shift, control:
BOOL] =
TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
ViewerTools.SetSelection[editToolData.renameSection.newName];
};
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 {
primaryCS, secondaryCS -- , finalPrimaryCS, finalSecondaryCS -- : CoordSystem;
primaryCS ← CoordSys.CreateCoordSys["primarySelection", Matrix3d.Identity[], NIL];
secondaryCS ← CoordSys.CreateCoordSys["secondarySelection", Matrix3d.Identity[], NIL];
finalPrimaryCS ← CoordSys.CreateCoordSys["finalPrimary", Matrix3d.Identity[], NIL];
finalSecondaryCS ← CoordSys.CreateCoordSys["finalSecondary", Matrix3d.Identity[], NIL];
primarySelection ← NEW[SelectionObj ← [[0,0], NIL, NIL, primaryCS, NIL]];
secondarySelection ← NEW[SelectionObj ← [[0,0], NIL, NIL, secondaryCS, NIL]];
finalPrimary ← NIL;
finalSecondary ← NIL;
};
Init[];
END.