@itwin/hypermodeling-frontend 4.6.0-dev.9 → 4.7.0-dev.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # Change Log - @itwin/hypermodeling-frontend
2
2
 
3
- This log was last generated on Wed, 03 Apr 2024 18:28:10 GMT and should not be manually modified.
3
+ This log was last generated on Tue, 16 Apr 2024 14:47:36 GMT and should not be manually modified.
4
+
5
+ ## 4.5.2
6
+ Tue, 16 Apr 2024 14:46:22 GMT
7
+
8
+ _Version update only_
4
9
 
5
10
  ## 4.5.1
6
11
  Wed, 03 Apr 2024 18:26:59 GMT
@@ -12,6 +17,11 @@ Tue, 02 Apr 2024 19:06:00 GMT
12
17
 
13
18
  _Version update only_
14
19
 
20
+ ## 4.4.9
21
+ Mon, 15 Apr 2024 20:29:22 GMT
22
+
23
+ _Version update only_
24
+
15
25
  ## 4.4.8
16
26
  Mon, 25 Mar 2024 22:22:26 GMT
17
27
 
@@ -232,7 +232,7 @@ class HyperModeling {
232
232
  }
233
233
  }
234
234
  }
235
+ exports.HyperModeling = HyperModeling;
235
236
  HyperModeling._markerConfig = {};
236
237
  HyperModeling._graphicsConfig = {};
