@itwin/hypermodeling-frontend 3.0.0-dev.72

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 (50) hide show
  1. package/CHANGELOG.md +714 -0
  2. package/LICENSE.md +9 -0
  3. package/README.md +40 -0
  4. package/lib/HyperModeling.d.ts +110 -0
  5. package/lib/HyperModeling.d.ts.map +1 -0
  6. package/lib/HyperModeling.js +225 -0
  7. package/lib/HyperModeling.js.map +1 -0
  8. package/lib/HyperModelingConfig.d.ts +55 -0
  9. package/lib/HyperModelingConfig.d.ts.map +1 -0
  10. package/lib/HyperModelingConfig.js +10 -0
  11. package/lib/HyperModelingConfig.js.map +1 -0
  12. package/lib/HyperModelingDecorator.d.ts +111 -0
  13. package/lib/HyperModelingDecorator.d.ts.map +1 -0
  14. package/lib/HyperModelingDecorator.js +338 -0
  15. package/lib/HyperModelingDecorator.js.map +1 -0
  16. package/lib/PopupToolbar.d.ts +25 -0
  17. package/lib/PopupToolbar.d.ts.map +1 -0
  18. package/lib/PopupToolbar.js +57 -0
  19. package/lib/PopupToolbar.js.map +1 -0
  20. package/lib/SectionDrawingLocationState.d.ts +91 -0
  21. package/lib/SectionDrawingLocationState.d.ts.map +1 -0
  22. package/lib/SectionDrawingLocationState.js +158 -0
  23. package/lib/SectionDrawingLocationState.js.map +1 -0
  24. package/lib/SectionGraphicsProvider.d.ts +14 -0
  25. package/lib/SectionGraphicsProvider.d.ts.map +1 -0
  26. package/lib/SectionGraphicsProvider.js +271 -0
  27. package/lib/SectionGraphicsProvider.js.map +1 -0
  28. package/lib/SectionMarkerHandler.d.ts +53 -0
  29. package/lib/SectionMarkerHandler.d.ts.map +1 -0
  30. package/lib/SectionMarkerHandler.js +113 -0
  31. package/lib/SectionMarkerHandler.js.map +1 -0
  32. package/lib/SectionMarkers.d.ts +83 -0
  33. package/lib/SectionMarkers.d.ts.map +1 -0
  34. package/lib/SectionMarkers.js +174 -0
  35. package/lib/SectionMarkers.js.map +1 -0
  36. package/lib/Tools.d.ts +7 -0
  37. package/lib/Tools.d.ts.map +1 -0
  38. package/lib/Tools.js +171 -0
  39. package/lib/Tools.js.map +1 -0
  40. package/lib/hypermodeling-frontend.d.ts +14 -0
  41. package/lib/hypermodeling-frontend.d.ts.map +1 -0
  42. package/lib/hypermodeling-frontend.js +30 -0
  43. package/lib/hypermodeling-frontend.js.map +1 -0
  44. package/lib/public/detail-marker.svg +1 -0
  45. package/lib/public/elevation-marker.svg +1 -0
  46. package/lib/public/locales/en/HyperModeling.json +32 -0
  47. package/lib/public/locales/en-PSEUDO/HyperModeling.json +32 -0
  48. package/lib/public/plan-marker.svg +1 -0
  49. package/lib/public/section-marker.svg +1 -0
  50. package/package.json +78 -0
