@itwin/rpcinterface-full-stack-tests 5.3.0 → 5.3.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/lib/dist/bundled-tests.js +952 -702
- package/lib/dist/bundled-tests.js.map +1 -1
- package/lib/dist/core_frontend_lib_esm_ApproximateTerrainHeightsProps_js.bundled-tests.js.map +1 -1
- package/lib/dist/vendors-common_temp_node_modules_pnpm_cross-fetch_4_0_0_node_modules_cross-fetch_dist_browser-24291b.bundled-tests.js.map +1 -1
- package/lib/dist/vendors-common_temp_node_modules_pnpm_loaders_gl_draco_4_3_4__loaders_gl_core_4_3_4_node_modu-4c1fc9.bundled-tests.js.map +1 -1
- package/package.json +14 -14
|
@@ -65935,7 +65935,10 @@ class MapImagerySettings {
|
|
|
65935
65935
|
}
|
|
65936
65936
|
/** @internal */
|
|
65937
65937
|
static createFromJSON(imageryJson, mapProps) {
|
|
65938
|
-
const
|
|
65938
|
+
const backgroundBase = imageryJson?.backgroundBase;
|
|
65939
|
+
const baseLayer = undefined !== backgroundBase ?
|
|
65940
|
+
BaseLayerSettings.fromJSON(backgroundBase) :
|
|
65941
|
+
_MapLayerSettings__WEBPACK_IMPORTED_MODULE_1__.BaseMapLayerSettings.fromBackgroundMapProps(mapProps ?? {});
|
|
65939
65942
|
return new MapImagerySettings(baseLayer, imageryJson?.backgroundLayers, imageryJson?.overlayLayers);
|
|
65940
65943
|
}
|
|
65941
65944
|
toJSON() {
|
|
@@ -111808,6 +111811,7 @@ class BriefcaseConnection extends _IModelConnection__WEBPACK_IMPORTED_MODULE_5__
|
|
|
111808
111811
|
this._modelsMonitor = new ModelChangeMonitor(this);
|
|
111809
111812
|
if (_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.OpenMode.ReadWrite === this._openMode)
|
|
111810
111813
|
this.txns.onAfterUndoRedo.addListener(async () => { await _IModelApp__WEBPACK_IMPORTED_MODULE_4__.IModelApp.toolAdmin.restartPrimitiveTool(); });
|
|
111814
|
+
this.categories.cache.attachToBriefcase(this);
|
|
111811
111815
|
}
|
|
111812
111816
|
/** Open a BriefcaseConnection to a [BriefcaseDb]($backend). */
|
|
111813
111817
|
static async openFile(briefcaseProps) {
|
|
@@ -123473,18 +123477,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
123473
123477
|
/* harmony import */ var _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @itwin/core-common */ "../../core/common/lib/esm/core-common.js");
|
|
123474
123478
|
/* harmony import */ var _CategorySelectorState__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./CategorySelectorState */ "../../core/frontend/lib/esm/CategorySelectorState.js");
|
|
123475
123479
|
/* harmony import */ var _DisplayStyleState__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./DisplayStyleState */ "../../core/frontend/lib/esm/DisplayStyleState.js");
|
|
123476
|
-
/* harmony import */ var
|
|
123477
|
-
/* harmony import */ var
|
|
123478
|
-
/* harmony import */ var
|
|
123479
|
-
/* harmony import */ var
|
|
123480
|
-
/* harmony import */ var _IModelApp__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./IModelApp */ "../../core/frontend/lib/esm/IModelApp.js");
|
|
123481
|
-
/* harmony import */ var _CoordSystem__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./CoordSystem */ "../../core/frontend/lib/esm/CoordSystem.js");
|
|
123482
|
-
/* harmony import */ var _Viewport__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Viewport */ "../../core/frontend/lib/esm/Viewport.js");
|
|
123483
|
-
/* harmony import */ var _ViewState__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ViewState */ "../../core/frontend/lib/esm/ViewState.js");
|
|
123484
|
-
/* harmony import */ var _tile_internal__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./tile/internal */ "../../core/frontend/lib/esm/tile/internal.js");
|
|
123485
|
-
/* harmony import */ var _common_ImageUtil__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./common/ImageUtil */ "../../core/frontend/lib/esm/common/ImageUtil.js");
|
|
123486
|
-
/* harmony import */ var _common_ViewRect__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./common/ViewRect */ "../../core/frontend/lib/esm/common/ViewRect.js");
|
|
123487
|
-
/* harmony import */ var _common_render_GraphicType__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./common/render/GraphicType */ "../../core/frontend/lib/esm/common/render/GraphicType.js");
|
|
123480
|
+
/* harmony import */ var _Frustum2d__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Frustum2d */ "../../core/frontend/lib/esm/Frustum2d.js");
|
|
123481
|
+
/* harmony import */ var _ViewState__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ViewState */ "../../core/frontend/lib/esm/ViewState.js");
|
|
123482
|
+
/* harmony import */ var _common_render_GraphicType__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./common/render/GraphicType */ "../../core/frontend/lib/esm/common/render/GraphicType.js");
|
|
123483
|
+
/* harmony import */ var _internal_SheetViewAttachments__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./internal/SheetViewAttachments */ "../../core/frontend/lib/esm/internal/SheetViewAttachments.js");
|
|
123488
123484
|
/*---------------------------------------------------------------------------------------------
|
|
123489
123485
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
123490
123486
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -123501,14 +123497,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
123501
123497
|
|
|
123502
123498
|
|
|
123503
123499
|
|
|
123504
|
-
|
|
123505
|
-
|
|
123506
|
-
|
|
123507
|
-
|
|
123508
|
-
|
|
123509
|
-
|
|
123510
|
-
|
|
123511
|
-
|
|
123512
123500
|
// cSpell:ignore ovrs
|
|
123513
123501
|
/** Describes the geometry and styling of a sheet border decoration.
|
|
123514
123502
|
* The sheet border decoration mimics a sheet of paper with a drop shadow.
|
|
@@ -123577,206 +123565,25 @@ class SheetBorder {
|
|
|
123577
123565
|
params.fillColor = fillColor;
|
|
123578
123566
|
params.gradient = this._gradient;
|
|
123579
123567
|
builder.activateGraphicParams(params);
|
|
123580
|
-
builder.addShape2d(this._shadow,
|
|
123568
|
+
builder.addShape2d(this._shadow, _Frustum2d__WEBPACK_IMPORTED_MODULE_5__.Frustum2d.minimumZDistance);
|
|
123581
123569
|
builder.setSymbology(lineColor, fillColor, 2);
|
|
123582
123570
|
builder.addLineString2d(this._rect, 0);
|
|
123583
123571
|
}
|
|
123584
123572
|
}
|
|
123585
|
-
/** The information required to instantiate an ViewAttachments object to draw ViewAttachments into a sheet. The list of view attachment Ids is
|
|
123586
|
-
* supplied to SheetViewState via the constructor. The corresponding ViewAttachmentProps for each attachment are obtained asynchronously in
|
|
123587
|
-
* SheetViewState.load(). The Attachments object is created in SheetViewState.attachToViewport and disposed of in SheetViewState.detachFromViewport.
|
|
123588
|
-
*/
|
|
123589
|
-
class ViewAttachmentsInfo {
|
|
123590
|
-
_attachments;
|
|
123591
|
-
get attachments() { return this._attachments; }
|
|
123592
|
-
constructor(attachments) {
|
|
123593
|
-
this._attachments = attachments;
|
|
123594
|
-
}
|
|
123595
|
-
get isLoaded() {
|
|
123596
|
-
return 0 === this._attachments.length || "string" !== typeof this._attachments[0];
|
|
123597
|
-
}
|
|
123598
|
-
get viewAttachmentProps() {
|
|
123599
|
-
return this.isLoaded ? this._props : [];
|
|
123600
|
-
}
|
|
123601
|
-
get _props() {
|
|
123602
|
-
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.assert)(this.isLoaded);
|
|
123603
|
-
return this._attachments;
|
|
123604
|
-
}
|
|
123605
|
-
get _ids() {
|
|
123606
|
-
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.assert)(!this.isLoaded);
|
|
123607
|
-
return this._attachments;
|
|
123608
|
-
}
|
|
123609
|
-
static fromJSON(ids = []) {
|
|
123610
|
-
return new ViewAttachmentsInfo(ids);
|
|
123611
|
-
}
|
|
123612
|
-
toJSON() {
|
|
123613
|
-
return this.isLoaded ? this._props.map((x) => (0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.expectDefined)(x.id)) : [...this._ids];
|
|
123614
|
-
}
|
|
123615
|
-
clone(iModel) {
|
|
123616
|
-
let attachments = this._attachments;
|
|
123617
|
-
if (this.isLoaded) {
|
|
123618
|
-
// Need to clone the attached ViewStates.
|
|
123619
|
-
attachments = attachments.map((attachment) => {
|
|
123620
|
-
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.assert)(typeof attachment !== "string");
|
|
123621
|
-
return {
|
|
123622
|
-
...attachment,
|
|
123623
|
-
attachedView: attachment.attachedView.clone(iModel),
|
|
123624
|
-
};
|
|
123625
|
-
});
|
|
123626
|
-
}
|
|
123627
|
-
return new ViewAttachmentsInfo(attachments);
|
|
123628
|
-
}
|
|
123629
|
-
preload(options) {
|
|
123630
|
-
if (this.isLoaded)
|
|
123631
|
-
return;
|
|
123632
|
-
options.sheetViewAttachmentIds = _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.CompressedId64Set.sortAndCompress(this._ids);
|
|
123633
|
-
options.viewStateLoadProps = {
|
|
123634
|
-
displayStyle: {
|
|
123635
|
-
omitScheduleScriptElementIds: !_IModelApp__WEBPACK_IMPORTED_MODULE_9__.IModelApp.tileAdmin.enableFrontendScheduleScripts,
|
|
123636
|
-
compressExcludedElementIds: true,
|
|
123637
|
-
},
|
|
123638
|
-
};
|
|
123639
|
-
}
|
|
123640
|
-
async postload(options, iModel) {
|
|
123641
|
-
if (options.sheetViewViews === undefined)
|
|
123642
|
-
return;
|
|
123643
|
-
if (options.sheetViewAttachmentProps === undefined)
|
|
123644
|
-
return;
|
|
123645
|
-
const viewStateProps = options.sheetViewViews; // This is viewstateProps, need to turn this into ViewState
|
|
123646
|
-
const promises = [];
|
|
123647
|
-
for (const viewProps of viewStateProps) {
|
|
123648
|
-
const loadView = async () => {
|
|
123649
|
-
try {
|
|
123650
|
-
if (viewProps === undefined)
|
|
123651
|
-
return undefined;
|
|
123652
|
-
const view = await iModel.views.convertViewStatePropsToViewState(viewProps);
|
|
123653
|
-
return view;
|
|
123654
|
-
}
|
|
123655
|
-
catch {
|
|
123656
|
-
return undefined;
|
|
123657
|
-
}
|
|
123658
|
-
};
|
|
123659
|
-
promises.push(loadView());
|
|
123660
|
-
}
|
|
123661
|
-
const views = await Promise.all(promises);
|
|
123662
|
-
const attachmentProps = options.sheetViewAttachmentProps;
|
|
123663
|
-
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.assert)(views.length === attachmentProps.length);
|
|
123664
|
-
const attachments = [];
|
|
123665
|
-
for (let i = 0; i < views.length; i++) {
|
|
123666
|
-
const view = views[i];
|
|
123667
|
-
if (view && !(view instanceof SheetViewState)) {
|
|
123668
|
-
const props = attachmentProps[i];
|
|
123669
|
-
props.attachedView = view;
|
|
123670
|
-
attachments.push(props);
|
|
123671
|
-
}
|
|
123672
|
-
}
|
|
123673
|
-
this._attachments = attachments;
|
|
123674
|
-
}
|
|
123675
|
-
async load(iModel) {
|
|
123676
|
-
if (this.isLoaded)
|
|
123677
|
-
return;
|
|
123678
|
-
const attachmentProps = await iModel.elements.getProps(this._ids);
|
|
123679
|
-
const promises = [];
|
|
123680
|
-
for (const attachment of attachmentProps) {
|
|
123681
|
-
const loadView = async () => {
|
|
123682
|
-
try {
|
|
123683
|
-
const view = await iModel.views.load(attachment.view.id);
|
|
123684
|
-
return view;
|
|
123685
|
-
}
|
|
123686
|
-
catch {
|
|
123687
|
-
return undefined;
|
|
123688
|
-
}
|
|
123689
|
-
};
|
|
123690
|
-
promises.push(loadView());
|
|
123691
|
-
}
|
|
123692
|
-
const views = await Promise.all(promises);
|
|
123693
|
-
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.assert)(views.length === attachmentProps.length);
|
|
123694
|
-
const attachments = [];
|
|
123695
|
-
for (let i = 0; i < views.length; i++) {
|
|
123696
|
-
const view = views[i];
|
|
123697
|
-
if (view && !(view instanceof SheetViewState)) {
|
|
123698
|
-
const props = attachmentProps[i];
|
|
123699
|
-
props.attachedView = view;
|
|
123700
|
-
attachments.push(props);
|
|
123701
|
-
}
|
|
123702
|
-
}
|
|
123703
|
-
this._attachments = attachments;
|
|
123704
|
-
}
|
|
123705
|
-
createAttachments(sheetView) {
|
|
123706
|
-
return this.isLoaded ? new ViewAttachments(this._props, sheetView) : undefined;
|
|
123707
|
-
}
|
|
123708
|
-
}
|
|
123709
|
-
/** The set of view attachments to be displayed in a Viewport via a SheetViewState. Allocated when the view becomes attached to a Viewport;
|
|
123710
|
-
* disposed of when it becomes detached from the viewport.
|
|
123711
|
-
*/
|
|
123712
|
-
class ViewAttachments {
|
|
123713
|
-
_attachments = [];
|
|
123714
|
-
maxDepth = _Frustum2d__WEBPACK_IMPORTED_MODULE_6__.Frustum2d.minimumZDistance;
|
|
123715
|
-
constructor(infos, sheetView) {
|
|
123716
|
-
for (const info of infos) {
|
|
123717
|
-
const drawAsRaster = info.jsonProperties?.displayOptions?.drawAsRaster || (info.attachedView.is3d() && info.attachedView.isCameraOn);
|
|
123718
|
-
const ctor = drawAsRaster ? RasterAttachment : OrthographicAttachment;
|
|
123719
|
-
const attachment = new ctor(info.attachedView, info, sheetView);
|
|
123720
|
-
this._attachments.push(attachment);
|
|
123721
|
-
this.maxDepth = Math.max(this.maxDepth, attachment.zDepth);
|
|
123722
|
-
}
|
|
123723
|
-
}
|
|
123724
|
-
[Symbol.dispose]() {
|
|
123725
|
-
for (const attachment of this._attachments)
|
|
123726
|
-
attachment[Symbol.dispose]();
|
|
123727
|
-
this._attachments.length = 0;
|
|
123728
|
-
}
|
|
123729
|
-
[Symbol.iterator]() {
|
|
123730
|
-
return this._attachments[Symbol.iterator]();
|
|
123731
|
-
}
|
|
123732
|
-
/** For tests. */
|
|
123733
|
-
get attachments() {
|
|
123734
|
-
return this._attachments;
|
|
123735
|
-
}
|
|
123736
|
-
get isEmpty() {
|
|
123737
|
-
return 0 === this._attachments.length;
|
|
123738
|
-
}
|
|
123739
|
-
areAllTileTreesLoaded(displayedExtents) {
|
|
123740
|
-
return this._attachments.every((x) => {
|
|
123741
|
-
const placement = _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.Placement2d.fromJSON(x.viewAttachmentProps.placement);
|
|
123742
|
-
const attachmentRange = placement.calculateRange();
|
|
123743
|
-
if (!attachmentRange.intersectsRangeXY(displayedExtents))
|
|
123744
|
-
return true;
|
|
123745
|
-
return x.areAllTileTreesLoaded;
|
|
123746
|
-
});
|
|
123747
|
-
}
|
|
123748
|
-
/** Strictly for testing purposes */
|
|
123749
|
-
areAllAttachmentsLoaded() {
|
|
123750
|
-
return this._attachments.every((attachment) => attachment.areAllTileTreesLoaded);
|
|
123751
|
-
}
|
|
123752
|
-
discloseTileTrees(trees) {
|
|
123753
|
-
for (const attachment of this._attachments)
|
|
123754
|
-
trees.disclose(attachment);
|
|
123755
|
-
}
|
|
123756
|
-
collectStatistics(stats) {
|
|
123757
|
-
for (const attachment of this._attachments)
|
|
123758
|
-
attachment.collectStatistics(stats);
|
|
123759
|
-
}
|
|
123760
|
-
addToScene(context) {
|
|
123761
|
-
for (const attachment of this._attachments)
|
|
123762
|
-
attachment.addToScene(context);
|
|
123763
|
-
}
|
|
123764
|
-
findById(attachmentId) {
|
|
123765
|
-
return this._attachments.find((attachment) => attachment.viewAttachmentProps.id === attachmentId);
|
|
123766
|
-
}
|
|
123767
|
-
}
|
|
123768
123573
|
/** A view of a [SheetModel]($backend).
|
|
123769
123574
|
* @public
|
|
123770
123575
|
* @extensions
|
|
123771
123576
|
*/
|
|
123772
|
-
class SheetViewState extends
|
|
123577
|
+
class SheetViewState extends _ViewState__WEBPACK_IMPORTED_MODULE_6__.ViewState2d {
|
|
123773
123578
|
/** The width and height of the sheet in world coordinates. */
|
|
123774
123579
|
sheetSize;
|
|
123775
|
-
|
|
123776
|
-
_attachments;
|
|
123580
|
+
_viewAttachments;
|
|
123777
123581
|
_viewedExtents;
|
|
123582
|
+
_onViewAttachmentsReloaded = () => undefined;
|
|
123583
|
+
/** Strictly for tests. */
|
|
123584
|
+
onViewAttachmentsReloaded = new _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.BeEvent();
|
|
123778
123585
|
get attachmentIds() {
|
|
123779
|
-
return this.
|
|
123586
|
+
return this._viewAttachments.attachmentIds;
|
|
123780
123587
|
}
|
|
123781
123588
|
static get className() { return "SheetViewDefinition"; }
|
|
123782
123589
|
static createFromProps(viewStateData, iModel) {
|
|
@@ -123787,7 +123594,7 @@ class SheetViewState extends _ViewState__WEBPACK_IMPORTED_MODULE_12__.ViewState2
|
|
|
123787
123594
|
}
|
|
123788
123595
|
toProps() {
|
|
123789
123596
|
const props = super.toProps();
|
|
123790
|
-
props.sheetAttachments = this.
|
|
123597
|
+
props.sheetAttachments = [...this.attachmentIds];
|
|
123791
123598
|
// For sheetProps all that is actually used is the size, so just null out everything else.
|
|
123792
123599
|
const codeProps = { spec: "", scope: "", value: "" };
|
|
123793
123600
|
props.sheetProps = {
|
|
@@ -123802,20 +123609,15 @@ class SheetViewState extends _ViewState__WEBPACK_IMPORTED_MODULE_12__.ViewState2
|
|
|
123802
123609
|
}
|
|
123803
123610
|
/** Strictly for testing. @internal */
|
|
123804
123611
|
get viewAttachmentProps() {
|
|
123805
|
-
return this.
|
|
123806
|
-
return {
|
|
123807
|
-
...x,
|
|
123808
|
-
attachedView: undefined,
|
|
123809
|
-
};
|
|
123810
|
-
});
|
|
123612
|
+
return this._viewAttachments.attachmentProps;
|
|
123811
123613
|
}
|
|
123812
123614
|
/** Strictly for testing. @internal */
|
|
123813
123615
|
get viewAttachmentInfos() {
|
|
123814
|
-
return this.
|
|
123616
|
+
return this._viewAttachments.attachmentInfos;
|
|
123815
123617
|
}
|
|
123816
123618
|
/** Strictly for testing. @internal */
|
|
123817
123619
|
get attachments() {
|
|
123818
|
-
return this.
|
|
123620
|
+
return this._viewAttachments.attachments;
|
|
123819
123621
|
}
|
|
123820
123622
|
isDrawingView() { return false; }
|
|
123821
123623
|
isSheetView() { return true; }
|
|
@@ -123824,41 +123626,53 @@ class SheetViewState extends _ViewState__WEBPACK_IMPORTED_MODULE_12__.ViewState2
|
|
|
123824
123626
|
if (categories instanceof SheetViewState) {
|
|
123825
123627
|
// we are coming from clone...
|
|
123826
123628
|
this.sheetSize = categories.sheetSize.clone();
|
|
123827
|
-
this.
|
|
123629
|
+
this._viewAttachments = categories._viewAttachments.clone(iModel);
|
|
123828
123630
|
this._viewedExtents = categories._viewedExtents.clone();
|
|
123829
123631
|
}
|
|
123830
123632
|
else {
|
|
123831
123633
|
this.sheetSize = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Point2d.create(sheetProps.width, sheetProps.height);
|
|
123832
|
-
this.
|
|
123634
|
+
this._viewAttachments = _internal_SheetViewAttachments__WEBPACK_IMPORTED_MODULE_8__.SheetViewAttachments.create(attachments);
|
|
123833
123635
|
const extents = new _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Range3d(0, 0, 0, this.sheetSize.x, this.sheetSize.y, 0);
|
|
123834
123636
|
const margin = 1.1;
|
|
123835
123637
|
extents.scaleAboutCenterInPlace(margin);
|
|
123836
123638
|
this._viewedExtents = extents;
|
|
123837
123639
|
}
|
|
123640
|
+
if (iModel.isBriefcaseConnection()) {
|
|
123641
|
+
iModel.txns.onElementsChanged.addListener(async (changes) => {
|
|
123642
|
+
let reload = false;
|
|
123643
|
+
for (const change of changes.filter({ includeMetadata: (meta) => meta.is("BisCore:ViewAttachment") })) {
|
|
123644
|
+
if (change.type === "inserted" || this._viewAttachments.attachmentIds.includes(change.id)) {
|
|
123645
|
+
reload = true;
|
|
123646
|
+
break;
|
|
123647
|
+
}
|
|
123648
|
+
}
|
|
123649
|
+
if (reload) {
|
|
123650
|
+
await this._viewAttachments.reload(this.baseModelId, iModel);
|
|
123651
|
+
this._onViewAttachmentsReloaded();
|
|
123652
|
+
this.onViewAttachmentsReloaded.raiseEvent();
|
|
123653
|
+
}
|
|
123654
|
+
});
|
|
123655
|
+
}
|
|
123838
123656
|
}
|
|
123839
123657
|
getOrigin() {
|
|
123840
123658
|
const origin = super.getOrigin();
|
|
123841
|
-
|
|
123842
|
-
origin.z = -this._attachments.maxDepth;
|
|
123659
|
+
origin.z = -this._viewAttachments.maxDepth;
|
|
123843
123660
|
return origin;
|
|
123844
123661
|
}
|
|
123845
123662
|
getExtents() {
|
|
123846
123663
|
const extents = super.getExtents();
|
|
123847
|
-
|
|
123848
|
-
extents.z = this._attachments.maxDepth + _Frustum2d__WEBPACK_IMPORTED_MODULE_6__.Frustum2d.minimumZDistance;
|
|
123664
|
+
extents.z = this._viewAttachments.maxDepth + _Frustum2d__WEBPACK_IMPORTED_MODULE_5__.Frustum2d.minimumZDistance;
|
|
123849
123665
|
return extents;
|
|
123850
123666
|
}
|
|
123851
123667
|
/** Overrides [[ViewState.discloseTileTrees]] to include tile trees associated with [ViewAttachment]($backend)s displayed on this sheet. */
|
|
123852
123668
|
discloseTileTrees(trees) {
|
|
123853
123669
|
super.discloseTileTrees(trees);
|
|
123854
|
-
|
|
123855
|
-
trees.disclose(this._attachments);
|
|
123670
|
+
trees.disclose(this._viewAttachments);
|
|
123856
123671
|
}
|
|
123857
123672
|
/** @internal */
|
|
123858
123673
|
collectNonTileTreeStatistics(stats) {
|
|
123859
123674
|
super.collectNonTileTreeStatistics(stats);
|
|
123860
|
-
|
|
123861
|
-
this._attachments.collectStatistics(stats);
|
|
123675
|
+
this._viewAttachments.collectStatistics(stats);
|
|
123862
123676
|
}
|
|
123863
123677
|
get defaultExtentLimits() {
|
|
123864
123678
|
return { min: _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Constant.oneMillimeter, max: this.sheetSize.magnitude() * 10 };
|
|
@@ -123869,36 +123683,23 @@ class SheetViewState extends _ViewState__WEBPACK_IMPORTED_MODULE_12__.ViewState2
|
|
|
123869
123683
|
/** @internal */
|
|
123870
123684
|
preload(hydrateRequest) {
|
|
123871
123685
|
super.preload(hydrateRequest);
|
|
123872
|
-
this.
|
|
123686
|
+
this._viewAttachments.preload(hydrateRequest);
|
|
123873
123687
|
}
|
|
123874
123688
|
/** @internal */
|
|
123875
123689
|
async postload(hydrateResponse) {
|
|
123876
123690
|
const promises = [];
|
|
123877
123691
|
promises.push(super.postload(hydrateResponse));
|
|
123878
|
-
promises.push(this.
|
|
123692
|
+
promises.push(this._viewAttachments.postload(hydrateResponse, this.iModel));
|
|
123879
123693
|
await Promise.all(promises);
|
|
123880
123694
|
}
|
|
123881
123695
|
/** @internal */
|
|
123882
123696
|
createScene(context) {
|
|
123883
123697
|
super.createScene(context);
|
|
123884
|
-
|
|
123885
|
-
this._attachments.addToScene(context);
|
|
123698
|
+
this._viewAttachments.addToScene(context);
|
|
123886
123699
|
}
|
|
123887
123700
|
/** @internal */
|
|
123888
123701
|
get secondaryViewports() {
|
|
123889
|
-
|
|
123890
|
-
return super.secondaryViewports;
|
|
123891
|
-
const attachments = this._attachments;
|
|
123892
|
-
function* iterator() {
|
|
123893
|
-
for (const attachment of attachments) {
|
|
123894
|
-
const vp = attachment.viewport;
|
|
123895
|
-
if (vp)
|
|
123896
|
-
yield vp;
|
|
123897
|
-
}
|
|
123898
|
-
}
|
|
123899
|
-
return {
|
|
123900
|
-
[Symbol.iterator]: () => iterator(),
|
|
123901
|
-
};
|
|
123702
|
+
return this._viewAttachments.getSecondaryViewports();
|
|
123902
123703
|
}
|
|
123903
123704
|
/** @internal */
|
|
123904
123705
|
async queryAttachmentIds() {
|
|
@@ -123911,39 +123712,43 @@ class SheetViewState extends _ViewState__WEBPACK_IMPORTED_MODULE_12__.ViewState2
|
|
|
123911
123712
|
async changeViewedModel(modelId) {
|
|
123912
123713
|
await super.changeViewedModel(modelId);
|
|
123913
123714
|
const attachmentIds = await this.queryAttachmentIds();
|
|
123914
|
-
this.
|
|
123915
|
-
|
|
123715
|
+
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.dispose)(this._viewAttachments);
|
|
123716
|
+
this._viewAttachments = _internal_SheetViewAttachments__WEBPACK_IMPORTED_MODULE_8__.SheetViewAttachments.create(attachmentIds);
|
|
123916
123717
|
}
|
|
123917
123718
|
/** See [[ViewState.attachToViewport]]. */
|
|
123918
123719
|
attachToViewport(args) {
|
|
123919
123720
|
super.attachToViewport(args);
|
|
123920
|
-
|
|
123921
|
-
|
|
123721
|
+
this._viewAttachments.attachToViewport({
|
|
123722
|
+
backgroundColor: this.displayStyle.backgroundColor,
|
|
123723
|
+
sheetModelId: this.baseModelId,
|
|
123724
|
+
});
|
|
123725
|
+
this._onViewAttachmentsReloaded = () => args.invalidateController();
|
|
123922
123726
|
}
|
|
123923
123727
|
/** See [[ViewState.detachFromViewport]]. */
|
|
123924
123728
|
detachFromViewport() {
|
|
123925
123729
|
super.detachFromViewport();
|
|
123926
|
-
this.
|
|
123730
|
+
this._viewAttachments.detachFromViewport();
|
|
123731
|
+
this._onViewAttachmentsReloaded = () => undefined;
|
|
123927
123732
|
}
|
|
123928
123733
|
get areAllTileTreesLoaded() {
|
|
123734
|
+
if (!super.areAllTileTreesLoaded) {
|
|
123735
|
+
return false;
|
|
123736
|
+
}
|
|
123929
123737
|
let displayedExtents = this._viewedExtents;
|
|
123930
123738
|
const frustum = this.calculateFrustum();
|
|
123931
123739
|
if (frustum) {
|
|
123932
123740
|
displayedExtents = frustum.toRange();
|
|
123933
123741
|
}
|
|
123934
|
-
return
|
|
123742
|
+
return this._viewAttachments.areAllTileTreesLoaded(displayedExtents);
|
|
123935
123743
|
}
|
|
123936
123744
|
/** @internal Strictly for testing */
|
|
123937
123745
|
areAllAttachmentsLoaded() {
|
|
123938
|
-
|
|
123939
|
-
return this._attachments.areAllAttachmentsLoaded();
|
|
123940
|
-
}
|
|
123941
|
-
return true;
|
|
123746
|
+
return this._viewAttachments.areAllAttachmentsLoaded();
|
|
123942
123747
|
}
|
|
123943
123748
|
/** Create a sheet border decoration graphic. */
|
|
123944
123749
|
createBorder(width, height, context) {
|
|
123945
123750
|
const border = SheetBorder.create(width, height, context);
|
|
123946
|
-
const builder = context.createGraphicBuilder(
|
|
123751
|
+
const builder = context.createGraphicBuilder(_common_render_GraphicType__WEBPACK_IMPORTED_MODULE_7__.GraphicType.ViewBackground);
|
|
123947
123752
|
border.addToBuilder(builder);
|
|
123948
123753
|
return builder.finish();
|
|
123949
123754
|
}
|
|
@@ -123963,453 +123768,13 @@ class SheetViewState extends _ViewState__WEBPACK_IMPORTED_MODULE_12__.ViewState2
|
|
|
123963
123768
|
}
|
|
123964
123769
|
/** @internal */
|
|
123965
123770
|
getAttachmentViewport(args) {
|
|
123966
|
-
|
|
123967
|
-
if (!attachment) {
|
|
123968
|
-
return undefined;
|
|
123969
|
-
}
|
|
123970
|
-
return args.inSectionDrawingAttachment ? attachment.viewport?.view.getAttachmentViewport({ inSectionDrawingAttachment: true }) : attachment.viewport;
|
|
123771
|
+
return this._viewAttachments.getAttachmentViewport(args);
|
|
123971
123772
|
}
|
|
123972
123773
|
/** @beta */
|
|
123973
123774
|
computeDisplayTransform(args) {
|
|
123974
123775
|
// ###TODO we're currently ignoring model and element Id in args, assuming irrelevant for sheets.
|
|
123975
123776
|
// Should probably call super or have super call us.
|
|
123976
|
-
|
|
123977
|
-
if (!attachment || !(attachment instanceof OrthographicAttachment)) {
|
|
123978
|
-
return undefined;
|
|
123979
|
-
}
|
|
123980
|
-
const sheetTransform = attachment.toSheet;
|
|
123981
|
-
const sectionTransform = args.inSectionDrawingAttachment ? attachment.view.computeDisplayTransform(args) : undefined;
|
|
123982
|
-
if (!sectionTransform) {
|
|
123983
|
-
return sheetTransform.clone(args.output);
|
|
123984
|
-
}
|
|
123985
|
-
return sheetTransform.multiplyTransformTransform(sectionTransform, args.output);
|
|
123986
|
-
}
|
|
123987
|
-
}
|
|
123988
|
-
/** A mostly no-op RenderTarget for an Attachment.
|
|
123989
|
-
* its Scene and symbology overrides.
|
|
123990
|
-
*/
|
|
123991
|
-
class AttachmentTarget extends _internal_render_MockRender__WEBPACK_IMPORTED_MODULE_7__.MockRender.OffScreenTarget {
|
|
123992
|
-
_attachment;
|
|
123993
|
-
constructor(attachment) {
|
|
123994
|
-
// The dimensions don't matter - we're not drawing anything.
|
|
123995
|
-
const rect = new _common_ViewRect__WEBPACK_IMPORTED_MODULE_15__.ViewRect(1, 1);
|
|
123996
|
-
super(_IModelApp__WEBPACK_IMPORTED_MODULE_9__.IModelApp.renderSystem, rect);
|
|
123997
|
-
this._attachment = attachment;
|
|
123998
|
-
}
|
|
123999
|
-
changeScene(scene) {
|
|
124000
|
-
this._attachment.scene = scene;
|
|
124001
|
-
}
|
|
124002
|
-
overrideFeatureSymbology(ovrs) {
|
|
124003
|
-
this._attachment.symbologyOverrides = ovrs;
|
|
124004
|
-
}
|
|
124005
|
-
}
|
|
124006
|
-
/** Draws the contents a 2d or orthographic 3d view directly into a sheet view.
|
|
124007
|
-
* We select tiles for the view in the context of a light-weight offscreen viewport with a no-op RenderTarget, then
|
|
124008
|
-
* collect the resultant graphics and add them to the sheet view's scene.
|
|
124009
|
-
*/
|
|
124010
|
-
class OrthographicAttachment {
|
|
124011
|
-
_viewport;
|
|
124012
|
-
_props;
|
|
124013
|
-
_sheetModelId;
|
|
124014
|
-
_viewFlagOverrides;
|
|
124015
|
-
_toSheet;
|
|
124016
|
-
_fromSheet;
|
|
124017
|
-
_sizeInMeters;
|
|
124018
|
-
_range;
|
|
124019
|
-
_viewRect = new _common_ViewRect__WEBPACK_IMPORTED_MODULE_15__.ViewRect(0, 0, 1, 1);
|
|
124020
|
-
_originalFrustum = new _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.Frustum();
|
|
124021
|
-
_clipVolume;
|
|
124022
|
-
_hiddenLineSettings;
|
|
124023
|
-
_scale;
|
|
124024
|
-
_debugFeatureTable;
|
|
124025
|
-
scene;
|
|
124026
|
-
symbologyOverrides;
|
|
124027
|
-
zDepth;
|
|
124028
|
-
get view() {
|
|
124029
|
-
return this._viewport.view;
|
|
124030
|
-
}
|
|
124031
|
-
get viewAttachmentProps() {
|
|
124032
|
-
return this._props;
|
|
124033
|
-
}
|
|
124034
|
-
get viewport() {
|
|
124035
|
-
return this._viewport;
|
|
124036
|
-
}
|
|
124037
|
-
constructor(view, props, sheetView) {
|
|
124038
|
-
this.symbologyOverrides = new _render_FeatureSymbology__WEBPACK_IMPORTED_MODULE_8__.FeatureSymbology.Overrides(view);
|
|
124039
|
-
const target = new AttachmentTarget(this);
|
|
124040
|
-
this._viewport = _Viewport__WEBPACK_IMPORTED_MODULE_11__.OffScreenViewport.createViewport(view, target, true);
|
|
124041
|
-
this._props = props;
|
|
124042
|
-
this._sheetModelId = sheetView.baseModelId;
|
|
124043
|
-
const applyClip = true; // set to false for debugging
|
|
124044
|
-
this._viewFlagOverrides = {
|
|
124045
|
-
...view.viewFlags,
|
|
124046
|
-
clipVolume: applyClip,
|
|
124047
|
-
lighting: false,
|
|
124048
|
-
shadows: false,
|
|
124049
|
-
};
|
|
124050
|
-
const placement = _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.Placement2d.fromJSON(props.placement);
|
|
124051
|
-
const range = placement.calculateRange();
|
|
124052
|
-
this._range = range;
|
|
124053
|
-
this._sizeInMeters = new _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Point2d(range.xLength(), range.yLength());
|
|
124054
|
-
// Compute transform from attached view's world coordinates to sheet's world coordinates.
|
|
124055
|
-
// NB: We obtain the extents and origin from the *viewport* not the *view* - they may have been adjusted by the viewport.
|
|
124056
|
-
const applySkew = true; // set to false for debugging
|
|
124057
|
-
const skew = applySkew ? view.getAspectRatioSkew() : 1;
|
|
124058
|
-
const extents = this._viewport.viewingSpace.viewDelta.clone();
|
|
124059
|
-
const zDepth = Math.abs(extents.z);
|
|
124060
|
-
const scaleX = this._sizeInMeters.x / Math.abs(extents.x);
|
|
124061
|
-
const scaleY = skew * this._sizeInMeters.y / Math.abs(extents.y);
|
|
124062
|
-
this._scale = { x: 1 / scaleX, y: 1 / scaleY };
|
|
124063
|
-
const zBias = _Frustum2d__WEBPACK_IMPORTED_MODULE_6__.Frustum2d.depthFromDisplayPriority(props.jsonProperties?.displayPriority ?? 0);
|
|
124064
|
-
this.zDepth = 1.01 * (zDepth - zBias); // give a little padding so that geometry right up against far plane doesn't get clipped.
|
|
124065
|
-
// View origin is at the *back* of the view. Align *front* of view based on display priority.
|
|
124066
|
-
const viewRot = view.getRotation();
|
|
124067
|
-
const viewOrg = viewRot.multiplyVector(this._viewport.viewingSpace.viewOrigin);
|
|
124068
|
-
viewOrg.z += zDepth;
|
|
124069
|
-
viewRot.multiplyTransposeVectorInPlace(viewOrg);
|
|
124070
|
-
const matrix = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Matrix3d.createScale(scaleX, scaleY, 1);
|
|
124071
|
-
matrix.multiplyMatrixMatrix(viewRot, matrix);
|
|
124072
|
-
const origin = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Matrix3d.xyzMinusMatrixTimesXYZ(viewOrg, matrix, viewOrg);
|
|
124073
|
-
const attachmentOrigin = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Point3d.createFrom(placement.origin);
|
|
124074
|
-
attachmentOrigin.z = zBias;
|
|
124075
|
-
const viewOrgToAttachment = attachmentOrigin.minus(viewOrg);
|
|
124076
|
-
origin.addInPlace(viewOrgToAttachment);
|
|
124077
|
-
this._toSheet = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Transform.createRefs(origin, matrix);
|
|
124078
|
-
this._fromSheet = (0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.expectDefined)(this._toSheet.inverse());
|
|
124079
|
-
// If the attached view is a section drawing, it may itself have an attached spatial view with a clip.
|
|
124080
|
-
// The clip needs to be transformed into sheet space.
|
|
124081
|
-
if (view.isDrawingView())
|
|
124082
|
-
this._viewport.drawingToSheetTransform = this._toSheet;
|
|
124083
|
-
// ###TODO? If we also apply the attachment's clip to the attached view, we may get additional culling during tile selection.
|
|
124084
|
-
// However the attached view's frustum is already clipped by intersection with sheet view's frustum, and additional clipping planes
|
|
124085
|
-
// introduce additional computation, so possibly not worth it.
|
|
124086
|
-
// Transform the view's clip (if any) to sheet space
|
|
124087
|
-
let viewClip = view.viewFlags.clipVolume ? view.getViewClip()?.clone() : undefined;
|
|
124088
|
-
if (viewClip)
|
|
124089
|
-
viewClip.transformInPlace(this._toSheet);
|
|
124090
|
-
else
|
|
124091
|
-
viewClip = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.ClipVector.createEmpty();
|
|
124092
|
-
let sheetClip;
|
|
124093
|
-
if (undefined !== props.jsonProperties?.clip)
|
|
124094
|
-
sheetClip = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.ClipVector.fromJSON(props.jsonProperties?.clip);
|
|
124095
|
-
if (sheetClip && sheetClip.isValid) {
|
|
124096
|
-
// Clip to view attachment's clip. NB: clip is in sheet coordinate space.
|
|
124097
|
-
for (const clip of sheetClip.clips)
|
|
124098
|
-
viewClip.clips.push(clip);
|
|
124099
|
-
}
|
|
124100
|
-
else {
|
|
124101
|
-
// Clip to view attachment's bounding box
|
|
124102
|
-
viewClip.appendShape([
|
|
124103
|
-
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Point3d.create(this._range.low.x, this._range.low.y),
|
|
124104
|
-
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Point3d.create(this._range.high.x, this._range.low.y),
|
|
124105
|
-
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Point3d.create(this._range.high.x, this._range.high.y),
|
|
124106
|
-
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Point3d.create(this._range.low.x, this._range.high.y),
|
|
124107
|
-
]);
|
|
124108
|
-
}
|
|
124109
|
-
this._clipVolume = _IModelApp__WEBPACK_IMPORTED_MODULE_9__.IModelApp.renderSystem.createClipVolume(viewClip);
|
|
124110
|
-
// Save off the original frustum (potentially adjusted by viewport).
|
|
124111
|
-
this._viewport.setupFromView();
|
|
124112
|
-
this._viewport.viewingSpace.getFrustum(_CoordSystem__WEBPACK_IMPORTED_MODULE_10__.CoordSystem.World, true, this._originalFrustum);
|
|
124113
|
-
const applyHiddenLineSettings = true; // for debugging edge display, set to false...
|
|
124114
|
-
const style = view.displayStyle;
|
|
124115
|
-
if (style.is3d() && applyHiddenLineSettings)
|
|
124116
|
-
this._hiddenLineSettings = style.settings.hiddenLineSettings;
|
|
124117
|
-
}
|
|
124118
|
-
[Symbol.dispose]() {
|
|
124119
|
-
this._viewport[Symbol.dispose]();
|
|
124120
|
-
}
|
|
124121
|
-
discloseTileTrees(trees) {
|
|
124122
|
-
trees.disclose(this._viewport);
|
|
124123
|
-
}
|
|
124124
|
-
addToScene(context) {
|
|
124125
|
-
if (context.viewport.freezeScene)
|
|
124126
|
-
return;
|
|
124127
|
-
if (!context.viewport.view.viewsCategory(this._props.category))
|
|
124128
|
-
return;
|
|
124129
|
-
const wantBounds = context.viewport.wantViewAttachmentBoundaries;
|
|
124130
|
-
const wantClipShapes = context.viewport.wantViewAttachmentClipShapes;
|
|
124131
|
-
if (wantBounds || wantClipShapes) {
|
|
124132
|
-
const builder = context.createSceneGraphicBuilder();
|
|
124133
|
-
if (wantBounds) {
|
|
124134
|
-
builder.setSymbology(_itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.ColorDef.red, _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.ColorDef.red, 2);
|
|
124135
|
-
builder.addRangeBox(this._range);
|
|
124136
|
-
}
|
|
124137
|
-
if (wantClipShapes && this._clipVolume) {
|
|
124138
|
-
builder.setSymbology(_itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.ColorDef.blue, _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.ColorDef.blue, 2);
|
|
124139
|
-
for (const prim of this._clipVolume.clipVector.clips) {
|
|
124140
|
-
if (!(prim instanceof _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.ClipShape))
|
|
124141
|
-
continue; // ###TODO handle non-shape primitives, if any such ever encountered
|
|
124142
|
-
const pts = [];
|
|
124143
|
-
const tf = prim.transformFromClip;
|
|
124144
|
-
for (const pt of prim.polygon) {
|
|
124145
|
-
const tfPt = tf ? tf.multiplyPoint3d(pt) : pt;
|
|
124146
|
-
pts.push(new _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Point2d(tfPt.x, tfPt.y));
|
|
124147
|
-
}
|
|
124148
|
-
builder.addLineString2d(pts, 0);
|
|
124149
|
-
}
|
|
124150
|
-
}
|
|
124151
|
-
// Put into a Batch so that we can see tooltip with attachment Id on mouseover.
|
|
124152
|
-
const batch = context.target.renderSystem.createBatch(builder.finish(), this.getDebugFeatureTable(), this._range);
|
|
124153
|
-
context.outputGraphic(batch);
|
|
124154
|
-
}
|
|
124155
|
-
if (!context.viewport.wantViewAttachments)
|
|
124156
|
-
return;
|
|
124157
|
-
// Pixel size used to compute size of ViewRect so that tiles of appropriate LOD are selected.
|
|
124158
|
-
const pixelSize = context.viewport.getPixelSizeAtPoint();
|
|
124159
|
-
if (0 === pixelSize)
|
|
124160
|
-
return;
|
|
124161
|
-
// Adjust attached view frustum based on intersection with sheet view frustum.
|
|
124162
|
-
const attachFrustum = this._originalFrustum.transformBy(this._toSheet);
|
|
124163
|
-
const attachFrustumRange = attachFrustum.toRange();
|
|
124164
|
-
const sheetFrustum = context.viewport.getWorldFrustum();
|
|
124165
|
-
const sheetFrustumRange = sheetFrustum.toRange();
|
|
124166
|
-
const intersect = attachFrustumRange.intersect(sheetFrustumRange);
|
|
124167
|
-
if (intersect.isNull)
|
|
124168
|
-
return;
|
|
124169
|
-
attachFrustum.initFromRange(intersect);
|
|
124170
|
-
attachFrustum.transformBy(this._fromSheet, attachFrustum);
|
|
124171
|
-
this._viewport.setupViewFromFrustum(attachFrustum);
|
|
124172
|
-
// Adjust view rect based on size of attachment on screen so that tiles of appropriate LOD are selected.
|
|
124173
|
-
const width = this._sizeInMeters.x * intersect.xLength() / attachFrustumRange.xLength();
|
|
124174
|
-
const height = this._sizeInMeters.y * intersect.yLength() / attachFrustumRange.yLength();
|
|
124175
|
-
this._viewRect.width = Math.max(1, Math.round(width / pixelSize));
|
|
124176
|
-
this._viewRect.height = Math.max(1, Math.round(height / pixelSize));
|
|
124177
|
-
this._viewport.setRect(this._viewRect);
|
|
124178
|
-
// Propagate settings from on-screen viewport.
|
|
124179
|
-
this._viewport.debugBoundingBoxes = context.viewport.debugBoundingBoxes;
|
|
124180
|
-
this._viewport.setTileSizeModifier(context.viewport.tileSizeModifier);
|
|
124181
|
-
// Create the scene.
|
|
124182
|
-
this._viewport.renderFrame();
|
|
124183
|
-
const scene = this.scene;
|
|
124184
|
-
if (!scene)
|
|
124185
|
-
return;
|
|
124186
|
-
// Extract scene graphics and insert into on-screen scene context.
|
|
124187
|
-
const options = {
|
|
124188
|
-
viewAttachmentId: this._props.id,
|
|
124189
|
-
clipVolume: this._clipVolume,
|
|
124190
|
-
hline: this._hiddenLineSettings,
|
|
124191
|
-
frustum: {
|
|
124192
|
-
is3d: this.view.is3d(),
|
|
124193
|
-
scale: this._scale,
|
|
124194
|
-
},
|
|
124195
|
-
};
|
|
124196
|
-
const outputGraphics = (source) => {
|
|
124197
|
-
if (0 === source.length)
|
|
124198
|
-
return;
|
|
124199
|
-
const graphics = new _render_GraphicBranch__WEBPACK_IMPORTED_MODULE_5__.GraphicBranch();
|
|
124200
|
-
graphics.setViewFlagOverrides(this._viewFlagOverrides);
|
|
124201
|
-
graphics.symbologyOverrides = this.symbologyOverrides;
|
|
124202
|
-
for (const graphic of source)
|
|
124203
|
-
graphics.entries.push(graphic);
|
|
124204
|
-
const branch = context.createGraphicBranch(graphics, this._toSheet, options);
|
|
124205
|
-
context.outputGraphic(branch);
|
|
124206
|
-
};
|
|
124207
|
-
outputGraphics(scene.foreground);
|
|
124208
|
-
context.withGraphicType(_tile_internal__WEBPACK_IMPORTED_MODULE_13__.TileGraphicType.BackgroundMap, () => outputGraphics(scene.background));
|
|
124209
|
-
context.withGraphicType(_tile_internal__WEBPACK_IMPORTED_MODULE_13__.TileGraphicType.Overlay, () => outputGraphics(scene.overlay));
|
|
124210
|
-
// Report tile statistics to sheet view's viewport.
|
|
124211
|
-
const tileAdmin = _IModelApp__WEBPACK_IMPORTED_MODULE_9__.IModelApp.tileAdmin;
|
|
124212
|
-
const selectedAndReady = tileAdmin.getTilesForUser(this._viewport);
|
|
124213
|
-
const requested = tileAdmin.getRequestsForUser(this._viewport);
|
|
124214
|
-
tileAdmin.addExternalTilesForUser(context.viewport, {
|
|
124215
|
-
requested: requested?.size ?? 0,
|
|
124216
|
-
selected: selectedAndReady?.selected.size ?? 0,
|
|
124217
|
-
ready: selectedAndReady?.ready.size ?? 0,
|
|
124218
|
-
});
|
|
124219
|
-
}
|
|
124220
|
-
getDebugFeatureTable() {
|
|
124221
|
-
if (this._debugFeatureTable)
|
|
124222
|
-
return this._debugFeatureTable;
|
|
124223
|
-
const featureTable = new _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.FeatureTable(1, this._sheetModelId);
|
|
124224
|
-
featureTable.insert(new _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.Feature(this._props.id));
|
|
124225
|
-
this._debugFeatureTable = _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.PackedFeatureTable.pack(featureTable);
|
|
124226
|
-
return this._debugFeatureTable;
|
|
124227
|
-
}
|
|
124228
|
-
get areAllTileTreesLoaded() {
|
|
124229
|
-
return this.view.areAllTileTreesLoaded;
|
|
124230
|
-
}
|
|
124231
|
-
collectStatistics(_stats) {
|
|
124232
|
-
// Handled by discloseTileTrees()
|
|
124233
|
-
}
|
|
124234
|
-
get toSheet() {
|
|
124235
|
-
return this._toSheet;
|
|
124236
|
-
}
|
|
124237
|
-
}
|
|
124238
|
-
function createRasterAttachmentViewport(_view, _rect, _attachment) {
|
|
124239
|
-
class RasterAttachmentViewport extends _Viewport__WEBPACK_IMPORTED_MODULE_11__.OffScreenViewport {
|
|
124240
|
-
_sceneContext;
|
|
124241
|
-
_isSceneReady = false;
|
|
124242
|
-
_attachment;
|
|
124243
|
-
constructor(view, rect, attachment) {
|
|
124244
|
-
super(_IModelApp__WEBPACK_IMPORTED_MODULE_9__.IModelApp.renderSystem.createOffscreenTarget(rect));
|
|
124245
|
-
this._attachment = attachment;
|
|
124246
|
-
this._isAspectRatioLocked = true;
|
|
124247
|
-
this.changeView(view);
|
|
124248
|
-
}
|
|
124249
|
-
createSceneContext() {
|
|
124250
|
-
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.assert)(!this._isSceneReady);
|
|
124251
|
-
this._sceneContext = super.createSceneContext();
|
|
124252
|
-
return this._sceneContext;
|
|
124253
|
-
}
|
|
124254
|
-
renderFrame() {
|
|
124255
|
-
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.assert)(!this._isSceneReady);
|
|
124256
|
-
this.clearSceneContext();
|
|
124257
|
-
super.renderFrame();
|
|
124258
|
-
if (undefined !== this._sceneContext) {
|
|
124259
|
-
this._isSceneReady = !this._sceneContext.hasMissingTiles && this.view.areAllTileTreesLoaded;
|
|
124260
|
-
if (this._isSceneReady)
|
|
124261
|
-
this._attachment.produceGraphics(this._sceneContext);
|
|
124262
|
-
this._sceneContext = undefined;
|
|
124263
|
-
}
|
|
124264
|
-
}
|
|
124265
|
-
clearSceneContext() {
|
|
124266
|
-
this._sceneContext = undefined;
|
|
124267
|
-
}
|
|
124268
|
-
addDecorations(_decorations) {
|
|
124269
|
-
// ###TODO: skybox, ground plane, possibly grid. DecorateContext requires a ScreenViewport...
|
|
124270
|
-
}
|
|
124271
|
-
}
|
|
124272
|
-
return new RasterAttachmentViewport(_view, _rect, _attachment);
|
|
124273
|
-
}
|
|
124274
|
-
/** Draws a 3d view with camera enabled into a sheet view by producing an image of the view's contents offscreen. */
|
|
124275
|
-
class RasterAttachment {
|
|
124276
|
-
_props;
|
|
124277
|
-
_placement;
|
|
124278
|
-
_transform;
|
|
124279
|
-
zDepth;
|
|
124280
|
-
_viewport;
|
|
124281
|
-
_graphics;
|
|
124282
|
-
constructor(view, props, sheetView) {
|
|
124283
|
-
// Render to a 2048x2048 view rect. Scale in Y to preserve aspect ratio.
|
|
124284
|
-
const maxSize = 2048;
|
|
124285
|
-
const rect = new _common_ViewRect__WEBPACK_IMPORTED_MODULE_15__.ViewRect(0, 0, maxSize, maxSize);
|
|
124286
|
-
const height = maxSize * view.getAspectRatio() * view.getAspectRatioSkew();
|
|
124287
|
-
const skew = maxSize / height;
|
|
124288
|
-
view.setAspectRatioSkew(skew);
|
|
124289
|
-
if (true !== props.jsonProperties?.displayOptions?.preserveBackground) {
|
|
124290
|
-
// Make background color 100% transparent so that Viewport.readImageBuffer() will discard transparent pixels.
|
|
124291
|
-
const bgColor = sheetView.displayStyle.backgroundColor.withAlpha(0);
|
|
124292
|
-
view.displayStyle.backgroundColor = bgColor;
|
|
124293
|
-
}
|
|
124294
|
-
this._viewport = createRasterAttachmentViewport(view, rect, this);
|
|
124295
|
-
this._props = props;
|
|
124296
|
-
this._placement = _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.Placement2d.fromJSON(props.placement);
|
|
124297
|
-
this._transform = this._placement.transform;
|
|
124298
|
-
this.zDepth = _Frustum2d__WEBPACK_IMPORTED_MODULE_6__.Frustum2d.depthFromDisplayPriority(props.jsonProperties?.displayPriority ?? 0);
|
|
124299
|
-
}
|
|
124300
|
-
[Symbol.dispose]() {
|
|
124301
|
-
this._viewport?.[Symbol.dispose]();
|
|
124302
|
-
}
|
|
124303
|
-
get viewAttachmentProps() {
|
|
124304
|
-
return this._props;
|
|
124305
|
-
}
|
|
124306
|
-
get viewport() {
|
|
124307
|
-
return this._viewport;
|
|
124308
|
-
}
|
|
124309
|
-
get areAllTileTreesLoaded() {
|
|
124310
|
-
return this._viewport?.areAllTileTreesLoaded ?? true;
|
|
124311
|
-
}
|
|
124312
|
-
addToScene(context) {
|
|
124313
|
-
// ###TODO: check viewport.wantViewAttachmentClipShapes
|
|
124314
|
-
if (!context.viewport.view.viewsCategory(this._props.category))
|
|
124315
|
-
return;
|
|
124316
|
-
if (context.viewport.wantViewAttachmentBoundaries) {
|
|
124317
|
-
const builder = context.createSceneGraphicBuilder(this._transform);
|
|
124318
|
-
builder.setSymbology(_itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.ColorDef.red, _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.ColorDef.red, 2);
|
|
124319
|
-
builder.addRangeBox(_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Range3d.createRange2d(this._placement.bbox));
|
|
124320
|
-
context.outputGraphic(builder.finish());
|
|
124321
|
-
}
|
|
124322
|
-
if (!context.viewport.wantViewAttachments)
|
|
124323
|
-
return;
|
|
124324
|
-
if (this._graphics) {
|
|
124325
|
-
context.outputGraphic(this._graphics);
|
|
124326
|
-
return;
|
|
124327
|
-
}
|
|
124328
|
-
if (undefined === this._viewport)
|
|
124329
|
-
return;
|
|
124330
|
-
this._viewport.debugBoundingBoxes = context.viewport.debugBoundingBoxes;
|
|
124331
|
-
this._viewport.setTileSizeModifier(context.viewport.tileSizeModifier);
|
|
124332
|
-
this._viewport.renderFrame();
|
|
124333
|
-
if (this._graphics)
|
|
124334
|
-
context.outputGraphic(this._graphics);
|
|
124335
|
-
}
|
|
124336
|
-
discloseTileTrees(trees) {
|
|
124337
|
-
if (this._viewport)
|
|
124338
|
-
trees.disclose(this._viewport);
|
|
124339
|
-
}
|
|
124340
|
-
produceGraphics(context) {
|
|
124341
|
-
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.assert)(context.viewport === this._viewport);
|
|
124342
|
-
this._graphics = this.createGraphics(this._viewport);
|
|
124343
|
-
this._viewport = (0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.dispose)(this._viewport);
|
|
124344
|
-
if (undefined !== this._graphics)
|
|
124345
|
-
context.outputGraphic(this._graphics);
|
|
124346
|
-
}
|
|
124347
|
-
createGraphics(vp) {
|
|
124348
|
-
// Create a texture from the contents of the view.
|
|
124349
|
-
const image = vp.readImageBuffer({ upsideDown: true });
|
|
124350
|
-
if (undefined === image)
|
|
124351
|
-
return undefined;
|
|
124352
|
-
const debugImage = false; // set to true to open a window displaying the captured image.
|
|
124353
|
-
if (debugImage) {
|
|
124354
|
-
const url = (0,_common_ImageUtil__WEBPACK_IMPORTED_MODULE_14__.imageBufferToPngDataUrl)(image, false);
|
|
124355
|
-
if (url)
|
|
124356
|
-
(0,_common_ImageUtil__WEBPACK_IMPORTED_MODULE_14__.openImageDataUrlInNewWindow)(url, "Attachment");
|
|
124357
|
-
}
|
|
124358
|
-
const texture = _IModelApp__WEBPACK_IMPORTED_MODULE_9__.IModelApp.renderSystem.createTexture({
|
|
124359
|
-
image: { source: image, transparency: _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.TextureTransparency.Opaque },
|
|
124360
|
-
});
|
|
124361
|
-
if (!texture)
|
|
124362
|
-
return undefined;
|
|
124363
|
-
// Create a material for the texture
|
|
124364
|
-
const graphicParams = new _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.GraphicParams();
|
|
124365
|
-
graphicParams.material = _IModelApp__WEBPACK_IMPORTED_MODULE_9__.IModelApp.renderSystem.createRenderMaterial({ textureMapping: { texture } });
|
|
124366
|
-
// Apply the texture to a rectangular polyface.
|
|
124367
|
-
const depth = this.zDepth;
|
|
124368
|
-
const east = this._placement.bbox.low.x;
|
|
124369
|
-
const west = this._placement.bbox.high.x;
|
|
124370
|
-
const north = this._placement.bbox.low.y;
|
|
124371
|
-
const south = this._placement.bbox.high.y;
|
|
124372
|
-
const corners = [
|
|
124373
|
-
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Point3d.create(east, north, depth),
|
|
124374
|
-
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Point3d.create(west, north, depth),
|
|
124375
|
-
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Point3d.create(west, south, depth),
|
|
124376
|
-
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Point3d.create(east, south, depth),
|
|
124377
|
-
];
|
|
124378
|
-
const params = [
|
|
124379
|
-
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Point2d.create(0, 0),
|
|
124380
|
-
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Point2d.create(1, 0),
|
|
124381
|
-
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Point2d.create(1, 1),
|
|
124382
|
-
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Point2d.create(0, 1),
|
|
124383
|
-
];
|
|
124384
|
-
const strokeOptions = new _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.StrokeOptions();
|
|
124385
|
-
strokeOptions.needParams = strokeOptions.shouldTriangulate = true;
|
|
124386
|
-
const polyfaceBuilder = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.PolyfaceBuilder.create(strokeOptions);
|
|
124387
|
-
polyfaceBuilder.addQuadFacet(corners, params);
|
|
124388
|
-
const polyface = polyfaceBuilder.claimPolyface();
|
|
124389
|
-
const graphicBuilder = _IModelApp__WEBPACK_IMPORTED_MODULE_9__.IModelApp.renderSystem.createGraphicBuilder(_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Transform.createIdentity(), _common_render_GraphicType__WEBPACK_IMPORTED_MODULE_16__.GraphicType.Scene, vp, this._props.id);
|
|
124390
|
-
graphicBuilder.activateGraphicParams(graphicParams);
|
|
124391
|
-
graphicBuilder.addPolyface(polyface, false);
|
|
124392
|
-
const graphic = graphicBuilder.finish();
|
|
124393
|
-
// Wrap the polyface in a GraphicBranch.
|
|
124394
|
-
const branch = new _render_GraphicBranch__WEBPACK_IMPORTED_MODULE_5__.GraphicBranch(true);
|
|
124395
|
-
const vfOvrs = (0,_tile_internal__WEBPACK_IMPORTED_MODULE_13__.createDefaultViewFlagOverrides)({ clipVolume: true, shadows: false, lighting: false, thematic: false });
|
|
124396
|
-
// Disable transparency - background pixels are 100% transparent so they will be discarded anyway. Other pixels are 100% opaque.
|
|
124397
|
-
vfOvrs.transparency = false;
|
|
124398
|
-
branch.setViewFlagOverrides(vfOvrs);
|
|
124399
|
-
branch.symbologyOverrides = new _render_FeatureSymbology__WEBPACK_IMPORTED_MODULE_8__.FeatureSymbology.Overrides();
|
|
124400
|
-
branch.entries.push(graphic);
|
|
124401
|
-
// Apply the attachment's clip, if any.
|
|
124402
|
-
let clipVolume;
|
|
124403
|
-
if (this._props.jsonProperties?.clip) {
|
|
124404
|
-
const clipVector = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.ClipVector.fromJSON(this._props.jsonProperties?.clip);
|
|
124405
|
-
if (clipVector.isValid)
|
|
124406
|
-
clipVolume = _IModelApp__WEBPACK_IMPORTED_MODULE_9__.IModelApp.renderSystem.createClipVolume(clipVector);
|
|
124407
|
-
}
|
|
124408
|
-
return _IModelApp__WEBPACK_IMPORTED_MODULE_9__.IModelApp.renderSystem.createGraphicBranch(branch, this._transform, { clipVolume });
|
|
124409
|
-
}
|
|
124410
|
-
collectStatistics(stats) {
|
|
124411
|
-
if (this._graphics)
|
|
124412
|
-
this._graphics.collectStatistics(stats);
|
|
123777
|
+
return this._viewAttachments.computeDisplayTransform(args);
|
|
124413
123778
|
}
|
|
124414
123779
|
}
|
|
124415
123780
|
|
|
@@ -125009,7 +124374,46 @@ class SubCategoriesCache {
|
|
|
125009
124374
|
_appearances = new Map();
|
|
125010
124375
|
_imodel;
|
|
125011
124376
|
_missingAtTimeOfPreload;
|
|
125012
|
-
constructor(imodel) {
|
|
124377
|
+
constructor(imodel) {
|
|
124378
|
+
this._imodel = imodel;
|
|
124379
|
+
}
|
|
124380
|
+
attachToBriefcase(imodel) {
|
|
124381
|
+
// We want to do this in the constructor but can't, because IModelConnection.subcategories is initialized before
|
|
124382
|
+
// BriefcaseConnection.txns.
|
|
124383
|
+
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.assert)(imodel === this._imodel);
|
|
124384
|
+
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.assert)(imodel.isBriefcaseConnection());
|
|
124385
|
+
imodel.txns.onElementsChanged.addListener((changes) => {
|
|
124386
|
+
const affectedSubCategories = new Set();
|
|
124387
|
+
for (const change of changes) {
|
|
124388
|
+
if (change.metadata.is("BisCore:Category")) {
|
|
124389
|
+
if (change.type === "deleted") {
|
|
124390
|
+
this._byCategoryId.delete(change.id);
|
|
124391
|
+
}
|
|
124392
|
+
}
|
|
124393
|
+
else if (change.metadata.is("BisCore:SubCategory")) {
|
|
124394
|
+
if (change.type === "inserted") {
|
|
124395
|
+
// We don't know to which category the subcategory belongs. Blow away the entire cache.
|
|
124396
|
+
this._byCategoryId.clear();
|
|
124397
|
+
this._appearances.clear();
|
|
124398
|
+
return;
|
|
124399
|
+
}
|
|
124400
|
+
this._appearances.delete(change.id);
|
|
124401
|
+
affectedSubCategories.add(change.id);
|
|
124402
|
+
}
|
|
124403
|
+
}
|
|
124404
|
+
if (affectedSubCategories.size > 0) {
|
|
124405
|
+
for (const [catId, subCatIds] of this._byCategoryId) {
|
|
124406
|
+
for (const subCatId of affectedSubCategories) {
|
|
124407
|
+
if (subCatIds.has(subCatId)) {
|
|
124408
|
+
this._byCategoryId.delete(catId);
|
|
124409
|
+
affectedSubCategories.delete(subCatId);
|
|
124410
|
+
break;
|
|
124411
|
+
}
|
|
124412
|
+
}
|
|
124413
|
+
}
|
|
124414
|
+
}
|
|
124415
|
+
});
|
|
124416
|
+
}
|
|
125013
124417
|
/** Get the Ids of all subcategories belonging to the category with the specified Id, or undefined if no such information is present. */
|
|
125014
124418
|
getSubCategories(categoryId) { return this._byCategoryId.get(categoryId); }
|
|
125015
124419
|
/** Get the base appearance of the subcategory with the specified Id, or undefined if no such information is present. */
|
|
@@ -143246,6 +142650,845 @@ function getAllElementIdsFromScript(script) {
|
|
|
143246
142650
|
}
|
|
143247
142651
|
|
|
143248
142652
|
|
|
142653
|
+
/***/ }),
|
|
142654
|
+
|
|
142655
|
+
/***/ "../../core/frontend/lib/esm/internal/SheetViewAttachments.js":
|
|
142656
|
+
/*!********************************************************************!*\
|
|
142657
|
+
!*** ../../core/frontend/lib/esm/internal/SheetViewAttachments.js ***!
|
|
142658
|
+
\********************************************************************/
|
|
142659
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
142660
|
+
|
|
142661
|
+
"use strict";
|
|
142662
|
+
__webpack_require__.r(__webpack_exports__);
|
|
142663
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
142664
|
+
/* harmony export */ SheetViewAttachments: () => (/* binding */ SheetViewAttachments)
|
|
142665
|
+
/* harmony export */ });
|
|
142666
|
+
/* harmony import */ var _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @itwin/core-common */ "../../core/common/lib/esm/core-common.js");
|
|
142667
|
+
/* harmony import */ var _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @itwin/core-bentley */ "../../core/bentley/lib/esm/core-bentley.js");
|
|
142668
|
+
/* harmony import */ var _IModelApp__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../IModelApp */ "../../core/frontend/lib/esm/IModelApp.js");
|
|
142669
|
+
/* harmony import */ var _ViewAttachmentRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ViewAttachmentRenderer */ "../../core/frontend/lib/esm/internal/ViewAttachmentRenderer.js");
|
|
142670
|
+
/* harmony import */ var _Frustum2d__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Frustum2d */ "../../core/frontend/lib/esm/Frustum2d.js");
|
|
142671
|
+
/*---------------------------------------------------------------------------------------------
|
|
142672
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
142673
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
142674
|
+
*--------------------------------------------------------------------------------------------*/
|
|
142675
|
+
/** @packageDocumentation
|
|
142676
|
+
* @module Views
|
|
142677
|
+
*/
|
|
142678
|
+
|
|
142679
|
+
|
|
142680
|
+
|
|
142681
|
+
|
|
142682
|
+
|
|
142683
|
+
/** Stateless state for a sheet that has no view attachments. */
|
|
142684
|
+
class EmptyAttachments {
|
|
142685
|
+
// We only need one instance of this stateless class.
|
|
142686
|
+
static _instance;
|
|
142687
|
+
static get() {
|
|
142688
|
+
return this._instance ?? (this._instance = new EmptyAttachments());
|
|
142689
|
+
}
|
|
142690
|
+
constructor() { }
|
|
142691
|
+
clone() {
|
|
142692
|
+
return this;
|
|
142693
|
+
}
|
|
142694
|
+
preload() { }
|
|
142695
|
+
async postload() {
|
|
142696
|
+
return this;
|
|
142697
|
+
}
|
|
142698
|
+
get attachmentIds() {
|
|
142699
|
+
return [];
|
|
142700
|
+
}
|
|
142701
|
+
}
|
|
142702
|
+
/** Holds the element Ids of the view attachments to be loaded for display. */
|
|
142703
|
+
class AttachmentIds {
|
|
142704
|
+
_ids;
|
|
142705
|
+
constructor(ids) {
|
|
142706
|
+
this._ids = ids;
|
|
142707
|
+
}
|
|
142708
|
+
get attachmentIds() {
|
|
142709
|
+
return this._ids;
|
|
142710
|
+
}
|
|
142711
|
+
clone() {
|
|
142712
|
+
return new AttachmentIds([...this._ids]);
|
|
142713
|
+
}
|
|
142714
|
+
preload(request) {
|
|
142715
|
+
request.sheetViewAttachmentIds = _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_1__.CompressedId64Set.sortAndCompress(this._ids);
|
|
142716
|
+
request.viewStateLoadProps = {
|
|
142717
|
+
displayStyle: {
|
|
142718
|
+
omitScheduleScriptElementIds: !_IModelApp__WEBPACK_IMPORTED_MODULE_2__.IModelApp.tileAdmin.enableFrontendScheduleScripts,
|
|
142719
|
+
compressExcludedElementIds: true,
|
|
142720
|
+
},
|
|
142721
|
+
};
|
|
142722
|
+
}
|
|
142723
|
+
async postload(response, iModel) {
|
|
142724
|
+
if (undefined === response.sheetViewViews || undefined === response.sheetViewAttachmentProps) {
|
|
142725
|
+
return this;
|
|
142726
|
+
}
|
|
142727
|
+
const viewStateProps = response.sheetViewViews;
|
|
142728
|
+
const promises = [];
|
|
142729
|
+
for (const viewProps of viewStateProps) {
|
|
142730
|
+
const loadView = async () => {
|
|
142731
|
+
try {
|
|
142732
|
+
if (viewProps === undefined)
|
|
142733
|
+
return undefined;
|
|
142734
|
+
const view = await iModel.views.convertViewStatePropsToViewState(viewProps);
|
|
142735
|
+
return view;
|
|
142736
|
+
}
|
|
142737
|
+
catch {
|
|
142738
|
+
return undefined;
|
|
142739
|
+
}
|
|
142740
|
+
};
|
|
142741
|
+
promises.push(loadView());
|
|
142742
|
+
}
|
|
142743
|
+
const views = await Promise.all(promises);
|
|
142744
|
+
const attachmentProps = response.sheetViewAttachmentProps;
|
|
142745
|
+
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_1__.assert)(views.length === attachmentProps.length);
|
|
142746
|
+
const infos = [];
|
|
142747
|
+
for (let i = 0; i < views.length; i++) {
|
|
142748
|
+
const view = views[i];
|
|
142749
|
+
if (view && !(view.isSheetView())) {
|
|
142750
|
+
const props = attachmentProps[i];
|
|
142751
|
+
props.attachedView = view;
|
|
142752
|
+
infos.push(props);
|
|
142753
|
+
}
|
|
142754
|
+
}
|
|
142755
|
+
return new AttachmentInfos(infos);
|
|
142756
|
+
}
|
|
142757
|
+
}
|
|
142758
|
+
/** Fully loaded view attachments. */
|
|
142759
|
+
class AttachmentInfos {
|
|
142760
|
+
infos;
|
|
142761
|
+
constructor(infos) {
|
|
142762
|
+
this.infos = infos;
|
|
142763
|
+
}
|
|
142764
|
+
get attachmentIds() {
|
|
142765
|
+
return this.infos.map((x) => (0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_1__.expectDefined)(x.id));
|
|
142766
|
+
}
|
|
142767
|
+
clone(iModel) {
|
|
142768
|
+
const infos = this.infos.map((info) => {
|
|
142769
|
+
return {
|
|
142770
|
+
...info,
|
|
142771
|
+
attachedView: info.attachedView.clone(iModel),
|
|
142772
|
+
};
|
|
142773
|
+
});
|
|
142774
|
+
return new AttachmentInfos(infos);
|
|
142775
|
+
}
|
|
142776
|
+
preload() {
|
|
142777
|
+
// already loaded.
|
|
142778
|
+
}
|
|
142779
|
+
async postload() {
|
|
142780
|
+
// already loaded.
|
|
142781
|
+
return this;
|
|
142782
|
+
}
|
|
142783
|
+
}
|
|
142784
|
+
/** Reloads the attachments after a change to the database. */
|
|
142785
|
+
async function reloadAttachments(sheetModelId, iModel) {
|
|
142786
|
+
const ecsql = `SELECT ECInstanceId as attachmentId FROM bis.ViewAttachment WHERE model.Id=${sheetModelId}`;
|
|
142787
|
+
const ids = [];
|
|
142788
|
+
for await (const row of iModel.createQueryReader(ecsql)) {
|
|
142789
|
+
ids.push(row[0]);
|
|
142790
|
+
}
|
|
142791
|
+
const attachmentProps = await iModel.elements.getProps(ids);
|
|
142792
|
+
const promises = [];
|
|
142793
|
+
for (const attachment of attachmentProps) {
|
|
142794
|
+
const loadView = async () => {
|
|
142795
|
+
try {
|
|
142796
|
+
const view = await iModel.views.load(attachment.view.id);
|
|
142797
|
+
return view;
|
|
142798
|
+
}
|
|
142799
|
+
catch {
|
|
142800
|
+
return undefined;
|
|
142801
|
+
}
|
|
142802
|
+
};
|
|
142803
|
+
promises.push(loadView());
|
|
142804
|
+
}
|
|
142805
|
+
const views = await Promise.all(promises);
|
|
142806
|
+
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_1__.assert)(views.length === attachmentProps.length);
|
|
142807
|
+
const infos = [];
|
|
142808
|
+
for (let i = 0; i < views.length; i++) {
|
|
142809
|
+
const view = views[i];
|
|
142810
|
+
if (view && !view.isSheetView()) {
|
|
142811
|
+
const props = attachmentProps[i];
|
|
142812
|
+
props.attachedView = view;
|
|
142813
|
+
infos.push(props);
|
|
142814
|
+
}
|
|
142815
|
+
}
|
|
142816
|
+
return new AttachmentInfos(infos);
|
|
142817
|
+
}
|
|
142818
|
+
function disposeRenderers(renderers) {
|
|
142819
|
+
if (renderers) {
|
|
142820
|
+
for (const renderer of renderers) {
|
|
142821
|
+
renderer[Symbol.dispose]();
|
|
142822
|
+
}
|
|
142823
|
+
}
|
|
142824
|
+
}
|
|
142825
|
+
/** Manages the set of ViewAttachment elements to be rendered by a SheetViewState.
|
|
142826
|
+
* Takes care of reloading them after ViewAttachment elements are modified, deleted, or inserted.
|
|
142827
|
+
*/
|
|
142828
|
+
class SheetViewAttachments {
|
|
142829
|
+
_impl;
|
|
142830
|
+
_reload;
|
|
142831
|
+
_maxDepth = _Frustum2d__WEBPACK_IMPORTED_MODULE_4__.Frustum2d.minimumZDistance;
|
|
142832
|
+
_rendererArgs;
|
|
142833
|
+
_renderers;
|
|
142834
|
+
get maxDepth() {
|
|
142835
|
+
return this._maxDepth;
|
|
142836
|
+
}
|
|
142837
|
+
*getSecondaryViewports() {
|
|
142838
|
+
if (this._renderers) {
|
|
142839
|
+
for (const renderer of this._renderers) {
|
|
142840
|
+
if (renderer.viewport) {
|
|
142841
|
+
yield renderer.viewport;
|
|
142842
|
+
}
|
|
142843
|
+
}
|
|
142844
|
+
}
|
|
142845
|
+
}
|
|
142846
|
+
constructor(impl) {
|
|
142847
|
+
this._impl = impl;
|
|
142848
|
+
}
|
|
142849
|
+
[Symbol.dispose]() {
|
|
142850
|
+
disposeRenderers(this._renderers);
|
|
142851
|
+
this._renderers = this._rendererArgs = undefined;
|
|
142852
|
+
this._reload = undefined;
|
|
142853
|
+
}
|
|
142854
|
+
static create(attachmentIds) {
|
|
142855
|
+
const impl = attachmentIds.length === 0 ? EmptyAttachments.get() : new AttachmentIds([...attachmentIds]);
|
|
142856
|
+
return new this(impl);
|
|
142857
|
+
}
|
|
142858
|
+
get attachmentIds() {
|
|
142859
|
+
return this._impl.attachmentIds;
|
|
142860
|
+
}
|
|
142861
|
+
clone(iModel) {
|
|
142862
|
+
return new SheetViewAttachments(this._impl.clone(iModel));
|
|
142863
|
+
}
|
|
142864
|
+
preload(request) {
|
|
142865
|
+
this._impl.preload(request);
|
|
142866
|
+
}
|
|
142867
|
+
async postload(response, iModel) {
|
|
142868
|
+
this._impl = await this._impl.postload(response, iModel);
|
|
142869
|
+
}
|
|
142870
|
+
async reload(sheetModelId, iModel) {
|
|
142871
|
+
const renderers = this._renderers;
|
|
142872
|
+
const reload = this._reload = reloadAttachments(sheetModelId, iModel);
|
|
142873
|
+
const impl = await this._reload;
|
|
142874
|
+
// We keep the previous renderers until reloading completes, to avoid drawing a blank view while waiting.
|
|
142875
|
+
// Afterward, always destroy the previous renderers.
|
|
142876
|
+
disposeRenderers(renderers);
|
|
142877
|
+
// If reload was not called again while we waited...
|
|
142878
|
+
if (this._reload === reload) {
|
|
142879
|
+
this._impl = impl;
|
|
142880
|
+
this._reload = this._renderers = undefined;
|
|
142881
|
+
if (this._rendererArgs) {
|
|
142882
|
+
// We are attached to a Viewport - reload the renderers.
|
|
142883
|
+
this.loadRenderers();
|
|
142884
|
+
}
|
|
142885
|
+
}
|
|
142886
|
+
}
|
|
142887
|
+
attachToViewport(args) {
|
|
142888
|
+
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_1__.assert)(undefined === this._renderers);
|
|
142889
|
+
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_1__.assert)(undefined === this._rendererArgs);
|
|
142890
|
+
this._rendererArgs = args;
|
|
142891
|
+
this.loadRenderers();
|
|
142892
|
+
}
|
|
142893
|
+
detachFromViewport() {
|
|
142894
|
+
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_1__.assert)(undefined !== this._rendererArgs);
|
|
142895
|
+
this._rendererArgs = undefined;
|
|
142896
|
+
disposeRenderers(this._renderers);
|
|
142897
|
+
this._renderers = undefined;
|
|
142898
|
+
}
|
|
142899
|
+
areAllTileTreesLoaded(displayedExtents) {
|
|
142900
|
+
if (this._reload) {
|
|
142901
|
+
return false;
|
|
142902
|
+
}
|
|
142903
|
+
else if (!this._renderers) {
|
|
142904
|
+
return true;
|
|
142905
|
+
}
|
|
142906
|
+
return this._renderers.every((renderer) => {
|
|
142907
|
+
const attachmentRange = _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.Placement2d.fromJSON(renderer.viewAttachmentProps.placement).calculateRange();
|
|
142908
|
+
return !attachmentRange.intersectsRangeXY(displayedExtents) || renderer.areAllTileTreesLoaded;
|
|
142909
|
+
});
|
|
142910
|
+
}
|
|
142911
|
+
discloseTileTrees(trees) {
|
|
142912
|
+
for (const renderer of this.renderers()) {
|
|
142913
|
+
trees.disclose(renderer);
|
|
142914
|
+
}
|
|
142915
|
+
}
|
|
142916
|
+
collectStatistics(stats) {
|
|
142917
|
+
for (const renderer of this.renderers()) {
|
|
142918
|
+
renderer.collectStatistics(stats);
|
|
142919
|
+
}
|
|
142920
|
+
}
|
|
142921
|
+
addToScene(context) {
|
|
142922
|
+
for (const renderer of this.renderers()) {
|
|
142923
|
+
renderer.addToScene(context);
|
|
142924
|
+
}
|
|
142925
|
+
}
|
|
142926
|
+
getAttachmentViewport(args) {
|
|
142927
|
+
const renderer = args.viewAttachmentId ? this.findRendererById(args.viewAttachmentId) : undefined;
|
|
142928
|
+
if (!renderer) {
|
|
142929
|
+
return undefined;
|
|
142930
|
+
}
|
|
142931
|
+
return args.inSectionDrawingAttachment ? renderer.viewport?.view.getAttachmentViewport({ inSectionDrawingAttachment: true }) : renderer.viewport;
|
|
142932
|
+
}
|
|
142933
|
+
computeDisplayTransform(args) {
|
|
142934
|
+
const renderer = undefined !== args.viewAttachmentId ? this.findRendererById(args.viewAttachmentId) : undefined;
|
|
142935
|
+
const ortho = renderer?.ortho;
|
|
142936
|
+
const sheetTransform = ortho?.toSheet;
|
|
142937
|
+
if (!sheetTransform) {
|
|
142938
|
+
return undefined;
|
|
142939
|
+
}
|
|
142940
|
+
const sectionTransform = args.inSectionDrawingAttachment ? ortho.view.computeDisplayTransform(args) : undefined;
|
|
142941
|
+
if (!sectionTransform) {
|
|
142942
|
+
return sheetTransform.clone(args.output);
|
|
142943
|
+
}
|
|
142944
|
+
return sheetTransform.multiplyTransformTransform(sectionTransform, args.output);
|
|
142945
|
+
}
|
|
142946
|
+
/** Strictly for tests. */
|
|
142947
|
+
areAllAttachmentsLoaded() {
|
|
142948
|
+
return !this._reload && (!this._renderers || this._renderers.every((x) => x.areAllTileTreesLoaded));
|
|
142949
|
+
}
|
|
142950
|
+
/** Strictly for tests. */
|
|
142951
|
+
get attachments() {
|
|
142952
|
+
return this._renderers;
|
|
142953
|
+
}
|
|
142954
|
+
/** Strictly for tests. */
|
|
142955
|
+
get attachmentProps() {
|
|
142956
|
+
const infos = this._impl.infos;
|
|
142957
|
+
if (!infos) {
|
|
142958
|
+
return [];
|
|
142959
|
+
}
|
|
142960
|
+
return infos.map((x) => {
|
|
142961
|
+
return {
|
|
142962
|
+
...x,
|
|
142963
|
+
attachedView: undefined,
|
|
142964
|
+
};
|
|
142965
|
+
});
|
|
142966
|
+
}
|
|
142967
|
+
/** Strictly for tests. */
|
|
142968
|
+
get attachmentInfos() {
|
|
142969
|
+
const infos = this._impl.infos;
|
|
142970
|
+
return infos ?? this._impl.attachmentIds;
|
|
142971
|
+
}
|
|
142972
|
+
loadRenderers() {
|
|
142973
|
+
const args = this._rendererArgs;
|
|
142974
|
+
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_1__.assert)(undefined !== args);
|
|
142975
|
+
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_1__.assert)(undefined === this._renderers);
|
|
142976
|
+
this._maxDepth = _Frustum2d__WEBPACK_IMPORTED_MODULE_4__.Frustum2d.minimumZDistance;
|
|
142977
|
+
const infos = this._impl.infos;
|
|
142978
|
+
if (!infos) {
|
|
142979
|
+
return;
|
|
142980
|
+
}
|
|
142981
|
+
this._renderers = infos.map((info) => {
|
|
142982
|
+
const renderer = (0,_ViewAttachmentRenderer__WEBPACK_IMPORTED_MODULE_3__.createViewAttachmentRenderer)({
|
|
142983
|
+
...args,
|
|
142984
|
+
props: info,
|
|
142985
|
+
view: info.attachedView,
|
|
142986
|
+
});
|
|
142987
|
+
this._maxDepth = Math.max(this._maxDepth, renderer.zDepth);
|
|
142988
|
+
return renderer;
|
|
142989
|
+
});
|
|
142990
|
+
}
|
|
142991
|
+
*renderers() {
|
|
142992
|
+
if (this._renderers) {
|
|
142993
|
+
for (const renderer of this._renderers) {
|
|
142994
|
+
yield renderer;
|
|
142995
|
+
}
|
|
142996
|
+
}
|
|
142997
|
+
}
|
|
142998
|
+
findRendererById(id) {
|
|
142999
|
+
return this._renderers?.find((x) => x.viewAttachmentProps.id === id);
|
|
143000
|
+
}
|
|
143001
|
+
}
|
|
143002
|
+
|
|
143003
|
+
|
|
143004
|
+
/***/ }),
|
|
143005
|
+
|
|
143006
|
+
/***/ "../../core/frontend/lib/esm/internal/ViewAttachmentRenderer.js":
|
|
143007
|
+
/*!**********************************************************************!*\
|
|
143008
|
+
!*** ../../core/frontend/lib/esm/internal/ViewAttachmentRenderer.js ***!
|
|
143009
|
+
\**********************************************************************/
|
|
143010
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
143011
|
+
|
|
143012
|
+
"use strict";
|
|
143013
|
+
__webpack_require__.r(__webpack_exports__);
|
|
143014
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
143015
|
+
/* harmony export */ createViewAttachmentRenderer: () => (/* binding */ createViewAttachmentRenderer)
|
|
143016
|
+
/* harmony export */ });
|
|
143017
|
+
/* harmony import */ var _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @itwin/core-common */ "../../core/common/lib/esm/core-common.js");
|
|
143018
|
+
/* harmony import */ var _CoordSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../CoordSystem */ "../../core/frontend/lib/esm/CoordSystem.js");
|
|
143019
|
+
/* harmony import */ var _Frustum2d__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Frustum2d */ "../../core/frontend/lib/esm/Frustum2d.js");
|
|
143020
|
+
/* harmony import */ var _IModelApp__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../IModelApp */ "../../core/frontend/lib/esm/IModelApp.js");
|
|
143021
|
+
/* harmony import */ var _Viewport__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Viewport */ "../../core/frontend/lib/esm/Viewport.js");
|
|
143022
|
+
/* harmony import */ var _common_ImageUtil__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../common/ImageUtil */ "../../core/frontend/lib/esm/common/ImageUtil.js");
|
|
143023
|
+
/* harmony import */ var _common_ViewRect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../common/ViewRect */ "../../core/frontend/lib/esm/common/ViewRect.js");
|
|
143024
|
+
/* harmony import */ var _common_render_GraphicType__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../common/render/GraphicType */ "../../core/frontend/lib/esm/common/render/GraphicType.js");
|
|
143025
|
+
/* harmony import */ var _render_FeatureSymbology__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../render/FeatureSymbology */ "../../core/frontend/lib/esm/render/FeatureSymbology.js");
|
|
143026
|
+
/* harmony import */ var _render_GraphicBranch__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../render/GraphicBranch */ "../../core/frontend/lib/esm/render/GraphicBranch.js");
|
|
143027
|
+
/* harmony import */ var _tile_internal__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../tile/internal */ "../../core/frontend/lib/esm/tile/internal.js");
|
|
143028
|
+
/* harmony import */ var _render_MockRender__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./render/MockRender */ "../../core/frontend/lib/esm/internal/render/MockRender.js");
|
|
143029
|
+
/* harmony import */ var _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! @itwin/core-bentley */ "../../core/bentley/lib/esm/core-bentley.js");
|
|
143030
|
+
/* harmony import */ var _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! @itwin/core-geometry */ "../../core/geometry/lib/esm/core-geometry.js");
|
|
143031
|
+
/* harmony import */ var _tile_ViewFlagOverrides__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./tile/ViewFlagOverrides */ "../../core/frontend/lib/esm/internal/tile/ViewFlagOverrides.js");
|
|
143032
|
+
/*---------------------------------------------------------------------------------------------
|
|
143033
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
143034
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
143035
|
+
*--------------------------------------------------------------------------------------------*/
|
|
143036
|
+
/** @packageDocumentation
|
|
143037
|
+
* @module Views
|
|
143038
|
+
*/
|
|
143039
|
+
|
|
143040
|
+
|
|
143041
|
+
|
|
143042
|
+
|
|
143043
|
+
|
|
143044
|
+
|
|
143045
|
+
|
|
143046
|
+
|
|
143047
|
+
|
|
143048
|
+
|
|
143049
|
+
|
|
143050
|
+
|
|
143051
|
+
|
|
143052
|
+
|
|
143053
|
+
|
|
143054
|
+
function createViewAttachmentRenderer(args) {
|
|
143055
|
+
const { props, view } = args;
|
|
143056
|
+
if (props.jsonProperties?.displayOptions?.drawAsRaster || (view.is3d() && view.isCameraOn)) {
|
|
143057
|
+
return new RasterAttachment(view, props, args.backgroundColor);
|
|
143058
|
+
}
|
|
143059
|
+
else {
|
|
143060
|
+
return new OrthographicAttachment(view, props, args.sheetModelId);
|
|
143061
|
+
}
|
|
143062
|
+
}
|
|
143063
|
+
/** A mostly no-op RenderTarget for an OrthographicAttachment. */
|
|
143064
|
+
class AttachmentTarget extends _render_MockRender__WEBPACK_IMPORTED_MODULE_11__.MockRender.OffScreenTarget {
|
|
143065
|
+
_attachment;
|
|
143066
|
+
constructor(attachment) {
|
|
143067
|
+
// The dimensions don't matter - we're not drawing anything.
|
|
143068
|
+
const rect = new _common_ViewRect__WEBPACK_IMPORTED_MODULE_6__.ViewRect(1, 1);
|
|
143069
|
+
super(_IModelApp__WEBPACK_IMPORTED_MODULE_3__.IModelApp.renderSystem, rect);
|
|
143070
|
+
this._attachment = attachment;
|
|
143071
|
+
}
|
|
143072
|
+
changeScene(scene) {
|
|
143073
|
+
this._attachment.scene = scene;
|
|
143074
|
+
}
|
|
143075
|
+
overrideFeatureSymbology(ovrs) {
|
|
143076
|
+
this._attachment.symbologyOverrides = ovrs;
|
|
143077
|
+
}
|
|
143078
|
+
}
|
|
143079
|
+
/** Draws the contents a 2d or orthographic 3d view directly into a sheet view.
|
|
143080
|
+
* We select tiles for the view in the context of a light-weight offscreen viewport with a no-op RenderTarget, then
|
|
143081
|
+
* collect the resultant graphics and add them to the sheet view's scene.
|
|
143082
|
+
*/
|
|
143083
|
+
class OrthographicAttachment {
|
|
143084
|
+
_viewport;
|
|
143085
|
+
_props;
|
|
143086
|
+
_sheetModelId;
|
|
143087
|
+
_viewFlagOverrides;
|
|
143088
|
+
_toSheet;
|
|
143089
|
+
_fromSheet;
|
|
143090
|
+
_sizeInMeters;
|
|
143091
|
+
_range;
|
|
143092
|
+
_viewRect = new _common_ViewRect__WEBPACK_IMPORTED_MODULE_6__.ViewRect(0, 0, 1, 1);
|
|
143093
|
+
_originalFrustum = new _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.Frustum();
|
|
143094
|
+
_clipVolume;
|
|
143095
|
+
_hiddenLineSettings;
|
|
143096
|
+
_scale;
|
|
143097
|
+
_debugFeatureTable;
|
|
143098
|
+
scene;
|
|
143099
|
+
symbologyOverrides;
|
|
143100
|
+
zDepth;
|
|
143101
|
+
get view() {
|
|
143102
|
+
return this._viewport.view;
|
|
143103
|
+
}
|
|
143104
|
+
get viewAttachmentProps() {
|
|
143105
|
+
return this._props;
|
|
143106
|
+
}
|
|
143107
|
+
get viewport() {
|
|
143108
|
+
return this._viewport;
|
|
143109
|
+
}
|
|
143110
|
+
constructor(view, props, sheetModelId) {
|
|
143111
|
+
this.symbologyOverrides = new _render_FeatureSymbology__WEBPACK_IMPORTED_MODULE_8__.FeatureSymbology.Overrides(view);
|
|
143112
|
+
const target = new AttachmentTarget(this);
|
|
143113
|
+
this._viewport = _Viewport__WEBPACK_IMPORTED_MODULE_4__.OffScreenViewport.createViewport(view, target, true);
|
|
143114
|
+
this._props = props;
|
|
143115
|
+
this._sheetModelId = sheetModelId;
|
|
143116
|
+
const applyClip = true; // set to false for debugging
|
|
143117
|
+
this._viewFlagOverrides = {
|
|
143118
|
+
...view.viewFlags,
|
|
143119
|
+
clipVolume: applyClip,
|
|
143120
|
+
lighting: false,
|
|
143121
|
+
shadows: false,
|
|
143122
|
+
};
|
|
143123
|
+
const placement = _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.Placement2d.fromJSON(props.placement);
|
|
143124
|
+
const range = placement.calculateRange();
|
|
143125
|
+
this._range = range;
|
|
143126
|
+
this._sizeInMeters = new _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.Point2d(range.xLength(), range.yLength());
|
|
143127
|
+
// Compute transform from attached view's world coordinates to sheet's world coordinates.
|
|
143128
|
+
// NB: We obtain the extents and origin from the *viewport* not the *view* - they may have been adjusted by the viewport.
|
|
143129
|
+
const applySkew = true; // set to false for debugging
|
|
143130
|
+
const skew = applySkew ? view.getAspectRatioSkew() : 1;
|
|
143131
|
+
const extents = this._viewport.viewingSpace.viewDelta.clone();
|
|
143132
|
+
const zDepth = Math.abs(extents.z);
|
|
143133
|
+
const scaleX = this._sizeInMeters.x / Math.abs(extents.x);
|
|
143134
|
+
const scaleY = skew * this._sizeInMeters.y / Math.abs(extents.y);
|
|
143135
|
+
this._scale = { x: 1 / scaleX, y: 1 / scaleY };
|
|
143136
|
+
const zBias = _Frustum2d__WEBPACK_IMPORTED_MODULE_2__.Frustum2d.depthFromDisplayPriority(props.jsonProperties?.displayPriority ?? 0);
|
|
143137
|
+
this.zDepth = 1.01 * (zDepth - zBias); // give a little padding so that geometry right up against far plane doesn't get clipped.
|
|
143138
|
+
// View origin is at the *back* of the view. Align *front* of view based on display priority.
|
|
143139
|
+
const viewRot = view.getRotation();
|
|
143140
|
+
const viewOrg = viewRot.multiplyVector(this._viewport.viewingSpace.viewOrigin);
|
|
143141
|
+
viewOrg.z += zDepth;
|
|
143142
|
+
viewRot.multiplyTransposeVectorInPlace(viewOrg);
|
|
143143
|
+
const matrix = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.Matrix3d.createScale(scaleX, scaleY, 1);
|
|
143144
|
+
matrix.multiplyMatrixMatrix(viewRot, matrix);
|
|
143145
|
+
const origin = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.Matrix3d.xyzMinusMatrixTimesXYZ(viewOrg, matrix, viewOrg);
|
|
143146
|
+
const attachmentOrigin = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.Point3d.createFrom(placement.origin);
|
|
143147
|
+
attachmentOrigin.z = zBias;
|
|
143148
|
+
const viewOrgToAttachment = attachmentOrigin.minus(viewOrg);
|
|
143149
|
+
origin.addInPlace(viewOrgToAttachment);
|
|
143150
|
+
this._toSheet = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.Transform.createRefs(origin, matrix);
|
|
143151
|
+
this._fromSheet = (0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_12__.expectDefined)(this._toSheet.inverse());
|
|
143152
|
+
// If the attached view is a section drawing, it may itself have an attached spatial view with a clip.
|
|
143153
|
+
// The clip needs to be transformed into sheet space.
|
|
143154
|
+
if (view.isDrawingView())
|
|
143155
|
+
this._viewport.drawingToSheetTransform = this._toSheet;
|
|
143156
|
+
// ###TODO? If we also apply the attachment's clip to the attached view, we may get additional culling during tile selection.
|
|
143157
|
+
// However the attached view's frustum is already clipped by intersection with sheet view's frustum, and additional clipping planes
|
|
143158
|
+
// introduce additional computation, so possibly not worth it.
|
|
143159
|
+
// Transform the view's clip (if any) to sheet space
|
|
143160
|
+
let viewClip = view.viewFlags.clipVolume ? view.getViewClip()?.clone() : undefined;
|
|
143161
|
+
if (viewClip)
|
|
143162
|
+
viewClip.transformInPlace(this._toSheet);
|
|
143163
|
+
else
|
|
143164
|
+
viewClip = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.ClipVector.createEmpty();
|
|
143165
|
+
let sheetClip;
|
|
143166
|
+
if (undefined !== props.jsonProperties?.clip)
|
|
143167
|
+
sheetClip = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.ClipVector.fromJSON(props.jsonProperties?.clip);
|
|
143168
|
+
if (sheetClip && sheetClip.isValid) {
|
|
143169
|
+
// Clip to view attachment's clip. NB: clip is in sheet coordinate space.
|
|
143170
|
+
for (const clip of sheetClip.clips)
|
|
143171
|
+
viewClip.clips.push(clip);
|
|
143172
|
+
}
|
|
143173
|
+
else {
|
|
143174
|
+
// Clip to view attachment's bounding box
|
|
143175
|
+
viewClip.appendShape([
|
|
143176
|
+
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.Point3d.create(this._range.low.x, this._range.low.y),
|
|
143177
|
+
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.Point3d.create(this._range.high.x, this._range.low.y),
|
|
143178
|
+
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.Point3d.create(this._range.high.x, this._range.high.y),
|
|
143179
|
+
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.Point3d.create(this._range.low.x, this._range.high.y),
|
|
143180
|
+
]);
|
|
143181
|
+
}
|
|
143182
|
+
this._clipVolume = _IModelApp__WEBPACK_IMPORTED_MODULE_3__.IModelApp.renderSystem.createClipVolume(viewClip);
|
|
143183
|
+
// Save off the original frustum (potentially adjusted by viewport).
|
|
143184
|
+
this._viewport.setupFromView();
|
|
143185
|
+
this._viewport.viewingSpace.getFrustum(_CoordSystem__WEBPACK_IMPORTED_MODULE_1__.CoordSystem.World, true, this._originalFrustum);
|
|
143186
|
+
const applyHiddenLineSettings = true; // for debugging edge display, set to false...
|
|
143187
|
+
const style = view.displayStyle;
|
|
143188
|
+
if (style.is3d() && applyHiddenLineSettings)
|
|
143189
|
+
this._hiddenLineSettings = style.settings.hiddenLineSettings;
|
|
143190
|
+
}
|
|
143191
|
+
[Symbol.dispose]() {
|
|
143192
|
+
this._viewport[Symbol.dispose]();
|
|
143193
|
+
}
|
|
143194
|
+
discloseTileTrees(trees) {
|
|
143195
|
+
trees.disclose(this._viewport);
|
|
143196
|
+
}
|
|
143197
|
+
addToScene(context) {
|
|
143198
|
+
if (context.viewport.freezeScene)
|
|
143199
|
+
return;
|
|
143200
|
+
if (!context.viewport.view.viewsCategory(this._props.category))
|
|
143201
|
+
return;
|
|
143202
|
+
const wantBounds = context.viewport.wantViewAttachmentBoundaries;
|
|
143203
|
+
const wantClipShapes = context.viewport.wantViewAttachmentClipShapes;
|
|
143204
|
+
if (wantBounds || wantClipShapes) {
|
|
143205
|
+
const builder = context.createSceneGraphicBuilder();
|
|
143206
|
+
if (wantBounds) {
|
|
143207
|
+
builder.setSymbology(_itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.ColorDef.red, _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.ColorDef.red, 2);
|
|
143208
|
+
builder.addRangeBox(this._range);
|
|
143209
|
+
}
|
|
143210
|
+
if (wantClipShapes && this._clipVolume) {
|
|
143211
|
+
builder.setSymbology(_itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.ColorDef.blue, _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.ColorDef.blue, 2);
|
|
143212
|
+
for (const prim of this._clipVolume.clipVector.clips) {
|
|
143213
|
+
if (!(prim instanceof _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.ClipShape))
|
|
143214
|
+
continue; // ###TODO handle non-shape primitives, if any such ever encountered
|
|
143215
|
+
const pts = [];
|
|
143216
|
+
const tf = prim.transformFromClip;
|
|
143217
|
+
for (const pt of prim.polygon) {
|
|
143218
|
+
const tfPt = tf ? tf.multiplyPoint3d(pt) : pt;
|
|
143219
|
+
pts.push(new _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.Point2d(tfPt.x, tfPt.y));
|
|
143220
|
+
}
|
|
143221
|
+
builder.addLineString2d(pts, 0);
|
|
143222
|
+
}
|
|
143223
|
+
}
|
|
143224
|
+
// Put into a Batch so that we can see tooltip with attachment Id on mouseover.
|
|
143225
|
+
const batch = context.target.renderSystem.createBatch(builder.finish(), this.getDebugFeatureTable(), this._range);
|
|
143226
|
+
context.outputGraphic(batch);
|
|
143227
|
+
}
|
|
143228
|
+
if (!context.viewport.wantViewAttachments)
|
|
143229
|
+
return;
|
|
143230
|
+
// Pixel size used to compute size of ViewRect so that tiles of appropriate LOD are selected.
|
|
143231
|
+
const pixelSize = context.viewport.getPixelSizeAtPoint();
|
|
143232
|
+
if (0 === pixelSize)
|
|
143233
|
+
return;
|
|
143234
|
+
// Adjust attached view frustum based on intersection with sheet view frustum.
|
|
143235
|
+
const attachFrustum = this._originalFrustum.transformBy(this._toSheet);
|
|
143236
|
+
const attachFrustumRange = attachFrustum.toRange();
|
|
143237
|
+
const sheetFrustum = context.viewport.getWorldFrustum();
|
|
143238
|
+
const sheetFrustumRange = sheetFrustum.toRange();
|
|
143239
|
+
const intersect = attachFrustumRange.intersect(sheetFrustumRange);
|
|
143240
|
+
if (intersect.isNull)
|
|
143241
|
+
return;
|
|
143242
|
+
attachFrustum.initFromRange(intersect);
|
|
143243
|
+
attachFrustum.transformBy(this._fromSheet, attachFrustum);
|
|
143244
|
+
this._viewport.setupViewFromFrustum(attachFrustum);
|
|
143245
|
+
// Adjust view rect based on size of attachment on screen so that tiles of appropriate LOD are selected.
|
|
143246
|
+
const width = this._sizeInMeters.x * intersect.xLength() / attachFrustumRange.xLength();
|
|
143247
|
+
const height = this._sizeInMeters.y * intersect.yLength() / attachFrustumRange.yLength();
|
|
143248
|
+
this._viewRect.width = Math.max(1, Math.round(width / pixelSize));
|
|
143249
|
+
this._viewRect.height = Math.max(1, Math.round(height / pixelSize));
|
|
143250
|
+
this._viewport.setRect(this._viewRect);
|
|
143251
|
+
// Propagate settings from on-screen viewport.
|
|
143252
|
+
this._viewport.debugBoundingBoxes = context.viewport.debugBoundingBoxes;
|
|
143253
|
+
this._viewport.setTileSizeModifier(context.viewport.tileSizeModifier);
|
|
143254
|
+
// Create the scene.
|
|
143255
|
+
this._viewport.renderFrame();
|
|
143256
|
+
const scene = this.scene;
|
|
143257
|
+
if (!scene)
|
|
143258
|
+
return;
|
|
143259
|
+
// Extract scene graphics and insert into on-screen scene context.
|
|
143260
|
+
const options = {
|
|
143261
|
+
viewAttachmentId: this._props.id,
|
|
143262
|
+
clipVolume: this._clipVolume,
|
|
143263
|
+
hline: this._hiddenLineSettings,
|
|
143264
|
+
frustum: {
|
|
143265
|
+
is3d: this.view.is3d(),
|
|
143266
|
+
scale: this._scale,
|
|
143267
|
+
},
|
|
143268
|
+
};
|
|
143269
|
+
const outputGraphics = (source) => {
|
|
143270
|
+
if (0 === source.length)
|
|
143271
|
+
return;
|
|
143272
|
+
const graphics = new _render_GraphicBranch__WEBPACK_IMPORTED_MODULE_9__.GraphicBranch();
|
|
143273
|
+
graphics.setViewFlagOverrides(this._viewFlagOverrides);
|
|
143274
|
+
graphics.symbologyOverrides = this.symbologyOverrides;
|
|
143275
|
+
for (const graphic of source)
|
|
143276
|
+
graphics.entries.push(graphic);
|
|
143277
|
+
const branch = context.createGraphicBranch(graphics, this._toSheet, options);
|
|
143278
|
+
context.outputGraphic(branch);
|
|
143279
|
+
};
|
|
143280
|
+
outputGraphics(scene.foreground);
|
|
143281
|
+
context.withGraphicType(_tile_internal__WEBPACK_IMPORTED_MODULE_10__.TileGraphicType.BackgroundMap, () => outputGraphics(scene.background));
|
|
143282
|
+
context.withGraphicType(_tile_internal__WEBPACK_IMPORTED_MODULE_10__.TileGraphicType.Overlay, () => outputGraphics(scene.overlay));
|
|
143283
|
+
// Report tile statistics to sheet view's viewport.
|
|
143284
|
+
const tileAdmin = _IModelApp__WEBPACK_IMPORTED_MODULE_3__.IModelApp.tileAdmin;
|
|
143285
|
+
const selectedAndReady = tileAdmin.getTilesForUser(this._viewport);
|
|
143286
|
+
const requested = tileAdmin.getRequestsForUser(this._viewport);
|
|
143287
|
+
tileAdmin.addExternalTilesForUser(context.viewport, {
|
|
143288
|
+
requested: requested?.size ?? 0,
|
|
143289
|
+
selected: selectedAndReady?.selected.size ?? 0,
|
|
143290
|
+
ready: selectedAndReady?.ready.size ?? 0,
|
|
143291
|
+
});
|
|
143292
|
+
}
|
|
143293
|
+
getDebugFeatureTable() {
|
|
143294
|
+
if (this._debugFeatureTable)
|
|
143295
|
+
return this._debugFeatureTable;
|
|
143296
|
+
const featureTable = new _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.FeatureTable(1, this._sheetModelId);
|
|
143297
|
+
featureTable.insert(new _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.Feature(this._props.id));
|
|
143298
|
+
this._debugFeatureTable = _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.PackedFeatureTable.pack(featureTable);
|
|
143299
|
+
return this._debugFeatureTable;
|
|
143300
|
+
}
|
|
143301
|
+
get areAllTileTreesLoaded() {
|
|
143302
|
+
return this.view.areAllTileTreesLoaded;
|
|
143303
|
+
}
|
|
143304
|
+
collectStatistics(_stats) {
|
|
143305
|
+
// Handled by discloseTileTrees()
|
|
143306
|
+
}
|
|
143307
|
+
get ortho() {
|
|
143308
|
+
return {
|
|
143309
|
+
toSheet: this._toSheet,
|
|
143310
|
+
view: this.view,
|
|
143311
|
+
};
|
|
143312
|
+
}
|
|
143313
|
+
}
|
|
143314
|
+
function createRasterAttachmentViewport(_view, _rect, _attachment) {
|
|
143315
|
+
class RasterAttachmentViewport extends _Viewport__WEBPACK_IMPORTED_MODULE_4__.OffScreenViewport {
|
|
143316
|
+
_sceneContext;
|
|
143317
|
+
_isSceneReady = false;
|
|
143318
|
+
_attachment;
|
|
143319
|
+
constructor(view, rect, attachment) {
|
|
143320
|
+
super(_IModelApp__WEBPACK_IMPORTED_MODULE_3__.IModelApp.renderSystem.createOffscreenTarget(rect));
|
|
143321
|
+
this._attachment = attachment;
|
|
143322
|
+
this._isAspectRatioLocked = true;
|
|
143323
|
+
this.changeView(view);
|
|
143324
|
+
}
|
|
143325
|
+
createSceneContext() {
|
|
143326
|
+
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_12__.assert)(!this._isSceneReady);
|
|
143327
|
+
this._sceneContext = super.createSceneContext();
|
|
143328
|
+
return this._sceneContext;
|
|
143329
|
+
}
|
|
143330
|
+
renderFrame() {
|
|
143331
|
+
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_12__.assert)(!this._isSceneReady);
|
|
143332
|
+
this.clearSceneContext();
|
|
143333
|
+
super.renderFrame();
|
|
143334
|
+
if (undefined !== this._sceneContext) {
|
|
143335
|
+
this._isSceneReady = !this._sceneContext.hasMissingTiles && this.view.areAllTileTreesLoaded;
|
|
143336
|
+
if (this._isSceneReady)
|
|
143337
|
+
this._attachment.produceGraphics(this._sceneContext);
|
|
143338
|
+
this._sceneContext = undefined;
|
|
143339
|
+
}
|
|
143340
|
+
}
|
|
143341
|
+
clearSceneContext() {
|
|
143342
|
+
this._sceneContext = undefined;
|
|
143343
|
+
}
|
|
143344
|
+
addDecorations() {
|
|
143345
|
+
// ###TODO: skybox, ground plane, possibly grid. DecorateContext requires a ScreenViewport...
|
|
143346
|
+
}
|
|
143347
|
+
}
|
|
143348
|
+
return new RasterAttachmentViewport(_view, _rect, _attachment);
|
|
143349
|
+
}
|
|
143350
|
+
/** Draws a 3d view (usually with camera enabled) into a sheet view by producing an image of the view's contents offscreen. */
|
|
143351
|
+
class RasterAttachment {
|
|
143352
|
+
_props;
|
|
143353
|
+
_placement;
|
|
143354
|
+
_transform;
|
|
143355
|
+
zDepth;
|
|
143356
|
+
_viewport;
|
|
143357
|
+
_graphics;
|
|
143358
|
+
constructor(view, props, bgColor) {
|
|
143359
|
+
// Render to a 2048x2048 view rect. Scale in Y to preserve aspect ratio.
|
|
143360
|
+
const maxSize = 2048;
|
|
143361
|
+
const rect = new _common_ViewRect__WEBPACK_IMPORTED_MODULE_6__.ViewRect(0, 0, maxSize, maxSize);
|
|
143362
|
+
const height = maxSize * view.getAspectRatio() * view.getAspectRatioSkew();
|
|
143363
|
+
const skew = maxSize / height;
|
|
143364
|
+
view.setAspectRatioSkew(skew);
|
|
143365
|
+
if (true !== props.jsonProperties?.displayOptions?.preserveBackground) {
|
|
143366
|
+
// Make background color 100% transparent so that Viewport.readImageBuffer() will discard transparent pixels.
|
|
143367
|
+
view.displayStyle.backgroundColor = bgColor.withAlpha(0);
|
|
143368
|
+
}
|
|
143369
|
+
this._viewport = createRasterAttachmentViewport(view, rect, this);
|
|
143370
|
+
this._props = props;
|
|
143371
|
+
this._placement = _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.Placement2d.fromJSON(props.placement);
|
|
143372
|
+
this._transform = this._placement.transform;
|
|
143373
|
+
this.zDepth = _Frustum2d__WEBPACK_IMPORTED_MODULE_2__.Frustum2d.depthFromDisplayPriority(props.jsonProperties?.displayPriority ?? 0);
|
|
143374
|
+
}
|
|
143375
|
+
[Symbol.dispose]() {
|
|
143376
|
+
this._viewport?.[Symbol.dispose]();
|
|
143377
|
+
}
|
|
143378
|
+
get viewAttachmentProps() {
|
|
143379
|
+
return this._props;
|
|
143380
|
+
}
|
|
143381
|
+
get viewport() {
|
|
143382
|
+
return this._viewport;
|
|
143383
|
+
}
|
|
143384
|
+
get areAllTileTreesLoaded() {
|
|
143385
|
+
return this._viewport?.areAllTileTreesLoaded ?? true;
|
|
143386
|
+
}
|
|
143387
|
+
addToScene(context) {
|
|
143388
|
+
// ###TODO: check viewport.wantViewAttachmentClipShapes
|
|
143389
|
+
if (!context.viewport.view.viewsCategory(this._props.category))
|
|
143390
|
+
return;
|
|
143391
|
+
if (context.viewport.wantViewAttachmentBoundaries) {
|
|
143392
|
+
const builder = context.createSceneGraphicBuilder(this._transform);
|
|
143393
|
+
builder.setSymbology(_itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.ColorDef.red, _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.ColorDef.red, 2);
|
|
143394
|
+
builder.addRangeBox(_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.Range3d.createRange2d(this._placement.bbox));
|
|
143395
|
+
context.outputGraphic(builder.finish());
|
|
143396
|
+
}
|
|
143397
|
+
if (!context.viewport.wantViewAttachments)
|
|
143398
|
+
return;
|
|
143399
|
+
if (this._graphics) {
|
|
143400
|
+
context.outputGraphic(this._graphics);
|
|
143401
|
+
return;
|
|
143402
|
+
}
|
|
143403
|
+
if (undefined === this._viewport)
|
|
143404
|
+
return;
|
|
143405
|
+
this._viewport.debugBoundingBoxes = context.viewport.debugBoundingBoxes;
|
|
143406
|
+
this._viewport.setTileSizeModifier(context.viewport.tileSizeModifier);
|
|
143407
|
+
this._viewport.renderFrame();
|
|
143408
|
+
if (this._graphics)
|
|
143409
|
+
context.outputGraphic(this._graphics);
|
|
143410
|
+
}
|
|
143411
|
+
discloseTileTrees(trees) {
|
|
143412
|
+
if (this._viewport)
|
|
143413
|
+
trees.disclose(this._viewport);
|
|
143414
|
+
}
|
|
143415
|
+
produceGraphics(context) {
|
|
143416
|
+
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_12__.assert)(context.viewport === this._viewport);
|
|
143417
|
+
this._graphics = this.createGraphics(this._viewport);
|
|
143418
|
+
this._viewport = (0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_12__.dispose)(this._viewport);
|
|
143419
|
+
if (undefined !== this._graphics)
|
|
143420
|
+
context.outputGraphic(this._graphics);
|
|
143421
|
+
}
|
|
143422
|
+
createGraphics(vp) {
|
|
143423
|
+
// Create a texture from the contents of the view.
|
|
143424
|
+
const image = vp.readImageBuffer({ upsideDown: true });
|
|
143425
|
+
if (undefined === image)
|
|
143426
|
+
return undefined;
|
|
143427
|
+
const debugImage = false; // set to true to open a window displaying the captured image.
|
|
143428
|
+
if (debugImage) {
|
|
143429
|
+
const url = (0,_common_ImageUtil__WEBPACK_IMPORTED_MODULE_5__.imageBufferToPngDataUrl)(image, false);
|
|
143430
|
+
if (url)
|
|
143431
|
+
(0,_common_ImageUtil__WEBPACK_IMPORTED_MODULE_5__.openImageDataUrlInNewWindow)(url, "Attachment");
|
|
143432
|
+
}
|
|
143433
|
+
const texture = _IModelApp__WEBPACK_IMPORTED_MODULE_3__.IModelApp.renderSystem.createTexture({
|
|
143434
|
+
image: { source: image, transparency: _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.TextureTransparency.Opaque },
|
|
143435
|
+
});
|
|
143436
|
+
if (!texture)
|
|
143437
|
+
return undefined;
|
|
143438
|
+
// Create a material for the texture
|
|
143439
|
+
const graphicParams = new _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.GraphicParams();
|
|
143440
|
+
graphicParams.material = _IModelApp__WEBPACK_IMPORTED_MODULE_3__.IModelApp.renderSystem.createRenderMaterial({ textureMapping: { texture } });
|
|
143441
|
+
// Apply the texture to a rectangular polyface.
|
|
143442
|
+
const depth = this.zDepth;
|
|
143443
|
+
const east = this._placement.bbox.low.x;
|
|
143444
|
+
const west = this._placement.bbox.high.x;
|
|
143445
|
+
const north = this._placement.bbox.low.y;
|
|
143446
|
+
const south = this._placement.bbox.high.y;
|
|
143447
|
+
const corners = [
|
|
143448
|
+
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.Point3d.create(east, north, depth),
|
|
143449
|
+
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.Point3d.create(west, north, depth),
|
|
143450
|
+
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.Point3d.create(west, south, depth),
|
|
143451
|
+
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.Point3d.create(east, south, depth),
|
|
143452
|
+
];
|
|
143453
|
+
const params = [
|
|
143454
|
+
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.Point2d.create(0, 0),
|
|
143455
|
+
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.Point2d.create(1, 0),
|
|
143456
|
+
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.Point2d.create(1, 1),
|
|
143457
|
+
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.Point2d.create(0, 1),
|
|
143458
|
+
];
|
|
143459
|
+
const strokeOptions = new _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.StrokeOptions();
|
|
143460
|
+
strokeOptions.needParams = strokeOptions.shouldTriangulate = true;
|
|
143461
|
+
const polyfaceBuilder = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.PolyfaceBuilder.create(strokeOptions);
|
|
143462
|
+
polyfaceBuilder.addQuadFacet(corners, params);
|
|
143463
|
+
const polyface = polyfaceBuilder.claimPolyface();
|
|
143464
|
+
const graphicBuilder = _IModelApp__WEBPACK_IMPORTED_MODULE_3__.IModelApp.renderSystem.createGraphicBuilder(_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.Transform.createIdentity(), _common_render_GraphicType__WEBPACK_IMPORTED_MODULE_7__.GraphicType.Scene, vp, this._props.id);
|
|
143465
|
+
graphicBuilder.activateGraphicParams(graphicParams);
|
|
143466
|
+
graphicBuilder.addPolyface(polyface, false);
|
|
143467
|
+
const graphic = graphicBuilder.finish();
|
|
143468
|
+
// Wrap the polyface in a GraphicBranch.
|
|
143469
|
+
const branch = new _render_GraphicBranch__WEBPACK_IMPORTED_MODULE_9__.GraphicBranch(true);
|
|
143470
|
+
const vfOvrs = (0,_tile_ViewFlagOverrides__WEBPACK_IMPORTED_MODULE_14__.createDefaultViewFlagOverrides)({ clipVolume: true, shadows: false, lighting: false, thematic: false });
|
|
143471
|
+
// Disable transparency - background pixels are 100% transparent so they will be discarded anyway. Other pixels are 100% opaque.
|
|
143472
|
+
vfOvrs.transparency = false;
|
|
143473
|
+
branch.setViewFlagOverrides(vfOvrs);
|
|
143474
|
+
branch.symbologyOverrides = new _render_FeatureSymbology__WEBPACK_IMPORTED_MODULE_8__.FeatureSymbology.Overrides();
|
|
143475
|
+
branch.entries.push(graphic);
|
|
143476
|
+
// Apply the attachment's clip, if any.
|
|
143477
|
+
let clipVolume;
|
|
143478
|
+
if (this._props.jsonProperties?.clip) {
|
|
143479
|
+
const clipVector = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.ClipVector.fromJSON(this._props.jsonProperties?.clip);
|
|
143480
|
+
if (clipVector.isValid)
|
|
143481
|
+
clipVolume = _IModelApp__WEBPACK_IMPORTED_MODULE_3__.IModelApp.renderSystem.createClipVolume(clipVector);
|
|
143482
|
+
}
|
|
143483
|
+
return _IModelApp__WEBPACK_IMPORTED_MODULE_3__.IModelApp.renderSystem.createGraphicBranch(branch, this._transform, { clipVolume });
|
|
143484
|
+
}
|
|
143485
|
+
collectStatistics(stats) {
|
|
143486
|
+
if (this._graphics)
|
|
143487
|
+
this._graphics.collectStatistics(stats);
|
|
143488
|
+
}
|
|
143489
|
+
}
|
|
143490
|
+
|
|
143491
|
+
|
|
143249
143492
|
/***/ }),
|
|
143250
143493
|
|
|
143251
143494
|
/***/ "../../core/frontend/lib/esm/internal/cross-package.js":
|
|
@@ -159459,12 +159702,19 @@ class VertexShaderBuilder extends ShaderBuilder {
|
|
|
159459
159702
|
}
|
|
159460
159703
|
main.addline(" v_color = baseColor;");
|
|
159461
159704
|
}
|
|
159705
|
+
/*
|
|
159706
|
+
There is currently a driver glitch which is known to affect much of the Intel Ultra 7 family of chipsets when using Intel driver from some point after driver version 32.0.101.6078 (9/13/2024).
|
|
159707
|
+
|
|
159708
|
+
The graphics driver will glitch when discarding triangles using the vertex shader (setting all vertices to the same value) if gl_Position was not initialized to a valid position beforehand.
|
|
159709
|
+
|
|
159710
|
+
The workaround for this bug involves ensuring that gl_Position is initialized to a valid position before attempting a discard using a degenerate triangle.
|
|
159711
|
+
*/
|
|
159712
|
+
main.addline(" gl_Position = computePosition(rawPosition);");
|
|
159462
159713
|
const checkForDiscard = this.get(9 /* VertexShaderComponent.CheckForDiscard */);
|
|
159463
159714
|
if (undefined !== checkForDiscard) {
|
|
159464
159715
|
prelude.addFunction("bool checkForDiscard()", checkForDiscard);
|
|
159465
159716
|
main.add(_glsl_Vertex__WEBPACK_IMPORTED_MODULE_3__.vertexDiscard);
|
|
159466
159717
|
}
|
|
159467
|
-
main.addline(" gl_Position = computePosition(rawPosition);");
|
|
159468
159718
|
const finalizePos = this.get(13 /* VertexShaderComponent.FinalizePosition */);
|
|
159469
159719
|
if (undefined !== finalizePos) {
|
|
159470
159720
|
prelude.addFunction("vec4 finalizePosition(vec4 pos)", finalizePos);
|
|
@@ -338822,7 +339072,7 @@ class TestContext {
|
|
|
338822
339072
|
this.initializeRpcInterfaces({ title: this.settings.Backend.name, version: this.settings.Backend.version });
|
|
338823
339073
|
const iModelClient = new imodels_client_management_1.IModelsClient({ api: { baseUrl: `https://${process.env.IMJS_URL_PREFIX ?? ""}api.bentley.com/imodels` } });
|
|
338824
339074
|
await core_frontend_1.NoRenderApp.startup({
|
|
338825
|
-
applicationVersion: "5.3.
|
|
339075
|
+
applicationVersion: "5.3.2",
|
|
338826
339076
|
applicationId: this.settings.gprid,
|
|
338827
339077
|
authorizationClient: new frontend_1.TestFrontendAuthorizationClient(this.serviceAuthToken),
|
|
338828
339078
|
hubAccess: new imodels_access_frontend_1.FrontendIModelsAccess(iModelClient),
|
|
@@ -364095,7 +364345,7 @@ var loadLanguages = instance.loadLanguages;
|
|
|
364095
364345
|
/***/ ((module) => {
|
|
364096
364346
|
|
|
364097
364347
|
"use strict";
|
|
364098
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@itwin/core-frontend","version":"5.3.
|
|
364348
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@itwin/core-frontend","version":"5.3.2","description":"iTwin.js frontend components","main":"lib/cjs/core-frontend.js","module":"lib/esm/core-frontend.js","typings":"lib/cjs/core-frontend","license":"MIT","scripts":{"build":"npm run -s copy:public && npm run -s build:cjs && npm run -s build:esm && npm run -s webpackWorkers && npm run -s copy:workers && npm run -s copy:draco","build:cjs":"npm run -s copy:js:cjs && tsc 1>&2 --outDir lib/cjs","build:esm":"npm run -s copy:js:esm && tsc 1>&2 --module ES2022 --outDir lib/esm","clean":"rimraf -g lib .rush/temp/package-deps*.json","copy:public":"cpx \\"./src/public/**/*\\" ./lib/public","copy:js:cjs":"cpx \\"./src/**/*.js\\" ./lib/cjs","copy:js:esm":"cpx \\"./src/**/*.js\\" ./lib/esm","copy:workers":"cpx \\"./lib/workers/webpack/parse-imdl-worker.js\\" ./lib/public/scripts","copy:draco":"cpx \\"./node_modules/@loaders.gl/draco/dist/libs/*\\" ./lib/public/scripts","docs":"betools docs --json=../../generated-docs/core/core-frontend/file.json --tsIndexFile=./core-frontend.ts --onlyJson --excludes=webgl/**/*,**/map/*.d.ts,**/tile/*.d.ts,**/*-css.ts","extract-api":"betools extract-api --entry=core-frontend && npm run extract-extension-api","extract-extension-api":"eslint --no-inline-config -c extraction.eslint.config.js \\"./src/**/*.ts\\" 1>&2","lint":"eslint \\"./src/**/*.ts\\" 1>&2","lint-fix":"eslint --fix -f visualstudio \\"./src/**/*.ts\\" 1>&2","lint-deprecation":"eslint --fix -f visualstudio --no-inline-config -c ../../common/config/eslint/eslint.config.deprecation-policy.js \\"./src/**/*.ts\\"","pseudolocalize":"betools pseudolocalize --englishDir ./src/public/locales/en --out ./public/locales/en-PSEUDO","test":"npm run webpackTestWorker && vitest --run","cover":"npm run webpackTestWorker && vitest --run","webpackTests":"webpack --config ./src/test/utils/webpack.config.js 1>&2 && npm run -s webpackTestWorker","webpackTestWorker":"webpack --config ./src/test/worker/webpack.config.js 1>&2 && cpx \\"./lib/test/test-worker.js\\" ./lib/test","webpackWorkers":"webpack --config ./src/workers/ImdlParser/webpack.config.js 1>&2"},"repository":{"type":"git","url":"https://github.com/iTwin/itwinjs-core.git","directory":"core/frontend"},"keywords":["Bentley","BIM","iModel","digital-twin","iTwin"],"author":{"name":"Bentley Systems, Inc.","url":"http://www.bentley.com"},"peerDependencies":{"@itwin/appui-abstract":"workspace:*","@itwin/core-bentley":"workspace:*","@itwin/core-common":"workspace:*","@itwin/core-geometry":"workspace:*","@itwin/core-orbitgt":"workspace:*","@itwin/core-quantity":"workspace:*","@itwin/ecschema-metadata":"workspace:*","@itwin/ecschema-rpcinterface-common":"workspace:*"},"//devDependencies":["NOTE: All peerDependencies should also be listed as devDependencies since peerDependencies are not considered by npm install","NOTE: All tools used by scripts in this package must be listed as devDependencies"],"devDependencies":{"@itwin/appui-abstract":"workspace:*","@itwin/build-tools":"workspace:*","@itwin/core-bentley":"workspace:*","@itwin/core-common":"workspace:*","@itwin/core-geometry":"workspace:*","@itwin/core-orbitgt":"workspace:*","@itwin/core-quantity":"workspace:*","@itwin/ecschema-metadata":"workspace:*","@itwin/ecschema-rpcinterface-common":"workspace:*","@itwin/object-storage-core":"^3.0.4","@itwin/eslint-plugin":"5.2.2-dev.2","@types/chai-as-promised":"^7","@types/draco3d":"^1.4.10","@types/sinon":"^17.0.2","@vitest/browser":"^3.0.6","@vitest/coverage-v8":"^3.0.6","cpx2":"^8.0.0","eslint":"^9.31.0","glob":"^10.3.12","playwright":"~1.56.1","rimraf":"^6.0.1","sinon":"^17.0.2","source-map-loader":"^5.0.0","typescript":"~5.6.2","typemoq":"^2.1.0","vitest":"^3.0.6","vite-multiple-assets":"^1.3.1","vite-plugin-static-copy":"2.2.0","webpack":"^5.97.1"},"//dependencies":["NOTE: these dependencies should be only for things that DO NOT APPEAR IN THE API","NOTE: core-frontend should remain UI technology agnostic, so no react/angular dependencies are allowed"],"dependencies":{"@itwin/core-i18n":"workspace:*","@itwin/webgl-compatibility":"workspace:*","@loaders.gl/core":"^4.3.4","@loaders.gl/draco":"^4.3.4","fuse.js":"^3.3.0","wms-capabilities":"0.4.0"}}');
|
|
364099
364349
|
|
|
364100
364350
|
/***/ }),
|
|
364101
364351
|
|