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