@itwin/hypermodeling-frontend 5.0.0-dev.8 → 5.0.0-dev.82
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 +46 -1
- package/lib/cjs/HyperModeling.js +7 -4
- package/lib/cjs/HyperModeling.js.map +1 -1
- package/lib/cjs/HyperModelingDecorator.d.ts +1 -1
- package/lib/cjs/HyperModelingDecorator.d.ts.map +1 -1
- package/lib/cjs/HyperModelingDecorator.js +21 -9
- package/lib/cjs/HyperModelingDecorator.js.map +1 -1
- package/lib/cjs/PopupToolbar.js +13 -11
- package/lib/cjs/PopupToolbar.js.map +1 -1
- package/lib/cjs/SectionDrawingLocationState.js +28 -0
- package/lib/cjs/SectionDrawingLocationState.js.map +1 -1
- package/lib/cjs/SectionGraphicsProvider.d.ts.map +1 -1
- package/lib/cjs/SectionGraphicsProvider.js +14 -0
- package/lib/cjs/SectionGraphicsProvider.js.map +1 -1
- package/lib/cjs/SectionMarkers.js +11 -7
- package/lib/cjs/SectionMarkers.js.map +1 -1
- package/lib/cjs/Tools.js +4 -4
- package/lib/cjs/Tools.js.map +1 -1
- package/lib/esm/HyperModeling.js +7 -4
- package/lib/esm/HyperModeling.js.map +1 -1
- package/lib/esm/HyperModelingDecorator.d.ts +1 -1
- package/lib/esm/HyperModelingDecorator.d.ts.map +1 -1
- package/lib/esm/HyperModelingDecorator.js +21 -9
- package/lib/esm/HyperModelingDecorator.js.map +1 -1
- package/lib/esm/PopupToolbar.js +13 -11
- package/lib/esm/PopupToolbar.js.map +1 -1
- package/lib/esm/SectionDrawingLocationState.js +28 -0
- package/lib/esm/SectionDrawingLocationState.js.map +1 -1
- package/lib/esm/SectionGraphicsProvider.d.ts.map +1 -1
- package/lib/esm/SectionGraphicsProvider.js +14 -0
- package/lib/esm/SectionGraphicsProvider.js.map +1 -1
- package/lib/esm/SectionMarkers.js +11 -7
- package/lib/esm/SectionMarkers.js.map +1 -1
- package/lib/esm/Tools.js +4 -4
- package/lib/esm/Tools.js.map +1 -1
- package/package.json +21 -21
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,51 @@
|
|
|
1
1
|
# Change Log - @itwin/hypermodeling-frontend
|
|
2
2
|
|
|
3
|
-
This log was last generated on
|
|
3
|
+
This log was last generated on Tue, 11 Mar 2025 15:27:53 GMT and should not be manually modified.
|
|
4
|
+
|
|
5
|
+
## 4.10.10
|
|
6
|
+
Tue, 11 Mar 2025 15:25:11 GMT
|
|
7
|
+
|
|
8
|
+
_Version update only_
|
|
9
|
+
|
|
10
|
+
## 4.10.9
|
|
11
|
+
Tue, 11 Mar 2025 05:17:33 GMT
|
|
12
|
+
|
|
13
|
+
_Version update only_
|
|
14
|
+
|
|
15
|
+
## 4.10.8
|
|
16
|
+
Thu, 06 Mar 2025 14:13:37 GMT
|
|
17
|
+
|
|
18
|
+
_Version update only_
|
|
19
|
+
|
|
20
|
+
## 4.10.7
|
|
21
|
+
Tue, 18 Feb 2025 17:27:03 GMT
|
|
22
|
+
|
|
23
|
+
_Version update only_
|
|
24
|
+
|
|
25
|
+
## 4.10.6
|
|
26
|
+
Fri, 24 Jan 2025 08:02:40 GMT
|
|
27
|
+
|
|
28
|
+
_Version update only_
|
|
29
|
+
|
|
30
|
+
## 4.10.5
|
|
31
|
+
Tue, 21 Jan 2025 21:56:45 GMT
|
|
32
|
+
|
|
33
|
+
_Version update only_
|
|
34
|
+
|
|
35
|
+
## 4.10.4
|
|
36
|
+
Mon, 13 Jan 2025 14:06:43 GMT
|
|
37
|
+
|
|
38
|
+
_Version update only_
|
|
39
|
+
|
|
40
|
+
## 4.10.3
|
|
41
|
+
Mon, 06 Jan 2025 14:00:13 GMT
|
|
42
|
+
|
|
43
|
+
_Version update only_
|
|
44
|
+
|
|
45
|
+
## 4.10.2
|
|
46
|
+
Thu, 21 Nov 2024 15:22:20 GMT
|
|
47
|
+
|
|
48
|
+
_Version update only_
|
|
4
49
|
|
|
5
50
|
## 4.10.1
|
|
6
51
|
Thu, 14 Nov 2024 18:11:00 GMT
|
package/lib/cjs/HyperModeling.js
CHANGED
|
@@ -25,6 +25,11 @@ function assertInitialized(maybe) {
|
|
|
25
25
|
* @public
|
|
26
26
|
*/
|
|
27
27
|
class HyperModeling {
|
|
28
|
+
/** @internal */
|
|
29
|
+
static resources;
|
|
30
|
+
static _markerHandler;
|
|
31
|
+
static _markerConfig = {};
|
|
32
|
+
static _graphicsConfig = {};
|
|
28
33
|
static shutdown() {
|
|
29
34
|
this.resources = undefined;
|
|
30
35
|
this._markerHandler = undefined;
|
|
@@ -175,7 +180,7 @@ class HyperModeling {
|
|
|
175
180
|
return this._start(viewport);
|
|
176
181
|
}
|
|
177
182
|
else {
|
|
178
|
-
decorator?.dispose();
|
|
183
|
+
decorator?.[Symbol.dispose]();
|
|
179
184
|
return undefined;
|
|
180
185
|
}
|
|
181
186
|
}
|
|
@@ -210,7 +215,7 @@ class HyperModeling {
|
|
|
210
215
|
*/
|
|
211
216
|
static stop(viewport) {
|
|
212
217
|
const decorator = HyperModelingDecorator_1.HyperModelingDecorator.getForViewport(viewport);
|
|
213
|
-
decorator?.dispose();
|
|
218
|
+
decorator?.[Symbol.dispose]();
|
|
214
219
|
}
|
|
215
220
|
/** @internal */
|
|
216
221
|
static get namespace() {
|
|
@@ -233,6 +238,4 @@ class HyperModeling {
|
|
|
233
238
|
}
|
|
234
239
|
}
|
|
235
240
|
exports.HyperModeling = HyperModeling;
|
|
236
|
-
HyperModeling._markerConfig = {};
|
|
237
|
-
HyperModeling._graphicsConfig = {};
|
|
238
241
|
//# 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;AA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,IAAiB;QAC3C,iBAAiB,CAAC,IAAI,CAAC,CAAC;QACxB,QAAQ,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;\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QAAQ,CAAC,aAAa,EAAE,CAAC;QAC3B,CAAC;QAED,OAAO,SAAS,CAAC;IACnB,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,IAAI,CAAC,QAAwB;QACzC,MAAM,SAAS,GAAG,+CAAsB,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;QAClE,SAAS,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,CAAC;IAChC,CAAC;IAED,gBAAgB;IACT,MAAM,KAAK,SAAS;QACzB,iBAAiB,CAAC,IAAI,CAAC,CAAC;QACxB,OAAO,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC;IAClC,CAAC;IAED,gBAAgB;IACT,MAAM,CAAC,aAAa,CAAC,IAAiB;QAC3C,iBAAiB,CAAC,IAAI,CAAC,CAAC;QACxB,QAAQ,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","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?.[Symbol.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?.[Symbol.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"]}
|
|
@@ -64,7 +64,7 @@ export declare class HyperModelingDecorator implements Decorator {
|
|
|
64
64
|
private toggleMarker;
|
|
65
65
|
private dropTiledGraphicsProvider;
|
|
66
66
|
/** @internal */
|
|
67
|
-
dispose(): void;
|
|
67
|
+
[Symbol.dispose](): void;
|
|
68
68
|
private showToolbarAfterTimeout;
|
|
69
69
|
/** Toggles whether the clip volume associated with the specified marker is applied to the view. */
|
|
70
70
|
toggleClipVolume(marker: SectionMarker, enable: boolean): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HyperModelingDecorator.d.ts","sourceRoot":"","sources":["../../src/HyperModelingDecorator.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EACQ,eAAe,EAAE,SAAS,EAA+B,cAAc,EACrF,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAKnE,OAAO,EAAE,mBAAmB,EAAE,MAAM,uBAAuB,CAAC;AAwC5D;;;;;;GAMG;AACH,qBAAa,sBAAuB,YAAW,SAAS;IACtD,kEAAkE;IAClE,SAAgB,OAAO,EAAE,gBAAgB,CAAC;IAC1C,OAAO,CAAC,OAAO,CAAsB;IACrC,OAAO,CAAC,QAAQ,CAAC,qBAAqB,C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27
27
|
class MarkerToolbarProvider {
|
|
28
|
+
_viewport;
|
|
29
|
+
marker;
|
|
30
|
+
toolbarProps;
|
|
31
|
+
onToolbarItemExecuted;
|
|
28
32
|
constructor(marker, decorator) {
|
|
29
33
|
this.marker = marker;
|
|
30
34
|
this._viewport = decorator.viewport;
|
|
@@ -49,6 +53,18 @@ class MarkerToolbarProvider {
|
|
|
49
53
|
* @public
|
|
50
54
|
*/
|
|
51
55
|
class HyperModelingDecorator {
|
|
56
|
+
/** The set of [[SectionMarker]]s controlled by this decorator. */
|
|
57
|
+
markers;
|
|
58
|
+
_config;
|
|
59
|
+
_removeEventListeners = new Array();
|
|
60
|
+
_iModel;
|
|
61
|
+
_needSync = false;
|
|
62
|
+
_toolbarProvider;
|
|
63
|
+
_tiledGraphicsProvider;
|
|
64
|
+
_activeMarker;
|
|
65
|
+
_appliedSpatialView;
|
|
66
|
+
/** @internal */
|
|
67
|
+
syncImmediately = false;
|
|
52
68
|
/** Create a new decorator and register it with the [ViewManager]($frontend). Typically invoked indirectly via [[HyperModeling.startOrStop]]. */
|
|
53
69
|
static async create(vp, config) {
|
|
54
70
|
const markers = await createMarkers(vp);
|
|
@@ -123,17 +139,13 @@ class HyperModelingDecorator {
|
|
|
123
139
|
return true;
|
|
124
140
|
}
|
|
125
141
|
/** @internal */
|
|
142
|
+
useCachedDecorations = true;
|
|
143
|
+
/** @internal */
|
|
126
144
|
decorate(context) {
|
|
127
145
|
if (this.viewport.view.is3d())
|
|
128
146
|
this.markers.addDecoration(context);
|
|
129
147
|
}
|
|
130
148
|
constructor(markers, config) {
|
|
131
|
-
this._removeEventListeners = new Array();
|
|
132
|
-
this._needSync = false;
|
|
133
|
-
/** @internal */
|
|
134
|
-
this.syncImmediately = false;
|
|
135
|
-
/** @internal */
|
|
136
|
-
this.useCachedDecorations = true;
|
|
137
149
|
this.markers = markers;
|
|
138
150
|
this._config = { ...config };
|
|
139
151
|
this._iModel = this.viewport.iModel;
|
|
@@ -141,7 +153,7 @@ class HyperModelingDecorator {
|
|
|
141
153
|
this.requestSync();
|
|
142
154
|
});
|
|
143
155
|
this._removeEventListeners.push(this.viewport.onViewportChanged.addListener((_, changeFlags) => this.onViewportChanged(changeFlags)));
|
|
144
|
-
this._removeEventListeners.push(this.viewport.onDisposed.addListener(() => this.dispose()));
|
|
156
|
+
this._removeEventListeners.push(this.viewport.onDisposed.addListener(() => this[Symbol.dispose]()));
|
|
145
157
|
for (const marker of markers.markers) {
|
|
146
158
|
marker.onMouseEnterEvent.addListener((mkr) => this.showToolbarAfterTimeout(mkr));
|
|
147
159
|
marker.onMouseButtonEvent.addListener((mkr) => this.toggleMarker(mkr)); // eslint-disable-line @typescript-eslint/promise-function-async
|
|
@@ -151,7 +163,7 @@ class HyperModelingDecorator {
|
|
|
151
163
|
}
|
|
152
164
|
onViewportChanged(changeFlags) {
|
|
153
165
|
if (this.viewport.iModel !== this._iModel) {
|
|
154
|
-
this.dispose();
|
|
166
|
+
this[Symbol.dispose]();
|
|
155
167
|
return;
|
|
156
168
|
}
|
|
157
169
|
if (changeFlags.viewedCategories || changeFlags.viewedModels || changeFlags.viewedCategoriesPerModel)
|
|
@@ -174,7 +186,7 @@ class HyperModelingDecorator {
|
|
|
174
186
|
this._tiledGraphicsProvider = undefined;
|
|
175
187
|
}
|
|
176
188
|
/** @internal */
|
|
177
|
-
dispose() {
|
|
189
|
+
[Symbol.dispose]() {
|
|
178
190
|
if (!core_frontend_1.IModelApp.viewManager.dropDecorator(this))
|
|
179
191
|
return;
|
|
180
192
|
for (const remove of this._removeEventListeners)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"HyperModelingDecorator.js","sourceRoot":"","sources":["../../src/HyperModelingDecorator.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,wDAAwD;AAExD,wDAE8B;AAC9B,qDAAmE;AACnE,+EAA4E;AAC5E,uEAA0E;AAC1E,iDAA2E;AAC3E,mDAAgD;AAGhD,KAA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K,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YAC1C,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;QACvD,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AA7VD,wDA6VC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module HyperModeling\n */\n\nimport { Transform, XAndY } from \"@itwin/core-geometry\";\nimport type { AbstractToolbarProps } from \"@itwin/appui-abstract\";\nimport {\n ChangeFlags, DecorateContext, Decorator, IModelApp, IModelConnection, ScreenViewport, SpatialViewState, TiledGraphicsProvider, ViewClipTool,\n} from \"@itwin/core-frontend\";\nimport { SectionMarker, SectionMarkerSet } from \"./SectionMarkers\";\nimport { SectionDrawingLocationState } from \"./SectionDrawingLocationState\";\nimport { createSectionGraphicsProvider } from \"./SectionGraphicsProvider\";\nimport { PopupToolbarManager, PopupToolbarProvider } from \"./PopupToolbar\";\nimport { HyperModeling } from \"./HyperModeling\";\nimport { SectionMarkerConfig } from \"./HyperModelingConfig\";\n\nasync function createMarkers(vp: ScreenViewport): Promise<SectionMarkerSet | undefined> {\n if (!vp.view.isSpatialView())\n return undefined;\n\n const states = await SectionDrawingLocationState.queryAll(vp.iModel);\n if (0 === states.length)\n return undefined;\n\n const markers = states.map((state) => new SectionMarker(state));\n return new SectionMarkerSet(vp, markers);\n}\n\nclass MarkerToolbarProvider implements PopupToolbarProvider {\n private readonly _viewport: ScreenViewport;\n public readonly marker: SectionMarker;\n public readonly toolbarProps: AbstractToolbarProps;\n public readonly onToolbarItemExecuted: (id: string) => void;\n\n public constructor(marker: SectionMarker, decorator: HyperModelingDecorator) {\n this.marker = marker;\n this._viewport = decorator.viewport;\n this.toolbarProps = HyperModeling.markerHandler.getToolbarProps(marker, decorator);\n this.onToolbarItemExecuted = (id) => HyperModeling.markerHandler.executeCommand(id, marker, decorator); // eslint-disable-line @typescript-eslint/promise-function-async\n }\n\n public get overToolbarHotspot() {\n return this.marker.isHilited;\n }\n\n public get toolbarLocation(): XAndY {\n return { x: this.marker.rect.right, y: this.marker.rect.top };\n }\n\n public get htmlElement() {\n return this._viewport.canvas;\n }\n}\n\n/** A [Decorator]($frontend) that displays a [[SectionMarker]] for each [SectionDrawingLocation]($backend) in the view.\n * Clicking on a marker toggles the section and the display of associated 2d graphics.\n * Hovering over a marker opens a mini toolbar with additional interactions.\n * @see [[SectionMarkerHandler]] to customize the marker interactions.\n * @see [[HyperModeling.startOrStop]] to enable or disable the decorator for a viewport.\n * @public\n */\nexport class HyperModelingDecorator implements Decorator {\n /** The set of [[SectionMarker]]s controlled by this decorator. */\n public readonly markers: SectionMarkerSet;\n private _config: SectionMarkerConfig;\n private readonly _removeEventListeners = new Array<() => void>();\n private readonly _iModel: IModelConnection;\n private _needSync = false;\n private _toolbarProvider?: MarkerToolbarProvider;\n private _tiledGraphicsProvider?: TiledGraphicsProvider;\n private _activeMarker?: SectionMarker;\n private _appliedSpatialView?: SpatialViewState;\n /** @internal */\n public syncImmediately = false;\n\n /** Create a new decorator and register it with the [ViewManager]($frontend). Typically invoked indirectly via [[HyperModeling.startOrStop]]. */\n public static async create(vp: ScreenViewport, config: SectionMarkerConfig): Promise<HyperModelingDecorator | undefined> {\n const markers = await createMarkers(vp);\n return undefined !== markers ? new HyperModelingDecorator(markers, config) : undefined;\n }\n\n /** Obtain the decorator associated with the specified viewport, if any. */\n public static getForViewport(vp: ScreenViewport): HyperModelingDecorator | undefined {\n for (const decorator of IModelApp.viewManager.decorators)\n if (decorator instanceof HyperModelingDecorator && decorator.viewport === vp)\n return decorator;\n\n return undefined;\n }\n\n /** The viewport into which this decorator draws its [[SectionMarker]]s. */\n public get viewport(): ScreenViewport {\n return this.markers.viewport;\n }\n\n /** The currently active marker. A marker typically becomes active when the user clicks on it.\n * @see [[setActiveMarker]] to change the active marker without user interaction.\n */\n public get activeMarker(): SectionMarker | undefined {\n return this._activeMarker;\n }\n\n /** @internal */\n public get config(): SectionMarkerConfig {\n return this._config;\n }\n\n /** Replaces the current marker display configuration, overwriting all previous settings. Passing `undefined` resets all settings to defaults.\n * @see [[updateConfiguration]] to override specific aspects of the configuration\n * @see [[HyperModeling.replaceConfiguration]] to replace the global configuration.\n */\n public replaceConfiguration(config?: SectionMarkerConfig): void {\n this._config = config ? { ...config } : {};\n this.requestSync();\n }\n\n /** Overrides specific aspects of the current marker display configuration.\n * Any field that is not `undefined` will be replaced in the current configuration; the rest will retain their current values.\n * @see [[replaceConfiguration]] to override all settings.\n * @see [[HyperModeling.updateConfiguration]] to update the global configuration.\n */\n public updateConfiguration(config: SectionMarkerConfig): void {\n this._config = {\n ignoreModelSelector: config.ignoreModelSelector ?? this._config.ignoreModelSelector,\n ignoreCategorySelector: config.ignoreCategorySelector ?? this._config.ignoreCategorySelector,\n hiddenSectionTypes: config.hiddenSectionTypes ?? this._config.hiddenSectionTypes,\n };\n\n this.requestSync();\n }\n\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.\n * Changing the active marker first deactivates the currently active marker, if any; then activates the specified marker, if supplied.\n * Returns false if marker activation fails.\n * @see [[activeMarker]] to obtain the currently active section marker.\n * @see [[SectionMarkerHandler.activateMarker]] to control what happens when a marker is activated.\n * @see [[SectionMarkerHandler.deactivateMarker]] to control what happens when a marker is deactivated.\n */\n public async setActiveMarker(marker: SectionMarker | undefined): Promise<boolean> {\n if (marker === this.activeMarker)\n return true;\n\n if (this.activeMarker) {\n this.activeMarker.setActive(false);\n await HyperModeling.markerHandler.deactivateMarker(this.activeMarker, this);\n this._activeMarker = undefined;\n }\n\n if (marker) {\n if (!await HyperModeling.markerHandler.activateMarker(marker, this)) {\n this.requestSync();\n return false;\n }\n\n marker.setActive(true);\n this._activeMarker = marker;\n }\n\n this.requestSync();\n return true;\n }\n\n /** @internal */\n public readonly useCachedDecorations = true;\n\n /** @internal */\n public decorate(context: DecorateContext): void {\n if (this.viewport.view.is3d())\n this.markers.addDecoration(context);\n }\n\n private constructor(markers: SectionMarkerSet, config: SectionMarkerConfig) {\n this.markers = markers;\n this._config = { ...config };\n this._iModel = this.viewport.iModel;\n\n this.viewport.onChangeView.addOnce(() => {\n this.requestSync();\n });\n\n this._removeEventListeners.push(this.viewport.onViewportChanged.addListener((_, changeFlags) => this.onViewportChanged(changeFlags)));\n this._removeEventListeners.push(this.viewport.onDisposed.addListener(() => this.dispose()));\n\n for (const marker of markers.markers) {\n marker.onMouseEnterEvent.addListener((mkr) => this.showToolbarAfterTimeout(mkr));\n marker.onMouseButtonEvent.addListener((mkr) => this.toggleMarker(mkr)); // eslint-disable-line @typescript-eslint/promise-function-async\n }\n\n this.updateMarkerVisibility();\n IModelApp.viewManager.addDecorator(this);\n }\n\n private onViewportChanged(changeFlags: ChangeFlags): void {\n if (this.viewport.iModel !== this._iModel) {\n this.dispose();\n return;\n }\n\n if (changeFlags.viewedCategories || changeFlags.viewedModels || changeFlags.viewedCategoriesPerModel)\n this.requestSync();\n\n if (changeFlags.viewState) {\n // If we're looking at a different view now, and we did not initiate that, turn off the active marker.\n if (this.viewport.view !== this._appliedSpatialView)\n this.setActiveMarker(undefined); // eslint-disable-line @typescript-eslint/no-floating-promises\n else\n this._appliedSpatialView = undefined;\n }\n }\n\n private async toggleMarker(marker: SectionMarker): Promise<void> {\n await this.setActiveMarker(marker === this.activeMarker ? undefined : marker);\n }\n\n private dropTiledGraphicsProvider(): void {\n if (undefined === this._tiledGraphicsProvider)\n return;\n\n this.viewport.dropTiledGraphicsProvider(this._tiledGraphicsProvider);\n this._tiledGraphicsProvider = undefined;\n }\n\n /** @internal */\n public dispose(): void {\n if (!IModelApp.viewManager.dropDecorator(this))\n return;\n\n for (const remove of this._removeEventListeners)\n remove();\n\n this.dropTiledGraphicsProvider();\n }\n\n private showToolbarAfterTimeout(marker: SectionMarker): void {\n if (this._toolbarProvider?.marker !== marker)\n this._toolbarProvider = new MarkerToolbarProvider(marker, this);\n\n PopupToolbarManager.showToolbarAfterTimeout(this._toolbarProvider);\n }\n\n /** Toggles whether the clip volume associated with the specified marker is applied to the view. */\n public toggleClipVolume(marker: SectionMarker, enable: boolean): void {\n ViewClipTool.enableClipVolume(this.viewport);\n ViewClipTool.setViewClip(this.viewport, enable ? marker.state.clip : undefined);\n }\n\n /** Toggles the specified section marker.\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.\n * Disabling the section disables the clip volume and 2d graphics.\n * @see [[toggleClipVolume]] to toggle only the clip volume.\n * @see [[toggleAttachment]] to toggle only the attachment graphics.\n */\n public async toggleSection(marker: SectionMarker, enable: boolean): Promise<boolean> {\n if (enable) {\n if (this.viewport.view.is3d()) {\n // Preserve the view settings; apply only the frustum and clip volume\n const spatialView = await marker.state.tryLoadSpatialView();\n if (!spatialView)\n return false;\n\n const aligned = await this.alignToSpatialView(marker);\n if (!aligned)\n return false;\n\n this.toggleClipVolume(marker, true);\n } else if (!await this.applySpatialView(marker)) {\n return false;\n }\n } else {\n this.toggleClipVolume(marker, false);\n }\n\n this.requestSync();\n return this.toggleAttachment(marker, enable);\n }\n\n /** Toggles display of 2d section graphics and sheet annotations for the specified marker.\n * @see [[toggleSection]] to apply the spatial view and clip volume in addition to the attachment graphics.\n */\n public async toggleAttachment(marker: SectionMarker, enable: boolean): Promise<boolean> {\n this.dropTiledGraphicsProvider();\n if (enable) {\n this._tiledGraphicsProvider = await createSectionGraphicsProvider(marker.state);\n this.viewport.addTiledGraphicsProvider(this._tiledGraphicsProvider);\n }\n\n return true;\n }\n\n /** Aligns the viewport to face the specified marker's section plane. */\n public alignView(marker: SectionMarker): void {\n const placement = marker.state.placement.transform;\n const origin = placement.origin;\n const matrix = placement.matrix;\n\n const vp = this.viewport;\n const targetMatrix = matrix.multiplyMatrixMatrix(vp.rotation);\n const rotateTransform = Transform.createFixedPointAndMatrix(origin, targetMatrix);\n\n const startFrustum = vp.getFrustum();\n const newFrustum = startFrustum.clone();\n newFrustum.multiply(rotateTransform);\n\n if (startFrustum.equals(newFrustum))\n return;\n\n vp.view.setupFromFrustum(newFrustum);\n vp.synchWithView();\n vp.animateFrustumChange();\n }\n\n /** Opens the marker's drawing view in the decorator's viewport. Returns false if the drawing view could not be loaded. */\n public async openSection(marker: SectionMarker): Promise<boolean> {\n const viewState = await marker.state.tryLoadDrawingView();\n if (viewState)\n this.viewport.changeView(viewState);\n\n return undefined !== viewState;\n }\n\n /** Opens marker's sheet view in the decorator's viewport and zooms in on the associated [ViewAttachment]($backend). Returns false if no view\n * attachment exists or the sheet view could not be loaded.\n */\n public async openSheet(marker: SectionMarker): Promise<boolean> {\n if (undefined === marker.state.viewAttachment)\n return false;\n\n const viewState = await marker.state.tryLoadSheetView();\n if (!viewState)\n return false;\n\n this.viewport.changeView(viewState);\n await this.viewport.zoomToElements(marker.state.viewAttachment.id);\n return true;\n }\n\n /** Aligns the view to match the frustum of the spatial view associated with the specified marker.\n * @param marker The marker whose spatial view's frustum should be applied.\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.\n * @see [[alignView]] to align to the *section plane*, which may differ.\n * @see [[toggleSection]] to also apply the clip volume.\n */\n public async alignToSpatialView(marker: SectionMarker): Promise<boolean> {\n if (!this.viewport.view.is3d())\n return false;\n\n const spatialView = await marker.state.tryLoadSpatialView();\n if (!spatialView)\n return false;\n\n this.viewport.view.setOrigin(spatialView.getOrigin());\n this.viewport.view.setExtents(spatialView.getExtents());\n this.viewport.view.setRotation(spatialView.getRotation());\n this.viewport.synchWithView({ animateFrustumChange: true });\n\n return true;\n }\n\n /** Applies the marker's spatial view - including its clip volume - to the decorator's viewport.\n * Returns false if the spatial view could not be loaded.\n * @see [[toggleSection]].\n * @see [[toggleClipVolume]].\n */\n public async applySpatialView(marker: SectionMarker): Promise<boolean> {\n const viewState = await marker.state.tryLoadSpatialView();\n if (viewState) {\n this._appliedSpatialView = viewState;\n this.viewport.changeView(viewState);\n }\n\n return undefined !== viewState;\n }\n\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\n * this method when the criteria governing your `isMarkerVisible` method have changed.\n */\n public requestSync(): void {\n if (this.syncImmediately) {\n this.sync();\n } else if (!this._needSync) {\n this._needSync = true;\n requestAnimationFrame(() => this.sync());\n }\n }\n\n private sync(): void {\n this._needSync = false;\n if (HyperModeling.isInitialized && this.viewport.view.is3d() && this.updateMarkerVisibility()) {\n this.markers.markDirty();\n this.viewport.invalidateCachedDecorations(this);\n }\n }\n\n private isMarkerVisible(marker: SectionMarker): boolean {\n if (undefined !== this.activeMarker)\n return marker === this.activeMarker;\n\n return HyperModeling.markerHandler.isMarkerVisible(marker, this, this._config);\n }\n\n private updateMarkerVisibility(): boolean {\n let changed = false;\n for (const marker of this.markers.markers) {\n const wasVisible = marker.visible;\n marker.visible = this.isMarkerVisible(marker);\n changed = changed || (marker.visible !== wasVisible);\n }\n\n return changed;\n }\n}\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,MA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AC,aAAa,CAAC,eAAe,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;IACjF,CAAC;IAEO,sBAAsB;QAC5B,IAAI,OAAO,GAAG,KAAK,CAAC;QACpB,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;YAC1C,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;QACvD,CAAC;QAED,OAAO,OAAO,CAAC;IACjB,CAAC;CACF;AA7VD,wDA6VC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module HyperModeling\n */\n\nimport { Transform, XAndY } from \"@itwin/core-geometry\";\nimport type { AbstractToolbarProps } from \"@itwin/appui-abstract\";\nimport {\n ChangeFlags, DecorateContext, Decorator, IModelApp, IModelConnection, ScreenViewport, SpatialViewState, TiledGraphicsProvider, ViewClipTool,\n} from \"@itwin/core-frontend\";\nimport { SectionMarker, SectionMarkerSet } from \"./SectionMarkers\";\nimport { SectionDrawingLocationState } from \"./SectionDrawingLocationState\";\nimport { createSectionGraphicsProvider } from \"./SectionGraphicsProvider\";\nimport { PopupToolbarManager, PopupToolbarProvider } from \"./PopupToolbar\";\nimport { HyperModeling } from \"./HyperModeling\";\nimport { SectionMarkerConfig } from \"./HyperModelingConfig\";\n\nasync function createMarkers(vp: ScreenViewport): Promise<SectionMarkerSet | undefined> {\n if (!vp.view.isSpatialView())\n return undefined;\n\n const states = await SectionDrawingLocationState.queryAll(vp.iModel);\n if (0 === states.length)\n return undefined;\n\n const markers = states.map((state) => new SectionMarker(state));\n return new SectionMarkerSet(vp, markers);\n}\n\nclass MarkerToolbarProvider implements PopupToolbarProvider {\n private readonly _viewport: ScreenViewport;\n public readonly marker: SectionMarker;\n public readonly toolbarProps: AbstractToolbarProps;\n public readonly onToolbarItemExecuted: (id: string) => void;\n\n public constructor(marker: SectionMarker, decorator: HyperModelingDecorator) {\n this.marker = marker;\n this._viewport = decorator.viewport;\n this.toolbarProps = HyperModeling.markerHandler.getToolbarProps(marker, decorator);\n this.onToolbarItemExecuted = (id) => HyperModeling.markerHandler.executeCommand(id, marker, decorator); // eslint-disable-line @typescript-eslint/promise-function-async\n }\n\n public get overToolbarHotspot() {\n return this.marker.isHilited;\n }\n\n public get toolbarLocation(): XAndY {\n return { x: this.marker.rect.right, y: this.marker.rect.top };\n }\n\n public get htmlElement() {\n return this._viewport.canvas;\n }\n}\n\n/** A [Decorator]($frontend) that displays a [[SectionMarker]] for each [SectionDrawingLocation]($backend) in the view.\n * Clicking on a marker toggles the section and the display of associated 2d graphics.\n * Hovering over a marker opens a mini toolbar with additional interactions.\n * @see [[SectionMarkerHandler]] to customize the marker interactions.\n * @see [[HyperModeling.startOrStop]] to enable or disable the decorator for a viewport.\n * @public\n */\nexport class HyperModelingDecorator implements Decorator {\n /** The set of [[SectionMarker]]s controlled by this decorator. */\n public readonly markers: SectionMarkerSet;\n private _config: SectionMarkerConfig;\n private readonly _removeEventListeners = new Array<() => void>();\n private readonly _iModel: IModelConnection;\n private _needSync = false;\n private _toolbarProvider?: MarkerToolbarProvider;\n private _tiledGraphicsProvider?: TiledGraphicsProvider;\n private _activeMarker?: SectionMarker;\n private _appliedSpatialView?: SpatialViewState;\n /** @internal */\n public syncImmediately = false;\n\n /** Create a new decorator and register it with the [ViewManager]($frontend). Typically invoked indirectly via [[HyperModeling.startOrStop]]. */\n public static async create(vp: ScreenViewport, config: SectionMarkerConfig): Promise<HyperModelingDecorator | undefined> {\n const markers = await createMarkers(vp);\n return undefined !== markers ? new HyperModelingDecorator(markers, config) : undefined;\n }\n\n /** Obtain the decorator associated with the specified viewport, if any. */\n public static getForViewport(vp: ScreenViewport): HyperModelingDecorator | undefined {\n for (const decorator of IModelApp.viewManager.decorators)\n if (decorator instanceof HyperModelingDecorator && decorator.viewport === vp)\n return decorator;\n\n return undefined;\n }\n\n /** The viewport into which this decorator draws its [[SectionMarker]]s. */\n public get viewport(): ScreenViewport {\n return this.markers.viewport;\n }\n\n /** The currently active marker. A marker typically becomes active when the user clicks on it.\n * @see [[setActiveMarker]] to change the active marker without user interaction.\n */\n public get activeMarker(): SectionMarker | undefined {\n return this._activeMarker;\n }\n\n /** @internal */\n public get config(): SectionMarkerConfig {\n return this._config;\n }\n\n /** Replaces the current marker display configuration, overwriting all previous settings. Passing `undefined` resets all settings to defaults.\n * @see [[updateConfiguration]] to override specific aspects of the configuration\n * @see [[HyperModeling.replaceConfiguration]] to replace the global configuration.\n */\n public replaceConfiguration(config?: SectionMarkerConfig): void {\n this._config = config ? { ...config } : {};\n this.requestSync();\n }\n\n /** Overrides specific aspects of the current marker display configuration.\n * Any field that is not `undefined` will be replaced in the current configuration; the rest will retain their current values.\n * @see [[replaceConfiguration]] to override all settings.\n * @see [[HyperModeling.updateConfiguration]] to update the global configuration.\n */\n public updateConfiguration(config: SectionMarkerConfig): void {\n this._config = {\n ignoreModelSelector: config.ignoreModelSelector ?? this._config.ignoreModelSelector,\n ignoreCategorySelector: config.ignoreCategorySelector ?? this._config.ignoreCategorySelector,\n hiddenSectionTypes: config.hiddenSectionTypes ?? this._config.hiddenSectionTypes,\n };\n\n this.requestSync();\n }\n\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.\n * Changing the active marker first deactivates the currently active marker, if any; then activates the specified marker, if supplied.\n * Returns false if marker activation fails.\n * @see [[activeMarker]] to obtain the currently active section marker.\n * @see [[SectionMarkerHandler.activateMarker]] to control what happens when a marker is activated.\n * @see [[SectionMarkerHandler.deactivateMarker]] to control what happens when a marker is deactivated.\n */\n public async setActiveMarker(marker: SectionMarker | undefined): Promise<boolean> {\n if (marker === this.activeMarker)\n return true;\n\n if (this.activeMarker) {\n this.activeMarker.setActive(false);\n await HyperModeling.markerHandler.deactivateMarker(this.activeMarker, this);\n this._activeMarker = undefined;\n }\n\n if (marker) {\n if (!await HyperModeling.markerHandler.activateMarker(marker, this)) {\n this.requestSync();\n return false;\n }\n\n marker.setActive(true);\n this._activeMarker = marker;\n }\n\n this.requestSync();\n return true;\n }\n\n /** @internal */\n public readonly useCachedDecorations = true;\n\n /** @internal */\n public decorate(context: DecorateContext): void {\n if (this.viewport.view.is3d())\n this.markers.addDecoration(context);\n }\n\n private constructor(markers: SectionMarkerSet, config: SectionMarkerConfig) {\n this.markers = markers;\n this._config = { ...config };\n this._iModel = this.viewport.iModel;\n\n this.viewport.onChangeView.addOnce(() => {\n this.requestSync();\n });\n\n this._removeEventListeners.push(this.viewport.onViewportChanged.addListener((_, changeFlags) => this.onViewportChanged(changeFlags)));\n this._removeEventListeners.push(this.viewport.onDisposed.addListener(() => this[Symbol.dispose]()));\n\n for (const marker of markers.markers) {\n marker.onMouseEnterEvent.addListener((mkr) => this.showToolbarAfterTimeout(mkr));\n marker.onMouseButtonEvent.addListener((mkr) => this.toggleMarker(mkr)); // eslint-disable-line @typescript-eslint/promise-function-async\n }\n\n this.updateMarkerVisibility();\n IModelApp.viewManager.addDecorator(this);\n }\n\n private onViewportChanged(changeFlags: ChangeFlags): void {\n if (this.viewport.iModel !== this._iModel) {\n this[Symbol.dispose]();\n return;\n }\n\n if (changeFlags.viewedCategories || changeFlags.viewedModels || changeFlags.viewedCategoriesPerModel)\n this.requestSync();\n\n if (changeFlags.viewState) {\n // If we're looking at a different view now, and we did not initiate that, turn off the active marker.\n if (this.viewport.view !== this._appliedSpatialView)\n this.setActiveMarker(undefined); // eslint-disable-line @typescript-eslint/no-floating-promises\n else\n this._appliedSpatialView = undefined;\n }\n }\n\n private async toggleMarker(marker: SectionMarker): Promise<void> {\n await this.setActiveMarker(marker === this.activeMarker ? undefined : marker);\n }\n\n private dropTiledGraphicsProvider(): void {\n if (undefined === this._tiledGraphicsProvider)\n return;\n\n this.viewport.dropTiledGraphicsProvider(this._tiledGraphicsProvider);\n this._tiledGraphicsProvider = undefined;\n }\n\n /** @internal */\n public [Symbol.dispose](): void {\n if (!IModelApp.viewManager.dropDecorator(this))\n return;\n\n for (const remove of this._removeEventListeners)\n remove();\n\n this.dropTiledGraphicsProvider();\n }\n\n private showToolbarAfterTimeout(marker: SectionMarker): void {\n if (this._toolbarProvider?.marker !== marker)\n this._toolbarProvider = new MarkerToolbarProvider(marker, this);\n\n PopupToolbarManager.showToolbarAfterTimeout(this._toolbarProvider);\n }\n\n /** Toggles whether the clip volume associated with the specified marker is applied to the view. */\n public toggleClipVolume(marker: SectionMarker, enable: boolean): void {\n ViewClipTool.enableClipVolume(this.viewport);\n ViewClipTool.setViewClip(this.viewport, enable ? marker.state.clip : undefined);\n }\n\n /** Toggles the specified section marker.\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.\n * Disabling the section disables the clip volume and 2d graphics.\n * @see [[toggleClipVolume]] to toggle only the clip volume.\n * @see [[toggleAttachment]] to toggle only the attachment graphics.\n */\n public async toggleSection(marker: SectionMarker, enable: boolean): Promise<boolean> {\n if (enable) {\n if (this.viewport.view.is3d()) {\n // Preserve the view settings; apply only the frustum and clip volume\n const spatialView = await marker.state.tryLoadSpatialView();\n if (!spatialView)\n return false;\n\n const aligned = await this.alignToSpatialView(marker);\n if (!aligned)\n return false;\n\n this.toggleClipVolume(marker, true);\n } else if (!await this.applySpatialView(marker)) {\n return false;\n }\n } else {\n this.toggleClipVolume(marker, false);\n }\n\n this.requestSync();\n return this.toggleAttachment(marker, enable);\n }\n\n /** Toggles display of 2d section graphics and sheet annotations for the specified marker.\n * @see [[toggleSection]] to apply the spatial view and clip volume in addition to the attachment graphics.\n */\n public async toggleAttachment(marker: SectionMarker, enable: boolean): Promise<boolean> {\n this.dropTiledGraphicsProvider();\n if (enable) {\n this._tiledGraphicsProvider = await createSectionGraphicsProvider(marker.state);\n this.viewport.addTiledGraphicsProvider(this._tiledGraphicsProvider);\n }\n\n return true;\n }\n\n /** Aligns the viewport to face the specified marker's section plane. */\n public alignView(marker: SectionMarker): void {\n const placement = marker.state.placement.transform;\n const origin = placement.origin;\n const matrix = placement.matrix;\n\n const vp = this.viewport;\n const targetMatrix = matrix.multiplyMatrixMatrix(vp.rotation);\n const rotateTransform = Transform.createFixedPointAndMatrix(origin, targetMatrix);\n\n const startFrustum = vp.getFrustum();\n const newFrustum = startFrustum.clone();\n newFrustum.multiply(rotateTransform);\n\n if (startFrustum.equals(newFrustum))\n return;\n\n vp.view.setupFromFrustum(newFrustum);\n vp.synchWithView();\n vp.animateFrustumChange();\n }\n\n /** Opens the marker's drawing view in the decorator's viewport. Returns false if the drawing view could not be loaded. */\n public async openSection(marker: SectionMarker): Promise<boolean> {\n const viewState = await marker.state.tryLoadDrawingView();\n if (viewState)\n this.viewport.changeView(viewState);\n\n return undefined !== viewState;\n }\n\n /** Opens marker's sheet view in the decorator's viewport and zooms in on the associated [ViewAttachment]($backend). Returns false if no view\n * attachment exists or the sheet view could not be loaded.\n */\n public async openSheet(marker: SectionMarker): Promise<boolean> {\n if (undefined === marker.state.viewAttachment)\n return false;\n\n const viewState = await marker.state.tryLoadSheetView();\n if (!viewState)\n return false;\n\n this.viewport.changeView(viewState);\n await this.viewport.zoomToElements(marker.state.viewAttachment.id);\n return true;\n }\n\n /** Aligns the view to match the frustum of the spatial view associated with the specified marker.\n * @param marker The marker whose spatial view's frustum should be applied.\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.\n * @see [[alignView]] to align to the *section plane*, which may differ.\n * @see [[toggleSection]] to also apply the clip volume.\n */\n public async alignToSpatialView(marker: SectionMarker): Promise<boolean> {\n if (!this.viewport.view.is3d())\n return false;\n\n const spatialView = await marker.state.tryLoadSpatialView();\n if (!spatialView)\n return false;\n\n this.viewport.view.setOrigin(spatialView.getOrigin());\n this.viewport.view.setExtents(spatialView.getExtents());\n this.viewport.view.setRotation(spatialView.getRotation());\n this.viewport.synchWithView({ animateFrustumChange: true });\n\n return true;\n }\n\n /** Applies the marker's spatial view - including its clip volume - to the decorator's viewport.\n * Returns false if the spatial view could not be loaded.\n * @see [[toggleSection]].\n * @see [[toggleClipVolume]].\n */\n public async applySpatialView(marker: SectionMarker): Promise<boolean> {\n const viewState = await marker.state.tryLoadSpatialView();\n if (viewState) {\n this._appliedSpatialView = viewState;\n this.viewport.changeView(viewState);\n }\n\n return undefined !== viewState;\n }\n\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\n * this method when the criteria governing your `isMarkerVisible` method have changed.\n */\n public requestSync(): void {\n if (this.syncImmediately) {\n this.sync();\n } else if (!this._needSync) {\n this._needSync = true;\n requestAnimationFrame(() => this.sync());\n }\n }\n\n private sync(): void {\n this._needSync = false;\n if (HyperModeling.isInitialized && this.viewport.view.is3d() && this.updateMarkerVisibility()) {\n this.markers.markDirty();\n this.viewport.invalidateCachedDecorations(this);\n }\n }\n\n private isMarkerVisible(marker: SectionMarker): boolean {\n if (undefined !== this.activeMarker)\n return marker === this.activeMarker;\n\n return HyperModeling.markerHandler.isMarkerVisible(marker, this, this._config);\n }\n\n private updateMarkerVisibility(): boolean {\n let changed = false;\n for (const marker of this.markers.markers) {\n const wasVisible = marker.visible;\n marker.visible = this.isMarkerVisible(marker);\n changed = changed || (marker.visible !== wasVisible);\n }\n\n return changed;\n }\n}\n"]}
|
package/lib/cjs/PopupToolbar.js
CHANGED
|
@@ -11,6 +11,8 @@ exports.PopupToolbarManager = void 0;
|
|
|
11
11
|
const core_frontend_1 = require("@itwin/core-frontend");
|
|
12
12
|
/** @internal */
|
|
13
13
|
class PopupToolbarManager {
|
|
14
|
+
static _provider;
|
|
15
|
+
static _current;
|
|
14
16
|
static show() {
|
|
15
17
|
const prov = this._provider;
|
|
16
18
|
if (!prov || !prov.overToolbarHotspot)
|
|
@@ -23,6 +25,17 @@ class PopupToolbarManager {
|
|
|
23
25
|
this.closeAfterTimeout();
|
|
24
26
|
return true;
|
|
25
27
|
}
|
|
28
|
+
static _itemExecuted = (item) => {
|
|
29
|
+
const mgr = PopupToolbarManager;
|
|
30
|
+
if (mgr._current)
|
|
31
|
+
mgr._current.onToolbarItemExecuted(item.id);
|
|
32
|
+
mgr.close();
|
|
33
|
+
};
|
|
34
|
+
static _cancel = () => {
|
|
35
|
+
const mgr = PopupToolbarManager;
|
|
36
|
+
if (!mgr._current || !mgr._current.overToolbarHotspot)
|
|
37
|
+
mgr.close(); // Don't hide when click is over hotspot
|
|
38
|
+
};
|
|
26
39
|
static close() {
|
|
27
40
|
this._current = undefined;
|
|
28
41
|
return core_frontend_1.IModelApp.uiAdmin.hideToolbar();
|
|
@@ -44,15 +57,4 @@ class PopupToolbarManager {
|
|
|
44
57
|
}
|
|
45
58
|
}
|
|
46
59
|
exports.PopupToolbarManager = PopupToolbarManager;
|
|
47
|
-
PopupToolbarManager._itemExecuted = (item) => {
|
|
48
|
-
const mgr = PopupToolbarManager;
|
|
49
|
-
if (mgr._current)
|
|
50
|
-
mgr._current.onToolbarItemExecuted(item.id);
|
|
51
|
-
mgr.close();
|
|
52
|
-
};
|
|
53
|
-
PopupToolbarManager._cancel = () => {
|
|
54
|
-
const mgr = PopupToolbarManager;
|
|
55
|
-
if (!mgr._current || !mgr._current.overToolbarHotspot)
|
|
56
|
-
mgr.close(); // Don't hide when click is over hotspot
|
|
57
|
-
};
|
|
58
60
|
//# 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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C,IAAI,CAAC,GAAG,CAAC,QAAQ,IAAI,CAAC,GAAG,CAAC,QAAQ,CAAC,kBAAkB;YACnD,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC,wCAAwC;IACzD,CAAC,CAAC;IAEM,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","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module HyperModeling\n */\n\nimport { XAndY } from \"@itwin/core-geometry\";\nimport type { AbstractToolbarProps } from \"@itwin/appui-abstract\";\nimport { IModelApp } from \"@itwin/core-frontend\";\n\n/** @internal */\nexport interface PopupToolbarProvider {\n toolbarProps: AbstractToolbarProps;\n overToolbarHotspot: boolean;\n toolbarLocation: XAndY;\n htmlElement: HTMLElement | undefined;\n onToolbarItemExecuted(id: string): void;\n}\n\n/** @internal */\nexport class PopupToolbarManager {\n private static _provider?: PopupToolbarProvider;\n private static _current?: PopupToolbarProvider;\n\n private static show(): boolean {\n const prov = this._provider;\n if (!prov || !prov.overToolbarHotspot)\n return false;\n\n const admin = IModelApp.uiAdmin;\n if (!admin.showToolbar(prov.toolbarProps, prov.toolbarLocation, { x: 0, y: 0 }, this._itemExecuted, this._cancel, undefined, prov.htmlElement))\n return false;\n\n this._current = this._provider;\n this._provider = undefined;\n this.closeAfterTimeout();\n return true;\n }\n\n private static _itemExecuted = (item: any) => {\n const mgr = PopupToolbarManager;\n if (mgr._current)\n mgr._current.onToolbarItemExecuted(item.id);\n\n mgr.close();\n };\n\n private static _cancel = () => {\n const mgr = PopupToolbarManager;\n if (!mgr._current || !mgr._current.overToolbarHotspot)\n mgr.close(); // Don't hide when click is over hotspot\n };\n\n private static close(): boolean {\n this._current = undefined;\n return IModelApp.uiAdmin.hideToolbar();\n }\n\n private static closeAfterTimeout(): void {\n if (!this._current)\n return;\n\n const delay = 1000;\n if (this._current.overToolbarHotspot || !IModelApp.toolAdmin.cursorView)\n setTimeout(() => this.closeAfterTimeout(), delay); // Cursor not in view or over hotspot, check again\n else\n this.close();\n }\n\n public static showToolbarAfterTimeout(provider: PopupToolbarProvider): void {\n if (this._current === provider)\n return;\n\n this._provider = provider;\n setTimeout(() => this.show(), 500);\n }\n}\n"]}
|
|
@@ -46,6 +46,34 @@ const selectSectionDrawingLocationStatesECSql = `
|
|
|
46
46
|
* @public
|
|
47
47
|
*/
|
|
48
48
|
class SectionDrawingLocationState {
|
|
49
|
+
/** The iModel in which this section drawing location resides. */
|
|
50
|
+
iModel;
|
|
51
|
+
/** The element Id of the section drawing location. */
|
|
52
|
+
id;
|
|
53
|
+
/** The Id of the [GeometricModel3d]($backend) in which this section drawing location resides. */
|
|
54
|
+
model;
|
|
55
|
+
/** A user-friendly label for the section drawing location. */
|
|
56
|
+
userLabel;
|
|
57
|
+
/** The Id of the [SpatialCategory]($backend) to which this section drawing location belongs. */
|
|
58
|
+
category;
|
|
59
|
+
/** The section drawing location's spatial placement. */
|
|
60
|
+
placement;
|
|
61
|
+
/** The type of section that generated the associated [SectionDrawing]($backend). */
|
|
62
|
+
sectionType;
|
|
63
|
+
/** The Id of the [ViewDefinition]($backend) that can display the section graphics. */
|
|
64
|
+
drawingViewId;
|
|
65
|
+
/** The Id of the [SpatialViewDefinition]($backend) from which the section drawing was generated. */
|
|
66
|
+
spatialViewId;
|
|
67
|
+
/** The section clip from the [SpatialViewDefinition]($backend) from which the section drawing was generated. */
|
|
68
|
+
clip;
|
|
69
|
+
/** The transform from the [GeometricModel]($backend) containing the section graphics to the spatial coordinate space.
|
|
70
|
+
* This is used to position the 2d graphics in the context of a spatial view.
|
|
71
|
+
*/
|
|
72
|
+
drawingToSpatialTransform;
|
|
73
|
+
/** If the section drawing is attached to a [Sheet]($backend), details about the corresponding [ViewAttachment]($backend).
|
|
74
|
+
* When this section drawing location is displayed in a spatial context, annotations in the sheet model can be displayed along with the section graphics.
|
|
75
|
+
*/
|
|
76
|
+
viewAttachment;
|
|
49
77
|
/** @internal */
|
|
50
78
|
constructor(props, iModel) {
|
|
51
79
|
this.iModel = iModel;
|
|
@@ -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,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S,KAAK,IAAI,CAAC,cAAc,CAAC,MAAM;YAC/E,OAAO,SAAS,CAAC;QAEnB,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,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":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module HyperModeling\n */\n\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { Placement3d, QueryRowFormat, SectionType } from \"@itwin/core-common\";\nimport { DrawingViewState, IModelConnection, SheetViewState, SpatialViewState } from \"@itwin/core-frontend\";\nimport { ClipVector, Transform, XYZProps } from \"@itwin/core-geometry\";\n\nconst selectSectionDrawingLocationStatesECSql = `\n SELECT\n bis.SectionDrawingLocation.ECInstanceId as sectionLocationId,\n bis.SectionDrawingLocation.Model.Id as sectionLocationModelId,\n bis.SectionDrawingLocation.SectionView.Id as sectionViewId,\n bis.SectionDrawingLocation.Category.Id as categoryId,\n bis.SectionDrawingLocation.Origin as origin,\n bis.SectionDrawingLocation.Yaw as yaw,\n bis.SectionDrawingLocation.Pitch as pitch,\n bis.SectionDrawingLocation.Roll as roll,\n bis.SectionDrawingLocation.BBoxLow as bboxLow,\n bis.SectionDrawingLocation.BBoxHigh as bboxHigh,\n bis.SectionDrawingLocation.UserLabel as userLabel,\n\n bis.SectionDrawing.SectionType as sectionType,\n json_extract(bis.SectionDrawing.jsonProperties, '$.drawingToSpatialTransform') as drawingToSpatialTransform,\n bis.SectionDrawing.SpatialView.Id as spatialViewId,\n json_extract(bis.SectionDrawing.jsonProperties, '$.sheetToSpatialTransform') as sheetToSpatialTransform,\n json_extract(bis.SectionDrawing.jsonProperties, '$.drawingBoundaryClip') as sheetClip,\n\n json_extract(bis.SpatialViewDefinition.jsonProperties, '$.viewDetails.clip') as clipJSON,\n bis.ViewAttachment.ECInstanceId as viewAttachmentId,\n bis.SheetViewDefinition.ECInstanceId as sheetViewId\n FROM bis.SectionDrawingLocation\n INNER JOIN bis.ViewDefinition2d on bis.SectionDrawingLocation.SectionView.Id = bis.ViewDefinition2d.ECInstanceId\n INNER JOIN bis.SectionDrawing on bis.ViewDefinition2d.BaseModel.Id = bis.SectionDrawing.ECInstanceId\n LEFT JOIN bis.ViewAttachment on bis.ViewDefinition2d.ECInstanceId = bis.ViewAttachment.View.Id\n LEFT JOIN bis.SheetViewDefinition on bis.SheetViewDefinition.BaseModel.Id = bis.ViewAttachment.Model.Id\n INNER JOIN bis.SpatialViewDefinition on bis.SpatialViewDefinition.ECInstanceId = bis.SectionDrawing.SpatialView.Id\n`;\n\n/** Raw data representing a [[SectionDrawingLocationState]]. This is an amalgamation of data from several related ECClasses.\n * @internal\n */\nexport interface SectionDrawingLocationStateData {\n sectionType: SectionType;\n drawingToSpatialTransform: string; // stringified TransformProps\n spatialViewId: Id64String;\n clipJSON?: string; // stringified ClipVector json\n viewAttachmentId?: Id64String;\n sheetToSpatialTransform?: string; // stringified TransformProps\n sheetClip?: string; // stringified ClipVector json\n sheetViewId?: Id64String;\n\n sectionLocationId: Id64String;\n sectionLocationModelId: Id64String;\n sectionViewId: Id64String;\n categoryId: Id64String;\n origin?: XYZProps;\n yaw?: number;\n pitch?: number;\n roll?: number;\n bboxLow?: XYZProps;\n bboxHigh?: XYZProps;\n userLabel: string;\n}\n\n/** Represents a [ViewAttachment]($backend) that attaches a [[SectionDrawingLocationState]] to a [Sheet]($backend) model.\n * @public\n */\nexport interface SectionViewAttachment {\n /** The view attachment's element Id. */\n readonly id: Id64String;\n /** The Id of a [SheetViewDefinition]($backend) that displays this view attachment.\n * This is used when navigating from the spatial view to the view attachment.\n */\n readonly viewId?: Id64String;\n /** The transform from the [Sheet]($backend) coordinate space to the spatial coordinate space. */\n readonly transformToSpatial: Transform;\n /** Optional 2d clip vector used to clip out portions of the [Sheet]($backend) containing annotations not relevant to this section drawing. */\n readonly clip?: ClipVector;\n}\n\n/** Represents a [SectionDrawingLocation]($backend), including data from related elements like [SectionDrawing]($backend) used in a hyper-modeling context.\n * @see [[SectionMarker]] for a widget that allows the user to interact with a section drawing location.\n * @public\n */\nexport class SectionDrawingLocationState {\n /** The iModel in which this section drawing location resides. */\n public readonly iModel: IModelConnection;\n /** The element Id of the section drawing location. */\n public readonly id: Id64String;\n /** The Id of the [GeometricModel3d]($backend) in which this section drawing location resides. */\n public readonly model: Id64String;\n /** A user-friendly label for the section drawing location. */\n public readonly userLabel: string;\n /** The Id of the [SpatialCategory]($backend) to which this section drawing location belongs. */\n public readonly category: Id64String;\n /** The section drawing location's spatial placement. */\n public readonly placement: Placement3d;\n /** The type of section that generated the associated [SectionDrawing]($backend). */\n public readonly sectionType: SectionType;\n /** The Id of the [ViewDefinition]($backend) that can display the section graphics. */\n public readonly drawingViewId: Id64String;\n /** The Id of the [SpatialViewDefinition]($backend) from which the section drawing was generated. */\n public readonly spatialViewId: Id64String;\n /** The section clip from the [SpatialViewDefinition]($backend) from which the section drawing was generated. */\n public readonly clip: ClipVector;\n /** The transform from the [GeometricModel]($backend) containing the section graphics to the spatial coordinate space.\n * This is used to position the 2d graphics in the context of a spatial view.\n */\n public readonly drawingToSpatialTransform: Transform;\n /** If the section drawing is attached to a [Sheet]($backend), details about the corresponding [ViewAttachment]($backend).\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.\n */\n public readonly viewAttachment?: SectionViewAttachment;\n\n /** @internal */\n public constructor(props: SectionDrawingLocationStateData, iModel: IModelConnection) {\n this.iModel = iModel;\n this.id = props.sectionLocationId;\n this.model = props.sectionLocationModelId;\n this.userLabel = props.userLabel;\n this.category = props.categoryId;\n this.sectionType = props.sectionType;\n this.drawingViewId = props.sectionViewId;\n this.spatialViewId = props.spatialViewId;\n this.drawingToSpatialTransform = Transform.fromJSON(JSON.parse(props.drawingToSpatialTransform));\n\n const extractClip = (str: string | undefined) => {\n let clip;\n if (str) {\n try {\n clip = ClipVector.fromJSON(JSON.parse(str));\n } catch { }\n }\n\n return clip;\n };\n\n this.clip = extractClip(props.clipJSON) ?? ClipVector.createEmpty();\n\n const placementProps = {\n origin: props.origin ?? {},\n angles: {\n yaw: props.yaw,\n pitch: props.pitch,\n roll: props.roll,\n },\n placement: (props.bboxLow && props.bboxHigh) ? { low: props.bboxLow, high: props.bboxHigh } : undefined,\n };\n this.placement = Placement3d.fromJSON(placementProps);\n\n if (props.viewAttachmentId && props.sheetToSpatialTransform) {\n this.viewAttachment = {\n id: props.viewAttachmentId,\n transformToSpatial: Transform.fromJSON(JSON.parse(props.sheetToSpatialTransform)),\n clip: extractClip(props.sheetClip),\n viewId: props.sheetViewId,\n };\n }\n }\n\n /** Return a promise that resolves to the [DrawingViewState]($frontend) corresponding to `this.drawingViewId`, or undefined if an exception occurs. */\n public async tryLoadDrawingView(): Promise<DrawingViewState | undefined> {\n try {\n const view = await this.iModel.views.load(this.drawingViewId);\n if (view instanceof DrawingViewState)\n return view;\n } catch { }\n\n return undefined;\n }\n\n /** Return a promise that resolves to the [SpatialViewState]($frontend) corresponding to `this.spatialViewId`, or undefined if an exception occurs. */\n public async tryLoadSpatialView(): Promise<SpatialViewState | undefined> {\n try {\n const view = await this.iModel.views.load(this.spatialViewId);\n if (view instanceof SpatialViewState)\n return view;\n } catch { }\n\n return undefined;\n }\n\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. */\n public async tryLoadSheetView(): Promise<SheetViewState | undefined> {\n if (undefined === this.viewAttachment || undefined === this.viewAttachment.viewId)\n return undefined;\n\n try {\n const view = await this.iModel.views.load(this.viewAttachment.viewId);\n if (view instanceof SheetViewState)\n return view;\n } catch { }\n\n return undefined;\n }\n\n /** Query the specified iModel for [SectionDrawingLocation]($backend)s and return a list of corresponding [[SectionDrawingLocationState]]s. */\n public static async queryAll(iModel: IModelConnection): Promise<SectionDrawingLocationState[]> {\n const states: SectionDrawingLocationState[] = [];\n try {\n for await (const row of iModel.createQueryReader(selectSectionDrawingLocationStatesECSql, undefined, { rowFormat: QueryRowFormat.UseJsPropertyNames }))\n states.push(new SectionDrawingLocationState(row.toRow() as SectionDrawingLocationStateData, iModel));\n } catch {\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.\n }\n\n return states;\n }\n}\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;I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CAAC;QAAC,MAAM,CAAC;YACP,sKAAsK;QACxK,CAAC;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA5HD,kEA4HC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module HyperModeling\n */\n\nimport { Id64String } from \"@itwin/core-bentley\";\nimport { Placement3d, QueryRowFormat, SectionType } from \"@itwin/core-common\";\nimport { DrawingViewState, IModelConnection, SheetViewState, SpatialViewState } from \"@itwin/core-frontend\";\nimport { ClipVector, Transform, XYZProps } from \"@itwin/core-geometry\";\n\nconst selectSectionDrawingLocationStatesECSql = `\n SELECT\n bis.SectionDrawingLocation.ECInstanceId as sectionLocationId,\n bis.SectionDrawingLocation.Model.Id as sectionLocationModelId,\n bis.SectionDrawingLocation.SectionView.Id as sectionViewId,\n bis.SectionDrawingLocation.Category.Id as categoryId,\n bis.SectionDrawingLocation.Origin as origin,\n bis.SectionDrawingLocation.Yaw as yaw,\n bis.SectionDrawingLocation.Pitch as pitch,\n bis.SectionDrawingLocation.Roll as roll,\n bis.SectionDrawingLocation.BBoxLow as bboxLow,\n bis.SectionDrawingLocation.BBoxHigh as bboxHigh,\n bis.SectionDrawingLocation.UserLabel as userLabel,\n\n bis.SectionDrawing.SectionType as sectionType,\n json_extract(bis.SectionDrawing.jsonProperties, '$.drawingToSpatialTransform') as drawingToSpatialTransform,\n bis.SectionDrawing.SpatialView.Id as spatialViewId,\n json_extract(bis.SectionDrawing.jsonProperties, '$.sheetToSpatialTransform') as sheetToSpatialTransform,\n json_extract(bis.SectionDrawing.jsonProperties, '$.drawingBoundaryClip') as sheetClip,\n\n json_extract(bis.SpatialViewDefinition.jsonProperties, '$.viewDetails.clip') as clipJSON,\n bis.ViewAttachment.ECInstanceId as viewAttachmentId,\n bis.SheetViewDefinition.ECInstanceId as sheetViewId\n FROM bis.SectionDrawingLocation\n INNER JOIN bis.ViewDefinition2d on bis.SectionDrawingLocation.SectionView.Id = bis.ViewDefinition2d.ECInstanceId\n INNER JOIN bis.SectionDrawing on bis.ViewDefinition2d.BaseModel.Id = bis.SectionDrawing.ECInstanceId\n LEFT JOIN bis.ViewAttachment on bis.ViewDefinition2d.ECInstanceId = bis.ViewAttachment.View.Id\n LEFT JOIN bis.SheetViewDefinition on bis.SheetViewDefinition.BaseModel.Id = bis.ViewAttachment.Model.Id\n INNER JOIN bis.SpatialViewDefinition on bis.SpatialViewDefinition.ECInstanceId = bis.SectionDrawing.SpatialView.Id\n`;\n\n/** Raw data representing a [[SectionDrawingLocationState]]. This is an amalgamation of data from several related ECClasses.\n * @internal\n */\nexport interface SectionDrawingLocationStateData {\n sectionType: SectionType;\n drawingToSpatialTransform: string; // stringified TransformProps\n spatialViewId: Id64String;\n clipJSON?: string; // stringified ClipVector json\n viewAttachmentId?: Id64String;\n sheetToSpatialTransform?: string; // stringified TransformProps\n sheetClip?: string; // stringified ClipVector json\n sheetViewId?: Id64String;\n\n sectionLocationId: Id64String;\n sectionLocationModelId: Id64String;\n sectionViewId: Id64String;\n categoryId: Id64String;\n origin?: XYZProps;\n yaw?: number;\n pitch?: number;\n roll?: number;\n bboxLow?: XYZProps;\n bboxHigh?: XYZProps;\n userLabel: string;\n}\n\n/** Represents a [ViewAttachment]($backend) that attaches a [[SectionDrawingLocationState]] to a [Sheet]($backend) model.\n * @public\n */\nexport interface SectionViewAttachment {\n /** The view attachment's element Id. */\n readonly id: Id64String;\n /** The Id of a [SheetViewDefinition]($backend) that displays this view attachment.\n * This is used when navigating from the spatial view to the view attachment.\n */\n readonly viewId?: Id64String;\n /** The transform from the [Sheet]($backend) coordinate space to the spatial coordinate space. */\n readonly transformToSpatial: Transform;\n /** Optional 2d clip vector used to clip out portions of the [Sheet]($backend) containing annotations not relevant to this section drawing. */\n readonly clip?: ClipVector;\n}\n\n/** Represents a [SectionDrawingLocation]($backend), including data from related elements like [SectionDrawing]($backend) used in a hyper-modeling context.\n * @see [[SectionMarker]] for a widget that allows the user to interact with a section drawing location.\n * @public\n */\nexport class SectionDrawingLocationState {\n /** The iModel in which this section drawing location resides. */\n public readonly iModel: IModelConnection;\n /** The element Id of the section drawing location. */\n public readonly id: Id64String;\n /** The Id of the [GeometricModel3d]($backend) in which this section drawing location resides. */\n public readonly model: Id64String;\n /** A user-friendly label for the section drawing location. */\n public readonly userLabel: string;\n /** The Id of the [SpatialCategory]($backend) to which this section drawing location belongs. */\n public readonly category: Id64String;\n /** The section drawing location's spatial placement. */\n public readonly placement: Placement3d;\n /** The type of section that generated the associated [SectionDrawing]($backend). */\n public readonly sectionType: SectionType;\n /** The Id of the [ViewDefinition]($backend) that can display the section graphics. */\n public readonly drawingViewId: Id64String;\n /** The Id of the [SpatialViewDefinition]($backend) from which the section drawing was generated. */\n public readonly spatialViewId: Id64String;\n /** The section clip from the [SpatialViewDefinition]($backend) from which the section drawing was generated. */\n public readonly clip: ClipVector;\n /** The transform from the [GeometricModel]($backend) containing the section graphics to the spatial coordinate space.\n * This is used to position the 2d graphics in the context of a spatial view.\n */\n public readonly drawingToSpatialTransform: Transform;\n /** If the section drawing is attached to a [Sheet]($backend), details about the corresponding [ViewAttachment]($backend).\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.\n */\n public readonly viewAttachment?: SectionViewAttachment;\n\n /** @internal */\n public constructor(props: SectionDrawingLocationStateData, iModel: IModelConnection) {\n this.iModel = iModel;\n this.id = props.sectionLocationId;\n this.model = props.sectionLocationModelId;\n this.userLabel = props.userLabel;\n this.category = props.categoryId;\n this.sectionType = props.sectionType;\n this.drawingViewId = props.sectionViewId;\n this.spatialViewId = props.spatialViewId;\n this.drawingToSpatialTransform = Transform.fromJSON(JSON.parse(props.drawingToSpatialTransform));\n\n const extractClip = (str: string | undefined) => {\n let clip;\n if (str) {\n try {\n clip = ClipVector.fromJSON(JSON.parse(str));\n } catch { }\n }\n\n return clip;\n };\n\n this.clip = extractClip(props.clipJSON) ?? ClipVector.createEmpty();\n\n const placementProps = {\n origin: props.origin ?? {},\n angles: {\n yaw: props.yaw,\n pitch: props.pitch,\n roll: props.roll,\n },\n placement: (props.bboxLow && props.bboxHigh) ? { low: props.bboxLow, high: props.bboxHigh } : undefined,\n };\n this.placement = Placement3d.fromJSON(placementProps);\n\n if (props.viewAttachmentId && props.sheetToSpatialTransform) {\n this.viewAttachment = {\n id: props.viewAttachmentId,\n transformToSpatial: Transform.fromJSON(JSON.parse(props.sheetToSpatialTransform)),\n clip: extractClip(props.sheetClip),\n viewId: props.sheetViewId,\n };\n }\n }\n\n /** Return a promise that resolves to the [DrawingViewState]($frontend) corresponding to `this.drawingViewId`, or undefined if an exception occurs. */\n public async tryLoadDrawingView(): Promise<DrawingViewState | undefined> {\n try {\n const view = await this.iModel.views.load(this.drawingViewId);\n if (view instanceof DrawingViewState)\n return view;\n } catch { }\n\n return undefined;\n }\n\n /** Return a promise that resolves to the [SpatialViewState]($frontend) corresponding to `this.spatialViewId`, or undefined if an exception occurs. */\n public async tryLoadSpatialView(): Promise<SpatialViewState | undefined> {\n try {\n const view = await this.iModel.views.load(this.spatialViewId);\n if (view instanceof SpatialViewState)\n return view;\n } catch { }\n\n return undefined;\n }\n\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. */\n public async tryLoadSheetView(): Promise<SheetViewState | undefined> {\n if (undefined === this.viewAttachment || undefined === this.viewAttachment.viewId)\n return undefined;\n\n try {\n const view = await this.iModel.views.load(this.viewAttachment.viewId);\n if (view instanceof SheetViewState)\n return view;\n } catch { }\n\n return undefined;\n }\n\n /** Query the specified iModel for [SectionDrawingLocation]($backend)s and return a list of corresponding [[SectionDrawingLocationState]]s. */\n public static async queryAll(iModel: IModelConnection): Promise<SectionDrawingLocationState[]> {\n const states: SectionDrawingLocationState[] = [];\n try {\n for await (const row of iModel.createQueryReader(selectSectionDrawingLocationStatesECSql, undefined, { rowFormat: QueryRowFormat.UseJsPropertyNames }))\n states.push(new SectionDrawingLocationState(row.toRow() as SectionDrawingLocationStateData, iModel));\n } catch {\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.\n }\n\n return states;\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SectionGraphicsProvider.d.ts","sourceRoot":"","sources":["../../src/SectionGraphicsProvider.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,EAE+J,qBAAqB,EAE1L,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;
|
|
1
|
+
{"version":3,"file":"SectionGraphicsProvider.d.ts","sourceRoot":"","sources":["../../src/SectionGraphicsProvider.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,EAE+J,qBAAqB,EAE1L,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAsU5E;;;;;;GAMG;AACH,wBAAsB,6BAA6B,CAAC,KAAK,EAAE,2BAA2B,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAStH"}
|