@itwin/editor-frontend 4.5.0-dev.9 → 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.
- package/CHANGELOG.md +46 -1
- package/LICENSE.md +1 -1
- package/README.md +0 -29
- package/lib/cjs/CreateElementTool.d.ts +64 -2
- package/lib/cjs/CreateElementTool.d.ts.map +1 -1
- package/lib/cjs/CreateElementTool.js +65 -4
- package/lib/cjs/CreateElementTool.js.map +1 -1
- package/lib/cjs/EditTool.d.ts +5 -0
- package/lib/cjs/EditTool.d.ts.map +1 -1
- package/lib/cjs/EditTool.js +10 -14
- package/lib/cjs/EditTool.js.map +1 -1
- package/lib/cjs/EditToolIpc.d.ts +1 -5
- package/lib/cjs/EditToolIpc.d.ts.map +1 -1
- package/lib/cjs/EditToolIpc.js +1 -5
- package/lib/cjs/EditToolIpc.js.map +1 -1
- package/lib/cjs/ModifyElementTool.js.map +1 -1
- package/lib/cjs/ProjectLocation/ProjectExtentsDecoration.js.map +1 -1
- package/lib/cjs/ProjectLocation/ProjectGeolocation.js.map +1 -1
- package/lib/cjs/TransformElementsTool.d.ts +17 -98
- package/lib/cjs/TransformElementsTool.d.ts.map +1 -1
- package/lib/cjs/TransformElementsTool.js +15 -412
- package/lib/cjs/TransformElementsTool.js.map +1 -1
- package/lib/cjs/UndoRedoTool.js.map +1 -1
- package/lib/cjs/editor-frontend.d.ts +0 -6
- package/lib/cjs/editor-frontend.d.ts.map +1 -1
- package/lib/cjs/editor-frontend.js +0 -6
- package/lib/cjs/editor-frontend.js.map +1 -1
- package/lib/esm/CreateElementTool.d.ts +64 -2
- package/lib/esm/CreateElementTool.d.ts.map +1 -1
- package/lib/esm/CreateElementTool.js +65 -4
- package/lib/esm/CreateElementTool.js.map +1 -1
- package/lib/esm/EditTool.d.ts +5 -0
- package/lib/esm/EditTool.d.ts.map +1 -1
- package/lib/esm/EditTool.js +10 -14
- package/lib/esm/EditTool.js.map +1 -1
- package/lib/esm/EditToolIpc.d.ts +1 -5
- package/lib/esm/EditToolIpc.d.ts.map +1 -1
- package/lib/esm/EditToolIpc.js +0 -4
- package/lib/esm/EditToolIpc.js.map +1 -1
- package/lib/esm/ModifyElementTool.js.map +1 -1
- package/lib/esm/ProjectLocation/ProjectExtentsDecoration.js.map +1 -1
- package/lib/esm/ProjectLocation/ProjectGeolocation.js.map +1 -1
- package/lib/esm/TransformElementsTool.d.ts +17 -98
- package/lib/esm/TransformElementsTool.d.ts.map +1 -1
- package/lib/esm/TransformElementsTool.js +16 -413
- package/lib/esm/TransformElementsTool.js.map +1 -1
- package/lib/esm/UndoRedoTool.js.map +1 -1
- package/lib/esm/editor-frontend.d.ts +0 -6
- package/lib/esm/editor-frontend.d.ts.map +1 -1
- package/lib/esm/editor-frontend.js +0 -6
- package/lib/esm/editor-frontend.js.map +1 -1
- package/lib/public/locales/en/Editor.json +79 -490
- package/package.json +14 -14
- package/lib/cjs/DeleteElementsTool.d.ts +0 -14
- package/lib/cjs/DeleteElementsTool.d.ts.map +0 -1
- package/lib/cjs/DeleteElementsTool.js +0 -42
- package/lib/cjs/DeleteElementsTool.js.map +0 -1
- package/lib/cjs/ElementGeometryTool.d.ts +0 -148
- package/lib/cjs/ElementGeometryTool.d.ts.map +0 -1
- package/lib/cjs/ElementGeometryTool.js +0 -705
- package/lib/cjs/ElementGeometryTool.js.map +0 -1
- package/lib/cjs/ModifyCurveTools.d.ts +0 -140
- package/lib/cjs/ModifyCurveTools.d.ts.map +0 -1
- package/lib/cjs/ModifyCurveTools.js +0 -777
- package/lib/cjs/ModifyCurveTools.js.map +0 -1
- package/lib/cjs/SketchTools.d.ts +0 -308
- package/lib/cjs/SketchTools.d.ts.map +0 -1
- package/lib/cjs/SketchTools.js +0 -1708
- package/lib/cjs/SketchTools.js.map +0 -1
- package/lib/cjs/SolidModelingTools.d.ts +0 -381
- package/lib/cjs/SolidModelingTools.d.ts.map +0 -1
- package/lib/cjs/SolidModelingTools.js +0 -1453
- package/lib/cjs/SolidModelingTools.js.map +0 -1
- package/lib/cjs/SolidPrimitiveTools.d.ts +0 -322
- package/lib/cjs/SolidPrimitiveTools.d.ts.map +0 -1
- package/lib/cjs/SolidPrimitiveTools.js +0 -1376
- package/lib/cjs/SolidPrimitiveTools.js.map +0 -1
- package/lib/esm/DeleteElementsTool.d.ts +0 -14
- package/lib/esm/DeleteElementsTool.d.ts.map +0 -1
- package/lib/esm/DeleteElementsTool.js +0 -39
- package/lib/esm/DeleteElementsTool.js.map +0 -1
- package/lib/esm/ElementGeometryTool.d.ts +0 -148
- package/lib/esm/ElementGeometryTool.d.ts.map +0 -1
- package/lib/esm/ElementGeometryTool.js +0 -697
- package/lib/esm/ElementGeometryTool.js.map +0 -1
- package/lib/esm/ModifyCurveTools.d.ts +0 -140
- package/lib/esm/ModifyCurveTools.d.ts.map +0 -1
- package/lib/esm/ModifyCurveTools.js +0 -772
- package/lib/esm/ModifyCurveTools.js.map +0 -1
- package/lib/esm/SketchTools.d.ts +0 -308
- package/lib/esm/SketchTools.d.ts.map +0 -1
- package/lib/esm/SketchTools.js +0 -1704
- package/lib/esm/SketchTools.js.map +0 -1
- package/lib/esm/SolidModelingTools.d.ts +0 -381
- package/lib/esm/SolidModelingTools.d.ts.map +0 -1
- package/lib/esm/SolidModelingTools.js +0 -1445
- package/lib/esm/SolidModelingTools.js.map +0 -1
- package/lib/esm/SolidPrimitiveTools.d.ts +0 -322
- package/lib/esm/SolidPrimitiveTools.d.ts.map +0 -1
- package/lib/esm/SolidPrimitiveTools.js +0 -1372
- package/lib/esm/SolidPrimitiveTools.js.map +0 -1
package/lib/cjs/SketchTools.js
DELETED
|
@@ -1,1708 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
exports.CreateBCurveTool = exports.BCurveMethod = exports.CreateRectangleTool = exports.CreateEllipseTool = exports.CreateCircleTool = exports.CircleMethod = exports.CreateArcTool = exports.ArcMethod = exports.CreateLineStringTool = exports.CreateOrContinuePathTool = exports.CreateCurvePhase = void 0;
|
|
8
|
-
/** @packageDocumentation
|
|
9
|
-
* @module Editing
|
|
10
|
-
*/
|
|
11
|
-
const appui_abstract_1 = require("@itwin/appui-abstract");
|
|
12
|
-
const core_bentley_1 = require("@itwin/core-bentley");
|
|
13
|
-
const core_common_1 = require("@itwin/core-common");
|
|
14
|
-
const core_frontend_1 = require("@itwin/core-frontend");
|
|
15
|
-
const core_geometry_1 = require("@itwin/core-geometry");
|
|
16
|
-
const editor_common_1 = require("@itwin/editor-common");
|
|
17
|
-
const CreateElementTool_1 = require("./CreateElementTool");
|
|
18
|
-
const EditTool_1 = require("./EditTool");
|
|
19
|
-
const EditToolIpc_1 = require("./EditToolIpc");
|
|
20
|
-
/** @alpha Values for [[CreateOrContinueTool.createCurvePhase] to support join and closure. */
|
|
21
|
-
var CreateCurvePhase;
|
|
22
|
-
(function (CreateCurvePhase) {
|
|
23
|
-
/** Current tool phase changes CurvePrimitive startPoint.
|
|
24
|
-
* ex. Arc defined by center, start would return this when accepted length is 1.
|
|
25
|
-
*/
|
|
26
|
-
CreateCurvePhase[CreateCurvePhase["DefineStart"] = 0] = "DefineStart";
|
|
27
|
-
/** Current tool phase changes CurvePrimitive endPoint.
|
|
28
|
-
* ex. Arc defined by start, end, mid would return this when accepted length is 1.
|
|
29
|
-
*/
|
|
30
|
-
CreateCurvePhase[CreateCurvePhase["DefineEnd"] = 1] = "DefineEnd";
|
|
31
|
-
/** Current tool phase does NOT change CurvePrimitive startPoint or endPoint.
|
|
32
|
-
* ex. When defining arc mid point, or start and end tangents for a bcurve return this.
|
|
33
|
-
*/
|
|
34
|
-
CreateCurvePhase[CreateCurvePhase["DefineOther"] = 2] = "DefineOther";
|
|
35
|
-
})(CreateCurvePhase = exports.CreateCurvePhase || (exports.CreateCurvePhase = {}));
|
|
36
|
-
/** @alpha Base class for creating open and closed paths. */
|
|
37
|
-
class CreateOrContinuePathTool extends CreateElementTool_1.CreateElementWithDynamicsTool {
|
|
38
|
-
constructor() {
|
|
39
|
-
super(...arguments);
|
|
40
|
-
this._createCurvePhase = CreateCurvePhase.DefineOther;
|
|
41
|
-
this.accepted = [];
|
|
42
|
-
this.isClosed = false;
|
|
43
|
-
this.isConstruction = false; // Sub-classes can set in createNewCurvePrimitive to bypass creating element graphics...
|
|
44
|
-
}
|
|
45
|
-
async startCommand() {
|
|
46
|
-
if (undefined !== this._startedCmd)
|
|
47
|
-
return this._startedCmd;
|
|
48
|
-
return EditTool_1.EditTools.startCommand({ commandId: editor_common_1.editorBuiltInCmdIds.cmdBasicManipulation, iModelKey: this.iModel.key });
|
|
49
|
-
}
|
|
50
|
-
get allowJoin() { return this.isControlDown; }
|
|
51
|
-
get allowClosure() { return this.isControlDown; }
|
|
52
|
-
get allowSimplify() { return true; }
|
|
53
|
-
get wantSmartRotation() { return this.isContinueExistingPath || this.isControlDown; }
|
|
54
|
-
get wantPickableDynamics() { return false; }
|
|
55
|
-
get wantJoin() { return this.allowJoin; }
|
|
56
|
-
get wantClosure() { return this.isContinueExistingPath && this.allowClosure; }
|
|
57
|
-
get wantSimplify() { return this.allowSimplify; }
|
|
58
|
-
get showCurveConstructions() { return false; }
|
|
59
|
-
get showJoin() { return this.isContinueExistingPath && CreateCurvePhase.DefineStart === this.createCurvePhase; }
|
|
60
|
-
get showClosure() { return this.isClosed && CreateCurvePhase.DefineEnd === this.createCurvePhase; }
|
|
61
|
-
get createCurvePhase() { return this._createCurvePhase; }
|
|
62
|
-
/** Sub-classes should override unless they don't support join or closure. */
|
|
63
|
-
updateCurvePhase() { }
|
|
64
|
-
getCurrentRotation(ev) {
|
|
65
|
-
const matrix = (undefined !== ev.viewport ? core_frontend_1.AccuDrawHintBuilder.getCurrentRotation(ev.viewport, true, true) : undefined);
|
|
66
|
-
return (undefined !== matrix ? matrix : core_geometry_1.Matrix3d.createIdentity());
|
|
67
|
-
}
|
|
68
|
-
getUpVector(ev) {
|
|
69
|
-
return this.getCurrentRotation(ev).getColumn(2);
|
|
70
|
-
}
|
|
71
|
-
async updateCurveAndContinuationData(ev, isDynamics) {
|
|
72
|
-
this.isConstruction = false;
|
|
73
|
-
this.current = this.createNewCurvePrimitive(ev, isDynamics);
|
|
74
|
-
if (CreateCurvePhase.DefineStart === this.createCurvePhase)
|
|
75
|
-
await this.isValidForJoin(); // Updates this.continuationData...
|
|
76
|
-
else if (CreateCurvePhase.DefineEnd === this.createCurvePhase)
|
|
77
|
-
await this.isValidForClosure(); // Updates this.isClosed...
|
|
78
|
-
}
|
|
79
|
-
async updateElementData(ev, isDynamics) {
|
|
80
|
-
if (!isDynamics)
|
|
81
|
-
this.accepted.push(ev.point.clone());
|
|
82
|
-
await this.updateCurveAndContinuationData(ev, isDynamics);
|
|
83
|
-
if (!isDynamics)
|
|
84
|
-
this.updateCurvePhase();
|
|
85
|
-
}
|
|
86
|
-
async updateDynamicData(ev) {
|
|
87
|
-
// Need to update continuation data for first data point before dynamics has started...
|
|
88
|
-
await this.updateCurveAndContinuationData(ev, true);
|
|
89
|
-
// Don't need to create graphic if dynamics aren't yet active or showing construction geometry...
|
|
90
|
-
return (core_frontend_1.IModelApp.viewManager.inDynamicsMode && !this.isConstruction);
|
|
91
|
-
}
|
|
92
|
-
get isContinueExistingPath() { return undefined !== this.continuationData; }
|
|
93
|
-
async isValidForContinue(snap) {
|
|
94
|
-
if (!snap.isElementHit)
|
|
95
|
-
return;
|
|
96
|
-
const snapCurve = snap.getCurvePrimitive();
|
|
97
|
-
if (undefined === snapCurve)
|
|
98
|
-
return;
|
|
99
|
-
const curveS = snapCurve.startPoint();
|
|
100
|
-
const curveE = snapCurve.endPoint();
|
|
101
|
-
if (curveS.isAlmostEqual(curveE))
|
|
102
|
-
return; // Reject snap to single physically closed curve primitive...
|
|
103
|
-
const snapPt = snap.adjustedPoint;
|
|
104
|
-
if (!(snapPt.isAlmostEqual(curveS) || snapPt.isAlmostEqual(curveE)))
|
|
105
|
-
return; // No point to further checks if snap wasn't to endpoint of curve primitive...
|
|
106
|
-
try {
|
|
107
|
-
this._startedCmd = await this.startCommand();
|
|
108
|
-
const info = await EditToolIpc_1.basicManipulationIpc.requestElementGeometry(snap.sourceId, { maxDisplayable: 1, geometry: { curves: true, surfaces: false, solids: false } });
|
|
109
|
-
if (undefined === info)
|
|
110
|
-
return;
|
|
111
|
-
const data = CreateOrContinuePathTool.isSingleOpenPath(info);
|
|
112
|
-
if (undefined === data)
|
|
113
|
-
return;
|
|
114
|
-
const props = await this.iModel.elements.loadProps(snap.sourceId);
|
|
115
|
-
if (undefined === props)
|
|
116
|
-
return;
|
|
117
|
-
return { props, path: data.path, params: data.params };
|
|
118
|
-
}
|
|
119
|
-
catch (err) {
|
|
120
|
-
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."));
|
|
121
|
-
return;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
async isValidForJoin() {
|
|
125
|
-
this.continuationData = undefined;
|
|
126
|
-
if (!this.wantJoin)
|
|
127
|
-
return false;
|
|
128
|
-
if (undefined === this.current)
|
|
129
|
-
return false;
|
|
130
|
-
const snap = core_frontend_1.TentativeOrAccuSnap.getCurrentSnap();
|
|
131
|
-
if (undefined === snap)
|
|
132
|
-
return false;
|
|
133
|
-
const data = await this.isValidForContinue(snap);
|
|
134
|
-
if (undefined === data)
|
|
135
|
-
return false;
|
|
136
|
-
if (!CreateOrContinuePathTool.isPathEndPoint(this.current, data.path))
|
|
137
|
-
return false;
|
|
138
|
-
this.continuationData = data;
|
|
139
|
-
return true;
|
|
140
|
-
}
|
|
141
|
-
async isValidForClosure() {
|
|
142
|
-
this.isClosed = false;
|
|
143
|
-
if (!this.wantClosure)
|
|
144
|
-
return false;
|
|
145
|
-
if (undefined === this.current)
|
|
146
|
-
return false;
|
|
147
|
-
return (this.isClosed = CreateOrContinuePathTool.isPathClosurePoint(this.current, this.continuationData?.path));
|
|
148
|
-
}
|
|
149
|
-
static isSingleOpenPath(info) {
|
|
150
|
-
const it = new core_common_1.ElementGeometry.Iterator(info);
|
|
151
|
-
it.requestWorldCoordinates();
|
|
152
|
-
for (const entry of it) {
|
|
153
|
-
const geom = entry.toGeometryQuery();
|
|
154
|
-
if (undefined === geom)
|
|
155
|
-
return;
|
|
156
|
-
if ("curvePrimitive" === geom.geometryCategory) {
|
|
157
|
-
const curve = geom;
|
|
158
|
-
const curveS = curve.startPoint();
|
|
159
|
-
const curveE = curve.endPoint();
|
|
160
|
-
if (curveS.isAlmostEqual(curveE))
|
|
161
|
-
return; // Reject zero length lines, physically closed arcs, linestrings, etc...
|
|
162
|
-
return { path: core_geometry_1.Path.create(curve), params: entry.geomParams };
|
|
163
|
-
}
|
|
164
|
-
else if ("curveCollection" === geom.geometryCategory) {
|
|
165
|
-
const curves = geom;
|
|
166
|
-
if (!curves.isOpenPath)
|
|
167
|
-
return;
|
|
168
|
-
const path = curves;
|
|
169
|
-
const curveS = path.children[0].startPoint();
|
|
170
|
-
const curveE = path.children[path.children.length - 1].endPoint();
|
|
171
|
-
if (curveS.isAlmostEqual(curveE))
|
|
172
|
-
return; // Reject physically closed path...
|
|
173
|
-
return { path, params: entry.geomParams };
|
|
174
|
-
}
|
|
175
|
-
break;
|
|
176
|
-
}
|
|
177
|
-
return;
|
|
178
|
-
}
|
|
179
|
-
static isPathEndPoint(curve, path) {
|
|
180
|
-
const curveS = curve.startPoint();
|
|
181
|
-
const pathS = path.children[0].startPoint();
|
|
182
|
-
const pathE = path.children[path.children.length - 1].endPoint();
|
|
183
|
-
if (!(curveS.isAlmostEqual(pathS) || curveS.isAlmostEqual(pathE)))
|
|
184
|
-
return false;
|
|
185
|
-
return true;
|
|
186
|
-
}
|
|
187
|
-
static isPathClosurePoint(curve, path) {
|
|
188
|
-
const length = curve.quickLength();
|
|
189
|
-
if (length < core_geometry_1.Geometry.smallMetricDistance)
|
|
190
|
-
return false;
|
|
191
|
-
const curveS = curve.startPoint();
|
|
192
|
-
const curveE = curve.endPoint();
|
|
193
|
-
if (undefined === path) {
|
|
194
|
-
if (!curveS.isAlmostEqual(curveE))
|
|
195
|
-
return false;
|
|
196
|
-
const curveLocalToWorld = core_geometry_1.FrameBuilder.createRightHandedFrame(undefined, curve);
|
|
197
|
-
if (undefined === curveLocalToWorld)
|
|
198
|
-
return false;
|
|
199
|
-
// Don't create a Loop unless new CurvePrimitive is planar...
|
|
200
|
-
const curvePlane = core_geometry_1.Plane3dByOriginAndUnitNormal.create(curveLocalToWorld.getOrigin(), curveLocalToWorld.matrix.getColumn(2));
|
|
201
|
-
return (undefined !== curvePlane && curve.isInPlane(curvePlane));
|
|
202
|
-
}
|
|
203
|
-
const pathS = path.children[0].startPoint();
|
|
204
|
-
const pathE = path.children[path.children.length - 1].endPoint();
|
|
205
|
-
if (!(curveS.isAlmostEqual(pathS) && curveE.isAlmostEqual(pathE) || curveS.isAlmostEqual(pathE) && curveE.isAlmostEqual(pathS)))
|
|
206
|
-
return false;
|
|
207
|
-
const pathLocalToWorld = core_geometry_1.FrameBuilder.createRightHandedFrame(undefined, [curve, path]);
|
|
208
|
-
if (undefined === pathLocalToWorld)
|
|
209
|
-
return false;
|
|
210
|
-
// Don't create a Loop unless new CurvePrimitive + existing Path is planar...
|
|
211
|
-
const pathPlane = core_geometry_1.Plane3dByOriginAndUnitNormal.create(pathLocalToWorld.getOrigin(), pathLocalToWorld.matrix.getColumn(2));
|
|
212
|
-
if (undefined === pathPlane)
|
|
213
|
-
return false;
|
|
214
|
-
if (!curve.isInPlane(pathPlane))
|
|
215
|
-
return false;
|
|
216
|
-
for (const child of path.children) {
|
|
217
|
-
if (!child.isInPlane(pathPlane))
|
|
218
|
-
return false;
|
|
219
|
-
}
|
|
220
|
-
return true;
|
|
221
|
-
}
|
|
222
|
-
addConstructionGraphics(curve, showCurve, context) {
|
|
223
|
-
if (!showCurve) {
|
|
224
|
-
switch (curve.curvePrimitiveType) {
|
|
225
|
-
case "arc":
|
|
226
|
-
case "bsplineCurve":
|
|
227
|
-
case "interpolationCurve":
|
|
228
|
-
break;
|
|
229
|
-
default:
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
|
-
}
|
|
233
|
-
const builder = context.createGraphic({ type: core_frontend_1.GraphicType.WorldOverlay });
|
|
234
|
-
builder.setSymbology(context.viewport.getContrastToBackgroundColor(), core_common_1.ColorDef.black, 1, core_common_1.LinePixels.Code2);
|
|
235
|
-
if (showCurve)
|
|
236
|
-
builder.addPath(core_geometry_1.Path.create(curve));
|
|
237
|
-
switch (curve.curvePrimitiveType) {
|
|
238
|
-
case "arc": {
|
|
239
|
-
const arc = curve;
|
|
240
|
-
const start = arc.startPoint();
|
|
241
|
-
const end = arc.endPoint();
|
|
242
|
-
builder.addLineString([arc.center, start]);
|
|
243
|
-
if (!start.isAlmostEqual(end))
|
|
244
|
-
builder.addLineString([arc.center, end]);
|
|
245
|
-
builder.setSymbology(context.viewport.getContrastToBackgroundColor(), core_common_1.ColorDef.black, 5);
|
|
246
|
-
builder.addPointString([arc.center]);
|
|
247
|
-
break;
|
|
248
|
-
}
|
|
249
|
-
case "bsplineCurve": {
|
|
250
|
-
const bcurve = curve;
|
|
251
|
-
const poles = [];
|
|
252
|
-
for (let iPole = 0; iPole < bcurve.numPoles; ++iPole) {
|
|
253
|
-
const polePt = bcurve.getPolePoint3d(iPole);
|
|
254
|
-
if (undefined !== polePt)
|
|
255
|
-
poles.push(polePt);
|
|
256
|
-
}
|
|
257
|
-
builder.addLineString(poles);
|
|
258
|
-
builder.setSymbology(context.viewport.getContrastToBackgroundColor(), core_common_1.ColorDef.black, 5);
|
|
259
|
-
builder.addPointString(poles);
|
|
260
|
-
break;
|
|
261
|
-
}
|
|
262
|
-
case "interpolationCurve": {
|
|
263
|
-
const fitCurve = curve;
|
|
264
|
-
builder.setSymbology(context.viewport.getContrastToBackgroundColor(), core_common_1.ColorDef.black, 5);
|
|
265
|
-
builder.addPointString(fitCurve.options.fitPoints); // deep copy shoulnd't be necessary...
|
|
266
|
-
break;
|
|
267
|
-
}
|
|
268
|
-
default:
|
|
269
|
-
break;
|
|
270
|
-
}
|
|
271
|
-
context.addGraphic(builder.finish());
|
|
272
|
-
}
|
|
273
|
-
showConstructionGraphics(_ev, context) {
|
|
274
|
-
if (undefined === this.current)
|
|
275
|
-
return false;
|
|
276
|
-
if (!this.isConstruction) {
|
|
277
|
-
if (this.showCurveConstructions)
|
|
278
|
-
this.addConstructionGraphics(this.current, false, context);
|
|
279
|
-
return false;
|
|
280
|
-
}
|
|
281
|
-
this.addConstructionGraphics(this.current, true, context);
|
|
282
|
-
return true;
|
|
283
|
-
}
|
|
284
|
-
onDynamicFrame(ev, context) {
|
|
285
|
-
if (this.showConstructionGraphics(ev, context))
|
|
286
|
-
return; // Don't display element graphics...
|
|
287
|
-
super.onDynamicFrame(ev, context);
|
|
288
|
-
}
|
|
289
|
-
showJoinIndicator(context, pt) {
|
|
290
|
-
const lengthX = Math.floor(context.viewport.pixelsFromInches(0.08)) + 0.5;
|
|
291
|
-
const lengthY = Math.floor(lengthX * 0.6) + 0.5;
|
|
292
|
-
const offsetX = lengthX * 3;
|
|
293
|
-
const offsetY = lengthY * 3;
|
|
294
|
-
const position = context.viewport.worldToView(pt);
|
|
295
|
-
position.x = Math.floor(position.x - offsetX) + 0.5;
|
|
296
|
-
position.y = Math.floor(position.y + offsetY) + 0.5;
|
|
297
|
-
const drawDecoration = (ctx) => {
|
|
298
|
-
ctx.beginPath();
|
|
299
|
-
ctx.strokeStyle = "rgba(0,0,0,.8)";
|
|
300
|
-
ctx.lineWidth = 3;
|
|
301
|
-
ctx.lineCap = "round";
|
|
302
|
-
ctx.moveTo(-lengthX, lengthY);
|
|
303
|
-
ctx.lineTo(0, lengthY);
|
|
304
|
-
ctx.lineTo(0, -lengthY);
|
|
305
|
-
ctx.lineTo(lengthX, -lengthY);
|
|
306
|
-
ctx.stroke();
|
|
307
|
-
ctx.beginPath();
|
|
308
|
-
ctx.strokeStyle = "rgba(255,255,255,.8)";
|
|
309
|
-
ctx.lineWidth = 1;
|
|
310
|
-
ctx.moveTo(-lengthX, lengthY);
|
|
311
|
-
ctx.lineTo(0, lengthY);
|
|
312
|
-
ctx.lineTo(0, -lengthY);
|
|
313
|
-
ctx.lineTo(lengthX, -lengthY);
|
|
314
|
-
ctx.stroke();
|
|
315
|
-
ctx.beginPath();
|
|
316
|
-
ctx.strokeStyle = "rgba(0,0,0,.8)";
|
|
317
|
-
ctx.fillStyle = "rgba(0,255,255,.8)";
|
|
318
|
-
ctx.arc(0, -lengthY, 2.5, 0, 2 * Math.PI);
|
|
319
|
-
ctx.fill();
|
|
320
|
-
ctx.stroke();
|
|
321
|
-
};
|
|
322
|
-
context.addCanvasDecoration({ position, drawDecoration }, true);
|
|
323
|
-
}
|
|
324
|
-
showClosureIndicator(context, pt) {
|
|
325
|
-
const radius = Math.floor(context.viewport.pixelsFromInches(0.06)) + 0.5;
|
|
326
|
-
const offset = radius * 2.5;
|
|
327
|
-
const position = context.viewport.worldToView(pt);
|
|
328
|
-
position.x = Math.floor(position.x - offset) + 0.5;
|
|
329
|
-
position.y = Math.floor(position.y + offset) + 0.5;
|
|
330
|
-
const drawDecoration = (ctx) => {
|
|
331
|
-
ctx.beginPath();
|
|
332
|
-
ctx.strokeStyle = "rgba(255,255,255,.8)";
|
|
333
|
-
ctx.lineWidth = 1;
|
|
334
|
-
ctx.fillStyle = "rgba(0,0,255,.2)";
|
|
335
|
-
ctx.arc(0, 0, radius, 0, 2 * Math.PI);
|
|
336
|
-
ctx.fill();
|
|
337
|
-
ctx.stroke();
|
|
338
|
-
ctx.beginPath();
|
|
339
|
-
ctx.strokeStyle = "rgba(0,0,0,.8)";
|
|
340
|
-
ctx.arc(0, 0, radius + 1, 0, 2 * Math.PI);
|
|
341
|
-
ctx.stroke();
|
|
342
|
-
ctx.beginPath();
|
|
343
|
-
ctx.strokeStyle = "rgba(0,0,0,.8)";
|
|
344
|
-
ctx.fillStyle = "rgba(0,255,255,.8)";
|
|
345
|
-
ctx.arc(-radius, 0, 2.5, 0, 2 * Math.PI);
|
|
346
|
-
ctx.fill();
|
|
347
|
-
ctx.stroke();
|
|
348
|
-
};
|
|
349
|
-
context.addCanvasDecoration({ position, drawDecoration }, true);
|
|
350
|
-
}
|
|
351
|
-
testDecorationHit(id) {
|
|
352
|
-
return id === this._snapGeomId;
|
|
353
|
-
}
|
|
354
|
-
async getToolTip(hit) {
|
|
355
|
-
if (this.testDecorationHit(hit.sourceId))
|
|
356
|
-
return this.description;
|
|
357
|
-
return super.getToolTip(hit);
|
|
358
|
-
}
|
|
359
|
-
getSnapGeometry() {
|
|
360
|
-
if (this.accepted.length < 2)
|
|
361
|
-
return;
|
|
362
|
-
// Treat accepted points as linear segments by default...
|
|
363
|
-
return core_geometry_1.LineString3d.create(this.accepted);
|
|
364
|
-
}
|
|
365
|
-
getDecorationGeometry(_hit) {
|
|
366
|
-
const geomQuery = this.getSnapGeometry();
|
|
367
|
-
if (undefined === geomQuery)
|
|
368
|
-
return;
|
|
369
|
-
const geomJson = core_geometry_1.IModelJson.Writer.toIModelJson(geomQuery);
|
|
370
|
-
return geomJson ? [geomJson] : undefined;
|
|
371
|
-
}
|
|
372
|
-
addPickableGraphics(context) {
|
|
373
|
-
const geomQuery = this.getSnapGeometry();
|
|
374
|
-
if (undefined === geomQuery)
|
|
375
|
-
return;
|
|
376
|
-
if (undefined === this._snapGeomId)
|
|
377
|
-
this._snapGeomId = this.iModel.transientIds.getNext();
|
|
378
|
-
const builder = context.createGraphic({ type: core_frontend_1.GraphicType.WorldDecoration, pickable: { id: this._snapGeomId, locateOnly: true } });
|
|
379
|
-
builder.setSymbology(core_common_1.ColorDef.white, core_common_1.ColorDef.white, 1);
|
|
380
|
-
switch (geomQuery.geometryCategory) {
|
|
381
|
-
case "pointCollection": {
|
|
382
|
-
const pointString = geomQuery;
|
|
383
|
-
builder.addPointString(pointString.points);
|
|
384
|
-
break;
|
|
385
|
-
}
|
|
386
|
-
case "curvePrimitive": {
|
|
387
|
-
const curvePrimitive = geomQuery;
|
|
388
|
-
switch (curvePrimitive.curvePrimitiveType) {
|
|
389
|
-
case "lineString": {
|
|
390
|
-
const lineString = geomQuery;
|
|
391
|
-
builder.addLineString(lineString.points);
|
|
392
|
-
break;
|
|
393
|
-
}
|
|
394
|
-
default:
|
|
395
|
-
return; // Don't need to support other types of CurvePrimitive currently...
|
|
396
|
-
}
|
|
397
|
-
break;
|
|
398
|
-
}
|
|
399
|
-
default:
|
|
400
|
-
return; // Don't need to support other types of GeometryQuery currently...
|
|
401
|
-
}
|
|
402
|
-
context.addDecorationFromBuilder(builder);
|
|
403
|
-
}
|
|
404
|
-
decorate(context) {
|
|
405
|
-
if (this.wantPickableDynamics)
|
|
406
|
-
this.addPickableGraphics(context);
|
|
407
|
-
if (undefined === this.current)
|
|
408
|
-
return;
|
|
409
|
-
if (this.showJoin)
|
|
410
|
-
this.showJoinIndicator(context, this.current.startPoint());
|
|
411
|
-
else if (this.showClosure)
|
|
412
|
-
this.showClosureIndicator(context, this.current.endPoint());
|
|
413
|
-
}
|
|
414
|
-
async onModifierKeyTransition(_wentDown, modifier, _event) {
|
|
415
|
-
if (core_frontend_1.BeModifierKeys.Control !== modifier)
|
|
416
|
-
return core_frontend_1.EventHandled.No;
|
|
417
|
-
// Update display for join/closure change w/o waiting for a motion event...
|
|
418
|
-
return core_frontend_1.EventHandled.Yes;
|
|
419
|
-
}
|
|
420
|
-
getPlacementProps() {
|
|
421
|
-
if (undefined !== this.continuationData)
|
|
422
|
-
return this.continuationData.props.placement;
|
|
423
|
-
if (undefined === this.current)
|
|
424
|
-
return;
|
|
425
|
-
const vp = this.targetView;
|
|
426
|
-
if (undefined === vp)
|
|
427
|
-
return;
|
|
428
|
-
const matrix = core_frontend_1.AccuDrawHintBuilder.getCurrentRotation(vp, true, true);
|
|
429
|
-
const localToWorld = core_geometry_1.FrameBuilder.createRightHandedFrame(matrix?.getColumn(2), this.current);
|
|
430
|
-
if (undefined === localToWorld)
|
|
431
|
-
return;
|
|
432
|
-
const origin = localToWorld.getOrigin();
|
|
433
|
-
const angles = new core_geometry_1.YawPitchRollAngles();
|
|
434
|
-
core_geometry_1.YawPitchRollAngles.createFromMatrix3d(localToWorld.matrix, angles);
|
|
435
|
-
if (vp.view.is3d())
|
|
436
|
-
return { origin, angles };
|
|
437
|
-
return { origin, angle: angles.yaw };
|
|
438
|
-
}
|
|
439
|
-
createNewPath(placement) {
|
|
440
|
-
if (undefined === this.current)
|
|
441
|
-
return;
|
|
442
|
-
const builder = new core_common_1.ElementGeometry.Builder();
|
|
443
|
-
builder.setLocalToWorldFromPlacement(placement);
|
|
444
|
-
const geometry = (this.isClosed ? core_geometry_1.Loop.create(this.current) : this.current);
|
|
445
|
-
if (!builder.appendGeometryQuery(geometry))
|
|
446
|
-
return;
|
|
447
|
-
return { format: "flatbuffer", data: builder.entries };
|
|
448
|
-
}
|
|
449
|
-
continueExistingPath(placement) {
|
|
450
|
-
if (undefined === this.current || undefined === this.continuationData)
|
|
451
|
-
return;
|
|
452
|
-
const length = this.current.quickLength();
|
|
453
|
-
if (length < core_geometry_1.Geometry.smallMetricDistance)
|
|
454
|
-
return;
|
|
455
|
-
const curveS = this.current.startPoint();
|
|
456
|
-
const pathS = this.continuationData.path.children[0].startPoint();
|
|
457
|
-
const pathE = this.continuationData.path.children[this.continuationData.path.children.length - 1].endPoint();
|
|
458
|
-
const append = pathE.isAlmostEqual(curveS);
|
|
459
|
-
if (!append && !pathS.isAlmostEqual(curveS))
|
|
460
|
-
return;
|
|
461
|
-
const continuePath = this.continuationData.path.clone();
|
|
462
|
-
if (undefined === continuePath)
|
|
463
|
-
return;
|
|
464
|
-
const current = this.current.clone();
|
|
465
|
-
if (undefined === current)
|
|
466
|
-
return;
|
|
467
|
-
if (append) {
|
|
468
|
-
continuePath.tryAddChild(current);
|
|
469
|
-
}
|
|
470
|
-
else {
|
|
471
|
-
current.reverseInPlace();
|
|
472
|
-
continuePath.children.splice(0, 0, current);
|
|
473
|
-
}
|
|
474
|
-
const geometry = (this.isClosed ? core_geometry_1.Loop.create(...continuePath.children) : continuePath);
|
|
475
|
-
if (this.wantSimplify)
|
|
476
|
-
core_geometry_1.RegionOps.consolidateAdjacentPrimitives(geometry);
|
|
477
|
-
const builder = new core_common_1.ElementGeometry.Builder();
|
|
478
|
-
builder.setLocalToWorldFromPlacement(placement);
|
|
479
|
-
builder.appendGeometryParamsChange(this.continuationData.params);
|
|
480
|
-
if (!builder.appendGeometryQuery(geometry))
|
|
481
|
-
return;
|
|
482
|
-
return { format: "flatbuffer", data: builder.entries };
|
|
483
|
-
}
|
|
484
|
-
getGeometryProps(placement) {
|
|
485
|
-
if (this.isContinueExistingPath)
|
|
486
|
-
return this.continueExistingPath(placement);
|
|
487
|
-
return this.createNewPath(placement);
|
|
488
|
-
}
|
|
489
|
-
getElementProps(placement) {
|
|
490
|
-
if (undefined !== this.continuationData)
|
|
491
|
-
return this.continuationData.props;
|
|
492
|
-
const model = this.targetModelId;
|
|
493
|
-
const category = this.targetCategory;
|
|
494
|
-
if ((0, core_common_1.isPlacement3dProps)(placement))
|
|
495
|
-
return { classFullName: "Generic:PhysicalObject", model, category, code: core_common_1.Code.createEmpty(), placement };
|
|
496
|
-
return { classFullName: "BisCore:DrawingGraphic", model, category, code: core_common_1.Code.createEmpty(), placement };
|
|
497
|
-
}
|
|
498
|
-
async doCreateElement(props, data) {
|
|
499
|
-
try {
|
|
500
|
-
this._startedCmd = await this.startCommand();
|
|
501
|
-
if (undefined === props.id)
|
|
502
|
-
await EditToolIpc_1.basicManipulationIpc.insertGeometricElement(props, data);
|
|
503
|
-
else
|
|
504
|
-
await EditToolIpc_1.basicManipulationIpc.updateGeometricElement(props, data);
|
|
505
|
-
await this.saveChanges();
|
|
506
|
-
}
|
|
507
|
-
catch (err) {
|
|
508
|
-
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."));
|
|
509
|
-
}
|
|
510
|
-
}
|
|
511
|
-
setupAccuDraw() {
|
|
512
|
-
const nPts = this.accepted.length;
|
|
513
|
-
if (0 === nPts)
|
|
514
|
-
return;
|
|
515
|
-
const hints = new core_frontend_1.AccuDrawHintBuilder();
|
|
516
|
-
if (this.wantSmartRotation)
|
|
517
|
-
hints.enableSmartRotation = true;
|
|
518
|
-
// Rotate AccuDraw to last segment...
|
|
519
|
-
if (nPts > 1 && !this.accepted[nPts - 1].isAlmostEqual(this.accepted[nPts - 2]))
|
|
520
|
-
hints.setXAxis(core_geometry_1.Vector3d.createStartEnd(this.accepted[nPts - 2], this.accepted[nPts - 1]));
|
|
521
|
-
hints.setOrigin(this.accepted[nPts - 1]);
|
|
522
|
-
hints.sendHints();
|
|
523
|
-
}
|
|
524
|
-
async onUndoPreviousStep() {
|
|
525
|
-
if (0 === this.accepted.length)
|
|
526
|
-
return false;
|
|
527
|
-
this.accepted.pop();
|
|
528
|
-
if (0 === this.accepted.length) {
|
|
529
|
-
await this.onReinitialize();
|
|
530
|
-
}
|
|
531
|
-
else {
|
|
532
|
-
this.updateCurvePhase();
|
|
533
|
-
this.setupAndPromptForNextAction();
|
|
534
|
-
}
|
|
535
|
-
return true;
|
|
536
|
-
}
|
|
537
|
-
async onPostInstall() {
|
|
538
|
-
await super.onPostInstall();
|
|
539
|
-
this.updateCurvePhase();
|
|
540
|
-
}
|
|
541
|
-
}
|
|
542
|
-
exports.CreateOrContinuePathTool = CreateOrContinuePathTool;
|
|
543
|
-
/** @alpha Creates a line string or shape. Uses model and category from [[BriefcaseConnection.editorToolSettings]]. */
|
|
544
|
-
class CreateLineStringTool extends CreateOrContinuePathTool {
|
|
545
|
-
get wantPickableDynamics() { return true; } // Allow snapping to accepted segments...
|
|
546
|
-
provideToolAssistance(_mainInstrText, _additionalInstr) {
|
|
547
|
-
const nPts = this.accepted.length;
|
|
548
|
-
const mainMsg = core_frontend_1.CoreTools.translate(0 === nPts ? "ElementSet.Prompts.StartPoint" : (1 === nPts ? "ElementSet.Prompts.EndPoint" : "ElementSet.Inputs.AdditionalPoint"));
|
|
549
|
-
const leftMsg = core_frontend_1.CoreTools.translate("ElementSet.Inputs.AcceptPoint");
|
|
550
|
-
const rightMsg = core_frontend_1.CoreTools.translate(nPts > 1 ? "ElementSet.Inputs.Complete" : "ElementSet.Inputs.Cancel");
|
|
551
|
-
const mouseInstructions = [];
|
|
552
|
-
const touchInstructions = [];
|
|
553
|
-
if (!core_frontend_1.ToolAssistance.createTouchCursorInstructions(touchInstructions))
|
|
554
|
-
touchInstructions.push(core_frontend_1.ToolAssistance.createInstruction(core_frontend_1.ToolAssistanceImage.OneTouchTap, leftMsg, false, core_frontend_1.ToolAssistanceInputMethod.Touch));
|
|
555
|
-
mouseInstructions.push(core_frontend_1.ToolAssistance.createInstruction(core_frontend_1.ToolAssistanceImage.LeftClick, leftMsg, false, core_frontend_1.ToolAssistanceInputMethod.Mouse));
|
|
556
|
-
touchInstructions.push(core_frontend_1.ToolAssistance.createInstruction(core_frontend_1.ToolAssistanceImage.TwoTouchTap, rightMsg, false, core_frontend_1.ToolAssistanceInputMethod.Touch));
|
|
557
|
-
mouseInstructions.push(core_frontend_1.ToolAssistance.createInstruction(core_frontend_1.ToolAssistanceImage.RightClick, rightMsg, false, core_frontend_1.ToolAssistanceInputMethod.Mouse));
|
|
558
|
-
const sections = [];
|
|
559
|
-
sections.push(core_frontend_1.ToolAssistance.createSection(mouseInstructions, core_frontend_1.ToolAssistance.inputsLabel));
|
|
560
|
-
sections.push(core_frontend_1.ToolAssistance.createSection(touchInstructions, core_frontend_1.ToolAssistance.inputsLabel));
|
|
561
|
-
const mainInstruction = core_frontend_1.ToolAssistance.createInstruction(this.iconSpec, mainMsg);
|
|
562
|
-
const instructions = core_frontend_1.ToolAssistance.createInstructions(mainInstruction, sections);
|
|
563
|
-
core_frontend_1.IModelApp.notifications.setToolAssistance(instructions);
|
|
564
|
-
}
|
|
565
|
-
get wantClosure() {
|
|
566
|
-
// A linestring can support physical closure when creating a new path...
|
|
567
|
-
return this.allowClosure;
|
|
568
|
-
}
|
|
569
|
-
updateCurvePhase() {
|
|
570
|
-
// The first point changes startPoint and last point changes endPoint.
|
|
571
|
-
this._createCurvePhase = (0 === this.accepted.length ? CreateCurvePhase.DefineStart : CreateCurvePhase.DefineEnd);
|
|
572
|
-
}
|
|
573
|
-
isComplete(ev) {
|
|
574
|
-
// Accept on reset with at least 2 points...
|
|
575
|
-
if (core_frontend_1.BeButton.Reset === ev.button)
|
|
576
|
-
return (this.accepted.length > 1);
|
|
577
|
-
// Allow data to complete on physical closure (creates Loop)...
|
|
578
|
-
return this.isClosed;
|
|
579
|
-
}
|
|
580
|
-
createNewCurvePrimitive(ev, isDynamics) {
|
|
581
|
-
const numRequired = (isDynamics ? 1 : 2);
|
|
582
|
-
if (this.accepted.length < numRequired) {
|
|
583
|
-
this.isConstruction = true; // Create zero length line as construction geometry to support join...
|
|
584
|
-
const pt = (0 !== this.accepted.length ? this.accepted[0] : ev.point);
|
|
585
|
-
return core_geometry_1.LineString3d.create([pt, pt]);
|
|
586
|
-
}
|
|
587
|
-
const pts = (isDynamics ? [...this.accepted, ev.point] : this.accepted);
|
|
588
|
-
return core_geometry_1.LineString3d.create(pts);
|
|
589
|
-
}
|
|
590
|
-
async cancelPoint(ev) {
|
|
591
|
-
// NOTE: Starting another tool will not create element...require reset or closure...
|
|
592
|
-
if (this.isComplete(ev)) {
|
|
593
|
-
this._createCurvePhase = CreateCurvePhase.DefineEnd;
|
|
594
|
-
await this.updateCurveAndContinuationData(ev, false);
|
|
595
|
-
await this.createElement();
|
|
596
|
-
}
|
|
597
|
-
return true;
|
|
598
|
-
}
|
|
599
|
-
async onRestartTool() {
|
|
600
|
-
const tool = new CreateLineStringTool();
|
|
601
|
-
if (!await tool.run())
|
|
602
|
-
return this.exitTool();
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
CreateLineStringTool.toolId = "CreateLineString";
|
|
606
|
-
CreateLineStringTool.iconSpec = "icon-snaps"; // Need better icon...
|
|
607
|
-
exports.CreateLineStringTool = CreateLineStringTool;
|
|
608
|
-
/** @alpha */
|
|
609
|
-
var ArcMethod;
|
|
610
|
-
(function (ArcMethod) {
|
|
611
|
-
ArcMethod[ArcMethod["CenterStart"] = 0] = "CenterStart";
|
|
612
|
-
ArcMethod[ArcMethod["StartCenter"] = 1] = "StartCenter";
|
|
613
|
-
ArcMethod[ArcMethod["StartMidEnd"] = 2] = "StartMidEnd";
|
|
614
|
-
ArcMethod[ArcMethod["StartEndMid"] = 3] = "StartEndMid";
|
|
615
|
-
})(ArcMethod = exports.ArcMethod || (exports.ArcMethod = {}));
|
|
616
|
-
/** @alpha Creates an arc. Uses model and category from [[BriefcaseConnection.editorToolSettings]]. */
|
|
617
|
-
class CreateArcTool extends CreateOrContinuePathTool {
|
|
618
|
-
static get minArgs() { return 0; }
|
|
619
|
-
static get maxArgs() { return 3; } // method, radius, sweep - zero value unlocks associated "use" toggle...
|
|
620
|
-
get showCurveConstructions() { return true; } // Display lines from center to start/end...
|
|
621
|
-
provideToolAssistance(mainInstrText, additionalInstr) {
|
|
622
|
-
const nPts = this.accepted.length;
|
|
623
|
-
switch (this.method) {
|
|
624
|
-
case ArcMethod.CenterStart:
|
|
625
|
-
mainInstrText = (0 === nPts ? EditTool_1.EditTools.translate("CreateArc.Prompts.CenterPoint") : (1 === nPts ? core_frontend_1.CoreTools.translate("ElementSet.Prompts.StartPoint") : core_frontend_1.CoreTools.translate("ElementSet.Prompts.EndPoint")));
|
|
626
|
-
break;
|
|
627
|
-
case ArcMethod.StartCenter:
|
|
628
|
-
mainInstrText = (0 === nPts ? core_frontend_1.CoreTools.translate("ElementSet.Prompts.StartPoint") : (1 === nPts ? EditTool_1.EditTools.translate("CreateArc.Prompts.CenterPoint") : core_frontend_1.CoreTools.translate("ElementSet.Prompts.EndPoint")));
|
|
629
|
-
break;
|
|
630
|
-
case ArcMethod.StartMidEnd:
|
|
631
|
-
mainInstrText = (0 === nPts ? core_frontend_1.CoreTools.translate("ElementSet.Prompts.StartPoint") : (1 === nPts ? EditTool_1.EditTools.translate("CreateArc.Prompts.MidPoint") : core_frontend_1.CoreTools.translate("ElementSet.Prompts.EndPoint")));
|
|
632
|
-
break;
|
|
633
|
-
case ArcMethod.StartEndMid:
|
|
634
|
-
mainInstrText = (0 === nPts ? core_frontend_1.CoreTools.translate("ElementSet.Prompts.StartPoint") : (1 === nPts ? core_frontend_1.CoreTools.translate("ElementSet.Prompts.EndPoint") : EditTool_1.EditTools.translate("CreateArc.Prompts.MidPoint")));
|
|
635
|
-
break;
|
|
636
|
-
}
|
|
637
|
-
super.provideToolAssistance(mainInstrText, additionalInstr);
|
|
638
|
-
}
|
|
639
|
-
setupAccuDraw() {
|
|
640
|
-
const nPts = this.accepted.length;
|
|
641
|
-
if (0 === nPts)
|
|
642
|
-
return;
|
|
643
|
-
const hints = new core_frontend_1.AccuDrawHintBuilder();
|
|
644
|
-
if (this.wantSmartRotation)
|
|
645
|
-
hints.enableSmartRotation = true;
|
|
646
|
-
switch (this.accepted.length) {
|
|
647
|
-
case 1:
|
|
648
|
-
hints.setOrigin(this.accepted[0]);
|
|
649
|
-
if (ArcMethod.CenterStart !== this.method)
|
|
650
|
-
break;
|
|
651
|
-
hints.setOriginFixed = true;
|
|
652
|
-
hints.setModePolar();
|
|
653
|
-
break;
|
|
654
|
-
case 2:
|
|
655
|
-
switch (this.method) {
|
|
656
|
-
case ArcMethod.CenterStart:
|
|
657
|
-
if (!this.accepted[0].isAlmostEqual(this.accepted[1]))
|
|
658
|
-
hints.setXAxis(core_geometry_1.Vector3d.createStartEnd(this.accepted[0], this.accepted[1])); // Rotate AccuDraw to major axis...
|
|
659
|
-
break;
|
|
660
|
-
case ArcMethod.StartCenter:
|
|
661
|
-
let center = this.accepted[1];
|
|
662
|
-
const start = this.accepted[0];
|
|
663
|
-
const vector0 = center.unitVectorTo(start);
|
|
664
|
-
if (undefined === vector0)
|
|
665
|
-
break;
|
|
666
|
-
if (this.useRadius)
|
|
667
|
-
center = start.plusScaled(vector0, -this.radius);
|
|
668
|
-
hints.setOrigin(center);
|
|
669
|
-
hints.setOriginFixed = true;
|
|
670
|
-
hints.setModePolar();
|
|
671
|
-
hints.setXAxis(vector0);
|
|
672
|
-
break;
|
|
673
|
-
default:
|
|
674
|
-
hints.setOrigin(this.accepted[1]);
|
|
675
|
-
break;
|
|
676
|
-
}
|
|
677
|
-
break;
|
|
678
|
-
}
|
|
679
|
-
hints.sendHints();
|
|
680
|
-
}
|
|
681
|
-
static methodMessage(str) { return EditTool_1.EditTools.translate(`CreateArc.Method.${str}`); }
|
|
682
|
-
get methodProperty() {
|
|
683
|
-
if (!this._methodProperty)
|
|
684
|
-
this._methodProperty = new appui_abstract_1.DialogProperty(appui_abstract_1.PropertyDescriptionHelper.buildEnumPicklistEditorDescription("arcMethod", EditTool_1.EditTools.translate("CreateArc.Label.Method"), CreateArcTool.getMethodChoices()), ArcMethod.StartCenter);
|
|
685
|
-
return this._methodProperty;
|
|
686
|
-
}
|
|
687
|
-
get method() { return this.methodProperty.value; }
|
|
688
|
-
set method(method) { this.methodProperty.value = method; }
|
|
689
|
-
get useRadiusProperty() {
|
|
690
|
-
if (!this._useRadiusProperty)
|
|
691
|
-
this._useRadiusProperty = new appui_abstract_1.DialogProperty(appui_abstract_1.PropertyDescriptionHelper.buildLockPropertyDescription("useArcRadius"), false);
|
|
692
|
-
return this._useRadiusProperty;
|
|
693
|
-
}
|
|
694
|
-
get useRadius() { return this.useRadiusProperty.value; }
|
|
695
|
-
set useRadius(value) { this.useRadiusProperty.value = value; }
|
|
696
|
-
get radiusProperty() {
|
|
697
|
-
if (!this._radiusProperty)
|
|
698
|
-
this._radiusProperty = new appui_abstract_1.DialogProperty(new core_frontend_1.LengthDescription("arcRadius", EditTool_1.EditTools.translate("CreateArc.Label.Radius")), 0.1, undefined, !this.useRadius);
|
|
699
|
-
return this._radiusProperty;
|
|
700
|
-
}
|
|
701
|
-
get radius() { return this.radiusProperty.value; }
|
|
702
|
-
set radius(value) { this.radiusProperty.value = value; }
|
|
703
|
-
get useSweepProperty() {
|
|
704
|
-
if (!this._useSweepProperty)
|
|
705
|
-
this._useSweepProperty = new appui_abstract_1.DialogProperty(appui_abstract_1.PropertyDescriptionHelper.buildLockPropertyDescription("useArcSweep"), false);
|
|
706
|
-
return this._useSweepProperty;
|
|
707
|
-
}
|
|
708
|
-
get useSweep() { return this.useSweepProperty.value; }
|
|
709
|
-
set useSweep(value) { this.useSweepProperty.value = value; }
|
|
710
|
-
get sweepProperty() {
|
|
711
|
-
if (!this._sweepProperty)
|
|
712
|
-
this._sweepProperty = new appui_abstract_1.DialogProperty(new core_frontend_1.AngleDescription("arcSweep", EditTool_1.EditTools.translate("CreateArc.Label.Sweep")), Math.PI / 2.0, undefined, !this.useSweep);
|
|
713
|
-
return this._sweepProperty;
|
|
714
|
-
}
|
|
715
|
-
get sweep() { return this.sweepProperty.value; }
|
|
716
|
-
set sweep(value) { this.sweepProperty.value = value; }
|
|
717
|
-
isComplete(_ev) {
|
|
718
|
-
return (3 === this.accepted.length);
|
|
719
|
-
}
|
|
720
|
-
updateCurvePhase() {
|
|
721
|
-
switch (this.accepted.length) {
|
|
722
|
-
case 0:
|
|
723
|
-
this._createCurvePhase = ArcMethod.CenterStart === this.method ? CreateCurvePhase.DefineOther : CreateCurvePhase.DefineStart;
|
|
724
|
-
break;
|
|
725
|
-
case 1:
|
|
726
|
-
if (ArcMethod.CenterStart === this.method)
|
|
727
|
-
this._createCurvePhase = CreateCurvePhase.DefineStart;
|
|
728
|
-
else if (ArcMethod.StartEndMid === this.method)
|
|
729
|
-
this._createCurvePhase = CreateCurvePhase.DefineEnd;
|
|
730
|
-
else
|
|
731
|
-
this._createCurvePhase = CreateCurvePhase.DefineOther;
|
|
732
|
-
break;
|
|
733
|
-
default:
|
|
734
|
-
this._createCurvePhase = ArcMethod.StartEndMid === this.method ? CreateCurvePhase.DefineOther : CreateCurvePhase.DefineEnd;
|
|
735
|
-
break;
|
|
736
|
-
}
|
|
737
|
-
}
|
|
738
|
-
createConstructionCurve(ev, isDynamics) {
|
|
739
|
-
switch (this.accepted.length) {
|
|
740
|
-
case 0: {
|
|
741
|
-
if (ArcMethod.CenterStart === this.method)
|
|
742
|
-
return undefined;
|
|
743
|
-
return core_geometry_1.LineString3d.create([ev.point, ev.point]);
|
|
744
|
-
}
|
|
745
|
-
case 1: {
|
|
746
|
-
const pt1 = this.accepted[0];
|
|
747
|
-
const pt2 = (isDynamics ? ev.point : pt1);
|
|
748
|
-
switch (this.method) {
|
|
749
|
-
case ArcMethod.CenterStart:
|
|
750
|
-
case ArcMethod.StartCenter: {
|
|
751
|
-
if (pt1.isAlmostEqual(pt2))
|
|
752
|
-
return (ArcMethod.StartCenter === this.method ? core_geometry_1.LineString3d.create([pt1, pt2]) : undefined);
|
|
753
|
-
let center = (ArcMethod.CenterStart === this.method ? pt1 : pt2);
|
|
754
|
-
const start = (ArcMethod.CenterStart === this.method ? pt2 : pt1);
|
|
755
|
-
const normal = this.getUpVector(ev);
|
|
756
|
-
const vector0 = core_geometry_1.Vector3d.createStartEnd(center, start);
|
|
757
|
-
const vector90 = normal.crossProduct(vector0);
|
|
758
|
-
const radius = (this.useRadius ? this.radius : vector0.magnitude());
|
|
759
|
-
if (this.useRadius) {
|
|
760
|
-
if (ArcMethod.StartCenter === this.method) {
|
|
761
|
-
vector0.normalizeInPlace();
|
|
762
|
-
center = start.plusScaled(vector0, -radius);
|
|
763
|
-
}
|
|
764
|
-
}
|
|
765
|
-
else {
|
|
766
|
-
this.radius = radius;
|
|
767
|
-
this.syncToolSettingsRadiusAndSweep();
|
|
768
|
-
}
|
|
769
|
-
vector0.scaleToLength(radius, vector0);
|
|
770
|
-
vector90.scaleToLength(radius, vector90);
|
|
771
|
-
return core_geometry_1.Arc3d.create(center, vector0, vector90);
|
|
772
|
-
}
|
|
773
|
-
case ArcMethod.StartMidEnd:
|
|
774
|
-
case ArcMethod.StartEndMid: {
|
|
775
|
-
return core_geometry_1.LineString3d.create([pt1, pt2]);
|
|
776
|
-
}
|
|
777
|
-
default:
|
|
778
|
-
return undefined;
|
|
779
|
-
}
|
|
780
|
-
}
|
|
781
|
-
case 2: {
|
|
782
|
-
switch (this.method) {
|
|
783
|
-
case ArcMethod.CenterStart:
|
|
784
|
-
return core_geometry_1.LineString3d.create([this.accepted[1], this.accepted[0]]);
|
|
785
|
-
case ArcMethod.StartCenter:
|
|
786
|
-
case ArcMethod.StartMidEnd:
|
|
787
|
-
case ArcMethod.StartEndMid:
|
|
788
|
-
return core_geometry_1.LineString3d.create([this.accepted[0], this.accepted[1]]);
|
|
789
|
-
default:
|
|
790
|
-
return undefined;
|
|
791
|
-
}
|
|
792
|
-
}
|
|
793
|
-
default:
|
|
794
|
-
return undefined;
|
|
795
|
-
}
|
|
796
|
-
}
|
|
797
|
-
createNewCurvePrimitive(ev, isDynamics) {
|
|
798
|
-
const numRequired = (isDynamics ? 2 : 3);
|
|
799
|
-
if (this.accepted.length < numRequired) {
|
|
800
|
-
this.isConstruction = true; // Create construction geometry to support join...
|
|
801
|
-
return this.createConstructionCurve(ev, isDynamics);
|
|
802
|
-
}
|
|
803
|
-
const final = (isDynamics ? ev.point : this.accepted[2]);
|
|
804
|
-
const start = (ArcMethod.CenterStart === this.method ? this.accepted[1] : this.accepted[0]);
|
|
805
|
-
const end = (ArcMethod.StartEndMid === this.method ? this.accepted[1] : final);
|
|
806
|
-
switch (this.method) {
|
|
807
|
-
case ArcMethod.CenterStart:
|
|
808
|
-
case ArcMethod.StartCenter:
|
|
809
|
-
let center = (ArcMethod.CenterStart === this.method ? this.accepted[0] : this.accepted[1]);
|
|
810
|
-
if (center.isAlmostEqual(start))
|
|
811
|
-
return undefined; // Don't create 0 radius arc...
|
|
812
|
-
const vector0 = core_geometry_1.Vector3d.createStartEnd(center, start);
|
|
813
|
-
const vector90 = core_geometry_1.Vector3d.create();
|
|
814
|
-
const radius = (this.useRadius ? this.radius : vector0.magnitude());
|
|
815
|
-
const sweep = core_geometry_1.Angle.createRadians(this.useSweep ? this.sweep : core_geometry_1.Angle.pi2Radians);
|
|
816
|
-
if (this.useRadius) {
|
|
817
|
-
if (ArcMethod.StartCenter === this.method) {
|
|
818
|
-
vector0.normalizeInPlace();
|
|
819
|
-
center = start.plusScaled(vector0, -radius);
|
|
820
|
-
}
|
|
821
|
-
}
|
|
822
|
-
else {
|
|
823
|
-
this.radius = radius;
|
|
824
|
-
}
|
|
825
|
-
let defaultArc = (undefined !== this.current && "arc" === this.current.curvePrimitiveType ? this.current : undefined);
|
|
826
|
-
if (undefined === defaultArc) {
|
|
827
|
-
this.getUpVector(ev).crossProduct(vector0, vector90);
|
|
828
|
-
vector0.scaleToLength(radius, vector0);
|
|
829
|
-
vector90.scaleToLength(radius, vector90);
|
|
830
|
-
// Create default arc that follows continuation path start/end tangent...
|
|
831
|
-
if (undefined !== this.continuationData) {
|
|
832
|
-
const pathS = this.continuationData.path.children[0].startPoint();
|
|
833
|
-
if (start.isAlmostEqual(pathS)) {
|
|
834
|
-
const tangentS = this.continuationData.path.children[0].fractionToPointAndUnitTangent(0.0);
|
|
835
|
-
if (vector90.dotProduct(tangentS.direction) > 0.0)
|
|
836
|
-
sweep.setRadians(-sweep.radians);
|
|
837
|
-
}
|
|
838
|
-
else {
|
|
839
|
-
const tangentE = this.continuationData.path.children[this.continuationData.path.children.length - 1].fractionToPointAndUnitTangent(1.0);
|
|
840
|
-
if (vector90.dotProduct(tangentE.direction) < 0.0)
|
|
841
|
-
sweep.setRadians(-sweep.radians);
|
|
842
|
-
}
|
|
843
|
-
}
|
|
844
|
-
defaultArc = core_geometry_1.Arc3d.create(center, vector0, vector90, core_geometry_1.AngleSweep.create(sweep));
|
|
845
|
-
}
|
|
846
|
-
// Don't have well defined minor axis, continue using previous or default arc...
|
|
847
|
-
if (start.isAlmostEqual(end))
|
|
848
|
-
return defaultArc;
|
|
849
|
-
const prevSweep = core_geometry_1.Angle.createRadians(defaultArc.sweep.sweepRadians);
|
|
850
|
-
core_geometry_1.Vector3d.createStartEnd(center, end, vector90);
|
|
851
|
-
sweep.setFrom(vector0.planarAngleTo(vector90, defaultArc.perpendicularVector));
|
|
852
|
-
defaultArc.perpendicularVector.crossProduct(vector0, vector90);
|
|
853
|
-
vector0.scaleToLength(radius, vector0);
|
|
854
|
-
vector90.scaleToLength(radius, vector90);
|
|
855
|
-
if (Math.abs(sweep.radians) < core_geometry_1.Angle.createDegrees(30.0).radians && prevSweep.isFullCircle && ((sweep.radians < 0.0 && prevSweep.radians > 0.0) || (sweep.radians > 0.0 && prevSweep.radians < 0.0)))
|
|
856
|
-
prevSweep.setRadians(-prevSweep.radians); // Reverse direction...
|
|
857
|
-
if (sweep.isAlmostZero)
|
|
858
|
-
sweep.setDegrees(prevSweep.radians < 0.0 ? -360.0 : 360.0); // Create full sweep...
|
|
859
|
-
if (this.useSweep) {
|
|
860
|
-
if ((sweep.radians < 0.0 && this.sweep > 0.0) || (sweep.radians > 0.0 && this.sweep < 0.0))
|
|
861
|
-
sweep.setRadians(-this.sweep);
|
|
862
|
-
else
|
|
863
|
-
sweep.setRadians(this.sweep);
|
|
864
|
-
}
|
|
865
|
-
else {
|
|
866
|
-
if (sweep.radians < 0.0 && prevSweep.radians > 0.0)
|
|
867
|
-
sweep.setRadians(core_geometry_1.Angle.pi2Radians + sweep.radians);
|
|
868
|
-
else if (sweep.radians > 0.0 && prevSweep.radians < 0.0)
|
|
869
|
-
sweep.setRadians(-(core_geometry_1.Angle.pi2Radians - sweep.radians));
|
|
870
|
-
this.sweep = sweep.radians;
|
|
871
|
-
}
|
|
872
|
-
if (!this.useRadius || !this.useSweep)
|
|
873
|
-
this.syncToolSettingsRadiusAndSweep();
|
|
874
|
-
return core_geometry_1.Arc3d.create(center, vector0, vector90, core_geometry_1.AngleSweep.create(sweep));
|
|
875
|
-
case ArcMethod.StartMidEnd:
|
|
876
|
-
case ArcMethod.StartEndMid:
|
|
877
|
-
const mid = (ArcMethod.StartEndMid === this.method ? final : this.accepted[1]);
|
|
878
|
-
return core_geometry_1.Arc3d.createCircularStartMiddleEnd(start, mid, end);
|
|
879
|
-
}
|
|
880
|
-
}
|
|
881
|
-
syncToolSettingsRadiusAndSweep() {
|
|
882
|
-
switch (this.method) {
|
|
883
|
-
case ArcMethod.CenterStart:
|
|
884
|
-
case ArcMethod.StartCenter:
|
|
885
|
-
if (this.useRadius && this.useSweep)
|
|
886
|
-
return;
|
|
887
|
-
break;
|
|
888
|
-
default:
|
|
889
|
-
return;
|
|
890
|
-
}
|
|
891
|
-
const syncData = [];
|
|
892
|
-
if (!this.useRadius)
|
|
893
|
-
syncData.push(this.radiusProperty.syncItem);
|
|
894
|
-
if (!this.useSweep)
|
|
895
|
-
syncData.push(this.sweepProperty.syncItem);
|
|
896
|
-
if (0 !== syncData.length)
|
|
897
|
-
this.syncToolSettingsProperties(syncData);
|
|
898
|
-
}
|
|
899
|
-
getToolSettingPropertyLocked(property) {
|
|
900
|
-
if (property === this.useRadiusProperty)
|
|
901
|
-
return this.radiusProperty;
|
|
902
|
-
else if (property === this.useSweepProperty)
|
|
903
|
-
return this.sweepProperty;
|
|
904
|
-
return undefined;
|
|
905
|
-
}
|
|
906
|
-
async applyToolSettingPropertyChange(updatedValue) {
|
|
907
|
-
if (!this.changeToolSettingPropertyValue(updatedValue))
|
|
908
|
-
return false;
|
|
909
|
-
if (this.methodProperty.name === updatedValue.propertyName)
|
|
910
|
-
await this.onReinitialize();
|
|
911
|
-
else if (updatedValue.propertyName === this.radiusProperty.name && ArcMethod.StartCenter === this.method && this.useRadius && 2 === this.accepted.length)
|
|
912
|
-
await this.onUndoPreviousStep(); // If radius is changed when creating arc by start/center after center has been defined, back up a step to defined a new center point...
|
|
913
|
-
return true;
|
|
914
|
-
}
|
|
915
|
-
supplyToolSettingsProperties() {
|
|
916
|
-
const toolSettings = new Array();
|
|
917
|
-
toolSettings.push(this.methodProperty.toDialogItem({ rowPriority: 1, columnIndex: 0 }));
|
|
918
|
-
if (ArcMethod.CenterStart === this.method || ArcMethod.StartCenter === this.method) {
|
|
919
|
-
// ensure controls are enabled/disabled base on current lock property state
|
|
920
|
-
this.radiusProperty.isDisabled = !this.useRadius;
|
|
921
|
-
this.sweepProperty.isDisabled = !this.useSweep;
|
|
922
|
-
const useRadiusLock = this.useRadiusProperty.toDialogItem({ rowPriority: 2, columnIndex: 0 });
|
|
923
|
-
const useSweepLock = this.useSweepProperty.toDialogItem({ rowPriority: 3, columnIndex: 0 });
|
|
924
|
-
toolSettings.push(this.radiusProperty.toDialogItem({ rowPriority: 2, columnIndex: 1 }, useRadiusLock));
|
|
925
|
-
toolSettings.push(this.sweepProperty.toDialogItem({ rowPriority: 3, columnIndex: 1 }, useSweepLock));
|
|
926
|
-
}
|
|
927
|
-
return toolSettings;
|
|
928
|
-
}
|
|
929
|
-
async onRestartTool() {
|
|
930
|
-
const tool = new CreateArcTool();
|
|
931
|
-
if (!await tool.run())
|
|
932
|
-
return this.exitTool();
|
|
933
|
-
}
|
|
934
|
-
async onInstall() {
|
|
935
|
-
if (!await super.onInstall())
|
|
936
|
-
return false;
|
|
937
|
-
// Setup initial values here instead of supplyToolSettingsProperties to support keyin args w/o appui-react...
|
|
938
|
-
this.initializeToolSettingPropertyValues([this.methodProperty, this.radiusProperty, this.useRadiusProperty, this.sweepProperty, this.useSweepProperty]);
|
|
939
|
-
if (!this.radius)
|
|
940
|
-
this.useRadius = false;
|
|
941
|
-
if (!this.sweep)
|
|
942
|
-
this.useSweep = false;
|
|
943
|
-
return true;
|
|
944
|
-
}
|
|
945
|
-
/** The keyin takes the following arguments, all of which are optional:
|
|
946
|
-
* - `method=0|1|2|3` How arc will be defined. 0 for center/start, 1 for start/center, 2 for start/mid/end, and 3 for start/end/mid.
|
|
947
|
-
* - `radius=number` Arc radius for start/center or center/start, 0 to define by points.
|
|
948
|
-
* - `sweep=number` Arc sweep angle in degrees for start/center or center/start, 0 to define by points.
|
|
949
|
-
*/
|
|
950
|
-
async parseAndRun(...inputArgs) {
|
|
951
|
-
let arcMethod;
|
|
952
|
-
let arcRadius;
|
|
953
|
-
let arcSweep;
|
|
954
|
-
for (const arg of inputArgs) {
|
|
955
|
-
const parts = arg.split("=");
|
|
956
|
-
if (2 !== parts.length)
|
|
957
|
-
continue;
|
|
958
|
-
if (parts[0].toLowerCase().startsWith("me")) {
|
|
959
|
-
const method = Number.parseInt(parts[1], 10);
|
|
960
|
-
if (!Number.isNaN(method)) {
|
|
961
|
-
switch (method) {
|
|
962
|
-
case 0:
|
|
963
|
-
arcMethod = ArcMethod.CenterStart;
|
|
964
|
-
break;
|
|
965
|
-
case 1:
|
|
966
|
-
arcMethod = ArcMethod.StartCenter;
|
|
967
|
-
break;
|
|
968
|
-
case 2:
|
|
969
|
-
arcMethod = ArcMethod.StartMidEnd;
|
|
970
|
-
break;
|
|
971
|
-
case 3:
|
|
972
|
-
arcMethod = ArcMethod.StartEndMid;
|
|
973
|
-
break;
|
|
974
|
-
}
|
|
975
|
-
}
|
|
976
|
-
}
|
|
977
|
-
else if (parts[0].toLowerCase().startsWith("ra")) {
|
|
978
|
-
const radius = Number.parseFloat(parts[1]);
|
|
979
|
-
if (!Number.isNaN(radius)) {
|
|
980
|
-
arcRadius = radius;
|
|
981
|
-
}
|
|
982
|
-
}
|
|
983
|
-
else if (parts[0].toLowerCase().startsWith("sw")) {
|
|
984
|
-
const sweep = Number.parseFloat(parts[1]);
|
|
985
|
-
if (!Number.isNaN(sweep)) {
|
|
986
|
-
arcSweep = core_geometry_1.Angle.createDegrees(sweep).radians;
|
|
987
|
-
}
|
|
988
|
-
}
|
|
989
|
-
}
|
|
990
|
-
// Update current session values so keyin args are picked up for tool settings/restart...
|
|
991
|
-
if (undefined !== arcMethod)
|
|
992
|
-
this.saveToolSettingPropertyValue(this.methodProperty, { value: arcMethod });
|
|
993
|
-
if (undefined !== arcRadius) {
|
|
994
|
-
if (0.0 !== arcRadius)
|
|
995
|
-
this.saveToolSettingPropertyValue(this.radiusProperty, { value: arcRadius });
|
|
996
|
-
this.saveToolSettingPropertyValue(this.useRadiusProperty, { value: 0.0 !== arcRadius });
|
|
997
|
-
}
|
|
998
|
-
if (undefined !== arcSweep) {
|
|
999
|
-
if (0.0 !== arcSweep)
|
|
1000
|
-
this.saveToolSettingPropertyValue(this.sweepProperty, { value: arcSweep });
|
|
1001
|
-
this.saveToolSettingPropertyValue(this.useSweepProperty, { value: 0.0 !== arcSweep });
|
|
1002
|
-
}
|
|
1003
|
-
return this.run();
|
|
1004
|
-
}
|
|
1005
|
-
}
|
|
1006
|
-
CreateArcTool.toolId = "CreateArc";
|
|
1007
|
-
CreateArcTool.iconSpec = "icon-three-points-circular-arc";
|
|
1008
|
-
CreateArcTool.getMethodChoices = () => {
|
|
1009
|
-
return [
|
|
1010
|
-
{ label: CreateArcTool.methodMessage("CenterStart"), value: ArcMethod.CenterStart },
|
|
1011
|
-
{ label: CreateArcTool.methodMessage("StartCenter"), value: ArcMethod.StartCenter },
|
|
1012
|
-
{ label: CreateArcTool.methodMessage("StartMidEnd"), value: ArcMethod.StartMidEnd },
|
|
1013
|
-
{ label: CreateArcTool.methodMessage("StartEndMid"), value: ArcMethod.StartEndMid },
|
|
1014
|
-
];
|
|
1015
|
-
};
|
|
1016
|
-
exports.CreateArcTool = CreateArcTool;
|
|
1017
|
-
/** @alpha */
|
|
1018
|
-
var CircleMethod;
|
|
1019
|
-
(function (CircleMethod) {
|
|
1020
|
-
CircleMethod[CircleMethod["Center"] = 0] = "Center";
|
|
1021
|
-
CircleMethod[CircleMethod["Edge"] = 1] = "Edge";
|
|
1022
|
-
})(CircleMethod = exports.CircleMethod || (exports.CircleMethod = {}));
|
|
1023
|
-
/** @alpha Creates a circle. Uses model and category from [[BriefcaseConnection.editorToolSettings]]. */
|
|
1024
|
-
class CreateCircleTool extends CreateOrContinuePathTool {
|
|
1025
|
-
static get minArgs() { return 0; }
|
|
1026
|
-
static get maxArgs() { return 2; } // method, radius - zero value unlocks associated "use" toggle...
|
|
1027
|
-
get showCurveConstructions() { return !(CircleMethod.Center === this.method && this.useRadius); }
|
|
1028
|
-
provideToolAssistance(mainInstrText, additionalInstr) {
|
|
1029
|
-
const nPts = this.accepted.length;
|
|
1030
|
-
switch (this.method) {
|
|
1031
|
-
case CircleMethod.Center:
|
|
1032
|
-
mainInstrText = EditTool_1.EditTools.translate(0 === nPts ? "CreateCircle.Prompts.CenterPoint" : "CreateCircle.Prompts.EdgePoint");
|
|
1033
|
-
break;
|
|
1034
|
-
case CircleMethod.Edge:
|
|
1035
|
-
mainInstrText = EditTool_1.EditTools.translate(0 === nPts ? "CreateCircle.Prompts.EdgePoint" : "CreateCircle.Prompts.CenterPoint");
|
|
1036
|
-
break;
|
|
1037
|
-
}
|
|
1038
|
-
super.provideToolAssistance(mainInstrText, additionalInstr);
|
|
1039
|
-
}
|
|
1040
|
-
setupAccuDraw() {
|
|
1041
|
-
const nPts = this.accepted.length;
|
|
1042
|
-
if (0 === nPts)
|
|
1043
|
-
return;
|
|
1044
|
-
const hints = new core_frontend_1.AccuDrawHintBuilder();
|
|
1045
|
-
if (this.wantSmartRotation)
|
|
1046
|
-
hints.enableSmartRotation = true;
|
|
1047
|
-
if (CircleMethod.Center === this.method && 1 === this.accepted.length) {
|
|
1048
|
-
hints.setOrigin(this.accepted[0]);
|
|
1049
|
-
hints.setOriginFixed = true;
|
|
1050
|
-
hints.setModePolar();
|
|
1051
|
-
}
|
|
1052
|
-
hints.sendHints();
|
|
1053
|
-
}
|
|
1054
|
-
static methodMessage(str) { return EditTool_1.EditTools.translate(`CreateCircle.Method.${str}`); }
|
|
1055
|
-
get methodProperty() {
|
|
1056
|
-
if (!this._methodProperty)
|
|
1057
|
-
this._methodProperty = new appui_abstract_1.DialogProperty(appui_abstract_1.PropertyDescriptionHelper.buildEnumPicklistEditorDescription("circleMethod", EditTool_1.EditTools.translate("CreateCircle.Label.Method"), CreateCircleTool.getMethodChoices()), CircleMethod.Center);
|
|
1058
|
-
return this._methodProperty;
|
|
1059
|
-
}
|
|
1060
|
-
get method() { return this.methodProperty.value; }
|
|
1061
|
-
set method(method) { this.methodProperty.value = method; }
|
|
1062
|
-
get useRadiusProperty() {
|
|
1063
|
-
if (!this._useRadiusProperty)
|
|
1064
|
-
this._useRadiusProperty = new appui_abstract_1.DialogProperty(appui_abstract_1.PropertyDescriptionHelper.buildLockPropertyDescription("useCircleRadius"), false);
|
|
1065
|
-
return this._useRadiusProperty;
|
|
1066
|
-
}
|
|
1067
|
-
get useRadius() { return this.useRadiusProperty.value; }
|
|
1068
|
-
set useRadius(value) { this.useRadiusProperty.value = value; }
|
|
1069
|
-
get radiusProperty() {
|
|
1070
|
-
if (!this._radiusProperty)
|
|
1071
|
-
this._radiusProperty = new appui_abstract_1.DialogProperty(new core_frontend_1.LengthDescription("circleRadius", EditTool_1.EditTools.translate("CreateCircle.Label.Radius")), 0.1, undefined, !this.useRadius);
|
|
1072
|
-
return this._radiusProperty;
|
|
1073
|
-
}
|
|
1074
|
-
get radius() { return this.radiusProperty.value; }
|
|
1075
|
-
set radius(value) { this.radiusProperty.value = value; }
|
|
1076
|
-
isComplete(_ev) {
|
|
1077
|
-
if (CircleMethod.Center === this.method && this.useRadius)
|
|
1078
|
-
return (this.accepted.length >= 1); // Could be 2 if radius locked after 1st data point...
|
|
1079
|
-
return (2 === this.accepted.length);
|
|
1080
|
-
}
|
|
1081
|
-
createNewCurvePrimitive(ev, isDynamics) {
|
|
1082
|
-
this.isClosed = true; // Always closed...
|
|
1083
|
-
const numRequired = (isDynamics ? 1 : 2);
|
|
1084
|
-
if (this.accepted.length < numRequired) {
|
|
1085
|
-
if (CircleMethod.Center === this.method && this.useRadius)
|
|
1086
|
-
return core_geometry_1.Arc3d.createCenterNormalRadius(isDynamics ? ev.point : this.accepted[0], this.getUpVector(ev), this.radius);
|
|
1087
|
-
return undefined;
|
|
1088
|
-
}
|
|
1089
|
-
const pt1 = this.accepted[0];
|
|
1090
|
-
const pt2 = (isDynamics ? ev.point : this.accepted[1]);
|
|
1091
|
-
let center = (CircleMethod.Center === this.method ? pt1 : pt2);
|
|
1092
|
-
const edge = (CircleMethod.Center === this.method ? pt2 : pt1);
|
|
1093
|
-
const normal = this.getUpVector(ev);
|
|
1094
|
-
const vector0 = core_geometry_1.Vector3d.createStartEnd(center, edge);
|
|
1095
|
-
const vector90 = normal.crossProduct(vector0);
|
|
1096
|
-
const radius = (this.useRadius ? this.radius : vector0.magnitude());
|
|
1097
|
-
if (this.useRadius) {
|
|
1098
|
-
if (CircleMethod.Edge === this.method) {
|
|
1099
|
-
vector0.normalizeInPlace();
|
|
1100
|
-
center = edge.plusScaled(vector0, -radius);
|
|
1101
|
-
}
|
|
1102
|
-
}
|
|
1103
|
-
else {
|
|
1104
|
-
this.radius = radius;
|
|
1105
|
-
this.syncToolSettingPropertyValue(this.radiusProperty);
|
|
1106
|
-
}
|
|
1107
|
-
vector0.scaleToLength(radius, vector0);
|
|
1108
|
-
vector90.scaleToLength(radius, vector90);
|
|
1109
|
-
return core_geometry_1.Arc3d.create(center, vector0, vector90);
|
|
1110
|
-
}
|
|
1111
|
-
async cancelPoint(_ev) {
|
|
1112
|
-
if (CircleMethod.Center === this.method && this.useRadius) {
|
|
1113
|
-
// Exit instead of restarting to avoid having circle "stuck" on cursor...
|
|
1114
|
-
await this.exitTool();
|
|
1115
|
-
return false;
|
|
1116
|
-
}
|
|
1117
|
-
return true;
|
|
1118
|
-
}
|
|
1119
|
-
getToolSettingPropertyLocked(property) {
|
|
1120
|
-
return (property === this.useRadiusProperty ? this.radiusProperty : undefined);
|
|
1121
|
-
}
|
|
1122
|
-
async applyToolSettingPropertyChange(updatedValue) {
|
|
1123
|
-
if (!this.changeToolSettingPropertyValue(updatedValue))
|
|
1124
|
-
return false;
|
|
1125
|
-
if (this.methodProperty.name === updatedValue.propertyName)
|
|
1126
|
-
await this.onReinitialize();
|
|
1127
|
-
else if (updatedValue.propertyName === this.useRadiusProperty.name && CircleMethod.Center === this.method && this.useRadius && 0 === this.accepted.length)
|
|
1128
|
-
await this.onReinitialize();
|
|
1129
|
-
return true;
|
|
1130
|
-
}
|
|
1131
|
-
supplyToolSettingsProperties() {
|
|
1132
|
-
const toolSettings = new Array();
|
|
1133
|
-
toolSettings.push(this.methodProperty.toDialogItem({ rowPriority: 1, columnIndex: 0 }));
|
|
1134
|
-
// ensure controls are enabled/disabled base on current lock property state
|
|
1135
|
-
this.radiusProperty.isDisabled = !this.useRadius;
|
|
1136
|
-
const useRadiusLock = this.useRadiusProperty.toDialogItem({ rowPriority: 2, columnIndex: 0 });
|
|
1137
|
-
toolSettings.push(this.radiusProperty.toDialogItem({ rowPriority: 2, columnIndex: 1 }, useRadiusLock));
|
|
1138
|
-
return toolSettings;
|
|
1139
|
-
}
|
|
1140
|
-
async onRestartTool() {
|
|
1141
|
-
const tool = new CreateCircleTool();
|
|
1142
|
-
if (!await tool.run())
|
|
1143
|
-
return this.exitTool();
|
|
1144
|
-
}
|
|
1145
|
-
async onReinitialize() {
|
|
1146
|
-
if (CircleMethod.Center === this.method && this.useRadius) {
|
|
1147
|
-
// Don't install a new tool instance, we want to preserve current AccuDraw state...
|
|
1148
|
-
this.accepted.length = 0;
|
|
1149
|
-
this.setupAndPromptForNextAction();
|
|
1150
|
-
this.beginDynamics();
|
|
1151
|
-
return;
|
|
1152
|
-
}
|
|
1153
|
-
return super.onReinitialize();
|
|
1154
|
-
}
|
|
1155
|
-
async onPostInstall() {
|
|
1156
|
-
await super.onPostInstall();
|
|
1157
|
-
if (CircleMethod.Center === this.method && this.useRadius) {
|
|
1158
|
-
// Start dynamics before 1st data point when placing by center w/locked radius value.
|
|
1159
|
-
// Require the user to explicitly enable AccuDraw so that the compass location can be adjusted for changes
|
|
1160
|
-
// to locks or view ACS (as opposed to appearing at it's previous or default location).
|
|
1161
|
-
core_frontend_1.AccuDrawHintBuilder.deactivate();
|
|
1162
|
-
this.beginDynamics();
|
|
1163
|
-
}
|
|
1164
|
-
}
|
|
1165
|
-
async onInstall() {
|
|
1166
|
-
if (!await super.onInstall())
|
|
1167
|
-
return false;
|
|
1168
|
-
// Setup initial values here instead of supplyToolSettingsProperties to support keyin args w/o appui-react...
|
|
1169
|
-
this.initializeToolSettingPropertyValues([this.methodProperty, this.radiusProperty, this.useRadiusProperty]);
|
|
1170
|
-
if (!this.radius)
|
|
1171
|
-
this.useRadius = false;
|
|
1172
|
-
return true;
|
|
1173
|
-
}
|
|
1174
|
-
/** The keyin takes the following arguments, all of which are optional:
|
|
1175
|
-
* - `method=0|1` How circle will be defined. 0 for center, 1 for edge.
|
|
1176
|
-
* - `radius=number` Circle radius, 0 to define by points.
|
|
1177
|
-
*/
|
|
1178
|
-
async parseAndRun(...inputArgs) {
|
|
1179
|
-
let circleMethod;
|
|
1180
|
-
let circleRadius;
|
|
1181
|
-
for (const arg of inputArgs) {
|
|
1182
|
-
const parts = arg.split("=");
|
|
1183
|
-
if (2 !== parts.length)
|
|
1184
|
-
continue;
|
|
1185
|
-
if (parts[0].toLowerCase().startsWith("me")) {
|
|
1186
|
-
const method = Number.parseInt(parts[1], 10);
|
|
1187
|
-
if (!Number.isNaN(method)) {
|
|
1188
|
-
switch (method) {
|
|
1189
|
-
case 0:
|
|
1190
|
-
circleMethod = CircleMethod.Center;
|
|
1191
|
-
break;
|
|
1192
|
-
case 1:
|
|
1193
|
-
circleMethod = CircleMethod.Edge;
|
|
1194
|
-
break;
|
|
1195
|
-
}
|
|
1196
|
-
}
|
|
1197
|
-
}
|
|
1198
|
-
else if (parts[0].toLowerCase().startsWith("ra")) {
|
|
1199
|
-
const radius = Number.parseFloat(parts[1]);
|
|
1200
|
-
if (!Number.isNaN(radius)) {
|
|
1201
|
-
circleRadius = radius;
|
|
1202
|
-
}
|
|
1203
|
-
}
|
|
1204
|
-
}
|
|
1205
|
-
// Update current session values so keyin args are picked up for tool settings/restart...
|
|
1206
|
-
if (undefined !== circleMethod)
|
|
1207
|
-
this.saveToolSettingPropertyValue(this.methodProperty, { value: circleMethod });
|
|
1208
|
-
if (undefined !== circleRadius) {
|
|
1209
|
-
if (0.0 !== circleRadius)
|
|
1210
|
-
this.saveToolSettingPropertyValue(this.radiusProperty, { value: circleRadius });
|
|
1211
|
-
this.saveToolSettingPropertyValue(this.useRadiusProperty, { value: 0.0 !== circleRadius });
|
|
1212
|
-
}
|
|
1213
|
-
return this.run();
|
|
1214
|
-
}
|
|
1215
|
-
}
|
|
1216
|
-
CreateCircleTool.toolId = "CreateCircle";
|
|
1217
|
-
CreateCircleTool.iconSpec = "icon-circle";
|
|
1218
|
-
CreateCircleTool.getMethodChoices = () => {
|
|
1219
|
-
return [
|
|
1220
|
-
{ label: CreateCircleTool.methodMessage("Center"), value: CircleMethod.Center },
|
|
1221
|
-
{ label: CreateCircleTool.methodMessage("Edge"), value: CircleMethod.Edge },
|
|
1222
|
-
];
|
|
1223
|
-
};
|
|
1224
|
-
exports.CreateCircleTool = CreateCircleTool;
|
|
1225
|
-
/** @alpha Creates an ellipse. Uses model and category from [[BriefcaseConnection.editorToolSettings]]. */
|
|
1226
|
-
class CreateEllipseTool extends CreateOrContinuePathTool {
|
|
1227
|
-
isComplete(_ev) {
|
|
1228
|
-
return (3 === this.accepted.length);
|
|
1229
|
-
}
|
|
1230
|
-
provideToolAssistance(mainInstrText, additionalInstr) {
|
|
1231
|
-
const nPts = this.accepted.length;
|
|
1232
|
-
switch (nPts) {
|
|
1233
|
-
case 0:
|
|
1234
|
-
mainInstrText = EditTool_1.EditTools.translate("CreateEllipse.Prompts.CenterPoint");
|
|
1235
|
-
break;
|
|
1236
|
-
case 1:
|
|
1237
|
-
mainInstrText = EditTool_1.EditTools.translate("CreateEllipse.Prompts.MajorAxis");
|
|
1238
|
-
break;
|
|
1239
|
-
case 2:
|
|
1240
|
-
mainInstrText = EditTool_1.EditTools.translate("CreateEllipse.Prompts.MinorAxis");
|
|
1241
|
-
break;
|
|
1242
|
-
}
|
|
1243
|
-
super.provideToolAssistance(mainInstrText, additionalInstr);
|
|
1244
|
-
}
|
|
1245
|
-
setupAccuDraw() {
|
|
1246
|
-
const nPts = this.accepted.length;
|
|
1247
|
-
if (0 === nPts)
|
|
1248
|
-
return;
|
|
1249
|
-
const hints = new core_frontend_1.AccuDrawHintBuilder();
|
|
1250
|
-
if (this.wantSmartRotation)
|
|
1251
|
-
hints.enableSmartRotation = true;
|
|
1252
|
-
switch (nPts) {
|
|
1253
|
-
case 1:
|
|
1254
|
-
hints.setOrigin(this.accepted[0]);
|
|
1255
|
-
hints.setOriginFixed = true;
|
|
1256
|
-
break;
|
|
1257
|
-
case 2:
|
|
1258
|
-
hints.setXAxis(core_geometry_1.Vector3d.createStartEnd(this.accepted[0], this.accepted[1]));
|
|
1259
|
-
hints.setLockX = true;
|
|
1260
|
-
break;
|
|
1261
|
-
}
|
|
1262
|
-
hints.sendHints();
|
|
1263
|
-
}
|
|
1264
|
-
createNewCurvePrimitive(ev, isDynamics) {
|
|
1265
|
-
const numRequired = (isDynamics ? 2 : 3);
|
|
1266
|
-
if (this.accepted.length < numRequired) {
|
|
1267
|
-
if (this.accepted.length < (numRequired - 1))
|
|
1268
|
-
return undefined;
|
|
1269
|
-
this.isConstruction = true; // Create construction geometry to show major axis...
|
|
1270
|
-
return core_geometry_1.LineString3d.create([this.accepted[0], (isDynamics ? ev.point : this.accepted[1])]);
|
|
1271
|
-
}
|
|
1272
|
-
this.isClosed = true; // Always closed...
|
|
1273
|
-
const center = this.accepted[0];
|
|
1274
|
-
const major = this.accepted[1];
|
|
1275
|
-
const normal = this.getUpVector(ev);
|
|
1276
|
-
const vector0 = core_geometry_1.Vector3d.createStartEnd(center, major);
|
|
1277
|
-
const vector90 = normal.crossProduct(vector0);
|
|
1278
|
-
const dir = core_geometry_1.Ray3d.create(center, vector90);
|
|
1279
|
-
const minor = dir.projectPointToRay(isDynamics ? ev.point : this.accepted[2]);
|
|
1280
|
-
vector90.scaleToLength(center.distance(minor), vector90);
|
|
1281
|
-
return core_geometry_1.Arc3d.create(center, vector0, vector90);
|
|
1282
|
-
}
|
|
1283
|
-
async onRestartTool() {
|
|
1284
|
-
const tool = new CreateEllipseTool();
|
|
1285
|
-
if (!await tool.run())
|
|
1286
|
-
return this.exitTool();
|
|
1287
|
-
}
|
|
1288
|
-
}
|
|
1289
|
-
CreateEllipseTool.toolId = "CreateEllipse";
|
|
1290
|
-
CreateEllipseTool.iconSpec = "icon-ellipse";
|
|
1291
|
-
exports.CreateEllipseTool = CreateEllipseTool;
|
|
1292
|
-
/** @alpha Creates a rectangle by corner points. Uses model and category from [[BriefcaseConnection.editorToolSettings]]. */
|
|
1293
|
-
class CreateRectangleTool extends CreateOrContinuePathTool {
|
|
1294
|
-
constructor() {
|
|
1295
|
-
super(...arguments);
|
|
1296
|
-
this.localToWorld = core_geometry_1.Transform.createIdentity();
|
|
1297
|
-
}
|
|
1298
|
-
static get minArgs() { return 0; }
|
|
1299
|
-
static get maxArgs() { return 1; } // radius - zero value unlocks associated "use" toggle...
|
|
1300
|
-
provideToolAssistance(mainInstrText, additionalInstr) {
|
|
1301
|
-
mainInstrText = core_frontend_1.CoreTools.translate(0 === this.accepted.length ? "ElementSet.Prompts.StartCorner" : "ElementSet.Prompts.OppositeCorner");
|
|
1302
|
-
super.provideToolAssistance(mainInstrText, additionalInstr);
|
|
1303
|
-
}
|
|
1304
|
-
setupAccuDraw() {
|
|
1305
|
-
const nPts = this.accepted.length;
|
|
1306
|
-
if (0 === nPts)
|
|
1307
|
-
return;
|
|
1308
|
-
const hints = new core_frontend_1.AccuDrawHintBuilder();
|
|
1309
|
-
if (this.wantSmartRotation)
|
|
1310
|
-
hints.enableSmartRotation = true;
|
|
1311
|
-
hints.setOrigin(this.accepted[0]);
|
|
1312
|
-
hints.sendHints();
|
|
1313
|
-
}
|
|
1314
|
-
get useRadiusProperty() {
|
|
1315
|
-
if (!this._useRadiusProperty)
|
|
1316
|
-
this._useRadiusProperty = new appui_abstract_1.DialogProperty(appui_abstract_1.PropertyDescriptionHelper.buildLockPropertyDescription("useCornerRadius"), false);
|
|
1317
|
-
return this._useRadiusProperty;
|
|
1318
|
-
}
|
|
1319
|
-
get useRadius() { return this.useRadiusProperty.value; }
|
|
1320
|
-
set useRadius(value) { this.useRadiusProperty.value = value; }
|
|
1321
|
-
get radiusProperty() {
|
|
1322
|
-
if (!this._radiusProperty)
|
|
1323
|
-
this._radiusProperty = new appui_abstract_1.DialogProperty(new core_frontend_1.LengthDescription("cornerRadius", EditTool_1.EditTools.translate("CreateRectangle.Label.CornerRadius")), 0.1, undefined, !this.useRadius);
|
|
1324
|
-
return this._radiusProperty;
|
|
1325
|
-
}
|
|
1326
|
-
get radius() { return this.radiusProperty.value; }
|
|
1327
|
-
set radius(value) { this.radiusProperty.value = value; }
|
|
1328
|
-
isComplete(_ev) {
|
|
1329
|
-
return (2 === this.accepted.length);
|
|
1330
|
-
}
|
|
1331
|
-
createNewCurvePrimitive(ev, isDynamics) {
|
|
1332
|
-
const numRequired = (isDynamics ? 1 : 2);
|
|
1333
|
-
if (this.accepted.length < numRequired)
|
|
1334
|
-
return undefined;
|
|
1335
|
-
const origin = this.accepted[0];
|
|
1336
|
-
const corner = (isDynamics ? ev.point : this.accepted[1]);
|
|
1337
|
-
const matrix = this.getCurrentRotation(ev);
|
|
1338
|
-
core_geometry_1.Transform.createOriginAndMatrix(core_geometry_1.Point3d.createZero(), matrix, this.localToWorld);
|
|
1339
|
-
this.originLocal = this.localToWorld.multiplyInversePoint3d(origin);
|
|
1340
|
-
this.cornerLocal = this.localToWorld.multiplyInversePoint3d(corner);
|
|
1341
|
-
if (undefined === this.originLocal || undefined === this.cornerLocal)
|
|
1342
|
-
return undefined;
|
|
1343
|
-
const shapePts = [];
|
|
1344
|
-
shapePts[0] = core_geometry_1.Point3d.create(this.originLocal.x, this.originLocal.y, this.originLocal.z);
|
|
1345
|
-
shapePts[1] = core_geometry_1.Point3d.create(this.cornerLocal.x, this.originLocal.y, this.cornerLocal.z);
|
|
1346
|
-
shapePts[2] = core_geometry_1.Point3d.create(this.cornerLocal.x, this.cornerLocal.y, this.cornerLocal.z);
|
|
1347
|
-
shapePts[3] = core_geometry_1.Point3d.create(this.originLocal.x, this.cornerLocal.y, this.originLocal.z);
|
|
1348
|
-
shapePts[4] = shapePts[0].clone();
|
|
1349
|
-
this.localToWorld.multiplyPoint3dArrayInPlace(shapePts);
|
|
1350
|
-
this.isClosed = true; // Always closed...
|
|
1351
|
-
return core_geometry_1.LineString3d.create(shapePts);
|
|
1352
|
-
}
|
|
1353
|
-
createNewPath(placement) {
|
|
1354
|
-
if (!this.useRadius || 0.0 === this.radius || undefined === this.originLocal || undefined === this.cornerLocal)
|
|
1355
|
-
return super.createNewPath(placement);
|
|
1356
|
-
const builder = new core_common_1.ElementGeometry.Builder();
|
|
1357
|
-
builder.setLocalToWorldFromPlacement(placement);
|
|
1358
|
-
const loop = core_geometry_1.CurveFactory.createRectangleXY(this.originLocal.x, this.originLocal.y, this.cornerLocal.x, this.cornerLocal.y, this.originLocal.z, this.radius);
|
|
1359
|
-
loop.tryTransformInPlace(this.localToWorld);
|
|
1360
|
-
if (!builder.appendGeometryQuery(loop))
|
|
1361
|
-
return;
|
|
1362
|
-
return { format: "flatbuffer", data: builder.entries };
|
|
1363
|
-
}
|
|
1364
|
-
getToolSettingPropertyLocked(property) {
|
|
1365
|
-
return (property === this.useRadiusProperty ? this.radiusProperty : undefined);
|
|
1366
|
-
}
|
|
1367
|
-
async applyToolSettingPropertyChange(updatedValue) {
|
|
1368
|
-
return this.changeToolSettingPropertyValue(updatedValue);
|
|
1369
|
-
}
|
|
1370
|
-
supplyToolSettingsProperties() {
|
|
1371
|
-
const toolSettings = new Array();
|
|
1372
|
-
// ensure controls are enabled/disabled base on current lock property state
|
|
1373
|
-
this.radiusProperty.isDisabled = !this.useRadius;
|
|
1374
|
-
const useRadiusLock = this.useRadiusProperty.toDialogItem({ rowPriority: 1, columnIndex: 0 });
|
|
1375
|
-
toolSettings.push(this.radiusProperty.toDialogItem({ rowPriority: 1, columnIndex: 1 }, useRadiusLock));
|
|
1376
|
-
return toolSettings;
|
|
1377
|
-
}
|
|
1378
|
-
async onRestartTool() {
|
|
1379
|
-
const tool = new CreateRectangleTool();
|
|
1380
|
-
if (!await tool.run())
|
|
1381
|
-
return this.exitTool();
|
|
1382
|
-
}
|
|
1383
|
-
async onInstall() {
|
|
1384
|
-
if (!await super.onInstall())
|
|
1385
|
-
return false;
|
|
1386
|
-
// Setup initial values here instead of supplyToolSettingsProperties to support keyin args w/o appui-react...
|
|
1387
|
-
this.initializeToolSettingPropertyValues([this.radiusProperty, this.useRadiusProperty]);
|
|
1388
|
-
if (!this.radius)
|
|
1389
|
-
this.useRadius = false;
|
|
1390
|
-
return true;
|
|
1391
|
-
}
|
|
1392
|
-
/** The keyin takes the following arguments, all of which are optional:
|
|
1393
|
-
* - `radius=number` Corner radius, 0 for sharp corners.
|
|
1394
|
-
*/
|
|
1395
|
-
async parseAndRun(...inputArgs) {
|
|
1396
|
-
let cornerRadius;
|
|
1397
|
-
for (const arg of inputArgs) {
|
|
1398
|
-
const parts = arg.split("=");
|
|
1399
|
-
if (2 !== parts.length)
|
|
1400
|
-
continue;
|
|
1401
|
-
if (parts[0].toLowerCase().startsWith("ra")) {
|
|
1402
|
-
const radius = Number.parseFloat(parts[1]);
|
|
1403
|
-
if (!Number.isNaN(radius)) {
|
|
1404
|
-
cornerRadius = radius;
|
|
1405
|
-
}
|
|
1406
|
-
}
|
|
1407
|
-
}
|
|
1408
|
-
// Update current session values so keyin args are picked up for tool settings/restart...
|
|
1409
|
-
if (undefined !== cornerRadius) {
|
|
1410
|
-
if (0.0 !== cornerRadius)
|
|
1411
|
-
this.saveToolSettingPropertyValue(this.radiusProperty, { value: cornerRadius });
|
|
1412
|
-
this.saveToolSettingPropertyValue(this.useRadiusProperty, { value: 0.0 !== cornerRadius });
|
|
1413
|
-
}
|
|
1414
|
-
return this.run();
|
|
1415
|
-
}
|
|
1416
|
-
}
|
|
1417
|
-
CreateRectangleTool.toolId = "CreateRectangle";
|
|
1418
|
-
CreateRectangleTool.iconSpec = "icon-rectangle";
|
|
1419
|
-
exports.CreateRectangleTool = CreateRectangleTool;
|
|
1420
|
-
/** @alpha */
|
|
1421
|
-
var BCurveMethod;
|
|
1422
|
-
(function (BCurveMethod) {
|
|
1423
|
-
BCurveMethod[BCurveMethod["ControlPoints"] = 0] = "ControlPoints";
|
|
1424
|
-
BCurveMethod[BCurveMethod["ThroughPoints"] = 1] = "ThroughPoints";
|
|
1425
|
-
})(BCurveMethod = exports.BCurveMethod || (exports.BCurveMethod = {}));
|
|
1426
|
-
/** @alpha Creates a bspline curve by poles or through points. Uses model and category from [[BriefcaseConnection.editorToolSettings]]. */
|
|
1427
|
-
class CreateBCurveTool extends CreateOrContinuePathTool {
|
|
1428
|
-
constructor() {
|
|
1429
|
-
super(...arguments);
|
|
1430
|
-
this._isPhysicallyClosedOrComplete = false;
|
|
1431
|
-
this._tangentPhase = CreateCurvePhase.DefineOther;
|
|
1432
|
-
}
|
|
1433
|
-
static get minArgs() { return 0; }
|
|
1434
|
-
static get maxArgs() { return 3; } // method, order, tangents...
|
|
1435
|
-
get wantPickableDynamics() { return true; } // Allow snapping to control polygon or through points...
|
|
1436
|
-
get showCurveConstructions() { return true; } // Display control polygon or through points...
|
|
1437
|
-
provideToolAssistance(_mainInstrText, _additionalInstr) {
|
|
1438
|
-
const nPts = this.accepted.length;
|
|
1439
|
-
let mainMsg;
|
|
1440
|
-
if (CreateCurvePhase.DefineOther === this._tangentPhase)
|
|
1441
|
-
mainMsg = core_frontend_1.CoreTools.translate(0 === nPts ? "ElementSet.Prompts.StartPoint" : "ElementSet.Inputs.AdditionalPoint");
|
|
1442
|
-
else
|
|
1443
|
-
mainMsg = EditTool_1.EditTools.translate(CreateCurvePhase.DefineStart === this._tangentPhase ? "CreateBCurve.Prompts.StartTangent" : "CreateBCurve.Prompts.EndTangent");
|
|
1444
|
-
const leftMsg = core_frontend_1.CoreTools.translate("ElementSet.Inputs.AcceptPoint");
|
|
1445
|
-
const rightMsg = core_frontend_1.CoreTools.translate(CreateCurvePhase.DefineOther === this._tangentPhase && nPts >= this.requiredPointCount ? "ElementSet.Inputs.Complete" : "ElementSet.Inputs.Cancel");
|
|
1446
|
-
const mouseInstructions = [];
|
|
1447
|
-
const touchInstructions = [];
|
|
1448
|
-
if (!core_frontend_1.ToolAssistance.createTouchCursorInstructions(touchInstructions))
|
|
1449
|
-
touchInstructions.push(core_frontend_1.ToolAssistance.createInstruction(core_frontend_1.ToolAssistanceImage.OneTouchTap, leftMsg, false, core_frontend_1.ToolAssistanceInputMethod.Touch));
|
|
1450
|
-
mouseInstructions.push(core_frontend_1.ToolAssistance.createInstruction(core_frontend_1.ToolAssistanceImage.LeftClick, leftMsg, false, core_frontend_1.ToolAssistanceInputMethod.Mouse));
|
|
1451
|
-
touchInstructions.push(core_frontend_1.ToolAssistance.createInstruction(core_frontend_1.ToolAssistanceImage.TwoTouchTap, rightMsg, false, core_frontend_1.ToolAssistanceInputMethod.Touch));
|
|
1452
|
-
mouseInstructions.push(core_frontend_1.ToolAssistance.createInstruction(core_frontend_1.ToolAssistanceImage.RightClick, rightMsg, false, core_frontend_1.ToolAssistanceInputMethod.Mouse));
|
|
1453
|
-
const sections = [];
|
|
1454
|
-
sections.push(core_frontend_1.ToolAssistance.createSection(mouseInstructions, core_frontend_1.ToolAssistance.inputsLabel));
|
|
1455
|
-
sections.push(core_frontend_1.ToolAssistance.createSection(touchInstructions, core_frontend_1.ToolAssistance.inputsLabel));
|
|
1456
|
-
const mainInstruction = core_frontend_1.ToolAssistance.createInstruction(this.iconSpec, mainMsg);
|
|
1457
|
-
const instructions = core_frontend_1.ToolAssistance.createInstructions(mainInstruction, sections);
|
|
1458
|
-
core_frontend_1.IModelApp.notifications.setToolAssistance(instructions);
|
|
1459
|
-
}
|
|
1460
|
-
static methodMessage(str) { return EditTool_1.EditTools.translate(`CreateBCurve.Method.${str}`); }
|
|
1461
|
-
get methodProperty() {
|
|
1462
|
-
if (!this._methodProperty)
|
|
1463
|
-
this._methodProperty = new appui_abstract_1.DialogProperty(appui_abstract_1.PropertyDescriptionHelper.buildEnumPicklistEditorDescription("bcurveMethod", EditTool_1.EditTools.translate("CreateBCurve.Label.Method"), CreateBCurveTool.getMethodChoices()), BCurveMethod.ControlPoints);
|
|
1464
|
-
return this._methodProperty;
|
|
1465
|
-
}
|
|
1466
|
-
get method() { return this.methodProperty.value; }
|
|
1467
|
-
set method(method) { this.methodProperty.value = method; }
|
|
1468
|
-
get orderProperty() {
|
|
1469
|
-
if (!this._orderProperty)
|
|
1470
|
-
this._orderProperty = new appui_abstract_1.DialogProperty(appui_abstract_1.PropertyDescriptionHelper.buildNumberEditorDescription("bcurveOrder", EditTool_1.EditTools.translate("CreateBCurve.Label.Order"), { type: appui_abstract_1.PropertyEditorParamTypes.Range, minimum: this.minOrder, maximum: this.maxOrder }), 3);
|
|
1471
|
-
return this._orderProperty;
|
|
1472
|
-
}
|
|
1473
|
-
get order() { return this.orderProperty.value; }
|
|
1474
|
-
set order(value) { this.orderProperty.value = value; }
|
|
1475
|
-
get minOrder() { return 2; }
|
|
1476
|
-
get maxOrder() { return 16; }
|
|
1477
|
-
get tangentsProperty() {
|
|
1478
|
-
if (!this._tangentsProperty)
|
|
1479
|
-
this._tangentsProperty = new appui_abstract_1.DialogProperty(appui_abstract_1.PropertyDescriptionHelper.buildToggleDescription("bcurveTangents", EditTool_1.EditTools.translate("CreateBCurve.Label.Tangents")), false);
|
|
1480
|
-
return this._tangentsProperty;
|
|
1481
|
-
}
|
|
1482
|
-
get tangents() { return this.tangentsProperty.value; }
|
|
1483
|
-
set tangents(value) { this.tangentsProperty.value = value; }
|
|
1484
|
-
get wantClosure() {
|
|
1485
|
-
// A bcurve can support physical closure when creating a new path...
|
|
1486
|
-
return this.allowClosure;
|
|
1487
|
-
}
|
|
1488
|
-
get requiredPointCount() {
|
|
1489
|
-
if (BCurveMethod.ThroughPoints === this.method)
|
|
1490
|
-
return 3; // Interpolation curve is always order 4 with 3 point minimum...
|
|
1491
|
-
return this.order;
|
|
1492
|
-
}
|
|
1493
|
-
get createCurvePhase() {
|
|
1494
|
-
if (CreateCurvePhase.DefineOther !== this._tangentPhase)
|
|
1495
|
-
return CreateCurvePhase.DefineOther;
|
|
1496
|
-
return super.createCurvePhase;
|
|
1497
|
-
}
|
|
1498
|
-
updateCurvePhase() {
|
|
1499
|
-
// The first point changes startPoint and last point changes endPoint.
|
|
1500
|
-
this._createCurvePhase = (0 === this.accepted.length ? CreateCurvePhase.DefineStart : CreateCurvePhase.DefineEnd);
|
|
1501
|
-
}
|
|
1502
|
-
isComplete(ev) {
|
|
1503
|
-
// Accept on reset with sufficient points...
|
|
1504
|
-
if (core_frontend_1.BeButton.Reset === ev.button)
|
|
1505
|
-
return (this.accepted.length >= this.requiredPointCount);
|
|
1506
|
-
// Allow data to complete on physical closure...
|
|
1507
|
-
return this.isClosed || this._isPhysicallyClosedOrComplete;
|
|
1508
|
-
}
|
|
1509
|
-
showConstructionGraphics(ev, context) {
|
|
1510
|
-
if (CreateCurvePhase.DefineOther !== this._tangentPhase && this.current) {
|
|
1511
|
-
const fitCurve = this.current;
|
|
1512
|
-
const builder = context.createGraphic({ type: core_frontend_1.GraphicType.WorldOverlay });
|
|
1513
|
-
const color = context.viewport.getContrastToBackgroundColor();
|
|
1514
|
-
builder.setSymbology(color, core_common_1.ColorDef.black, 1, core_common_1.LinePixels.Code2);
|
|
1515
|
-
builder.addLineString([ev.point, fitCurve.options.fitPoints[CreateCurvePhase.DefineStart === this._tangentPhase ? 0 : fitCurve.options.fitPoints.length - 1]]);
|
|
1516
|
-
builder.setSymbology(color, core_common_1.ColorDef.black, 8);
|
|
1517
|
-
builder.addPointString([ev.point]);
|
|
1518
|
-
context.addGraphic(builder.finish());
|
|
1519
|
-
}
|
|
1520
|
-
return super.showConstructionGraphics(ev, context);
|
|
1521
|
-
}
|
|
1522
|
-
createNewCurvePrimitive(ev, isDynamics) {
|
|
1523
|
-
if (CreateCurvePhase.DefineOther !== this._tangentPhase && this.current) {
|
|
1524
|
-
const fitCurve = this.current;
|
|
1525
|
-
if (CreateCurvePhase.DefineStart === this._tangentPhase) {
|
|
1526
|
-
const tangentS = core_geometry_1.Vector3d.createStartEnd(ev.point, fitCurve.options.fitPoints[0]);
|
|
1527
|
-
if (tangentS.magnitude() > core_geometry_1.Geometry.smallMetricDistance)
|
|
1528
|
-
fitCurve.options.startTangent = tangentS;
|
|
1529
|
-
}
|
|
1530
|
-
else {
|
|
1531
|
-
const tangentE = core_geometry_1.Vector3d.createStartEnd(ev.point, fitCurve.options.fitPoints[fitCurve.options.fitPoints.length - 1]);
|
|
1532
|
-
if (tangentE.magnitude() > core_geometry_1.Geometry.smallMetricDistance)
|
|
1533
|
-
fitCurve.options.endTangent = tangentE;
|
|
1534
|
-
}
|
|
1535
|
-
return fitCurve;
|
|
1536
|
-
}
|
|
1537
|
-
// Don't include current point if it's the same as the last accepted point, want dynamics to show an accurate preview of what reset will accept...
|
|
1538
|
-
const includeCurrPt = (isDynamics && (0 === this.accepted.length || !ev.point.isAlmostEqual(this.accepted[this.accepted.length - 1])));
|
|
1539
|
-
const pts = (includeCurrPt ? [...this.accepted, ev.point] : this.accepted);
|
|
1540
|
-
const numRequired = this.requiredPointCount;
|
|
1541
|
-
if (pts.length < numRequired) {
|
|
1542
|
-
// Create point/linestring construction geometry to support join...
|
|
1543
|
-
this.isConstruction = true;
|
|
1544
|
-
return core_geometry_1.LineString3d.create(1 === pts.length ? [pts[0], pts[0]] : pts);
|
|
1545
|
-
}
|
|
1546
|
-
// Create periodic-looking curve on physical closure with sufficient points even when not creating a loop/surface...
|
|
1547
|
-
this._isPhysicallyClosedOrComplete = (undefined === this.continuationData && pts[0].isAlmostEqual(pts[pts.length - 1]));
|
|
1548
|
-
if (BCurveMethod.ControlPoints === this.method) {
|
|
1549
|
-
if (this._isPhysicallyClosedOrComplete && this.order > 2) {
|
|
1550
|
-
const tmpPts = pts.slice(undefined, -1); // Don't include closure point...
|
|
1551
|
-
return core_geometry_1.BSplineCurve3d.createPeriodicUniformKnots(tmpPts, this.order);
|
|
1552
|
-
}
|
|
1553
|
-
return core_geometry_1.BSplineCurve3d.createUniformKnots(pts, this.order);
|
|
1554
|
-
}
|
|
1555
|
-
const interpProps = { fitPoints: pts, closed: this._isPhysicallyClosedOrComplete, isChordLenKnots: 1, isColinearTangents: 1 };
|
|
1556
|
-
// Create interpolation curve tangent to continuation curve...
|
|
1557
|
-
if (undefined !== this.continuationData && this.tangents) {
|
|
1558
|
-
const tangentS = this.continuationData.path.children[0].fractionToPointAndUnitTangent(0.0);
|
|
1559
|
-
const tangentE = this.continuationData.path.children[this.continuationData.path.children.length - 1].fractionToPointAndUnitTangent(1.0);
|
|
1560
|
-
if (pts[0].isAlmostEqual(tangentS.origin))
|
|
1561
|
-
interpProps.startTangent = tangentS.direction.scale(-1);
|
|
1562
|
-
else if (pts[0].isAlmostEqual(tangentE.origin))
|
|
1563
|
-
interpProps.startTangent = tangentE.direction;
|
|
1564
|
-
if (pts[pts.length - 1].isAlmostEqual(tangentS.origin))
|
|
1565
|
-
interpProps.endTangent = tangentS.direction.scale(-1);
|
|
1566
|
-
else if (pts[pts.length - 1].isAlmostEqual(tangentE.origin))
|
|
1567
|
-
interpProps.endTangent = tangentE.direction;
|
|
1568
|
-
this._isPhysicallyClosedOrComplete = (undefined !== interpProps.startTangent && undefined !== interpProps.endTangent);
|
|
1569
|
-
}
|
|
1570
|
-
const interpOpts = core_geometry_1.InterpolationCurve3dOptions.create(interpProps);
|
|
1571
|
-
return core_geometry_1.InterpolationCurve3d.createCapture(interpOpts);
|
|
1572
|
-
}
|
|
1573
|
-
getSnapGeometry() {
|
|
1574
|
-
// Only snap to through points...
|
|
1575
|
-
if (BCurveMethod.ThroughPoints === this.method)
|
|
1576
|
-
return (this.accepted.length > 1 ? core_geometry_1.PointString3d.create(this.accepted) : undefined);
|
|
1577
|
-
return super.getSnapGeometry();
|
|
1578
|
-
}
|
|
1579
|
-
async acceptPoint(ev) {
|
|
1580
|
-
switch (this._tangentPhase) {
|
|
1581
|
-
case CreateCurvePhase.DefineOther:
|
|
1582
|
-
return super.acceptPoint(ev);
|
|
1583
|
-
case CreateCurvePhase.DefineStart:
|
|
1584
|
-
this._tangentPhase = CreateCurvePhase.DefineEnd;
|
|
1585
|
-
break;
|
|
1586
|
-
case CreateCurvePhase.DefineEnd:
|
|
1587
|
-
this._isPhysicallyClosedOrComplete = true;
|
|
1588
|
-
break;
|
|
1589
|
-
}
|
|
1590
|
-
await this.updateCurveAndContinuationData(ev, false);
|
|
1591
|
-
return true;
|
|
1592
|
-
}
|
|
1593
|
-
async cancelPoint(ev) {
|
|
1594
|
-
// NOTE: Starting another tool will not create element...require reset or closure...
|
|
1595
|
-
if (this.isComplete(ev)) {
|
|
1596
|
-
if (BCurveMethod.ThroughPoints === this.method && this.tangents && this.current) {
|
|
1597
|
-
const fitCurve = this.current;
|
|
1598
|
-
switch (this._tangentPhase) {
|
|
1599
|
-
case CreateCurvePhase.DefineOther:
|
|
1600
|
-
this._createCurvePhase = CreateCurvePhase.DefineEnd;
|
|
1601
|
-
await this.updateCurveAndContinuationData(ev, false);
|
|
1602
|
-
this._tangentPhase = (undefined === fitCurve.options.startTangent ? CreateCurvePhase.DefineStart : CreateCurvePhase.DefineEnd);
|
|
1603
|
-
core_frontend_1.IModelApp.toolAdmin.updateDynamics();
|
|
1604
|
-
this.setupAndPromptForNextAction();
|
|
1605
|
-
return false;
|
|
1606
|
-
case CreateCurvePhase.DefineStart:
|
|
1607
|
-
fitCurve.options.startTangent = undefined; // Not accepted, compute default start tangent...
|
|
1608
|
-
this._tangentPhase = CreateCurvePhase.DefineEnd;
|
|
1609
|
-
core_frontend_1.IModelApp.toolAdmin.updateDynamics();
|
|
1610
|
-
this.setupAndPromptForNextAction();
|
|
1611
|
-
return false;
|
|
1612
|
-
case CreateCurvePhase.DefineEnd:
|
|
1613
|
-
fitCurve.options.endTangent = undefined; // Not accepted, compute default end tangent...
|
|
1614
|
-
await this.createElement();
|
|
1615
|
-
return true;
|
|
1616
|
-
}
|
|
1617
|
-
}
|
|
1618
|
-
this._createCurvePhase = CreateCurvePhase.DefineEnd;
|
|
1619
|
-
await this.updateCurveAndContinuationData(ev, false);
|
|
1620
|
-
await this.createElement();
|
|
1621
|
-
}
|
|
1622
|
-
return true;
|
|
1623
|
-
}
|
|
1624
|
-
async applyToolSettingPropertyChange(updatedValue) {
|
|
1625
|
-
if (!this.changeToolSettingPropertyValue(updatedValue))
|
|
1626
|
-
return false;
|
|
1627
|
-
if (this.methodProperty.name === updatedValue.propertyName)
|
|
1628
|
-
await this.onReinitialize();
|
|
1629
|
-
return true;
|
|
1630
|
-
}
|
|
1631
|
-
supplyToolSettingsProperties() {
|
|
1632
|
-
const toolSettings = new Array();
|
|
1633
|
-
toolSettings.push(this.methodProperty.toDialogItem({ rowPriority: 1, columnIndex: 0 }));
|
|
1634
|
-
if (BCurveMethod.ThroughPoints === this.method)
|
|
1635
|
-
toolSettings.push(this.tangentsProperty.toDialogItem({ rowPriority: 2, columnIndex: 0 }));
|
|
1636
|
-
else
|
|
1637
|
-
toolSettings.push(this.orderProperty.toDialogItem({ rowPriority: 2, columnIndex: 1 }));
|
|
1638
|
-
return toolSettings;
|
|
1639
|
-
}
|
|
1640
|
-
async onRestartTool() {
|
|
1641
|
-
const tool = new CreateBCurveTool();
|
|
1642
|
-
if (!await tool.run())
|
|
1643
|
-
return this.exitTool();
|
|
1644
|
-
}
|
|
1645
|
-
async onInstall() {
|
|
1646
|
-
if (!await super.onInstall())
|
|
1647
|
-
return false;
|
|
1648
|
-
// Setup initial values here instead of supplyToolSettingsProperties to support keyin args w/o appui-react...
|
|
1649
|
-
this.initializeToolSettingPropertyValues([this.methodProperty, this.orderProperty, this.tangentsProperty]);
|
|
1650
|
-
return true;
|
|
1651
|
-
}
|
|
1652
|
-
/** The keyin takes the following arguments, all of which are optional:
|
|
1653
|
-
* - `method=0|1` How bcurve will be defined. 0 for control points, 1 for through points.
|
|
1654
|
-
* - `order=number` bcurve order from 2 to 16.
|
|
1655
|
-
* - 'tangents=0|1 Whether to specify start/end tangents for through points construction.
|
|
1656
|
-
*/
|
|
1657
|
-
async parseAndRun(...inputArgs) {
|
|
1658
|
-
let bcurveMethod;
|
|
1659
|
-
let bcurveOrder;
|
|
1660
|
-
let bcurveTangents;
|
|
1661
|
-
for (const arg of inputArgs) {
|
|
1662
|
-
const parts = arg.split("=");
|
|
1663
|
-
if (2 !== parts.length)
|
|
1664
|
-
continue;
|
|
1665
|
-
if (parts[0].toLowerCase().startsWith("me")) {
|
|
1666
|
-
const method = Number.parseInt(parts[1], 10);
|
|
1667
|
-
if (!Number.isNaN(method)) {
|
|
1668
|
-
switch (method) {
|
|
1669
|
-
case 0:
|
|
1670
|
-
bcurveMethod = BCurveMethod.ControlPoints;
|
|
1671
|
-
break;
|
|
1672
|
-
case 1:
|
|
1673
|
-
bcurveMethod = BCurveMethod.ThroughPoints;
|
|
1674
|
-
break;
|
|
1675
|
-
}
|
|
1676
|
-
}
|
|
1677
|
-
}
|
|
1678
|
-
else if (parts[0].toLowerCase().startsWith("or")) {
|
|
1679
|
-
const order = Number.parseInt(parts[1], 10);
|
|
1680
|
-
if (order >= this.minOrder && order <= this.maxOrder) {
|
|
1681
|
-
bcurveOrder = order;
|
|
1682
|
-
}
|
|
1683
|
-
}
|
|
1684
|
-
else if (parts[0].toLowerCase().startsWith("ta")) {
|
|
1685
|
-
const tangents = Number.parseInt(parts[1], 10);
|
|
1686
|
-
bcurveTangents = (0 !== tangents);
|
|
1687
|
-
}
|
|
1688
|
-
}
|
|
1689
|
-
// Update current session values so keyin args are picked up for tool settings/restart...
|
|
1690
|
-
if (undefined !== bcurveMethod)
|
|
1691
|
-
this.saveToolSettingPropertyValue(this.methodProperty, { value: bcurveMethod });
|
|
1692
|
-
if (undefined !== bcurveOrder)
|
|
1693
|
-
this.saveToolSettingPropertyValue(this.orderProperty, { value: bcurveOrder });
|
|
1694
|
-
if (undefined !== bcurveTangents)
|
|
1695
|
-
this.saveToolSettingPropertyValue(this.tangentsProperty, { value: bcurveTangents });
|
|
1696
|
-
return this.run();
|
|
1697
|
-
}
|
|
1698
|
-
}
|
|
1699
|
-
CreateBCurveTool.toolId = "CreateBCurve";
|
|
1700
|
-
CreateBCurveTool.iconSpec = "icon-snaps-nearest"; // Need better icon...
|
|
1701
|
-
CreateBCurveTool.getMethodChoices = () => {
|
|
1702
|
-
return [
|
|
1703
|
-
{ label: CreateBCurveTool.methodMessage("ControlPoints"), value: BCurveMethod.ControlPoints },
|
|
1704
|
-
{ label: CreateBCurveTool.methodMessage("ThroughPoints"), value: BCurveMethod.ThroughPoints },
|
|
1705
|
-
];
|
|
1706
|
-
};
|
|
1707
|
-
exports.CreateBCurveTool = CreateBCurveTool;
|
|
1708
|
-
//# sourceMappingURL=SketchTools.js.map
|