237
- exports.HyperModeling = HyperModeling;
238
238
  //# sourceMappingURL=HyperModeling.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"HyperModeling.js","sourceRoot":"","sources":["../../src/HyperModeling.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA6C;AAC7C,oDAAiD;AACjD,wDAAsH;AACtH,mCAAwC;AACxC,qEAAkE;AAElE,iEAA8D;AA0B9D,SAAS,iBAAiB,CAAC,KAAuB;IAChD,IAAI,SAAS,KAAK,KAAK,CAAC,SAAS;QAC/B,MAAM,IAAI,KAAK,CAAC,+EAA+E,CAAC,CAAC;AACrG,CAAC;AAED;;;;;GAKG;AACH,MAAa,aAAa;I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,yBAAW,CAAC,MAAM;gBACrB,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC;YACvC;gBACE,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC;SACzC;IACH,CAAC;;AA5Oc,2BAAa,GAAwB,EAAE,CAAC;AACxC,6BAAe,GAA0B,EAAE,CAAC;AALhD,sCAAa","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 { assert } from \"@itwin/core-bentley\";\r\nimport { SectionType } from \"@itwin/core-common\";\r\nimport { IModelApp, IModelConnection, ScreenViewport, tryImageElementFromUrl, ViewManip } from \"@itwin/core-frontend\";\r\nimport { registerTools } from \"./Tools\";\r\nimport { HyperModelingDecorator } from \"./HyperModelingDecorator\";\r\nimport { HyperModelingConfig, SectionGraphicsConfig, SectionMarkerConfig } from \"./HyperModelingConfig\";\r\nimport { SectionMarkerHandler } from \"./SectionMarkerHandler\";\r\n\r\n/** @internal */\r\nexport interface MarkerData {\r\n readonly label: string;\r\n readonly image: HTMLImageElement | undefined;\r\n}\r\n\r\ninterface Resources {\r\n readonly namespace?: string;\r\n readonly markers: {\r\n readonly section: MarkerData;\r\n readonly plan: MarkerData;\r\n readonly elevation: MarkerData;\r\n readonly detail: MarkerData;\r\n };\r\n}\r\n\r\ninterface MaybeInitialized {\r\n resources?: Resources;\r\n}\r\n\r\ninterface Initialized {\r\n resources: Resources;\r\n}\r\n\r\nfunction assertInitialized(maybe: MaybeInitialized): asserts maybe is Initialized {\r\n if (undefined === maybe.resources)\r\n throw new Error(\"You must call HyperModeling.initialize before using the hypermodeling package\");\r\n}\r\n\r\n/** The API entry point for the hypermodeling package. Applications must call [[initialize]] and await the result before using the package.\r\n * The behavior of the package can be customized via a [[HyperModelingConfig]] supplied to [[initialize]], [[updateConfiguration]], or [[replaceConfiguration]].\r\n * Hypermodeling mode can be enabled or disabled via [[startOrStop]], which returns a [[HyperModelingDecorator]] when enabling hypermodeling.\r\n * Consult the package's `README.md` for a description of the available functionality.\r\n * @public\r\n */\r\nexport class HyperModeling {\r\n /** @internal */\r\n public static resources?: Resources;\r\n private static _markerHandler?: SectionMarkerHandler;\r\n private static _markerConfig: SectionMarkerConfig = {};\r\n private static _graphicsConfig: SectionGraphicsConfig = {};\r\n\r\n private static shutdown() {\r\n this.resources = undefined;\r\n this._markerHandler = undefined;\r\n this._markerConfig = {};\r\n this._graphicsConfig = {};\r\n }\r\n\r\n /** Returns whether the hypermodeling package is initialized.\r\n * @see [[HyperModeling.initialize]] to initialize the package.\r\n */\r\n public static get isInitialized(): boolean {\r\n return undefined !== this.resources;\r\n }\r\n\r\n /** Invoke this method to initialize the hypermodeling package for use. You *must* await the result before using any of this package's APIs.\r\n * Typically an application would invoke this after [IModelApp.startup]($frontend), e.g.,\r\n * ```ts\r\n * await IModelApp.startup();\r\n * await HyperModeling.initialize();\r\n * ```\r\n * Calling this method again after the first initialization behaves the same as calling [[HyperModeling.replaceConfiguration]].\r\n * @note The hypermodeling package will be reset to uninitialized after [IModelApp.shutdown]($frontend) is invoked.\r\n * @see [[replaceConfiguration]] and [[updateConfiguration]] to modify the configuration after initialization.\r\n */\r\n public static async initialize(config?: HyperModelingConfig): Promise<void> {\r\n if (undefined !== this.resources) {\r\n this.replaceConfiguration(config);\r\n return;\r\n }\r\n\r\n // clean up if we're being shut down\r\n IModelApp.onBeforeShutdown.addListener(() => this.shutdown());\r\n\r\n const namespace = \"HyperModeling\";\r\n await IModelApp.localization.registerNamespace(namespace);\r\n\r\n const loadImages = [\r\n tryImageElementFromUrl(`${IModelApp.publicPath}section-marker.svg`),\r\n tryImageElementFromUrl(`${IModelApp.publicPath}detail-marker.svg`),\r\n tryImageElementFromUrl(`${IModelApp.publicPath}elevation-marker.svg`),\r\n tryImageElementFromUrl(`${IModelApp.publicPath}plan-marker.svg`),\r\n ];\r\n\r\n const images = await Promise.all(loadImages);\r\n this.resources = {\r\n namespace,\r\n markers: {\r\n section: { image: images[0], label: IModelApp.localization.getLocalizedString(\"HyperModeling:Message.SectionCallout\") },\r\n detail: { image: images[1], label: IModelApp.localization.getLocalizedString(\"HyperModeling:Message.DetailCallout\") },\r\n elevation: { image: images[2], label: IModelApp.localization.getLocalizedString(\"HyperModeling:Message.ElevationCallout\") },\r\n plan: { image: images[3], label: IModelApp.localization.getLocalizedString(\"HyperModeling:Message.PlanCallout\") },\r\n },\r\n };\r\n\r\n registerTools(namespace);\r\n this.replaceConfiguration(config);\r\n }\r\n\r\n private static async ensureInitialized(): Promise<void> {\r\n if (undefined === this.resources)\r\n await this.initialize();\r\n\r\n assertInitialized(this);\r\n }\r\n\r\n /** Replaces the current package configuration, overwriting all previous settings. Passing `undefined` resets all settings to defaults.\r\n * @see [[HyperModeling.updateConfiguration]] for overriding specific aspects of the configuration.\r\n */\r\n public static replaceConfiguration(config?: HyperModelingConfig): void {\r\n config = config ?? {};\r\n this._markerHandler = config.markerHandler ?? new SectionMarkerHandler();\r\n this._markerConfig = config.markers ? { ...config.markers } : {};\r\n this._graphicsConfig = config.graphics ? { ...config.graphics } : {};\r\n }\r\n\r\n /** Overrides specific aspects of the current package configuration. Any field that is not `undefined` will be replaced in the current configuration;\r\n * the rest will retain their current values.\r\n * @see [[HyperModeling.replaceConfiguration]].\r\n */\r\n public static updateConfiguration(config: HyperModelingConfig): void {\r\n this._markerHandler = config.markerHandler ?? this._markerHandler;\r\n\r\n if (config.markers) {\r\n this._markerConfig = {\r\n ignoreModelSelector: config.markers.ignoreModelSelector ?? this._markerConfig.ignoreModelSelector,\r\n ignoreCategorySelector: config.markers.ignoreCategorySelector ?? this._markerConfig.ignoreCategorySelector,\r\n hiddenSectionTypes: config.markers.hiddenSectionTypes ?? this._markerConfig.hiddenSectionTypes,\r\n };\r\n }\r\n\r\n if (config.graphics) {\r\n this._graphicsConfig = {\r\n ignoreClip: config.graphics.ignoreClip ?? this._graphicsConfig.ignoreClip,\r\n debugClipVolumes: config.graphics.debugClipVolumes ?? this._graphicsConfig.debugClipVolumes,\r\n hideSectionGraphics: config.graphics.hideSectionGraphics ?? this._graphicsConfig.hideSectionGraphics,\r\n hideSheetAnnotations: config.graphics.hideSheetAnnotations ?? this._graphicsConfig.hideSheetAnnotations,\r\n };\r\n\r\n IModelApp.viewManager.invalidateViewportScenes();\r\n }\r\n }\r\n\r\n /** The handler that defines interactions with [[SectionMarker]]s.\r\n * @see [[initialize]] to override the default handler at package initialization.\r\n * @see [[updateConfiguration]] or [[replaceConfiguration]] to change the current handler.\r\n */\r\n public static get markerHandler(): SectionMarkerHandler {\r\n assertInitialized(this);\r\n assert(undefined !== this._markerHandler);\r\n return this._markerHandler;\r\n }\r\n\r\n /** The current marker display configuration applied to any newly-created [[HyperModelingDecorator]]s.\r\n * @see [[initialize]] to override the default configuration at package initialization.\r\n * @see [[updateConfiguration]] or [[replaceConfiguration]] to change the current configuration.\r\n * @see [[HyperModelingDecorator.replaceConfiguration]] or [[HyperModelingDecorator.updateConfiguration]] to change the configuration for an existing decorator.\r\n */\r\n public static get markerConfig(): SectionMarkerConfig {\r\n return this._markerConfig;\r\n }\r\n\r\n /** This graphics options applied to graphics displayed by all [[HyperModelingDecorator]]s.\r\n * @see [[updateConfiguration]] or [[replaceConfiguration]] to change the current configuration.\r\n */\r\n public static get graphicsConfig(): SectionGraphicsConfig {\r\n return this._graphicsConfig;\r\n }\r\n\r\n /** Returns true if the specified iModel contains any [SectionDrawingLocation]($backend)s. Hypermodeling is based on section drawing locations,\r\n * so if none are present, hypermodeling features are not relevant to the iModel. Attempting to use those features with such an iModel is fine,\r\n * but probably not useful.\r\n */\r\n public static async isSupportedForIModel(imodel: IModelConnection): Promise<boolean> {\r\n try {\r\n const reader = imodel.createQueryReader(\"SELECT ECInstanceId FROM bis.SectionDrawingLocation LIMIT 1\");\r\n return await reader.step(); // i.e., are any results are returned?\r\n } catch {\r\n // An iModel with a version of BisCore older than 1.0.11 will produce an expected \"table not found\" on the SectionDrawingLocation ECClass.\r\n return false;\r\n }\r\n }\r\n\r\n /** Returns whether hypermodeling is currently enabled for the specified viewport.\r\n * @see [[startOrStop]] to enable or disable hypermodeling for a viewport.\r\n */\r\n public static isEnabledForViewport(viewport: ScreenViewport): boolean {\r\n return undefined !== HyperModelingDecorator.getForViewport(viewport);\r\n }\r\n\r\n /** Start or stop hypermodeling mode for the specified viewport.\r\n * Enabling hypermodeling registers and returns a [[HyperModelingDecorator]] to display [[SectionMarker]]s within the viewport.\r\n * Disabling hypermodeling removes that decorator.\r\n * @param viewport The hypermodeling viewport\r\n * @param start `true` to enter hypermodeling mode, `false` to exit, or `undefined` to toggle the current mode.\r\n * @returns The new decorator is hypermodeling was successfully enabled.\r\n * @note Enabling hypermodeling may fail if the viewport is not viewing a spatial model or if the viewport's iModel does not support hypermodeling.\r\n * @see [[start]] and [[stop]].\r\n * @see [[isSupportedForIModel]].\r\n */\r\n public static async startOrStop(viewport: ScreenViewport, start?: boolean): Promise<HyperModelingDecorator | undefined> {\r\n // Help out the caller since we're async anyway...\r\n await this.ensureInitialized();\r\n\r\n const decorator = HyperModelingDecorator.getForViewport(viewport);\r\n if (undefined === start)\r\n start = undefined === decorator;\r\n\r\n if (start) {\r\n return this._start(viewport);\r\n } else {\r\n decorator?.dispose();\r\n return undefined;\r\n }\r\n }\r\n\r\n /** Start hypermodeling mode for the specified viewport if it is not currently enabled.\r\n * If hypermodeling is already enabled for the viewport, the existing decorator is returned; otherwise, a new decorator is created.\r\n * @param viewport The viewport for which to enable hypermodeling\r\n * @returns The decorator that implements hypermodeling features for the viewport, or `undefined` if hypermodeling could not be enabled.\r\n * @note Enabling hypermodeling may fail if the viewport is not viewing a spatial model or if the viewport's iModel does not support hypermodeling.\r\n */\r\n public static async start(viewport: ScreenViewport): Promise<HyperModelingDecorator | undefined> {\r\n await this.ensureInitialized();\r\n return this._start(viewport);\r\n }\r\n\r\n private static async _start(viewport: ScreenViewport): Promise<HyperModelingDecorator | undefined> {\r\n assertInitialized(this);\r\n if (!viewport.view.isSpatialView())\r\n return undefined;\r\n\r\n let decorator = HyperModelingDecorator.getForViewport(viewport);\r\n if (!decorator)\r\n decorator = await HyperModelingDecorator.create(viewport, this._markerConfig);\r\n\r\n if (undefined !== decorator && viewport.view.isCameraOn) {\r\n // We want the 2d graphics to align with the 3d geometry. Perspective ruins that.\r\n viewport.view.turnCameraOff();\r\n ViewManip.fitView(viewport, false, { noSaveInUndo: true });\r\n viewport.clearViewUndo();\r\n }\r\n\r\n return decorator;\r\n }\r\n\r\n /** Stop hypermodeling mode for the specified viewport if it is currently enabled. This disposes of the [[HyperModelingDecorator]] associated with the viewport.\r\n * @see [[start]] to enable hypermodeling for a viewport.\r\n * @see [[startOrStop]] to toggle hypermodeling mode.\r\n */\r\n public static stop(viewport: ScreenViewport): void {\r\n const decorator = HyperModelingDecorator.getForViewport(viewport);\r\n decorator?.dispose();\r\n }\r\n\r\n /** @internal */\r\n public static get namespace(): string | undefined {\r\n assertInitialized(this);\r\n return this.resources.namespace;\r\n }\r\n\r\n /** @internal */\r\n public static getMarkerData(type: SectionType): MarkerData {\r\n assertInitialized(this);\r\n switch (type) {\r\n case SectionType.Plan:\r\n return this.resources.markers.plan;\r\n case SectionType.Elevation:\r\n return this.resources.markers.elevation;\r\n case SectionType.Detail:\r\n return this.resources.markers.detail;\r\n default:\r\n return this.resources.markers.section;\r\n }\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"HyperModeling.js","sourceRoot":"","sources":["../../src/HyperModeling.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAA6C;AAC7C,oDAAiD;AACjD,wDAAsH;AACtH,mCAAwC;AACxC,qEAAkE;AAElE,iEAA8D;AA0B9D,SAAS,iBAAiB,CAAC,KAAuB;IAChD,IAAI,SAAS,KAAK,KA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,IAAI,EAAE,CAAC;YACb,KAAK,yBAAW,CAAC,IAAI;gBACnB,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,IAAI,CAAC;YACrC,KAAK,yBAAW,CAAC,SAAS;gBACxB,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,SAAS,CAAC;YAC1C,KAAK,yBAAW,CAAC,MAAM;gBACrB,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC;YACvC;gBACE,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,OAAO,CAAC;QAC1C,CAAC;IACH,CAAC;;AAhPH,sCAiPC;AA7OgB,2BAAa,GAAwB,EAAE,CAAC;AACxC,6BAAe,GAA0B,EAAE,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 { assert } from \"@itwin/core-bentley\";\r\nimport { SectionType } from \"@itwin/core-common\";\r\nimport { IModelApp, IModelConnection, ScreenViewport, tryImageElementFromUrl, ViewManip } from \"@itwin/core-frontend\";\r\nimport { registerTools } from \"./Tools\";\r\nimport { HyperModelingDecorator } from \"./HyperModelingDecorator\";\r\nimport { HyperModelingConfig, SectionGraphicsConfig, SectionMarkerConfig } from \"./HyperModelingConfig\";\r\nimport { SectionMarkerHandler } from \"./SectionMarkerHandler\";\r\n\r\n/** @internal */\r\nexport interface MarkerData {\r\n readonly label: string;\r\n readonly image: HTMLImageElement | undefined;\r\n}\r\n\r\ninterface Resources {\r\n readonly namespace?: string;\r\n readonly markers: {\r\n readonly section: MarkerData;\r\n readonly plan: MarkerData;\r\n readonly elevation: MarkerData;\r\n readonly detail: MarkerData;\r\n };\r\n}\r\n\r\ninterface MaybeInitialized {\r\n resources?: Resources;\r\n}\r\n\r\ninterface Initialized {\r\n resources: Resources;\r\n}\r\n\r\nfunction assertInitialized(maybe: MaybeInitialized): asserts maybe is Initialized {\r\n if (undefined === maybe.resources)\r\n throw new Error(\"You must call HyperModeling.initialize before using the hypermodeling package\");\r\n}\r\n\r\n/** The API entry point for the hypermodeling package. Applications must call [[initialize]] and await the result before using the package.\r\n * The behavior of the package can be customized via a [[HyperModelingConfig]] supplied to [[initialize]], [[updateConfiguration]], or [[replaceConfiguration]].\r\n * Hypermodeling mode can be enabled or disabled via [[startOrStop]], which returns a [[HyperModelingDecorator]] when enabling hypermodeling.\r\n * Consult the package's `README.md` for a description of the available functionality.\r\n * @public\r\n */\r\nexport class HyperModeling {\r\n /** @internal */\r\n public static resources?: Resources;\r\n private static _markerHandler?: SectionMarkerHandler;\r\n private static _markerConfig: SectionMarkerConfig = {};\r\n private static _graphicsConfig: SectionGraphicsConfig = {};\r\n\r\n private static shutdown() {\r\n this.resources = undefined;\r\n this._markerHandler = undefined;\r\n this._markerConfig = {};\r\n this._graphicsConfig = {};\r\n }\r\n\r\n /** Returns whether the hypermodeling package is initialized.\r\n * @see [[HyperModeling.initialize]] to initialize the package.\r\n */\r\n public static get isInitialized(): boolean {\r\n return undefined !== this.resources;\r\n }\r\n\r\n /** Invoke this method to initialize the hypermodeling package for use. You *must* await the result before using any of this package's APIs.\r\n * Typically an application would invoke this after [IModelApp.startup]($frontend), e.g.,\r\n * ```ts\r\n * await IModelApp.startup();\r\n * await HyperModeling.initialize();\r\n * ```\r\n * Calling this method again after the first initialization behaves the same as calling [[HyperModeling.replaceConfiguration]].\r\n * @note The hypermodeling package will be reset to uninitialized after [IModelApp.shutdown]($frontend) is invoked.\r\n * @see [[replaceConfiguration]] and [[updateConfiguration]] to modify the configuration after initialization.\r\n */\r\n public static async initialize(config?: HyperModelingConfig): Promise<void> {\r\n if (undefined !== this.resources) {\r\n this.replaceConfiguration(config);\r\n return;\r\n }\r\n\r\n // clean up if we're being shut down\r\n IModelApp.onBeforeShutdown.addListener(() => this.shutdown());\r\n\r\n const namespace = \"HyperModeling\";\r\n await IModelApp.localization.registerNamespace(namespace);\r\n\r\n const loadImages = [\r\n tryImageElementFromUrl(`${IModelApp.publicPath}section-marker.svg`),\r\n tryImageElementFromUrl(`${IModelApp.publicPath}detail-marker.svg`),\r\n tryImageElementFromUrl(`${IModelApp.publicPath}elevation-marker.svg`),\r\n tryImageElementFromUrl(`${IModelApp.publicPath}plan-marker.svg`),\r\n ];\r\n\r\n const images = await Promise.all(loadImages);\r\n this.resources = {\r\n namespace,\r\n markers: {\r\n section: { image: images[0], label: IModelApp.localization.getLocalizedString(\"HyperModeling:Message.SectionCallout\") },\r\n detail: { image: images[1], label: IModelApp.localization.getLocalizedString(\"HyperModeling:Message.DetailCallout\") },\r\n elevation: { image: images[2], label: IModelApp.localization.getLocalizedString(\"HyperModeling:Message.ElevationCallout\") },\r\n plan: { image: images[3], label: IModelApp.localization.getLocalizedString(\"HyperModeling:Message.PlanCallout\") },\r\n },\r\n };\r\n\r\n registerTools(namespace);\r\n this.replaceConfiguration(config);\r\n }\r\n\r\n private static async ensureInitialized(): Promise<void> {\r\n if (undefined === this.resources)\r\n await this.initialize();\r\n\r\n assertInitialized(this);\r\n }\r\n\r\n /** Replaces the current package configuration, overwriting all previous settings. Passing `undefined` resets all settings to defaults.\r\n * @see [[HyperModeling.updateConfiguration]] for overriding specific aspects of the configuration.\r\n */\r\n public static replaceConfiguration(config?: HyperModelingConfig): void {\r\n config = config ?? {};\r\n this._markerHandler = config.markerHandler ?? new SectionMarkerHandler();\r\n this._markerConfig = config.markers ? { ...config.markers } : {};\r\n this._graphicsConfig = config.graphics ? { ...config.graphics } : {};\r\n }\r\n\r\n /** Overrides specific aspects of the current package configuration. Any field that is not `undefined` will be replaced in the current configuration;\r\n * the rest will retain their current values.\r\n * @see [[HyperModeling.replaceConfiguration]].\r\n */\r\n public static updateConfiguration(config: HyperModelingConfig): void {\r\n this._markerHandler = config.markerHandler ?? this._markerHandler;\r\n\r\n if (config.markers) {\r\n this._markerConfig = {\r\n ignoreModelSelector: config.markers.ignoreModelSelector ?? this._markerConfig.ignoreModelSelector,\r\n ignoreCategorySelector: config.markers.ignoreCategorySelector ?? this._markerConfig.ignoreCategorySelector,\r\n hiddenSectionTypes: config.markers.hiddenSectionTypes ?? this._markerConfig.hiddenSectionTypes,\r\n };\r\n }\r\n\r\n if (config.graphics) {\r\n this._graphicsConfig = {\r\n ignoreClip: config.graphics.ignoreClip ?? this._graphicsConfig.ignoreClip,\r\n debugClipVolumes: config.graphics.debugClipVolumes ?? this._graphicsConfig.debugClipVolumes,\r\n hideSectionGraphics: config.graphics.hideSectionGraphics ?? this._graphicsConfig.hideSectionGraphics,\r\n hideSheetAnnotations: config.graphics.hideSheetAnnotations ?? this._graphicsConfig.hideSheetAnnotations,\r\n };\r\n\r\n IModelApp.viewManager.invalidateViewportScenes();\r\n }\r\n }\r\n\r\n /** The handler that defines interactions with [[SectionMarker]]s.\r\n * @see [[initialize]] to override the default handler at package initialization.\r\n * @see [[updateConfiguration]] or [[replaceConfiguration]] to change the current handler.\r\n */\r\n public static get markerHandler(): SectionMarkerHandler {\r\n assertInitialized(this);\r\n assert(undefined !== this._markerHandler);\r\n return this._markerHandler;\r\n }\r\n\r\n /** The current marker display configuration applied to any newly-created [[HyperModelingDecorator]]s.\r\n * @see [[initialize]] to override the default configuration at package initialization.\r\n * @see [[updateConfiguration]] or [[replaceConfiguration]] to change the current configuration.\r\n * @see [[HyperModelingDecorator.replaceConfiguration]] or [[HyperModelingDecorator.updateConfiguration]] to change the configuration for an existing decorator.\r\n */\r\n public static get markerConfig(): SectionMarkerConfig {\r\n return this._markerConfig;\r\n }\r\n\r\n /** This graphics options applied to graphics displayed by all [[HyperModelingDecorator]]s.\r\n * @see [[updateConfiguration]] or [[replaceConfiguration]] to change the current configuration.\r\n */\r\n public static get graphicsConfig(): SectionGraphicsConfig {\r\n return this._graphicsConfig;\r\n }\r\n\r\n /** Returns true if the specified iModel contains any [SectionDrawingLocation]($backend)s. Hypermodeling is based on section drawing locations,\r\n * so if none are present, hypermodeling features are not relevant to the iModel. Attempting to use those features with such an iModel is fine,\r\n * but probably not useful.\r\n */\r\n public static async isSupportedForIModel(imodel: IModelConnection): Promise<boolean> {\r\n try {\r\n const reader = imodel.createQueryReader(\"SELECT ECInstanceId FROM bis.SectionDrawingLocation LIMIT 1\");\r\n return await reader.step(); // i.e., are any results are returned?\r\n } catch {\r\n // An iModel with a version of BisCore older than 1.0.11 will produce an expected \"table not found\" on the SectionDrawingLocation ECClass.\r\n return false;\r\n }\r\n }\r\n\r\n /** Returns whether hypermodeling is currently enabled for the specified viewport.\r\n * @see [[startOrStop]] to enable or disable hypermodeling for a viewport.\r\n */\r\n public static isEnabledForViewport(viewport: ScreenViewport): boolean {\r\n return undefined !== HyperModelingDecorator.getForViewport(viewport);\r\n }\r\n\r\n /** Start or stop hypermodeling mode for the specified viewport.\r\n * Enabling hypermodeling registers and returns a [[HyperModelingDecorator]] to display [[SectionMarker]]s within the viewport.\r\n * Disabling hypermodeling removes that decorator.\r\n * @param viewport The hypermodeling viewport\r\n * @param start `true` to enter hypermodeling mode, `false` to exit, or `undefined` to toggle the current mode.\r\n * @returns The new decorator is hypermodeling was successfully enabled.\r\n * @note Enabling hypermodeling may fail if the viewport is not viewing a spatial model or if the viewport's iModel does not support hypermodeling.\r\n * @see [[start]] and [[stop]].\r\n * @see [[isSupportedForIModel]].\r\n */\r\n public static async startOrStop(viewport: ScreenViewport, start?: boolean): Promise<HyperModelingDecorator | undefined> {\r\n // Help out the caller since we're async anyway...\r\n await this.ensureInitialized();\r\n\r\n const decorator = HyperModelingDecorator.getForViewport(viewport);\r\n if (undefined === start)\r\n start = undefined === decorator;\r\n\r\n if (start) {\r\n return this._start(viewport);\r\n } else {\r\n decorator?.dispose();\r\n return undefined;\r\n }\r\n }\r\n\r\n /** Start hypermodeling mode for the specified viewport if it is not currently enabled.\r\n * If hypermodeling is already enabled for the viewport, the existing decorator is returned; otherwise, a new decorator is created.\r\n * @param viewport The viewport for which to enable hypermodeling\r\n * @returns The decorator that implements hypermodeling features for the viewport, or `undefined` if hypermodeling could not be enabled.\r\n * @note Enabling hypermodeling may fail if the viewport is not viewing a spatial model or if the viewport's iModel does not support hypermodeling.\r\n */\r\n public static async start(viewport: ScreenViewport): Promise<HyperModelingDecorator | undefined> {\r\n await this.ensureInitialized();\r\n return this._start(viewport);\r\n }\r\n\r\n private static async _start(viewport: ScreenViewport): Promise<HyperModelingDecorator | undefined> {\r\n assertInitialized(this);\r\n if (!viewport.view.isSpatialView())\r\n return undefined;\r\n\r\n let decorator = HyperModelingDecorator.getForViewport(viewport);\r\n if (!decorator)\r\n decorator = await HyperModelingDecorator.create(viewport, this._markerConfig);\r\n\r\n if (undefined !== decorator && viewport.view.isCameraOn) {\r\n // We want the 2d graphics to align with the 3d geometry. Perspective ruins that.\r\n viewport.view.turnCameraOff();\r\n ViewManip.fitView(viewport, false, { noSaveInUndo: true });\r\n viewport.clearViewUndo();\r\n }\r\n\r\n return decorator;\r\n }\r\n\r\n /** Stop hypermodeling mode for the specified viewport if it is currently enabled. This disposes of the [[HyperModelingDecorator]] associated with the viewport.\r\n * @see [[start]] to enable hypermodeling for a viewport.\r\n * @see [[startOrStop]] to toggle hypermodeling mode.\r\n */\r\n public static stop(viewport: ScreenViewport): void {\r\n const decorator = HyperModelingDecorator.getForViewport(viewport);\r\n decorator?.dispose();\r\n }\r\n\r\n /** @internal */\r\n public static get namespace(): string | undefined {\r\n assertInitialized(this);\r\n return this.resources.namespace;\r\n }\r\n\r\n /** @internal */\r\n public static getMarkerData(type: SectionType): MarkerData {\r\n assertInitialized(this);\r\n switch (type) {\r\n case SectionType.Plan:\r\n return this.resources.markers.plan;\r\n case SectionType.Elevation:\r\n return this.resources.markers.elevation;\r\n case SectionType.Detail:\r\n return this.resources.markers.detail;\r\n default:\r\n return this.resources.markers.section;\r\n }\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"Hyper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AO,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 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 { x: this.marker.rect.right, y: 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,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,CA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------------------\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 { x: this.marker.rect.right, y: 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"]}
