@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,1453 +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
- /** @packageDocumentation
7
- * @module Editing
8
- */
9
- Object.defineProperty(exports, "__esModule", { value: true });
10
- exports.SpinFacesTool = exports.SweepFacesTool = exports.LocateFaceOrProfileTool = exports.ProfileLocationData = exports.ChamferEdgesTool = exports.RoundEdgesTool = exports.BlendEdgesTool = exports.ImprintSolidElementsTool = exports.ImprintSolidMethod = exports.DeleteSubEntitiesTool = exports.HollowFacesTool = exports.OffsetFacesTool = exports.FaceLocationData = exports.LoftProfilesTool = exports.SweepAlongPathTool = exports.EmbossSolidElementsTool = exports.CutSolidElementsTool = exports.ThickenSheetElementsTool = exports.SewSheetElementsTool = exports.IntersectSolidElementsTool = exports.SubtractSolidElementsTool = exports.UniteSolidElementsTool = exports.BooleanOperationTool = void 0;
11
- const appui_abstract_1 = require("@itwin/appui-abstract");
12
- const core_common_1 = require("@itwin/core-common");
13
- const core_frontend_1 = require("@itwin/core-frontend");
14
- const core_geometry_1 = require("@itwin/core-geometry");
15
- const editor_common_1 = require("@itwin/editor-common");
16
- const CreateElementTool_1 = require("./CreateElementTool");
17
- const EditTool_1 = require("./EditTool");
18
- const ElementGeometryTool_1 = require("./ElementGeometryTool");
19
- const EditToolIpc_1 = require("./EditToolIpc");
20
- /** @alpha Base class for tools that perform boolean operations on a set of elements. */
21
- class BooleanOperationTool extends ElementGeometryTool_1.ElementGeometryCacheTool {
22
- get allowSelectionSet() { return editor_common_1.BooleanMode.Subtract !== this.mode; }
23
- get allowDragSelect() { return editor_common_1.BooleanMode.Subtract !== this.mode; }
24
- get controlKeyContinuesSelection() { return true; }
25
- get requiredElementCount() { return 2; }
26
- get geometryCacheFilter() {
27
- return { parts: true, curves: false, surfaces: editor_common_1.BooleanMode.Subtract === this.mode && !this.agenda.isEmpty, solids: true, other: false };
28
- }
29
- async onAgendaModified() {
30
- // Filter changes to allow surfaces as tools, invalidate cached accept status...
31
- if (editor_common_1.BooleanMode.Subtract === this.mode && (this.agenda.isEmpty || 1 === this.agenda.length))
32
- this.onGeometryCacheFilterChanged();
33
- }
34
- async applyAgendaOperation() {
35
- if (this.agenda.length < this.requiredElementCount)
36
- return undefined;
37
- try {
38
- this._startedCmd = await this.startCommand();
39
- const target = this.agenda.elements[0];
40
- const tools = this.agenda.elements.slice(1);
41
- const params = { mode: this.mode, tools };
42
- const opts = { writeChanges: true };
43
- return await EditToolIpc_1.solidModelingIpc.booleanOperation(target, params, opts);
44
- }
45
- catch (err) {
46
- return undefined;
47
- }
48
- }
49
- async processAgenda(_ev) {
50
- const result = await this.applyAgendaOperation();
51
- if (result?.elementId)
52
- await this.saveChanges();
53
- }
54
- }
55
- exports.BooleanOperationTool = BooleanOperationTool;
56
- /** @alpha Perform boolean union of solid geometry. */
57
- class UniteSolidElementsTool extends BooleanOperationTool {
58
- get mode() { return editor_common_1.BooleanMode.Unite; }
59
- async onRestartTool() {
60
- const tool = new UniteSolidElementsTool();
61
- if (!await tool.run())
62
- return this.exitTool();
63
- }
64
- }
65
- UniteSolidElementsTool.toolId = "UniteSolids";
66
- UniteSolidElementsTool.iconSpec = "icon-move"; // TODO: Need better icon...
67
- exports.UniteSolidElementsTool = UniteSolidElementsTool;
68
- /** @alpha Perform boolean subtract of solid geometry. */
69
- class SubtractSolidElementsTool extends BooleanOperationTool {
70
- get mode() { return editor_common_1.BooleanMode.Subtract; }
71
- async onRestartTool() {
72
- const tool = new SubtractSolidElementsTool();
73
- if (!await tool.run())
74
- return this.exitTool();
75
- }
76
- }
77
- SubtractSolidElementsTool.toolId = "SubtractSolids";
78
- SubtractSolidElementsTool.iconSpec = "icon-move"; // TODO: Need better icon...
79
- exports.SubtractSolidElementsTool = SubtractSolidElementsTool;
80
- /** @alpha Perform boolean intersection of solid geometry. */
81
- class IntersectSolidElementsTool extends BooleanOperationTool {
82
- get mode() { return editor_common_1.BooleanMode.Intersect; }
83
- async onRestartTool() {
84
- const tool = new IntersectSolidElementsTool();
85
- if (!await tool.run())
86
- return this.exitTool();
87
- }
88
- }
89
- IntersectSolidElementsTool.toolId = "IntersectSolids";
90
- IntersectSolidElementsTool.iconSpec = "icon-move"; // TODO: Need better icon...
91
- exports.IntersectSolidElementsTool = IntersectSolidElementsTool;
92
- /** @alpha Perform sew operation on surface geometry. */
93
- class SewSheetElementsTool extends ElementGeometryTool_1.ElementGeometryCacheTool {
94
- get allowSelectionSet() { return true; }
95
- get allowDragSelect() { return true; }
96
- get controlKeyContinuesSelection() { return true; }
97
- get requiredElementCount() { return 2; }
98
- get geometryCacheFilter() {
99
- return { parts: true, curves: false, surfaces: true, solids: false, other: false };
100
- }
101
- async applyAgendaOperation() {
102
- if (this.agenda.length < this.requiredElementCount)
103
- return undefined;
104
- try {
105
- this._startedCmd = await this.startCommand();
106
- const target = this.agenda.elements[0];
107
- const tools = this.agenda.elements.slice(1);
108
- const params = { tools };
109
- const opts = { writeChanges: true };
110
- return await EditToolIpc_1.solidModelingIpc.sewSheets(target, params, opts);
111
- }
112
- catch (err) {
113
- return undefined;
114
- }
115
- }
116
- async processAgenda(_ev) {
117
- const result = await this.applyAgendaOperation();
118
- if (result?.elementId)
119
- await this.saveChanges();
120
- }
121
- async onRestartTool() {
122
- const tool = new SewSheetElementsTool();
123
- if (!await tool.run())
124
- return this.exitTool();
125
- }
126
- }
127
- SewSheetElementsTool.toolId = "SewSheets";
128
- SewSheetElementsTool.iconSpec = "icon-move"; // TODO: Need better icon...
129
- exports.SewSheetElementsTool = SewSheetElementsTool;
130
- /** @alpha Perform thicken operation on surface geometry. */
131
- class ThickenSheetElementsTool extends ElementGeometryTool_1.ElementGeometryCacheTool {
132
- get frontDistanceProperty() {
133
- if (!this._frontDistanceProperty)
134
- this._frontDistanceProperty = new appui_abstract_1.DialogProperty(new core_frontend_1.LengthDescription("thickenFront", EditTool_1.EditTools.translate("ThickenSheets.Label.FrontDistance")), 0.1, undefined);
135
- return this._frontDistanceProperty;
136
- }
137
- get frontDistance() { return this.frontDistanceProperty.value; }
138
- set frontDistance(value) { this.frontDistanceProperty.value = value; }
139
- get backDistanceProperty() {
140
- if (!this._backDistanceProperty)
141
- this._backDistanceProperty = new appui_abstract_1.DialogProperty(new core_frontend_1.LengthDescription("thickenBack", EditTool_1.EditTools.translate("ThickenSheets.Label.BackDistance")), 0.0, undefined);
142
- return this._backDistanceProperty;
143
- }
144
- get backDistance() { return this.backDistanceProperty.value; }
145
- set backDistance(value) { this.backDistanceProperty.value = value; }
146
- get geometryCacheFilter() {
147
- return { parts: true, curves: false, surfaces: true, solids: false, other: false };
148
- }
149
- async applyAgendaOperation() {
150
- if (this.agenda.length < this.requiredElementCount)
151
- return undefined;
152
- try {
153
- this._startedCmd = await this.startCommand();
154
- const target = this.agenda.elements[0];
155
- const params = { front: this.frontDistance, back: this.backDistance };
156
- const opts = { writeChanges: true };
157
- return await EditToolIpc_1.solidModelingIpc.thickenSheets(target, params, opts);
158
- }
159
- catch (err) {
160
- return undefined;
161
- }
162
- }
163
- async processAgenda(_ev) {
164
- const result = await this.applyAgendaOperation();
165
- if (result?.elementId)
166
- await this.saveChanges();
167
- }
168
- async applyToolSettingPropertyChange(updatedValue) {
169
- return this.changeToolSettingPropertyValue(updatedValue);
170
- }
171
- supplyToolSettingsProperties() {
172
- this.initializeToolSettingPropertyValues([this.frontDistanceProperty, this.backDistanceProperty]);
173
- const toolSettings = new Array();
174
- toolSettings.push(this.frontDistanceProperty.toDialogItem({ rowPriority: 1, columnIndex: 0 }));
175
- toolSettings.push(this.backDistanceProperty.toDialogItem({ rowPriority: 2, columnIndex: 0 }));
176
- return toolSettings;
177
- }
178
- async onRestartTool() {
179
- const tool = new ThickenSheetElementsTool();
180
- if (!await tool.run())
181
- return this.exitTool();
182
- }
183
- }
184
- ThickenSheetElementsTool.toolId = "ThickenSheets";
185
- ThickenSheetElementsTool.iconSpec = "icon-move"; // TODO: Need better icon...
186
- exports.ThickenSheetElementsTool = ThickenSheetElementsTool;
187
- /** @alpha Perform cut operation on solid using region or path profile. */
188
- class CutSolidElementsTool extends ElementGeometryTool_1.ElementGeometryCacheTool {
189
- get bothDirectionsProperty() {
190
- if (!this._bothDirectionsProperty)
191
- this._bothDirectionsProperty = new appui_abstract_1.DialogProperty(appui_abstract_1.PropertyDescriptionHelper.buildToggleDescription("cutBothDirections", EditTool_1.EditTools.translate("CutSolids.Label.BothDirections")), false);
192
- return this._bothDirectionsProperty;
193
- }
194
- get bothDirections() { return this.bothDirectionsProperty.value; }
195
- set bothDirections(value) { this.bothDirectionsProperty.value = value; }
196
- get outsideProperty() {
197
- if (!this._outsideProperty)
198
- this._outsideProperty = new appui_abstract_1.DialogProperty(appui_abstract_1.PropertyDescriptionHelper.buildToggleDescription("cutOutside", EditTool_1.EditTools.translate("CutSolids.Label.Outside")), false);
199
- return this._outsideProperty;
200
- }
201
- get outside() { return this.outsideProperty.value; }
202
- set outside(value) { this.outsideProperty.value = value; }
203
- get useDepthProperty() {
204
- if (!this._useDepthProperty)
205
- this._useDepthProperty = new appui_abstract_1.DialogProperty(appui_abstract_1.PropertyDescriptionHelper.buildLockPropertyDescription("useCutDepth"), false);
206
- return this._useDepthProperty;
207
- }
208
- get useDepth() { return this.useDepthProperty.value; }
209
- set useDepth(value) { this.useDepthProperty.value = value; }
210
- get depthProperty() {
211
- if (!this._depthProperty)
212
- this._depthProperty = new appui_abstract_1.DialogProperty(new core_frontend_1.LengthDescription("cutDepth", EditTool_1.EditTools.translate("CutSolids.Label.Depth")), 0.1, undefined, !this.useDepth);
213
- return this._depthProperty;
214
- }
215
- get depth() { return this.depthProperty.value; }
216
- set depth(value) { this.depthProperty.value = value; }
217
- get requiredElementCount() { return 2; }
218
- get isProfilePhase() { return !this.agenda.isEmpty; }
219
- get geometryCacheFilter() {
220
- const profilePhase = this.isProfilePhase;
221
- return { minGeom: 1, maxGeom: profilePhase ? 1 : undefined, parts: true, curves: profilePhase, surfaces: profilePhase, solids: !profilePhase, other: false };
222
- }
223
- async createElementGeometryCache(id) {
224
- if (!await super.createElementGeometryCache(id))
225
- return false;
226
- if (!this.isProfilePhase)
227
- return true;
228
- try {
229
- this._startedCmd = await this.startCommand();
230
- return await EditToolIpc_1.solidModelingIpc.isPlanarBody(id, 0);
231
- }
232
- catch (err) {
233
- return false;
234
- }
235
- }
236
- async onAgendaModified() {
237
- // Filter changes to allow sheets and wires as profiles, invalidate cached accept status...
238
- if (this.agenda.isEmpty || 1 === this.agenda.length)
239
- this.onGeometryCacheFilterChanged();
240
- }
241
- async applyAgendaOperation() {
242
- if (this.agenda.length < this.requiredElementCount)
243
- return undefined;
244
- const direction = (this.bothDirections ? editor_common_1.CutDirectionMode.Both : editor_common_1.CutDirectionMode.Auto);
245
- const depth = (this.useDepth ? editor_common_1.CutDepthMode.Blind : editor_common_1.CutDepthMode.All);
246
- try {
247
- this._startedCmd = await this.startCommand();
248
- const target = this.agenda.elements[0];
249
- const profile = this.agenda.elements[1];
250
- const params = { profile, direction, depth, distance: this.depth, outside: this.outside ? true : undefined, closeOpen: editor_common_1.ProfileClosure.Auto, targetPoint: this.targetPoint, toolPoint: this.toolPoint };
251
- const opts = { writeChanges: true };
252
- return await EditToolIpc_1.solidModelingIpc.cutSolid(target, params, opts);
253
- }
254
- catch (err) {
255
- return undefined;
256
- }
257
- }
258
- async processAgenda(_ev) {
259
- const result = await this.applyAgendaOperation();
260
- if (result?.elementId)
261
- await this.saveChanges();
262
- }
263
- async buildLocateAgenda(hit) {
264
- if (this.isProfilePhase)
265
- this.toolPoint = hit.hitPoint;
266
- else
267
- this.targetPoint = hit.hitPoint;
268
- return super.buildLocateAgenda(hit);
269
- }
270
- getToolSettingPropertyLocked(property) {
271
- return (property === this.useDepthProperty ? this.depthProperty : undefined);
272
- }
273
- async applyToolSettingPropertyChange(updatedValue) {
274
- return this.changeToolSettingPropertyValue(updatedValue);
275
- }
276
- supplyToolSettingsProperties() {
277
- this.initializeToolSettingPropertyValues([this.bothDirectionsProperty, this.outsideProperty, this.useDepthProperty, this.depthProperty]);
278
- const toolSettings = new Array();
279
- toolSettings.push(this.bothDirectionsProperty.toDialogItem({ rowPriority: 1, columnIndex: 0 }));
280
- toolSettings.push(this.outsideProperty.toDialogItem({ rowPriority: 2, columnIndex: 0 }));
281
- // ensure controls are enabled/disabled based on current lock property state
282
- this.depthProperty.isDisabled = !this.useDepth;
283
- const useDepthLock = this.useDepthProperty.toDialogItem({ rowPriority: 3, columnIndex: 0 });
284
- toolSettings.push(this.depthProperty.toDialogItem({ rowPriority: 3, columnIndex: 1 }, useDepthLock));
285
- return toolSettings;
286
- }
287
- async onRestartTool() {
288
- const tool = new CutSolidElementsTool();
289
- if (!await tool.run())
290
- return this.exitTool();
291
- }
292
- }
293
- CutSolidElementsTool.toolId = "CutSolids";
294
- CutSolidElementsTool.iconSpec = "icon-move"; // TODO: Need better icon...
295
- exports.CutSolidElementsTool = CutSolidElementsTool;
296
- /** @alpha Perform emboss operation on solid or sheet using sheet profile. */
297
- class EmbossSolidElementsTool extends ElementGeometryTool_1.ElementGeometryCacheTool {
298
- get requiredElementCount() { return 2; }
299
- get isProfilePhase() { return !this.agenda.isEmpty; }
300
- get geometryCacheFilter() {
301
- const profilePhase = this.isProfilePhase;
302
- return { minGeom: 1, maxGeom: 1, parts: true, curves: false, surfaces: true, solids: !profilePhase, other: false };
303
- }
304
- async onAgendaModified() {
305
- // Filter changes to disallow solids as profiles, invalidate cached accept status...
306
- if (this.agenda.isEmpty || 1 === this.agenda.length)
307
- this.onGeometryCacheFilterChanged();
308
- }
309
- async applyAgendaOperation() {
310
- if (this.agenda.length < this.requiredElementCount)
311
- return undefined;
312
- try {
313
- this._startedCmd = await this.startCommand();
314
- const target = this.agenda.elements[0];
315
- const profile = this.agenda.elements[1];
316
- const params = { profile, direction: editor_common_1.EmbossDirectionMode.Auto, targetPoint: this.targetPoint };
317
- const opts = { writeChanges: true };
318
- return await EditToolIpc_1.solidModelingIpc.embossBody(target, params, opts);
319
- }
320
- catch (err) {
321
- return undefined;
322
- }
323
- }
324
- async processAgenda(_ev) {
325
- const result = await this.applyAgendaOperation();
326
- if (result?.elementId)
327
- await this.saveChanges();
328
- }
329
- async buildLocateAgenda(hit) {
330
- if (!this.isProfilePhase)
331
- this.targetPoint = hit.hitPoint;
332
- return super.buildLocateAgenda(hit);
333
- }
334
- async onRestartTool() {
335
- const tool = new EmbossSolidElementsTool();
336
- if (!await tool.run())
337
- return this.exitTool();
338
- }
339
- }
340
- EmbossSolidElementsTool.toolId = "EmbossSolids";
341
- EmbossSolidElementsTool.iconSpec = "icon-move"; // TODO: Need better icon...
342
- exports.EmbossSolidElementsTool = EmbossSolidElementsTool;
343
- /** @alpha Create a solid for sheet by sweeping a profile along a path. */
344
- class SweepAlongPathTool extends ElementGeometryTool_1.ElementGeometryCacheTool {
345
- get requiredElementCount() { return 2; }
346
- get geometryCacheFilter() {
347
- return { minGeom: 1, maxGeom: 1, parts: true, curves: true, surfaces: true, solids: false, other: false };
348
- }
349
- async applyAgendaOperation() {
350
- if (this.agenda.length < this.requiredElementCount)
351
- return undefined;
352
- try {
353
- this._startedCmd = await this.startCommand();
354
- const target = this.agenda.elements[0];
355
- const path = this.agenda.elements[1];
356
- const params = { path };
357
- const opts = { writeChanges: true };
358
- return await EditToolIpc_1.solidModelingIpc.sweepAlongPath(target, params, opts);
359
- }
360
- catch (err) {
361
- return undefined;
362
- }
363
- }
364
- async processAgenda(_ev) {
365
- const result = await this.applyAgendaOperation();
366
- if (result?.elementId)
367
- await this.saveChanges();
368
- }
369
- async onRestartTool() {
370
- const tool = new SweepAlongPathTool();
371
- if (!await tool.run())
372
- return this.exitTool();
373
- }
374
- }
375
- SweepAlongPathTool.toolId = "SweepAlongPath";
376
- SweepAlongPathTool.iconSpec = "icon-move"; // TODO: Need better icon...
377
- exports.SweepAlongPathTool = SweepAlongPathTool;
378
- /** @alpha Create a new sheet or solid body by lofting through a set of profiles. */
379
- class LoftProfilesTool extends ElementGeometryTool_1.ElementGeometryCacheTool {
380
- get requiredElementCount() { return 2; }
381
- get controlKeyContinuesSelection() { return true; }
382
- get geometryCacheFilter() {
383
- return { minGeom: 1, maxGeom: 1, parts: true, curves: true, surfaces: true, solids: false, other: false };
384
- }
385
- async applyAgendaOperation() {
386
- if (this.agenda.length < this.requiredElementCount)
387
- return undefined;
388
- try {
389
- this._startedCmd = await this.startCommand();
390
- const target = this.agenda.elements[0];
391
- const tools = this.agenda.elements.slice(1);
392
- const params = { tools, orderCurves: this.isSelectionSetModify ? true : undefined, orientCurves: true };
393
- const opts = { writeChanges: true };
394
- return await EditToolIpc_1.solidModelingIpc.loftProfiles(target, params, opts);
395
- }
396
- catch (err) {
397
- return undefined;
398
- }
399
- }
400
- async processAgenda(_ev) {
401
- const result = await this.applyAgendaOperation();
402
- if (result?.elementId)
403
- await this.saveChanges();
404
- }
405
- async onRestartTool() {
406
- const tool = new LoftProfilesTool();
407
- if (!await tool.run())
408
- return this.exitTool();
409
- }
410
- }
411
- LoftProfilesTool.toolId = "LoftProfiles";
412
- LoftProfilesTool.iconSpec = "icon-move"; // TODO: Need better icon...
413
- exports.LoftProfilesTool = LoftProfilesTool;
414
- /** @alpha */
415
- class FaceLocationData {
416
- constructor(point, normal) {
417
- this.point = point;
418
- this.normal = normal;
419
- }
420
- static create(pointProps, normalProps) {
421
- const point = core_geometry_1.Point3d.fromJSON(pointProps);
422
- const normal = core_geometry_1.Vector3d.fromJSON(normalProps);
423
- return new FaceLocationData(point, normal);
424
- }
425
- }
426
- exports.FaceLocationData = FaceLocationData;
427
- /** @alpha Identify faces of solids and surfaces to offset. */
428
- class OffsetFacesTool extends ElementGeometryTool_1.LocateSubEntityTool {
429
- get addSmoothProperty() {
430
- if (!this._addSmoothProperty)
431
- this._addSmoothProperty = new appui_abstract_1.DialogProperty(appui_abstract_1.PropertyDescriptionHelper.buildToggleDescription("offsetSmooth", EditTool_1.EditTools.translate("OffsetFaces.Label.AddSmooth")), false);
432
- return this._addSmoothProperty;
433
- }
434
- get addSmooth() { return this.addSmoothProperty.value; }
435
- set addSmooth(value) { this.addSmoothProperty.value = value; }
436
- get useDistanceProperty() {
437
- if (!this._useDistanceProperty)
438
- this._useDistanceProperty = new appui_abstract_1.DialogProperty(appui_abstract_1.PropertyDescriptionHelper.buildLockPropertyDescription("useOffsetDistance"), false);
439
- return this._useDistanceProperty;
440
- }
441
- get useDistance() { return this.useDistanceProperty.value; }
442
- set useDistance(value) { this.useDistanceProperty.value = value; }
443
- get distanceProperty() {
444
- if (!this._distanceProperty)
445
- this._distanceProperty = new appui_abstract_1.DialogProperty(new core_frontend_1.LengthDescription("offsetDistance", EditTool_1.EditTools.translate("OffsetFaces.Label.Distance")), 0.1, undefined, !this.useDistance);
446
- return this._distanceProperty;
447
- }
448
- get distance() { return this.distanceProperty.value; }
449
- set distance(value) { this.distanceProperty.value = value; }
450
- get wantDynamics() { return true; }
451
- get wantAccuSnap() { return this.isDynamicsStarted; }
452
- get geometryCacheFilter() {
453
- return { parts: true, curves: false, surfaces: true, solids: true, other: false };
454
- }
455
- async createSubEntityData(id, hit) {
456
- const data = await super.createSubEntityData(id, hit);
457
- if (undefined !== hit.point && undefined !== hit.normal)
458
- data.toolData = FaceLocationData.create(hit.point, hit.normal);
459
- return data;
460
- }
461
- drawAcceptedSubEntities(context) {
462
- super.drawAcceptedSubEntities(context);
463
- // Show pick point on last identified face, offset direction/distance will be computed from this location...
464
- const faceData = this.getAcceptedSubEntityData()?.toolData;
465
- if (undefined === faceData)
466
- return;
467
- const builder = context.createGraphic({ type: core_frontend_1.GraphicType.WorldOverlay });
468
- builder.setSymbology(context.viewport.getContrastToBackgroundColor(), core_common_1.ColorDef.black, 10);
469
- builder.addPointString([faceData.point]);
470
- context.addDecorationFromBuilder(builder);
471
- }
472
- async getSmoothFaces(id, face) {
473
- try {
474
- // NOTE: For offset, include all smoothly connected faces, not just adjacent...
475
- return await EditToolIpc_1.solidModelingIpc.getConnectedSubEntities(id, face, editor_common_1.SubEntityType.Face, { smoothFaces: true });
476
- }
477
- catch (err) {
478
- return undefined;
479
- }
480
- }
481
- async applyAgendaOperation(ev, isAccept) {
482
- if (undefined === ev.viewport || this.agenda.isEmpty || !this.haveAcceptedSubEntities)
483
- return undefined;
484
- const faceData = this.getAcceptedSubEntityData()?.toolData;
485
- if (undefined === faceData)
486
- return undefined;
487
- const projPt = core_frontend_1.AccuDrawHintBuilder.projectPointToLineInView(ev.point, faceData.point, faceData.normal, ev.viewport);
488
- if (undefined === projPt)
489
- return undefined;
490
- const offsetDir = core_geometry_1.Vector3d.createStartEnd(faceData.point, projPt);
491
- if (this.useDistance && undefined === offsetDir.scaleToLength(this.distance, offsetDir))
492
- return undefined;
493
- let offset = offsetDir.magnitude();
494
- if (offset < core_geometry_1.Geometry.smallMetricDistance)
495
- return undefined;
496
- if (offsetDir.dotProduct(faceData.normal) < 0.0)
497
- offset = -offset;
498
- if (!this.useDistance) {
499
- this.distance = offset;
500
- this.syncToolSettingPropertyValue(this.distanceProperty);
501
- if (isAccept)
502
- this.saveToolSettingPropertyValue(this.distanceProperty, this.distanceProperty.dialogItemValue);
503
- }
504
- try {
505
- this._startedCmd = await this.startCommand();
506
- const id = this.agenda.elements[0];
507
- const faces = this.getAcceptedSubEntities();
508
- if (this.addSmooth) {
509
- const allSmoothFaces = [];
510
- for (const face of faces) {
511
- const smoothFaces = await this.getSmoothFaces(id, face);
512
- if (undefined !== smoothFaces)
513
- allSmoothFaces.push(...smoothFaces);
514
- }
515
- for (const smooth of allSmoothFaces) {
516
- if (undefined === faces.find((selected) => (0, ElementGeometryTool_1.isSameSubEntity)(selected, smooth)))
517
- faces.unshift(smooth); // Preserve last selected entry as reference face...
518
- }
519
- }
520
- const params = { faces, distances: offset };
521
- const opts = {
522
- wantGraphic: isAccept ? undefined : true,
523
- chordTolerance: (0, CreateElementTool_1.computeChordToleranceFromPoint)(ev.viewport, ev.point),
524
- requestId: `${this.toolId}:${id}`,
525
- writeChanges: isAccept ? true : undefined,
526
- };
527
- return await EditToolIpc_1.solidModelingIpc.offsetFaces(id, params, opts);
528
- }
529
- catch (err) {
530
- return undefined;
531
- }
532
- }
533
- setupAccuDraw() {
534
- if (!this.haveAcceptedSubEntities)
535
- return;
536
- const faceData = this.getAcceptedSubEntityData()?.toolData;
537
- if (undefined === faceData)
538
- return;
539
- const hints = new core_frontend_1.AccuDrawHintBuilder();
540
- hints.setOriginFixed = true;
541
- hints.setLockY = true;
542
- hints.setLockZ = true;
543
- hints.setModeRectangular();
544
- hints.setOrigin(faceData.point);
545
- hints.setXAxis2(faceData.normal);
546
- hints.sendHints(false);
547
- }
548
- getToolSettingPropertyLocked(property) {
549
- return (property === this.useDistanceProperty ? this.distanceProperty : undefined);
550
- }
551
- async applyToolSettingPropertyChange(updatedValue) {
552
- return this.changeToolSettingPropertyValue(updatedValue);
553
- }
554
- supplyToolSettingsProperties() {
555
- this.initializeToolSettingPropertyValues([this.addSmoothProperty, this.useDistanceProperty, this.distanceProperty]);
556
- const toolSettings = new Array();
557
- // ensure controls are enabled/disabled based on current lock property state
558
- this.distanceProperty.isDisabled = !this.useDistance;
559
- const useDistanceLock = this.useDistanceProperty.toDialogItem({ rowPriority: 1, columnIndex: 0 });
560
- toolSettings.push(this.distanceProperty.toDialogItem({ rowPriority: 1, columnIndex: 1 }, useDistanceLock));
561
- toolSettings.push(this.addSmoothProperty.toDialogItem({ rowPriority: 2, columnIndex: 0 }));
562
- return toolSettings;
563
- }
564
- async onRestartTool() {
565
- const tool = new OffsetFacesTool();
566
- if (!await tool.run())
567
- return this.exitTool();
568
- }
569
- }
570
- OffsetFacesTool.toolId = "OffsetFaces";
571
- OffsetFacesTool.iconSpec = "icon-move"; // TODO: Need better icon...
572
- exports.OffsetFacesTool = OffsetFacesTool;
573
- /** @alpha Identify faces to offset to hollow solids. */
574
- class HollowFacesTool extends ElementGeometryTool_1.LocateSubEntityTool {
575
- get shellThicknessProperty() {
576
- if (!this._shellThicknessProperty)
577
- this._shellThicknessProperty = new appui_abstract_1.DialogProperty(new core_frontend_1.LengthDescription("hollowShellThickness", EditTool_1.EditTools.translate("HollowFaces.Label.ShellThickness")), 0.1, undefined);
578
- return this._shellThicknessProperty;
579
- }
580
- get shellThickness() { return this.shellThicknessProperty.value; }
581
- set shellThickness(value) { this.shellThicknessProperty.value = value; }
582
- get faceThicknessProperty() {
583
- if (!this._faceThicknessProperty)
584
- this._faceThicknessProperty = new appui_abstract_1.DialogProperty(new core_frontend_1.LengthDescription("hollowFaceThickness", EditTool_1.EditTools.translate("HollowFaces.Label.FaceThickness")), 0.0, undefined);
585
- return this._faceThicknessProperty;
586
- }
587
- get faceThickness() { return this.faceThicknessProperty.value; }
588
- set faceThickness(value) { this.faceThicknessProperty.value = value; }
589
- get geometryCacheFilter() {
590
- return { parts: true, curves: false, surfaces: false, solids: true, other: false };
591
- }
592
- async applyAgendaOperation(ev, isAccept) {
593
- if (undefined === ev.viewport || this.agenda.isEmpty || !this.haveAcceptedSubEntities)
594
- return undefined;
595
- try {
596
- this._startedCmd = await this.startCommand();
597
- const params = { faces: this.getAcceptedSubEntities(), distances: this.faceThickness, defaultDistance: this.shellThickness };
598
- const opts = {
599
- wantGraphic: isAccept ? undefined : true,
600
- chordTolerance: (0, CreateElementTool_1.computeChordToleranceFromPoint)(ev.viewport, ev.point),
601
- requestId: `${this.toolId}:${this.agenda.elements[0]}`,
602
- writeChanges: isAccept ? true : undefined,
603
- };
604
- return await EditToolIpc_1.solidModelingIpc.hollowFaces(this.agenda.elements[0], params, opts);
605
- }
606
- catch (err) {
607
- return undefined;
608
- }
609
- }
610
- async applyToolSettingPropertyChange(updatedValue) {
611
- return this.changeToolSettingPropertyValue(updatedValue);
612
- }
613
- supplyToolSettingsProperties() {
614
- this.initializeToolSettingPropertyValues([this.shellThicknessProperty, this.faceThicknessProperty]);
615
- const toolSettings = new Array();
616
- toolSettings.push(this.shellThicknessProperty.toDialogItem({ rowPriority: 1, columnIndex: 0 }));
617
- toolSettings.push(this.faceThicknessProperty.toDialogItem({ rowPriority: 2, columnIndex: 0 }));
618
- return toolSettings;
619
- }
620
- async onRestartTool() {
621
- const tool = new HollowFacesTool();
622
- if (!await tool.run())
623
- return this.exitTool();
624
- }
625
- }
626
- HollowFacesTool.toolId = "HollowFaces";
627
- HollowFacesTool.iconSpec = "icon-move"; // TODO: Need better icon...
628
- exports.HollowFacesTool = HollowFacesTool;
629
- /** @alpha Identify faces or edges for removal by growing surrounding faces. */
630
- class DeleteSubEntitiesTool extends ElementGeometryTool_1.LocateSubEntityTool {
631
- wantSubEntityType(type) {
632
- switch (type) {
633
- case editor_common_1.SubEntityType.Face:
634
- case editor_common_1.SubEntityType.Edge:
635
- // Choose all faces or all edges...
636
- return (0 === this._acceptedSubEntities.length || this._acceptedSubEntities[0].props.type === type);
637
- default:
638
- return false;
639
- }
640
- }
641
- getMaximumSubEntityHits(type) {
642
- if (!this.wantSubEntityType(type))
643
- return 0;
644
- // Only return single closest edge, avoids having to test for redundant edges on reset...
645
- return (editor_common_1.SubEntityType.Edge === type ? 1 : 25);
646
- }
647
- get geometryCacheFilter() {
648
- return { parts: true, curves: false, surfaces: true, solids: true, other: false };
649
- }
650
- async doPickSubEntities(id, ev) {
651
- const hits = await super.doPickSubEntities(id, ev);
652
- if (undefined === hits)
653
- return hits;
654
- // Don't allow reset to select a back edge...
655
- if (editor_common_1.SubEntityType.Face === hits[0].subEntity.type)
656
- return hits.filter((hit) => { return editor_common_1.SubEntityType.Face === hit.subEntity.type; });
657
- try {
658
- const accept = await EditToolIpc_1.solidModelingIpc.isRedundantEdge(id, hits[0].subEntity);
659
- if (accept)
660
- return hits;
661
- if (hits.length > 1 && editor_common_1.SubEntityType.Face === hits[1].subEntity.type)
662
- return hits.slice(1); // Accept face of rejected edge...
663
- return undefined;
664
- }
665
- catch (err) {
666
- return undefined;
667
- }
668
- }
669
- async applyAgendaOperation(ev, isAccept) {
670
- if (undefined === ev.viewport || this.agenda.isEmpty || !this.haveAcceptedSubEntities)
671
- return undefined;
672
- try {
673
- this._startedCmd = await this.startCommand();
674
- const params = { subEntities: this.getAcceptedSubEntities() };
675
- const opts = {
676
- wantGraphic: isAccept ? undefined : true,
677
- chordTolerance: (0, CreateElementTool_1.computeChordToleranceFromPoint)(ev.viewport, ev.point),
678
- requestId: `${this.toolId}:${this.agenda.elements[0]}`,
679
- writeChanges: isAccept ? true : undefined,
680
- };
681
- return await EditToolIpc_1.solidModelingIpc.deleteSubEntities(this.agenda.elements[0], params, opts);
682
- }
683
- catch (err) {
684
- return undefined;
685
- }
686
- }
687
- async onRestartTool() {
688
- const tool = new DeleteSubEntitiesTool();
689
- if (!await tool.run())
690
- return this.exitTool();
691
- }
692
- }
693
- DeleteSubEntitiesTool.toolId = "DeleteSubEntities";
694
- DeleteSubEntitiesTool.iconSpec = "icon-move"; // TODO: Need better icon...
695
- exports.DeleteSubEntitiesTool = DeleteSubEntitiesTool;
696
- /** @alpha */
697
- var ImprintSolidMethod;
698
- (function (ImprintSolidMethod) {
699
- /** Imprint intersection with another element */
700
- ImprintSolidMethod[ImprintSolidMethod["Element"] = 0] = "Element";
701
- /** Imprint offset edges onto face */
702
- ImprintSolidMethod[ImprintSolidMethod["Edges"] = 1] = "Edges";
703
- /** Imprint line string defined by points onto face */
704
- ImprintSolidMethod[ImprintSolidMethod["Points"] = 2] = "Points";
705
- })(ImprintSolidMethod = exports.ImprintSolidMethod || (exports.ImprintSolidMethod = {}));
706
- /** @alpha Identify edges or elements to imprint on solid or surface. */
707
- class ImprintSolidElementsTool extends ElementGeometryTool_1.LocateSubEntityTool {
708
- constructor() {
709
- super(...arguments);
710
- this.points = [];
711
- }
712
- static methodMessage(str) { return EditTool_1.EditTools.translate(`ImprintSolids.Method.${str}`); }
713
- get methodProperty() {
714
- if (!this._methodProperty)
715
- this._methodProperty = new appui_abstract_1.DialogProperty(appui_abstract_1.PropertyDescriptionHelper.buildEnumPicklistEditorDescription("imprintMethod", EditTool_1.EditTools.translate("ImprintSolids.Label.Method"), ImprintSolidElementsTool.getMethodChoices()), ImprintSolidMethod.Element);
716
- return this._methodProperty;
717
- }
718
- get method() { return this.methodProperty.value; }
719
- set method(method) { this.methodProperty.value = method; }
720
- get distanceProperty() {
721
- if (!this._distanceProperty)
722
- this._distanceProperty = new appui_abstract_1.DialogProperty(new core_frontend_1.LengthDescription("imprintDistance", EditTool_1.EditTools.translate("ImprintSolids.Label.Distance")), 0.1, undefined);
723
- return this._distanceProperty;
724
- }
725
- get distance() { return this.distanceProperty.value; }
726
- set distance(value) { this.distanceProperty.value = value; }
727
- get extendProperty() {
728
- if (!this._extendProperty)
729
- this._extendProperty = new appui_abstract_1.DialogProperty(appui_abstract_1.PropertyDescriptionHelper.buildToggleDescription("imprintExtend", EditTool_1.EditTools.translate("ImprintSolids.Label.Extend")), false);
730
- return this._extendProperty;
731
- }
732
- get extend() { return this.extendProperty.value; }
733
- set extend(value) { this.extendProperty.value = value; }
734
- get requiredSubEntityCount() { return ImprintSolidMethod.Element === this.method ? 0 : 1; }
735
- get requiredElementCount() { return ImprintSolidMethod.Element === this.method ? 2 : 1; }
736
- get allowSubEntityControlSelect() { return ImprintSolidMethod.Edges === this.method; }
737
- get inhibitSubEntityDisplay() { return ImprintSolidMethod.Points === this.method ? false : super.inhibitSubEntityDisplay; }
738
- wantSubEntityType(type) {
739
- switch (type) {
740
- case editor_common_1.SubEntityType.Face:
741
- return ImprintSolidMethod.Points === this.method;
742
- case editor_common_1.SubEntityType.Edge:
743
- return ImprintSolidMethod.Edges === this.method;
744
- default:
745
- return false;
746
- }
747
- }
748
- get wantDynamics() { return ImprintSolidMethod.Points === this.method; }
749
- get wantAccuSnap() { return ImprintSolidMethod.Points === this.method && this.isDynamicsStarted; }
750
- get geometryCacheFilter() {
751
- return { parts: true, curves: !this.agenda.isEmpty, surfaces: true, solids: true, other: false };
752
- }
753
- async onAgendaModified() {
754
- // Filter changes to allow imprinting an open path, invalidate cached accept status...
755
- if (ImprintSolidMethod.Element === this.method && (this.agenda.isEmpty || 1 === this.agenda.length))
756
- this.onGeometryCacheFilterChanged();
757
- }
758
- async createSubEntityData(id, hit) {
759
- const data = await super.createSubEntityData(id, hit);
760
- if (undefined !== hit.point && undefined !== hit.normal)
761
- data.toolData = FaceLocationData.create(hit.point, hit.normal);
762
- return data;
763
- }
764
- async applyAgendaOperation(_ev, isAccept) {
765
- if (!isAccept || this.agenda.length < this.requiredElementCount)
766
- return undefined;
767
- const id = this.agenda.elements[0];
768
- try {
769
- this._startedCmd = await this.startCommand();
770
- let params;
771
- if (ImprintSolidMethod.Points === this.method) {
772
- if (!this.haveAcceptedSubEntities)
773
- return undefined;
774
- const geom = core_common_1.ElementGeometry.fromGeometryQuery(core_geometry_1.LineString3d.create(this.points));
775
- if (undefined === geom)
776
- return undefined;
777
- params = { imprint: geom, face: this.getAcceptedSubEntityData(0)?.props, extend: this.extend ? true : undefined };
778
- }
779
- else if (ImprintSolidMethod.Edges === this.method) {
780
- if (!this.haveAcceptedSubEntities)
781
- return undefined;
782
- // TODO: Include all accepted edges...
783
- const edge = this.getAcceptedSubEntityData(0)?.props;
784
- if (undefined === edge)
785
- return undefined;
786
- const edgeFaces = await EditToolIpc_1.solidModelingIpc.getConnectedSubEntities(id, edge, editor_common_1.SubEntityType.Face);
787
- if (undefined === edgeFaces || 0 === edgeFaces.length)
788
- return undefined;
789
- // TODO: Check planar face...get preferred face from cursor location in dynamics, etc.
790
- const edgeLoop = await EditToolIpc_1.solidModelingIpc.getConnectedSubEntities(id, edge, editor_common_1.SubEntityType.Edge, { loopFace: edgeFaces[0] });
791
- if (undefined === edgeLoop || 0 === edgeLoop.length)
792
- return undefined;
793
- params = { imprint: edgeLoop, face: edgeFaces[0], distance: this.distance, extend: this.extend ? true : undefined };
794
- }
795
- else {
796
- params = { imprint: this.agenda.elements[1], extend: this.extend ? true : undefined };
797
- }
798
- const opts = { writeChanges: true };
799
- return await EditToolIpc_1.solidModelingIpc.imprintBody(id, params, opts);
800
- }
801
- catch (err) {
802
- return undefined;
803
- }
804
- }
805
- onDynamicFrame(ev, context) {
806
- if (ImprintSolidMethod.Points !== this.method || 0 === this.points.length)
807
- return;
808
- const pts = this.points.slice();
809
- pts.push(ev.point.clone());
810
- const builder = context.createGraphic({ type: core_frontend_1.GraphicType.WorldOverlay });
811
- builder.setSymbology(context.viewport.getContrastToBackgroundColor(), core_common_1.ColorDef.black, 3);
812
- builder.addLineString(pts);
813
- context.addGraphic(builder.finish());
814
- }
815
- async gatherInput(ev) {
816
- switch (this.method) {
817
- case ImprintSolidMethod.Points: {
818
- if (!this.haveAcceptedSubEntities)
819
- break;
820
- this.points.push(ev.point.clone());
821
- if (!ev.isControlKey)
822
- break;
823
- this.setupAndPromptForNextAction();
824
- return core_frontend_1.EventHandled.No;
825
- }
826
- default:
827
- break;
828
- }
829
- return super.gatherInput(ev);
830
- }
831
- get wantAdditionalInput() {
832
- switch (this.method) {
833
- case ImprintSolidMethod.Element:
834
- return false;
835
- case ImprintSolidMethod.Edges:
836
- return super.wantAdditionalInput;
837
- case ImprintSolidMethod.Points:
838
- return super.wantAdditionalInput || this.points.length < 2;
839
- }
840
- }
841
- setupAccuDraw() {
842
- if (ImprintSolidMethod.Points !== this.method || 0 !== this.points.length)
843
- return;
844
- if (!this.haveAcceptedSubEntities)
845
- return;
846
- const faceData = this.getAcceptedSubEntityData()?.toolData;
847
- if (undefined === faceData)
848
- return;
849
- const hints = new core_frontend_1.AccuDrawHintBuilder();
850
- hints.setModeRectangular();
851
- hints.setOrigin(faceData.point);
852
- hints.setNormal(faceData.normal);
853
- hints.sendHints(false);
854
- }
855
- async applyToolSettingPropertyChange(updatedValue) {
856
- if (!this.changeToolSettingPropertyValue(updatedValue))
857
- return false;
858
- if (updatedValue.propertyName === this.methodProperty.name)
859
- await this.onReinitialize();
860
- return true;
861
- }
862
- supplyToolSettingsProperties() {
863
- this.initializeToolSettingPropertyValues([this.methodProperty, this.extendProperty, this.distanceProperty]);
864
- const toolSettings = new Array();
865
- toolSettings.push(this.methodProperty.toDialogItem({ rowPriority: 1, columnIndex: 0 }));
866
- switch (this.method) {
867
- case ImprintSolidMethod.Element:
868
- toolSettings.push(this.extendProperty.toDialogItem({ rowPriority: 2, columnIndex: 0 }));
869
- break;
870
- case ImprintSolidMethod.Edges:
871
- toolSettings.push(this.distanceProperty.toDialogItem({ rowPriority: 2, columnIndex: 0 }));
872
- break;
873
- case ImprintSolidMethod.Points:
874
- toolSettings.push(this.extendProperty.toDialogItem({ rowPriority: 2, columnIndex: 0 }));
875
- break;
876
- }
877
- return toolSettings;
878
- }
879
- async onRestartTool() {
880
- const tool = new ImprintSolidElementsTool();
881
- if (!await tool.run())
882
- return this.exitTool();
883
- }
884
- }
885
- ImprintSolidElementsTool.toolId = "ImprintSolids";
886
- ImprintSolidElementsTool.iconSpec = "icon-move"; // TODO: Need better icon...
887
- ImprintSolidElementsTool.getMethodChoices = () => {
888
- return [
889
- { label: ImprintSolidElementsTool.methodMessage("Element"), value: ImprintSolidMethod.Element },
890
- { label: ImprintSolidElementsTool.methodMessage("Edges"), value: ImprintSolidMethod.Edges },
891
- { label: ImprintSolidElementsTool.methodMessage("Points"), value: ImprintSolidMethod.Points },
892
- ];
893
- };
894
- exports.ImprintSolidElementsTool = ImprintSolidElementsTool;
895
- /** @alpha Base class for tools to identify edges of solids and surfaces and apply blends. */
896
- class BlendEdgesTool extends ElementGeometryTool_1.LocateSubEntityTool {
897
- get addSmoothProperty() {
898
- if (!this._addSmoothProperty)
899
- this._addSmoothProperty = new appui_abstract_1.DialogProperty(appui_abstract_1.PropertyDescriptionHelper.buildToggleDescription("blendSmooth", EditTool_1.EditTools.translate("RoundEdges.Label.AddSmooth")), false);
900
- return this._addSmoothProperty;
901
- }
902
- get addSmooth() { return this.addSmoothProperty.value; }
903
- set addSmooth(value) { this.addSmoothProperty.value = value; }
904
- wantSubEntityType(type) { return editor_common_1.SubEntityType.Edge === type; }
905
- getSubEntityFilter() {
906
- return { laminarEdges: true, smoothEdges: true };
907
- }
908
- get geometryCacheFilter() {
909
- return { parts: true, curves: false, surfaces: true, solids: true, other: false };
910
- }
911
- async getTangentEdges(id, edge) {
912
- try {
913
- return await EditToolIpc_1.solidModelingIpc.getConnectedSubEntities(id, edge, editor_common_1.SubEntityType.Edge, { smoothEdges: true });
914
- }
915
- catch (err) {
916
- return undefined;
917
- }
918
- }
919
- async addTangentEdges(id, edge, chordTolerance) {
920
- if (undefined === edge) {
921
- this._acceptedSubEntities.forEach(async (accepted) => {
922
- if (undefined === accepted.toolData)
923
- await this.addTangentEdges(id, accepted.props, accepted.chordTolerance);
924
- });
925
- return;
926
- }
927
- const tangentEdges = await this.getTangentEdges(id, edge);
928
- if (undefined === tangentEdges)
929
- return;
930
- tangentEdges.forEach(async (entry) => {
931
- if (!(0, ElementGeometryTool_1.isSameSubEntity)(entry, edge)) {
932
- const data = new ElementGeometryTool_1.SubEntityData(entry);
933
- data.toolData = edge; // Mark edge so we know it was added as tangent edge...
934
- await this.createSubEntityGraphic(id, data, chordTolerance);
935
- this._acceptedSubEntities.push(data);
936
- }
937
- });
938
- }
939
- async removeTangentEdges(_id, edge) {
940
- if (undefined === edge) {
941
- this._acceptedSubEntities = this._acceptedSubEntities.filter((entry) => undefined === entry.toolData);
942
- return;
943
- }
944
- const edgeData = this._acceptedSubEntities.find((entry) => (0, ElementGeometryTool_1.isSameSubEntity)(entry.props, edge));
945
- if (undefined === edgeData)
946
- return undefined;
947
- const isTangentEdge = (other) => {
948
- const primaryOther = (undefined !== other.toolData ? other.toolData : other.props);
949
- return (0, ElementGeometryTool_1.isSameSubEntity)(primaryEdge, primaryOther);
950
- };
951
- const primaryEdge = (undefined !== edgeData.toolData ? edgeData.toolData : edgeData.props);
952
- this._acceptedSubEntities = this._acceptedSubEntities.filter((entry) => !isTangentEdge(entry));
953
- }
954
- async syncTangentEdges() {
955
- const id = this.getCurrentElement();
956
- if (undefined === id)
957
- return;
958
- if (this.addSmooth)
959
- await this.addTangentEdges(id);
960
- else
961
- await this.removeTangentEdges(id);
962
- core_frontend_1.IModelApp.viewManager.invalidateDecorationsAllViews();
963
- }
964
- async addSubEntity(id, props) {
965
- await super.addSubEntity(id, props);
966
- if (!this.addSmooth)
967
- return;
968
- const chordTolerance = (this.targetView ? (0, CreateElementTool_1.computeChordToleranceFromPoint)(this.targetView, core_geometry_1.Point3d.fromJSON(props.point)) : undefined);
969
- return this.addTangentEdges(id, props.subEntity, chordTolerance);
970
- }
971
- async removeSubEntity(id, props) {
972
- if (!this.addSmooth)
973
- return super.removeSubEntity(id, props);
974
- const edge = (undefined !== props) ? props.subEntity : this.getAcceptedSubEntityData()?.props;
975
- if (undefined === edge)
976
- return;
977
- return this.removeTangentEdges(id, edge);
978
- }
979
- getAcceptedSubEntities() {
980
- const edges = [];
981
- this._acceptedSubEntities.forEach((entry) => {
982
- if (undefined === entry.toolData)
983
- edges.push(entry.props);
984
- });
985
- return edges;
986
- }
987
- }
988
- exports.BlendEdgesTool = BlendEdgesTool;
989
- /** @alpha Identify edges of solids and surfaces to apply a rolling ball blend to. */
990
- class RoundEdgesTool extends BlendEdgesTool {
991
- get radiusProperty() {
992
- if (!this._radiusProperty)
993
- this._radiusProperty = new appui_abstract_1.DialogProperty(new core_frontend_1.LengthDescription("roundRadius", EditTool_1.EditTools.translate("RoundEdges.Label.Radius")), 0.1, undefined);
994
- return this._radiusProperty;
995
- }
996
- get radius() { return this.radiusProperty.value; }
997
- set radius(value) { this.radiusProperty.value = value; }
998
- async applyAgendaOperation(ev, isAccept) {
999
- if (undefined === ev.viewport || this.agenda.isEmpty || !this.haveAcceptedSubEntities)
1000
- return undefined;
1001
- try {
1002
- this._startedCmd = await this.startCommand();
1003
- const params = { edges: this.getAcceptedSubEntities(), radii: this.radius, propagateSmooth: this.addSmooth };
1004
- const opts = {
1005
- wantGraphic: isAccept ? undefined : true,
1006
- chordTolerance: (0, CreateElementTool_1.computeChordToleranceFromPoint)(ev.viewport, ev.point),
1007
- requestId: `${this.toolId}:${this.agenda.elements[0]}`,
1008
- writeChanges: isAccept ? true : undefined,
1009
- };
1010
- return await EditToolIpc_1.solidModelingIpc.blendEdges(this.agenda.elements[0], params, opts);
1011
- }
1012
- catch (err) {
1013
- return undefined;
1014
- }
1015
- }
1016
- async applyToolSettingPropertyChange(updatedValue) {
1017
- if (!this.changeToolSettingPropertyValue(updatedValue))
1018
- return false;
1019
- if (updatedValue.propertyName === this.addSmoothProperty.name)
1020
- await this.syncTangentEdges();
1021
- return true;
1022
- }
1023
- supplyToolSettingsProperties() {
1024
- this.initializeToolSettingPropertyValues([this.radiusProperty, this.addSmoothProperty]);
1025
- const toolSettings = new Array();
1026
- toolSettings.push(this.radiusProperty.toDialogItem({ rowPriority: 1, columnIndex: 0 }));
1027
- toolSettings.push(this.addSmoothProperty.toDialogItem({ rowPriority: 2, columnIndex: 0 }));
1028
- return toolSettings;
1029
- }
1030
- async onRestartTool() {
1031
- const tool = new RoundEdgesTool();
1032
- if (!await tool.run())
1033
- return this.exitTool();
1034
- }
1035
- }
1036
- RoundEdgesTool.toolId = "RoundEdges";
1037
- RoundEdgesTool.iconSpec = "icon-move"; // TODO: Need better icon...
1038
- exports.RoundEdgesTool = RoundEdgesTool;
1039
- /** @alpha Identify edges of solids and surfaces to apply a rolling ball blend to. */
1040
- class ChamferEdgesTool extends BlendEdgesTool {
1041
- static methodMessage(str) { return EditTool_1.EditTools.translate(`ChamferEdges.Method.${str}`); }
1042
- get methodProperty() {
1043
- if (!this._methodProperty)
1044
- this._methodProperty = new appui_abstract_1.DialogProperty(appui_abstract_1.PropertyDescriptionHelper.buildEnumPicklistEditorDescription("chamferMethod", EditTool_1.EditTools.translate("ChamferEdges.Label.Method"), ChamferEdgesTool.getMethodChoices()), editor_common_1.ChamferMode.Length);
1045
- return this._methodProperty;
1046
- }
1047
- get method() { return this.methodProperty.value; }
1048
- set method(method) { this.methodProperty.value = method; }
1049
- get lengthProperty() {
1050
- if (!this._lengthProperty)
1051
- this._lengthProperty = new appui_abstract_1.DialogProperty(new core_frontend_1.LengthDescription("chamferLength", EditTool_1.EditTools.translate("ChamferEdges.Label.Length")), 0.1, undefined);
1052
- return this._lengthProperty;
1053
- }
1054
- get length() { return this.lengthProperty.value; }
1055
- set length(value) { this.lengthProperty.value = value; }
1056
- get distanceLeftProperty() {
1057
- if (!this._distanceLeftProperty)
1058
- this._distanceLeftProperty = new appui_abstract_1.DialogProperty(new core_frontend_1.LengthDescription("chamferLeftDist", EditTool_1.EditTools.translate("ChamferEdges.Label.LeftDistance")), 0.1, undefined);
1059
- return this._distanceLeftProperty;
1060
- }
1061
- get distanceLeft() { return this.distanceLeftProperty.value; }
1062
- set distanceLeft(value) { this.distanceLeftProperty.value = value; }
1063
- get distanceRightProperty() {
1064
- if (!this._distanceRightProperty)
1065
- this._distanceRightProperty = new appui_abstract_1.DialogProperty(new core_frontend_1.LengthDescription("chamferRightDist", EditTool_1.EditTools.translate("ChamferEdges.Label.RightDistance")), 0.1, undefined);
1066
- return this._distanceRightProperty;
1067
- }
1068
- get distanceRight() { return this.distanceRightProperty.value; }
1069
- set distanceRight(value) { this.distanceRightProperty.value = value; }
1070
- get angleProperty() {
1071
- if (!this._angleProperty)
1072
- this._angleProperty = new appui_abstract_1.DialogProperty(new core_frontend_1.AngleDescription("chamferAngle", EditTool_1.EditTools.translate("ChamferEdges.Label.Angle")), core_geometry_1.Angle.piOver4Radians, undefined, false);
1073
- return this._angleProperty;
1074
- }
1075
- get angle() { return this.angleProperty.value; }
1076
- set angle(value) { this.angleProperty.value = value; }
1077
- async applyAgendaOperation(ev, isAccept) {
1078
- if (undefined === ev.viewport || this.agenda.isEmpty || !this.haveAcceptedSubEntities)
1079
- return undefined;
1080
- try {
1081
- this._startedCmd = await this.startCommand();
1082
- let values1;
1083
- let values2;
1084
- switch (this.method) {
1085
- case editor_common_1.ChamferMode.Length:
1086
- values1 = this.length;
1087
- break;
1088
- case editor_common_1.ChamferMode.Distances:
1089
- values1 = this.distanceLeft;
1090
- values2 = this.distanceRight;
1091
- break;
1092
- case editor_common_1.ChamferMode.DistanceAngle:
1093
- values1 = this.distanceLeft;
1094
- values2 = this.angle;
1095
- break;
1096
- case editor_common_1.ChamferMode.AngleDistance:
1097
- values1 = this.angle;
1098
- values2 = this.distanceRight;
1099
- break;
1100
- default:
1101
- return undefined;
1102
- }
1103
- const params = { edges: this.getAcceptedSubEntities(), mode: this.method, values1, values2, propagateSmooth: this.addSmooth };
1104
- const opts = {
1105
- wantGraphic: isAccept ? undefined : true,
1106
- chordTolerance: (0, CreateElementTool_1.computeChordToleranceFromPoint)(ev.viewport, ev.point),
1107
- requestId: `${this.toolId}:${this.agenda.elements[0]}`,
1108
- writeChanges: isAccept ? true : undefined,
1109
- };
1110
- return await EditToolIpc_1.solidModelingIpc.chamferEdges(this.agenda.elements[0], params, opts);
1111
- }
1112
- catch (err) {
1113
- return undefined;
1114
- }
1115
- }
1116
- async applyToolSettingPropertyChange(updatedValue) {
1117
- if (!this.changeToolSettingPropertyValue(updatedValue))
1118
- return false;
1119
- if (updatedValue.propertyName === this.methodProperty.name)
1120
- await this.onReinitialize();
1121
- return true;
1122
- }
1123
- supplyToolSettingsProperties() {
1124
- this.initializeToolSettingPropertyValues([this.methodProperty, this.addSmoothProperty, this.lengthProperty, this.distanceLeftProperty, this.distanceRightProperty, this.angleProperty]);
1125
- const toolSettings = new Array();
1126
- toolSettings.push(this.methodProperty.toDialogItem({ rowPriority: 1, columnIndex: 0 }));
1127
- toolSettings.push(this.addSmoothProperty.toDialogItem({ rowPriority: editor_common_1.ChamferMode.Length === this.method ? 3 : 4, columnIndex: 0 }));
1128
- switch (this.method) {
1129
- case editor_common_1.ChamferMode.Length:
1130
- toolSettings.push(this.lengthProperty.toDialogItem({ rowPriority: 2, columnIndex: 0 }));
1131
- break;
1132
- case editor_common_1.ChamferMode.Distances:
1133
- toolSettings.push(this.distanceLeftProperty.toDialogItem({ rowPriority: 2, columnIndex: 0 }));
1134
- toolSettings.push(this.distanceRightProperty.toDialogItem({ rowPriority: 3, columnIndex: 0 }));
1135
- break;
1136
- case editor_common_1.ChamferMode.DistanceAngle:
1137
- toolSettings.push(this.distanceLeftProperty.toDialogItem({ rowPriority: 2, columnIndex: 0 }));
1138
- toolSettings.push(this.angleProperty.toDialogItem({ rowPriority: 3, columnIndex: 0 }));
1139
- break;
1140
- case editor_common_1.ChamferMode.AngleDistance:
1141
- toolSettings.push(this.distanceRightProperty.toDialogItem({ rowPriority: 2, columnIndex: 0 }));
1142
- toolSettings.push(this.angleProperty.toDialogItem({ rowPriority: 3, columnIndex: 0 }));
1143
- break;
1144
- }
1145
- return toolSettings;
1146
- }
1147
- async onRestartTool() {
1148
- const tool = new ChamferEdgesTool();
1149
- if (!await tool.run())
1150
- return this.exitTool();
1151
- }
1152
- }
1153
- ChamferEdgesTool.toolId = "ChamferEdges";
1154
- ChamferEdgesTool.iconSpec = "icon-move"; // TODO: Need better icon...
1155
- ChamferEdgesTool.getMethodChoices = () => {
1156
- return [
1157
- { label: ChamferEdgesTool.methodMessage("Length"), value: editor_common_1.ChamferMode.Length },
1158
- { label: ChamferEdgesTool.methodMessage("Distances"), value: editor_common_1.ChamferMode.Distances },
1159
- { label: ChamferEdgesTool.methodMessage("DistanceAngle"), value: editor_common_1.ChamferMode.DistanceAngle },
1160
- { label: ChamferEdgesTool.methodMessage("AngleDistance"), value: editor_common_1.ChamferMode.AngleDistance },
1161
- ];
1162
- };
1163
- exports.ChamferEdgesTool = ChamferEdgesTool;
1164
- /** @alpha */
1165
- class ProfileLocationData {
1166
- constructor(point, orientation) {
1167
- this.point = point;
1168
- this.orientation = orientation;
1169
- }
1170
- }
1171
- exports.ProfileLocationData = ProfileLocationData;
1172
- /** @alpha Base class for picking profiles (open paths and regions) or faces of solids. */
1173
- class LocateFaceOrProfileTool extends ElementGeometryTool_1.LocateSubEntityTool {
1174
- get wantGeometrySummary() { return true; }
1175
- wantSubEntityType(type) {
1176
- switch (type) {
1177
- case editor_common_1.SubEntityType.Face:
1178
- case editor_common_1.SubEntityType.Edge:
1179
- // Choose all faces or all edges...
1180
- return (0 === this._acceptedSubEntities.length || this._acceptedSubEntities[0].props.type === type);
1181
- default:
1182
- return false;
1183
- }
1184
- }
1185
- get geometryCacheFilter() {
1186
- return { parts: true, curves: true, surfaces: true, solids: true, other: false };
1187
- }
1188
- async doPickSubEntities(id, ev) {
1189
- const hits = await super.doPickSubEntities(id, ev);
1190
- if (undefined === hits)
1191
- return hits;
1192
- // Only want edges from wire bodies...
1193
- const accept = (editor_common_1.BRepEntityType.Wire === this.getBRepEntityTypeForSubEntity(id, hits[0].subEntity) ? editor_common_1.SubEntityType.Edge : editor_common_1.SubEntityType.Face);
1194
- return hits.filter((hit) => accept === hit.subEntity.type);
1195
- }
1196
- async createSubEntityData(id, hit) {
1197
- const data = await super.createSubEntityData(id, hit);
1198
- // Prefer orientation from snap to take entire path curve as well as placement z into account...
1199
- const snap = core_frontend_1.TentativeOrAccuSnap.getCurrentSnap(false);
1200
- const point = (id === snap?.sourceId && snap.isHot ? snap.snapPoint : core_geometry_1.Point3d.fromJSON(hit.point));
1201
- const matrix = (id === snap?.sourceId ? core_frontend_1.AccuDraw.getSnapRotation(snap, undefined) : undefined);
1202
- const invMatrix = matrix?.inverse(); // getSnapRotation returns row matrix...
1203
- if (undefined !== invMatrix)
1204
- data.toolData = new ProfileLocationData(point, invMatrix);
1205
- else
1206
- data.toolData = new ProfileLocationData(point, undefined !== hit.normal ? core_geometry_1.Vector3d.fromJSON(hit.normal) : core_geometry_1.Vector3d.unitZ());
1207
- return data;
1208
- }
1209
- drawSubEntity(context, subEntity, accepted) {
1210
- const id = this.getCurrentElement();
1211
- if (undefined !== id && editor_common_1.BRepEntityType.Solid !== this.getBRepEntityTypeForSubEntity(id, subEntity.props))
1212
- return; // Operation will be applied to wire or sheet body, don't display sub-entity...
1213
- super.drawSubEntity(context, subEntity, accepted);
1214
- }
1215
- drawAcceptedSubEntities(context) {
1216
- super.drawAcceptedSubEntities(context);
1217
- // Show pick point on last identified face...
1218
- const profileData = this.getAcceptedSubEntityData()?.toolData;
1219
- if (undefined === profileData)
1220
- return;
1221
- const builder = context.createGraphic({ type: core_frontend_1.GraphicType.WorldOverlay });
1222
- builder.setSymbology(context.viewport.getContrastToBackgroundColor(), core_common_1.ColorDef.black, 10);
1223
- builder.addPointString([profileData.point]);
1224
- context.addDecorationFromBuilder(builder);
1225
- }
1226
- }
1227
- exports.LocateFaceOrProfileTool = LocateFaceOrProfileTool;
1228
- /** @alpha Identify faces of solids and surfaces to translate. */
1229
- class SweepFacesTool extends LocateFaceOrProfileTool {
1230
- get wantDynamics() { return true; }
1231
- get wantAccuSnap() { return true; }
1232
- get wantSubEntitySnap() { return true; }
1233
- get addSmoothProperty() {
1234
- if (!this._addSmoothProperty)
1235
- this._addSmoothProperty = new appui_abstract_1.DialogProperty(appui_abstract_1.PropertyDescriptionHelper.buildToggleDescription("sweepSmooth", EditTool_1.EditTools.translate("SweepFaces.Label.AddSmooth")), false);
1236
- return this._addSmoothProperty;
1237
- }
1238
- get addSmooth() { return this.addSmoothProperty.value; }
1239
- set addSmooth(value) { this.addSmoothProperty.value = value; }
1240
- get useDistanceProperty() {
1241
- if (!this._useDistanceProperty)
1242
- this._useDistanceProperty = new appui_abstract_1.DialogProperty(appui_abstract_1.PropertyDescriptionHelper.buildLockPropertyDescription("useOffsetDistance"), false);
1243
- return this._useDistanceProperty;
1244
- }
1245
- get useDistance() { return this.useDistanceProperty.value; }
1246
- set useDistance(value) { this.useDistanceProperty.value = value; }
1247
- get distanceProperty() {
1248
- if (!this._distanceProperty)
1249
- this._distanceProperty = new appui_abstract_1.DialogProperty(new core_frontend_1.LengthDescription("sweepDistance", EditTool_1.EditTools.translate("SweepFaces.Label.Distance")), 0.1, undefined, !this.useDistance);
1250
- return this._distanceProperty;
1251
- }
1252
- get distance() { return this.distanceProperty.value; }
1253
- set distance(value) { this.distanceProperty.value = value; }
1254
- async getSmoothFaces(id, face) {
1255
- try {
1256
- // NOTE: For sweep/translation, it makes sense to limit smooth to immediately adjacent...
1257
- return await EditToolIpc_1.solidModelingIpc.getConnectedSubEntities(id, face, editor_common_1.SubEntityType.Face, { smoothFaces: true, adjacentFaces: true });
1258
- }
1259
- catch (err) {
1260
- return undefined;
1261
- }
1262
- }
1263
- async applyAgendaOperation(ev, isAccept) {
1264
- if (undefined === ev.viewport || this.agenda.isEmpty || !this.haveAcceptedSubEntities)
1265
- return undefined;
1266
- const profileData = this.getAcceptedSubEntityData()?.toolData;
1267
- if (undefined === profileData)
1268
- return undefined;
1269
- const path = core_geometry_1.Vector3d.createStartEnd(profileData.point, ev.point);
1270
- if (this.useDistance && undefined === path.scaleToLength(this.distance, path))
1271
- return undefined;
1272
- if (path.magnitude() < core_geometry_1.Geometry.smallMetricDistance)
1273
- return undefined;
1274
- if (!this.useDistance) {
1275
- this.distance = path.magnitude();
1276
- this.syncToolSettingPropertyValue(this.distanceProperty);
1277
- if (isAccept)
1278
- this.saveToolSettingPropertyValue(this.distanceProperty, this.distanceProperty.dialogItemValue);
1279
- }
1280
- try {
1281
- this._startedCmd = await this.startCommand();
1282
- const id = this.agenda.elements[0];
1283
- const opts = {
1284
- wantGraphic: isAccept ? undefined : true,
1285
- chordTolerance: (0, CreateElementTool_1.computeChordToleranceFromPoint)(ev.viewport, ev.point),
1286
- requestId: `${this.toolId}:${id}`,
1287
- writeChanges: isAccept ? true : undefined,
1288
- };
1289
- const subEntities = this.getAcceptedSubEntities();
1290
- const params = { path };
1291
- if (editor_common_1.SubEntityType.Edge === subEntities[0].type || editor_common_1.BRepEntityType.Solid !== this.getBRepEntityTypeForSubEntity(id, subEntities[0])) {
1292
- return await EditToolIpc_1.solidModelingIpc.sweepFaces(id, params, opts);
1293
- }
1294
- if (this.addSmooth) {
1295
- const allSmoothFaces = [];
1296
- for (const face of subEntities) {
1297
- const smoothFaces = await this.getSmoothFaces(id, face);
1298
- if (undefined !== smoothFaces)
1299
- allSmoothFaces.push(...smoothFaces);
1300
- }
1301
- for (const smooth of allSmoothFaces) {
1302
- if (undefined === subEntities.find((selected) => (0, ElementGeometryTool_1.isSameSubEntity)(selected, smooth)))
1303
- subEntities.unshift(smooth); // Preserve last selected entry as reference face...
1304
- }
1305
- }
1306
- params.faces = subEntities;
1307
- return await EditToolIpc_1.solidModelingIpc.sweepFaces(id, params, opts);
1308
- }
1309
- catch (err) {
1310
- return undefined;
1311
- }
1312
- }
1313
- setupAccuDraw() {
1314
- if (!this.haveAcceptedSubEntities)
1315
- return;
1316
- const profileData = this.getAcceptedSubEntityData()?.toolData;
1317
- if (undefined === profileData)
1318
- return;
1319
- const hints = new core_frontend_1.AccuDrawHintBuilder();
1320
- hints.setOriginFixed = true;
1321
- hints.setLockY = true;
1322
- hints.setLockZ = true;
1323
- hints.setModeRectangular();
1324
- hints.setOrigin(profileData.point);
1325
- hints.setXAxis2(profileData.orientation instanceof core_geometry_1.Matrix3d ? profileData.orientation.getColumn(2) : profileData.orientation);
1326
- hints.sendHints(false);
1327
- }
1328
- async applyToolSettingPropertyChange(updatedValue) {
1329
- return this.changeToolSettingPropertyValue(updatedValue);
1330
- }
1331
- supplyToolSettingsProperties() {
1332
- this.initializeToolSettingPropertyValues([this.addSmoothProperty, this.useDistanceProperty, this.distanceProperty]);
1333
- const toolSettings = new Array();
1334
- // ensure controls are enabled/disabled based on current lock property state
1335
- this.distanceProperty.isDisabled = !this.useDistance;
1336
- const useDistanceLock = this.useDistanceProperty.toDialogItem({ rowPriority: 1, columnIndex: 0 });
1337
- toolSettings.push(this.distanceProperty.toDialogItem({ rowPriority: 1, columnIndex: 1 }, useDistanceLock));
1338
- toolSettings.push(this.addSmoothProperty.toDialogItem({ rowPriority: 2, columnIndex: 0 }));
1339
- return toolSettings;
1340
- }
1341
- async onRestartTool() {
1342
- const tool = new SweepFacesTool();
1343
- if (!await tool.run())
1344
- return this.exitTool();
1345
- }
1346
- }
1347
- SweepFacesTool.toolId = "SweepFaces";
1348
- SweepFacesTool.iconSpec = "icon-move"; // TODO: Need better icon...
1349
- exports.SweepFacesTool = SweepFacesTool;
1350
- /** @alpha Identify faces of solids and surfaces to revolve. */
1351
- class SpinFacesTool extends LocateFaceOrProfileTool {
1352
- constructor() {
1353
- super(...arguments);
1354
- this.points = [];
1355
- }
1356
- get angleProperty() {
1357
- if (!this._angleProperty)
1358
- this._angleProperty = new appui_abstract_1.DialogProperty(new core_frontend_1.AngleDescription("spinAngle", EditTool_1.EditTools.translate("SpinFaces.Label.Angle")), core_geometry_1.Angle.piOver2Radians, undefined, false);
1359
- return this._angleProperty;
1360
- }
1361
- get angle() { return this.angleProperty.value; }
1362
- set angle(value) { this.angleProperty.value = value; }
1363
- get wantDynamics() { return true; }
1364
- get wantAccuSnap() { return true; }
1365
- get wantSubEntitySnap() { return true; }
1366
- async applyAgendaOperation(ev, isAccept) {
1367
- if (undefined === ev.viewport || this.agenda.isEmpty || !this.haveAcceptedSubEntities || this.points.length < (isAccept ? 2 : 1))
1368
- return undefined;
1369
- const direction = core_geometry_1.Vector3d.createStartEnd(this.points[0], isAccept ? this.points[1] : ev.point);
1370
- if (direction.magnitude() < core_geometry_1.Geometry.smallMetricDistance)
1371
- return undefined;
1372
- const origin = this.points[0];
1373
- const angle = core_geometry_1.Angle.createRadians(this.angle);
1374
- try {
1375
- this._startedCmd = await this.startCommand();
1376
- const id = this.agenda.elements[0];
1377
- const opts = {
1378
- wantGraphic: isAccept ? undefined : true,
1379
- chordTolerance: (0, CreateElementTool_1.computeChordToleranceFromPoint)(ev.viewport, ev.point),
1380
- requestId: `${this.toolId}:${id}`,
1381
- writeChanges: isAccept ? true : undefined,
1382
- };
1383
- const subEntities = this.getAcceptedSubEntities();
1384
- const params = { origin, direction, angle };
1385
- if (editor_common_1.SubEntityType.Edge === subEntities[0].type || editor_common_1.BRepEntityType.Solid !== this.getBRepEntityTypeForSubEntity(id, subEntities[0])) {
1386
- return await EditToolIpc_1.solidModelingIpc.spinFaces(id, params, opts);
1387
- }
1388
- params.faces = subEntities;
1389
- let result = await EditToolIpc_1.solidModelingIpc.spinFaces(id, params, opts);
1390
- // Spun face can be used to create a pocket...retry with negative sweep...
1391
- if (undefined === result) {
1392
- angle.setRadians(-angle.radians);
1393
- result = await EditToolIpc_1.solidModelingIpc.spinFaces(id, params, opts);
1394
- }
1395
- return result;
1396
- }
1397
- catch (err) {
1398
- return undefined;
1399
- }
1400
- }
1401
- onDynamicFrame(ev, context) {
1402
- if (0 === this.points.length)
1403
- return;
1404
- const pts = this.points.slice();
1405
- pts.push(ev.point.clone());
1406
- const builder = context.createGraphic({ type: core_frontend_1.GraphicType.WorldOverlay });
1407
- builder.setSymbology(context.viewport.getContrastToBackgroundColor(), core_common_1.ColorDef.black, 3);
1408
- builder.addLineString(pts);
1409
- context.addGraphic(builder.finish());
1410
- super.onDynamicFrame(ev, context);
1411
- }
1412
- async gatherInput(ev) {
1413
- if (!this.wantAdditionalSubEntities)
1414
- this.points.push(ev.point.clone());
1415
- return super.gatherInput(ev);
1416
- }
1417
- get wantAdditionalInput() {
1418
- return super.wantAdditionalInput || this.points.length < 2;
1419
- }
1420
- setupAccuDraw() {
1421
- if (!this.haveAcceptedSubEntities || 0 !== this.points.length)
1422
- return;
1423
- const profileData = this.getAcceptedSubEntityData()?.toolData;
1424
- if (undefined === profileData)
1425
- return;
1426
- const hints = new core_frontend_1.AccuDrawHintBuilder();
1427
- hints.setModeRectangular();
1428
- hints.setOrigin(profileData.point);
1429
- if (profileData.orientation instanceof core_geometry_1.Matrix3d)
1430
- hints.setMatrix(profileData.orientation);
1431
- else
1432
- hints.setNormal(profileData.orientation);
1433
- hints.sendHints(false);
1434
- }
1435
- async applyToolSettingPropertyChange(updatedValue) {
1436
- return this.changeToolSettingPropertyValue(updatedValue);
1437
- }
1438
- supplyToolSettingsProperties() {
1439
- this.initializeToolSettingPropertyValues([this.angleProperty]);
1440
- const toolSettings = new Array();
1441
- toolSettings.push(this.angleProperty.toDialogItem({ rowPriority: 1, columnIndex: 0 }));
1442
- return toolSettings;
1443
- }
1444
- async onRestartTool() {
1445
- const tool = new SpinFacesTool();
1446
- if (!await tool.run())
1447
- return this.exitTool();
1448
- }
1449
- }
1450
- SpinFacesTool.toolId = "SpinFaces";
1451
- SpinFacesTool.iconSpec = "icon-move"; // TODO: Need better icon...
1452
- exports.SpinFacesTool = SpinFacesTool;
1453
- //# sourceMappingURL=SolidModelingTools.js.map