@itwin/editor-frontend 4.5.0-dev.8 → 4.6.0-dev.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (93) hide show
  1. package/CHANGELOG.md +51 -1
  2. package/LICENSE.md +1 -1
  3. package/README.md +0 -29
  4. package/lib/cjs/CreateElementTool.d.ts +64 -2
  5. package/lib/cjs/CreateElementTool.d.ts.map +1 -1
  6. package/lib/cjs/CreateElementTool.js +65 -4
  7. package/lib/cjs/CreateElementTool.js.map +1 -1
  8. package/lib/cjs/EditTool.d.ts +5 -0
  9. package/lib/cjs/EditTool.d.ts.map +1 -1
  10. package/lib/cjs/EditTool.js +10 -14
  11. package/lib/cjs/EditTool.js.map +1 -1
  12. package/lib/cjs/EditToolIpc.d.ts +1 -5
  13. package/lib/cjs/EditToolIpc.d.ts.map +1 -1
  14. package/lib/cjs/EditToolIpc.js +1 -5
  15. package/lib/cjs/EditToolIpc.js.map +1 -1
  16. package/lib/cjs/TransformElementsTool.d.ts +17 -98
  17. package/lib/cjs/TransformElementsTool.d.ts.map +1 -1
  18. package/lib/cjs/TransformElementsTool.js +15 -412
  19. package/lib/cjs/TransformElementsTool.js.map +1 -1
  20. package/lib/cjs/editor-frontend.d.ts +0 -6
  21. package/lib/cjs/editor-frontend.d.ts.map +1 -1
  22. package/lib/cjs/editor-frontend.js +0 -6
  23. package/lib/cjs/editor-frontend.js.map +1 -1
  24. package/lib/esm/CreateElementTool.d.ts +64 -2
  25. package/lib/esm/CreateElementTool.d.ts.map +1 -1
  26. package/lib/esm/CreateElementTool.js +65 -4
  27. package/lib/esm/CreateElementTool.js.map +1 -1
  28. package/lib/esm/EditTool.d.ts +5 -0
  29. package/lib/esm/EditTool.d.ts.map +1 -1
  30. package/lib/esm/EditTool.js +10 -14
  31. package/lib/esm/EditTool.js.map +1 -1
  32. package/lib/esm/EditToolIpc.d.ts +1 -5
  33. package/lib/esm/EditToolIpc.d.ts.map +1 -1
  34. package/lib/esm/EditToolIpc.js +0 -4
  35. package/lib/esm/EditToolIpc.js.map +1 -1
  36. package/lib/esm/TransformElementsTool.d.ts +17 -98
  37. package/lib/esm/TransformElementsTool.d.ts.map +1 -1
  38. package/lib/esm/TransformElementsTool.js +16 -413
  39. package/lib/esm/TransformElementsTool.js.map +1 -1
  40. package/lib/esm/editor-frontend.d.ts +0 -6
  41. package/lib/esm/editor-frontend.d.ts.map +1 -1
  42. package/lib/esm/editor-frontend.js +0 -6
  43. package/lib/esm/editor-frontend.js.map +1 -1
  44. package/lib/public/locales/en/Editor.json +0 -411
  45. package/package.json +14 -14
  46. package/lib/cjs/DeleteElementsTool.d.ts +0 -14
  47. package/lib/cjs/DeleteElementsTool.d.ts.map +0 -1
  48. package/lib/cjs/DeleteElementsTool.js +0 -42
  49. package/lib/cjs/DeleteElementsTool.js.map +0 -1
  50. package/lib/cjs/ElementGeometryTool.d.ts +0 -148
  51. package/lib/cjs/ElementGeometryTool.d.ts.map +0 -1
  52. package/lib/cjs/ElementGeometryTool.js +0 -705
  53. package/lib/cjs/ElementGeometryTool.js.map +0 -1
  54. package/lib/cjs/ModifyCurveTools.d.ts +0 -140
  55. package/lib/cjs/ModifyCurveTools.d.ts.map +0 -1
  56. package/lib/cjs/ModifyCurveTools.js +0 -777
  57. package/lib/cjs/ModifyCurveTools.js.map +0 -1
  58. package/lib/cjs/SketchTools.d.ts +0 -308
  59. package/lib/cjs/SketchTools.d.ts.map +0 -1
  60. package/lib/cjs/SketchTools.js +0 -1708
  61. package/lib/cjs/SketchTools.js.map +0 -1
  62. package/lib/cjs/SolidModelingTools.d.ts +0 -381
  63. package/lib/cjs/SolidModelingTools.d.ts.map +0 -1
  64. package/lib/cjs/SolidModelingTools.js +0 -1453
  65. package/lib/cjs/SolidModelingTools.js.map +0 -1
  66. package/lib/cjs/SolidPrimitiveTools.d.ts +0 -322
  67. package/lib/cjs/SolidPrimitiveTools.d.ts.map +0 -1
  68. package/lib/cjs/SolidPrimitiveTools.js +0 -1376
  69. package/lib/cjs/SolidPrimitiveTools.js.map +0 -1
  70. package/lib/esm/DeleteElementsTool.d.ts +0 -14
  71. package/lib/esm/DeleteElementsTool.d.ts.map +0 -1
  72. package/lib/esm/DeleteElementsTool.js +0 -39
  73. package/lib/esm/DeleteElementsTool.js.map +0 -1
  74. package/lib/esm/ElementGeometryTool.d.ts +0 -148
  75. package/lib/esm/ElementGeometryTool.d.ts.map +0 -1
  76. package/lib/esm/ElementGeometryTool.js +0 -697
  77. package/lib/esm/ElementGeometryTool.js.map +0 -1
  78. package/lib/esm/ModifyCurveTools.d.ts +0 -140
  79. package/lib/esm/ModifyCurveTools.d.ts.map +0 -1
  80. package/lib/esm/ModifyCurveTools.js +0 -772
  81. package/lib/esm/ModifyCurveTools.js.map +0 -1
  82. package/lib/esm/SketchTools.d.ts +0 -308
  83. package/lib/esm/SketchTools.d.ts.map +0 -1
  84. package/lib/esm/SketchTools.js +0 -1704
  85. package/lib/esm/SketchTools.js.map +0 -1
  86. package/lib/esm/SolidModelingTools.d.ts +0 -381
  87. package/lib/esm/SolidModelingTools.d.ts.map +0 -1
  88. package/lib/esm/SolidModelingTools.js +0 -1445
  89. package/lib/esm/SolidModelingTools.js.map +0 -1
  90. package/lib/esm/SolidPrimitiveTools.d.ts +0 -322
  91. package/lib/esm/SolidPrimitiveTools.d.ts.map +0 -1
  92. package/lib/esm/SolidPrimitiveTools.js +0 -1372
  93. package/lib/esm/SolidPrimitiveTools.js.map +0 -1
