@itwin/hypermodeling-frontend 3.7.17 → 3.8.0

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.
Files changed (59) hide show
  1. package/CHANGELOG.md +6 -1
  2. package/lib/cjs/HyperModeling.d.ts +114 -114
  3. package/lib/cjs/HyperModeling.js +240 -240
  4. package/lib/cjs/HyperModelingConfig.d.ts +54 -54
  5. package/lib/cjs/HyperModelingConfig.js +9 -9
  6. package/lib/cjs/HyperModelingConfig.js.map +1 -1
  7. package/lib/cjs/HyperModelingDecorator.d.ts +110 -110
  8. package/lib/cjs/HyperModelingDecorator.js +337 -337
  9. package/lib/cjs/HyperModelingDecorator.js.map +1 -1
  10. package/lib/cjs/PopupToolbar.d.ts +24 -24
  11. package/lib/cjs/PopupToolbar.js +57 -57
  12. package/lib/cjs/PopupToolbar.js.map +1 -1
  13. package/lib/cjs/SectionDrawingLocationState.d.ts +90 -90
  14. package/lib/cjs/SectionDrawingLocationState.js +137 -137
  15. package/lib/cjs/SectionDrawingLocationState.js.map +1 -1
  16. package/lib/cjs/SectionGraphicsProvider.d.ts +13 -13
  17. package/lib/cjs/SectionGraphicsProvider.js +273 -273
  18. package/lib/cjs/SectionGraphicsProvider.js.map +1 -1
  19. package/lib/cjs/SectionMarkerHandler.d.ts +52 -52
  20. package/lib/cjs/SectionMarkerHandler.js +112 -112
  21. package/lib/cjs/SectionMarkerHandler.js.map +1 -1
  22. package/lib/cjs/SectionMarkers.d.ts +82 -82
  23. package/lib/cjs/SectionMarkers.js +174 -174
  24. package/lib/cjs/SectionMarkers.js.map +1 -1
  25. package/lib/cjs/Tools.d.ts +5 -5
  26. package/lib/cjs/Tools.js +170 -170
  27. package/lib/cjs/hypermodeling-frontend.d.ts +13 -13
  28. package/lib/cjs/hypermodeling-frontend.js +29 -29
  29. package/lib/cjs/hypermodeling-frontend.js.map +1 -1
  30. package/lib/esm/HyperModeling.d.ts +114 -114
  31. package/lib/esm/HyperModeling.js +236 -236
  32. package/lib/esm/HyperModelingConfig.d.ts +54 -54
  33. package/lib/esm/HyperModelingConfig.js +8 -8
  34. package/lib/esm/HyperModelingConfig.js.map +1 -1
  35. package/lib/esm/HyperModelingDecorator.d.ts +110 -110
  36. package/lib/esm/HyperModelingDecorator.js +333 -333
  37. package/lib/esm/HyperModelingDecorator.js.map +1 -1
  38. package/lib/esm/PopupToolbar.d.ts +24 -24
  39. package/lib/esm/PopupToolbar.js +53 -53
  40. package/lib/esm/PopupToolbar.js.map +1 -1
  41. package/lib/esm/SectionDrawingLocationState.d.ts +90 -90
  42. package/lib/esm/SectionDrawingLocationState.js +133 -133
  43. package/lib/esm/SectionDrawingLocationState.js.map +1 -1
  44. package/lib/esm/SectionGraphicsProvider.d.ts +13 -13
  45. package/lib/esm/SectionGraphicsProvider.js +269 -269
  46. package/lib/esm/SectionGraphicsProvider.js.map +1 -1
  47. package/lib/esm/SectionMarkerHandler.d.ts +52 -52
  48. package/lib/esm/SectionMarkerHandler.js +108 -108
  49. package/lib/esm/SectionMarkerHandler.js.map +1 -1
  50. package/lib/esm/SectionMarkers.d.ts +82 -82
  51. package/lib/esm/SectionMarkers.js +168 -168
  52. package/lib/esm/SectionMarkers.js.map +1 -1
  53. package/lib/esm/Tools.d.ts +5 -5
  54. package/lib/esm/Tools.js +166 -166
  55. package/lib/esm/hypermodeling-frontend.d.ts +13 -13
  56. package/lib/esm/hypermodeling-frontend.js +17 -17
  57. package/lib/esm/hypermodeling-frontend.js.map +1 -1
  58. package/lib/public/locales/en/HyperModeling.json +32 -32
  59. package/package.json +13 -13