@@ -0,0 +1,113 @@
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.SectionMarkerHandler = void 0;
11
+ const core_frontend_1 = require("@itwin/core-frontend");
12
+ /** Supplies interactions with [[SectionMarker]]s, including a mini-toolbar displayed when the mouse hovers over a marker and what action occurs when the user clicks a marker.
13
+ * The base implementation supplies the following interactions:
14
+ * * Click: Toggle display of the section graphics and clip volume; apply the section's spatial view if toggling on.
15
+ * * Toolbar:
16
+ * * Apply Section: Applies the section location's spatial view to the viewport and displays the 2d section graphics.
17
+ * * Open Drawing: Navigates to the section drawing view. By default, this applies the section drawing view to the viewport.
18
+ * * Open Sheet: Navigates to the [ViewAttachment]($backend) of the section drawing on a [Sheet]($backend). Disabled if no such attachment exists.
19
+ * @see [[HyperModelingConfig]] to override the default handler by supplying a subclass of `SectionMarkerHandler`.
20
+ * @see [[HyperModelingDecorator]] for various methods that might be usefully wired up to marker click or toolbar actions.
21
+ * @public
22
+ */
23
+ class SectionMarkerHandler {
24
+ /** Respond to activation of the specified marker. Return true if the marker should become the active marker - i.e., if the marker was successfully activated.
25
+ * @see [[SectionMarkerHandler.deactivateMarker]].
26
+ */
27
+ async activateMarker(marker, decorator) {
28
+ return decorator.toggleSection(marker, true);
29
+ }
30
+ /** Respond to deactivation of the specified marker. Invoked when the user clicks on the marker while it is the active marker.
31
+ * This should perform the inverse of [[SectionMarkerHandler.activateMarker]]. The marker becomes inactive as a result.
32
+ */
33
+ async deactivateMarker(marker, decorator) {
34
+ await decorator.toggleSection(marker, false);
35
+ }
36
+ /** Return toolbar items for the specified marker. If the array of toolbar items is empty, no toolbar will be displayed.
37
+ * @see [[executeCommand]] to implement each toolbar command.
38
+ */
39
+ getToolbarProps(marker, _decorator) {
40
+ var _a;
41
+ const i18n = core_frontend_1.IModelApp.i18n;
42
+ return {
43
+ items: [
44
+ {
45
+ id: "apply_view",
46
+ itemPriority: 10,
47
+ label: i18n.translate("HyperModeling:Message.ApplyView"),
48
+ icon: "icon-spatial-view-apply",
49
+ execute: () => { },
50
+ isDisabled: false,
51
+ },
52
+ {
53
+ id: "open_section",
54
+ itemPriority: 20,
55
+ label: i18n.translate("HyperModeling:Message.OpenSection"),
56
+ icon: "icon-plan-drawing",
57
+ execute: () => { },
58
+ isDisabled: false,
59
+ },
60
+ {
61
+ id: "open_sheet",
62
+ itemPriority: 30,
63
+ label: i18n.translate("HyperModeling:Message.OpenSheet"),
64
+ icon: "icon-plan-floor",
65
+ execute: () => { },
66
+ isDisabled: undefined === ((_a = marker.state.viewAttachment) === null || _a === void 0 ? void 0 : _a.viewId),
67
+ },
68
+ ],
69
+ };
70
+ }
71
+ /** Execute the command associated with the specified tool bar item.
72
+ * @see [[getToolbarProps]] to define the set of commands.
73
+ */
74
+ async executeCommand(commandId, marker, decorator) {
75
+ switch (commandId) {
76
+ case "apply_view":
77
+ await decorator.applySpatialView(marker);
78
+ break;
79
+ case "open_section":
80
+ await decorator.openSection(marker);
81
+ break;
82
+ case "open_sheet":
83
+ await decorator.openSheet(marker);
84
+ break;
85
+ }
86
+ }
87
+ /** Customize which markers are visible. [[HyperModelingDecorator]] determines marker visibility as follows:
88
+ * - If a marker is currently active (selected), only that marker is visible.
89
+ * - Otherwise, the marker is visible if this method returns `true`.
90
+ * The default implementation of this method determines visibility based on the [[SectionMarkerConfig]] as follows.
91
+ * - If the marker is of a type included in the config's `hiddenSectionTypes`, it is invisible.
92
+ * - If the marker belongs to a model not currently displayed in the viewport and the config's `ignoreModelSelector` is false, it is invisible.
93
+ * - If the marker belongs to a category not currently displayed in the viewport and the config's `ignoreCategorySelector` is false, it is invisible,
94
+ * - Otherwise, the marker is visible, unless this method returns `false`.
95
+ * The default implementation of this method always returns `true`
96
+ * @param marker The marker whose visibility is to be determined.
97
+ * @param decorator The hypermodeling decorator to which the marker belongs.
98
+ * @param config The configuration controlling marker visibility based on [SectionType]($common), [ModelSelectorState]($frontend), and [CategorySelectorState]($frontend).
99
+ * @returns true if the marker should be displayed; false to make it invisible.
100
+ * @see [[HyperModelingDecorator.requestSync]] to force the decorator to reevaluate marker visibility when the criterion used by your implementation of this method changes.
101
+ */
102
+ isMarkerVisible(marker, decorator, config) {
103
+ if (undefined !== config.hiddenSectionTypes && config.hiddenSectionTypes.includes(marker.state.sectionType))
104
+ return false;
105
+ if (!config.ignoreCategorySelector && !decorator.viewport.view.viewsCategory(marker.state.category))
106
+ return false;
107
+ if (!config.ignoreModelSelector && !decorator.viewport.view.viewsModel(marker.state.model))
108
+ return false;
109
+ return true;
110
+ }
111
+ }
112
+ exports.SectionMarkerHandler = SectionMarkerHandler;
113
+ //# sourceMappingURL=SectionMarkerHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SectionMarkerHandler.js","sourceRoot":"","sources":["../src/SectionMarkerHandler.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,wDAAiD;AAMjD;;;;;;;;;;GAUG;AACH,MA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,EAAE,SAAiC;QACrG,QAAQ,SAAS,EAAE;YACjB,KAAK,YAAY;gBACf,MAAM,SAAS,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAC;gBACzC,MAAM;YACR,KAAK,cAAc;gBACjB,MAAM,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;gBACpC,MAAM;YACR,KAAK,YAAY;gBACf,MAAM,SAAS,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;gBAClC,MAAM;SACT;IACH,CAAC;IAED;;;;;;;;;;;;;;OAcG;IACI,eAAe,CAAC,MAAqB,EAAE,SAAiC,EAAE,MAA2B;QAC1G,IAAI,SAAS,KAAK,MAAM,CAAC,kBAAkB,IAAI,MAAM,CAAC,kBAAkB,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,WAAW,CAAC;YACzG,OAAO,KAAK,CAAC;QAEf,IAAI,CAAC,MAAM,CAAC,sBAAsB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,MAAM,CAAC,KAAK,CAAC,QAAQ,CAAC;YACjG,OAAO,KAAK,CAAC;QAEf,IAAI,CAAC,MAAM,CAAC,mBAAmB,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,KAAK,CAAC,KAAK,CAAC;YACxF,OAAO,KAAK,CAAC;QAEf,OAAO,IAAI,CAAC;IACd,CAAC;CACF;AA9FD,oDA8FC","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 { IModelApp } from \"@itwin/core-frontend\";\r\nimport { AbstractToolbarProps } from \"@itwin/appui-abstract\";\r\nimport { SectionMarker } from \"./SectionMarkers\";\r\nimport { SectionMarkerConfig } from \"./HyperModelingConfig\";\r\nimport { HyperModelingDecorator } from \"./HyperModelingDecorator\";\r\n\r\n/** Supplies interactions with [[SectionMarker]]s, including a mini-toolbar displayed when the mouse hovers over a marker and what action occurs when the user clicks a marker.\r\n * The base implementation supplies the following interactions:\r\n * * Click: Toggle display of the section graphics and clip volume; apply the section's spatial view if toggling on.\r\n * * Toolbar:\r\n * * Apply Section: Applies the section location's spatial view to the viewport and displays the 2d section graphics.\r\n * * Open Drawing: Navigates to the section drawing view. By default, this applies the section drawing view to the viewport.\r\n * * Open Sheet: Navigates to the [ViewAttachment]($backend) of the section drawing on a [Sheet]($backend). Disabled if no such attachment exists.\r\n * @see [[HyperModelingConfig]] to override the default handler by supplying a subclass of `SectionMarkerHandler`.\r\n * @see [[HyperModelingDecorator]] for various methods that might be usefully wired up to marker click or toolbar actions.\r\n * @public\r\n */\r\nexport class SectionMarkerHandler {\r\n /** Respond to activation of the specified marker. Return true if the marker should become the active marker - i.e., if the marker was successfully activated.\r\n * @see [[SectionMarkerHandler.deactivateMarker]].\r\n */\r\n public async activateMarker(marker: SectionMarker, decorator: HyperModelingDecorator): Promise<boolean> {\r\n return decorator.toggleSection(marker, true);\r\n }\r\n\r\n /** Respond to deactivation of the specified marker. Invoked when the user clicks on the marker while it is the active marker.\r\n * This should perform the inverse of [[SectionMarkerHandler.activateMarker]]. The marker becomes inactive as a result.\r\n */\r\n public async deactivateMarker(marker: SectionMarker, decorator: HyperModelingDecorator): Promise<void> {\r\n await decorator.toggleSection(marker, false);\r\n }\r\n\r\n /** Return toolbar items for the specified marker. If the array of toolbar items is empty, no toolbar will be displayed.\r\n * @see [[executeCommand]] to implement each toolbar command.\r\n */\r\n public getToolbarProps(marker: SectionMarker, _decorator: HyperModelingDecorator): AbstractToolbarProps {\r\n const i18n = IModelApp.i18n;\r\n return {\r\n items: [\r\n {\r\n id: \"apply_view\",\r\n itemPriority: 10,\r\n label: i18n.translate(\"HyperModeling:Message.ApplyView\"),\r\n icon: \"icon-spatial-view-apply\",\r\n execute: () => { },\r\n isDisabled: false,\r\n },\r\n {\r\n id: \"open_section\",\r\n itemPriority: 20,\r\n label: i18n.translate(\"HyperModeling:Message.OpenSection\"),\r\n icon: \"icon-plan-drawing\",\r\n execute: () => { },\r\n isDisabled: false,\r\n },\r\n {\r\n id: \"open_sheet\",\r\n itemPriority: 30,\r\n label: i18n.translate(\"HyperModeling:Message.OpenSheet\"),\r\n icon: \"icon-plan-floor\",\r\n execute: () => { },\r\n isDisabled: undefined === marker.state.viewAttachment?.viewId,\r\n },\r\n ],\r\n };\r\n }\r\n\r\n /** Execute the command associated with the specified tool bar item.\r\n * @see [[getToolbarProps]] to define the set of commands.\r\n */\r\n public async executeCommand(commandId: string, marker: SectionMarker, decorator: HyperModelingDecorator): Promise<void> {\r\n switch (commandId) {\r\n case \"apply_view\":\r\n await decorator.applySpatialView(marker);\r\n break;\r\n case \"open_section\":\r\n await decorator.openSection(marker);\r\n break;\r\n case \"open_sheet\":\r\n await decorator.openSheet(marker);\r\n break;\r\n }\r\n }\r\n\r\n /** Customize which markers are visible. [[HyperModelingDecorator]] determines marker visibility as follows:\r\n * - If a marker is currently active (selected), only that marker is visible.\r\n * - Otherwise, the marker is visible if this method returns `true`.\r\n * The default implementation of this method determines visibility based on the [[SectionMarkerConfig]] as follows.\r\n * - If the marker is of a type included in the config's `hiddenSectionTypes`, it is invisible.\r\n * - If the marker belongs to a model not currently displayed in the viewport and the config's `ignoreModelSelector` is false, it is invisible.\r\n * - If the marker belongs to a category not currently displayed in the viewport and the config's `ignoreCategorySelector` is false, it is invisible,\r\n * - Otherwise, the marker is visible, unless this method returns `false`.\r\n * The default implementation of this method always returns `true`\r\n * @param marker The marker whose visibility is to be determined.\r\n * @param decorator The hypermodeling decorator to which the marker belongs.\r\n * @param config The configuration controlling marker visibility based on [SectionType]($common), [ModelSelectorState]($frontend), and [CategorySelectorState]($frontend).\r\n * @returns true if the marker should be displayed; false to make it invisible.\r\n * @see [[HyperModelingDecorator.requestSync]] to force the decorator to reevaluate marker visibility when the criterion used by your implementation of this method changes.\r\n */\r\n public isMarkerVisible(marker: SectionMarker, decorator: HyperModelingDecorator, config: SectionMarkerConfig): boolean {\r\n if (undefined !== config.hiddenSectionTypes && config.hiddenSectionTypes.includes(marker.state.sectionType))\r\n return false;\r\n\r\n if (!config.ignoreCategorySelector && !decorator.viewport.view.viewsCategory(marker.state.category))\r\n return false;\r\n\r\n if (!config.ignoreModelSelector && !decorator.viewport.view.viewsModel(marker.state.model))\r\n return false;\r\n\r\n return true;\r\n }\r\n}\r\n"]}
@@ -0,0 +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: Promise<MarkerImage>);
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
+ //# sourceMappingURL=SectionMarkers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SectionMarkers.d.ts","sourceRoot":"","sources":["../src/SectionMarkers.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAU,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAoB,KAAK,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAEvE,OAAO,EACK,aAAa,EAAE,OAAO,EAAE,eAAe,EAA0B,MAAM,EAAE,WAAW,EAAE,SAAS,EAAE,cAAc,EAC1H,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,2BAA2B,EAAE,MAAM,+BAA+B,CAAC;AAK5E;;;;;GAKG;AACH,qBAAa,aAAc,SAAQ,MAAM;IACvC,qEAAqE;IACrE,SAAgB,KAAK,EAAE,2BAA2B,CAAC;IACnD,uGAAuG;IACvG,SAAgB,WAAW,EAAE,MAAM,CAAC;IACpC,gBAAgB;IAChB,SAAgB,iBAAiB,mBAAwB,aAAa,KAAK,IAAI,EAAI;IACnF,gBAAgB;IAChB,SAAgB,kBAAkB,mBAAwB,aAAa,KAAK,IAAI,EAAI;IACpF,gBAAgB;IAChB,OAAO,CAAC,SAAS,CAAS;IAE1B;;;;;;OAMG;gBACgB,KAAK,EAAE,2BAA2B;IAYrD,gBAAgB;IAChB,IAAW,SAAS,IAAI,OAAO,CAA4B;IAE3D;;;;OAIG;IACH,IAAW,QAAQ,IAAI,OAAO,CAE7B;IAED,gBAAgB;IACT,SAAS,CAAC,MAAM,EAAE,OAAO,GAAG,IAAI;IAIvC,gBAAgB;IAChB,SAAS,CAAC,UAAU,CAAC,GAAG,EAAE,wBAAwB;IAMlD,gBAAgB;IACA,cAAc,CAAC,GAAG,EAAE,wBAAwB,GAAG,IAAI;IAKnE,gBAAgB;IACA,YAAY,CAAC,EAAE,EAAE,aAAa;IAc9C,gBAAgB;IACA,aAAa,CAAC,EAAE,EAAE,aAAa,GAAG,OAAO;IAOzD,gBAAgB;IACA,SAAS,CAAC,OAAO,EAAE,eAAe;CAKnD;AAED;;GAEG;AACH,qBAAa,oBAAqB,SAAQ,MAAM;IAC9C,kCAAkC;gBACtB,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,EAAE,KAAK,EAAE,OAAO,CAAC,WAAW,CAAC;IA2BvG,yDAAyD;IACzC,QAAQ,CAAC,GAAG,EAAE,wBAAwB,GAAG,IAAI;IAU7C,aAAa,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO;CAC3D;AAED;;;GAGG;AACH,qBAAa,gBAAiB,SAAQ,SAAS,CAAC,aAAa,CAAC;IAC5C,kBAAkB,SAAK;IAEvC;;;;OAIG;gBACgB,QAAQ,EAAE,cAAc,EAAE,OAAO,EAAE,aAAa,EAAE;IAQrE,6DAA6D;IAC7D,IAAoB,QAAQ,IAAI,cAAc,CAG7C;IAED,gBAAgB;IAChB,SAAS,CAAC,gBAAgB,CAAC,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,GAAG,MAAM;IAInE,mGAAmG;IAC5F,cAAc,CAAC,wBAAwB,EAAE,UAAU,GAAG,aAAa,GAAG,SAAS;CAOvF"}
@@ -0,0 +1,174 @@
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
+ this.setImage(image);
124
+ }
125
+ /** Show the cluster as a white circle with an outline */
126
+ drawFunc(ctx) {
127
+ ctx.beginPath();
128
+ ctx.strokeStyle = "#372528";
129
+ ctx.fillStyle = "white";
130
+ ctx.lineWidth = 5;
131
+ ctx.arc(0, 0, 13, 0, Math.PI * 2);
132
+ ctx.fill();
133
+ ctx.stroke();
134
+ }
135
+ onMouseButton(_ev) { return true; } // Don't allow clicks to be sent to active tool...
136
+ }
137
+ exports.SectionMarkerCluster = SectionMarkerCluster;
138
+ /** A [MarkerSet]($frontend) containing [[SectionMarker]]s identifying [SectionDrawingLocation]($backend)s within a spatial view.
139
+ * Typically used indirectly via [[HyperModelingDecorator]].
140
+ * @public
141
+ */
142
+ class SectionMarkerSet extends core_frontend_1.MarkerSet {
143
+ /** Constructor
144
+ * @param viewport The viewport in which the markers are to be displayed.
145
+ * @param markers The markers to be displayed.
146
+ * @note Each marker's [[SectionDrawingLocationState]] must be associated with the same [IModelConnection]($frontend) as the viewport; any markers from other iModels will be omitted.
147
+ */
148
+ constructor(viewport, markers) {
149
+ super(viewport);
150
+ this.minimumClusterSize = 5;
151
+ for (const marker of markers) {
152
+ if (marker.state.iModel === viewport.iModel)
153
+ this.markers.add(marker);
154
+ }
155
+ }
156
+ /** The viewport in which the markers are to be displayed. */
157
+ get viewport() {
158
+ (0, core_bentley_1.assert)(undefined !== super.viewport);
159
+ return super.viewport;
160
+ }
161
+ /** @internal */
162
+ getClusterMarker(cluster) {
163
+ return SectionMarkerCluster.makeFrom(cluster.markers[0], cluster, cluster.markers[0].image);
164
+ }
165
+ /** Find the SectionMarker corresponding to the specified [SectionDrawingLocation]($backend) Id. */
166
+ findMarkerById(sectionDrawingLocationId) {
167
+ for (const marker of this.markers)
168
+ if (marker.state.id === sectionDrawingLocationId)
169
+ return marker;
170
+ return undefined;
171
+ }
172
+ }
173
+ exports.SectionMarkerSet = SectionMarkerSet;
174
+ //# sourceMappingURL=SectionMarkers.js.map
@@ -0,0 +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,CAAC,QAAQ,CAAC,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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,oBAAoB,CAAC,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IAC9F,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: Promise<MarkerImage>) {\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 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 SectionMarkerCluster.makeFrom(cluster.markers[0], 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"]}
package/lib/Tools.d.ts ADDED
@@ -0,0 +1,7 @@
1
+ /** @packageDocumentation
2
+ * @module HyperModeling
3
+ */
4
+ import { I18N, I18NNamespace } from "@itwin/core-i18n";
5
+ /** @internal */
6
+ export declare function registerTools(namespace: I18NNamespace | undefined, i18n: I18N): void;
7
+ //# sourceMappingURL=Tools.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tools.d.ts","sourceRoot":"","sources":["../src/Tools.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,EACL,IAAI,EACJ,aAAa,EACd,MAAM,kBAAkB,CAAC;AA2L1B,gBAAgB;AAChB,wBAAgB,aAAa,CAAC,SAAS,EAAE,aAAa,GAAG,SAAS,EAAE,IAAI,EAAE,IAAI,GAAG,IAAI,CAMpF"}
package/lib/Tools.js ADDED
@@ -0,0 +1,171 @@
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.registerTools = void 0;
11
+ const core_common_1 = require("@itwin/core-common");
12
+ const core_frontend_1 = require("@itwin/core-frontend");
13
+ const HyperModeling_1 = require("./HyperModeling");
14
+ const HyperModelingDecorator_1 = require("./HyperModelingDecorator");
15
+ /** Parses a string case-insensitively returning true for "ON", false for "OFF", undefined for "TOGGLE" or undefined, and the input string for anything else. */
16
+ function parseToggle(arg) {
17
+ if (undefined === arg)
18
+ return undefined;
19
+ switch (arg.toLowerCase()) {
20
+ case "on": return true;
21
+ case "off": return false;
22
+ case "toggle": return undefined;
23
+ default: return arg;
24
+ }
25
+ }
26
+ class HyperModelingTool extends core_frontend_1.Tool {
27
+ static get minArgs() { return 0; }
28
+ static get maxArgs() { return 1; }
29
+ async run(enable, vp) {
30
+ vp = vp !== null && vp !== void 0 ? vp : core_frontend_1.IModelApp.viewManager.selectedView;
31
+ if (vp)
32
+ await HyperModeling_1.HyperModeling.startOrStop(vp, enable);
33
+ return true;
34
+ }
35
+ async parseAndRun(...args) {
36
+ const enable = parseToggle(args[0]);
37
+ return typeof enable !== "string" && this.run(enable);
38
+ }
39
+ }
40
+ HyperModelingTool.toolId = "HyperModeling";
41
+ /** Configures how section graphics are displayed. These are global settings. If no arguments are supplied, the defaults are restored.
42
+ * Otherwise, each argument is of the form "name=value" where value is 0 (disable) or 1 (enable). Only the first letter of each argument matters.
43
+ * - drawings: Whether to display the section drawing graphics. Default: 1.
44
+ * - sheets: Whether to display the sheet annotation graphics. Default: 1.
45
+ * - clip: Whether to apply clip volumes to the 2d graphics. Default: 1.
46
+ * - boundaries: Whether to display clip volumes as boundary shapes for debugging purposes. Default: 0.
47
+ */
48
+ class SectionGraphicsConfigTool extends core_frontend_1.Tool {
49
+ static get minArgs() { return 0; }
50
+ static get maxArgs() { return 4; }
51
+ async run(config) {
52
+ if (!config) {
53
+ config = {
54
+ ignoreClip: false,
55
+ debugClipVolumes: false,
56
+ hideSectionGraphics: false,
57
+ hideSheetAnnotations: false,
58
+ };
59
+ }
60
+ HyperModeling_1.HyperModeling.updateConfiguration({ graphics: config });
61
+ return true;
62
+ }
63
+ async parseAndRun(...args) {
64
+ if (0 === args.length)
65
+ return this.run(); // restore defaults...
66
+ const config = {};
67
+ for (const arg of args) {
68
+ const parts = arg.toLowerCase().split("=");
69
+ if (2 !== parts.length)
70
+ continue;
71
+ const value = Number.parseInt(parts[1], 10);
72
+ if (Number.isNaN(value) || (0 !== value && 1 !== value))
73
+ continue;
74
+ const enable = 1 === value;
75
+ switch (parts[0][0]) {
76
+ case "d":
77
+ config.hideSectionGraphics = !enable;
78
+ break;
79
+ case "s":
80
+ config.hideSheetAnnotations = !enable;
81
+ break;
82
+ case "c":
83
+ config.ignoreClip = !enable;
84
+ break;
85
+ case "b":
86
+ config.debugClipVolumes = enable;
87
+ break;
88
+ }
89
+ }
90
+ return this.run(config);
91
+ }
92
+ }
93
+ SectionGraphicsConfigTool.toolId = "HyperModeling.Graphics.Config";
94
+ class SectionMarkerConfigTool extends core_frontend_1.Tool {
95
+ static get minArgs() { return 0; }
96
+ static get maxArgs() { return 3; }
97
+ async run(config) {
98
+ config = config !== null && config !== void 0 ? config : { ignoreModelSelector: false, ignoreCategorySelector: false, hiddenSectionTypes: [] };
99
+ this.update(config);
100
+ return true;
101
+ }
102
+ async parseAndRun(...args) {
103
+ if (0 === args.length)
104
+ return this.run(); // restore defaults...
105
+ const config = {};
106
+ for (const arg of args) {
107
+ const parts = arg.toLowerCase().split("=");
108
+ if (2 !== parts.length)
109
+ continue;
110
+ const setting = parts[0][0];
111
+ switch (setting) {
112
+ case "h": {
113
+ config.hiddenSectionTypes = [];
114
+ for (const c of parts[1]) {
115
+ switch (c) {
116
+ case "s":
117
+ config.hiddenSectionTypes.push(core_common_1.SectionType.Section);
118
+ break;
119
+ case "d":
120
+ config.hiddenSectionTypes.push(core_common_1.SectionType.Detail);
121
+ break;
122
+ case "e":
123
+ config.hiddenSectionTypes.push(core_common_1.SectionType.Elevation);
124
+ break;
125
+ case "p":
126
+ config.hiddenSectionTypes.push(core_common_1.SectionType.Plan);
127
+ break;
128
+ }
129
+ }
130
+ break;
131
+ }
132
+ default: {
133
+ const intVal = Number.parseInt(parts[1], 10);
134
+ if (!Number.isNaN(intVal) && (0 === intVal || 1 === intVal)) {
135
+ if ("c" === setting)
136
+ config.ignoreCategorySelector = 0 === intVal;
137
+ else if ("m" === setting)
138
+ config.ignoreModelSelector = 0 === intVal;
139
+ }
140
+ break;
141
+ }
142
+ }
143
+ }
144
+ return this.run(config);
145
+ }
146
+ }
147
+ class SectionMarkerDefaultConfigTool extends SectionMarkerConfigTool {
148
+ update(config) {
149
+ HyperModeling_1.HyperModeling.updateConfiguration({ markers: config });
150
+ }
151
+ }
152
+ SectionMarkerDefaultConfigTool.toolId = "HyperModeling.Marker.Default.Config";
153
+ class SectionMarkerDecoratorConfigTool extends SectionMarkerConfigTool {
154
+ update(config) {
155
+ const vp = core_frontend_1.IModelApp.viewManager.selectedView;
156
+ const decorator = vp ? HyperModelingDecorator_1.HyperModelingDecorator.getForViewport(vp) : undefined;
157
+ if (decorator)
158
+ decorator.updateConfiguration(config);
159
+ }
160
+ }
161
+ SectionMarkerDecoratorConfigTool.toolId = "HyperModeling.Marker.Config";
162
+ /** @internal */
163
+ function registerTools(namespace, i18n) {
164
+ const register = (tool) => core_frontend_1.IModelApp.tools.register(tool, namespace, i18n);
165
+ register(HyperModelingTool);
166
+ register(SectionGraphicsConfigTool);
167
+ register(SectionMarkerDecoratorConfigTool);
168
+ register(SectionMarkerDefaultConfigTool);
169
+ }
170
+ exports.registerTools = registerTools;
171
+ //# sourceMappingURL=Tools.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Tools.js","sourceRoot":"","sources":["../src/Tools.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAAiD;AAKjD,wDAI8B;AAC9B,mDAAgD;AAEhD,qEAAkE;AAElE,gKAAgK;AAChK,SAAS,WAAW,CAAC,GAAuB;IAC1C,IAAI,SAAS,KAAK,GAAG;QACnB,OAAO,SAAS,CAAC;IAEnB,QAAQ,GAAG,CAAC,WAAW,EAAE,EAAE;QACzB,KAAK,IAAI,CAAC,C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AAC,SAAS,CAAC;QAC7E,IAAI,SAAS;YACX,SAAS,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAC1C,CAAC;;AAPsB,uCAAM,GAAG,6BAA6B,CAAC;AAUhE,gBAAgB;AAChB,SAAgB,aAAa,CAAC,SAAoC,EAAE,IAAU;IAC5E,MAAM,QAAQ,GAAG,CAAC,IAAiB,EAAE,EAAE,CAAC,yBAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;IACxF,QAAQ,CAAC,iBAAiB,CAAC,CAAC;IAC5B,QAAQ,CAAC,yBAAyB,CAAC,CAAC;IACpC,QAAQ,CAAC,gCAAgC,CAAC,CAAC;IAC3C,QAAQ,CAAC,8BAA8B,CAAC,CAAC;AAC3C,CAAC;AAND,sCAMC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module HyperModeling\r\n */\r\n\r\nimport { SectionType } from \"@itwin/core-common\";\r\nimport {\r\n I18N,\r\n I18NNamespace,\r\n} from \"@itwin/core-i18n\";\r\nimport {\r\n IModelApp,\r\n ScreenViewport,\r\n Tool,\r\n} from \"@itwin/core-frontend\";\r\nimport { HyperModeling } from \"./HyperModeling\";\r\nimport { SectionGraphicsConfig, SectionMarkerConfig } from \"./HyperModelingConfig\";\r\nimport { HyperModelingDecorator } from \"./HyperModelingDecorator\";\r\n\r\n/** Parses a string case-insensitively returning true for \"ON\", false for \"OFF\", undefined for \"TOGGLE\" or undefined, and the input string for anything else. */\r\nfunction parseToggle(arg: string | undefined): string | boolean | undefined {\r\n if (undefined === arg)\r\n return undefined;\r\n\r\n switch (arg.toLowerCase()) {\r\n case \"on\": return true;\r\n case \"off\": return false;\r\n case \"toggle\": return undefined;\r\n default: return arg;\r\n }\r\n}\r\n\r\nclass HyperModelingTool extends Tool {\r\n public static override toolId = \"HyperModeling\";\r\n public static override get minArgs() { return 0; }\r\n public static override get maxArgs() { return 1; }\r\n\r\n public override async run(enable?: boolean, vp?: ScreenViewport): Promise<boolean> {\r\n vp = vp ?? IModelApp.viewManager.selectedView;\r\n if (vp)\r\n await HyperModeling.startOrStop(vp, enable);\r\n\r\n return true;\r\n }\r\n\r\n public override async parseAndRun(...args: string[]): Promise<boolean> {\r\n const enable = parseToggle(args[0]);\r\n return typeof enable !== \"string\" && this.run(enable);\r\n }\r\n}\r\n\r\ntype Writeable<T> = { -readonly [P in keyof T]: T[P] };\r\n\r\n/** Configures how section graphics are displayed. These are global settings. If no arguments are supplied, the defaults are restored.\r\n * Otherwise, each argument is of the form \"name=value\" where value is 0 (disable) or 1 (enable). Only the first letter of each argument matters.\r\n * - drawings: Whether to display the section drawing graphics. Default: 1.\r\n * - sheets: Whether to display the sheet annotation graphics. Default: 1.\r\n * - clip: Whether to apply clip volumes to the 2d graphics. Default: 1.\r\n * - boundaries: Whether to display clip volumes as boundary shapes for debugging purposes. Default: 0.\r\n */\r\nclass SectionGraphicsConfigTool extends Tool {\r\n public static override toolId = \"HyperModeling.Graphics.Config\";\r\n public static override get minArgs() { return 0; }\r\n public static override get maxArgs() { return 4; }\r\n\r\n public override async run(config?: SectionGraphicsConfig): Promise<boolean> {\r\n if (!config) {\r\n config = {\r\n ignoreClip: false,\r\n debugClipVolumes: false,\r\n hideSectionGraphics: false,\r\n hideSheetAnnotations: false,\r\n };\r\n }\r\n\r\n HyperModeling.updateConfiguration({ graphics: config });\r\n return true;\r\n }\r\n\r\n public override async parseAndRun(...args: string[]): Promise<boolean> {\r\n if (0 === args.length)\r\n return this.run(); // restore defaults...\r\n\r\n const config: Writeable<SectionGraphicsConfig> = {};\r\n for (const arg of args) {\r\n const parts = arg.toLowerCase().split(\"=\");\r\n if (2 !== parts.length)\r\n continue;\r\n\r\n const value = Number.parseInt(parts[1], 10);\r\n if (Number.isNaN(value) || (0 !== value && 1 !== value))\r\n continue;\r\n\r\n const enable = 1 === value;\r\n switch (parts[0][0]) {\r\n case \"d\":\r\n config.hideSectionGraphics = !enable;\r\n break;\r\n case \"s\":\r\n config.hideSheetAnnotations = !enable;\r\n break;\r\n case \"c\":\r\n config.ignoreClip = !enable;\r\n break;\r\n case \"b\":\r\n config.debugClipVolumes = enable;\r\n break;\r\n }\r\n }\r\n\r\n return this.run(config);\r\n }\r\n}\r\n\r\nabstract class SectionMarkerConfigTool extends Tool {\r\n public static override get minArgs() { return 0; }\r\n public static override get maxArgs() { return 3; }\r\n\r\n protected abstract update(config: SectionMarkerConfig): void;\r\n\r\n public override async run(config?: SectionMarkerConfig): Promise<boolean> {\r\n config = config ?? { ignoreModelSelector: false, ignoreCategorySelector: false, hiddenSectionTypes: [] };\r\n this.update(config);\r\n return true;\r\n }\r\n\r\n public override async parseAndRun(...args: string[]): Promise<boolean> {\r\n if (0 === args.length)\r\n return this.run(); // restore defaults...\r\n\r\n const config: Writeable<SectionMarkerConfig> = {};\r\n for (const arg of args) {\r\n const parts = arg.toLowerCase().split(\"=\");\r\n if (2 !== parts.length)\r\n continue;\r\n\r\n const setting = parts[0][0];\r\n switch (setting) {\r\n case \"h\": {\r\n config.hiddenSectionTypes = [];\r\n for (const c of parts[1]) {\r\n switch (c) {\r\n case \"s\":\r\n config.hiddenSectionTypes.push(SectionType.Section);\r\n break;\r\n case \"d\":\r\n config.hiddenSectionTypes.push(SectionType.Detail);\r\n break;\r\n case \"e\":\r\n config.hiddenSectionTypes.push(SectionType.Elevation);\r\n break;\r\n case \"p\":\r\n config.hiddenSectionTypes.push(SectionType.Plan);\r\n break;\r\n }\r\n }\r\n\r\n break;\r\n }\r\n default: {\r\n const intVal = Number.parseInt(parts[1], 10);\r\n if (!Number.isNaN(intVal) && (0 === intVal || 1 === intVal)) {\r\n if (\"c\" === setting)\r\n config.ignoreCategorySelector = 0 === intVal;\r\n else if (\"m\" === setting)\r\n config.ignoreModelSelector = 0 === intVal;\r\n }\r\n\r\n break;\r\n }\r\n }\r\n }\r\n\r\n return this.run(config);\r\n }\r\n}\r\n\r\nclass SectionMarkerDefaultConfigTool extends SectionMarkerConfigTool {\r\n public static override toolId = \"HyperModeling.Marker.Default.Config\";\r\n\r\n protected update(config: SectionMarkerConfig): void {\r\n HyperModeling.updateConfiguration({ markers: config });\r\n }\r\n}\r\n\r\nclass SectionMarkerDecoratorConfigTool extends SectionMarkerConfigTool {\r\n public static override toolId = \"HyperModeling.Marker.Config\";\r\n\r\n protected update(config: SectionMarkerConfig): void {\r\n const vp = IModelApp.viewManager.selectedView;\r\n const decorator = vp ? HyperModelingDecorator.getForViewport(vp) : undefined;\r\n if (decorator)\r\n decorator.updateConfiguration(config);\r\n }\r\n}\r\n\r\n/** @internal */\r\nexport function registerTools(namespace: I18NNamespace | undefined, i18n: I18N): void {\r\n const register = (tool: typeof Tool) => IModelApp.tools.register(tool, namespace, i18n);\r\n register(HyperModelingTool);\r\n register(SectionGraphicsConfigTool);\r\n register(SectionMarkerDecoratorConfigTool);\r\n register(SectionMarkerDefaultConfigTool);\r\n}\r\n"]}