@itwin/editor-frontend 3.3.0-dev.4 → 3.3.0-dev.40
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.
- package/CHANGELOG.md +19 -1
- package/lib/cjs/CreateElementTool.d.ts +25 -1
- package/lib/cjs/CreateElementTool.d.ts.map +1 -1
- package/lib/cjs/CreateElementTool.js +89 -2
- package/lib/cjs/CreateElementTool.js.map +1 -1
- package/lib/cjs/EditTool.d.ts +1 -0
- package/lib/cjs/EditTool.d.ts.map +1 -1
- package/lib/cjs/EditTool.js +9 -0
- package/lib/cjs/EditTool.js.map +1 -1
- package/lib/cjs/SketchTools.d.ts +14 -23
- package/lib/cjs/SketchTools.d.ts.map +1 -1
- package/lib/cjs/SketchTools.js +59 -104
- package/lib/cjs/SketchTools.js.map +1 -1
- package/lib/cjs/SolidPrimitiveTools.d.ts +155 -0
- package/lib/cjs/SolidPrimitiveTools.d.ts.map +1 -0
- package/lib/cjs/SolidPrimitiveTools.js +605 -0
- package/lib/cjs/SolidPrimitiveTools.js.map +1 -0
- package/lib/cjs/editor-frontend.d.ts +1 -0
- package/lib/cjs/editor-frontend.d.ts.map +1 -1
- package/lib/cjs/editor-frontend.js +1 -0
- package/lib/cjs/editor-frontend.js.map +1 -1
- package/lib/esm/CreateElementTool.d.ts +25 -1
- package/lib/esm/CreateElementTool.d.ts.map +1 -1
- package/lib/esm/CreateElementTool.js +88 -2
- package/lib/esm/CreateElementTool.js.map +1 -1
- package/lib/esm/EditTool.d.ts +1 -0
- package/lib/esm/EditTool.d.ts.map +1 -1
- package/lib/esm/EditTool.js +9 -0
- package/lib/esm/EditTool.js.map +1 -1
- package/lib/esm/SketchTools.d.ts +14 -23
- package/lib/esm/SketchTools.d.ts.map +1 -1
- package/lib/esm/SketchTools.js +60 -105
- package/lib/esm/SketchTools.js.map +1 -1
- package/lib/esm/SolidPrimitiveTools.d.ts +155 -0
- package/lib/esm/SolidPrimitiveTools.d.ts.map +1 -0
- package/lib/esm/SolidPrimitiveTools.js +598 -0
- package/lib/esm/SolidPrimitiveTools.js.map +1 -0
- package/lib/esm/editor-frontend.d.ts +1 -0
- package/lib/esm/editor-frontend.d.ts.map +1 -1
- package/lib/esm/editor-frontend.js +1 -0
- package/lib/esm/editor-frontend.js.map +1 -1
- package/lib/public/locales/en/Editor.json +44 -0
- package/package.json +12 -12
|
@@ -0,0 +1,605 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CreateConeTool = exports.CreateConePhase = exports.CreateCylinderTool = exports.CreateCylinderPhase = exports.CreateSphereTool = exports.SolidPrimitiveTool = void 0;
|
|
4
|
+
/*---------------------------------------------------------------------------------------------
|
|
5
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
6
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
7
|
+
*--------------------------------------------------------------------------------------------*/
|
|
8
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
9
|
+
const core_geometry_1 = require("@itwin/core-geometry");
|
|
10
|
+
const core_common_1 = require("@itwin/core-common");
|
|
11
|
+
const core_frontend_1 = require("@itwin/core-frontend");
|
|
12
|
+
const editor_common_1 = require("@itwin/editor-common");
|
|
13
|
+
const CreateElementTool_1 = require("./CreateElementTool");
|
|
14
|
+
const EditTool_1 = require("./EditTool");
|
|
15
|
+
const appui_abstract_1 = require("@itwin/appui-abstract");
|
|
16
|
+
/** @alpha Base class for creating a capped or uncapped SolidPrimitive. */
|
|
17
|
+
class SolidPrimitiveTool extends CreateElementTool_1.CreateElementWithDynamicsTool {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
this.accepted = [];
|
|
21
|
+
}
|
|
22
|
+
allowView(vp) { return vp.view.is3d(); }
|
|
23
|
+
isCompatibleViewport(vp, isSelectedViewChange) { return (super.isCompatibleViewport(vp, isSelectedViewChange) && undefined !== vp && this.allowView(vp)); }
|
|
24
|
+
async startCommand() {
|
|
25
|
+
if (undefined !== this._startedCmd)
|
|
26
|
+
return this._startedCmd;
|
|
27
|
+
return EditTool_1.EditTools.startCommand(editor_common_1.editorBuiltInCmdIds.cmdBasicManipulation, this.iModel.key);
|
|
28
|
+
}
|
|
29
|
+
static callCommand(method, ...args) {
|
|
30
|
+
return EditTool_1.EditTools.callCommand(method, ...args);
|
|
31
|
+
}
|
|
32
|
+
getPlacementProps() {
|
|
33
|
+
if (undefined === this.current)
|
|
34
|
+
return undefined;
|
|
35
|
+
const localToWorld = ("solid" === this.current.geometryCategory ? this.current.getConstructiveFrame() : core_geometry_1.FrameBuilder.createRightHandedFrame(undefined, this.current));
|
|
36
|
+
if (undefined === localToWorld)
|
|
37
|
+
return undefined;
|
|
38
|
+
const origin = localToWorld.getOrigin();
|
|
39
|
+
const angles = new core_geometry_1.YawPitchRollAngles();
|
|
40
|
+
core_geometry_1.YawPitchRollAngles.createFromMatrix3d(localToWorld.matrix, angles);
|
|
41
|
+
return { origin, angles };
|
|
42
|
+
}
|
|
43
|
+
getGeometryProps(placement) {
|
|
44
|
+
if (undefined === this.current)
|
|
45
|
+
return undefined;
|
|
46
|
+
const builder = new core_common_1.ElementGeometry.Builder();
|
|
47
|
+
builder.setLocalToWorldFromPlacement(placement);
|
|
48
|
+
if (!builder.appendGeometryQuery(this.current))
|
|
49
|
+
return;
|
|
50
|
+
return { format: "flatbuffer", data: builder.entries };
|
|
51
|
+
}
|
|
52
|
+
getElementProps(placement) {
|
|
53
|
+
const model = this.targetModelId;
|
|
54
|
+
const category = this.targetCategory;
|
|
55
|
+
return { classFullName: "Generic:PhysicalObject", model, category, code: core_common_1.Code.createEmpty(), placement };
|
|
56
|
+
}
|
|
57
|
+
async doCreateElement(props, data) {
|
|
58
|
+
try {
|
|
59
|
+
this._startedCmd = await this.startCommand();
|
|
60
|
+
await SolidPrimitiveTool.callCommand("insertGeometricElement", props, data);
|
|
61
|
+
await this.saveChanges();
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
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."));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
exports.SolidPrimitiveTool = SolidPrimitiveTool;
|
|
69
|
+
/** @alpha Creates a sphere. Uses model and category from [[BriefcaseConnection.editorToolSettings]]. */
|
|
70
|
+
class CreateSphereTool extends SolidPrimitiveTool {
|
|
71
|
+
provideToolAssistance(mainInstrText, additionalInstr) {
|
|
72
|
+
mainInstrText = EditTool_1.EditTools.translate(0 === this.accepted.length ? "CreateSphere.Prompts.CenterPoint" : "CreateSphere.Prompts.RadiusPoint");
|
|
73
|
+
super.provideToolAssistance(mainInstrText, additionalInstr);
|
|
74
|
+
}
|
|
75
|
+
setupAccuDraw() {
|
|
76
|
+
const nPts = this.accepted.length;
|
|
77
|
+
if (0 === nPts)
|
|
78
|
+
return;
|
|
79
|
+
const hints = new core_frontend_1.AccuDrawHintBuilder();
|
|
80
|
+
hints.setModePolar();
|
|
81
|
+
hints.setOrigin(this.accepted[0]);
|
|
82
|
+
hints.setOriginFixed = true;
|
|
83
|
+
hints.sendHints();
|
|
84
|
+
}
|
|
85
|
+
get useRadiusProperty() {
|
|
86
|
+
if (!this._useRadiusProperty)
|
|
87
|
+
this._useRadiusProperty = new appui_abstract_1.DialogProperty(appui_abstract_1.PropertyDescriptionHelper.buildLockPropertyDescription("useSphereRadius"), false);
|
|
88
|
+
return this._useRadiusProperty;
|
|
89
|
+
}
|
|
90
|
+
get useRadius() { return this.useRadiusProperty.value; }
|
|
91
|
+
set useRadius(value) { this.useRadiusProperty.value = value; }
|
|
92
|
+
get radiusProperty() {
|
|
93
|
+
if (!this._radiusProperty)
|
|
94
|
+
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);
|
|
95
|
+
return this._radiusProperty;
|
|
96
|
+
}
|
|
97
|
+
get radius() { return this.radiusProperty.value; }
|
|
98
|
+
set radius(value) { this.radiusProperty.value = value; }
|
|
99
|
+
get cappedProperty() {
|
|
100
|
+
if (!this._cappedProperty)
|
|
101
|
+
this._cappedProperty = new appui_abstract_1.DialogProperty(appui_abstract_1.PropertyDescriptionHelper.buildToggleDescription("sphereCapped", EditTool_1.EditTools.translate("CreateSphere.Label.Capped")), true);
|
|
102
|
+
return this._cappedProperty;
|
|
103
|
+
}
|
|
104
|
+
get capped() { return this.cappedProperty.value; }
|
|
105
|
+
set capped(value) { this.cappedProperty.value = value; }
|
|
106
|
+
isComplete(_ev) {
|
|
107
|
+
return (2 === this.accepted.length);
|
|
108
|
+
}
|
|
109
|
+
async updateElementData(ev, isDynamics) {
|
|
110
|
+
const vp = this.targetView;
|
|
111
|
+
if (undefined === vp)
|
|
112
|
+
return;
|
|
113
|
+
if (0 === this.accepted.length) {
|
|
114
|
+
if (!isDynamics)
|
|
115
|
+
this.accepted.push(ev.point.clone());
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
const pt1 = this.accepted[0];
|
|
119
|
+
const pt2 = ev.point;
|
|
120
|
+
const vector0 = core_geometry_1.Vector3d.createStartEnd(pt1, pt2);
|
|
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(pt1, 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
|
+
exports.CreateSphereTool = CreateSphereTool;
|
|
163
|
+
CreateSphereTool.toolId = "CreateSphere";
|
|
164
|
+
CreateSphereTool.iconSpec = "icon-circle"; // TODO: Need better icon...
|
|
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(ev.point.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 || undefined === this.current)
|
|
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
|
+
exports.CreateCylinderTool = CreateCylinderTool;
|
|
358
|
+
CreateCylinderTool.toolId = "CreateCylinder";
|
|
359
|
+
CreateCylinderTool.iconSpec = "icon-circle"; // TODO: Need better icon...
|
|
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
|
+
var _a;
|
|
481
|
+
const vp = this.targetView;
|
|
482
|
+
if (undefined === vp)
|
|
483
|
+
return;
|
|
484
|
+
const pt1 = (0 === this.accepted.length ? ev.point : this.accepted[0]);
|
|
485
|
+
const pt2 = ev.point;
|
|
486
|
+
switch (this.createPhase) {
|
|
487
|
+
case CreateConePhase.AcceptBase: {
|
|
488
|
+
if (isDynamics)
|
|
489
|
+
break;
|
|
490
|
+
// Allow creating cone by 2 points when orthogonal and base/top radii are locked...
|
|
491
|
+
this.accepted.push(ev.point.clone());
|
|
492
|
+
this.createPhase = (this.orthogonal && this.useBaseRadius ? CreateConePhase.AcceptLength : CreateConePhase.AcceptBaseRadius);
|
|
493
|
+
break;
|
|
494
|
+
}
|
|
495
|
+
case CreateConePhase.AcceptBaseRadius: {
|
|
496
|
+
this.baseRotation = core_frontend_1.AccuDrawHintBuilder.getCurrentRotation(vp, true, true);
|
|
497
|
+
const normal = this.baseRotation ? this.baseRotation.getColumn(2) : core_geometry_1.Vector3d.unitZ();
|
|
498
|
+
const vector0 = core_geometry_1.Vector3d.createStartEnd(pt1, pt2);
|
|
499
|
+
const vector90 = normal.crossProduct(vector0);
|
|
500
|
+
const radius = (this.useBaseRadius ? this.baseRadius : vector0.magnitude());
|
|
501
|
+
if (!this.useBaseRadius) {
|
|
502
|
+
this.baseRadius = radius;
|
|
503
|
+
this.syncToolSettingPropertyValue(this.baseRadiusProperty);
|
|
504
|
+
}
|
|
505
|
+
if (undefined === vector0.scaleToLength(radius, vector0) || undefined === vector90.scaleToLength(radius, vector90)) {
|
|
506
|
+
this.current = undefined;
|
|
507
|
+
this.clearGraphics();
|
|
508
|
+
return;
|
|
509
|
+
}
|
|
510
|
+
const arc = core_geometry_1.Arc3d.create(pt1, vector0, vector90);
|
|
511
|
+
this.baseRotation = core_geometry_1.Matrix3d.createRigidFromMatrix3d(arc.matrixRef); // Update base rotation from result arc...
|
|
512
|
+
this.current = (this.capped ? core_geometry_1.Loop.create(arc) : arc);
|
|
513
|
+
if (isDynamics || undefined === this.current)
|
|
514
|
+
break;
|
|
515
|
+
this.createPhase = CreateConePhase.AcceptLength;
|
|
516
|
+
break;
|
|
517
|
+
}
|
|
518
|
+
case CreateConePhase.AcceptLength: {
|
|
519
|
+
const zAxis = core_geometry_1.Vector3d.createStartEnd(pt1, pt2);
|
|
520
|
+
const length = (this.useLength ? this.length : zAxis.magnitude());
|
|
521
|
+
if (!this.useLength) {
|
|
522
|
+
this.length = length;
|
|
523
|
+
this.syncToolSettingPropertyValue(this.lengthProperty);
|
|
524
|
+
}
|
|
525
|
+
// Establish base rotation when creating cone by 2 points...
|
|
526
|
+
if (undefined === this.baseRotation)
|
|
527
|
+
this.baseRotation = core_frontend_1.AccuDrawHintBuilder.getCurrentRotation(vp, true, true);
|
|
528
|
+
const xAxis = this.baseRotation ? this.baseRotation.getColumn(0) : core_geometry_1.Vector3d.unitX();
|
|
529
|
+
const yAxis = this.baseRotation ? this.baseRotation.getColumn(1) : core_geometry_1.Vector3d.unitY();
|
|
530
|
+
if (undefined === zAxis.scaleToLength(length, zAxis)) {
|
|
531
|
+
xAxis.scaleToLength(this.baseRadius, xAxis);
|
|
532
|
+
yAxis.scaleToLength(this.baseRadius, yAxis);
|
|
533
|
+
const baseArc = core_geometry_1.Arc3d.create(pt1, xAxis, yAxis);
|
|
534
|
+
this.current = (this.capped ? core_geometry_1.Loop.create(baseArc) : baseArc);
|
|
535
|
+
return;
|
|
536
|
+
}
|
|
537
|
+
if (this.orthogonal)
|
|
538
|
+
this.current = core_geometry_1.Cone.createAxisPoints(pt1, pt1.plus(zAxis), this.baseRadius, this.useTopRadius ? this.topRadius : 0.0, this.capped);
|
|
539
|
+
else
|
|
540
|
+
this.current = core_geometry_1.Cone.createBaseAndTarget(pt1, pt1.plus(zAxis), xAxis, yAxis, this.baseRadius, this.useTopRadius ? this.topRadius : 0.0, this.capped);
|
|
541
|
+
if (isDynamics || undefined === this.current)
|
|
542
|
+
break;
|
|
543
|
+
const localToWorld = this.current.getConstructiveFrame();
|
|
544
|
+
if (undefined !== localToWorld)
|
|
545
|
+
this.baseRotation = localToWorld.matrix; // Update base rotation from result for AccuDraw hints...
|
|
546
|
+
this.accepted.push(this.current.getCenterB()); // Add top center to accepted points for AccuDraw hints...
|
|
547
|
+
this.createPhase = this.useTopRadius ? CreateConePhase.AcceptResult : CreateConePhase.AcceptTopRadius;
|
|
548
|
+
break;
|
|
549
|
+
}
|
|
550
|
+
case CreateConePhase.AcceptTopRadius: {
|
|
551
|
+
const cone = ("solid" === ((_a = this.current) === null || _a === void 0 ? void 0 : _a.geometryCategory) ? this.current : undefined);
|
|
552
|
+
if (undefined === cone)
|
|
553
|
+
break;
|
|
554
|
+
const vector0 = core_geometry_1.Vector3d.createStartEnd(cone.getCenterB(), ev.point);
|
|
555
|
+
const radius = (this.useTopRadius ? this.topRadius : vector0.magnitude());
|
|
556
|
+
if (!this.useTopRadius) {
|
|
557
|
+
this.topRadius = radius;
|
|
558
|
+
this.syncToolSettingPropertyValue(this.topRadiusProperty);
|
|
559
|
+
}
|
|
560
|
+
this.current = core_geometry_1.Cone.createBaseAndTarget(cone.getCenterA(), cone.getCenterB(), cone.getVectorX(), cone.getVectorY(), cone.getRadiusA(), radius, this.capped);
|
|
561
|
+
if (isDynamics || undefined === this.current)
|
|
562
|
+
break;
|
|
563
|
+
this.createPhase = CreateConePhase.AcceptResult;
|
|
564
|
+
break;
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
getToolSettingPropertyLocked(property) {
|
|
569
|
+
if (property === this.useBaseRadiusProperty)
|
|
570
|
+
return this.baseRadiusProperty;
|
|
571
|
+
else if (property === this.useTopRadiusProperty)
|
|
572
|
+
return this.topRadiusProperty;
|
|
573
|
+
else if (property === this.useLengthProperty)
|
|
574
|
+
return this.lengthProperty;
|
|
575
|
+
return undefined;
|
|
576
|
+
}
|
|
577
|
+
async applyToolSettingPropertyChange(updatedValue) {
|
|
578
|
+
return this.changeToolSettingPropertyValue(updatedValue);
|
|
579
|
+
}
|
|
580
|
+
supplyToolSettingsProperties() {
|
|
581
|
+
this.initializeToolSettingPropertyValues([this.baseRadiusProperty, this.useBaseRadiusProperty, this.topRadiusProperty, this.useTopRadiusProperty, this.lengthProperty, this.useLengthProperty, this.orthogonalProperty, this.cappedProperty]);
|
|
582
|
+
const toolSettings = new Array();
|
|
583
|
+
this.baseRadiusProperty.isDisabled = !this.useBaseRadius;
|
|
584
|
+
const useBaseRadiusLock = this.useBaseRadiusProperty.toDialogItem({ rowPriority: 1, columnIndex: 0 });
|
|
585
|
+
toolSettings.push(this.baseRadiusProperty.toDialogItem({ rowPriority: 1, columnIndex: 1 }, useBaseRadiusLock));
|
|
586
|
+
this.topRadiusProperty.isDisabled = !this.useTopRadius;
|
|
587
|
+
const useTopRadiusLock = this.useTopRadiusProperty.toDialogItem({ rowPriority: 1, columnIndex: 0 });
|
|
588
|
+
toolSettings.push(this.topRadiusProperty.toDialogItem({ rowPriority: 2, columnIndex: 1 }, useTopRadiusLock));
|
|
589
|
+
this.lengthProperty.isDisabled = !this.useLength;
|
|
590
|
+
const useLengthLock = this.useLengthProperty.toDialogItem({ rowPriority: 3, columnIndex: 0 });
|
|
591
|
+
toolSettings.push(this.lengthProperty.toDialogItem({ rowPriority: 3, columnIndex: 1 }, useLengthLock));
|
|
592
|
+
toolSettings.push(this.orthogonalProperty.toDialogItem({ rowPriority: 4, columnIndex: 0 }));
|
|
593
|
+
toolSettings.push(this.cappedProperty.toDialogItem({ rowPriority: 5, columnIndex: 0 }));
|
|
594
|
+
return toolSettings;
|
|
595
|
+
}
|
|
596
|
+
async onRestartTool() {
|
|
597
|
+
const tool = new CreateConeTool();
|
|
598
|
+
if (!await tool.run())
|
|
599
|
+
return this.exitTool();
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
exports.CreateConeTool = CreateConeTool;
|
|
603
|
+
CreateConeTool.toolId = "CreateCone";
|
|
604
|
+
CreateConeTool.iconSpec = "icon-circle"; // TODO: Need better icon...
|
|
605
|
+
//# sourceMappingURL=SolidPrimitiveTools.js.map
|