@@ -1,237 +1,237 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
5
- /** @packageDocumentation
6
- * @module HyperModeling
7
- */
8
- import { assert } from "@itwin/core-bentley";
9
- import { SectionType } from "@itwin/core-common";
10
- import { IModelApp, tryImageElementFromUrl, ViewManip } from "@itwin/core-frontend";
11
- import { registerTools } from "./Tools";
12
- import { HyperModelingDecorator } from "./HyperModelingDecorator";
13
- import { SectionMarkerHandler } from "./SectionMarkerHandler";
14
- function assertInitialized(maybe) {
15
- if (undefined === maybe.resources)
16
- throw new Error("You must call HyperModeling.initialize before using the hypermodeling package");
17
- }
18
- /** The API entry point for the hypermodeling package. Applications must call [[initialize]] and await the result before using the package.
19
- * The behavior of the package can be customized via a [[HyperModelingConfig]] supplied to [[initialize]], [[updateConfiguration]], or [[replaceConfiguration]].
20
- * Hypermodeling mode can be enabled or disabled via [[startOrStop]], which returns a [[HyperModelingDecorator]] when enabling hypermodeling.
21
- * Consult the package's `README.md` for a description of the available functionality.
22
- * @public
23
- */
24
- export class HyperModeling {
25
- static shutdown() {
26
- this.resources = undefined;
27
- this._markerHandler = undefined;
28
- this._markerConfig = {};
29
- this._graphicsConfig = {};
30
- }
31
- /** Returns whether the hypermodeling package is initialized.
32
- * @see [[HyperModeling.initialize]] to initialize the package.
33
- */
34
- static get isInitialized() {
35
- return undefined !== this.resources;
36
- }
37
- /** Invoke this method to initialize the hypermodeling package for use. You *must* await the result before using any of this package's APIs.
38
- * Typically an application would invoke this after [IModelApp.startup]($frontend), e.g.,
39
- * ```ts
40
- * await IModelApp.startup();
41
- * await HyperModeling.initialize();
42
- * ```
43
- * Calling this method again after the first initialization behaves the same as calling [[HyperModeling.replaceConfiguration]].
44
- * @note The hypermodeling package will be reset to uninitialized after [IModelApp.shutdown]($frontend) is invoked.
45
- * @see [[replaceConfiguration]] and [[updateConfiguration]] to modify the configuration after initialization.
46
- */
47
- static async initialize(config) {
48
- if (undefined !== this.resources) {
49
- this.replaceConfiguration(config);
50
- return;
51
- }
52
- // clean up if we're being shut down
53
- IModelApp.onBeforeShutdown.addListener(() => this.shutdown());
54
- const namespace = "HyperModeling";
55
- await IModelApp.localization.registerNamespace(namespace);
56
- const loadImages = [
57
- tryImageElementFromUrl(`${IModelApp.publicPath}section-marker.svg`),
58
- tryImageElementFromUrl(`${IModelApp.publicPath}detail-marker.svg`),
59
- tryImageElementFromUrl(`${IModelApp.publicPath}elevation-marker.svg`),
60
- tryImageElementFromUrl(`${IModelApp.publicPath}plan-marker.svg`),
61
- ];
62
- const images = await Promise.all(loadImages);
63
- this.resources = {
64
- namespace,
65
- markers: {
66
- section: { image: images[0], label: IModelApp.localization.getLocalizedString("HyperModeling:Message.SectionCallout") },
67
- detail: { image: images[1], label: IModelApp.localization.getLocalizedString("HyperModeling:Message.DetailCallout") },
68
- elevation: { image: images[2], label: IModelApp.localization.getLocalizedString("HyperModeling:Message.ElevationCallout") },
69
- plan: { image: images[3], label: IModelApp.localization.getLocalizedString("HyperModeling:Message.PlanCallout") },
70
- },
71
- };
72
- registerTools(namespace);
73
- this.replaceConfiguration(config);
74
- }
75
- static async ensureInitialized() {
76
- if (undefined === this.resources)
77
- await this.initialize();
78
- assertInitialized(this);
79
- }
80
- /** Replaces the current package configuration, overwriting all previous settings. Passing `undefined` resets all settings to defaults.
81
- * @see [[HyperModeling.updateConfiguration]] for overriding specific aspects of the configuration.
82
- */
83
- static replaceConfiguration(config) {
84
- var _a;
85
- config = config !== null && config !== void 0 ? config : {};
86
- this._markerHandler = (_a = config.markerHandler) !== null && _a !== void 0 ? _a : new SectionMarkerHandler();
87
- this._markerConfig = config.markers ? { ...config.markers } : {};
88
- this._graphicsConfig = config.graphics ? { ...config.graphics } : {};
89
- }
90
- /** Overrides specific aspects of the current package configuration. Any field that is not `undefined` will be replaced in the current configuration;
91
- * the rest will retain their current values.
92
- * @see [[HyperModeling.replaceConfiguration]].
93
- */
94
- static updateConfiguration(config) {
95
- var _a, _b, _c, _d, _e, _f, _g, _h;
96
- this._markerHandler = (_a = config.markerHandler) !== null && _a !== void 0 ? _a : this._markerHandler;
97
- if (config.markers) {
98
- this._markerConfig = {
99
- ignoreModelSelector: (_b = config.markers.ignoreModelSelector) !== null && _b !== void 0 ? _b : this._markerConfig.ignoreModelSelector,
100
- ignoreCategorySelector: (_c = config.markers.ignoreCategorySelector) !== null && _c !== void 0 ? _c : this._markerConfig.ignoreCategorySelector,
101
- hiddenSectionTypes: (_d = config.markers.hiddenSectionTypes) !== null && _d !== void 0 ? _d : this._markerConfig.hiddenSectionTypes,
102
- };
103
- }
104
- if (config.graphics) {
105
- this._graphicsConfig = {
106
- ignoreClip: (_e = config.graphics.ignoreClip) !== null && _e !== void 0 ? _e : this._graphicsConfig.ignoreClip,
107
- debugClipVolumes: (_f = config.graphics.debugClipVolumes) !== null && _f !== void 0 ? _f : this._graphicsConfig.debugClipVolumes,
108
- hideSectionGraphics: (_g = config.graphics.hideSectionGraphics) !== null && _g !== void 0 ? _g : this._graphicsConfig.hideSectionGraphics,
109
- hideSheetAnnotations: (_h = config.graphics.hideSheetAnnotations) !== null && _h !== void 0 ? _h : this._graphicsConfig.hideSheetAnnotations,
110
- };
111
- IModelApp.viewManager.invalidateViewportScenes();
112
- }
113
- }
114
- /** The handler that defines interactions with [[SectionMarker]]s.
115
- * @see [[initialize]] to override the default handler at package initialization.
116
- * @see [[updateConfiguration]] or [[replaceConfiguration]] to change the current handler.
117
- */
118
- static get markerHandler() {
119
- assertInitialized(this);
120
- assert(undefined !== this._markerHandler);
121
- return this._markerHandler;
122
- }
123
- /** The current marker display configuration applied to any newly-created [[HyperModelingDecorator]]s.
124
- * @see [[initialize]] to override the default configuration at package initialization.
125
- * @see [[updateConfiguration]] or [[replaceConfiguration]] to change the current configuration.
126
- * @see [[HyperModelingDecorator.replaceConfiguration]] or [[HyperModelingDecorator.updateConfiguration]] to change the configuration for an existing decorator.
127
- */
128
- static get markerConfig() {
129
- return this._markerConfig;
130
- }
131
- /** This graphics options applied to graphics displayed by all [[HyperModelingDecorator]]s.
132
- * @see [[updateConfiguration]] or [[replaceConfiguration]] to change the current configuration.
133
- */
134
- static get graphicsConfig() {
135
- return this._graphicsConfig;
136
- }
137
- /** Returns true if the specified iModel contains any [SectionDrawingLocation]($backend)s. Hypermodeling is based on section drawing locations,
138
- * so if none are present, hypermodeling features are not relevant to the iModel. Attempting to use those features with such an iModel is fine,
139
- * but probably not useful.
140
- */
141
- static async isSupportedForIModel(imodel) {
142
- try {
143
- // eslint-disable-next-line deprecation/deprecation
144
- const nRows = await imodel.queryRowCount("SELECT ECInstanceId FROM bis.SectionDrawingLocation LIMIT 1");
145
- return nRows > 0;
146
- }
147
- catch {
148
- // An iModel with a version of BisCore older than 1.0.11 will produce an expected "table not found" on the SectionDrawingLocation ECClass.
149
- return false;
150
- }
151
- }
152
- /** Returns whether hypermodeling is currently enabled for the specified viewport.
153
- * @see [[startOrStop]] to enable or disable hypermodeling for a viewport.
154
- */
155
- static isEnabledForViewport(viewport) {
156
- return undefined !== HyperModelingDecorator.getForViewport(viewport);
157
- }
158
- /** Start or stop hypermodeling mode for the specified viewport.
159
- * Enabling hypermodeling registers and returns a [[HyperModelingDecorator]] to display [[SectionMarker]]s within the viewport.
160
- * Disabling hypermodeling removes that decorator.
161
- * @param viewport The hypermodeling viewport
162
- * @param start `true` to enter hypermodeling mode, `false` to exit, or `undefined` to toggle the current mode.
163
- * @returns The new decorator is hypermodeling was successfully enabled.
164
- * @note Enabling hypermodeling may fail if the viewport is not viewing a spatial model or if the viewport's iModel does not support hypermodeling.
165
- * @see [[start]] and [[stop]].
166
- * @see [[isSupportedForIModel]].
167
- */
168
- static async startOrStop(viewport, start) {
169
- // Help out the caller since we're async anyway...
170
- await this.ensureInitialized();
171
- const decorator = HyperModelingDecorator.getForViewport(viewport);
172
- if (undefined === start)
173
- start = undefined === decorator;
174
- if (start) {
175
- return this._start(viewport);
176
- }
177
- else {
178
- decorator === null || decorator === void 0 ? void 0 : decorator.dispose();
179
- return undefined;
180
- }
181
- }
182
- /** Start hypermodeling mode for the specified viewport if it is not currently enabled.
183
- * If hypermodeling is already enabled for the viewport, the existing decorator is returned; otherwise, a new decorator is created.
184
- * @param viewport The viewport for which to enable hypermodeling
185
- * @returns The decorator that implements hypermodeling features for the viewport, or `undefined` if hypermodeling could not be enabled.
186
- * @note Enabling hypermodeling may fail if the viewport is not viewing a spatial model or if the viewport's iModel does not support hypermodeling.
187
- */
188
- static async start(viewport) {
189
- await this.ensureInitialized();
190
- return this._start(viewport);
191
- }
192
- static async _start(viewport) {
193
- assertInitialized(this);
194
- if (!viewport.view.isSpatialView())
195
- return undefined;
196
- let decorator = HyperModelingDecorator.getForViewport(viewport);
197
- if (!decorator)
198
- decorator = await HyperModelingDecorator.create(viewport, this._markerConfig);
199
- if (undefined !== decorator && viewport.view.isCameraOn) {
200
- // We want the 2d graphics to align with the 3d geometry. Perspective ruins that.
201
- viewport.view.turnCameraOff();
202
- ViewManip.fitView(viewport, false, { noSaveInUndo: true });
203
- viewport.clearViewUndo();
204
- }
205
- return decorator;
206
- }
207
- /** Stop hypermodeling mode for the specified viewport if it is currently enabled. This disposes of the [[HyperModelingDecorator]] associated with the viewport.
208
- * @see [[start]] to enable hypermodeling for a viewport.
209
- * @see [[startOrStop]] to toggle hypermodeling mode.
210
- */
211
- static stop(viewport) {
212
- const decorator = HyperModelingDecorator.getForViewport(viewport);
213
- decorator === null || decorator === void 0 ? void 0 : decorator.dispose();
214
- }
215
- /** @internal */
216
- static get namespace() {
217
- assertInitialized(this);
218
- return this.resources.namespace;
219
- }
220
- /** @internal */
221
- static getMarkerData(type) {
222
- assertInitialized(this);
223
- switch (type) {
224
- case SectionType.Plan:
225
- return this.resources.markers.plan;
226
- case SectionType.Elevation:
227
- return this.resources.markers.elevation;
228
- case SectionType.Detail:
229
- return this.resources.markers.detail;
230
- default:
231
- return this.resources.markers.section;
232
- }
233
- }
234
- }
235
- HyperModeling._markerConfig = {};
236
- HyperModeling._graphicsConfig = {};
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ /** @packageDocumentation
6
+ * @module HyperModeling
7
+ */
8
+ import { assert } from "@itwin/core-bentley";
9
+ import { SectionType } from "@itwin/core-common";
10
+ import { IModelApp, tryImageElementFromUrl, ViewManip } from "@itwin/core-frontend";
11
+ import { registerTools } from "./Tools";
12
+ import { HyperModelingDecorator } from "./HyperModelingDecorator";
13
+ import { SectionMarkerHandler } from "./SectionMarkerHandler";
14
+ function assertInitialized(maybe) {
15
+ if (undefined === maybe.resources)
16
+ throw new Error("You must call HyperModeling.initialize before using the hypermodeling package");
17
+ }
18
+ /** The API entry point for the hypermodeling package. Applications must call [[initialize]] and await the result before using the package.
19
+ * The behavior of the package can be customized via a [[HyperModelingConfig]] supplied to [[initialize]], [[updateConfiguration]], or [[replaceConfiguration]].
20
+ * Hypermodeling mode can be enabled or disabled via [[startOrStop]], which returns a [[HyperModelingDecorator]] when enabling hypermodeling.
21
+ * Consult the package's `README.md` for a description of the available functionality.
22
+ * @public
23
+ */
24
+ export class HyperModeling {
25
+ static shutdown() {
26
+ this.resources = undefined;
27
+ this._markerHandler = undefined;
28
+ this._markerConfig = {};
29
+ this._graphicsConfig = {};
30
+ }
31
+ /** Returns whether the hypermodeling package is initialized.
32
+ * @see [[HyperModeling.initialize]] to initialize the package.
33
+ */
34
+ static get isInitialized() {
35
+ return undefined !== this.resources;
36
+ }
37
+ /** Invoke this method to initialize the hypermodeling package for use. You *must* await the result before using any of this package's APIs.
38
+ * Typically an application would invoke this after [IModelApp.startup]($frontend), e.g.,
39
+ * ```ts
40
+ * await IModelApp.startup();
41
+ * await HyperModeling.initialize();
42
+ * ```
43
+ * Calling this method again after the first initialization behaves the same as calling [[HyperModeling.replaceConfiguration]].
44
+ * @note The hypermodeling package will be reset to uninitialized after [IModelApp.shutdown]($frontend) is invoked.
45
+ * @see [[replaceConfiguration]] and [[updateConfiguration]] to modify the configuration after initialization.
46
+ */
47
+ static async initialize(config) {
48
+ if (undefined !== this.resources) {
49
+ this.replaceConfiguration(config);
50
+ return;
51
+ }
52
+ // clean up if we're being shut down
53
+ IModelApp.onBeforeShutdown.addListener(() => this.shutdown());
54
+ const namespace = "HyperModeling";
55
+ await IModelApp.localization.registerNamespace(namespace);
56
+ const loadImages = [
57
+ tryImageElementFromUrl(`${IModelApp.publicPath}section-marker.svg`),
58
+ tryImageElementFromUrl(`${IModelApp.publicPath}detail-marker.svg`),
59
+ tryImageElementFromUrl(`${IModelApp.publicPath}elevation-marker.svg`),
60
+ tryImageElementFromUrl(`${IModelApp.publicPath}plan-marker.svg`),
61
+ ];
62
+ const images = await Promise.all(loadImages);
63
+ this.resources = {
64
+ namespace,
65
+ markers: {
66
+ section: { image: images[0], label: IModelApp.localization.getLocalizedString("HyperModeling:Message.SectionCallout") },
67
+ detail: { image: images[1], label: IModelApp.localization.getLocalizedString("HyperModeling:Message.DetailCallout") },
68
+ elevation: { image: images[2], label: IModelApp.localization.getLocalizedString("HyperModeling:Message.ElevationCallout") },
69
+ plan: { image: images[3], label: IModelApp.localization.getLocalizedString("HyperModeling:Message.PlanCallout") },
70
+ },
71
+ };
72
+ registerTools(namespace);
73
+ this.replaceConfiguration(config);
74
+ }
75
+ static async ensureInitialized() {
76
+ if (undefined === this.resources)
77
+ await this.initialize();
78
+ assertInitialized(this);
79
+ }
80
+ /** Replaces the current package configuration, overwriting all previous settings. Passing `undefined` resets all settings to defaults.
81
+ * @see [[HyperModeling.updateConfiguration]] for overriding specific aspects of the configuration.
82
+ */
83
+ static replaceConfiguration(config) {
84
+ var _a;
85
+ config = config !== null && config !== void 0 ? config : {};
86
+ this._markerHandler = (_a = config.markerHandler) !== null && _a !== void 0 ? _a : new SectionMarkerHandler();
87
+ this._markerConfig = config.markers ? { ...config.markers } : {};
88
+ this._graphicsConfig = config.graphics ? { ...config.graphics } : {};
89
+ }
90
+ /** Overrides specific aspects of the current package configuration. Any field that is not `undefined` will be replaced in the current configuration;
91
+ * the rest will retain their current values.
92
+ * @see [[HyperModeling.replaceConfiguration]].
93
+ */
94
+ static updateConfiguration(config) {
95
+ var _a, _b, _c, _d, _e, _f, _g, _h;
96
+ this._markerHandler = (_a = config.markerHandler) !== null && _a !== void 0 ? _a : this._markerHandler;
97
+ if (config.markers) {
98
+ this._markerConfig = {
99
+ ignoreModelSelector: (_b = config.markers.ignoreModelSelector) !== null && _b !== void 0 ? _b : this._markerConfig.ignoreModelSelector,
100
+ ignoreCategorySelector: (_c = config.markers.ignoreCategorySelector) !== null && _c !== void 0 ? _c : this._markerConfig.ignoreCategorySelector,
101
+ hiddenSectionTypes: (_d = config.markers.hiddenSectionTypes) !== null && _d !== void 0 ? _d : this._markerConfig.hiddenSectionTypes,
102
+ };
103
+ }
104
+ if (config.graphics) {
105
+ this._graphicsConfig = {
106
+ ignoreClip: (_e = config.graphics.ignoreClip) !== null && _e !== void 0 ? _e : this._graphicsConfig.ignoreClip,
107
+ debugClipVolumes: (_f = config.graphics.debugClipVolumes) !== null && _f !== void 0 ? _f : this._graphicsConfig.debugClipVolumes,
108
+ hideSectionGraphics: (_g = config.graphics.hideSectionGraphics) !== null && _g !== void 0 ? _g : this._graphicsConfig.hideSectionGraphics,
109
+ hideSheetAnnotations: (_h = config.graphics.hideSheetAnnotations) !== null && _h !== void 0 ? _h : this._graphicsConfig.hideSheetAnnotations,
110
+ };
111
+ IModelApp.viewManager.invalidateViewportScenes();
112
+ }
113
+ }
114
+ /** The handler that defines interactions with [[SectionMarker]]s.
115
+ * @see [[initialize]] to override the default handler at package initialization.
116
+ * @see [[updateConfiguration]] or [[replaceConfiguration]] to change the current handler.
117
+ */
118
+ static get markerHandler() {
119
+ assertInitialized(this);
120
+ assert(undefined !== this._markerHandler);
121
+ return this._markerHandler;
122
+ }
123
+ /** The current marker display configuration applied to any newly-created [[HyperModelingDecorator]]s.
124
+ * @see [[initialize]] to override the default configuration at package initialization.
125
+ * @see [[updateConfiguration]] or [[replaceConfiguration]] to change the current configuration.
126
+ * @see [[HyperModelingDecorator.replaceConfiguration]] or [[HyperModelingDecorator.updateConfiguration]] to change the configuration for an existing decorator.
127
+ */
128
+ static get markerConfig() {
129
+ return this._markerConfig;
130
+ }
131
+ /** This graphics options applied to graphics displayed by all [[HyperModelingDecorator]]s.
132
+ * @see [[updateConfiguration]] or [[replaceConfiguration]] to change the current configuration.
133
+ */
134
+ static get graphicsConfig() {
135
+ return this._graphicsConfig;
136
+ }
137
+ /** Returns true if the specified iModel contains any [SectionDrawingLocation]($backend)s. Hypermodeling is based on section drawing locations,
138
+ * so if none are present, hypermodeling features are not relevant to the iModel. Attempting to use those features with such an iModel is fine,
139
+ * but probably not useful.
140
+ */
141
+ static async isSupportedForIModel(imodel) {
142
+ try {
143
+ // eslint-disable-next-line deprecation/deprecation
144
+ const nRows = await imodel.queryRowCount("SELECT ECInstanceId FROM bis.SectionDrawingLocation LIMIT 1");
145
+ return nRows > 0;
146
+ }
147
+ catch {
148
+ // An iModel with a version of BisCore older than 1.0.11 will produce an expected "table not found" on the SectionDrawingLocation ECClass.
149
+ return false;
150
+ }
151
+ }
152
+ /** Returns whether hypermodeling is currently enabled for the specified viewport.
153
+ * @see [[startOrStop]] to enable or disable hypermodeling for a viewport.
154
+ */
155
+ static isEnabledForViewport(viewport) {
156
+ return undefined !== HyperModelingDecorator.getForViewport(viewport);
157
+ }
158
+ /** Start or stop hypermodeling mode for the specified viewport.
159
+ * Enabling hypermodeling registers and returns a [[HyperModelingDecorator]] to display [[SectionMarker]]s within the viewport.
160
+ * Disabling hypermodeling removes that decorator.
161
+ * @param viewport The hypermodeling viewport
162
+ * @param start `true` to enter hypermodeling mode, `false` to exit, or `undefined` to toggle the current mode.
163
+ * @returns The new decorator is hypermodeling was successfully enabled.
164
+ * @note Enabling hypermodeling may fail if the viewport is not viewing a spatial model or if the viewport's iModel does not support hypermodeling.
165
+ * @see [[start]] and [[stop]].
166
+ * @see [[isSupportedForIModel]].
167
+ */
168
+ static async startOrStop(viewport, start) {
169
+ // Help out the caller since we're async anyway...
170
+ await this.ensureInitialized();
171
+ const decorator = HyperModelingDecorator.getForViewport(viewport);
172
+ if (undefined === start)
173
+ start = undefined === decorator;
174
+ if (start) {
175
+ return this._start(viewport);
176
+ }
177
+ else {
178
+ decorator === null || decorator === void 0 ? void 0 : decorator.dispose();
179
+ return undefined;
180
+ }
181
+ }
182
+ /** Start hypermodeling mode for the specified viewport if it is not currently enabled.
183
+ * If hypermodeling is already enabled for the viewport, the existing decorator is returned; otherwise, a new decorator is created.
184
+ * @param viewport The viewport for which to enable hypermodeling
185
+ * @returns The decorator that implements hypermodeling features for the viewport, or `undefined` if hypermodeling could not be enabled.
186
+ * @note Enabling hypermodeling may fail if the viewport is not viewing a spatial model or if the viewport's iModel does not support hypermodeling.
187
+ */
188
+ static async start(viewport) {
189
+ await this.ensureInitialized();
190
+ return this._start(viewport);
191
+ }
192
+ static async _start(viewport) {
193
+ assertInitialized(this);
194
+ if (!viewport.view.isSpatialView())
195
+ return undefined;
196
+ let decorator = HyperModelingDecorator.getForViewport(viewport);
197
+ if (!decorator)
198
+ decorator = await HyperModelingDecorator.create(viewport, this._markerConfig);
199
+ if (undefined !== decorator && viewport.view.isCameraOn) {
200
+ // We want the 2d graphics to align with the 3d geometry. Perspective ruins that.
201
+ viewport.view.turnCameraOff();
202
+ ViewManip.fitView(viewport, false, { noSaveInUndo: true });
203
+ viewport.clearViewUndo();
204
+ }
205
+ return decorator;
206
+ }
207
+ /** Stop hypermodeling mode for the specified viewport if it is currently enabled. This disposes of the [[HyperModelingDecorator]] associated with the viewport.
208
+ * @see [[start]] to enable hypermodeling for a viewport.
209
+ * @see [[startOrStop]] to toggle hypermodeling mode.
210
+ */
211
+ static stop(viewport) {
212
+ const decorator = HyperModelingDecorator.getForViewport(viewport);
213
+ decorator === null || decorator === void 0 ? void 0 : decorator.dispose();
214
+ }
215
+ /** @internal */
216
+ static get namespace() {
217
+ assertInitialized(this);
218
+ return this.resources.namespace;
219
+ }
220
+ /** @internal */
221
+ static getMarkerData(type) {
222
+ assertInitialized(this);
223
+ switch (type) {
224
+ case SectionType.Plan:
225
+ return this.resources.markers.plan;
226
+ case SectionType.Elevation:
227
+ return this.resources.markers.elevation;
228
+ case SectionType.Detail:
229
+ return this.resources.markers.detail;
230
+ default:
231
+ return this.resources.markers.section;
232
+ }
233
+ }
234
+ }
235
+ HyperModeling._markerConfig = {};
236
+ HyperModeling._graphicsConfig = {};
237
237
  //# sourceMappingURL=HyperModeling.js.map
