@itwin/ecschema-rpcinterface-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 +951 -701
- 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 +15 -15
|
@@ -36300,7 +36300,10 @@ class MapImagerySettings {
|
|
|
36300
36300
|
}
|
|
36301
36301
|
/** @internal */
|
|
36302
36302
|
static createFromJSON(imageryJson, mapProps) {
|
|
36303
|
-
const
|
|
36303
|
+
const backgroundBase = imageryJson?.backgroundBase;
|
|
36304
|
+
const baseLayer = undefined !== backgroundBase ?
|
|
36305
|
+
BaseLayerSettings.fromJSON(backgroundBase) :
|
|
36306
|
+
_MapLayerSettings__WEBPACK_IMPORTED_MODULE_1__.BaseMapLayerSettings.fromBackgroundMapProps(mapProps ?? {});
|
|
36304
36307
|
return new MapImagerySettings(baseLayer, imageryJson?.backgroundLayers, imageryJson?.overlayLayers);
|
|
36305
36308
|
}
|
|
36306
36309
|
toJSON() {
|
|
@@ -82173,6 +82176,7 @@ class BriefcaseConnection extends _IModelConnection__WEBPACK_IMPORTED_MODULE_5__
|
|
|
82173
82176
|
this._modelsMonitor = new ModelChangeMonitor(this);
|
|
82174
82177
|
if (_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.OpenMode.ReadWrite === this._openMode)
|
|
82175
82178
|
this.txns.onAfterUndoRedo.addListener(async () => { await _IModelApp__WEBPACK_IMPORTED_MODULE_4__.IModelApp.toolAdmin.restartPrimitiveTool(); });
|
|
82179
|
+
this.categories.cache.attachToBriefcase(this);
|
|
82176
82180
|
}
|
|
82177
82181
|
/** Open a BriefcaseConnection to a [BriefcaseDb]($backend). */
|
|
82178
82182
|
static async openFile(briefcaseProps) {
|
|
@@ -93838,18 +93842,10 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
93838
93842
|
/* harmony import */ var _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @itwin/core-common */ "../../core/common/lib/esm/core-common.js");
|
|
93839
93843
|
/* harmony import */ var _CategorySelectorState__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./CategorySelectorState */ "../../core/frontend/lib/esm/CategorySelectorState.js");
|
|
93840
93844
|
/* harmony import */ var _DisplayStyleState__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./DisplayStyleState */ "../../core/frontend/lib/esm/DisplayStyleState.js");
|
|
93841
|
-
/* harmony import */ var
|
|
93842
|
-
/* harmony import */ var
|
|
93843
|
-
/* harmony import */ var
|
|
93844
|
-
/* harmony import */ var
|
|
93845
|
-
/* harmony import */ var _IModelApp__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./IModelApp */ "../../core/frontend/lib/esm/IModelApp.js");
|
|
93846
|
-
/* harmony import */ var _CoordSystem__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./CoordSystem */ "../../core/frontend/lib/esm/CoordSystem.js");
|
|
93847
|
-
/* harmony import */ var _Viewport__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Viewport */ "../../core/frontend/lib/esm/Viewport.js");
|
|
93848
|
-
/* harmony import */ var _ViewState__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ViewState */ "../../core/frontend/lib/esm/ViewState.js");
|
|
93849
|
-
/* harmony import */ var _tile_internal__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./tile/internal */ "../../core/frontend/lib/esm/tile/internal.js");
|
|
93850
|
-
/* harmony import */ var _common_ImageUtil__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./common/ImageUtil */ "../../core/frontend/lib/esm/common/ImageUtil.js");
|
|
93851
|
-
/* harmony import */ var _common_ViewRect__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./common/ViewRect */ "../../core/frontend/lib/esm/common/ViewRect.js");
|
|
93852
|
-
/* harmony import */ var _common_render_GraphicType__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./common/render/GraphicType */ "../../core/frontend/lib/esm/common/render/GraphicType.js");
|
|
93845
|
+
/* harmony import */ var _Frustum2d__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Frustum2d */ "../../core/frontend/lib/esm/Frustum2d.js");
|
|
93846
|
+
/* harmony import */ var _ViewState__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ViewState */ "../../core/frontend/lib/esm/ViewState.js");
|
|
93847
|
+
/* harmony import */ var _common_render_GraphicType__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./common/render/GraphicType */ "../../core/frontend/lib/esm/common/render/GraphicType.js");
|
|
93848
|
+
/* harmony import */ var _internal_SheetViewAttachments__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./internal/SheetViewAttachments */ "../../core/frontend/lib/esm/internal/SheetViewAttachments.js");
|
|
93853
93849
|
/*---------------------------------------------------------------------------------------------
|
|
93854
93850
|
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
93855
93851
|
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
@@ -93866,14 +93862,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
93866
93862
|
|
|
93867
93863
|
|
|
93868
93864
|
|
|
93869
|
-
|
|
93870
|
-
|
|
93871
|
-
|
|
93872
|
-
|
|
93873
|
-
|
|
93874
|
-
|
|
93875
|
-
|
|
93876
|
-
|
|
93877
93865
|
// cSpell:ignore ovrs
|
|
93878
93866
|
/** Describes the geometry and styling of a sheet border decoration.
|
|
93879
93867
|
* The sheet border decoration mimics a sheet of paper with a drop shadow.
|
|
@@ -93942,206 +93930,25 @@ class SheetBorder {
|
|
|
93942
93930
|
params.fillColor = fillColor;
|
|
93943
93931
|
params.gradient = this._gradient;
|
|
93944
93932
|
builder.activateGraphicParams(params);
|
|
93945
|
-
builder.addShape2d(this._shadow,
|
|
93933
|
+
builder.addShape2d(this._shadow, _Frustum2d__WEBPACK_IMPORTED_MODULE_5__.Frustum2d.minimumZDistance);
|
|
93946
93934
|
builder.setSymbology(lineColor, fillColor, 2);
|
|
93947
93935
|
builder.addLineString2d(this._rect, 0);
|
|
93948
93936
|
}
|
|
93949
93937
|
}
|
|
93950
|
-
/** The information required to instantiate an ViewAttachments object to draw ViewAttachments into a sheet. The list of view attachment Ids is
|
|
93951
|
-
* supplied to SheetViewState via the constructor. The corresponding ViewAttachmentProps for each attachment are obtained asynchronously in
|
|
93952
|
-
* SheetViewState.load(). The Attachments object is created in SheetViewState.attachToViewport and disposed of in SheetViewState.detachFromViewport.
|
|
93953
|
-
*/
|
|
93954
|
-
class ViewAttachmentsInfo {
|
|
93955
|
-
_attachments;
|
|
93956
|
-
get attachments() { return this._attachments; }
|
|
93957
|
-
constructor(attachments) {
|
|
93958
|
-
this._attachments = attachments;
|
|
93959
|
-
}
|
|
93960
|
-
get isLoaded() {
|
|
93961
|
-
return 0 === this._attachments.length || "string" !== typeof this._attachments[0];
|
|
93962
|
-
}
|
|
93963
|
-
get viewAttachmentProps() {
|
|
93964
|
-
return this.isLoaded ? this._props : [];
|
|
93965
|
-
}
|
|
93966
|
-
get _props() {
|
|
93967
|
-
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.assert)(this.isLoaded);
|
|
93968
|
-
return this._attachments;
|
|
93969
|
-
}
|
|
93970
|
-
get _ids() {
|
|
93971
|
-
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.assert)(!this.isLoaded);
|
|
93972
|
-
return this._attachments;
|
|
93973
|
-
}
|
|
93974
|
-
static fromJSON(ids = []) {
|
|
93975
|
-
return new ViewAttachmentsInfo(ids);
|
|
93976
|
-
}
|
|
93977
|
-
toJSON() {
|
|
93978
|
-
return this.isLoaded ? this._props.map((x) => (0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.expectDefined)(x.id)) : [...this._ids];
|
|
93979
|
-
}
|
|
93980
|
-
clone(iModel) {
|
|
93981
|
-
let attachments = this._attachments;
|
|
93982
|
-
if (this.isLoaded) {
|
|
93983
|
-
// Need to clone the attached ViewStates.
|
|
93984
|
-
attachments = attachments.map((attachment) => {
|
|
93985
|
-
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.assert)(typeof attachment !== "string");
|
|
93986
|
-
return {
|
|
93987
|
-
...attachment,
|
|
93988
|
-
attachedView: attachment.attachedView.clone(iModel),
|
|
93989
|
-
};
|
|
93990
|
-
});
|
|
93991
|
-
}
|
|
93992
|
-
return new ViewAttachmentsInfo(attachments);
|
|
93993
|
-
}
|
|
93994
|
-
preload(options) {
|
|
93995
|
-
if (this.isLoaded)
|
|
93996
|
-
return;
|
|
93997
|
-
options.sheetViewAttachmentIds = _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.CompressedId64Set.sortAndCompress(this._ids);
|
|
93998
|
-
options.viewStateLoadProps = {
|
|
93999
|
-
displayStyle: {
|
|
94000
|
-
omitScheduleScriptElementIds: !_IModelApp__WEBPACK_IMPORTED_MODULE_9__.IModelApp.tileAdmin.enableFrontendScheduleScripts,
|
|
94001
|
-
compressExcludedElementIds: true,
|
|
94002
|
-
},
|
|
94003
|
-
};
|
|
94004
|
-
}
|
|
94005
|
-
async postload(options, iModel) {
|
|
94006
|
-
if (options.sheetViewViews === undefined)
|
|
94007
|
-
return;
|
|
94008
|
-
if (options.sheetViewAttachmentProps === undefined)
|
|
94009
|
-
return;
|
|
94010
|
-
const viewStateProps = options.sheetViewViews; // This is viewstateProps, need to turn this into ViewState
|
|
94011
|
-
const promises = [];
|
|
94012
|
-
for (const viewProps of viewStateProps) {
|
|
94013
|
-
const loadView = async () => {
|
|
94014
|
-
try {
|
|
94015
|
-
if (viewProps === undefined)
|
|
94016
|
-
return undefined;
|
|
94017
|
-
const view = await iModel.views.convertViewStatePropsToViewState(viewProps);
|
|
94018
|
-
return view;
|
|
94019
|
-
}
|
|
94020
|
-
catch {
|
|
94021
|
-
return undefined;
|
|
94022
|
-
}
|
|
94023
|
-
};
|
|
94024
|
-
promises.push(loadView());
|
|
94025
|
-
}
|
|
94026
|
-
const views = await Promise.all(promises);
|
|
94027
|
-
const attachmentProps = options.sheetViewAttachmentProps;
|
|
94028
|
-
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.assert)(views.length === attachmentProps.length);
|
|
94029
|
-
const attachments = [];
|
|
94030
|
-
for (let i = 0; i < views.length; i++) {
|
|
94031
|
-
const view = views[i];
|
|
94032
|
-
if (view && !(view instanceof SheetViewState)) {
|
|
94033
|
-
const props = attachmentProps[i];
|
|
94034
|
-
props.attachedView = view;
|
|
94035
|
-
attachments.push(props);
|
|
94036
|
-
}
|
|
94037
|
-
}
|
|
94038
|
-
this._attachments = attachments;
|
|
94039
|
-
}
|
|
94040
|
-
async load(iModel) {
|
|
94041
|
-
if (this.isLoaded)
|
|
94042
|
-
return;
|
|
94043
|
-
const attachmentProps = await iModel.elements.getProps(this._ids);
|
|
94044
|
-
const promises = [];
|
|
94045
|
-
for (const attachment of attachmentProps) {
|
|
94046
|
-
const loadView = async () => {
|
|
94047
|
-
try {
|
|
94048
|
-
const view = await iModel.views.load(attachment.view.id);
|
|
94049
|
-
return view;
|
|
94050
|
-
}
|
|
94051
|
-
catch {
|
|
94052
|
-
return undefined;
|
|
94053
|
-
}
|
|
94054
|
-
};
|
|
94055
|
-
promises.push(loadView());
|
|
94056
|
-
}
|
|
94057
|
-
const views = await Promise.all(promises);
|
|
94058
|
-
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.assert)(views.length === attachmentProps.length);
|
|
94059
|
-
const attachments = [];
|
|
94060
|
-
for (let i = 0; i < views.length; i++) {
|
|
94061
|
-
const view = views[i];
|
|
94062
|
-
if (view && !(view instanceof SheetViewState)) {
|
|
94063
|
-
const props = attachmentProps[i];
|
|
94064
|
-
props.attachedView = view;
|
|
94065
|
-
attachments.push(props);
|
|
94066
|
-
}
|
|
94067
|
-
}
|
|
94068
|
-
this._attachments = attachments;
|
|
94069
|
-
}
|
|
94070
|
-
createAttachments(sheetView) {
|
|
94071
|
-
return this.isLoaded ? new ViewAttachments(this._props, sheetView) : undefined;
|
|
94072
|
-
}
|
|
94073
|
-
}
|
|
94074
|
-
/** The set of view attachments to be displayed in a Viewport via a SheetViewState. Allocated when the view becomes attached to a Viewport;
|
|
94075
|
-
* disposed of when it becomes detached from the viewport.
|
|
94076
|
-
*/
|
|
94077
|
-
class ViewAttachments {
|
|
94078
|
-
_attachments = [];
|
|
94079
|
-
maxDepth = _Frustum2d__WEBPACK_IMPORTED_MODULE_6__.Frustum2d.minimumZDistance;
|
|
94080
|
-
constructor(infos, sheetView) {
|
|
94081
|
-
for (const info of infos) {
|
|
94082
|
-
const drawAsRaster = info.jsonProperties?.displayOptions?.drawAsRaster || (info.attachedView.is3d() && info.attachedView.isCameraOn);
|
|
94083
|
-
const ctor = drawAsRaster ? RasterAttachment : OrthographicAttachment;
|
|
94084
|
-
const attachment = new ctor(info.attachedView, info, sheetView);
|
|
94085
|
-
this._attachments.push(attachment);
|
|
94086
|
-
this.maxDepth = Math.max(this.maxDepth, attachment.zDepth);
|
|
94087
|
-
}
|
|
94088
|
-
}
|
|
94089
|
-
[Symbol.dispose]() {
|
|
94090
|
-
for (const attachment of this._attachments)
|
|
94091
|
-
attachment[Symbol.dispose]();
|
|
94092
|
-
this._attachments.length = 0;
|
|
94093
|
-
}
|
|
94094
|
-
[Symbol.iterator]() {
|
|
94095
|
-
return this._attachments[Symbol.iterator]();
|
|
94096
|
-
}
|
|
94097
|
-
/** For tests. */
|
|
94098
|
-
get attachments() {
|
|
94099
|
-
return this._attachments;
|
|
94100
|
-
}
|
|
94101
|
-
get isEmpty() {
|
|
94102
|
-
return 0 === this._attachments.length;
|
|
94103
|
-
}
|
|
94104
|
-
areAllTileTreesLoaded(displayedExtents) {
|
|
94105
|
-
return this._attachments.every((x) => {
|
|
94106
|
-
const placement = _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.Placement2d.fromJSON(x.viewAttachmentProps.placement);
|
|
94107
|
-
const attachmentRange = placement.calculateRange();
|
|
94108
|
-
if (!attachmentRange.intersectsRangeXY(displayedExtents))
|
|
94109
|
-
return true;
|
|
94110
|
-
return x.areAllTileTreesLoaded;
|
|
94111
|
-
});
|
|
94112
|
-
}
|
|
94113
|
-
/** Strictly for testing purposes */
|
|
94114
|
-
areAllAttachmentsLoaded() {
|
|
94115
|
-
return this._attachments.every((attachment) => attachment.areAllTileTreesLoaded);
|
|
94116
|
-
}
|
|
94117
|
-
discloseTileTrees(trees) {
|
|
94118
|
-
for (const attachment of this._attachments)
|
|
94119
|
-
trees.disclose(attachment);
|
|
94120
|
-
}
|
|
94121
|
-
collectStatistics(stats) {
|
|
94122
|
-
for (const attachment of this._attachments)
|
|
94123
|
-
attachment.collectStatistics(stats);
|
|
94124
|
-
}
|
|
94125
|
-
addToScene(context) {
|
|
94126
|
-
for (const attachment of this._attachments)
|
|
94127
|
-
attachment.addToScene(context);
|
|
94128
|
-
}
|
|
94129
|
-
findById(attachmentId) {
|
|
94130
|
-
return this._attachments.find((attachment) => attachment.viewAttachmentProps.id === attachmentId);
|
|
94131
|
-
}
|
|
94132
|
-
}
|
|
94133
93938
|
/** A view of a [SheetModel]($backend).
|
|
94134
93939
|
* @public
|
|
94135
93940
|
* @extensions
|
|
94136
93941
|
*/
|
|
94137
|
-
class SheetViewState extends
|
|
93942
|
+
class SheetViewState extends _ViewState__WEBPACK_IMPORTED_MODULE_6__.ViewState2d {
|
|
94138
93943
|
/** The width and height of the sheet in world coordinates. */
|
|
94139
93944
|
sheetSize;
|
|
94140
|
-
|
|
94141
|
-
_attachments;
|
|
93945
|
+
_viewAttachments;
|
|
94142
93946
|
_viewedExtents;
|
|
93947
|
+
_onViewAttachmentsReloaded = () => undefined;
|
|
93948
|
+
/** Strictly for tests. */
|
|
93949
|
+
onViewAttachmentsReloaded = new _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.BeEvent();
|
|
94143
93950
|
get attachmentIds() {
|
|
94144
|
-
return this.
|
|
93951
|
+
return this._viewAttachments.attachmentIds;
|
|
94145
93952
|
}
|
|
94146
93953
|
static get className() { return "SheetViewDefinition"; }
|
|
94147
93954
|
static createFromProps(viewStateData, iModel) {
|
|
@@ -94152,7 +93959,7 @@ class SheetViewState extends _ViewState__WEBPACK_IMPORTED_MODULE_12__.ViewState2
|
|
|
94152
93959
|
}
|
|
94153
93960
|
toProps() {
|
|
94154
93961
|
const props = super.toProps();
|
|
94155
|
-
props.sheetAttachments = this.
|
|
93962
|
+
props.sheetAttachments = [...this.attachmentIds];
|
|
94156
93963
|
// For sheetProps all that is actually used is the size, so just null out everything else.
|
|
94157
93964
|
const codeProps = { spec: "", scope: "", value: "" };
|
|
94158
93965
|
props.sheetProps = {
|
|
@@ -94167,20 +93974,15 @@ class SheetViewState extends _ViewState__WEBPACK_IMPORTED_MODULE_12__.ViewState2
|
|
|
94167
93974
|
}
|
|
94168
93975
|
/** Strictly for testing. @internal */
|
|
94169
93976
|
get viewAttachmentProps() {
|
|
94170
|
-
return this.
|
|
94171
|
-
return {
|
|
94172
|
-
...x,
|
|
94173
|
-
attachedView: undefined,
|
|
94174
|
-
};
|
|
94175
|
-
});
|
|
93977
|
+
return this._viewAttachments.attachmentProps;
|
|
94176
93978
|
}
|
|
94177
93979
|
/** Strictly for testing. @internal */
|
|
94178
93980
|
get viewAttachmentInfos() {
|
|
94179
|
-
return this.
|
|
93981
|
+
return this._viewAttachments.attachmentInfos;
|
|
94180
93982
|
}
|
|
94181
93983
|
/** Strictly for testing. @internal */
|
|
94182
93984
|
get attachments() {
|
|
94183
|
-
return this.
|
|
93985
|
+
return this._viewAttachments.attachments;
|
|
94184
93986
|
}
|
|
94185
93987
|
isDrawingView() { return false; }
|
|
94186
93988
|
isSheetView() { return true; }
|
|
@@ -94189,41 +93991,53 @@ class SheetViewState extends _ViewState__WEBPACK_IMPORTED_MODULE_12__.ViewState2
|
|
|
94189
93991
|
if (categories instanceof SheetViewState) {
|
|
94190
93992
|
// we are coming from clone...
|
|
94191
93993
|
this.sheetSize = categories.sheetSize.clone();
|
|
94192
|
-
this.
|
|
93994
|
+
this._viewAttachments = categories._viewAttachments.clone(iModel);
|
|
94193
93995
|
this._viewedExtents = categories._viewedExtents.clone();
|
|
94194
93996
|
}
|
|
94195
93997
|
else {
|
|
94196
93998
|
this.sheetSize = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Point2d.create(sheetProps.width, sheetProps.height);
|
|
94197
|
-
this.
|
|
93999
|
+
this._viewAttachments = _internal_SheetViewAttachments__WEBPACK_IMPORTED_MODULE_8__.SheetViewAttachments.create(attachments);
|
|
94198
94000
|
const extents = new _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Range3d(0, 0, 0, this.sheetSize.x, this.sheetSize.y, 0);
|
|
94199
94001
|
const margin = 1.1;
|
|
94200
94002
|
extents.scaleAboutCenterInPlace(margin);
|
|
94201
94003
|
this._viewedExtents = extents;
|
|
94202
94004
|
}
|
|
94005
|
+
if (iModel.isBriefcaseConnection()) {
|
|
94006
|
+
iModel.txns.onElementsChanged.addListener(async (changes) => {
|
|
94007
|
+
let reload = false;
|
|
94008
|
+
for (const change of changes.filter({ includeMetadata: (meta) => meta.is("BisCore:ViewAttachment") })) {
|
|
94009
|
+
if (change.type === "inserted" || this._viewAttachments.attachmentIds.includes(change.id)) {
|
|
94010
|
+
reload = true;
|
|
94011
|
+
break;
|
|
94012
|
+
}
|
|
94013
|
+
}
|
|
94014
|
+
if (reload) {
|
|
94015
|
+
await this._viewAttachments.reload(this.baseModelId, iModel);
|
|
94016
|
+
this._onViewAttachmentsReloaded();
|
|
94017
|
+
this.onViewAttachmentsReloaded.raiseEvent();
|
|
94018
|
+
}
|
|
94019
|
+
});
|
|
94020
|
+
}
|
|
94203
94021
|
}
|
|
94204
94022
|
getOrigin() {
|
|
94205
94023
|
const origin = super.getOrigin();
|
|
94206
|
-
|
|
94207
|
-
origin.z = -this._attachments.maxDepth;
|
|
94024
|
+
origin.z = -this._viewAttachments.maxDepth;
|
|
94208
94025
|
return origin;
|
|
94209
94026
|
}
|
|
94210
94027
|
getExtents() {
|
|
94211
94028
|
const extents = super.getExtents();
|
|
94212
|
-
|
|
94213
|
-
extents.z = this._attachments.maxDepth + _Frustum2d__WEBPACK_IMPORTED_MODULE_6__.Frustum2d.minimumZDistance;
|
|
94029
|
+
extents.z = this._viewAttachments.maxDepth + _Frustum2d__WEBPACK_IMPORTED_MODULE_5__.Frustum2d.minimumZDistance;
|
|
94214
94030
|
return extents;
|
|
94215
94031
|
}
|
|
94216
94032
|
/** Overrides [[ViewState.discloseTileTrees]] to include tile trees associated with [ViewAttachment]($backend)s displayed on this sheet. */
|
|
94217
94033
|
discloseTileTrees(trees) {
|
|
94218
94034
|
super.discloseTileTrees(trees);
|
|
94219
|
-
|
|
94220
|
-
trees.disclose(this._attachments);
|
|
94035
|
+
trees.disclose(this._viewAttachments);
|
|
94221
94036
|
}
|
|
94222
94037
|
/** @internal */
|
|
94223
94038
|
collectNonTileTreeStatistics(stats) {
|
|
94224
94039
|
super.collectNonTileTreeStatistics(stats);
|
|
94225
|
-
|
|
94226
|
-
this._attachments.collectStatistics(stats);
|
|
94040
|
+
this._viewAttachments.collectStatistics(stats);
|
|
94227
94041
|
}
|
|
94228
94042
|
get defaultExtentLimits() {
|
|
94229
94043
|
return { min: _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Constant.oneMillimeter, max: this.sheetSize.magnitude() * 10 };
|
|
@@ -94234,36 +94048,23 @@ class SheetViewState extends _ViewState__WEBPACK_IMPORTED_MODULE_12__.ViewState2
|
|
|
94234
94048
|
/** @internal */
|
|
94235
94049
|
preload(hydrateRequest) {
|
|
94236
94050
|
super.preload(hydrateRequest);
|
|
94237
|
-
this.
|
|
94051
|
+
this._viewAttachments.preload(hydrateRequest);
|
|
94238
94052
|
}
|
|
94239
94053
|
/** @internal */
|
|
94240
94054
|
async postload(hydrateResponse) {
|
|
94241
94055
|
const promises = [];
|
|
94242
94056
|
promises.push(super.postload(hydrateResponse));
|
|
94243
|
-
promises.push(this.
|
|
94057
|
+
promises.push(this._viewAttachments.postload(hydrateResponse, this.iModel));
|
|
94244
94058
|
await Promise.all(promises);
|
|
94245
94059
|
}
|
|
94246
94060
|
/** @internal */
|
|
94247
94061
|
createScene(context) {
|
|
94248
94062
|
super.createScene(context);
|
|
94249
|
-
|
|
94250
|
-
this._attachments.addToScene(context);
|
|
94063
|
+
this._viewAttachments.addToScene(context);
|
|
94251
94064
|
}
|
|
94252
94065
|
/** @internal */
|
|
94253
94066
|
get secondaryViewports() {
|
|
94254
|
-
|
|
94255
|
-
return super.secondaryViewports;
|
|
94256
|
-
const attachments = this._attachments;
|
|
94257
|
-
function* iterator() {
|
|
94258
|
-
for (const attachment of attachments) {
|
|
94259
|
-
const vp = attachment.viewport;
|
|
94260
|
-
if (vp)
|
|
94261
|
-
yield vp;
|
|
94262
|
-
}
|
|
94263
|
-
}
|
|
94264
|
-
return {
|
|
94265
|
-
[Symbol.iterator]: () => iterator(),
|
|
94266
|
-
};
|
|
94067
|
+
return this._viewAttachments.getSecondaryViewports();
|
|
94267
94068
|
}
|
|
94268
94069
|
/** @internal */
|
|
94269
94070
|
async queryAttachmentIds() {
|
|
@@ -94276,39 +94077,43 @@ class SheetViewState extends _ViewState__WEBPACK_IMPORTED_MODULE_12__.ViewState2
|
|
|
94276
94077
|
async changeViewedModel(modelId) {
|
|
94277
94078
|
await super.changeViewedModel(modelId);
|
|
94278
94079
|
const attachmentIds = await this.queryAttachmentIds();
|
|
94279
|
-
this.
|
|
94280
|
-
|
|
94080
|
+
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.dispose)(this._viewAttachments);
|
|
94081
|
+
this._viewAttachments = _internal_SheetViewAttachments__WEBPACK_IMPORTED_MODULE_8__.SheetViewAttachments.create(attachmentIds);
|
|
94281
94082
|
}
|
|
94282
94083
|
/** See [[ViewState.attachToViewport]]. */
|
|
94283
94084
|
attachToViewport(args) {
|
|
94284
94085
|
super.attachToViewport(args);
|
|
94285
|
-
|
|
94286
|
-
|
|
94086
|
+
this._viewAttachments.attachToViewport({
|
|
94087
|
+
backgroundColor: this.displayStyle.backgroundColor,
|
|
94088
|
+
sheetModelId: this.baseModelId,
|
|
94089
|
+
});
|
|
94090
|
+
this._onViewAttachmentsReloaded = () => args.invalidateController();
|
|
94287
94091
|
}
|
|
94288
94092
|
/** See [[ViewState.detachFromViewport]]. */
|
|
94289
94093
|
detachFromViewport() {
|
|
94290
94094
|
super.detachFromViewport();
|
|
94291
|
-
this.
|
|
94095
|
+
this._viewAttachments.detachFromViewport();
|
|
94096
|
+
this._onViewAttachmentsReloaded = () => undefined;
|
|
94292
94097
|
}
|
|
94293
94098
|
get areAllTileTreesLoaded() {
|
|
94099
|
+
if (!super.areAllTileTreesLoaded) {
|
|
94100
|
+
return false;
|
|
94101
|
+
}
|
|
94294
94102
|
let displayedExtents = this._viewedExtents;
|
|
94295
94103
|
const frustum = this.calculateFrustum();
|
|
94296
94104
|
if (frustum) {
|
|
94297
94105
|
displayedExtents = frustum.toRange();
|
|
94298
94106
|
}
|
|
94299
|
-
return
|
|
94107
|
+
return this._viewAttachments.areAllTileTreesLoaded(displayedExtents);
|
|
94300
94108
|
}
|
|
94301
94109
|
/** @internal Strictly for testing */
|
|
94302
94110
|
areAllAttachmentsLoaded() {
|
|
94303
|
-
|
|
94304
|
-
return this._attachments.areAllAttachmentsLoaded();
|
|
94305
|
-
}
|
|
94306
|
-
return true;
|
|
94111
|
+
return this._viewAttachments.areAllAttachmentsLoaded();
|
|
94307
94112
|
}
|
|
94308
94113
|
/** Create a sheet border decoration graphic. */
|
|
94309
94114
|
createBorder(width, height, context) {
|
|
94310
94115
|
const border = SheetBorder.create(width, height, context);
|
|
94311
|
-
const builder = context.createGraphicBuilder(
|
|
94116
|
+
const builder = context.createGraphicBuilder(_common_render_GraphicType__WEBPACK_IMPORTED_MODULE_7__.GraphicType.ViewBackground);
|
|
94312
94117
|
border.addToBuilder(builder);
|
|
94313
94118
|
return builder.finish();
|
|
94314
94119
|
}
|
|
@@ -94328,453 +94133,13 @@ class SheetViewState extends _ViewState__WEBPACK_IMPORTED_MODULE_12__.ViewState2
|
|
|
94328
94133
|
}
|
|
94329
94134
|
/** @internal */
|
|
94330
94135
|
getAttachmentViewport(args) {
|
|
94331
|
-
|
|
94332
|
-
if (!attachment) {
|
|
94333
|
-
return undefined;
|
|
94334
|
-
}
|
|
94335
|
-
return args.inSectionDrawingAttachment ? attachment.viewport?.view.getAttachmentViewport({ inSectionDrawingAttachment: true }) : attachment.viewport;
|
|
94136
|
+
return this._viewAttachments.getAttachmentViewport(args);
|
|
94336
94137
|
}
|
|
94337
94138
|
/** @beta */
|
|
94338
94139
|
computeDisplayTransform(args) {
|
|
94339
94140
|
// ###TODO we're currently ignoring model and element Id in args, assuming irrelevant for sheets.
|
|
94340
94141
|
// Should probably call super or have super call us.
|
|
94341
|
-
|
|
94342
|
-
if (!attachment || !(attachment instanceof OrthographicAttachment)) {
|
|
94343
|
-
return undefined;
|
|
94344
|
-
}
|
|
94345
|
-
const sheetTransform = attachment.toSheet;
|
|
94346
|
-
const sectionTransform = args.inSectionDrawingAttachment ? attachment.view.computeDisplayTransform(args) : undefined;
|
|
94347
|
-
if (!sectionTransform) {
|
|
94348
|
-
return sheetTransform.clone(args.output);
|
|
94349
|
-
}
|
|
94350
|
-
return sheetTransform.multiplyTransformTransform(sectionTransform, args.output);
|
|
94351
|
-
}
|
|
94352
|
-
}
|
|
94353
|
-
/** A mostly no-op RenderTarget for an Attachment.
|
|
94354
|
-
* its Scene and symbology overrides.
|
|
94355
|
-
*/
|
|
94356
|
-
class AttachmentTarget extends _internal_render_MockRender__WEBPACK_IMPORTED_MODULE_7__.MockRender.OffScreenTarget {
|
|
94357
|
-
_attachment;
|
|
94358
|
-
constructor(attachment) {
|
|
94359
|
-
// The dimensions don't matter - we're not drawing anything.
|
|
94360
|
-
const rect = new _common_ViewRect__WEBPACK_IMPORTED_MODULE_15__.ViewRect(1, 1);
|
|
94361
|
-
super(_IModelApp__WEBPACK_IMPORTED_MODULE_9__.IModelApp.renderSystem, rect);
|
|
94362
|
-
this._attachment = attachment;
|
|
94363
|
-
}
|
|
94364
|
-
changeScene(scene) {
|
|
94365
|
-
this._attachment.scene = scene;
|
|
94366
|
-
}
|
|
94367
|
-
overrideFeatureSymbology(ovrs) {
|
|
94368
|
-
this._attachment.symbologyOverrides = ovrs;
|
|
94369
|
-
}
|
|
94370
|
-
}
|
|
94371
|
-
/** Draws the contents a 2d or orthographic 3d view directly into a sheet view.
|
|
94372
|
-
* We select tiles for the view in the context of a light-weight offscreen viewport with a no-op RenderTarget, then
|
|
94373
|
-
* collect the resultant graphics and add them to the sheet view's scene.
|
|
94374
|
-
*/
|
|
94375
|
-
class OrthographicAttachment {
|
|
94376
|
-
_viewport;
|
|
94377
|
-
_props;
|
|
94378
|
-
_sheetModelId;
|
|
94379
|
-
_viewFlagOverrides;
|
|
94380
|
-
_toSheet;
|
|
94381
|
-
_fromSheet;
|
|
94382
|
-
_sizeInMeters;
|
|
94383
|
-
_range;
|
|
94384
|
-
_viewRect = new _common_ViewRect__WEBPACK_IMPORTED_MODULE_15__.ViewRect(0, 0, 1, 1);
|
|
94385
|
-
_originalFrustum = new _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.Frustum();
|
|
94386
|
-
_clipVolume;
|
|
94387
|
-
_hiddenLineSettings;
|
|
94388
|
-
_scale;
|
|
94389
|
-
_debugFeatureTable;
|
|
94390
|
-
scene;
|
|
94391
|
-
symbologyOverrides;
|
|
94392
|
-
zDepth;
|
|
94393
|
-
get view() {
|
|
94394
|
-
return this._viewport.view;
|
|
94395
|
-
}
|
|
94396
|
-
get viewAttachmentProps() {
|
|
94397
|
-
return this._props;
|
|
94398
|
-
}
|
|
94399
|
-
get viewport() {
|
|
94400
|
-
return this._viewport;
|
|
94401
|
-
}
|
|
94402
|
-
constructor(view, props, sheetView) {
|
|
94403
|
-
this.symbologyOverrides = new _render_FeatureSymbology__WEBPACK_IMPORTED_MODULE_8__.FeatureSymbology.Overrides(view);
|
|
94404
|
-
const target = new AttachmentTarget(this);
|
|
94405
|
-
this._viewport = _Viewport__WEBPACK_IMPORTED_MODULE_11__.OffScreenViewport.createViewport(view, target, true);
|
|
94406
|
-
this._props = props;
|
|
94407
|
-
this._sheetModelId = sheetView.baseModelId;
|
|
94408
|
-
const applyClip = true; // set to false for debugging
|
|
94409
|
-
this._viewFlagOverrides = {
|
|
94410
|
-
...view.viewFlags,
|
|
94411
|
-
clipVolume: applyClip,
|
|
94412
|
-
lighting: false,
|
|
94413
|
-
shadows: false,
|
|
94414
|
-
};
|
|
94415
|
-
const placement = _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.Placement2d.fromJSON(props.placement);
|
|
94416
|
-
const range = placement.calculateRange();
|
|
94417
|
-
this._range = range;
|
|
94418
|
-
this._sizeInMeters = new _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Point2d(range.xLength(), range.yLength());
|
|
94419
|
-
// Compute transform from attached view's world coordinates to sheet's world coordinates.
|
|
94420
|
-
// NB: We obtain the extents and origin from the *viewport* not the *view* - they may have been adjusted by the viewport.
|
|
94421
|
-
const applySkew = true; // set to false for debugging
|
|
94422
|
-
const skew = applySkew ? view.getAspectRatioSkew() : 1;
|
|
94423
|
-
const extents = this._viewport.viewingSpace.viewDelta.clone();
|
|
94424
|
-
const zDepth = Math.abs(extents.z);
|
|
94425
|
-
const scaleX = this._sizeInMeters.x / Math.abs(extents.x);
|
|
94426
|
-
const scaleY = skew * this._sizeInMeters.y / Math.abs(extents.y);
|
|
94427
|
-
this._scale = { x: 1 / scaleX, y: 1 / scaleY };
|
|
94428
|
-
const zBias = _Frustum2d__WEBPACK_IMPORTED_MODULE_6__.Frustum2d.depthFromDisplayPriority(props.jsonProperties?.displayPriority ?? 0);
|
|
94429
|
-
this.zDepth = 1.01 * (zDepth - zBias); // give a little padding so that geometry right up against far plane doesn't get clipped.
|
|
94430
|
-
// View origin is at the *back* of the view. Align *front* of view based on display priority.
|
|
94431
|
-
const viewRot = view.getRotation();
|
|
94432
|
-
const viewOrg = viewRot.multiplyVector(this._viewport.viewingSpace.viewOrigin);
|
|
94433
|
-
viewOrg.z += zDepth;
|
|
94434
|
-
viewRot.multiplyTransposeVectorInPlace(viewOrg);
|
|
94435
|
-
const matrix = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Matrix3d.createScale(scaleX, scaleY, 1);
|
|
94436
|
-
matrix.multiplyMatrixMatrix(viewRot, matrix);
|
|
94437
|
-
const origin = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Matrix3d.xyzMinusMatrixTimesXYZ(viewOrg, matrix, viewOrg);
|
|
94438
|
-
const attachmentOrigin = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Point3d.createFrom(placement.origin);
|
|
94439
|
-
attachmentOrigin.z = zBias;
|
|
94440
|
-
const viewOrgToAttachment = attachmentOrigin.minus(viewOrg);
|
|
94441
|
-
origin.addInPlace(viewOrgToAttachment);
|
|
94442
|
-
this._toSheet = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Transform.createRefs(origin, matrix);
|
|
94443
|
-
this._fromSheet = (0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.expectDefined)(this._toSheet.inverse());
|
|
94444
|
-
// If the attached view is a section drawing, it may itself have an attached spatial view with a clip.
|
|
94445
|
-
// The clip needs to be transformed into sheet space.
|
|
94446
|
-
if (view.isDrawingView())
|
|
94447
|
-
this._viewport.drawingToSheetTransform = this._toSheet;
|
|
94448
|
-
// ###TODO? If we also apply the attachment's clip to the attached view, we may get additional culling during tile selection.
|
|
94449
|
-
// However the attached view's frustum is already clipped by intersection with sheet view's frustum, and additional clipping planes
|
|
94450
|
-
// introduce additional computation, so possibly not worth it.
|
|
94451
|
-
// Transform the view's clip (if any) to sheet space
|
|
94452
|
-
let viewClip = view.viewFlags.clipVolume ? view.getViewClip()?.clone() : undefined;
|
|
94453
|
-
if (viewClip)
|
|
94454
|
-
viewClip.transformInPlace(this._toSheet);
|
|
94455
|
-
else
|
|
94456
|
-
viewClip = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.ClipVector.createEmpty();
|
|
94457
|
-
let sheetClip;
|
|
94458
|
-
if (undefined !== props.jsonProperties?.clip)
|
|
94459
|
-
sheetClip = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.ClipVector.fromJSON(props.jsonProperties?.clip);
|
|
94460
|
-
if (sheetClip && sheetClip.isValid) {
|
|
94461
|
-
// Clip to view attachment's clip. NB: clip is in sheet coordinate space.
|
|
94462
|
-
for (const clip of sheetClip.clips)
|
|
94463
|
-
viewClip.clips.push(clip);
|
|
94464
|
-
}
|
|
94465
|
-
else {
|
|
94466
|
-
// Clip to view attachment's bounding box
|
|
94467
|
-
viewClip.appendShape([
|
|
94468
|
-
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Point3d.create(this._range.low.x, this._range.low.y),
|
|
94469
|
-
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Point3d.create(this._range.high.x, this._range.low.y),
|
|
94470
|
-
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Point3d.create(this._range.high.x, this._range.high.y),
|
|
94471
|
-
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Point3d.create(this._range.low.x, this._range.high.y),
|
|
94472
|
-
]);
|
|
94473
|
-
}
|
|
94474
|
-
this._clipVolume = _IModelApp__WEBPACK_IMPORTED_MODULE_9__.IModelApp.renderSystem.createClipVolume(viewClip);
|
|
94475
|
-
// Save off the original frustum (potentially adjusted by viewport).
|
|
94476
|
-
this._viewport.setupFromView();
|
|
94477
|
-
this._viewport.viewingSpace.getFrustum(_CoordSystem__WEBPACK_IMPORTED_MODULE_10__.CoordSystem.World, true, this._originalFrustum);
|
|
94478
|
-
const applyHiddenLineSettings = true; // for debugging edge display, set to false...
|
|
94479
|
-
const style = view.displayStyle;
|
|
94480
|
-
if (style.is3d() && applyHiddenLineSettings)
|
|
94481
|
-
this._hiddenLineSettings = style.settings.hiddenLineSettings;
|
|
94482
|
-
}
|
|
94483
|
-
[Symbol.dispose]() {
|
|
94484
|
-
this._viewport[Symbol.dispose]();
|
|
94485
|
-
}
|
|
94486
|
-
discloseTileTrees(trees) {
|
|
94487
|
-
trees.disclose(this._viewport);
|
|
94488
|
-
}
|
|
94489
|
-
addToScene(context) {
|
|
94490
|
-
if (context.viewport.freezeScene)
|
|
94491
|
-
return;
|
|
94492
|
-
if (!context.viewport.view.viewsCategory(this._props.category))
|
|
94493
|
-
return;
|
|
94494
|
-
const wantBounds = context.viewport.wantViewAttachmentBoundaries;
|
|
94495
|
-
const wantClipShapes = context.viewport.wantViewAttachmentClipShapes;
|
|
94496
|
-
if (wantBounds || wantClipShapes) {
|
|
94497
|
-
const builder = context.createSceneGraphicBuilder();
|
|
94498
|
-
if (wantBounds) {
|
|
94499
|
-
builder.setSymbology(_itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.ColorDef.red, _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.ColorDef.red, 2);
|
|
94500
|
-
builder.addRangeBox(this._range);
|
|
94501
|
-
}
|
|
94502
|
-
if (wantClipShapes && this._clipVolume) {
|
|
94503
|
-
builder.setSymbology(_itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.ColorDef.blue, _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.ColorDef.blue, 2);
|
|
94504
|
-
for (const prim of this._clipVolume.clipVector.clips) {
|
|
94505
|
-
if (!(prim instanceof _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.ClipShape))
|
|
94506
|
-
continue; // ###TODO handle non-shape primitives, if any such ever encountered
|
|
94507
|
-
const pts = [];
|
|
94508
|
-
const tf = prim.transformFromClip;
|
|
94509
|
-
for (const pt of prim.polygon) {
|
|
94510
|
-
const tfPt = tf ? tf.multiplyPoint3d(pt) : pt;
|
|
94511
|
-
pts.push(new _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Point2d(tfPt.x, tfPt.y));
|
|
94512
|
-
}
|
|
94513
|
-
builder.addLineString2d(pts, 0);
|
|
94514
|
-
}
|
|
94515
|
-
}
|
|
94516
|
-
// Put into a Batch so that we can see tooltip with attachment Id on mouseover.
|
|
94517
|
-
const batch = context.target.renderSystem.createBatch(builder.finish(), this.getDebugFeatureTable(), this._range);
|
|
94518
|
-
context.outputGraphic(batch);
|
|
94519
|
-
}
|
|
94520
|
-
if (!context.viewport.wantViewAttachments)
|
|
94521
|
-
return;
|
|
94522
|
-
// Pixel size used to compute size of ViewRect so that tiles of appropriate LOD are selected.
|
|
94523
|
-
const pixelSize = context.viewport.getPixelSizeAtPoint();
|
|
94524
|
-
if (0 === pixelSize)
|
|
94525
|
-
return;
|
|
94526
|
-
// Adjust attached view frustum based on intersection with sheet view frustum.
|
|
94527
|
-
const attachFrustum = this._originalFrustum.transformBy(this._toSheet);
|
|
94528
|
-
const attachFrustumRange = attachFrustum.toRange();
|
|
94529
|
-
const sheetFrustum = context.viewport.getWorldFrustum();
|
|
94530
|
-
const sheetFrustumRange = sheetFrustum.toRange();
|
|
94531
|
-
const intersect = attachFrustumRange.intersect(sheetFrustumRange);
|
|
94532
|
-
if (intersect.isNull)
|
|
94533
|
-
return;
|
|
94534
|
-
attachFrustum.initFromRange(intersect);
|
|
94535
|
-
attachFrustum.transformBy(this._fromSheet, attachFrustum);
|
|
94536
|
-
this._viewport.setupViewFromFrustum(attachFrustum);
|
|
94537
|
-
// Adjust view rect based on size of attachment on screen so that tiles of appropriate LOD are selected.
|
|
94538
|
-
const width = this._sizeInMeters.x * intersect.xLength() / attachFrustumRange.xLength();
|
|
94539
|
-
const height = this._sizeInMeters.y * intersect.yLength() / attachFrustumRange.yLength();
|
|
94540
|
-
this._viewRect.width = Math.max(1, Math.round(width / pixelSize));
|
|
94541
|
-
this._viewRect.height = Math.max(1, Math.round(height / pixelSize));
|
|
94542
|
-
this._viewport.setRect(this._viewRect);
|
|
94543
|
-
// Propagate settings from on-screen viewport.
|
|
94544
|
-
this._viewport.debugBoundingBoxes = context.viewport.debugBoundingBoxes;
|
|
94545
|
-
this._viewport.setTileSizeModifier(context.viewport.tileSizeModifier);
|
|
94546
|
-
// Create the scene.
|
|
94547
|
-
this._viewport.renderFrame();
|
|
94548
|
-
const scene = this.scene;
|
|
94549
|
-
if (!scene)
|
|
94550
|
-
return;
|
|
94551
|
-
// Extract scene graphics and insert into on-screen scene context.
|
|
94552
|
-
const options = {
|
|
94553
|
-
viewAttachmentId: this._props.id,
|
|
94554
|
-
clipVolume: this._clipVolume,
|
|
94555
|
-
hline: this._hiddenLineSettings,
|
|
94556
|
-
frustum: {
|
|
94557
|
-
is3d: this.view.is3d(),
|
|
94558
|
-
scale: this._scale,
|
|
94559
|
-
},
|
|
94560
|
-
};
|
|
94561
|
-
const outputGraphics = (source) => {
|
|
94562
|
-
if (0 === source.length)
|
|
94563
|
-
return;
|
|
94564
|
-
const graphics = new _render_GraphicBranch__WEBPACK_IMPORTED_MODULE_5__.GraphicBranch();
|
|
94565
|
-
graphics.setViewFlagOverrides(this._viewFlagOverrides);
|
|
94566
|
-
graphics.symbologyOverrides = this.symbologyOverrides;
|
|
94567
|
-
for (const graphic of source)
|
|
94568
|
-
graphics.entries.push(graphic);
|
|
94569
|
-
const branch = context.createGraphicBranch(graphics, this._toSheet, options);
|
|
94570
|
-
context.outputGraphic(branch);
|
|
94571
|
-
};
|
|
94572
|
-
outputGraphics(scene.foreground);
|
|
94573
|
-
context.withGraphicType(_tile_internal__WEBPACK_IMPORTED_MODULE_13__.TileGraphicType.BackgroundMap, () => outputGraphics(scene.background));
|
|
94574
|
-
context.withGraphicType(_tile_internal__WEBPACK_IMPORTED_MODULE_13__.TileGraphicType.Overlay, () => outputGraphics(scene.overlay));
|
|
94575
|
-
// Report tile statistics to sheet view's viewport.
|
|
94576
|
-
const tileAdmin = _IModelApp__WEBPACK_IMPORTED_MODULE_9__.IModelApp.tileAdmin;
|
|
94577
|
-
const selectedAndReady = tileAdmin.getTilesForUser(this._viewport);
|
|
94578
|
-
const requested = tileAdmin.getRequestsForUser(this._viewport);
|
|
94579
|
-
tileAdmin.addExternalTilesForUser(context.viewport, {
|
|
94580
|
-
requested: requested?.size ?? 0,
|
|
94581
|
-
selected: selectedAndReady?.selected.size ?? 0,
|
|
94582
|
-
ready: selectedAndReady?.ready.size ?? 0,
|
|
94583
|
-
});
|
|
94584
|
-
}
|
|
94585
|
-
getDebugFeatureTable() {
|
|
94586
|
-
if (this._debugFeatureTable)
|
|
94587
|
-
return this._debugFeatureTable;
|
|
94588
|
-
const featureTable = new _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.FeatureTable(1, this._sheetModelId);
|
|
94589
|
-
featureTable.insert(new _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.Feature(this._props.id));
|
|
94590
|
-
this._debugFeatureTable = _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.PackedFeatureTable.pack(featureTable);
|
|
94591
|
-
return this._debugFeatureTable;
|
|
94592
|
-
}
|
|
94593
|
-
get areAllTileTreesLoaded() {
|
|
94594
|
-
return this.view.areAllTileTreesLoaded;
|
|
94595
|
-
}
|
|
94596
|
-
collectStatistics(_stats) {
|
|
94597
|
-
// Handled by discloseTileTrees()
|
|
94598
|
-
}
|
|
94599
|
-
get toSheet() {
|
|
94600
|
-
return this._toSheet;
|
|
94601
|
-
}
|
|
94602
|
-
}
|
|
94603
|
-
function createRasterAttachmentViewport(_view, _rect, _attachment) {
|
|
94604
|
-
class RasterAttachmentViewport extends _Viewport__WEBPACK_IMPORTED_MODULE_11__.OffScreenViewport {
|
|
94605
|
-
_sceneContext;
|
|
94606
|
-
_isSceneReady = false;
|
|
94607
|
-
_attachment;
|
|
94608
|
-
constructor(view, rect, attachment) {
|
|
94609
|
-
super(_IModelApp__WEBPACK_IMPORTED_MODULE_9__.IModelApp.renderSystem.createOffscreenTarget(rect));
|
|
94610
|
-
this._attachment = attachment;
|
|
94611
|
-
this._isAspectRatioLocked = true;
|
|
94612
|
-
this.changeView(view);
|
|
94613
|
-
}
|
|
94614
|
-
createSceneContext() {
|
|
94615
|
-
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.assert)(!this._isSceneReady);
|
|
94616
|
-
this._sceneContext = super.createSceneContext();
|
|
94617
|
-
return this._sceneContext;
|
|
94618
|
-
}
|
|
94619
|
-
renderFrame() {
|
|
94620
|
-
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.assert)(!this._isSceneReady);
|
|
94621
|
-
this.clearSceneContext();
|
|
94622
|
-
super.renderFrame();
|
|
94623
|
-
if (undefined !== this._sceneContext) {
|
|
94624
|
-
this._isSceneReady = !this._sceneContext.hasMissingTiles && this.view.areAllTileTreesLoaded;
|
|
94625
|
-
if (this._isSceneReady)
|
|
94626
|
-
this._attachment.produceGraphics(this._sceneContext);
|
|
94627
|
-
this._sceneContext = undefined;
|
|
94628
|
-
}
|
|
94629
|
-
}
|
|
94630
|
-
clearSceneContext() {
|
|
94631
|
-
this._sceneContext = undefined;
|
|
94632
|
-
}
|
|
94633
|
-
addDecorations(_decorations) {
|
|
94634
|
-
// ###TODO: skybox, ground plane, possibly grid. DecorateContext requires a ScreenViewport...
|
|
94635
|
-
}
|
|
94636
|
-
}
|
|
94637
|
-
return new RasterAttachmentViewport(_view, _rect, _attachment);
|
|
94638
|
-
}
|
|
94639
|
-
/** Draws a 3d view with camera enabled into a sheet view by producing an image of the view's contents offscreen. */
|
|
94640
|
-
class RasterAttachment {
|
|
94641
|
-
_props;
|
|
94642
|
-
_placement;
|
|
94643
|
-
_transform;
|
|
94644
|
-
zDepth;
|
|
94645
|
-
_viewport;
|
|
94646
|
-
_graphics;
|
|
94647
|
-
constructor(view, props, sheetView) {
|
|
94648
|
-
// Render to a 2048x2048 view rect. Scale in Y to preserve aspect ratio.
|
|
94649
|
-
const maxSize = 2048;
|
|
94650
|
-
const rect = new _common_ViewRect__WEBPACK_IMPORTED_MODULE_15__.ViewRect(0, 0, maxSize, maxSize);
|
|
94651
|
-
const height = maxSize * view.getAspectRatio() * view.getAspectRatioSkew();
|
|
94652
|
-
const skew = maxSize / height;
|
|
94653
|
-
view.setAspectRatioSkew(skew);
|
|
94654
|
-
if (true !== props.jsonProperties?.displayOptions?.preserveBackground) {
|
|
94655
|
-
// Make background color 100% transparent so that Viewport.readImageBuffer() will discard transparent pixels.
|
|
94656
|
-
const bgColor = sheetView.displayStyle.backgroundColor.withAlpha(0);
|
|
94657
|
-
view.displayStyle.backgroundColor = bgColor;
|
|
94658
|
-
}
|
|
94659
|
-
this._viewport = createRasterAttachmentViewport(view, rect, this);
|
|
94660
|
-
this._props = props;
|
|
94661
|
-
this._placement = _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.Placement2d.fromJSON(props.placement);
|
|
94662
|
-
this._transform = this._placement.transform;
|
|
94663
|
-
this.zDepth = _Frustum2d__WEBPACK_IMPORTED_MODULE_6__.Frustum2d.depthFromDisplayPriority(props.jsonProperties?.displayPriority ?? 0);
|
|
94664
|
-
}
|
|
94665
|
-
[Symbol.dispose]() {
|
|
94666
|
-
this._viewport?.[Symbol.dispose]();
|
|
94667
|
-
}
|
|
94668
|
-
get viewAttachmentProps() {
|
|
94669
|
-
return this._props;
|
|
94670
|
-
}
|
|
94671
|
-
get viewport() {
|
|
94672
|
-
return this._viewport;
|
|
94673
|
-
}
|
|
94674
|
-
get areAllTileTreesLoaded() {
|
|
94675
|
-
return this._viewport?.areAllTileTreesLoaded ?? true;
|
|
94676
|
-
}
|
|
94677
|
-
addToScene(context) {
|
|
94678
|
-
// ###TODO: check viewport.wantViewAttachmentClipShapes
|
|
94679
|
-
if (!context.viewport.view.viewsCategory(this._props.category))
|
|
94680
|
-
return;
|
|
94681
|
-
if (context.viewport.wantViewAttachmentBoundaries) {
|
|
94682
|
-
const builder = context.createSceneGraphicBuilder(this._transform);
|
|
94683
|
-
builder.setSymbology(_itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.ColorDef.red, _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.ColorDef.red, 2);
|
|
94684
|
-
builder.addRangeBox(_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Range3d.createRange2d(this._placement.bbox));
|
|
94685
|
-
context.outputGraphic(builder.finish());
|
|
94686
|
-
}
|
|
94687
|
-
if (!context.viewport.wantViewAttachments)
|
|
94688
|
-
return;
|
|
94689
|
-
if (this._graphics) {
|
|
94690
|
-
context.outputGraphic(this._graphics);
|
|
94691
|
-
return;
|
|
94692
|
-
}
|
|
94693
|
-
if (undefined === this._viewport)
|
|
94694
|
-
return;
|
|
94695
|
-
this._viewport.debugBoundingBoxes = context.viewport.debugBoundingBoxes;
|
|
94696
|
-
this._viewport.setTileSizeModifier(context.viewport.tileSizeModifier);
|
|
94697
|
-
this._viewport.renderFrame();
|
|
94698
|
-
if (this._graphics)
|
|
94699
|
-
context.outputGraphic(this._graphics);
|
|
94700
|
-
}
|
|
94701
|
-
discloseTileTrees(trees) {
|
|
94702
|
-
if (this._viewport)
|
|
94703
|
-
trees.disclose(this._viewport);
|
|
94704
|
-
}
|
|
94705
|
-
produceGraphics(context) {
|
|
94706
|
-
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.assert)(context.viewport === this._viewport);
|
|
94707
|
-
this._graphics = this.createGraphics(this._viewport);
|
|
94708
|
-
this._viewport = (0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.dispose)(this._viewport);
|
|
94709
|
-
if (undefined !== this._graphics)
|
|
94710
|
-
context.outputGraphic(this._graphics);
|
|
94711
|
-
}
|
|
94712
|
-
createGraphics(vp) {
|
|
94713
|
-
// Create a texture from the contents of the view.
|
|
94714
|
-
const image = vp.readImageBuffer({ upsideDown: true });
|
|
94715
|
-
if (undefined === image)
|
|
94716
|
-
return undefined;
|
|
94717
|
-
const debugImage = false; // set to true to open a window displaying the captured image.
|
|
94718
|
-
if (debugImage) {
|
|
94719
|
-
const url = (0,_common_ImageUtil__WEBPACK_IMPORTED_MODULE_14__.imageBufferToPngDataUrl)(image, false);
|
|
94720
|
-
if (url)
|
|
94721
|
-
(0,_common_ImageUtil__WEBPACK_IMPORTED_MODULE_14__.openImageDataUrlInNewWindow)(url, "Attachment");
|
|
94722
|
-
}
|
|
94723
|
-
const texture = _IModelApp__WEBPACK_IMPORTED_MODULE_9__.IModelApp.renderSystem.createTexture({
|
|
94724
|
-
image: { source: image, transparency: _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.TextureTransparency.Opaque },
|
|
94725
|
-
});
|
|
94726
|
-
if (!texture)
|
|
94727
|
-
return undefined;
|
|
94728
|
-
// Create a material for the texture
|
|
94729
|
-
const graphicParams = new _itwin_core_common__WEBPACK_IMPORTED_MODULE_2__.GraphicParams();
|
|
94730
|
-
graphicParams.material = _IModelApp__WEBPACK_IMPORTED_MODULE_9__.IModelApp.renderSystem.createRenderMaterial({ textureMapping: { texture } });
|
|
94731
|
-
// Apply the texture to a rectangular polyface.
|
|
94732
|
-
const depth = this.zDepth;
|
|
94733
|
-
const east = this._placement.bbox.low.x;
|
|
94734
|
-
const west = this._placement.bbox.high.x;
|
|
94735
|
-
const north = this._placement.bbox.low.y;
|
|
94736
|
-
const south = this._placement.bbox.high.y;
|
|
94737
|
-
const corners = [
|
|
94738
|
-
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Point3d.create(east, north, depth),
|
|
94739
|
-
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Point3d.create(west, north, depth),
|
|
94740
|
-
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Point3d.create(west, south, depth),
|
|
94741
|
-
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Point3d.create(east, south, depth),
|
|
94742
|
-
];
|
|
94743
|
-
const params = [
|
|
94744
|
-
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Point2d.create(0, 0),
|
|
94745
|
-
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Point2d.create(1, 0),
|
|
94746
|
-
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Point2d.create(1, 1),
|
|
94747
|
-
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.Point2d.create(0, 1),
|
|
94748
|
-
];
|
|
94749
|
-
const strokeOptions = new _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.StrokeOptions();
|
|
94750
|
-
strokeOptions.needParams = strokeOptions.shouldTriangulate = true;
|
|
94751
|
-
const polyfaceBuilder = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.PolyfaceBuilder.create(strokeOptions);
|
|
94752
|
-
polyfaceBuilder.addQuadFacet(corners, params);
|
|
94753
|
-
const polyface = polyfaceBuilder.claimPolyface();
|
|
94754
|
-
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);
|
|
94755
|
-
graphicBuilder.activateGraphicParams(graphicParams);
|
|
94756
|
-
graphicBuilder.addPolyface(polyface, false);
|
|
94757
|
-
const graphic = graphicBuilder.finish();
|
|
94758
|
-
// Wrap the polyface in a GraphicBranch.
|
|
94759
|
-
const branch = new _render_GraphicBranch__WEBPACK_IMPORTED_MODULE_5__.GraphicBranch(true);
|
|
94760
|
-
const vfOvrs = (0,_tile_internal__WEBPACK_IMPORTED_MODULE_13__.createDefaultViewFlagOverrides)({ clipVolume: true, shadows: false, lighting: false, thematic: false });
|
|
94761
|
-
// Disable transparency - background pixels are 100% transparent so they will be discarded anyway. Other pixels are 100% opaque.
|
|
94762
|
-
vfOvrs.transparency = false;
|
|
94763
|
-
branch.setViewFlagOverrides(vfOvrs);
|
|
94764
|
-
branch.symbologyOverrides = new _render_FeatureSymbology__WEBPACK_IMPORTED_MODULE_8__.FeatureSymbology.Overrides();
|
|
94765
|
-
branch.entries.push(graphic);
|
|
94766
|
-
// Apply the attachment's clip, if any.
|
|
94767
|
-
let clipVolume;
|
|
94768
|
-
if (this._props.jsonProperties?.clip) {
|
|
94769
|
-
const clipVector = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_1__.ClipVector.fromJSON(this._props.jsonProperties?.clip);
|
|
94770
|
-
if (clipVector.isValid)
|
|
94771
|
-
clipVolume = _IModelApp__WEBPACK_IMPORTED_MODULE_9__.IModelApp.renderSystem.createClipVolume(clipVector);
|
|
94772
|
-
}
|
|
94773
|
-
return _IModelApp__WEBPACK_IMPORTED_MODULE_9__.IModelApp.renderSystem.createGraphicBranch(branch, this._transform, { clipVolume });
|
|
94774
|
-
}
|
|
94775
|
-
collectStatistics(stats) {
|
|
94776
|
-
if (this._graphics)
|
|
94777
|
-
this._graphics.collectStatistics(stats);
|
|
94142
|
+
return this._viewAttachments.computeDisplayTransform(args);
|
|
94778
94143
|
}
|
|
94779
94144
|
}
|
|
94780
94145
|
|
|
@@ -95374,7 +94739,46 @@ class SubCategoriesCache {
|
|
|
95374
94739
|
_appearances = new Map();
|
|
95375
94740
|
_imodel;
|
|
95376
94741
|
_missingAtTimeOfPreload;
|
|
95377
|
-
constructor(imodel) {
|
|
94742
|
+
constructor(imodel) {
|
|
94743
|
+
this._imodel = imodel;
|
|
94744
|
+
}
|
|
94745
|
+
attachToBriefcase(imodel) {
|
|
94746
|
+
// We want to do this in the constructor but can't, because IModelConnection.subcategories is initialized before
|
|
94747
|
+
// BriefcaseConnection.txns.
|
|
94748
|
+
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.assert)(imodel === this._imodel);
|
|
94749
|
+
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_0__.assert)(imodel.isBriefcaseConnection());
|
|
94750
|
+
imodel.txns.onElementsChanged.addListener((changes) => {
|
|
94751
|
+
const affectedSubCategories = new Set();
|
|
94752
|
+
for (const change of changes) {
|
|
94753
|
+
if (change.metadata.is("BisCore:Category")) {
|
|
94754
|
+
if (change.type === "deleted") {
|
|
94755
|
+
this._byCategoryId.delete(change.id);
|
|
94756
|
+
}
|
|
94757
|
+
}
|
|
94758
|
+
else if (change.metadata.is("BisCore:SubCategory")) {
|
|
94759
|
+
if (change.type === "inserted") {
|
|
94760
|
+
// We don't know to which category the subcategory belongs. Blow away the entire cache.
|
|
94761
|
+
this._byCategoryId.clear();
|
|
94762
|
+
this._appearances.clear();
|
|
94763
|
+
return;
|
|
94764
|
+
}
|
|
94765
|
+
this._appearances.delete(change.id);
|
|
94766
|
+
affectedSubCategories.add(change.id);
|
|
94767
|
+
}
|
|
94768
|
+
}
|
|
94769
|
+
if (affectedSubCategories.size > 0) {
|
|
94770
|
+
for (const [catId, subCatIds] of this._byCategoryId) {
|
|
94771
|
+
for (const subCatId of affectedSubCategories) {
|
|
94772
|
+
if (subCatIds.has(subCatId)) {
|
|
94773
|
+
this._byCategoryId.delete(catId);
|
|
94774
|
+
affectedSubCategories.delete(subCatId);
|
|
94775
|
+
break;
|
|
94776
|
+
}
|
|
94777
|
+
}
|
|
94778
|
+
}
|
|
94779
|
+
}
|
|
94780
|
+
});
|
|
94781
|
+
}
|
|
95378
94782
|
/** Get the Ids of all subcategories belonging to the category with the specified Id, or undefined if no such information is present. */
|
|
95379
94783
|
getSubCategories(categoryId) { return this._byCategoryId.get(categoryId); }
|
|
95380
94784
|
/** Get the base appearance of the subcategory with the specified Id, or undefined if no such information is present. */
|
|
@@ -113611,6 +113015,845 @@ function getAllElementIdsFromScript(script) {
|
|
|
113611
113015
|
}
|
|
113612
113016
|
|
|
113613
113017
|
|
|
113018
|
+
/***/ }),
|
|
113019
|
+
|
|
113020
|
+
/***/ "../../core/frontend/lib/esm/internal/SheetViewAttachments.js":
|
|
113021
|
+
/*!********************************************************************!*\
|
|
113022
|
+
!*** ../../core/frontend/lib/esm/internal/SheetViewAttachments.js ***!
|
|
113023
|
+
\********************************************************************/
|
|
113024
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
113025
|
+
|
|
113026
|
+
"use strict";
|
|
113027
|
+
__webpack_require__.r(__webpack_exports__);
|
|
113028
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
113029
|
+
/* harmony export */ SheetViewAttachments: () => (/* binding */ SheetViewAttachments)
|
|
113030
|
+
/* harmony export */ });
|
|
113031
|
+
/* harmony import */ var _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @itwin/core-common */ "../../core/common/lib/esm/core-common.js");
|
|
113032
|
+
/* harmony import */ var _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @itwin/core-bentley */ "../../core/bentley/lib/esm/core-bentley.js");
|
|
113033
|
+
/* harmony import */ var _IModelApp__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../IModelApp */ "../../core/frontend/lib/esm/IModelApp.js");
|
|
113034
|
+
/* harmony import */ var _ViewAttachmentRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ViewAttachmentRenderer */ "../../core/frontend/lib/esm/internal/ViewAttachmentRenderer.js");
|
|
113035
|
+
/* harmony import */ var _Frustum2d__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Frustum2d */ "../../core/frontend/lib/esm/Frustum2d.js");
|
|
113036
|
+
/*---------------------------------------------------------------------------------------------
|
|
113037
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
113038
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
113039
|
+
*--------------------------------------------------------------------------------------------*/
|
|
113040
|
+
/** @packageDocumentation
|
|
113041
|
+
* @module Views
|
|
113042
|
+
*/
|
|
113043
|
+
|
|
113044
|
+
|
|
113045
|
+
|
|
113046
|
+
|
|
113047
|
+
|
|
113048
|
+
/** Stateless state for a sheet that has no view attachments. */
|
|
113049
|
+
class EmptyAttachments {
|
|
113050
|
+
// We only need one instance of this stateless class.
|
|
113051
|
+
static _instance;
|
|
113052
|
+
static get() {
|
|
113053
|
+
return this._instance ?? (this._instance = new EmptyAttachments());
|
|
113054
|
+
}
|
|
113055
|
+
constructor() { }
|
|
113056
|
+
clone() {
|
|
113057
|
+
return this;
|
|
113058
|
+
}
|
|
113059
|
+
preload() { }
|
|
113060
|
+
async postload() {
|
|
113061
|
+
return this;
|
|
113062
|
+
}
|
|
113063
|
+
get attachmentIds() {
|
|
113064
|
+
return [];
|
|
113065
|
+
}
|
|
113066
|
+
}
|
|
113067
|
+
/** Holds the element Ids of the view attachments to be loaded for display. */
|
|
113068
|
+
class AttachmentIds {
|
|
113069
|
+
_ids;
|
|
113070
|
+
constructor(ids) {
|
|
113071
|
+
this._ids = ids;
|
|
113072
|
+
}
|
|
113073
|
+
get attachmentIds() {
|
|
113074
|
+
return this._ids;
|
|
113075
|
+
}
|
|
113076
|
+
clone() {
|
|
113077
|
+
return new AttachmentIds([...this._ids]);
|
|
113078
|
+
}
|
|
113079
|
+
preload(request) {
|
|
113080
|
+
request.sheetViewAttachmentIds = _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_1__.CompressedId64Set.sortAndCompress(this._ids);
|
|
113081
|
+
request.viewStateLoadProps = {
|
|
113082
|
+
displayStyle: {
|
|
113083
|
+
omitScheduleScriptElementIds: !_IModelApp__WEBPACK_IMPORTED_MODULE_2__.IModelApp.tileAdmin.enableFrontendScheduleScripts,
|
|
113084
|
+
compressExcludedElementIds: true,
|
|
113085
|
+
},
|
|
113086
|
+
};
|
|
113087
|
+
}
|
|
113088
|
+
async postload(response, iModel) {
|
|
113089
|
+
if (undefined === response.sheetViewViews || undefined === response.sheetViewAttachmentProps) {
|
|
113090
|
+
return this;
|
|
113091
|
+
}
|
|
113092
|
+
const viewStateProps = response.sheetViewViews;
|
|
113093
|
+
const promises = [];
|
|
113094
|
+
for (const viewProps of viewStateProps) {
|
|
113095
|
+
const loadView = async () => {
|
|
113096
|
+
try {
|
|
113097
|
+
if (viewProps === undefined)
|
|
113098
|
+
return undefined;
|
|
113099
|
+
const view = await iModel.views.convertViewStatePropsToViewState(viewProps);
|
|
113100
|
+
return view;
|
|
113101
|
+
}
|
|
113102
|
+
catch {
|
|
113103
|
+
return undefined;
|
|
113104
|
+
}
|
|
113105
|
+
};
|
|
113106
|
+
promises.push(loadView());
|
|
113107
|
+
}
|
|
113108
|
+
const views = await Promise.all(promises);
|
|
113109
|
+
const attachmentProps = response.sheetViewAttachmentProps;
|
|
113110
|
+
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_1__.assert)(views.length === attachmentProps.length);
|
|
113111
|
+
const infos = [];
|
|
113112
|
+
for (let i = 0; i < views.length; i++) {
|
|
113113
|
+
const view = views[i];
|
|
113114
|
+
if (view && !(view.isSheetView())) {
|
|
113115
|
+
const props = attachmentProps[i];
|
|
113116
|
+
props.attachedView = view;
|
|
113117
|
+
infos.push(props);
|
|
113118
|
+
}
|
|
113119
|
+
}
|
|
113120
|
+
return new AttachmentInfos(infos);
|
|
113121
|
+
}
|
|
113122
|
+
}
|
|
113123
|
+
/** Fully loaded view attachments. */
|
|
113124
|
+
class AttachmentInfos {
|
|
113125
|
+
infos;
|
|
113126
|
+
constructor(infos) {
|
|
113127
|
+
this.infos = infos;
|
|
113128
|
+
}
|
|
113129
|
+
get attachmentIds() {
|
|
113130
|
+
return this.infos.map((x) => (0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_1__.expectDefined)(x.id));
|
|
113131
|
+
}
|
|
113132
|
+
clone(iModel) {
|
|
113133
|
+
const infos = this.infos.map((info) => {
|
|
113134
|
+
return {
|
|
113135
|
+
...info,
|
|
113136
|
+
attachedView: info.attachedView.clone(iModel),
|
|
113137
|
+
};
|
|
113138
|
+
});
|
|
113139
|
+
return new AttachmentInfos(infos);
|
|
113140
|
+
}
|
|
113141
|
+
preload() {
|
|
113142
|
+
// already loaded.
|
|
113143
|
+
}
|
|
113144
|
+
async postload() {
|
|
113145
|
+
// already loaded.
|
|
113146
|
+
return this;
|
|
113147
|
+
}
|
|
113148
|
+
}
|
|
113149
|
+
/** Reloads the attachments after a change to the database. */
|
|
113150
|
+
async function reloadAttachments(sheetModelId, iModel) {
|
|
113151
|
+
const ecsql = `SELECT ECInstanceId as attachmentId FROM bis.ViewAttachment WHERE model.Id=${sheetModelId}`;
|
|
113152
|
+
const ids = [];
|
|
113153
|
+
for await (const row of iModel.createQueryReader(ecsql)) {
|
|
113154
|
+
ids.push(row[0]);
|
|
113155
|
+
}
|
|
113156
|
+
const attachmentProps = await iModel.elements.getProps(ids);
|
|
113157
|
+
const promises = [];
|
|
113158
|
+
for (const attachment of attachmentProps) {
|
|
113159
|
+
const loadView = async () => {
|
|
113160
|
+
try {
|
|
113161
|
+
const view = await iModel.views.load(attachment.view.id);
|
|
113162
|
+
return view;
|
|
113163
|
+
}
|
|
113164
|
+
catch {
|
|
113165
|
+
return undefined;
|
|
113166
|
+
}
|
|
113167
|
+
};
|
|
113168
|
+
promises.push(loadView());
|
|
113169
|
+
}
|
|
113170
|
+
const views = await Promise.all(promises);
|
|
113171
|
+
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_1__.assert)(views.length === attachmentProps.length);
|
|
113172
|
+
const infos = [];
|
|
113173
|
+
for (let i = 0; i < views.length; i++) {
|
|
113174
|
+
const view = views[i];
|
|
113175
|
+
if (view && !view.isSheetView()) {
|
|
113176
|
+
const props = attachmentProps[i];
|
|
113177
|
+
props.attachedView = view;
|
|
113178
|
+
infos.push(props);
|
|
113179
|
+
}
|
|
113180
|
+
}
|
|
113181
|
+
return new AttachmentInfos(infos);
|
|
113182
|
+
}
|
|
113183
|
+
function disposeRenderers(renderers) {
|
|
113184
|
+
if (renderers) {
|
|
113185
|
+
for (const renderer of renderers) {
|
|
113186
|
+
renderer[Symbol.dispose]();
|
|
113187
|
+
}
|
|
113188
|
+
}
|
|
113189
|
+
}
|
|
113190
|
+
/** Manages the set of ViewAttachment elements to be rendered by a SheetViewState.
|
|
113191
|
+
* Takes care of reloading them after ViewAttachment elements are modified, deleted, or inserted.
|
|
113192
|
+
*/
|
|
113193
|
+
class SheetViewAttachments {
|
|
113194
|
+
_impl;
|
|
113195
|
+
_reload;
|
|
113196
|
+
_maxDepth = _Frustum2d__WEBPACK_IMPORTED_MODULE_4__.Frustum2d.minimumZDistance;
|
|
113197
|
+
_rendererArgs;
|
|
113198
|
+
_renderers;
|
|
113199
|
+
get maxDepth() {
|
|
113200
|
+
return this._maxDepth;
|
|
113201
|
+
}
|
|
113202
|
+
*getSecondaryViewports() {
|
|
113203
|
+
if (this._renderers) {
|
|
113204
|
+
for (const renderer of this._renderers) {
|
|
113205
|
+
if (renderer.viewport) {
|
|
113206
|
+
yield renderer.viewport;
|
|
113207
|
+
}
|
|
113208
|
+
}
|
|
113209
|
+
}
|
|
113210
|
+
}
|
|
113211
|
+
constructor(impl) {
|
|
113212
|
+
this._impl = impl;
|
|
113213
|
+
}
|
|
113214
|
+
[Symbol.dispose]() {
|
|
113215
|
+
disposeRenderers(this._renderers);
|
|
113216
|
+
this._renderers = this._rendererArgs = undefined;
|
|
113217
|
+
this._reload = undefined;
|
|
113218
|
+
}
|
|
113219
|
+
static create(attachmentIds) {
|
|
113220
|
+
const impl = attachmentIds.length === 0 ? EmptyAttachments.get() : new AttachmentIds([...attachmentIds]);
|
|
113221
|
+
return new this(impl);
|
|
113222
|
+
}
|
|
113223
|
+
get attachmentIds() {
|
|
113224
|
+
return this._impl.attachmentIds;
|
|
113225
|
+
}
|
|
113226
|
+
clone(iModel) {
|
|
113227
|
+
return new SheetViewAttachments(this._impl.clone(iModel));
|
|
113228
|
+
}
|
|
113229
|
+
preload(request) {
|
|
113230
|
+
this._impl.preload(request);
|
|
113231
|
+
}
|
|
113232
|
+
async postload(response, iModel) {
|
|
113233
|
+
this._impl = await this._impl.postload(response, iModel);
|
|
113234
|
+
}
|
|
113235
|
+
async reload(sheetModelId, iModel) {
|
|
113236
|
+
const renderers = this._renderers;
|
|
113237
|
+
const reload = this._reload = reloadAttachments(sheetModelId, iModel);
|
|
113238
|
+
const impl = await this._reload;
|
|
113239
|
+
// We keep the previous renderers until reloading completes, to avoid drawing a blank view while waiting.
|
|
113240
|
+
// Afterward, always destroy the previous renderers.
|
|
113241
|
+
disposeRenderers(renderers);
|
|
113242
|
+
// If reload was not called again while we waited...
|
|
113243
|
+
if (this._reload === reload) {
|
|
113244
|
+
this._impl = impl;
|
|
113245
|
+
this._reload = this._renderers = undefined;
|
|
113246
|
+
if (this._rendererArgs) {
|
|
113247
|
+
// We are attached to a Viewport - reload the renderers.
|
|
113248
|
+
this.loadRenderers();
|
|
113249
|
+
}
|
|
113250
|
+
}
|
|
113251
|
+
}
|
|
113252
|
+
attachToViewport(args) {
|
|
113253
|
+
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_1__.assert)(undefined === this._renderers);
|
|
113254
|
+
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_1__.assert)(undefined === this._rendererArgs);
|
|
113255
|
+
this._rendererArgs = args;
|
|
113256
|
+
this.loadRenderers();
|
|
113257
|
+
}
|
|
113258
|
+
detachFromViewport() {
|
|
113259
|
+
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_1__.assert)(undefined !== this._rendererArgs);
|
|
113260
|
+
this._rendererArgs = undefined;
|
|
113261
|
+
disposeRenderers(this._renderers);
|
|
113262
|
+
this._renderers = undefined;
|
|
113263
|
+
}
|
|
113264
|
+
areAllTileTreesLoaded(displayedExtents) {
|
|
113265
|
+
if (this._reload) {
|
|
113266
|
+
return false;
|
|
113267
|
+
}
|
|
113268
|
+
else if (!this._renderers) {
|
|
113269
|
+
return true;
|
|
113270
|
+
}
|
|
113271
|
+
return this._renderers.every((renderer) => {
|
|
113272
|
+
const attachmentRange = _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.Placement2d.fromJSON(renderer.viewAttachmentProps.placement).calculateRange();
|
|
113273
|
+
return !attachmentRange.intersectsRangeXY(displayedExtents) || renderer.areAllTileTreesLoaded;
|
|
113274
|
+
});
|
|
113275
|
+
}
|
|
113276
|
+
discloseTileTrees(trees) {
|
|
113277
|
+
for (const renderer of this.renderers()) {
|
|
113278
|
+
trees.disclose(renderer);
|
|
113279
|
+
}
|
|
113280
|
+
}
|
|
113281
|
+
collectStatistics(stats) {
|
|
113282
|
+
for (const renderer of this.renderers()) {
|
|
113283
|
+
renderer.collectStatistics(stats);
|
|
113284
|
+
}
|
|
113285
|
+
}
|
|
113286
|
+
addToScene(context) {
|
|
113287
|
+
for (const renderer of this.renderers()) {
|
|
113288
|
+
renderer.addToScene(context);
|
|
113289
|
+
}
|
|
113290
|
+
}
|
|
113291
|
+
getAttachmentViewport(args) {
|
|
113292
|
+
const renderer = args.viewAttachmentId ? this.findRendererById(args.viewAttachmentId) : undefined;
|
|
113293
|
+
if (!renderer) {
|
|
113294
|
+
return undefined;
|
|
113295
|
+
}
|
|
113296
|
+
return args.inSectionDrawingAttachment ? renderer.viewport?.view.getAttachmentViewport({ inSectionDrawingAttachment: true }) : renderer.viewport;
|
|
113297
|
+
}
|
|
113298
|
+
computeDisplayTransform(args) {
|
|
113299
|
+
const renderer = undefined !== args.viewAttachmentId ? this.findRendererById(args.viewAttachmentId) : undefined;
|
|
113300
|
+
const ortho = renderer?.ortho;
|
|
113301
|
+
const sheetTransform = ortho?.toSheet;
|
|
113302
|
+
if (!sheetTransform) {
|
|
113303
|
+
return undefined;
|
|
113304
|
+
}
|
|
113305
|
+
const sectionTransform = args.inSectionDrawingAttachment ? ortho.view.computeDisplayTransform(args) : undefined;
|
|
113306
|
+
if (!sectionTransform) {
|
|
113307
|
+
return sheetTransform.clone(args.output);
|
|
113308
|
+
}
|
|
113309
|
+
return sheetTransform.multiplyTransformTransform(sectionTransform, args.output);
|
|
113310
|
+
}
|
|
113311
|
+
/** Strictly for tests. */
|
|
113312
|
+
areAllAttachmentsLoaded() {
|
|
113313
|
+
return !this._reload && (!this._renderers || this._renderers.every((x) => x.areAllTileTreesLoaded));
|
|
113314
|
+
}
|
|
113315
|
+
/** Strictly for tests. */
|
|
113316
|
+
get attachments() {
|
|
113317
|
+
return this._renderers;
|
|
113318
|
+
}
|
|
113319
|
+
/** Strictly for tests. */
|
|
113320
|
+
get attachmentProps() {
|
|
113321
|
+
const infos = this._impl.infos;
|
|
113322
|
+
if (!infos) {
|
|
113323
|
+
return [];
|
|
113324
|
+
}
|
|
113325
|
+
return infos.map((x) => {
|
|
113326
|
+
return {
|
|
113327
|
+
...x,
|
|
113328
|
+
attachedView: undefined,
|
|
113329
|
+
};
|
|
113330
|
+
});
|
|
113331
|
+
}
|
|
113332
|
+
/** Strictly for tests. */
|
|
113333
|
+
get attachmentInfos() {
|
|
113334
|
+
const infos = this._impl.infos;
|
|
113335
|
+
return infos ?? this._impl.attachmentIds;
|
|
113336
|
+
}
|
|
113337
|
+
loadRenderers() {
|
|
113338
|
+
const args = this._rendererArgs;
|
|
113339
|
+
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_1__.assert)(undefined !== args);
|
|
113340
|
+
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_1__.assert)(undefined === this._renderers);
|
|
113341
|
+
this._maxDepth = _Frustum2d__WEBPACK_IMPORTED_MODULE_4__.Frustum2d.minimumZDistance;
|
|
113342
|
+
const infos = this._impl.infos;
|
|
113343
|
+
if (!infos) {
|
|
113344
|
+
return;
|
|
113345
|
+
}
|
|
113346
|
+
this._renderers = infos.map((info) => {
|
|
113347
|
+
const renderer = (0,_ViewAttachmentRenderer__WEBPACK_IMPORTED_MODULE_3__.createViewAttachmentRenderer)({
|
|
113348
|
+
...args,
|
|
113349
|
+
props: info,
|
|
113350
|
+
view: info.attachedView,
|
|
113351
|
+
});
|
|
113352
|
+
this._maxDepth = Math.max(this._maxDepth, renderer.zDepth);
|
|
113353
|
+
return renderer;
|
|
113354
|
+
});
|
|
113355
|
+
}
|
|
113356
|
+
*renderers() {
|
|
113357
|
+
if (this._renderers) {
|
|
113358
|
+
for (const renderer of this._renderers) {
|
|
113359
|
+
yield renderer;
|
|
113360
|
+
}
|
|
113361
|
+
}
|
|
113362
|
+
}
|
|
113363
|
+
findRendererById(id) {
|
|
113364
|
+
return this._renderers?.find((x) => x.viewAttachmentProps.id === id);
|
|
113365
|
+
}
|
|
113366
|
+
}
|
|
113367
|
+
|
|
113368
|
+
|
|
113369
|
+
/***/ }),
|
|
113370
|
+
|
|
113371
|
+
/***/ "../../core/frontend/lib/esm/internal/ViewAttachmentRenderer.js":
|
|
113372
|
+
/*!**********************************************************************!*\
|
|
113373
|
+
!*** ../../core/frontend/lib/esm/internal/ViewAttachmentRenderer.js ***!
|
|
113374
|
+
\**********************************************************************/
|
|
113375
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
113376
|
+
|
|
113377
|
+
"use strict";
|
|
113378
|
+
__webpack_require__.r(__webpack_exports__);
|
|
113379
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
113380
|
+
/* harmony export */ createViewAttachmentRenderer: () => (/* binding */ createViewAttachmentRenderer)
|
|
113381
|
+
/* harmony export */ });
|
|
113382
|
+
/* harmony import */ var _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @itwin/core-common */ "../../core/common/lib/esm/core-common.js");
|
|
113383
|
+
/* harmony import */ var _CoordSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../CoordSystem */ "../../core/frontend/lib/esm/CoordSystem.js");
|
|
113384
|
+
/* harmony import */ var _Frustum2d__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Frustum2d */ "../../core/frontend/lib/esm/Frustum2d.js");
|
|
113385
|
+
/* harmony import */ var _IModelApp__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../IModelApp */ "../../core/frontend/lib/esm/IModelApp.js");
|
|
113386
|
+
/* harmony import */ var _Viewport__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Viewport */ "../../core/frontend/lib/esm/Viewport.js");
|
|
113387
|
+
/* harmony import */ var _common_ImageUtil__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../common/ImageUtil */ "../../core/frontend/lib/esm/common/ImageUtil.js");
|
|
113388
|
+
/* harmony import */ var _common_ViewRect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../common/ViewRect */ "../../core/frontend/lib/esm/common/ViewRect.js");
|
|
113389
|
+
/* harmony import */ var _common_render_GraphicType__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../common/render/GraphicType */ "../../core/frontend/lib/esm/common/render/GraphicType.js");
|
|
113390
|
+
/* harmony import */ var _render_FeatureSymbology__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../render/FeatureSymbology */ "../../core/frontend/lib/esm/render/FeatureSymbology.js");
|
|
113391
|
+
/* harmony import */ var _render_GraphicBranch__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../render/GraphicBranch */ "../../core/frontend/lib/esm/render/GraphicBranch.js");
|
|
113392
|
+
/* harmony import */ var _tile_internal__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../tile/internal */ "../../core/frontend/lib/esm/tile/internal.js");
|
|
113393
|
+
/* harmony import */ var _render_MockRender__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./render/MockRender */ "../../core/frontend/lib/esm/internal/render/MockRender.js");
|
|
113394
|
+
/* harmony import */ var _itwin_core_bentley__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! @itwin/core-bentley */ "../../core/bentley/lib/esm/core-bentley.js");
|
|
113395
|
+
/* harmony import */ var _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! @itwin/core-geometry */ "../../core/geometry/lib/esm/core-geometry.js");
|
|
113396
|
+
/* harmony import */ var _tile_ViewFlagOverrides__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./tile/ViewFlagOverrides */ "../../core/frontend/lib/esm/internal/tile/ViewFlagOverrides.js");
|
|
113397
|
+
/*---------------------------------------------------------------------------------------------
|
|
113398
|
+
* Copyright (c) Bentley Systems, Incorporated. All rights reserved.
|
|
113399
|
+
* See LICENSE.md in the project root for license terms and full copyright notice.
|
|
113400
|
+
*--------------------------------------------------------------------------------------------*/
|
|
113401
|
+
/** @packageDocumentation
|
|
113402
|
+
* @module Views
|
|
113403
|
+
*/
|
|
113404
|
+
|
|
113405
|
+
|
|
113406
|
+
|
|
113407
|
+
|
|
113408
|
+
|
|
113409
|
+
|
|
113410
|
+
|
|
113411
|
+
|
|
113412
|
+
|
|
113413
|
+
|
|
113414
|
+
|
|
113415
|
+
|
|
113416
|
+
|
|
113417
|
+
|
|
113418
|
+
|
|
113419
|
+
function createViewAttachmentRenderer(args) {
|
|
113420
|
+
const { props, view } = args;
|
|
113421
|
+
if (props.jsonProperties?.displayOptions?.drawAsRaster || (view.is3d() && view.isCameraOn)) {
|
|
113422
|
+
return new RasterAttachment(view, props, args.backgroundColor);
|
|
113423
|
+
}
|
|
113424
|
+
else {
|
|
113425
|
+
return new OrthographicAttachment(view, props, args.sheetModelId);
|
|
113426
|
+
}
|
|
113427
|
+
}
|
|
113428
|
+
/** A mostly no-op RenderTarget for an OrthographicAttachment. */
|
|
113429
|
+
class AttachmentTarget extends _render_MockRender__WEBPACK_IMPORTED_MODULE_11__.MockRender.OffScreenTarget {
|
|
113430
|
+
_attachment;
|
|
113431
|
+
constructor(attachment) {
|
|
113432
|
+
// The dimensions don't matter - we're not drawing anything.
|
|
113433
|
+
const rect = new _common_ViewRect__WEBPACK_IMPORTED_MODULE_6__.ViewRect(1, 1);
|
|
113434
|
+
super(_IModelApp__WEBPACK_IMPORTED_MODULE_3__.IModelApp.renderSystem, rect);
|
|
113435
|
+
this._attachment = attachment;
|
|
113436
|
+
}
|
|
113437
|
+
changeScene(scene) {
|
|
113438
|
+
this._attachment.scene = scene;
|
|
113439
|
+
}
|
|
113440
|
+
overrideFeatureSymbology(ovrs) {
|
|
113441
|
+
this._attachment.symbologyOverrides = ovrs;
|
|
113442
|
+
}
|
|
113443
|
+
}
|
|
113444
|
+
/** Draws the contents a 2d or orthographic 3d view directly into a sheet view.
|
|
113445
|
+
* We select tiles for the view in the context of a light-weight offscreen viewport with a no-op RenderTarget, then
|
|
113446
|
+
* collect the resultant graphics and add them to the sheet view's scene.
|
|
113447
|
+
*/
|
|
113448
|
+
class OrthographicAttachment {
|
|
113449
|
+
_viewport;
|
|
113450
|
+
_props;
|
|
113451
|
+
_sheetModelId;
|
|
113452
|
+
_viewFlagOverrides;
|
|
113453
|
+
_toSheet;
|
|
113454
|
+
_fromSheet;
|
|
113455
|
+
_sizeInMeters;
|
|
113456
|
+
_range;
|
|
113457
|
+
_viewRect = new _common_ViewRect__WEBPACK_IMPORTED_MODULE_6__.ViewRect(0, 0, 1, 1);
|
|
113458
|
+
_originalFrustum = new _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.Frustum();
|
|
113459
|
+
_clipVolume;
|
|
113460
|
+
_hiddenLineSettings;
|
|
113461
|
+
_scale;
|
|
113462
|
+
_debugFeatureTable;
|
|
113463
|
+
scene;
|
|
113464
|
+
symbologyOverrides;
|
|
113465
|
+
zDepth;
|
|
113466
|
+
get view() {
|
|
113467
|
+
return this._viewport.view;
|
|
113468
|
+
}
|
|
113469
|
+
get viewAttachmentProps() {
|
|
113470
|
+
return this._props;
|
|
113471
|
+
}
|
|
113472
|
+
get viewport() {
|
|
113473
|
+
return this._viewport;
|
|
113474
|
+
}
|
|
113475
|
+
constructor(view, props, sheetModelId) {
|
|
113476
|
+
this.symbologyOverrides = new _render_FeatureSymbology__WEBPACK_IMPORTED_MODULE_8__.FeatureSymbology.Overrides(view);
|
|
113477
|
+
const target = new AttachmentTarget(this);
|
|
113478
|
+
this._viewport = _Viewport__WEBPACK_IMPORTED_MODULE_4__.OffScreenViewport.createViewport(view, target, true);
|
|
113479
|
+
this._props = props;
|
|
113480
|
+
this._sheetModelId = sheetModelId;
|
|
113481
|
+
const applyClip = true; // set to false for debugging
|
|
113482
|
+
this._viewFlagOverrides = {
|
|
113483
|
+
...view.viewFlags,
|
|
113484
|
+
clipVolume: applyClip,
|
|
113485
|
+
lighting: false,
|
|
113486
|
+
shadows: false,
|
|
113487
|
+
};
|
|
113488
|
+
const placement = _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.Placement2d.fromJSON(props.placement);
|
|
113489
|
+
const range = placement.calculateRange();
|
|
113490
|
+
this._range = range;
|
|
113491
|
+
this._sizeInMeters = new _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.Point2d(range.xLength(), range.yLength());
|
|
113492
|
+
// Compute transform from attached view's world coordinates to sheet's world coordinates.
|
|
113493
|
+
// NB: We obtain the extents and origin from the *viewport* not the *view* - they may have been adjusted by the viewport.
|
|
113494
|
+
const applySkew = true; // set to false for debugging
|
|
113495
|
+
const skew = applySkew ? view.getAspectRatioSkew() : 1;
|
|
113496
|
+
const extents = this._viewport.viewingSpace.viewDelta.clone();
|
|
113497
|
+
const zDepth = Math.abs(extents.z);
|
|
113498
|
+
const scaleX = this._sizeInMeters.x / Math.abs(extents.x);
|
|
113499
|
+
const scaleY = skew * this._sizeInMeters.y / Math.abs(extents.y);
|
|
113500
|
+
this._scale = { x: 1 / scaleX, y: 1 / scaleY };
|
|
113501
|
+
const zBias = _Frustum2d__WEBPACK_IMPORTED_MODULE_2__.Frustum2d.depthFromDisplayPriority(props.jsonProperties?.displayPriority ?? 0);
|
|
113502
|
+
this.zDepth = 1.01 * (zDepth - zBias); // give a little padding so that geometry right up against far plane doesn't get clipped.
|
|
113503
|
+
// View origin is at the *back* of the view. Align *front* of view based on display priority.
|
|
113504
|
+
const viewRot = view.getRotation();
|
|
113505
|
+
const viewOrg = viewRot.multiplyVector(this._viewport.viewingSpace.viewOrigin);
|
|
113506
|
+
viewOrg.z += zDepth;
|
|
113507
|
+
viewRot.multiplyTransposeVectorInPlace(viewOrg);
|
|
113508
|
+
const matrix = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.Matrix3d.createScale(scaleX, scaleY, 1);
|
|
113509
|
+
matrix.multiplyMatrixMatrix(viewRot, matrix);
|
|
113510
|
+
const origin = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.Matrix3d.xyzMinusMatrixTimesXYZ(viewOrg, matrix, viewOrg);
|
|
113511
|
+
const attachmentOrigin = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.Point3d.createFrom(placement.origin);
|
|
113512
|
+
attachmentOrigin.z = zBias;
|
|
113513
|
+
const viewOrgToAttachment = attachmentOrigin.minus(viewOrg);
|
|
113514
|
+
origin.addInPlace(viewOrgToAttachment);
|
|
113515
|
+
this._toSheet = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.Transform.createRefs(origin, matrix);
|
|
113516
|
+
this._fromSheet = (0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_12__.expectDefined)(this._toSheet.inverse());
|
|
113517
|
+
// If the attached view is a section drawing, it may itself have an attached spatial view with a clip.
|
|
113518
|
+
// The clip needs to be transformed into sheet space.
|
|
113519
|
+
if (view.isDrawingView())
|
|
113520
|
+
this._viewport.drawingToSheetTransform = this._toSheet;
|
|
113521
|
+
// ###TODO? If we also apply the attachment's clip to the attached view, we may get additional culling during tile selection.
|
|
113522
|
+
// However the attached view's frustum is already clipped by intersection with sheet view's frustum, and additional clipping planes
|
|
113523
|
+
// introduce additional computation, so possibly not worth it.
|
|
113524
|
+
// Transform the view's clip (if any) to sheet space
|
|
113525
|
+
let viewClip = view.viewFlags.clipVolume ? view.getViewClip()?.clone() : undefined;
|
|
113526
|
+
if (viewClip)
|
|
113527
|
+
viewClip.transformInPlace(this._toSheet);
|
|
113528
|
+
else
|
|
113529
|
+
viewClip = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.ClipVector.createEmpty();
|
|
113530
|
+
let sheetClip;
|
|
113531
|
+
if (undefined !== props.jsonProperties?.clip)
|
|
113532
|
+
sheetClip = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.ClipVector.fromJSON(props.jsonProperties?.clip);
|
|
113533
|
+
if (sheetClip && sheetClip.isValid) {
|
|
113534
|
+
// Clip to view attachment's clip. NB: clip is in sheet coordinate space.
|
|
113535
|
+
for (const clip of sheetClip.clips)
|
|
113536
|
+
viewClip.clips.push(clip);
|
|
113537
|
+
}
|
|
113538
|
+
else {
|
|
113539
|
+
// Clip to view attachment's bounding box
|
|
113540
|
+
viewClip.appendShape([
|
|
113541
|
+
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.Point3d.create(this._range.low.x, this._range.low.y),
|
|
113542
|
+
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.Point3d.create(this._range.high.x, this._range.low.y),
|
|
113543
|
+
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.Point3d.create(this._range.high.x, this._range.high.y),
|
|
113544
|
+
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.Point3d.create(this._range.low.x, this._range.high.y),
|
|
113545
|
+
]);
|
|
113546
|
+
}
|
|
113547
|
+
this._clipVolume = _IModelApp__WEBPACK_IMPORTED_MODULE_3__.IModelApp.renderSystem.createClipVolume(viewClip);
|
|
113548
|
+
// Save off the original frustum (potentially adjusted by viewport).
|
|
113549
|
+
this._viewport.setupFromView();
|
|
113550
|
+
this._viewport.viewingSpace.getFrustum(_CoordSystem__WEBPACK_IMPORTED_MODULE_1__.CoordSystem.World, true, this._originalFrustum);
|
|
113551
|
+
const applyHiddenLineSettings = true; // for debugging edge display, set to false...
|
|
113552
|
+
const style = view.displayStyle;
|
|
113553
|
+
if (style.is3d() && applyHiddenLineSettings)
|
|
113554
|
+
this._hiddenLineSettings = style.settings.hiddenLineSettings;
|
|
113555
|
+
}
|
|
113556
|
+
[Symbol.dispose]() {
|
|
113557
|
+
this._viewport[Symbol.dispose]();
|
|
113558
|
+
}
|
|
113559
|
+
discloseTileTrees(trees) {
|
|
113560
|
+
trees.disclose(this._viewport);
|
|
113561
|
+
}
|
|
113562
|
+
addToScene(context) {
|
|
113563
|
+
if (context.viewport.freezeScene)
|
|
113564
|
+
return;
|
|
113565
|
+
if (!context.viewport.view.viewsCategory(this._props.category))
|
|
113566
|
+
return;
|
|
113567
|
+
const wantBounds = context.viewport.wantViewAttachmentBoundaries;
|
|
113568
|
+
const wantClipShapes = context.viewport.wantViewAttachmentClipShapes;
|
|
113569
|
+
if (wantBounds || wantClipShapes) {
|
|
113570
|
+
const builder = context.createSceneGraphicBuilder();
|
|
113571
|
+
if (wantBounds) {
|
|
113572
|
+
builder.setSymbology(_itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.ColorDef.red, _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.ColorDef.red, 2);
|
|
113573
|
+
builder.addRangeBox(this._range);
|
|
113574
|
+
}
|
|
113575
|
+
if (wantClipShapes && this._clipVolume) {
|
|
113576
|
+
builder.setSymbology(_itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.ColorDef.blue, _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.ColorDef.blue, 2);
|
|
113577
|
+
for (const prim of this._clipVolume.clipVector.clips) {
|
|
113578
|
+
if (!(prim instanceof _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.ClipShape))
|
|
113579
|
+
continue; // ###TODO handle non-shape primitives, if any such ever encountered
|
|
113580
|
+
const pts = [];
|
|
113581
|
+
const tf = prim.transformFromClip;
|
|
113582
|
+
for (const pt of prim.polygon) {
|
|
113583
|
+
const tfPt = tf ? tf.multiplyPoint3d(pt) : pt;
|
|
113584
|
+
pts.push(new _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.Point2d(tfPt.x, tfPt.y));
|
|
113585
|
+
}
|
|
113586
|
+
builder.addLineString2d(pts, 0);
|
|
113587
|
+
}
|
|
113588
|
+
}
|
|
113589
|
+
// Put into a Batch so that we can see tooltip with attachment Id on mouseover.
|
|
113590
|
+
const batch = context.target.renderSystem.createBatch(builder.finish(), this.getDebugFeatureTable(), this._range);
|
|
113591
|
+
context.outputGraphic(batch);
|
|
113592
|
+
}
|
|
113593
|
+
if (!context.viewport.wantViewAttachments)
|
|
113594
|
+
return;
|
|
113595
|
+
// Pixel size used to compute size of ViewRect so that tiles of appropriate LOD are selected.
|
|
113596
|
+
const pixelSize = context.viewport.getPixelSizeAtPoint();
|
|
113597
|
+
if (0 === pixelSize)
|
|
113598
|
+
return;
|
|
113599
|
+
// Adjust attached view frustum based on intersection with sheet view frustum.
|
|
113600
|
+
const attachFrustum = this._originalFrustum.transformBy(this._toSheet);
|
|
113601
|
+
const attachFrustumRange = attachFrustum.toRange();
|
|
113602
|
+
const sheetFrustum = context.viewport.getWorldFrustum();
|
|
113603
|
+
const sheetFrustumRange = sheetFrustum.toRange();
|
|
113604
|
+
const intersect = attachFrustumRange.intersect(sheetFrustumRange);
|
|
113605
|
+
if (intersect.isNull)
|
|
113606
|
+
return;
|
|
113607
|
+
attachFrustum.initFromRange(intersect);
|
|
113608
|
+
attachFrustum.transformBy(this._fromSheet, attachFrustum);
|
|
113609
|
+
this._viewport.setupViewFromFrustum(attachFrustum);
|
|
113610
|
+
// Adjust view rect based on size of attachment on screen so that tiles of appropriate LOD are selected.
|
|
113611
|
+
const width = this._sizeInMeters.x * intersect.xLength() / attachFrustumRange.xLength();
|
|
113612
|
+
const height = this._sizeInMeters.y * intersect.yLength() / attachFrustumRange.yLength();
|
|
113613
|
+
this._viewRect.width = Math.max(1, Math.round(width / pixelSize));
|
|
113614
|
+
this._viewRect.height = Math.max(1, Math.round(height / pixelSize));
|
|
113615
|
+
this._viewport.setRect(this._viewRect);
|
|
113616
|
+
// Propagate settings from on-screen viewport.
|
|
113617
|
+
this._viewport.debugBoundingBoxes = context.viewport.debugBoundingBoxes;
|
|
113618
|
+
this._viewport.setTileSizeModifier(context.viewport.tileSizeModifier);
|
|
113619
|
+
// Create the scene.
|
|
113620
|
+
this._viewport.renderFrame();
|
|
113621
|
+
const scene = this.scene;
|
|
113622
|
+
if (!scene)
|
|
113623
|
+
return;
|
|
113624
|
+
// Extract scene graphics and insert into on-screen scene context.
|
|
113625
|
+
const options = {
|
|
113626
|
+
viewAttachmentId: this._props.id,
|
|
113627
|
+
clipVolume: this._clipVolume,
|
|
113628
|
+
hline: this._hiddenLineSettings,
|
|
113629
|
+
frustum: {
|
|
113630
|
+
is3d: this.view.is3d(),
|
|
113631
|
+
scale: this._scale,
|
|
113632
|
+
},
|
|
113633
|
+
};
|
|
113634
|
+
const outputGraphics = (source) => {
|
|
113635
|
+
if (0 === source.length)
|
|
113636
|
+
return;
|
|
113637
|
+
const graphics = new _render_GraphicBranch__WEBPACK_IMPORTED_MODULE_9__.GraphicBranch();
|
|
113638
|
+
graphics.setViewFlagOverrides(this._viewFlagOverrides);
|
|
113639
|
+
graphics.symbologyOverrides = this.symbologyOverrides;
|
|
113640
|
+
for (const graphic of source)
|
|
113641
|
+
graphics.entries.push(graphic);
|
|
113642
|
+
const branch = context.createGraphicBranch(graphics, this._toSheet, options);
|
|
113643
|
+
context.outputGraphic(branch);
|
|
113644
|
+
};
|
|
113645
|
+
outputGraphics(scene.foreground);
|
|
113646
|
+
context.withGraphicType(_tile_internal__WEBPACK_IMPORTED_MODULE_10__.TileGraphicType.BackgroundMap, () => outputGraphics(scene.background));
|
|
113647
|
+
context.withGraphicType(_tile_internal__WEBPACK_IMPORTED_MODULE_10__.TileGraphicType.Overlay, () => outputGraphics(scene.overlay));
|
|
113648
|
+
// Report tile statistics to sheet view's viewport.
|
|
113649
|
+
const tileAdmin = _IModelApp__WEBPACK_IMPORTED_MODULE_3__.IModelApp.tileAdmin;
|
|
113650
|
+
const selectedAndReady = tileAdmin.getTilesForUser(this._viewport);
|
|
113651
|
+
const requested = tileAdmin.getRequestsForUser(this._viewport);
|
|
113652
|
+
tileAdmin.addExternalTilesForUser(context.viewport, {
|
|
113653
|
+
requested: requested?.size ?? 0,
|
|
113654
|
+
selected: selectedAndReady?.selected.size ?? 0,
|
|
113655
|
+
ready: selectedAndReady?.ready.size ?? 0,
|
|
113656
|
+
});
|
|
113657
|
+
}
|
|
113658
|
+
getDebugFeatureTable() {
|
|
113659
|
+
if (this._debugFeatureTable)
|
|
113660
|
+
return this._debugFeatureTable;
|
|
113661
|
+
const featureTable = new _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.FeatureTable(1, this._sheetModelId);
|
|
113662
|
+
featureTable.insert(new _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.Feature(this._props.id));
|
|
113663
|
+
this._debugFeatureTable = _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.PackedFeatureTable.pack(featureTable);
|
|
113664
|
+
return this._debugFeatureTable;
|
|
113665
|
+
}
|
|
113666
|
+
get areAllTileTreesLoaded() {
|
|
113667
|
+
return this.view.areAllTileTreesLoaded;
|
|
113668
|
+
}
|
|
113669
|
+
collectStatistics(_stats) {
|
|
113670
|
+
// Handled by discloseTileTrees()
|
|
113671
|
+
}
|
|
113672
|
+
get ortho() {
|
|
113673
|
+
return {
|
|
113674
|
+
toSheet: this._toSheet,
|
|
113675
|
+
view: this.view,
|
|
113676
|
+
};
|
|
113677
|
+
}
|
|
113678
|
+
}
|
|
113679
|
+
function createRasterAttachmentViewport(_view, _rect, _attachment) {
|
|
113680
|
+
class RasterAttachmentViewport extends _Viewport__WEBPACK_IMPORTED_MODULE_4__.OffScreenViewport {
|
|
113681
|
+
_sceneContext;
|
|
113682
|
+
_isSceneReady = false;
|
|
113683
|
+
_attachment;
|
|
113684
|
+
constructor(view, rect, attachment) {
|
|
113685
|
+
super(_IModelApp__WEBPACK_IMPORTED_MODULE_3__.IModelApp.renderSystem.createOffscreenTarget(rect));
|
|
113686
|
+
this._attachment = attachment;
|
|
113687
|
+
this._isAspectRatioLocked = true;
|
|
113688
|
+
this.changeView(view);
|
|
113689
|
+
}
|
|
113690
|
+
createSceneContext() {
|
|
113691
|
+
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_12__.assert)(!this._isSceneReady);
|
|
113692
|
+
this._sceneContext = super.createSceneContext();
|
|
113693
|
+
return this._sceneContext;
|
|
113694
|
+
}
|
|
113695
|
+
renderFrame() {
|
|
113696
|
+
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_12__.assert)(!this._isSceneReady);
|
|
113697
|
+
this.clearSceneContext();
|
|
113698
|
+
super.renderFrame();
|
|
113699
|
+
if (undefined !== this._sceneContext) {
|
|
113700
|
+
this._isSceneReady = !this._sceneContext.hasMissingTiles && this.view.areAllTileTreesLoaded;
|
|
113701
|
+
if (this._isSceneReady)
|
|
113702
|
+
this._attachment.produceGraphics(this._sceneContext);
|
|
113703
|
+
this._sceneContext = undefined;
|
|
113704
|
+
}
|
|
113705
|
+
}
|
|
113706
|
+
clearSceneContext() {
|
|
113707
|
+
this._sceneContext = undefined;
|
|
113708
|
+
}
|
|
113709
|
+
addDecorations() {
|
|
113710
|
+
// ###TODO: skybox, ground plane, possibly grid. DecorateContext requires a ScreenViewport...
|
|
113711
|
+
}
|
|
113712
|
+
}
|
|
113713
|
+
return new RasterAttachmentViewport(_view, _rect, _attachment);
|
|
113714
|
+
}
|
|
113715
|
+
/** Draws a 3d view (usually with camera enabled) into a sheet view by producing an image of the view's contents offscreen. */
|
|
113716
|
+
class RasterAttachment {
|
|
113717
|
+
_props;
|
|
113718
|
+
_placement;
|
|
113719
|
+
_transform;
|
|
113720
|
+
zDepth;
|
|
113721
|
+
_viewport;
|
|
113722
|
+
_graphics;
|
|
113723
|
+
constructor(view, props, bgColor) {
|
|
113724
|
+
// Render to a 2048x2048 view rect. Scale in Y to preserve aspect ratio.
|
|
113725
|
+
const maxSize = 2048;
|
|
113726
|
+
const rect = new _common_ViewRect__WEBPACK_IMPORTED_MODULE_6__.ViewRect(0, 0, maxSize, maxSize);
|
|
113727
|
+
const height = maxSize * view.getAspectRatio() * view.getAspectRatioSkew();
|
|
113728
|
+
const skew = maxSize / height;
|
|
113729
|
+
view.setAspectRatioSkew(skew);
|
|
113730
|
+
if (true !== props.jsonProperties?.displayOptions?.preserveBackground) {
|
|
113731
|
+
// Make background color 100% transparent so that Viewport.readImageBuffer() will discard transparent pixels.
|
|
113732
|
+
view.displayStyle.backgroundColor = bgColor.withAlpha(0);
|
|
113733
|
+
}
|
|
113734
|
+
this._viewport = createRasterAttachmentViewport(view, rect, this);
|
|
113735
|
+
this._props = props;
|
|
113736
|
+
this._placement = _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.Placement2d.fromJSON(props.placement);
|
|
113737
|
+
this._transform = this._placement.transform;
|
|
113738
|
+
this.zDepth = _Frustum2d__WEBPACK_IMPORTED_MODULE_2__.Frustum2d.depthFromDisplayPriority(props.jsonProperties?.displayPriority ?? 0);
|
|
113739
|
+
}
|
|
113740
|
+
[Symbol.dispose]() {
|
|
113741
|
+
this._viewport?.[Symbol.dispose]();
|
|
113742
|
+
}
|
|
113743
|
+
get viewAttachmentProps() {
|
|
113744
|
+
return this._props;
|
|
113745
|
+
}
|
|
113746
|
+
get viewport() {
|
|
113747
|
+
return this._viewport;
|
|
113748
|
+
}
|
|
113749
|
+
get areAllTileTreesLoaded() {
|
|
113750
|
+
return this._viewport?.areAllTileTreesLoaded ?? true;
|
|
113751
|
+
}
|
|
113752
|
+
addToScene(context) {
|
|
113753
|
+
// ###TODO: check viewport.wantViewAttachmentClipShapes
|
|
113754
|
+
if (!context.viewport.view.viewsCategory(this._props.category))
|
|
113755
|
+
return;
|
|
113756
|
+
if (context.viewport.wantViewAttachmentBoundaries) {
|
|
113757
|
+
const builder = context.createSceneGraphicBuilder(this._transform);
|
|
113758
|
+
builder.setSymbology(_itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.ColorDef.red, _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.ColorDef.red, 2);
|
|
113759
|
+
builder.addRangeBox(_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.Range3d.createRange2d(this._placement.bbox));
|
|
113760
|
+
context.outputGraphic(builder.finish());
|
|
113761
|
+
}
|
|
113762
|
+
if (!context.viewport.wantViewAttachments)
|
|
113763
|
+
return;
|
|
113764
|
+
if (this._graphics) {
|
|
113765
|
+
context.outputGraphic(this._graphics);
|
|
113766
|
+
return;
|
|
113767
|
+
}
|
|
113768
|
+
if (undefined === this._viewport)
|
|
113769
|
+
return;
|
|
113770
|
+
this._viewport.debugBoundingBoxes = context.viewport.debugBoundingBoxes;
|
|
113771
|
+
this._viewport.setTileSizeModifier(context.viewport.tileSizeModifier);
|
|
113772
|
+
this._viewport.renderFrame();
|
|
113773
|
+
if (this._graphics)
|
|
113774
|
+
context.outputGraphic(this._graphics);
|
|
113775
|
+
}
|
|
113776
|
+
discloseTileTrees(trees) {
|
|
113777
|
+
if (this._viewport)
|
|
113778
|
+
trees.disclose(this._viewport);
|
|
113779
|
+
}
|
|
113780
|
+
produceGraphics(context) {
|
|
113781
|
+
(0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_12__.assert)(context.viewport === this._viewport);
|
|
113782
|
+
this._graphics = this.createGraphics(this._viewport);
|
|
113783
|
+
this._viewport = (0,_itwin_core_bentley__WEBPACK_IMPORTED_MODULE_12__.dispose)(this._viewport);
|
|
113784
|
+
if (undefined !== this._graphics)
|
|
113785
|
+
context.outputGraphic(this._graphics);
|
|
113786
|
+
}
|
|
113787
|
+
createGraphics(vp) {
|
|
113788
|
+
// Create a texture from the contents of the view.
|
|
113789
|
+
const image = vp.readImageBuffer({ upsideDown: true });
|
|
113790
|
+
if (undefined === image)
|
|
113791
|
+
return undefined;
|
|
113792
|
+
const debugImage = false; // set to true to open a window displaying the captured image.
|
|
113793
|
+
if (debugImage) {
|
|
113794
|
+
const url = (0,_common_ImageUtil__WEBPACK_IMPORTED_MODULE_5__.imageBufferToPngDataUrl)(image, false);
|
|
113795
|
+
if (url)
|
|
113796
|
+
(0,_common_ImageUtil__WEBPACK_IMPORTED_MODULE_5__.openImageDataUrlInNewWindow)(url, "Attachment");
|
|
113797
|
+
}
|
|
113798
|
+
const texture = _IModelApp__WEBPACK_IMPORTED_MODULE_3__.IModelApp.renderSystem.createTexture({
|
|
113799
|
+
image: { source: image, transparency: _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.TextureTransparency.Opaque },
|
|
113800
|
+
});
|
|
113801
|
+
if (!texture)
|
|
113802
|
+
return undefined;
|
|
113803
|
+
// Create a material for the texture
|
|
113804
|
+
const graphicParams = new _itwin_core_common__WEBPACK_IMPORTED_MODULE_0__.GraphicParams();
|
|
113805
|
+
graphicParams.material = _IModelApp__WEBPACK_IMPORTED_MODULE_3__.IModelApp.renderSystem.createRenderMaterial({ textureMapping: { texture } });
|
|
113806
|
+
// Apply the texture to a rectangular polyface.
|
|
113807
|
+
const depth = this.zDepth;
|
|
113808
|
+
const east = this._placement.bbox.low.x;
|
|
113809
|
+
const west = this._placement.bbox.high.x;
|
|
113810
|
+
const north = this._placement.bbox.low.y;
|
|
113811
|
+
const south = this._placement.bbox.high.y;
|
|
113812
|
+
const corners = [
|
|
113813
|
+
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.Point3d.create(east, north, depth),
|
|
113814
|
+
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.Point3d.create(west, north, depth),
|
|
113815
|
+
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.Point3d.create(west, south, depth),
|
|
113816
|
+
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.Point3d.create(east, south, depth),
|
|
113817
|
+
];
|
|
113818
|
+
const params = [
|
|
113819
|
+
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.Point2d.create(0, 0),
|
|
113820
|
+
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.Point2d.create(1, 0),
|
|
113821
|
+
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.Point2d.create(1, 1),
|
|
113822
|
+
_itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.Point2d.create(0, 1),
|
|
113823
|
+
];
|
|
113824
|
+
const strokeOptions = new _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.StrokeOptions();
|
|
113825
|
+
strokeOptions.needParams = strokeOptions.shouldTriangulate = true;
|
|
113826
|
+
const polyfaceBuilder = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.PolyfaceBuilder.create(strokeOptions);
|
|
113827
|
+
polyfaceBuilder.addQuadFacet(corners, params);
|
|
113828
|
+
const polyface = polyfaceBuilder.claimPolyface();
|
|
113829
|
+
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);
|
|
113830
|
+
graphicBuilder.activateGraphicParams(graphicParams);
|
|
113831
|
+
graphicBuilder.addPolyface(polyface, false);
|
|
113832
|
+
const graphic = graphicBuilder.finish();
|
|
113833
|
+
// Wrap the polyface in a GraphicBranch.
|
|
113834
|
+
const branch = new _render_GraphicBranch__WEBPACK_IMPORTED_MODULE_9__.GraphicBranch(true);
|
|
113835
|
+
const vfOvrs = (0,_tile_ViewFlagOverrides__WEBPACK_IMPORTED_MODULE_14__.createDefaultViewFlagOverrides)({ clipVolume: true, shadows: false, lighting: false, thematic: false });
|
|
113836
|
+
// Disable transparency - background pixels are 100% transparent so they will be discarded anyway. Other pixels are 100% opaque.
|
|
113837
|
+
vfOvrs.transparency = false;
|
|
113838
|
+
branch.setViewFlagOverrides(vfOvrs);
|
|
113839
|
+
branch.symbologyOverrides = new _render_FeatureSymbology__WEBPACK_IMPORTED_MODULE_8__.FeatureSymbology.Overrides();
|
|
113840
|
+
branch.entries.push(graphic);
|
|
113841
|
+
// Apply the attachment's clip, if any.
|
|
113842
|
+
let clipVolume;
|
|
113843
|
+
if (this._props.jsonProperties?.clip) {
|
|
113844
|
+
const clipVector = _itwin_core_geometry__WEBPACK_IMPORTED_MODULE_13__.ClipVector.fromJSON(this._props.jsonProperties?.clip);
|
|
113845
|
+
if (clipVector.isValid)
|
|
113846
|
+
clipVolume = _IModelApp__WEBPACK_IMPORTED_MODULE_3__.IModelApp.renderSystem.createClipVolume(clipVector);
|
|
113847
|
+
}
|
|
113848
|
+
return _IModelApp__WEBPACK_IMPORTED_MODULE_3__.IModelApp.renderSystem.createGraphicBranch(branch, this._transform, { clipVolume });
|
|
113849
|
+
}
|
|
113850
|
+
collectStatistics(stats) {
|
|
113851
|
+
if (this._graphics)
|
|
113852
|
+
this._graphics.collectStatistics(stats);
|
|
113853
|
+
}
|
|
113854
|
+
}
|
|
113855
|
+
|
|
113856
|
+
|
|
113614
113857
|
/***/ }),
|
|
113615
113858
|
|
|
113616
113859
|
/***/ "../../core/frontend/lib/esm/internal/cross-package.js":
|
|
@@ -129824,12 +130067,19 @@ class VertexShaderBuilder extends ShaderBuilder {
|
|
|
129824
130067
|
}
|
|
129825
130068
|
main.addline(" v_color = baseColor;");
|
|
129826
130069
|
}
|
|
130070
|
+
/*
|
|
130071
|
+
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).
|
|
130072
|
+
|
|
130073
|
+
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.
|
|
130074
|
+
|
|
130075
|
+
The workaround for this bug involves ensuring that gl_Position is initialized to a valid position before attempting a discard using a degenerate triangle.
|
|
130076
|
+
*/
|
|
130077
|
+
main.addline(" gl_Position = computePosition(rawPosition);");
|
|
129827
130078
|
const checkForDiscard = this.get(9 /* VertexShaderComponent.CheckForDiscard */);
|
|
129828
130079
|
if (undefined !== checkForDiscard) {
|
|
129829
130080
|
prelude.addFunction("bool checkForDiscard()", checkForDiscard);
|
|
129830
130081
|
main.add(_glsl_Vertex__WEBPACK_IMPORTED_MODULE_3__.vertexDiscard);
|
|
129831
130082
|
}
|
|
129832
|
-
main.addline(" gl_Position = computePosition(rawPosition);");
|
|
129833
130083
|
const finalizePos = this.get(13 /* VertexShaderComponent.FinalizePosition */);
|
|
129834
130084
|
if (undefined !== finalizePos) {
|
|
129835
130085
|
prelude.addFunction("vec4 finalizePosition(vec4 pos)", finalizePos);
|
|
@@ -321868,7 +322118,7 @@ var loadLanguages = instance.loadLanguages;
|
|
|
321868
322118
|
/***/ ((module) => {
|
|
321869
322119
|
|
|
321870
322120
|
"use strict";
|
|
321871
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@itwin/core-frontend","version":"5.3.
|
|
322121
|
+
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"}}');
|
|
321872
322122
|
|
|
321873
322123
|
/***/ })
|
|
321874
322124
|
|