File: SVEditUserImplC.mesa
Last edited by Bier on August 18, 1983 1:45 pm
Author: Eric Bier
Contents: All of the procedures called by SVEditTool when menus and buttons are pressed (part 3)
DIRECTORY
BasicObject3d,
ColorMap,
CoordSys,
CSG,
CSGGraphics,
DisplayList3d,
GraphicsColor,
IO,
Labels,
Matrix3d,
Menus,
MessageWindow,
Preprocess3d,
Rope,
Scratchpad2dUser,
SVArtwork,
SVEditUser,
SVPolygon2d,
SVTransforms,
SVViewerTools,
SVViewerUser,
SweepGeometry,
ViewerClasses,
ViewerTools;
SVEditUserImplC:
CEDAR
PROGRAM
IMPORTS ColorMap, DisplayList3d, IO, Labels, Matrix3d, MessageWindow, Preprocess3d, Rope, Scratchpad2dUser, SVArtwork, SVEditUser, SVPolygon2d, SVTransforms, SVViewerTools, SVViewerUser, SweepGeometry, ViewerTools
EXPORTS SVEditUser =
BEGIN
Artwork: TYPE = SVArtwork.Artwork;
Assembly: TYPE = DisplayList3d.Assembly;
AssemblyList: TYPE = DisplayList3d.AssemblyList;
Camera: TYPE = CSGGraphics.Camera;
Color: TYPE = GraphicsColor.Color;
CoordSystem: TYPE = CoordSys.CoordSystem;
EditToolData: TYPE = REF EditToolDataObj;
EditToolDataObj: TYPE = SVEditUser.EditToolDataObj;
LinearMesh: TYPE = SweepGeometry.LinearMesh;
MasterObject: TYPE = DisplayList3d.MasterObject;
Material: TYPE = SVArtwork.Material;
Matrix4by4: TYPE = Matrix3d.Matrix4by4;
MouseButton: TYPE = Menus.MouseButton;
Path: TYPE = SVPolygon2d.Path;
Point3d: TYPE = Matrix3d.Point3d;
Polygon: TYPE = SVPolygon2d.Polygon;
PointSetOp: TYPE = CSG.PointSetOp;
RevoluteMesh: TYPE = SweepGeometry.RevoluteMesh;
Scene: TYPE = DisplayList3d.Scene;
ScratchpadData: TYPE = Scratchpad2dUser.ScratchpadData;
ScratchViewerData: TYPE = Scratchpad2dUser.ScratchViewerData;
Viewer: TYPE = ViewerClasses.Viewer;
ViewerCell: TYPE = REF ViewerCellObj;
ViewerCellObj: TYPE = SVEditUser.ViewerCellObj;
ViewerToolData: TYPE = SVViewerUser.ViewerToolData;
ViewerPictureData: TYPE = SVViewerUser.ViewerPictureData;
Basic Shapes
SphereRec: TYPE = REF SphereRecObj;
SphereRecObj: TYPE = BasicObject3d.SphereRecObj;
BlockRec: TYPE = REF BlockRecObj;
BlockRecObj: TYPE = BasicObject3d.BlockRecObj;
CylinderRec: TYPE = REF CylinderRecObj;
CylinderRecObj: TYPE = BasicObject3d.CylinderRecObj;
ConeRec: TYPE = REF ConeRecObj;
ConeRecObj: TYPE = BasicObject3d.ConeRecObj;
TorusRec: TYPE = REF TorusRecObj;
TorusRecObj: TYPE = BasicObject3d.TorusRecObj;
GLOBAL VARIABLES
globalOpIndex: NAT ← 1;
globalOpCount: NAT = 3;
globalOpArray: ARRAY[1..globalOpCount] OF Rope.ROPE ←
["union", "intersection", "difference"];
globalIsColor: BOOL ← FALSE;
Prompts which cycle through possibilities (B)
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];
};
Command Buttons
First:
PUBLIC
PROC [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
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.
editToolData: EditToolData ← NARROW[clientData];
scene: Scene ← editToolData.sceneSection.currentScene;
asName: Rope.ROPE ← ViewerTools.GetContents[editToolData.sceneSection.assemblyName];
assembly, superA: Assembly;
found: BOOL;
namePresent: BOOL ← FALSE;
IF mouseButton = blue
THEN {
MessageWindow.Append["Can't undo First!", TRUE];
MessageWindow.Blink[];
RETURN};
[assembly, superA, found] ← SVEditUser.FindAssemblyFromName[asName, scene];
IF NOT found THEN RETURN;
DisplayList3d.MoveToFrontOfAssembly[assembly, superA, scene];
SVViewerUser.SceneNewVersion[editToolData.currentViewerToolData];
}; -- end of First
DrawCS: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton,
shift, control:
BOOL] =
TRUSTED {
find the assembly mentioned by the edittool and draw its coordinate system.
editToolData: EditToolData ← NARROW[clientData];
scene: Scene ← editToolData.sceneSection.currentScene;
asName: Rope.ROPE ← ViewerTools.GetContents[editToolData.sceneSection.assemblyName];
assembly: Assembly;
cs: CoordSystem;
viewerToolData: ViewerToolData;
success: BOOL;
viewerCell: ViewerCell;
[assembly, ----, success] ← SVEditUser.FindAssemblyFromName[asName, scene];
IF NOT success THEN RETURN;
cs ← assembly.coordSys;
[viewerCell, success] ← SVEditUser.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.DrawOneCSInViewer[viewerToolData, cs];
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.DrawOneCSInViewer[viewerToolData, cs];
ENDLOOP;
};
Delete:
PUBLIC
PROC [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
scene: Scene ← editToolData.sceneSection.currentScene;
found: BOOL ← TRUE;
success: BOOL;
mo: MasterObject;
primList: LIST OF Assembly;
assemblyName: Rope.ROPE ← ViewerTools.GetContents[editToolData.sceneSection.assemblyName];
assembly, superAssembly: Assembly;
IF mouseButton = blue
THEN {
MessageWindow.Append["Can't undo Delete!", TRUE];
MessageWindow.Blink[];
RETURN};
[assembly, superAssembly, success] ←
SVEditUser.FindAssemblyFromName[assemblyName, scene];
IF NOT success THEN RETURN;
success ← DisplayList3d.DeleteSubassemblyFromAssembly[assembly, superAssembly, scene];
DisplayList3d.DeleteCoordSysNamed[assemblyName, scene];
IF NOT success THEN ERROR;
SVViewerUser.SceneNewVersion[editToolData.currentViewerToolData];
SVEditUser.DrawSceneInternal[parent, clientData, mouseButton, shift, control];
};
SetColor:
PUBLIC
PROC [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
scene: Scene ← editToolData.sceneSection.currentScene;
get r, g, and b from x, y, and z.
color: Color;
colorArtwork: Artwork;
material: Material;
materialName: Rope.ROPE ← SVEditUser.globalMatArray[editToolData.artworkSection.materialValue];
assembly: Assembly;
found, success: BOOL;
IF mouseButton = blue
THEN {
MessageWindow.Append["Can't undo SetColor!", TRUE];
MessageWindow.Blink[];
RETURN};
[color, success] ← SVViewerTools.GetColor[editToolData.artworkSection.rgb];
IF
NOT success
THEN {
MessageWindow.Append[Rope.Cat["Can't read your rgb color."]];
MessageWindow.Blink[];
RETURN};
IF Rope.Equal[ViewerTools.GetContents[editToolData.sceneSection.assemblyName], "background",
FALSE]
THEN {
scene.backgroundColor ← color;
SVEditUser.DrawSceneInternal[parent, clientData, mouseButton, shift, control];
RETURN}; -- a special case to set background color
[assembly, found] ← SVEditUser.GetAssembly[editToolData.sceneSection.assemblyName, scene];
IF NOT found THEN RETURN;
[material, found] ← SVArtwork.RopeToMaterial[materialName];
IF
NOT found
THEN {
MessageWindow.Append[Rope.Cat["Material ",materialName," not known."]];
MessageWindow.Blink[];
RETURN};
colorArtwork ← SVArtwork.CreateColorArtwork[color, material];
DisplayList3d.SetArtworkAssembly[assembly, colorArtwork, scene];
SVViewerUser.SceneNewVersion[editToolData.currentViewerToolData];
SVEditUser.DrawSceneInternal[parent, clientData, mouseButton, shift, control];
};
SetOp:
PUBLIC
PROC [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
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.
editToolData: EditToolData ← NARROW[clientData];
scene: Scene ← editToolData.sceneSection.currentScene;
pointSetOp: PointSetOp ← editToolData.sceneSection.op;
compAssembly: Assembly;
compName: Rope.ROPE ← ViewerTools.GetContents[editToolData.sceneSection.assemblyName];
found: BOOL;
namePresent: BOOL ← FALSE;
IF mouseButton = blue
THEN {
MessageWindow.Append["Can't undo SetOp!", TRUE];
MessageWindow.Blink[];
RETURN};
[compAssembly, found] ← SVEditUser.GetAssembly[editToolData.sceneSection.assemblyName, scene];
IF NOT found THEN RETURN;
WITH compAssembly.object
SELECT
FROM
mo: MasterObject => {
MessageWindow.Append["Can't add op to primitive assembly "];
MessageWindow.Append[compName];
MessageWindow.Append["."];
MessageWindow.Blink[];
RETURN};
al: AssemblyList => al.pointSetOp ← pointSetOp;
ENDCASE => ERROR;
SVViewerUser.SceneNewVersion[editToolData.currentViewerToolData];
}; -- end of SetOp
SetColorMap: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton,
shift, control:
BOOL] =
TRUSTED {
Preprocess3d.SetUpColorMap[];
};
BWMap: PUBLIC PROC [parent: REF ANY, clientData: REF ANY, mouseButton: MouseButton,
shift, control:
BOOL] =
TRUSTED {
ColorMap.GrayMap[];
ColorMap.SetUpGrayTable[];
};
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];
wrt: CoordSystem;
assembly: Assembly;
found: BOOL;
[wrt, found] ← SVEditUser.GetCoordSys[editToolData.sceneSection.wrt, scene];
IF NOT found THEN RETURN;
[assembly, found] ← SVEditUser.GetAssembly[editToolData.sceneSection.assemblyName, scene];
IF NOT found THEN RETURN;
IF mouseButton = blue THEN degrees ← -degrees;
SVTransforms.XRotate[assembly,wrt,degrees];
SVViewerUser.SceneNewVersion[editToolData.currentViewerToolData];
SVEditUser.DrawSceneInternal[parent, clientData, mouseButton, shift, control];
};
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];
wrt: CoordSystem;
assembly: Assembly;
found: BOOL;
[wrt, found] ← SVEditUser.GetCoordSys[editToolData.sceneSection.wrt, scene];
IF NOT found THEN RETURN;
[assembly, found] ← SVEditUser.GetAssembly[editToolData.sceneSection.assemblyName, scene];
IF NOT found THEN RETURN;
IF mouseButton = blue THEN degrees ← -degrees;
SVTransforms.YRotate[assembly,wrt,degrees];
SVViewerUser.SceneNewVersion[editToolData.currentViewerToolData];
SVEditUser.DrawSceneInternal[parent, clientData, mouseButton, shift, control];
};
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];
wrt: CoordSystem;
assembly: Assembly;
found: BOOL;
[wrt, found] ← SVEditUser.GetCoordSys[editToolData.sceneSection.wrt, scene];
IF NOT found THEN RETURN;
[assembly, found] ← SVEditUser.GetAssembly[editToolData.sceneSection.assemblyName, scene];
IF NOT found THEN RETURN;
IF mouseButton = blue THEN degrees ← -degrees;
SVTransforms.ZRotate[assembly,wrt,degrees];
SVViewerUser.SceneNewVersion[editToolData.currentViewerToolData];
SVEditUser.DrawSceneInternal[parent, clientData, mouseButton, shift, control];
};
Trans:
PUBLIC
PROC [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
scene: Scene ← editToolData.sceneSection.currentScene;
wrt: CoordSystem;
assembly: Assembly;
found: BOOL;
x, y, z: REAL;
[x, y, z] ← SVViewerTools.GetThreeReals[editToolData.transformSection.transXYZ];
[wrt, found] ← SVEditUser.GetCoordSys[editToolData.sceneSection.wrt, scene];
IF NOT found THEN RETURN;
[assembly, found] ← SVEditUser.GetAssembly[editToolData.sceneSection.assemblyName, scene];
IF NOT found THEN RETURN;
IF mouseButton = blue THEN {x ← -x; y ← -y; z ← -z};
SVTransforms.Translate[assembly, wrt, x, y, z];
SVViewerUser.SceneNewVersion[editToolData.currentViewerToolData];
SVEditUser.DrawSceneInternal[parent, clientData, mouseButton, shift, control];
};
ScalePrimitive:
PUBLIC
PROC [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
editToolData: EditToolData ← NARROW[clientData];
scene: Scene ← editToolData.sceneSection.currentScene;
errorStream: IO.STREAM;
errorRope: Rope.ROPE;
assembly: Assembly;
found: BOOL;
x, y, z: REAL;
[x, y, z] ← SVViewerTools.GetThreeReals[editToolData.transformSection.scaleXYZ];
IF x = 0
OR y = 0
OR z = 0
THEN {
MessageWindow.Append["Can't scale by 0", TRUE];
MessageWindow.Blink[];
RETURN};
[assembly, found] ← SVEditUser.GetAssembly[editToolData.sceneSection.assemblyName, scene];
IF NOT found THEN RETURN;
IF
NOT
ISTYPE[assembly.object, MasterObject]
THEN {
errorStream ← IO.CreateOutputStreamToRope[];
errorStream.PutF["Can't ScalePrimitive! a cluster assembly [%g]",[rope[assembly.name]]];
errorRope ← IO.GetOutputStreamRope[errorStream];
MessageWindow.Append[errorRope, TRUE];
MessageWindow.Blink[];
RETURN};
IF mouseButton = blue THEN {x ← 1/x; y ← 1/y; z ← 1/z};
SVTransforms.ScalePrimitive[assembly, x, y, z];
SVViewerUser.SceneNewVersion[editToolData.currentViewerToolData];
SVEditUser.DrawSceneInternal[parent, clientData, mouseButton, shift, control];
};
EvenScale: 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;
wrt: CoordSystem;
found: BOOL;
scalar: REAL;
scalar ← SVViewerTools.GetReal[editToolData.transformSection.scalar, 0];
IF scalar = 0
THEN {
MessageWindow.Append["Can't scale by 0", TRUE];
MessageWindow.Blink[];
RETURN};
[assembly, found] ← SVEditUser.GetAssembly[editToolData.sceneSection.assemblyName, scene];
IF NOT found THEN RETURN;
[wrt, found] ← SVEditUser.GetCoordSys[editToolData.sceneSection.wrt, scene];
IF NOT found THEN RETURN;
IF mouseButton = blue THEN {scalar ← 1/scalar};
SVTransforms.ScaleEven[assembly, wrt, scalar];
SVViewerUser.SceneNewVersion[editToolData.currentViewerToolData];
SVEditUser.DrawSceneInternal[parent, clientData, mouseButton, shift, control];
};
Edit:
PUBLIC
PROC [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
Find out if the current object is a sweep shape. If so, extract its path and feed to the scratchpad. Otherwise complain in MessageWindow.
editToolData: EditToolData ← NARROW[clientData];
scratchpad: Viewer ← editToolData.scratchpad;
scratchpadData: ScratchpadData ← NARROW[scratchpad.data];
scratchViewerData: ScratchViewerData ← scratchpadData.scratchViewerData;
scene: Scene ← editToolData.sceneSection.currentScene;
success: BOOL;
mo: MasterObject;
path: Path;
poly: Polygon;
moClassName: Rope.ROPE;
objectName: Rope.ROPE ← ViewerTools.GetContents[editToolData.sceneSection.assemblyName];
assembly: Assembly;
[assembly, ----, success] ← SVEditUser.FindAssemblyFromName[objectName, scene];
IF NOT success THEN RETURN;
IF
NOT
ISTYPE[assembly.object, MasterObject]
THEN {
MessageWindow.Append["Cannot Edit Composite Assembly", TRUE];
MessageWindow.Blink[];
RETURN};
mo ← NARROW[assembly.object];
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, assembly.scalars[1], assembly.scalars[2], assembly.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, assembly.scalars[1], assembly.scalars[2], assembly.scalars[3]];
};
Rope.Equal[moClassName, "sphere"] => {
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:".
radius: REAL;
sphereRec: SphereRec ← NARROW[mo.mainBody];
radius ← sphereRec.radius;
IF assembly.scalars[1] = assembly.scalars[2] AND assembly.scalars[2] = assembly.scalars[3]
THEN {
-- stuff the radius and 1's into the scalars
SVViewerTools.SetReal[editToolData.sphereSection.radius, assembly.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, assembly.scalars[1]*radius, assembly.scalars[2]*radius, assembly.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
since the system doesn't currently allow shear in primitives, this is easy
SVViewerTools.SetThreeReals[editToolData.blockSection.xyz, bx*assembly.scalars[1], by*assembly.scalars[2], bz*assembly.scalars[3]];
SVViewerTools.SetThreeReals[editToolData.transformSection.scaleXYZ, 1,1,1];
};
Rope.Equal[moClassName, "cylinder"] => {
if sx = sz then stuff radius and height. Otherwise using scaling blank to list all scalars
radius, height: REAL;
cylinderRec: CylinderRec ← NARROW[mo.mainBody];
radius ← cylinderRec.radius;
height ← cylinderRec.height;-- dimensions of the master object
IF assembly.scalars[1] = assembly.scalars[3]
THEN {
SVViewerTools.SetReal[editToolData.cylinderSection.radius, radius*assembly.scalars[1]];
SVViewerTools.SetReal[editToolData.cylinderSection.height, height*assembly.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, assembly.scalars[1]*radius, assembly.scalars[2]*height, assembly.scalars[3]*radius];
};
};
Rope.Equal[moClassName, "cone"] => {
similar to cylinder
radius, height: REAL;
coneRec: ConeRec ← NARROW[mo.mainBody];
radius ← coneRec.radius;
height ← coneRec.height;-- dimensions of the master object
IF assembly.scalars[1] = assembly.scalars[3]
THEN {
SVViewerTools.SetReal[editToolData.coneSection.radius, radius*assembly.scalars[1]];
SVViewerTools.SetReal[editToolData.coneSection.height, height*assembly.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, assembly.scalars[1]*radius, assembly.scalars[2]*height, assembly.scalars[3]*radius];
};
};
Rope.Equal[moClassName, "torus"] => {
in the case of the torus, we write the current scalars AND take the radius data directly from the torus record (master object)
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, assembly.scalars[1], assembly.scalars[2], assembly.scalars[3]];
};
ENDCASE => ERROR;
}; -- end of Edit
AddComposite:
PUBLIC
PROC [parent:
REF
ANY, clientData:
REF
ANY, mouseButton: MouseButton, shift, control:
BOOL] =
TRUSTED {
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".
editToolData: EditToolData ← NARROW[clientData];
scene: Scene ← editToolData.sceneSection.currentScene;
pointSetOp: PointSetOp ← editToolData.sceneSection.op;
compName: Rope.ROPE ← ViewerTools.GetContents[editToolData.sceneSection.assemblyName];
newAssembly, superAssembly: Assembly;
success: BOOL;
addSucceeds: BOOL ← TRUE;
[superAssembly, success] ← SVEditUser.GetSuper[editToolData];
IF NOT success THEN RETURN;
newAssembly ← DisplayList3d.CreateClusterAssembly[compName, pointSetOp];
DisplayList3d.AddSubassemblyToAssembly[newAssembly, superAssembly, scene, Matrix3d.Identity[]
! DisplayList3d.NameAlreadyPresent => {
MessageWindow.Append["This composite name is already registered. Try another.",TRUE];
MessageWindow.Blink[];
addSucceeds ← FALSE; CONTINUE};
DisplayList3d.AttemptToAddSubassemblyToPrimitive => {
MessageWindow.Append["Attempt To Add Subassembly To Primitive", TRUE];
MessageWindow.Blink[];
addSucceeds ← FALSE; CONTINUE}];
IF NOT addSucceeds THEN RETURN;
SVViewerUser.SceneNewVersion[editToolData.currentViewerToolData];
}; -- end of AddComposite
END.