@@ -1,55 +1,55 @@
1
- /** @packageDocumentation
2
- * @module HyperModeling
3
- */
4
- import { SectionType } from "@itwin/core-common";
5
- import { SectionMarkerHandler } from "./SectionMarkerHandler";
6
- /** Configures display of [[SectionMarker]]s for [[HyperModelingDecorator]]s.
7
- * @see [[HyperModelingDecorator.updateConfiguration]] or [[HyperModelingDecorator.replaceConfiguration]] to change the configuration for a specific decorator.
8
- * @see [[HyperModeling.initialize]] to set the default configuration for all decorators at package initialization.
9
- * @see [[HyperModeling.updateConfiguration]] or [[HyperModeling.replaceConfiguration]] to change the default configuration for all subsequently created decorators.
10
- * @see [[HyperModelingConfig]].
11
- * @public
12
- */
13
- export interface SectionMarkerConfig {
14
- /** Whether to hide markers belonging to models that are not present in the view's [ModelSelector]($backend). If true, markers are displayed regardless of their models. */
15
- readonly ignoreModelSelector?: boolean;
16
- /** Whether to hide markers belonging to categories that are not present in the view's [CategorySelector]($backend). If true, markers are displayed regardless of their categories. */
17
- readonly ignoreCategorySelector?: boolean;
18
- /** A list of types of section markers that shouold not be displayed. By default, markers for all section types are displayed. */
19
- readonly hiddenSectionTypes?: SectionType[];
20
- }
21
- /** Configures how 2d graphics are displayed by a [[HyperModelingDecorator]] when hypermodeling is active.
22
- * This configuration is used primarily for debugging, and applies globally to section graphics associated with all [[HyperModelingDecorator]]s.
23
- * @see [[HyperModeling.initialize]] to set this configuration at package initialization.
24
- * @see [[HyperModeling.updateConfiguration]] or [[HyperModeling.replaceConfiguration]] to change this configuration after package initialization.
25
- * @see [[HyperModelingConfig]].
26
- * @public
27
- */
28
- export interface SectionGraphicsConfig {
29
- /** If true, 2d graphics will not be clipped. */
30
- readonly ignoreClip?: boolean;
31
- /** If true, clip volumes for 2d graphics are displayed as shapes. */
32
- readonly debugClipVolumes?: boolean;
33
- /** If true, [SectionDrawing]($backend) graphics will not be displayed.
34
- * @see [[hideSheetAnnotations]]
35
- */
36
- readonly hideSectionGraphics?: boolean;
37
- /** If true, [Sheet]($backend) annotation graphics will not be displayed.
38
- * @see [[hideSectionGraphics]]
39
- */
40
- readonly hideSheetAnnotations?: boolean;
41
- }
42
- /** Configuration options for the hyper-modeling package.
43
- * @see [[HyperModeling.initialize]] to set the configuration at package initialization.
44
- * @see [[HyperModeling.updateConfiguration]] or [[HyperModeling.replaceConfiguration]] to modify the configuration after package initialization.
45
- * @public
46
- */
47
- export interface HyperModelingConfig {
48
- /** Specifies how the user interacts with [[SectionMarker]]s. If omitted, the default interactions will be used. */
49
- readonly markerHandler?: SectionMarkerHandler;
50
- /** Default [[SectionMarker]] display configuration used when creating a new [[HyperModelingDecorator]]. */
51
- readonly markers?: SectionMarkerConfig;
52
- /** Global section graphics configuration used by all [[HyperModelingDecorator]]s when displaying drawings and sheets in a spatial view. Primarily for debugging. */
53
- readonly graphics?: SectionGraphicsConfig;
54
- }
1
+ /** @packageDocumentation
2
+ * @module HyperModeling
3
+ */
4
+ import { SectionType } from "@itwin/core-common";
5
+ import { SectionMarkerHandler } from "./SectionMarkerHandler";
6
+ /** Configures display of [[SectionMarker]]s for [[HyperModelingDecorator]]s.
7
+ * @see [[HyperModelingDecorator.updateConfiguration]] or [[HyperModelingDecorator.replaceConfiguration]] to change the configuration for a specific decorator.
8
+ * @see [[HyperModeling.initialize]] to set the default configuration for all decorators at package initialization.
9
+ * @see [[HyperModeling.updateConfiguration]] or [[HyperModeling.replaceConfiguration]] to change the default configuration for all subsequently created decorators.
10
+ * @see [[HyperModelingConfig]].
11
+ * @public
12
+ */
13
+ export interface SectionMarkerConfig {
14
+ /** Whether to hide markers belonging to models that are not present in the view's [ModelSelector]($backend). If true, markers are displayed regardless of their models. */
15
+ readonly ignoreModelSelector?: boolean;
16
+ /** Whether to hide markers belonging to categories that are not present in the view's [CategorySelector]($backend). If true, markers are displayed regardless of their categories. */
17
+ readonly ignoreCategorySelector?: boolean;
18
+ /** A list of types of section markers that shouold not be displayed. By default, markers for all section types are displayed. */
19
+ readonly hiddenSectionTypes?: SectionType[];
20
+ }
21
+ /** Configures how 2d graphics are displayed by a [[HyperModelingDecorator]] when hypermodeling is active.
22
+ * This configuration is used primarily for debugging, and applies globally to section graphics associated with all [[HyperModelingDecorator]]s.
23
+ * @see [[HyperModeling.initialize]] to set this configuration at package initialization.
24
+ * @see [[HyperModeling.updateConfiguration]] or [[HyperModeling.replaceConfiguration]] to change this configuration after package initialization.
25
+ * @see [[HyperModelingConfig]].
26
+ * @public
27
+ */
28
+ export interface SectionGraphicsConfig {
29
+ /** If true, 2d graphics will not be clipped. */
30
+ readonly ignoreClip?: boolean;
31
+ /** If true, clip volumes for 2d graphics are displayed as shapes. */
32
+ readonly debugClipVolumes?: boolean;
33
+ /** If true, [SectionDrawing]($backend) graphics will not be displayed.
34
+ * @see [[hideSheetAnnotations]]
35
+ */
36
+ readonly hideSectionGraphics?: boolean;
37
+ /** If true, [Sheet]($backend) annotation graphics will not be displayed.
38
+ * @see [[hideSectionGraphics]]
39
+ */
40
+ readonly hideSheetAnnotations?: boolean;
41
+ }
42
+ /** Configuration options for the hyper-modeling package.
43
+ * @see [[HyperModeling.initialize]] to set the configuration at package initialization.
44
+ * @see [[HyperModeling.updateConfiguration]] or [[HyperModeling.replaceConfiguration]] to modify the configuration after package initialization.
45
+ * @public
46
+ */
47
+ export interface HyperModelingConfig {
48
+ /** Specifies how the user interacts with [[SectionMarker]]s. If omitted, the default interactions will be used. */
49
+ readonly markerHandler?: SectionMarkerHandler;
50
+ /** Default [[SectionMarker]] display configuration used when creating a new [[HyperModelingDecorator]]. */
51
+ readonly markers?: SectionMarkerConfig;
52
+ /** Global section graphics configuration used by all [[HyperModelingDecorator]]s when displaying drawings and sheets in a spatial view. Primarily for debugging. */
53
+ readonly graphics?: SectionGraphicsConfig;
54
+ }
55
55
  //# sourceMappingURL=HyperModelingConfig.d.ts.map
