DIRECTORY CoordSys, DisplayList3d, Graphics, Matrix3d, Rope, SV2d, SV3d, SVDraw3d, SVEditUser, SVError, SVInterfaceTypes, SVModelTypes, SVRayTypes, SVSceneTypes, SVSelections, SVViewerUser; SVSelectionsImpl: CEDAR PROGRAM IMPORTS CoordSys, DisplayList3d, Graphics, Matrix3d, Rope, SVDraw3d, SVEditUser, SVError, SVViewerUser EXPORTS SVSelections = BEGIN Assembly: TYPE = SVSceneTypes.Assembly; Camera: TYPE = SVModelTypes.Camera; CoordSystem: TYPE = SVModelTypes.CoordSystem; EditToolData: TYPE = SVInterfaceTypes.EditToolData; MasterObject: TYPE = SVSceneTypes.MasterObject; Matrix4by4: TYPE = SV3d.Matrix4by4; Point2d: TYPE = SV2d.Point2d; Primitive: TYPE = SVRayTypes.Primitive; Scene: TYPE = SVSceneTypes.Scene; ToolData: TYPE = SVSceneTypes.ToolData; ViewerToolData: TYPE = SVInterfaceTypes.ViewerToolData; globalSkitter: Skitter; globalTargetList: LIST OF Selection _ NIL; globalMoveeList: LIST OF Selection _ NIL; globalPlaneList: LIST OF Selection _ NIL; Skitter: TYPE = REF SkitterObj; SkitterObj: TYPE = SVInterfaceTypes.SkitterObj; SkitterMode: TYPE = SVInterfaceTypes.SkitterMode; -- {surface, extend, coordframe} UpdateSkitter: PUBLIC PROC [assembly: Assembly, primitive: Primitive, viewerToolData: ViewerToolData] = { globalSkitter.assembly _ assembly; globalSkitter.primitive _ primitive; globalSkitter.viewerToolData _ viewerToolData; IF assembly # NIL THEN { SVEditUser.SetCurrentAssemblyName[assembly, viewerToolData.editToolData]; globalSkitter.alive _ TRUE; } ELSE globalSkitter.alive _ FALSE; }; SetModeSkitter: PUBLIC PROC [mode: SkitterMode] = { globalSkitter.mode _ mode; }; PositionSkitter: PUBLIC PROC [cameraPoint: Point2d, skitterWORLD: Matrix4by4] = { globalSkitter.alive _ TRUE; globalSkitter.cameraPoint _ cameraPoint; globalSkitter.skitterWORLD _ skitterWORLD; }; ComplementSkitter: PUBLIC PROC [dc: Graphics.Context, camera: Camera] = TRUSTED { oldMode: Graphics.PaintMode; skitterCAMERA: Matrix4by4; IF NOT globalSkitter.alive THEN RETURN; oldMode _ Graphics.SetPaintMode[dc, invert]; skitterCAMERA _ Matrix3d.WorldToLocal[CoordSys.FindInTermsOfWorld[camera.coordSys], globalSkitter.skitterWORLD]; SVDraw3d.DrawCoordSys[dc, skitterCAMERA, camera]; [] _ Graphics.SetPaintMode[dc, oldMode]; }; DrawSkitter: PUBLIC PROC [dc: Graphics.Context, camera: Camera] = TRUSTED { skitterCAMERA: Matrix4by4; skitterCAMERA _ Matrix3d.WorldToLocal[CoordSys.FindInTermsOfWorld[camera.coordSys], globalSkitter.skitterWORLD]; SVDraw3d.DrawCoordSys[dc, skitterCAMERA, camera]; }; KillSkitter: PUBLIC PROC [editToolData: EditToolData] = { globalSkitter.alive _ FALSE; globalSkitter.assembly _ NIL; globalSkitter.primitive _ NIL; globalSkitter.viewerToolData _ NIL; SVEditUser.SetCurrentAssemblyName[NIL, editToolData]; }; IsAliveSkitter: PUBLIC PROC [] RETURNS [BOOL] = { RETURN[globalSkitter.alive]; }; GetSkitterData: PUBLIC PROC [] RETURNS [assembly: Assembly, primitive: Primitive, viewerToolData: ViewerToolData] = { IF globalSkitter.alive THEN { assembly _ globalSkitter.assembly; primitive _ globalSkitter.primitive; viewerToolData _ globalSkitter.viewerToolData; } ELSE { assembly _ NIL; primitive _ NIL; viewerToolData _ NIL; SVError.Append["Please make a skitter selection first.", TRUE, TRUE]; SVError.Blink[]; }; }; GetModeSkitter: PUBLIC PROC [] RETURNS [mode: SkitterMode] = { IF globalSkitter.alive THEN mode _ globalSkitter.mode ELSE { mode _ coordframe; SVError.Append["Get Mode Skitter: There is no skitter.", TRUE, TRUE]; SVError.Blink[]; }; }; GetPositionSkitter: PUBLIC PROC [] RETURNS [cameraPoint: Point2d, skitterWORLD: Matrix4by4] = TRUSTED { IF globalSkitter.alive THEN { cameraPoint _ globalSkitter.cameraPoint; skitterWORLD _ globalSkitter.skitterWORLD; } ELSE { cameraPoint _ [0,0]; skitterWORLD _ Matrix3d.Identity[]; SVError.Append["Get Position Skitter: There is no skitter.", TRUE, TRUE]; SVError.Blink[]; }; }; AddHookFromSkitter: PUBLIC PROC [] RETURNS [assembly: Assembly] = TRUSTED { editToolData: EditToolData _ globalSkitter.viewerToolData.editToolData; viewerToolData: ViewerToolData _ globalSkitter.viewerToolData; scene: Scene _ viewerToolData.scene; addSucceeds: BOOL _ TRUE; currentCS: CoordSystem _ globalSkitter.assembly.coordSys; jackName: Rope.ROPE; hooksuper: Matrix4by4; hookCS: CoordSystem; jackName _ CoordSys.UniqueNameWithSuffix[globalSkitter.assembly.name, "Hook", scene.coordSysRoot]; hooksuper _ Matrix3d.WorldToLocal[CoordSys.FindInTermsOfWorld[currentCS], globalSkitter.skitterWORLD]; hookCS _ CoordSys.CreateCoordSysInTree[jackName, hooksuper, currentCS, scene.coordSysRoot]; [assembly, ----] _ DisplayList3d.CreatePrimitiveAtExistingCoordSys[jackName, "jack", [50, 50, 50], scene, hookCS ! DisplayList3d.NameAlreadyPresent => { SVError.Append[Rope.Cat["Jack name ", jackName, " is not unique. Contact implementor."], TRUE, TRUE]; SVError.Blink[]; addSucceeds _ FALSE; CONTINUE}; DisplayList3d.AttemptToAddSubassemblyToPrimitive => ERROR; ]; IF NOT addSucceeds THEN RETURN; assembly.sittingOn _ globalSkitter.assembly.name; DisplayList3d.ConnectAssemblyToParent[assembly, scene.assembly]; }; AddFloaterFromSkitter: PUBLIC PROC [] RETURNS [assembly: Assembly] = TRUSTED { editToolData: EditToolData _ globalSkitter.viewerToolData.editToolData; viewerToolData: ViewerToolData _ globalSkitter.viewerToolData; scene: Scene _ viewerToolData.scene; addSucceeds: BOOL _ TRUE; jackName: Rope.ROPE; sceneAssemblyCS: CoordSystem _ scene.assembly.coordSys; floatersuper: Matrix4by4; floaterCS: CoordSystem; jackName _ CoordSys.UniqueNameFrom["Floater", scene.coordSysRoot]; floatersuper _ Matrix3d.WorldToLocal[CoordSys.FindInTermsOfWorld[sceneAssemblyCS], globalSkitter.skitterWORLD]; floaterCS _ CoordSys.CreateCoordSysInTree[jackName, floatersuper, sceneAssemblyCS, scene.coordSysRoot]; [assembly, ----] _ DisplayList3d.CreatePrimitiveAtExistingCoordSys[jackName, "jack", [50, 50, 50], scene, floaterCS ! DisplayList3d.NameAlreadyPresent => { SVError.Append[Rope.Cat["Jack name ", jackName, " is not unique. Contact implementor."], TRUE, TRUE]; SVError.Blink[]; addSucceeds _ FALSE; CONTINUE}; DisplayList3d.AttemptToAddSubassemblyToPrimitive => ERROR; ]; IF NOT addSucceeds THEN RETURN; DisplayList3d.ConnectAssemblyToParent[assembly, scene.assembly]; }; Selection: TYPE = REF SelectionObj; SelectionObj: TYPE = SVInterfaceTypes.SelectionObj; ReferentType: TYPE = SVInterfaceTypes.ReferentType; -- {hook, floater, coordSys}; SelectionType: TYPE = SVInterfaceTypes.SelectionType; -- {target, movee, plane}; CreateHookMovee: PUBLIC PROC [jack: Assembly, indirect: Assembly, viewerToolData: ViewerToolData] RETURNS [movee: Selection] = { movee _ NEW[SelectionObj _ [jack, indirect, viewerToolData, hook, movee]]; }; CreateCoordSysMovee: PUBLIC PROC [coincident: Assembly, viewerToolData: ViewerToolData] RETURNS [movee: Selection] = { movee _ NEW[SelectionObj _ [coincident, NIL, viewerToolData, coordSys, movee]]; }; CreateHookTarget: PUBLIC PROC [jack: Assembly, indirect: Assembly, viewerToolData: ViewerToolData] RETURNS [target: Selection] = { target _ NEW[SelectionObj _ [jack, indirect, viewerToolData, hook, target]]; }; CreateCoordSysTarget: PUBLIC PROC [coincident: Assembly, viewerToolData: ViewerToolData] RETURNS [target: Selection] = { target _ NEW[SelectionObj _ [coincident, NIL, viewerToolData, coordSys, target]]; }; CreatePlaneSelection: PUBLIC PROC [coincident: Assembly, viewerToolData: ViewerToolData] RETURNS [planeSel: Selection] = TRUSTED { planeSel _ NEW[SelectionObj _ [coincident, NIL, viewerToolData, coordSys, plane]]; DisplayList3d.AddOrResizeToolToAssembly[coincident, viewerToolData.scene]; }; SelectionGenerator: TYPE = SVInterfaceTypes.SelectionGenerator; SelectionGeneratorObj: TYPE = SVInterfaceTypes.SelectionGeneratorObj; GetSelectionGenerator: PUBLIC PROC [selectType: SelectionType] RETURNS [g: SelectionGenerator, selectionsExist: BOOL] = { SELECT selectType FROM movee => { g _ NEW[SelectionGeneratorObj _ [currentPtr: globalMoveeList]]; selectionsExist _ (NOT globalMoveeList = NIL); }; target => { g _ NEW[SelectionGeneratorObj _ [currentPtr: globalTargetList]]; selectionsExist _ (NOT globalTargetList = NIL); }; plane => { g _ NEW[SelectionGeneratorObj _ [currentPtr: globalPlaneList]]; selectionsExist _ (NOT globalPlaneList = NIL); }; ENDCASE => ERROR; }; ComplainIfNot: PUBLIC PROC [selectionsExist: BOOL] = { IF NOT selectionsExist THEN { SVError.Append["There are no source selections.", TRUE, TRUE]; SVError.Blink[]; }; }; NextSelection: PUBLIC PROC [g: SelectionGenerator] RETURNS [sel: Selection] = { IF g.currentPtr = NIL THEN RETURN[NIL]; sel _ g.currentPtr.first; g.currentPtr _ g.currentPtr.rest; }; NextSelectionCoincident: PUBLIC PROC [g: SelectionGenerator] RETURNS [coin: Assembly] = { IF g.currentPtr = NIL THEN RETURN[NIL]; coin _ g.currentPtr.first.coincident; g.currentPtr _ g.currentPtr.rest; }; PushMovee: PUBLIC PROC [moveeSel: Selection] = { globalMoveeList _ CONS[moveeSel, globalMoveeList]; SVEditUser.SetSourceName[moveeSel.coincident, moveeSel.viewerToolData.editToolData]; }; PopMovee: PUBLIC PROC [] RETURNS [moveeSel: Selection] = { newTop: Selection; IF globalMoveeList = NIL THEN { moveeSel _ NIL; SVError.Append["There are no source selections.", TRUE, TRUE]; SVError.Blink[]; } ELSE { moveeSel _ globalMoveeList.first; globalMoveeList _ globalMoveeList.rest; newTop _ IF globalMoveeList = NIL THEN NIL ELSE globalMoveeList.first; IF newTop # NIL THEN SVEditUser.SetSourceName[newTop.coincident, newTop.viewerToolData.editToolData] ELSE SVEditUser.SetSourceName[NIL, moveeSel.viewerToolData.editToolData]; }; }; NextMovee: PUBLIC PROC [] RETURNS [moveeSel: Selection] = { newTop: Selection; IF globalMoveeList = NIL THEN moveeSel _ NIL ELSE { moveeSel _ globalMoveeList.first; globalMoveeList _ globalMoveeList.rest; newTop _ IF globalMoveeList = NIL THEN NIL ELSE globalMoveeList.first; IF newTop # NIL THEN SVEditUser.SetSourceName[newTop.coincident, newTop.viewerToolData.editToolData] ELSE SVEditUser.SetSourceName[NIL, moveeSel.viewerToolData.editToolData]; }; }; PopMoveeCoincident: PUBLIC PROC [] RETURNS [movee: Assembly] = { newTop: Selection; moveeSel: Selection; IF globalMoveeList = NIL THEN { movee _ NIL; SVError.Append["There are no source selections.", TRUE, TRUE]; SVError.Blink[]; } ELSE { moveeSel _ globalMoveeList.first; movee _ moveeSel.coincident; globalMoveeList _ globalMoveeList.rest; newTop _ IF globalMoveeList = NIL THEN NIL ELSE globalMoveeList.first; IF newTop # NIL THEN SVEditUser.SetSourceName[newTop.coincident, newTop.viewerToolData.editToolData] ELSE SVEditUser.SetSourceName[NIL, moveeSel.viewerToolData.editToolData]; }; }; NextMoveeCoincident: PUBLIC PROC [] RETURNS [movee: Assembly] = { newTop: Selection; moveeSel: Selection; IF globalMoveeList = NIL THEN movee _ NIL ELSE { moveeSel _ globalMoveeList.first; movee _ moveeSel.coincident; globalMoveeList _ globalMoveeList.rest; newTop _ IF globalMoveeList = NIL THEN NIL ELSE globalMoveeList.first; IF newTop # NIL THEN SVEditUser.SetSourceName[newTop.coincident, newTop.viewerToolData.editToolData] ELSE SVEditUser.SetSourceName[NIL, moveeSel.viewerToolData.editToolData]; }; }; TopMovee: PUBLIC PROC [] RETURNS [moveeSel: Selection] = { IF globalMoveeList = NIL THEN moveeSel _ NIL ELSE moveeSel _ globalMoveeList.first; }; TopMoveeC: PUBLIC PROC [] RETURNS [moveeSel: Selection] = { IF globalTargetList = NIL THEN { moveeSel _ NIL; SVError.Append["There are no source selections.", TRUE, TRUE]; SVError.Blink[]; } ELSE moveeSel _ globalTargetList.first; }; TopMoveeCoincident: PUBLIC PROC [] RETURNS [movee: Assembly] = { IF globalMoveeList = NIL THEN movee _ NIL ELSE movee _ globalMoveeList.first.coincident; }; ClearMoveeStack: PUBLIC PROC [editToolData: EditToolData] = { ComplementAllSelections[movee]; globalMoveeList _ NIL; SVEditUser.SetSourceName[NIL, editToolData]; }; PushTarget: PUBLIC PROC [targetSel: Selection] = { globalTargetList _ CONS[targetSel, globalTargetList]; SVEditUser.SetTargetName[targetSel.coincident, targetSel.viewerToolData.editToolData]; }; PopTarget: PUBLIC PROC [] RETURNS [targetSel: Selection] = { newTop: Selection; IF globalTargetList = NIL THEN { targetSel _ NIL; SVError.Append["There are no target selections.", TRUE, TRUE]; SVError.Blink[]; } ELSE { targetSel _ globalTargetList.first; globalTargetList _ globalTargetList.rest; newTop _ IF globalTargetList = NIL THEN NIL ELSE globalTargetList.first; IF newTop # NIL THEN SVEditUser.SetTargetName[newTop.coincident, newTop.viewerToolData.editToolData] ELSE SVEditUser.SetTargetName[NIL, targetSel.viewerToolData.editToolData]; }; }; NextTarget: PUBLIC PROC [] RETURNS [targetSel: Selection] = { newTop: Selection; IF globalTargetList = NIL THEN targetSel _ NIL ELSE { targetSel _ globalTargetList.first; globalTargetList _ globalTargetList.rest; newTop _ IF globalTargetList = NIL THEN NIL ELSE globalTargetList.first; IF newTop # NIL THEN SVEditUser.SetTargetName[newTop.coincident, newTop.viewerToolData.editToolData] ELSE SVEditUser.SetTargetName[NIL, targetSel.viewerToolData.editToolData]; }; }; PopTargetCoincident: PUBLIC PROC [] RETURNS [target: Assembly] = { targetSel, newTop: Selection; IF globalTargetList = NIL THEN { target _ NIL; SVError.Append["There are no target selections.", TRUE, TRUE]; SVError.Blink[]; } ELSE { targetSel _ globalTargetList.first; target _ targetSel.coincident; globalTargetList _ globalTargetList.rest; newTop _ IF globalTargetList = NIL THEN NIL ELSE globalTargetList.first; IF newTop # NIL THEN SVEditUser.SetTargetName[newTop.coincident, newTop.viewerToolData.editToolData] ELSE SVEditUser.SetTargetName[NIL, targetSel.viewerToolData.editToolData]; }; }; NextTargetCoincident: PUBLIC PROC [] RETURNS [target: Assembly] = { targetSel, newTop: Selection; IF globalTargetList = NIL THEN target _ NIL ELSE { targetSel _ globalTargetList.first; target _ targetSel.coincident; globalTargetList _ globalTargetList.rest; newTop _ IF globalTargetList = NIL THEN NIL ELSE globalTargetList.first; IF newTop # NIL THEN SVEditUser.SetTargetName[newTop.coincident, newTop.viewerToolData.editToolData] ELSE SVEditUser.SetTargetName[NIL, targetSel.viewerToolData.editToolData]; }; }; TopTarget: PUBLIC PROC [] RETURNS [targetSel: Selection] = { IF globalTargetList = NIL THEN targetSel _ NIL ELSE targetSel _ globalTargetList.first; }; TopTargetC: PUBLIC PROC [] RETURNS [targetSel: Selection] = { IF globalTargetList = NIL THEN { targetSel _ NIL; SVError.Append["There are no target selections.", TRUE, TRUE]; SVError.Blink[]; } ELSE targetSel _ globalTargetList.first; }; TopTargetCoincident: PUBLIC PROC [] RETURNS [target: Assembly] = { IF globalTargetList = NIL THEN { target _ NIL; SVError.Append["There are no target selections.", TRUE, TRUE]; SVError.Blink[]; } ELSE target _ globalTargetList.first.coincident; }; TopTargetCoinCoordSys: PUBLIC PROC [] RETURNS [targetCS: CoordSystem] = { IF globalTargetList = NIL THEN targetCS _ NIL ELSE targetCS _ globalTargetList.first.coincident.coordSys; }; TopTargetCoinCoordSysC: PUBLIC PROC [] RETURNS [targetCS: CoordSystem] = { IF globalTargetList = NIL THEN { targetCS _ NIL; SVError.Append["There are no target selections.", TRUE, TRUE]; SVError.Blink[]; } ELSE targetCS _ globalTargetList.first.coincident.coordSys; }; ClearTargetStack: PUBLIC PROC [editToolData: EditToolData] = { ComplementAllSelections[target]; globalTargetList _ NIL; SVEditUser.SetTargetName[NIL, editToolData]; }; PushPlane: PUBLIC PROC [planeSel: Selection] = { globalPlaneList _ CONS[planeSel, globalPlaneList]; SVEditUser.SetPlaneName[planeSel.coincident, planeSel.viewerToolData.editToolData]; }; PopPlane: PUBLIC PROC [] RETURNS [planeSel: Selection] = { newTop: Selection; IF globalPlaneList = NIL THEN { planeSel _ NIL; SVError.Append["There are no plane selections.", TRUE, TRUE]; SVError.Blink[]; } ELSE { planeSel _ globalPlaneList.first; globalPlaneList _ globalPlaneList.rest; newTop _ IF globalPlaneList = NIL THEN NIL ELSE globalPlaneList.first; IF newTop # NIL THEN SVEditUser.SetPlaneName[newTop.coincident, newTop.viewerToolData.editToolData] ELSE SVEditUser.SetPlaneName[NIL, planeSel.viewerToolData.editToolData]; }; }; TopPlane: PUBLIC PROC [] RETURNS [planeSel: Selection] = { IF globalPlaneList = NIL THEN planeSel _ NIL ELSE planeSel _ globalPlaneList.first; }; TopPlaneC: PUBLIC PROC [] RETURNS [planeSel: Selection] = { IF globalPlaneList = NIL THEN { planeSel _ NIL; SVError.Append["There are no plane selections.", TRUE, TRUE]; SVError.Blink[]; } ELSE planeSel _ globalPlaneList.first; }; TopPlaneCoincident: PUBLIC PROC [] RETURNS [planeAssem: Assembly] = { IF globalPlaneList = NIL THEN { planeAssem _ NIL; SVError.Append["There are no plane selections.", TRUE, TRUE]; SVError.Blink[]; } ELSE planeAssem _ globalPlaneList.first.coincident; }; PlaneStackEmpty: PUBLIC PROC [] RETURNS [BOOL] = { RETURN[globalPlaneList = NIL]; }; ClearPlaneStack: PUBLIC PROC [editToolData: EditToolData] = { ComplementAllSelections[plane]; globalPlaneList _ NIL; SVEditUser.SetPlaneName[NIL, editToolData]; }; ComplementAnySelectionsOnDC: PUBLIC PROC [dc: Graphics.Context, assembly: Assembly, scene: Scene] = TRUSTED { g: SelectionGenerator; selectionsExist: BOOL; camera: Camera; viewerToolData: ViewerToolData; FOR type: SelectionType IN [target..plane] DO [g, selectionsExist] _ GetSelectionGenerator[type]; IF NOT selectionsExist THEN LOOP; FOR sel: Selection _ NextSelection[g], NextSelection[g] UNTIL sel = NIL DO IF (sel.referentType = hook AND sel.indirect = assembly) OR sel.coincident = assembly THEN { viewerToolData _ sel.viewerToolData; camera _ viewerToolData.camera; SELECT sel.selectionType FROM target => { csCAMERA: Matrix4by4; csCAMERA _ CoordSys.FindInTermsOfCamera[sel.coincident.coordSys, camera.coordSys]; SVDraw3d.DrawTargetCoordSys[dc, csCAMERA, camera]; }; movee => SVDraw3d.DrawMovee[dc, sel.coincident.coordSys, camera]; plane => { toolData: ToolData; planeAssem: Assembly; planeAssem _ sel.coincident; IF planeAssem.toolMasterObject = NIL OR planeAssem.toolMasterObject.mainBody = NIL THEN ERROR; toolData _ NARROW[planeAssem.toolMasterObject.mainBody]; SVDraw3d.DrawPlaneSelection[dc, sel.coincident.coordSys, toolData.plane, camera]; }; ENDCASE => ERROR; }; ENDLOOP; ENDLOOP; }; ComplementSelection: PUBLIC PROC [viewerToolData: ViewerToolData, sel: Selection] = { DoComplementSelection: PROC [dc: Graphics.Context] = { ComplementSelectionDC[dc, sel, viewerToolData]; }; SVViewerUser.Painter[DoComplementSelection, sel.viewerToolData]; }; ComplementSelectionDC: PUBLIC PROC [dc: Graphics.Context, sel: Selection, viewerToolData: ViewerToolData] = TRUSTED { oldMode: Graphics.PaintMode; camera: Camera; IF viewerToolData # sel.viewerToolData THEN RETURN; camera _ viewerToolData.camera; oldMode _ Graphics.SetPaintMode[dc, invert]; SELECT sel.selectionType FROM target => { csCAMERA: Matrix4by4; csCAMERA _ CoordSys.FindInTermsOfCamera[sel.coincident.coordSys, camera.coordSys]; SVDraw3d.DrawTargetCoordSys[dc, csCAMERA, camera]; }; movee => SVDraw3d.DrawMovee[dc, sel.coincident.coordSys, camera]; plane => { toolData: ToolData; planeAssem: Assembly; planeAssem _ sel.coincident; IF planeAssem.toolMasterObject = NIL OR planeAssem.toolMasterObject.mainBody = NIL THEN ERROR; toolData _ NARROW[planeAssem.toolMasterObject.mainBody]; SVDraw3d.DrawPlaneSelection[dc, sel.coincident.coordSys, toolData.plane, camera]; }; ENDCASE => ERROR; [] _ Graphics.SetPaintMode[dc, oldMode]; }; ComplementAnySelectionsDC: PUBLIC PROC [dc: Graphics.Context, viewerToolData: ViewerToolData] = { camera: Camera _ viewerToolData.camera; scene: Scene _ viewerToolData.scene; IF globalSkitter.viewerToolData = viewerToolData THEN ComplementSkitter[dc, viewerToolData.camera]; ComplementAnySelectionsDCAux[dc, movee, viewerToolData, scene, camera]; ComplementAnySelectionsDCAux[dc, target, viewerToolData, scene, camera]; ComplementAnySelectionsDCAux[dc, plane, viewerToolData, scene, camera]; }; ComplementAnySelectionsDCAux: PRIVATE PROC [dc: Graphics.Context, selType: SelectionType, viewerToolData: ViewerToolData, scene: Scene, camera: Camera] = { g: SelectionGenerator; selectionsExist: BOOL; [g, selectionsExist] _ GetSelectionGenerator[selType]; IF NOT selectionsExist THEN RETURN; FOR sel: Selection _ NextSelection[g], NextSelection[g] UNTIL sel = NIL DO IF sel.viewerToolData = viewerToolData THEN { ComplementReferentDC[dc, sel, viewerToolData]; -- erase the Jack if any. ComplementSelectionDC[dc, sel, viewerToolData]; }; ENDLOOP; }; ComplementReferentDC: PUBLIC PROC [dc: Graphics.Context, selection: Selection, viewerToolData: ViewerToolData] = TRUSTED { IF selection.referentType # coordSys AND selection.viewerToolData = viewerToolData THEN { SVViewerUser.DrawAssemblyXOR[dc, viewerToolData, selection.coincident]; }; }; ComplementAllSelections: PUBLIC PROC [selType: SelectionType] = { g: SelectionGenerator; selectionsExist: BOOL; scene: Scene; camera: Camera; sel: Selection; DoComplementSelection: PROC [dc: Graphics.Context] = { ComplementReferentDC[dc, sel, sel.viewerToolData]; -- erase the Jack if any. ComplementSelectionDC[dc, sel, sel.viewerToolData]; }; [g, selectionsExist] _ GetSelectionGenerator[selType]; IF NOT selectionsExist THEN RETURN; FOR sel _ NextSelection[g], NextSelection[g] UNTIL sel = NIL DO scene _ sel.viewerToolData.scene; camera _ sel.viewerToolData.camera; SVViewerUser.Painter[DoComplementSelection, sel.viewerToolData]; ENDLOOP; }; KillSkitterAndSelections: PUBLIC PROC [editToolData: EditToolData] = { viewerToolData: ViewerToolData; camera: Camera; DoComplementSkitter: PROC [dc: Graphics.Context] = { ComplementSkitter[dc, camera]; }; ClearTargetStack[editToolData]; ClearMoveeStack[editToolData]; ClearPlaneStack[editToolData]; IF IsAliveSkitter[] THEN { [----,----,viewerToolData] _ GetSkitterData[]; IF viewerToolData = NIL THEN ERROR; camera _ viewerToolData.camera; SVViewerUser.Painter[DoComplementSkitter, viewerToolData]; }; KillSkitter[editToolData]; }; Init: PROC [] = TRUSTED { globalSkitter _ NEW[SkitterObj _ [FALSE, [0,0], NIL, NIL, Matrix3d.Identity[], NIL, surface]]; }; Init[]; END. @File: SVSelectionsImpl.mesa Last edited by: Eric Bier on January 16, 1985 5:30:53 pm PST Copyright c 1984 by Xerox Corporation. All rights reserved. Created on July 11, 1984 11:27:40 am PDT Contents: Definitions for several kinds of selection objects in Solidviews including Movees and Targets. A Skitter is an interactive selection on an object surface. It has no lasting effect unless it is turned into a Movee or Target. There is only one live skitter at a time in the whole world. Skitters only move by interactive pointing. The assembly which is under a live skitter becomes the Star assembly for purposes of shape editing and artwork editing. Skitters have no coordinate system. Just a single matrix to remind them where in WORLD they are. They are viewpoint dependent. A single skitter is created at initialization time. The user can update with the following routines: Remove all pointers to objects. Complement the skitter one last time and cease drawing it. Hooks, and Floaters are special primitive assemblies which refer to a special "null" master object. For convenience, we provide procedures here to wire up these objects to a scene. For now, both are created as Solidviews Jack objects (Jack is a class, just as sphere is. Jacks look like three perpendicular line segments). We add the hook jack under assembly in the coordinate system tree, so it will follow assembly around. We also tell the new assembly that it is sitting on the skitter assembly. SVEditUser.SceneNewVersion[globalSkitter.viewerToolData]; -- Commented out for now to permit so that viewerToolData.treeOutOfDate doesn't get set to TRUE when a Jack is created. We add the floater under the sceneAssembly since it is not associated directly with any other object in the scene. SVEditUser.SceneNewVersion[globalSkitter.viewerToolData]; -- Commented out for now to permit so that viewerToolData.treeOutOfDate doesn't get set to TRUE when a Jack is created. Movees and Targets are persistent Selections. They refer to one of the following: 1) A Floater's coordSys 2) A Hook coordSys 3) An Object's coordSys. Movees allow the referent to participate in operations including: 1) A hook movee selects an object to be tugged and a tugboat at the same time. 2) A floater, hook, or object selection allows the selected coordSys to be moved. A hook might be moved around on a surface or might become a floater. An object moves along with its children. A floater moves in space. 3) The origin of an in-scene ray is specified. 4) The origin of a floater calculation is specified. Targets allow secondary objects to be specified. 1) Any target can be a center of rotation, a base frame for translation. 2) All selectable objects are also assemblies in the scene tree. All assemblies have an associated distinguished plane. Hence a target can suggest a plane to be used for dragging. 3) The direction point of an in-scene ray is specified. 4) The end point of a floater calculation is specified. Selections do not move interactively as skitters do. They are not really objects at all. Think of them as pointers to coordinate frames which are currently active. If the referent coordinate frame moves, so does the image of the selection. The system maintains the following lists and distinguished objects: 1) The global skitter. 2) A stack of all movee selections. 3) A stack of all target selections. Like PopMovee, but doesn't complain if stack is empty. Like PopMoveeCoincident, but doesn't complain if stack is empty. Returns NIL AND complains if there are none. Should be done before deleting any movee selected object. Must also be done after each command which uses a movee to allow the user to make new selections. Just like PopTarget but doesn't complain if there aren't any. Like PopTargetCoincident but doesn't complain if stack is empty. Should be done before deleting any target-selected object. Must also be done after each command which uses a target to allow the user to make new selections. bitmap: Graphics.Context; BitMap3d.Erase[viewerToolData.xorDC]; bitmap _ viewerToolData.xorDC.dc; Draw bitmap onto display. BitMap3d.DrawAltDisplayContext[dc, viewerToolData.xorDC]; Draw the skitter into dc, if the skitter is in the viewer associated with viewerToolData. Draw and movee and target selections for that viewer as well. (Called by SVViewerUser.DrawSceneEtc[] after DisplayList3d.DrawScene.) For each selection, If the selected object is a hook or a floater, complement the jack and then draw the selection. If a coordinate system, just draw selection. Complements all selections of selType regardless of what viewer they are in. Κ°˜Ihead™J™Jšžœžœ˜5šžœ˜Jšœ˜Jšœ9žœžœ˜EJšœ˜J˜—J˜J˜—š ‘œžœžœžœ’œžœ˜gšžœžœ˜Jšœ(˜(Jšœ’œ’œ˜,—šžœ˜Jšœ˜Jšœ’œ˜#Jšœ=žœžœ˜IJšœ˜J˜—J˜—˜JšŸœŸœ²™ΕJ˜—š ‘œžœžœžœžœ˜KJ™°JšœG˜GJšœ>˜>Jšœ$˜$Lšœ žœžœ˜LšœŸœ˜9Lšœžœ˜Lšœ’œ ˜Lšœ˜L˜Lšœb˜bLšœ’œV’œ˜fLšœ5’œ!˜[šœŸœ œ˜LšœŸ!œ.˜]šœ'˜'LšœZžœžœ˜fLšœ˜Lšœžœžœ˜—Lšœ4žœ˜:Lšœ˜—Lšžœžœ žœžœ˜LšŸœ˜1Lšœ@˜@Lšœ±™±L˜L˜—š ‘œžœžœžœžœ˜NJ™rJšœG˜GJšœ>˜>Jšœ$˜$Lšœ žœžœ˜Lšœžœ˜Lšœ7˜7Lšœ’œ ˜Lšœ˜L˜LšœB˜BLšœ’œ\’œ˜oLšœ;’œ'˜gšœ  œ˜Lšœ`˜`šœ'˜'LšœZžœžœ˜fLšœ˜Lšœžœžœ˜—Lšœ4žœ˜:Lšœ˜—Lšžœžœ žœžœ˜Lšœ@˜@Lšœ±™±L˜L˜—˜JšŸœŸœ@™RJ™J™J™J™AJ™OJ™έJ™/J™5J™0J™IJ™ΆJ™8J™8J™—J™σJ˜Lšœ žœžœ˜#Lšœžœ!˜3Lšœžœ" ˜QLšœžœ# œ ˜P˜L™CL™L™$L™%L™—š‘œžœžœFžœ˜€Jšœžœ?˜JJšœ˜—š‘œžœžœ8žœ˜vJšœžœžœ$˜OJšœ˜—J˜š‘œžœžœFžœ˜‚Jšœ žœ@˜LJšœ˜—š‘œžœžœ8žœ˜xJšœ žœžœ%˜QJšœ˜—J˜š ‘œžœžœ8žœžœ˜‚Jšœ žœžœ$˜RJšœJ˜JJšœ˜J˜—J˜Jšœžœ'˜?Jšœžœ*˜EJ˜š ‘œžœžœžœ*žœ˜yJšžœ ž˜šœ ˜ Jšœžœ8˜?Jšœžœžœ˜.J˜—šœ ˜ Jšœžœ9˜@Jšœžœžœ˜/J˜—˜ Jšœžœ8˜?Jšœžœžœ˜.J˜—Jšžœžœ˜J˜—š‘ œžœžœžœ˜6šžœžœžœ˜Jšœ2žœžœ˜>J˜J˜—J˜—š‘ œžœžœžœ˜OJš žœžœžœžœžœ˜'Jšœ˜Jšœ!˜!J˜—š‘œž œžœ˜YJš žœžœžœžœžœ˜'Jšœ%˜%Jšœ!˜!J˜—J˜š‘ œžœžœ˜0Jšœžœ˜2JšœT˜TJšœ˜—š‘œžœžœžœ˜:Jšœ˜šžœžœžœ˜Jšœ žœ˜Jšœ2žœžœ˜>J˜J˜—šžœ˜Jšœ!˜!Jšœ'˜'Jš œ žœžœžœžœžœ˜FJšžœ žœžœP˜dJšžœžœ(˜IJ˜—Jšœ˜—š‘ œžœžœžœ˜;Jšœ‘œ)™6Jšœ˜Jšžœžœžœ ž˜,šžœ˜Jšœ!˜!Jšœ'˜'Jš œ žœžœžœžœžœ˜FJšžœ žœžœP˜dJšžœžœ(˜IJ˜—Jšœ˜—š‘œžœžœžœ˜@Jšœ˜Jšœ˜šžœžœžœ˜ Jšœžœ˜ Jšœ2žœžœ˜>J˜J˜—šžœ˜Jšœ!˜!Jšœ˜Jšœ'˜'Jš œ žœžœžœžœžœ˜FJšžœ žœžœP˜dJšžœžœ(˜IJ˜—Jšœ˜J˜—š‘œžœžœžœ˜AJšœ‘œ)™@Jšœ˜Jšœ˜Jšžœžœžœ ž˜)šžœ˜Jšœ!˜!Jšœ˜Jšœ'˜'Jš œ žœžœžœžœžœ˜FJšžœ žœžœP˜dJšžœžœ(˜IJ˜—Jšœ˜J˜—š‘œžœžœžœ˜:Jšžœžœžœ ž˜,Jšžœ"˜&Jšœ˜—š‘ œž œžœ˜;Jšœžœ!™,šžœžœžœ˜ Jšœ žœ˜Jšœ2žœžœ˜>J˜J˜—Jšžœ#˜'Jšœ˜—J˜š‘œžœžœžœ˜@Jšžœžœžœ ž˜)Jšžœ*˜.Jšœ˜—š‘œžœžœ!˜=J™œJ˜Jšœžœ˜Jšœžœ˜,J˜—J˜J˜š‘ œžœžœ˜2Jšœžœ˜5JšœV˜VJšœ˜—š‘ œžœžœžœ˜J˜J˜—šžœ˜Jšœ#˜#Jšœ)˜)Jš œ žœžœžœžœžœ˜HJšžœ žœžœP˜dJšžœžœ)˜JJ˜—Jšœ˜—š‘ œžœžœžœ˜=J™=Jšœ˜Jšžœžœžœ ž˜.šžœ˜Jšœ#˜#Jšœ)˜)Jš œ žœžœžœžœžœ˜HJšžœ žœžœP˜dJšžœžœ)˜JJ˜—Jšœ˜—š‘œžœžœžœ˜BJšœ˜šžœžœžœ˜ Jšœ žœ˜ Jšœ2žœžœ˜>J˜J˜—šžœ˜Jšœ#˜#Jšœ˜Jšœ)˜)Jš œ žœžœžœžœžœ˜HJšžœ žœžœP˜dJšžœžœ)˜JJ˜—Jšœ˜—š‘œžœžœžœ˜CJšœ@™@Jšœ˜Jšžœžœžœ ž˜+šžœ˜Jšœ#˜#Jšœ˜Jšœ)˜)Jš œ žœžœžœžœžœ˜HJšžœ žœžœP˜dJšžœžœ)˜JJ˜—Jšœ˜—š‘ œžœžœžœ˜J˜J˜—Jšžœ$˜(Jšœ˜—š‘œžœžœžœ˜Bšžœžœžœ˜ Jšœ žœ˜ Jšœ2žœžœ˜>J˜J˜—Jšžœ,˜0Jšœ˜—š‘œžœžœžœ˜IJšžœžœžœ ž˜-Jšžœ7˜;Jšœ˜J˜—š‘œžœžœžœ˜Jšžœžœžœ˜ Jšœ žœ˜Jšœ2žœžœ˜>J˜J˜—Jšžœ7˜;Jšœ˜J˜—š‘œžœžœ!˜>J™žJ˜ Jšœžœ˜Jšœžœ˜,J˜J˜—š‘ œžœžœ˜0Jšœžœ˜2JšœS˜SJšœ˜—š‘œžœžœžœ˜:Jšœ˜šžœžœžœ˜Jšœ žœ˜Jšœ1žœžœ˜=J˜J˜—šžœ˜Jšœ!˜!Jšœ'˜'Jš œ žœžœžœžœžœ˜FJšžœ žœžœO˜cJšžœžœ(˜HJ˜—Jšœ˜—š‘œžœžœžœ˜:Jšžœžœžœ ž˜,Jšžœ"˜&Jšœ˜—š‘ œžœžœžœ˜;šžœžœžœ˜Jšœ žœ˜Jšœ1žœžœ˜=J˜J˜—Jšžœ"˜&Jšœ˜—š‘œžœžœžœ˜Ešžœžœžœ˜Jšœ žœ˜Jšœ1žœžœ˜=J˜J˜—Jšžœ/˜3Jšœ˜J˜—š ‘œžœžœžœžœ˜2Jšžœžœ˜J˜—š‘œžœžœ!˜=J˜Jšœžœ˜Jšœžœ˜+J˜—J˜š‘œžœžœ<žœ˜mL˜Lšœžœ˜L˜Lšœ˜šžœžœž˜-Lšœ3˜3Lšžœžœžœžœ˜!šžœ5žœžœž˜Jšžœžœžœžœ˜\Lšœ$˜$Lšœ˜L˜Jšžœž˜šœ ˜ Lšœ’œ ˜Jšœ’œJ˜RJšœ Ÿœ’œ ˜2J˜—JšœŸ œ&˜Ašœ ˜ J˜J˜Jšœ˜Jš žœžœžœ(žœžœžœ˜^Jšœ žœ'˜8Jšœ Ÿœ6˜QJ˜—Jšžœžœ˜L˜——Lšžœ˜—Lšžœ˜L˜J˜—š‘œžœžœ5˜Uš‘œžœ˜6Jšœ/˜/J˜—Lšœ@˜@J˜—š‘œžœžœJžœ˜uJ˜Lšœ™L˜L˜Lšžœ%žœžœ˜3Lšœ˜L˜J˜,LšŸœ™%Lšœ!™!L™Jšžœž˜šœ ˜ Lšœ’œ ˜Jšœ’œJ˜RJšœ Ÿœ’œ ˜2J˜—JšœŸ œ&˜Ašœ ˜ J˜J˜Jšœ˜Jš žœžœžœ(žœžœžœ˜^Jšœ žœ'˜8Jšœ Ÿœ6˜QJ˜—šžœžœ˜J™—LšŸœ™9J˜(J˜J˜—š‘œžœžœ;˜aLšœΰ™ΰLšœ'˜'Lšœ$˜$šžœ/ž˜5LšŸœ˜-—Lšœ!Ÿœ!˜GLšœ!Ÿœ!˜HLšœ!Ÿœ!˜GL˜L˜—š‘œžœžœq˜›L™‘L˜Lšœžœ˜Lšœ6˜6Lšžœžœžœžœ˜#šžœ5žœžœž˜Jšžœ%žœ˜-Lšœ/ ˜HLšœ/˜/L˜——Lšžœ˜L˜L˜—š‘œžœžœPžœ˜zšžœ#žœ+žœ˜YLšœG˜GL˜—L˜L˜—š‘œžœžœ˜ALšœL™LL˜Lšœžœ˜Lšœ ˜ Lšœ˜Lšœ˜L˜š‘œžœ˜6Lšœ3 ˜LLšœ3˜3L˜L˜—Lšœ6˜6Lšžœžœžœžœ˜#šžœ*žœžœž˜?Lšœ!˜!Lšœ#˜#Lšœ@˜@—Lšžœ˜L˜—L˜š‘œžœžœ!˜FJšœ˜J˜š‘œžœ˜4Jšœ!˜!—Lšœ˜Lšœ˜Lšœ˜šžœžœ˜Jšœ œ œ$˜.Jšžœžœžœžœ˜#Jšœ˜Jšœ:˜:J˜—Lšœ˜L˜L˜—š‘œžœžœ˜Lš œžœžœ žœžœžœ ˜^L˜L˜—L˜J˜Jšžœ˜J˜J˜—…—Vp‚`