@@ -1,1372 +0,0 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
5
- /** @packageDocumentation
6
- * @module Editing
7
- */
8
- import { DialogProperty, PropertyDescriptionHelper } from "@itwin/appui-abstract";
9
- import { BentleyError } from "@itwin/core-bentley";
10
- import { Code, ColorDef, ElementGeometry, } from "@itwin/core-common";
11
- import { AccuDrawHintBuilder, AngleDescription, GraphicType, IModelApp, LengthDescription, NotifyMessageDetails, OutputMessagePriority, } from "@itwin/core-frontend";
12
- import { Angle, Arc3d, AxisOrder, Box, Cone, CurvePrimitive, FrameBuilder, Geometry, LinearSweep, LineSegment3d, LineString3d, Loop, Matrix3d, Path, Ray3d, RotationalSweep, Sphere, TorusPipe, Vector3d, YawPitchRollAngles, } from "@itwin/core-geometry";
13
- import { editorBuiltInCmdIds } from "@itwin/editor-common";
14
- import { CreateElementWithDynamicsTool } from "./CreateElementTool";
15
- import { EditTools } from "./EditTool";
16
- import { basicManipulationIpc } from "./EditToolIpc";
17
- import { ModifyCurveTool } from "./ModifyCurveTools";
18
- /** @alpha Base class for creating a capped or uncapped SolidPrimitive. */
19
- export class SolidPrimitiveTool extends CreateElementWithDynamicsTool {
20
- constructor() {
21
- super(...arguments);
22
- this.accepted = [];
23
- }
24
- allowView(vp) { return vp.view.is3d(); }
25
- isCompatibleViewport(vp, isSelectedViewChange) { return (super.isCompatibleViewport(vp, isSelectedViewChange) && undefined !== vp && this.allowView(vp)); }
26
- async startCommand() {
27
- if (undefined !== this._startedCmd)
28
- return this._startedCmd;
29
- return EditTools.startCommand({ commandId: editorBuiltInCmdIds.cmdBasicManipulation, iModelKey: this.iModel.key });
30
- }
31
- getPlacementProps() {
32
- if (undefined === this.current)
33
- return undefined;
34
- const localToWorld = ("solid" === this.current.geometryCategory ? this.current.getConstructiveFrame() : FrameBuilder.createRightHandedFrame(this.baseRotation?.getColumn(2), this.current));
35
- if (undefined === localToWorld)
36
- return undefined;
37
- const origin = localToWorld.getOrigin();
38
- const angles = new YawPitchRollAngles();
39
- YawPitchRollAngles.createFromMatrix3d(localToWorld.matrix, angles);
40
- return { origin, angles };
41
- }
42
- getGeometryProps(placement) {
43
- if (undefined === this.current)
44
- return undefined;
45
- const builder = new ElementGeometry.Builder();
46
- builder.setLocalToWorldFromPlacement(placement);
47
- if (!builder.appendGeometryQuery(this.current))
48
- return;
49
- return { format: "flatbuffer", data: builder.entries };
50
- }
51
- getElementProps(placement) {
52
- const model = this.targetModelId;
53
- const category = this.targetCategory;
54
- return { classFullName: "Generic:PhysicalObject", model, category, code: Code.createEmpty(), placement };
55
- }
56
- async doCreateElement(props, data) {
57
- try {
58
- this._startedCmd = await this.startCommand();
59
- await basicManipulationIpc.insertGeometricElement(props, data);
60
- await this.saveChanges();
61
- }
62
- catch (err) {
63
- IModelApp.notifications.outputMessage(new NotifyMessageDetails(OutputMessagePriority.Error, BentleyError.getErrorMessage(err) || "An unknown error occurred."));
64
- }
65
- }
66
- }
67
- /** @alpha Creates a sphere. Uses model and category from [[BriefcaseConnection.editorToolSettings]]. */
68
- class CreateSphereTool extends SolidPrimitiveTool {
69
- provideToolAssistance(mainInstrText, additionalInstr) {
70
- mainInstrText = EditTools.translate(0 === this.accepted.length ? "CreateSphere.Prompts.CenterPoint" : "CreateSphere.Prompts.RadiusPoint");
71
- super.provideToolAssistance(mainInstrText, additionalInstr);
72
- }
73
- setupAccuDraw() {
74
- const nPts = this.accepted.length;
75
- if (0 === nPts)
76
- return;
77
- const hints = new AccuDrawHintBuilder();
78
- hints.setModePolar();
79
- hints.setOrigin(this.accepted[0]);
80
- hints.setOriginFixed = true;
81
- hints.sendHints();
82
- }
83
- get useRadiusProperty() {
84
- if (!this._useRadiusProperty)
85
- this._useRadiusProperty = new DialogProperty(PropertyDescriptionHelper.buildLockPropertyDescription("useSphereRadius"), false);
86
- return this._useRadiusProperty;
87
- }
88
- get useRadius() { return this.useRadiusProperty.value; }
89
- set useRadius(value) { this.useRadiusProperty.value = value; }
90
- get radiusProperty() {
91
- if (!this._radiusProperty)
92
- this._radiusProperty = new DialogProperty(new LengthDescription("sphereRadius", EditTools.translate("CreateSphere.Label.Radius")), 0.1, undefined, !this.useRadius);
93
- return this._radiusProperty;
94
- }
95
- get radius() { return this.radiusProperty.value; }
96
- set radius(value) { this.radiusProperty.value = value; }
97
- get cappedProperty() {
98
- if (!this._cappedProperty)
99
- this._cappedProperty = new DialogProperty(PropertyDescriptionHelper.buildToggleDescription("sphereCapped", EditTools.translate("CreateSphere.Label.Capped")), true);
100
- return this._cappedProperty;
101
- }
102
- get capped() { return this.cappedProperty.value; }
103
- set capped(value) { this.cappedProperty.value = value; }
104
- isComplete(_ev) {
105
- return (2 === this.accepted.length);
106
- }
107
- async updateElementData(ev, isDynamics) {
108
- const vp = this.targetView;
109
- if (undefined === vp)
110
- return;
111
- if (0 === this.accepted.length) {
112
- if (!isDynamics)
113
- this.accepted.push(ev.point.clone());
114
- return;
115
- }
116
- const vector0 = Vector3d.createStartEnd(this.accepted[0], ev.point);
117
- const radius = (this.useRadius ? this.radius : vector0.magnitude());
118
- if (!this.useRadius) {
119
- this.radius = radius;
120
- this.syncToolSettingPropertyValue(this.radiusProperty);
121
- }
122
- if (undefined === vector0.scaleToLength(radius, vector0)) {
123
- this.current = undefined;
124
- this.clearGraphics();
125
- return;
126
- }
127
- this.baseRotation = AccuDrawHintBuilder.getCurrentRotation(vp, true, true);
128
- const normal = this.baseRotation ? this.baseRotation.getColumn(2) : Vector3d.unitZ();
129
- const vector90 = normal.crossProduct(vector0);
130
- const matrix = Matrix3d.createColumns(vector0, vector90, normal);
131
- this.baseRotation = Matrix3d.createRigidFromMatrix3d(matrix);
132
- this.current = Sphere.createFromAxesAndScales(this.accepted[0], this.baseRotation, radius, radius, radius, undefined, this.capped);
133
- if (isDynamics || undefined === this.current)
134
- return;
135
- this.accepted.push(ev.point.clone());
136
- }
137
- getToolSettingPropertyLocked(property) {
138
- return (property === this.useRadiusProperty ? this.radiusProperty : undefined);
139
- }
140
- async applyToolSettingPropertyChange(updatedValue) {
141
- return this.changeToolSettingPropertyValue(updatedValue);
142
- }
143
- supplyToolSettingsProperties() {
144
- this.initializeToolSettingPropertyValues([this.radiusProperty, this.useRadiusProperty, this.cappedProperty]);
145
- const toolSettings = new Array();
146
- this.radiusProperty.isDisabled = !this.useRadius;
147
- const useRadiusLock = this.useRadiusProperty.toDialogItem({ rowPriority: 1, columnIndex: 0 });
148
- toolSettings.push(this.radiusProperty.toDialogItem({ rowPriority: 1, columnIndex: 1 }, useRadiusLock));
149
- toolSettings.push(this.cappedProperty.toDialogItem({ rowPriority: 2, columnIndex: 0 }));
150
- return toolSettings;
151
- }
152
- async onRestartTool() {
153
- const tool = new CreateSphereTool();
154
- if (!await tool.run())
155
- return this.exitTool();
156
- }
157
- }
158
- CreateSphereTool.toolId = "CreateSphere";
159
- CreateSphereTool.iconSpec = "icon-circle"; // TODO: Need better icon...
160
- export { CreateSphereTool };
161
- /** @alpha Values for [[CreateCylinderTool.createPhase]. */
162
- export var CreateCylinderPhase;
163
- (function (CreateCylinderPhase) {
164
- /** Current tool phase to define center of base */
165
- CreateCylinderPhase[CreateCylinderPhase["AcceptBase"] = 0] = "AcceptBase";
166
- /** Current tool phase to define radius or base axes */
167
- CreateCylinderPhase[CreateCylinderPhase["AcceptRadius"] = 1] = "AcceptRadius";
168
- /** Current tool phase to define length or axis */
169
- CreateCylinderPhase[CreateCylinderPhase["AcceptLength"] = 2] = "AcceptLength";
170
- /** Current tool phase to accept result */
171
- CreateCylinderPhase[CreateCylinderPhase["AcceptResult"] = 3] = "AcceptResult";
172
- })(CreateCylinderPhase || (CreateCylinderPhase = {}));
173
- /** @alpha Creates a cylinder. Uses model and category from [[BriefcaseConnection.editorToolSettings]]. */
174
- class CreateCylinderTool extends SolidPrimitiveTool {
175
- constructor() {
176
- super(...arguments);
177
- this.createPhase = CreateCylinderPhase.AcceptBase;
178
- }
179
- provideToolAssistance(mainInstrText, additionalInstr) {
180
- switch (this.createPhase) {
181
- case CreateCylinderPhase.AcceptBase:
182
- mainInstrText = EditTools.translate("CreateCylinder.Prompts.BasePoint");
183
- break;
184
- case CreateCylinderPhase.AcceptRadius:
185
- mainInstrText = EditTools.translate("CreateCylinder.Prompts.RadiusPoint");
186
- break;
187
- default:
188
- mainInstrText = EditTools.translate("CreateCylinder.Prompts.LengthPoint");
189
- break;
190
- }
191
- super.provideToolAssistance(mainInstrText, additionalInstr);
192
- }
193
- setupAccuDraw() {
194
- const nPts = this.accepted.length;
195
- if (0 === nPts)
196
- return;
197
- const hints = new AccuDrawHintBuilder();
198
- hints.setModePolar();
199
- hints.setOrigin(this.accepted[0]);
200
- hints.setOriginFixed = true;
201
- if (CreateCylinderPhase.AcceptLength === this.createPhase && undefined !== this.baseRotation) {
202
- hints.setXAxis2(this.baseRotation.getColumn(2));
203
- if (this.orthogonal) {
204
- hints.setModeRectangular();
205
- hints.setLockY = true;
206
- hints.setLockZ = true;
207
- }
208
- }
209
- hints.sendHints();
210
- }
211
- get useRadiusProperty() {
212
- if (!this._useRadiusProperty)
213
- this._useRadiusProperty = new DialogProperty(PropertyDescriptionHelper.buildLockPropertyDescription("useCylinderRadius"), false);
214
- return this._useRadiusProperty;
215
- }
216
- get useRadius() { return this.useRadiusProperty.value; }
217
- set useRadius(value) { this.useRadiusProperty.value = value; }
218
- get radiusProperty() {
219
- if (!this._radiusProperty)
220
- this._radiusProperty = new DialogProperty(new LengthDescription("cylinderRadius", EditTools.translate("CreateCylinder.Label.Radius")), 0.1, undefined, !this.useRadius);
221
- return this._radiusProperty;
222
- }
223
- get radius() { return this.radiusProperty.value; }
224
- set radius(value) { this.radiusProperty.value = value; }
225
- get useLengthProperty() {
226
- if (!this._useLengthProperty)
227
- this._useLengthProperty = new DialogProperty(PropertyDescriptionHelper.buildLockPropertyDescription("useCylinderLength"), false);
228
- return this._useLengthProperty;
229
- }
230
- get useLength() { return this.useLengthProperty.value; }
231
- set useLength(value) { this.useLengthProperty.value = value; }
232
- get lengthProperty() {
233
- if (!this._lengthProperty)
234
- this._lengthProperty = new DialogProperty(new LengthDescription("cylinderLength", EditTools.translate("CreateCylinder.Label.Length")), 0.1, undefined, !this.useLength);
235
- return this._lengthProperty;
236
- }
237
- get length() { return this.lengthProperty.value; }
238
- set length(value) { this.lengthProperty.value = value; }
239
- get cappedProperty() {
240
- if (!this._cappedProperty)
241
- this._cappedProperty = new DialogProperty(PropertyDescriptionHelper.buildToggleDescription("cylinderCapped", EditTools.translate("CreateCylinder.Label.Capped")), true);
242
- return this._cappedProperty;
243
- }
244
- get capped() { return this.cappedProperty.value; }
245
- set capped(value) { this.cappedProperty.value = value; }
246
- get orthogonalProperty() {
247
- if (!this._orthogonalProperty)
248
- this._orthogonalProperty = new DialogProperty(PropertyDescriptionHelper.buildToggleDescription("cylinderOrthogonal", EditTools.translate("CreateCylinder.Label.Orthogonal")), true);
249
- return this._orthogonalProperty;
250
- }
251
- get orthogonal() { return this.orthogonalProperty.value; }
252
- set orthogonal(value) { this.orthogonalProperty.value = value; }
253
- isComplete(_ev) {
254
- return (CreateCylinderPhase.AcceptResult === this.createPhase);
255
- }
256
- async updateElementData(ev, isDynamics) {
257
- const vp = this.targetView;
258
- if (undefined === vp)
259
- return;
260
- const pt1 = (0 === this.accepted.length ? ev.point : this.accepted[0]);
261
- const pt2 = ev.point;
262
- switch (this.createPhase) {
263
- case CreateCylinderPhase.AcceptBase: {
264
- if (isDynamics)
265
- break;
266
- // Allow creating cylinder by 2 points when orthogonal and radius are locked...
267
- this.accepted.push(pt2.clone());
268
- this.createPhase = (this.orthogonal && this.useRadius ? CreateCylinderPhase.AcceptLength : CreateCylinderPhase.AcceptRadius);
269
- break;
270
- }
271
- case CreateCylinderPhase.AcceptRadius: {
272
- this.baseRotation = AccuDrawHintBuilder.getCurrentRotation(vp, true, true);
273
- const normal = this.baseRotation ? this.baseRotation.getColumn(2) : Vector3d.unitZ();
274
- const vector0 = Vector3d.createStartEnd(pt1, pt2);
275
- const vector90 = normal.crossProduct(vector0);
276
- const radius = (this.useRadius ? this.radius : vector0.magnitude());
277
- if (!this.useRadius) {
278
- this.radius = radius;
279
- this.syncToolSettingPropertyValue(this.radiusProperty);
280
- }
281
- if (undefined === vector0.scaleToLength(radius, vector0) || undefined === vector90.scaleToLength(radius, vector90)) {
282
- this.current = undefined;
283
- this.clearGraphics();
284
- return;
285
- }
286
- const arc = Arc3d.create(pt1, vector0, vector90);
287
- this.baseRotation = Matrix3d.createRigidFromMatrix3d(arc.matrixRef); // Update base rotation from result arc...
288
- this.current = (this.capped ? Loop.create(arc) : arc);
289
- if (isDynamics)
290
- break;
291
- this.createPhase = CreateCylinderPhase.AcceptLength;
292
- break;
293
- }
294
- case CreateCylinderPhase.AcceptLength: {
295
- const zAxis = Vector3d.createStartEnd(pt1, pt2);
296
- const length = (this.useLength ? this.length : zAxis.magnitude());
297
- if (!this.useLength) {
298
- this.length = length;
299
- this.syncToolSettingPropertyValue(this.lengthProperty);
300
- }
301
- // Establish base rotation when creating cylinder by 2 points...
302
- if (undefined === this.baseRotation)
303
- this.baseRotation = AccuDrawHintBuilder.getCurrentRotation(vp, true, true);
304
- const xAxis = this.baseRotation ? this.baseRotation.getColumn(0) : Vector3d.unitX();
305
- const yAxis = this.baseRotation ? this.baseRotation.getColumn(1) : Vector3d.unitY();
306
- if (undefined === zAxis.scaleToLength(length, zAxis)) {
307
- xAxis.scaleToLength(this.radius, xAxis);
308
- yAxis.scaleToLength(this.radius, yAxis);
309
- const baseArc = Arc3d.create(pt1, xAxis, yAxis);
310
- this.current = (this.capped ? Loop.create(baseArc) : baseArc);
311
- return;
312
- }
313
- if (this.orthogonal)
314
- this.current = Cone.createAxisPoints(pt1, pt1.plus(zAxis), this.radius, this.radius, this.capped);
315
- else
316
- this.current = Cone.createBaseAndTarget(pt1, pt1.plus(zAxis), xAxis, yAxis, this.radius, this.radius, this.capped);
317
- if (isDynamics || undefined === this.current)
318
- break;
319
- this.createPhase = CreateCylinderPhase.AcceptResult;
320
- break;
321
- }
322
- }
323
- }
324
- getToolSettingPropertyLocked(property) {
325
- if (property === this.useRadiusProperty)
326
- return this.radiusProperty;
327
- else if (property === this.useLengthProperty)
328
- return this.lengthProperty;
329
- return undefined;
330
- }
331
- async applyToolSettingPropertyChange(updatedValue) {
332
- return this.changeToolSettingPropertyValue(updatedValue);
333
- }
334
- supplyToolSettingsProperties() {
335
- this.initializeToolSettingPropertyValues([this.radiusProperty, this.useRadiusProperty, this.lengthProperty, this.useLengthProperty, this.orthogonalProperty, this.cappedProperty]);
336
- const toolSettings = new Array();
337
- this.radiusProperty.isDisabled = !this.useRadius;
338
- const useRadiusLock = this.useRadiusProperty.toDialogItem({ rowPriority: 1, columnIndex: 0 });
339
- toolSettings.push(this.radiusProperty.toDialogItem({ rowPriority: 1, columnIndex: 1 }, useRadiusLock));
340
- this.lengthProperty.isDisabled = !this.useLength;
341
- const useLengthLock = this.useLengthProperty.toDialogItem({ rowPriority: 2, columnIndex: 0 });
342
- toolSettings.push(this.lengthProperty.toDialogItem({ rowPriority: 2, columnIndex: 1 }, useLengthLock));
343
- toolSettings.push(this.orthogonalProperty.toDialogItem({ rowPriority: 3, columnIndex: 0 }));
344
- toolSettings.push(this.cappedProperty.toDialogItem({ rowPriority: 4, columnIndex: 0 }));
345
- return toolSettings;
346
- }
347
- async onRestartTool() {
348
- const tool = new CreateCylinderTool();
349
- if (!await tool.run())
350
- return this.exitTool();
351
- }
352
- }
353
- CreateCylinderTool.toolId = "CreateCylinder";
354
- CreateCylinderTool.iconSpec = "icon-circle"; // TODO: Need better icon...
355
- export { CreateCylinderTool };
356
- /** @alpha Values for [[CreateConeTool.createPhase]. */
357
- export var CreateConePhase;
358
- (function (CreateConePhase) {
359
- /** Current tool phase to define center of base */
360
- CreateConePhase[CreateConePhase["AcceptBase"] = 0] = "AcceptBase";
361
- /** Current tool phase to define base radius or base axes */
362
- CreateConePhase[CreateConePhase["AcceptBaseRadius"] = 1] = "AcceptBaseRadius";
363
- /** Current tool phase to define length or axis */
364
- CreateConePhase[CreateConePhase["AcceptLength"] = 2] = "AcceptLength";
365
- /** Current tool phase to define top radius */
366
- CreateConePhase[CreateConePhase["AcceptTopRadius"] = 3] = "AcceptTopRadius";
367
- /** Current tool phase to accept result */
368
- CreateConePhase[CreateConePhase["AcceptResult"] = 4] = "AcceptResult";
369
- })(CreateConePhase || (CreateConePhase = {}));
370
- /** @alpha Creates a cone. Uses model and category from [[BriefcaseConnection.editorToolSettings]]. */
371
- class CreateConeTool extends SolidPrimitiveTool {
372
- constructor() {
373
- super(...arguments);
374
- this.createPhase = CreateConePhase.AcceptBase;
375
- }
376
- provideToolAssistance(mainInstrText, additionalInstr) {
377
- switch (this.createPhase) {
378
- case CreateConePhase.AcceptBase:
379
- mainInstrText = EditTools.translate("CreateCone.Prompts.BasePoint");
380
- break;
381
- case CreateConePhase.AcceptBaseRadius:
382
- mainInstrText = EditTools.translate("CreateCone.Prompts.BaseRadiusPoint");
383
- break;
384
- case CreateConePhase.AcceptTopRadius:
385
- mainInstrText = EditTools.translate("CreateCone.Prompts.TopRadiusPoint");
386
- break;
387
- default:
388
- mainInstrText = EditTools.translate("CreateCone.Prompts.LengthPoint");
389
- break;
390
- }
391
- super.provideToolAssistance(mainInstrText, additionalInstr);
392
- }
393
- setupAccuDraw() {
394
- const nPts = this.accepted.length;
395
- if (0 === nPts)
396
- return;
397
- const hints = new AccuDrawHintBuilder();
398
- hints.setModePolar();
399
- hints.setOrigin(this.accepted[0]);
400
- hints.setOriginFixed = true;
401
- if (CreateConePhase.AcceptTopRadius === this.createPhase && 2 === nPts) {
402
- hints.setOrigin(this.accepted[1]);
403
- if (undefined !== this.baseRotation)
404
- hints.setMatrix(this.baseRotation);
405
- }
406
- else if (CreateConePhase.AcceptLength === this.createPhase && undefined !== this.baseRotation) {
407
- hints.setXAxis2(this.baseRotation.getColumn(2));
408
- if (this.orthogonal) {
409
- hints.setModeRectangular();
410
- hints.setLockY = true;
411
- hints.setLockZ = true;
412
- }
413
- }
414
- hints.sendHints();
415
- }
416
- get useBaseRadiusProperty() {
417
- if (!this._useBaseRadiusProperty)
418
- this._useBaseRadiusProperty = new DialogProperty(PropertyDescriptionHelper.buildLockPropertyDescription("useConeBaseRadius"), false);
419
- return this._useBaseRadiusProperty;
420
- }
421
- get useBaseRadius() { return this.useBaseRadiusProperty.value; }
422
- set useBaseRadius(value) { this.useBaseRadiusProperty.value = value; }
423
- get baseRadiusProperty() {
424
- if (!this._baseRadiusProperty)
425
- this._baseRadiusProperty = new DialogProperty(new LengthDescription("coneBaseRadius", EditTools.translate("CreateCone.Label.BaseRadius")), 0.1, undefined, !this.useBaseRadius);
426
- return this._baseRadiusProperty;
427
- }
428
- get baseRadius() { return this.baseRadiusProperty.value; }
429
- set baseRadius(value) { this.baseRadiusProperty.value = value; }
430
- get useTopRadiusProperty() {
431
- if (!this._useTopRadiusProperty)
432
- this._useTopRadiusProperty = new DialogProperty(PropertyDescriptionHelper.buildLockPropertyDescription("useConeTopRadius"), false);
433
- return this._useTopRadiusProperty;
434
- }
435
- get useTopRadius() { return this.useTopRadiusProperty.value; }
436
- set useTopRadius(value) { this.useTopRadiusProperty.value = value; }
437
- get topRadiusProperty() {
438
- if (!this._topRadiusProperty)
439
- this._topRadiusProperty = new DialogProperty(new LengthDescription("coneTopRadius", EditTools.translate("CreateCone.Label.TopRadius")), 0.1, undefined, !this.useTopRadius);
440
- return this._topRadiusProperty;
441
- }
442
- get topRadius() { return this.topRadiusProperty.value; }
443
- set topRadius(value) { this.topRadiusProperty.value = value; }
444
- get useLengthProperty() {
445
- if (!this._useLengthProperty)
446
- this._useLengthProperty = new DialogProperty(PropertyDescriptionHelper.buildLockPropertyDescription("useConeLength"), false);
447
- return this._useLengthProperty;
448
- }
449
- get useLength() { return this.useLengthProperty.value; }
450
- set useLength(value) { this.useLengthProperty.value = value; }
451
- get lengthProperty() {
452
- if (!this._lengthProperty)
453
- this._lengthProperty = new DialogProperty(new LengthDescription("coneLength", EditTools.translate("CreateCone.Label.Length")), 0.1, undefined, !this.useLength);
454
- return this._lengthProperty;
455
- }
456
- get length() { return this.lengthProperty.value; }
457
- set length(value) { this.lengthProperty.value = value; }
458
- get cappedProperty() {
459
- if (!this._cappedProperty)
460
- this._cappedProperty = new DialogProperty(PropertyDescriptionHelper.buildToggleDescription("coneCapped", EditTools.translate("CreateCone.Label.Capped")), true);
461
- return this._cappedProperty;
462
- }
463
- get capped() { return this.cappedProperty.value; }
464
- set capped(value) { this.cappedProperty.value = value; }
465
- get orthogonalProperty() {
466
- if (!this._orthogonalProperty)
467
- this._orthogonalProperty = new DialogProperty(PropertyDescriptionHelper.buildToggleDescription("coneOrthogonal", EditTools.translate("CreateCone.Label.Orthogonal")), true);
468
- return this._orthogonalProperty;
469
- }
470
- get orthogonal() { return this.orthogonalProperty.value; }
471
- set orthogonal(value) { this.orthogonalProperty.value = value; }
472
- isComplete(_ev) {
473
- return (CreateConePhase.AcceptResult === this.createPhase);
474
- }
475
- async updateElementData(ev, isDynamics) {
476
- const vp = this.targetView;
477
- if (undefined === vp)
478
- return;
479
- const pt1 = (0 === this.accepted.length ? ev.point : this.accepted[0]);
480
- const pt2 = ev.point;
481
- switch (this.createPhase) {
482
- case CreateConePhase.AcceptBase: {
483
- if (isDynamics)
484
- break;
485
- // Allow creating cone by 2 points when orthogonal and base/top radii are locked...
486
- this.accepted.push(pt2.clone());
487
- this.createPhase = (this.orthogonal && this.useBaseRadius ? CreateConePhase.AcceptLength : CreateConePhase.AcceptBaseRadius);
488
- break;
489
- }
490
- case CreateConePhase.AcceptBaseRadius: {
491
- this.baseRotation = AccuDrawHintBuilder.getCurrentRotation(vp, true, true);
492
- const normal = this.baseRotation ? this.baseRotation.getColumn(2) : Vector3d.unitZ();
493
- const vector0 = Vector3d.createStartEnd(pt1, pt2);
494
- const vector90 = normal.crossProduct(vector0);
495
- const radius = (this.useBaseRadius ? this.baseRadius : vector0.magnitude());
496
- if (!this.useBaseRadius) {
497
- this.baseRadius = radius;
498
- this.syncToolSettingPropertyValue(this.baseRadiusProperty);
499
- }
500
- if (undefined === vector0.scaleToLength(radius, vector0) || undefined === vector90.scaleToLength(radius, vector90)) {
501
- this.current = undefined;
502
- this.clearGraphics();
503
- return;
504
- }
505
- const arc = Arc3d.create(pt1, vector0, vector90);
506
- this.baseRotation = Matrix3d.createRigidFromMatrix3d(arc.matrixRef); // Update base rotation from result arc...
507
- this.current = (this.capped ? Loop.create(arc) : arc);
508
- if (isDynamics)
509
- break;
510
- this.createPhase = CreateConePhase.AcceptLength;
511
- break;
512
- }
513
- case CreateConePhase.AcceptLength: {
514
- const zAxis = Vector3d.createStartEnd(pt1, pt2);
515
- const length = (this.useLength ? this.length : zAxis.magnitude());
516
- if (!this.useLength) {
517
- this.length = length;
518
- this.syncToolSettingPropertyValue(this.lengthProperty);
519
- }
520
- // Establish base rotation when creating cone by 2 points...
521
- if (undefined === this.baseRotation)
522
- this.baseRotation = AccuDrawHintBuilder.getCurrentRotation(vp, true, true);
523
- const xAxis = this.baseRotation ? this.baseRotation.getColumn(0) : Vector3d.unitX();
524
- const yAxis = this.baseRotation ? this.baseRotation.getColumn(1) : Vector3d.unitY();
525
- if (undefined === zAxis.scaleToLength(length, zAxis)) {
526
- xAxis.scaleToLength(this.baseRadius, xAxis);
527
- yAxis.scaleToLength(this.baseRadius, yAxis);
528
- const baseArc = Arc3d.create(pt1, xAxis, yAxis);
529
- this.current = (this.capped ? Loop.create(baseArc) : baseArc);
530
- return;
531
- }
532
- if (this.orthogonal)
533
- this.current = Cone.createAxisPoints(pt1, pt1.plus(zAxis), this.baseRadius, this.useTopRadius ? this.topRadius : 0.0, this.capped);
534
- else
535
- this.current = Cone.createBaseAndTarget(pt1, pt1.plus(zAxis), xAxis, yAxis, this.baseRadius, this.useTopRadius ? this.topRadius : 0.0, this.capped);
536
- if (isDynamics || undefined === this.current)
537
- break;
538
- const localToWorld = this.current.getConstructiveFrame();
539
- if (undefined !== localToWorld)
540
- this.baseRotation = localToWorld.matrix; // Update base rotation from result for AccuDraw hints...
541
- this.accepted.push(this.current.getCenterB()); // Add top center to accepted points for AccuDraw hints...
542
- this.createPhase = this.useTopRadius ? CreateConePhase.AcceptResult : CreateConePhase.AcceptTopRadius;
543
- break;
544
- }
545
- case CreateConePhase.AcceptTopRadius: {
546
- const cone = ("solid" === this.current?.geometryCategory ? this.current : undefined);
547
- if (undefined === cone)
548
- break;
549
- const vector0 = Vector3d.createStartEnd(cone.getCenterB(), pt2);
550
- const radius = (this.useTopRadius ? this.topRadius : vector0.magnitude());
551
- if (!this.useTopRadius) {
552
- this.topRadius = radius;
553
- this.syncToolSettingPropertyValue(this.topRadiusProperty);
554
- }
555
- this.current = Cone.createBaseAndTarget(cone.getCenterA(), cone.getCenterB(), cone.getVectorX(), cone.getVectorY(), cone.getRadiusA(), radius, this.capped);
556
- if (isDynamics)
557
- break;
558
- this.createPhase = CreateConePhase.AcceptResult;
559
- break;
560
- }
561
- }
562
- }
563
- getToolSettingPropertyLocked(property) {
564
- if (property === this.useBaseRadiusProperty)
565
- return this.baseRadiusProperty;
566
- else if (property === this.useTopRadiusProperty)
567
- return this.topRadiusProperty;
568
- else if (property === this.useLengthProperty)
569
- return this.lengthProperty;
570
- return undefined;
571
- }
572
- async applyToolSettingPropertyChange(updatedValue) {
573
- return this.changeToolSettingPropertyValue(updatedValue);
574
- }
575
- supplyToolSettingsProperties() {
576
- this.initializeToolSettingPropertyValues([this.baseRadiusProperty, this.useBaseRadiusProperty, this.topRadiusProperty, this.useTopRadiusProperty, this.lengthProperty, this.useLengthProperty, this.orthogonalProperty, this.cappedProperty]);
577
- const toolSettings = new Array();
578
- this.baseRadiusProperty.isDisabled = !this.useBaseRadius;
579
- const useBaseRadiusLock = this.useBaseRadiusProperty.toDialogItem({ rowPriority: 1, columnIndex: 0 });
580
- toolSettings.push(this.baseRadiusProperty.toDialogItem({ rowPriority: 1, columnIndex: 1 }, useBaseRadiusLock));
581
- this.topRadiusProperty.isDisabled = !this.useTopRadius;
582
- const useTopRadiusLock = this.useTopRadiusProperty.toDialogItem({ rowPriority: 2, columnIndex: 0 });
583
- toolSettings.push(this.topRadiusProperty.toDialogItem({ rowPriority: 2, columnIndex: 1 }, useTopRadiusLock));
584
- this.lengthProperty.isDisabled = !this.useLength;
585
- const useLengthLock = this.useLengthProperty.toDialogItem({ rowPriority: 3, columnIndex: 0 });
586
- toolSettings.push(this.lengthProperty.toDialogItem({ rowPriority: 3, columnIndex: 1 }, useLengthLock));
587
- toolSettings.push(this.orthogonalProperty.toDialogItem({ rowPriority: 4, columnIndex: 0 }));
588
- toolSettings.push(this.cappedProperty.toDialogItem({ rowPriority: 5, columnIndex: 0 }));
589
- return toolSettings;
590
- }
591
- async onRestartTool() {
592
- const tool = new CreateConeTool();
593
- if (!await tool.run())
594
- return this.exitTool();
595
- }
596
- }
597
- CreateConeTool.toolId = "CreateCone";
598
- CreateConeTool.iconSpec = "icon-circle"; // TODO: Need better icon...
599
- export { CreateConeTool };
600
- /** @alpha Creates a bix. Uses model and category from [[BriefcaseConnection.editorToolSettings]]. */
601
- class CreateBoxTool extends SolidPrimitiveTool {
602
- provideToolAssistance(mainInstrText, additionalInstr) {
603
- switch (this.accepted.length) {
604
- case 0:
605
- mainInstrText = EditTools.translate("CreateBox.Prompts.BasePoint");
606
- break;
607
- case 1:
608
- mainInstrText = EditTools.translate("CreateBox.Prompts.LengthPoint");
609
- break;
610
- case 2:
611
- mainInstrText = EditTools.translate("CreateBox.Prompts.WidthPoint");
612
- break;
613
- default:
614
- mainInstrText = EditTools.translate("CreateBox.Prompts.HeightPoint");
615
- break;
616
- }
617
- super.provideToolAssistance(mainInstrText, additionalInstr);
618
- }
619
- setupAccuDraw() {
620
- const nPts = this.accepted.length;
621
- if (0 === nPts)
622
- return;
623
- const hints = new AccuDrawHintBuilder();
624
- hints.setModeRectangular();
625
- hints.setOrigin(this.accepted[0]);
626
- hints.setOriginFixed = true;
627
- if (undefined !== this.baseRotation) {
628
- if (2 === nPts) {
629
- hints.setMatrix(this.baseRotation);
630
- hints.setLockX = true;
631
- hints.setLockZ = true;
632
- }
633
- else if (3 === nPts) {
634
- hints.setXAxis2(this.baseRotation.getColumn(2));
635
- if (this.orthogonal) {
636
- hints.setLockY = true;
637
- hints.setLockZ = true;
638
- }
639
- }
640
- }
641
- hints.sendHints();
642
- }
643
- get useLengthProperty() {
644
- if (!this._useLengthProperty)
645
- this._useLengthProperty = new DialogProperty(PropertyDescriptionHelper.buildLockPropertyDescription("useBoxLength"), false);
646
- return this._useLengthProperty;
647
- }
648
- get useLength() { return this.useLengthProperty.value; }
649
- set useLength(value) { this.useLengthProperty.value = value; }
650
- get lengthProperty() {
651
- if (!this._lengthProperty)
652
- this._lengthProperty = new DialogProperty(new LengthDescription("boxLength", EditTools.translate("CreateBox.Label.Length")), 0.1, undefined, !this.useLength);
653
- return this._lengthProperty;
654
- }
655
- get length() { return this.lengthProperty.value; }
656
- set length(value) { this.lengthProperty.value = value; }
657
- get useWidthProperty() {
658
- if (!this._useWidthProperty)
659
- this._useWidthProperty = new DialogProperty(PropertyDescriptionHelper.buildLockPropertyDescription("useBoxWidth"), false);
660
- return this._useWidthProperty;
661
- }
662
- get useWidth() { return this.useWidthProperty.value; }
663
- set useWidth(value) { this.useWidthProperty.value = value; }
664
- get widthProperty() {
665
- if (!this._widthProperty)
666
- this._widthProperty = new DialogProperty(new LengthDescription("boxWidth", EditTools.translate("CreateBox.Label.Width")), 0.1, undefined, !this.useWidth);
667
- return this._widthProperty;
668
- }
669
- get width() { return this.widthProperty.value; }
670
- set width(value) { this.widthProperty.value = value; }
671
- get useHeightProperty() {
672
- if (!this._useHeightProperty)
673
- this._useHeightProperty = new DialogProperty(PropertyDescriptionHelper.buildLockPropertyDescription("useBoxHeight"), false);
674
- return this._useHeightProperty;
675
- }
676
- get useHeight() { return this.useHeightProperty.value; }
677
- set useHeight(value) { this.useHeightProperty.value = value; }
678
- get heightProperty() {
679
- if (!this._heightProperty)
680
- this._heightProperty = new DialogProperty(new LengthDescription("boxHeight", EditTools.translate("CreateBox.Label.Height")), 0.1, undefined, !this.useHeight);
681
- return this._heightProperty;
682
- }
683
- get height() { return this.heightProperty.value; }
684
- set height(value) { this.heightProperty.value = value; }
685
- get cappedProperty() {
686
- if (!this._cappedProperty)
687
- this._cappedProperty = new DialogProperty(PropertyDescriptionHelper.buildToggleDescription("boxCapped", EditTools.translate("CreateBox.Label.Capped")), true);
688
- return this._cappedProperty;
689
- }
690
- get capped() { return this.cappedProperty.value; }
691
- set capped(value) { this.cappedProperty.value = value; }
692
- get orthogonalProperty() {
693
- if (!this._orthogonalProperty)
694
- this._orthogonalProperty = new DialogProperty(PropertyDescriptionHelper.buildToggleDescription("boxOrthogonal", EditTools.translate("CreateBox.Label.Orthogonal")), true);
695
- return this._orthogonalProperty;
696
- }
697
- get orthogonal() { return this.orthogonalProperty.value; }
698
- set orthogonal(value) { this.orthogonalProperty.value = value; }
699
- isComplete(_ev) {
700
- return (4 === this.accepted.length);
701
- }
702
- async updateElementData(ev, isDynamics) {
703
- const vp = this.targetView;
704
- if (undefined === vp)
705
- return;
706
- switch (this.accepted.length) {
707
- case 0: {
708
- if (!isDynamics)
709
- this.accepted.push(ev.point.clone());
710
- break;
711
- }
712
- case 1: {
713
- const vector0 = Vector3d.createStartEnd(this.accepted[0], ev.point);
714
- const length = (this.useLength ? this.length : vector0.magnitude());
715
- if (!this.useLength) {
716
- this.length = length;
717
- this.syncToolSettingPropertyValue(this.lengthProperty);
718
- }
719
- if (undefined === vector0.scaleToLength(length, vector0)) {
720
- this.current = undefined;
721
- this.clearGraphics();
722
- return;
723
- }
724
- this.baseRotation = AccuDrawHintBuilder.getCurrentRotation(vp, true, true);
725
- const normal = this.baseRotation ? this.baseRotation.getColumn(2) : Vector3d.unitZ();
726
- const vector90 = normal.crossProduct(vector0);
727
- const matrix = Matrix3d.createColumns(vector0, vector90, normal);
728
- this.baseRotation = Matrix3d.createRigidFromMatrix3d(matrix);
729
- this.current = LineSegment3d.create(this.accepted[0], this.accepted[0].plus(vector0));
730
- if (isDynamics)
731
- return;
732
- this.accepted.push(ev.point.clone());
733
- break;
734
- }
735
- case 2: {
736
- const vector90 = Vector3d.createStartEnd(this.accepted[0], ev.point);
737
- const width = (this.useWidth ? this.width : vector90.magnitude());
738
- if (!this.useWidth) {
739
- this.width = width;
740
- this.syncToolSettingPropertyValue(this.widthProperty);
741
- }
742
- const vector0 = this.baseRotation ? this.baseRotation.getColumn(0) : Vector3d.unitX();
743
- const normal = vector90.crossProduct(vector0);
744
- const matrix = Matrix3d.createColumns(vector0, vector90, normal);
745
- if (undefined === vector90.scaleToLength(width, vector90) || undefined === Matrix3d.createRigidFromMatrix3d(matrix, undefined, matrix)) {
746
- this.current = LineSegment3d.create(this.accepted[0], this.accepted[0].plusScaled(vector0, this.length));
747
- return;
748
- }
749
- this.baseRotation = matrix; // Update base rotation from cross product...
750
- const shapePts = [];
751
- shapePts[0] = this.accepted[0].clone();
752
- shapePts[1] = shapePts[0].plusScaled(this.baseRotation.getColumn(0), this.length);
753
- shapePts[2] = shapePts[1].plusScaled(this.baseRotation.getColumn(1), width);
754
- shapePts[3] = shapePts[0].plusScaled(this.baseRotation.getColumn(1), width);
755
- shapePts[4] = shapePts[0].clone();
756
- const base = LineString3d.create(shapePts);
757
- this.current = (this.capped ? Loop.create(base) : base);
758
- if (isDynamics)
759
- return;
760
- this.accepted.push(ev.point.clone());
761
- break;
762
- }
763
- default: {
764
- if (undefined === this.baseRotation)
765
- return; // Should always have base rotation after width is defined...
766
- const zAxis = Vector3d.createStartEnd(this.accepted[0], ev.point);
767
- const height = (this.useHeight ? this.height : zAxis.magnitude());
768
- if (!this.useHeight) {
769
- this.height = height;
770
- this.syncToolSettingPropertyValue(this.heightProperty);
771
- }
772
- if (undefined === zAxis.scaleToLength(height, zAxis)) {
773
- const shapePts = [];
774
- shapePts[0] = this.accepted[0].clone();
775
- shapePts[1] = shapePts[0].plusScaled(this.baseRotation.getColumn(0), this.length);
776
- shapePts[2] = shapePts[1].plusScaled(this.baseRotation.getColumn(1), this.width);
777
- shapePts[3] = shapePts[0].plusScaled(this.baseRotation.getColumn(1), this.width);
778
- shapePts[4] = shapePts[0].clone();
779
- const base = LineString3d.create(shapePts);
780
- this.current = (this.capped ? Loop.create(base) : base);
781
- return;
782
- }
783
- if (this.orthogonal) {
784
- const normal = this.baseRotation.getColumn(2);
785
- normal.scaleToLength(normal.dotProduct(zAxis) >= 0.0 ? height : -height, zAxis);
786
- }
787
- this.current = Box.createDgnBoxWithAxes(this.accepted[0], this.baseRotation, this.accepted[0].plus(zAxis), this.length, this.width, this.length, this.width, this.capped);
788
- if (isDynamics || undefined === this.current)
789
- return;
790
- this.accepted.push(ev.point.clone());
791
- break;
792
- }
793
- }
794
- }
795
- getToolSettingPropertyLocked(property) {
796
- if (property === this.useLengthProperty)
797
- return this.lengthProperty;
798
- else if (property === this.useWidthProperty)
799
- return this.widthProperty;
800
- else if (property === this.useHeightProperty)
801
- return this.heightProperty;
802
- return undefined;
803
- }
804
- async applyToolSettingPropertyChange(updatedValue) {
805
- return this.changeToolSettingPropertyValue(updatedValue);
806
- }
807
- supplyToolSettingsProperties() {
808
- this.initializeToolSettingPropertyValues([this.lengthProperty, this.useLengthProperty, this.widthProperty, this.useWidthProperty, this.heightProperty, this.useHeightProperty, this.orthogonalProperty, this.cappedProperty]);
809
- const toolSettings = new Array();
810
- this.lengthProperty.isDisabled = !this.useLength;
811
- const useLengthLock = this.useLengthProperty.toDialogItem({ rowPriority: 1, columnIndex: 0 });
812
- toolSettings.push(this.lengthProperty.toDialogItem({ rowPriority: 1, columnIndex: 1 }, useLengthLock));
813
- this.widthProperty.isDisabled = !this.useWidth;
814
- const useWidthLock = this.useWidthProperty.toDialogItem({ rowPriority: 2, columnIndex: 0 });
815
- toolSettings.push(this.widthProperty.toDialogItem({ rowPriority: 2, columnIndex: 1 }, useWidthLock));
816
- this.heightProperty.isDisabled = !this.useHeight;
817
- const useHeightLock = this.useHeightProperty.toDialogItem({ rowPriority: 3, columnIndex: 0 });
818
- toolSettings.push(this.heightProperty.toDialogItem({ rowPriority: 3, columnIndex: 1 }, useHeightLock));
819
- toolSettings.push(this.orthogonalProperty.toDialogItem({ rowPriority: 4, columnIndex: 0 }));
820
- toolSettings.push(this.cappedProperty.toDialogItem({ rowPriority: 5, columnIndex: 0 }));
821
- return toolSettings;
822
- }
823
- async onRestartTool() {
824
- const tool = new CreateBoxTool();
825
- if (!await tool.run())
826
- return this.exitTool();
827
- }
828
- }
829
- CreateBoxTool.toolId = "CreateBox";
830
- CreateBoxTool.iconSpec = "icon-circle"; // TODO: Need better icon...
831
- export { CreateBoxTool };
832
- /** @alpha Values for [[CreateTorusTool.createPhase]. */
833
- export var CreateTorusPhase;
834
- (function (CreateTorusPhase) {
835
- /** Current tool phase to define start point */
836
- CreateTorusPhase[CreateTorusPhase["AcceptStart"] = 0] = "AcceptStart";
837
- /** Current tool phase to define center point */
838
- CreateTorusPhase[CreateTorusPhase["AcceptCenter"] = 1] = "AcceptCenter";
839
- /** Current tool phase to define secondary radius */
840
- CreateTorusPhase[CreateTorusPhase["AcceptSecondaryRadius"] = 2] = "AcceptSecondaryRadius";
841
- /** Current tool phase to define sweep angle */
842
- CreateTorusPhase[CreateTorusPhase["AcceptAngle"] = 3] = "AcceptAngle";
843
- /** Current tool phase to accept result */
844
- CreateTorusPhase[CreateTorusPhase["AcceptResult"] = 4] = "AcceptResult";
845
- })(CreateTorusPhase || (CreateTorusPhase = {}));
846
- /** @alpha Creates a torus pipe. Uses model and category from [[BriefcaseConnection.editorToolSettings]]. */
847
- class CreateTorusTool extends SolidPrimitiveTool {
848
- constructor() {
849
- super(...arguments);
850
- this.createPhase = CreateTorusPhase.AcceptStart;
851
- }
852
- provideToolAssistance(mainInstrText, additionalInstr) {
853
- switch (this.createPhase) {
854
- case CreateTorusPhase.AcceptStart:
855
- mainInstrText = EditTools.translate("CreateTorus.Prompts.StartPoint");
856
- break;
857
- case CreateTorusPhase.AcceptCenter:
858
- mainInstrText = EditTools.translate("CreateTorus.Prompts.CenterPoint");
859
- break;
860
- case CreateTorusPhase.AcceptSecondaryRadius:
861
- mainInstrText = EditTools.translate("CreateTorus.Prompts.SecondaryRadiusPoint");
862
- break;
863
- default:
864
- mainInstrText = EditTools.translate("CreateTorus.Prompts.AnglePoint");
865
- break;
866
- }
867
- super.provideToolAssistance(mainInstrText, additionalInstr);
868
- }
869
- setupAccuDraw() {
870
- const nPts = this.accepted.length;
871
- if (0 === nPts)
872
- return;
873
- const hints = new AccuDrawHintBuilder();
874
- if (CreateTorusPhase.AcceptCenter === this.createPhase) {
875
- hints.setOrigin(this.accepted[0]);
876
- }
877
- else if (CreateTorusPhase.AcceptSecondaryRadius === this.createPhase) {
878
- hints.setModePolar();
879
- hints.setOrigin(this.accepted[0]);
880
- hints.setOriginFixed = true;
881
- if (undefined !== this.baseRotation)
882
- hints.setMatrix(Matrix3d.createColumns(this.baseRotation.getColumn(0), this.baseRotation.getColumn(2), this.baseRotation.getColumn(1)));
883
- }
884
- else if (CreateTorusPhase.AcceptAngle === this.createPhase && 2 === nPts) {
885
- hints.setModePolar();
886
- hints.setOrigin(this.accepted[1]);
887
- hints.setOriginFixed = true;
888
- if (undefined !== this.baseRotation)
889
- hints.setMatrix(this.baseRotation);
890
- }
891
- hints.sendHints();
892
- }
893
- get usePrimaryRadiusProperty() {
894
- if (!this._usePrimaryRadiusProperty)
895
- this._usePrimaryRadiusProperty = new DialogProperty(PropertyDescriptionHelper.buildLockPropertyDescription("useTorusPrimaryRadius"), false);
896
- return this._usePrimaryRadiusProperty;
897
- }
898
- get usePrimaryRadius() { return this.usePrimaryRadiusProperty.value; }
899
- set usePrimaryRadius(value) { this.usePrimaryRadiusProperty.value = value; }
900
- get primaryRadiusProperty() {
901
- if (!this._primaryRadiusProperty)
902
- this._primaryRadiusProperty = new DialogProperty(new LengthDescription("torusPrimaryRadius", EditTools.translate("CreateTorus.Label.PrimaryRadius")), 0.1, undefined, !this.usePrimaryRadius);
903
- return this._primaryRadiusProperty;
904
- }
905
- get primaryRadius() { return this.primaryRadiusProperty.value; }
906
- set primaryRadius(value) { this.primaryRadiusProperty.value = value; }
907
- get useSecondaryRadiusProperty() {
908
- if (!this._useSecondaryRadiusProperty)
909
- this._useSecondaryRadiusProperty = new DialogProperty(PropertyDescriptionHelper.buildLockPropertyDescription("useTorusSecondaryRadius"), false);
910
- return this._useSecondaryRadiusProperty;
911
- }
912
- get useSecondaryRadius() { return this.useSecondaryRadiusProperty.value; }
913
- set useSecondaryRadius(value) { this.useSecondaryRadiusProperty.value = value; }
914
- get secondaryRadiusProperty() {
915
- if (!this._secondaryRadiusProperty)
916
- this._secondaryRadiusProperty = new DialogProperty(new LengthDescription("torusSecondaryRadius", EditTools.translate("CreateTorus.Label.SecondaryRadius")), 0.05, undefined, !this.useSecondaryRadius);
917
- return this._secondaryRadiusProperty;
918
- }
919
- get secondaryRadius() { return this.secondaryRadiusProperty.value; }
920
- set secondaryRadius(value) { this.secondaryRadiusProperty.value = value; }
921
- get useAngleProperty() {
922
- if (!this._useAngleProperty)
923
- this._useAngleProperty = new DialogProperty(PropertyDescriptionHelper.buildLockPropertyDescription("useTorusAngle"), false);
924
- return this._useAngleProperty;
925
- }
926
- get useAngle() { return this.useAngleProperty.value; }
927
- set useAngle(value) { this.useAngleProperty.value = value; }
928
- get angleProperty() {
929
- if (!this._angleProperty)
930
- this._angleProperty = new DialogProperty(new AngleDescription("torusAngle", EditTools.translate("CreateTorus.Label.Angle")), Math.PI / 2.0, undefined, !this.useAngle);
931
- return this._angleProperty;
932
- }
933
- get angle() { return this.angleProperty.value; }
934
- set angle(value) { this.angleProperty.value = value; }
935
- get cappedProperty() {
936
- if (!this._cappedProperty)
937
- this._cappedProperty = new DialogProperty(PropertyDescriptionHelper.buildToggleDescription("torusCapped", EditTools.translate("CreateTorus.Label.Capped")), true);
938
- return this._cappedProperty;
939
- }
940
- get capped() { return this.cappedProperty.value; }
941
- set capped(value) { this.cappedProperty.value = value; }
942
- isComplete(_ev) {
943
- return (CreateTorusPhase.AcceptResult === this.createPhase);
944
- }
945
- async updateElementData(ev, isDynamics) {
946
- const vp = this.targetView;
947
- if (undefined === vp)
948
- return;
949
- switch (this.createPhase) {
950
- case CreateTorusPhase.AcceptStart: {
951
- if (isDynamics)
952
- break;
953
- this.accepted.push(ev.point.clone());
954
- this.createPhase = CreateTorusPhase.AcceptCenter;
955
- break;
956
- }
957
- case CreateTorusPhase.AcceptCenter: {
958
- this.baseRotation = AccuDrawHintBuilder.getCurrentRotation(vp, true, true);
959
- const normal = this.baseRotation ? this.baseRotation.getColumn(2) : Vector3d.unitZ();
960
- const vector0 = Vector3d.createStartEnd(ev.point, this.accepted[0]);
961
- const vector90 = normal.crossProduct(vector0);
962
- const primaryRadius = (this.usePrimaryRadius ? this.primaryRadius : vector0.magnitude());
963
- if (!this.usePrimaryRadius) {
964
- this.primaryRadius = primaryRadius;
965
- this.syncToolSettingPropertyValue(this.primaryRadiusProperty);
966
- }
967
- if (undefined === vector0.scaleToLength(primaryRadius, vector0) || undefined === vector90.scaleToLength(primaryRadius, vector90)) {
968
- this.current = undefined;
969
- this.clearGraphics();
970
- return;
971
- }
972
- const center = this.accepted[0].plus(vector0.negate());
973
- const allowComplete = (this.useSecondaryRadius && this.useAngle && (2 * Math.PI) === this.angle);
974
- if (allowComplete) {
975
- vector0.normalizeInPlace();
976
- vector90.normalizeInPlace();
977
- this.current = TorusPipe.createDgnTorusPipe(center, vector0, vector90, primaryRadius, this.secondaryRadius, Angle.createRadians(this.angle), this.capped);
978
- if (undefined === this.current) {
979
- this.clearGraphics();
980
- break;
981
- }
982
- if (!isDynamics)
983
- this.createPhase = CreateTorusPhase.AcceptResult;
984
- break;
985
- }
986
- const arc = Arc3d.create(center, vector0, vector90);
987
- this.baseRotation = Matrix3d.createRigidFromMatrix3d(arc.matrixRef); // Update base rotation from result arc...
988
- this.current = arc;
989
- if (isDynamics)
990
- break;
991
- this.accepted.push(arc.center); // Add center to accepted points for AccuDraw hints...
992
- this.createPhase = (this.useSecondaryRadius ? CreateTorusPhase.AcceptAngle : CreateTorusPhase.AcceptSecondaryRadius);
993
- break;
994
- }
995
- case CreateTorusPhase.AcceptSecondaryRadius: {
996
- const vector0 = Vector3d.createStartEnd(this.accepted[0], ev.point);
997
- const secondaryRadius = (this.useSecondaryRadius ? this.secondaryRadius : Math.min(this.primaryRadius, vector0.magnitude()));
998
- if (!this.useSecondaryRadius) {
999
- this.secondaryRadius = secondaryRadius;
1000
- this.syncToolSettingPropertyValue(this.secondaryRadiusProperty);
1001
- }
1002
- const xAxis = this.baseRotation ? this.baseRotation.getColumn(0) : Vector3d.unitX();
1003
- const yAxis = this.baseRotation ? this.baseRotation.getColumn(1) : Vector3d.unitY();
1004
- if (undefined === vector0.scaleToLength(secondaryRadius, vector0)) {
1005
- xAxis.scaleToLength(this.primaryRadius, xAxis);
1006
- yAxis.scaleToLength(this.primaryRadius, yAxis);
1007
- this.current = Arc3d.create(this.accepted[1], xAxis, yAxis);
1008
- return;
1009
- }
1010
- const sweep = Angle.createRadians(this.useAngle ? this.angle : 2 * Math.PI);
1011
- this.current = TorusPipe.createDgnTorusPipe(this.accepted[1], xAxis, yAxis, this.primaryRadius, secondaryRadius, sweep, this.capped);
1012
- if (undefined === this.current) {
1013
- this.clearGraphics();
1014
- break;
1015
- }
1016
- if (!isDynamics)
1017
- this.createPhase = ((this.useAngle && (2 * Math.PI) === this.angle) ? CreateTorusPhase.AcceptResult : CreateTorusPhase.AcceptAngle);
1018
- break;
1019
- }
1020
- case CreateTorusPhase.AcceptAngle: {
1021
- const vector90 = Vector3d.createStartEnd(this.accepted[1], ev.point);
1022
- const xAxis = this.baseRotation ? this.baseRotation.getColumn(0) : Vector3d.unitX();
1023
- const yAxis = this.baseRotation ? this.baseRotation.getColumn(1) : Vector3d.unitY();
1024
- const zAxis = this.baseRotation ? this.baseRotation.getColumn(2) : Vector3d.unitZ();
1025
- const prevSweep = Angle.createRadians(this.angle);
1026
- const sweep = xAxis.planarAngleTo(vector90, zAxis);
1027
- if (Math.abs(sweep.radians) < Angle.createDegrees(30.0).radians && prevSweep.isFullCircle && ((sweep.radians < 0.0 && prevSweep.radians > 0.0) || (sweep.radians > 0.0 && prevSweep.radians < 0.0)))
1028
- prevSweep.setRadians(-prevSweep.radians); // Reverse direction...
1029
- if (sweep.isAlmostZero)
1030
- sweep.setDegrees(prevSweep.radians < 0.0 ? -360.0 : 360.0); // Create full sweep...
1031
- if (this.useAngle) {
1032
- if ((sweep.radians < 0.0 && this.angle > 0.0) || (sweep.radians > 0.0 && this.angle < 0.0))
1033
- sweep.setRadians(-this.angle);
1034
- else
1035
- sweep.setRadians(this.angle);
1036
- }
1037
- else {
1038
- if (sweep.radians < 0.0 && prevSweep.radians > 0.0)
1039
- sweep.setRadians(Angle.pi2Radians + sweep.radians);
1040
- else if (sweep.radians > 0.0 && prevSweep.radians < 0.0)
1041
- sweep.setRadians(-(Angle.pi2Radians - sweep.radians));
1042
- this.angle = sweep.radians;
1043
- this.syncToolSettingPropertyValue(this.angleProperty);
1044
- }
1045
- this.current = TorusPipe.createDgnTorusPipe(this.accepted[1], xAxis, yAxis, this.primaryRadius, this.secondaryRadius, sweep, this.capped);
1046
- if (undefined === this.current) {
1047
- this.clearGraphics();
1048
- break;
1049
- }
1050
- if (!isDynamics)
1051
- this.createPhase = CreateTorusPhase.AcceptResult;
1052
- break;
1053
- }
1054
- }
1055
- }
1056
- getToolSettingPropertyLocked(property) {
1057
- if (property === this.usePrimaryRadiusProperty)
1058
- return this.primaryRadiusProperty;
1059
- else if (property === this.useSecondaryRadiusProperty)
1060
- return this.secondaryRadiusProperty;
1061
- else if (property === this.useAngleProperty)
1062
- return this.angleProperty;
1063
- return undefined;
1064
- }
1065
- async applyToolSettingPropertyChange(updatedValue) {
1066
- return this.changeToolSettingPropertyValue(updatedValue);
1067
- }
1068
- supplyToolSettingsProperties() {
1069
- this.initializeToolSettingPropertyValues([this.primaryRadiusProperty, this.usePrimaryRadiusProperty, this.secondaryRadiusProperty, this.useSecondaryRadiusProperty, this.angleProperty, this.useAngleProperty, this.cappedProperty]);
1070
- const toolSettings = new Array();
1071
- this.primaryRadiusProperty.isDisabled = !this.usePrimaryRadius;
1072
- const usePrimaryRadiusLock = this.usePrimaryRadiusProperty.toDialogItem({ rowPriority: 1, columnIndex: 0 });
1073
- toolSettings.push(this.primaryRadiusProperty.toDialogItem({ rowPriority: 1, columnIndex: 1 }, usePrimaryRadiusLock));
1074
- this.secondaryRadiusProperty.isDisabled = !this.useSecondaryRadius;
1075
- const useSecondaryRadiusLock = this.useSecondaryRadiusProperty.toDialogItem({ rowPriority: 2, columnIndex: 0 });
1076
- toolSettings.push(this.secondaryRadiusProperty.toDialogItem({ rowPriority: 2, columnIndex: 1 }, useSecondaryRadiusLock));
1077
- this.angleProperty.isDisabled = !this.useAngle;
1078
- const useAngleLock = this.useAngleProperty.toDialogItem({ rowPriority: 3, columnIndex: 0 });
1079
- toolSettings.push(this.angleProperty.toDialogItem({ rowPriority: 3, columnIndex: 1 }, useAngleLock));
1080
- toolSettings.push(this.cappedProperty.toDialogItem({ rowPriority: 4, columnIndex: 0 }));
1081
- return toolSettings;
1082
- }
1083
- async onRestartTool() {
1084
- const tool = new CreateTorusTool();
1085
- if (!await tool.run())
1086
- return this.exitTool();
1087
- }
1088
- }
1089
- CreateTorusTool.toolId = "CreateTorus";
1090
- CreateTorusTool.iconSpec = "icon-circle"; // TODO: Need better icon...
1091
- export { CreateTorusTool };
1092
- /** @alpha Tool for extruding paths and regions. */
1093
- class ExtrudeCurveTool extends ModifyCurveTool {
1094
- allowView(vp) { return vp.view.is3d(); }
1095
- get useLengthProperty() {
1096
- if (!this._useLengthProperty)
1097
- this._useLengthProperty = new DialogProperty(PropertyDescriptionHelper.buildLockPropertyDescription("useExtrudeLength"), false);
1098
- return this._useLengthProperty;
1099
- }
1100
- get useLength() { return this.useLengthProperty.value; }
1101
- set useLength(value) { this.useLengthProperty.value = value; }
1102
- get lengthProperty() {
1103
- if (!this._lengthProperty)
1104
- this._lengthProperty = new DialogProperty(new LengthDescription("extrudeLength", EditTools.translate("ExtrudeCurve.Label.Length")), 0.1, undefined, !this.useLength);
1105
- return this._lengthProperty;
1106
- }
1107
- get length() { return this.lengthProperty.value; }
1108
- set length(value) { this.lengthProperty.value = value; }
1109
- get cappedProperty() {
1110
- if (!this._cappedProperty)
1111
- this._cappedProperty = new DialogProperty(PropertyDescriptionHelper.buildToggleDescription("extrudeCapped", EditTools.translate("ExtrudeCurve.Label.Capped")), true);
1112
- return this._cappedProperty;
1113
- }
1114
- get capped() { return this.cappedProperty.value; }
1115
- set capped(value) { this.cappedProperty.value = value; }
1116
- get orthogonalProperty() {
1117
- if (!this._orthogonalProperty)
1118
- this._orthogonalProperty = new DialogProperty(PropertyDescriptionHelper.buildToggleDescription("extrudeOrthogonal", EditTools.translate("ExtrudeCurve.Label.Orthogonal")), true);
1119
- return this._orthogonalProperty;
1120
- }
1121
- get orthogonal() { return this.orthogonalProperty.value; }
1122
- set orthogonal(value) { this.orthogonalProperty.value = value; }
1123
- get keepProfileProperty() {
1124
- if (!this._keepProfileProperty)
1125
- this._keepProfileProperty = new DialogProperty(PropertyDescriptionHelper.buildToggleDescription("extrudeKeepProfile", EditTools.translate("ExtrudeCurve.Label.KeepProfile")), false);
1126
- return this._keepProfileProperty;
1127
- }
1128
- get keepProfile() { return this.keepProfileProperty.value; }
1129
- set keepProfile(value) { this.keepProfileProperty.value = value; }
1130
- getToolSettingPropertyLocked(property) {
1131
- return (property === this.useLengthProperty ? this.lengthProperty : undefined);
1132
- }
1133
- async applyToolSettingPropertyChange(updatedValue) {
1134
- return this.changeToolSettingPropertyValue(updatedValue);
1135
- }
1136
- supplyToolSettingsProperties() {
1137
- this.initializeToolSettingPropertyValues([this.keepProfileProperty, this.orthogonalProperty, this.cappedProperty, this.useLengthProperty, this.lengthProperty]);
1138
- const toolSettings = new Array();
1139
- // ensure controls are enabled/disabled based on current lock property state
1140
- this.lengthProperty.isDisabled = !this.useLength;
1141
- const useLengthLock = this.useLengthProperty.toDialogItem({ rowPriority: 1, columnIndex: 0 });
1142
- toolSettings.push(this.lengthProperty.toDialogItem({ rowPriority: 1, columnIndex: 1 }, useLengthLock));
1143
- toolSettings.push(this.orthogonalProperty.toDialogItem({ rowPriority: 2, columnIndex: 0 }));
1144
- toolSettings.push(this.cappedProperty.toDialogItem({ rowPriority: 3, columnIndex: 0 }));
1145
- toolSettings.push(this.keepProfileProperty.toDialogItem({ rowPriority: 4, columnIndex: 0 }));
1146
- return toolSettings;
1147
- }
1148
- acceptCurve(curve) {
1149
- if ("curvePrimitive" === curve.geometryCategory)
1150
- return true;
1151
- switch (curve.curveCollectionType) {
1152
- case "path":
1153
- case "loop":
1154
- case "parityRegion":
1155
- return true;
1156
- default:
1157
- return false;
1158
- }
1159
- }
1160
- modifyCurve(ev, isAccept) {
1161
- if (undefined === ev.viewport || undefined === this.anchorPoint)
1162
- return undefined;
1163
- const geom = this.curveData?.geom;
1164
- if (undefined === geom)
1165
- return undefined;
1166
- const matrix = AccuDrawHintBuilder.getCurrentRotation(ev.viewport, true, true);
1167
- const localToWorld = FrameBuilder.createRightHandedFrame(matrix?.getColumn(2), geom);
1168
- if (undefined === localToWorld)
1169
- return undefined;
1170
- const spacePoint = this.orthogonal ? AccuDrawHintBuilder.projectPointToLineInView(ev.point, this.anchorPoint, localToWorld.matrix.getColumn(2), ev.viewport, true) : ev.point;
1171
- if (undefined === spacePoint)
1172
- return undefined;
1173
- const direction = Vector3d.createStartEnd(this.anchorPoint, spacePoint);
1174
- if (this.useLength && undefined === direction.scaleToLength(this.length, direction))
1175
- return undefined;
1176
- if (direction.magnitude() < Geometry.smallMetricDistance)
1177
- return undefined;
1178
- if (!this.useLength) {
1179
- this.length = direction.magnitude();
1180
- this.syncToolSettingPropertyValue(this.lengthProperty);
1181
- if (isAccept)
1182
- this.saveToolSettingPropertyValue(this.lengthProperty, this.lengthProperty.dialogItemValue);
1183
- }
1184
- const contour = (geom instanceof CurvePrimitive) ? Path.create(geom) : geom;
1185
- return LinearSweep.create(contour, direction, this.capped && contour.isAnyRegionType);
1186
- }
1187
- get wantModifyOriginal() {
1188
- return !this.keepProfile;
1189
- }
1190
- setupAccuDraw() {
1191
- const hints = new AccuDrawHintBuilder();
1192
- if (this.agenda.isEmpty) {
1193
- hints.enableSmartRotation = true;
1194
- }
1195
- else if (undefined !== this.anchorPoint && undefined !== this.targetView) {
1196
- const geom = this.curveData?.geom;
1197
- const matrix = AccuDrawHintBuilder.getCurrentRotation(this.targetView, true, true);
1198
- const localToWorld = FrameBuilder.createRightHandedFrame(matrix?.getColumn(2), geom);
1199
- hints.setModeRectangular();
1200
- hints.setOrigin(this.anchorPoint);
1201
- hints.setOriginFixed = true;
1202
- if (undefined !== localToWorld) {
1203
- hints.setXAxis2(localToWorld.matrix.getColumn(2));
1204
- if (this.orthogonal) {
1205
- hints.setLockY = true;
1206
- hints.setLockZ = true;
1207
- }
1208
- }
1209
- }
1210
- hints.sendHints(false);
1211
- }
1212
- provideToolAssistance(_mainInstrText, _additionalInstr) {
1213
- let mainMsg;
1214
- if (!this.agenda.isEmpty)
1215
- mainMsg = EditTools.translate("ExtrudeCurve.Prompts.DefineLength");
1216
- super.provideToolAssistance(mainMsg);
1217
- }
1218
- async onRestartTool() {
1219
- const tool = new ExtrudeCurveTool();
1220
- if (!await tool.run())
1221
- return this.exitTool();
1222
- }
1223
- }
1224
- ExtrudeCurveTool.toolId = "ExtrudeCurve";
1225
- ExtrudeCurveTool.iconSpec = "icon-scale"; // Need better icon...
1226
- export { ExtrudeCurveTool };
1227
- /** @alpha Tool for revolving paths and regions. */
1228
- class RevolveCurveTool extends ModifyCurveTool {
1229
- constructor() {
1230
- super(...arguments);
1231
- this.points = [];
1232
- }
1233
- allowView(vp) { return vp.view.is3d(); }
1234
- get angleProperty() {
1235
- if (!this._angleProperty)
1236
- this._angleProperty = new DialogProperty(new AngleDescription("revolveAngle", EditTools.translate("RevolveCurve.Label.Angle")), Angle.piOver2Radians, undefined, false);
1237
- return this._angleProperty;
1238
- }
1239
- get angle() { return this.angleProperty.value; }
1240
- set angle(value) { this.angleProperty.value = value; }
1241
- get cappedProperty() {
1242
- if (!this._cappedProperty)
1243
- this._cappedProperty = new DialogProperty(PropertyDescriptionHelper.buildToggleDescription("revolveCapped", EditTools.translate("RevolveCurve.Label.Capped")), true);
1244
- return this._cappedProperty;
1245
- }
1246
- get capped() { return this.cappedProperty.value; }
1247
- set capped(value) { this.cappedProperty.value = value; }
1248
- get keepProfileProperty() {
1249
- if (!this._keepProfileProperty)
1250
- this._keepProfileProperty = new DialogProperty(PropertyDescriptionHelper.buildToggleDescription("revolveKeepProfile", EditTools.translate("RevolveCurve.Label.KeepProfile")), false);
1251
- return this._keepProfileProperty;
1252
- }
1253
- get keepProfile() { return this.keepProfileProperty.value; }
1254
- set keepProfile(value) { this.keepProfileProperty.value = value; }
1255
- async applyToolSettingPropertyChange(updatedValue) {
1256
- return this.changeToolSettingPropertyValue(updatedValue);
1257
- }
1258
- supplyToolSettingsProperties() {
1259
- this.initializeToolSettingPropertyValues([this.keepProfileProperty, this.cappedProperty, this.angleProperty]);
1260
- const toolSettings = new Array();
1261
- toolSettings.push(this.angleProperty.toDialogItem({ rowPriority: 1, columnIndex: 1 }));
1262
- toolSettings.push(this.cappedProperty.toDialogItem({ rowPriority: 3, columnIndex: 0 }));
1263
- toolSettings.push(this.keepProfileProperty.toDialogItem({ rowPriority: 4, columnIndex: 0 }));
1264
- return toolSettings;
1265
- }
1266
- acceptCurve(curve) {
1267
- if ("curvePrimitive" === curve.geometryCategory)
1268
- return true;
1269
- switch (curve.curveCollectionType) {
1270
- case "path":
1271
- case "loop":
1272
- case "parityRegion":
1273
- return true;
1274
- default:
1275
- return false;
1276
- }
1277
- }
1278
- modifyCurve(ev, isAccept) {
1279
- if (undefined === ev.viewport || this.points.length < (isAccept ? 2 : 1))
1280
- return undefined;
1281
- const geom = this.curveData?.geom;
1282
- if (undefined === geom)
1283
- return undefined;
1284
- const direction = Vector3d.createStartEnd(this.points[0], isAccept ? this.points[1] : ev.point);
1285
- if (direction.magnitude() < Geometry.smallMetricDistance)
1286
- return undefined;
1287
- const axis = Ray3d.create(this.points[0], direction);
1288
- const angle = Angle.createRadians(this.angle);
1289
- const contour = (geom instanceof CurvePrimitive) ? Path.create(geom) : geom;
1290
- const sweep = RotationalSweep.create(contour, axis, angle, this.capped && contour.isAnyRegionType);
1291
- // Detect a self-intersection...contour should not intersect axis of revolution...
1292
- const localToWorld = sweep?.getConstructiveFrame();
1293
- if (undefined === localToWorld)
1294
- return undefined;
1295
- const xVec = localToWorld.matrix.columnX(); // NOTE: Not always towards contour...
1296
- const xAxis = Ray3d.create(localToWorld.getOrigin(), xVec);
1297
- // Check parameter range of radial axis ray, if low is negative and high is positive reject result...
1298
- const paramRange = sweep?.getCurves().projectedParameterRange(xAxis);
1299
- if (undefined === paramRange || (paramRange.low < -Geometry.smallMetricDistanceSquared && paramRange.high > Geometry.smallMetricDistanceSquared))
1300
- return undefined;
1301
- return sweep;
1302
- }
1303
- onDynamicFrame(ev, context) {
1304
- if (0 === this.points.length)
1305
- return;
1306
- const pts = this.points.slice();
1307
- pts.push(ev.point.clone());
1308
- const builder = context.createGraphic({ type: GraphicType.WorldOverlay });
1309
- builder.setSymbology(context.viewport.getContrastToBackgroundColor(), ColorDef.black, 3);
1310
- builder.addLineString(pts);
1311
- context.addGraphic(builder.finish());
1312
- super.onDynamicFrame(ev, context);
1313
- }
1314
- get wantModifyOriginal() {
1315
- return !this.keepProfile;
1316
- }
1317
- get wantAdditionalInput() {
1318
- return this.points.length < 2;
1319
- }
1320
- async gatherInput(ev) {
1321
- if (undefined !== this.anchorPoint)
1322
- this.points.push(ev.point.clone());
1323
- return super.gatherInput(ev);
1324
- }
1325
- setupAccuDraw() {
1326
- const hints = new AccuDrawHintBuilder();
1327
- if (this.agenda.isEmpty) {
1328
- hints.enableSmartRotation = true;
1329
- }
1330
- else if (0 !== this.points.length) {
1331
- hints.setOrigin(this.points[0]);
1332
- hints.setOriginFixed = true;
1333
- hints.setLockZ = true;
1334
- }
1335
- else if (undefined !== this.anchorPoint && undefined !== this.targetView) {
1336
- const geom = this.curveData?.geom;
1337
- const closeDetail = (geom instanceof CurvePrimitive) ? geom.closestPoint(this.anchorPoint, false) : geom?.closestPoint(this.anchorPoint);
1338
- if (undefined === closeDetail?.curve)
1339
- return;
1340
- const unitX = closeDetail.curve.fractionToPointAndUnitTangent(closeDetail.fraction).direction;
1341
- if (undefined === unitX)
1342
- return;
1343
- const matrix = AccuDrawHintBuilder.getCurrentRotation(this.targetView, true, true);
1344
- const localToWorld = FrameBuilder.createRightHandedFrame(matrix?.getColumn(2), geom);
1345
- if (undefined === localToWorld)
1346
- return;
1347
- const unitZ = localToWorld.matrix.getColumn(2);
1348
- const frame = Matrix3d.createRigidFromColumns(unitX, unitZ, AxisOrder.XZY);
1349
- if (undefined === frame)
1350
- return;
1351
- hints.setModeRectangular();
1352
- hints.setOrigin(closeDetail.point);
1353
- hints.setMatrix(frame);
1354
- }
1355
- hints.sendHints(false);
1356
- }
1357
- provideToolAssistance(_mainInstrText, _additionalInstr) {
1358
- let mainMsg;
1359
- if (!this.agenda.isEmpty)
1360
- mainMsg = EditTools.translate(0 === this.points.length ? "RevolveCurve.Prompts.AxisPoint" : "RevolveCurve.Prompts.AxisDirection");
1361
- super.provideToolAssistance(mainMsg);
1362
- }
1363
- async onRestartTool() {
1364
- const tool = new RevolveCurveTool();
1365
- if (!await tool.run())
1366
- return this.exitTool();
1367
- }
1368
- }
1369
- RevolveCurveTool.toolId = "RevolveCurve";
1370
- RevolveCurveTool.iconSpec = "icon-scale"; // Need better icon...
1371
- export { RevolveCurveTool };
1372
- //# sourceMappingURL=SolidPrimitiveTools.js.map