@@ -1,9 +1,9 @@
1
- /*---------------------------------------------------------------------------------------------
2
- * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
- * See LICENSE.md in the project root for license terms and full copyright notice.
4
- *--------------------------------------------------------------------------------------------*/
5
- /** @packageDocumentation
6
- * @module HyperModeling
7
- */
8
- export {};
1
+ /*---------------------------------------------------------------------------------------------
2
+ * Copyright (c) Bentley Systems, Incorporated. All rights reserved.
3
+ * See LICENSE.md in the project root for license terms and full copyright notice.
4
+ *--------------------------------------------------------------------------------------------*/
5
+ /** @packageDocumentation
6
+ * @module HyperModeling
7
+ */
8
+ export {};
9
9
  //# sourceMappingURL=HyperModelingConfig.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"HyperModelingConfig.js","sourceRoot":"","sources":["../../src/HyperModelingConfig.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG","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 { SectionType } from \"@itwin/core-common\";\r\nimport { SectionMarkerHandler } from \"./SectionMarkerHandler\";\r\n\r\n/** Configures display of [[SectionMarker]]s for [[HyperModelingDecorator]]s.\r\n * @see [[HyperModelingDecorator.updateConfiguration]] or [[HyperModelingDecorator.replaceConfiguration]] to change the configuration for a specific decorator.\r\n * @see [[HyperModeling.initialize]] to set the default configuration for all decorators at package initialization.\r\n * @see [[HyperModeling.updateConfiguration]] or [[HyperModeling.replaceConfiguration]] to change the default configuration for all subsequently created decorators.\r\n * @see [[HyperModelingConfig]].\r\n * @public\r\n */\r\nexport interface SectionMarkerConfig {\r\n /** Whether to hide markers belonging to models that are not present in the view's [ModelSelector]($backend). If true, markers are displayed regardless of their models. */\r\n readonly ignoreModelSelector?: boolean;\r\n /** Whether to hide markers belonging to categories that are not present in the view's [CategorySelector]($backend). If true, markers are displayed regardless of their categories. */\r\n readonly ignoreCategorySelector?: boolean;\r\n /** A list of types of section markers that shouold not be displayed. By default, markers for all section types are displayed. */\r\n readonly hiddenSectionTypes?: SectionType[];\r\n}\r\n\r\n/** Configures how 2d graphics are displayed by a [[HyperModelingDecorator]] when hypermodeling is active.\r\n * This configuration is used primarily for debugging, and applies globally to section graphics associated with all [[HyperModelingDecorator]]s.\r\n * @see [[HyperModeling.initialize]] to set this configuration at package initialization.\r\n * @see [[HyperModeling.updateConfiguration]] or [[HyperModeling.replaceConfiguration]] to change this configuration after package initialization.\r\n * @see [[HyperModelingConfig]].\r\n * @public\r\n */\r\nexport interface SectionGraphicsConfig {\r\n /** If true, 2d graphics will not be clipped. */\r\n readonly ignoreClip?: boolean;\r\n /** If true, clip volumes for 2d graphics are displayed as shapes. */\r\n readonly debugClipVolumes?: boolean;\r\n /** If true, [SectionDrawing]($backend) graphics will not be displayed.\r\n * @see [[hideSheetAnnotations]]\r\n */\r\n readonly hideSectionGraphics?: boolean;\r\n /** If true, [Sheet]($backend) annotation graphics will not be displayed.\r\n * @see [[hideSectionGraphics]]\r\n */\r\n readonly hideSheetAnnotations?: boolean;\r\n}\r\n\r\n/** Configuration options for the hyper-modeling package.\r\n * @see [[HyperModeling.initialize]] to set the configuration at package initialization.\r\n * @see [[HyperModeling.updateConfiguration]] or [[HyperModeling.replaceConfiguration]] to modify the configuration after package initialization.\r\n * @public\r\n */\r\nexport interface HyperModelingConfig {\r\n /** Specifies how the user interacts with [[SectionMarker]]s. If omitted, the default interactions will be used. */\r\n readonly markerHandler?: SectionMarkerHandler;\r\n /** Default [[SectionMarker]] display configuration used when creating a new [[HyperModelingDecorator]]. */\r\n readonly markers?: SectionMarkerConfig;\r\n /** Global section graphics configuration used by all [[HyperModelingDecorator]]s when displaying drawings and sheets in a spatial view. Primarily for debugging. */\r\n readonly graphics?: SectionGraphicsConfig;\r\n}\r\n"]}