@@ -43,6 +43,7 @@ class PopupToolbarManager {
43
43
  setTimeout(() => this.show(), 500);
44
44
  }
45
45
  }
46
+ exports.PopupToolbarManager = PopupToolbarManager;
46
47
  PopupToolbarManager._itemExecuted = (item) => {
47
48
  const mgr = PopupToolbarManager;
48
49
  if (mgr._current)
@@ -54,5 +55,4 @@ PopupToolbarManager._cancel = () => {
54
55
  if (!mgr._current || !mgr._current.overToolbarHotspot)
55
56
  mgr.close(); // Don't hide when click is over hotspot
56
57
  };
57
- exports.PopupToolbarManager = PopupToolbarManager;
58
58
  //# sourceMappingURL=PopupToolbar.js.map
@@ -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;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,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,CA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G,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;AA/BS,kDAAmB","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, { x: 0, y: 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 const delay = 1000;\r\n if (this._current.overToolbarHotspot || !IModelApp.toolAdmin.cursorView)\r\n setTimeout(() => this.closeAfterTimeout(), delay); // 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,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,IAAI,CAAC,aAAa,EAAE,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,IAAI,CAAC,WAAW,CAAC;YAC5I,OAAO,KAAK,CAAC;QAEf,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC;QAC/B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,iBAAiB,EAAE,CAAC;QACzB,OAAO,IAAI,CAAC;IACd,CAAC;IAgBO,MAAM,CAAC,KAAK;QAClB,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC;QAC1B,OAAO,yBAAS,CAAC,OAAO,CAAC,WAAW,EAAE,CAAC;IACzC,CAAC;IAEO,MAAM,CAAC,iBAAiB;QAC9B,IAAI,CAAC,IAAI,CAAC,QAAQ;YAChB,OAAO;QAET,MAAM,KAAK,GAAG,IAAI,CAAC;QACnB,IAAI,IAAI,CAAC,QAAQ,CAAC,kBAAkB,IAAI,CAAC,yBAAS,CAAC,SAAS,CAAC,UAAU;YACrE,UAAU,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,iBAAiB,EAAE,EAAE,KAAK,CAAC,CAAC,CAAC,kDAAkD;;YAErG,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;;AAvDH,kDAwDC;AArCgB,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, { x: 0, y: 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 const delay = 1000;\r\n if (this._current.overToolbarHotspot || !IModelApp.toolAdmin.cursorView)\r\n setTimeout(() => this.closeAfterTimeout(), delay); // 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 +1 @@
1
- {"version":3,"file":"SectionDrawingLocationState.js","sourceRoot":"","sources":["../../src/SectionDrawingLocationState.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,oDAA8E;AAC9E,wDAA4G;AAC5G,wDAAuE;AAEvE,MAAM,uCAAuC,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6B/C,CAAC;AA4CF;;;GAGG;AACH,MAAa,2BAA2B;IA8BtC,gBAAgB;IAChB,YAAmB,KAAsC,EAAE,MAAwB;QACjF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,EAAE,GAAG,KAAK,CAAC,iBAAiB,CAAC;QAClC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,sBAAsB,CAAC;QAC1C,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;QACjC,IAAI,CAAC,QAAQ,GAAG,KAAK,CAAC,UAAU,CAAC;QACjC,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC,WAAW,CAAC;QACrC,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,aAAa,CAAC;QACzC,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,aAAa,CAAC;QACzC,IAAI,CAAC,yBAAyB,GAAG,yBAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,yBAAyB,CAAC,CAAC,CAAC;QAEjG,MAAM,WAAW,GAAG,CAAC,GAAuB,EAAE,EAAE;YAC9C,IAAI,IAAI,CAAC;YACT,IAAI,GAAG,EAAE;gBACP,IAAI;oBACF,IAAI,GAAG,0BAAU,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,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;CACF;AA5HD,kEA4HC","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 { Id64String } from \"@itwin/core-bentley\";\r\nimport { Placement3d, QueryRowFormat, SectionType } from \"@itwin/core-common\";\r\nimport { DrawingViewState, IModelConnection, SheetViewState, SpatialViewState } from \"@itwin/core-frontend\";\r\nimport { ClipVector, Transform, XYZProps } from \"@itwin/core-geometry\";\r\n\r\nconst selectSectionDrawingLocationStatesECSql = `\r\n SELECT\r\n bis.SectionDrawingLocation.ECInstanceId as sectionLocationId,\r\n bis.SectionDrawingLocation.Model.Id as sectionLocationModelId,\r\n bis.SectionDrawingLocation.SectionView.Id as sectionViewId,\r\n bis.SectionDrawingLocation.Category.Id as categoryId,\r\n bis.SectionDrawingLocation.Origin as origin,\r\n bis.SectionDrawingLocation.Yaw as yaw,\r\n bis.SectionDrawingLocation.Pitch as pitch,\r\n bis.SectionDrawingLocation.Roll as roll,\r\n bis.SectionDrawingLocation.BBoxLow as bboxLow,\r\n bis.SectionDrawingLocation.BBoxHigh as bboxHigh,\r\n bis.SectionDrawingLocation.UserLabel as userLabel,\r\n\r\n bis.SectionDrawing.SectionType as sectionType,\r\n json_extract(bis.SectionDrawing.jsonProperties, '$.drawingToSpatialTransform') as drawingToSpatialTransform,\r\n bis.SectionDrawing.SpatialView.Id as spatialViewId,\r\n json_extract(bis.SectionDrawing.jsonProperties, '$.sheetToSpatialTransform') as sheetToSpatialTransform,\r\n json_extract(bis.SectionDrawing.jsonProperties, '$.drawingBoundaryClip') as sheetClip,\r\n\r\n json_extract(bis.SpatialViewDefinition.jsonProperties, '$.viewDetails.clip') as clipJSON,\r\n bis.ViewAttachment.ECInstanceId as viewAttachmentId,\r\n bis.SheetViewDefinition.ECInstanceId as sheetViewId\r\n FROM bis.SectionDrawingLocation\r\n INNER JOIN bis.ViewDefinition2d on bis.SectionDrawingLocation.SectionView.Id = bis.ViewDefinition2d.ECInstanceId\r\n INNER JOIN bis.SectionDrawing on bis.ViewDefinition2d.BaseModel.Id = bis.SectionDrawing.ECInstanceId\r\n LEFT JOIN bis.ViewAttachment on bis.ViewDefinition2d.ECInstanceId = bis.ViewAttachment.View.Id\r\n LEFT JOIN bis.SheetViewDefinition on bis.SheetViewDefinition.BaseModel.Id = bis.ViewAttachment.Model.Id\r\n INNER JOIN bis.SpatialViewDefinition on bis.SpatialViewDefinition.ECInstanceId = bis.SectionDrawing.SpatialView.Id\r\n`;\r\n\r\n/** Raw data representing a [[SectionDrawingLocationState]]. This is an amalgamation of data from several related ECClasses.\r\n * @internal\r\n */\r\nexport interface SectionDrawingLocationStateData {\r\n sectionType: SectionType;\r\n drawingToSpatialTransform: string; // stringified TransformProps\r\n spatialViewId: Id64String;\r\n clipJSON?: string; // stringified ClipVector json\r\n viewAttachmentId?: Id64String;\r\n sheetToSpatialTransform?: string; // stringified TransformProps\r\n sheetClip?: string; // stringified ClipVector json\r\n sheetViewId?: Id64String;\r\n\r\n sectionLocationId: Id64String;\r\n sectionLocationModelId: Id64String;\r\n sectionViewId: Id64String;\r\n categoryId: Id64String;\r\n origin?: XYZProps;\r\n yaw?: number;\r\n pitch?: number;\r\n roll?: number;\r\n bboxLow?: XYZProps;\r\n bboxHigh?: XYZProps;\r\n userLabel: string;\r\n}\r\n\r\n/** Represents a [ViewAttachment]($backend) that attaches a [[SectionDrawingLocationState]] to a [Sheet]($backend) model.\r\n * @public\r\n */\r\nexport interface SectionViewAttachment {\r\n /** The view attachment's element Id. */\r\n readonly id: Id64String;\r\n /** The Id of a [SheetViewDefinition]($backend) that displays this view attachment.\r\n * This is used when navigating from the spatial view to the view attachment.\r\n */\r\n readonly viewId?: Id64String;\r\n /** The transform from the [Sheet]($backend) coordinate space to the spatial coordinate space. */\r\n readonly transformToSpatial: Transform;\r\n /** Optional 2d clip vector used to clip out portions of the [Sheet]($backend) containing annotations not relevant to this section drawing. */\r\n readonly clip?: ClipVector;\r\n}\r\n\r\n/** Represents a [SectionDrawingLocation]($backend), including data from related elements like [SectionDrawing]($backend) used in a hyper-modeling context.\r\n * @see [[SectionMarker]] for a widget that allows the user to interact with a section drawing location.\r\n * @public\r\n */\r\nexport class SectionDrawingLocationState {\r\n /** The iModel in which this section drawing location resides. */\r\n public readonly iModel: IModelConnection;\r\n /** The element Id of the section drawing location. */\r\n public readonly id: Id64String;\r\n /** The Id of the [GeometricModel3d]($backend) in which this section drawing location resides. */\r\n public readonly model: Id64String;\r\n /** A user-friendly label for the section drawing location. */\r\n public readonly userLabel: string;\r\n /** The Id of the [SpatialCategory]($backend) to which this section drawing location belongs. */\r\n public readonly category: Id64String;\r\n /** The section drawing location's spatial placement. */\r\n public readonly placement: Placement3d;\r\n /** The type of section that generated the associated [SectionDrawing]($backend). */\r\n public readonly sectionType: SectionType;\r\n /** The Id of the [ViewDefinition]($backend) that can display the section graphics. */\r\n public readonly drawingViewId: Id64String;\r\n /** The Id of the [SpatialViewDefinition]($backend) from which the section drawing was generated. */\r\n public readonly spatialViewId: Id64String;\r\n /** The section clip from the [SpatialViewDefinition]($backend) from which the section drawing was generated. */\r\n public readonly clip: ClipVector;\r\n /** The transform from the [GeometricModel]($backend) containing the section graphics to the spatial coordinate space.\r\n * This is used to position the 2d graphics in the context of a spatial view.\r\n */\r\n public readonly drawingToSpatialTransform: Transform;\r\n /** If the section drawing is attached to a [Sheet]($backend), details about the corresponding [ViewAttachment]($backend).\r\n * When this section drawing location is displayed in a spatial context, annotations in the sheet model can be displayed along with the section graphics.\r\n */\r\n public readonly viewAttachment?: SectionViewAttachment;\r\n\r\n /** @internal */\r\n public constructor(props: SectionDrawingLocationStateData, iModel: IModelConnection) {\r\n this.iModel = iModel;\r\n this.id = props.sectionLocationId;\r\n this.model = props.sectionLocationModelId;\r\n this.userLabel = props.userLabel;\r\n this.category = props.categoryId;\r\n this.sectionType = props.sectionType;\r\n this.drawingViewId = props.sectionViewId;\r\n this.spatialViewId = props.spatialViewId;\r\n this.drawingToSpatialTransform = Transform.fromJSON(JSON.parse(props.drawingToSpatialTransform));\r\n\r\n const extractClip = (str: string | undefined) => {\r\n let clip;\r\n if (str) {\r\n try {\r\n clip = ClipVector.fromJSON(JSON.parse(str));\r\n } catch { }\r\n }\r\n\r\n return clip;\r\n };\r\n\r\n this.clip = extractClip(props.clipJSON) ?? ClipVector.createEmpty();\r\n\r\n const placementProps = {\r\n origin: props.origin ?? {},\r\n angles: {\r\n yaw: props.yaw,\r\n pitch: props.pitch,\r\n roll: props.roll,\r\n },\r\n placement: (props.bboxLow && props.bboxHigh) ? { low: props.bboxLow, high: props.bboxHigh } : undefined,\r\n };\r\n this.placement = Placement3d.fromJSON(placementProps);\r\n\r\n if (props.viewAttachmentId && props.sheetToSpatialTransform) {\r\n this.viewAttachment = {\r\n id: props.viewAttachmentId,\r\n transformToSpatial: Transform.fromJSON(JSON.parse(props.sheetToSpatialTransform)),\r\n clip: extractClip(props.sheetClip),\r\n viewId: props.sheetViewId,\r\n };\r\n }\r\n }\r\n\r\n /** Return a promise that resolves to the [DrawingViewState]($frontend) corresponding to `this.drawingViewId`, or undefined if an exception occurs. */\r\n public async tryLoadDrawingView(): Promise<DrawingViewState | undefined> {\r\n try {\r\n const view = await this.iModel.views.load(this.drawingViewId);\r\n if (view instanceof DrawingViewState)\r\n return view;\r\n } catch { }\r\n\r\n return undefined;\r\n }\r\n\r\n /** Return a promise that resolves to the [SpatialViewState]($frontend) corresponding to `this.spatialViewId`, or undefined if an exception occurs. */\r\n public async tryLoadSpatialView(): Promise<SpatialViewState | undefined> {\r\n try {\r\n const view = await this.iModel.views.load(this.spatialViewId);\r\n if (view instanceof SpatialViewState)\r\n return view;\r\n } catch { }\r\n\r\n return undefined;\r\n }\r\n\r\n /** Return a promise that resolves to the [SheetViewState]($frontend) corresponding to `this.viewAttachment.viewId`; or undefined if there is no corresponding [ViewAttachment]($backend) or an exception occurs. */\r\n public async tryLoadSheetView(): Promise<SheetViewState | undefined> {\r\n if (undefined === this.viewAttachment || undefined === this.viewAttachment.viewId)\r\n return undefined;\r\n\r\n try {\r\n const view = await this.iModel.views.load(this.viewAttachment.viewId);\r\n if (view instanceof SheetViewState)\r\n return view;\r\n } catch { }\r\n\r\n return undefined;\r\n }\r\n\r\n /** Query the specified iModel for [SectionDrawingLocation]($backend)s and return a list of corresponding [[SectionDrawingLocationState]]s. */\r\n public static async queryAll(iModel: IModelConnection): Promise<SectionDrawingLocationState[]> {\r\n const states: SectionDrawingLocationState[] = [];\r\n try {\r\n for await (const row of iModel.createQueryReader(selectSectionDrawingLocationStatesECSql, undefined, { rowFormat: QueryRowFormat.UseJsPropertyNames }))\r\n states.push(new SectionDrawingLocationState(row.toRow() as SectionDrawingLocationStateData, iModel));\r\n } catch {\r\n // If the iModel contains a version of BisCore schema older than 1.12.0, the query will produce an exception due to missing SectionDrawingLocation class. That's fine.\r\n }\r\n\r\n return states;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"SectionDrawingLocationState.js","sourceRoot":"","sources":["../../src/SectionDrawingLocationState.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,oDAA8E;AAC9E,wDAA4G;AAC5G,wDAAuE;AAEvE,MAAM,uCAAuC,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA6B/C,CAAC;AA4CF;;;GAGG;AACH,MAAa,2BAA2B;IA8BtC,gBAAgB;IAChB,YAAmB,KAAsC,EAAE,MAAwB;QACjF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,EAAE,GAAG,KAAK,CAAC,iBAAiB,CAAC;QAClC,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,sBAAsB,CAAC;QAC1C,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC,SAAS,CAAC;QACjC,IAAI,CAAC,QAAQ,GAA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AAC,cAAc,CAAC,MAAM,CAAC,CAAC;YACtE,IAAI,IAAI,YAAY,8BAAc;gBAChC,OAAO,IAAI,CAAC;QAChB,CAAC;QAAC,MAAM,CAAC,CAAC,CAAC;QAEX,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,8IAA8I;IACvI,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,MAAwB;QACnD,MAAM,MAAM,GAAkC,EAAE,CAAC;QACjD,IAAI,CAAC;YACH,IAAI,KAAK,EAAE,MAAM,GAAG,IAAI,MAAM,CAAC,iBAAiB,CAAC,uCAAuC,EAAE,SAAS,EAAE,EAAE,SAAS,EAAE,4BAAc,CAAC,kBAAkB,EAAE,CAAC;gBACpJ,MAAM,CAAC,IAAI,CAAC,IAAI,2BAA2B,CAAC,GAAG,CAAC,KAAK,EAAqC,EAAE,MAAM,CAAC,CAAC,CAAC;QACzG,CAAC;QAAC,MAAM,CAAC;YACP,sKAAsK;QACxK,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA5HD,kEA4HC","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 { Id64String } from \"@itwin/core-bentley\";\r\nimport { Placement3d, QueryRowFormat, SectionType } from \"@itwin/core-common\";\r\nimport { DrawingViewState, IModelConnection, SheetViewState, SpatialViewState } from \"@itwin/core-frontend\";\r\nimport { ClipVector, Transform, XYZProps } from \"@itwin/core-geometry\";\r\n\r\nconst selectSectionDrawingLocationStatesECSql = `\r\n SELECT\r\n bis.SectionDrawingLocation.ECInstanceId as sectionLocationId,\r\n bis.SectionDrawingLocation.Model.Id as sectionLocationModelId,\r\n bis.SectionDrawingLocation.SectionView.Id as sectionViewId,\r\n bis.SectionDrawingLocation.Category.Id as categoryId,\r\n bis.SectionDrawingLocation.Origin as origin,\r\n bis.SectionDrawingLocation.Yaw as yaw,\r\n bis.SectionDrawingLocation.Pitch as pitch,\r\n bis.SectionDrawingLocation.Roll as roll,\r\n bis.SectionDrawingLocation.BBoxLow as bboxLow,\r\n bis.SectionDrawingLocation.BBoxHigh as bboxHigh,\r\n bis.SectionDrawingLocation.UserLabel as userLabel,\r\n\r\n bis.SectionDrawing.SectionType as sectionType,\r\n json_extract(bis.SectionDrawing.jsonProperties, '$.drawingToSpatialTransform') as drawingToSpatialTransform,\r\n bis.SectionDrawing.SpatialView.Id as spatialViewId,\r\n json_extract(bis.SectionDrawing.jsonProperties, '$.sheetToSpatialTransform') as sheetToSpatialTransform,\r\n json_extract(bis.SectionDrawing.jsonProperties, '$.drawingBoundaryClip') as sheetClip,\r\n\r\n json_extract(bis.SpatialViewDefinition.jsonProperties, '$.viewDetails.clip') as clipJSON,\r\n bis.ViewAttachment.ECInstanceId as viewAttachmentId,\r\n bis.SheetViewDefinition.ECInstanceId as sheetViewId\r\n FROM bis.SectionDrawingLocation\r\n INNER JOIN bis.ViewDefinition2d on bis.SectionDrawingLocation.SectionView.Id = bis.ViewDefinition2d.ECInstanceId\r\n INNER JOIN bis.SectionDrawing on bis.ViewDefinition2d.BaseModel.Id = bis.SectionDrawing.ECInstanceId\r\n LEFT JOIN bis.ViewAttachment on bis.ViewDefinition2d.ECInstanceId = bis.ViewAttachment.View.Id\r\n LEFT JOIN bis.SheetViewDefinition on bis.SheetViewDefinition.BaseModel.Id = bis.ViewAttachment.Model.Id\r\n INNER JOIN bis.SpatialViewDefinition on bis.SpatialViewDefinition.ECInstanceId = bis.SectionDrawing.SpatialView.Id\r\n`;\r\n\r\n/** Raw data representing a [[SectionDrawingLocationState]]. This is an amalgamation of data from several related ECClasses.\r\n * @internal\r\n */\r\nexport interface SectionDrawingLocationStateData {\r\n sectionType: SectionType;\r\n drawingToSpatialTransform: string; // stringified TransformProps\r\n spatialViewId: Id64String;\r\n clipJSON?: string; // stringified ClipVector json\r\n viewAttachmentId?: Id64String;\r\n sheetToSpatialTransform?: string; // stringified TransformProps\r\n sheetClip?: string; // stringified ClipVector json\r\n sheetViewId?: Id64String;\r\n\r\n sectionLocationId: Id64String;\r\n sectionLocationModelId: Id64String;\r\n sectionViewId: Id64String;\r\n categoryId: Id64String;\r\n origin?: XYZProps;\r\n yaw?: number;\r\n pitch?: number;\r\n roll?: number;\r\n bboxLow?: XYZProps;\r\n bboxHigh?: XYZProps;\r\n userLabel: string;\r\n}\r\n\r\n/** Represents a [ViewAttachment]($backend) that attaches a [[SectionDrawingLocationState]] to a [Sheet]($backend) model.\r\n * @public\r\n */\r\nexport interface SectionViewAttachment {\r\n /** The view attachment's element Id. */\r\n readonly id: Id64String;\r\n /** The Id of a [SheetViewDefinition]($backend) that displays this view attachment.\r\n * This is used when navigating from the spatial view to the view attachment.\r\n */\r\n readonly viewId?: Id64String;\r\n /** The transform from the [Sheet]($backend) coordinate space to the spatial coordinate space. */\r\n readonly transformToSpatial: Transform;\r\n /** Optional 2d clip vector used to clip out portions of the [Sheet]($backend) containing annotations not relevant to this section drawing. */\r\n readonly clip?: ClipVector;\r\n}\r\n\r\n/** Represents a [SectionDrawingLocation]($backend), including data from related elements like [SectionDrawing]($backend) used in a hyper-modeling context.\r\n * @see [[SectionMarker]] for a widget that allows the user to interact with a section drawing location.\r\n * @public\r\n */\r\nexport class SectionDrawingLocationState {\r\n /** The iModel in which this section drawing location resides. */\r\n public readonly iModel: IModelConnection;\r\n /** The element Id of the section drawing location. */\r\n public readonly id: Id64String;\r\n /** The Id of the [GeometricModel3d]($backend) in which this section drawing location resides. */\r\n public readonly model: Id64String;\r\n /** A user-friendly label for the section drawing location. */\r\n public readonly userLabel: string;\r\n /** The Id of the [SpatialCategory]($backend) to which this section drawing location belongs. */\r\n public readonly category: Id64String;\r\n /** The section drawing location's spatial placement. */\r\n public readonly placement: Placement3d;\r\n /** The type of section that generated the associated [SectionDrawing]($backend). */\r\n public readonly sectionType: SectionType;\r\n /** The Id of the [ViewDefinition]($backend) that can display the section graphics. */\r\n public readonly drawingViewId: Id64String;\r\n /** The Id of the [SpatialViewDefinition]($backend) from which the section drawing was generated. */\r\n public readonly spatialViewId: Id64String;\r\n /** The section clip from the [SpatialViewDefinition]($backend) from which the section drawing was generated. */\r\n public readonly clip: ClipVector;\r\n /** The transform from the [GeometricModel]($backend) containing the section graphics to the spatial coordinate space.\r\n * This is used to position the 2d graphics in the context of a spatial view.\r\n */\r\n public readonly drawingToSpatialTransform: Transform;\r\n /** If the section drawing is attached to a [Sheet]($backend), details about the corresponding [ViewAttachment]($backend).\r\n * When this section drawing location is displayed in a spatial context, annotations in the sheet model can be displayed along with the section graphics.\r\n */\r\n public readonly viewAttachment?: SectionViewAttachment;\r\n\r\n /** @internal */\r\n public constructor(props: SectionDrawingLocationStateData, iModel: IModelConnection) {\r\n this.iModel = iModel;\r\n this.id = props.sectionLocationId;\r\n this.model = props.sectionLocationModelId;\r\n this.userLabel = props.userLabel;\r\n this.category = props.categoryId;\r\n this.sectionType = props.sectionType;\r\n this.drawingViewId = props.sectionViewId;\r\n this.spatialViewId = props.spatialViewId;\r\n this.drawingToSpatialTransform = Transform.fromJSON(JSON.parse(props.drawingToSpatialTransform));\r\n\r\n const extractClip = (str: string | undefined) => {\r\n let clip;\r\n if (str) {\r\n try {\r\n clip = ClipVector.fromJSON(JSON.parse(str));\r\n } catch { }\r\n }\r\n\r\n return clip;\r\n };\r\n\r\n this.clip = extractClip(props.clipJSON) ?? ClipVector.createEmpty();\r\n\r\n const placementProps = {\r\n origin: props.origin ?? {},\r\n angles: {\r\n yaw: props.yaw,\r\n pitch: props.pitch,\r\n roll: props.roll,\r\n },\r\n placement: (props.bboxLow && props.bboxHigh) ? { low: props.bboxLow, high: props.bboxHigh } : undefined,\r\n };\r\n this.placement = Placement3d.fromJSON(placementProps);\r\n\r\n if (props.viewAttachmentId && props.sheetToSpatialTransform) {\r\n this.viewAttachment = {\r\n id: props.viewAttachmentId,\r\n transformToSpatial: Transform.fromJSON(JSON.parse(props.sheetToSpatialTransform)),\r\n clip: extractClip(props.sheetClip),\r\n viewId: props.sheetViewId,\r\n };\r\n }\r\n }\r\n\r\n /** Return a promise that resolves to the [DrawingViewState]($frontend) corresponding to `this.drawingViewId`, or undefined if an exception occurs. */\r\n public async tryLoadDrawingView(): Promise<DrawingViewState | undefined> {\r\n try {\r\n const view = await this.iModel.views.load(this.drawingViewId);\r\n if (view instanceof DrawingViewState)\r\n return view;\r\n } catch { }\r\n\r\n return undefined;\r\n }\r\n\r\n /** Return a promise that resolves to the [SpatialViewState]($frontend) corresponding to `this.spatialViewId`, or undefined if an exception occurs. */\r\n public async tryLoadSpatialView(): Promise<SpatialViewState | undefined> {\r\n try {\r\n const view = await this.iModel.views.load(this.spatialViewId);\r\n if (view instanceof SpatialViewState)\r\n return view;\r\n } catch { }\r\n\r\n return undefined;\r\n }\r\n\r\n /** Return a promise that resolves to the [SheetViewState]($frontend) corresponding to `this.viewAttachment.viewId`; or undefined if there is no corresponding [ViewAttachment]($backend) or an exception occurs. */\r\n public async tryLoadSheetView(): Promise<SheetViewState | undefined> {\r\n if (undefined === this.viewAttachment || undefined === this.viewAttachment.viewId)\r\n return undefined;\r\n\r\n try {\r\n const view = await this.iModel.views.load(this.viewAttachment.viewId);\r\n if (view instanceof SheetViewState)\r\n return view;\r\n } catch { }\r\n\r\n return undefined;\r\n }\r\n\r\n /** Query the specified iModel for [SectionDrawingLocation]($backend)s and return a list of corresponding [[SectionDrawingLocationState]]s. */\r\n public static async queryAll(iModel: IModelConnection): Promise<SectionDrawingLocationState[]> {\r\n const states: SectionDrawingLocationState[] = [];\r\n try {\r\n for await (const row of iModel.createQueryReader(selectSectionDrawingLocationStatesECSql, undefined, { rowFormat: QueryRowFormat.UseJsPropertyNames }))\r\n states.push(new SectionDrawingLocationState(row.toRow() as SectionDrawingLocationStateData, iModel));\r\n } catch {\r\n // If the iModel contains a version of BisCore schema older than 1.12.0, the query will produce an exception due to missing SectionDrawingLocation class. That's fine.\r\n }\r\n\r\n return states;\r\n }\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SectionGraphicsProvider.js","sourceRoot":"","sources":["../../src/SectionGraphicsProvider.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAoF;AACpF,wDAA0F;AAC1F,oDAA0H;AAC1H,wDAI8B;AAE9B,mDAAgD;AAgBhD,MAAM,iBAAiB;IACd,kBAAkB,CAAC,GAAgB,EAAE,GAAgB;QAC1D,IAAI,GAAG,GAAG,IAAA,8BAAe,EAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;QACpD,IAAI,CAAC,KAAK,GAAG;YACX,GAAG,GAAG,IAAA,6BAAc,EAAC,GAAG,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAEnD,OAAO,GAAG,CAAC;IACb,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,EAAe,EAAE,MAAwB;QACnE,IAAI,IAAI,CAAC;QACT,IAAI,EAAE,CAAC,OAAO,EAAE;YACd,IAAA,qBAAM,EAAC,SAAS,KAAK,EAAE,CAAC,UAAU,CAAC,CAAC;YACpC,IAAI,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC;SACjE;aAAM;YACL,IAAI,GAAG,MAAM,EAAE,CAAC,KAAK,CAAC,kBAAkB,EAAE,CAAC;SAC5C;QAED,IAAI,SAAS,KAAK,IAAI;YACpB,OAAO,SAAS,CAAC;QAEnB,IAAI;YACF,MAAM,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YAC3C,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YACxD,IAAI,SAA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------------------\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 { assert, compareBooleans, compareStrings, Id64 } from \"@itwin/core-bentley\";\r\nimport { ClipShape, ClipVector, Point3d, Range3d, Transform } from \"@itwin/core-geometry\";\r\nimport { ColorDef, Placement2d, ViewAttachmentProps, ViewDefinition2dProps, ViewFlagOverrides } from \"@itwin/core-common\";\r\nimport {\r\n CategorySelectorState, DisclosedTileTreeSet, DisplayStyle2dState, DrawingViewState,\r\n FeatureSymbology, GeometricModel2dState, GraphicBranch, HitDetail, IModelApp, IModelConnection, RenderClipVolume, RenderSystem, SheetModelState, Tile, TileContent, TiledGraphicsProvider, TileDrawArgs,\r\n TileLoadPriority, TileRequest, TileRequestChannel, TileTree, TileTreeOwner, TileTreeReference, TileTreeSupplier, Viewport, ViewState2d,\r\n} from \"@itwin/core-frontend\";\r\nimport { SectionDrawingLocationState } from \"./SectionDrawingLocationState\";\r\nimport { HyperModeling } from \"./HyperModeling\";\r\n\r\ninterface ProxyTreeId {\r\n state: SectionDrawingLocationState;\r\n isSheet: boolean;\r\n attachment?: ViewAttachmentProps;\r\n}\r\n\r\ninterface ProxyTreeParams {\r\n tree: TileTree;\r\n ref: TileTreeReference;\r\n view: ViewState2d;\r\n state: SectionDrawingLocationState;\r\n attachment?: ViewAttachmentProps;\r\n}\r\n\r\nclass ProxyTreeSupplier implements TileTreeSupplier {\r\n public compareTileTreeIds(lhs: ProxyTreeId, rhs: ProxyTreeId): number {\r\n let cmp = compareBooleans(lhs.isSheet, rhs.isSheet);\r\n if (0 === cmp)\r\n cmp = compareStrings(lhs.state.id, rhs.state.id);\r\n\r\n return cmp;\r\n }\r\n\r\n public async createTileTree(id: ProxyTreeId, iModel: IModelConnection): Promise<TileTree | undefined> {\r\n let view;\r\n if (id.isSheet) {\r\n assert(undefined !== id.attachment);\r\n view = await this.createSheetViewState(id.state, id.attachment);\r\n } else {\r\n view = await id.state.tryLoadDrawingView();\r\n }\r\n\r\n if (undefined === view)\r\n return undefined;\r\n\r\n try {\r\n await iModel.models.load(view.baseModelId);\r\n const model = iModel.models.getLoaded(view.baseModelId);\r\n if (undefined === model || !(model instanceof GeometricModel2dState))\r\n return undefined;\r\n\r\n const treeRef = model.createTileTreeReference(view);\r\n const tree = await treeRef.treeOwner.loadTree();\r\n if (undefined === tree)\r\n return undefined;\r\n\r\n const ctor = id.isSheet ? SheetProxyTree : DrawingProxyTree;\r\n return new ctor({ tree, ref: treeRef, view, state: id.state, attachment: id.attachment });\r\n } catch {\r\n return undefined;\r\n }\r\n }\r\n\r\n private async createSheetViewState(state: SectionDrawingLocationState, attachment: ViewAttachmentProps): Promise<DrawingViewState | undefined> {\r\n assert(undefined !== state.viewAttachment);\r\n try {\r\n // A persistent view of the sheet doesn't necessarily exist, and we don't want a SheetViewState anyway.\r\n // All we want is to draw all the elements in the sheet (sans view attachments) clipped by the drawing boundary.\r\n // However, ModelState.createTileTreeReference() requires a ViewState.\r\n await state.iModel.models.load(attachment.model);\r\n const sheet = state.iModel.models.getLoaded(attachment.model);\r\n if (undefined === sheet || !(sheet instanceof SheetModelState))\r\n return undefined;\r\n\r\n const sheetExtents = await sheet.queryModelRange();\r\n const viewProps: ViewDefinition2dProps = {\r\n baseModelId: attachment.model,\r\n origin: { x: 0, y: 0 },\r\n delta: { x: sheetExtents.high.x, y: sheetExtents.high.y },\r\n angle: 0,\r\n categorySelectorId: Id64.invalid,\r\n displayStyleId: Id64.invalid,\r\n model: Id64.invalid,\r\n code: {\r\n spec: Id64.invalid,\r\n scope: Id64.invalid,\r\n },\r\n classFullName: DrawingViewState.classFullName,\r\n };\r\n\r\n const displayStyle = new DisplayStyle2dState({} as any, state.iModel);\r\n const categorySelector = new CategorySelectorState({} as any, state.iModel);\r\n\r\n return new DrawingViewState(viewProps, state.iModel, categorySelector, displayStyle, sheetExtents);\r\n } catch {\r\n return undefined;\r\n }\r\n }\r\n}\r\n\r\nconst proxyTreeSupplier = new ProxyTreeSupplier();\r\n\r\n/** A proxy for a 2d tile tree to be drawn in the context of a spatial view. */\r\nclass ProxyTreeReference extends TileTreeReference {\r\n private readonly _owner: TileTreeOwner;\r\n\r\n public constructor(id: ProxyTreeId) {\r\n super();\r\n this._owner = id.state.iModel.tiles.getTileTreeOwner(id, proxyTreeSupplier);\r\n }\r\n\r\n public override get castsShadows() {\r\n return false;\r\n }\r\n\r\n public override getClipVolume(tree: TileTree) {\r\n return true !== HyperModeling.graphicsConfig.ignoreClip ? super.getClipVolume(tree) : undefined;\r\n }\r\n\r\n public get treeOwner() { return this._owner; }\r\n\r\n private get _proxiedRef(): TileTreeReference | undefined {\r\n const proxiedTree = this.treeOwner.tileTree as ProxyTree;\r\n return undefined !== proxiedTree ? proxiedTree.ref : undefined;\r\n }\r\n\r\n public override discloseTileTrees(trees: DisclosedTileTreeSet): void {\r\n super.discloseTileTrees(trees);\r\n const ref = this._proxiedRef;\r\n if (undefined !== ref)\r\n ref.discloseTileTrees(trees);\r\n }\r\n\r\n public override async getToolTip(hit: HitDetail) {\r\n const ref = this._proxiedRef;\r\n return undefined !== ref ? ref.getToolTip(hit) : super.getToolTip(hit);\r\n }\r\n}\r\n\r\n/** A proxy for a 2d tile tree to be drawn in the context of a spatial view. */\r\nabstract class ProxyTree extends TileTree {\r\n private readonly _rootTile: ProxyTile;\r\n private readonly _viewFlagOverrides: ViewFlagOverrides;\r\n public readonly tree: TileTree;\r\n public readonly ref: TileTreeReference;\r\n public readonly symbologyOverrides: FeatureSymbology.Overrides;\r\n\r\n protected constructor(params: ProxyTreeParams, location: Transform, clipVolume: RenderClipVolume | undefined) {\r\n const { tree, ref, view } = { ...params };\r\n super({\r\n id: params.state.id,\r\n modelId: tree.modelId,\r\n iModel: tree.iModel,\r\n location,\r\n priority: TileLoadPriority.Primary,\r\n clipVolume,\r\n });\r\n\r\n this.tree = tree;\r\n this.ref = ref;\r\n this.symbologyOverrides = new FeatureSymbology.Overrides(view);\r\n\r\n const range = tree.iModelTransform.multiplyRange(tree.rootTile.range);\r\n const inverse = location.inverse();\r\n if (undefined !== inverse)\r\n inverse.multiplyRange(range, range);\r\n\r\n this._viewFlagOverrides = {\r\n ...view.viewFlags,\r\n lighting: false,\r\n // View clip (section clip) should not apply to 2d graphics.\r\n clipVolume: false,\r\n };\r\n\r\n this._rootTile = new ProxyTile(this, range);\r\n }\r\n\r\n public get rootTile(): ProxyTile { return this._rootTile; }\r\n public get viewFlagOverrides() { return this._viewFlagOverrides; }\r\n public get is3d() { return false; }\r\n public override get isContentUnbounded() { return false; }\r\n public get maxDepth() { return 1; }\r\n\r\n protected abstract get isDisplayed(): boolean;\r\n\r\n public draw(args: TileDrawArgs): void {\r\n if (!this.isDisplayed)\r\n return;\r\n\r\n const tiles = this.selectTiles(args);\r\n for (const tile of tiles)\r\n tile.drawGraphics(args);\r\n\r\n args.drawGraphics();\r\n }\r\n\r\n protected _selectTiles(_args: TileDrawArgs): Tile[] {\r\n return this.isDisplayed ? [this.rootTile] : [];\r\n }\r\n\r\n public prune(): void {\r\n // Our single tile is only a proxy. Our proxied tree(s) will be pruned separately\r\n }\r\n}\r\n\r\nclass DrawingProxyTree extends ProxyTree {\r\n public constructor(params: ProxyTreeParams) {\r\n const { state, attachment } = { ...params };\r\n const location = state.drawingToSpatialTransform.clone();\r\n\r\n let clipVolume;\r\n if (attachment) {\r\n assert(undefined !== state.viewAttachment);\r\n const clipJSON = attachment.jsonProperties?.clip;\r\n const clip = clipJSON ? ClipVector.fromJSON(clipJSON) : ClipVector.createEmpty();\r\n if (!clipJSON) {\r\n const placement = Placement2d.fromJSON(attachment.placement);\r\n const range = placement.calculateRange();\r\n clip.appendShape([\r\n Point3d.create(range.low.x, range.low.y),\r\n Point3d.create(range.high.x, range.low.y),\r\n Point3d.create(range.high.x, range.high.y),\r\n Point3d.create(range.low.x, range.high.y),\r\n ]);\r\n }\r\n\r\n if (clip.isValid) {\r\n const sheetToWorld = state.viewAttachment.transformToSpatial.clone();\r\n clip.transformInPlace(sheetToWorld);\r\n clipVolume = IModelApp.renderSystem.createClipVolume(clip);\r\n }\r\n }\r\n\r\n super(params, location, clipVolume);\r\n }\r\n\r\n protected get isDisplayed() { return true !== HyperModeling.graphicsConfig.hideSectionGraphics; }\r\n}\r\n\r\nclass SheetProxyTree extends ProxyTree {\r\n public constructor(params: ProxyTreeParams) {\r\n const { state, attachment } = { ...params };\r\n assert(undefined !== state.viewAttachment);\r\n assert(undefined !== attachment);\r\n const location = state.viewAttachment.transformToSpatial.clone();\r\n\r\n let clipVolume;\r\n if (state.viewAttachment.clip)\r\n clipVolume = IModelApp.renderSystem.createClipVolume(state.viewAttachment.clip);\r\n\r\n super(params, location, clipVolume);\r\n\r\n // Our view is manufactured. It draws everything regardless of subcategory.\r\n this.symbologyOverrides.ignoreSubCategory = true;\r\n }\r\n\r\n protected get isDisplayed() { return true !== HyperModeling.graphicsConfig.hideSheetAnnotations; }\r\n}\r\n\r\n/** The single Tile belonging to a ProxyTree, serving as a proxy for all of the proxied tree's tiles. */\r\nclass ProxyTile extends Tile {\r\n public constructor(tree: ProxyTree, range: Range3d) {\r\n super({ contentId: \"\", range, maximumSize: 512, isLeaf: true }, tree);\r\n this.setIsReady();\r\n }\r\n\r\n public get hasChildren() { return false; }\r\n public override get hasGraphics() { return true; }\r\n\r\n public get channel(): TileRequestChannel { throw new Error(\"Proxy tile has no content\"); }\r\n public async requestContent(_isCanceled: () => boolean): Promise<TileRequest.Response> { return undefined; }\r\n public async readContent(_data: TileRequest.ResponseData, _system: RenderSystem, _isCanceled?: () => boolean): Promise<TileContent> { return {}; }\r\n protected _loadChildren(_resolve: (children: Tile[]) => void, _reject: (error: Error) => void): void { }\r\n\r\n public override drawGraphics(args: TileDrawArgs) {\r\n const proxyTree = this.tree as ProxyTree;\r\n const sectionTree = proxyTree.tree;\r\n\r\n const location = proxyTree.iModelTransform.multiplyTransformTransform(sectionTree.iModelTransform);\r\n const clipVolume = true === proxyTree.viewFlagOverrides.clipVolume ? proxyTree.clipVolume : undefined;\r\n args = new TileDrawArgs({ context: args.context, location, tree: sectionTree, now: args.now, viewFlagOverrides: proxyTree.viewFlagOverrides, clipVolume, parentsAndChildrenExclusive: args.parentsAndChildrenExclusive, symbologyOverrides: proxyTree.symbologyOverrides });\r\n sectionTree.draw(args);\r\n\r\n const rangeGfx = this.getRangeGraphic(args.context);\r\n if (undefined !== rangeGfx)\r\n args.graphics.add(rangeGfx);\r\n\r\n if (true !== HyperModeling.graphicsConfig.debugClipVolumes || undefined === proxyTree.clipVolume)\r\n return;\r\n\r\n const builder = args.context.createSceneGraphicBuilder();\r\n builder.setSymbology(ColorDef.red, ColorDef.red, 2);\r\n for (const prim of proxyTree.clipVolume.clipVector.clips) {\r\n if (!(prim instanceof ClipShape))\r\n continue;\r\n\r\n const tf = prim.transformFromClip;\r\n const pts = prim.polygon.map((pt) => tf ? tf.multiplyPoint3d(pt) : pt.clone());\r\n builder.addLineString(pts);\r\n }\r\n\r\n const branch = new GraphicBranch();\r\n branch.entries.push(builder.finish());\r\n branch.setViewFlagOverrides({ clipVolume: false });\r\n args.context.outputGraphic(args.context.createGraphicBranch(branch, Transform.createIdentity()));\r\n }\r\n}\r\n\r\n/** Draws the 2d section graphics into the 3d view. */\r\nclass SectionGraphicsProvider implements TiledGraphicsProvider {\r\n private readonly _drawingRef: TileTreeReference;\r\n private readonly _sheetRef?: TileTreeReference;\r\n\r\n public constructor(state: SectionDrawingLocationState, attachment: ViewAttachmentProps | undefined) {\r\n this._drawingRef = new ProxyTreeReference({ state, attachment, isSheet: false });\r\n if (attachment)\r\n this._sheetRef = new ProxyTreeReference({ state, attachment, isSheet: true });\r\n }\r\n\r\n public forEachTileTreeRef(_viewport: Viewport, func: (ref: TileTreeReference) => void): void {\r\n func(this._drawingRef);\r\n if (undefined !== this._sheetRef)\r\n func(this._sheetRef);\r\n }\r\n}\r\n\r\n/** Creates a TiledGraphicsProvider that can be associated with a [Viewport]($frontend) to display 2d section graphics and annotations in the context of a [SpatialViewState]($frontend).\r\n * Typically used indirectly via [[HyperModelingDecorator]].\r\n * @param state The section drawing location specifying which section drawing to display.\r\n * @returns A provider suitable for passing to [Viewport.addTiledGraphicsProvider]($frontend).\r\n * @see [[HyperModelingDecorator.toggleAttachment]] to activate section graphics for a given [[SectionMarker]].\r\n * @public\r\n */\r\nexport async function createSectionGraphicsProvider(state: SectionDrawingLocationState): Promise<TiledGraphicsProvider> {\r\n let attachment;\r\n if (undefined !== state.viewAttachment) {\r\n const attachments = await state.iModel.elements.getProps(state.viewAttachment.id) as ViewAttachmentProps[];\r\n if (1 === attachments.length)\r\n attachment = attachments[0];\r\n }\r\n\r\n return new SectionGraphicsProvider(state, attachment);\r\n}\r\n"]}
1
+ {"version":3,"file":"SectionGraphicsProvider.js","sourceRoot":"","sources":["../../src/SectionGraphicsProvider.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAoF;AACpF,wDAA0F;AAC1F,oDAA0H;AAC1H,wDAI8B;AAE9B,mDAAgD;AAgBhD,MAAM,iBAAiB;IACd,kBAAkB,CAAC,GAAgB,EAAE,GAAgB;QAC1D,IAAI,GAAG,GAAG,IAAA,8BAAe,EAAC,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,CAAC,CAAC;QACpD,IAAI,CAAC,KAAK,GAAG;YACX,GAAG,GAAG,IAAA,6BAAc,EAAC,GAAG,CAAC,KAAK,CAAC,EAAE,EAAE,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QAEnD,OAAO,GAAG,CAAC;IACb,CAAC;IAEM,KAAK,CAAC,cAAc,CAAC,EAAe,EAAE,MAAwB;QACnE,IAAI,IAAI,CAAC;QACT,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;YACf,IAAA,qBAAM,EAAC,SAAS,KAAK,EAAE,CAAC,UAAU,CAAC,C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,SAAS,KAAK,IAAI,CAAC,SAAS;YAC9B,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IACzB,CAAC;CACF;AAED;;;;;;GAMG;AACI,KAAK,UAAU,6BAA6B,CAAC,KAAkC;IACpF,IAAI,UAAU,CAAC;IACf,IAAI,SAAS,KAAK,KAAK,CAAC,cAAc,EAAE,CAAC;QACvC,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,cAAc,CAAC,EAAE,CAA0B,CAAC;QAC3G,IAAI,CAAC,KAAK,WAAW,CAAC,MAAM;YAC1B,UAAU,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;IAChC,CAAC;IAED,OAAO,IAAI,uBAAuB,CAAC,KAAK,EAAE,UAAU,CAAC,CAAC;AACxD,CAAC;AATD,sEASC","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 { assert, compareBooleans, compareStrings, Id64 } from \"@itwin/core-bentley\";\r\nimport { ClipShape, ClipVector, Point3d, Range3d, Transform } from \"@itwin/core-geometry\";\r\nimport { ColorDef, Placement2d, ViewAttachmentProps, ViewDefinition2dProps, ViewFlagOverrides } from \"@itwin/core-common\";\r\nimport {\r\n CategorySelectorState, DisclosedTileTreeSet, DisplayStyle2dState, DrawingViewState,\r\n FeatureSymbology, GeometricModel2dState, GraphicBranch, HitDetail, IModelApp, IModelConnection, RenderClipVolume, RenderSystem, SheetModelState, Tile, TileContent, TiledGraphicsProvider, TileDrawArgs,\r\n TileLoadPriority, TileRequest, TileRequestChannel, TileTree, TileTreeOwner, TileTreeReference, TileTreeSupplier, Viewport, ViewState2d,\r\n} from \"@itwin/core-frontend\";\r\nimport { SectionDrawingLocationState } from \"./SectionDrawingLocationState\";\r\nimport { HyperModeling } from \"./HyperModeling\";\r\n\r\ninterface ProxyTreeId {\r\n state: SectionDrawingLocationState;\r\n isSheet: boolean;\r\n attachment?: ViewAttachmentProps;\r\n}\r\n\r\ninterface ProxyTreeParams {\r\n tree: TileTree;\r\n ref: TileTreeReference;\r\n view: ViewState2d;\r\n state: SectionDrawingLocationState;\r\n attachment?: ViewAttachmentProps;\r\n}\r\n\r\nclass ProxyTreeSupplier implements TileTreeSupplier {\r\n public compareTileTreeIds(lhs: ProxyTreeId, rhs: ProxyTreeId): number {\r\n let cmp = compareBooleans(lhs.isSheet, rhs.isSheet);\r\n if (0 === cmp)\r\n cmp = compareStrings(lhs.state.id, rhs.state.id);\r\n\r\n return cmp;\r\n }\r\n\r\n public async createTileTree(id: ProxyTreeId, iModel: IModelConnection): Promise<TileTree | undefined> {\r\n let view;\r\n if (id.isSheet) {\r\n assert(undefined !== id.attachment);\r\n view = await this.createSheetViewState(id.state, id.attachment);\r\n } else {\r\n view = await id.state.tryLoadDrawingView();\r\n }\r\n\r\n if (undefined === view)\r\n return undefined;\r\n\r\n try {\r\n await iModel.models.load(view.baseModelId);\r\n const model = iModel.models.getLoaded(view.baseModelId);\r\n if (undefined === model || !(model instanceof GeometricModel2dState))\r\n return undefined;\r\n\r\n const treeRef = model.createTileTreeReference(view);\r\n const tree = await treeRef.treeOwner.loadTree();\r\n if (undefined === tree)\r\n return undefined;\r\n\r\n const ctor = id.isSheet ? SheetProxyTree : DrawingProxyTree;\r\n return new ctor({ tree, ref: treeRef, view, state: id.state, attachment: id.attachment });\r\n } catch {\r\n return undefined;\r\n }\r\n }\r\n\r\n private async createSheetViewState(state: SectionDrawingLocationState, attachment: ViewAttachmentProps): Promise<DrawingViewState | undefined> {\r\n assert(undefined !== state.viewAttachment);\r\n try {\r\n // A persistent view of the sheet doesn't necessarily exist, and we don't want a SheetViewState anyway.\r\n // All we want is to draw all the elements in the sheet (sans view attachments) clipped by the drawing boundary.\r\n // However, ModelState.createTileTreeReference() requires a ViewState.\r\n await state.iModel.models.load(attachment.model);\r\n const sheet = state.iModel.models.getLoaded(attachment.model);\r\n if (undefined === sheet || !(sheet instanceof SheetModelState))\r\n return undefined;\r\n\r\n const sheetExtents = await sheet.queryModelRange();\r\n const viewProps: ViewDefinition2dProps = {\r\n baseModelId: attachment.model,\r\n origin: { x: 0, y: 0 },\r\n delta: { x: sheetExtents.high.x, y: sheetExtents.high.y },\r\n angle: 0,\r\n categorySelectorId: Id64.invalid,\r\n displayStyleId: Id64.invalid,\r\n model: Id64.invalid,\r\n code: {\r\n spec: Id64.invalid,\r\n scope: Id64.invalid,\r\n },\r\n classFullName: DrawingViewState.classFullName,\r\n };\r\n\r\n const displayStyle = new DisplayStyle2dState({} as any, state.iModel);\r\n const categorySelector = new CategorySelectorState({} as any, state.iModel);\r\n\r\n return new DrawingViewState(viewProps, state.iModel, categorySelector, displayStyle, sheetExtents);\r\n } catch {\r\n return undefined;\r\n }\r\n }\r\n}\r\n\r\nconst proxyTreeSupplier = new ProxyTreeSupplier();\r\n\r\n/** A proxy for a 2d tile tree to be drawn in the context of a spatial view. */\r\nclass ProxyTreeReference extends TileTreeReference {\r\n private readonly _owner: TileTreeOwner;\r\n\r\n public constructor(id: ProxyTreeId) {\r\n super();\r\n this._owner = id.state.iModel.tiles.getTileTreeOwner(id, proxyTreeSupplier);\r\n }\r\n\r\n public override get castsShadows() {\r\n return false;\r\n }\r\n\r\n public override getClipVolume(tree: TileTree) {\r\n return true !== HyperModeling.graphicsConfig.ignoreClip ? super.getClipVolume(tree) : undefined;\r\n }\r\n\r\n public get treeOwner() { return this._owner; }\r\n\r\n private get _proxiedRef(): TileTreeReference | undefined {\r\n const proxiedTree = this.treeOwner.tileTree as ProxyTree;\r\n return undefined !== proxiedTree ? proxiedTree.ref : undefined;\r\n }\r\n\r\n public override discloseTileTrees(trees: DisclosedTileTreeSet): void {\r\n super.discloseTileTrees(trees);\r\n const ref = this._proxiedRef;\r\n if (undefined !== ref)\r\n ref.discloseTileTrees(trees);\r\n }\r\n\r\n public override async getToolTip(hit: HitDetail) {\r\n const ref = this._proxiedRef;\r\n return undefined !== ref ? ref.getToolTip(hit) : super.getToolTip(hit);\r\n }\r\n}\r\n\r\n/** A proxy for a 2d tile tree to be drawn in the context of a spatial view. */\r\nabstract class ProxyTree extends TileTree {\r\n private readonly _rootTile: ProxyTile;\r\n private readonly _viewFlagOverrides: ViewFlagOverrides;\r\n public readonly tree: TileTree;\r\n public readonly ref: TileTreeReference;\r\n public readonly symbologyOverrides: FeatureSymbology.Overrides;\r\n\r\n protected constructor(params: ProxyTreeParams, location: Transform, clipVolume: RenderClipVolume | undefined) {\r\n const { tree, ref, view } = { ...params };\r\n super({\r\n id: params.state.id,\r\n modelId: tree.modelId,\r\n iModel: tree.iModel,\r\n location,\r\n priority: TileLoadPriority.Primary,\r\n clipVolume,\r\n });\r\n\r\n this.tree = tree;\r\n this.ref = ref;\r\n this.symbologyOverrides = new FeatureSymbology.Overrides(view);\r\n\r\n const range = tree.iModelTransform.multiplyRange(tree.rootTile.range);\r\n const inverse = location.inverse();\r\n if (undefined !== inverse)\r\n inverse.multiplyRange(range, range);\r\n\r\n this._viewFlagOverrides = {\r\n ...view.viewFlags,\r\n lighting: false,\r\n // View clip (section clip) should not apply to 2d graphics.\r\n clipVolume: false,\r\n };\r\n\r\n this._rootTile = new ProxyTile(this, range);\r\n }\r\n\r\n public get rootTile(): ProxyTile { return this._rootTile; }\r\n public get viewFlagOverrides() { return this._viewFlagOverrides; }\r\n public get is3d() { return false; }\r\n public override get isContentUnbounded() { return false; }\r\n public get maxDepth() { return 1; }\r\n\r\n protected abstract get isDisplayed(): boolean;\r\n\r\n public draw(args: TileDrawArgs): void {\r\n if (!this.isDisplayed)\r\n return;\r\n\r\n const tiles = this.selectTiles(args);\r\n for (const tile of tiles)\r\n tile.drawGraphics(args);\r\n\r\n args.drawGraphics();\r\n }\r\n\r\n protected _selectTiles(_args: TileDrawArgs): Tile[] {\r\n return this.isDisplayed ? [this.rootTile] : [];\r\n }\r\n\r\n public prune(): void {\r\n // Our single tile is only a proxy. Our proxied tree(s) will be pruned separately\r\n }\r\n}\r\n\r\nclass DrawingProxyTree extends ProxyTree {\r\n public constructor(params: ProxyTreeParams) {\r\n const { state, attachment } = { ...params };\r\n const location = state.drawingToSpatialTransform.clone();\r\n\r\n let clipVolume;\r\n if (attachment) {\r\n assert(undefined !== state.viewAttachment);\r\n const clipJSON = attachment.jsonProperties?.clip;\r\n const clip = clipJSON ? ClipVector.fromJSON(clipJSON) : ClipVector.createEmpty();\r\n if (!clipJSON) {\r\n const placement = Placement2d.fromJSON(attachment.placement);\r\n const range = placement.calculateRange();\r\n clip.appendShape([\r\n Point3d.create(range.low.x, range.low.y),\r\n Point3d.create(range.high.x, range.low.y),\r\n Point3d.create(range.high.x, range.high.y),\r\n Point3d.create(range.low.x, range.high.y),\r\n ]);\r\n }\r\n\r\n if (clip.isValid) {\r\n const sheetToWorld = state.viewAttachment.transformToSpatial.clone();\r\n clip.transformInPlace(sheetToWorld);\r\n clipVolume = IModelApp.renderSystem.createClipVolume(clip);\r\n }\r\n }\r\n\r\n super(params, location, clipVolume);\r\n }\r\n\r\n protected get isDisplayed() { return true !== HyperModeling.graphicsConfig.hideSectionGraphics; }\r\n}\r\n\r\nclass SheetProxyTree extends ProxyTree {\r\n public constructor(params: ProxyTreeParams) {\r\n const { state, attachment } = { ...params };\r\n assert(undefined !== state.viewAttachment);\r\n assert(undefined !== attachment);\r\n const location = state.viewAttachment.transformToSpatial.clone();\r\n\r\n let clipVolume;\r\n if (state.viewAttachment.clip)\r\n clipVolume = IModelApp.renderSystem.createClipVolume(state.viewAttachment.clip);\r\n\r\n super(params, location, clipVolume);\r\n\r\n // Our view is manufactured. It draws everything regardless of subcategory.\r\n this.symbologyOverrides.ignoreSubCategory = true;\r\n }\r\n\r\n protected get isDisplayed() { return true !== HyperModeling.graphicsConfig.hideSheetAnnotations; }\r\n}\r\n\r\n/** The single Tile belonging to a ProxyTree, serving as a proxy for all of the proxied tree's tiles. */\r\nclass ProxyTile extends Tile {\r\n public constructor(tree: ProxyTree, range: Range3d) {\r\n super({ contentId: \"\", range, maximumSize: 512, isLeaf: true }, tree);\r\n this.setIsReady();\r\n }\r\n\r\n public get hasChildren() { return false; }\r\n public override get hasGraphics() { return true; }\r\n\r\n public get channel(): TileRequestChannel { throw new Error(\"Proxy tile has no content\"); }\r\n public async requestContent(_isCanceled: () => boolean): Promise<TileRequest.Response> { return undefined; }\r\n public async readContent(_data: TileRequest.ResponseData, _system: RenderSystem, _isCanceled?: () => boolean): Promise<TileContent> { return {}; }\r\n protected _loadChildren(_resolve: (children: Tile[]) => void, _reject: (error: Error) => void): void { }\r\n\r\n public override drawGraphics(args: TileDrawArgs) {\r\n const proxyTree = this.tree as ProxyTree;\r\n const sectionTree = proxyTree.tree;\r\n\r\n const location = proxyTree.iModelTransform.multiplyTransformTransform(sectionTree.iModelTransform);\r\n const clipVolume = true === proxyTree.viewFlagOverrides.clipVolume ? proxyTree.clipVolume : undefined;\r\n args = new TileDrawArgs({ context: args.context, location, tree: sectionTree, now: args.now, viewFlagOverrides: proxyTree.viewFlagOverrides, clipVolume, parentsAndChildrenExclusive: args.parentsAndChildrenExclusive, symbologyOverrides: proxyTree.symbologyOverrides });\r\n sectionTree.draw(args);\r\n\r\n const rangeGfx = this.getRangeGraphic(args.context);\r\n if (undefined !== rangeGfx)\r\n args.graphics.add(rangeGfx);\r\n\r\n if (true !== HyperModeling.graphicsConfig.debugClipVolumes || undefined === proxyTree.clipVolume)\r\n return;\r\n\r\n const builder = args.context.createSceneGraphicBuilder();\r\n builder.setSymbology(ColorDef.red, ColorDef.red, 2);\r\n for (const prim of proxyTree.clipVolume.clipVector.clips) {\r\n if (!(prim instanceof ClipShape))\r\n continue;\r\n\r\n const tf = prim.transformFromClip;\r\n const pts = prim.polygon.map((pt) => tf ? tf.multiplyPoint3d(pt) : pt.clone());\r\n builder.addLineString(pts);\r\n }\r\n\r\n const branch = new GraphicBranch();\r\n branch.entries.push(builder.finish());\r\n branch.setViewFlagOverrides({ clipVolume: false });\r\n args.context.outputGraphic(args.context.createGraphicBranch(branch, Transform.createIdentity()));\r\n }\r\n}\r\n\r\n/** Draws the 2d section graphics into the 3d view. */\r\nclass SectionGraphicsProvider implements TiledGraphicsProvider {\r\n private readonly _drawingRef: TileTreeReference;\r\n private readonly _sheetRef?: TileTreeReference;\r\n\r\n public constructor(state: SectionDrawingLocationState, attachment: ViewAttachmentProps | undefined) {\r\n this._drawingRef = new ProxyTreeReference({ state, attachment, isSheet: false });\r\n if (attachment)\r\n this._sheetRef = new ProxyTreeReference({ state, attachment, isSheet: true });\r\n }\r\n\r\n public forEachTileTreeRef(_viewport: Viewport, func: (ref: TileTreeReference) => void): void {\r\n func(this._drawingRef);\r\n if (undefined !== this._sheetRef)\r\n func(this._sheetRef);\r\n }\r\n}\r\n\r\n/** Creates a TiledGraphicsProvider that can be associated with a [Viewport]($frontend) to display 2d section graphics and annotations in the context of a [SpatialViewState]($frontend).\r\n * Typically used indirectly via [[HyperModelingDecorator]].\r\n * @param state The section drawing location specifying which section drawing to display.\r\n * @returns A provider suitable for passing to [Viewport.addTiledGraphicsProvider]($frontend).\r\n * @see [[HyperModelingDecorator.toggleAttachment]] to activate section graphics for a given [[SectionMarker]].\r\n * @public\r\n */\r\nexport async function createSectionGraphicsProvider(state: SectionDrawingLocationState): Promise<TiledGraphicsProvider> {\r\n let attachment;\r\n if (undefined !== state.viewAttachment) {\r\n const attachments = await state.iModel.elements.getProps(state.viewAttachment.id) as ViewAttachmentProps[];\r\n if (1 === attachments.length)\r\n attachment = attachments[0];\r\n }\r\n\r\n return new SectionGraphicsProvider(state, attachment);\r\n}\r\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SectionMarkerHandler.js","sourceRoot":"","sources":["../../src/SectionMarkerHandler.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,wDAAi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,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;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
+ {"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,CAAC,YAAY,CAAC;QAC5C,OAAO;YACL,KAAK,EAAE;gBACL;oBACE,EAAE,EAAE,YAAY;oBAChB,YAAY,EAAE,EAAE;oBAChB,KAAK,EAAE,YAAY,CAAC,kBAAkB,CAAC,iCAAiC,CAAC;oBACzE,IAAI,EAAE,yBAAyB;oBAC/B,OAAO,EAAE,GAAG,EAAE,GAAG,CAAC;oBAClB,UAAU,EAAE,KAAK;iBAClB;gBACD;oBACE,EAAE,EAAE,cAAc;o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AC;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"]}