@itwin/hypermodeling-frontend 3.6.0-dev.51 → 3.6.0-dev.53

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 (58) hide show
  1. package/lib/cjs/HyperModeling.d.ts +114 -114
  2. package/lib/cjs/HyperModeling.js +239 -239
  3. package/lib/cjs/HyperModelingConfig.d.ts +54 -54
  4. package/lib/cjs/HyperModelingConfig.js +9 -9
  5. package/lib/cjs/HyperModelingConfig.js.map +1 -1
  6. package/lib/cjs/HyperModelingDecorator.d.ts +110 -110
  7. package/lib/cjs/HyperModelingDecorator.js +337 -337
  8. package/lib/cjs/HyperModelingDecorator.js.map +1 -1
  9. package/lib/cjs/PopupToolbar.d.ts +24 -24
  10. package/lib/cjs/PopupToolbar.js +57 -57
  11. package/lib/cjs/PopupToolbar.js.map +1 -1
  12. package/lib/cjs/SectionDrawingLocationState.d.ts +90 -90
  13. package/lib/cjs/SectionDrawingLocationState.js +136 -136
  14. package/lib/cjs/SectionDrawingLocationState.js.map +1 -1
  15. package/lib/cjs/SectionGraphicsProvider.d.ts +13 -13
  16. package/lib/cjs/SectionGraphicsProvider.js +273 -273
  17. package/lib/cjs/SectionGraphicsProvider.js.map +1 -1
  18. package/lib/cjs/SectionMarkerHandler.d.ts +52 -52
  19. package/lib/cjs/SectionMarkerHandler.js +112 -112
  20. package/lib/cjs/SectionMarkerHandler.js.map +1 -1
  21. package/lib/cjs/SectionMarkers.d.ts +82 -82
  22. package/lib/cjs/SectionMarkers.js +174 -174
  23. package/lib/cjs/SectionMarkers.js.map +1 -1
  24. package/lib/cjs/Tools.d.ts +5 -5
  25. package/lib/cjs/Tools.js +170 -170
  26. package/lib/cjs/hypermodeling-frontend.d.ts +13 -13
  27. package/lib/cjs/hypermodeling-frontend.js +29 -29
  28. package/lib/cjs/hypermodeling-frontend.js.map +1 -1
  29. package/lib/esm/HyperModeling.d.ts +114 -114
  30. package/lib/esm/HyperModeling.js +235 -235
  31. package/lib/esm/HyperModelingConfig.d.ts +54 -54
  32. package/lib/esm/HyperModelingConfig.js +8 -8
  33. package/lib/esm/HyperModelingConfig.js.map +1 -1
  34. package/lib/esm/HyperModelingDecorator.d.ts +110 -110
  35. package/lib/esm/HyperModelingDecorator.js +333 -333
  36. package/lib/esm/HyperModelingDecorator.js.map +1 -1
  37. package/lib/esm/PopupToolbar.d.ts +24 -24
  38. package/lib/esm/PopupToolbar.js +53 -53
  39. package/lib/esm/PopupToolbar.js.map +1 -1
  40. package/lib/esm/SectionDrawingLocationState.d.ts +90 -90
  41. package/lib/esm/SectionDrawingLocationState.js +132 -132
  42. package/lib/esm/SectionDrawingLocationState.js.map +1 -1
  43. package/lib/esm/SectionGraphicsProvider.d.ts +13 -13
  44. package/lib/esm/SectionGraphicsProvider.js +269 -269
  45. package/lib/esm/SectionGraphicsProvider.js.map +1 -1
  46. package/lib/esm/SectionMarkerHandler.d.ts +52 -52
  47. package/lib/esm/SectionMarkerHandler.js +108 -108
  48. package/lib/esm/SectionMarkerHandler.js.map +1 -1
  49. package/lib/esm/SectionMarkers.d.ts +82 -82
  50. package/lib/esm/SectionMarkers.js +168 -168
  51. package/lib/esm/SectionMarkers.js.map +1 -1
  52. package/lib/esm/Tools.d.ts +5 -5
  53. package/lib/esm/Tools.js +166 -166
  54. package/lib/esm/hypermodeling-frontend.d.ts +13 -13
  55. package/lib/esm/hypermodeling-frontend.js +17 -17
  56. package/lib/esm/hypermodeling-frontend.js.map +1 -1
  57. package/lib/public/locales/en/HyperModeling.json +32 -32
  58. package/package.json +13 -13
