@itwin/hypermodeling-frontend 3.0.0-dev.125 → 3.0.0-dev.129

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.
@@ -1 +1 @@
1
- {"version":3,"file":"HyperModelingDecorator.js","sourceRoot":"","sources":["../../src/HyperModelingDecorator.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,wDAAwD;AAExD,wDAE8B;AAC9B,qDAAmE;AACnE,+EAA4E;AAC5E,uEAA0E;AAC1E,iDAA2E;AAC3E,mDAAgD;AAGhD,KAAK,UAAU,aAAa,CAAC,EAAkB;IAC7C,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,aAAa,EAAE;QAC1B,OAAO,SAAS,CAAC;IAEnB,MAAM,MAAM,GAAG,MAAM,yDAA2B,CAAC,QAAQ,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC;IACrE,IAAI,CAAC,KAAK,MAAM,CAAC,MAAM;QACrB,OAAO,SAAS,CAAC;IAEnB,MAAM,OAAO,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,IAAI,8BAAa,CAAC,KAAK,CAAC,CAAC,CAAC;IAChE,OAAO,IAAI,iCAAgB,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC;AAC3C,CAAC;AAED,MAAM,qBAAqB;IAMzB,YAAmB,MAAqB,EAAE,SAAiC;QACzE,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC,QAAQ,CAAC;QACpC,IAAI,CAAC,YAAY,GAAG,6BAAa,CAAC,aAAa,CAAC,eAAe,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QACnF,IAAI,CAAC,qBAAqB,GAAG,CAAC,EAAE,EAAE,EAAE,CAAC,6BAAa,CAAC,aAAa,CAAC,cAAc,CAAC,EAAE,EAAE,MAAM,EAAE,SAAS,CAAC,CAAC,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,IAAI,CAAC,YAAY;YACjC,OAAO,MAAM,KAAK,IAAI,CAAC,YAAY,CAAC;QAEtC,OAAO,6BAAa,CAAC,aAAa,CAAC,eAAe,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACjF,CAAC;IAEO,sBAAsB;QAC5B,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YACzC,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC;YAClC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;YAC9C,OAAO,GAAG,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,KAAK,UAAU,CAAC,CAAC;SACtD;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AA7VD,wDA6VC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module HyperModeling\r\n */\r\n\r\nimport { Transform, XAndY } from \"@itwin/core-geometry\";\r\nimport { AbstractToolbarProps } from \"@itwin/appui-abstract\";\r\nimport {\r\n ChangeFlags, DecorateContext, Decorator, IModelApp, IModelConnection, ScreenViewport, SpatialViewState, TiledGraphicsProvider, ViewClipTool,\r\n} from \"@itwin/core-frontend\";\r\nimport { SectionMarker, SectionMarkerSet } from \"./SectionMarkers\";\r\nimport { SectionDrawingLocationState } from \"./SectionDrawingLocationState\";\r\nimport { createSectionGraphicsProvider } from \"./SectionGraphicsProvider\";\r\nimport { PopupToolbarManager, PopupToolbarProvider } from \"./PopupToolbar\";\r\nimport { HyperModeling } from \"./HyperModeling\";\r\nimport { SectionMarkerConfig } from \"./HyperModelingConfig\";\r\n\r\nasync function createMarkers(vp: ScreenViewport): Promise<SectionMarkerSet | undefined> {\r\n if (!vp.view.isSpatialView())\r\n return undefined;\r\n\r\n const states = await SectionDrawingLocationState.queryAll(vp.iModel);\r\n if (0 === states.length)\r\n return undefined;\r\n\r\n const markers = states.map((state) => new SectionMarker(state));\r\n return new SectionMarkerSet(vp, markers);\r\n}\r\n\r\nclass MarkerToolbarProvider implements PopupToolbarProvider {\r\n private readonly _viewport: ScreenViewport;\r\n public readonly marker: SectionMarker;\r\n public readonly toolbarProps: AbstractToolbarProps;\r\n public readonly onToolbarItemExecuted: (id: string) => void;\r\n\r\n public constructor(marker: SectionMarker, decorator: HyperModelingDecorator) {\r\n this.marker = marker;\r\n this._viewport = decorator.viewport;\r\n this.toolbarProps = HyperModeling.markerHandler.getToolbarProps(marker, decorator);\r\n this.onToolbarItemExecuted = (id) => HyperModeling.markerHandler.executeCommand(id, marker, decorator); // eslint-disable-line @typescript-eslint/promise-function-async\r\n }\r\n\r\n public get overToolbarHotspot() {\r\n return this.marker.isHilited;\r\n }\r\n\r\n public get toolbarLocation(): XAndY {\r\n return IModelApp.uiAdmin.createXAndY(this.marker.rect.right, this.marker.rect.top);\r\n }\r\n\r\n public get htmlElement() {\r\n return this._viewport.canvas;\r\n }\r\n}\r\n\r\n/** A [Decorator]($frontend) that displays a [[SectionMarker]] for each [SectionDrawingLocation]($backend) in the view.\r\n * Clicking on a marker toggles the section and the display of associated 2d graphics.\r\n * Hovering over a marker opens a mini toolbar with additional interactions.\r\n * @see [[SectionMarkerHandler]] to customize the marker interactions.\r\n * @see [[HyperModeling.startOrStop]] to enable or disable the decorator for a viewport.\r\n * @public\r\n */\r\nexport class HyperModelingDecorator implements Decorator {\r\n /** The set of [[SectionMarker]]s controlled by this decorator. */\r\n public readonly markers: SectionMarkerSet;\r\n private _config: SectionMarkerConfig;\r\n private readonly _removeEventListeners = new Array<() => void>();\r\n private readonly _iModel: IModelConnection;\r\n private _needSync = false;\r\n private _toolbarProvider?: MarkerToolbarProvider;\r\n private _tiledGraphicsProvider?: TiledGraphicsProvider;\r\n private _activeMarker?: SectionMarker;\r\n private _appliedSpatialView?: SpatialViewState;\r\n /** @internal */\r\n public syncImmediately = false;\r\n\r\n /** Create a new decorator and register it with the [ViewManager]($frontend). Typically invoked indirectly via [[HyperModeling.startOrStop]]. */\r\n public static async create(vp: ScreenViewport, config: SectionMarkerConfig): Promise<HyperModelingDecorator | undefined> {\r\n const markers = await createMarkers(vp);\r\n return undefined !== markers ? new HyperModelingDecorator(markers, config) : undefined;\r\n }\r\n\r\n /** Obtain the decorator associated with the specified viewport, if any. */\r\n public static getForViewport(vp: ScreenViewport): HyperModelingDecorator | undefined {\r\n for (const decorator of IModelApp.viewManager.decorators)\r\n if (decorator instanceof HyperModelingDecorator && decorator.viewport === vp)\r\n return decorator;\r\n\r\n return undefined;\r\n }\r\n\r\n /** The viewport into which this decorator draws its [[SectionMarker]]s. */\r\n public get viewport(): ScreenViewport {\r\n return this.markers.viewport;\r\n }\r\n\r\n /** The currently active marker. A marker typically becomes active when the user clicks on it.\r\n * @see [[setActiveMarker]] to change the active marker without user interaction.\r\n */\r\n public get activeMarker(): SectionMarker | undefined {\r\n return this._activeMarker;\r\n }\r\n\r\n /** @internal */\r\n public get config(): SectionMarkerConfig {\r\n return this._config;\r\n }\r\n\r\n /** Replaces the current marker display configuration, overwriting all previous settings. Passing `undefined` resets all settings to defaults.\r\n * @see [[updateConfiguration]] to override specific aspects of the configuration\r\n * @see [[HyperModeling.replaceConfiguration]] to replace the global configuration.\r\n */\r\n public replaceConfiguration(config?: SectionMarkerConfig): void {\r\n this._config = config ? { ...config } : {};\r\n this.requestSync();\r\n }\r\n\r\n /** Overrides specific aspects of the current marker display configuration.\r\n * Any field that is not `undefined` will be replaced in the current configuration; the rest will retain their current values.\r\n * @see [[replaceConfiguration]] to override all settings.\r\n * @see [[HyperModeling.updateConfiguration]] to update the global configuration.\r\n */\r\n public updateConfiguration(config: SectionMarkerConfig): void {\r\n this._config = {\r\n ignoreModelSelector: config.ignoreModelSelector ?? this._config.ignoreModelSelector,\r\n ignoreCategorySelector: config.ignoreCategorySelector ?? this._config.ignoreCategorySelector,\r\n hiddenSectionTypes: config.hiddenSectionTypes ?? this._config.hiddenSectionTypes,\r\n };\r\n\r\n this.requestSync();\r\n }\r\n\r\n /** Sets the currently active marker. This function is invoked when the user clicks on a marker, but may also be called manually to produce the same result.\r\n * Changing the active marker first deactivates the currently active marker, if any; then activates the specified marker, if supplied.\r\n * Returns false if marker activation fails.\r\n * @see [[activeMarker]] to obtain the currently active section marker.\r\n * @see [[SectionMarkerHandler.activateMarker]] to control what happens when a marker is activated.\r\n * @see [[SectionMarkerHandler.deactivateMarker]] to control what happens when a marker is deactivated.\r\n */\r\n public async setActiveMarker(marker: SectionMarker | undefined): Promise<boolean> {\r\n if (marker === this.activeMarker)\r\n return true;\r\n\r\n if (this.activeMarker) {\r\n this.activeMarker.setActive(false);\r\n await HyperModeling.markerHandler.deactivateMarker(this.activeMarker, this);\r\n this._activeMarker = undefined;\r\n }\r\n\r\n if (marker) {\r\n if (!await HyperModeling.markerHandler.activateMarker(marker, this)) {\r\n this.requestSync();\r\n return false;\r\n }\r\n\r\n marker.setActive(true);\r\n this._activeMarker = marker;\r\n }\r\n\r\n this.requestSync();\r\n return true;\r\n }\r\n\r\n /** @internal */\r\n public readonly useCachedDecorations = true;\r\n\r\n /** @internal */\r\n public decorate(context: DecorateContext): void {\r\n if (this.viewport.view.is3d())\r\n this.markers.addDecoration(context);\r\n }\r\n\r\n private constructor(markers: SectionMarkerSet, config: SectionMarkerConfig) {\r\n this.markers = markers;\r\n this._config = { ...config };\r\n this._iModel = this.viewport.iModel;\r\n\r\n this.viewport.onChangeView.addOnce(() => {\r\n this.requestSync();\r\n });\r\n\r\n this._removeEventListeners.push(this.viewport.onViewportChanged.addListener((_, changeFlags) => this.onViewportChanged(changeFlags)));\r\n this._removeEventListeners.push(this.viewport.onDisposed.addListener(() => this.dispose()));\r\n\r\n for (const marker of markers.markers) {\r\n marker.onMouseEnterEvent.addListener((mkr) => this.showToolbarAfterTimeout(mkr));\r\n marker.onMouseButtonEvent.addListener((mkr) => this.toggleMarker(mkr)); // eslint-disable-line @typescript-eslint/promise-function-async\r\n }\r\n\r\n this.updateMarkerVisibility();\r\n IModelApp.viewManager.addDecorator(this);\r\n }\r\n\r\n private onViewportChanged(changeFlags: ChangeFlags): void {\r\n if (this.viewport.iModel !== this._iModel) {\r\n this.dispose();\r\n return;\r\n }\r\n\r\n if (changeFlags.viewedCategories || changeFlags.viewedModels || changeFlags.viewedCategoriesPerModel)\r\n this.requestSync();\r\n\r\n if (changeFlags.viewState) {\r\n // If we're looking at a different view now, and we did not initiate that, turn off the active marker.\r\n if (this.viewport.view !== this._appliedSpatialView)\r\n this.setActiveMarker(undefined); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n else\r\n this._appliedSpatialView = undefined;\r\n }\r\n }\r\n\r\n private async toggleMarker(marker: SectionMarker): Promise<void> {\r\n await this.setActiveMarker(marker === this.activeMarker ? undefined : marker);\r\n }\r\n\r\n private dropTiledGraphicsProvider(): void {\r\n if (undefined === this._tiledGraphicsProvider)\r\n return;\r\n\r\n this.viewport.dropTiledGraphicsProvider(this._tiledGraphicsProvider);\r\n this._tiledGraphicsProvider = undefined;\r\n }\r\n\r\n /** @internal */\r\n public dispose(): void {\r\n if (!IModelApp.viewManager.dropDecorator(this))\r\n return;\r\n\r\n for (const remove of this._removeEventListeners)\r\n remove();\r\n\r\n this.dropTiledGraphicsProvider();\r\n }\r\n\r\n private showToolbarAfterTimeout(marker: SectionMarker): void {\r\n if (this._toolbarProvider?.marker !== marker)\r\n this._toolbarProvider = new MarkerToolbarProvider(marker, this);\r\n\r\n PopupToolbarManager.showToolbarAfterTimeout(this._toolbarProvider);\r\n }\r\n\r\n /** Toggles whether the clip volume associated with the specified marker is applied to the view. */\r\n public toggleClipVolume(marker: SectionMarker, enable: boolean): void {\r\n ViewClipTool.enableClipVolume(this.viewport);\r\n ViewClipTool.setViewClip(this.viewport, enable ? marker.state.clip : undefined);\r\n }\r\n\r\n /** Toggles the specified section marker.\r\n * Enabling the section applies the frustum and clip volume of the marker's spatial view to the viewport, and displays the 2d section graphics and sheet annotations.\r\n * Disabling the section disables the clip volume and 2d graphics.\r\n * @see [[toggleClipVolume]] to toggle only the clip volume.\r\n * @see [[toggleAttachment]] to toggle only the attachment graphics.\r\n */\r\n public async toggleSection(marker: SectionMarker, enable: boolean): Promise<boolean> {\r\n if (enable) {\r\n if (this.viewport.view.is3d()) {\r\n // Preserve the view settings; apply only the frustum and clip volume\r\n const spatialView = await marker.state.tryLoadSpatialView();\r\n if (!spatialView)\r\n return false;\r\n\r\n const aligned = await this.alignToSpatialView(marker);\r\n if (!aligned)\r\n return false;\r\n\r\n this.toggleClipVolume(marker, true);\r\n } else if (!await this.applySpatialView(marker)) {\r\n return false;\r\n }\r\n } else {\r\n this.toggleClipVolume(marker, false);\r\n }\r\n\r\n this.requestSync();\r\n return this.toggleAttachment(marker, enable);\r\n }\r\n\r\n /** Toggles display of 2d section graphics and sheet annotations for the specified marker.\r\n * @see [[toggleSection]] to apply the spatial view and clip volume in addition to the attachment graphics.\r\n */\r\n public async toggleAttachment(marker: SectionMarker, enable: boolean): Promise<boolean> {\r\n this.dropTiledGraphicsProvider();\r\n if (enable) {\r\n this._tiledGraphicsProvider = await createSectionGraphicsProvider(marker.state);\r\n this.viewport.addTiledGraphicsProvider(this._tiledGraphicsProvider);\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /** Aligns the viewport to face the specified marker's section plane. */\r\n public alignView(marker: SectionMarker): void {\r\n const placement = marker.state.placement.transform;\r\n const origin = placement.origin;\r\n const matrix = placement.matrix;\r\n\r\n const vp = this.viewport;\r\n const targetMatrix = matrix.multiplyMatrixMatrix(vp.rotation);\r\n const rotateTransform = Transform.createFixedPointAndMatrix(origin, targetMatrix);\r\n\r\n const startFrustum = vp.getFrustum();\r\n const newFrustum = startFrustum.clone();\r\n newFrustum.multiply(rotateTransform);\r\n\r\n if (startFrustum.equals(newFrustum))\r\n return;\r\n\r\n vp.view.setupFromFrustum(newFrustum);\r\n vp.synchWithView();\r\n vp.animateFrustumChange();\r\n }\r\n\r\n /** Opens the marker's drawing view in the decorator's viewport. Returns false if the drawing view could not be loaded. */\r\n public async openSection(marker: SectionMarker): Promise<boolean> {\r\n const viewState = await marker.state.tryLoadDrawingView();\r\n if (viewState)\r\n this.viewport.changeView(viewState);\r\n\r\n return undefined !== viewState;\r\n }\r\n\r\n /** Opens marker's sheet view in the decorator's viewport and zooms in on the associated [ViewAttachment]($backend). Returns false if no view\r\n * attachment exists or the sheet view could not be loaded.\r\n */\r\n public async openSheet(marker: SectionMarker): Promise<boolean> {\r\n if (undefined === marker.state.viewAttachment)\r\n return false;\r\n\r\n const viewState = await marker.state.tryLoadSheetView();\r\n if (!viewState)\r\n return false;\r\n\r\n this.viewport.changeView(viewState);\r\n await this.viewport.zoomToElements(marker.state.viewAttachment.id);\r\n return true;\r\n }\r\n\r\n /** Aligns the view to match the frustum of the spatial view associated with the specified marker.\r\n * @param marker The marker whose spatial view's frustum should be applied.\r\n * @returns false if the frustum could not be applied, e.g. because the spatial view could not be loaded or the viewport is viewing a 2d model.\r\n * @see [[alignView]] to align to the *section plane*, which may differ.\r\n * @see [[toggleSection]] to also apply the clip volume.\r\n */\r\n public async alignToSpatialView(marker: SectionMarker): Promise<boolean> {\r\n if (!this.viewport.view.is3d())\r\n return false;\r\n\r\n const spatialView = await marker.state.tryLoadSpatialView();\r\n if (!spatialView)\r\n return false;\r\n\r\n this.viewport.view.setOrigin(spatialView.getOrigin());\r\n this.viewport.view.setExtents(spatialView.getExtents());\r\n this.viewport.view.setRotation(spatialView.getRotation());\r\n this.viewport.synchWithView({ animateFrustumChange: true });\r\n\r\n return true;\r\n }\r\n\r\n /** Applies the marker's spatial view - including its clip volume - to the decorator's viewport.\r\n * Returns false if the spatial view could not be loaded.\r\n * @see [[toggleSection]].\r\n * @see [[toggleClipVolume]].\r\n */\r\n public async applySpatialView(marker: SectionMarker): Promise<boolean> {\r\n const viewState = await marker.state.tryLoadSpatialView();\r\n if (viewState) {\r\n this._appliedSpatialView = viewState;\r\n this.viewport.changeView(viewState);\r\n }\r\n\r\n return undefined !== viewState;\r\n }\r\n\r\n /** Request that the visibility of the section markers be recomputed. It is only necessary to call this if you have overridden [[SectionMarkerHandler.isMarkerVisible]]; if so, you should invoke\r\n * this method when the criteria governing your `isMarkerVisible` method have changed.\r\n */\r\n public requestSync(): void {\r\n if (this.syncImmediately) {\r\n this.sync();\r\n } else if (!this._needSync) {\r\n this._needSync = true;\r\n requestAnimationFrame(() => this.sync());\r\n }\r\n }\r\n\r\n private sync(): void {\r\n this._needSync = false;\r\n if (HyperModeling.isInitialized && this.viewport.view.is3d() && this.updateMarkerVisibility()) {\r\n this.markers.markDirty();\r\n this.viewport.invalidateCachedDecorations(this);\r\n }\r\n }\r\n\r\n private isMarkerVisible(marker: SectionMarker): boolean {\r\n if (undefined !== this.activeMarker)\r\n return marker === this.activeMarker;\r\n\r\n return HyperModeling.markerHandler.isMarkerVisible(marker, this, this._config);\r\n }\r\n\r\n private updateMarkerVisibility(): boolean {\r\n let changed = false;\r\n for (const marker of this.markers.markers) {\r\n const wasVisible = marker.visible;\r\n marker.visible = this.isMarkerVisible(marker);\r\n changed = changed || (marker.visible !== wasVisible);\r\n }\r\n\r\n return changed;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"HyperModelingDecorator.js","sourceRoot":"","sources":["../../src/HyperModelingDecorator.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,wDAAwD;AAExD,wDAE8B;AAC9B,qDAAmE;AACnE,+EAA4E;AAC5E,uEAA0E;AAC1E,iDAA2E;AAC3E,mDAAgD;AAGhD,KAAK,UAAU,aAAa,CAAC,EAAkB;IAC7C,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,aAAa,EAAE;QAC1B,OAAO,SAAS,CAAC;IAEnB,MAAM,MAAM,G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QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AA7VD,wDA6VC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module HyperModeling\r\n */\r\n\r\nimport { Transform, XAndY } from \"@itwin/core-geometry\";\r\nimport type { AbstractToolbarProps } from \"@itwin/appui-abstract\";\r\nimport {\r\n ChangeFlags, DecorateContext, Decorator, IModelApp, IModelConnection, ScreenViewport, SpatialViewState, TiledGraphicsProvider, ViewClipTool,\r\n} from \"@itwin/core-frontend\";\r\nimport { SectionMarker, SectionMarkerSet } from \"./SectionMarkers\";\r\nimport { SectionDrawingLocationState } from \"./SectionDrawingLocationState\";\r\nimport { createSectionGraphicsProvider } from \"./SectionGraphicsProvider\";\r\nimport { PopupToolbarManager, PopupToolbarProvider } from \"./PopupToolbar\";\r\nimport { HyperModeling } from \"./HyperModeling\";\r\nimport { SectionMarkerConfig } from \"./HyperModelingConfig\";\r\n\r\nasync function createMarkers(vp: ScreenViewport): Promise<SectionMarkerSet | undefined> {\r\n if (!vp.view.isSpatialView())\r\n return undefined;\r\n\r\n const states = await SectionDrawingLocationState.queryAll(vp.iModel);\r\n if (0 === states.length)\r\n return undefined;\r\n\r\n const markers = states.map((state) => new SectionMarker(state));\r\n return new SectionMarkerSet(vp, markers);\r\n}\r\n\r\nclass MarkerToolbarProvider implements PopupToolbarProvider {\r\n private readonly _viewport: ScreenViewport;\r\n public readonly marker: SectionMarker;\r\n public readonly toolbarProps: AbstractToolbarProps;\r\n public readonly onToolbarItemExecuted: (id: string) => void;\r\n\r\n public constructor(marker: SectionMarker, decorator: HyperModelingDecorator) {\r\n this.marker = marker;\r\n this._viewport = decorator.viewport;\r\n this.toolbarProps = HyperModeling.markerHandler.getToolbarProps(marker, decorator);\r\n this.onToolbarItemExecuted = (id) => HyperModeling.markerHandler.executeCommand(id, marker, decorator); // eslint-disable-line @typescript-eslint/promise-function-async\r\n }\r\n\r\n public get overToolbarHotspot() {\r\n return this.marker.isHilited;\r\n }\r\n\r\n public get toolbarLocation(): XAndY {\r\n return IModelApp.uiAdmin.createXAndY(this.marker.rect.right, this.marker.rect.top);\r\n }\r\n\r\n public get htmlElement() {\r\n return this._viewport.canvas;\r\n }\r\n}\r\n\r\n/** A [Decorator]($frontend) that displays a [[SectionMarker]] for each [SectionDrawingLocation]($backend) in the view.\r\n * Clicking on a marker toggles the section and the display of associated 2d graphics.\r\n * Hovering over a marker opens a mini toolbar with additional interactions.\r\n * @see [[SectionMarkerHandler]] to customize the marker interactions.\r\n * @see [[HyperModeling.startOrStop]] to enable or disable the decorator for a viewport.\r\n * @public\r\n */\r\nexport class HyperModelingDecorator implements Decorator {\r\n /** The set of [[SectionMarker]]s controlled by this decorator. */\r\n public readonly markers: SectionMarkerSet;\r\n private _config: SectionMarkerConfig;\r\n private readonly _removeEventListeners = new Array<() => void>();\r\n private readonly _iModel: IModelConnection;\r\n private _needSync = false;\r\n private _toolbarProvider?: MarkerToolbarProvider;\r\n private _tiledGraphicsProvider?: TiledGraphicsProvider;\r\n private _activeMarker?: SectionMarker;\r\n private _appliedSpatialView?: SpatialViewState;\r\n /** @internal */\r\n public syncImmediately = false;\r\n\r\n /** Create a new decorator and register it with the [ViewManager]($frontend). Typically invoked indirectly via [[HyperModeling.startOrStop]]. */\r\n public static async create(vp: ScreenViewport, config: SectionMarkerConfig): Promise<HyperModelingDecorator | undefined> {\r\n const markers = await createMarkers(vp);\r\n return undefined !== markers ? new HyperModelingDecorator(markers, config) : undefined;\r\n }\r\n\r\n /** Obtain the decorator associated with the specified viewport, if any. */\r\n public static getForViewport(vp: ScreenViewport): HyperModelingDecorator | undefined {\r\n for (const decorator of IModelApp.viewManager.decorators)\r\n if (decorator instanceof HyperModelingDecorator && decorator.viewport === vp)\r\n return decorator;\r\n\r\n return undefined;\r\n }\r\n\r\n /** The viewport into which this decorator draws its [[SectionMarker]]s. */\r\n public get viewport(): ScreenViewport {\r\n return this.markers.viewport;\r\n }\r\n\r\n /** The currently active marker. A marker typically becomes active when the user clicks on it.\r\n * @see [[setActiveMarker]] to change the active marker without user interaction.\r\n */\r\n public get activeMarker(): SectionMarker | undefined {\r\n return this._activeMarker;\r\n }\r\n\r\n /** @internal */\r\n public get config(): SectionMarkerConfig {\r\n return this._config;\r\n }\r\n\r\n /** Replaces the current marker display configuration, overwriting all previous settings. Passing `undefined` resets all settings to defaults.\r\n * @see [[updateConfiguration]] to override specific aspects of the configuration\r\n * @see [[HyperModeling.replaceConfiguration]] to replace the global configuration.\r\n */\r\n public replaceConfiguration(config?: SectionMarkerConfig): void {\r\n this._config = config ? { ...config } : {};\r\n this.requestSync();\r\n }\r\n\r\n /** Overrides specific aspects of the current marker display configuration.\r\n * Any field that is not `undefined` will be replaced in the current configuration; the rest will retain their current values.\r\n * @see [[replaceConfiguration]] to override all settings.\r\n * @see [[HyperModeling.updateConfiguration]] to update the global configuration.\r\n */\r\n public updateConfiguration(config: SectionMarkerConfig): void {\r\n this._config = {\r\n ignoreModelSelector: config.ignoreModelSelector ?? this._config.ignoreModelSelector,\r\n ignoreCategorySelector: config.ignoreCategorySelector ?? this._config.ignoreCategorySelector,\r\n hiddenSectionTypes: config.hiddenSectionTypes ?? this._config.hiddenSectionTypes,\r\n };\r\n\r\n this.requestSync();\r\n }\r\n\r\n /** Sets the currently active marker. This function is invoked when the user clicks on a marker, but may also be called manually to produce the same result.\r\n * Changing the active marker first deactivates the currently active marker, if any; then activates the specified marker, if supplied.\r\n * Returns false if marker activation fails.\r\n * @see [[activeMarker]] to obtain the currently active section marker.\r\n * @see [[SectionMarkerHandler.activateMarker]] to control what happens when a marker is activated.\r\n * @see [[SectionMarkerHandler.deactivateMarker]] to control what happens when a marker is deactivated.\r\n */\r\n public async setActiveMarker(marker: SectionMarker | undefined): Promise<boolean> {\r\n if (marker === this.activeMarker)\r\n return true;\r\n\r\n if (this.activeMarker) {\r\n this.activeMarker.setActive(false);\r\n await HyperModeling.markerHandler.deactivateMarker(this.activeMarker, this);\r\n this._activeMarker = undefined;\r\n }\r\n\r\n if (marker) {\r\n if (!await HyperModeling.markerHandler.activateMarker(marker, this)) {\r\n this.requestSync();\r\n return false;\r\n }\r\n\r\n marker.setActive(true);\r\n this._activeMarker = marker;\r\n }\r\n\r\n this.requestSync();\r\n return true;\r\n }\r\n\r\n /** @internal */\r\n public readonly useCachedDecorations = true;\r\n\r\n /** @internal */\r\n public decorate(context: DecorateContext): void {\r\n if (this.viewport.view.is3d())\r\n this.markers.addDecoration(context);\r\n }\r\n\r\n private constructor(markers: SectionMarkerSet, config: SectionMarkerConfig) {\r\n this.markers = markers;\r\n this._config = { ...config };\r\n this._iModel = this.viewport.iModel;\r\n\r\n this.viewport.onChangeView.addOnce(() => {\r\n this.requestSync();\r\n });\r\n\r\n this._removeEventListeners.push(this.viewport.onViewportChanged.addListener((_, changeFlags) => this.onViewportChanged(changeFlags)));\r\n this._removeEventListeners.push(this.viewport.onDisposed.addListener(() => this.dispose()));\r\n\r\n for (const marker of markers.markers) {\r\n marker.onMouseEnterEvent.addListener((mkr) => this.showToolbarAfterTimeout(mkr));\r\n marker.onMouseButtonEvent.addListener((mkr) => this.toggleMarker(mkr)); // eslint-disable-line @typescript-eslint/promise-function-async\r\n }\r\n\r\n this.updateMarkerVisibility();\r\n IModelApp.viewManager.addDecorator(this);\r\n }\r\n\r\n private onViewportChanged(changeFlags: ChangeFlags): void {\r\n if (this.viewport.iModel !== this._iModel) {\r\n this.dispose();\r\n return;\r\n }\r\n\r\n if (changeFlags.viewedCategories || changeFlags.viewedModels || changeFlags.viewedCategoriesPerModel)\r\n this.requestSync();\r\n\r\n if (changeFlags.viewState) {\r\n // If we're looking at a different view now, and we did not initiate that, turn off the active marker.\r\n if (this.viewport.view !== this._appliedSpatialView)\r\n this.setActiveMarker(undefined); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n else\r\n this._appliedSpatialView = undefined;\r\n }\r\n }\r\n\r\n private async toggleMarker(marker: SectionMarker): Promise<void> {\r\n await this.setActiveMarker(marker === this.activeMarker ? undefined : marker);\r\n }\r\n\r\n private dropTiledGraphicsProvider(): void {\r\n if (undefined === this._tiledGraphicsProvider)\r\n return;\r\n\r\n this.viewport.dropTiledGraphicsProvider(this._tiledGraphicsProvider);\r\n this._tiledGraphicsProvider = undefined;\r\n }\r\n\r\n /** @internal */\r\n public dispose(): void {\r\n if (!IModelApp.viewManager.dropDecorator(this))\r\n return;\r\n\r\n for (const remove of this._removeEventListeners)\r\n remove();\r\n\r\n this.dropTiledGraphicsProvider();\r\n }\r\n\r\n private showToolbarAfterTimeout(marker: SectionMarker): void {\r\n if (this._toolbarProvider?.marker !== marker)\r\n this._toolbarProvider = new MarkerToolbarProvider(marker, this);\r\n\r\n PopupToolbarManager.showToolbarAfterTimeout(this._toolbarProvider);\r\n }\r\n\r\n /** Toggles whether the clip volume associated with the specified marker is applied to the view. */\r\n public toggleClipVolume(marker: SectionMarker, enable: boolean): void {\r\n ViewClipTool.enableClipVolume(this.viewport);\r\n ViewClipTool.setViewClip(this.viewport, enable ? marker.state.clip : undefined);\r\n }\r\n\r\n /** Toggles the specified section marker.\r\n * Enabling the section applies the frustum and clip volume of the marker's spatial view to the viewport, and displays the 2d section graphics and sheet annotations.\r\n * Disabling the section disables the clip volume and 2d graphics.\r\n * @see [[toggleClipVolume]] to toggle only the clip volume.\r\n * @see [[toggleAttachment]] to toggle only the attachment graphics.\r\n */\r\n public async toggleSection(marker: SectionMarker, enable: boolean): Promise<boolean> {\r\n if (enable) {\r\n if (this.viewport.view.is3d()) {\r\n // Preserve the view settings; apply only the frustum and clip volume\r\n const spatialView = await marker.state.tryLoadSpatialView();\r\n if (!spatialView)\r\n return false;\r\n\r\n const aligned = await this.alignToSpatialView(marker);\r\n if (!aligned)\r\n return false;\r\n\r\n this.toggleClipVolume(marker, true);\r\n } else if (!await this.applySpatialView(marker)) {\r\n return false;\r\n }\r\n } else {\r\n this.toggleClipVolume(marker, false);\r\n }\r\n\r\n this.requestSync();\r\n return this.toggleAttachment(marker, enable);\r\n }\r\n\r\n /** Toggles display of 2d section graphics and sheet annotations for the specified marker.\r\n * @see [[toggleSection]] to apply the spatial view and clip volume in addition to the attachment graphics.\r\n */\r\n public async toggleAttachment(marker: SectionMarker, enable: boolean): Promise<boolean> {\r\n this.dropTiledGraphicsProvider();\r\n if (enable) {\r\n this._tiledGraphicsProvider = await createSectionGraphicsProvider(marker.state);\r\n this.viewport.addTiledGraphicsProvider(this._tiledGraphicsProvider);\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /** Aligns the viewport to face the specified marker's section plane. */\r\n public alignView(marker: SectionMarker): void {\r\n const placement = marker.state.placement.transform;\r\n const origin = placement.origin;\r\n const matrix = placement.matrix;\r\n\r\n const vp = this.viewport;\r\n const targetMatrix = matrix.multiplyMatrixMatrix(vp.rotation);\r\n const rotateTransform = Transform.createFixedPointAndMatrix(origin, targetMatrix);\r\n\r\n const startFrustum = vp.getFrustum();\r\n const newFrustum = startFrustum.clone();\r\n newFrustum.multiply(rotateTransform);\r\n\r\n if (startFrustum.equals(newFrustum))\r\n return;\r\n\r\n vp.view.setupFromFrustum(newFrustum);\r\n vp.synchWithView();\r\n vp.animateFrustumChange();\r\n }\r\n\r\n /** Opens the marker's drawing view in the decorator's viewport. Returns false if the drawing view could not be loaded. */\r\n public async openSection(marker: SectionMarker): Promise<boolean> {\r\n const viewState = await marker.state.tryLoadDrawingView();\r\n if (viewState)\r\n this.viewport.changeView(viewState);\r\n\r\n return undefined !== viewState;\r\n }\r\n\r\n /** Opens marker's sheet view in the decorator's viewport and zooms in on the associated [ViewAttachment]($backend). Returns false if no view\r\n * attachment exists or the sheet view could not be loaded.\r\n */\r\n public async openSheet(marker: SectionMarker): Promise<boolean> {\r\n if (undefined === marker.state.viewAttachment)\r\n return false;\r\n\r\n const viewState = await marker.state.tryLoadSheetView();\r\n if (!viewState)\r\n return false;\r\n\r\n this.viewport.changeView(viewState);\r\n await this.viewport.zoomToElements(marker.state.viewAttachment.id);\r\n return true;\r\n }\r\n\r\n /** Aligns the view to match the frustum of the spatial view associated with the specified marker.\r\n * @param marker The marker whose spatial view's frustum should be applied.\r\n * @returns false if the frustum could not be applied, e.g. because the spatial view could not be loaded or the viewport is viewing a 2d model.\r\n * @see [[alignView]] to align to the *section plane*, which may differ.\r\n * @see [[toggleSection]] to also apply the clip volume.\r\n */\r\n public async alignToSpatialView(marker: SectionMarker): Promise<boolean> {\r\n if (!this.viewport.view.is3d())\r\n return false;\r\n\r\n const spatialView = await marker.state.tryLoadSpatialView();\r\n if (!spatialView)\r\n return false;\r\n\r\n this.viewport.view.setOrigin(spatialView.getOrigin());\r\n this.viewport.view.setExtents(spatialView.getExtents());\r\n this.viewport.view.setRotation(spatialView.getRotation());\r\n this.viewport.synchWithView({ animateFrustumChange: true });\r\n\r\n return true;\r\n }\r\n\r\n /** Applies the marker's spatial view - including its clip volume - to the decorator's viewport.\r\n * Returns false if the spatial view could not be loaded.\r\n * @see [[toggleSection]].\r\n * @see [[toggleClipVolume]].\r\n */\r\n public async applySpatialView(marker: SectionMarker): Promise<boolean> {\r\n const viewState = await marker.state.tryLoadSpatialView();\r\n if (viewState) {\r\n this._appliedSpatialView = viewState;\r\n this.viewport.changeView(viewState);\r\n }\r\n\r\n return undefined !== viewState;\r\n }\r\n\r\n /** Request that the visibility of the section markers be recomputed. It is only necessary to call this if you have overridden [[SectionMarkerHandler.isMarkerVisible]]; if so, you should invoke\r\n * this method when the criteria governing your `isMarkerVisible` method have changed.\r\n */\r\n public requestSync(): void {\r\n if (this.syncImmediately) {\r\n this.sync();\r\n } else if (!this._needSync) {\r\n this._needSync = true;\r\n requestAnimationFrame(() => this.sync());\r\n }\r\n }\r\n\r\n private sync(): void {\r\n this._needSync = false;\r\n if (HyperModeling.isInitialized && this.viewport.view.is3d() && this.updateMarkerVisibility()) {\r\n this.markers.markDirty();\r\n this.viewport.invalidateCachedDecorations(this);\r\n }\r\n }\r\n\r\n private isMarkerVisible(marker: SectionMarker): boolean {\r\n if (undefined !== this.activeMarker)\r\n return marker === this.activeMarker;\r\n\r\n return HyperModeling.markerHandler.isMarkerVisible(marker, this, this._config);\r\n }\r\n\r\n private updateMarkerVisibility(): boolean {\r\n let changed = false;\r\n for (const marker of this.markers.markers) {\r\n const wasVisible = marker.visible;\r\n marker.visible = this.isMarkerVisible(marker);\r\n changed = changed || (marker.visible !== wasVisible);\r\n }\r\n\r\n return changed;\r\n }\r\n}\r\n"]}
@@ -2,7 +2,7 @@
2
2
  * @module HyperModeling
