@itwin/hypermodeling-frontend 4.0.0-dev.52 → 4.0.0-dev.55
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/lib/cjs/HyperModeling.d.ts +114 -114
- package/lib/cjs/HyperModeling.js +238 -238
- package/lib/cjs/HyperModeling.js.map +1 -1
- package/lib/cjs/HyperModelingConfig.d.ts +54 -54
- package/lib/cjs/HyperModelingConfig.js +9 -9
- package/lib/cjs/HyperModelingDecorator.d.ts +110 -110
- package/lib/cjs/HyperModelingDecorator.js +335 -335
- 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 +107 -107
- package/lib/cjs/SectionGraphicsProvider.d.ts +13 -13
- package/lib/cjs/SectionGraphicsProvider.js +272 -272
- package/lib/cjs/SectionMarkerHandler.d.ts +52 -52
- package/lib/cjs/SectionMarkerHandler.js +111 -111
- package/lib/cjs/SectionMarkers.d.ts +82 -82
- package/lib/cjs/SectionMarkers.js +174 -174
- 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 +33 -29
- package/lib/cjs/hypermodeling-frontend.js.map +1 -1
- package/lib/esm/HyperModeling.d.ts +114 -114
- package/lib/esm/HyperModeling.js +235 -234
- package/lib/esm/HyperModeling.js.map +1 -1
- package/lib/esm/HyperModelingConfig.d.ts +54 -54
- package/lib/esm/HyperModelingConfig.js +8 -8
- package/lib/esm/HyperModelingDecorator.d.ts +110 -110
- package/lib/esm/HyperModelingDecorator.js +331 -331
- package/lib/esm/HyperModelingDecorator.js.map +1 -1
- package/lib/esm/PopupToolbar.d.ts +24 -24
- package/lib/esm/PopupToolbar.js +54 -53
- package/lib/esm/PopupToolbar.js.map +1 -1
- package/lib/esm/SectionDrawingLocationState.d.ts +90 -90
- package/lib/esm/SectionDrawingLocationState.js +103 -103
- package/lib/esm/SectionGraphicsProvider.d.ts +13 -13
- package/lib/esm/SectionGraphicsProvider.js +268 -268
- package/lib/esm/SectionMarkerHandler.d.ts +52 -52
- package/lib/esm/SectionMarkerHandler.js +107 -107
- package/lib/esm/SectionMarkers.d.ts +82 -82
- package/lib/esm/SectionMarkers.js +168 -168
- 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/package.json +14 -14
|
@@ -1,269 +1,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
|
-
const { state, attachment } = { ...params };
|
|
160
|
-
const location = state.drawingToSpatialTransform.clone();
|
|
161
|
-
let clipVolume;
|
|
162
|
-
if (attachment) {
|
|
163
|
-
assert(undefined !== state.viewAttachment);
|
|
164
|
-
const clipJSON = attachment.jsonProperties?.clip;
|
|
165
|
-
const clip = clipJSON ? ClipVector.fromJSON(clipJSON) : ClipVector.createEmpty();
|
|
166
|
-
if (!clipJSON) {
|
|
167
|
-
const placement = Placement2d.fromJSON(attachment.placement);
|
|
168
|
-
const range = placement.calculateRange();
|
|
169
|
-
clip.appendShape([
|
|
170
|
-
Point3d.create(range.low.x, range.low.y),
|
|
171
|
-
Point3d.create(range.high.x, range.low.y),
|
|
172
|
-
Point3d.create(range.high.x, range.high.y),
|
|
173
|
-
Point3d.create(range.low.x, range.high.y),
|
|
174
|
-
]);
|
|
175
|
-
}
|
|
176
|
-
if (clip.isValid) {
|
|
177
|
-
const sheetToWorld = state.viewAttachment.transformToSpatial.clone();
|
|
178
|
-
clip.transformInPlace(sheetToWorld);
|
|
179
|
-
clipVolume = IModelApp.renderSystem.createClipVolume(clip);
|
|
180
|
-
}
|
|
181
|
-
}
|
|
182
|
-
super(params, location, clipVolume);
|
|
183
|
-
}
|
|
184
|
-
get isDisplayed() { return true !== HyperModeling.graphicsConfig.hideSectionGraphics; }
|
|
185
|
-
}
|
|
186
|
-
class SheetProxyTree extends ProxyTree {
|
|
187
|
-
constructor(params) {
|
|
188
|
-
const { state, attachment } = { ...params };
|
|
189
|
-
assert(undefined !== state.viewAttachment);
|
|
190
|
-
assert(undefined !== attachment);
|
|
191
|
-
const location = state.viewAttachment.transformToSpatial.clone();
|
|
192
|
-
let clipVolume;
|
|
193
|
-
if (state.viewAttachment.clip)
|
|
194
|
-
clipVolume = IModelApp.renderSystem.createClipVolume(state.viewAttachment.clip);
|
|
195
|
-
super(params, location, clipVolume);
|
|
196
|
-
// Our view is manufactured. It draws everything regardless of subcategory.
|
|
197
|
-
this.symbologyOverrides.ignoreSubCategory = true;
|
|
198
|
-
}
|
|
199
|
-
get isDisplayed() { return true !== HyperModeling.graphicsConfig.hideSheetAnnotations; }
|
|
200
|
-
}
|
|
201
|
-
/** The single Tile belonging to a ProxyTree, serving as a proxy for all of the proxied tree's tiles. */
|
|
202
|
-
class ProxyTile extends Tile {
|
|
203
|
-
constructor(tree, range) {
|
|
204
|
-
super({ contentId: "", range, maximumSize: 512, isLeaf: true }, tree);
|
|
205
|
-
this.setIsReady();
|
|
206
|
-
}
|
|
207
|
-
get hasChildren() { return false; }
|
|
208
|
-
get hasGraphics() { return true; }
|
|
209
|
-
get channel() { throw new Error("Proxy tile has no content"); }
|
|
210
|
-
async requestContent(_isCanceled) { return undefined; }
|
|
211
|
-
async readContent(_data, _system, _isCanceled) { return {}; }
|
|
212
|
-
_loadChildren(_resolve, _reject) { }
|
|
213
|
-
drawGraphics(args) {
|
|
214
|
-
const proxyTree = this.tree;
|
|
215
|
-
const sectionTree = proxyTree.tree;
|
|
216
|
-
const location = proxyTree.iModelTransform.multiplyTransformTransform(sectionTree.iModelTransform);
|
|
217
|
-
const clipVolume = true === proxyTree.viewFlagOverrides.clipVolume ? proxyTree.clipVolume : undefined;
|
|
218
|
-
args = new TileDrawArgs({ context: args.context, location, tree: sectionTree, now: args.now, viewFlagOverrides: proxyTree.viewFlagOverrides, clipVolume, parentsAndChildrenExclusive: args.parentsAndChildrenExclusive, symbologyOverrides: proxyTree.symbologyOverrides });
|
|
219
|
-
sectionTree.draw(args);
|
|
220
|
-
const rangeGfx = this.getRangeGraphic(args.context);
|
|
221
|
-
if (undefined !== rangeGfx)
|
|
222
|
-
args.graphics.add(rangeGfx);
|
|
223
|
-
if (true !== HyperModeling.graphicsConfig.debugClipVolumes || undefined === proxyTree.clipVolume)
|
|
224
|
-
return;
|
|
225
|
-
const builder = args.context.createSceneGraphicBuilder();
|
|
226
|
-
builder.setSymbology(ColorDef.red, ColorDef.red, 2);
|
|
227
|
-
for (const prim of proxyTree.clipVolume.clipVector.clips) {
|
|
228
|
-
if (!(prim instanceof ClipShape))
|
|
229
|
-
continue;
|
|
230
|
-
const tf = prim.transformFromClip;
|
|
231
|
-
const pts = prim.polygon.map((pt) => tf ? tf.multiplyPoint3d(pt) : pt.clone());
|
|
232
|
-
builder.addLineString(pts);
|
|
233
|
-
}
|
|
234
|
-
const branch = new GraphicBranch();
|
|
235
|
-
branch.entries.push(builder.finish());
|
|
236
|
-
branch.setViewFlagOverrides({ clipVolume: false });
|
|
237
|
-
args.context.outputGraphic(args.context.createGraphicBranch(branch, Transform.createIdentity()));
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
/** Draws the 2d section graphics into the 3d view. */
|
|
241
|
-
class SectionGraphicsProvider {
|
|
242
|
-
constructor(state, attachment) {
|
|
243
|
-
this._drawingRef = new ProxyTreeReference({ state, attachment, isSheet: false });
|
|
244
|
-
if (attachment)
|
|
245
|
-
this._sheetRef = new ProxyTreeReference({ state, attachment, isSheet: true });
|
|
246
|
-
}
|
|
247
|
-
forEachTileTreeRef(_viewport, func) {
|
|
248
|
-
func(this._drawingRef);
|
|
249
|
-
if (undefined !== this._sheetRef)
|
|
250
|
-
func(this._sheetRef);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
/** 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).
|
|
254
|
-
* Typically used indirectly via [[HyperModelingDecorator]].
|
|
255
|
-
* @param state The section drawing location specifying which section drawing to display.
|
|
256
|
-
* @returns A provider suitable for passing to [Viewport.addTiledGraphicsProvider]($frontend).
|
|
257
|
-
* @see [[HyperModelingDecorator.toggleAttachment]] to activate section graphics for a given [[SectionMarker]].
|
|
258
|
-
* @public
|
|
259
|
-
*/
|
|
260
|
-
export async function createSectionGraphicsProvider(state) {
|
|
261
|
-
let attachment;
|
|
262
|
-
if (undefined !== state.viewAttachment) {
|
|
263
|
-
const attachments = await state.iModel.elements.getProps(state.viewAttachment.id);
|
|
264
|
-
if (1 === attachments.length)
|
|
265
|
-
attachment = attachments[0];
|
|
266
|
-
}
|
|
267
|
-
return new SectionGraphicsProvider(state, attachment);
|
|
268
|
-
}
|
|
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
|
+
const { state, attachment } = { ...params };
|
|
160
|
+
const location = state.drawingToSpatialTransform.clone();
|
|
161
|
+
let clipVolume;
|
|
162
|
+
if (attachment) {
|
|
163
|
+
assert(undefined !== state.viewAttachment);
|
|
164
|
+
const clipJSON = attachment.jsonProperties?.clip;
|
|
165
|
+
const clip = clipJSON ? ClipVector.fromJSON(clipJSON) : ClipVector.createEmpty();
|
|
166
|
+
if (!clipJSON) {
|
|
167
|
+
const placement = Placement2d.fromJSON(attachment.placement);
|
|
168
|
+
const range = placement.calculateRange();
|
|
169
|
+
clip.appendShape([
|
|
170
|
+
Point3d.create(range.low.x, range.low.y),
|
|
171
|
+
Point3d.create(range.high.x, range.low.y),
|
|
172
|
+
Point3d.create(range.high.x, range.high.y),
|
|
173
|
+
Point3d.create(range.low.x, range.high.y),
|
|
174
|
+
]);
|
|
175
|
+
}
|
|
176
|
+
if (clip.isValid) {
|
|
177
|
+
const sheetToWorld = state.viewAttachment.transformToSpatial.clone();
|
|
178
|
+
clip.transformInPlace(sheetToWorld);
|
|
179
|
+
clipVolume = IModelApp.renderSystem.createClipVolume(clip);
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
super(params, location, clipVolume);
|
|
183
|
+
}
|
|
184
|
+
get isDisplayed() { return true !== HyperModeling.graphicsConfig.hideSectionGraphics; }
|
|
185
|
+
}
|
|
186
|
+
class SheetProxyTree extends ProxyTree {
|
|
187
|
+
constructor(params) {
|
|
188
|
+
const { state, attachment } = { ...params };
|
|
189
|
+
assert(undefined !== state.viewAttachment);
|
|
190
|
+
assert(undefined !== attachment);
|
|
191
|
+
const location = state.viewAttachment.transformToSpatial.clone();
|
|
192
|
+
let clipVolume;
|
|
193
|
+
if (state.viewAttachment.clip)
|
|
194
|
+
clipVolume = IModelApp.renderSystem.createClipVolume(state.viewAttachment.clip);
|
|
195
|
+
super(params, location, clipVolume);
|
|
196
|
+
// Our view is manufactured. It draws everything regardless of subcategory.
|
|
197
|
+
this.symbologyOverrides.ignoreSubCategory = true;
|
|
198
|
+
}
|
|
199
|
+
get isDisplayed() { return true !== HyperModeling.graphicsConfig.hideSheetAnnotations; }
|
|
200
|
+
}
|
|
201
|
+
/** The single Tile belonging to a ProxyTree, serving as a proxy for all of the proxied tree's tiles. */
|
|
202
|
+
class ProxyTile extends Tile {
|
|
203
|
+
constructor(tree, range) {
|
|
204
|
+
super({ contentId: "", range, maximumSize: 512, isLeaf: true }, tree);
|
|
205
|
+
this.setIsReady();
|
|
206
|
+
}
|
|
207
|
+
get hasChildren() { return false; }
|
|
208
|
+
get hasGraphics() { return true; }
|
|
209
|
+
get channel() { throw new Error("Proxy tile has no content"); }
|
|
210
|
+
async requestContent(_isCanceled) { return undefined; }
|
|
211
|
+
async readContent(_data, _system, _isCanceled) { return {}; }
|
|
212
|
+
_loadChildren(_resolve, _reject) { }
|
|
213
|
+
drawGraphics(args) {
|
|
214
|
+
const proxyTree = this.tree;
|
|
215
|
+
const sectionTree = proxyTree.tree;
|
|
216
|
+
const location = proxyTree.iModelTransform.multiplyTransformTransform(sectionTree.iModelTransform);
|
|
217
|
+
const clipVolume = true === proxyTree.viewFlagOverrides.clipVolume ? proxyTree.clipVolume : undefined;
|
|
218
|
+
args = new TileDrawArgs({ context: args.context, location, tree: sectionTree, now: args.now, viewFlagOverrides: proxyTree.viewFlagOverrides, clipVolume, parentsAndChildrenExclusive: args.parentsAndChildrenExclusive, symbologyOverrides: proxyTree.symbologyOverrides });
|
|
219
|
+
sectionTree.draw(args);
|
|
220
|
+
const rangeGfx = this.getRangeGraphic(args.context);
|
|
221
|
+
if (undefined !== rangeGfx)
|
|
222
|
+
args.graphics.add(rangeGfx);
|
|
223
|
+
if (true !== HyperModeling.graphicsConfig.debugClipVolumes || undefined === proxyTree.clipVolume)
|
|
224
|
+
return;
|
|
225
|
+
const builder = args.context.createSceneGraphicBuilder();
|
|
226
|
+
builder.setSymbology(ColorDef.red, ColorDef.red, 2);
|
|
227
|
+
for (const prim of proxyTree.clipVolume.clipVector.clips) {
|
|
228
|
+
if (!(prim instanceof ClipShape))
|
|
229
|
+
continue;
|
|
230
|
+
const tf = prim.transformFromClip;
|
|
231
|
+
const pts = prim.polygon.map((pt) => tf ? tf.multiplyPoint3d(pt) : pt.clone());
|
|
232
|
+
builder.addLineString(pts);
|
|
233
|
+
}
|
|
234
|
+
const branch = new GraphicBranch();
|
|
235
|
+
branch.entries.push(builder.finish());
|
|
236
|
+
branch.setViewFlagOverrides({ clipVolume: false });
|
|
237
|
+
args.context.outputGraphic(args.context.createGraphicBranch(branch, Transform.createIdentity()));
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
/** Draws the 2d section graphics into the 3d view. */
|
|
241
|
+
class SectionGraphicsProvider {
|
|
242
|
+
constructor(state, attachment) {
|
|
243
|
+
this._drawingRef = new ProxyTreeReference({ state, attachment, isSheet: false });
|
|
244
|
+
if (attachment)
|
|
245
|
+
this._sheetRef = new ProxyTreeReference({ state, attachment, isSheet: true });
|
|
246
|
+
}
|
|
247
|
+
forEachTileTreeRef(_viewport, func) {
|
|
248
|
+
func(this._drawingRef);
|
|
249
|
+
if (undefined !== this._sheetRef)
|
|
250
|
+
func(this._sheetRef);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
/** 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).
|
|
254
|
+
* Typically used indirectly via [[HyperModelingDecorator]].
|
|
255
|
+
* @param state The section drawing location specifying which section drawing to display.
|
|
256
|
+
* @returns A provider suitable for passing to [Viewport.addTiledGraphicsProvider]($frontend).
|
|
257
|
+
* @see [[HyperModelingDecorator.toggleAttachment]] to activate section graphics for a given [[SectionMarker]].
|
|
258
|
+
* @public
|
|
259
|
+
*/
|
|
260
|
+
export async function createSectionGraphicsProvider(state) {
|
|
261
|
+
let attachment;
|
|
262
|
+
if (undefined !== state.viewAttachment) {
|
|
263
|
+
const attachments = await state.iModel.elements.getProps(state.viewAttachment.id);
|
|
264
|
+
if (1 === attachments.length)
|
|
265
|
+
attachment = attachments[0];
|
|
266
|
+
}
|
|
267
|
+
return new SectionGraphicsProvider(state, attachment);
|
|
268
|
+
}
|
|
269
269
|
//# sourceMappingURL=SectionGraphicsProvider.js.map
|
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
/** @packageDocumentation
|
|
2
|
-
* @module HyperModeling
|
|
3
|
-
*/
|
|
4
|
-
import type { AbstractToolbarProps } from "@itwin/appui-abstract";
|
|
5
|
-
import { SectionMarker } from "./SectionMarkers";
|
|
6
|
-
import { SectionMarkerConfig } from "./HyperModelingConfig";
|
|
7
|
-
import { HyperModelingDecorator } from "./HyperModelingDecorator";
|
|
8
|
-
/** Supplies interactions with [[SectionMarker]]s, including a mini-toolbar displayed when the mouse hovers over a marker and what action occurs when the user clicks a marker.
|
|
9
|
-
* The base implementation supplies the following interactions:
|
|
10
|
-
* * Click: Toggle display of the section graphics and clip volume; apply the section's spatial view if toggling on.
|
|
11
|
-
* * Toolbar:
|
|
12
|
-
* * Apply Section: Applies the section location's spatial view to the viewport and displays the 2d section graphics.
|
|
13
|
-
* * Open Drawing: Navigates to the section drawing view. By default, this applies the section drawing view to the viewport.
|
|
14
|
-
* * Open Sheet: Navigates to the [ViewAttachment]($backend) of the section drawing on a [Sheet]($backend). Disabled if no such attachment exists.
|
|
15
|
-
* @see [[HyperModelingConfig]] to override the default handler by supplying a subclass of `SectionMarkerHandler`.
|
|
16
|
-
* @see [[HyperModelingDecorator]] for various methods that might be usefully wired up to marker click or toolbar actions.
|
|
17
|
-
* @public
|
|
18
|
-
*/
|
|
19
|
-
export declare class SectionMarkerHandler {
|
|
20
|
-
/** Respond to activation of the specified marker. Return true if the marker should become the active marker - i.e., if the marker was successfully activated.
|
|
21
|
-
* @see [[SectionMarkerHandler.deactivateMarker]].
|
|
22
|
-
*/
|
|
23
|
-
activateMarker(marker: SectionMarker, decorator: HyperModelingDecorator): Promise<boolean>;
|
|
24
|
-
/** Respond to deactivation of the specified marker. Invoked when the user clicks on the marker while it is the active marker.
|
|
25
|
-
* This should perform the inverse of [[SectionMarkerHandler.activateMarker]]. The marker becomes inactive as a result.
|
|
26
|
-
*/
|
|
27
|
-
deactivateMarker(marker: SectionMarker, decorator: HyperModelingDecorator): Promise<void>;
|
|
28
|
-
/** Return toolbar items for the specified marker. If the array of toolbar items is empty, no toolbar will be displayed.
|
|
29
|
-
* @see [[executeCommand]] to implement each toolbar command.
|
|
30
|
-
*/
|
|
31
|
-
getToolbarProps(marker: SectionMarker, _decorator: HyperModelingDecorator): AbstractToolbarProps;
|
|
32
|
-
/** Execute the command associated with the specified tool bar item.
|
|
33
|
-
* @see [[getToolbarProps]] to define the set of commands.
|
|
34
|
-
*/
|
|
35
|
-
executeCommand(commandId: string, marker: SectionMarker, decorator: HyperModelingDecorator): Promise<void>;
|
|
36
|
-
/** Customize which markers are visible. [[HyperModelingDecorator]] determines marker visibility as follows:
|
|
37
|
-
* - If a marker is currently active (selected), only that marker is visible.
|
|
38
|
-
* - Otherwise, the marker is visible if this method returns `true`.
|
|
39
|
-
* The default implementation of this method determines visibility based on the [[SectionMarkerConfig]] as follows.
|
|
40
|
-
* - If the marker is of a type included in the config's `hiddenSectionTypes`, it is invisible.
|
|
41
|
-
* - If the marker belongs to a model not currently displayed in the viewport and the config's `ignoreModelSelector` is false, it is invisible.
|
|
42
|
-
* - If the marker belongs to a category not currently displayed in the viewport and the config's `ignoreCategorySelector` is false, it is invisible,
|
|
43
|
-
* - Otherwise, the marker is visible, unless this method returns `false`.
|
|
44
|
-
* The default implementation of this method always returns `true`
|
|
45
|
-
* @param marker The marker whose visibility is to be determined.
|
|
46
|
-
* @param decorator The hypermodeling decorator to which the marker belongs.
|
|
47
|
-
* @param config The configuration controlling marker visibility based on [SectionType]($common), [ModelSelectorState]($frontend), and [CategorySelectorState]($frontend).
|
|
48
|
-
* @returns true if the marker should be displayed; false to make it invisible.
|
|
49
|
-
* @see [[HyperModelingDecorator.requestSync]] to force the decorator to reevaluate marker visibility when the criterion used by your implementation of this method changes.
|
|
50
|
-
*/
|
|
51
|
-
isMarkerVisible(marker: SectionMarker, decorator: HyperModelingDecorator, config: SectionMarkerConfig): boolean;
|
|
52
|
-
}
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module HyperModeling
|
|
3
|
+
*/
|
|
4
|
+
import type { AbstractToolbarProps } from "@itwin/appui-abstract";
|
|
5
|
+
import { SectionMarker } from "./SectionMarkers";
|
|
6
|
+
import { SectionMarkerConfig } from "./HyperModelingConfig";
|
|
7
|
+
import { HyperModelingDecorator } from "./HyperModelingDecorator";
|
|
8
|
+
/** Supplies interactions with [[SectionMarker]]s, including a mini-toolbar displayed when the mouse hovers over a marker and what action occurs when the user clicks a marker.
|
|
9
|
+
* The base implementation supplies the following interactions:
|
|
10
|
+
* * Click: Toggle display of the section graphics and clip volume; apply the section's spatial view if toggling on.
|
|
11
|
+
* * Toolbar:
|
|
12
|
+
* * Apply Section: Applies the section location's spatial view to the viewport and displays the 2d section graphics.
|
|
13
|
+
* * Open Drawing: Navigates to the section drawing view. By default, this applies the section drawing view to the viewport.
|
|
14
|
+
* * Open Sheet: Navigates to the [ViewAttachment]($backend) of the section drawing on a [Sheet]($backend). Disabled if no such attachment exists.
|
|
15
|
+
* @see [[HyperModelingConfig]] to override the default handler by supplying a subclass of `SectionMarkerHandler`.
|
|
16
|
+
* @see [[HyperModelingDecorator]] for various methods that might be usefully wired up to marker click or toolbar actions.
|
|
17
|
+
* @public
|
|
18
|
+
*/
|
|
19
|
+
export declare class SectionMarkerHandler {
|
|
20
|
+
/** Respond to activation of the specified marker. Return true if the marker should become the active marker - i.e., if the marker was successfully activated.
|
|
21
|
+
* @see [[SectionMarkerHandler.deactivateMarker]].
|
|
22
|
+
*/
|
|
23
|
+
activateMarker(marker: SectionMarker, decorator: HyperModelingDecorator): Promise<boolean>;
|
|
24
|
+
/** Respond to deactivation of the specified marker. Invoked when the user clicks on the marker while it is the active marker.
|
|
25
|
+
* This should perform the inverse of [[SectionMarkerHandler.activateMarker]]. The marker becomes inactive as a result.
|
|
26
|
+
*/
|
|
27
|
+
deactivateMarker(marker: SectionMarker, decorator: HyperModelingDecorator): Promise<void>;
|
|
28
|
+
/** Return toolbar items for the specified marker. If the array of toolbar items is empty, no toolbar will be displayed.
|
|
29
|
+
* @see [[executeCommand]] to implement each toolbar command.
|
|
30
|
+
*/
|
|
31
|
+
getToolbarProps(marker: SectionMarker, _decorator: HyperModelingDecorator): AbstractToolbarProps;
|
|
32
|
+
/** Execute the command associated with the specified tool bar item.
|
|
33
|
+
* @see [[getToolbarProps]] to define the set of commands.
|
|
34
|
+
*/
|
|
35
|
+
executeCommand(commandId: string, marker: SectionMarker, decorator: HyperModelingDecorator): Promise<void>;
|
|
36
|
+
/** Customize which markers are visible. [[HyperModelingDecorator]] determines marker visibility as follows:
|
|
37
|
+
* - If a marker is currently active (selected), only that marker is visible.
|
|
38
|
+
* - Otherwise, the marker is visible if this method returns `true`.
|
|
39
|
+
* The default implementation of this method determines visibility based on the [[SectionMarkerConfig]] as follows.
|
|
40
|
+
* - If the marker is of a type included in the config's `hiddenSectionTypes`, it is invisible.
|
|
41
|
+
* - If the marker belongs to a model not currently displayed in the viewport and the config's `ignoreModelSelector` is false, it is invisible.
|
|
42
|
+
* - If the marker belongs to a category not currently displayed in the viewport and the config's `ignoreCategorySelector` is false, it is invisible,
|
|
43
|
+
* - Otherwise, the marker is visible, unless this method returns `false`.
|
|
44
|
+
* The default implementation of this method always returns `true`
|
|
45
|
+
* @param marker The marker whose visibility is to be determined.
|
|
46
|
+
* @param decorator The hypermodeling decorator to which the marker belongs.
|
|
47
|
+
* @param config The configuration controlling marker visibility based on [SectionType]($common), [ModelSelectorState]($frontend), and [CategorySelectorState]($frontend).
|
|
48
|
+
* @returns true if the marker should be displayed; false to make it invisible.
|
|
49
|
+
* @see [[HyperModelingDecorator.requestSync]] to force the decorator to reevaluate marker visibility when the criterion used by your implementation of this method changes.
|
|
50
|
+
*/
|
|
51
|
+
isMarkerVisible(marker: SectionMarker, decorator: HyperModelingDecorator, config: SectionMarkerConfig): boolean;
|
|
52
|
+
}
|
|
53
53
|
//# sourceMappingURL=SectionMarkerHandler.d.ts.map
|