UNPKG

@itwin/core-frontend

Version:
99 lines 4.72 kB
"use strict"; /*--------------------------------------------------------------------------------------------- * Copyright (c) Bentley Systems, Incorporated. All rights reserved. * See LICENSE.md in the project root for license terms and full copyright notice. *--------------------------------------------------------------------------------------------*/ /** @packageDocumentation * @module Tiles */ Object.defineProperty(exports, "__esModule", { value: true }); exports.MapLayerTileTreeReference = void 0; exports.createMapLayerTreeReference = createMapLayerTreeReference; const core_bentley_1 = require("@itwin/core-bentley"); const core_common_1 = require("@itwin/core-common"); const IModelApp_1 = require("../../IModelApp"); const internal_1 = require("../internal"); /** * A [[TileTreeReference]] to be used specifically for [[MapTileTree]]s. * The reference refers to its MapTileTree by way of the tree's [[TileTreeOwner]]. * Multiple MapLayerTileTreeReferences can refer to the same TileTree if the map layer settings are equivalent, meaning * they have identical format IDs, URLs, credentials, etc. * @beta */ class MapLayerTileTreeReference extends internal_1.TileTreeReference { /* @internal */ _layerSettings; /* @internal */ _layerIndex; /* @internal */ iModel; /** * Constructor for a MapLayerTileTreeReference. * @param _layerSettings Map layer settings that are applied to the MapLayerTileTreeReference. * @param _layerIndex The index of the associated map layer. * @param iModel The iModel containing the MapLayerTileTreeReference. * @internal */ constructor(_layerSettings, _layerIndex, iModel) { super(); this._layerSettings = _layerSettings; this._layerIndex = _layerIndex; this.iModel = iModel; } /* @internal */ get _transparency() { return this._layerSettings.transparency ? this._layerSettings.transparency : undefined; } /** Returns true if the associated map layer, including its sublayers, is opaque. */ get isOpaque() { return this._layerSettings.visible && (!this._layerSettings.allSubLayersInvisible) && !this._layerSettings.transparentBackground && 0 === this._layerSettings.transparency; } /* Returns the map layer name. */ get layerName() { return this._layerSettings.name; } /** Returns the imagery provider for the tile tree. */ get imageryProvider() { return undefined; } set layerSettings(layerSettings) { this._layerSettings = layerSettings; } /** Returns the layer settings for the map layer. */ get layerSettings() { return this._layerSettings; } /** Returns the index of the map layer associated with the tile tree. */ get layerIndex() { return this._layerIndex; } /** Returns the transparency value of the map layer. */ get transparency() { return this._transparency; } canSupplyToolTip(hit) { const tree = this.treeOwner.tileTree; return undefined !== tree && hit.iModel === tree.iModel && tree.modelId === hit.sourceId; } /* Returns a tooltip describing the hit with the map layer name. */ async getToolTip(hit) { const tree = this.treeOwner.tileTree; if (undefined === tree || hit.iModel !== tree.iModel || tree.modelId !== hit.sourceId) return undefined; const strings = []; strings.push(`Map Layer: ${this._layerSettings.name}`); const div = document.createElement("div"); div.innerHTML = strings.join("<br>"); return div; } decorate(_context) { this.imageryProvider?.decorate(_context); } } exports.MapLayerTileTreeReference = MapLayerTileTreeReference; /** * Creates a MapLayerTileTreeReference. * @param layerSettings Model or image map layer settings that are applied to the MapLayerTileTreeReference. * @param layerIndex The index of the associated map layer. * @param iModel The iModel containing the new MapLayerTileTreeReference. * @returns Returns the new tile tree reference, either a ModelMapLayerTileTreeReference or an ImageryMapLayerTreeReference. * @internal */ function createMapLayerTreeReference(layerSettings, layerIndex, iModel) { if (layerSettings instanceof core_common_1.ModelMapLayerSettings) { return (0, internal_1.createModelMapLayerTileTreeReference)(layerSettings, layerIndex, iModel); } else if (layerSettings instanceof core_common_1.ImageMapLayerSettings) return IModelApp_1.IModelApp.mapLayerFormatRegistry.createImageryMapLayerTree(layerSettings, layerIndex, iModel); else { (0, core_bentley_1.assert)(false); return undefined; } } //# sourceMappingURL=MapLayerTileTreeReference.js.map