1
+ {"version":3,"file":"HyperModelingConfig.js","sourceRoot":"","sources":["../../src/HyperModelingConfig.ts"],"names":[],"mappings":"AAAA;;;+FAG+F;AAC/F;;GAEG","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 { SectionType } from \"@itwin/core-common\";\nimport { SectionMarkerHandler } from \"./SectionMarkerHandler\";\n\n/** Configures display of [[SectionMarker]]s for [[HyperModelingDecorator]]s.\n * @see [[HyperModelingDecorator.updateConfiguration]] or [[HyperModelingDecorator.replaceConfiguration]] to change the configuration for a specific decorator.\n * @see [[HyperModeling.initialize]] to set the default configuration for all decorators at package initialization.\n * @see [[HyperModeling.updateConfiguration]] or [[HyperModeling.replaceConfiguration]] to change the default configuration for all subsequently created decorators.\n * @see [[HyperModelingConfig]].\n * @public\n */\nexport interface SectionMarkerConfig {\n /** Whether to hide markers belonging to models that are not present in the view's [ModelSelector]($backend). If true, markers are displayed regardless of their models. */\n readonly ignoreModelSelector?: boolean;\n /** Whether to hide markers belonging to categories that are not present in the view's [CategorySelector]($backend). If true, markers are displayed regardless of their categories. */\n readonly ignoreCategorySelector?: boolean;\n /** A list of types of section markers that shouold not be displayed. By default, markers for all section types are displayed. */\n readonly hiddenSectionTypes?: SectionType[];\n}\n\n/** Configures how 2d graphics are displayed by a [[HyperModelingDecorator]] when hypermodeling is active.\n * This configuration is used primarily for debugging, and applies globally to section graphics associated with all [[HyperModelingDecorator]]s.\n * @see [[HyperModeling.initialize]] to set this configuration at package initialization.\n * @see [[HyperModeling.updateConfiguration]] or [[HyperModeling.replaceConfiguration]] to change this configuration after package initialization.\n * @see [[HyperModelingConfig]].\n * @public\n */\nexport interface SectionGraphicsConfig {\n /** If true, 2d graphics will not be clipped. */\n readonly ignoreClip?: boolean;\n /** If true, clip volumes for 2d graphics are displayed as shapes. */\n readonly debugClipVolumes?: boolean;\n /** If true, [SectionDrawing]($backend) graphics will not be displayed.\n * @see [[hideSheetAnnotations]]\n */\n readonly hideSectionGraphics?: boolean;\n /** If true, [Sheet]($backend) annotation graphics will not be displayed.\n * @see [[hideSectionGraphics]]\n */\n readonly hideSheetAnnotations?: boolean;\n}\n\n/** Configuration options for the hyper-modeling package.\n * @see [[HyperModeling.initialize]] to set the configuration at package initialization.\n * @see [[HyperModeling.updateConfiguration]] or [[HyperModeling.replaceConfiguration]] to modify the configuration after package initialization.\n * @public\n */\nexport interface HyperModelingConfig {\n /** Specifies how the user interacts with [[SectionMarker]]s. If omitted, the default interactions will be used. */\n readonly markerHandler?: SectionMarkerHandler;\n /** Default [[SectionMarker]] display configuration used when creating a new [[HyperModelingDecorator]]. */\n readonly markers?: SectionMarkerConfig;\n /** Global section graphics configuration used by all [[HyperModelingDecorator]]s when displaying drawings and sheets in a spatial view. Primarily for debugging. */\n readonly graphics?: SectionGraphicsConfig;\n}\n"]}