@@ -1,83 +1,83 @@
1
- /** @packageDocumentation
2
- * @module HyperModeling
3
- */
4
- import { BeEvent, Id64String } from "@itwin/core-bentley";
5
- import { XAndY, XYAndZ } from "@itwin/core-geometry";
6
- import { BeButtonEvent, Cluster, DecorateContext, Marker, MarkerImage, MarkerSet, ScreenViewport } from "@itwin/core-frontend";
7
- import { SectionDrawingLocationState } from "./SectionDrawingLocationState";
8
- /** A [Marker]($frontend) associated with a [[SectionDrawingLocationState]], displayed as a canvas decoration at the location of the section.
9
- * Clicking on the marker toggles display of the section graphics. Mousing over the marker produces a toolbar with additional interactions.
10
- * @see [[HyperModelingDecorator]] for a [Decorator]($frontend) capable of displaying section markers for each section drawing location.
11
- * @see [[SectionMarkerHandler]] to customize the marker interactions.
12
- * @public
13
- */
14
- export declare class SectionMarker extends Marker {
15
- /** The section drawing location state associated with the marker. */
16
- readonly state: SectionDrawingLocationState;
17
- /** A description displayed as part of the tooltip when this marker is clustered with other markers. */
18
- readonly description: string;
19
- /** @internal */
20
- readonly onMouseEnterEvent: BeEvent<(marker: SectionMarker) => void>;
21
- /** @internal */
22
- readonly onMouseButtonEvent: BeEvent<(marker: SectionMarker) => void>;
23
- /** @internal */
24
- private _isActive;
25
- /** Constructor, typically invoked indirectly via [[HyperModelingDecorator]].
26
- * @param state The section drawing location state this marker will represent.
27
- * @param pos The world coordinates at which to display the marker.
28
- * @param description A brief description of this marker, used as part of the tooltip when this marker is part of a cluster.
29
- * @param icon The icon displayed by the marker.
30
- * @param tooltip Optional detailed tooltip displayed on mouse hover. If undefined, the `description` is used instead.
31
- */
32
- constructor(state: SectionDrawingLocationState);
33
- /** @internal */
34
- get isHilited(): boolean;
35
- /** Returns true if this is the "active" section marker. At most one marker is active at a given time.
36
- * @see [[HyperModelingDecorator.activeMarker]].
37
- * @see [[HyperModelingDecorator.setActiveMarker]].
38
- * @see [[SectionMarkerHandler.toggleMarker]].
39
- */
40
- get isActive(): boolean;
41
- /** @internal */
42
- setActive(active: boolean): void;
43
- /** @internal */
44
- protected drawActive(ctx: CanvasRenderingContext2D): boolean;
45
- /** @internal */
46
- drawDecoration(ctx: CanvasRenderingContext2D): void;
47
- /** @internal */
48
- onMouseEnter(ev: BeButtonEvent): void;
49
- /** @internal */
50
- onMouseButton(ev: BeButtonEvent): boolean;
51
- /** @internal */
52
- addMarker(context: DecorateContext): void;
53
- }
54
- /** A Marker used to show a cluster of section locations.
55
- * @internal
56
- */
57
- export declare class SectionMarkerCluster extends Marker {
58
- /** Create a new cluster marker */
59
- constructor(location: XYAndZ, size: XAndY, cluster: Cluster<SectionMarker>, image: MarkerImage | Promise<MarkerImage> | undefined);
60
- /** Show the cluster as a white circle with an outline */
61
- drawFunc(ctx: CanvasRenderingContext2D): void;
62
- onMouseButton(_ev: BeButtonEvent): boolean;
63
- }
64
- /** A [MarkerSet]($frontend) containing [[SectionMarker]]s identifying [SectionDrawingLocation]($backend)s within a spatial view.
65
- * Typically used indirectly via [[HyperModelingDecorator]].
66
- * @public
67
- */
68
- export declare class SectionMarkerSet extends MarkerSet<SectionMarker> {
69
- minimumClusterSize: number;
70
- /** Constructor
71
- * @param viewport The viewport in which the markers are to be displayed.
72
- * @param markers The markers to be displayed.
73
- * @note Each marker's [[SectionDrawingLocationState]] must be associated with the same [IModelConnection]($frontend) as the viewport; any markers from other iModels will be omitted.
74
- */
75
- constructor(viewport: ScreenViewport, markers: SectionMarker[]);
76
- /** The viewport in which the markers are to be displayed. */
77
- get viewport(): ScreenViewport;
78
- /** @internal */
79
- protected getClusterMarker(cluster: Cluster<SectionMarker>): Marker;
80
- /** Find the SectionMarker corresponding to the specified [SectionDrawingLocation]($backend) Id. */
81
- findMarkerById(sectionDrawingLocationId: Id64String): SectionMarker | undefined;
82
- }
1
+ /** @packageDocumentation
2
+ * @module HyperModeling
3
+ */
4
+ import { BeEvent, Id64String } from "@itwin/core-bentley";
5
+ import { XAndY, XYAndZ } from "@itwin/core-geometry";
6
+ import { BeButtonEvent, Cluster, DecorateContext, Marker, MarkerImage, MarkerSet, ScreenViewport } from "@itwin/core-frontend";
7
+ import { SectionDrawingLocationState } from "./SectionDrawingLocationState";
8
+ /** A [Marker]($frontend) associated with a [[SectionDrawingLocationState]], displayed as a canvas decoration at the location of the section.
9
+ * Clicking on the marker toggles display of the section graphics. Mousing over the marker produces a toolbar with additional interactions.
10
+ * @see [[HyperModelingDecorator]] for a [Decorator]($frontend) capable of displaying section markers for each section drawing location.
11
+ * @see [[SectionMarkerHandler]] to customize the marker interactions.
12
+ * @public
13
+ */
14
+ export declare class SectionMarker extends Marker {
15
+ /** The section drawing location state associated with the marker. */
16
+ readonly state: SectionDrawingLocationState;
17
+ /** A description displayed as part of the tooltip when this marker is clustered with other markers. */
18
+ readonly description: string;
19
+ /** @internal */
20
+ readonly onMouseEnterEvent: BeEvent<(marker: SectionMarker) => void>;
21
+ /** @internal */
22
+ readonly onMouseButtonEvent: BeEvent<(marker: SectionMarker) => void>;
23
+ /** @internal */
24
+ private _isActive;
25
+ /** Constructor, typically invoked indirectly via [[HyperModelingDecorator]].
26
+ * @param state The section drawing location state this marker will represent.
27
+ * @param pos The world coordinates at which to display the marker.
28
+ * @param description A brief description of this marker, used as part of the tooltip when this marker is part of a cluster.
29
+ * @param icon The icon displayed by the marker.
30
+ * @param tooltip Optional detailed tooltip displayed on mouse hover. If undefined, the `description` is used instead.
31
+ */
32
+ constructor(state: SectionDrawingLocationState);
33
+ /** @internal */
34
+ get isHilited(): boolean;
35
+ /** Returns true if this is the "active" section marker. At most one marker is active at a given time.
36
+ * @see [[HyperModelingDecorator.activeMarker]].
37
+ * @see [[HyperModelingDecorator.setActiveMarker]].
38
+ * @see [[SectionMarkerHandler.toggleMarker]].
39
+ */
40
+ get isActive(): boolean;
41
+ /** @internal */
42
+ setActive(active: boolean): void;
43
+ /** @internal */
44
+ protected drawActive(ctx: CanvasRenderingContext2D): boolean;
45
+ /** @internal */
46
+ drawDecoration(ctx: CanvasRenderingContext2D): void;
47
+ /** @internal */
48
+ onMouseEnter(ev: BeButtonEvent): void;
49
+ /** @internal */
50
+ onMouseButton(ev: BeButtonEvent): boolean;
51
+ /** @internal */
52
+ addMarker(context: DecorateContext): void;
53
+ }
54
+ /** A Marker used to show a cluster of section locations.
55
+ * @internal
56
+ */
57
+ export declare class SectionMarkerCluster extends Marker {
58
+ /** Create a new cluster marker */
59
+ constructor(location: XYAndZ, size: XAndY, cluster: Cluster<SectionMarker>, image: MarkerImage | Promise<MarkerImage> | undefined);
60
+ /** Show the cluster as a white circle with an outline */
61
+ drawFunc(ctx: CanvasRenderingContext2D): void;
62
+ onMouseButton(_ev: BeButtonEvent): boolean;
63
+ }
64
+ /** A [MarkerSet]($frontend) containing [[SectionMarker]]s identifying [SectionDrawingLocation]($backend)s within a spatial view.
65
+ * Typically used indirectly via [[HyperModelingDecorator]].
66
+ * @public
67
+ */
68
+ export declare class SectionMarkerSet extends MarkerSet<SectionMarker> {
69
+ minimumClusterSize: number;
70
+ /** Constructor
71
+ * @param viewport The viewport in which the markers are to be displayed.
72
+ * @param markers The markers to be displayed.
73
+ * @note Each marker's [[SectionDrawingLocationState]] must be associated with the same [IModelConnection]($frontend) as the viewport; any markers from other iModels will be omitted.
74
+ */
75
+ constructor(viewport: ScreenViewport, markers: SectionMarker[]);
76
+ /** The viewport in which the markers are to be displayed. */
77
+ get viewport(): ScreenViewport;
78
+ /** @internal */
79
+ protected getClusterMarker(cluster: Cluster<SectionMarker>): Marker;
80
+ /** Find the SectionMarker corresponding to the specified [SectionDrawingLocation]($backend) Id. */
81
+ findMarkerById(sectionDrawingLocationId: Id64String): SectionMarker | undefined;
82
+ }
83
83
  //# sourceMappingURL=SectionMarkers.d.ts.map
