@itwin/hypermodeling-frontend 3.7.1 → 3.7.3

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