@itwin/hypermodeling-frontend 3.7.0-dev.7 → 3.7.0-dev.8

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,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,169 +1,169 @@
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, BeEvent } from "@itwin/core-bentley";
9
- import { Point2d, Point3d } from "@itwin/core-geometry";
10
- import { IModelReadRpcInterface } from "@itwin/core-common";
11
- import { BeButton, IModelApp, InputSource, Marker, MarkerSet, ViewClipTool, } from "@itwin/core-frontend";
12
- import { HyperModeling } from "./HyperModeling";
13
- const markerSize = Point2d.create(40, 40);
14
- /** A [Marker]($frontend) associated with a [[SectionDrawingLocationState]], displayed as a canvas decoration at the location of the section.
15
- * Clicking on the marker toggles display of the section graphics. Mousing over the marker produces a toolbar with additional interactions.
16
- * @see [[HyperModelingDecorator]] for a [Decorator]($frontend) capable of displaying section markers for each section drawing location.
17
- * @see [[SectionMarkerHandler]] to customize the marker interactions.
18
- * @public
19
- */
20
- export class SectionMarker extends Marker {
21
- /** Constructor, typically invoked indirectly via [[HyperModelingDecorator]].
22
- * @param state The section drawing location state this marker will represent.
23
- * @param pos The world coordinates at which to display the marker.
24
- * @param description A brief description of this marker, used as part of the tooltip when this marker is part of a cluster.
25
- * @param icon The icon displayed by the marker.
26
- * @param tooltip Optional detailed tooltip displayed on mouse hover. If undefined, the `description` is used instead.
27
- */
28
- constructor(state) {
29
- super(state.placement.origin.clone(), markerSize);
30
- /** @internal */
31
- this.onMouseEnterEvent = new BeEvent();
32
- /** @internal */
33
- this.onMouseButtonEvent = new BeEvent();
34
- /** @internal */
35
- this._isActive = false;
36
- this.state = state;
37
- const data = HyperModeling.getMarkerData(state.sectionType);
38
- this.description = data.label;
39
- if (data.image)
40
- this.setImage(data.image);
41
- this.setScaleFactor({ low: .2, high: 1.4 }); // make size 20% at back of frustum and 140% at front of frustum (if camera is on)
42
- }
43
- /** @internal */
44
- get isHilited() { return this._isHilited; }
45
- /** Returns true if this is the "active" section marker. At most one marker is active at a given time.
46
- * @see [[HyperModelingDecorator.activeMarker]].
47
- * @see [[HyperModelingDecorator.setActiveMarker]].
48
- * @see [[SectionMarkerHandler.toggleMarker]].
49
- */
50
- get isActive() {
51
- return this._isActive;
52
- }
53
- /** @internal */
54
- setActive(active) {
55
- this._isActive = active;
56
- }
57
- /** @internal */
58
- drawActive(ctx) {
59
- ctx.shadowBlur = 30;
60
- ctx.shadowColor = "gold";
61
- return false;
62
- }
63
- /** @internal */
64
- drawDecoration(ctx) {
65
- if (!this.isActive || !this.drawActive(ctx))
66
- super.drawDecoration(ctx);
67
- }
68
- /** @internal */
69
- onMouseEnter(ev) {
70
- // Lazily load the tooltip.
71
- if (undefined === this.title) {
72
- IModelReadRpcInterface.getClientForRouting(this.state.iModel.routingContext.token).getToolTipMessage(this.state.iModel.getRpcProps(), this.state.id).then((tooltipMsg) => {
73
- this.title = IModelApp.formatElementToolTip(tooltipMsg);
74
- }).catch((_) => {
75
- this.title = this.description;
76
- });
77
- }
78
- super.onMouseEnter(ev);
79
- this.onMouseEnterEvent.raiseEvent(this);
80
- }
81
- /** @internal */
82
- onMouseButton(ev) {
83
- if (InputSource.Mouse === ev.inputSource && BeButton.Data === ev.button && ev.isDown && ev.viewport)
84
- this.onMouseButtonEvent.raiseEvent(this);
85
- return true; // Don't allow clicks to be sent to active tool...
86
- }
87
- /** @internal */
88
- addMarker(context) {
89
- super.addMarker(context);
90
- if (this.isHilited)
91
- ViewClipTool.drawClip(context, this.state.clip, undefined, { fillClipPlanes: true, hasPrimaryPlane: true });
92
- }
93
- }
94
- /** A Marker used to show a cluster of section locations.
95
- * @internal
96
- */
97
- export class SectionMarkerCluster extends Marker {
98
- /** Create a new cluster marker */
99
- constructor(location, size, cluster, image) {
100
- super(location, size);
101
- this.imageOffset = new Point3d(0, 30);
102
- this.label = cluster.markers.length.toLocaleString();
103
- this.labelColor = "black";
104
- this.labelFont = "bold 14px sans-serif";
105
- const maxLen = 10;
106
- let title = "";
107
- cluster.markers.forEach((marker, index) => {
108
- if (index < maxLen) {
109
- if (title !== "")
110
- title += "<br>";
111
- title += marker.description;
112
- }
113
- });
114
- if (cluster.markers.length > maxLen)
115
- title += "<br>...";
116
- const div = document.createElement("div");
117
- div.innerHTML = title;
118
- this.title = div;
119
- if (image)
120
- this.setImage(image);
121
- }
122
- /** Show the cluster as a white circle with an outline */
123
- drawFunc(ctx) {
124
- ctx.beginPath();
125
- ctx.strokeStyle = "#372528";
126
- ctx.fillStyle = "white";
127
- ctx.lineWidth = 5;
128
- ctx.arc(0, 0, 13, 0, Math.PI * 2);
129
- ctx.fill();
130
- ctx.stroke();
131
- }
132
- onMouseButton(_ev) { return true; } // Don't allow clicks to be sent to active tool...
133
- }
134
- /** A [MarkerSet]($frontend) containing [[SectionMarker]]s identifying [SectionDrawingLocation]($backend)s within a spatial view.
135
- * Typically used indirectly via [[HyperModelingDecorator]].
136
- * @public
137
- */
138
- export class SectionMarkerSet extends MarkerSet {
139
- /** Constructor
140
- * @param viewport The viewport in which the markers are to be displayed.
141
- * @param markers The markers to be displayed.
142
- * @note Each marker's [[SectionDrawingLocationState]] must be associated with the same [IModelConnection]($frontend) as the viewport; any markers from other iModels will be omitted.
143
- */
144
- constructor(viewport, markers) {
145
- super(viewport);
146
- this.minimumClusterSize = 5;
147
- for (const marker of markers) {
148
- if (marker.state.iModel === viewport.iModel)
149
- this.markers.add(marker);
150
- }
151
- }
152
- /** The viewport in which the markers are to be displayed. */
153
- get viewport() {
154
- assert(undefined !== super.viewport);
155
- return super.viewport;
156
- }
157
- /** @internal */
158
- getClusterMarker(cluster) {
159
- return new SectionMarkerCluster(cluster.getClusterLocation(), cluster.markers[0].size, cluster, cluster.markers[0].image);
160
- }
161
- /** Find the SectionMarker corresponding to the specified [SectionDrawingLocation]($backend) Id. */
162
- findMarkerById(sectionDrawingLocationId) {
163
- for (const marker of this.markers)
164
- if (marker.state.id === sectionDrawingLocationId)
165
- return marker;
166
- return undefined;
167
- }
168
- }
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, BeEvent } from "@itwin/core-bentley";
9
+ import { Point2d, Point3d } from "@itwin/core-geometry";
10
+ import { IModelReadRpcInterface } from "@itwin/core-common";
11
+ import { BeButton, IModelApp, InputSource, Marker, MarkerSet, ViewClipTool, } from "@itwin/core-frontend";
12
+ import { HyperModeling } from "./HyperModeling";
13
+ const markerSize = Point2d.create(40, 40);
14
+ /** A [Marker]($frontend) associated with a [[SectionDrawingLocationState]], displayed as a canvas decoration at the location of the section.
15
+ * Clicking on the marker toggles display of the section graphics. Mousing over the marker produces a toolbar with additional interactions.
16
+ * @see [[HyperModelingDecorator]] for a [Decorator]($frontend) capable of displaying section markers for each section drawing location.
17
+ * @see [[SectionMarkerHandler]] to customize the marker interactions.
18
+ * @public
19
+ */
20
+ export class SectionMarker extends Marker {
21
+ /** Constructor, typically invoked indirectly via [[HyperModelingDecorator]].
22
+ * @param state The section drawing location state this marker will represent.
23
+ * @param pos The world coordinates at which to display the marker.
24
+ * @param description A brief description of this marker, used as part of the tooltip when this marker is part of a cluster.
25
+ * @param icon The icon displayed by the marker.
26
+ * @param tooltip Optional detailed tooltip displayed on mouse hover. If undefined, the `description` is used instead.
27
+ */
28
+ constructor(state) {
29
+ super(state.placement.origin.clone(), markerSize);
30
+ /** @internal */
31
+ this.onMouseEnterEvent = new BeEvent();
32
+ /** @internal */
33
+ this.onMouseButtonEvent = new BeEvent();
34
+ /** @internal */
35
+ this._isActive = false;
36
+ this.state = state;
37
+ const data = HyperModeling.getMarkerData(state.sectionType);
38
+ this.description = data.label;
39
+ if (data.image)
40
+ this.setImage(data.image);
41
+ this.setScaleFactor({ low: .2, high: 1.4 }); // make size 20% at back of frustum and 140% at front of frustum (if camera is on)
42
+ }
43
+ /** @internal */
44
+ get isHilited() { return this._isHilited; }
45
+ /** Returns true if this is the "active" section marker. At most one marker is active at a given time.
46
+ * @see [[HyperModelingDecorator.activeMarker]].
47
+ * @see [[HyperModelingDecorator.setActiveMarker]].
48
+ * @see [[SectionMarkerHandler.toggleMarker]].
49
+ */
50
+ get isActive() {
51
+ return this._isActive;
52
+ }
53
+ /** @internal */
54
+ setActive(active) {
55
+ this._isActive = active;
56
+ }
57
+ /** @internal */
58
+ drawActive(ctx) {
59
+ ctx.shadowBlur = 30;
60
+ ctx.shadowColor = "gold";
61
+ return false;
62
+ }
63
+ /** @internal */
64
+ drawDecoration(ctx) {
65
+ if (!this.isActive || !this.drawActive(ctx))
66
+ super.drawDecoration(ctx);
67
+ }
68
+ /** @internal */
69
+ onMouseEnter(ev) {
70
+ // Lazily load the tooltip.
71
+ if (undefined === this.title) {
72
+ IModelReadRpcInterface.getClientForRouting(this.state.iModel.routingContext.token).getToolTipMessage(this.state.iModel.getRpcProps(), this.state.id).then((tooltipMsg) => {
73
+ this.title = IModelApp.formatElementToolTip(tooltipMsg);
74
+ }).catch((_) => {
75
+ this.title = this.description;
76
+ });
77
+ }
78
+ super.onMouseEnter(ev);
79
+ this.onMouseEnterEvent.raiseEvent(this);
80
+ }
81
+ /** @internal */
82
+ onMouseButton(ev) {
83
+ if (InputSource.Mouse === ev.inputSource && BeButton.Data === ev.button && ev.isDown && ev.viewport)
84
+ this.onMouseButtonEvent.raiseEvent(this);
85
+ return true; // Don't allow clicks to be sent to active tool...
86
+ }
87
+ /** @internal */
88
+ addMarker(context) {
89
+ super.addMarker(context);
90
+ if (this.isHilited)
91
+ ViewClipTool.drawClip(context, this.state.clip, undefined, { fillClipPlanes: true, hasPrimaryPlane: true });
92
+ }
93
+ }
94
+ /** A Marker used to show a cluster of section locations.
95
+ * @internal
96
+ */
97
+ export class SectionMarkerCluster extends Marker {
98
+ /** Create a new cluster marker */
99
+ constructor(location, size, cluster, image) {
100
+ super(location, size);
101
+ this.imageOffset = new Point3d(0, 30);
102
+ this.label = cluster.markers.length.toLocaleString();
103
+ this.labelColor = "black";
104
+ this.labelFont = "bold 14px sans-serif";
105
+ const maxLen = 10;
106
+ let title = "";
107
+ cluster.markers.forEach((marker, index) => {
108
+ if (index < maxLen) {
109
+ if (title !== "")
110
+ title += "<br>";
111
+ title += marker.description;
112
+ }
113
+ });
114
+ if (cluster.markers.length > maxLen)
115
+ title += "<br>...";
116
+ const div = document.createElement("div");
117
+ div.innerHTML = title;
118
+ this.title = div;
119
+ if (image)
120
+ this.setImage(image);
121
+ }
122
+ /** Show the cluster as a white circle with an outline */
123
+ drawFunc(ctx) {
124
+ ctx.beginPath();
125
+ ctx.strokeStyle = "#372528";
126
+ ctx.fillStyle = "white";
127
+ ctx.lineWidth = 5;
128
+ ctx.arc(0, 0, 13, 0, Math.PI * 2);
129
+ ctx.fill();
130
+ ctx.stroke();
131
+ }
132
+ onMouseButton(_ev) { return true; } // Don't allow clicks to be sent to active tool...
133
+ }
134
+ /** A [MarkerSet]($frontend) containing [[SectionMarker]]s identifying [SectionDrawingLocation]($backend)s within a spatial view.
135
+ * Typically used indirectly via [[HyperModelingDecorator]].
136
+ * @public
137
+ */
138
+ export class SectionMarkerSet extends MarkerSet {
139
+ /** Constructor
140
+ * @param viewport The viewport in which the markers are to be displayed.
141
+ * @param markers The markers to be displayed.
142
+ * @note Each marker's [[SectionDrawingLocationState]] must be associated with the same [IModelConnection]($frontend) as the viewport; any markers from other iModels will be omitted.
143
+ */
144
+ constructor(viewport, markers) {
145
+ super(viewport);
146
+ this.minimumClusterSize = 5;
147
+ for (const marker of markers) {
148
+ if (marker.state.iModel === viewport.iModel)
149
+ this.markers.add(marker);
150
+ }
151
+ }
152
+ /** The viewport in which the markers are to be displayed. */
153
+ get viewport() {
154
+ assert(undefined !== super.viewport);
155
+ return super.viewport;
156
+ }
157
+ /** @internal */
158
+ getClusterMarker(cluster) {
159
+ return new SectionMarkerCluster(cluster.getClusterLocation(), cluster.markers[0].size, cluster, cluster.markers[0].image);
160
+ }
161
+ /** Find the SectionMarker corresponding to the specified [SectionDrawingLocation]($backend) Id. */
162
+ findMarkerById(sectionDrawingLocationId) {
163
+ for (const marker of this.markers)
164
+ if (marker.state.id === sectionDrawingLocationId)
165
+ return marker;
166
+ return undefined;
167
+ }
168
+ }
169
169
  //# 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,OAAO,EAAE,MAAM,EAAE,OAAO,EAA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6DAA6D;IAC7D,IAAoB,QAAQ;QAC1B,MAAM,CAAC,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","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,OAAO,EAAE,MAAM,EAAE,OAAO,EAAc,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,OAAO,EAAE,OAAO,EAAiB,MAAM,sBAAsB,CAAC;AACvE,OAAO,EAAE,sBAAsB,EAAE,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EACL,QAAQ,EAA2C,SAAS,EAAE,WAAW,EAAE,MAAM,EAAe,SAAS,EAAkB,YAAY,GACxI,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC;AAE1C;;;;;GAKG;AACH,MAAM,OAAO,aAAc,SAAQ,MAAM;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,OAAO,EAAmC,CAAC;QACnF,gBAAgB;QACA,uBAAkB,GAAG,IAAI,OAAO,EAAmC,CAAC;QACpF,gBAAgB;QACR,cAAS,GAAG,KAAK,CAAC;QAWxB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QAEnB,MAAM,IAAI,GAAG,aAAa,CAAC,aAAa,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;QAC5D,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC;QAC9B,IAAI,IAAI,CAAC,KAAK;YACZ,I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,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,MAAM,CAAC,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","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