DIRECTORY BasicObject3d, ColorMap, CoordSys, CSG, CSGGraphics, DisplayList3d, FS, Graphics, GraphicsColor, IO, Labels, Matrix3d, Menus, Preprocess3d, Rope, Scratchpad2dUser, SV2d, SV3d, SVEditUser, SVEditUserB, SVError, SVHalfSpaces, SVInputMonitor, SVInterfaceTypes, SVModelTypes, SVRayTypes, SVSceneTypes, SVPolygon2d, SVSelections, SVTransforms, SVViewerTools, SVViewerUser, SweepGeometry, TiogaMenuOps, ViewerClasses, ViewerTools; SVEditUserImplC: CEDAR PROGRAM IMPORTS ColorMap, CoordSys, DisplayList3d, FS, IO, Labels, Matrix3d, Preprocess3d, Rope, Scratchpad2dUser, SVEditUser, SVError, SVInputMonitor, SVPolygon2d, SVSelections, SVTransforms, SVViewerTools, SVViewerUser, SweepGeometry, TiogaMenuOps, ViewerTools EXPORTS SVEditUser, SVEditUserB = BEGIN Assembly: TYPE = REF AssemblyObj; AssemblyObj: TYPE = SVSceneTypes.AssemblyObj; AssemblyList: TYPE = SVSceneTypes.AssemblyList; Camera: TYPE = SVModelTypes.Camera; Color: TYPE = GraphicsColor.Color; CoordSystem: TYPE = SVModelTypes.CoordSystem; EditToolData: TYPE = SVInterfaceTypes.EditToolData; LinearMesh: TYPE = SweepGeometry.LinearMesh; MasterObject: TYPE = SVSceneTypes.MasterObject; Matrix4by4: TYPE = SV3d.Matrix4by4; MouseButton: TYPE = Menus.MouseButton; Path: TYPE = SV2d.Path; Point3d: TYPE = SV3d.Point3d; Polygon: TYPE = SV2d.Polygon; PointSetOp: TYPE = SVRayTypes.PointSetOp; RevoluteMesh: TYPE = SweepGeometry.RevoluteMesh; Scene: TYPE = SVSceneTypes.Scene; ScratchpadData: TYPE = SVInterfaceTypes.ScratchpadData; ScratchViewerData: TYPE = SVInterfaceTypes.ScratchViewerData; Selection: TYPE = SVInterfaceTypes.Selection; SelectionGenerator: TYPE = SVInterfaceTypes.SelectionGenerator; Shape: TYPE = SVSceneTypes.Shape; Vector: TYPE = SV3d.Vector; Viewer: TYPE = ViewerClasses.Viewer; ViewerCell: TYPE = REF ViewerCellObj; ViewerCellObj: TYPE = SVInterfaceTypes.ViewerCellObj; ViewerToolData: TYPE = SVInterfaceTypes.ViewerToolData; HalfSpaceRec: TYPE = SVHalfSpaces.HalfSpaceRec; SphereRec: TYPE = BasicObject3d.SphereRec; BlockRec: TYPE = BasicObject3d.BlockRec; CylinderRec: TYPE = BasicObject3d.CylinderRec; ConeRec: TYPE = BasicObject3d.ConeRec; TorusRec: TYPE = BasicObject3d.TorusRec; globalOpIndex: NAT _ 1; globalOpCount: NAT = 3; globalOpArray: ARRAY[1..globalOpCount] OF Rope.ROPE _ ["union", "intersection", "difference"]; globalIsColor: BOOL _ FALSE; PlaneButtonAux: PRIVATE PROC [planeName: Rope.ROPE, editToolData: EditToolData] = TRUSTED { currentScene: Scene _ editToolData.sceneSection.currentScene; viewerToolData: ViewerToolData _ editToolData.currentViewerToolData; planeSel: Selection; planeAssem: Assembly; success: BOOL; DrawPlane: PROC [dc: Graphics.Context, viewerToolData: ViewerToolData] = TRUSTED { SVSelections.ComplementSelectionDC[dc, planeSel, viewerToolData]; }; [planeAssem, ----, success] _ SVEditUser.FindAssemblyFromName[planeName, currentScene]; IF NOT success THEN RETURN; planeSel _ SVSelections.CreatePlaneSelection[planeAssem, viewerToolData]; SVSelections.PushPlane[planeSel]; SVEditUser.PaintSceneAllViewers[DrawPlane, editToolData, currentScene]; }; SourceButtonAux: PRIVATE PROC [sourceName: Rope.ROPE, editToolData: EditToolData] = TRUSTED { currentScene: Scene _ editToolData.sceneSection.currentScene; viewerToolData: ViewerToolData _ editToolData.currentViewerToolData; sourceSel: Selection; source: Assembly; success: BOOL; DrawSource: PROC [dc: Graphics.Context, viewerToolData: ViewerToolData] = TRUSTED { SVSelections.ComplementSelectionDC[dc, sourceSel, viewerToolData]; }; IF Rope.Equal[sourceName, "background", TRUE] THEN { source _ NEW[AssemblyObj _ ["background", currentScene.coordSysRoot, NIL, normal, FALSE, NIL, NIL, NIL]]; success _ TRUE; } ELSE [source, ----, success] _ SVEditUser.FindAssemblyFromName[sourceName, currentScene]; IF NOT success THEN RETURN; sourceSel _ SVSelections.CreateCoordSysMovee[source, viewerToolData]; SVSelections.PushMovee[sourceSel]; SVEditUser.PaintSceneAllViewers[DrawSource, editToolData, currentScene]; }; TargetButtonAux: PRIVATE PROC [targetName: Rope.ROPE, editToolData: EditToolData] = TRUSTED { currentScene: Scene _ editToolData.sceneSection.currentScene; viewerToolData: ViewerToolData _ editToolData.currentViewerToolData; targetSel: Selection; target: Assembly; success: BOOL; DrawTarget: PROC [dc: Graphics.Context, viewerToolData: ViewerToolData] = TRUSTED { SVSelections.ComplementSelectionDC[dc, targetSel, viewerToolData]; }; IF Rope.Equal[targetName, "WORLD", TRUE] THEN { target _ NEW[AssemblyObj _ ["WORLD", currentScene.coordSysRoot, NIL, normal, FALSE, NIL, NIL, NIL]]; success _ TRUE; } ELSE [target, ----, success] _ SVEditUser.FindAssemblyFromName[targetName, currentScene]; IF NOT success THEN RETURN; targetSel _ SVSelections.CreateCoordSysTarget[target, viewerToolData]; SVSelections.PushTarget[targetSel]; SVEditUser.PaintSceneAllViewers[DrawTarget, editToolData, currentScene]; }; ParentButtonAux: PRIVATE PROC [parentName: Rope.ROPE, editToolData: EditToolData] = { currentScene: Scene _ editToolData.sceneSection.currentScene; success: BOOL; [----, ----, success] _ SVEditUser.FindAssemblyFromName[parentName, currentScene]; IF NOT success THEN RETURN; ViewerTools.SetContents[editToolData.sceneSection.parent, parentName]; }; SkitterSourceButton: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = { sourceName: Rope.ROPE; editToolData: EditToolData _ NARROW[clientData]; sourceName _ ViewerTools.GetContents[editToolData.sceneSection.current]; SourceButtonAux[sourceName, editToolData]; }; SkitterTargetButton: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = { targetName: Rope.ROPE; editToolData: EditToolData _ NARROW[clientData]; targetName _ ViewerTools.GetContents[editToolData.sceneSection.current]; TargetButtonAux[targetName, editToolData]; }; SkitterParentButton: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = { editToolData: EditToolData _ NARROW[clientData]; parentName: Rope.ROPE; parentName _ ViewerTools.GetContents[editToolData.sceneSection.current]; ParentButtonAux[parentName, editToolData]; }; Text1PromptButton: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = { editToolData: EditToolData _ NARROW[clientData]; ViewerTools.SetSelection[editToolData.sceneSection.text1]; }; Text1SourceButton: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = { sourceName: Rope.ROPE; editToolData: EditToolData _ NARROW[clientData]; sourceName _ ViewerTools.GetContents[editToolData.sceneSection.text1]; SourceButtonAux[sourceName, editToolData]; }; Text1TargetButton: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = { targetName: Rope.ROPE; editToolData: EditToolData _ NARROW[clientData]; targetName _ ViewerTools.GetContents[editToolData.sceneSection.text1]; TargetButtonAux[targetName, editToolData]; }; Text1ParentButton: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = { editToolData: EditToolData _ NARROW[clientData]; parentName: Rope.ROPE; parentName _ ViewerTools.GetContents[editToolData.sceneSection.text1]; ParentButtonAux[parentName, editToolData]; }; SelectedTextPlaneButton: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = { planeName: Rope.ROPE; editToolData: EditToolData _ NARROW[clientData]; planeName _ ViewerTools.GetSelectionContents[]; PlaneButtonAux[planeName, editToolData]; }; SelectedTextSourceButton: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = { sourceName: Rope.ROPE; editToolData: EditToolData _ NARROW[clientData]; sourceName _ ViewerTools.GetSelectionContents[]; SourceButtonAux[sourceName, editToolData]; }; SelectedTextTargetButton: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = { targetName: Rope.ROPE; editToolData: EditToolData _ NARROW[clientData]; targetName _ ViewerTools.GetSelectionContents[]; TargetButtonAux[targetName, editToolData]; }; SelectedTextParentButton: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = { editToolData: EditToolData _ NARROW[clientData]; parentName: Rope.ROPE; parentName _ ViewerTools.GetSelectionContents[]; ParentButtonAux[parentName, editToolData]; }; SelectOp: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { editToolData: EditToolData _ NARROW[clientData]; scene: Scene _ editToolData.sceneSection.currentScene; globalOpIndex _ IF globalOpIndex = globalOpCount THEN 1 ELSE globalOpIndex + 1; Labels.Set[editToolData.sceneSection.opLabel, globalOpArray[globalOpIndex]]; SELECT globalOpArray[globalOpIndex] FROM "union" => editToolData.sceneSection.op _ union; "intersection" => editToolData.sceneSection.op _ intersection; "difference" => editToolData.sceneSection.op _ difference; ENDCASE => ERROR; }; IsColor: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { editToolData: EditToolData _ NARROW[clientData]; scene: Scene _ editToolData.sceneSection.currentScene; truthRope: Rope.ROPE; globalIsColor _ NOT globalIsColor; truthRope _ IF globalIsColor THEN "TRUE" ELSE "FALSE"; Labels.Set[editToolData.artworkSection.isColor, truthRope]; }; First: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { editToolData: EditToolData _ NARROW[clientData]; scene: Scene _ editToolData.sceneSection.currentScene; assembly, superA: Assembly; found: BOOL; namePresent: BOOL _ FALSE; IF mouseButton = blue THEN { SVError.Append["Can't undo First!", TRUE, TRUE]; SVError.Blink[]; RETURN}; assembly _ SVSelections.TopMoveeCoincident[]; IF assembly = NIL THEN RETURN; [assembly, superA, found] _ SVEditUser.FindAssemblyFromName[assembly.name, scene]; IF NOT found THEN RETURN; DisplayList3d.MoveToFrontOfAssembly[assembly, superA, scene]; SVEditUser.SceneNewVersion[editToolData.currentViewerToolData]; }; -- end of First DrawCS: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { editToolData: EditToolData _ NARROW[clientData]; scene: Scene _ editToolData.sceneSection.currentScene; assembly: Assembly; cs: CoordSystem; viewerToolData: ViewerToolData; success: BOOL; viewerCell: ViewerCell; assembly _ SVSelections.TopMoveeCoincident[]; IF assembly = NIL THEN RETURN; cs _ assembly.coordSys; [viewerCell, success] _ SVEditUser.FindSceneInAllViewers[scene, editToolData.allViewers]; IF NOT success THEN ERROR; IF viewerCell.viewersOnScene = NIL THEN RETURN; viewerToolData _ NARROW[viewerCell.viewersOnScene.data]; SVViewerUser.DrawOneCSInViewer[viewerToolData, cs]; 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.DrawOneCSInViewer[viewerToolData, cs]; ENDLOOP; }; DeleteButton: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { editToolData: EditToolData _ NARROW[clientData]; scene: Scene _ editToolData.sceneSection.currentScene; IF mouseButton = blue THEN { SVError.Append["Can't undo Delete!", TRUE, TRUE]; SVError.Blink[]; RETURN; }; DeleteSources[editToolData]; }; DeleteSources: PUBLIC PROC [editToolData: EditToolData] = TRUSTED { found: BOOL _ TRUE; success: BOOL; coin, assembly, superAssembly: Assembly; scene: Scene; FOR sel: Selection _ SVSelections.PopMovee[], SVSelections.NextMovee[] UNTIL sel = NIL DO coin _ sel.coincident; scene _ sel.viewerToolData.scene; [assembly, superAssembly, success] _ SVEditUser.FindAssemblyFromName[coin.name, scene]; IF NOT success THEN LOOP; success _ DisplayList3d.DeleteSubassemblyFromAssembly[assembly, superAssembly, scene]; IF NOT success THEN ERROR; ENDLOOP; SVSelections.ClearMoveeStack[editToolData]; -- This should be superfluous SVSelections.ClearTargetStack[editToolData]; SVEditUser.SceneNewVersion[editToolData.currentViewerToolData]; SVEditUser.PaintSceneAllViewers[SVViewerUser.EraseAndDrawSceneEtc, editToolData, scene]; }; SetOp: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { editToolData: EditToolData _ NARROW[clientData]; scene: Scene _ editToolData.sceneSection.currentScene; pointSetOp: PointSetOp _ editToolData.sceneSection.op; compAssembly: Assembly; namePresent: BOOL _ FALSE; IF mouseButton = blue THEN { SVError.Append["Can't undo SetOp!", TRUE, TRUE]; SVError.Blink[]; RETURN}; compAssembly _ SVSelections.PopMoveeCoincident[]; IF compAssembly = NIL THEN RETURN; WITH compAssembly.shape SELECT FROM shape: Shape => { SVError.Append["Can't add op to primitive assembly ", TRUE]; SVError.Append[compAssembly.name]; SVError.Append[".", FALSE, TRUE]; SVError.Blink[]; RETURN}; al: AssemblyList => al.pointSetOp _ pointSetOp; ENDCASE => ERROR; SVEditUser.SceneNewVersion[editToolData.currentViewerToolData]; }; -- end of SetOp Help: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { editToolData: EditToolData _ NARROW[clientData]; fullName: Rope.ROPE; wdir: Rope.ROPE; success: BOOL _ TRUE; wdir _ editToolData.originalWorkingDirectory; [fullName,,] _ FS.ExpandName["SVHelpFile.tioga", wdir ! FS.Error => IF error.group = user THEN { success _ FALSE; CONTINUE; } ]; IF NOT success THEN RETURN; [] _ TiogaMenuOps.Open[fullName]; }; SetColorMap: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { editToolData: EditToolData _ NARROW[clientData]; Preprocess3d.SetUpColorMap[Rope.Concat[editToolData.originalWorkingDirectory, "Std.Tab"]]; }; BWMap: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { ColorMap.GrayMap[]; ColorMap.SetUpGrayTable[]; }; Restart: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { SVInputMonitor.Restart[]; }; RotX: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { editToolData: EditToolData _ NARROW[clientData]; scene: Scene _ editToolData.sceneSection.currentScene; degrees: REAL _ SVViewerTools.GetReal[editToolData.transformSection.degrees, 0]; targetCS: CoordSystem; g: SelectionGenerator; selectionsExist: BOOL; targetCSspecified: BOOL _ TRUE; IF mouseButton = blue THEN degrees _ -degrees; targetCS _ SVSelections.TopTargetCoinCoordSys[]; IF targetCS = NIL THEN targetCSspecified _ FALSE; [g, selectionsExist] _ SVSelections.GetSelectionGenerator[movee]; SVSelections.ComplainIfNot[selectionsExist]; IF NOT selectionsExist THEN RETURN; FOR thisSource: Assembly _ SVSelections.NextSelectionCoincident[g], SVSelections.NextSelectionCoincident[g] UNTIL thisSource = NIL DO SVEditUser.PaintAssemblyAllViewers[SVViewerUser.DrawAssemblyXOR, editToolData, scene, thisSource]; IF NOT targetCSspecified THEN targetCS _ thisSource.coordSys; SVTransforms.XRotate[thisSource.coordSys, targetCS, degrees]; SVEditUser.PaintAssemblyAllViewers[SVViewerUser.DrawAssemblyXOR, editToolData, scene, thisSource]; ENDLOOP; SVEditUser.SceneNewVersion[editToolData.currentViewerToolData]; }; RotY: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { editToolData: EditToolData _ NARROW[clientData]; scene: Scene _ editToolData.sceneSection.currentScene; degrees: REAL _ SVViewerTools.GetReal[editToolData.transformSection.degrees, 0]; targetCS: CoordSystem; g: SelectionGenerator; selectionsExist: BOOL; targetCSspecified: BOOL _ TRUE; IF mouseButton = blue THEN degrees _ -degrees; targetCS _ SVSelections.TopTargetCoinCoordSys[]; IF targetCS = NIL THEN targetCSspecified _ FALSE; [g, selectionsExist] _ SVSelections.GetSelectionGenerator[movee]; SVSelections.ComplainIfNot[selectionsExist]; IF NOT selectionsExist THEN RETURN; FOR thisSource: Assembly _ SVSelections.NextSelectionCoincident[g], SVSelections.NextSelectionCoincident[g] UNTIL thisSource = NIL DO SVEditUser.PaintAssemblyAllViewers[SVViewerUser.DrawAssemblyXOR, editToolData, scene, thisSource]; IF NOT targetCSspecified THEN targetCS _ thisSource.coordSys; SVTransforms.YRotate[thisSource.coordSys, targetCS, degrees]; SVEditUser.PaintAssemblyAllViewers[SVViewerUser.DrawAssemblyXOR, editToolData, scene, thisSource]; ENDLOOP; SVEditUser.SceneNewVersion[editToolData.currentViewerToolData]; }; RotZ: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { editToolData: EditToolData _ NARROW[clientData]; scene: Scene _ editToolData.sceneSection.currentScene; degrees: REAL _ SVViewerTools.GetReal[editToolData.transformSection.degrees, 0]; targetCS: CoordSystem; g: SelectionGenerator; selectionsExist: BOOL; targetCSspecified: BOOL _ TRUE; IF mouseButton = blue THEN degrees _ -degrees; targetCS _ SVSelections.TopTargetCoinCoordSys[]; IF targetCS = NIL THEN targetCSspecified _ FALSE; [g, selectionsExist] _ SVSelections.GetSelectionGenerator[movee]; SVSelections.ComplainIfNot[selectionsExist]; IF NOT selectionsExist THEN RETURN; FOR thisSource: Assembly _ SVSelections.NextSelectionCoincident[g], SVSelections.NextSelectionCoincident[g] UNTIL thisSource = NIL DO SVEditUser.PaintAssemblyAllViewers[SVViewerUser.DrawAssemblyXOR, editToolData, scene, thisSource]; IF NOT targetCSspecified THEN targetCS _ thisSource.coordSys; SVTransforms.ZRotate[thisSource.coordSys, targetCS, degrees]; SVEditUser.PaintAssemblyAllViewers[SVViewerUser.DrawAssemblyXOR, editToolData, scene, thisSource]; ENDLOOP; SVEditUser.SceneNewVersion[editToolData.currentViewerToolData]; }; Trans: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { editToolData: EditToolData _ NARROW[clientData]; scene: Scene _ editToolData.sceneSection.currentScene; x, y, z: REAL; targetCS: CoordSystem; g: SelectionGenerator; selectionsExist: BOOL; targetCSspecified: BOOL _ TRUE; [x, y, z] _ SVViewerTools.GetThreeReals[editToolData.transformSection.transXYZ]; IF mouseButton = blue THEN {x _ -x; y _ -y; z _ -z}; targetCS _ SVSelections.TopTargetCoinCoordSys[]; IF targetCS = NIL THEN targetCSspecified _ FALSE; [g, selectionsExist] _ SVSelections.GetSelectionGenerator[movee]; SVSelections.ComplainIfNot[selectionsExist]; IF NOT selectionsExist THEN RETURN; FOR thisSource: Assembly _ SVSelections.NextSelectionCoincident[g], SVSelections.NextSelectionCoincident[g] UNTIL thisSource = NIL DO SVEditUser.PaintAssemblyAllViewers[SVViewerUser.DrawAssemblyXOR, editToolData, scene, thisSource]; IF NOT targetCSspecified THEN targetCS _ thisSource.coordSys; SVTransforms.Translate[thisSource.coordSys, targetCS, x, y, z]; SVEditUser.PaintAssemblyAllViewers[SVViewerUser.DrawAssemblyXOR, editToolData, scene, thisSource]; ENDLOOP; SVEditUser.SceneNewVersion[editToolData.currentViewerToolData]; }; ScalePrimitive: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { editToolData: EditToolData _ NARROW[clientData]; scene: Scene _ editToolData.sceneSection.currentScene; errorRope: Rope.ROPE; g: SelectionGenerator; selectionsExist: BOOL; x, y, z: REAL; [x, y, z] _ SVViewerTools.GetThreeReals[editToolData.transformSection.scaleXYZ]; IF x = 0 OR y = 0 OR z = 0 THEN { SVError.Append["Can't scale by 0", TRUE, TRUE]; SVError.Blink[]; RETURN}; IF mouseButton = blue THEN {x _ 1/x; y _ 1/y; z _ 1/z}; [g, selectionsExist] _ SVSelections.GetSelectionGenerator[movee]; SVSelections.ComplainIfNot[selectionsExist]; IF NOT selectionsExist THEN RETURN; FOR thisSource: Assembly _ SVSelections.NextSelectionCoincident[g], SVSelections.NextSelectionCoincident[g] UNTIL thisSource = NIL DO IF NOT ISTYPE[thisSource.shape, Shape] THEN { errorRope _ IO.PutFR["Can't ScalePrimitive! a cluster assembly [%g]",[rope[thisSource.name]]]; SVError.Append[errorRope, TRUE, TRUE]; SVError.Blink[]; LOOP; }; SVEditUser.PaintAssemblyAllViewers[SVViewerUser.DrawAssemblyXOR, editToolData, scene, thisSource]; SVTransforms.ScalePrimitive[thisSource, x, y, z]; SVEditUser.PaintAssemblyAllViewers[SVViewerUser.DrawAssemblyXOR, editToolData, scene, thisSource]; ENDLOOP; SVEditUser.SceneNewVersion[editToolData.currentViewerToolData]; }; EvenScale: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { editToolData: EditToolData _ NARROW[clientData]; scene: Scene _ editToolData.sceneSection.currentScene; targetCS: CoordSystem; g: SelectionGenerator; selectionsExist: BOOL; scalar: REAL; targetCSspecified: BOOL _ TRUE; scalar _ SVViewerTools.GetReal[editToolData.transformSection.scalar, 0]; IF scalar = 0 THEN { SVError.Append["Can't scale by 0", TRUE, TRUE]; SVError.Blink[]; RETURN}; IF mouseButton = blue THEN {scalar _ 1/scalar}; targetCS _ SVSelections.TopTargetCoinCoordSys[]; IF targetCS = NIL THEN targetCSspecified _ FALSE; [g, selectionsExist] _ SVSelections.GetSelectionGenerator[movee]; SVSelections.ComplainIfNot[selectionsExist]; IF NOT selectionsExist THEN RETURN; FOR thisSource: Assembly _ SVSelections.NextSelectionCoincident[g], SVSelections.NextSelectionCoincident[g] UNTIL thisSource = NIL DO IF NOT targetCSspecified THEN targetCS _ thisSource.coordSys; IF thisSource.coordSys.parent # NIL THEN { SVEditUser.PaintAssemblyAllViewers[SVViewerUser.DrawAssemblyXOR, editToolData, scene, thisSource]; SVTransforms.ScaleEven[thisSource, targetCS, scalar]; SVEditUser.PaintAssemblyAllViewers[SVViewerUser.DrawAssemblyXOR, editToolData, scene, thisSource]; } ELSE { SVTransforms.ScaleEven[thisSource, targetCS, scalar]; SVEditUser.PaintSceneAllViewers[SVViewerUser.EraseAndDrawSceneEtc, editToolData, scene]; }; ENDLOOP; SVEditUser.SceneNewVersion[editToolData.currentViewerToolData]; }; Edit: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { editToolData: EditToolData _ NARROW[clientData]; scratchpad: Viewer _ editToolData.scratchpad; scratchpadData: ScratchpadData _ NARROW[scratchpad.data]; scratchViewerData: ScratchViewerData _ scratchpadData.scratchViewerData; scene: Scene _ editToolData.sceneSection.currentScene; mo: MasterObject; shape: Shape; scalars: Vector; path: Path; poly: Polygon; moClassName: Rope.ROPE; assembly: Assembly; assembly _ SVSelections.TopMoveeCoincident[]; IF assembly = NIL THEN RETURN; IF NOT ISTYPE[assembly.shape, Shape] THEN { SVError.Append["Cannot Edit Composite Assembly", TRUE, TRUE]; SVError.Blink[]; RETURN}; shape _ NARROW[assembly.shape]; mo _ shape.mo; scalars _ CoordSys.GetScalars[shape.coordSys]; moClassName _ mo.class.name; SELECT TRUE FROM Rope.Equal[moClassName, "revoluteSweep"] => { path _ SweepGeometry.GetRevolutePath[NARROW[mo.lineBody, RevoluteMesh]]; Scratchpad2dUser.Edit[path, revo, scratchViewerData]; SVViewerTools.SetThreeReals[editToolData.transformSection.scaleXYZ, scalars[1], scalars[2], scalars[3]]; }; Rope.Equal[moClassName, "linearSweep"] => { linMesh: LinearMesh _ NARROW[mo.lineBody]; depth: REAL; poly _ SweepGeometry.GetLinearPoly[linMesh]; path _ SVPolygon2d.PolygonToPath[poly]; Scratchpad2dUser.Edit[path, lin, scratchViewerData]; depth _ linMesh.array[1][1][3]*2; SVViewerTools.SetReal[editToolData.linSection.depth, depth]; SVViewerTools.SetThreeReals[editToolData.transformSection.scaleXYZ, scalars[1], scalars[2], scalars[3]]; }; Rope.Equal[moClassName, "sphere"] => { radius: REAL; sphereRec: SphereRec _ NARROW[mo.mainBody]; radius _ sphereRec.radius; IF scalars[1] = scalars[2] AND scalars[2] = scalars[3] THEN {-- stuff the radius and 1's into the scalars SVViewerTools.SetReal[editToolData.sphereSection.radius, scalars[1]*radius]; SVViewerTools.SetThreeReals[editToolData.transformSection.scaleXYZ, 1,1,1]; } ELSE {-- radius = 1; write scalars SVViewerTools.SetReal[editToolData.sphereSection.radius, 1]; SVViewerTools.SetThreeReals[editToolData.transformSection.scaleXYZ, scalars[1]*radius, scalars[2]*radius, scalars[3]*radius]; }; }; Rope.Equal[moClassName, "block"] => { bx, by, bz: REAL; blockRec: BlockRec _ NARROW[mo.mainBody]; bx _ blockRec.x; by _ blockRec.y; bz _ blockRec.z;-- size of the primitive object SVViewerTools.SetThreeReals[editToolData.blockSection.xyz, bx*scalars[1], by*scalars[2], bz*scalars[3]]; SVViewerTools.SetThreeReals[editToolData.transformSection.scaleXYZ, 1,1,1]; }; Rope.Equal[moClassName, "cylinder"] => { radius, height: REAL; cylinderRec: CylinderRec _ NARROW[mo.mainBody]; radius _ cylinderRec.radius; height _ cylinderRec.height;-- dimensions of the master object IF scalars[1] = scalars[3] THEN { SVViewerTools.SetReal[editToolData.cylinderSection.radius, radius*scalars[1]]; SVViewerTools.SetReal[editToolData.cylinderSection.height, height*scalars[2]]; SVViewerTools.SetThreeReals[editToolData.transformSection.scaleXYZ, 1,1,1]; } ELSE { SVViewerTools.SetReal[editToolData.cylinderSection.radius, 1]; SVViewerTools.SetReal[editToolData.cylinderSection.height, 1]; SVViewerTools.SetThreeReals[editToolData.transformSection.scaleXYZ, scalars[1]*radius, scalars[2]*height, scalars[3]*radius]; }; }; Rope.Equal[moClassName, "cone"] => { radius, height: REAL; coneRec: ConeRec _ NARROW[mo.mainBody]; radius _ coneRec.radius; height _ coneRec.height;-- dimensions of the master object IF scalars[1] = scalars[3] THEN { SVViewerTools.SetReal[editToolData.coneSection.radius, radius*scalars[1]]; SVViewerTools.SetReal[editToolData.coneSection.height, height*scalars[2]]; SVViewerTools.SetThreeReals[editToolData.transformSection.scaleXYZ, 1,1,1]; } ELSE { SVViewerTools.SetReal[editToolData.coneSection.radius, 1]; SVViewerTools.SetReal[editToolData.coneSection.height, 1]; SVViewerTools.SetThreeReals[editToolData.transformSection.scaleXYZ, scalars[1]*radius, scalars[2]*height, scalars[3]*radius]; }; }; Rope.Equal[moClassName, "torus"] => { bigRadius, sectionRadius: REAL; torusRec: TorusRec _ NARROW[mo.mainBody]; bigRadius _ torusRec.bigRadius; sectionRadius _ torusRec.sectionRadius; SVViewerTools.SetReal[editToolData.torusSection.bigRadius, bigRadius]; SVViewerTools.SetReal[editToolData.torusSection.sectionRadius, sectionRadius]; SVViewerTools.SetThreeReals[editToolData.transformSection.scaleXYZ, scalars[1], scalars[2], scalars[3]]; }; ENDCASE => { SVError.Append[Rope.Concat["I don't know how to edit ", moClassName], TRUE, TRUE]; SVError.Blink[]; }; }; -- end of Edit AddComposite: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { editToolData: EditToolData _ NARROW[clientData]; scene: Scene _ editToolData.sceneSection.currentScene; pointSetOp: PointSetOp _ editToolData.sceneSection.op; compName: Rope.ROPE; newAssembly, superAssembly: Assembly; success: BOOL; addSucceeds: BOOL _ TRUE; compName _ ViewerTools.GetContents[editToolData.sceneSection.new]; [superAssembly, success] _ SVEditUser.GetParent[editToolData]; IF NOT success THEN RETURN; [newAssembly, addSucceeds] _ DisplayList3d.CreateAndAddClusterAssembly[compName, pointSetOp, scene, superAssembly, Matrix3d.Identity[]]; IF NOT addSucceeds THEN RETURN; SVEditUser.SceneNewVersion[editToolData.currentViewerToolData]; }; -- end of AddComposite SetAmbient: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { editToolData: EditToolData _ NARROW[clientData]; scene: Scene _ editToolData.sceneSection.currentScene; color: Color; success: BOOLEAN; [color, success] _ SVViewerTools.GetColor[editToolData.lightSection.color]; IF NOT success THEN RETURN; IF NOT scene.lightSources.first.type = ambient THEN ERROR; scene.lightSources.first.color _ color; SVEditUser.SceneNewVersion[editToolData.currentViewerToolData]; SVEditUser.PaintSceneAllViewers[SVViewerUser.EraseAndDrawSceneEtc, editToolData, scene]; }; GetAmbient: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton, shift, control: BOOL] = TRUSTED { editToolData: EditToolData _ NARROW[clientData]; scene: Scene _ editToolData.sceneSection.currentScene; color: Color; IF NOT scene.lightSources.first.type = ambient THEN ERROR; color _ scene.lightSources.first.color; SVViewerTools.SetColor[editToolData.lightSection.color, color]; }; END. @File: SVEditUserImplC.mesa Last edited by Bier on May 24, 1985 0:31:56 am PDT Copyright c 1984 by Xerox Corporation. All rights reserved. Author: Eric Bier Contents: All of the procedures called by SVEditTool when menus and buttons are pressed (part 3) Basic Shapes GLOBAL VARIABLES Text Input Section Use planeName to coordsys-select. Create a plane-selection of this assembly. Use sourceName to coordsys-select. Create a source-selection of this assembly. Use targetName to coordsys-select. Create a target-selection of this assembly. Stuff parentName into the Parent slot. Use the text in the skitter area as the name of an assembly to coordsys-select. Create a source-selection of this assembly. Stuff the text next to Skitter: into the Parent slot. Stuff the text next to Text1: into the Parent slot. Stuff the text of the current selection into the Parent slot. Prompts which cycle through possibilities Command Buttons Make sure that the assembly named in "Assembly: " is the first element in the AssemblyList of its super assembly (useful when csg op = "difference" since the result of difference is that of the first element minus all of the rest. find the assembly mentioned by the edittool and draw its coordinate system. Draw the first viewer if there is one. draw the rest (remember they are linked in a ring) Removes assembly from the assemblyList of superAssembly and deletes the coordinate systems of all of its children. We will certainly delete the coincident of all movee's. We may also delete an assembly indirectly referenced by a selection. Worst of all, we may delete an assembly and forget to delete the hooks which are on it. This last may be fixed soon. the name in the assembly slot should refer to an already existing Composite Assembly. Make its CSG pointSetOp equal to the op shown next to "Op:". Error if Assembly is a Primitive Assembly. Find out if the current object is a sweep shape. If so, extract its path and feed to the scratchpad. Otherwise complain in SVError. A sphere may actually be an oblate spheroid if the scalars are uneven. If they are even, I will will stuff the radius. Otherwise, I will set radius = 1 and stuff the scalars in the scaling part of the transform section. **** This should also stuff the name of the sphere's parent in "With Respect To:". since the system doesn't currently allow shear in primitives, this is easy if sx = sz then stuff radius and height. Otherwise using scaling blank to list all scalars similar to cylinder in the case of the torus, we write the current scalars AND take the radius data directly from the torus record (master object) Use the name in the assembly slot to name this new composite. It is a subassembly of the assembly named in "WithRespectTo"; It has no sub-assemblies to begin with. Add * will now add objects to the assembly named in "WithRespectTo". Κ^˜Ihead1šœ™Jšœ2™2Jšœ Οmœ1™˜>Jšœ:˜:—Jšžœžœ˜Jšœ˜—J˜šŸœžœžœ žœžœžœžœ,žœžœ˜wJšœžœ ˜0Jšœ6˜6Jšœžœ˜Jšœžœ˜"Jšœ žœžœžœ ˜6Jšœ;˜;Jšœ˜—J˜Jšœ™J˜šŸœžœžœ žœžœžœžœ,žœžœ˜uJšœζ™ζJšœžœ ˜0Jšœ6˜6Jšœ˜Jšœžœ˜ Jšœ žœžœ˜J˜šžœžœ˜Jšœ$žœžœ˜0Jšœ˜Jšžœ˜—Jšœ-˜-Jšœ˜JšœR˜RJšžœžœžœžœ˜Jšœ=˜=Jšœ?˜?Jšœ ˜—J˜JšŸœžœžœ žœžœžœžœ˜Tšœžœžœ˜!JšœK™KJšœžœ ˜0Jšœ6˜6Jšœ˜Jšœ˜Jšœ˜Jšœ žœ˜Jšœ˜J˜Jšœ-˜-Jšžœžœžœ˜Jšœ˜JšœY˜YJšžœžœ žœžœ˜Jšœ&™&Jšžœžœžœžœ˜/Jšœžœ!˜8Jšœ3˜3Jšœ2™2Jšžœ"žœžœžœ˜4Jšžœ9˜<šžœ"ž˜)Jšœžœ ˜#Jšœ3˜3—Jšžœ˜Jšœ˜—J˜šŸ œžœžœ žœžœžœžœ,žœžœ˜|Jšœžœ ˜0Jšœ6˜6J˜šžœžœ˜Jšœ%žœžœ˜1Jšœ˜Jšž˜Jšœ˜—Jšœ˜J˜J˜—šŸ œžœžœ žœ˜CJšœžœžœ˜Jšœ žœ˜Jšœ(˜(Jšœ ˜ J˜šžœDžœžœž˜YJš‘œ˜Jš‘œ˜!JšœE‘œ˜WJšžœžœ žœžœ˜šœ‘œ!˜VJšœr™r—Jšžœžœ žœžœ˜—Jšžœ˜šœ, ˜IJ™τ—Jšœ,˜,Jšœ?˜?LšœX˜XJšœ˜—J˜šŸœžœžœ žœžœžœžœ,žœžœ˜uJšœΏ™ΏJšœžœ ˜0Jšœ6˜6Jšœ6˜6Jšœ˜Jšœ žœžœ˜J˜šžœžœ˜Jšœ$žœžœ˜0Jšœ˜Jšžœ˜—Jšœ1˜1Jšžœžœžœžœ˜"šžœžœž˜#šœ˜Jšœ6žœ˜šžœžœ˜!JšœN˜NJšœN˜NJšœK˜KJšœ˜—šžœ˜Jšœ>˜>Jšœ>˜>Jšœ}˜}Jšœ˜—Jšœ˜—šœ$˜$Jšœ™Jšœžœ˜Jšœžœ˜'Jšœ˜Jšœ "˜:šžœžœ˜!JšœJ˜JJšœJ˜JJšœK˜KJšœ˜—šžœ˜Jšœ:˜:Jšœ:˜:Jšœ}˜}Jšœ˜—Jšœ˜—šœ%˜%Jšœ~™~Jšœžœ˜Jšœžœ˜)Jšœ˜Jšœ'˜'JšœF˜FJšœN˜NJšœh˜hJšœ˜—šžœ˜ JšœFžœžœ˜RJšœ˜J˜——Jšœ ˜—J˜šŸ œžœžœ žœžœžœžœ,žœžœ˜|Jšœλ™λJšœžœ ˜0Jšœ6˜6Jšœ6˜6Jšœž˜Jšœ%˜%Jšœ žœ˜Jšœ žœžœ˜Jšœ=‘œ˜BJšœ&‘ œ˜>Jšžœžœ žœžœ˜Jšœ+‘œB˜ˆJšžœžœ žœžœ˜Jšœ?˜?Jšœ ˜J˜—šŸ œžœžœ žœžœžœžœ,žœžœ˜zJšœžœ ˜0Jšœ6˜6Jšœ ˜ Jšœ žœ˜JšœK˜KJšžœžœ žœžœ˜Jšžœžœ)žœžœ˜:Jšœ'˜'Jšœ?˜?LšœX˜XJ˜J˜—šŸ œž œ žœžœžœžœ,žœžœ˜zJšœžœ ˜0Jšœ6˜6Jšœ ˜ Jšžœžœ)žœžœ˜:Jšœ'˜'Jšœ?˜?J˜J˜—J˜Jšžœ˜J˜J˜—…—oꘈ