<> <> <> <> <> <<>> 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]; <> }; <> <<1) A Floater's coordSys>> <<2) A Hook coordSys>> <<3) An Object's coordSys.>> <> <<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.>> <> <<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.>> <<>> <> Selection: TYPE = REF SelectionObj; SelectionObj: TYPE = SVInterfaceTypes.SelectionObj; ReferentType: TYPE = SVInterfaceTypes.ReferentType; -- {hook, floater, coordSys}; SelectionType: TYPE = SVInterfaceTypes.SelectionType; -- {target, movee, plane}; <> <<1) The global skitter.>> <<2) A stack of all movee selections.>> <<3) A stack of all target selections.>> <<>> 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.