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