@itwin/editor-frontend 3.5.0-dev.8 → 3.6.0-dev.1
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 +58 -1
- package/lib/cjs/DeleteElementsTool.d.ts +0 -2
- package/lib/cjs/DeleteElementsTool.d.ts.map +1 -1
- package/lib/cjs/DeleteElementsTool.js +3 -5
- package/lib/cjs/DeleteElementsTool.js.map +1 -1
- package/lib/cjs/EditTool.d.ts +0 -1
- package/lib/cjs/EditTool.d.ts.map +1 -1
- package/lib/cjs/EditTool.js +6 -7
- package/lib/cjs/EditTool.js.map +1 -1
- package/lib/cjs/EditToolIpc.d.ts +18 -0
- package/lib/cjs/EditToolIpc.d.ts.map +1 -0
- package/lib/cjs/EditToolIpc.js +28 -0
- package/lib/cjs/EditToolIpc.js.map +1 -0
- package/lib/cjs/ElementGeometryTool.d.ts +2 -3
- package/lib/cjs/ElementGeometryTool.d.ts.map +1 -1
- package/lib/cjs/ElementGeometryTool.js +8 -10
- package/lib/cjs/ElementGeometryTool.js.map +1 -1
- package/lib/cjs/ModifyCurveTools.d.ts +19 -43
- package/lib/cjs/ModifyCurveTools.d.ts.map +1 -1
- package/lib/cjs/ModifyCurveTools.js +127 -188
- package/lib/cjs/ModifyCurveTools.js.map +1 -1
- package/lib/cjs/ModifyElementTool.d.ts +43 -0
- package/lib/cjs/ModifyElementTool.d.ts.map +1 -0
- package/lib/cjs/ModifyElementTool.js +161 -0
- package/lib/cjs/ModifyElementTool.js.map +1 -0
- package/lib/cjs/ProjectLocation/ProjectExtentsDecoration.d.ts +0 -2
- package/lib/cjs/ProjectLocation/ProjectExtentsDecoration.d.ts.map +1 -1
- package/lib/cjs/ProjectLocation/ProjectExtentsDecoration.js +3 -5
- package/lib/cjs/ProjectLocation/ProjectExtentsDecoration.js.map +1 -1
- package/lib/cjs/SketchTools.d.ts +2 -4
- package/lib/cjs/SketchTools.d.ts.map +1 -1
- package/lib/cjs/SketchTools.js +8 -10
- package/lib/cjs/SketchTools.js.map +1 -1
- package/lib/cjs/SolidModelingTools.d.ts +3 -3
- package/lib/cjs/SolidModelingTools.d.ts.map +1 -1
- package/lib/cjs/SolidModelingTools.js +30 -29
- package/lib/cjs/SolidModelingTools.js.map +1 -1
- package/lib/cjs/SolidPrimitiveTools.d.ts +69 -5
- package/lib/cjs/SolidPrimitiveTools.d.ts.map +1 -1
- package/lib/cjs/SolidPrimitiveTools.js +291 -8
- package/lib/cjs/SolidPrimitiveTools.js.map +1 -1
- package/lib/cjs/TransformElementsTool.d.ts +3 -5
- package/lib/cjs/TransformElementsTool.d.ts.map +1 -1
- package/lib/cjs/TransformElementsTool.js +10 -12
- package/lib/cjs/TransformElementsTool.js.map +1 -1
- package/lib/cjs/UndoRedoTool.js +1 -1
- package/lib/cjs/UndoRedoTool.js.map +1 -1
- package/lib/cjs/editor-frontend.d.ts +5 -3
- package/lib/cjs/editor-frontend.d.ts.map +1 -1
- package/lib/cjs/editor-frontend.js +5 -3
- package/lib/cjs/editor-frontend.js.map +1 -1
- package/lib/esm/DeleteElementsTool.d.ts +0 -2
- package/lib/esm/DeleteElementsTool.d.ts.map +1 -1
- package/lib/esm/DeleteElementsTool.js +3 -5
- package/lib/esm/DeleteElementsTool.js.map +1 -1
- package/lib/esm/EditTool.d.ts +0 -1
- package/lib/esm/EditTool.d.ts.map +1 -1
- package/lib/esm/EditTool.js +7 -8
- package/lib/esm/EditTool.js.map +1 -1
- package/lib/esm/EditToolIpc.d.ts +18 -0
- package/lib/esm/EditToolIpc.d.ts.map +1 -0
- package/lib/esm/EditToolIpc.js +24 -0
- package/lib/esm/EditToolIpc.js.map +1 -0
- package/lib/esm/ElementGeometryTool.d.ts +2 -3
- package/lib/esm/ElementGeometryTool.d.ts.map +1 -1
- package/lib/esm/ElementGeometryTool.js +8 -10
- package/lib/esm/ElementGeometryTool.js.map +1 -1
- package/lib/esm/ModifyCurveTools.d.ts +19 -43
- package/lib/esm/ModifyCurveTools.d.ts.map +1 -1
- package/lib/esm/ModifyCurveTools.js +127 -188
- package/lib/esm/ModifyCurveTools.js.map +1 -1
- package/lib/esm/ModifyElementTool.d.ts +43 -0
- package/lib/esm/ModifyElementTool.d.ts.map +1 -0
- package/lib/esm/ModifyElementTool.js +156 -0
- package/lib/esm/ModifyElementTool.js.map +1 -0
- package/lib/esm/ProjectLocation/ProjectExtentsDecoration.d.ts +0 -2
- package/lib/esm/ProjectLocation/ProjectExtentsDecoration.d.ts.map +1 -1
- package/lib/esm/ProjectLocation/ProjectExtentsDecoration.js +3 -5
- package/lib/esm/ProjectLocation/ProjectExtentsDecoration.js.map +1 -1
- package/lib/esm/SketchTools.d.ts +2 -4
- package/lib/esm/SketchTools.d.ts.map +1 -1
- package/lib/esm/SketchTools.js +8 -10
- package/lib/esm/SketchTools.js.map +1 -1
- package/lib/esm/SolidModelingTools.d.ts +3 -3
- package/lib/esm/SolidModelingTools.d.ts.map +1 -1
- package/lib/esm/SolidModelingTools.js +30 -29
- package/lib/esm/SolidModelingTools.js.map +1 -1
- package/lib/esm/SolidPrimitiveTools.d.ts +69 -5
- package/lib/esm/SolidPrimitiveTools.d.ts.map +1 -1
- package/lib/esm/SolidPrimitiveTools.js +289 -8
- package/lib/esm/SolidPrimitiveTools.js.map +1 -1
- package/lib/esm/TransformElementsTool.d.ts +3 -5
- package/lib/esm/TransformElementsTool.d.ts.map +1 -1
- package/lib/esm/TransformElementsTool.js +10 -12
- package/lib/esm/TransformElementsTool.js.map +1 -1
- package/lib/esm/UndoRedoTool.js +1 -1
- package/lib/esm/UndoRedoTool.js.map +1 -1
- package/lib/esm/editor-frontend.d.ts +5 -3
- package/lib/esm/editor-frontend.d.ts.map +1 -1
- package/lib/esm/editor-frontend.js +5 -3
- package/lib/esm/editor-frontend.js.map +1 -1
- package/lib/public/locales/en/Editor.json +26 -0
- package/package.json +15 -15
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ExtendCurveTool = exports.BreakCurveTool = exports.OffsetCurveTool = exports.ModifyCurveTool = exports.CurveData = void 0;
|
|
4
2
|
/*---------------------------------------------------------------------------------------------
|
|
5
3
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
6
4
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
7
5
|
*--------------------------------------------------------------------------------------------*/
|
|
8
|
-
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.ExtendCurveTool = exports.BreakCurveTool = exports.OffsetCurveTool = exports.ModifyCurveTool = exports.CurveData = void 0;
|
|
8
|
+
const appui_abstract_1 = require("@itwin/appui-abstract");
|
|
9
9
|
const core_common_1 = require("@itwin/core-common");
|
|
10
|
-
const
|
|
10
|
+
const core_frontend_1 = require("@itwin/core-frontend");
|
|
11
11
|
const core_geometry_1 = require("@itwin/core-geometry");
|
|
12
12
|
const editor_common_1 = require("@itwin/editor-common");
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
13
|
+
const EditTool_1 = require("./EditTool");
|
|
14
|
+
const EditToolIpc_1 = require("./EditToolIpc");
|
|
15
|
+
const ModifyElementTool_1 = require("./ModifyElementTool");
|
|
16
16
|
/** @alpha */
|
|
17
17
|
class CurveData {
|
|
18
18
|
constructor(props, params, geom) {
|
|
@@ -22,79 +22,13 @@ class CurveData {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
exports.CurveData = CurveData;
|
|
25
|
-
/** @alpha Base class for
|
|
26
|
-
class ModifyCurveTool extends
|
|
27
|
-
constructor() {
|
|
28
|
-
super(...arguments);
|
|
29
|
-
this._checkedIds = new Map();
|
|
30
|
-
this._firstResult = true;
|
|
31
|
-
}
|
|
32
|
-
allowView(_vp) { return true; }
|
|
33
|
-
isCompatibleViewport(vp, isSelectedViewChange) { return (super.isCompatibleViewport(vp, isSelectedViewChange) && undefined !== vp && this.allowView(vp)); }
|
|
25
|
+
/** @alpha Base class for modifying all types of curve geometry. */
|
|
26
|
+
class ModifyCurveTool extends ModifyElementTool_1.ModifyElementWithDynamicsTool {
|
|
34
27
|
async startCommand() {
|
|
35
28
|
if (undefined !== this._startedCmd)
|
|
36
29
|
return this._startedCmd;
|
|
37
30
|
return EditTool_1.EditTools.startCommand(editor_common_1.editorBuiltInCmdIds.cmdBasicManipulation, this.iModel.key);
|
|
38
31
|
}
|
|
39
|
-
static callCommand(method, ...args) {
|
|
40
|
-
return EditTool_1.EditTools.callCommand(method, ...args);
|
|
41
|
-
}
|
|
42
|
-
agendaAppearance(isDynamics) {
|
|
43
|
-
if (isDynamics) {
|
|
44
|
-
if (undefined === this._agendaAppearanceDynamic)
|
|
45
|
-
this._agendaAppearanceDynamic = core_common_1.FeatureAppearance.fromTransparency(0.0);
|
|
46
|
-
return this._agendaAppearanceDynamic;
|
|
47
|
-
}
|
|
48
|
-
if (undefined === this._agendaAppearanceDefault)
|
|
49
|
-
this._agendaAppearanceDefault = core_common_1.FeatureAppearance.fromTransparency(0.9);
|
|
50
|
-
return this._agendaAppearanceDefault;
|
|
51
|
-
}
|
|
52
|
-
get wantAgendaAppearanceOverride() { return false; }
|
|
53
|
-
addFeatureOverrides(overrides, _vp) {
|
|
54
|
-
if (this.agenda.isEmpty)
|
|
55
|
-
return;
|
|
56
|
-
const appearance = this.agendaAppearance(false);
|
|
57
|
-
this.agenda.elements.forEach((elementId) => overrides.override({ elementId, appearance }));
|
|
58
|
-
}
|
|
59
|
-
updateAgendaAppearanceProvider(drop) {
|
|
60
|
-
if (!this.wantAgendaAppearanceOverride)
|
|
61
|
-
return;
|
|
62
|
-
for (const vp of core_frontend_1.IModelApp.viewManager) {
|
|
63
|
-
if (!this.allowView(vp))
|
|
64
|
-
continue;
|
|
65
|
-
if (drop || this.agenda.isEmpty)
|
|
66
|
-
vp.dropFeatureOverrideProvider(this);
|
|
67
|
-
else if (!vp.addFeatureOverrideProvider(this))
|
|
68
|
-
vp.setFeatureOverrideProviderChanged();
|
|
69
|
-
}
|
|
70
|
-
}
|
|
71
|
-
clearGraphics() {
|
|
72
|
-
if (undefined === this._graphicsProvider)
|
|
73
|
-
return;
|
|
74
|
-
this._graphicsProvider.cleanupGraphic();
|
|
75
|
-
this._graphicsProvider = undefined;
|
|
76
|
-
}
|
|
77
|
-
async createGraphics(ev) {
|
|
78
|
-
if (!core_frontend_1.IModelApp.viewManager.inDynamicsMode)
|
|
79
|
-
return; // Don't need to create graphic if dynamics aren't yet active...
|
|
80
|
-
const geometry = this.getGeometryProps(ev, false);
|
|
81
|
-
if (undefined === geometry)
|
|
82
|
-
return;
|
|
83
|
-
const elemProps = this.getElementProps(ev);
|
|
84
|
-
if (undefined === (elemProps === null || elemProps === void 0 ? void 0 : elemProps.placement))
|
|
85
|
-
return;
|
|
86
|
-
if (undefined === this._graphicsProvider) {
|
|
87
|
-
if (this._firstResult) {
|
|
88
|
-
this.updateAgendaAppearanceProvider();
|
|
89
|
-
this._firstResult = false;
|
|
90
|
-
}
|
|
91
|
-
this._graphicsProvider = new CreateElementTool_1.DynamicGraphicsProvider(this.iModel, this.toolId);
|
|
92
|
-
}
|
|
93
|
-
// Set chord tolerance for non-linear curve primitives...
|
|
94
|
-
if (ev.viewport)
|
|
95
|
-
this._graphicsProvider.chordTolerance = (0, CreateElementTool_1.computeChordToleranceFromPoint)(ev.viewport, ev.point);
|
|
96
|
-
await this._graphicsProvider.createGraphic(elemProps.category, elemProps.placement, geometry);
|
|
97
|
-
}
|
|
98
32
|
static isSingleCurve(info) {
|
|
99
33
|
const it = new core_common_1.ElementGeometry.Iterator(info);
|
|
100
34
|
it.requestWorldCoordinates();
|
|
@@ -118,7 +52,7 @@ class ModifyCurveTool extends core_frontend_1.ElementSetTool {
|
|
|
118
52
|
try {
|
|
119
53
|
this._startedCmd = await this.startCommand();
|
|
120
54
|
const reject = [core_common_1.ElementGeometryOpcode.Polyface, core_common_1.ElementGeometryOpcode.SolidPrimitive, core_common_1.ElementGeometryOpcode.BsplineSurface, core_common_1.ElementGeometryOpcode.BRep];
|
|
121
|
-
const info = await
|
|
55
|
+
const info = await EditToolIpc_1.basicManipulationIpc.requestElementGeometry(id, { maxDisplayable: 1, reject, geometry: { curves: true, surfaces: true, solids: false } });
|
|
122
56
|
if (undefined === info)
|
|
123
57
|
return undefined;
|
|
124
58
|
const data = ModifyCurveTool.isSingleCurve(info);
|
|
@@ -136,23 +70,8 @@ class ModifyCurveTool extends core_frontend_1.ElementSetTool {
|
|
|
136
70
|
return undefined;
|
|
137
71
|
}
|
|
138
72
|
}
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
if (core_bentley_1.Id64.isInvalid(id) || core_bentley_1.Id64.isTransient(id))
|
|
142
|
-
return false;
|
|
143
|
-
let accept = this._checkedIds.get(id);
|
|
144
|
-
if (undefined === accept) {
|
|
145
|
-
if (this.agenda.isEmpty && this._checkedIds.size > 1000)
|
|
146
|
-
this._checkedIds.clear(); // Limit auto-locate cache size to something reasonable...
|
|
147
|
-
accept = (undefined !== await this.getCurveData(id));
|
|
148
|
-
this._checkedIds.set(id, accept);
|
|
149
|
-
}
|
|
150
|
-
return accept;
|
|
151
|
-
}
|
|
152
|
-
async isElementValidForOperation(hit, out) {
|
|
153
|
-
if (!await super.isElementValidForOperation(hit, out))
|
|
154
|
-
return false;
|
|
155
|
-
return this.acceptElementForOperation(hit.sourceId);
|
|
73
|
+
async doAcceptElementForOperation(id) {
|
|
74
|
+
return (undefined !== await this.getCurveData(id));
|
|
156
75
|
}
|
|
157
76
|
async onAgendaModified() {
|
|
158
77
|
this.curveData = undefined;
|
|
@@ -161,33 +80,22 @@ class ModifyCurveTool extends core_frontend_1.ElementSetTool {
|
|
|
161
80
|
const id = this.agenda.elements[this.agenda.length - 1];
|
|
162
81
|
this.curveData = await this.getCurveData(id);
|
|
163
82
|
}
|
|
164
|
-
onDynamicFrame(_ev, context) {
|
|
165
|
-
if (undefined !== this._graphicsProvider)
|
|
166
|
-
this._graphicsProvider.addGraphic(context);
|
|
167
|
-
}
|
|
168
|
-
async onMouseMotion(ev) {
|
|
169
|
-
return this.createGraphics(ev);
|
|
170
|
-
}
|
|
171
83
|
setupAccuDraw() {
|
|
172
84
|
const hints = new core_frontend_1.AccuDrawHintBuilder();
|
|
173
85
|
hints.enableSmartRotation = true;
|
|
174
86
|
hints.sendHints(false);
|
|
175
87
|
}
|
|
176
|
-
setupAndPromptForNextAction() {
|
|
177
|
-
this.setupAccuDraw();
|
|
178
|
-
super.setupAndPromptForNextAction();
|
|
179
|
-
}
|
|
180
88
|
getGeometryProps(ev, isAccept) {
|
|
181
89
|
if (undefined === this.curveData)
|
|
182
90
|
return;
|
|
183
|
-
const
|
|
184
|
-
if (undefined ===
|
|
91
|
+
const geom = this.modifyCurve(ev, isAccept);
|
|
92
|
+
if (undefined === geom)
|
|
185
93
|
return;
|
|
186
94
|
const builder = new core_common_1.ElementGeometry.Builder();
|
|
187
95
|
builder.setLocalToWorldFromPlacement(this.curveData.props.placement);
|
|
188
96
|
if (!builder.appendGeometryParamsChange(this.curveData.params))
|
|
189
97
|
return;
|
|
190
|
-
if (!builder.appendGeometryQuery(
|
|
98
|
+
if (!builder.appendGeometryQuery(geom))
|
|
191
99
|
return;
|
|
192
100
|
return { format: "flatbuffer", data: builder.entries };
|
|
193
101
|
}
|
|
@@ -202,29 +110,19 @@ class ModifyCurveTool extends core_frontend_1.ElementSetTool {
|
|
|
202
110
|
}
|
|
203
111
|
return this.curveData.props;
|
|
204
112
|
}
|
|
205
|
-
async
|
|
206
|
-
const geometry = this.getGeometryProps(ev, true);
|
|
207
|
-
if (undefined === geometry)
|
|
208
|
-
return false;
|
|
209
|
-
const elemProps = this.getElementProps(ev);
|
|
210
|
-
if (undefined === elemProps)
|
|
211
|
-
return false;
|
|
212
|
-
if ("flatbuffer" === geometry.format)
|
|
213
|
-
elemProps.elementGeometryBuilderParams = { entryArray: geometry.data };
|
|
214
|
-
else
|
|
215
|
-
elemProps.geom = geometry.data;
|
|
113
|
+
async doUpdateElement(elemProps) {
|
|
216
114
|
try {
|
|
217
115
|
this._startedCmd = await this.startCommand();
|
|
218
116
|
if (undefined === elemProps.id) {
|
|
219
117
|
const repeatOperation = this.wantContinueWithPreviousResult;
|
|
220
118
|
if (repeatOperation)
|
|
221
119
|
this.agenda.clear();
|
|
222
|
-
const newId = await
|
|
120
|
+
const newId = await EditToolIpc_1.basicManipulationIpc.insertGeometricElement(elemProps);
|
|
223
121
|
if (repeatOperation && this.agenda.add(newId))
|
|
224
122
|
await this.onAgendaModified();
|
|
225
123
|
}
|
|
226
124
|
else {
|
|
227
|
-
await
|
|
125
|
+
await EditToolIpc_1.basicManipulationIpc.updateGeometricElement(elemProps);
|
|
228
126
|
}
|
|
229
127
|
return true;
|
|
230
128
|
}
|
|
@@ -233,10 +131,6 @@ class ModifyCurveTool extends core_frontend_1.ElementSetTool {
|
|
|
233
131
|
return false;
|
|
234
132
|
}
|
|
235
133
|
}
|
|
236
|
-
async processAgenda(ev) {
|
|
237
|
-
if (await this.applyAgendaOperation(ev))
|
|
238
|
-
return this.saveChanges();
|
|
239
|
-
}
|
|
240
134
|
get wantModifyOriginal() { return true; }
|
|
241
135
|
get wantContinueWithPreviousResult() { return false; }
|
|
242
136
|
async onProcessComplete() {
|
|
@@ -245,32 +139,10 @@ class ModifyCurveTool extends core_frontend_1.ElementSetTool {
|
|
|
245
139
|
return;
|
|
246
140
|
return super.onProcessComplete();
|
|
247
141
|
}
|
|
248
|
-
async onUnsuspend() {
|
|
249
|
-
if (!this._firstResult)
|
|
250
|
-
this.updateAgendaAppearanceProvider();
|
|
251
|
-
return super.onUnsuspend();
|
|
252
|
-
}
|
|
253
|
-
async onSuspend() {
|
|
254
|
-
if (!this._firstResult)
|
|
255
|
-
this.updateAgendaAppearanceProvider(true);
|
|
256
|
-
return super.onSuspend();
|
|
257
|
-
}
|
|
258
|
-
async onPostInstall() {
|
|
259
|
-
await super.onPostInstall();
|
|
260
|
-
if (this.wantAgendaAppearanceOverride)
|
|
261
|
-
this.agenda.manageHiliteState = false;
|
|
262
|
-
}
|
|
263
|
-
async onCleanup() {
|
|
264
|
-
this.clearGraphics();
|
|
265
|
-
this.updateAgendaAppearanceProvider(true);
|
|
266
|
-
return super.onCleanup();
|
|
267
|
-
}
|
|
268
142
|
}
|
|
269
143
|
exports.ModifyCurveTool = ModifyCurveTool;
|
|
270
144
|
/** @alpha Tool for applying an offset to paths and loops. */
|
|
271
145
|
class OffsetCurveTool extends ModifyCurveTool {
|
|
272
|
-
get wantAccuSnap() { return true; }
|
|
273
|
-
get wantDynamics() { return true; }
|
|
274
146
|
get useDistanceProperty() {
|
|
275
147
|
if (!this._useDistanceProperty)
|
|
276
148
|
this._useDistanceProperty = new appui_abstract_1.DialogProperty(appui_abstract_1.PropertyDescriptionHelper.buildLockPropertyDescription("useOffsetDistance"), false);
|
|
@@ -435,7 +307,7 @@ class BreakCurveTool extends ModifyCurveTool {
|
|
|
435
307
|
super(...arguments);
|
|
436
308
|
this.modifyOriginal = true;
|
|
437
309
|
}
|
|
438
|
-
get
|
|
310
|
+
get wantDynamics() { return false; }
|
|
439
311
|
get wantModifyOriginal() { return this.modifyOriginal; }
|
|
440
312
|
acceptCurve(curve) {
|
|
441
313
|
if ("curvePrimitive" === curve.geometryCategory)
|
|
@@ -563,34 +435,16 @@ class BreakCurveTool extends ModifyCurveTool {
|
|
|
563
435
|
exports.BreakCurveTool = BreakCurveTool;
|
|
564
436
|
BreakCurveTool.toolId = "BreakCurve";
|
|
565
437
|
BreakCurveTool.iconSpec = "icon-scale"; // Need better icon...
|
|
566
|
-
/** @alpha Tool
|
|
438
|
+
/** @alpha Tool to extend or trim a path or open curve */
|
|
567
439
|
class ExtendCurveTool extends ModifyCurveTool {
|
|
568
|
-
get wantAccuSnap() { return true; }
|
|
569
|
-
get wantDynamics() { return true; }
|
|
570
440
|
get wantAgendaAppearanceOverride() { return true; }
|
|
571
441
|
acceptCurve(curve) {
|
|
572
|
-
if ("curvePrimitive"
|
|
573
|
-
return
|
|
574
|
-
return curve.
|
|
442
|
+
if ("curvePrimitive" === curve.geometryCategory)
|
|
443
|
+
return curve.isExtensibleFractionSpace;
|
|
444
|
+
return ("path" === curve.curveCollectionType);
|
|
575
445
|
}
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
if (undefined === ev.viewport || undefined === this.anchorPoint)
|
|
579
|
-
return undefined;
|
|
580
|
-
const geom = (_a = this.curveData) === null || _a === void 0 ? void 0 : _a.geom;
|
|
581
|
-
if (undefined === geom)
|
|
582
|
-
return undefined;
|
|
583
|
-
const matrix = core_frontend_1.AccuDrawHintBuilder.getCurrentRotation(ev.viewport, true, true);
|
|
584
|
-
const localToWorld = core_geometry_1.FrameBuilder.createRightHandedFrame(matrix === null || matrix === void 0 ? void 0 : matrix.getColumn(2), geom);
|
|
585
|
-
if (undefined === localToWorld)
|
|
586
|
-
return undefined;
|
|
587
|
-
const worldToLocal = localToWorld.inverse();
|
|
588
|
-
if (undefined === worldToLocal)
|
|
589
|
-
return undefined;
|
|
590
|
-
const spacePoint = core_frontend_1.AccuDrawHintBuilder.projectPointToPlaneInView(ev.point, localToWorld.getOrigin(), localToWorld.matrix.getColumn(2), ev.viewport);
|
|
591
|
-
if (undefined === spacePoint)
|
|
592
|
-
return undefined;
|
|
593
|
-
const pickDetail = geom.closestPoint(this.anchorPoint, false);
|
|
446
|
+
extendCurve(geom, pickPoint, spacePoint) {
|
|
447
|
+
const pickDetail = geom.closestPoint(pickPoint, false);
|
|
594
448
|
if (undefined === (pickDetail === null || pickDetail === void 0 ? void 0 : pickDetail.curve))
|
|
595
449
|
return undefined;
|
|
596
450
|
const closeDetail = geom.closestPoint(spacePoint, true);
|
|
@@ -613,41 +467,126 @@ class ExtendCurveTool extends ModifyCurveTool {
|
|
|
613
467
|
return fullArc;
|
|
614
468
|
}
|
|
615
469
|
}
|
|
616
|
-
return
|
|
470
|
+
return geom.clonePartialCurve(pickDetail.fraction > 0.5 ? 0.0 : 1.0, closeDetail.fraction);
|
|
617
471
|
}
|
|
618
|
-
|
|
472
|
+
extendPathEnd(geom, closeDetail, isStart) {
|
|
473
|
+
if (undefined === closeDetail.curve)
|
|
474
|
+
return undefined;
|
|
475
|
+
const curve = closeDetail.curve.clonePartialCurve(isStart ? closeDetail.fraction : 0.0, isStart ? 1.0 : closeDetail.fraction);
|
|
476
|
+
if (undefined === curve)
|
|
477
|
+
return undefined;
|
|
478
|
+
if (curve instanceof core_geometry_1.Arc3d && closeDetail.curve instanceof core_geometry_1.Arc3d && (curve.sweep.isCCW !== closeDetail.curve.sweep.isCCW))
|
|
479
|
+
curve.sweep.cloneComplement(true, curve.sweep); // Preserve current sweep direction...
|
|
480
|
+
const result = geom.clone();
|
|
481
|
+
result.children[isStart ? 0 : geom.children.length - 1] = curve;
|
|
482
|
+
return result;
|
|
483
|
+
}
|
|
484
|
+
extendPath(geom, pickPoint, spacePoint) {
|
|
485
|
+
var _a;
|
|
486
|
+
if (geom.children.length < 2)
|
|
487
|
+
return this.extendCurve(geom.children[0], pickPoint, spacePoint);
|
|
488
|
+
const pathAsPrimitive = core_geometry_1.CurveChainWithDistanceIndex.createCapture(geom);
|
|
489
|
+
const closeDetail = pathAsPrimitive.closestPoint(spacePoint, true);
|
|
490
|
+
if (undefined === (closeDetail === null || closeDetail === void 0 ? void 0 : closeDetail.curve) || undefined === ((_a = closeDetail.childDetail) === null || _a === void 0 ? void 0 : _a.curve))
|
|
491
|
+
return undefined;
|
|
492
|
+
if (undefined !== this.modifyingEnd) {
|
|
493
|
+
if (closeDetail.childDetail.curve === this.modifyingEnd) {
|
|
494
|
+
this.modifyingEnd = undefined; // Ok to unlock extending first/last curve in path...
|
|
495
|
+
}
|
|
496
|
+
else {
|
|
497
|
+
const pathEndDetail = this.modifyingEnd.closestPoint(spacePoint, true);
|
|
498
|
+
if (undefined === (pathEndDetail === null || pathEndDetail === void 0 ? void 0 : pathEndDetail.curve))
|
|
499
|
+
return undefined;
|
|
500
|
+
return this.extendPathEnd(geom, pathEndDetail, (pathEndDetail.curve === geom.children[0]));
|
|
501
|
+
}
|
|
502
|
+
}
|
|
503
|
+
// NOTE: Special case extend instead of using CurveChainWithDistanceIndex.clonePartialCurve...
|
|
504
|
+
if (closeDetail.fraction < 0.0) {
|
|
505
|
+
this.modifyingEnd = closeDetail.childDetail.curve;
|
|
506
|
+
return this.extendPathEnd(geom, closeDetail.childDetail, true);
|
|
507
|
+
}
|
|
508
|
+
else if (closeDetail.fraction > 1.0) {
|
|
509
|
+
this.modifyingEnd = closeDetail.childDetail.curve;
|
|
510
|
+
return this.extendPathEnd(geom, closeDetail.childDetail, false);
|
|
511
|
+
}
|
|
512
|
+
const pickDetail = pathAsPrimitive.closestPoint(pickPoint, false);
|
|
513
|
+
if (undefined === (pickDetail === null || pickDetail === void 0 ? void 0 : pickDetail.curve))
|
|
514
|
+
return undefined;
|
|
515
|
+
const result = pathAsPrimitive.clonePartialCurve(pickDetail.fraction > 0.5 ? 0.0 : 1.0, closeDetail.fraction);
|
|
516
|
+
if (undefined === result)
|
|
517
|
+
return undefined;
|
|
518
|
+
return core_geometry_1.Path.create(...result.path.children);
|
|
519
|
+
}
|
|
520
|
+
modifyCurve(ev, _isAccept) {
|
|
619
521
|
var _a;
|
|
522
|
+
if (undefined === ev.viewport || undefined === this.anchorPoint)
|
|
523
|
+
return undefined;
|
|
524
|
+
const geom = (_a = this.curveData) === null || _a === void 0 ? void 0 : _a.geom;
|
|
525
|
+
if (undefined === geom)
|
|
526
|
+
return undefined;
|
|
527
|
+
const matrix = core_frontend_1.AccuDrawHintBuilder.getCurrentRotation(ev.viewport, true, true);
|
|
528
|
+
const localToWorld = core_geometry_1.FrameBuilder.createRightHandedFrame(matrix === null || matrix === void 0 ? void 0 : matrix.getColumn(2), geom);
|
|
529
|
+
if (undefined === localToWorld)
|
|
530
|
+
return undefined;
|
|
531
|
+
const worldToLocal = localToWorld.inverse();
|
|
532
|
+
if (undefined === worldToLocal)
|
|
533
|
+
return undefined;
|
|
534
|
+
const spacePoint = core_frontend_1.AccuDrawHintBuilder.projectPointToPlaneInView(ev.point, localToWorld.getOrigin(), localToWorld.matrix.getColumn(2), ev.viewport);
|
|
535
|
+
if (undefined === spacePoint)
|
|
536
|
+
return undefined;
|
|
537
|
+
if (geom instanceof core_geometry_1.CurvePrimitive)
|
|
538
|
+
return this.extendCurve(geom, this.anchorPoint, spacePoint);
|
|
539
|
+
else if (geom instanceof core_geometry_1.Path)
|
|
540
|
+
return this.extendPath(geom, this.anchorPoint, spacePoint);
|
|
541
|
+
return undefined;
|
|
542
|
+
}
|
|
543
|
+
async onAgendaModified() {
|
|
544
|
+
core_frontend_1.IModelApp.accuSnap.neverFlash(this.agenda.elements); // Don't flash snapped segment for better preview when trimming curve/path...
|
|
545
|
+
return super.onAgendaModified();
|
|
546
|
+
}
|
|
547
|
+
setupAccuDraw() {
|
|
548
|
+
var _a, _b, _c;
|
|
620
549
|
const hints = new core_frontend_1.AccuDrawHintBuilder();
|
|
621
550
|
if (this.agenda.isEmpty) {
|
|
622
551
|
hints.enableSmartRotation = true;
|
|
623
552
|
}
|
|
624
553
|
else {
|
|
625
554
|
const geom = (_a = this.curveData) === null || _a === void 0 ? void 0 : _a.geom;
|
|
626
|
-
if (undefined === geom ||
|
|
555
|
+
if (undefined === geom || undefined === this.anchorPoint)
|
|
556
|
+
return;
|
|
557
|
+
let pickDetail;
|
|
558
|
+
if (geom instanceof core_geometry_1.CurvePrimitive)
|
|
559
|
+
pickDetail = geom.closestPoint(this.anchorPoint, false);
|
|
560
|
+
else if (geom instanceof core_geometry_1.Path)
|
|
561
|
+
pickDetail = core_geometry_1.CurveChainWithDistanceIndex.createCapture(geom).closestPoint(this.anchorPoint, false);
|
|
562
|
+
if (undefined === (pickDetail === null || pickDetail === void 0 ? void 0 : pickDetail.curve))
|
|
627
563
|
return;
|
|
628
|
-
|
|
629
|
-
|
|
564
|
+
const curve = (undefined !== ((_b = pickDetail.childDetail) === null || _b === void 0 ? void 0 : _b.curve) ? (_c = pickDetail.childDetail) === null || _c === void 0 ? void 0 : _c.curve : pickDetail.curve);
|
|
565
|
+
if (curve instanceof core_geometry_1.Arc3d) {
|
|
566
|
+
const matrix = curve.matrixClone();
|
|
630
567
|
matrix.normalizeColumnsInPlace();
|
|
631
|
-
hints.setOrigin(
|
|
568
|
+
hints.setOrigin(curve.center);
|
|
632
569
|
hints.setMatrix(matrix);
|
|
633
570
|
hints.setModePolar();
|
|
634
571
|
}
|
|
635
|
-
else if (
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
hints.setOrigin(pickDetail.fraction > 0.5 ? geom.point0Ref : geom.point1Ref);
|
|
639
|
-
hints.setXAxis(core_geometry_1.Vector3d.createStartEnd(pickDetail.fraction > 0.5 ? geom.point0Ref : geom.point1Ref, pickDetail.fraction > 0.5 ? geom.point1Ref : geom.point0Ref));
|
|
640
|
-
}
|
|
572
|
+
else if (curve instanceof core_geometry_1.LineSegment3d) {
|
|
573
|
+
hints.setOrigin(pickDetail.fraction > 0.5 ? curve.point0Ref : curve.point1Ref);
|
|
574
|
+
hints.setXAxis(core_geometry_1.Vector3d.createStartEnd(pickDetail.fraction > 0.5 ? curve.point0Ref : curve.point1Ref, pickDetail.fraction > 0.5 ? curve.point1Ref : curve.point0Ref));
|
|
641
575
|
hints.setModeRectangular();
|
|
642
576
|
}
|
|
643
|
-
else if (
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
hints.
|
|
647
|
-
hints.setXAxis(core_geometry_1.Vector3d.createStartEnd(geom.packedPoints.getPoint3dAtUncheckedPointIndex(pickDetail.fraction > 0.5 ? geom.numPoints() - 2 : 1), geom.packedPoints.getPoint3dAtUncheckedPointIndex(pickDetail.fraction > 0.5 ? geom.numPoints() - 1 : 0)));
|
|
577
|
+
else if (curve instanceof core_geometry_1.LineString3d) {
|
|
578
|
+
if (curve.numPoints() > 1) {
|
|
579
|
+
hints.setOrigin(curve.packedPoints.getPoint3dAtUncheckedPointIndex(pickDetail.fraction > 0.5 ? curve.numPoints() - 2 : 1));
|
|
580
|
+
hints.setXAxis(core_geometry_1.Vector3d.createStartEnd(curve.packedPoints.getPoint3dAtUncheckedPointIndex(pickDetail.fraction > 0.5 ? curve.numPoints() - 2 : 1), curve.packedPoints.getPoint3dAtUncheckedPointIndex(pickDetail.fraction > 0.5 ? curve.numPoints() - 1 : 0)));
|
|
648
581
|
}
|
|
649
582
|
hints.setModeRectangular();
|
|
650
583
|
}
|
|
584
|
+
else {
|
|
585
|
+
const ray = curve.fractionToPointAndUnitTangent(pickDetail.fraction > 0.5 ? 0.0 : 1.0);
|
|
586
|
+
hints.setOrigin(ray.origin);
|
|
587
|
+
hints.setXAxis(ray.direction);
|
|
588
|
+
hints.setModeRectangular();
|
|
589
|
+
}
|
|
651
590
|
}
|
|
652
591
|
hints.sendHints(false);
|
|
653
592
|
}
|