@@ -1,175 +1,175 @@
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.SectionMarkerSet = exports.SectionMarkerCluster = exports.SectionMarker = void 0;
11
- const core_bentley_1 = require("@itwin/core-bentley");
12
- const core_geometry_1 = require("@itwin/core-geometry");
13
- const core_common_1 = require("@itwin/core-common");
14
- const core_frontend_1 = require("@itwin/core-frontend");
15
- const HyperModeling_1 = require("./HyperModeling");
16
- const markerSize = core_geometry_1.Point2d.create(40, 40);
17
- /** A [Marker]($frontend) associated with a [[SectionDrawingLocationState]], displayed as a canvas decoration at the location of the section.
18
- * Clicking on the marker toggles display of the section graphics. Mousing over the marker produces a toolbar with additional interactions.
19
- * @see [[HyperModelingDecorator]] for a [Decorator]($frontend) capable of displaying section markers for each section drawing location.
20
- * @see [[SectionMarkerHandler]] to customize the marker interactions.
21
- * @public
22
- */
23
- class SectionMarker extends core_frontend_1.Marker {
24
- /** Constructor, typically invoked indirectly via [[HyperModelingDecorator]].
25
- * @param state The section drawing location state this marker will represent.
26
- * @param pos The world coordinates at which to display the marker.
27
- * @param description A brief description of this marker, used as part of the tooltip when this marker is part of a cluster.
28
- * @param icon The icon displayed by the marker.
29
- * @param tooltip Optional detailed tooltip displayed on mouse hover. If undefined, the `description` is used instead.
30
- */
31
- constructor(state) {
32
- super(state.placement.origin.clone(), markerSize);
33
- /** @internal */
34
- this.onMouseEnterEvent = new core_bentley_1.BeEvent();
35
- /** @internal */
36
- this.onMouseButtonEvent = new core_bentley_1.BeEvent();
37
- /** @internal */
38
- this._isActive = false;
39
- this.state = state;
40
- const data = HyperModeling_1.HyperModeling.getMarkerData(state.sectionType);
41
- this.description = data.label;
42
- if (data.image)
43
- this.setImage(data.image);
44
- this.setScaleFactor({ low: .2, high: 1.4 }); // make size 20% at back of frustum and 140% at front of frustum (if camera is on)
45
- }
46
- /** @internal */
47
- get isHilited() { return this._isHilited; }
48
- /** Returns true if this is the "active" section marker. At most one marker is active at a given time.
49
- * @see [[HyperModelingDecorator.activeMarker]].
50
- * @see [[HyperModelingDecorator.setActiveMarker]].
51
- * @see [[SectionMarkerHandler.toggleMarker]].
52
- */
53
- get isActive() {
54
- return this._isActive;
55
- }
56
- /** @internal */
57
- setActive(active) {
58
- this._isActive = active;
59
- }
60
- /** @internal */
61
- drawActive(ctx) {
62
- ctx.shadowBlur = 30;
63
- ctx.shadowColor = "gold";
64
- return false;
65
- }
66
- /** @internal */
67
- drawDecoration(ctx) {
68
- if (!this.isActive || !this.drawActive(ctx))
69
- super.drawDecoration(ctx);
70
- }
71
- /** @internal */
72
- onMouseEnter(ev) {
73
- // Lazily load the tooltip.
74
- if (undefined === this.title) {
75
- core_common_1.IModelReadRpcInterface.getClientForRouting(this.state.iModel.routingContext.token).getToolTipMessage(this.state.iModel.getRpcProps(), this.state.id).then((tooltipMsg) => {
76
- this.title = core_frontend_1.IModelApp.formatElementToolTip(tooltipMsg);
77
- }).catch((_) => {
78
- this.title = this.description;
79
- });
80
- }
81
- super.onMouseEnter(ev);
82
- this.onMouseEnterEvent.raiseEvent(this);
83
- }
84
- /** @internal */
85
- onMouseButton(ev) {
86
- if (core_frontend_1.InputSource.Mouse === ev.inputSource && core_frontend_1.BeButton.Data === ev.button && ev.isDown && ev.viewport)
87
- this.onMouseButtonEvent.raiseEvent(this);
88
- return true; // Don't allow clicks to be sent to active tool...
89
- }
90
- /** @internal */
91
- addMarker(context) {
92
- super.addMarker(context);
93
- if (this.isHilited)
94
- core_frontend_1.ViewClipTool.drawClip(context, this.state.clip, undefined, { fillClipPlanes: true, hasPrimaryPlane: true });
95
- }
96
- }
97
- exports.SectionMarker = SectionMarker;
98
- /** A Marker used to show a cluster of section locations.
99
- * @internal
100
- */
101
- class SectionMarkerCluster extends core_frontend_1.Marker {
102
- /** Create a new cluster marker */
103
- constructor(location, size, cluster, image) {
104
- super(location, size);
105
- this.imageOffset = new core_geometry_1.Point3d(0, 30);
106
- this.label = cluster.markers.length.toLocaleString();
107
- this.labelColor = "black";
108
- this.labelFont = "bold 14px sans-serif";
109
- const maxLen = 10;
110
- let title = "";
111
- cluster.markers.forEach((marker, index) => {
112
- if (index < maxLen) {
113
- if (title !== "")
114
- title += "<br>";
115
- title += marker.description;
116
- }
117
- });
118
- if (cluster.markers.length > maxLen)
119
- title += "<br>...";
120
- const div = document.createElement("div");
121
- div.innerHTML = title;
122
- this.title = div;
123
- if (image)
124
- this.setImage(image);
125
- }
126
- /** Show the cluster as a white circle with an outline */
127
- drawFunc(ctx) {
128
- ctx.beginPath();
129
- ctx.strokeStyle = "#372528";
130
- ctx.fillStyle = "white";
131
- ctx.lineWidth = 5;
132
- ctx.arc(0, 0, 13, 0, Math.PI * 2);
133
- ctx.fill();
134
- ctx.stroke();
135
- }
136
- onMouseButton(_ev) { return true; } // Don't allow clicks to be sent to active tool...
137
- }
138
- exports.SectionMarkerCluster = SectionMarkerCluster;
139
- /** A [MarkerSet]($frontend) containing [[SectionMarker]]s identifying [SectionDrawingLocation]($backend)s within a spatial view.
140
- * Typically used indirectly via [[HyperModelingDecorator]].
141
- * @public
142
- */
143
- class SectionMarkerSet extends core_frontend_1.MarkerSet {
144
- /** Constructor
145
- * @param viewport The viewport in which the markers are to be displayed.
146
- * @param markers The markers to be displayed.
147
- * @note Each marker's [[SectionDrawingLocationState]] must be associated with the same [IModelConnection]($frontend) as the viewport; any markers from other iModels will be omitted.
148
- */
149
- constructor(viewport, markers) {
150
- super(viewport);
151
- this.minimumClusterSize = 5;
152
- for (const marker of markers) {
153
- if (marker.state.iModel === viewport.iModel)
154
- this.markers.add(marker);
155
- }
156
- }
157
- /** The viewport in which the markers are to be displayed. */
158
- get viewport() {
159
- (0, core_bentley_1.assert)(undefined !== super.viewport);
160
- return super.viewport;
161
- }
162
- /** @internal */
163
- getClusterMarker(cluster) {
164
- return new SectionMarkerCluster(cluster.getClusterLocation(), cluster.markers[0].size, cluster, cluster.markers[0].image);
165
- }
166
- /** Find the SectionMarker corresponding to the specified [SectionDrawingLocation]($backend) Id. */
167
- findMarkerById(sectionDrawingLocationId) {
168
- for (const marker of this.markers)
169
- if (marker.state.id === sectionDrawingLocationId)
170
- return marker;
171
- return undefined;
172
- }
173
- }
174
- exports.SectionMarkerSet = SectionMarkerSet;
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.SectionMarkerSet = exports.SectionMarkerCluster = exports.SectionMarker = void 0;
11
+ const core_bentley_1 = require("@itwin/core-bentley");
12
+ const core_geometry_1 = require("@itwin/core-geometry");
13
+ const core_common_1 = require("@itwin/core-common");
14
+ const core_frontend_1 = require("@itwin/core-frontend");
15
+ const HyperModeling_1 = require("./HyperModeling");
16
+ const markerSize = core_geometry_1.Point2d.create(40, 40);
17
+ /** A [Marker]($frontend) associated with a [[SectionDrawingLocationState]], displayed as a canvas decoration at the location of the section.
18
+ * Clicking on the marker toggles display of the section graphics. Mousing over the marker produces a toolbar with additional interactions.
19
+ * @see [[HyperModelingDecorator]] for a [Decorator]($frontend) capable of displaying section markers for each section drawing location.
20
+ * @see [[SectionMarkerHandler]] to customize the marker interactions.
21
+ * @public
22
+ */
23
+ class SectionMarker extends core_frontend_1.Marker {
24
+ /** Constructor, typically invoked indirectly via [[HyperModelingDecorator]].
25
+ * @param state The section drawing location state this marker will represent.
26
+ * @param pos The world coordinates at which to display the marker.
27
+ * @param description A brief description of this marker, used as part of the tooltip when this marker is part of a cluster.
28
+ * @param icon The icon displayed by the marker.
29
+ * @param tooltip Optional detailed tooltip displayed on mouse hover. If undefined, the `description` is used instead.
30
+ */
31
+ constructor(state) {
32
+ super(state.placement.origin.clone(), markerSize);
33
+ /** @internal */
34
+ this.onMouseEnterEvent = new core_bentley_1.BeEvent();
35
+ /** @internal */
36
+ this.onMouseButtonEvent = new core_bentley_1.BeEvent();
37
+ /** @internal */
38
+ this._isActive = false;
39
+ this.state = state;
40
+ const data = HyperModeling_1.HyperModeling.getMarkerData(state.sectionType);
41
+ this.description = data.label;
42
+ if (data.image)
43
+ this.setImage(data.image);
44
+ this.setScaleFactor({ low: .2, high: 1.4 }); // make size 20% at back of frustum and 140% at front of frustum (if camera is on)
45
+ }
46
+ /** @internal */
47
+ get isHilited() { return this._isHilited; }
48
+ /** Returns true if this is the "active" section marker. At most one marker is active at a given time.
49
+ * @see [[HyperModelingDecorator.activeMarker]].
50
+ * @see [[HyperModelingDecorator.setActiveMarker]].
51
+ * @see [[SectionMarkerHandler.toggleMarker]].
52
+ */
53
+ get isActive() {
54
+ return this._isActive;
55
+ }
56
+ /** @internal */
57
+ setActive(active) {
58
+ this._isActive = active;
59
+ }
60
+ /** @internal */
61
+ drawActive(ctx) {
62
+ ctx.shadowBlur = 30;
63
+ ctx.shadowColor = "gold";
64
+ return false;
65
+ }
66
+ /** @internal */
67
+ drawDecoration(ctx) {
68
+ if (!this.isActive || !this.drawActive(ctx))
69
+ super.drawDecoration(ctx);
70
+ }
71
+ /** @internal */
72
+ onMouseEnter(ev) {
73
+ // Lazily load the tooltip.
74
+ if (undefined === this.title) {
75
+ core_common_1.IModelReadRpcInterface.getClientForRouting(this.state.iModel.routingContext.token).getToolTipMessage(this.state.iModel.getRpcProps(), this.state.id).then((tooltipMsg) => {
76
+ this.title = core_frontend_1.IModelApp.formatElementToolTip(tooltipMsg);
77
+ }).catch((_) => {
78
+ this.title = this.description;
79
+ });
80
+ }
81
+ super.onMouseEnter(ev);
82
+ this.onMouseEnterEvent.raiseEvent(this);
83
+ }
84
+ /** @internal */
85
+ onMouseButton(ev) {
86
+ if (core_frontend_1.InputSource.Mouse === ev.inputSource && core_frontend_1.BeButton.Data === ev.button && ev.isDown && ev.viewport)
87
+ this.onMouseButtonEvent.raiseEvent(this);
88
+ return true; // Don't allow clicks to be sent to active tool...
89
+ }
90
+ /** @internal */
91
+ addMarker(context) {
92
+ super.addMarker(context);
93
+ if (this.isHilited)
94
+ core_frontend_1.ViewClipTool.drawClip(context, this.state.clip, undefined, { fillClipPlanes: true, hasPrimaryPlane: true });
95
+ }
96
+ }
97
+ exports.SectionMarker = SectionMarker;
98
+ /** A Marker used to show a cluster of section locations.
99
+ * @internal
100
+ */
101
+ class SectionMarkerCluster extends core_frontend_1.Marker {
102
+ /** Create a new cluster marker */
103
+ constructor(location, size, cluster, image) {
104
+ super(location, size);
105
+ this.imageOffset = new core_geometry_1.Point3d(0, 30);
106
+ this.label = cluster.markers.length.toLocaleString();
107
+ this.labelColor = "black";
108
+ this.labelFont = "bold 14px sans-serif";
109
+ const maxLen = 10;
110
+ let title = "";
111
+ cluster.markers.forEach((marker, index) => {
112
+ if (index < maxLen) {
113
+ if (title !== "")
114
+ title += "<br>";
115
+ title += marker.description;
116
+ }
117
+ });
118
+ if (cluster.markers.length > maxLen)
119
+ title += "<br>...";
120
+ const div = document.createElement("div");
121
+ div.innerHTML = title;
122
+ this.title = div;
123
+ if (image)
124
+ this.setImage(image);
125
+ }
126
+ /** Show the cluster as a white circle with an outline */
127
+ drawFunc(ctx) {
128
+ ctx.beginPath();
129
+ ctx.strokeStyle = "#372528";
130
+ ctx.fillStyle = "white";
131
+ ctx.lineWidth = 5;
132
+ ctx.arc(0, 0, 13, 0, Math.PI * 2);
133
+ ctx.fill();
134
+ ctx.stroke();
135
+ }
136
+ onMouseButton(_ev) { return true; } // Don't allow clicks to be sent to active tool...
137
+ }
138
+ exports.SectionMarkerCluster = SectionMarkerCluster;
139
+ /** A [MarkerSet]($frontend) containing [[SectionMarker]]s identifying [SectionDrawingLocation]($backend)s within a spatial view.
140
+ * Typically used indirectly via [[HyperModelingDecorator]].
141
+ * @public
142
+ */
143
+ class SectionMarkerSet extends core_frontend_1.MarkerSet {
144
+ /** Constructor
145
+ * @param viewport The viewport in which the markers are to be displayed.
146
+ * @param markers The markers to be displayed.
147
+ * @note Each marker's [[SectionDrawingLocationState]] must be associated with the same [IModelConnection]($frontend) as the viewport; any markers from other iModels will be omitted.
148
+ */
149
+ constructor(viewport, markers) {
150
+ super(viewport);
151
+ this.minimumClusterSize = 5;
152
+ for (const marker of markers) {
153
+ if (marker.state.iModel === viewport.iModel)
154
+ this.markers.add(marker);
155
+ }
156
+ }
157
+ /** The viewport in which the markers are to be displayed. */
158
+ get viewport() {
159
+ (0, core_bentley_1.assert)(undefined !== super.viewport);
160
+ return super.viewport;
161
+ }
162
+ /** @internal */
163
+ getClusterMarker(cluster) {
164
+ return new SectionMarkerCluster(cluster.getClusterLocation(), cluster.markers[0].size, cluster, cluster.markers[0].image);
165
+ }
166
+ /** Find the SectionMarker corresponding to the specified [SectionDrawingLocation]($backend) Id. */
167
+ findMarkerById(sectionDrawingLocationId) {
168
+ for (const marker of this.markers)
169
+ if (marker.state.id === sectionDrawingLocationId)
170
+ return marker;
171
+ return undefined;
172
+ }
173
+ }
174
+ exports.SectionMarkerSet = SectionMarkerSet;
175
175
  //# sourceMappingURL=SectionMarkers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"SectionMarkers.js","sourceRoot":"","sources":["../../src/SectionMarkers.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAkE;AAClE,wDAAuE;AACvE,oDAA4D;AAC5D,wDAE8B;AAE9B,mDAAgD;AAEhD,MAAM,UAAU,GAAG,uBAAO,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAE1C;;;;;GAKG;AACH,MAAa,aAAc,SAAQ,sBAAM;IAYvC;;;;;;OAMG;IACH,YAAmB,KAAkC;QACnD,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,UAAU,CAAC,CAAC;QAfpD,gBAAgB;QACA,sBAAiB,GAAG,IAAI,sBAAO,EAAmC,CAAC;QACnF,gBAAgB;QACA,uBAAkB,GAAG,IAAI,sBAAO,EAAmC,CAAC;QACpF,gBAAgB;QACR,cAAS,GAAG,KAAK,CAAC;QAWxB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QAEnB,MAAM,IAAI,GAAG,6BAAa,CAAC,aAAa,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAC5D,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC;QAC9B,IAAI,IAAI,CAAC,KAAK;YACZ,IAAI,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D;;;;OAIG;IACH,YAAmB,QAAwB,EAAE,OAAwB;QACnE,KAAK,CAAC,QAAQ,CAAC,CAAC;QARF,uBAAkB,GAAG,CAAC,CAAC;QASrC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;YAC5B,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM;gBACzC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;SAC5B;IACH,CAAC;IAED,6DAA6D;IAC7D,IAAoB,QAAQ;QAC1B,IAAA,qBAAM,EAAC,SAAS,KAAK,KAAK,CAAC,QAAQ,CAAC,CAAC;QACrC,OAAO,KAAK,CAAC,QAAQ,CAAC;IACxB,CAAC;IAED,gBAAgB;IACN,gBAAgB,CAAC,OAA+B;QACxD,OAAO,IAAI,oBAAoB,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAC5H,CAAC;IAED,mGAAmG;IAC5F,cAAc,CAAC,wBAAoC;QACxD,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO;YAC/B,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,wBAAwB;gBAC9C,OAAO,MAAM,CAAC;QAElB,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAnCD,4CAmCC","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, BeEvent, Id64String } from \"@itwin/core-bentley\";\r\nimport { Point2d, Point3d, XAndY, XYAndZ } from \"@itwin/core-geometry\";\r\nimport { IModelReadRpcInterface } from \"@itwin/core-common\";\r\nimport {\r\n BeButton, BeButtonEvent, Cluster, DecorateContext, IModelApp, InputSource, Marker, MarkerImage, MarkerSet, ScreenViewport, ViewClipTool,\r\n} from \"@itwin/core-frontend\";\r\nimport { SectionDrawingLocationState } from \"./SectionDrawingLocationState\";\r\nimport { HyperModeling } from \"./HyperModeling\";\r\n\r\nconst markerSize = Point2d.create(40, 40);\r\n\r\n/** A [Marker]($frontend) associated with a [[SectionDrawingLocationState]], displayed as a canvas decoration at the location of the section.\r\n * Clicking on the marker toggles display of the section graphics. Mousing over the marker produces a toolbar with additional interactions.\r\n * @see [[HyperModelingDecorator]] for a [Decorator]($frontend) capable of displaying section markers for each section drawing location.\r\n * @see [[SectionMarkerHandler]] to customize the marker interactions.\r\n * @public\r\n */\r\nexport class SectionMarker extends Marker {\r\n /** The section drawing location state associated with the marker. */\r\n public readonly state: SectionDrawingLocationState;\r\n /** A description displayed as part of the tooltip when this marker is clustered with other markers. */\r\n public readonly description: string;\r\n /** @internal */\r\n public readonly onMouseEnterEvent = new BeEvent<(marker: SectionMarker) => void>();\r\n /** @internal */\r\n public readonly onMouseButtonEvent = new BeEvent<(marker: SectionMarker) => void>();\r\n /** @internal */\r\n private _isActive = false;\r\n\r\n /** Constructor, typically invoked indirectly via [[HyperModelingDecorator]].\r\n * @param state The section drawing location state this marker will represent.\r\n * @param pos The world coordinates at which to display the marker.\r\n * @param description A brief description of this marker, used as part of the tooltip when this marker is part of a cluster.\r\n * @param icon The icon displayed by the marker.\r\n * @param tooltip Optional detailed tooltip displayed on mouse hover. If undefined, the `description` is used instead.\r\n */\r\n public constructor(state: SectionDrawingLocationState) {\r\n super(state.placement.origin.clone(), markerSize);\r\n this.state = state;\r\n\r\n const data = HyperModeling.getMarkerData(state.sectionType);\r\n this.description = data.label;\r\n if (data.image)\r\n this.setImage(data.image);\r\n\r\n this.setScaleFactor({ low: .2, high: 1.4 }); // make size 20% at back of frustum and 140% at front of frustum (if camera is on)\r\n }\r\n\r\n /** @internal */\r\n public get isHilited(): boolean { return this._isHilited; }\r\n\r\n /** Returns true if this is the \"active\" section marker. At most one marker is active at a given time.\r\n * @see [[HyperModelingDecorator.activeMarker]].\r\n * @see [[HyperModelingDecorator.setActiveMarker]].\r\n * @see [[SectionMarkerHandler.toggleMarker]].\r\n */\r\n public get isActive(): boolean {\r\n return this._isActive;\r\n }\r\n\r\n /** @internal */\r\n public setActive(active: boolean): void {\r\n this._isActive = active;\r\n }\r\n\r\n /** @internal */\r\n protected drawActive(ctx: CanvasRenderingContext2D) {\r\n ctx.shadowBlur = 30;\r\n ctx.shadowColor = \"gold\";\r\n return false;\r\n }\r\n\r\n /** @internal */\r\n public override drawDecoration(ctx: CanvasRenderingContext2D): void {\r\n if (!this.isActive || !this.drawActive(ctx))\r\n super.drawDecoration(ctx);\r\n }\r\n\r\n /** @internal */\r\n public override onMouseEnter(ev: BeButtonEvent) {\r\n // Lazily load the tooltip.\r\n if (undefined === this.title) {\r\n IModelReadRpcInterface.getClientForRouting(this.state.iModel.routingContext.token).getToolTipMessage(this.state.iModel.getRpcProps(), this.state.id).then((tooltipMsg) => {\r\n this.title = IModelApp.formatElementToolTip(tooltipMsg);\r\n }).catch((_) => {\r\n this.title = this.description;\r\n });\r\n }\r\n\r\n super.onMouseEnter(ev);\r\n this.onMouseEnterEvent.raiseEvent(this);\r\n }\r\n\r\n /** @internal */\r\n public override onMouseButton(ev: BeButtonEvent): boolean {\r\n if (InputSource.Mouse === ev.inputSource && BeButton.Data === ev.button && ev.isDown && ev.viewport)\r\n this.onMouseButtonEvent.raiseEvent(this);\r\n\r\n return true; // Don't allow clicks to be sent to active tool...\r\n }\r\n\r\n /** @internal */\r\n public override addMarker(context: DecorateContext) {\r\n super.addMarker(context);\r\n if (this.isHilited)\r\n ViewClipTool.drawClip(context, this.state.clip, undefined, { fillClipPlanes: true, hasPrimaryPlane: true });\r\n }\r\n}\r\n\r\n/** A Marker used to show a cluster of section locations.\r\n * @internal\r\n */\r\nexport class SectionMarkerCluster extends Marker {\r\n /** Create a new cluster marker */\r\n constructor(location: XYAndZ, size: XAndY, cluster: Cluster<SectionMarker>, image: MarkerImage | Promise<MarkerImage> | undefined) {\r\n super(location, size);\r\n\r\n this.imageOffset = new Point3d(0, 30);\r\n this.label = cluster.markers.length.toLocaleString();\r\n this.labelColor = \"black\";\r\n this.labelFont = \"bold 14px sans-serif\";\r\n\r\n const maxLen = 10;\r\n let title = \"\";\r\n cluster.markers.forEach((marker, index: number) => {\r\n if (index < maxLen) {\r\n if (title !== \"\")\r\n title += \"<br>\";\r\n title += marker.description;\r\n }\r\n });\r\n\r\n if (cluster.markers.length > maxLen)\r\n title += \"<br>...\";\r\n\r\n const div = document.createElement(\"div\");\r\n div.innerHTML = title;\r\n this.title = div;\r\n if (image)\r\n this.setImage(image);\r\n }\r\n\r\n /** Show the cluster as a white circle with an outline */\r\n public override drawFunc(ctx: CanvasRenderingContext2D): void {\r\n ctx.beginPath();\r\n ctx.strokeStyle = \"#372528\";\r\n ctx.fillStyle = \"white\";\r\n ctx.lineWidth = 5;\r\n ctx.arc(0, 0, 13, 0, Math.PI * 2);\r\n ctx.fill();\r\n ctx.stroke();\r\n }\r\n\r\n public override onMouseButton(_ev: BeButtonEvent): boolean { return true; } // Don't allow clicks to be sent to active tool...\r\n}\r\n\r\n/** A [MarkerSet]($frontend) containing [[SectionMarker]]s identifying [SectionDrawingLocation]($backend)s within a spatial view.\r\n * Typically used indirectly via [[HyperModelingDecorator]].\r\n * @public\r\n */\r\nexport class SectionMarkerSet extends MarkerSet<SectionMarker> {\r\n public override minimumClusterSize = 5;\r\n\r\n /** Constructor\r\n * @param viewport The viewport in which the markers are to be displayed.\r\n * @param markers The markers to be displayed.\r\n * @note Each marker's [[SectionDrawingLocationState]] must be associated with the same [IModelConnection]($frontend) as the viewport; any markers from other iModels will be omitted.\r\n */\r\n public constructor(viewport: ScreenViewport, markers: SectionMarker[]) {\r\n super(viewport);\r\n for (const marker of markers) {\r\n if (marker.state.iModel === viewport.iModel)\r\n this.markers.add(marker);\r\n }\r\n }\r\n\r\n /** The viewport in which the markers are to be displayed. */\r\n public override get viewport(): ScreenViewport {\r\n assert(undefined !== super.viewport);\r\n return super.viewport;\r\n }\r\n\r\n /** @internal */\r\n protected getClusterMarker(cluster: Cluster<SectionMarker>): Marker {\r\n return new SectionMarkerCluster(cluster.getClusterLocation(), cluster.markers[0].size, cluster, cluster.markers[0].image);\r\n }\r\n\r\n /** Find the SectionMarker corresponding to the specified [SectionDrawingLocation]($backend) Id. */\r\n public findMarkerById(sectionDrawingLocationId: Id64String): SectionMarker | undefined {\r\n for (const marker of this.markers)\r\n if (marker.state.id === sectionDrawingLocationId)\r\n return marker;\r\n\r\n return undefined;\r\n }\r\n}\r\n"]}
