@itwin/hypermodeling-frontend 3.5.1 → 3.5.2
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 +6 -1
- package/lib/cjs/HyperModeling.d.ts +114 -114
- package/lib/cjs/HyperModeling.js +239 -239
- package/lib/cjs/HyperModelingConfig.d.ts +54 -54
- package/lib/cjs/HyperModelingConfig.js +9 -9
- package/lib/cjs/HyperModelingConfig.js.map +1 -1
- package/lib/cjs/HyperModelingDecorator.d.ts +110 -110
- package/lib/cjs/HyperModelingDecorator.js +337 -337
- package/lib/cjs/HyperModelingDecorator.js.map +1 -1
- package/lib/cjs/PopupToolbar.d.ts +24 -24
- package/lib/cjs/PopupToolbar.js +57 -57
- package/lib/cjs/PopupToolbar.js.map +1 -1
- package/lib/cjs/SectionDrawingLocationState.d.ts +90 -90
- package/lib/cjs/SectionDrawingLocationState.js +136 -136
- package/lib/cjs/SectionDrawingLocationState.js.map +1 -1
- package/lib/cjs/SectionGraphicsProvider.d.ts +13 -13
- package/lib/cjs/SectionGraphicsProvider.js +273 -273
- package/lib/cjs/SectionGraphicsProvider.js.map +1 -1
- package/lib/cjs/SectionMarkerHandler.d.ts +52 -52
- package/lib/cjs/SectionMarkerHandler.js +112 -112
- package/lib/cjs/SectionMarkerHandler.js.map +1 -1
- package/lib/cjs/SectionMarkers.d.ts +82 -82
- package/lib/cjs/SectionMarkers.js +174 -174
- package/lib/cjs/SectionMarkers.js.map +1 -1
- package/lib/cjs/Tools.d.ts +5 -5
- package/lib/cjs/Tools.js +170 -170
- package/lib/cjs/hypermodeling-frontend.d.ts +13 -13
- package/lib/cjs/hypermodeling-frontend.js +29 -29
- package/lib/cjs/hypermodeling-frontend.js.map +1 -1
- package/lib/esm/HyperModeling.d.ts +114 -114
- package/lib/esm/HyperModeling.js +235 -235
- package/lib/esm/HyperModelingConfig.d.ts +54 -54
- package/lib/esm/HyperModelingConfig.js +8 -8
- package/lib/esm/HyperModelingConfig.js.map +1 -1
- package/lib/esm/HyperModelingDecorator.d.ts +110 -110
- package/lib/esm/HyperModelingDecorator.js +333 -333
- package/lib/esm/HyperModelingDecorator.js.map +1 -1
- package/lib/esm/PopupToolbar.d.ts +24 -24
- package/lib/esm/PopupToolbar.js +53 -53
- package/lib/esm/PopupToolbar.js.map +1 -1
- package/lib/esm/SectionDrawingLocationState.d.ts +90 -90
- package/lib/esm/SectionDrawingLocationState.js +132 -132
- package/lib/esm/SectionDrawingLocationState.js.map +1 -1
- package/lib/esm/SectionGraphicsProvider.d.ts +13 -13
- package/lib/esm/SectionGraphicsProvider.js +269 -269
- package/lib/esm/SectionGraphicsProvider.js.map +1 -1
- package/lib/esm/SectionMarkerHandler.d.ts +52 -52
- package/lib/esm/SectionMarkerHandler.js +108 -108
- package/lib/esm/SectionMarkerHandler.js.map +1 -1
- package/lib/esm/SectionMarkers.d.ts +82 -82
- package/lib/esm/SectionMarkers.js +168 -168
- package/lib/esm/SectionMarkers.js.map +1 -1
- package/lib/esm/Tools.d.ts +5 -5
- package/lib/esm/Tools.js +166 -166
- package/lib/esm/hypermodeling-frontend.d.ts +13 -13
- package/lib/esm/hypermodeling-frontend.js +17 -17
- package/lib/esm/hypermodeling-frontend.js.map +1 -1
- package/lib/public/locales/en/HyperModeling.json +32 -32
- package/package.json +13 -13
|
@@ -1,274 +1,274 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/*---------------------------------------------------------------------------------------------
|
|
3
|
-
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
-
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
-
*--------------------------------------------------------------------------------------------*/
|
|
6
|
-
/** @packageDocumentation
|
|
7
|
-
* @module HyperModeling
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.createSectionGraphicsProvider = void 0;
|
|
11
|
-
const core_bentley_1 = require("@itwin/core-bentley");
|
|
12
|
-
const core_geometry_1 = require("@itwin/core-geometry");
|
|
13
|
-
const core_common_1 = require("@itwin/core-common");
|
|
14
|
-
const core_frontend_1 = require("@itwin/core-frontend");
|
|
15
|
-
const HyperModeling_1 = require("./HyperModeling");
|
|
16
|
-
class ProxyTreeSupplier {
|
|
17
|
-
compareTileTreeIds(lhs, rhs) {
|
|
18
|
-
let cmp = (0, core_bentley_1.compareBooleans)(lhs.isSheet, rhs.isSheet);
|
|
19
|
-
if (0 === cmp)
|
|
20
|
-
cmp = (0, core_bentley_1.compareStrings)(lhs.state.id, rhs.state.id);
|
|
21
|
-
return cmp;
|
|
22
|
-
}
|
|
23
|
-
async createTileTree(id, iModel) {
|
|
24
|
-
let view;
|
|
25
|
-
if (id.isSheet) {
|
|
26
|
-
(0, core_bentley_1.assert)(undefined !== id.attachment);
|
|
27
|
-
view = await this.createSheetViewState(id.state, id.attachment);
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
view = await id.state.tryLoadDrawingView();
|
|
31
|
-
}
|
|
32
|
-
if (undefined === view)
|
|
33
|
-
return undefined;
|
|
34
|
-
try {
|
|
35
|
-
await iModel.models.load(view.baseModelId);
|
|
36
|
-
const model = iModel.models.getLoaded(view.baseModelId);
|
|
37
|
-
if (undefined === model || !(model instanceof core_frontend_1.GeometricModel2dState))
|
|
38
|
-
return undefined;
|
|
39
|
-
const treeRef = model.createTileTreeReference(view);
|
|
40
|
-
const tree = await treeRef.treeOwner.loadTree();
|
|
41
|
-
if (undefined === tree)
|
|
42
|
-
return undefined;
|
|
43
|
-
const ctor = id.isSheet ? SheetProxyTree : DrawingProxyTree;
|
|
44
|
-
return new ctor({ tree, ref: treeRef, view, state: id.state, attachment: id.attachment });
|
|
45
|
-
}
|
|
46
|
-
catch {
|
|
47
|
-
return undefined;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
async createSheetViewState(state, attachment) {
|
|
51
|
-
(0, core_bentley_1.assert)(undefined !== state.viewAttachment);
|
|
52
|
-
try {
|
|
53
|
-
// A persistent view of the sheet doesn't necessarily exist, and we don't want a SheetViewState anyway.
|
|
54
|
-
// All we want is to draw all the elements in the sheet (sans view attachments) clipped by the drawing boundary.
|
|
55
|
-
// However, ModelState.createTileTreeReference() requires a ViewState.
|
|
56
|
-
await state.iModel.models.load(attachment.model);
|
|
57
|
-
const sheet = state.iModel.models.getLoaded(attachment.model);
|
|
58
|
-
if (undefined === sheet || !(sheet instanceof core_frontend_1.SheetModelState))
|
|
59
|
-
return undefined;
|
|
60
|
-
const sheetExtents = await sheet.queryModelRange();
|
|
61
|
-
const viewProps = {
|
|
62
|
-
baseModelId: attachment.model,
|
|
63
|
-
origin: { x: 0, y: 0 },
|
|
64
|
-
delta: { x: sheetExtents.high.x, y: sheetExtents.high.y },
|
|
65
|
-
angle: 0,
|
|
66
|
-
categorySelectorId: core_bentley_1.Id64.invalid,
|
|
67
|
-
displayStyleId: core_bentley_1.Id64.invalid,
|
|
68
|
-
model: core_bentley_1.Id64.invalid,
|
|
69
|
-
code: {
|
|
70
|
-
spec: core_bentley_1.Id64.invalid,
|
|
71
|
-
scope: core_bentley_1.Id64.invalid,
|
|
72
|
-
},
|
|
73
|
-
classFullName: core_frontend_1.DrawingViewState.classFullName,
|
|
74
|
-
};
|
|
75
|
-
const displayStyle = new core_frontend_1.DisplayStyle2dState({}, state.iModel);
|
|
76
|
-
const categorySelector = new core_frontend_1.CategorySelectorState({}, state.iModel);
|
|
77
|
-
return new core_frontend_1.DrawingViewState(viewProps, state.iModel, categorySelector, displayStyle, sheetExtents);
|
|
78
|
-
}
|
|
79
|
-
catch {
|
|
80
|
-
return undefined;
|
|
81
|
-
}
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
const proxyTreeSupplier = new ProxyTreeSupplier();
|
|
85
|
-
/** A proxy for a 2d tile tree to be drawn in the context of a spatial view. */
|
|
86
|
-
class ProxyTreeReference extends core_frontend_1.TileTreeReference {
|
|
87
|
-
constructor(id) {
|
|
88
|
-
super();
|
|
89
|
-
this._owner = id.state.iModel.tiles.getTileTreeOwner(id, proxyTreeSupplier);
|
|
90
|
-
}
|
|
91
|
-
get castsShadows() {
|
|
92
|
-
return false;
|
|
93
|
-
}
|
|
94
|
-
getClipVolume(tree) {
|
|
95
|
-
return true !== HyperModeling_1.HyperModeling.graphicsConfig.ignoreClip ? super.getClipVolume(tree) : undefined;
|
|
96
|
-
}
|
|
97
|
-
get treeOwner() { return this._owner; }
|
|
98
|
-
get _proxiedRef() {
|
|
99
|
-
const proxiedTree = this.treeOwner.tileTree;
|
|
100
|
-
return undefined !== proxiedTree ? proxiedTree.ref : undefined;
|
|
101
|
-
}
|
|
102
|
-
discloseTileTrees(trees) {
|
|
103
|
-
super.discloseTileTrees(trees);
|
|
104
|
-
const ref = this._proxiedRef;
|
|
105
|
-
if (undefined !== ref)
|
|
106
|
-
ref.discloseTileTrees(trees);
|
|
107
|
-
}
|
|
108
|
-
async getToolTip(hit) {
|
|
109
|
-
const ref = this._proxiedRef;
|
|
110
|
-
return undefined !== ref ? ref.getToolTip(hit) : super.getToolTip(hit);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
/** A proxy for a 2d tile tree to be drawn in the context of a spatial view. */
|
|
114
|
-
class ProxyTree extends core_frontend_1.TileTree {
|
|
115
|
-
constructor(params, location, clipVolume) {
|
|
116
|
-
const { tree, ref, view } = { ...params };
|
|
117
|
-
super({
|
|
118
|
-
id: params.state.id,
|
|
119
|
-
modelId: tree.modelId,
|
|
120
|
-
iModel: tree.iModel,
|
|
121
|
-
location,
|
|
122
|
-
priority: core_frontend_1.TileLoadPriority.Primary,
|
|
123
|
-
clipVolume,
|
|
124
|
-
});
|
|
125
|
-
this.tree = tree;
|
|
126
|
-
this.ref = ref;
|
|
127
|
-
this.symbologyOverrides = new core_frontend_1.FeatureSymbology.Overrides(view);
|
|
128
|
-
const range = tree.iModelTransform.multiplyRange(tree.rootTile.range);
|
|
129
|
-
const inverse = location.inverse();
|
|
130
|
-
if (undefined !== inverse)
|
|
131
|
-
inverse.multiplyRange(range, range);
|
|
132
|
-
this._viewFlagOverrides = {
|
|
133
|
-
...view.viewFlags,
|
|
134
|
-
lighting: false,
|
|
135
|
-
// View clip (section clip) should not apply to 2d graphics.
|
|
136
|
-
clipVolume: false,
|
|
137
|
-
};
|
|
138
|
-
this._rootTile = new ProxyTile(this, range);
|
|
139
|
-
}
|
|
140
|
-
get rootTile() { return this._rootTile; }
|
|
141
|
-
get viewFlagOverrides() { return this._viewFlagOverrides; }
|
|
142
|
-
get is3d() { return false; }
|
|
143
|
-
get isContentUnbounded() { return false; }
|
|
144
|
-
get maxDepth() { return 1; }
|
|
145
|
-
draw(args) {
|
|
146
|
-
if (!this.isDisplayed)
|
|
147
|
-
return;
|
|
148
|
-
const tiles = this.selectTiles(args);
|
|
149
|
-
for (const tile of tiles)
|
|
150
|
-
tile.drawGraphics(args);
|
|
151
|
-
args.drawGraphics();
|
|
152
|
-
}
|
|
153
|
-
_selectTiles(_args) {
|
|
154
|
-
return this.isDisplayed ? [this.rootTile] : [];
|
|
155
|
-
}
|
|
156
|
-
prune() {
|
|
157
|
-
// Our single tile is only a proxy. Our proxied tree(s) will be pruned separately
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
class DrawingProxyTree extends ProxyTree {
|
|
161
|
-
constructor(params) {
|
|
162
|
-
var _a;
|
|
163
|
-
const { state, attachment } = { ...params };
|
|
164
|
-
const location = state.drawingToSpatialTransform.clone();
|
|
165
|
-
let clipVolume;
|
|
166
|
-
if (attachment) {
|
|
167
|
-
(0, core_bentley_1.assert)(undefined !== state.viewAttachment);
|
|
168
|
-
const clipJSON = (_a = attachment.jsonProperties) === null || _a === void 0 ? void 0 : _a.clip;
|
|
169
|
-
const clip = clipJSON ? core_geometry_1.ClipVector.fromJSON(clipJSON) : core_geometry_1.ClipVector.createEmpty();
|
|
170
|
-
if (!clipJSON) {
|
|
171
|
-
const placement = core_common_1.Placement2d.fromJSON(attachment.placement);
|
|
172
|
-
const range = placement.calculateRange();
|
|
173
|
-
clip.appendShape([
|
|
174
|
-
core_geometry_1.Point3d.create(range.low.x, range.low.y),
|
|
175
|
-
core_geometry_1.Point3d.create(range.high.x, range.low.y),
|
|
176
|
-
core_geometry_1.Point3d.create(range.high.x, range.high.y),
|
|
177
|
-
core_geometry_1.Point3d.create(range.low.x, range.high.y),
|
|
178
|
-
]);
|
|
179
|
-
}
|
|
180
|
-
if (clip.isValid) {
|
|
181
|
-
const sheetToWorld = state.viewAttachment.transformToSpatial.clone();
|
|
182
|
-
clip.transformInPlace(sheetToWorld);
|
|
183
|
-
clipVolume = core_frontend_1.IModelApp.renderSystem.createClipVolume(clip);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
super(params, location, clipVolume);
|
|
187
|
-
}
|
|
188
|
-
get isDisplayed() { return true !== HyperModeling_1.HyperModeling.graphicsConfig.hideSectionGraphics; }
|
|
189
|
-
}
|
|
190
|
-
class SheetProxyTree extends ProxyTree {
|
|
191
|
-
constructor(params) {
|
|
192
|
-
const { state, attachment } = { ...params };
|
|
193
|
-
(0, core_bentley_1.assert)(undefined !== state.viewAttachment);
|
|
194
|
-
(0, core_bentley_1.assert)(undefined !== attachment);
|
|
195
|
-
const location = state.viewAttachment.transformToSpatial.clone();
|
|
196
|
-
let clipVolume;
|
|
197
|
-
if (state.viewAttachment.clip)
|
|
198
|
-
clipVolume = core_frontend_1.IModelApp.renderSystem.createClipVolume(state.viewAttachment.clip);
|
|
199
|
-
super(params, location, clipVolume);
|
|
200
|
-
// Our view is manufactured. It draws everything regardless of subcategory.
|
|
201
|
-
this.symbologyOverrides.ignoreSubCategory = true;
|
|
202
|
-
}
|
|
203
|
-
get isDisplayed() { return true !== HyperModeling_1.HyperModeling.graphicsConfig.hideSheetAnnotations; }
|
|
204
|
-
}
|
|
205
|
-
/** The single Tile belonging to a ProxyTree, serving as a proxy for all of the proxied tree's tiles. */
|
|
206
|
-
class ProxyTile extends core_frontend_1.Tile {
|
|
207
|
-
constructor(tree, range) {
|
|
208
|
-
super({ contentId: "", range, maximumSize: 512, isLeaf: true }, tree);
|
|
209
|
-
this.setIsReady();
|
|
210
|
-
}
|
|
211
|
-
get hasChildren() { return false; }
|
|
212
|
-
get hasGraphics() { return true; }
|
|
213
|
-
get channel() { throw new Error("Proxy tile has no content"); }
|
|
214
|
-
async requestContent(_isCanceled) { return undefined; }
|
|
215
|
-
async readContent(_data, _system, _isCanceled) { return {}; }
|
|
216
|
-
_loadChildren(_resolve, _reject) { }
|
|
217
|
-
drawGraphics(args) {
|
|
218
|
-
const proxyTree = this.tree;
|
|
219
|
-
const sectionTree = proxyTree.tree;
|
|
220
|
-
const location = proxyTree.iModelTransform.multiplyTransformTransform(sectionTree.iModelTransform);
|
|
221
|
-
const clipVolume = true === proxyTree.viewFlagOverrides.clipVolume ? proxyTree.clipVolume : undefined;
|
|
222
|
-
args = new core_frontend_1.TileDrawArgs({ context: args.context, location, tree: sectionTree, now: args.now, viewFlagOverrides: proxyTree.viewFlagOverrides, clipVolume, parentsAndChildrenExclusive: args.parentsAndChildrenExclusive, symbologyOverrides: proxyTree.symbologyOverrides });
|
|
223
|
-
sectionTree.draw(args);
|
|
224
|
-
const rangeGfx = this.getRangeGraphic(args.context);
|
|
225
|
-
if (undefined !== rangeGfx)
|
|
226
|
-
args.graphics.add(rangeGfx);
|
|
227
|
-
if (true !== HyperModeling_1.HyperModeling.graphicsConfig.debugClipVolumes || undefined === proxyTree.clipVolume)
|
|
228
|
-
return;
|
|
229
|
-
const builder = args.context.createSceneGraphicBuilder();
|
|
230
|
-
builder.setSymbology(core_common_1.ColorDef.red, core_common_1.ColorDef.red, 2);
|
|
231
|
-
for (const prim of proxyTree.clipVolume.clipVector.clips) {
|
|
232
|
-
if (!(prim instanceof core_geometry_1.ClipShape))
|
|
233
|
-
continue;
|
|
234
|
-
const tf = prim.transformFromClip;
|
|
235
|
-
const pts = prim.polygon.map((pt) => tf ? tf.multiplyPoint3d(pt) : pt.clone());
|
|
236
|
-
builder.addLineString(pts);
|
|
237
|
-
}
|
|
238
|
-
const branch = new core_frontend_1.GraphicBranch();
|
|
239
|
-
branch.entries.push(builder.finish());
|
|
240
|
-
branch.setViewFlagOverrides({ clipVolume: false });
|
|
241
|
-
args.context.outputGraphic(args.context.createGraphicBranch(branch, core_geometry_1.Transform.createIdentity()));
|
|
242
|
-
}
|
|
243
|
-
}
|
|
244
|
-
/** Draws the 2d section graphics into the 3d view. */
|
|
245
|
-
class SectionGraphicsProvider {
|
|
246
|
-
constructor(state, attachment) {
|
|
247
|
-
this._drawingRef = new ProxyTreeReference({ state, attachment, isSheet: false });
|
|
248
|
-
if (attachment)
|
|
249
|
-
this._sheetRef = new ProxyTreeReference({ state, attachment, isSheet: true });
|
|
250
|
-
}
|
|
251
|
-
forEachTileTreeRef(_viewport, func) {
|
|
252
|
-
func(this._drawingRef);
|
|
253
|
-
if (undefined !== this._sheetRef)
|
|
254
|
-
func(this._sheetRef);
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
/** Creates a TiledGraphicsProvider that can be associated with a [Viewport]($frontend) to display 2d section graphics and annotations in the context of a [SpatialViewState]($frontend).
|
|
258
|
-
* Typically used indirectly via [[HyperModelingDecorator]].
|
|
259
|
-
* @param state The section drawing location specifying which section drawing to display.
|
|
260
|
-
* @returns A provider suitable for passing to [Viewport.addTiledGraphicsProvider]($frontend).
|
|
261
|
-
* @see [[HyperModelingDecorator.toggleAttachment]] to activate section graphics for a given [[SectionMarker]].
|
|
262
|
-
* @public
|
|
263
|
-
*/
|
|
264
|
-
async function createSectionGraphicsProvider(state) {
|
|
265
|
-
let attachment;
|
|
266
|
-
if (undefined !== state.viewAttachment) {
|
|
267
|
-
const attachments = await state.iModel.elements.getProps(state.viewAttachment.id);
|
|
268
|
-
if (1 === attachments.length)
|
|
269
|
-
attachment = attachments[0];
|
|
270
|
-
}
|
|
271
|
-
return new SectionGraphicsProvider(state, attachment);
|
|
272
|
-
}
|
|
273
|
-
exports.createSectionGraphicsProvider = createSectionGraphicsProvider;
|
|
1
|
+
"use strict";
|
|
2
|
+
/*---------------------------------------------------------------------------------------------
|
|
3
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
4
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
5
|
+
*--------------------------------------------------------------------------------------------*/
|
|
6
|
+
/** @packageDocumentation
|
|
7
|
+
* @module HyperModeling
|
|
8
|
+
*/
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.createSectionGraphicsProvider = void 0;
|
|
11
|
+
const core_bentley_1 = require("@itwin/core-bentley");
|
|
12
|
+
const core_geometry_1 = require("@itwin/core-geometry");
|
|
13
|
+
const core_common_1 = require("@itwin/core-common");
|
|
14
|
+
const core_frontend_1 = require("@itwin/core-frontend");
|
|
15
|
+
const HyperModeling_1 = require("./HyperModeling");
|
|
16
|
+
class ProxyTreeSupplier {
|
|
17
|
+
compareTileTreeIds(lhs, rhs) {
|
|
18
|
+
let cmp = (0, core_bentley_1.compareBooleans)(lhs.isSheet, rhs.isSheet);
|
|
19
|
+
if (0 === cmp)
|
|
20
|
+
cmp = (0, core_bentley_1.compareStrings)(lhs.state.id, rhs.state.id);
|
|
21
|
+
return cmp;
|
|
22
|
+
}
|
|
23
|
+
async createTileTree(id, iModel) {
|
|
24
|
+
let view;
|
|
25
|
+
if (id.isSheet) {
|
|
26
|
+
(0, core_bentley_1.assert)(undefined !== id.attachment);
|
|
27
|
+
view = await this.createSheetViewState(id.state, id.attachment);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
view = await id.state.tryLoadDrawingView();
|
|
31
|
+
}
|
|
32
|
+
if (undefined === view)
|
|
33
|
+
return undefined;
|
|
34
|
+
try {
|
|
35
|
+
await iModel.models.load(view.baseModelId);
|
|
36
|
+
const model = iModel.models.getLoaded(view.baseModelId);
|
|
37
|
+
if (undefined === model || !(model instanceof core_frontend_1.GeometricModel2dState))
|
|
38
|
+
return undefined;
|
|
39
|
+
const treeRef = model.createTileTreeReference(view);
|
|
40
|
+
const tree = await treeRef.treeOwner.loadTree();
|
|
41
|
+
if (undefined === tree)
|
|
42
|
+
return undefined;
|
|
43
|
+
const ctor = id.isSheet ? SheetProxyTree : DrawingProxyTree;
|
|
44
|
+
return new ctor({ tree, ref: treeRef, view, state: id.state, attachment: id.attachment });
|
|
45
|
+
}
|
|
46
|
+
catch {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
async createSheetViewState(state, attachment) {
|
|
51
|
+
(0, core_bentley_1.assert)(undefined !== state.viewAttachment);
|
|
52
|
+
try {
|
|
53
|
+
// A persistent view of the sheet doesn't necessarily exist, and we don't want a SheetViewState anyway.
|
|
54
|
+
// All we want is to draw all the elements in the sheet (sans view attachments) clipped by the drawing boundary.
|
|
55
|
+
// However, ModelState.createTileTreeReference() requires a ViewState.
|
|
56
|
+
await state.iModel.models.load(attachment.model);
|
|
57
|
+
const sheet = state.iModel.models.getLoaded(attachment.model);
|
|
58
|
+
if (undefined === sheet || !(sheet instanceof core_frontend_1.SheetModelState))
|
|
59
|
+
return undefined;
|
|
60
|
+
const sheetExtents = await sheet.queryModelRange();
|
|
61
|
+
const viewProps = {
|
|
62
|
+
baseModelId: attachment.model,
|
|
63
|
+
origin: { x: 0, y: 0 },
|
|
64
|
+
delta: { x: sheetExtents.high.x, y: sheetExtents.high.y },
|
|
65
|
+
angle: 0,
|
|
66
|
+
categorySelectorId: core_bentley_1.Id64.invalid,
|
|
67
|
+
displayStyleId: core_bentley_1.Id64.invalid,
|
|
68
|
+
model: core_bentley_1.Id64.invalid,
|
|
69
|
+
code: {
|
|
70
|
+
spec: core_bentley_1.Id64.invalid,
|
|
71
|
+
scope: core_bentley_1.Id64.invalid,
|
|
72
|
+
},
|
|
73
|
+
classFullName: core_frontend_1.DrawingViewState.classFullName,
|
|
74
|
+
};
|
|
75
|
+
const displayStyle = new core_frontend_1.DisplayStyle2dState({}, state.iModel);
|
|
76
|
+
const categorySelector = new core_frontend_1.CategorySelectorState({}, state.iModel);
|
|
77
|
+
return new core_frontend_1.DrawingViewState(viewProps, state.iModel, categorySelector, displayStyle, sheetExtents);
|
|
78
|
+
}
|
|
79
|
+
catch {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
const proxyTreeSupplier = new ProxyTreeSupplier();
|
|
85
|
+
/** A proxy for a 2d tile tree to be drawn in the context of a spatial view. */
|
|
86
|
+
class ProxyTreeReference extends core_frontend_1.TileTreeReference {
|
|
87
|
+
constructor(id) {
|
|
88
|
+
super();
|
|
89
|
+
this._owner = id.state.iModel.tiles.getTileTreeOwner(id, proxyTreeSupplier);
|
|
90
|
+
}
|
|
91
|
+
get castsShadows() {
|
|
92
|
+
return false;
|
|
93
|
+
}
|
|
94
|
+
getClipVolume(tree) {
|
|
95
|
+
return true !== HyperModeling_1.HyperModeling.graphicsConfig.ignoreClip ? super.getClipVolume(tree) : undefined;
|
|
96
|
+
}
|
|
97
|
+
get treeOwner() { return this._owner; }
|
|
98
|
+
get _proxiedRef() {
|
|
99
|
+
const proxiedTree = this.treeOwner.tileTree;
|
|
100
|
+
return undefined !== proxiedTree ? proxiedTree.ref : undefined;
|
|
101
|
+
}
|
|
102
|
+
discloseTileTrees(trees) {
|
|
103
|
+
super.discloseTileTrees(trees);
|
|
104
|
+
const ref = this._proxiedRef;
|
|
105
|
+
if (undefined !== ref)
|
|
106
|
+
ref.discloseTileTrees(trees);
|
|
107
|
+
}
|
|
108
|
+
async getToolTip(hit) {
|
|
109
|
+
const ref = this._proxiedRef;
|
|
110
|
+
return undefined !== ref ? ref.getToolTip(hit) : super.getToolTip(hit);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/** A proxy for a 2d tile tree to be drawn in the context of a spatial view. */
|
|
114
|
+
class ProxyTree extends core_frontend_1.TileTree {
|
|
115
|
+
constructor(params, location, clipVolume) {
|
|
116
|
+
const { tree, ref, view } = { ...params };
|
|
117
|
+
super({
|
|
118
|
+
id: params.state.id,
|
|
119
|
+
modelId: tree.modelId,
|
|
120
|
+
iModel: tree.iModel,
|
|
121
|
+
location,
|
|
122
|
+
priority: core_frontend_1.TileLoadPriority.Primary,
|
|
123
|
+
clipVolume,
|
|
124
|
+
});
|
|
125
|
+
this.tree = tree;
|
|
126
|
+
this.ref = ref;
|
|
127
|
+
this.symbologyOverrides = new core_frontend_1.FeatureSymbology.Overrides(view);
|
|
128
|
+
const range = tree.iModelTransform.multiplyRange(tree.rootTile.range);
|
|
129
|
+
const inverse = location.inverse();
|
|
130
|
+
if (undefined !== inverse)
|
|
131
|
+
inverse.multiplyRange(range, range);
|
|
132
|
+
this._viewFlagOverrides = {
|
|
133
|
+
...view.viewFlags,
|
|
134
|
+
lighting: false,
|
|
135
|
+
// View clip (section clip) should not apply to 2d graphics.
|
|
136
|
+
clipVolume: false,
|
|
137
|
+
};
|
|
138
|
+
this._rootTile = new ProxyTile(this, range);
|
|
139
|
+
}
|
|
140
|
+
get rootTile() { return this._rootTile; }
|
|
141
|
+
get viewFlagOverrides() { return this._viewFlagOverrides; }
|
|
142
|
+
get is3d() { return false; }
|
|
143
|
+
get isContentUnbounded() { return false; }
|
|
144
|
+
get maxDepth() { return 1; }
|
|
145
|
+
draw(args) {
|
|
146
|
+
if (!this.isDisplayed)
|
|
147
|
+
return;
|
|
148
|
+
const tiles = this.selectTiles(args);
|
|
149
|
+
for (const tile of tiles)
|
|
150
|
+
tile.drawGraphics(args);
|
|
151
|
+
args.drawGraphics();
|
|
152
|
+
}
|
|
153
|
+
_selectTiles(_args) {
|
|
154
|
+
return this.isDisplayed ? [this.rootTile] : [];
|
|
155
|
+
}
|
|
156
|
+
prune() {
|
|
157
|
+
// Our single tile is only a proxy. Our proxied tree(s) will be pruned separately
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
class DrawingProxyTree extends ProxyTree {
|
|
161
|
+
constructor(params) {
|
|
162
|
+
var _a;
|
|
163
|
+
const { state, attachment } = { ...params };
|
|
164
|
+
const location = state.drawingToSpatialTransform.clone();
|
|
165
|
+
let clipVolume;
|
|
166
|
+
if (attachment) {
|
|
167
|
+
(0, core_bentley_1.assert)(undefined !== state.viewAttachment);
|
|
168
|
+
const clipJSON = (_a = attachment.jsonProperties) === null || _a === void 0 ? void 0 : _a.clip;
|
|
169
|
+
const clip = clipJSON ? core_geometry_1.ClipVector.fromJSON(clipJSON) : core_geometry_1.ClipVector.createEmpty();
|
|
170
|
+
if (!clipJSON) {
|
|
171
|
+
const placement = core_common_1.Placement2d.fromJSON(attachment.placement);
|
|
172
|
+
const range = placement.calculateRange();
|
|
173
|
+
clip.appendShape([
|
|
174
|
+
core_geometry_1.Point3d.create(range.low.x, range.low.y),
|
|
175
|
+
core_geometry_1.Point3d.create(range.high.x, range.low.y),
|
|
176
|
+
core_geometry_1.Point3d.create(range.high.x, range.high.y),
|
|
177
|
+
core_geometry_1.Point3d.create(range.low.x, range.high.y),
|
|
178
|
+
]);
|
|
179
|
+
}
|
|
180
|
+
if (clip.isValid) {
|
|
181
|
+
const sheetToWorld = state.viewAttachment.transformToSpatial.clone();
|
|
182
|
+
clip.transformInPlace(sheetToWorld);
|
|
183
|
+
clipVolume = core_frontend_1.IModelApp.renderSystem.createClipVolume(clip);
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
super(params, location, clipVolume);
|
|
187
|
+
}
|
|
188
|
+
get isDisplayed() { return true !== HyperModeling_1.HyperModeling.graphicsConfig.hideSectionGraphics; }
|
|
189
|
+
}
|
|
190
|
+
class SheetProxyTree extends ProxyTree {
|
|
191
|
+
constructor(params) {
|
|
192
|
+
const { state, attachment } = { ...params };
|
|
193
|
+
(0, core_bentley_1.assert)(undefined !== state.viewAttachment);
|
|
194
|
+
(0, core_bentley_1.assert)(undefined !== attachment);
|
|
195
|
+
const location = state.viewAttachment.transformToSpatial.clone();
|
|
196
|
+
let clipVolume;
|
|
197
|
+
if (state.viewAttachment.clip)
|
|
198
|
+
clipVolume = core_frontend_1.IModelApp.renderSystem.createClipVolume(state.viewAttachment.clip);
|
|
199
|
+
super(params, location, clipVolume);
|
|
200
|
+
// Our view is manufactured. It draws everything regardless of subcategory.
|
|
201
|
+
this.symbologyOverrides.ignoreSubCategory = true;
|
|
202
|
+
}
|
|
203
|
+
get isDisplayed() { return true !== HyperModeling_1.HyperModeling.graphicsConfig.hideSheetAnnotations; }
|
|
204
|
+
}
|
|
205
|
+
/** The single Tile belonging to a ProxyTree, serving as a proxy for all of the proxied tree's tiles. */
|
|
206
|
+
class ProxyTile extends core_frontend_1.Tile {
|
|
207
|
+
constructor(tree, range) {
|
|
208
|
+
super({ contentId: "", range, maximumSize: 512, isLeaf: true }, tree);
|
|
209
|
+
this.setIsReady();
|
|
210
|
+
}
|
|
211
|
+
get hasChildren() { return false; }
|
|
212
|
+
get hasGraphics() { return true; }
|
|
213
|
+
get channel() { throw new Error("Proxy tile has no content"); }
|
|
214
|
+
async requestContent(_isCanceled) { return undefined; }
|
|
215
|
+
async readContent(_data, _system, _isCanceled) { return {}; }
|
|
216
|
+
_loadChildren(_resolve, _reject) { }
|
|
217
|
+
drawGraphics(args) {
|
|
218
|
+
const proxyTree = this.tree;
|
|
219
|
+
const sectionTree = proxyTree.tree;
|
|
220
|
+
const location = proxyTree.iModelTransform.multiplyTransformTransform(sectionTree.iModelTransform);
|
|
221
|
+
const clipVolume = true === proxyTree.viewFlagOverrides.clipVolume ? proxyTree.clipVolume : undefined;
|
|
222
|
+
args = new core_frontend_1.TileDrawArgs({ context: args.context, location, tree: sectionTree, now: args.now, viewFlagOverrides: proxyTree.viewFlagOverrides, clipVolume, parentsAndChildrenExclusive: args.parentsAndChildrenExclusive, symbologyOverrides: proxyTree.symbologyOverrides });
|
|
223
|
+
sectionTree.draw(args);
|
|
224
|
+
const rangeGfx = this.getRangeGraphic(args.context);
|
|
225
|
+
if (undefined !== rangeGfx)
|
|
226
|
+
args.graphics.add(rangeGfx);
|
|
227
|
+
if (true !== HyperModeling_1.HyperModeling.graphicsConfig.debugClipVolumes || undefined === proxyTree.clipVolume)
|
|
228
|
+
return;
|
|
229
|
+
const builder = args.context.createSceneGraphicBuilder();
|
|
230
|
+
builder.setSymbology(core_common_1.ColorDef.red, core_common_1.ColorDef.red, 2);
|
|
231
|
+
for (const prim of proxyTree.clipVolume.clipVector.clips) {
|
|
232
|
+
if (!(prim instanceof core_geometry_1.ClipShape))
|
|
233
|
+
continue;
|
|
234
|
+
const tf = prim.transformFromClip;
|
|
235
|
+
const pts = prim.polygon.map((pt) => tf ? tf.multiplyPoint3d(pt) : pt.clone());
|
|
236
|
+
builder.addLineString(pts);
|
|
237
|
+
}
|
|
238
|
+
const branch = new core_frontend_1.GraphicBranch();
|
|
239
|
+
branch.entries.push(builder.finish());
|
|
240
|
+
branch.setViewFlagOverrides({ clipVolume: false });
|
|
241
|
+
args.context.outputGraphic(args.context.createGraphicBranch(branch, core_geometry_1.Transform.createIdentity()));
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
/** Draws the 2d section graphics into the 3d view. */
|
|
245
|
+
class SectionGraphicsProvider {
|
|
246
|
+
constructor(state, attachment) {
|
|
247
|
+
this._drawingRef = new ProxyTreeReference({ state, attachment, isSheet: false });
|
|
248
|
+
if (attachment)
|
|
249
|
+
this._sheetRef = new ProxyTreeReference({ state, attachment, isSheet: true });
|
|
250
|
+
}
|
|
251
|
+
forEachTileTreeRef(_viewport, func) {
|
|
252
|
+
func(this._drawingRef);
|
|
253
|
+
if (undefined !== this._sheetRef)
|
|
254
|
+
func(this._sheetRef);
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
/** Creates a TiledGraphicsProvider that can be associated with a [Viewport]($frontend) to display 2d section graphics and annotations in the context of a [SpatialViewState]($frontend).
|
|
258
|
+
* Typically used indirectly via [[HyperModelingDecorator]].
|
|
259
|
+
* @param state The section drawing location specifying which section drawing to display.
|
|
260
|
+
* @returns A provider suitable for passing to [Viewport.addTiledGraphicsProvider]($frontend).
|
|
261
|
+
* @see [[HyperModelingDecorator.toggleAttachment]] to activate section graphics for a given [[SectionMarker]].
|
|
262
|
+
* @public
|
|
263
|
+
*/
|
|
264
|
+
async function createSectionGraphicsProvider(state) {
|
|
265
|
+
let attachment;
|
|
266
|
+
if (undefined !== state.viewAttachment) {
|
|
267
|
+
const attachments = await state.iModel.elements.getProps(state.viewAttachment.id);
|
|
268
|
+
if (1 === attachments.length)
|
|
269
|
+
attachment = attachments[0];
|
|
270
|
+
}
|
|
271
|
+
return new SectionGraphicsProvider(state, attachment);
|
|
272
|
+
}
|
|
273
|
+
exports.createSectionGraphicsProvider = createSectionGraphicsProvider;
|
|
274
274
|
//# sourceMappingURL=SectionGraphicsProvider.js.map
|