3
3
  */
4
4
  import { XAndY } from "@itwin/core-geometry";
5
- import { AbstractToolbarProps } from "@itwin/appui-abstract";
5
+ import type { AbstractToolbarProps } from "@itwin/appui-abstract";
6
6
  /** @internal */
7
7
  export interface PopupToolbarProvider {
8
8
  toolbarProps: AbstractToolbarProps;
@@ -1 +1 @@
1
- {"version":3,"file":"PopupToolbar.d.ts","sourceRoot":"","sources":["../../src/PopupToolbar.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAG7D,gBAAgB;AAChB,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,oBAAoB,CAAC;IACnC,kBAAkB,EAAE,OAAO,CAAC;IAC5B,eAAe,EAAE,KAAK,CAAC;IACvB,WAAW,EAAE,WAAW,GAAG,SAAS,CAAC;IACrC,qBAAqB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;CACzC;AAED,gBAAgB;AAChB,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAuB;IAChD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAuB;IAE/C,OAAO,CAAC,MAAM,CAAC,IAAI;IAenB,OAAO,CAAC,MAAM,CAAC,aAAa,CAM1B;IAEF,OAAO,CAAC,MAAM,CAAC,OAAO,CAIpB;IAEF,OAAO,CAAC,MAAM,CAAC,KAAK;IAKpB,OAAO,CAAC,MAAM,CAAC,iBAAiB;WAUlB,uBAAuB,CAAC,QAAQ,EAAE,oBAAoB,GAAG,IAAI;CAO5E"}
1
+ {"version":3,"file":"PopupToolbar.d.ts","sourceRoot":"","sources":["../../src/PopupToolbar.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAGlE,gBAAgB;AAChB,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,oBAAoB,CAAC;IACnC,kBAAkB,EAAE,OAAO,CAAC;IAC5B,eAAe,EAAE,KAAK,CAAC;IACvB,WAAW,EAAE,WAAW,GAAG,SAAS,CAAC;IACrC,qBAAqB,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,CAAC;CACzC;AAED,gBAAgB;AAChB,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,MAAM,CAAC,SAAS,CAAC,CAAuB;IAChD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAuB;IAE/C,OAAO,CAAC,MAAM,CAAC,IAAI;IAenB,OAAO,CAAC,MAAM,CAAC,aAAa,CAM1B;IAEF,OAAO,CAAC,MAAM,CAAC,OAAO,CAIpB;IAEF,OAAO,CAAC,MAAM,CAAC,KAAK;IAKpB,OAAO,CAAC,MAAM,CAAC,iBAAiB;WAUlB,uBAAuB,CAAC,QAAQ,EAAE,oBAAoB,GAAG,IAAI;CAO5E"}
@@ -1 +1 @@
1
- {"version":3,"file":"PopupToolbar.js","sourceRoot":"","sources":["../../src/PopupToolbar.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAIH,wDAAiD;AAWjD,gBAAgB;AAChB,MAAa,mBAAmB;IA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U,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC;IACrC,CAAC;;AAtDH,kDAuDC;AApCgB,iCAAa,GAAG,CAAC,IAAS,EAAE,EAAE;IAC3C,MAAM,GAAG,GAAG,mBAAmB,CAAC;IAChC,IAAI,GAAG,CAAC,QAAQ;QACd,GAAG,CAAC,QAAQ,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAE9C,GAAG,CAAC,KAAK,EAAE,CAAC;AACd,CAAC,CAAC;AAEa,2BAAO,GAAG,GAAG,EAAE;IAC5B,MAAM,GAAG,GAAG,mBAAmB,CAAC;IAChC,IAAI,CAAC,GAAG,CAAC,QAAQ,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,kBAAkB;QACnD,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,wCAAwC;AACzD,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module HyperModeling\r\n */\r\n\r\nimport { XAndY } from \"@itwin/core-geometry\";\r\nimport { AbstractToolbarProps } from \"@itwin/appui-abstract\";\r\nimport { IModelApp } from \"@itwin/core-frontend\";\r\n\r\n/** @internal */\r\nexport interface PopupToolbarProvider {\r\n toolbarProps: AbstractToolbarProps;\r\n overToolbarHotspot: boolean;\r\n toolbarLocation: XAndY;\r\n htmlElement: HTMLElement | undefined;\r\n onToolbarItemExecuted(id: string): void;\r\n}\r\n\r\n/** @internal */\r\nexport class PopupToolbarManager {\r\n private static _provider?: PopupToolbarProvider;\r\n private static _current?: PopupToolbarProvider;\r\n\r\n private static show(): boolean {\r\n const prov = this._provider;\r\n if (!prov || !prov.overToolbarHotspot)\r\n return false;\r\n\r\n const admin = IModelApp.uiAdmin;\r\n if (!admin.showToolbar(prov.toolbarProps, prov.toolbarLocation, admin.createXAndY(0, 0), this._itemExecuted, this._cancel, undefined, prov.htmlElement))\r\n return false;\r\n\r\n this._current = this._provider;\r\n this._provider = undefined;\r\n this.closeAfterTimeout();\r\n return true;\r\n }\r\n\r\n private static _itemExecuted = (item: any) => {\r\n const mgr = PopupToolbarManager;\r\n if (mgr._current)\r\n mgr._current.onToolbarItemExecuted(item.id);\r\n\r\n mgr.close();\r\n };\r\n\r\n private static _cancel = () => {\r\n const mgr = PopupToolbarManager;\r\n if (!mgr._current || !mgr._current.overToolbarHotspot)\r\n mgr.close(); // Don't hide when click is over hotspot\r\n };\r\n\r\n private static close(): boolean {\r\n this._current = undefined;\r\n return IModelApp.uiAdmin.hideToolbar();\r\n }\r\n\r\n private static closeAfterTimeout(): void {\r\n if (!this._current)\r\n return;\r\n\r\n if (this._current.overToolbarHotspot || !IModelApp.toolAdmin.cursorView)\r\n setTimeout(() => this.closeAfterTimeout(), 500); // Cursor not in view or over hotspot, check again\r\n else\r\n this.close();\r\n }\r\n\r\n public static showToolbarAfterTimeout(provider: PopupToolbarProvider): void {\r\n if (this._current === provider)\r\n return;\r\n\r\n this._provider = provider;\r\n setTimeout(() => this.show(), 500);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"PopupToolbar.js","sourceRoot":"","sources":["../../src/PopupToolbar.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAIH,wDAAiD;AAWjD,gBAAgB;AAChB,MAAa,mBAAmB;IAItB,MAAM,CAAC,IAAI;QACjB,MAAM,IAAI,GAAG,IAAI,CAAC,SAAS,CAAC;QAC5B,IAAI,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,kBAAkB;YACnC,OAAO,KAAK,CAAC;QAEf,MAAM,KAAK,GAAG,yBAAS,CAAC,OAAO,CAAC;QAChC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,YAAY,EAAE,IAAI,CAAC,eAAe,EAAE,KAA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AE9C,GAAG,CAAC,KAAK,EAAE,CAAC;AACd,CAAC,CAAC;AAEa,2BAAO,GAAG,GAAG,EAAE;IAC5B,MAAM,GAAG,GAAG,mBAAmB,CAAC;IAChC,IAAI,CAAC,GAAG,CAAC,QAAQ,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,kBAAkB;QACnD,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,wCAAwC;AACzD,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module HyperModeling\r\n */\r\n\r\nimport { XAndY } from \"@itwin/core-geometry\";\r\nimport type { AbstractToolbarProps } from \"@itwin/appui-abstract\";\r\nimport { IModelApp } from \"@itwin/core-frontend\";\r\n\r\n/** @internal */\r\nexport interface PopupToolbarProvider {\r\n toolbarProps: AbstractToolbarProps;\r\n overToolbarHotspot: boolean;\r\n toolbarLocation: XAndY;\r\n htmlElement: HTMLElement | undefined;\r\n onToolbarItemExecuted(id: string): void;\r\n}\r\n\r\n/** @internal */\r\nexport class PopupToolbarManager {\r\n private static _provider?: PopupToolbarProvider;\r\n private static _current?: PopupToolbarProvider;\r\n\r\n private static show(): boolean {\r\n const prov = this._provider;\r\n if (!prov || !prov.overToolbarHotspot)\r\n return false;\r\n\r\n const admin = IModelApp.uiAdmin;\r\n if (!admin.showToolbar(prov.toolbarProps, prov.toolbarLocation, admin.createXAndY(0, 0), this._itemExecuted, this._cancel, undefined, prov.htmlElement))\r\n return false;\r\n\r\n this._current = this._provider;\r\n this._provider = undefined;\r\n this.closeAfterTimeout();\r\n return true;\r\n }\r\n\r\n private static _itemExecuted = (item: any) => {\r\n const mgr = PopupToolbarManager;\r\n if (mgr._current)\r\n mgr._current.onToolbarItemExecuted(item.id);\r\n\r\n mgr.close();\r\n };\r\n\r\n private static _cancel = () => {\r\n const mgr = PopupToolbarManager;\r\n if (!mgr._current || !mgr._current.overToolbarHotspot)\r\n mgr.close(); // Don't hide when click is over hotspot\r\n };\r\n\r\n private static close(): boolean {\r\n this._current = undefined;\r\n return IModelApp.uiAdmin.hideToolbar();\r\n }\r\n\r\n private static closeAfterTimeout(): void {\r\n if (!this._current)\r\n return;\r\n\r\n if (this._current.overToolbarHotspot || !IModelApp.toolAdmin.cursorView)\r\n setTimeout(() => this.closeAfterTimeout(), 500); // Cursor not in view or over hotspot, check again\r\n else\r\n this.close();\r\n }\r\n\r\n public static showToolbarAfterTimeout(provider: PopupToolbarProvider): void {\r\n if (this._current === provider)\r\n return;\r\n\r\n this._provider = provider;\r\n setTimeout(() => this.show(), 500);\r\n }\r\n}\r\n"]}
@@ -1,7 +1,7 @@
1
1
  /** @packageDocumentation
2
2
  * @module HyperModeling
3
3
  */
4
- import { AbstractToolbarProps } from "@itwin/appui-abstract";
4
+ import type { AbstractToolbarProps } from "@itwin/appui-abstract";
5
5
  import { SectionMarker } from "./SectionMarkers";
6
6
  import { SectionMarkerConfig } from "./HyperModelingConfig";
7
7
  import { HyperModelingDecorator } from "./HyperModelingDecorator";
@@ -1 +1 @@
1
- {"version":3,"file":"SectionMarkerHandler.d.ts","sourceRoot":"","sources":["../../src/SectionMarkerHandler.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAElE;;;;;;;;;;GAUG;AACH,qBAAa,oBAAoB;IAC/B;;OAEG;IACU,cAAc,CAAC,MAAM,EAAE,aAAa,EAAE,SAAS,EAAE,sBAAsB,GAAG,OAAO,CAAC,OAAO,CAAC;IAIvG;;OAEG;IACU,gBAAg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9FD,oDA8FC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module HyperModeling\r\n */\r\n\r\nimport { IModelApp } from \"@itwin/core-frontend\";\r\nimport { AbstractToolbarProps } from \"@itwin/appui-abstract\";\r\nimport { SectionMarker } from \"./SectionMarkers\";\r\nimport { SectionMarkerConfig } from \"./HyperModelingConfig\";\r\nimport { HyperModelingDecorator } from \"./HyperModelingDecorator\";\r\n\r\n/** Supplies interactions with [[SectionMarker]]s, including a mini-toolbar displayed when the mouse hovers over a marker and what action occurs when the user clicks a marker.\r\n * The base implementation supplies the following interactions:\r\n * * Click: Toggle display of the section graphics and clip volume; apply the section's spatial view if toggling on.\r\n * * Toolbar:\r\n * * Apply Section: Applies the section location's spatial view to the viewport and displays the 2d section graphics.\r\n * * Open Drawing: Navigates to the section drawing view. By default, this applies the section drawing view to the viewport.\r\n * * Open Sheet: Navigates to the [ViewAttachment]($backend) of the section drawing on a [Sheet]($backend). Disabled if no such attachment exists.\r\n * @see [[HyperModelingConfig]] to override the default handler by supplying a subclass of `SectionMarkerHandler`.\r\n * @see [[HyperModelingDecorator]] for various methods that might be usefully wired up to marker click or toolbar actions.\r\n * @public\r\n */\r\nexport class SectionMarkerHandler {\r\n /** Respond to activation of the specified marker. Return true if the marker should become the active marker - i.e., if the marker was successfully activated.\r\n * @see [[SectionMarkerHandler.deactivateMarker]].\r\n */\r\n public async activateMarker(marker: SectionMarker, decorator: HyperModelingDecorator): Promise<boolean> {\r\n return decorator.toggleSection(marker, true);\r\n }\r\n\r\n /** Respond to deactivation of the specified marker. Invoked when the user clicks on the marker while it is the active marker.\r\n * This should perform the inverse of [[SectionMarkerHandler.activateMarker]]. The marker becomes inactive as a result.\r\n */\r\n public async deactivateMarker(marker: SectionMarker, decorator: HyperModelingDecorator): Promise<void> {\r\n await decorator.toggleSection(marker, false);\r\n }\r\n\r\n /** Return toolbar items for the specified marker. If the array of toolbar items is empty, no toolbar will be displayed.\r\n * @see [[executeCommand]] to implement each toolbar command.\r\n */\r\n public getToolbarProps(marker: SectionMarker, _decorator: HyperModelingDecorator): AbstractToolbarProps {\r\n const localization = IModelApp.localization;\r\n return {\r\n items: [\r\n {\r\n id: \"apply_view\",\r\n itemPriority: 10,\r\n label: localization.getLocalizedString(\"HyperModeling:Message.ApplyView\"),\r\n icon: \"icon-spatial-view-apply\",\r\n execute: () => { },\r\n isDisabled: false,\r\n },\r\n {\r\n id: \"open_section\",\r\n itemPriority: 20,\r\n label: localization.getLocalizedString(\"HyperModeling:Message.OpenSection\"),\r\n icon: \"icon-plan-drawing\",\r\n execute: () => { },\r\n isDisabled: false,\r\n },\r\n {\r\n id: \"open_sheet\",\r\n itemPriority: 30,\r\n label: localization.getLocalizedString(\"HyperModeling:Message.OpenSheet\"),\r\n icon: \"icon-plan-floor\",\r\n execute: () => { },\r\n isDisabled: undefined === marker.state.viewAttachment?.viewId,\r\n },\r\n ],\r\n };\r\n }\r\n\r\n /** Execute the command associated with the specified tool bar item.\r\n * @see [[getToolbarProps]] to define the set of commands.\r\n */\r\n public async executeCommand(commandId: string, marker: SectionMarker, decorator: HyperModelingDecorator): Promise<void> {\r\n switch (commandId) {\r\n case \"apply_view\":\r\n await decorator.applySpatialView(marker);\r\n break;\r\n case \"open_section\":\r\n await decorator.openSection(marker);\r\n break;\r\n case \"open_sheet\":\r\n await decorator.openSheet(marker);\r\n break;\r\n }\r\n }\r\n\r\n /** Customize which markers are visible. [[HyperModelingDecorator]] determines marker visibility as follows:\r\n * - If a marker is currently active (selected), only that marker is visible.\r\n * - Otherwise, the marker is visible if this method returns `true`.\r\n * The default implementation of this method determines visibility based on the [[SectionMarkerConfig]] as follows.\r\n * - If the marker is of a type included in the config's `hiddenSectionTypes`, it is invisible.\r\n * - If the marker belongs to a model not currently displayed in the viewport and the config's `ignoreModelSelector` is false, it is invisible.\r\n * - If the marker belongs to a category not currently displayed in the viewport and the config's `ignoreCategorySelector` is false, it is invisible,\r\n * - Otherwise, the marker is visible, unless this method returns `false`.\r\n * The default implementation of this method always returns `true`\r\n * @param marker The marker whose visibility is to be determined.\r\n * @param decorator The hypermodeling decorator to which the marker belongs.\r\n * @param config The configuration controlling marker visibility based on [SectionType]($common), [ModelSelectorState]($frontend), and [CategorySelectorState]($frontend).\r\n * @returns true if the marker should be displayed; false to make it invisible.\r\n * @see [[HyperModelingDecorator.requestSync]] to force the decorator to reevaluate marker visibility when the criterion used by your implementation of this method changes.\r\n */\r\n public isMarkerVisible(marker: SectionMarker, decorator: HyperModelingDecorator, config: SectionMarkerConfig): boolean {\r\n if (undefined !== config.hiddenSectionTypes && config.hiddenSectionTypes.includes(marker.state.sectionType))\r\n return false;\r\n\r\n if (!config.ignoreCategorySelector && !decorator.viewport.view.viewsCategory(marker.state.category))\r\n return false;\r\n\r\n if (!config.ignoreModelSelector && !decorator.viewport.view.viewsModel(marker.state.model))\r\n return false;\r\n\r\n return true;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"SectionMarkerHandler.js","sourceRoot":"","sources":["../../src/SectionMarkerHandler.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,wDAAiD;AAMjD;;;;;;;;;;GAUG;AACH,MAAa,oBAAoB;IAC/B;;OAEG;IACI,KAAK,CAAC,cAAc,CAAC,MAAqB,EAAE,SAAiC;QAClF,OAAO,SAAS,CAAC,aAAa,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;IAC/C,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,gBAAgB,CAAC,MAAqB,EAAE,SAAiC;QACpF,MAAM,SAAS,CAAC,aAAa,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;IAC/C,CAAC;IAED;;OAEG;IACI,eAAe,CAAC,MAAqB,EAAE,UAAkC;;QAC9E,MAAM,YAAY,GAAG,yBAAS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iC,EAAE,MAA2B;QAC1G,IAAI,SAAS,KAAK,MAAM,CAAC,kBAAkB,IAAI,MAAM,CAAC,kBAAkB,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC;YACzG,OAAO,KAAK,CAAC;QAEf,IAAI,CAAC,MAAM,CAAC,sBAAsB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC;YACjG,OAAO,KAAK,CAAC;QAEf,IAAI,CAAC,MAAM,CAAC,mBAAmB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC;YACxF,OAAO,KAAK,CAAC;QAEf,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA9FD,oDA8FC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module HyperModeling\r\n */\r\n\r\nimport { IModelApp } from \"@itwin/core-frontend\";\r\nimport type { AbstractToolbarProps } from \"@itwin/appui-abstract\";\r\nimport { SectionMarker } from \"./SectionMarkers\";\r\nimport { SectionMarkerConfig } from \"./HyperModelingConfig\";\r\nimport { HyperModelingDecorator } from \"./HyperModelingDecorator\";\r\n\r\n/** Supplies interactions with [[SectionMarker]]s, including a mini-toolbar displayed when the mouse hovers over a marker and what action occurs when the user clicks a marker.\r\n * The base implementation supplies the following interactions:\r\n * * Click: Toggle display of the section graphics and clip volume; apply the section's spatial view if toggling on.\r\n * * Toolbar:\r\n * * Apply Section: Applies the section location's spatial view to the viewport and displays the 2d section graphics.\r\n * * Open Drawing: Navigates to the section drawing view. By default, this applies the section drawing view to the viewport.\r\n * * Open Sheet: Navigates to the [ViewAttachment]($backend) of the section drawing on a [Sheet]($backend). Disabled if no such attachment exists.\r\n * @see [[HyperModelingConfig]] to override the default handler by supplying a subclass of `SectionMarkerHandler`.\r\n * @see [[HyperModelingDecorator]] for various methods that might be usefully wired up to marker click or toolbar actions.\r\n * @public\r\n */\r\nexport class SectionMarkerHandler {\r\n /** Respond to activation of the specified marker. Return true if the marker should become the active marker - i.e., if the marker was successfully activated.\r\n * @see [[SectionMarkerHandler.deactivateMarker]].\r\n */\r\n public async activateMarker(marker: SectionMarker, decorator: HyperModelingDecorator): Promise<boolean> {\r\n return decorator.toggleSection(marker, true);\r\n }\r\n\r\n /** Respond to deactivation of the specified marker. Invoked when the user clicks on the marker while it is the active marker.\r\n * This should perform the inverse of [[SectionMarkerHandler.activateMarker]]. The marker becomes inactive as a result.\r\n */\r\n public async deactivateMarker(marker: SectionMarker, decorator: HyperModelingDecorator): Promise<void> {\r\n await decorator.toggleSection(marker, false);\r\n }\r\n\r\n /** Return toolbar items for the specified marker. If the array of toolbar items is empty, no toolbar will be displayed.\r\n * @see [[executeCommand]] to implement each toolbar command.\r\n */\r\n public getToolbarProps(marker: SectionMarker, _decorator: HyperModelingDecorator): AbstractToolbarProps {\r\n const localization = IModelApp.localization;\r\n return {\r\n items: [\r\n {\r\n id: \"apply_view\",\r\n itemPriority: 10,\r\n label: localization.getLocalizedString(\"HyperModeling:Message.ApplyView\"),\r\n icon: \"icon-spatial-view-apply\",\r\n execute: () => { },\r\n isDisabled: false,\r\n },\r\n {\r\n id: \"open_section\",\r\n itemPriority: 20,\r\n label: localization.getLocalizedString(\"HyperModeling:Message.OpenSection\"),\r\n icon: \"icon-plan-drawing\",\r\n execute: () => { },\r\n isDisabled: false,\r\n },\r\n {\r\n id: \"open_sheet\",\r\n itemPriority: 30,\r\n label: localization.getLocalizedString(\"HyperModeling:Message.OpenSheet\"),\r\n icon: \"icon-plan-floor\",\r\n execute: () => { },\r\n isDisabled: undefined === marker.state.viewAttachment?.viewId,\r\n },\r\n ],\r\n };\r\n }\r\n\r\n /** Execute the command associated with the specified tool bar item.\r\n * @see [[getToolbarProps]] to define the set of commands.\r\n */\r\n public async executeCommand(commandId: string, marker: SectionMarker, decorator: HyperModelingDecorator): Promise<void> {\r\n switch (commandId) {\r\n case \"apply_view\":\r\n await decorator.applySpatialView(marker);\r\n break;\r\n case \"open_section\":\r\n await decorator.openSection(marker);\r\n break;\r\n case \"open_sheet\":\r\n await decorator.openSheet(marker);\r\n break;\r\n }\r\n }\r\n\r\n /** Customize which markers are visible. [[HyperModelingDecorator]] determines marker visibility as follows:\r\n * - If a marker is currently active (selected), only that marker is visible.\r\n * - Otherwise, the marker is visible if this method returns `true`.\r\n * The default implementation of this method determines visibility based on the [[SectionMarkerConfig]] as follows.\r\n * - If the marker is of a type included in the config's `hiddenSectionTypes`, it is invisible.\r\n * - If the marker belongs to a model not currently displayed in the viewport and the config's `ignoreModelSelector` is false, it is invisible.\r\n * - If the marker belongs to a category not currently displayed in the viewport and the config's `ignoreCategorySelector` is false, it is invisible,\r\n * - Otherwise, the marker is visible, unless this method returns `false`.\r\n * The default implementation of this method always returns `true`\r\n * @param marker The marker whose visibility is to be determined.\r\n * @param decorator The hypermodeling decorator to which the marker belongs.\r\n * @param config The configuration controlling marker visibility based on [SectionType]($common), [ModelSelectorState]($frontend), and [CategorySelectorState]($frontend).\r\n * @returns true if the marker should be displayed; false to make it invisible.\r\n * @see [[HyperModelingDecorator.requestSync]] to force the decorator to reevaluate marker visibility when the criterion used by your implementation of this method changes.\r\n */\r\n public isMarkerVisible(marker: SectionMarker, decorator: HyperModelingDecorator, config: SectionMarkerConfig): boolean {\r\n if (undefined !== config.hiddenSectionTypes && config.hiddenSectionTypes.includes(marker.state.sectionType))\r\n return false;\r\n\r\n if (!config.ignoreCategorySelector && !decorator.viewport.view.viewsCategory(marker.state.category))\r\n return false;\r\n\r\n if (!config.ignoreModelSelector && !decorator.viewport.view.viewsModel(marker.state.model))\r\n return false;\r\n\r\n return true;\r\n }\r\n}\r\n"]}
@@ -1 +1 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YACzB,IAAI,CAAC,QAAQ,CAAC,2BAA2B,CAAC,IAAI,CAAC,CAAC;SACjD;IACH,CAAC;IAEO,eAAe,CAAC,MAAqB;QAC3C,IAAI,SAAS,KAAK,IAAI,CAAC,YAAY;YACjC,OAAO,MAAM,KAAK,IAAI,CAAC,YAAY,CAAC;QAEtC,OAAO,aAAa,CAAC,aAAa,CAAC,eAAe,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACjF,CAAC;IAEO,sBAAsB;QAC5B,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YACzC,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC;YAClC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;YAC9C,OAAO,GAAG,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,KAAK,UAAU,CAAC,CAAC;SACtD;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module HyperModeling\r\n */\r\n\r\nimport { Transform, XAndY } from \"@itwin/core-geometry\";\r\nimport { AbstractToolbarProps } from \"@itwin/appui-abstract\";\r\nimport {\r\n ChangeFlags, DecorateContext, Decorator, IModelApp, IModelConnection, ScreenViewport, SpatialViewState, TiledGraphicsProvider, ViewClipTool,\r\n} from \"@itwin/core-frontend\";\r\nimport { SectionMarker, SectionMarkerSet } from \"./SectionMarkers\";\r\nimport { SectionDrawingLocationState } from \"./SectionDrawingLocationState\";\r\nimport { createSectionGraphicsProvider } from \"./SectionGraphicsProvider\";\r\nimport { PopupToolbarManager, PopupToolbarProvider } from \"./PopupToolbar\";\r\nimport { HyperModeling } from \"./HyperModeling\";\r\nimport { SectionMarkerConfig } from \"./HyperModelingConfig\";\r\n\r\nasync function createMarkers(vp: ScreenViewport): Promise<SectionMarkerSet | undefined> {\r\n if (!vp.view.isSpatialView())\r\n return undefined;\r\n\r\n const states = await SectionDrawingLocationState.queryAll(vp.iModel);\r\n if (0 === states.length)\r\n return undefined;\r\n\r\n const markers = states.map((state) => new SectionMarker(state));\r\n return new SectionMarkerSet(vp, markers);\r\n}\r\n\r\nclass MarkerToolbarProvider implements PopupToolbarProvider {\r\n private readonly _viewport: ScreenViewport;\r\n public readonly marker: SectionMarker;\r\n public readonly toolbarProps: AbstractToolbarProps;\r\n public readonly onToolbarItemExecuted: (id: string) => void;\r\n\r\n public constructor(marker: SectionMarker, decorator: HyperModelingDecorator) {\r\n this.marker = marker;\r\n this._viewport = decorator.viewport;\r\n this.toolbarProps = HyperModeling.markerHandler.getToolbarProps(marker, decorator);\r\n this.onToolbarItemExecuted = (id) => HyperModeling.markerHandler.executeCommand(id, marker, decorator); // eslint-disable-line @typescript-eslint/promise-function-async\r\n }\r\n\r\n public get overToolbarHotspot() {\r\n return this.marker.isHilited;\r\n }\r\n\r\n public get toolbarLocation(): XAndY {\r\n return IModelApp.uiAdmin.createXAndY(this.marker.rect.right, this.marker.rect.top);\r\n }\r\n\r\n public get htmlElement() {\r\n return this._viewport.canvas;\r\n }\r\n}\r\n\r\n/** A [Decorator]($frontend) that displays a [[SectionMarker]] for each [SectionDrawingLocation]($backend) in the view.\r\n * Clicking on a marker toggles the section and the display of associated 2d graphics.\r\n * Hovering over a marker opens a mini toolbar with additional interactions.\r\n * @see [[SectionMarkerHandler]] to customize the marker interactions.\r\n * @see [[HyperModeling.startOrStop]] to enable or disable the decorator for a viewport.\r\n * @public\r\n */\r\nexport class HyperModelingDecorator implements Decorator {\r\n /** The set of [[SectionMarker]]s controlled by this decorator. */\r\n public readonly markers: SectionMarkerSet;\r\n private _config: SectionMarkerConfig;\r\n private readonly _removeEventListeners = new Array<() => void>();\r\n private readonly _iModel: IModelConnection;\r\n private _needSync = false;\r\n private _toolbarProvider?: MarkerToolbarProvider;\r\n private _tiledGraphicsProvider?: TiledGraphicsProvider;\r\n private _activeMarker?: SectionMarker;\r\n private _appliedSpatialView?: SpatialViewState;\r\n /** @internal */\r\n public syncImmediately = false;\r\n\r\n /** Create a new decorator and register it with the [ViewManager]($frontend). Typically invoked indirectly via [[HyperModeling.startOrStop]]. */\r\n public static async create(vp: ScreenViewport, config: SectionMarkerConfig): Promise<HyperModelingDecorator | undefined> {\r\n const markers = await createMarkers(vp);\r\n return undefined !== markers ? new HyperModelingDecorator(markers, config) : undefined;\r\n }\r\n\r\n /** Obtain the decorator associated with the specified viewport, if any. */\r\n public static getForViewport(vp: ScreenViewport): HyperModelingDecorator | undefined {\r\n for (const decorator of IModelApp.viewManager.decorators)\r\n if (decorator instanceof HyperModelingDecorator && decorator.viewport === vp)\r\n return decorator;\r\n\r\n return undefined;\r\n }\r\n\r\n /** The viewport into which this decorator draws its [[SectionMarker]]s. */\r\n public get viewport(): ScreenViewport {\r\n return this.markers.viewport;\r\n }\r\n\r\n /** The currently active marker. A marker typically becomes active when the user clicks on it.\r\n * @see [[setActiveMarker]] to change the active marker without user interaction.\r\n */\r\n public get activeMarker(): SectionMarker | undefined {\r\n return this._activeMarker;\r\n }\r\n\r\n /** @internal */\r\n public get config(): SectionMarkerConfig {\r\n return this._config;\r\n }\r\n\r\n /** Replaces the current marker display configuration, overwriting all previous settings. Passing `undefined` resets all settings to defaults.\r\n * @see [[updateConfiguration]] to override specific aspects of the configuration\r\n * @see [[HyperModeling.replaceConfiguration]] to replace the global configuration.\r\n */\r\n public replaceConfiguration(config?: SectionMarkerConfig): void {\r\n this._config = config ? { ...config } : {};\r\n this.requestSync();\r\n }\r\n\r\n /** Overrides specific aspects of the current marker display configuration.\r\n * Any field that is not `undefined` will be replaced in the current configuration; the rest will retain their current values.\r\n * @see [[replaceConfiguration]] to override all settings.\r\n * @see [[HyperModeling.updateConfiguration]] to update the global configuration.\r\n */\r\n public updateConfiguration(config: SectionMarkerConfig): void {\r\n this._config = {\r\n ignoreModelSelector: config.ignoreModelSelector ?? this._config.ignoreModelSelector,\r\n ignoreCategorySelector: config.ignoreCategorySelector ?? this._config.ignoreCategorySelector,\r\n hiddenSectionTypes: config.hiddenSectionTypes ?? this._config.hiddenSectionTypes,\r\n };\r\n\r\n this.requestSync();\r\n }\r\n\r\n /** Sets the currently active marker. This function is invoked when the user clicks on a marker, but may also be called manually to produce the same result.\r\n * Changing the active marker first deactivates the currently active marker, if any; then activates the specified marker, if supplied.\r\n * Returns false if marker activation fails.\r\n * @see [[activeMarker]] to obtain the currently active section marker.\r\n * @see [[SectionMarkerHandler.activateMarker]] to control what happens when a marker is activated.\r\n * @see [[SectionMarkerHandler.deactivateMarker]] to control what happens when a marker is deactivated.\r\n */\r\n public async setActiveMarker(marker: SectionMarker | undefined): Promise<boolean> {\r\n if (marker === this.activeMarker)\r\n return true;\r\n\r\n if (this.activeMarker) {\r\n this.activeMarker.setActive(false);\r\n await HyperModeling.markerHandler.deactivateMarker(this.activeMarker, this);\r\n this._activeMarker = undefined;\r\n }\r\n\r\n if (marker) {\r\n if (!await HyperModeling.markerHandler.activateMarker(marker, this)) {\r\n this.requestSync();\r\n return false;\r\n }\r\n\r\n marker.setActive(true);\r\n this._activeMarker = marker;\r\n }\r\n\r\n this.requestSync();\r\n return true;\r\n }\r\n\r\n /** @internal */\r\n public readonly useCachedDecorations = true;\r\n\r\n /** @internal */\r\n public decorate(context: DecorateContext): void {\r\n if (this.viewport.view.is3d())\r\n this.markers.addDecoration(context);\r\n }\r\n\r\n private constructor(markers: SectionMarkerSet, config: SectionMarkerConfig) {\r\n this.markers = markers;\r\n this._config = { ...config };\r\n this._iModel = this.viewport.iModel;\r\n\r\n this.viewport.onChangeView.addOnce(() => {\r\n this.requestSync();\r\n });\r\n\r\n this._removeEventListeners.push(this.viewport.onViewportChanged.addListener((_, changeFlags) => this.onViewportChanged(changeFlags)));\r\n this._removeEventListeners.push(this.viewport.onDisposed.addListener(() => this.dispose()));\r\n\r\n for (const marker of markers.markers) {\r\n marker.onMouseEnterEvent.addListener((mkr) => this.showToolbarAfterTimeout(mkr));\r\n marker.onMouseButtonEvent.addListener((mkr) => this.toggleMarker(mkr)); // eslint-disable-line @typescript-eslint/promise-function-async\r\n }\r\n\r\n this.updateMarkerVisibility();\r\n IModelApp.viewManager.addDecorator(this);\r\n }\r\n\r\n private onViewportChanged(changeFlags: ChangeFlags): void {\r\n if (this.viewport.iModel !== this._iModel) {\r\n this.dispose();\r\n return;\r\n }\r\n\r\n if (changeFlags.viewedCategories || changeFlags.viewedModels || changeFlags.viewedCategoriesPerModel)\r\n this.requestSync();\r\n\r\n if (changeFlags.viewState) {\r\n // If we're looking at a different view now, and we did not initiate that, turn off the active marker.\r\n if (this.viewport.view !== this._appliedSpatialView)\r\n this.setActiveMarker(undefined); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n else\r\n this._appliedSpatialView = undefined;\r\n }\r\n }\r\n\r\n private async toggleMarker(marker: SectionMarker): Promise<void> {\r\n await this.setActiveMarker(marker === this.activeMarker ? undefined : marker);\r\n }\r\n\r\n private dropTiledGraphicsProvider(): void {\r\n if (undefined === this._tiledGraphicsProvider)\r\n return;\r\n\r\n this.viewport.dropTiledGraphicsProvider(this._tiledGraphicsProvider);\r\n this._tiledGraphicsProvider = undefined;\r\n }\r\n\r\n /** @internal */\r\n public dispose(): void {\r\n if (!IModelApp.viewManager.dropDecorator(this))\r\n return;\r\n\r\n for (const remove of this._removeEventListeners)\r\n remove();\r\n\r\n this.dropTiledGraphicsProvider();\r\n }\r\n\r\n private showToolbarAfterTimeout(marker: SectionMarker): void {\r\n if (this._toolbarProvider?.marker !== marker)\r\n this._toolbarProvider = new MarkerToolbarProvider(marker, this);\r\n\r\n PopupToolbarManager.showToolbarAfterTimeout(this._toolbarProvider);\r\n }\r\n\r\n /** Toggles whether the clip volume associated with the specified marker is applied to the view. */\r\n public toggleClipVolume(marker: SectionMarker, enable: boolean): void {\r\n ViewClipTool.enableClipVolume(this.viewport);\r\n ViewClipTool.setViewClip(this.viewport, enable ? marker.state.clip : undefined);\r\n }\r\n\r\n /** Toggles the specified section marker.\r\n * Enabling the section applies the frustum and clip volume of the marker's spatial view to the viewport, and displays the 2d section graphics and sheet annotations.\r\n * Disabling the section disables the clip volume and 2d graphics.\r\n * @see [[toggleClipVolume]] to toggle only the clip volume.\r\n * @see [[toggleAttachment]] to toggle only the attachment graphics.\r\n */\r\n public async toggleSection(marker: SectionMarker, enable: boolean): Promise<boolean> {\r\n if (enable) {\r\n if (this.viewport.view.is3d()) {\r\n // Preserve the view settings; apply only the frustum and clip volume\r\n const spatialView = await marker.state.tryLoadSpatialView();\r\n if (!spatialView)\r\n return false;\r\n\r\n const aligned = await this.alignToSpatialView(marker);\r\n if (!aligned)\r\n return false;\r\n\r\n this.toggleClipVolume(marker, true);\r\n } else if (!await this.applySpatialView(marker)) {\r\n return false;\r\n }\r\n } else {\r\n this.toggleClipVolume(marker, false);\r\n }\r\n\r\n this.requestSync();\r\n return this.toggleAttachment(marker, enable);\r\n }\r\n\r\n /** Toggles display of 2d section graphics and sheet annotations for the specified marker.\r\n * @see [[toggleSection]] to apply the spatial view and clip volume in addition to the attachment graphics.\r\n */\r\n public async toggleAttachment(marker: SectionMarker, enable: boolean): Promise<boolean> {\r\n this.dropTiledGraphicsProvider();\r\n if (enable) {\r\n this._tiledGraphicsProvider = await createSectionGraphicsProvider(marker.state);\r\n this.viewport.addTiledGraphicsProvider(this._tiledGraphicsProvider);\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /** Aligns the viewport to face the specified marker's section plane. */\r\n public alignView(marker: SectionMarker): void {\r\n const placement = marker.state.placement.transform;\r\n const origin = placement.origin;\r\n const matrix = placement.matrix;\r\n\r\n const vp = this.viewport;\r\n const targetMatrix = matrix.multiplyMatrixMatrix(vp.rotation);\r\n const rotateTransform = Transform.createFixedPointAndMatrix(origin, targetMatrix);\r\n\r\n const startFrustum = vp.getFrustum();\r\n const newFrustum = startFrustum.clone();\r\n newFrustum.multiply(rotateTransform);\r\n\r\n if (startFrustum.equals(newFrustum))\r\n return;\r\n\r\n vp.view.setupFromFrustum(newFrustum);\r\n vp.synchWithView();\r\n vp.animateFrustumChange();\r\n }\r\n\r\n /** Opens the marker's drawing view in the decorator's viewport. Returns false if the drawing view could not be loaded. */\r\n public async openSection(marker: SectionMarker): Promise<boolean> {\r\n const viewState = await marker.state.tryLoadDrawingView();\r\n if (viewState)\r\n this.viewport.changeView(viewState);\r\n\r\n return undefined !== viewState;\r\n }\r\n\r\n /** Opens marker's sheet view in the decorator's viewport and zooms in on the associated [ViewAttachment]($backend). Returns false if no view\r\n * attachment exists or the sheet view could not be loaded.\r\n */\r\n public async openSheet(marker: SectionMarker): Promise<boolean> {\r\n if (undefined === marker.state.viewAttachment)\r\n return false;\r\n\r\n const viewState = await marker.state.tryLoadSheetView();\r\n if (!viewState)\r\n return false;\r\n\r\n this.viewport.changeView(viewState);\r\n await this.viewport.zoomToElements(marker.state.viewAttachment.id);\r\n return true;\r\n }\r\n\r\n /** Aligns the view to match the frustum of the spatial view associated with the specified marker.\r\n * @param marker The marker whose spatial view's frustum should be applied.\r\n * @returns false if the frustum could not be applied, e.g. because the spatial view could not be loaded or the viewport is viewing a 2d model.\r\n * @see [[alignView]] to align to the *section plane*, which may differ.\r\n * @see [[toggleSection]] to also apply the clip volume.\r\n */\r\n public async alignToSpatialView(marker: SectionMarker): Promise<boolean> {\r\n if (!this.viewport.view.is3d())\r\n return false;\r\n\r\n const spatialView = await marker.state.tryLoadSpatialView();\r\n if (!spatialView)\r\n return false;\r\n\r\n this.viewport.view.setOrigin(spatialView.getOrigin());\r\n this.viewport.view.setExtents(spatialView.getExtents());\r\n this.viewport.view.setRotation(spatialView.getRotation());\r\n this.viewport.synchWithView({ animateFrustumChange: true });\r\n\r\n return true;\r\n }\r\n\r\n /** Applies the marker's spatial view - including its clip volume - to the decorator's viewport.\r\n * Returns false if the spatial view could not be loaded.\r\n * @see [[toggleSection]].\r\n * @see [[toggleClipVolume]].\r\n */\r\n public async applySpatialView(marker: SectionMarker): Promise<boolean> {\r\n const viewState = await marker.state.tryLoadSpatialView();\r\n if (viewState) {\r\n this._appliedSpatialView = viewState;\r\n this.viewport.changeView(viewState);\r\n }\r\n\r\n return undefined !== viewState;\r\n }\r\n\r\n /** Request that the visibility of the section markers be recomputed. It is only necessary to call this if you have overridden [[SectionMarkerHandler.isMarkerVisible]]; if so, you should invoke\r\n * this method when the criteria governing your `isMarkerVisible` method have changed.\r\n */\r\n public requestSync(): void {\r\n if (this.syncImmediately) {\r\n this.sync();\r\n } else if (!this._needSync) {\r\n this._needSync = true;\r\n requestAnimationFrame(() => this.sync());\r\n }\r\n }\r\n\r\n private sync(): void {\r\n this._needSync = false;\r\n if (HyperModeling.isInitialized && this.viewport.view.is3d() && this.updateMarkerVisibility()) {\r\n this.markers.markDirty();\r\n this.viewport.invalidateCachedDecorations(this);\r\n }\r\n }\r\n\r\n private isMarkerVisible(marker: SectionMarker): boolean {\r\n if (undefined !== this.activeMarker)\r\n return marker === this.activeMarker;\r\n\r\n return HyperModeling.markerHandler.isMarkerVisible(marker, this, this._config);\r\n }\r\n\r\n private updateMarkerVisibility(): boolean {\r\n let changed = false;\r\n for (const marker of this.markers.markers) {\r\n const wasVisible = marker.visible;\r\n marker.visible = this.isMarkerVisible(marker);\r\n changed = changed || (marker.visible !== wasVisible);\r\n }\r\n\r\n return changed;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"HyperModelingDecorator.js","sourceRoot":"","sources":["../../src/HyperModelingDecorator.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG;AAEH,OAAO,EAAE,SAAS,EAAS,MAAM,sBAAsB,CAAC;AAExD,OAAO,EACoC,SAAS,EAA6E,YAAY,GAC5I,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,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EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACjF,CAAC;IAEO,sBAAsB;QAC5B,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE;YACzC,MAAM,UAAU,GAAG,MAAM,CAAC,OAAO,CAAC;YAClC,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,CAAC;YAC9C,OAAO,GAAG,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,KAAK,UAAU,CAAC,CAAC;SACtD;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module HyperModeling\r\n */\r\n\r\nimport { Transform, XAndY } from \"@itwin/core-geometry\";\r\nimport type { AbstractToolbarProps } from \"@itwin/appui-abstract\";\r\nimport {\r\n ChangeFlags, DecorateContext, Decorator, IModelApp, IModelConnection, ScreenViewport, SpatialViewState, TiledGraphicsProvider, ViewClipTool,\r\n} from \"@itwin/core-frontend\";\r\nimport { SectionMarker, SectionMarkerSet } from \"./SectionMarkers\";\r\nimport { SectionDrawingLocationState } from \"./SectionDrawingLocationState\";\r\nimport { createSectionGraphicsProvider } from \"./SectionGraphicsProvider\";\r\nimport { PopupToolbarManager, PopupToolbarProvider } from \"./PopupToolbar\";\r\nimport { HyperModeling } from \"./HyperModeling\";\r\nimport { SectionMarkerConfig } from \"./HyperModelingConfig\";\r\n\r\nasync function createMarkers(vp: ScreenViewport): Promise<SectionMarkerSet | undefined> {\r\n if (!vp.view.isSpatialView())\r\n return undefined;\r\n\r\n const states = await SectionDrawingLocationState.queryAll(vp.iModel);\r\n if (0 === states.length)\r\n return undefined;\r\n\r\n const markers = states.map((state) => new SectionMarker(state));\r\n return new SectionMarkerSet(vp, markers);\r\n}\r\n\r\nclass MarkerToolbarProvider implements PopupToolbarProvider {\r\n private readonly _viewport: ScreenViewport;\r\n public readonly marker: SectionMarker;\r\n public readonly toolbarProps: AbstractToolbarProps;\r\n public readonly onToolbarItemExecuted: (id: string) => void;\r\n\r\n public constructor(marker: SectionMarker, decorator: HyperModelingDecorator) {\r\n this.marker = marker;\r\n this._viewport = decorator.viewport;\r\n this.toolbarProps = HyperModeling.markerHandler.getToolbarProps(marker, decorator);\r\n this.onToolbarItemExecuted = (id) => HyperModeling.markerHandler.executeCommand(id, marker, decorator); // eslint-disable-line @typescript-eslint/promise-function-async\r\n }\r\n\r\n public get overToolbarHotspot() {\r\n return this.marker.isHilited;\r\n }\r\n\r\n public get toolbarLocation(): XAndY {\r\n return IModelApp.uiAdmin.createXAndY(this.marker.rect.right, this.marker.rect.top);\r\n }\r\n\r\n public get htmlElement() {\r\n return this._viewport.canvas;\r\n }\r\n}\r\n\r\n/** A [Decorator]($frontend) that displays a [[SectionMarker]] for each [SectionDrawingLocation]($backend) in the view.\r\n * Clicking on a marker toggles the section and the display of associated 2d graphics.\r\n * Hovering over a marker opens a mini toolbar with additional interactions.\r\n * @see [[SectionMarkerHandler]] to customize the marker interactions.\r\n * @see [[HyperModeling.startOrStop]] to enable or disable the decorator for a viewport.\r\n * @public\r\n */\r\nexport class HyperModelingDecorator implements Decorator {\r\n /** The set of [[SectionMarker]]s controlled by this decorator. */\r\n public readonly markers: SectionMarkerSet;\r\n private _config: SectionMarkerConfig;\r\n private readonly _removeEventListeners = new Array<() => void>();\r\n private readonly _iModel: IModelConnection;\r\n private _needSync = false;\r\n private _toolbarProvider?: MarkerToolbarProvider;\r\n private _tiledGraphicsProvider?: TiledGraphicsProvider;\r\n private _activeMarker?: SectionMarker;\r\n private _appliedSpatialView?: SpatialViewState;\r\n /** @internal */\r\n public syncImmediately = false;\r\n\r\n /** Create a new decorator and register it with the [ViewManager]($frontend). Typically invoked indirectly via [[HyperModeling.startOrStop]]. */\r\n public static async create(vp: ScreenViewport, config: SectionMarkerConfig): Promise<HyperModelingDecorator | undefined> {\r\n const markers = await createMarkers(vp);\r\n return undefined !== markers ? new HyperModelingDecorator(markers, config) : undefined;\r\n }\r\n\r\n /** Obtain the decorator associated with the specified viewport, if any. */\r\n public static getForViewport(vp: ScreenViewport): HyperModelingDecorator | undefined {\r\n for (const decorator of IModelApp.viewManager.decorators)\r\n if (decorator instanceof HyperModelingDecorator && decorator.viewport === vp)\r\n return decorator;\r\n\r\n return undefined;\r\n }\r\n\r\n /** The viewport into which this decorator draws its [[SectionMarker]]s. */\r\n public get viewport(): ScreenViewport {\r\n return this.markers.viewport;\r\n }\r\n\r\n /** The currently active marker. A marker typically becomes active when the user clicks on it.\r\n * @see [[setActiveMarker]] to change the active marker without user interaction.\r\n */\r\n public get activeMarker(): SectionMarker | undefined {\r\n return this._activeMarker;\r\n }\r\n\r\n /** @internal */\r\n public get config(): SectionMarkerConfig {\r\n return this._config;\r\n }\r\n\r\n /** Replaces the current marker display configuration, overwriting all previous settings. Passing `undefined` resets all settings to defaults.\r\n * @see [[updateConfiguration]] to override specific aspects of the configuration\r\n * @see [[HyperModeling.replaceConfiguration]] to replace the global configuration.\r\n */\r\n public replaceConfiguration(config?: SectionMarkerConfig): void {\r\n this._config = config ? { ...config } : {};\r\n this.requestSync();\r\n }\r\n\r\n /** Overrides specific aspects of the current marker display configuration.\r\n * Any field that is not `undefined` will be replaced in the current configuration; the rest will retain their current values.\r\n * @see [[replaceConfiguration]] to override all settings.\r\n * @see [[HyperModeling.updateConfiguration]] to update the global configuration.\r\n */\r\n public updateConfiguration(config: SectionMarkerConfig): void {\r\n this._config = {\r\n ignoreModelSelector: config.ignoreModelSelector ?? this._config.ignoreModelSelector,\r\n ignoreCategorySelector: config.ignoreCategorySelector ?? this._config.ignoreCategorySelector,\r\n hiddenSectionTypes: config.hiddenSectionTypes ?? this._config.hiddenSectionTypes,\r\n };\r\n\r\n this.requestSync();\r\n }\r\n\r\n /** Sets the currently active marker. This function is invoked when the user clicks on a marker, but may also be called manually to produce the same result.\r\n * Changing the active marker first deactivates the currently active marker, if any; then activates the specified marker, if supplied.\r\n * Returns false if marker activation fails.\r\n * @see [[activeMarker]] to obtain the currently active section marker.\r\n * @see [[SectionMarkerHandler.activateMarker]] to control what happens when a marker is activated.\r\n * @see [[SectionMarkerHandler.deactivateMarker]] to control what happens when a marker is deactivated.\r\n */\r\n public async setActiveMarker(marker: SectionMarker | undefined): Promise<boolean> {\r\n if (marker === this.activeMarker)\r\n return true;\r\n\r\n if (this.activeMarker) {\r\n this.activeMarker.setActive(false);\r\n await HyperModeling.markerHandler.deactivateMarker(this.activeMarker, this);\r\n this._activeMarker = undefined;\r\n }\r\n\r\n if (marker) {\r\n if (!await HyperModeling.markerHandler.activateMarker(marker, this)) {\r\n this.requestSync();\r\n return false;\r\n }\r\n\r\n marker.setActive(true);\r\n this._activeMarker = marker;\r\n }\r\n\r\n this.requestSync();\r\n return true;\r\n }\r\n\r\n /** @internal */\r\n public readonly useCachedDecorations = true;\r\n\r\n /** @internal */\r\n public decorate(context: DecorateContext): void {\r\n if (this.viewport.view.is3d())\r\n this.markers.addDecoration(context);\r\n }\r\n\r\n private constructor(markers: SectionMarkerSet, config: SectionMarkerConfig) {\r\n this.markers = markers;\r\n this._config = { ...config };\r\n this._iModel = this.viewport.iModel;\r\n\r\n this.viewport.onChangeView.addOnce(() => {\r\n this.requestSync();\r\n });\r\n\r\n this._removeEventListeners.push(this.viewport.onViewportChanged.addListener((_, changeFlags) => this.onViewportChanged(changeFlags)));\r\n this._removeEventListeners.push(this.viewport.onDisposed.addListener(() => this.dispose()));\r\n\r\n for (const marker of markers.markers) {\r\n marker.onMouseEnterEvent.addListener((mkr) => this.showToolbarAfterTimeout(mkr));\r\n marker.onMouseButtonEvent.addListener((mkr) => this.toggleMarker(mkr)); // eslint-disable-line @typescript-eslint/promise-function-async\r\n }\r\n\r\n this.updateMarkerVisibility();\r\n IModelApp.viewManager.addDecorator(this);\r\n }\r\n\r\n private onViewportChanged(changeFlags: ChangeFlags): void {\r\n if (this.viewport.iModel !== this._iModel) {\r\n this.dispose();\r\n return;\r\n }\r\n\r\n if (changeFlags.viewedCategories || changeFlags.viewedModels || changeFlags.viewedCategoriesPerModel)\r\n this.requestSync();\r\n\r\n if (changeFlags.viewState) {\r\n // If we're looking at a different view now, and we did not initiate that, turn off the active marker.\r\n if (this.viewport.view !== this._appliedSpatialView)\r\n this.setActiveMarker(undefined); // eslint-disable-line @typescript-eslint/no-floating-promises\r\n else\r\n this._appliedSpatialView = undefined;\r\n }\r\n }\r\n\r\n private async toggleMarker(marker: SectionMarker): Promise<void> {\r\n await this.setActiveMarker(marker === this.activeMarker ? undefined : marker);\r\n }\r\n\r\n private dropTiledGraphicsProvider(): void {\r\n if (undefined === this._tiledGraphicsProvider)\r\n return;\r\n\r\n this.viewport.dropTiledGraphicsProvider(this._tiledGraphicsProvider);\r\n this._tiledGraphicsProvider = undefined;\r\n }\r\n\r\n /** @internal */\r\n public dispose(): void {\r\n if (!IModelApp.viewManager.dropDecorator(this))\r\n return;\r\n\r\n for (const remove of this._removeEventListeners)\r\n remove();\r\n\r\n this.dropTiledGraphicsProvider();\r\n }\r\n\r\n private showToolbarAfterTimeout(marker: SectionMarker): void {\r\n if (this._toolbarProvider?.marker !== marker)\r\n this._toolbarProvider = new MarkerToolbarProvider(marker, this);\r\n\r\n PopupToolbarManager.showToolbarAfterTimeout(this._toolbarProvider);\r\n }\r\n\r\n /** Toggles whether the clip volume associated with the specified marker is applied to the view. */\r\n public toggleClipVolume(marker: SectionMarker, enable: boolean): void {\r\n ViewClipTool.enableClipVolume(this.viewport);\r\n ViewClipTool.setViewClip(this.viewport, enable ? marker.state.clip : undefined);\r\n }\r\n\r\n /** Toggles the specified section marker.\r\n * Enabling the section applies the frustum and clip volume of the marker's spatial view to the viewport, and displays the 2d section graphics and sheet annotations.\r\n * Disabling the section disables the clip volume and 2d graphics.\r\n * @see [[toggleClipVolume]] to toggle only the clip volume.\r\n * @see [[toggleAttachment]] to toggle only the attachment graphics.\r\n */\r\n public async toggleSection(marker: SectionMarker, enable: boolean): Promise<boolean> {\r\n if (enable) {\r\n if (this.viewport.view.is3d()) {\r\n // Preserve the view settings; apply only the frustum and clip volume\r\n const spatialView = await marker.state.tryLoadSpatialView();\r\n if (!spatialView)\r\n return false;\r\n\r\n const aligned = await this.alignToSpatialView(marker);\r\n if (!aligned)\r\n return false;\r\n\r\n this.toggleClipVolume(marker, true);\r\n } else if (!await this.applySpatialView(marker)) {\r\n return false;\r\n }\r\n } else {\r\n this.toggleClipVolume(marker, false);\r\n }\r\n\r\n this.requestSync();\r\n return this.toggleAttachment(marker, enable);\r\n }\r\n\r\n /** Toggles display of 2d section graphics and sheet annotations for the specified marker.\r\n * @see [[toggleSection]] to apply the spatial view and clip volume in addition to the attachment graphics.\r\n */\r\n public async toggleAttachment(marker: SectionMarker, enable: boolean): Promise<boolean> {\r\n this.dropTiledGraphicsProvider();\r\n if (enable) {\r\n this._tiledGraphicsProvider = await createSectionGraphicsProvider(marker.state);\r\n this.viewport.addTiledGraphicsProvider(this._tiledGraphicsProvider);\r\n }\r\n\r\n return true;\r\n }\r\n\r\n /** Aligns the viewport to face the specified marker's section plane. */\r\n public alignView(marker: SectionMarker): void {\r\n const placement = marker.state.placement.transform;\r\n const origin = placement.origin;\r\n const matrix = placement.matrix;\r\n\r\n const vp = this.viewport;\r\n const targetMatrix = matrix.multiplyMatrixMatrix(vp.rotation);\r\n const rotateTransform = Transform.createFixedPointAndMatrix(origin, targetMatrix);\r\n\r\n const startFrustum = vp.getFrustum();\r\n const newFrustum = startFrustum.clone();\r\n newFrustum.multiply(rotateTransform);\r\n\r\n if (startFrustum.equals(newFrustum))\r\n return;\r\n\r\n vp.view.setupFromFrustum(newFrustum);\r\n vp.synchWithView();\r\n vp.animateFrustumChange();\r\n }\r\n\r\n /** Opens the marker's drawing view in the decorator's viewport. Returns false if the drawing view could not be loaded. */\r\n public async openSection(marker: SectionMarker): Promise<boolean> {\r\n const viewState = await marker.state.tryLoadDrawingView();\r\n if (viewState)\r\n this.viewport.changeView(viewState);\r\n\r\n return undefined !== viewState;\r\n }\r\n\r\n /** Opens marker's sheet view in the decorator's viewport and zooms in on the associated [ViewAttachment]($backend). Returns false if no view\r\n * attachment exists or the sheet view could not be loaded.\r\n */\r\n public async openSheet(marker: SectionMarker): Promise<boolean> {\r\n if (undefined === marker.state.viewAttachment)\r\n return false;\r\n\r\n const viewState = await marker.state.tryLoadSheetView();\r\n if (!viewState)\r\n return false;\r\n\r\n this.viewport.changeView(viewState);\r\n await this.viewport.zoomToElements(marker.state.viewAttachment.id);\r\n return true;\r\n }\r\n\r\n /** Aligns the view to match the frustum of the spatial view associated with the specified marker.\r\n * @param marker The marker whose spatial view's frustum should be applied.\r\n * @returns false if the frustum could not be applied, e.g. because the spatial view could not be loaded or the viewport is viewing a 2d model.\r\n * @see [[alignView]] to align to the *section plane*, which may differ.\r\n * @see [[toggleSection]] to also apply the clip volume.\r\n */\r\n public async alignToSpatialView(marker: SectionMarker): Promise<boolean> {\r\n if (!this.viewport.view.is3d())\r\n return false;\r\n\r\n const spatialView = await marker.state.tryLoadSpatialView();\r\n if (!spatialView)\r\n return false;\r\n\r\n this.viewport.view.setOrigin(spatialView.getOrigin());\r\n this.viewport.view.setExtents(spatialView.getExtents());\r\n this.viewport.view.setRotation(spatialView.getRotation());\r\n this.viewport.synchWithView({ animateFrustumChange: true });\r\n\r\n return true;\r\n }\r\n\r\n /** Applies the marker's spatial view - including its clip volume - to the decorator's viewport.\r\n * Returns false if the spatial view could not be loaded.\r\n * @see [[toggleSection]].\r\n * @see [[toggleClipVolume]].\r\n */\r\n public async applySpatialView(marker: SectionMarker): Promise<boolean> {\r\n const viewState = await marker.state.tryLoadSpatialView();\r\n if (viewState) {\r\n this._appliedSpatialView = viewState;\r\n this.viewport.changeView(viewState);\r\n }\r\n\r\n return undefined !== viewState;\r\n }\r\n\r\n /** Request that the visibility of the section markers be recomputed. It is only necessary to call this if you have overridden [[SectionMarkerHandler.isMarkerVisible]]; if so, you should invoke\r\n * this method when the criteria governing your `isMarkerVisible` method have changed.\r\n */\r\n public requestSync(): void {\r\n if (this.syncImmediately) {\r\n this.sync();\r\n } else if (!this._needSync) {\r\n this._needSync = true;\r\n requestAnimationFrame(() => this.sync());\r\n }\r\n }\r\n\r\n private sync(): void {\r\n this._needSync = false;\r\n if (HyperModeling.isInitialized && this.viewport.view.is3d() && this.updateMarkerVisibility()) {\r\n this.markers.markDirty();\r\n this.viewport.invalidateCachedDecorations(this);\r\n }\r\n }\r\n\r\n private isMarkerVisible(marker: SectionMarker): boolean {\r\n if (undefined !== this.activeMarker)\r\n return marker === this.activeMarker;\r\n\r\n return HyperModeling.markerHandler.isMarkerVisible(marker, this, this._config);\r\n }\r\n\r\n private updateMarkerVisibility(): boolean {\r\n let changed = false;\r\n for (const marker of this.markers.markers) {\r\n const wasVisible = marker.visible;\r\n marker.visible = this.isMarkerVisible(marker);\r\n changed = changed || (marker.visible !== wasVisible);\r\n }\r\n\r\n return changed;\r\n }\r\n}\r\n"]}
@@ -2,7 +2,7 @@
2
2
  * @module HyperModeling
3
3
  */
4
4
  import { XAndY } from "@itwin/core-geometry";
5
- import { AbstractToolbarProps } from "@itwin/appui-abstract";
5
+ import type { AbstractToolbarProps } from "@itwin/appui-abstract";
6
6
  /** @internal */
7
7
  export interface PopupToolbarProvider {
8
8
  toolbarProps: AbstractToolbarProps;
@@ -1 +1 @@
1
- {"version":3,"file":"PopupToolbar.d.ts","sourceRoot":"","sources":["../../src/PopupToolbar.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAC7C,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAG7D,gBAAgB;AAChB,MAAM,WAAW,oBAAoB;IACnC,YAAY,EAAE,oBAAoB,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Q;YAChB,OAAO;QAET,IAAI,IAAI,CAAC,QAAQ,CAAC,kBAAkB,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,UAAU;YACrE,UAAU,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,iBAAiB,EAAE,EAAE,GAAG,CAAC,CAAC,CAAC,kDAAkD;;YAEnG,IAAI,CAAC,KAAK,EAAE,CAAC;IACjB,CAAC;IAEM,MAAM,CAAC,uBAAuB,CAAC,QAA8B;QAClE,IAAI,IAAI,CAAC,QAAQ,KAAK,QAAQ;YAC5B,OAAO;QAET,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,UAAU,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC;IACrC,CAAC;;AAnCc,iCAAa,GAAG,CAAC,IAAS,EAAE,EAAE;IAC3C,MAAM,GAAG,GAAG,mBAAmB,CAAC;IAChC,IAAI,GAAG,CAAC,QAAQ;QACd,GAAG,CAAC,QAAQ,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAE9C,GAAG,CAAC,KAAK,EAAE,CAAC;AACd,CAAC,CAAC;AAEa,2BAAO,GAAG,GAAG,EAAE;IAC5B,MAAM,GAAG,GAAG,mBAAmB,CAAC;IAChC,IAAI,CAAC,GAAG,CAAC,QAAQ,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,kBAAkB;QACnD,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,wCAAwC;AACzD,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module HyperModeling\r\n */\r\n\r\nimport { XAndY } from \"@itwin/core-geometry\";\r\nimport { AbstractToolbarProps } from \"@itwin/appui-abstract\";\r\nimport { IModelApp } from \"@itwin/core-frontend\";\r\n\r\n/** @internal */\r\nexport interface PopupToolbarProvider {\r\n toolbarProps: AbstractToolbarProps;\r\n overToolbarHotspot: boolean;\r\n toolbarLocation: XAndY;\r\n htmlElement: HTMLElement | undefined;\r\n onToolbarItemExecuted(id: string): void;\r\n}\r\n\r\n/** @internal */\r\nexport class PopupToolbarManager {\r\n private static _provider?: PopupToolbarProvider;\r\n private static _current?: PopupToolbarProvider;\r\n\r\n private static show(): boolean {\r\n const prov = this._provider;\r\n if (!prov || !prov.overToolbarHotspot)\r\n return false;\r\n\r\n const admin = IModelApp.uiAdmin;\r\n if (!admin.showToolbar(prov.toolbarProps, prov.toolbarLocation, admin.createXAndY(0, 0), this._itemExecuted, this._cancel, undefined, prov.htmlElement))\r\n return false;\r\n\r\n this._current = this._provider;\r\n this._provider = undefined;\r\n this.closeAfterTimeout();\r\n return true;\r\n }\r\n\r\n private static _itemExecuted = (item: any) => {\r\n const mgr = PopupToolbarManager;\r\n if (mgr._current)\r\n mgr._current.onToolbarItemExecuted(item.id);\r\n\r\n mgr.close();\r\n };\r\n\r\n private static _cancel = () => {\r\n const mgr = PopupToolbarManager;\r\n if (!mgr._current || !mgr._current.overToolbarHotspot)\r\n mgr.close(); // Don't hide when click is over hotspot\r\n };\r\n\r\n private static close(): boolean {\r\n this._current = undefined;\r\n return IModelApp.uiAdmin.hideToolbar();\r\n }\r\n\r\n private static closeAfterTimeout(): void {\r\n if (!this._current)\r\n return;\r\n\r\n if (this._current.overToolbarHotspot || !IModelApp.toolAdmin.cursorView)\r\n setTimeout(() => this.closeAfterTimeout(), 500); // Cursor not in view or over hotspot, check again\r\n else\r\n this.close();\r\n }\r\n\r\n public static showToolbarAfterTimeout(provider: PopupToolbarProvider): void {\r\n if (this._current === provider)\r\n return;\r\n\r\n this._provider = provider;\r\n setTimeout(() => this.show(), 500);\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"PopupToolbar.js","sourceRoot":"","sources":["../../src/PopupToolbar.ts"],"names":[],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AAuB,CAAC,QAA8B;QAClE,IAAI,IAAI,CAAC,QAAQ,KAAK,QAAQ;YAC5B,OAAO;QAET,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,UAAU,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,IAAI,EAAE,EAAE,GAAG,CAAC,CAAC;IACrC,CAAC;;AAnCc,iCAAa,GAAG,CAAC,IAAS,EAAE,EAAE;IAC3C,MAAM,GAAG,GAAG,mBAAmB,CAAC;IAChC,IAAI,GAAG,CAAC,QAAQ;QACd,GAAG,CAAC,QAAQ,CAAC,qBAAqB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IAE9C,GAAG,CAAC,KAAK,EAAE,CAAC;AACd,CAAC,CAAC;AAEa,2BAAO,GAAG,GAAG,EAAE;IAC5B,MAAM,GAAG,GAAG,mBAAmB,CAAC;IAChC,IAAI,CAAC,GAAG,CAAC,QAAQ,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,kBAAkB;QACnD,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,wCAAwC;AACzD,CAAC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module HyperModeling\r\n */\r\n\r\nimport { XAndY } from \"@itwin/core-geometry\";\r\nimport type { AbstractToolbarProps } from \"@itwin/appui-abstract\";\r\nimport { IModelApp } from \"@itwin/core-frontend\";\r\n\r\n/** @internal */\r\nexport interface PopupToolbarProvider {\r\n toolbarProps: AbstractToolbarProps;\r\n overToolbarHotspot: boolean;\r\n toolbarLocation: XAndY;\r\n htmlElement: HTMLElement | undefined;\r\n onToolbarItemExecuted(id: string): void;\r\n}\r\n\r\n/** @internal */\r\nexport class PopupToolbarManager {\r\n private static _provider?: PopupToolbarProvider;\r\n private static _current?: PopupToolbarProvider;\r\n\r\n private static show(): boolean {\r\n const prov = this._provider;\r\n if (!prov || !prov.overToolbarHotspot)\r\n return false;\r\n\r\n const admin = IModelApp.uiAdmin;\r\n if (!admin.showToolbar(prov.toolbarProps, prov.toolbarLocation, admin.createXAndY(0, 0), this._itemExecuted, this._cancel, undefined, prov.htmlElement))\r\n return false;\r\n\r\n this._current = this._provider;\r\n this._provider = undefined;\r\n this.closeAfterTimeout();\r\n return true;\r\n }\r\n\r\n private static _itemExecuted = (item: any) => {\r\n const mgr = PopupToolbarManager;\r\n if (mgr._current)\r\n mgr._current.onToolbarItemExecuted(item.id);\r\n\r\n mgr.close();\r\n };\r\n\r\n private static _cancel = () => {\r\n const mgr = PopupToolbarManager;\r\n if (!mgr._current || !mgr._current.overToolbarHotspot)\r\n mgr.close(); // Don't hide when click is over hotspot\r\n };\r\n\r\n private static close(): boolean {\r\n this._current = undefined;\r\n return IModelApp.uiAdmin.hideToolbar();\r\n }\r\n\r\n private static closeAfterTimeout(): void {\r\n if (!this._current)\r\n return;\r\n\r\n if (this._current.overToolbarHotspot || !IModelApp.toolAdmin.cursorView)\r\n setTimeout(() => this.closeAfterTimeout(), 500); // Cursor not in view or over hotspot, check again\r\n else\r\n this.close();\r\n }\r\n\r\n public static showToolbarAfterTimeout(provider: PopupToolbarProvider): void {\r\n if (this._current === provider)\r\n return;\r\n\r\n this._provider = provider;\r\n setTimeout(() => this.show(), 500);\r\n }\r\n}\r\n"]}
@@ -1,7 +1,7 @@
1
1
  /** @packageDocumentation
2
2
  * @module HyperModeling
3
3
  */
4
- import { AbstractToolbarProps } from "@itwin/appui-abstract";
4
+ import type { AbstractToolbarProps } from "@itwin/appui-abstract";
5
5
  import { SectionMarker } from "./SectionMarkers";
6
6
  import { SectionMarkerConfig } from "./HyperModelingConfig";
7
7
  import { HyperModelingDecorator } from "./HyperModelingDecorator";
@@ -1 +1 @@
1
- {"version":3,"file":"SectionMarkerHandler.d.ts","sourceRoot":"","sources":["../../src/SectionMarkerHandler.ts"],"names":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AkB,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC;YACzG,OAAO,KAAK,CAAC;QAEf,IAAI,CAAC,MAAM,CAAC,sBAAsB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC;YACjG,OAAO,KAAK,CAAC;QAEf,IAAI,CAAC,MAAM,CAAC,mBAAmB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC;YACxF,OAAO,KAAK,CAAC;QAEf,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module HyperModeling\r\n */\r\n\r\nimport { IModelApp } from \"@itwin/core-frontend\";\r\nimport { AbstractToolbarProps } from \"@itwin/appui-abstract\";\r\nimport { SectionMarker } from \"./SectionMarkers\";\r\nimport { SectionMarkerConfig } from \"./HyperModelingConfig\";\r\nimport { HyperModelingDecorator } from \"./HyperModelingDecorator\";\r\n\r\n/** Supplies interactions with [[SectionMarker]]s, including a mini-toolbar displayed when the mouse hovers over a marker and what action occurs when the user clicks a marker.\r\n * The base implementation supplies the following interactions:\r\n * * Click: Toggle display of the section graphics and clip volume; apply the section's spatial view if toggling on.\r\n * * Toolbar:\r\n * * Apply Section: Applies the section location's spatial view to the viewport and displays the 2d section graphics.\r\n * * Open Drawing: Navigates to the section drawing view. By default, this applies the section drawing view to the viewport.\r\n * * Open Sheet: Navigates to the [ViewAttachment]($backend) of the section drawing on a [Sheet]($backend). Disabled if no such attachment exists.\r\n * @see [[HyperModelingConfig]] to override the default handler by supplying a subclass of `SectionMarkerHandler`.\r\n * @see [[HyperModelingDecorator]] for various methods that might be usefully wired up to marker click or toolbar actions.\r\n * @public\r\n */\r\nexport class SectionMarkerHandler {\r\n /** Respond to activation of the specified marker. Return true if the marker should become the active marker - i.e., if the marker was successfully activated.\r\n * @see [[SectionMarkerHandler.deactivateMarker]].\r\n */\r\n public async activateMarker(marker: SectionMarker, decorator: HyperModelingDecorator): Promise<boolean> {\r\n return decorator.toggleSection(marker, true);\r\n }\r\n\r\n /** Respond to deactivation of the specified marker. Invoked when the user clicks on the marker while it is the active marker.\r\n * This should perform the inverse of [[SectionMarkerHandler.activateMarker]]. The marker becomes inactive as a result.\r\n */\r\n public async deactivateMarker(marker: SectionMarker, decorator: HyperModelingDecorator): Promise<void> {\r\n await decorator.toggleSection(marker, false);\r\n }\r\n\r\n /** Return toolbar items for the specified marker. If the array of toolbar items is empty, no toolbar will be displayed.\r\n * @see [[executeCommand]] to implement each toolbar command.\r\n */\r\n public getToolbarProps(marker: SectionMarker, _decorator: HyperModelingDecorator): AbstractToolbarProps {\r\n const localization = IModelApp.localization;\r\n return {\r\n items: [\r\n {\r\n id: \"apply_view\",\r\n itemPriority: 10,\r\n label: localization.getLocalizedString(\"HyperModeling:Message.ApplyView\"),\r\n icon: \"icon-spatial-view-apply\",\r\n execute: () => { },\r\n isDisabled: false,\r\n },\r\n {\r\n id: \"open_section\",\r\n itemPriority: 20,\r\n label: localization.getLocalizedString(\"HyperModeling:Message.OpenSection\"),\r\n icon: \"icon-plan-drawing\",\r\n execute: () => { },\r\n isDisabled: false,\r\n },\r\n {\r\n id: \"open_sheet\",\r\n itemPriority: 30,\r\n label: localization.getLocalizedString(\"HyperModeling:Message.OpenSheet\"),\r\n icon: \"icon-plan-floor\",\r\n execute: () => { },\r\n isDisabled: undefined === marker.state.viewAttachment?.viewId,\r\n },\r\n ],\r\n };\r\n }\r\n\r\n /** Execute the command associated with the specified tool bar item.\r\n * @see [[getToolbarProps]] to define the set of commands.\r\n */\r\n public async executeCommand(commandId: string, marker: SectionMarker, decorator: HyperModelingDecorator): Promise<void> {\r\n switch (commandId) {\r\n case \"apply_view\":\r\n await decorator.applySpatialView(marker);\r\n break;\r\n case \"open_section\":\r\n await decorator.openSection(marker);\r\n break;\r\n case \"open_sheet\":\r\n await decorator.openSheet(marker);\r\n break;\r\n }\r\n }\r\n\r\n /** Customize which markers are visible. [[HyperModelingDecorator]] determines marker visibility as follows:\r\n * - If a marker is currently active (selected), only that marker is visible.\r\n * - Otherwise, the marker is visible if this method returns `true`.\r\n * The default implementation of this method determines visibility based on the [[SectionMarkerConfig]] as follows.\r\n * - If the marker is of a type included in the config's `hiddenSectionTypes`, it is invisible.\r\n * - If the marker belongs to a model not currently displayed in the viewport and the config's `ignoreModelSelector` is false, it is invisible.\r\n * - If the marker belongs to a category not currently displayed in the viewport and the config's `ignoreCategorySelector` is false, it is invisible,\r\n * - Otherwise, the marker is visible, unless this method returns `false`.\r\n * The default implementation of this method always returns `true`\r\n * @param marker The marker whose visibility is to be determined.\r\n * @param decorator The hypermodeling decorator to which the marker belongs.\r\n * @param config The configuration controlling marker visibility based on [SectionType]($common), [ModelSelectorState]($frontend), and [CategorySelectorState]($frontend).\r\n * @returns true if the marker should be displayed; false to make it invisible.\r\n * @see [[HyperModelingDecorator.requestSync]] to force the decorator to reevaluate marker visibility when the criterion used by your implementation of this method changes.\r\n */\r\n public isMarkerVisible(marker: SectionMarker, decorator: HyperModelingDecorator, config: SectionMarkerConfig): boolean {\r\n if (undefined !== config.hiddenSectionTypes && config.hiddenSectionTypes.includes(marker.state.sectionType))\r\n return false;\r\n\r\n if (!config.ignoreCategorySelector && !decorator.viewport.view.viewsCategory(marker.state.category))\r\n return false;\r\n\r\n if (!config.ignoreModelSelector && !decorator.viewport.view.viewsModel(marker.state.model))\r\n return false;\r\n\r\n return true;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"SectionMarkerHandler.js","sourceRoot":"","sources":["../../src/SectionMarkerHandler.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GA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;iBAC9D;aACF;SACF,CAAC;IACJ,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,cAAc,CAAC,SAAiB,EAAE,MAAqB,EAAE,SAAiC;QACrG,QAAQ,SAAS,EAAE;YACjB,KAAK,YAAY;gBACf,MAAM,SAAS,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;gBACzC,MAAM;YACR,KAAK,cAAc;gBACjB,MAAM,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;gBACpC,MAAM;YACR,KAAK,YAAY;gBACf,MAAM,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;gBAClC,MAAM;SACT;IACH,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACI,eAAe,CAAC,MAAqB,EAAE,SAAiC,EAAE,MAA2B;QAC1G,IAAI,SAAS,KAAK,MAAM,CAAC,kBAAkB,IAAI,MAAM,CAAC,kBAAkB,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC;YACzG,OAAO,KAAK,CAAC;QAEf,IAAI,CAAC,MAAM,CAAC,sBAAsB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC;YACjG,OAAO,KAAK,CAAC;QAEf,IAAI,CAAC,MAAM,CAAC,mBAAmB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC;YACxF,OAAO,KAAK,CAAC;QAEf,OAAO,IAAI,CAAC;IACd,CAAC;CACF","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module HyperModeling\r\n */\r\n\r\nimport { IModelApp } from \"@itwin/core-frontend\";\r\nimport type { AbstractToolbarProps } from \"@itwin/appui-abstract\";\r\nimport { SectionMarker } from \"./SectionMarkers\";\r\nimport { SectionMarkerConfig } from \"./HyperModelingConfig\";\r\nimport { HyperModelingDecorator } from \"./HyperModelingDecorator\";\r\n\r\n/** Supplies interactions with [[SectionMarker]]s, including a mini-toolbar displayed when the mouse hovers over a marker and what action occurs when the user clicks a marker.\r\n * The base implementation supplies the following interactions:\r\n * * Click: Toggle display of the section graphics and clip volume; apply the section's spatial view if toggling on.\r\n * * Toolbar:\r\n * * Apply Section: Applies the section location's spatial view to the viewport and displays the 2d section graphics.\r\n * * Open Drawing: Navigates to the section drawing view. By default, this applies the section drawing view to the viewport.\r\n * * Open Sheet: Navigates to the [ViewAttachment]($backend) of the section drawing on a [Sheet]($backend). Disabled if no such attachment exists.\r\n * @see [[HyperModelingConfig]] to override the default handler by supplying a subclass of `SectionMarkerHandler`.\r\n * @see [[HyperModelingDecorator]] for various methods that might be usefully wired up to marker click or toolbar actions.\r\n * @public\r\n */\r\nexport class SectionMarkerHandler {\r\n /** Respond to activation of the specified marker. Return true if the marker should become the active marker - i.e., if the marker was successfully activated.\r\n * @see [[SectionMarkerHandler.deactivateMarker]].\r\n */\r\n public async activateMarker(marker: SectionMarker, decorator: HyperModelingDecorator): Promise<boolean> {\r\n return decorator.toggleSection(marker, true);\r\n }\r\n\r\n /** Respond to deactivation of the specified marker. Invoked when the user clicks on the marker while it is the active marker.\r\n * This should perform the inverse of [[SectionMarkerHandler.activateMarker]]. The marker becomes inactive as a result.\r\n */\r\n public async deactivateMarker(marker: SectionMarker, decorator: HyperModelingDecorator): Promise<void> {\r\n await decorator.toggleSection(marker, false);\r\n }\r\n\r\n /** Return toolbar items for the specified marker. If the array of toolbar items is empty, no toolbar will be displayed.\r\n * @see [[executeCommand]] to implement each toolbar command.\r\n */\r\n public getToolbarProps(marker: SectionMarker, _decorator: HyperModelingDecorator): AbstractToolbarProps {\r\n const localization = IModelApp.localization;\r\n return {\r\n items: [\r\n {\r\n id: \"apply_view\",\r\n itemPriority: 10,\r\n label: localization.getLocalizedString(\"HyperModeling:Message.ApplyView\"),\r\n icon: \"icon-spatial-view-apply\",\r\n execute: () => { },\r\n isDisabled: false,\r\n },\r\n {\r\n id: \"open_section\",\r\n itemPriority: 20,\r\n label: localization.getLocalizedString(\"HyperModeling:Message.OpenSection\"),\r\n icon: \"icon-plan-drawing\",\r\n execute: () => { },\r\n isDisabled: false,\r\n },\r\n {\r\n id: \"open_sheet\",\r\n itemPriority: 30,\r\n label: localization.getLocalizedString(\"HyperModeling:Message.OpenSheet\"),\r\n icon: \"icon-plan-floor\",\r\n execute: () => { },\r\n isDisabled: undefined === marker.state.viewAttachment?.viewId,\r\n },\r\n ],\r\n };\r\n }\r\n\r\n /** Execute the command associated with the specified tool bar item.\r\n * @see [[getToolbarProps]] to define the set of commands.\r\n */\r\n public async executeCommand(commandId: string, marker: SectionMarker, decorator: HyperModelingDecorator): Promise<void> {\r\n switch (commandId) {\r\n case \"apply_view\":\r\n await decorator.applySpatialView(marker);\r\n break;\r\n case \"open_section\":\r\n await decorator.openSection(marker);\r\n break;\r\n case \"open_sheet\":\r\n await decorator.openSheet(marker);\r\n break;\r\n }\r\n }\r\n\r\n /** Customize which markers are visible. [[HyperModelingDecorator]] determines marker visibility as follows:\r\n * - If a marker is currently active (selected), only that marker is visible.\r\n * - Otherwise, the marker is visible if this method returns `true`.\r\n * The default implementation of this method determines visibility based on the [[SectionMarkerConfig]] as follows.\r\n * - If the marker is of a type included in the config's `hiddenSectionTypes`, it is invisible.\r\n * - If the marker belongs to a model not currently displayed in the viewport and the config's `ignoreModelSelector` is false, it is invisible.\r\n * - If the marker belongs to a category not currently displayed in the viewport and the config's `ignoreCategorySelector` is false, it is invisible,\r\n * - Otherwise, the marker is visible, unless this method returns `false`.\r\n * The default implementation of this method always returns `true`\r\n * @param marker The marker whose visibility is to be determined.\r\n * @param decorator The hypermodeling decorator to which the marker belongs.\r\n * @param config The configuration controlling marker visibility based on [SectionType]($common), [ModelSelectorState]($frontend), and [CategorySelectorState]($frontend).\r\n * @returns true if the marker should be displayed; false to make it invisible.\r\n * @see [[HyperModelingDecorator.requestSync]] to force the decorator to reevaluate marker visibility when the criterion used by your implementation of this method changes.\r\n */\r\n public isMarkerVisible(marker: SectionMarker, decorator: HyperModelingDecorator, config: SectionMarkerConfig): boolean {\r\n if (undefined !== config.hiddenSectionTypes && config.hiddenSectionTypes.includes(marker.state.sectionType))\r\n return false;\r\n\r\n if (!config.ignoreCategorySelector && !decorator.viewport.view.viewsCategory(marker.state.category))\r\n return false;\r\n\r\n if (!config.ignoreModelSelector && !decorator.viewport.view.viewsModel(marker.state.model))\r\n return false;\r\n\r\n return true;\r\n }\r\n}\r\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itwin/hypermodeling-frontend",
3
- "version": "3.0.0-dev.125",
3
+ "version": "3.0.0-dev.129",
4
4
  "description": "iModel.js hypermodeling package",
5
5
  "main": "lib/cjs/hypermodeling-frontend.js",
6
6
  "module": "lib/esm/hypermodeling-frontend.js",
@@ -22,21 +22,19 @@
22
22
  "url": "http://www.bentley.com"
23
23
  },
24
24
  "peerDependencies": {
25
- "@itwin/core-bentley": "^3.0.0-dev.125",
26
- "@itwin/core-geometry": "^3.0.0-dev.125",
27
- "@itwin/core-common": "^3.0.0-dev.125",
28
- "@itwin/core-frontend": "^3.0.0-dev.125",
29
- "@itwin/appui-abstract": "^3.0.0-dev.125"
25
+ "@itwin/core-bentley": "^3.0.0-dev.129",
26
+ "@itwin/core-common": "^3.0.0-dev.129",
27
+ "@itwin/core-frontend": "^3.0.0-dev.129",
28
+ "@itwin/core-geometry": "^3.0.0-dev.129"
30
29
  },
31
30
  "devDependencies": {
32
- "@itwin/core-bentley": "3.0.0-dev.125",
33
- "@itwin/build-tools": "3.0.0-dev.125",
34
- "@itwin/certa": "3.0.0-dev.125",
35
- "@itwin/eslint-plugin": "3.0.0-dev.125",
36
- "@itwin/core-geometry": "3.0.0-dev.125",
37
- "@itwin/core-common": "3.0.0-dev.125",
38
- "@itwin/core-frontend": "3.0.0-dev.125",
39
- "@itwin/appui-abstract": "3.0.0-dev.125",
31
+ "@itwin/build-tools": "3.0.0-dev.129",
32
+ "@itwin/core-bentley": "3.0.0-dev.129",
33
+ "@itwin/core-common": "3.0.0-dev.129",
34
+ "@itwin/core-frontend": "3.0.0-dev.129",
35
+ "@itwin/core-geometry": "3.0.0-dev.129",
36
+ "@itwin/certa": "3.0.0-dev.129",
37
+ "@itwin/eslint-plugin": "3.0.0-dev.129",
40
38
  "@types/chai": "^4.1.4",
41
39
  "@types/mocha": "^8.2.2",
42
40
  "@types/node": "14.14.31",
@@ -51,6 +49,9 @@
51
49
  "typescript": "~4.4.0",
52
50
  "webpack": "4.42.0"
53
51
  },
52
+ "dependencies": {
53
+ "@itwin/appui-abstract": "3.0.0-dev.129"
54
+ },
54
55
  "nyc": {
55
56
  "extends": "./node_modules/@itwin/build-tools/.nycrc"
56
57
  },