1
+ {"version":3,"file":"SectionMarkers.js","sourceRoot":"","sources":["../../src/SectionMarkers.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAkE;AAClE,wDAAuE;AACvE,oDAA4D;AAC5D,wDAE8B;AAE9B,mDAAgD;AAEhD,MAAM,UAAU,GAAG,uBAAO,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAE1C;;;;;GAKG;AACH,MAAa,aAAc,SAAQ,sBAAM;IAYvC;;;;;;OAMG;IACH,YAAmB,KAAkC;QACnD,KAAK,CAAC,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,KAAK,EAAE,EAAE,UAAU,CAAC,CAAC;QAfpD,gBAAgB;QACA,sBAAiB,GAAG,IAAI,sBAAO,EAAmC,CAAC;QACnF,gBAAgB;QACA,uBAAkB,GAAG,IAAI,sBAAO,EAAmC,CAAC;QACpF,gBAAgB;QACR,cAAS,GAAG,KAAK,CAAC;QAWxB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QAEnB,MAAM,IAAI,GAAG,6BAAa,CAAC,aAAa,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAC5D,IAAI,CAAC,WAAW,GAAG,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A1CD,oDA0CC;AAED;;;GAGG;AACH,MAAa,gBAAiB,SAAQ,yBAAwB;IAG5D;;;;OAIG;IACH,YAAmB,QAAwB,EAAE,OAAwB;QACnE,KAAK,CAAC,QAAQ,CAAC,CAAC;QARF,uBAAkB,GAAG,CAAC,CAAC;QASrC,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE;YAC5B,IAAI,MAAM,CAAC,KAAK,CAAC,MAAM,KAAK,QAAQ,CAAC,MAAM;gBACzC,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;SAC5B;IACH,CAAC;IAED,6DAA6D;IAC7D,IAAoB,QAAQ;QAC1B,IAAA,qBAAM,EAAC,SAAS,KAAK,KAAK,CAAC,QAAQ,CAAC,CAAC;QACrC,OAAO,KAAK,CAAC,QAAQ,CAAC;IACxB,CAAC;IAED,gBAAgB;IACN,gBAAgB,CAAC,OAA+B;QACxD,OAAO,IAAI,oBAAoB,CAAC,OAAO,CAAC,kBAAkB,EAAE,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAC5H,CAAC;IAED,mGAAmG;IAC5F,cAAc,CAAC,wBAAoC;QACxD,KAAK,MAAM,MAAM,IAAI,IAAI,CAAC,OAAO;YAC/B,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE,KAAK,wBAAwB;gBAC9C,OAAO,MAAM,CAAC;QAElB,OAAO,SAAS,CAAC;IACnB,CAAC;CACF;AAnCD,4CAmCC","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 { assert, BeEvent, Id64String } from \"@itwin/core-bentley\";\nimport { Point2d, Point3d, XAndY, XYAndZ } from \"@itwin/core-geometry\";\nimport { IModelReadRpcInterface } from \"@itwin/core-common\";\nimport {\n BeButton, BeButtonEvent, Cluster, DecorateContext, IModelApp, InputSource, Marker, MarkerImage, MarkerSet, ScreenViewport, ViewClipTool,\n} from \"@itwin/core-frontend\";\nimport { SectionDrawingLocationState } from \"./SectionDrawingLocationState\";\nimport { HyperModeling } from \"./HyperModeling\";\n\nconst markerSize = Point2d.create(40, 40);\n\n/** A [Marker]($frontend) associated with a [[SectionDrawingLocationState]], displayed as a canvas decoration at the location of the section.\n * Clicking on the marker toggles display of the section graphics. Mousing over the marker produces a toolbar with additional interactions.\n * @see [[HyperModelingDecorator]] for a [Decorator]($frontend) capable of displaying section markers for each section drawing location.\n * @see [[SectionMarkerHandler]] to customize the marker interactions.\n * @public\n */\nexport class SectionMarker extends Marker {\n /** The section drawing location state associated with the marker. */\n public readonly state: SectionDrawingLocationState;\n /** A description displayed as part of the tooltip when this marker is clustered with other markers. */\n public readonly description: string;\n /** @internal */\n public readonly onMouseEnterEvent = new BeEvent<(marker: SectionMarker) => void>();\n /** @internal */\n public readonly onMouseButtonEvent = new BeEvent<(marker: SectionMarker) => void>();\n /** @internal */\n private _isActive = false;\n\n /** Constructor, typically invoked indirectly via [[HyperModelingDecorator]].\n * @param state The section drawing location state this marker will represent.\n * @param pos The world coordinates at which to display the marker.\n * @param description A brief description of this marker, used as part of the tooltip when this marker is part of a cluster.\n * @param icon The icon displayed by the marker.\n * @param tooltip Optional detailed tooltip displayed on mouse hover. If undefined, the `description` is used instead.\n */\n public constructor(state: SectionDrawingLocationState) {\n super(state.placement.origin.clone(), markerSize);\n this.state = state;\n\n const data = HyperModeling.getMarkerData(state.sectionType);\n this.description = data.label;\n if (data.image)\n this.setImage(data.image);\n\n this.setScaleFactor({ low: .2, high: 1.4 }); // make size 20% at back of frustum and 140% at front of frustum (if camera is on)\n }\n\n /** @internal */\n public get isHilited(): boolean { return this._isHilited; }\n\n /** Returns true if this is the \"active\" section marker. At most one marker is active at a given time.\n * @see [[HyperModelingDecorator.activeMarker]].\n * @see [[HyperModelingDecorator.setActiveMarker]].\n * @see [[SectionMarkerHandler.toggleMarker]].\n */\n public get isActive(): boolean {\n return this._isActive;\n }\n\n /** @internal */\n public setActive(active: boolean): void {\n this._isActive = active;\n }\n\n /** @internal */\n protected drawActive(ctx: CanvasRenderingContext2D) {\n ctx.shadowBlur = 30;\n ctx.shadowColor = \"gold\";\n return false;\n }\n\n /** @internal */\n public override drawDecoration(ctx: CanvasRenderingContext2D): void {\n if (!this.isActive || !this.drawActive(ctx))\n super.drawDecoration(ctx);\n }\n\n /** @internal */\n public override onMouseEnter(ev: BeButtonEvent) {\n // Lazily load the tooltip.\n if (undefined === this.title) {\n IModelReadRpcInterface.getClientForRouting(this.state.iModel.routingContext.token).getToolTipMessage(this.state.iModel.getRpcProps(), this.state.id).then((tooltipMsg) => {\n this.title = IModelApp.formatElementToolTip(tooltipMsg);\n }).catch((_) => {\n this.title = this.description;\n });\n }\n\n super.onMouseEnter(ev);\n this.onMouseEnterEvent.raiseEvent(this);\n }\n\n /** @internal */\n public override onMouseButton(ev: BeButtonEvent): boolean {\n if (InputSource.Mouse === ev.inputSource && BeButton.Data === ev.button && ev.isDown && ev.viewport)\n this.onMouseButtonEvent.raiseEvent(this);\n\n return true; // Don't allow clicks to be sent to active tool...\n }\n\n /** @internal */\n public override addMarker(context: DecorateContext) {\n super.addMarker(context);\n if (this.isHilited)\n ViewClipTool.drawClip(context, this.state.clip, undefined, { fillClipPlanes: true, hasPrimaryPlane: true });\n }\n}\n\n/** A Marker used to show a cluster of section locations.\n * @internal\n */\nexport class SectionMarkerCluster extends Marker {\n /** Create a new cluster marker */\n constructor(location: XYAndZ, size: XAndY, cluster: Cluster<SectionMarker>, image: MarkerImage | Promise<MarkerImage> | undefined) {\n super(location, size);\n\n this.imageOffset = new Point3d(0, 30);\n this.label = cluster.markers.length.toLocaleString();\n this.labelColor = \"black\";\n this.labelFont = \"bold 14px sans-serif\";\n\n const maxLen = 10;\n let title = \"\";\n cluster.markers.forEach((marker, index: number) => {\n if (index < maxLen) {\n if (title !== \"\")\n title += \"<br>\";\n title += marker.description;\n }\n });\n\n if (cluster.markers.length > maxLen)\n title += \"<br>...\";\n\n const div = document.createElement(\"div\");\n div.innerHTML = title;\n this.title = div;\n if (image)\n this.setImage(image);\n }\n\n /** Show the cluster as a white circle with an outline */\n public override drawFunc(ctx: CanvasRenderingContext2D): void {\n ctx.beginPath();\n ctx.strokeStyle = \"#372528\";\n ctx.fillStyle = \"white\";\n ctx.lineWidth = 5;\n ctx.arc(0, 0, 13, 0, Math.PI * 2);\n ctx.fill();\n ctx.stroke();\n }\n\n public override onMouseButton(_ev: BeButtonEvent): boolean { return true; } // Don't allow clicks to be sent to active tool...\n}\n\n/** A [MarkerSet]($frontend) containing [[SectionMarker]]s identifying [SectionDrawingLocation]($backend)s within a spatial view.\n * Typically used indirectly via [[HyperModelingDecorator]].\n * @public\n */\nexport class SectionMarkerSet extends MarkerSet<SectionMarker> {\n public override minimumClusterSize = 5;\n\n /** Constructor\n * @param viewport The viewport in which the markers are to be displayed.\n * @param markers The markers to be displayed.\n * @note Each marker's [[SectionDrawingLocationState]] must be associated with the same [IModelConnection]($frontend) as the viewport; any markers from other iModels will be omitted.\n */\n public constructor(viewport: ScreenViewport, markers: SectionMarker[]) {\n super(viewport);\n for (const marker of markers) {\n if (marker.state.iModel === viewport.iModel)\n this.markers.add(marker);\n }\n }\n\n /** The viewport in which the markers are to be displayed. */\n public override get viewport(): ScreenViewport {\n assert(undefined !== super.viewport);\n return super.viewport;\n }\n\n /** @internal */\n protected getClusterMarker(cluster: Cluster<SectionMarker>): Marker {\n return new SectionMarkerCluster(cluster.getClusterLocation(), cluster.markers[0].size, cluster, cluster.markers[0].image);\n }\n\n /** Find the SectionMarker corresponding to the specified [SectionDrawingLocation]($backend) Id. */\n public findMarkerById(sectionDrawingLocationId: Id64String): SectionMarker | undefined {\n for (const marker of this.markers)\n if (marker.state.id === sectionDrawingLocationId)\n return marker;\n\n return undefined;\n }\n}\n"]}
@@ -1,6 +1,6 @@
1
- /** @packageDocumentation
2
- * @module HyperModeling
3
- */
4
- /** @internal */
5
- export declare function registerTools(namespace: string): void;
1
+ /** @packageDocumentation
2
+ * @module HyperModeling
3
+ */
4
+ /** @internal */
5
+ export declare function registerTools(namespace: string): void;
6
6
  //# sourceMappingURL=Tools.d.ts.map